From 9d2b6faf9cab766347f966687643019ca457cc73 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 26 Mar 2015 21:20:57 +0000 Subject: [PATCH] fixed bug with default chat lobby identity causing settings to show an empty list. Also fixed up GxsIdChooser git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8081 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- TODO.txt | 1 + libretroshare/src/chat/distributedchat.cc | 24 +++++++++++++++++--- libretroshare/src/chat/distributedchat.h | 1 + retroshare-gui/src/gui/gxs/GxsIdChooser.cpp | 5 ++-- retroshare-gui/src/gui/gxs/GxsIdChooser.h | 2 +- retroshare-gui/src/gui/settings/ChatPage.cpp | 6 +++-- 6 files changed, 31 insertions(+), 8 deletions(-) diff --git a/TODO.txt b/TODO.txt index e1f523516..6ad2c02be 100644 --- a/TODO.txt +++ b/TODO.txt @@ -66,6 +66,7 @@ H [ ] Distant chat should work with shared identities [X] Distant chat fails (tunnel bullet never gets green) when re-openning a distant chat window after closing a tunnel [X] Distant chat fails (chat window never appears) when re-openning a distant chat window after closing a tunnel [X] You should not be enabled to distant-chat yourself! + [ ] Nickname completion is broken. It only works with @ Identities: [X] "Owned by you" => "Owned by node [nodename]" diff --git a/libretroshare/src/chat/distributedchat.cc b/libretroshare/src/chat/distributedchat.cc index 09e9c0a33..e83e566b5 100644 --- a/libretroshare/src/chat/distributedchat.cc +++ b/libretroshare/src/chat/distributedchat.cc @@ -1565,9 +1565,27 @@ bool DistributedChatService::setDefaultIdentityForChatLobby(const RsGxsId& nick) } bool DistributedChatService::getDefaultIdentityForChatLobby(RsGxsId& nick) { - RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/ - nick = _default_identity ; - return true ; + RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/ + + nick = locked_getDefaultIdentity() ; + + return true ; +} + +RsGxsId DistributedChatService::locked_getDefaultIdentity() +{ + if(_default_identity.isNull() && rsIdentity!=NULL) + { + std::list own_ids ; + rsIdentity->getOwnIds(own_ids) ; + + if(!own_ids.empty()) + { + _default_identity = own_ids.front() ; + triggerConfigSave(); + } + } + return _default_identity ; } bool DistributedChatService::getIdentityForChatLobby(const ChatLobbyId& lobby_id,RsGxsId& nick) { diff --git a/libretroshare/src/chat/distributedchat.h b/libretroshare/src/chat/distributedchat.h index 526e1e65c..7c85132f1 100644 --- a/libretroshare/src/chat/distributedchat.h +++ b/libretroshare/src/chat/distributedchat.h @@ -130,6 +130,7 @@ class DistributedChatService bool locked_initLobbyBouncableObject(const ChatLobbyId& id,RsChatLobbyBouncingObject&) ; void locked_printDebugInfo() const ; + RsGxsId locked_getDefaultIdentity(); static ChatLobbyVirtualPeerId makeVirtualPeerId(ChatLobbyId) ; static uint64_t makeConnexionChallengeCode(const RsPeerId& peer_id,ChatLobbyId lobby_id,ChatLobbyMsgId msg_id) ; diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp index 9dbc2c46b..e32f082f9 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp @@ -306,9 +306,10 @@ void GxsIdChooser::indexActivated(int index) } } -void GxsIdChooser::updateDisplay(bool complete) +void GxsIdChooser::updateDisplay(bool reset) { - Q_UNUSED(complete) + if(reset) + mFirstLoad = true ; /* Update identity list */ loadPrivateIds(); diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.h b/retroshare-gui/src/gui/gxs/GxsIdChooser.h index adf52c05c..75cd3f70f 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdChooser.h +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.h @@ -58,7 +58,7 @@ public: protected: virtual void showEvent(QShowEvent *event); - void updateDisplay(bool complete); + void updateDisplay(bool reset); private slots: void fillDisplay(bool complete); diff --git a/retroshare-gui/src/gui/settings/ChatPage.cpp b/retroshare-gui/src/gui/settings/ChatPage.cpp index cc560a1ce..e7a1b5d33 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.cpp +++ b/retroshare-gui/src/gui/settings/ChatPage.cpp @@ -272,8 +272,10 @@ ChatPage::load() RsGxsId gxs_id ; rsMsgs->getDefaultIdentityForChatLobby(gxs_id) ; - ui.chatLobbyIdentity_IC->loadIds(IDCHOOSER_ID_REQUIRED, gxs_id); - ui.chatLobbyIdentity_IC->setChosenId(gxs_id); + ui.chatLobbyIdentity_IC->setFlags(IDCHOOSER_ID_REQUIRED) ; + + if(!gxs_id.isNull()) + ui.chatLobbyIdentity_IC->setChosenId(gxs_id); uint chatflags = Settings->getChatFlags();