diff --git a/libretroshare/src/pqi/p3connmgr.cc b/libretroshare/src/pqi/p3connmgr.cc index 029048172..2b8aeff9a 100644 --- a/libretroshare/src/pqi/p3connmgr.cc +++ b/libretroshare/src/pqi/p3connmgr.cc @@ -1523,6 +1523,23 @@ void p3ConnectMgr::getFriendList(std::list &peers) //} +void p3ConnectMgr::getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount) +{ + RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/ + + if (pnFriendCount) *pnFriendCount = mFriendList.size(); + if (pnOnlineCount) { + *pnOnlineCount = 0; + + std::map::iterator it; + for(it = mFriendList.begin(); it != mFriendList.end(); it++) { + if (it->second.state & RS_PEER_S_CONNECTED) { + (*pnOnlineCount)++; + } + } + } +} + bool p3ConnectMgr::connectAttempt(std::string id, struct sockaddr_in &addr, uint32_t &delay, uint32_t &period, uint32_t &type) diff --git a/libretroshare/src/pqi/p3connmgr.h b/libretroshare/src/pqi/p3connmgr.h index a68b24706..bdd4d3683 100644 --- a/libretroshare/src/pqi/p3connmgr.h +++ b/libretroshare/src/pqi/p3connmgr.h @@ -258,6 +258,7 @@ bool getOthersNetStatus(std::string id, peerConnectState &state); void getOnlineList(std::list &ssl_peers); void getFriendList(std::list &ssl_peers); //void getOthersList(std::list &peers); /deprecated +void getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount); /**************** handle monitors *****************/ diff --git a/libretroshare/src/rsiface/rsmsgs.h b/libretroshare/src/rsiface/rsmsgs.h index cd82c3e33..afa00103d 100644 --- a/libretroshare/src/rsiface/rsmsgs.h +++ b/libretroshare/src/rsiface/rsmsgs.h @@ -121,6 +121,7 @@ virtual ~RsMsgs() { return; } virtual bool getMessageSummaries(std::list &msgList) = 0; virtual bool getMessage(std::string mId, MessageInfo &msg) = 0; +virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox) = 0; virtual bool MessageSend(MessageInfo &info) = 0; virtual bool MessageDelete(std::string mid) = 0; diff --git a/libretroshare/src/rsiface/rspeers.h b/libretroshare/src/rsiface/rspeers.h index 857347248..389dcdbcb 100644 --- a/libretroshare/src/rsiface/rspeers.h +++ b/libretroshare/src/rsiface/rspeers.h @@ -138,6 +138,7 @@ virtual std::string getOwnId() = 0; virtual bool getOnlineList(std::list &ssl_ids) = 0; virtual bool getFriendList(std::list &ssl_ids) = 0; //virtual bool getOthersList(std::list &ssl_ids) = 0; +virtual void getPeerCount (unsigned int *pnFriendCount, unsigned int *pnnOnlineCount) = 0; virtual bool isOnline(std::string ssl_id) = 0; virtual bool isFriend(std::string ssl_id) = 0; diff --git a/libretroshare/src/rsserver/p3msgs.cc b/libretroshare/src/rsserver/p3msgs.cc index 15fac107b..abbabb3a9 100644 --- a/libretroshare/src/rsserver/p3msgs.cc +++ b/libretroshare/src/rsserver/p3msgs.cc @@ -62,7 +62,10 @@ bool p3Msgs::getMessage(std::string mid, MessageInfo &msg) return mMsgSrv->getMessage(mid, msg); } - +void p3Msgs::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox) +{ + mMsgSrv->getMessageCount(pnInbox, pnInboxNew, pnOutbox, pnDraftbox, pnSentbox); +} /****************************************/ /****************************************/ diff --git a/libretroshare/src/rsserver/p3msgs.h b/libretroshare/src/rsserver/p3msgs.h index b0c4ad3ac..65736a2a3 100644 --- a/libretroshare/src/rsserver/p3msgs.h +++ b/libretroshare/src/rsserver/p3msgs.h @@ -55,6 +55,7 @@ class p3Msgs: public RsMsgs */ virtual bool getMessageSummaries(std::list &msgList); virtual bool getMessage(std::string mId, MessageInfo &msg); + virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox); virtual bool MessageSend(MessageInfo &info); virtual bool MessageDelete(std::string mid); diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index 859ea5838..596bbb86a 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -221,6 +221,16 @@ bool p3Peers::getFriendList(std::list &ids) // return true; //} +void p3Peers::getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount) +{ +#ifdef P3PEERS_DEBUG + std::cerr << "p3Peers::getPeerCount()" << std::endl; +#endif + + /* get from mConnectMgr */ + mConnMgr->getPeerCount(pnFriendCount, pnOnlineCount); +} + bool p3Peers::isOnline(std::string id) { #ifdef P3PEERS_DEBUG diff --git a/libretroshare/src/rsserver/p3peers.h b/libretroshare/src/rsserver/p3peers.h index 9f0110d3f..593dfcf94 100644 --- a/libretroshare/src/rsserver/p3peers.h +++ b/libretroshare/src/rsserver/p3peers.h @@ -46,6 +46,7 @@ virtual std::string getOwnId(); virtual bool getOnlineList(std::list &ids); virtual bool getFriendList(std::list &ids); //virtual bool getOthersList(std::list &ids); +virtual void getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount); virtual bool isOnline(std::string id); virtual bool isFriend(std::string id); diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index 0f1f1f1db..d255ab427 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -455,7 +455,7 @@ bool p3MsgService::getMessageSummaries(std::list &msgList) initRsMIS(mit->second, mis); msgList.push_back(mis); } - return 1; + return true; } @@ -481,6 +481,44 @@ bool p3MsgService::getMessage(std::string mId, MessageInfo &msg) return true; } +void p3MsgService::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox) +{ + RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/ + + if (pnInbox) *pnInbox = 0; + if (pnInboxNew) *pnInboxNew = 0; + if (pnOutbox) *pnOutbox = 0; + if (pnDraftbox) *pnDraftbox = 0; + if (pnSentbox) *pnSentbox = 0; + + std::map::iterator mit; + std::map *apMsg [2] = { &imsg, &msgOutgoing }; + + for (int i = 0; i < 2; i++) { + for (mit = apMsg [i]->begin(); mit != apMsg [i]->end(); mit++) { + MsgInfoSummary mis; + initRsMIS(mit->second, mis); + + switch (mis.msgflags & RS_MSG_BOXMASK) { + case RS_MSG_INBOX: + if (pnInbox) (*pnInbox)++; + if ((mis.msgflags & RS_MSG_NEW) == RS_MSG_NEW) { + if (pnInboxNew) (*pnInboxNew)++; + } + break; + case RS_MSG_OUTBOX: + if (pnOutbox) (*pnOutbox)++; + break; + case RS_MSG_DRAFTBOX: + if (pnDraftbox) (*pnDraftbox)++; + break; + case RS_MSG_SENTBOX: + if (pnSentbox) (*pnSentbox)++; + break; + } + } + } +} /* remove based on the unique mid (stored in sid) */ bool p3MsgService::removeMsgId(std::string mid) diff --git a/libretroshare/src/services/p3msgservice.h b/libretroshare/src/services/p3msgservice.h index 4eac57a8a..a1d5e3b27 100644 --- a/libretroshare/src/services/p3msgservice.h +++ b/libretroshare/src/services/p3msgservice.h @@ -57,6 +57,7 @@ bool getMessageNotifications(std::list ¬eList); bool getMessageSummaries(std::list &msgList); bool getMessage(std::string mid, MessageInfo &msg); +void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox); bool removeMsgId(std::string mid); bool markMsgIdRead(std::string mid); diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 7930cdb8c..90a0a787d 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -351,19 +351,11 @@ void MainWindow::updateStatus() if (natstatus) natstatus->getNATStatus(); - std::list ids; - rsPeers->getOnlineList(ids); - int online = ids.size(); + unsigned int online = 0; + rsPeers->getPeerCount (NULL, &online); - std::list msgList; - std::list::const_iterator it; - - rsMsgs -> getMessageSummaries(msgList); - int newInboxCount = 0; - - for(it = msgList.begin(); it != msgList.end(); it++) - if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_INBOX && ((it -> msgflags & RS_MSG_NEW) == RS_MSG_NEW)) - newInboxCount ++; + unsigned int newInboxCount = 0; + rsMsgs->getMessageCount (NULL, &newInboxCount, NULL, NULL, NULL); if(newInboxCount) messageAction->setIcon(QIcon(QPixmap(":/images/messages_new.png"))) ; diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 219d090d5..fd6142e44 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -79,12 +79,14 @@ public: Transfers, /** Transfers page. */ SharedDirectories, /** Shared Directories page. */ Messages, /** Messages page. */ +#ifndef RS_RELEASE_VERSION Links, /** Links page. */ Channels, /** Channels page. */ +#endif Forums, /** Forums page. */ - Blogs /** Blogs page. */ - - +#ifdef BLOGS + Blogs, /** Blogs page. */ +#endif }; /** Create main window */ diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index 2e2b769c7..f065798b4 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -1381,39 +1381,14 @@ void MessagesDialog::filterColumnChanged() void MessagesDialog::updateMessageSummaryList() { - std::list msgList; - std::list::const_iterator it; + unsigned int newInboxCount = 0; + unsigned int newOutboxCount = 0; + unsigned int newDraftCount = 0; + unsigned int newSentboxCount = 0; + unsigned int inboxCount = 0; - rsMsgs -> getMessageSummaries(msgList); - int newInboxCount = 0; - int newOutboxCount = 0; - int newDraftCount = 0; - int newSentboxCount = 0; - int inboxCount = 0; - - /*calculating the new messages*/ - for(it = msgList.begin(); it != msgList.end(); it++) - { - if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_INBOX) - { - inboxCount ++; - if ((it -> msgflags & RS_MSG_NEW) == RS_MSG_NEW) { - newInboxCount ++; - } - } - if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX) - { - newOutboxCount ++; - } - if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_DRAFTBOX) - { - newDraftCount ++; - } - if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_SENTBOX ) - { - newSentboxCount ++; - } - } + /* calculating the new messages */ + rsMsgs->getMessageCount (&inboxCount, &newInboxCount, &newOutboxCount, &newDraftCount, &newSentboxCount); QString textItem; /*updating the labels in leftcolumn*/ diff --git a/retroshare-gui/src/gui/feeds/SubFileItem.cpp b/retroshare-gui/src/gui/feeds/SubFileItem.cpp index 46bad5761..71477f7e6 100644 --- a/retroshare-gui/src/gui/feeds/SubFileItem.cpp +++ b/retroshare-gui/src/gui/feeds/SubFileItem.cpp @@ -67,8 +67,7 @@ const uint32_t SFI_DEFAULT_PERIOD = (30 * 3600 * 24); /* 30 Days */ /** Constructor */ SubFileItem::SubFileItem(std::string hash, std::string name, std::string path, uint64_t size, uint32_t flags, std::string srcId) -:QWidget(NULL), mFileHash(hash), mFileName(name), mFileSize(size), mSrcId(srcId), - mPath(path) +:QWidget(NULL), mPath(path), mFileHash(hash), mFileName(name), mFileSize(size), mSrcId(srcId) { /* Invoke the Qt Designer generated object setup routine */ setupUi(this); diff --git a/retroshare-gui/src/gui/statusbar/peerstatus.cpp b/retroshare-gui/src/gui/statusbar/peerstatus.cpp index d2ff1aa8b..a706aba71 100644 --- a/retroshare-gui/src/gui/statusbar/peerstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/peerstatus.cpp @@ -63,25 +63,21 @@ void PeerStatus::getPeerStatus() { /* set users/friends/network */ - std::list ids; - rsPeers->getOnlineList(ids); - int online = ids.size(); - - ids.clear(); - rsPeers->getFriendList(ids); - int friends = ids.size(); + unsigned int nFriendCount = 0; + unsigned int nOnlineCount = 0; + rsPeers->getPeerCount (&nFriendCount, &nOnlineCount); std::ostringstream out; - out << friends << " "; + out << nFriendCount << " "; std::ostringstream out2; - out2 << online << " "; + out2 << nOnlineCount << " "; if (statusPeers) statusPeers -> setText( tr("Friends:") + " " + QString::fromStdString(out.str()) + " | " + tr("Online:") + " " + QString::fromStdString(out2.str()) ); - if (online > 0) + if (nOnlineCount > 0) { iconLabel->setPixmap(QPixmap::QPixmap(":/images/user/identity16.png")); }