Fixed start of chat with right or double click on a friend item (not location) in friend list.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7633 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-10-25 12:26:09 +00:00
parent 26f93c2a55
commit a3af37c7e4
4 changed files with 75 additions and 48 deletions

View file

@ -206,22 +206,22 @@ void ChatDialog::init(const RsPeerId &peerId, const QString &title)
/*static*/ void ChatDialog::chatFriend(const RsPeerId &peerId, const bool forceFocus) /*static*/ void ChatDialog::chatFriend(const RsPeerId &peerId, const bool forceFocus)
{ {
if (peerId.isNull()){ if (peerId.isNull()){
return; return;
} }
RsGxsId distant_chat_gxs_id ; RsGxsId distant_chat_gxs_id ;
uint32_t distant_peer_status ; uint32_t distant_peer_status ;
if(rsMsgs->getDistantChatStatus(peerId,distant_chat_gxs_id,distant_peer_status)) if(rsMsgs->getDistantChatStatus(peerId,distant_chat_gxs_id,distant_peer_status))
{ {
getChat(peerId, forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN ); // use own flags getChat(peerId, forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN ); // use own flags
return ; return ;
} }
ChatLobbyId lid; ChatLobbyId lid;
if (rsMsgs->isLobbyId(peerId, lid)) { if (rsMsgs->isLobbyId(peerId, lid)) {
getChat(peerId, (forceFocus ? (RS_CHAT_OPEN | RS_CHAT_FOCUS) : RS_CHAT_OPEN)); getChat(peerId, (forceFocus ? (RS_CHAT_OPEN | RS_CHAT_FOCUS) : RS_CHAT_OPEN));
} }
RsPeerDetails detail; RsPeerDetails detail;
@ -229,37 +229,55 @@ void ChatDialog::init(const RsPeerId &peerId, const QString &title)
return; return;
if (detail.isOnlyGPGdetail) { if (detail.isOnlyGPGdetail) {
std::list<RsPeerId> onlineIds; /* Should not happen */
//chatFriend(detail.gpg_id, forceFocus);
//let's get the ssl child details return;
std::list<RsPeerId> sslIds;
rsPeers->getAssociatedSSLIds(detail.gpg_id, sslIds);
if (sslIds.size() == 1) {
// chat with the one ssl id (online or offline)
getChat(sslIds.front(), forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN);
return;
}
// more than one ssl ids available, check for online
for (std::list<RsPeerId>::iterator it = sslIds.begin(); it != sslIds.end(); ++it) {
if (rsPeers->isOnline(*it)) {
onlineIds.push_back(*it);
}
}
if (onlineIds.size() == 1) {
// chat with the online ssl id
getChat(onlineIds.front(), forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN);
return;
}
// more than one ssl ids online or all offline
QMessageBox mb(QMessageBox::Warning, "RetroShare", tr("Your friend has more than one locations.\nPlease choose one of it to chat with."), QMessageBox::Ok);
mb.exec();
} else {
getChat(peerId, forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN);
} }
getChat(peerId, forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN);
}
/*static*/ void ChatDialog::chatFriend(const RsPgpId &gpgId, const bool forceFocus)
{
if (gpgId.isNull()){
return;
}
RsPeerDetails detail;
if (!rsPeers->getGPGDetails(gpgId, detail))
return;
if (!detail.isOnlyGPGdetail) {
return;
}
//let's get the ssl child details
std::list<RsPeerId> sslIds;
rsPeers->getAssociatedSSLIds(detail.gpg_id, sslIds);
if (sslIds.size() == 1) {
// chat with the one ssl id (online or offline)
chatFriend(sslIds.front(), forceFocus);
return;
}
// more than one ssl ids available, check for online
std::list<RsPeerId> onlineIds;
for (std::list<RsPeerId>::iterator it = sslIds.begin(); it != sslIds.end(); ++it) {
if (rsPeers->isOnline(*it)) {
onlineIds.push_back(*it);
}
}
if (onlineIds.size() == 1) {
// chat with the online ssl id
chatFriend(onlineIds.front(), forceFocus);
return;
}
// more than one ssl ids online or all offline
QMessageBox mb(QMessageBox::Warning, "RetroShare", tr("Your friend has more than one locations.\nPlease choose one of it to chat with."), QMessageBox::Ok);
mb.exec();
} }
void ChatDialog::addToParent(QWidget *newParent) void ChatDialog::addToParent(QWidget *newParent)

View file

@ -34,11 +34,12 @@ class ChatDialog : public QWidget
Q_OBJECT Q_OBJECT
public: public:
static ChatDialog *getExistingChat(const RsPeerId &peerId); static ChatDialog *getExistingChat(const RsPeerId &peerId);
static ChatDialog *getChat(const RsPeerId &peerId, uint chatflags); static ChatDialog *getChat(const RsPeerId &peerId, uint chatflags);
static void cleanupChat(); static void cleanupChat();
static void chatFriend(const RsPeerId &peerId, bool forceFocus = true); static void chatFriend(const RsPeerId &peerId, bool forceFocus = true);
static void closeChat(const RsPeerId &peerId); static void chatFriend(const RsPgpId &gpgId, bool forceFocus = true);
static void closeChat(const RsPeerId &peerId);
static void chatChanged(int list, int type); static void chatChanged(int list, int type);
virtual void showDialog(uint /*chatflags*/) {} virtual void showDialog(uint /*chatflags*/) {}
@ -50,7 +51,7 @@ public:
void addToParent(QWidget *newParent); void addToParent(QWidget *newParent);
void removeFromParent(QWidget *oldParent); void removeFromParent(QWidget *oldParent);
RsPeerId getPeerId() { return peerId; } RsPeerId getPeerId() { return peerId; }
QString getTitle(); QString getTitle();
bool hasNewMessages(); bool hasNewMessages();
bool isTyping(); bool isTyping();
@ -80,14 +81,14 @@ protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
virtual bool canClose() { return true; } virtual bool canClose() { return true; }
virtual QString getPeerName(const RsPeerId &sslid) const ; // can be overloaded for chat dialogs that have specific peers virtual QString getPeerName(const RsPeerId &sslid) const ; // can be overloaded for chat dialogs that have specific peers
virtual void init(const RsPeerId &peerId, const QString &title); virtual void init(const RsPeerId &peerId, const QString &title);
virtual void onChatChanged(int /*list*/, int /*type*/) {} virtual void onChatChanged(int /*list*/, int /*type*/) {}
virtual void addIncomingChatMsg(const ChatInfo& info) = 0; virtual void addIncomingChatMsg(const ChatInfo& info) = 0;
RsPeerId peerId; RsPeerId peerId;
}; };
#endif // CHATDIALOG_H #endif // CHATDIALOG_H

View file

@ -1278,14 +1278,22 @@ void FriendList::chatfriendproxy()
* *
* @param pPeer the gpg or ssl QTreeWidgetItem to chat with * @param pPeer the gpg or ssl QTreeWidgetItem to chat with
*/ */
void FriendList::chatfriend(QTreeWidgetItem *pPeer) void FriendList::chatfriend(QTreeWidgetItem *item)
{ {
if (pPeer == NULL) { if (item == NULL) {
return; return;
} }
std::string id = getRsId(pPeer); switch (item->type()) {
ChatDialog::chatFriend(RsPeerId(id)); case TYPE_GROUP:
break;
case TYPE_GPG:
ChatDialog::chatFriend(RsPgpId(getRsId(item)));
break;
case TYPE_SSL:
ChatDialog::chatFriend(RsPeerId(getRsId(item)));
break;
}
} }
void FriendList::addFriend() void FriendList::addFriend()

View file

@ -138,7 +138,7 @@ private slots:
void connectfriend(); void connectfriend();
void configurefriend(); void configurefriend();
void chatfriend(QTreeWidgetItem *); void chatfriend(QTreeWidgetItem *item);
void chatfriendproxy(); void chatfriendproxy();
//void copyLink(); //void copyLink();
void copyFullCertificate(); void copyFullCertificate();