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:
electron128 2015-12-05 17:00:57 +01:00
parent 0ac76d621e
commit 7cd880e1e4
9 changed files with 43 additions and 55 deletions

View File

@ -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

View File

@ -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;
}
};

View File

@ -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

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -64,7 +64,6 @@ private:
FeedHolder *mParent;
uint32_t mFeedId;
ChatId mPeerId;
std::string mMsgId;
QString mMsg;

View File

@ -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);