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 (pnOnlineCount) *pnOnlineCount = 0;
std::list<std::string> gpgIds;
if (AuthGPG::getAuthGPG()->getGPGAcceptedList(gpgIds) == false) {
return false;
}
if (pnFriendCount || pnOnlineCount) {
std::list<std::string> gpgIds;
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 *******/
std::list<std::string>::iterator gpgIt;
/* check ssl id's */
std::map<std::string, peerConnectState>::iterator it;
for (it = mFriendList.begin(); it != mFriendList.end(); it++) {
if (it->second.state & RS_PEER_S_CONNECTED) {
std::list<std::string>::iterator gpgIt = std::find(gpgIds.begin(), gpgIds.end(), it->second.gpg_id);
if (pnFriendCount && gpgIds.size()) {
gpgIt = std::find(gpgIds.begin(), gpgIds.end(), it->second.gpg_id);
if (gpgIt != gpgIds.end()) {
(*pnOnlineCount)++;
(*pnFriendCount)++;
gpgIds.erase(gpgIt);
}
}
if (gpgIds.empty()) {
/* no more gpg id's to check */
break;
if (pnOnlineCount && gpgOnlineIds.size()) {
if (it->second.state & RS_PEER_S_CONNECTED) {
gpgIt = std::find(gpgOnlineIds.begin(), gpgOnlineIds.end(), it->second.gpg_id);
if (gpgIt != gpgOnlineIds.end()) {
(*pnOnlineCount)++;
gpgOnlineIds.erase(gpgIt);
}
}
}