Count the own gpg id as friend, when another location exists.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3896 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-12-05 00:20:11 +00:00
parent 207dddf4d8
commit 38203704f0

View File

@ -1630,28 +1630,38 @@ bool p3ConnectMgr::getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOn
if (pnFriendCount) *pnFriendCount = 0; if (pnFriendCount) *pnFriendCount = 0;
if (pnOnlineCount) *pnOnlineCount = 0; if (pnOnlineCount) *pnOnlineCount = 0;
std::list<std::string> gpgIds; if (pnFriendCount || pnOnlineCount) {
if (AuthGPG::getAuthGPG()->getGPGAcceptedList(gpgIds) == false) { std::list<std::string> gpgIds;
return false; if (AuthGPG::getAuthGPG()->getGPGAcceptedList(gpgIds) == false) {
} return false;
}
if (pnFriendCount) *pnFriendCount = gpgIds.size(); /* add own id */
gpgIds.push_back(AuthGPG::getAuthGPG()->getGPGOwnId());
std::list<std::string> gpgOnlineIds = gpgIds;
if (pnOnlineCount) {
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
std::list<std::string>::iterator gpgIt;
/* check ssl id's */ /* check ssl id's */
std::map<std::string, peerConnectState>::iterator it; std::map<std::string, peerConnectState>::iterator it;
for (it = mFriendList.begin(); it != mFriendList.end(); it++) { for (it = mFriendList.begin(); it != mFriendList.end(); it++) {
if (it->second.state & RS_PEER_S_CONNECTED) { if (pnFriendCount && gpgIds.size()) {
std::list<std::string>::iterator gpgIt = std::find(gpgIds.begin(), gpgIds.end(), it->second.gpg_id); gpgIt = std::find(gpgIds.begin(), gpgIds.end(), it->second.gpg_id);
if (gpgIt != gpgIds.end()) { if (gpgIt != gpgIds.end()) {
(*pnOnlineCount)++; (*pnFriendCount)++;
gpgIds.erase(gpgIt); gpgIds.erase(gpgIt);
}
}
if (gpgIds.empty()) { if (pnOnlineCount && gpgOnlineIds.size()) {
/* no more gpg id's to check */ if (it->second.state & RS_PEER_S_CONNECTED) {
break; gpgIt = std::find(gpgOnlineIds.begin(), gpgOnlineIds.end(), it->second.gpg_id);
if (gpgIt != gpgOnlineIds.end()) {
(*pnOnlineCount)++;
gpgOnlineIds.erase(gpgIt);
} }
} }
} }