diff --git a/libresapi/src/api/ChatHandler.cpp b/libresapi/src/api/ChatHandler.cpp index a99759990..b9f7bda4b 100644 --- a/libresapi/src/api/ChatHandler.cpp +++ b/libresapi/src/api/ChatHandler.cpp @@ -81,8 +81,8 @@ StreamBase& operator << (StreamBase& left, ChatHandler::Lobby& l) << makeKeyValueReference("subscribed", l.subscribed) << makeKeyValueReference("auto_subscribe", l.auto_subscribe) << makeKeyValueReference("is_private", l.is_private) - << makeKeyValueReference("distant_chat_id", l.distant_chat_id) - << makeKeyValueReference("is_broadcast", l.is_broadcast); + << makeKeyValueReference("is_broadcast", l.is_broadcast) + << makeKeyValueReference("gxs_id", l.gxs_id); return left; } @@ -167,8 +167,8 @@ void ChatHandler::tick() l.subscribed = true; l.auto_subscribe = info.lobby_flags & RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE; l.is_private = !(info.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC); - l.distant_chat_id.clear() ; l.is_broadcast = false; + l.gxs_id = info.gxs_id; lobbies.push_back(l); } } @@ -200,8 +200,8 @@ void ChatHandler::tick() l.subscribed = false; l.auto_subscribe = info.lobby_flags & RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE; l.is_private = !(info.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC); - l.distant_chat_id.clear(); l.is_broadcast = false; + l.gxs_id = RsGxsId(); lobbies.push_back(l); } } @@ -233,11 +233,11 @@ void ChatHandler::tick() std::cerr << "(EE) cannot get info for distant chat peer " << msg.chat_id.toDistantChatId() << std::endl; continue ; } - - author_id = dcpinfo.to_id.toStdString(); + RsIdentityDetails details; - if(!gxs_id_failed && mRsIdentity->getIdDetails(dcpinfo.to_id, details)) + if(!gxs_id_failed && mRsIdentity->getIdDetails(msg.incoming? dcpinfo.to_id: dcpinfo.own_id, details)) { + author_id = details.mId.toStdString(); author_name = details.mNickname; } else @@ -301,10 +301,10 @@ void ChatHandler::tick() RsIdentityDetails details; DistantChatPeerInfo dcpinfo ; - if(!gxs_id_failed && rsMsgs->getDistantChatStatus(msg.chat_id.toDistantChatId(),dcpinfo) - && mRsIdentity->getIdDetails(dcpinfo.to_id, details)) + if(!gxs_id_failed && rsMsgs->getDistantChatStatus(msg.chat_id.toDistantChatId(),dcpinfo) + && mRsIdentity->getIdDetails(msg.incoming? dcpinfo.to_id: dcpinfo.own_id, details)) { - info.remote_author_id = msg.chat_id.toGxsId().toStdString(); + info.remote_author_id = details.mId.toStdString(); info.remote_author_name = details.mNickname; } else diff --git a/libresapi/src/api/ChatHandler.h b/libresapi/src/api/ChatHandler.h index 1d4ed221f..bb15cf2f1 100644 --- a/libresapi/src/api/ChatHandler.h +++ b/libresapi/src/api/ChatHandler.h @@ -66,7 +66,7 @@ public: bool is_private; bool is_broadcast; - RsGxsId distant_chat_id;// for subscribed lobbies: the id we use to write messages + RsGxsId gxs_id;// for subscribed lobbies: the id we use to write messages bool operator==(const Lobby& l) const { @@ -76,8 +76,8 @@ public: && subscribed == l.subscribed && auto_subscribe == l.auto_subscribe && is_private == l.is_private - && id == l.id - && is_broadcast == l.is_broadcast; + && is_broadcast == l.is_broadcast + && gxs_id == l.gxs_id; } }; diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index 4eadb79d1..edeb0a66e 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -279,7 +279,6 @@ class ChatId public: ChatId(); explicit ChatId(RsPeerId id); - explicit ChatId(RsGxsId id); explicit ChatId(ChatLobbyId id); explicit ChatId(DistantChatPeerId id); explicit ChatId(std::string str); @@ -295,7 +294,6 @@ public: bool isPeerId() const; bool isDistantChatId() const; bool isLobbyId() const; - bool isGxsId() const; bool isBroadcast() const; RsPeerId toPeerId() const; @@ -312,7 +310,6 @@ private: TYPE_PRIVATE, // private chat with directly connected friend, peer_id is valid TYPE_PRIVATE_DISTANT, // private chat with distant peer, gxs_id is valid TYPE_LOBBY, // chat lobby id, lobby_id is valid - TYPE_GXS_ID, // TYPE_BROADCAST // message to/from all connected peers }; @@ -320,7 +317,6 @@ private: RsPeerId peer_id; DistantChatPeerId distant_chat_id; ChatLobbyId lobby_id; - RsGxsId gxs_id; }; class ChatMessage diff --git a/libretroshare/src/rsserver/p3msgs.cc b/libretroshare/src/rsserver/p3msgs.cc index b9690c95d..e4986467e 100644 --- a/libretroshare/src/rsserver/p3msgs.cc +++ b/libretroshare/src/rsserver/p3msgs.cc @@ -58,13 +58,6 @@ ChatId::ChatId(): } -ChatId::ChatId(RsGxsId id): - lobby_id(0) -{ - type = TYPE_GXS_ID; - gxs_id = id; -} - ChatId::ChatId(RsPeerId id): lobby_id(0) { @@ -244,10 +237,6 @@ bool ChatId::isLobbyId() const { return type == TYPE_LOBBY; } -bool ChatId::isGxsId() const -{ - return type == TYPE_GXS_ID; -} bool ChatId::isBroadcast() const { return type == TYPE_BROADCAST; @@ -263,16 +252,6 @@ RsPeerId ChatId::toPeerId() const } } -RsGxsId ChatId::toGxsId() const -{ - if(type == TYPE_GXS_ID) - return gxs_id; - else - { - std::cerr << "ChatId Warning: conversation to gxs_id requested, but type is different. Current value=\"" << toStdString() << "\"" << std::endl; - return RsGxsId(); - } -} DistantChatPeerId ChatId::toDistantChatId() const { if(type == TYPE_PRIVATE_DISTANT) diff --git a/retroshare-gui/src/gui/common/AvatarWidget.cpp b/retroshare-gui/src/gui/common/AvatarWidget.cpp index 2ed494184..71147d7b6 100644 --- a/retroshare-gui/src/gui/common/AvatarWidget.cpp +++ b/retroshare-gui/src/gui/common/AvatarWidget.cpp @@ -124,19 +124,33 @@ void AvatarWidget::setFrameType(FrameType type) void AvatarWidget::setId(const ChatId &id) { mId = id; + mGxsId.clear(); setPixmap(QPixmap()); if (id.isNotSet()) { setEnabled(false); } - - if(mId.isGxsId()) - std::cerr << "(EE) AvatarWidget should not be set to a GXS id." << std::endl; refreshAvatarImage(); refreshStatus(); } + +void AvatarWidget::setGxsId(const RsGxsId &id) +{ + mId = ChatId(); + mGxsId = id; + + setPixmap(QPixmap()); + + if (id.isNull()) { + setEnabled(false); + } + + refreshAvatarImage(); + refreshStatus(); +} + void AvatarWidget::setOwnId() { mFlag.isOwnId = true; @@ -242,6 +256,14 @@ void AvatarWidget::updateAvatar(const QString &peerId) } void AvatarWidget::refreshAvatarImage() { + if (mGxsId.isNull()==false) + { + QPixmap avatar; + + AvatarDefs::getAvatarFromGxsId(mGxsId, avatar, defaultAvatar); + setPixmap(avatar); + return; + } if (mId.isNotSet()) { QPixmap avatar(defaultAvatar); @@ -262,14 +284,6 @@ void AvatarWidget::refreshAvatarImage() setPixmap(avatar); return; } -// else if (mId.isGxsId()) -// { -// QPixmap avatar; -// -// AvatarDefs::getAvatarFromGxsId(mId.toGxsId(), avatar, defaultAvatar); -// setPixmap(avatar); -// return; -// } else if (mId.isDistantChatId()) { QPixmap avatar; diff --git a/retroshare-gui/src/gui/common/AvatarWidget.h b/retroshare-gui/src/gui/common/AvatarWidget.h index 1c140f469..de15ef066 100644 --- a/retroshare-gui/src/gui/common/AvatarWidget.h +++ b/retroshare-gui/src/gui/common/AvatarWidget.h @@ -50,6 +50,7 @@ public: QString frameState(); void setFrameType(FrameType type); void setId(const ChatId& id) ; + void setGxsId(const RsGxsId& id) ; void setOwnId(); void setDefaultAvatar(const QString &avatar_file_name); @@ -70,6 +71,7 @@ private: Ui::AvatarWidget *ui; ChatId mId; + RsGxsId mGxsId; struct { bool isOwnId : 1; diff --git a/retroshare-gui/src/gui/feeds/MsgItem.cpp b/retroshare-gui/src/gui/feeds/MsgItem.cpp index cb44de952..93b9d3e8c 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/MsgItem.cpp @@ -88,11 +88,9 @@ void MsgItem::updateItemStatic() /* get peer Id */ if(mi.msgflags & RS_MSG_SIGNED) - mPeerId = ChatId(mi.rsgxsid_srcId); + avatar->setGxsId(mi.rsgxsid_srcId); else - mPeerId = ChatId(mi.rspeerid_srcId); - - avatar->setId(mPeerId); + avatar->setId(ChatId(mi.rspeerid_srcId)); QString title; QString srcName; diff --git a/retroshare-gui/src/gui/feeds/MsgItem.h b/retroshare-gui/src/gui/feeds/MsgItem.h index dd82dfb50..9b036260e 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.h +++ b/retroshare-gui/src/gui/feeds/MsgItem.h @@ -64,7 +64,6 @@ private: FeedHolder *mParent; uint32_t mFeedId; - ChatId mPeerId; std::string mMsgId; QString mMsg; diff --git a/retroshare-gui/src/gui/toaster/ChatLobbyToaster.cpp b/retroshare-gui/src/gui/toaster/ChatLobbyToaster.cpp index 882004975..25d5c2d2a 100644 --- a/retroshare-gui/src/gui/toaster/ChatLobbyToaster.cpp +++ b/retroshare-gui/src/gui/toaster/ChatLobbyToaster.cpp @@ -45,7 +45,7 @@ ChatLobbyToaster::ChatLobbyToaster(const ChatLobbyId &lobby_id, const RsGxsId &s if(!rsIdentity->getIdDetails(sender_id, idd)) return; - ui.avatarWidget->setId(ChatId(sender_id)); + ui.avatarWidget->setGxsId(sender_id); QString lobbyName = RsHtml::plainText(idd.mNickname);