mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -05:00
removed member gxs_id from ChatId class, because ChatId now uses tunnel ids stored in distant_chat_id for distant chat.
reverted naming confusion in in libresapi ChatHandler and fixed author of distant chat messages (distant chat is still unfinished)
This commit is contained in:
parent
0ac76d621e
commit
7cd880e1e4
@ -81,8 +81,8 @@ StreamBase& operator << (StreamBase& left, ChatHandler::Lobby& l)
|
|||||||
<< makeKeyValueReference("subscribed", l.subscribed)
|
<< makeKeyValueReference("subscribed", l.subscribed)
|
||||||
<< makeKeyValueReference("auto_subscribe", l.auto_subscribe)
|
<< makeKeyValueReference("auto_subscribe", l.auto_subscribe)
|
||||||
<< makeKeyValueReference("is_private", l.is_private)
|
<< 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;
|
return left;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,8 +167,8 @@ void ChatHandler::tick()
|
|||||||
l.subscribed = true;
|
l.subscribed = true;
|
||||||
l.auto_subscribe = info.lobby_flags & RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE;
|
l.auto_subscribe = info.lobby_flags & RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE;
|
||||||
l.is_private = !(info.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC);
|
l.is_private = !(info.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC);
|
||||||
l.distant_chat_id.clear() ;
|
|
||||||
l.is_broadcast = false;
|
l.is_broadcast = false;
|
||||||
|
l.gxs_id = info.gxs_id;
|
||||||
lobbies.push_back(l);
|
lobbies.push_back(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,8 +200,8 @@ void ChatHandler::tick()
|
|||||||
l.subscribed = false;
|
l.subscribed = false;
|
||||||
l.auto_subscribe = info.lobby_flags & RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE;
|
l.auto_subscribe = info.lobby_flags & RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE;
|
||||||
l.is_private = !(info.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC);
|
l.is_private = !(info.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC);
|
||||||
l.distant_chat_id.clear();
|
|
||||||
l.is_broadcast = false;
|
l.is_broadcast = false;
|
||||||
|
l.gxs_id = RsGxsId();
|
||||||
lobbies.push_back(l);
|
lobbies.push_back(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,10 +234,10 @@ void ChatHandler::tick()
|
|||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
||||||
author_id = dcpinfo.to_id.toStdString();
|
|
||||||
RsIdentityDetails details;
|
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;
|
author_name = details.mNickname;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -302,9 +302,9 @@ void ChatHandler::tick()
|
|||||||
DistantChatPeerInfo dcpinfo ;
|
DistantChatPeerInfo dcpinfo ;
|
||||||
|
|
||||||
if(!gxs_id_failed && rsMsgs->getDistantChatStatus(msg.chat_id.toDistantChatId(),dcpinfo)
|
if(!gxs_id_failed && rsMsgs->getDistantChatStatus(msg.chat_id.toDistantChatId(),dcpinfo)
|
||||||
&& mRsIdentity->getIdDetails(dcpinfo.to_id, details))
|
&& 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;
|
info.remote_author_name = details.mNickname;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -66,7 +66,7 @@ public:
|
|||||||
bool is_private;
|
bool is_private;
|
||||||
bool is_broadcast;
|
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
|
bool operator==(const Lobby& l) const
|
||||||
{
|
{
|
||||||
@ -76,8 +76,8 @@ public:
|
|||||||
&& subscribed == l.subscribed
|
&& subscribed == l.subscribed
|
||||||
&& auto_subscribe == l.auto_subscribe
|
&& auto_subscribe == l.auto_subscribe
|
||||||
&& is_private == l.is_private
|
&& is_private == l.is_private
|
||||||
&& id == l.id
|
&& is_broadcast == l.is_broadcast
|
||||||
&& is_broadcast == l.is_broadcast;
|
&& gxs_id == l.gxs_id;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -279,7 +279,6 @@ class ChatId
|
|||||||
public:
|
public:
|
||||||
ChatId();
|
ChatId();
|
||||||
explicit ChatId(RsPeerId id);
|
explicit ChatId(RsPeerId id);
|
||||||
explicit ChatId(RsGxsId id);
|
|
||||||
explicit ChatId(ChatLobbyId id);
|
explicit ChatId(ChatLobbyId id);
|
||||||
explicit ChatId(DistantChatPeerId id);
|
explicit ChatId(DistantChatPeerId id);
|
||||||
explicit ChatId(std::string str);
|
explicit ChatId(std::string str);
|
||||||
@ -295,7 +294,6 @@ public:
|
|||||||
bool isPeerId() const;
|
bool isPeerId() const;
|
||||||
bool isDistantChatId() const;
|
bool isDistantChatId() const;
|
||||||
bool isLobbyId() const;
|
bool isLobbyId() const;
|
||||||
bool isGxsId() const;
|
|
||||||
bool isBroadcast() const;
|
bool isBroadcast() const;
|
||||||
|
|
||||||
RsPeerId toPeerId() const;
|
RsPeerId toPeerId() const;
|
||||||
@ -312,7 +310,6 @@ private:
|
|||||||
TYPE_PRIVATE, // private chat with directly connected friend, peer_id is valid
|
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_PRIVATE_DISTANT, // private chat with distant peer, gxs_id is valid
|
||||||
TYPE_LOBBY, // chat lobby id, lobby_id is valid
|
TYPE_LOBBY, // chat lobby id, lobby_id is valid
|
||||||
TYPE_GXS_ID, //
|
|
||||||
TYPE_BROADCAST // message to/from all connected peers
|
TYPE_BROADCAST // message to/from all connected peers
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -320,7 +317,6 @@ private:
|
|||||||
RsPeerId peer_id;
|
RsPeerId peer_id;
|
||||||
DistantChatPeerId distant_chat_id;
|
DistantChatPeerId distant_chat_id;
|
||||||
ChatLobbyId lobby_id;
|
ChatLobbyId lobby_id;
|
||||||
RsGxsId gxs_id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChatMessage
|
class ChatMessage
|
||||||
|
@ -58,13 +58,6 @@ ChatId::ChatId():
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatId::ChatId(RsGxsId id):
|
|
||||||
lobby_id(0)
|
|
||||||
{
|
|
||||||
type = TYPE_GXS_ID;
|
|
||||||
gxs_id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatId::ChatId(RsPeerId id):
|
ChatId::ChatId(RsPeerId id):
|
||||||
lobby_id(0)
|
lobby_id(0)
|
||||||
{
|
{
|
||||||
@ -244,10 +237,6 @@ bool ChatId::isLobbyId() const
|
|||||||
{
|
{
|
||||||
return type == TYPE_LOBBY;
|
return type == TYPE_LOBBY;
|
||||||
}
|
}
|
||||||
bool ChatId::isGxsId() const
|
|
||||||
{
|
|
||||||
return type == TYPE_GXS_ID;
|
|
||||||
}
|
|
||||||
bool ChatId::isBroadcast() const
|
bool ChatId::isBroadcast() const
|
||||||
{
|
{
|
||||||
return type == TYPE_BROADCAST;
|
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
|
DistantChatPeerId ChatId::toDistantChatId() const
|
||||||
{
|
{
|
||||||
if(type == TYPE_PRIVATE_DISTANT)
|
if(type == TYPE_PRIVATE_DISTANT)
|
||||||
|
@ -124,6 +124,7 @@ void AvatarWidget::setFrameType(FrameType type)
|
|||||||
void AvatarWidget::setId(const ChatId &id)
|
void AvatarWidget::setId(const ChatId &id)
|
||||||
{
|
{
|
||||||
mId = id;
|
mId = id;
|
||||||
|
mGxsId.clear();
|
||||||
|
|
||||||
setPixmap(QPixmap());
|
setPixmap(QPixmap());
|
||||||
|
|
||||||
@ -131,12 +132,25 @@ void AvatarWidget::setId(const ChatId &id)
|
|||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mId.isGxsId())
|
refreshAvatarImage();
|
||||||
std::cerr << "(EE) AvatarWidget should not be set to a GXS id." << std::endl;
|
refreshStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AvatarWidget::setGxsId(const RsGxsId &id)
|
||||||
|
{
|
||||||
|
mId = ChatId();
|
||||||
|
mGxsId = id;
|
||||||
|
|
||||||
|
setPixmap(QPixmap());
|
||||||
|
|
||||||
|
if (id.isNull()) {
|
||||||
|
setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
refreshAvatarImage();
|
refreshAvatarImage();
|
||||||
refreshStatus();
|
refreshStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarWidget::setOwnId()
|
void AvatarWidget::setOwnId()
|
||||||
{
|
{
|
||||||
mFlag.isOwnId = true;
|
mFlag.isOwnId = true;
|
||||||
@ -242,6 +256,14 @@ void AvatarWidget::updateAvatar(const QString &peerId)
|
|||||||
}
|
}
|
||||||
void AvatarWidget::refreshAvatarImage()
|
void AvatarWidget::refreshAvatarImage()
|
||||||
{
|
{
|
||||||
|
if (mGxsId.isNull()==false)
|
||||||
|
{
|
||||||
|
QPixmap avatar;
|
||||||
|
|
||||||
|
AvatarDefs::getAvatarFromGxsId(mGxsId, avatar, defaultAvatar);
|
||||||
|
setPixmap(avatar);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mId.isNotSet())
|
if (mId.isNotSet())
|
||||||
{
|
{
|
||||||
QPixmap avatar(defaultAvatar);
|
QPixmap avatar(defaultAvatar);
|
||||||
@ -262,14 +284,6 @@ void AvatarWidget::refreshAvatarImage()
|
|||||||
setPixmap(avatar);
|
setPixmap(avatar);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// else if (mId.isGxsId())
|
|
||||||
// {
|
|
||||||
// QPixmap avatar;
|
|
||||||
//
|
|
||||||
// AvatarDefs::getAvatarFromGxsId(mId.toGxsId(), avatar, defaultAvatar);
|
|
||||||
// setPixmap(avatar);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
else if (mId.isDistantChatId())
|
else if (mId.isDistantChatId())
|
||||||
{
|
{
|
||||||
QPixmap avatar;
|
QPixmap avatar;
|
||||||
|
@ -50,6 +50,7 @@ public:
|
|||||||
QString frameState();
|
QString frameState();
|
||||||
void setFrameType(FrameType type);
|
void setFrameType(FrameType type);
|
||||||
void setId(const ChatId& id) ;
|
void setId(const ChatId& id) ;
|
||||||
|
void setGxsId(const RsGxsId& id) ;
|
||||||
void setOwnId();
|
void setOwnId();
|
||||||
void setDefaultAvatar(const QString &avatar_file_name);
|
void setDefaultAvatar(const QString &avatar_file_name);
|
||||||
|
|
||||||
@ -70,6 +71,7 @@ private:
|
|||||||
Ui::AvatarWidget *ui;
|
Ui::AvatarWidget *ui;
|
||||||
|
|
||||||
ChatId mId;
|
ChatId mId;
|
||||||
|
RsGxsId mGxsId;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool isOwnId : 1;
|
bool isOwnId : 1;
|
||||||
|
@ -88,11 +88,9 @@ void MsgItem::updateItemStatic()
|
|||||||
/* get peer Id */
|
/* get peer Id */
|
||||||
|
|
||||||
if(mi.msgflags & RS_MSG_SIGNED)
|
if(mi.msgflags & RS_MSG_SIGNED)
|
||||||
mPeerId = ChatId(mi.rsgxsid_srcId);
|
avatar->setGxsId(mi.rsgxsid_srcId);
|
||||||
else
|
else
|
||||||
mPeerId = ChatId(mi.rspeerid_srcId);
|
avatar->setId(ChatId(mi.rspeerid_srcId));
|
||||||
|
|
||||||
avatar->setId(mPeerId);
|
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
QString srcName;
|
QString srcName;
|
||||||
|
@ -64,7 +64,6 @@ private:
|
|||||||
FeedHolder *mParent;
|
FeedHolder *mParent;
|
||||||
uint32_t mFeedId;
|
uint32_t mFeedId;
|
||||||
|
|
||||||
ChatId mPeerId;
|
|
||||||
std::string mMsgId;
|
std::string mMsgId;
|
||||||
QString mMsg;
|
QString mMsg;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ ChatLobbyToaster::ChatLobbyToaster(const ChatLobbyId &lobby_id, const RsGxsId &s
|
|||||||
if(!rsIdentity->getIdDetails(sender_id, idd))
|
if(!rsIdentity->getIdDetails(sender_id, idd))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ui.avatarWidget->setId(ChatId(sender_id));
|
ui.avatarWidget->setGxsId(sender_id);
|
||||||
|
|
||||||
QString lobbyName = RsHtml::plainText(idd.mNickname);
|
QString lobbyName = RsHtml::plainText(idd.mNickname);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user