Changed p3Peers::getPeerCount to count also gpg id's only.

Show count of friends in MainWindow, not the count of locations.

Recompile of GUI needed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3653 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-10-08 12:03:25 +00:00
parent 0e063f9a1b
commit 1207b5793b
6 changed files with 54 additions and 21 deletions

View File

@ -473,10 +473,6 @@ void p3ConnectMgr::addNetListener(pqiNetListener *listener)
mNetListeners.push_back(listener);
}
void p3ConnectMgr::netStatusReset_locked()
{
//std::cerr << "p3ConnectMgr::netStatusReset()" << std::endl;;
@ -1598,21 +1594,60 @@ void p3ConnectMgr::getOthersList(std::list<std::string> &peers)
#endif
void p3ConnectMgr::getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount)
bool p3ConnectMgr::getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount, bool ssl)
{
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
if (ssl) {
/* count ssl id's */
if (pnFriendCount) *pnFriendCount = mFriendList.size();
if (pnOnlineCount) {
*pnOnlineCount = 0;
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
std::map<std::string, peerConnectState>::iterator it;
for(it = mFriendList.begin(); it != mFriendList.end(); it++) {
if (it->second.state & RS_PEER_S_CONNECTED) {
(*pnOnlineCount)++;
if (pnFriendCount) *pnFriendCount = mFriendList.size();
if (pnOnlineCount) {
*pnOnlineCount = 0;
std::map<std::string, peerConnectState>::iterator it;
for (it = mFriendList.begin(); it != mFriendList.end(); it++) {
if (it->second.state & RS_PEER_S_CONNECTED) {
(*pnOnlineCount)++;
}
}
}
} else {
/* count gpg id's */
if (pnFriendCount) *pnFriendCount = 0;
if (pnOnlineCount) *pnOnlineCount = 0;
std::list<std::string> gpgIds;
if (AuthGPG::getAuthGPG()->getGPGAcceptedList(gpgIds) == false) {
return false;
}
if (pnFriendCount) *pnFriendCount = gpgIds.size();
if (pnOnlineCount) {
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
/* 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 (gpgIt != gpgIds.end()) {
(*pnOnlineCount)++;
gpgIds.erase(gpgIt);
if (gpgIds.empty()) {
/* no more gpg id's to check */
break;
}
}
}
}
}
}
return true;
}
@ -2644,8 +2679,6 @@ bool p3ConnectMgr::addAddressIfUnique(std::list<peerConnectAddress> &addrList,
* in the list
*/
bool found = false;
std::list<peerConnectAddress>::iterator it;
for(it = addrList.begin(); it != addrList.end(); it++)
{

View File

@ -281,7 +281,7 @@ bool getOthersNetStatus(std::string id, peerConnectState &state);
void getOnlineList(std::list<std::string> &ssl_peers);
void getFriendList(std::list<std::string> &ssl_peers);
//void getOthersList(std::list<std::string> &peers); /deprecated
void getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount);
bool getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount, bool ssl);
/**************** handle monitors *****************/

View File

@ -159,7 +159,7 @@ virtual std::string getOwnId() = 0;
virtual bool getOnlineList(std::list<std::string> &ssl_ids) = 0;
virtual bool getFriendList(std::list<std::string> &ssl_ids) = 0;
//virtual bool getOthersList(std::list<std::string> &ssl_ids) = 0;
virtual void getPeerCount (unsigned int *pnFriendCount, unsigned int *pnnOnlineCount) = 0;
virtual bool getPeerCount (unsigned int *pnFriendCount, unsigned int *pnnOnlineCount, bool ssl) = 0;
virtual bool isOnline(std::string ssl_id) = 0;
virtual bool isFriend(std::string ssl_id) = 0;

View File

@ -221,14 +221,14 @@ bool p3Peers::getFriendList(std::list<std::string> &ids)
// return true;
//}
void p3Peers::getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount)
bool p3Peers::getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount, bool ssl)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPeerCount()" << std::endl;
#endif
/* get from mConnectMgr */
mConnMgr->getPeerCount(pnFriendCount, pnOnlineCount);
return mConnMgr->getPeerCount(pnFriendCount, pnOnlineCount, ssl);
}
bool p3Peers::isOnline(std::string id)

View File

@ -46,7 +46,7 @@ virtual std::string getOwnId();
virtual bool getOnlineList(std::list<std::string> &ids);
virtual bool getFriendList(std::list<std::string> &ids);
//virtual bool getOthersList(std::list<std::string> &ids);
virtual void getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount);
virtual bool getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount, bool ssl);
virtual bool isOnline(std::string id);
virtual bool isFriend(std::string id);

View File

@ -514,7 +514,7 @@ void MainWindow::updateStatus()
unsigned int nFriendCount = 0;
unsigned int nOnlineCount = 0;
rsPeers->getPeerCount (&nFriendCount, &nOnlineCount);
rsPeers->getPeerCount (&nFriendCount, &nOnlineCount, false);
if (ratesstatus)
ratesstatus->getRatesStatus();