diff --git a/libretroshare/src/pqi/p3historymgr.cc b/libretroshare/src/pqi/p3historymgr.cc index 01d365b4b..f967297d9 100644 --- a/libretroshare/src/pqi/p3historymgr.cc +++ b/libretroshare/src/pqi/p3historymgr.cc @@ -87,7 +87,8 @@ void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, cons item->saveToDisc = false; } - librs::util::ConvertUtf16ToUtf8(chatItem->message, item->message); + item->message = chatItem->message ; + //librs::util::ConvertUtf16ToUtf8(chatItem->message, item->message); std::map >::iterator mit = mMessages.find(item->chatPeerId); if (mit != mMessages.end()) { diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index e2c195984..8a8d459c3 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -98,11 +98,11 @@ class MessageInfo std::list msgcc; std::list msgbcc; - std::wstring title; - std::wstring msg; + std::string title; + std::string msg; - std::wstring attach_title; - std::wstring attach_comment; + std::string attach_title; + std::string attach_comment; std::list files; std::map encryption_keys ; // for concerned ids only the public pgp key id to encrypt the message with. int size; /* total of files */ @@ -121,7 +121,7 @@ class MsgInfoSummary uint32_t msgflags; - std::wstring title; + std::string title; int count; /* file count */ time_t ts; @@ -170,7 +170,7 @@ class ChatInfo unsigned int chatflags; uint32_t sendTime; uint32_t recvTime; - std::wstring msg; + std::string msg; }; 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 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 MessageToTrash(const std::string &mid, bool bTrash) = 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 */ /****************************************/ -virtual bool sendPublicChat(const std::wstring& msg) = 0; -virtual bool sendPrivateChat(const std::string& id, const std::wstring& msg) = 0; +virtual bool sendPublicChat(const std::string& msg) = 0; +virtual bool sendPrivateChat(const std::string& id, const std::string& msg) = 0; virtual int getPublicChatQueueCount() = 0; virtual bool getPublicChatQueue(std::list &chats) = 0; virtual int getPrivateChatQueueCount(bool incoming) = 0; diff --git a/libretroshare/src/rsserver/p3msgs.cc b/libretroshare/src/rsserver/p3msgs.cc index 58613ac26..3346a1964 100644 --- a/libretroshare/src/rsserver/p3msgs.cc +++ b/libretroshare/src/rsserver/p3msgs.cc @@ -121,7 +121,7 @@ bool p3Msgs::getDistantMessageHash(const std::string& pgp_id,std::string& 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); } @@ -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 */ 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 */ return mChatSrv -> sendPrivateChat(id, msg); diff --git a/libretroshare/src/rsserver/p3msgs.h b/libretroshare/src/rsserver/p3msgs.h index c42888a4e..371992dea 100644 --- a/libretroshare/src/rsserver/p3msgs.h +++ b/libretroshare/src/rsserver/p3msgs.h @@ -59,7 +59,7 @@ class p3Msgs: public RsMsgs virtual bool MessageSend(MessageInfo &info); 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 MessageToTrash(const std::string &mid, bool bTrash); virtual bool MessageDelete(const std::string &mid); @@ -120,13 +120,13 @@ class p3Msgs: public RsMsgs /*! * 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 * @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 diff --git a/libretroshare/src/serialiser/rshistoryitems.cc b/libretroshare/src/serialiser/rshistoryitems.cc index 0cb270ad3..023fdc81c 100644 --- a/libretroshare/src/serialiser/rshistoryitems.cc +++ b/libretroshare/src/serialiser/rshistoryitems.cc @@ -147,7 +147,7 @@ bool RsHistorySerialiser::serialiseHistoryMsgItem(RsHistoryMsgItem* item, void* ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->peerName); ok &= setRawUInt32(data, tlvsize, &offset, item->sendTime); 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) { @@ -202,7 +202,7 @@ RsHistoryMsgItem *RsHistorySerialiser::deserialiseHistoryMsgItem(void *data, uin ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->peerName); ok &= getRawUInt32(data, rssize, &offset, &(item->sendTime)); 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) { diff --git a/libretroshare/src/serialiser/rsmsgitems.cc b/libretroshare/src/serialiser/rsmsgitems.cc index 5e0c5131b..706ed8f8f 100644 --- a/libretroshare/src/serialiser/rsmsgitems.cc +++ b/libretroshare/src/serialiser/rsmsgitems.cc @@ -303,7 +303,7 @@ uint32_t RsChatMsgItem::serial_size() uint32_t s = 8; /* header */ s += 4; /* chatFlags */ s += 4; /* sendTime */ - s += GetTlvWideStringSize(message); + s += GetTlvStringSize(message); return s; } @@ -418,7 +418,7 @@ uint32_t RsPrivateChatMsgConfigItem::serial_size() s += 4; /* chatFlags */ s += 4; /* configFlags */ s += 4; /* sendTime */ - s += GetTlvWideStringSize(message); + s += GetTlvStringSize(message); s += 4; /* recvTime */ return s; @@ -498,7 +498,7 @@ bool RsChatMsgItem::serialise(void *data, uint32_t& pktsize) /* add mandatory parts first */ ok &= setRawUInt32(data, tlvsize, &offset, chatFlags); 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 std::cerr << "Serialized the following 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, configFlags); 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); if (offset != tlvsize) @@ -989,7 +989,7 @@ RsChatMsgItem::RsChatMsgItem(void *data,uint32_t /*size*/,uint8_t subtype) /* get mandatory parts first */ ok &= getRawUInt32(data, rssize, &offset, &chatFlags); 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 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, &configFlags); 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); #ifdef CHAT_DEBUG @@ -1500,8 +1500,8 @@ uint32_t RsMsgItem::serial_size(bool m_bConfiguration) s += 4; /* sendTime */ s += 4; /* recvTime */ - s += GetTlvWideStringSize(subject); - s += GetTlvWideStringSize(message); + s += GetTlvStringSize(subject); + s += GetTlvStringSize(message); s += msgto.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, recvTime); - ok &= SetTlvWideString(data,tlvsize,&offset,TLV_TYPE_WSTR_SUBJECT,subject); - ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_MSG, message); + ok &= SetTlvString(data,tlvsize,&offset,TLV_TYPE_STR_SUBJECT,subject); + ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_MSG, message); ok &= msgto.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->recvTime)); - ok &= GetTlvWideString(data,rssize,&offset,TLV_TYPE_WSTR_SUBJECT,item->subject); - ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_MSG, item->message); + ok &= GetTlvString(data,rssize,&offset,TLV_TYPE_STR_SUBJECT,item->subject); + ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_MSG, item->message); ok &= item->msgto.GetTlv(data, rssize, &offset); ok &= item->msgcc.GetTlv(data, rssize, &offset); ok &= item->msgbcc.GetTlv(data, rssize, &offset); diff --git a/libretroshare/src/serialiser/rsmsgitems.h b/libretroshare/src/serialiser/rsmsgitems.h index 7c9704c1f..0ab2c7519 100644 --- a/libretroshare/src/serialiser/rsmsgitems.h +++ b/libretroshare/src/serialiser/rsmsgitems.h @@ -50,24 +50,24 @@ const uint32_t RS_CHAT_FLAG_ACK_DISTANT_CONNECTION = 0x0800; const uint32_t RS_CHATMSG_CONFIGFLAG_INCOMING = 0x0001; -const uint8_t RS_PKT_SUBTYPE_CHAT_AVATAR = 0x03 ; -const uint8_t RS_PKT_SUBTYPE_CHAT_STATUS = 0x04 ; -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_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_CHALLENGE = 0x09 ; -const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_UNSUBSCRIBE = 0x0A ; -const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_EVENT_DEPREC = 0x0B ; // don't use ! Deprecated -const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_MSG = 0x0C ; -const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_LIST_REQUEST = 0x0D ; +const uint8_t RS_PKT_SUBTYPE_CHAT_AVATAR = 0x03 ; +const uint8_t RS_PKT_SUBTYPE_CHAT_STATUS = 0x04 ; +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_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_CHALLENGE = 0x09 ; +const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_UNSUBSCRIBE = 0x0A ; +const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_EVENT_DEPREC = 0x0B ; // don't use ! Deprecated +const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_MSG = 0x0C ; +const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_LIST_REQUEST = 0x0D ; const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_LIST_deprecated = 0x0E ; // to be removed -const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE = 0x0F ; -const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_EVENT = 0x10 ; +const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE = 0x0F ; +const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_EVENT = 0x10 ; const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_LIST_deprecated2 = 0x11 ; // to be removed (deprecated since 02 Dec. 2012) -const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_LIST = 0x12 ; -const uint8_t RS_PKT_SUBTYPE_DISTANT_INVITE_CONFIG = 0x13 ; -const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_CONFIG = 0x15 ; +const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_LIST = 0x12 ; +const uint8_t RS_PKT_SUBTYPE_DISTANT_INVITE_CONFIG = 0x13 ; +const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_CONFIG = 0x15 ; // for defining tags themselves and msg tags const uint8_t RS_PKT_SUBTYPE_MSG_TAG_TYPE = 0x03; @@ -117,7 +117,7 @@ class RsChatMsgItem: public RsChatItem uint32_t chatFlags; uint32_t sendTime; - std::wstring message; + std::string message; /* not serialised */ uint32_t recvTime; }; @@ -316,7 +316,7 @@ class RsPrivateChatMsgConfigItem: public RsChatItem uint32_t chatFlags; uint32_t configFlags; uint32_t sendTime; - std::wstring message; + std::string message; uint32_t recvTime; }; class RsPrivateChatDistantInviteConfigItem: public RsChatItem @@ -475,8 +475,8 @@ class RsMsgItem: public RsMessageItem uint32_t sendTime; uint32_t recvTime; - std::wstring subject; - std::wstring message; + std::string subject; + std::string message; RsTlvPeerIdSet msgto; RsTlvPeerIdSet msgcc; diff --git a/libretroshare/src/serialiser/rstlvfileitem.cc b/libretroshare/src/serialiser/rstlvfileitem.cc index 644bdb856..939830e57 100644 --- a/libretroshare/src/serialiser/rstlvfileitem.cc +++ b/libretroshare/src/serialiser/rstlvfileitem.cc @@ -417,9 +417,9 @@ uint32_t RsTlvFileSet::TlvSize() /* now add comment and title length of this tlv object */ if (title.length() > 0) - s += GetTlvWideStringSize(title); + s += GetTlvStringSize(title); if (comment.length() > 0) - s += GetTlvWideStringSize(comment); + s += GetTlvStringSize(comment); return s; } @@ -454,9 +454,9 @@ bool RsTlvFileSet::SetTlv(void *data, uint32_t size, uint32_t *offset) /* se /* now optional ones */ 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) - ok &= SetTlvWideString(data, tlvend, offset, TLV_TYPE_WSTR_COMMENT, comment); + ok &= SetTlvString(data, tlvend, offset, TLV_TYPE_STR_COMMENT, comment); return ok; @@ -500,15 +500,15 @@ bool RsTlvFileSet::GetTlv(void *data, uint32_t size, uint32_t *offset) items.push_back(newitem); } } - else if (tlvsubtype == TLV_TYPE_WSTR_TITLE) + else if (tlvsubtype == TLV_TYPE_STR_TITLE) { - ok &= GetTlvWideString(data, tlvend, offset, - TLV_TYPE_WSTR_TITLE, title); + ok &= GetTlvString(data, tlvend, offset, + TLV_TYPE_STR_TITLE, title); } - else if (tlvsubtype == TLV_TYPE_WSTR_COMMENT) + else if (tlvsubtype == TLV_TYPE_STR_COMMENT) { - ok &= GetTlvWideString(data, tlvend, offset, - TLV_TYPE_WSTR_COMMENT, comment); + ok &= GetTlvString(data, tlvend, offset, + TLV_TYPE_STR_COMMENT, comment); } else { diff --git a/libretroshare/src/serialiser/rstlvtypes.h b/libretroshare/src/serialiser/rstlvtypes.h index 4fd45bd4a..7b6f582b9 100644 --- a/libretroshare/src/serialiser/rstlvtypes.h +++ b/libretroshare/src/serialiser/rstlvtypes.h @@ -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); std::list items; /// Mandatory - std::wstring title; /// Optional: title of file set - std::wstring comment; /// Optional: comments for file + std::string title; /// Optional: title of file set + std::string comment; /// Optional: comments for file }; diff --git a/libretroshare/src/services/p3chatservice.cc b/libretroshare/src/services/p3chatservice.cc index be71584f3..ef409e266 100644 --- a/libretroshare/src/services/p3chatservice.cc +++ b/libretroshare/src/services/p3chatservice.cc @@ -141,7 +141,7 @@ int p3ChatService::status() /***************** Chat Stuff **********************/ -int p3ChatService::sendPublicChat(const std::wstring &msg) +int p3ChatService::sendPublicChat(const std::string &msg) { /* go through all the peers */ @@ -460,7 +460,7 @@ bool p3ChatService::isOnline(const std::string& id) 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? @@ -643,7 +643,7 @@ bool p3ChatService::locked_checkAndRebuildPartialMessage(RsChatLobbyMsgItem *ci) #ifdef CHAT_DEBUG std::cerr << " Message is complete ! Re-forming it and returning true." << std::endl; #endif - std::wstring msg ; + std::string msg ; uint32_t flags = 0 ; for(uint32_t i=0;isecond.size();++i) @@ -998,20 +998,18 @@ bool p3ChatService::checkForMessageSecurity(RsChatMsgItem *ci) // https://en.wikipedia.org/wiki/Billion_laughs // This should be done for all incoming HTML messages (also in forums // etc.) so this should be a function in some other file. - wchar_t tmp[10]; - mbstowcs(tmp, "message.find(tmp) != std::string::npos) + if (ci->message.find("message << std::endl; - std::wcout << "**********" << std::endl; - std::wcout << "********** entity attack by " << ci->PeerId().c_str() << std::endl; - std::wcout << "**********" << std::endl; + std::cout << "handleRecvChatMsgItem: " << ci->message << std::endl; + std::cout << "**********" << std::endl; + std::cout << "********** entity attack by " << ci->PeerId().c_str() << 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; } // For a future whitelist: @@ -1146,8 +1144,9 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *ci) ci->chatFlags |= RS_CHAT_FLAG_AVATAR_AVAILABLE ; } - std::string message; - librs::util::ConvertUtf16ToUtf8(ci->message, message); + std::string message = ci->message; + //librs::util::ConvertUtf16ToUtf8(ci->message, message); + if (ci->chatFlags & RS_CHAT_FLAG_PRIVATE) { /* notify private chat message */ getPqiNotify()->AddPopupMessage(popupChatFlag, ci->PeerId(), name, message); @@ -1691,7 +1690,7 @@ void p3ChatService::sendAvatarJpegData(const std::string& peer_id) RsChatAvatarItem *ci = makeOwnAvatarItem(); 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 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 ; } -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 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->msg_id = 0 ; 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->chatFlags = RS_CHAT_FLAG_PRIVATE | RS_CHAT_FLAG_LOBBY ; diff --git a/libretroshare/src/services/p3chatservice.h b/libretroshare/src/services/p3chatservice.h index d48f157a8..010ba1b8d 100644 --- a/libretroshare/src/services/p3chatservice.h +++ b/libretroshare/src/services/p3chatservice.h @@ -70,14 +70,14 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi /*! * public chat sent to all peers */ - int sendPublicChat(const std::wstring &msg); + int sendPublicChat(const std::string &msg); /********* RsMsgs ***********/ /*! * chat is sent to specifc peer * @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) @@ -244,7 +244,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi /// receive and handle chat lobby item 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 checkAndRedirectMsgToLobby(RsChatMsgItem*) ; void handleConnectionChallenge(RsChatLobbyConnectChallengeItem *item) ; diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index a3ae97627..e66971a78 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -138,14 +138,10 @@ void p3MsgService::processMsg(RsMsgItem *mi, bool incoming) pqiNotify *notify = getPqiNotify(); 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) - notify->AddPopupMessage(RS_POPUP_ENCRYPTED_MSG, mi->PeerId(), title, message); + notify->AddPopupMessage(RS_POPUP_ENCRYPTED_MSG, mi->PeerId(), mi->subject, mi->message); else - notify->AddPopupMessage(RS_POPUP_MSG, mi->PeerId(), title, message); + notify->AddPopupMessage(RS_POPUP_MSG, mi->PeerId(), mi->subject, mi->message); std::string out; rs_sprintf(out, "%lu", mi->msgId); @@ -669,12 +665,12 @@ void p3MsgService::loadWelcomeMsg() msg -> recvTime = time(NULL); 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 += L"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 += L"Enjoy."; + msg -> message = "Send and receive messages with your friends...\n"; + msg -> message += "These can hold recommendations from your local shared files.\n\n"; + msg -> message += "Add recommendations through the Local Files Dialog.\n\n"; + msg -> message += "Enjoy."; msg -> msgId = getNewUniqueMsgId(); @@ -1072,7 +1068,7 @@ bool p3MsgService::MessageSend(MessageInfo &info) 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) { /* no flag specified */ @@ -1829,22 +1825,21 @@ bool p3MsgService::encryptMessage(const std::string& pgp_id,RsMsgItem *item) #endif // 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 ; Radix64::encode((char *)encrypted_data,encrypted_size,armoured_data) ; delete[] encrypted_data ; - std::wstring encrypted_msg ; - -#ifdef DEBUG_DISTANT_MSG - std::cerr << " Converting to radix64" << std::endl; -#endif - if(!librs::util::ConvertUtf8ToUtf16(armoured_data,encrypted_msg)) - return false; + //std::wstring encrypted_msg = armoured_data; + //if(!librs::util::ConvertUtf8ToUtf16(armoured_data,encrypted_msg)) + // return false; // wipe the item clean and replace the message by the encrypted data. - item->message = encrypted_msg ; - item->subject = L"" ; + item->message = armoured_data ; + item->subject = "" ; item->msgcc.ids.clear() ; item->msgbcc.ids.clear() ; item->msgto.ids.clear() ; @@ -1870,11 +1865,13 @@ bool p3MsgService::decryptMessage(const std::string& mId) std::map::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; return false; } + + encrypted_string = mit->second->message ; } char *encrypted_data ; diff --git a/libretroshare/src/services/p3msgservice.h b/libretroshare/src/services/p3msgservice.h index 81ebbae2d..6e1ac98f8 100644 --- a/libretroshare/src/services/p3msgservice.h +++ b/libretroshare/src/services/p3msgservice.h @@ -66,7 +66,7 @@ bool getMsgParentId(const std::string &msgId, std::string &msgParentId); bool setMsgParentId(uint32_t msgId, uint32_t msgParentId); 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 MessageToTrash(const std::string &mid, bool bTrash); diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index 9ea095d12..0ded05914 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.cpp @@ -500,7 +500,7 @@ void FriendsDialog::insertChat() QDateTime sendTime = QDateTime::fromTime_t(it->sendTime); QDateTime recvTime = QDateTime::fromTime_t(it->recvTime); 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 std::cerr << "FriendsDialog::insertChat(): " << msg.toStdString() << std::endl; @@ -571,7 +571,7 @@ void FriendsDialog::sendMsg() QString text; RsHtml::optimizeHtml(lineWidget, text); - std::wstring message = text.toStdWString(); + std::string message = text.toUtf8().constData(); #ifdef FRIENDS_DEBUG std::string msg(message.begin(), message.end()); diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index 63a7fa38c..9c37d0e1b 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -1138,7 +1138,7 @@ void MessagesDialog::insertMessages() if(it->msgflags & RS_MSG_ENCRYPTED) text = tr("Encrypted message. Right-click to decrypt it.") ; else - text = QString::fromStdWString(it->title); + text = QString::fromStdString(it->title); item[COLUMN_SUBJECT]->setText(text); item[COLUMN_SUBJECT]->setData(text + dateString, ROLE_SORT); @@ -1206,7 +1206,7 @@ void MessagesDialog::insertMessages() if (gotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) { gotInfo = true; QTextDocument doc; - doc.setHtml(QString::fromStdWString(msgInfo.msg)); + doc.setHtml(QString::fromStdString(msgInfo.msg)); item[COLUMN_CONTENT]->setText(doc.toPlainText().replace(QString("\n"), QString(" "))); } else { std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl; diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index 8a872f455..f20837476 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -284,7 +284,7 @@ void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info) { QDateTime sendTime = QDateTime::fromTime_t(info.sendTime); 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 rsid = QString::fromUtf8(info.rsid.c_str()); diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 3fff5a757..ce21026e3 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -711,7 +711,7 @@ void ChatWidget::sendChat() QString text; RsHtml::optimizeHtml(chatWidget, text); - std::wstring msg = text.toStdWString(); + std::string msg = text.toUtf8().constData(); if (msg.empty()) { // nothing to send @@ -724,7 +724,7 @@ void ChatWidget::sendChat() if (rsMsgs->sendPrivateChat(peerId, msg)) { QDateTime currentTime = QDateTime::currentDateTime(); - addChatMsg(false, name, currentTime, currentTime, QString::fromStdWString(msg), TYPE_NORMAL); + addChatMsg(false, name, currentTime, currentTime, text, TYPE_NORMAL); } chatWidget->clear(); diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 668f9c158..4066ef5cc 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -134,7 +134,7 @@ void PopupChatDialog::addIncomingChatMsg(const ChatInfo& info) if (cw) { QDateTime sendTime = QDateTime::fromTime_t(info.sendTime); 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) ; 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 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); } @@ -195,7 +195,7 @@ void PopupChatDialog::onChatChanged(int list, int type) for(it = savedOfflineChat.begin(); it != savedOfflineChat.end(); ++it) { QDateTime sendTime = QDateTime::fromTime_t(it->sendTime); 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); } diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp index cbbe24674..98d075b32 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp @@ -243,8 +243,8 @@ void ChatMsgItem::sendMessage() /* construct a message */ MessageInfo mi; - mi.title = tr("Quick Message").toStdWString(); - mi.msg = quickmsgText->toHtml().toStdWString(); + mi.title = tr("Quick Message").toUtf8().constData(); + mi.msg = quickmsgText->toHtml().toUtf8().constData(); mi.msgto.push_back(mPeerId); rsMsgs->MessageSend(mi); diff --git a/retroshare-gui/src/gui/feeds/MsgItem.cpp b/retroshare-gui/src/gui/feeds/MsgItem.cpp index 096403c87..0e23812b6 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/MsgItem.cpp @@ -127,12 +127,12 @@ void MsgItem::updateItemStatic() title += srcName; titleLabel->setText(title); - subjectLabel->setText(QString::fromStdWString(mi.title)); + subjectLabel->setText(QString::fromUtf8(mi.title.c_str())); if(mi.msgflags & RS_MSG_ENCRYPTED) msgLabel->setText(RsHtml().formatText(NULL, tr("[Encrypted message]"), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); 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::iterator it; for(it = mi.files.begin(); it != mi.files.end(); it++) diff --git a/retroshare-gui/src/gui/feeds/PeerItem.cpp b/retroshare-gui/src/gui/feeds/PeerItem.cpp index 5df812e15..feadc489a 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.cpp +++ b/retroshare-gui/src/gui/feeds/PeerItem.cpp @@ -312,8 +312,8 @@ void PeerItem::sendMessage() /* construct a message */ MessageInfo mi; - mi.title = tr("Quick Message").toStdWString(); - mi.msg = quickmsgText->toHtml().toStdWString(); + mi.title = tr("Quick Message").toUtf8().constData(); + mi.msg = quickmsgText->toHtml().toUtf8().constData(); mi.msgto.push_back(mPeerId); rsMsgs->MessageSend(mi); diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.cpp b/retroshare-gui/src/gui/feeds/SecurityItem.cpp index bc062177d..52887d8ca 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityItem.cpp @@ -407,8 +407,8 @@ void SecurityItem::sendMessage() /* construct a message */ MessageInfo mi; - mi.title = tr("Quick Message").toStdWString(); - mi.msg = quickmsgText->toHtml().toStdWString(); + mi.title = tr("Quick Message").toUtf8().constData(); + mi.msg = quickmsgText->toHtml().toUtf8().constData(); mi.msgto.push_back(mGpgId); rsMsgs->MessageSend(mi); diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index cd9758a14..a0ba87360 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -512,14 +512,14 @@ void MessageComposer::sendConnectAttemptMsg(const std::string &gpgId, const std: if ((it->msgflags & RS_MSG_USER_REQUEST) == 0) { continue; } - if (it->title == title.toStdWString()) { + if (it->title == title.toUtf8().constData()) { return; } } /* create a message */ QString msgText = tr("Hi %1,

%2 wants to be friends with you on RetroShare.

Respond now:
%3

Thanks,
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) @@ -889,8 +889,8 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/) // needed to send system flags with reply msgComposer->msgFlags = (msgInfo.msgflags & RS_MSG_SYSTEM); - msgComposer->setTitleText(QString::fromStdWString(msgInfo.title)); - msgComposer->setMsgText(QString::fromStdWString(msgInfo.msg)); + msgComposer->setTitleText(QString::fromUtf8(msgInfo.title.c_str())); + msgComposer->setMsgText(QString::fromUtf8(msgInfo.msg.c_str())); msgComposer->setFileList(msgInfo.files); // get existing groups @@ -975,7 +975,7 @@ QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo) } header += QString("
%1: %2
").arg(tr("Sent"), DateTime::formatLongDateTime(msgInfo.ts)); - header += QString("%1: %2
").arg(tr("Subject"), QString::fromStdWString(msgInfo.title)); + header += QString("%1: %2
").arg(tr("Subject"), QString::fromUtf8(msgInfo.title.c_str())); header += "
"; 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 */ - msgComposer->setTitleText(QString::fromStdWString(msgInfo.title), REPLY); - msgComposer->setQuotedMsg(QString::fromStdWString(msgInfo.msg), buildReplyHeader(msgInfo)); + msgComposer->setTitleText(QString::fromUtf8(msgInfo.title.c_str()), REPLY); + msgComposer->setQuotedMsg(QString::fromUtf8(msgInfo.msg.c_str()), buildReplyHeader(msgInfo)); msgComposer->addRecipient(MessageComposer::TO, msgInfo.srcId, false); @@ -1078,8 +1078,8 @@ MessageComposer *MessageComposer::forwardMsg(const std::string &msgId) /* fill it in */ - msgComposer->setTitleText(QString::fromStdWString(msgInfo.title), FORWARD); - msgComposer->setQuotedMsg(QString::fromStdWString(msgInfo.msg), buildReplyHeader(msgInfo)); + msgComposer->setTitleText(QString::fromUtf8(msgInfo.title.c_str()), FORWARD); + msgComposer->setQuotedMsg(QString::fromUtf8(msgInfo.msg.c_str()), buildReplyHeader(msgInfo)); std::list& files_info = msgInfo.files; @@ -1151,13 +1151,13 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox) /* construct a message */ 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 mi.msgflags = msgFlags; QString text; RsHtml::optimizeHtml(ui.msgText, text); - mi.msg = text.toStdWString(); + mi.msg = text.toUtf8().constData(); /* check for existing title */ if (bDraftbox == false && mi.title.empty()) { diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index 6e646a382..21e1b6af1 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -554,9 +554,9 @@ void MessageWidget::fill(const std::string &msgId) 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.filesText->setText(QString("(%1 %2)").arg(msgInfo.count).arg(msgInfo.count == 1 ? tr("File") : tr("Files")));