From c9d5c7b3cbd30f5cbee141603b284c3bd76baf98 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 17 Apr 2015 21:36:22 +0000 Subject: [PATCH] turned some std::list into std::set, as it automatically prevents duplicates git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8138 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/chat/distributedchat.cc | 4 +- libretroshare/src/chat/distributedchat.h | 2 +- libretroshare/src/ft/ftcontroller.cc | 10 +- libretroshare/src/gxs/rsgenexchange.cc | 2 +- libretroshare/src/gxs/rsgenexchange.h | 2 +- libretroshare/src/gxs/rsgxsnetservice.cc | 10 +- libretroshare/src/gxs/rsgxsnetservice.h | 4 +- libretroshare/src/gxs/rsnxs.h | 2 +- libretroshare/src/pgp/pgphandler.cc | 6 +- libretroshare/src/pgp/pgphandler.h | 2 +- libretroshare/src/pqi/authgpg.cc | 12 +- libretroshare/src/pqi/authgpg.h | 2 +- libretroshare/src/pqi/p3peermgr.cc | 4 +- libretroshare/src/retroshare/rsgxschannels.h | 2 +- libretroshare/src/retroshare/rsgxscircles.h | 6 +- libretroshare/src/retroshare/rsmsgs.h | 14 +- libretroshare/src/retroshare/rspeers.h | 6 +- libretroshare/src/retroshare/rsposted.h | 2 +- libretroshare/src/rsserver/p3msgs.cc | 2 +- libretroshare/src/rsserver/p3msgs.h | 2 +- libretroshare/src/rsserver/p3peers.cc | 10 +- libretroshare/src/rsserver/p3peers.h | 2 +- libretroshare/src/serialiser/rsconfigitems.cc | 2 +- libretroshare/src/serialiser/rspluginitems.cc | 2 +- libretroshare/src/serialiser/rstlvidset.h | 10 +- libretroshare/src/services/p3discovery2.cc | 18 +-- libretroshare/src/services/p3discovery2.h | 2 +- libretroshare/src/services/p3gxschannels.cc | 2 +- libretroshare/src/services/p3gxschannels.h | 2 +- libretroshare/src/services/p3gxscircles.cc | 14 +- libretroshare/src/services/p3msgservice.cc | 14 +- libretroshare/src/services/p3posted.cc | 2 +- libretroshare/src/services/p3posted.h | 2 +- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 126 +++++++++--------- retroshare-gui/src/gui/MessagesDialog.cpp | 4 +- retroshare-gui/src/gui/NetworkDialog.cpp | 8 +- .../src/gui/chat/ChatLobbyDialog.cpp | 4 +- .../src/gui/chat/CreateLobbyDialog.cpp | 4 +- .../src/gui/chat/CreateLobbyDialog.h | 2 +- retroshare-gui/src/gui/common/FriendList.cpp | 7 +- .../src/gui/common/FriendSelectionDialog.cpp | 44 +++--- .../src/gui/common/FriendSelectionDialog.h | 14 +- .../src/gui/common/FriendSelectionWidget.cpp | 16 +-- .../src/gui/common/FriendSelectionWidget.h | 20 +-- .../src/gui/connect/ConnectFriendWizard.cpp | 6 +- retroshare-gui/src/gui/feeds/ChatMsgItem.cpp | 2 +- retroshare-gui/src/gui/groups/CreateGroup.cpp | 6 +- .../src/gui/gxs/GxsGroupShareKey.cpp | 2 +- .../src/gui/msgs/MessageComposer.cpp | 78 ++++++----- retroshare-gui/src/gui/msgs/MessageComposer.h | 2 +- retroshare-gui/src/gui/msgs/MessageWidget.cpp | 12 +- 51 files changed, 269 insertions(+), 266 deletions(-) diff --git a/libretroshare/src/chat/distributedchat.cc b/libretroshare/src/chat/distributedchat.cc index e83e566b5..3c223f4a7 100644 --- a/libretroshare/src/chat/distributedchat.cc +++ b/libretroshare/src/chat/distributedchat.cc @@ -1421,7 +1421,7 @@ bool DistributedChatService::joinVisibleChatLobby(const ChatLobbyId& lobby_id,co return true ; } -ChatLobbyId DistributedChatService::createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::list& invited_friends,ChatLobbyFlags lobby_flags) +ChatLobbyId DistributedChatService::createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::set& invited_friends,ChatLobbyFlags lobby_flags) { #ifdef DEBUG_CHAT_LOBBIES std::cerr << "Creating a new Chat lobby !!" << std::endl; @@ -1456,7 +1456,7 @@ ChatLobbyId DistributedChatService::createChatLobby(const std::string& lobby_nam _chat_lobbys[lobby_id] = entry ; } - for(std::list::const_iterator it(invited_friends.begin());it!=invited_friends.end();++it) + for(std::set::const_iterator it(invited_friends.begin());it!=invited_friends.end();++it) invitePeerToLobby(lobby_id,*it) ; RsServer::notify()->notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_ADD) ; diff --git a/libretroshare/src/chat/distributedchat.h b/libretroshare/src/chat/distributedchat.h index 7c85132f1..d3fc006d9 100644 --- a/libretroshare/src/chat/distributedchat.h +++ b/libretroshare/src/chat/distributedchat.h @@ -76,7 +76,7 @@ class DistributedChatService bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id); void sendLobbyStatusString(const ChatLobbyId& id,const std::string& status_string) ; - ChatLobbyId createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic, const std::list& invited_friends,ChatLobbyFlags flags) ; + ChatLobbyId createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic, const std::set& invited_friends,ChatLobbyFlags flags) ; void getListOfNearbyChatLobbies(std::vector& public_lobbies) ; bool joinVisibleChatLobby(const ChatLobbyId& id, const RsGxsId &gxs_id) ; diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index 6dee42a26..704bdf46f 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -2089,7 +2089,7 @@ bool ftController::saveList(bool &cleanup, std::list& saveData) // for(std::list::const_iterator it(lst.begin());it!=lst.end();++it) if(!mTurtle->isTurtlePeer(*it)) - rft->allPeerIds.ids.push_back(*it) ; + rft->allPeerIds.ids.insert(*it) ; rft->transferred = fit->second->mCreator->getRecvd(); fit->second->mCreator->getAvailabilityMap(rft->compressed_chunk_map) ; @@ -2126,17 +2126,17 @@ bool ftController::saveList(bool &cleanup, std::list& saveData) rft->allPeerIds.ids.clear() ; for(std::list::const_iterator it(pit->mSrcIds.begin());it!=pit->mSrcIds.end();++it) - rft->allPeerIds.ids.push_back( *it ) ; + rft->allPeerIds.ids.insert( *it ) ; } // Remove turtle peers from sources, as they are not supposed to survive a reboot of RS, since they are dynamic sources. // Otherwize, such sources are unknown from the turtle router, at restart, and never get removed. We do that in post // process since the rft object may have been created from mPendingChunkMaps // - for(std::list::iterator sit(rft->allPeerIds.ids.begin());sit!=rft->allPeerIds.ids.end();) + for(std::set::iterator sit(rft->allPeerIds.ids.begin());sit!=rft->allPeerIds.ids.end();) if(mTurtle->isTurtlePeer(RsPeerId(*sit))) { - std::list::iterator sittmp(sit) ; + std::set::iterator sittmp(sit) ; ++sittmp ; rft->allPeerIds.ids.erase(sit) ; sit = sittmp ; @@ -2199,7 +2199,7 @@ bool ftController::loadList(std::list& load) std::cerr << "ftController::loadList(): requesting " << rsft->file.name << ", " << rsft->file.hash << ", " << rsft->file.filesize << std::endl ; #endif std::list src_lst ; - for(std::list::const_iterator it(rsft->allPeerIds.ids.begin());it!=rsft->allPeerIds.ids.end();++it) + for(std::set::const_iterator it(rsft->allPeerIds.ids.begin());it!=rsft->allPeerIds.ids.end();++it) src_lst.push_back(*it) ; FileRequest(rsft->file.name, rsft->file.hash, rsft->file.filesize, rsft->file.path, TransferRequestFlags(rsft->flags), src_lst, rsft->state); diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 90f4fd6c4..e5dc58c1b 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -2391,7 +2391,7 @@ bool RsGenExchange::getGroupKeys(const RsGxsGroupId &grpId, RsTlvSecurityKeySet return true; } -void RsGenExchange::shareGroupPublishKey(const RsGxsGroupId& grpId,const std::list& peers) +void RsGenExchange::shareGroupPublishKey(const RsGxsGroupId& grpId,const std::set& peers) { if(grpId.isNull()) return ; diff --git a/libretroshare/src/gxs/rsgenexchange.h b/libretroshare/src/gxs/rsgenexchange.h index a641fb9f1..9cb8d0734 100644 --- a/libretroshare/src/gxs/rsgenexchange.h +++ b/libretroshare/src/gxs/rsgenexchange.h @@ -604,7 +604,7 @@ public: * sets the message service string */ - void shareGroupPublishKey(const RsGxsGroupId& grpId,const std::list& peers) ; + void shareGroupPublishKey(const RsGxsGroupId& grpId,const std::set& peers) ; protected: diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 6d7ef85a7..8634ff7b6 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -3239,7 +3239,7 @@ void RsGxsNetService::processExplicitGroupRequests() mExplicitRequest.clear(); } -int RsGxsNetService::sharePublishKey(const RsGxsGroupId& grpId,const std::list& peers) +int RsGxsNetService::sharePublishKey(const RsGxsGroupId& grpId,const std::set& peers) { RS_STACK_MUTEX(mNxsMutex) ; @@ -3264,7 +3264,7 @@ void RsGxsNetService::sharePublishKeysPending() std::set peersOnline; std::list toDelete; - std::map >::iterator mit ; + std::map >::iterator mit ; mNetMgr->getOnlineList(mServiceInfo.mServiceType, peersOnline); @@ -3278,9 +3278,9 @@ void RsGxsNetService::sharePublishKeysPending() // Compute the set of peers to send to. We start with this, to avoid retrieving the data for nothing. std::list recipients ; - std::list offline_recipients ; + std::set offline_recipients ; - for(std::list::const_iterator it(mit->second.begin());it!=mit->second.end();++it) + for(std::set::const_iterator it(mit->second.begin());it!=mit->second.end();++it) if(peersOnline.find(*it) != peersOnline.end()) { #ifdef NXS_NET_DEBUG @@ -3293,7 +3293,7 @@ void RsGxsNetService::sharePublishKeysPending() #ifdef NXS_NET_DEBUG std::cerr << " " << *it << ": offline. Keeping for next try." << std::endl; #endif - offline_recipients.push_back(*it) ; + offline_recipients.insert(*it) ; } // If empty, skip diff --git a/libretroshare/src/gxs/rsgxsnetservice.h b/libretroshare/src/gxs/rsgxsnetservice.h index 9181ba7da..43ad6b14a 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.h +++ b/libretroshare/src/gxs/rsgxsnetservice.h @@ -135,7 +135,7 @@ public: * share publish keys for the specified group with the peers in the specified list. */ - virtual int sharePublishKey(const RsGxsGroupId& grpId,const std::list& peers) ; + virtual int sharePublishKey(const RsGxsGroupId& grpId,const std::set& peers) ; /*! * Returns statistics for the group networking activity: popularity (number of friends subscribers) and max_visible_msg_count, @@ -484,7 +484,7 @@ private: // need to be verfied std::vector mPendingResp; std::vector mPendingCircleVets; - std::map > mPendingPublishKeyRecipients ; + std::map > mPendingPublishKeyRecipients ; std::map > mExplicitRequest; std::map > mPartialMsgUpdates ; diff --git a/libretroshare/src/gxs/rsnxs.h b/libretroshare/src/gxs/rsnxs.h index 88f5c6e08..c59dd4fab 100644 --- a/libretroshare/src/gxs/rsnxs.h +++ b/libretroshare/src/gxs/rsnxs.h @@ -124,7 +124,7 @@ public: * Request for this group is sent through to peers on your network * and how many hops from them you've indicated */ - virtual int sharePublishKey(const RsGxsGroupId& grpId,const std::list& peers)=0 ; + virtual int sharePublishKey(const RsGxsGroupId& grpId,const std::set& peers)=0 ; }; diff --git a/libretroshare/src/pgp/pgphandler.cc b/libretroshare/src/pgp/pgphandler.cc index 1d3bfd57e..294be072d 100644 --- a/libretroshare/src/pgp/pgphandler.cc +++ b/libretroshare/src/pgp/pgphandler.cc @@ -1867,7 +1867,7 @@ void PGPHandler::locked_mergeKeyringFromDisk( ops_keyring_t *keyring, ops_keyring_free(tmp_keyring) ; } -bool PGPHandler::removeKeysFromPGPKeyring(const std::list& keys_to_remove,std::string& backup_file,uint32_t& error_code) +bool PGPHandler::removeKeysFromPGPKeyring(const std::set& keys_to_remove,std::string& backup_file,uint32_t& error_code) { // 1 - lock everything. // @@ -1876,7 +1876,7 @@ bool PGPHandler::removeKeysFromPGPKeyring(const std::list& keys_to_remo error_code = PGP_KEYRING_REMOVAL_ERROR_NO_ERROR ; - for(std::list::const_iterator it(keys_to_remove.begin());it!=keys_to_remove.end();++it) + for(std::set::const_iterator it(keys_to_remove.begin());it!=keys_to_remove.end();++it) if(locked_getSecretKey(*it) != NULL) { std::cerr << "(EE) PGPHandler:: can't remove key " << (*it).toStdString() << " since its shared by a secret key! Operation cancelled." << std::endl; @@ -1912,7 +1912,7 @@ bool PGPHandler::removeKeysFromPGPKeyring(const std::list& keys_to_remo // Remove keys from the keyring, and update the keyring map. // - for(std::list::const_iterator it(keys_to_remove.begin());it!=keys_to_remove.end();++it) + for(std::set::const_iterator it(keys_to_remove.begin());it!=keys_to_remove.end();++it) { if(locked_getSecretKey(*it) != NULL) { diff --git a/libretroshare/src/pgp/pgphandler.h b/libretroshare/src/pgp/pgphandler.h index 917458847..304efc6be 100644 --- a/libretroshare/src/pgp/pgphandler.h +++ b/libretroshare/src/pgp/pgphandler.h @@ -109,7 +109,7 @@ class PGPHandler // Removes the given keys from the keyring. Also backup the keyring to a file which name is automatically generated // and given pack for proper display. // - bool removeKeysFromPGPKeyring(const std::list& key_ids,std::string& backup_file,uint32_t& error_code) ; + bool removeKeysFromPGPKeyring(const std::set& key_ids,std::string& backup_file,uint32_t& error_code) ; //bool isKeySupported(const RsPgpId& id) const ; diff --git a/libretroshare/src/pqi/authgpg.cc b/libretroshare/src/pqi/authgpg.cc index 024d530cd..92309af9e 100644 --- a/libretroshare/src/pqi/authgpg.cc +++ b/libretroshare/src/pqi/authgpg.cc @@ -61,14 +61,14 @@ bool AuthGPG::decryptTextFromFile(std::string& text,const std::string& inputfile return PGPHandler::decryptTextFromFile(mOwnGpgId,text,inputfile) ; } -bool AuthGPG::removeKeysFromPGPKeyring(const std::list& pgp_ids,std::string& backup_file,uint32_t& error_code) +bool AuthGPG::removeKeysFromPGPKeyring(const std::set& pgp_ids,std::string& backup_file,uint32_t& error_code) { - std::list pids ; +// std::list pids ; +// +// for(std::list::const_iterator it(pgp_ids.begin());it!=pgp_ids.end();++it) +// pids.push_back(RsPgpId(*it)) ; - for(std::list::const_iterator it(pgp_ids.begin());it!=pgp_ids.end();++it) - pids.push_back(RsPgpId(*it)) ; - - return PGPHandler::removeKeysFromPGPKeyring(pids,backup_file,error_code) ; + return PGPHandler::removeKeysFromPGPKeyring(pgp_ids,backup_file,error_code) ; } // bool AuthGPG::decryptTextFromString(std::string& encrypted_text,std::string& output) diff --git a/libretroshare/src/pqi/authgpg.h b/libretroshare/src/pqi/authgpg.h index eedcf3c7c..bfa09a6c5 100644 --- a/libretroshare/src/pqi/authgpg.h +++ b/libretroshare/src/pqi/authgpg.h @@ -166,7 +166,7 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler virtual bool importProfile(const std::string& filename,RsPgpId& gpg_id,std::string& import_error) ; virtual bool exportProfile(const std::string& filename,const RsPgpId& gpg_id) ; - virtual bool removeKeysFromPGPKeyring(const std::list& pgp_ids,std::string& backup_file,uint32_t& error_code) ; + virtual bool removeKeysFromPGPKeyring(const std::set &pgp_ids,std::string& backup_file,uint32_t& error_code) ; /*********************************************************************************/ /************************* STAGE 4 ***********************************************/ diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index 2ec95a4b0..fdeddb086 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -2089,10 +2089,10 @@ bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::li std::list::const_iterator peerIt; for (peerIt = peerIds.begin(); peerIt != peerIds.end(); ++peerIt) { - std::list::iterator peerIt1 = std::find(groupItem->pgpList.ids.begin(), groupItem->pgpList.ids.end(), *peerIt); + std::set::iterator peerIt1 = std::find(groupItem->pgpList.ids.begin(), groupItem->pgpList.ids.end(), *peerIt); if (assign) { if (peerIt1 == groupItem->pgpList.ids.end()) { - groupItem->pgpList.ids.push_back(*peerIt); + groupItem->pgpList.ids.insert(*peerIt); changed = true; } } else { diff --git a/libretroshare/src/retroshare/rsgxschannels.h b/libretroshare/src/retroshare/rsgxschannels.h index 107e408ad..c72245ad3 100644 --- a/libretroshare/src/retroshare/rsgxschannels.h +++ b/libretroshare/src/retroshare/rsgxschannels.h @@ -101,7 +101,7 @@ virtual bool getChannelAutoDownload(const RsGxsGroupId &groupid) = 0; //virtual bool setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask); //virtual bool groupRestoreKeys(const std::string &groupId); - virtual bool groupShareKeys(const RsGxsGroupId &groupId, std::list& peers)=0; + virtual bool groupShareKeys(const RsGxsGroupId &groupId, std::set& peers)=0; // Overloaded subscribe fn. virtual bool subscribeToGroup(uint32_t &token, const RsGxsGroupId &groupId, bool subscribe) = 0; diff --git a/libretroshare/src/retroshare/rsgxscircles.h b/libretroshare/src/retroshare/rsgxscircles.h index 729d51adf..2736adc75 100644 --- a/libretroshare/src/retroshare/rsgxscircles.h +++ b/libretroshare/src/retroshare/rsgxscircles.h @@ -78,9 +78,9 @@ class RsGxsCircleGroup public: RsGroupMetaData mMeta; // includes GxsPermissions, for control of group distribution. - std::list mLocalFriends; - std::list mInvitedMembers; - std::list mSubCircles; + std::set mLocalFriends; + std::set mInvitedMembers; + std::set mSubCircles; // Not Serialised. // Internally inside rsCircles, this will be turned into: diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index 823936ee5..c8c608229 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -185,15 +185,15 @@ public: // friend destinations // - std::list rspeerid_msgto; // RsPeerId is used here for various purposes: - std::list rspeerid_msgcc; // - real peer ids which are actual friend locations - std::list rspeerid_msgbcc; // - + std::set rspeerid_msgto; // RsPeerId is used here for various purposes: + std::set rspeerid_msgcc; // - real peer ids which are actual friend locations + std::set rspeerid_msgbcc; // - // distant peers // - std::list rsgxsid_msgto; // RsPeerId is used here for various purposes: - std::list rsgxsid_msgcc; // - real peer ids which are actual friend locations - std::list rsgxsid_msgbcc; // - + std::set rsgxsid_msgto; // RsPeerId is used here for various purposes: + std::set rsgxsid_msgcc; // - real peer ids which are actual friend locations + std::set rsgxsid_msgbcc; // - std::string title; std::string msg; @@ -474,7 +474,7 @@ virtual bool setDefaultIdentityForChatLobby(const RsGxsId& nick) = 0; virtual bool getDefaultIdentityForChatLobby(RsGxsId& id) = 0 ; virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe) = 0 ; virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id) = 0 ; -virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::list& invited_friends,ChatLobbyFlags lobby_privacy_type) = 0 ; +virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::set& invited_friends,ChatLobbyFlags lobby_privacy_type) = 0 ; /****************************************/ /* Distant chat */ diff --git a/libretroshare/src/retroshare/rspeers.h b/libretroshare/src/retroshare/rspeers.h index f4d62e875..315ce477b 100644 --- a/libretroshare/src/retroshare/rspeers.h +++ b/libretroshare/src/retroshare/rspeers.h @@ -277,7 +277,7 @@ public: std::string name; uint32_t flag; - std::list peerIds; + std::set peerIds; }; std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail); @@ -319,7 +319,7 @@ class RsPeers virtual bool getGPGSignedList(std::list &gpg_ids) = 0;//friends that we accpet to connect with but we don't want to sign their gpg key virtual bool getGPGValidList(std::list &gpg_ids) = 0; virtual bool getGPGAllList(std::list &gpg_ids) = 0; - virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list& ids) = 0; + virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list& ids) = 0; virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) = 0; /* Add/Remove Friends */ @@ -328,7 +328,7 @@ class RsPeers virtual bool removeFriendLocation(const RsPeerId& sslId) = 0; /* keyring management */ - virtual bool removeKeysFromPGPKeyring(const std::list& pgp_ids,std::string& backup_file,uint32_t& error_code)=0 ; + virtual bool removeKeysFromPGPKeyring(const std::set& pgp_ids,std::string& backup_file,uint32_t& error_code)=0 ; /* Network Stuff */ virtual bool connectAttempt(const RsPeerId& ssl_id) = 0; diff --git a/libretroshare/src/retroshare/rsposted.h b/libretroshare/src/retroshare/rsposted.h index 0ff4bf9ea..22c738c24 100644 --- a/libretroshare/src/retroshare/rsposted.h +++ b/libretroshare/src/retroshare/rsposted.h @@ -100,7 +100,7 @@ virtual bool createPost(uint32_t &token, RsPostedPost &post) = 0; virtual bool updateGroup(uint32_t &token, RsPostedGroup &group) = 0; - virtual bool groupShareKeys(const RsGxsGroupId& group,const std::list& peers) = 0 ; + virtual bool groupShareKeys(const RsGxsGroupId& group,const std::set& peers) = 0 ; }; diff --git a/libretroshare/src/rsserver/p3msgs.cc b/libretroshare/src/rsserver/p3msgs.cc index dd4adcc27..43e16a476 100644 --- a/libretroshare/src/rsserver/p3msgs.cc +++ b/libretroshare/src/rsserver/p3msgs.cc @@ -495,7 +495,7 @@ void p3Msgs::getListOfNearbyChatLobbies(std::vector& pub mChatSrv->getListOfNearbyChatLobbies(public_lobbies) ; } -ChatLobbyId p3Msgs::createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::list& invited_friends,ChatLobbyFlags privacy_type) +ChatLobbyId p3Msgs::createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::set& invited_friends,ChatLobbyFlags privacy_type) { return mChatSrv->createChatLobby(lobby_name,lobby_identity,lobby_topic,invited_friends,privacy_type) ; } diff --git a/libretroshare/src/rsserver/p3msgs.h b/libretroshare/src/rsserver/p3msgs.h index b2d5177c3..cf505a348 100644 --- a/libretroshare/src/rsserver/p3msgs.h +++ b/libretroshare/src/rsserver/p3msgs.h @@ -153,7 +153,7 @@ class p3Msgs: public RsMsgs virtual bool getDefaultIdentityForChatLobby(RsGxsId& nick) ; virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe); virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id); - virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::list& invited_friends,ChatLobbyFlags privacy_type) ; + virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::set& invited_friends,ChatLobbyFlags privacy_type) ; virtual bool initiateDistantChatConnexion(const RsGxsId& to_gxs_id,const RsGxsId& from_gxs_id,uint32_t& error_code) ; virtual bool getDistantChatStatus(const RsGxsId& gxs_id,uint32_t& status, RsGxsId *from_gxs_id=NULL) ; diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index e0cfb0b8d..e0a97318a 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -660,7 +660,7 @@ bool p3Peers::addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePe return mPeerMgr->addFriend(ssl_id, gpg_id, RS_NET_MODE_UDP, RS_VS_DISC_FULL, RS_VS_DHT_FULL, now, perm_flags); } -bool p3Peers::removeKeysFromPGPKeyring(const std::list& pgp_ids,std::string& backup_file,uint32_t& error_code) +bool p3Peers::removeKeysFromPGPKeyring(const std::set& pgp_ids,std::string& backup_file,uint32_t& error_code) { return AuthGPG::getAuthGPG()->removeKeysFromPGPKeyring(pgp_ids,backup_file,error_code) ; } @@ -1279,9 +1279,11 @@ FileSearchFlags p3Peers::computePeerPermissionFlags(const RsPeerId& peer_ssl_id, continue ; } - for(std::list::const_iterator it2(info.peerIds.begin());it2!=info.peerIds.end() && !found;++it2) - if(*it2 == pgp_id) - found = true ; + found = found || (info.peerIds.find(pgp_id) != info.peerIds.end()) ; + + //for(std::set::const_iterator it2(info.peerIds.begin());it2!=info.peerIds.end() && !found;++it2) + // if(*it2 == pgp_id) + // found = true ; } bool network_wide = (share_flags & DIR_FLAGS_NETWORK_WIDE_OTHERS) ;//|| ( (share_flags & DIR_FLAGS_NETWORK_WIDE_GROUPS) && found) ; diff --git a/libretroshare/src/rsserver/p3peers.h b/libretroshare/src/rsserver/p3peers.h index f15b1d5e2..29db22f30 100644 --- a/libretroshare/src/rsserver/p3peers.h +++ b/libretroshare/src/rsserver/p3peers.h @@ -80,7 +80,7 @@ virtual bool removeFriend(const RsPgpId& gpgid); virtual bool removeFriendLocation(const RsPeerId& sslId); /* keyring management */ - virtual bool removeKeysFromPGPKeyring(const std::list& pgp_ids,std::string& backup_file,uint32_t& error_code); + virtual bool removeKeysFromPGPKeyring(const std::set &pgp_ids,std::string& backup_file,uint32_t& error_code); /* Network Stuff */ virtual bool connectAttempt(const RsPeerId &id); diff --git a/libretroshare/src/serialiser/rsconfigitems.cc b/libretroshare/src/serialiser/rsconfigitems.cc index 738bcc081..90abd8c0a 100644 --- a/libretroshare/src/serialiser/rsconfigitems.cc +++ b/libretroshare/src/serialiser/rsconfigitems.cc @@ -1178,7 +1178,7 @@ std::ostream &RsPeerGroupItem::print(std::ostream &out, uint16_t indent) printIndent(out, int_Indent); out << "groupFlag: " << flag << std::endl; - std::list::iterator it; + std::set::iterator it; for (it = pgpList.ids.begin(); it != pgpList.ids.end(); ++it) { printIndent(out, int_Indent); out << "peerId: " << it->toStdString() << std::endl; diff --git a/libretroshare/src/serialiser/rspluginitems.cc b/libretroshare/src/serialiser/rspluginitems.cc index 4e991f331..d671d1a1c 100644 --- a/libretroshare/src/serialiser/rspluginitems.cc +++ b/libretroshare/src/serialiser/rspluginitems.cc @@ -123,7 +123,7 @@ std::ostream& RsPluginHashSetItem::print(std::ostream& o, uint16_t) o << "Item type: RsPluginHashSetItem" << std::endl; o << " Hash list: " << std::endl; - for(std::list::const_iterator it(hashes.ids.begin());it!=hashes.ids.end();++it) + for(std::set::const_iterator it(hashes.ids.begin());it!=hashes.ids.end();++it) o << " " << *it << std::endl; return o ; diff --git a/libretroshare/src/serialiser/rstlvidset.h b/libretroshare/src/serialiser/rstlvidset.h index efa70c573..e5b3d257b 100644 --- a/libretroshare/src/serialiser/rstlvidset.h +++ b/libretroshare/src/serialiser/rstlvidset.h @@ -59,7 +59,7 @@ template class t_RsTlvIdSet: public RsTlvItem /* start at data[offset] */ ok = ok && SetTlvBase(data, tlvend, offset, TLV_TYPE, tlvsize); - for(typename std::list::const_iterator it(ids.begin());it!=ids.end();++it) + for(typename std::set::const_iterator it(ids.begin());it!=ids.end();++it) ok = ok && (*it).serialise(data,tlvend,*offset) ; return ok ; @@ -91,7 +91,7 @@ template class t_RsTlvIdSet: public RsTlvItem { ID_CLASS id ; ok = ok && id.deserialise(data,tlvend,*offset) ; - ids.push_back(id) ; + ids.insert(id) ; } if(*offset != tlvend) std::cerr << "(EE) deserialisaiton error in " << __PRETTY_FUNCTION__ << std::endl; @@ -99,20 +99,20 @@ template class t_RsTlvIdSet: public RsTlvItem } virtual std::ostream &print(std::ostream &out, uint16_t /* indent */) const { - for(typename std::list::const_iterator it(ids.begin());it!=ids.end();++it) + for(typename std::set::const_iterator it(ids.begin());it!=ids.end();++it) out << (*it).toStdString() << ", " ; return out ; } virtual std::ostream &printHex(std::ostream &out, uint16_t /* indent */) const /* SPECIAL One */ { - for(typename std::list::const_iterator it(ids.begin());it!=ids.end();++it) + for(typename std::set::const_iterator it(ids.begin());it!=ids.end();++it) out << (*it).toStdString() << ", " ; return out ; } - std::list ids ; + std::set ids ; }; typedef t_RsTlvIdSet RsTlvPeerIdSet ; diff --git a/libretroshare/src/services/p3discovery2.cc b/libretroshare/src/services/p3discovery2.cc index a408c815f..f499c37a5 100644 --- a/libretroshare/src/services/p3discovery2.cc +++ b/libretroshare/src/services/p3discovery2.cc @@ -74,9 +74,9 @@ bool populateContactInfo(const peerState &detail, RsDiscContactItem *pkt) return true; } -void DiscPgpInfo::mergeFriendList(const std::list &friends) +void DiscPgpInfo::mergeFriendList(const std::set &friends) { - std::list::const_iterator it; + std::set::const_iterator it; for(it = friends.begin(); it != friends.end(); ++it) { mFriendSet.insert(*it); @@ -481,7 +481,7 @@ void p3discovery2::sendPGPList(const SSLID &toId) std::map::const_iterator it; for(it = mFriendList.begin(); it != mFriendList.end(); ++it) { - pkt->pgpIdSet.ids.push_back(it->first); + pkt->pgpIdSet.ids.insert(it->first); } pkt->PeerId(toId); @@ -517,7 +517,7 @@ void p3discovery2::updatePgpFriendList() mLastPgpUpdate = time(NULL); - std::list pgpList; + std::list pgpList; std::set pgpSet; std::set::iterator sit; @@ -525,7 +525,7 @@ void p3discovery2::updatePgpFriendList() std::map::iterator it; PGPID ownPgpId = AuthGPG::getAuthGPG()->getGPGOwnId(); - AuthGPG::getAuthGPG()->getGPGAcceptedList(pgpList); + AuthGPG::getAuthGPG()->getGPGAcceptedList(pgpList); pgpList.push_back(ownPgpId); // convert to set for ordering. @@ -597,7 +597,7 @@ void p3discovery2::updatePgpFriendList() /* finally install the pgpList on our own entry */ DiscPgpInfo &ownInfo = mFriendList[ownPgpId]; - ownInfo.mergeFriendList(pgpList); + ownInfo.mergeFriendList(pgpSet); } @@ -647,7 +647,7 @@ void p3discovery2::processPGPList(const SSLID &fromId, const RsDiscPgpListItem * if (requestUnknownPgpCerts) { - std::list::const_iterator fit; + std::set::const_iterator fit; for(fit = item->pgpIdSet.ids.begin(); fit != item->pgpIdSet.ids.end(); ++fit) { if (!AuthGPG::getAuthGPG()->isGPGId(*fit)) @@ -946,7 +946,7 @@ void p3discovery2::requestPGPCertificate(const PGPID &aboutId, const SSLID &toId RsDiscPgpListItem *pkt = new RsDiscPgpListItem(); pkt->mode = DISC_PGP_LIST_MODE_GETCERT; - pkt->pgpIdSet.ids.push_back(aboutId); + pkt->pgpIdSet.ids.insert(aboutId); pkt->PeerId(toId); #ifdef P3DISC_DEBUG @@ -966,7 +966,7 @@ void p3discovery2::recvPGPCertificateRequest(const SSLID &fromId, const RsDiscPg std::cerr << std::endl; #endif - std::list::const_iterator it; + std::set::const_iterator it; for(it = item->pgpIdSet.ids.begin(); it != item->pgpIdSet.ids.end(); ++it) { // NB: This doesn't include own certificates? why not. diff --git a/libretroshare/src/services/p3discovery2.h b/libretroshare/src/services/p3discovery2.h index 122a95435..2d063ee77 100644 --- a/libretroshare/src/services/p3discovery2.h +++ b/libretroshare/src/services/p3discovery2.h @@ -66,7 +66,7 @@ class DiscPgpInfo public: DiscPgpInfo() {} -void mergeFriendList(const std::list &friends); +void mergeFriendList(const std::set &friends); //PGPID mPgpId; std::set mFriendSet; diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index 4135c09f2..ee8a7d682 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -302,7 +302,7 @@ bool p3GxsChannels::getGroupData(const uint32_t &token, std::vector& peers) +bool p3GxsChannels::groupShareKeys(const RsGxsGroupId &groupId, std::set& peers) { RsGenExchange::shareGroupPublishKey(groupId,peers) ; return true ; diff --git a/libretroshare/src/services/p3gxschannels.h b/libretroshare/src/services/p3gxschannels.h index 22c79bf94..e3f8f38dd 100644 --- a/libretroshare/src/services/p3gxschannels.h +++ b/libretroshare/src/services/p3gxschannels.h @@ -88,7 +88,7 @@ virtual bool getRelatedPosts(const uint32_t &token, std::vector& peers) ; + virtual bool groupShareKeys(const RsGxsGroupId &groupId, std::set& peers) ; virtual bool createGroup(uint32_t &token, RsGxsChannelGroup &group); virtual bool createPost(uint32_t &token, RsGxsChannelPost &post); diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index f8afd4658..0144c9ea5 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -913,8 +913,8 @@ bool p3GxsCircles::cache_load_for_token(uint32_t token) std::cerr << std::endl; #endif - std::list &peers = group.mInvitedMembers; - std::list::const_iterator pit; + std::set &peers = group.mInvitedMembers; + std::set::const_iterator pit; // need to trigger the searches. for(pit = peers.begin(); pit != peers.end(); ++pit) @@ -1018,8 +1018,8 @@ bool p3GxsCircles::cache_load_for_token(uint32_t token) #endif // LOCAL Load. - std::list &peers = group.mLocalFriends; - std::list::const_iterator pit; + std::set &peers = group.mLocalFriends; + std::set::const_iterator pit; // need to trigger the searches. for(pit = peers.begin(); pit != peers.end(); ++pit) @@ -1610,7 +1610,7 @@ void p3GxsCircles::generateDummyCircle() std::set::iterator it; for(it = idset.begin(); it != idset.end(); ++it) { - group.mInvitedMembers.push_back(*it); + group.mInvitedMembers.insert(*it); #ifdef DEBUG_CIRCLES std::cerr << "p3GxsCircles::generateDummyCircle() Adding: " << *it; std::cerr << std::endl; @@ -1634,8 +1634,8 @@ std::ostream &operator<<(std::ostream &out, const RsGxsCircleGroup &grp) out << "InvitedMembers: "; out << std::endl; - std::list::const_iterator it; - std::list::const_iterator sit; + std::set::const_iterator it; + std::set::const_iterator sit; for(it = grp.mInvitedMembers.begin(); it != grp.mInvitedMembers.begin(); ++it) { diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index ef689efe5..b5195b1d0 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -1036,13 +1036,13 @@ uint32_t p3MsgService::sendDistantMessage(RsMsgItem *item,const RsGxsId& fro bool p3MsgService::MessageSend(MessageInfo &info) { - for(std::list::const_iterator pit = info.rspeerid_msgto.begin(); pit != info.rspeerid_msgto.end(); ++pit) sendMessage(initMIRsMsg(info, *pit)); - for(std::list::const_iterator pit = info.rspeerid_msgcc.begin(); pit != info.rspeerid_msgcc.end(); ++pit) sendMessage(initMIRsMsg(info, *pit)); - for(std::list::const_iterator pit = info.rspeerid_msgbcc.begin(); pit != info.rspeerid_msgbcc.end(); ++pit) sendMessage(initMIRsMsg(info, *pit)); + for(std::set::const_iterator pit = info.rspeerid_msgto.begin(); pit != info.rspeerid_msgto.end(); ++pit) sendMessage(initMIRsMsg(info, *pit)); + for(std::set::const_iterator pit = info.rspeerid_msgcc.begin(); pit != info.rspeerid_msgcc.end(); ++pit) sendMessage(initMIRsMsg(info, *pit)); + for(std::set::const_iterator pit = info.rspeerid_msgbcc.begin(); pit != info.rspeerid_msgbcc.end(); ++pit) sendMessage(initMIRsMsg(info, *pit)); - for(std::list::const_iterator pit = info.rsgxsid_msgto.begin(); pit != info.rsgxsid_msgto.end(); ++pit) sendDistantMessage(initMIRsMsg(info, *pit),info.rsgxsid_srcId); - for(std::list::const_iterator pit = info.rsgxsid_msgcc.begin(); pit != info.rsgxsid_msgcc.end(); ++pit) sendDistantMessage(initMIRsMsg(info, *pit),info.rsgxsid_srcId); - for(std::list::const_iterator pit = info.rsgxsid_msgbcc.begin(); pit != info.rsgxsid_msgbcc.end(); ++pit) sendDistantMessage(initMIRsMsg(info, *pit),info.rsgxsid_srcId); + for(std::set::const_iterator pit = info.rsgxsid_msgto.begin(); pit != info.rsgxsid_msgto.end(); ++pit) sendDistantMessage(initMIRsMsg(info, *pit),info.rsgxsid_srcId); + for(std::set::const_iterator pit = info.rsgxsid_msgcc.begin(); pit != info.rsgxsid_msgcc.end(); ++pit) sendDistantMessage(initMIRsMsg(info, *pit),info.rsgxsid_srcId); + for(std::set::const_iterator pit = info.rsgxsid_msgbcc.begin(); pit != info.rsgxsid_msgbcc.end(); ++pit) sendDistantMessage(initMIRsMsg(info, *pit),info.rsgxsid_srcId); /* send to ourselves as well */ RsMsgItem *msg = initMIRsMsg(info, mServiceCtrl->getOwnId()); @@ -1096,7 +1096,7 @@ bool p3MsgService::SystemMessage(const std::string &title, const std::string &me msg->subject = title; msg->message = message; - msg->rspeerid_msgto.ids.push_back(ownId); + msg->rspeerid_msgto.ids.insert(ownId); processMsg(msg, true); diff --git a/libretroshare/src/services/p3posted.cc b/libretroshare/src/services/p3posted.cc index fb4634df6..2a9237a13 100644 --- a/libretroshare/src/services/p3posted.cc +++ b/libretroshare/src/services/p3posted.cc @@ -62,7 +62,7 @@ RsServiceInfo p3Posted::getServiceInfo() GXS_POSTED_MIN_MINOR_VERSION); } -bool p3Posted::groupShareKeys(const RsGxsGroupId& groupId,const std::list& peers) +bool p3Posted::groupShareKeys(const RsGxsGroupId& groupId,const std::set& peers) { RsGenExchange::shareGroupPublishKey(groupId,peers) ; return true ; diff --git a/libretroshare/src/services/p3posted.h b/libretroshare/src/services/p3posted.h index 700253e5e..b14d338ac 100644 --- a/libretroshare/src/services/p3posted.h +++ b/libretroshare/src/services/p3posted.h @@ -70,7 +70,7 @@ virtual bool createGroup(uint32_t &token, RsPostedGroup &group); virtual bool createPost(uint32_t &token, RsPostedPost &post); virtual bool updateGroup(uint32_t &token, RsPostedGroup &group); -virtual bool groupShareKeys(const RsGxsGroupId &group, const std::list& peers); +virtual bool groupShareKeys(const RsGxsGroupId &group, const std::set& peers); ////////////////////////////////////////////////////////////////////////////// // WRAPPERS due to the separate Interface. diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index d48e2cf6c..2b03502ea 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -55,7 +55,7 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) ui.setupUi(this); m_bProcessSettings = false; - myChatLobbyUserNotify = NULL; + myChatLobbyUserNotify = NULL; QObject::connect( NotifyQt::getInstance(), SIGNAL(lobbyListChanged()), SLOT(lobbyChanged())); QObject::connect( NotifyQt::getInstance(), SIGNAL(chatLobbyEvent(qulonglong,int,const QString&,const QString&)), this, SLOT(displayChatLobbyEvent(qulonglong,int,const QString&,const QString&))); @@ -195,29 +195,29 @@ ChatLobbyWidget::~ChatLobbyWidget() UserNotify *ChatLobbyWidget::getUserNotify(QObject *parent) { - if (!myChatLobbyUserNotify){ - myChatLobbyUserNotify = new ChatLobbyUserNotify(parent); - connect(myChatLobbyUserNotify, SIGNAL(countChanged(ChatLobbyId, unsigned int)), this, SLOT(updateNotify(ChatLobbyId, unsigned int))); - } - return myChatLobbyUserNotify; -} - -void ChatLobbyWidget::updateNotify(ChatLobbyId id, unsigned int count) -{ - ChatLobbyDialog *dialog=NULL; - dialog=_lobby_infos[id].dialog; - if(!dialog) return; - - QToolButton* notifyButton=dialog->getChatWidget()->getNotifyButton(); - if (!notifyButton) return; - dialog->getChatWidget()->setNotify(myChatLobbyUserNotify); - if (count>0){ - notifyButton->setVisible(true); - notifyButton->setIcon(_lobby_infos[id].default_icon); - notifyButton->setToolTip(QString("(%1)").arg(count)); - } else { - notifyButton->setVisible(false); - } + if (!myChatLobbyUserNotify){ + myChatLobbyUserNotify = new ChatLobbyUserNotify(parent); + connect(myChatLobbyUserNotify, SIGNAL(countChanged(ChatLobbyId, unsigned int)), this, SLOT(updateNotify(ChatLobbyId, unsigned int))); + } + return myChatLobbyUserNotify; +} + +void ChatLobbyWidget::updateNotify(ChatLobbyId id, unsigned int count) +{ + ChatLobbyDialog *dialog=NULL; + dialog=_lobby_infos[id].dialog; + if(!dialog) return; + + QToolButton* notifyButton=dialog->getChatWidget()->getNotifyButton(); + if (!notifyButton) return; + dialog->getChatWidget()->setNotify(myChatLobbyUserNotify); + if (count>0){ + notifyButton->setVisible(true); + notifyButton->setIcon(_lobby_infos[id].default_icon); + notifyButton->setToolTip(QString("(%1)").arg(count)); + } else { + notifyButton->setVisible(false); + } } void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint) @@ -350,7 +350,7 @@ void ChatLobbyWidget::addChatPage(ChatLobbyDialog *d) connect(d,SIGNAL(lobbyLeave(ChatLobbyId)),this,SLOT(unsubscribeChatLobby(ChatLobbyId))) ; connect(d,SIGNAL(typingEventReceived(ChatLobbyId)),this,SLOT(updateTypingStatus(ChatLobbyId))) ; - connect(d,SIGNAL(messageReceived(bool,ChatLobbyId,QDateTime,QString,QString)),this,SLOT(updateMessageChanged(bool,ChatLobbyId,QDateTime,QString,QString))) ; + connect(d,SIGNAL(messageReceived(bool,ChatLobbyId,QDateTime,QString,QString)),this,SLOT(updateMessageChanged(bool,ChatLobbyId,QDateTime,QString,QString))) ; connect(d,SIGNAL(peerJoined(ChatLobbyId)),this,SLOT(updatePeerEntering(ChatLobbyId))) ; connect(d,SIGNAL(peerLeft(ChatLobbyId)),this,SLOT(updatePeerLeaving(ChatLobbyId))) ; @@ -618,7 +618,7 @@ void ChatLobbyWidget::createChatLobby() privacyLevel = action->data().toInt(); } - std::list friends; + std::set friends; CreateLobbyDialog(friends, privacyLevel).exec(); } @@ -636,7 +636,7 @@ void ChatLobbyWidget::showLobby(QTreeWidgetItem *item) else ui.stackedWidget->setCurrentWidget(_lobby_infos[id].dialog) ; } - + void ChatLobbyWidget::subscribeChatLobbyAs() { QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem(); @@ -656,31 +656,31 @@ void ChatLobbyWidget::subscribeChatLobbyAs() if(rsMsgs->joinVisibleChatLobby(id,gxs_id)) ChatDialog::chatFriend(ChatId(id),true) ; } - -void ChatLobbyWidget::showLobbyAnchor(ChatLobbyId id, QString anchor) -{ - QTreeWidgetItem *item = getTreeWidgetItem(id) ; - - if(item != NULL) { - if(item->type() == TYPE_LOBBY) { - - if(_lobby_infos.find(id) == _lobby_infos.end()) { - showBlankPage(id) ; - } else { - //ChatLobbyDialog cldChatLobby =_lobby_infos[id].dialog; - ui.stackedWidget->setCurrentWidget(_lobby_infos[id].dialog) ; - ChatLobbyDialog *cldCW=NULL ; - if (NULL != (cldCW = dynamic_cast(ui.stackedWidget->currentWidget()))) - cldCW->getChatWidget()->scrollToAnchor(anchor); - - ui.lobbyTreeWidget->setCurrentItem(item); - } - - } - } - -} - + +void ChatLobbyWidget::showLobbyAnchor(ChatLobbyId id, QString anchor) +{ + QTreeWidgetItem *item = getTreeWidgetItem(id) ; + + if(item != NULL) { + if(item->type() == TYPE_LOBBY) { + + if(_lobby_infos.find(id) == _lobby_infos.end()) { + showBlankPage(id) ; + } else { + //ChatLobbyDialog cldChatLobby =_lobby_infos[id].dialog; + ui.stackedWidget->setCurrentWidget(_lobby_infos[id].dialog) ; + ChatLobbyDialog *cldCW=NULL ; + if (NULL != (cldCW = dynamic_cast(ui.stackedWidget->currentWidget()))) + cldCW->getChatWidget()->scrollToAnchor(anchor); + + ui.lobbyTreeWidget->setCurrentItem(item); + } + + } + } + +} + void ChatLobbyWidget::subscribeChatLobbyAtItem(QTreeWidgetItem *item) { if (item == NULL || item->type() != TYPE_LOBBY) { @@ -853,10 +853,10 @@ void ChatLobbyWidget::unsubscribeChatLobby(ChatLobbyId id) if(it != _lobby_infos.end()) { - if (myChatLobbyUserNotify){ - myChatLobbyUserNotify->chatLobbyCleared(id, ""); - } - + if (myChatLobbyUserNotify){ + myChatLobbyUserNotify->chatLobbyCleared(id, ""); + } + ui.stackedWidget->removeWidget(it->second.dialog) ; _lobby_infos.erase(it) ; } @@ -906,18 +906,18 @@ void ChatLobbyWidget::updateCurrentLobby() filterItems(ui.filterLineEdit->text()); } } -void ChatLobbyWidget::updateMessageChanged(bool incoming, ChatLobbyId id, QDateTime time, QString senderName, QString msg) +void ChatLobbyWidget::updateMessageChanged(bool incoming, ChatLobbyId id, QDateTime time, QString senderName, QString msg) { QTreeWidgetItem *current_item = ui.lobbyTreeWidget->currentItem(); - bool bIsCurrentItem = (current_item != NULL && current_item->data(COLUMN_DATA, ROLE_ID).toULongLong() == id); - - if (myChatLobbyUserNotify){ - if (incoming) myChatLobbyUserNotify->chatLobbyNewMessage(id, time, senderName, msg); - } + bool bIsCurrentItem = (current_item != NULL && current_item->data(COLUMN_DATA, ROLE_ID).toULongLong() == id); + + if (myChatLobbyUserNotify){ + if (incoming) myChatLobbyUserNotify->chatLobbyNewMessage(id, time, senderName, msg); + } // Don't show anything for current lobby. // - if(bIsCurrentItem) + if(bIsCurrentItem) return ; _lobby_infos[id].default_icon = QIcon(IMAGE_MESSAGE) ; diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index 3982d0bff..6d2c3e89d 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -1125,7 +1125,7 @@ void MessagesDialog::insertMessages() text.clear(); - for(std::list::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); ++pit) + for(std::set::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); ++pit) { if (!text.isEmpty()) text += ", "; @@ -1136,7 +1136,7 @@ void MessagesDialog::insertMessages() else text += QString::fromUtf8(peerName.c_str()); } - for(std::list::const_iterator pit = msgInfo.rsgxsid_msgto.begin(); pit != msgInfo.rsgxsid_msgto.end(); ++pit) + for(std::set::const_iterator pit = msgInfo.rsgxsid_msgto.begin(); pit != msgInfo.rsgxsid_msgto.end(); ++pit) { if (!text.isEmpty()) text += ", "; diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index 9a5dd481a..76a863206 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -225,7 +225,7 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ ) void NetworkDialog::removeUnusedKeys() { - std::list pre_selected ; + std::set pre_selected ; std::list ids ; rsPeers->getGPGAllList(ids) ; @@ -245,17 +245,17 @@ void NetworkDialog::removeUnusedKeys() if(now > (time_t) (THREE_MONTHS + details.lastUsed)) { std::cerr << "Adding " << *it << " to pre-selection." << std::endl; - pre_selected.push_back(*it) ; + pre_selected.insert(*it) ; } } - std::list selected = FriendSelectionDialog::selectFriends_PGP(NULL, + std::set selected = FriendSelectionDialog::selectFriends_PGP(NULL, tr("Clean keyring"), tr("The selected keys below haven't been used in the last 3 months. \nDo you want to delete them permanently ? \n\nNotes: Your old keyring will be backed up.\n The removal may fail when running multiple Retroshare instances on the same machine."),FriendSelectionWidget::MODUS_CHECK,FriendSelectionWidget::SHOW_GPG | FriendSelectionWidget::SHOW_NON_FRIEND_GPG, pre_selected) ; std::cerr << "Removing these keys from the keyring: " << std::endl; - for(std::list::const_iterator it(selected.begin());it!=selected.end();++it) + for(std::set::const_iterator it(selected.begin());it!=selected.end();++it) std::cerr << " " << *it << std::endl; std::string backup_file ; diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index ef31807ac..84bd8f45c 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -136,14 +136,14 @@ void ChatLobbyDialog::inviteFriends() { std::cerr << "Inviting friends" << std::endl; - std::list ids = FriendSelectionDialog::selectFriends_SSL(NULL,tr("Invite friends"),tr("Select friends to invite:")) ; + std::set ids = FriendSelectionDialog::selectFriends_SSL(NULL,tr("Invite friends"),tr("Select friends to invite:")) ; std::cerr << "Inviting these friends:" << std::endl; if (!mChatId.isLobbyId()) return ; - for(std::list::const_iterator it(ids.begin());it!=ids.end();++it) + for(std::set::const_iterator it(ids.begin());it!=ids.end();++it) { std::cerr << " " << *it << std::endl; diff --git a/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp b/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp index fd927a1d3..4fdb660be 100644 --- a/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp @@ -33,7 +33,7 @@ #include "ChatDialog.h" #include "gui/ChatLobbyWidget.h" -CreateLobbyDialog::CreateLobbyDialog(const std::list& peer_list, int privacyLevel, QWidget *parent) : +CreateLobbyDialog::CreateLobbyDialog(const std::set& peer_list, int privacyLevel, QWidget *parent) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint) { ui = new Ui::CreateLobbyDialog() ; @@ -109,7 +109,7 @@ void CreateLobbyDialog::checkTextFields() void CreateLobbyDialog::createLobby() { - std::list shareList; + std::set shareList; ui->keyShareList->selectedIds(shareList, false); // if (shareList.empty()) { diff --git a/retroshare-gui/src/gui/chat/CreateLobbyDialog.h b/retroshare-gui/src/gui/chat/CreateLobbyDialog.h index 49a0b7337..2fe668674 100644 --- a/retroshare-gui/src/gui/chat/CreateLobbyDialog.h +++ b/retroshare-gui/src/gui/chat/CreateLobbyDialog.h @@ -13,7 +13,7 @@ public: /* *@param chanId The channel id to send request for */ - CreateLobbyDialog(const std::list& friends_list, int privacyLevel = 0, QWidget *parent = 0); + CreateLobbyDialog(const std::set& friends_list, int privacyLevel = 0, QWidget *parent = 0); ~CreateLobbyDialog(); protected: diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index b7615180b..719c2c03e 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -1343,8 +1343,11 @@ void FriendList::recommendfriend() default: return; } + std::set sids ; + for(std::list::const_iterator it(ids.begin());it!=ids.end();++it) + sids.insert(*it) ; - MessageComposer::recommendFriend(ids); + MessageComposer::recommendFriend(sids); } void FriendList::pastePerson() @@ -1596,7 +1599,7 @@ void FriendList::getSslIdsFromItem(QTreeWidgetItem *item, std::list &s { RsGroupInfo groupInfo; if (rsPeers->getGroupInfo(peerId, groupInfo)) { - std::list::iterator gpgIt; + std::set::iterator gpgIt; for (gpgIt = groupInfo.peerIds.begin(); gpgIt != groupInfo.peerIds.end(); ++gpgIt) { rsPeers->getAssociatedSSLIds(*gpgIt, sslIds); } diff --git a/retroshare-gui/src/gui/common/FriendSelectionDialog.cpp b/retroshare-gui/src/gui/common/FriendSelectionDialog.cpp index 6297970cc..01556eb49 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionDialog.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionDialog.cpp @@ -4,65 +4,65 @@ #include #include "FriendSelectionDialog.h" -std::list FriendSelectionDialog::selectFriends_PGP(QWidget *parent,const QString& caption,const QString& header_text, +std::set FriendSelectionDialog::selectFriends_PGP(QWidget *parent,const QString& caption,const QString& header_text, FriendSelectionWidget::Modus modus, FriendSelectionWidget::ShowTypes show_type, - const std::list& pre_selected_ids) + const std::set& pre_selected_ids) { - std::list psids ; - for(std::list::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it) - psids.push_back( (*it).toStdString() ) ; + std::set psids ; + for(std::set::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it) + psids.insert( (*it).toStdString() ) ; FriendSelectionDialog dialog(parent,header_text,modus,show_type,FriendSelectionWidget::IDTYPE_GPG,psids) ; dialog.setWindowTitle(caption) ; if(QDialog::Rejected == dialog.exec()) - return std::list() ; + return std::set() ; - std::list sids ; + std::set sids ; dialog.friends_widget->selectedIds(sids,false) ; return sids ; } -std::list FriendSelectionDialog::selectFriends_SSL(QWidget *parent,const QString& caption,const QString& header_text, +std::set FriendSelectionDialog::selectFriends_SSL(QWidget *parent,const QString& caption,const QString& header_text, FriendSelectionWidget::Modus modus, FriendSelectionWidget::ShowTypes show_type, - const std::list& pre_selected_ids) + const std::set& pre_selected_ids) { - std::list psids ; - for(std::list::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it) - psids.push_back( (*it).toStdString() ) ; + std::set psids ; + for(std::set::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it) + psids.insert( (*it).toStdString() ) ; FriendSelectionDialog dialog(parent,header_text,modus,show_type,FriendSelectionWidget::IDTYPE_SSL,psids) ; dialog.setWindowTitle(caption) ; if(QDialog::Rejected == dialog.exec()) - return std::list() ; + return std::set() ; - std::list sids ; + std::set sids ; dialog.friends_widget->selectedIds(sids,false) ; return sids ; } -std::list FriendSelectionDialog::selectFriends_GXS(QWidget *parent,const QString& caption,const QString& header_text, +std::set FriendSelectionDialog::selectFriends_GXS(QWidget *parent,const QString& caption,const QString& header_text, FriendSelectionWidget::Modus modus, FriendSelectionWidget::ShowTypes show_type, - const std::list& pre_selected_ids) + const std::set& pre_selected_ids) { - std::list psids ; - for(std::list::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it) - psids.push_back( (*it).toStdString() ) ; + std::set psids ; + for(std::set::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it) + psids.insert( (*it).toStdString() ) ; FriendSelectionDialog dialog(parent,header_text,modus,show_type,FriendSelectionWidget::IDTYPE_SSL,psids) ; dialog.setWindowTitle(caption) ; if(QDialog::Rejected == dialog.exec()) - return std::list() ; + return std::set() ; - std::list sids ; + std::set sids ; dialog.friends_widget->selectedIds(sids,false) ; return sids ; @@ -71,7 +71,7 @@ FriendSelectionDialog::FriendSelectionDialog(QWidget *parent,const QString& head FriendSelectionWidget::Modus modus, FriendSelectionWidget::ShowTypes show_type, FriendSelectionWidget::IdType pre_selected_id_type, - const std::list& pre_selected_ids) + const std::set& pre_selected_ids) : QDialog(parent) { friends_widget = new FriendSelectionWidget(this) ; diff --git a/retroshare-gui/src/gui/common/FriendSelectionDialog.h b/retroshare-gui/src/gui/common/FriendSelectionDialog.h index fd38fbf7d..0bd3b5614 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionDialog.h +++ b/retroshare-gui/src/gui/common/FriendSelectionDialog.h @@ -8,26 +8,26 @@ class FriendSelectionDialog : public QDialog { public: - static std::list selectFriends_PGP(QWidget *parent,const QString& caption,const QString& header_string, + static std::set selectFriends_PGP(QWidget *parent,const QString& caption,const QString& header_string, FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI, FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP, - const std::list& pre_selected_ids = std::list()) ; + const std::set& pre_selected_ids = std::set()) ; - static std::list selectFriends_SSL(QWidget *parent,const QString& caption,const QString& header_string, + static std::set selectFriends_SSL(QWidget *parent,const QString& caption,const QString& header_string, FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI, FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL, - const std::list& pre_selected_ids = std::list()) ; + const std::set& pre_selected_ids = std::set()) ; - static std::list selectFriends_GXS(QWidget *parent,const QString& caption,const QString& header_string, + static std::set selectFriends_GXS(QWidget *parent,const QString& caption,const QString& header_string, FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI, FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_GXS, - const std::list& pre_selected_ids = std::list()) ; + const std::set& pre_selected_ids = std::set()) ; private: virtual ~FriendSelectionDialog() ; FriendSelectionDialog(QWidget *parent,const QString& header_string,FriendSelectionWidget::Modus modus,FriendSelectionWidget::ShowTypes show_type, FriendSelectionWidget::IdType pre_selected_id_type, - const std::list& pre_selected_ids) ; + const std::set& pre_selected_ids) ; FriendSelectionWidget *friends_widget ; }; diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index 8108f6416..19b8c63c6 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -266,22 +266,22 @@ void FriendSelectionWidget::secured_fillList() mInFillList = true; // get selected items - std::list sslIdsSelected; + std::set sslIdsSelected; if (mShowTypes & SHOW_SSL) { selectedIds(sslIdsSelected,true); } - std::list groupIdsSelected; + std::set groupIdsSelected; if (mShowTypes & SHOW_GROUP) { selectedIds(groupIdsSelected,true); } - std::list gpgIdsSelected; + std::set gpgIdsSelected; if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) { selectedIds(gpgIdsSelected,true); } - std::list gxsIdsSelected; + std::set gxsIdsSelected; if (mShowTypes & SHOW_GXS) selectedIds(gxsIdsSelected,true); @@ -881,7 +881,7 @@ std::string FriendSelectionWidget::selectedId(IdType &idType) return idFromItem(item); } -void FriendSelectionWidget::selectedIds(IdType idType, std::list &ids, bool onlyDirectSelected) +void FriendSelectionWidget::selectedIds(IdType idType, std::set &ids, bool onlyDirectSelected) { QTreeWidgetItemIterator itemIterator(ui->friendList); QTreeWidgetItem *item; @@ -938,7 +938,7 @@ void FriendSelectionWidget::selectedIds(IdType idType, std::list &i break; } if (!id.empty() && std::find(ids.begin(), ids.end(), id) == ids.end()) { - ids.push_back(id); + ids.insert(id); } } } @@ -955,7 +955,7 @@ void FriendSelectionWidget::selectAll() setSelected(mListModus, *itemIterator, true); } -void FriendSelectionWidget::setSelectedIds(IdType idType, const std::list &ids, bool add) +void FriendSelectionWidget::setSelectedIds(IdType idType, const std::set &ids, bool add) { QTreeWidgetItemIterator itemIterator(ui->friendList); QTreeWidgetItem *item; @@ -973,7 +973,7 @@ void FriendSelectionWidget::setSelectedIds(IdType idType, const std::list void selectedIds(std::list& ids, bool onlyDirectSelected) + template void selectedIds(std::set& ids, bool onlyDirectSelected) { - std::list tmpids ; + std::set tmpids ; selectedIds(TYPE, tmpids, onlyDirectSelected); ids.clear() ; - for(std::list::const_iterator it(tmpids.begin());it!=tmpids.end();++it) - ids.push_back(ID_CLASS(*it)) ; + for(std::set::const_iterator it(tmpids.begin());it!=tmpids.end();++it) + ids.insert(ID_CLASS(*it)) ; } - template void setSelectedIds(const std::list& ids, bool add) + template void setSelectedIds(const std::set& ids, bool add) { - std::list tmpids ; - for(typename std::list::const_iterator it(ids.begin());it!=ids.end();++it) - tmpids.push_back((*it).toStdString()) ; + std::set tmpids ; + for(typename std::set::const_iterator it(ids.begin());it!=ids.end();++it) + tmpids.insert((*it).toStdString()) ; setSelectedIds(TYPE, tmpids, add); } @@ -137,8 +137,8 @@ private: void secured_fillList(); bool filterItem(QTreeWidgetItem *item, const QString &text); - void selectedIds(IdType idType, std::list &ids, bool onlyDirectSelected); - void setSelectedIds(IdType idType, const std::list &ids, bool add); + void selectedIds(IdType idType, std::set &ids, bool onlyDirectSelected); + void setSelectedIds(IdType idType, const std::set &ids, bool add); void requestGXSIdList() ; diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 29f32e564..a61ff4d3a 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -562,7 +562,7 @@ bool ConnectFriendWizard::validateCurrentPage() break; case Page_FriendRecommendations: { - std::list recommendIds; + std::set recommendIds; ui->frec_recommendList->selectedIds(recommendIds, false); if (recommendIds.empty()) { @@ -570,7 +570,7 @@ bool ConnectFriendWizard::validateCurrentPage() return false; } - std::list toIds; + std::set toIds; ui->frec_toList->selectedIds(toIds, false); if (toIds.empty()) { @@ -578,7 +578,7 @@ bool ConnectFriendWizard::validateCurrentPage() return false; } - std::list::iterator toId; + std::set::iterator toId; for (toId = toIds.begin(); toId != toIds.end(); ++toId) { MessageComposer::recommendFriend(recommendIds, *toId, ui->frec_messageEdit->toHtml(), true); } diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp index edad9f61e..8431226cc 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp @@ -249,7 +249,7 @@ void ChatMsgItem::sendMessage() mi.title = tr("Quick Message").toUtf8().constData(); mi.msg = quickmsgText->toHtml().toUtf8().constData(); - mi.rspeerid_msgto.push_back(mPeerId); + mi.rspeerid_msgto.insert(mPeerId); rsMail->MessageSend(mi); diff --git a/retroshare-gui/src/gui/groups/CreateGroup.cpp b/retroshare-gui/src/gui/groups/CreateGroup.cpp index 3b7ecfd5b..7a919f93a 100644 --- a/retroshare-gui/src/gui/groups/CreateGroup.cpp +++ b/retroshare-gui/src/gui/groups/CreateGroup.cpp @@ -131,12 +131,12 @@ void CreateGroup::changeGroup() } } - std::list gpgIds; + std::set gpgIds; ui.friendList->selectedIds(gpgIds, true); - std::list::iterator it; + std::set::iterator it; for (it = groupInfo.peerIds.begin(); it != groupInfo.peerIds.end(); ++it) { - std::list::iterator gpgIt = std::find(gpgIds.begin(), gpgIds.end(), *it); + std::set::iterator gpgIt = std::find(gpgIds.begin(), gpgIds.end(), *it); if (gpgIt == gpgIds.end()) { rsPeers->assignPeerToGroup(groupInfo.id, *it, false); continue; diff --git a/retroshare-gui/src/gui/gxs/GxsGroupShareKey.cpp b/retroshare-gui/src/gui/gxs/GxsGroupShareKey.cpp index 90d42017f..32821456e 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupShareKey.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupShareKey.cpp @@ -110,7 +110,7 @@ void GroupShareKey::setTyp() void GroupShareKey::shareKey() { - std::list shareList; + std::set shareList; ui->keyShareList->selectedIds(shareList, false); if (shareList.empty()) { diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 7193d25a5..bb4377397 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -451,12 +451,12 @@ void MessageComposer::processSettings(bool bLoad) /* window will destroy itself! */ } -static QString buildRecommendHtml(const std::list &sslIds, const RsPeerId& excludeId = RsPeerId()) +static QString buildRecommendHtml(const std::set &sslIds, const RsPeerId& excludeId = RsPeerId()) { QString text; /* process ssl ids */ - std::list ::const_iterator sslIt; + std::set ::const_iterator sslIt; for (sslIt = sslIds.begin(); sslIt != sslIds.end(); ++sslIt) { if (*sslIt == excludeId) { continue; @@ -475,7 +475,7 @@ QString MessageComposer::recommendMessage() return tr("Hello,
I recommend a good friend of mine; you can trust them too when you trust me.
"); } -void MessageComposer::recommendFriend(const std::list &sslIds, const RsPeerId &to, const QString &msg, bool autoSend) +void MessageComposer::recommendFriend(const std::set &sslIds, const RsPeerId &to, const QString &msg, bool autoSend) { // std::cerr << "MessageComposer::recommendFriend()" << std::endl; @@ -509,7 +509,7 @@ void MessageComposer::recommendFriend(const std::list &sslIds, const sMsgText += tr("Thanks,
") + QString::fromUtf8(rsPeers->getGPGName(rsPeers->getGPGOwnId()).c_str()); composer->setMsgText(sMsgText); - std::list ::const_iterator peerIt; + std::set ::const_iterator peerIt; for (peerIt = sslIds.begin(); peerIt != sslIds.end(); ++peerIt) { if (*peerIt == to) { continue; @@ -876,7 +876,7 @@ static void calculateGroupsOfSslIds(const std::list &existingGroupI } // iterate all assigned peers (gpg id's) - std::list::const_iterator peerIt; + std::set::const_iterator peerIt; for (peerIt = groupInfoIt->peerIds.begin(); peerIt != groupInfoIt->peerIds.end(); ++peerIt) { std::list sslIds; @@ -913,7 +913,7 @@ static void calculateGroupsOfSslIds(const std::list &existingGroupI // remove all ssl id's of all found groups from the list for (groupInfoIt = groupInfos.begin(); groupInfoIt != groupInfos.end(); ++groupInfoIt) { // iterate all assigned peers (gpg id's) - std::list::const_iterator peerIt; + std::set::const_iterator peerIt; for (peerIt = groupInfoIt->peerIds.begin(); peerIt != groupInfoIt->peerIds.end(); ++peerIt) { std::list sslIds; @@ -997,12 +997,12 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/) // msgComposer->addRecipient(MessageComposer::BCC, *groupIt, true) ; // } - for (std::list::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); ++it ) msgComposer->addRecipient(MessageComposer::TO, *it) ; - for (std::list::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::CC, *it) ; - for (std::list::const_iterator it = msgInfo.rspeerid_msgbcc.begin(); it != msgInfo.rspeerid_msgbcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::BCC, *it) ; - for (std::list::const_iterator it = msgInfo.rsgxsid_msgto.begin(); it != msgInfo.rsgxsid_msgto.end(); ++it ) msgComposer->addRecipient(MessageComposer::TO, *it) ; - for (std::list::const_iterator it = msgInfo.rsgxsid_msgcc.begin(); it != msgInfo.rsgxsid_msgcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::CC, *it) ; - for (std::list::const_iterator it = msgInfo.rsgxsid_msgbcc.begin(); it != msgInfo.rsgxsid_msgbcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::BCC, *it) ; + for (std::set::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); ++it ) msgComposer->addRecipient(MessageComposer::TO, *it) ; + for (std::set::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::CC, *it) ; + for (std::set::const_iterator it = msgInfo.rspeerid_msgbcc.begin(); it != msgInfo.rspeerid_msgbcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::BCC, *it) ; + for (std::set::const_iterator it = msgInfo.rsgxsid_msgto.begin(); it != msgInfo.rsgxsid_msgto.end(); ++it ) msgComposer->addRecipient(MessageComposer::TO, *it) ; + for (std::set::const_iterator it = msgInfo.rsgxsid_msgcc.begin(); it != msgInfo.rsgxsid_msgcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::CC, *it) ; + for (std::set::const_iterator it = msgInfo.rsgxsid_msgbcc.begin(); it != msgInfo.rsgxsid_msgbcc.end(); ++it ) msgComposer->addRecipient(MessageComposer::BCC, *it) ; MsgTagInfo tagInfo; rsMail->getMessageTag(msgId, tagInfo); @@ -1024,7 +1024,7 @@ QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo) QString from = link.toHtml(); QString to; - for ( std::list::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); ++it) + for ( std::set::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); ++it) if (link.createMessage(*it, "")) { if (!to.isEmpty()) @@ -1032,7 +1032,7 @@ QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo) to += link.toHtml(); } - for ( std::list::const_iterator it = msgInfo.rsgxsid_msgto.begin(); it != msgInfo.rsgxsid_msgto.end(); ++it) + for ( std::set::const_iterator it = msgInfo.rsgxsid_msgto.begin(); it != msgInfo.rsgxsid_msgto.end(); ++it) if (link.createMessage(*it, "")) { if (!to.isEmpty()) @@ -1043,14 +1043,14 @@ QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo) QString cc; - for (std::list::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); ++it) + for (std::set::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); ++it) if (link.createMessage(*it, "")) { if (!cc.isEmpty()) { cc += ", "; } cc += link.toHtml(); } - for (std::list::const_iterator it = msgInfo.rsgxsid_msgcc.begin(); it != msgInfo.rsgxsid_msgcc.end(); ++it) + for (std::set::const_iterator it = msgInfo.rsgxsid_msgcc.begin(); it != msgInfo.rsgxsid_msgcc.end(); ++it) if (link.createMessage(*it, "")) { if (!cc.isEmpty()) { cc += ", "; @@ -1137,19 +1137,19 @@ MessageComposer *MessageComposer::replyMsg(const std::string &msgId, bool all) { RsPeerId ownId = rsPeers->getOwnId(); - for (std::list::iterator tli = msgInfo.rspeerid_msgto.begin(); tli != msgInfo.rspeerid_msgto.end(); ++tli) + for (std::set::iterator tli = msgInfo.rspeerid_msgto.begin(); tli != msgInfo.rspeerid_msgto.end(); ++tli) if (ownId != *tli) msgComposer->addRecipient(MessageComposer::TO, *tli) ; - for (std::list::iterator tli = msgInfo.rspeerid_msgcc.begin(); tli != msgInfo.rspeerid_msgcc.end(); ++tli) + for (std::set::iterator tli = msgInfo.rspeerid_msgcc.begin(); tli != msgInfo.rspeerid_msgcc.end(); ++tli) if (ownId != *tli) msgComposer->addRecipient(MessageComposer::TO, *tli) ; - for (std::list::iterator tli = msgInfo.rsgxsid_msgto.begin(); tli != msgInfo.rsgxsid_msgto.end(); ++tli) + for (std::set::iterator tli = msgInfo.rsgxsid_msgto.begin(); tli != msgInfo.rsgxsid_msgto.end(); ++tli) //if (ownId != *tli) msgComposer->addRecipient(MessageComposer::TO, *tli) ; - for (std::list::iterator tli = msgInfo.rsgxsid_msgcc.begin(); tli != msgInfo.rsgxsid_msgcc.end(); ++tli) + for (std::set::iterator tli = msgInfo.rsgxsid_msgcc.begin(); tli != msgInfo.rsgxsid_msgcc.end(); ++tli) //if (ownId != *tli) msgComposer->addRecipient(MessageComposer::TO, *tli) ; } @@ -1245,8 +1245,6 @@ void MessageComposer::sendMessage() } } -template void addUnique(std::list& lst,const T& t) { if(std::find(lst.begin(),lst.end(),t) == lst.end()) lst.push_back(t) ; } - bool MessageComposer::sendMessage_internal(bool bDraftbox) { /* construct a message */ @@ -1316,7 +1314,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox) continue; } - std::list::const_iterator groupIt; + std::set::const_iterator groupIt; for (groupIt = groupInfo.peerIds.begin(); groupIt != groupInfo.peerIds.end(); ++groupIt) { std::list sslIds; rsPeers->getAssociatedSSLIds(*groupIt, sslIds); @@ -1330,11 +1328,11 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox) switch (type) { - case TO: addUnique(mi.rspeerid_msgto,*sslIt); + case TO: mi.rspeerid_msgto.insert(*sslIt); break; - case CC: addUnique(mi.rspeerid_msgcc,*sslIt); + case CC: mi.rspeerid_msgcc.insert(*sslIt); break; - case BCC:addUnique(mi.rspeerid_msgbcc,*sslIt); + case BCC:mi.rspeerid_msgbcc.insert(*sslIt); break; } } @@ -1347,11 +1345,11 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox) switch (type) { - case TO: addUnique(mi.rspeerid_msgto,pid); + case TO: mi.rspeerid_msgto.insert(pid); break ; - case CC: addUnique(mi.rspeerid_msgcc,pid); + case CC: mi.rspeerid_msgcc.insert(pid); break ; - case BCC:addUnique(mi.rspeerid_msgbcc,pid); + case BCC:mi.rspeerid_msgbcc.insert(pid); break ; } } @@ -1362,11 +1360,11 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox) switch (type) { - case TO: addUnique(mi.rsgxsid_msgto,gid) ; + case TO: mi.rsgxsid_msgto.insert(gid) ; break ; - case CC: addUnique(mi.rsgxsid_msgcc,gid) ; + case CC: mi.rsgxsid_msgcc.insert(gid) ; break ; - case BCC:addUnique(mi.rsgxsid_msgbcc,gid) ; + case BCC:mi.rsgxsid_msgbcc.insert(gid) ; break ; } } @@ -2472,16 +2470,16 @@ void MessageComposer::fileHashingFinished(QList hashedFiles) void MessageComposer::addContact(enumType type) { - std::list peerIds ; + std::set peerIds ; ui.friendSelectionWidget->selectedIds(peerIds, false); - for (std::list::const_iterator idIt = peerIds.begin(); idIt != peerIds.end(); ++idIt) + for (std::set::const_iterator idIt = peerIds.begin(); idIt != peerIds.end(); ++idIt) addRecipient(type, *idIt); - std::list gxsIds ; + std::set gxsIds ; ui.friendSelectionWidget->selectedIds(gxsIds, false); - for (std::list::const_iterator idIt = gxsIds.begin(); idIt != gxsIds.end(); ++idIt) + for (std::set::const_iterator idIt = gxsIds.begin(); idIt != gxsIds.end(); ++idIt) addRecipient(type, *idIt); } @@ -2522,18 +2520,18 @@ void MessageComposer::addBcc() void MessageComposer::addRecommend() { - std::list sslIds; + std::set sslIds; ui.friendSelectionWidget->selectedIds(sslIds, false); - std::list gxsIds ; + std::set gxsIds ; ui.friendSelectionWidget->selectedIds(gxsIds, true); if (sslIds.empty() && gxsIds.empty()) return; - for(std::list ::iterator it = sslIds.begin(); it != sslIds.end(); ++it) + for(std::set ::iterator it = sslIds.begin(); it != sslIds.end(); ++it) addRecipient(CC, *it); - for (std::list::const_iterator it = gxsIds.begin(); it != gxsIds.end(); ++it) + for (std::set::const_iterator it = gxsIds.begin(); it != gxsIds.end(); ++it) addRecipient(TO, *it); QString text = buildRecommendHtml(sslIds); diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index 4f42eebdd..a5511c72a 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -60,7 +60,7 @@ public: static void msgGroup(const std::string& group_id) ; static QString recommendMessage(); - static void recommendFriend(const std::list &sslIds, const RsPeerId &to = RsPeerId(), const QString &msg = "", bool autoSend = false); + static void recommendFriend(const std::set &sslIds, const RsPeerId &to = RsPeerId(), const QString &msg = "", bool autoSend = false); static void sendConnectAttemptMsg(const RsPgpId &gpgId, const RsPeerId &sslId, const QString &sslName); static void sendChannelPublishKey(RsGxsChannelGroup &group); static void sendForumPublishKey(RsGxsForumGroup &group); diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index d56220213..35c9f82ec 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -508,8 +508,8 @@ void MessageWidget::fill(const std::string &msgId) RetroShareLink link; QString text; - for(std::list::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; - for(std::list::const_iterator pit = msgInfo.rsgxsid_msgto.begin(); pit != msgInfo.rsgxsid_msgto.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; + for(std::set::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; + for(std::set::const_iterator pit = msgInfo.rsgxsid_msgto.begin(); pit != msgInfo.rsgxsid_msgto.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; ui.toText->setText(text); @@ -519,8 +519,8 @@ void MessageWidget::fill(const std::string &msgId) ui.ccText->setVisible(true); text.clear(); - for(std::list::const_iterator pit = msgInfo.rspeerid_msgcc.begin(); pit != msgInfo.rspeerid_msgcc.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; - for(std::list::const_iterator pit = msgInfo.rsgxsid_msgcc.begin(); pit != msgInfo.rsgxsid_msgcc.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; + for(std::set::const_iterator pit = msgInfo.rspeerid_msgcc.begin(); pit != msgInfo.rspeerid_msgcc.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; + for(std::set::const_iterator pit = msgInfo.rsgxsid_msgcc.begin(); pit != msgInfo.rsgxsid_msgcc.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; ui.ccText->setText(text); } else { @@ -535,8 +535,8 @@ void MessageWidget::fill(const std::string &msgId) ui.bccText->setVisible(true); text.clear(); - for(std::list::const_iterator pit = msgInfo.rspeerid_msgbcc.begin(); pit != msgInfo.rspeerid_msgbcc.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; - for(std::list::const_iterator pit = msgInfo.rsgxsid_msgbcc.begin(); pit != msgInfo.rsgxsid_msgbcc.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; + for(std::set::const_iterator pit = msgInfo.rspeerid_msgbcc.begin(); pit != msgInfo.rspeerid_msgbcc.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; + for(std::set::const_iterator pit = msgInfo.rsgxsid_msgbcc.begin(); pit != msgInfo.rsgxsid_msgbcc.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; ui.bccText->setText(text); } else {