mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
changed std::wstring for std::string+utf8 in chat, and messages
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-initdev@6795 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
420fadb5c3
commit
695e417fd5
@ -87,7 +87,8 @@ void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, cons
|
|||||||
item->saveToDisc = false;
|
item->saveToDisc = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
librs::util::ConvertUtf16ToUtf8(chatItem->message, item->message);
|
item->message = chatItem->message ;
|
||||||
|
//librs::util::ConvertUtf16ToUtf8(chatItem->message, item->message);
|
||||||
|
|
||||||
std::map<std::string, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(item->chatPeerId);
|
std::map<std::string, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(item->chatPeerId);
|
||||||
if (mit != mMessages.end()) {
|
if (mit != mMessages.end()) {
|
||||||
|
@ -98,11 +98,11 @@ class MessageInfo
|
|||||||
std::list<std::string> msgcc;
|
std::list<std::string> msgcc;
|
||||||
std::list<std::string> msgbcc;
|
std::list<std::string> msgbcc;
|
||||||
|
|
||||||
std::wstring title;
|
std::string title;
|
||||||
std::wstring msg;
|
std::string msg;
|
||||||
|
|
||||||
std::wstring attach_title;
|
std::string attach_title;
|
||||||
std::wstring attach_comment;
|
std::string attach_comment;
|
||||||
std::list<FileInfo> files;
|
std::list<FileInfo> files;
|
||||||
std::map<std::string,std::string> encryption_keys ; // for concerned ids only the public pgp key id to encrypt the message with.
|
std::map<std::string,std::string> encryption_keys ; // for concerned ids only the public pgp key id to encrypt the message with.
|
||||||
int size; /* total of files */
|
int size; /* total of files */
|
||||||
@ -121,7 +121,7 @@ class MsgInfoSummary
|
|||||||
|
|
||||||
uint32_t msgflags;
|
uint32_t msgflags;
|
||||||
|
|
||||||
std::wstring title;
|
std::string title;
|
||||||
int count; /* file count */
|
int count; /* file count */
|
||||||
time_t ts;
|
time_t ts;
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ class ChatInfo
|
|||||||
unsigned int chatflags;
|
unsigned int chatflags;
|
||||||
uint32_t sendTime;
|
uint32_t sendTime;
|
||||||
uint32_t recvTime;
|
uint32_t recvTime;
|
||||||
std::wstring msg;
|
std::string msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChatLobbyInvite
|
class ChatLobbyInvite
|
||||||
@ -254,7 +254,7 @@ virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, un
|
|||||||
virtual bool decryptMessage(const std::string& mId) = 0 ;
|
virtual bool decryptMessage(const std::string& mId) = 0 ;
|
||||||
|
|
||||||
virtual bool MessageSend(MessageInfo &info) = 0;
|
virtual bool MessageSend(MessageInfo &info) = 0;
|
||||||
virtual bool SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag) = 0;
|
virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag) = 0;
|
||||||
virtual bool MessageToDraft(MessageInfo &info, const std::string &msgParentId) = 0;
|
virtual bool MessageToDraft(MessageInfo &info, const std::string &msgParentId) = 0;
|
||||||
virtual bool MessageToTrash(const std::string &mid, bool bTrash) = 0;
|
virtual bool MessageToTrash(const std::string &mid, bool bTrash) = 0;
|
||||||
virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId) = 0;
|
virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId) = 0;
|
||||||
@ -288,8 +288,8 @@ virtual bool getDistantMessageHash(const std::string& pgp_id, std::string& hash)
|
|||||||
/****************************************/
|
/****************************************/
|
||||||
/* Chat */
|
/* Chat */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
virtual bool sendPublicChat(const std::wstring& msg) = 0;
|
virtual bool sendPublicChat(const std::string& msg) = 0;
|
||||||
virtual bool sendPrivateChat(const std::string& id, const std::wstring& msg) = 0;
|
virtual bool sendPrivateChat(const std::string& id, const std::string& msg) = 0;
|
||||||
virtual int getPublicChatQueueCount() = 0;
|
virtual int getPublicChatQueueCount() = 0;
|
||||||
virtual bool getPublicChatQueue(std::list<ChatInfo> &chats) = 0;
|
virtual bool getPublicChatQueue(std::list<ChatInfo> &chats) = 0;
|
||||||
virtual int getPrivateChatQueueCount(bool incoming) = 0;
|
virtual int getPrivateChatQueueCount(bool incoming) = 0;
|
||||||
|
@ -121,7 +121,7 @@ bool p3Msgs::getDistantMessageHash(const std::string& pgp_id,std::string& hash)
|
|||||||
return mMsgSrv->getDistantMessageHash(pgp_id,hash);
|
return mMsgSrv->getDistantMessageHash(pgp_id,hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Msgs::SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag)
|
bool p3Msgs::SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag)
|
||||||
{
|
{
|
||||||
return mMsgSrv->SystemMessage(title, message, systemFlag);
|
return mMsgSrv->SystemMessage(title, message, systemFlag);
|
||||||
}
|
}
|
||||||
@ -207,13 +207,13 @@ bool p3Msgs::resetMessageStandardTagTypes(MsgTagType& tags)
|
|||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/****************************************/
|
/****************************************/
|
||||||
bool p3Msgs::sendPublicChat(const std::wstring& msg)
|
bool p3Msgs::sendPublicChat(const std::string& msg)
|
||||||
{
|
{
|
||||||
/* send a message to all for now */
|
/* send a message to all for now */
|
||||||
return mChatSrv -> sendPublicChat(msg);
|
return mChatSrv -> sendPublicChat(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Msgs::sendPrivateChat(const std::string& id, const std::wstring& msg)
|
bool p3Msgs::sendPrivateChat(const std::string& id, const std::string& msg)
|
||||||
{
|
{
|
||||||
/* send a message to peer */
|
/* send a message to peer */
|
||||||
return mChatSrv -> sendPrivateChat(id, msg);
|
return mChatSrv -> sendPrivateChat(id, msg);
|
||||||
|
@ -59,7 +59,7 @@ class p3Msgs: public RsMsgs
|
|||||||
|
|
||||||
virtual bool MessageSend(MessageInfo &info);
|
virtual bool MessageSend(MessageInfo &info);
|
||||||
virtual bool decryptMessage(const std::string& mid);
|
virtual bool decryptMessage(const std::string& mid);
|
||||||
virtual bool SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag);
|
virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag);
|
||||||
virtual bool MessageToDraft(MessageInfo &info, const std::string &msgParentId);
|
virtual bool MessageToDraft(MessageInfo &info, const std::string &msgParentId);
|
||||||
virtual bool MessageToTrash(const std::string &mid, bool bTrash);
|
virtual bool MessageToTrash(const std::string &mid, bool bTrash);
|
||||||
virtual bool MessageDelete(const std::string &mid);
|
virtual bool MessageDelete(const std::string &mid);
|
||||||
@ -120,13 +120,13 @@ class p3Msgs: public RsMsgs
|
|||||||
/*!
|
/*!
|
||||||
* public chat sent to all peers
|
* public chat sent to all peers
|
||||||
*/
|
*/
|
||||||
virtual bool sendPublicChat(const std::wstring& msg);
|
virtual bool sendPublicChat(const std::string& msg);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* chat is sent to specifc peer
|
* chat is sent to specifc peer
|
||||||
* @param id peer to send chat msg to
|
* @param id peer to send chat msg to
|
||||||
*/
|
*/
|
||||||
virtual bool sendPrivateChat(const std::string& id, const std::wstring& msg);
|
virtual bool sendPrivateChat(const std::string& id, const std::string& msg);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* returns the count of messages in public or private queue
|
* returns the count of messages in public or private queue
|
||||||
|
@ -147,7 +147,7 @@ bool RsHistorySerialiser::serialiseHistoryMsgItem(RsHistoryMsgItem* item, void*
|
|||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->peerName);
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->peerName);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->sendTime);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->sendTime);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->recvTime);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->recvTime);
|
||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_WSTR_MSG, item->message);
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_MSG, item->message);
|
||||||
|
|
||||||
if (offset != tlvsize)
|
if (offset != tlvsize)
|
||||||
{
|
{
|
||||||
@ -202,7 +202,7 @@ RsHistoryMsgItem *RsHistorySerialiser::deserialiseHistoryMsgItem(void *data, uin
|
|||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->peerName);
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->peerName);
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->sendTime));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->sendTime));
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->recvTime));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->recvTime));
|
||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_WSTR_MSG, item->message);
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_MSG, item->message);
|
||||||
|
|
||||||
if (offset != rssize)
|
if (offset != rssize)
|
||||||
{
|
{
|
||||||
|
@ -303,7 +303,7 @@ uint32_t RsChatMsgItem::serial_size()
|
|||||||
uint32_t s = 8; /* header */
|
uint32_t s = 8; /* header */
|
||||||
s += 4; /* chatFlags */
|
s += 4; /* chatFlags */
|
||||||
s += 4; /* sendTime */
|
s += 4; /* sendTime */
|
||||||
s += GetTlvWideStringSize(message);
|
s += GetTlvStringSize(message);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -418,7 +418,7 @@ uint32_t RsPrivateChatMsgConfigItem::serial_size()
|
|||||||
s += 4; /* chatFlags */
|
s += 4; /* chatFlags */
|
||||||
s += 4; /* configFlags */
|
s += 4; /* configFlags */
|
||||||
s += 4; /* sendTime */
|
s += 4; /* sendTime */
|
||||||
s += GetTlvWideStringSize(message);
|
s += GetTlvStringSize(message);
|
||||||
s += 4; /* recvTime */
|
s += 4; /* recvTime */
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
@ -498,7 +498,7 @@ bool RsChatMsgItem::serialise(void *data, uint32_t& pktsize)
|
|||||||
/* add mandatory parts first */
|
/* add mandatory parts first */
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, chatFlags);
|
ok &= setRawUInt32(data, tlvsize, &offset, chatFlags);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, sendTime);
|
ok &= setRawUInt32(data, tlvsize, &offset, sendTime);
|
||||||
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_MSG, message);
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_MSG, message);
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "Serialized the following message:" << std::endl;
|
std::cerr << "Serialized the following message:" << std::endl;
|
||||||
std::cerr << "========== BEGIN MESSAGE =========" << std::endl;
|
std::cerr << "========== BEGIN MESSAGE =========" << std::endl;
|
||||||
@ -806,7 +806,7 @@ bool RsPrivateChatMsgConfigItem::serialise(void *data, uint32_t& pktsize)
|
|||||||
ok &= setRawUInt32(data, tlvsize, &offset, chatFlags);
|
ok &= setRawUInt32(data, tlvsize, &offset, chatFlags);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, configFlags);
|
ok &= setRawUInt32(data, tlvsize, &offset, configFlags);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, sendTime);
|
ok &= setRawUInt32(data, tlvsize, &offset, sendTime);
|
||||||
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_MSG, message);
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_MSG, message);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, recvTime);
|
ok &= setRawUInt32(data, tlvsize, &offset, recvTime);
|
||||||
|
|
||||||
if (offset != tlvsize)
|
if (offset != tlvsize)
|
||||||
@ -989,7 +989,7 @@ RsChatMsgItem::RsChatMsgItem(void *data,uint32_t /*size*/,uint8_t subtype)
|
|||||||
/* get mandatory parts first */
|
/* get mandatory parts first */
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &chatFlags);
|
ok &= getRawUInt32(data, rssize, &offset, &chatFlags);
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &sendTime);
|
ok &= getRawUInt32(data, rssize, &offset, &sendTime);
|
||||||
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_MSG, message);
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_MSG, message);
|
||||||
|
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "Building new chat msg item." << std::endl ;
|
std::cerr << "Building new chat msg item." << std::endl ;
|
||||||
@ -1227,7 +1227,7 @@ RsPrivateChatMsgConfigItem::RsPrivateChatMsgConfigItem(void *data,uint32_t /*siz
|
|||||||
ok &= getRawUInt32(data, rssize, &offset, &chatFlags);
|
ok &= getRawUInt32(data, rssize, &offset, &chatFlags);
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &configFlags);
|
ok &= getRawUInt32(data, rssize, &offset, &configFlags);
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &sendTime);
|
ok &= getRawUInt32(data, rssize, &offset, &sendTime);
|
||||||
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_MSG, message);
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_MSG, message);
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &recvTime);
|
ok &= getRawUInt32(data, rssize, &offset, &recvTime);
|
||||||
|
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
@ -1500,8 +1500,8 @@ uint32_t RsMsgItem::serial_size(bool m_bConfiguration)
|
|||||||
s += 4; /* sendTime */
|
s += 4; /* sendTime */
|
||||||
s += 4; /* recvTime */
|
s += 4; /* recvTime */
|
||||||
|
|
||||||
s += GetTlvWideStringSize(subject);
|
s += GetTlvStringSize(subject);
|
||||||
s += GetTlvWideStringSize(message);
|
s += GetTlvStringSize(message);
|
||||||
|
|
||||||
s += msgto.TlvSize();
|
s += msgto.TlvSize();
|
||||||
s += msgcc.TlvSize();
|
s += msgcc.TlvSize();
|
||||||
@ -1544,8 +1544,8 @@ bool RsMsgItem::serialise(void *data, uint32_t& pktsize,bool config)
|
|||||||
ok &= setRawUInt32(data, tlvsize, &offset, sendTime);
|
ok &= setRawUInt32(data, tlvsize, &offset, sendTime);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, recvTime);
|
ok &= setRawUInt32(data, tlvsize, &offset, recvTime);
|
||||||
|
|
||||||
ok &= SetTlvWideString(data,tlvsize,&offset,TLV_TYPE_WSTR_SUBJECT,subject);
|
ok &= SetTlvString(data,tlvsize,&offset,TLV_TYPE_STR_SUBJECT,subject);
|
||||||
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_MSG, message);
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_MSG, message);
|
||||||
|
|
||||||
ok &= msgto.SetTlv(data, tlvsize, &offset);
|
ok &= msgto.SetTlv(data, tlvsize, &offset);
|
||||||
ok &= msgcc.SetTlv(data, tlvsize, &offset);
|
ok &= msgcc.SetTlv(data, tlvsize, &offset);
|
||||||
@ -1601,8 +1601,8 @@ RsMsgItem *RsMsgSerialiser::deserialiseMsgItem(void *data, uint32_t *pktsize)
|
|||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->sendTime));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->sendTime));
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->recvTime));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->recvTime));
|
||||||
|
|
||||||
ok &= GetTlvWideString(data,rssize,&offset,TLV_TYPE_WSTR_SUBJECT,item->subject);
|
ok &= GetTlvString(data,rssize,&offset,TLV_TYPE_STR_SUBJECT,item->subject);
|
||||||
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_MSG, item->message);
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_MSG, item->message);
|
||||||
ok &= item->msgto.GetTlv(data, rssize, &offset);
|
ok &= item->msgto.GetTlv(data, rssize, &offset);
|
||||||
ok &= item->msgcc.GetTlv(data, rssize, &offset);
|
ok &= item->msgcc.GetTlv(data, rssize, &offset);
|
||||||
ok &= item->msgbcc.GetTlv(data, rssize, &offset);
|
ok &= item->msgbcc.GetTlv(data, rssize, &offset);
|
||||||
|
@ -53,7 +53,7 @@ const uint32_t RS_CHATMSG_CONFIGFLAG_INCOMING = 0x0001;
|
|||||||
const uint8_t RS_PKT_SUBTYPE_CHAT_AVATAR = 0x03 ;
|
const uint8_t RS_PKT_SUBTYPE_CHAT_AVATAR = 0x03 ;
|
||||||
const uint8_t RS_PKT_SUBTYPE_CHAT_STATUS = 0x04 ;
|
const uint8_t RS_PKT_SUBTYPE_CHAT_STATUS = 0x04 ;
|
||||||
const uint8_t RS_PKT_SUBTYPE_PRIVATECHATMSG_CONFIG = 0x05 ;
|
const uint8_t RS_PKT_SUBTYPE_PRIVATECHATMSG_CONFIG = 0x05 ;
|
||||||
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_MSG_DEPRECATED= 0x06 ; // don't use ! Deprecated
|
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_MSG_DEPRECATED = 0x06 ; // don't use ! Deprecated
|
||||||
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE_DEPREC = 0x07 ; // don't use ! Deprecated
|
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE_DEPREC = 0x07 ; // don't use ! Deprecated
|
||||||
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_ACCEPT = 0x08 ;
|
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_ACCEPT = 0x08 ;
|
||||||
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_CHALLENGE = 0x09 ;
|
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_CHALLENGE = 0x09 ;
|
||||||
@ -117,7 +117,7 @@ class RsChatMsgItem: public RsChatItem
|
|||||||
|
|
||||||
uint32_t chatFlags;
|
uint32_t chatFlags;
|
||||||
uint32_t sendTime;
|
uint32_t sendTime;
|
||||||
std::wstring message;
|
std::string message;
|
||||||
/* not serialised */
|
/* not serialised */
|
||||||
uint32_t recvTime;
|
uint32_t recvTime;
|
||||||
};
|
};
|
||||||
@ -316,7 +316,7 @@ class RsPrivateChatMsgConfigItem: public RsChatItem
|
|||||||
uint32_t chatFlags;
|
uint32_t chatFlags;
|
||||||
uint32_t configFlags;
|
uint32_t configFlags;
|
||||||
uint32_t sendTime;
|
uint32_t sendTime;
|
||||||
std::wstring message;
|
std::string message;
|
||||||
uint32_t recvTime;
|
uint32_t recvTime;
|
||||||
};
|
};
|
||||||
class RsPrivateChatDistantInviteConfigItem: public RsChatItem
|
class RsPrivateChatDistantInviteConfigItem: public RsChatItem
|
||||||
@ -475,8 +475,8 @@ class RsMsgItem: public RsMessageItem
|
|||||||
uint32_t sendTime;
|
uint32_t sendTime;
|
||||||
uint32_t recvTime;
|
uint32_t recvTime;
|
||||||
|
|
||||||
std::wstring subject;
|
std::string subject;
|
||||||
std::wstring message;
|
std::string message;
|
||||||
|
|
||||||
RsTlvPeerIdSet msgto;
|
RsTlvPeerIdSet msgto;
|
||||||
RsTlvPeerIdSet msgcc;
|
RsTlvPeerIdSet msgcc;
|
||||||
|
@ -417,9 +417,9 @@ uint32_t RsTlvFileSet::TlvSize()
|
|||||||
/* now add comment and title length of this tlv object */
|
/* now add comment and title length of this tlv object */
|
||||||
|
|
||||||
if (title.length() > 0)
|
if (title.length() > 0)
|
||||||
s += GetTlvWideStringSize(title);
|
s += GetTlvStringSize(title);
|
||||||
if (comment.length() > 0)
|
if (comment.length() > 0)
|
||||||
s += GetTlvWideStringSize(comment);
|
s += GetTlvStringSize(comment);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -454,9 +454,9 @@ bool RsTlvFileSet::SetTlv(void *data, uint32_t size, uint32_t *offset) /* se
|
|||||||
|
|
||||||
/* now optional ones */
|
/* now optional ones */
|
||||||
if (title.length() > 0)
|
if (title.length() > 0)
|
||||||
ok &= SetTlvWideString(data, tlvend, offset, TLV_TYPE_WSTR_TITLE, title);
|
ok &= SetTlvString(data, tlvend, offset, TLV_TYPE_STR_TITLE, title);
|
||||||
if (comment.length() > 0)
|
if (comment.length() > 0)
|
||||||
ok &= SetTlvWideString(data, tlvend, offset, TLV_TYPE_WSTR_COMMENT, comment);
|
ok &= SetTlvString(data, tlvend, offset, TLV_TYPE_STR_COMMENT, comment);
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
|
|
||||||
@ -500,15 +500,15 @@ bool RsTlvFileSet::GetTlv(void *data, uint32_t size, uint32_t *offset)
|
|||||||
items.push_back(newitem);
|
items.push_back(newitem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tlvsubtype == TLV_TYPE_WSTR_TITLE)
|
else if (tlvsubtype == TLV_TYPE_STR_TITLE)
|
||||||
{
|
{
|
||||||
ok &= GetTlvWideString(data, tlvend, offset,
|
ok &= GetTlvString(data, tlvend, offset,
|
||||||
TLV_TYPE_WSTR_TITLE, title);
|
TLV_TYPE_STR_TITLE, title);
|
||||||
}
|
}
|
||||||
else if (tlvsubtype == TLV_TYPE_WSTR_COMMENT)
|
else if (tlvsubtype == TLV_TYPE_STR_COMMENT)
|
||||||
{
|
{
|
||||||
ok &= GetTlvWideString(data, tlvend, offset,
|
ok &= GetTlvString(data, tlvend, offset,
|
||||||
TLV_TYPE_WSTR_COMMENT, comment);
|
TLV_TYPE_STR_COMMENT, comment);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -187,8 +187,8 @@ virtual bool GetTlv(void *data, uint32_t size, uint32_t *offset); /* deseria
|
|||||||
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
||||||
|
|
||||||
std::list<RsTlvFileItem> items; /// Mandatory
|
std::list<RsTlvFileItem> items; /// Mandatory
|
||||||
std::wstring title; /// Optional: title of file set
|
std::string title; /// Optional: title of file set
|
||||||
std::wstring comment; /// Optional: comments for file
|
std::string comment; /// Optional: comments for file
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ int p3ChatService::status()
|
|||||||
|
|
||||||
/***************** Chat Stuff **********************/
|
/***************** Chat Stuff **********************/
|
||||||
|
|
||||||
int p3ChatService::sendPublicChat(const std::wstring &msg)
|
int p3ChatService::sendPublicChat(const std::string &msg)
|
||||||
{
|
{
|
||||||
/* go through all the peers */
|
/* go through all the peers */
|
||||||
|
|
||||||
@ -460,7 +460,7 @@ bool p3ChatService::isOnline(const std::string& id)
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::sendPrivateChat(const std::string &id, const std::wstring &msg)
|
bool p3ChatService::sendPrivateChat(const std::string &id, const std::string &msg)
|
||||||
{
|
{
|
||||||
// look into ID. Is it a peer, or a chat lobby?
|
// look into ID. Is it a peer, or a chat lobby?
|
||||||
|
|
||||||
@ -643,7 +643,7 @@ bool p3ChatService::locked_checkAndRebuildPartialMessage(RsChatLobbyMsgItem *ci)
|
|||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << " Message is complete ! Re-forming it and returning true." << std::endl;
|
std::cerr << " Message is complete ! Re-forming it and returning true." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
std::wstring msg ;
|
std::string msg ;
|
||||||
uint32_t flags = 0 ;
|
uint32_t flags = 0 ;
|
||||||
|
|
||||||
for(uint32_t i=0;i<it->second.size();++i)
|
for(uint32_t i=0;i<it->second.size();++i)
|
||||||
@ -998,20 +998,18 @@ bool p3ChatService::checkForMessageSecurity(RsChatMsgItem *ci)
|
|||||||
// https://en.wikipedia.org/wiki/Billion_laughs
|
// https://en.wikipedia.org/wiki/Billion_laughs
|
||||||
// This should be done for all incoming HTML messages (also in forums
|
// This should be done for all incoming HTML messages (also in forums
|
||||||
// etc.) so this should be a function in some other file.
|
// etc.) so this should be a function in some other file.
|
||||||
wchar_t tmp[10];
|
|
||||||
mbstowcs(tmp, "<!", 9);
|
|
||||||
|
|
||||||
if (ci->message.find(tmp) != std::string::npos)
|
if (ci->message.find("<!") != std::string::npos)
|
||||||
{
|
{
|
||||||
// Drop any message with "<!doctype" or "<!entity"...
|
// Drop any message with "<!doctype" or "<!entity"...
|
||||||
// TODO: check what happens with partial messages
|
// TODO: check what happens with partial messages
|
||||||
//
|
//
|
||||||
std::wcout << "handleRecvChatMsgItem: " << ci->message << std::endl;
|
std::cout << "handleRecvChatMsgItem: " << ci->message << std::endl;
|
||||||
std::wcout << "**********" << std::endl;
|
std::cout << "**********" << std::endl;
|
||||||
std::wcout << "********** entity attack by " << ci->PeerId().c_str() << std::endl;
|
std::cout << "********** entity attack by " << ci->PeerId().c_str() << std::endl;
|
||||||
std::wcout << "**********" << std::endl;
|
std::cout << "**********" << std::endl;
|
||||||
|
|
||||||
ci->message = L"**** This message has been removed because it breaks security rules.****" ;
|
ci->message = "**** This message has been removed because it breaks security rules.****" ;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// For a future whitelist:
|
// For a future whitelist:
|
||||||
@ -1146,8 +1144,9 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *ci)
|
|||||||
ci->chatFlags |= RS_CHAT_FLAG_AVATAR_AVAILABLE ;
|
ci->chatFlags |= RS_CHAT_FLAG_AVATAR_AVAILABLE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string message;
|
std::string message = ci->message;
|
||||||
librs::util::ConvertUtf16ToUtf8(ci->message, message);
|
//librs::util::ConvertUtf16ToUtf8(ci->message, message);
|
||||||
|
|
||||||
if (ci->chatFlags & RS_CHAT_FLAG_PRIVATE) {
|
if (ci->chatFlags & RS_CHAT_FLAG_PRIVATE) {
|
||||||
/* notify private chat message */
|
/* notify private chat message */
|
||||||
getPqiNotify()->AddPopupMessage(popupChatFlag, ci->PeerId(), name, message);
|
getPqiNotify()->AddPopupMessage(popupChatFlag, ci->PeerId(), name, message);
|
||||||
@ -1691,7 +1690,7 @@ void p3ChatService::sendAvatarJpegData(const std::string& peer_id)
|
|||||||
RsChatAvatarItem *ci = makeOwnAvatarItem();
|
RsChatAvatarItem *ci = makeOwnAvatarItem();
|
||||||
ci->PeerId(peer_id);
|
ci->PeerId(peer_id);
|
||||||
|
|
||||||
// take avatar, and embed it into a std::wstring.
|
// take avatar, and embed it into a std::string.
|
||||||
//
|
//
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "p3ChatService::sending avatar image to peer" << peer_id << ", image size = " << ci->image_size << std::endl ;
|
std::cerr << "p3ChatService::sending avatar image to peer" << peer_id << ", image size = " << ci->image_size << std::endl ;
|
||||||
@ -2142,7 +2141,7 @@ void p3ChatService::locked_initLobbyBouncableObject(const ChatLobbyId& lobby_id,
|
|||||||
item.nick = lobby.nick_name ;
|
item.nick = lobby.nick_name ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::sendLobbyChat(const std::string &id, const std::wstring& msg, const ChatLobbyId& lobby_id)
|
bool p3ChatService::sendLobbyChat(const std::string &id, const std::string& msg, const ChatLobbyId& lobby_id)
|
||||||
{
|
{
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "Sending chat lobby message to lobby " << std::hex << lobby_id << std::dec << std::endl;
|
std::cerr << "Sending chat lobby message to lobby " << std::hex << lobby_id << std::dec << std::endl;
|
||||||
@ -2461,7 +2460,7 @@ bool p3ChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id)
|
|||||||
item->lobby_id = entry.lobby_id ;
|
item->lobby_id = entry.lobby_id ;
|
||||||
item->msg_id = 0 ;
|
item->msg_id = 0 ;
|
||||||
item->nick = "Lobby management" ;
|
item->nick = "Lobby management" ;
|
||||||
item->message = std::wstring(L"Welcome to chat lobby") ;
|
item->message = std::string("Welcome to chat lobby") ;
|
||||||
item->PeerId(entry.virtual_peer_id) ;
|
item->PeerId(entry.virtual_peer_id) ;
|
||||||
item->chatFlags = RS_CHAT_FLAG_PRIVATE | RS_CHAT_FLAG_LOBBY ;
|
item->chatFlags = RS_CHAT_FLAG_PRIVATE | RS_CHAT_FLAG_LOBBY ;
|
||||||
|
|
||||||
|
@ -70,14 +70,14 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
|||||||
/*!
|
/*!
|
||||||
* public chat sent to all peers
|
* public chat sent to all peers
|
||||||
*/
|
*/
|
||||||
int sendPublicChat(const std::wstring &msg);
|
int sendPublicChat(const std::string &msg);
|
||||||
|
|
||||||
/********* RsMsgs ***********/
|
/********* RsMsgs ***********/
|
||||||
/*!
|
/*!
|
||||||
* chat is sent to specifc peer
|
* chat is sent to specifc peer
|
||||||
* @param id peer to send chat msg to
|
* @param id peer to send chat msg to
|
||||||
*/
|
*/
|
||||||
bool sendPrivateChat(const std::string &id, const std::wstring &msg);
|
bool sendPrivateChat(const std::string &id, const std::string &msg);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* can be used to send 'immediate' status msgs, these status updates are meant for immediate use by peer (not saved by rs)
|
* can be used to send 'immediate' status msgs, these status updates are meant for immediate use by peer (not saved by rs)
|
||||||
@ -244,7 +244,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
|||||||
|
|
||||||
/// receive and handle chat lobby item
|
/// receive and handle chat lobby item
|
||||||
bool recvLobbyChat(RsChatLobbyMsgItem*,const std::string& src_peer_id) ;
|
bool recvLobbyChat(RsChatLobbyMsgItem*,const std::string& src_peer_id) ;
|
||||||
bool sendLobbyChat(const std::string &id, const std::wstring&, const ChatLobbyId&) ;
|
bool sendLobbyChat(const std::string &id, const std::string&, const ChatLobbyId&) ;
|
||||||
void handleRecvLobbyInvite(RsChatLobbyInviteItem*) ;
|
void handleRecvLobbyInvite(RsChatLobbyInviteItem*) ;
|
||||||
void checkAndRedirectMsgToLobby(RsChatMsgItem*) ;
|
void checkAndRedirectMsgToLobby(RsChatMsgItem*) ;
|
||||||
void handleConnectionChallenge(RsChatLobbyConnectChallengeItem *item) ;
|
void handleConnectionChallenge(RsChatLobbyConnectChallengeItem *item) ;
|
||||||
|
@ -138,14 +138,10 @@ void p3MsgService::processMsg(RsMsgItem *mi, bool incoming)
|
|||||||
pqiNotify *notify = getPqiNotify();
|
pqiNotify *notify = getPqiNotify();
|
||||||
if (notify)
|
if (notify)
|
||||||
{
|
{
|
||||||
std::string title, message;
|
|
||||||
librs::util::ConvertUtf16ToUtf8(mi->subject, title);
|
|
||||||
librs::util::ConvertUtf16ToUtf8(mi->message, message);
|
|
||||||
|
|
||||||
if(mi->msgFlags & RS_MSG_FLAGS_ENCRYPTED)
|
if(mi->msgFlags & RS_MSG_FLAGS_ENCRYPTED)
|
||||||
notify->AddPopupMessage(RS_POPUP_ENCRYPTED_MSG, mi->PeerId(), title, message);
|
notify->AddPopupMessage(RS_POPUP_ENCRYPTED_MSG, mi->PeerId(), mi->subject, mi->message);
|
||||||
else
|
else
|
||||||
notify->AddPopupMessage(RS_POPUP_MSG, mi->PeerId(), title, message);
|
notify->AddPopupMessage(RS_POPUP_MSG, mi->PeerId(), mi->subject, mi->message);
|
||||||
|
|
||||||
std::string out;
|
std::string out;
|
||||||
rs_sprintf(out, "%lu", mi->msgId);
|
rs_sprintf(out, "%lu", mi->msgId);
|
||||||
@ -669,12 +665,12 @@ void p3MsgService::loadWelcomeMsg()
|
|||||||
msg -> recvTime = time(NULL);
|
msg -> recvTime = time(NULL);
|
||||||
msg -> msgFlags = RS_MSG_FLAGS_NEW;
|
msg -> msgFlags = RS_MSG_FLAGS_NEW;
|
||||||
|
|
||||||
msg -> subject = L"Welcome to Retroshare";
|
msg -> subject = "Welcome to Retroshare";
|
||||||
|
|
||||||
msg -> message = L"Send and receive messages with your friends...\n";
|
msg -> message = "Send and receive messages with your friends...\n";
|
||||||
msg -> message += L"These can hold recommendations from your local shared files.\n\n";
|
msg -> message += "These can hold recommendations from your local shared files.\n\n";
|
||||||
msg -> message += L"Add recommendations through the Local Files Dialog.\n\n";
|
msg -> message += "Add recommendations through the Local Files Dialog.\n\n";
|
||||||
msg -> message += L"Enjoy.";
|
msg -> message += "Enjoy.";
|
||||||
|
|
||||||
msg -> msgId = getNewUniqueMsgId();
|
msg -> msgId = getNewUniqueMsgId();
|
||||||
|
|
||||||
@ -1072,7 +1068,7 @@ bool p3MsgService::MessageSend(MessageInfo &info)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3MsgService::SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag)
|
bool p3MsgService::SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag)
|
||||||
{
|
{
|
||||||
if ((systemFlag & RS_MSG_SYSTEM) == 0) {
|
if ((systemFlag & RS_MSG_SYSTEM) == 0) {
|
||||||
/* no flag specified */
|
/* no flag specified */
|
||||||
@ -1829,22 +1825,21 @@ bool p3MsgService::encryptMessage(const std::string& pgp_id,RsMsgItem *item)
|
|||||||
#endif
|
#endif
|
||||||
// Now turn the binary encrypted chunk into a readable radix string.
|
// Now turn the binary encrypted chunk into a readable radix string.
|
||||||
//
|
//
|
||||||
|
#ifdef DEBUG_DISTANT_MSG
|
||||||
|
std::cerr << " Converting to radix64" << std::endl;
|
||||||
|
#endif
|
||||||
std::string armoured_data ;
|
std::string armoured_data ;
|
||||||
Radix64::encode((char *)encrypted_data,encrypted_size,armoured_data) ;
|
Radix64::encode((char *)encrypted_data,encrypted_size,armoured_data) ;
|
||||||
delete[] encrypted_data ;
|
delete[] encrypted_data ;
|
||||||
|
|
||||||
std::wstring encrypted_msg ;
|
//std::wstring encrypted_msg = armoured_data;
|
||||||
|
//if(!librs::util::ConvertUtf8ToUtf16(armoured_data,encrypted_msg))
|
||||||
#ifdef DEBUG_DISTANT_MSG
|
// return false;
|
||||||
std::cerr << " Converting to radix64" << std::endl;
|
|
||||||
#endif
|
|
||||||
if(!librs::util::ConvertUtf8ToUtf16(armoured_data,encrypted_msg))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// wipe the item clean and replace the message by the encrypted data.
|
// wipe the item clean and replace the message by the encrypted data.
|
||||||
|
|
||||||
item->message = encrypted_msg ;
|
item->message = armoured_data ;
|
||||||
item->subject = L"" ;
|
item->subject = "" ;
|
||||||
item->msgcc.ids.clear() ;
|
item->msgcc.ids.clear() ;
|
||||||
item->msgbcc.ids.clear() ;
|
item->msgbcc.ids.clear() ;
|
||||||
item->msgto.ids.clear() ;
|
item->msgto.ids.clear() ;
|
||||||
@ -1870,11 +1865,13 @@ bool p3MsgService::decryptMessage(const std::string& mId)
|
|||||||
|
|
||||||
std::map<uint32_t, RsMsgItem *>::iterator mit = imsg.find(msgId);
|
std::map<uint32_t, RsMsgItem *>::iterator mit = imsg.find(msgId);
|
||||||
|
|
||||||
if(mit == imsg.end() || !librs::util::ConvertUtf16ToUtf8(mit->second->message,encrypted_string))
|
if(mit == imsg.end())
|
||||||
{
|
{
|
||||||
std::cerr << "Can't find this message in msg list. Id=" << mId << std::endl;
|
std::cerr << "Can't find this message in msg list. Id=" << mId << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
encrypted_string = mit->second->message ;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *encrypted_data ;
|
char *encrypted_data ;
|
||||||
|
@ -66,7 +66,7 @@ bool getMsgParentId(const std::string &msgId, std::string &msgParentId);
|
|||||||
bool setMsgParentId(uint32_t msgId, uint32_t msgParentId);
|
bool setMsgParentId(uint32_t msgId, uint32_t msgParentId);
|
||||||
|
|
||||||
bool MessageSend(MessageInfo &info);
|
bool MessageSend(MessageInfo &info);
|
||||||
bool SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag);
|
bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag);
|
||||||
bool MessageToDraft(MessageInfo &info, const std::string &msgParentId);
|
bool MessageToDraft(MessageInfo &info, const std::string &msgParentId);
|
||||||
bool MessageToTrash(const std::string &mid, bool bTrash);
|
bool MessageToTrash(const std::string &mid, bool bTrash);
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ void FriendsDialog::insertChat()
|
|||||||
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
|
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
|
||||||
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
|
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
|
||||||
QString name = QString::fromUtf8(rsPeers->getPeerName(it->rsid).c_str());
|
QString name = QString::fromUtf8(rsPeers->getPeerName(it->rsid).c_str());
|
||||||
QString msg = QString::fromStdWString(it->msg);
|
QString msg = QString::fromUtf8(it->msg.c_str());
|
||||||
|
|
||||||
#ifdef FRIENDS_DEBUG
|
#ifdef FRIENDS_DEBUG
|
||||||
std::cerr << "FriendsDialog::insertChat(): " << msg.toStdString() << std::endl;
|
std::cerr << "FriendsDialog::insertChat(): " << msg.toStdString() << std::endl;
|
||||||
@ -571,7 +571,7 @@ void FriendsDialog::sendMsg()
|
|||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
RsHtml::optimizeHtml(lineWidget, text);
|
RsHtml::optimizeHtml(lineWidget, text);
|
||||||
std::wstring message = text.toStdWString();
|
std::string message = text.toUtf8().constData();
|
||||||
|
|
||||||
#ifdef FRIENDS_DEBUG
|
#ifdef FRIENDS_DEBUG
|
||||||
std::string msg(message.begin(), message.end());
|
std::string msg(message.begin(), message.end());
|
||||||
|
@ -1138,7 +1138,7 @@ void MessagesDialog::insertMessages()
|
|||||||
if(it->msgflags & RS_MSG_ENCRYPTED)
|
if(it->msgflags & RS_MSG_ENCRYPTED)
|
||||||
text = tr("Encrypted message. Right-click to decrypt it.") ;
|
text = tr("Encrypted message. Right-click to decrypt it.") ;
|
||||||
else
|
else
|
||||||
text = QString::fromStdWString(it->title);
|
text = QString::fromStdString(it->title);
|
||||||
|
|
||||||
item[COLUMN_SUBJECT]->setText(text);
|
item[COLUMN_SUBJECT]->setText(text);
|
||||||
item[COLUMN_SUBJECT]->setData(text + dateString, ROLE_SORT);
|
item[COLUMN_SUBJECT]->setData(text + dateString, ROLE_SORT);
|
||||||
@ -1206,7 +1206,7 @@ void MessagesDialog::insertMessages()
|
|||||||
if (gotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) {
|
if (gotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) {
|
||||||
gotInfo = true;
|
gotInfo = true;
|
||||||
QTextDocument doc;
|
QTextDocument doc;
|
||||||
doc.setHtml(QString::fromStdWString(msgInfo.msg));
|
doc.setHtml(QString::fromStdString(msgInfo.msg));
|
||||||
item[COLUMN_CONTENT]->setText(doc.toPlainText().replace(QString("\n"), QString(" ")));
|
item[COLUMN_CONTENT]->setText(doc.toPlainText().replace(QString("\n"), QString(" ")));
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl;
|
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl;
|
||||||
|
@ -284,7 +284,7 @@ void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
|
|||||||
{
|
{
|
||||||
QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
|
QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
|
||||||
QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
|
QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
|
||||||
QString message = QString::fromStdWString(info.msg);
|
QString message = QString::fromUtf8(info.msg.c_str());
|
||||||
QString name = QString::fromUtf8(info.peer_nickname.c_str());
|
QString name = QString::fromUtf8(info.peer_nickname.c_str());
|
||||||
QString rsid = QString::fromUtf8(info.rsid.c_str());
|
QString rsid = QString::fromUtf8(info.rsid.c_str());
|
||||||
|
|
||||||
|
@ -711,7 +711,7 @@ void ChatWidget::sendChat()
|
|||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
RsHtml::optimizeHtml(chatWidget, text);
|
RsHtml::optimizeHtml(chatWidget, text);
|
||||||
std::wstring msg = text.toStdWString();
|
std::string msg = text.toUtf8().constData();
|
||||||
|
|
||||||
if (msg.empty()) {
|
if (msg.empty()) {
|
||||||
// nothing to send
|
// nothing to send
|
||||||
@ -724,7 +724,7 @@ void ChatWidget::sendChat()
|
|||||||
|
|
||||||
if (rsMsgs->sendPrivateChat(peerId, msg)) {
|
if (rsMsgs->sendPrivateChat(peerId, msg)) {
|
||||||
QDateTime currentTime = QDateTime::currentDateTime();
|
QDateTime currentTime = QDateTime::currentDateTime();
|
||||||
addChatMsg(false, name, currentTime, currentTime, QString::fromStdWString(msg), TYPE_NORMAL);
|
addChatMsg(false, name, currentTime, currentTime, text, TYPE_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
chatWidget->clear();
|
chatWidget->clear();
|
||||||
|
@ -134,7 +134,7 @@ void PopupChatDialog::addIncomingChatMsg(const ChatInfo& info)
|
|||||||
if (cw) {
|
if (cw) {
|
||||||
QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
|
QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
|
||||||
QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
|
QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
|
||||||
QString message = QString::fromStdWString(info.msg);
|
QString message = QString::fromUtf8(info.msg.c_str());
|
||||||
QString name = getPeerName(info.rsid) ;
|
QString name = getPeerName(info.rsid) ;
|
||||||
|
|
||||||
cw->addChatMsg(true, name, sendTime, recvTime, message, ChatWidget::TYPE_NORMAL);
|
cw->addChatMsg(true, name, sendTime, recvTime, message, ChatWidget::TYPE_NORMAL);
|
||||||
@ -176,7 +176,7 @@ void PopupChatDialog::onChatChanged(int list, int type)
|
|||||||
|
|
||||||
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
|
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
|
||||||
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
|
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
|
||||||
QString message = QString::fromStdWString(it->msg);
|
QString message = QString::fromUtf8(it->msg.c_str());
|
||||||
|
|
||||||
ui.chatWidget->addChatMsg(false, name, sendTime, recvTime, message, ChatWidget::TYPE_OFFLINE);
|
ui.chatWidget->addChatMsg(false, name, sendTime, recvTime, message, ChatWidget::TYPE_OFFLINE);
|
||||||
}
|
}
|
||||||
@ -195,7 +195,7 @@ void PopupChatDialog::onChatChanged(int list, int type)
|
|||||||
for(it = savedOfflineChat.begin(); it != savedOfflineChat.end(); ++it) {
|
for(it = savedOfflineChat.begin(); it != savedOfflineChat.end(); ++it) {
|
||||||
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
|
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
|
||||||
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
|
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
|
||||||
QString message = QString::fromStdWString(it->msg);
|
QString message = QString::fromUtf8(it->msg.c_str());
|
||||||
|
|
||||||
ui.chatWidget->addChatMsg(false, name, sendTime, recvTime, message, ChatWidget::TYPE_NORMAL);
|
ui.chatWidget->addChatMsg(false, name, sendTime, recvTime, message, ChatWidget::TYPE_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -243,8 +243,8 @@ void ChatMsgItem::sendMessage()
|
|||||||
/* construct a message */
|
/* construct a message */
|
||||||
MessageInfo mi;
|
MessageInfo mi;
|
||||||
|
|
||||||
mi.title = tr("Quick Message").toStdWString();
|
mi.title = tr("Quick Message").toUtf8().constData();
|
||||||
mi.msg = quickmsgText->toHtml().toStdWString();
|
mi.msg = quickmsgText->toHtml().toUtf8().constData();
|
||||||
mi.msgto.push_back(mPeerId);
|
mi.msgto.push_back(mPeerId);
|
||||||
|
|
||||||
rsMsgs->MessageSend(mi);
|
rsMsgs->MessageSend(mi);
|
||||||
|
@ -127,12 +127,12 @@ void MsgItem::updateItemStatic()
|
|||||||
title += srcName;
|
title += srcName;
|
||||||
|
|
||||||
titleLabel->setText(title);
|
titleLabel->setText(title);
|
||||||
subjectLabel->setText(QString::fromStdWString(mi.title));
|
subjectLabel->setText(QString::fromUtf8(mi.title.c_str()));
|
||||||
|
|
||||||
if(mi.msgflags & RS_MSG_ENCRYPTED)
|
if(mi.msgflags & RS_MSG_ENCRYPTED)
|
||||||
msgLabel->setText(RsHtml().formatText(NULL, tr("[Encrypted message]"), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
msgLabel->setText(RsHtml().formatText(NULL, tr("[Encrypted message]"), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
||||||
else
|
else
|
||||||
msgLabel->setText(RsHtml().formatText(NULL, QString::fromStdWString(mi.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mi.msg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
||||||
|
|
||||||
std::list<FileInfo>::iterator it;
|
std::list<FileInfo>::iterator it;
|
||||||
for(it = mi.files.begin(); it != mi.files.end(); it++)
|
for(it = mi.files.begin(); it != mi.files.end(); it++)
|
||||||
|
@ -312,8 +312,8 @@ void PeerItem::sendMessage()
|
|||||||
/* construct a message */
|
/* construct a message */
|
||||||
MessageInfo mi;
|
MessageInfo mi;
|
||||||
|
|
||||||
mi.title = tr("Quick Message").toStdWString();
|
mi.title = tr("Quick Message").toUtf8().constData();
|
||||||
mi.msg = quickmsgText->toHtml().toStdWString();
|
mi.msg = quickmsgText->toHtml().toUtf8().constData();
|
||||||
mi.msgto.push_back(mPeerId);
|
mi.msgto.push_back(mPeerId);
|
||||||
|
|
||||||
rsMsgs->MessageSend(mi);
|
rsMsgs->MessageSend(mi);
|
||||||
|
@ -407,8 +407,8 @@ void SecurityItem::sendMessage()
|
|||||||
/* construct a message */
|
/* construct a message */
|
||||||
MessageInfo mi;
|
MessageInfo mi;
|
||||||
|
|
||||||
mi.title = tr("Quick Message").toStdWString();
|
mi.title = tr("Quick Message").toUtf8().constData();
|
||||||
mi.msg = quickmsgText->toHtml().toStdWString();
|
mi.msg = quickmsgText->toHtml().toUtf8().constData();
|
||||||
mi.msgto.push_back(mGpgId);
|
mi.msgto.push_back(mGpgId);
|
||||||
|
|
||||||
rsMsgs->MessageSend(mi);
|
rsMsgs->MessageSend(mi);
|
||||||
|
@ -512,14 +512,14 @@ void MessageComposer::sendConnectAttemptMsg(const std::string &gpgId, const std:
|
|||||||
if ((it->msgflags & RS_MSG_USER_REQUEST) == 0) {
|
if ((it->msgflags & RS_MSG_USER_REQUEST) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (it->title == title.toStdWString()) {
|
if (it->title == title.toUtf8().constData()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a message */
|
/* create a message */
|
||||||
QString msgText = tr("Hi %1,<br><br>%2 wants to be friends with you on RetroShare.<br><br>Respond now:<br>%3<br><br>Thanks,<br>The RetroShare Team").arg(QString::fromUtf8(rsPeers->getGPGName(rsPeers->getGPGOwnId()).c_str()), sslName, link.toHtml());
|
QString msgText = tr("Hi %1,<br><br>%2 wants to be friends with you on RetroShare.<br><br>Respond now:<br>%3<br><br>Thanks,<br>The RetroShare Team").arg(QString::fromUtf8(rsPeers->getGPGName(rsPeers->getGPGOwnId()).c_str()), sslName, link.toHtml());
|
||||||
rsMsgs->SystemMessage(title.toStdWString(), msgText.toStdWString(), RS_MSG_USER_REQUEST);
|
rsMsgs->SystemMessage(title.toUtf8().constData(), msgText.toUtf8().constData(), RS_MSG_USER_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageComposer::closeEvent (QCloseEvent * event)
|
void MessageComposer::closeEvent (QCloseEvent * event)
|
||||||
@ -889,8 +889,8 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/)
|
|||||||
// needed to send system flags with reply
|
// needed to send system flags with reply
|
||||||
msgComposer->msgFlags = (msgInfo.msgflags & RS_MSG_SYSTEM);
|
msgComposer->msgFlags = (msgInfo.msgflags & RS_MSG_SYSTEM);
|
||||||
|
|
||||||
msgComposer->setTitleText(QString::fromStdWString(msgInfo.title));
|
msgComposer->setTitleText(QString::fromUtf8(msgInfo.title.c_str()));
|
||||||
msgComposer->setMsgText(QString::fromStdWString(msgInfo.msg));
|
msgComposer->setMsgText(QString::fromUtf8(msgInfo.msg.c_str()));
|
||||||
msgComposer->setFileList(msgInfo.files);
|
msgComposer->setFileList(msgInfo.files);
|
||||||
|
|
||||||
// get existing groups
|
// get existing groups
|
||||||
@ -975,7 +975,7 @@ QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
header += QString("<br><font size='3'><strong>%1: </strong>%2</font><br>").arg(tr("Sent"), DateTime::formatLongDateTime(msgInfo.ts));
|
header += QString("<br><font size='3'><strong>%1: </strong>%2</font><br>").arg(tr("Sent"), DateTime::formatLongDateTime(msgInfo.ts));
|
||||||
header += QString("<font size='3'><strong>%1: </strong>%2</font></span><br>").arg(tr("Subject"), QString::fromStdWString(msgInfo.title));
|
header += QString("<font size='3'><strong>%1: </strong>%2</font></span><br>").arg(tr("Subject"), QString::fromUtf8(msgInfo.title.c_str()));
|
||||||
header += "<br>";
|
header += "<br>";
|
||||||
|
|
||||||
header += tr("On %1, %2 wrote:").arg(DateTime::formatDateTime(msgInfo.ts), from);
|
header += tr("On %1, %2 wrote:").arg(DateTime::formatDateTime(msgInfo.ts), from);
|
||||||
@ -1034,8 +1034,8 @@ MessageComposer *MessageComposer::replyMsg(const std::string &msgId, bool all)
|
|||||||
|
|
||||||
/* fill it in */
|
/* fill it in */
|
||||||
|
|
||||||
msgComposer->setTitleText(QString::fromStdWString(msgInfo.title), REPLY);
|
msgComposer->setTitleText(QString::fromUtf8(msgInfo.title.c_str()), REPLY);
|
||||||
msgComposer->setQuotedMsg(QString::fromStdWString(msgInfo.msg), buildReplyHeader(msgInfo));
|
msgComposer->setQuotedMsg(QString::fromUtf8(msgInfo.msg.c_str()), buildReplyHeader(msgInfo));
|
||||||
|
|
||||||
msgComposer->addRecipient(MessageComposer::TO, msgInfo.srcId, false);
|
msgComposer->addRecipient(MessageComposer::TO, msgInfo.srcId, false);
|
||||||
|
|
||||||
@ -1078,8 +1078,8 @@ MessageComposer *MessageComposer::forwardMsg(const std::string &msgId)
|
|||||||
|
|
||||||
/* fill it in */
|
/* fill it in */
|
||||||
|
|
||||||
msgComposer->setTitleText(QString::fromStdWString(msgInfo.title), FORWARD);
|
msgComposer->setTitleText(QString::fromUtf8(msgInfo.title.c_str()), FORWARD);
|
||||||
msgComposer->setQuotedMsg(QString::fromStdWString(msgInfo.msg), buildReplyHeader(msgInfo));
|
msgComposer->setQuotedMsg(QString::fromUtf8(msgInfo.msg.c_str()), buildReplyHeader(msgInfo));
|
||||||
|
|
||||||
std::list<FileInfo>& files_info = msgInfo.files;
|
std::list<FileInfo>& files_info = msgInfo.files;
|
||||||
|
|
||||||
@ -1151,13 +1151,13 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
|||||||
/* construct a message */
|
/* construct a message */
|
||||||
MessageInfo mi;
|
MessageInfo mi;
|
||||||
|
|
||||||
mi.title = misc::removeNewLine(ui.titleEdit->text()).toStdWString();
|
mi.title = misc::removeNewLine(ui.titleEdit->text()).toUtf8().constData();
|
||||||
// needed to send system flags with reply
|
// needed to send system flags with reply
|
||||||
mi.msgflags = msgFlags;
|
mi.msgflags = msgFlags;
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
RsHtml::optimizeHtml(ui.msgText, text);
|
RsHtml::optimizeHtml(ui.msgText, text);
|
||||||
mi.msg = text.toStdWString();
|
mi.msg = text.toUtf8().constData();
|
||||||
|
|
||||||
/* check for existing title */
|
/* check for existing title */
|
||||||
if (bDraftbox == false && mi.title.empty()) {
|
if (bDraftbox == false && mi.title.empty()) {
|
||||||
|
@ -554,9 +554,9 @@ void MessageWidget::fill(const std::string &msgId)
|
|||||||
ui.fromText->setToolTip(PeerDefs::rsidFromId(srcId));
|
ui.fromText->setToolTip(PeerDefs::rsidFromId(srcId));
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.subjectText->setText(QString::fromStdWString(msgInfo.title));
|
ui.subjectText->setText(QString::fromUtf8(msgInfo.title.c_str()));
|
||||||
|
|
||||||
text = RsHtmlMsg(msgInfo.msgflags).formatText(ui.msgText->document(), QString::fromStdWString(msgInfo.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_REPLACE_LINKS);
|
text = RsHtmlMsg(msgInfo.msgflags).formatText(ui.msgText->document(), QString::fromUtf8(msgInfo.msg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_REPLACE_LINKS);
|
||||||
ui.msgText->setHtml(text);
|
ui.msgText->setHtml(text);
|
||||||
|
|
||||||
ui.filesText->setText(QString("(%1 %2)").arg(msgInfo.count).arg(msgInfo.count == 1 ? tr("File") : tr("Files")));
|
ui.filesText->setText(QString("(%1 %2)").arg(msgInfo.count).arg(msgInfo.count == 1 ? tr("File") : tr("Files")));
|
||||||
|
Loading…
Reference in New Issue
Block a user