From aab46a5295ee8c916478f6afe0c8476bdfc2091c Mon Sep 17 00:00:00 2001 From: thunder2 Date: Wed, 29 Jun 2011 22:54:44 +0000 Subject: [PATCH] Changed parameter of the methods of pqiNotify from "std::string" to "const std::string&" Stops loading of a cache in p3GroupDistrib::loadFileMsgs on shutdown of RetroShare. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4363 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/p3notify.cc | 12 +- libretroshare/src/pqi/p3notify.h | 11 +- libretroshare/src/pqi/pqinotify.h | 8 +- libretroshare/src/services/p3blogs.cc | 4 +- libretroshare/src/services/p3blogs.h | 4 +- libretroshare/src/services/p3channels.cc | 4 +- libretroshare/src/services/p3channels.h | 4 +- libretroshare/src/services/p3distrib.cc | 190 ++++++++++------------- libretroshare/src/services/p3distrib.h | 4 +- libretroshare/src/services/p3forums.cc | 4 +- libretroshare/src/services/p3forums.h | 4 +- 11 files changed, 109 insertions(+), 140 deletions(-) diff --git a/libretroshare/src/pqi/p3notify.cc b/libretroshare/src/pqi/p3notify.cc index 1eac56d65..e7e3a01a5 100644 --- a/libretroshare/src/pqi/p3notify.cc +++ b/libretroshare/src/pqi/p3notify.cc @@ -128,7 +128,7 @@ bool p3Notify::SetPopupMessageMode(uint32_t ptype, uint32_t mode) /* Input from libretroshare */ -bool p3Notify::AddPopupMessage(uint32_t ptype, std::string name, std::string title, std::string msg) +bool p3Notify::AddPopupMessage(uint32_t ptype, const std::string& name, const std::string& title, const std::string& msg) { RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/ @@ -136,7 +136,7 @@ bool p3Notify::AddPopupMessage(uint32_t ptype, std::string name, std::string tit pmsg.type = ptype; pmsg.name = name; - pmsg.title = title; + pmsg.title = title; pmsg.msg = msg; pendingPopupMsgs.push_back(pmsg); @@ -145,8 +145,7 @@ bool p3Notify::AddPopupMessage(uint32_t ptype, std::string name, std::string tit } -bool p3Notify::AddSysMessage(uint32_t sysid, uint32_t type, - std::string title, std::string msg) +bool p3Notify::AddSysMessage(uint32_t sysid, uint32_t type, const std::string& title, const std::string& msg) { RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/ @@ -162,8 +161,7 @@ bool p3Notify::AddSysMessage(uint32_t sysid, uint32_t type, return true; } -bool p3Notify::AddLogMessage(uint32_t sysid, uint32_t type, - std::string title, std::string msg) +bool p3Notify::AddLogMessage(uint32_t sysid, uint32_t type, const std::string& title, const std::string& msg) { RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/ @@ -195,7 +193,7 @@ bool p3Notify::GetFeedItem(RsFeedItem &item) } -bool p3Notify::AddFeedItem(uint32_t type, std::string id1, std::string id2, std::string id3) +bool p3Notify::AddFeedItem(uint32_t type, const std::string& id1, const std::string& id2, const std::string& id3) { RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/ pendingNewsFeed.push_back(RsFeedItem(type, id1, id2, id3)); diff --git a/libretroshare/src/pqi/p3notify.h b/libretroshare/src/pqi/p3notify.h index 983077a51..52ad94502 100644 --- a/libretroshare/src/pqi/p3notify.h +++ b/libretroshare/src/pqi/p3notify.h @@ -70,8 +70,7 @@ class p3Notify: public RsNotify, public pqiNotify virtual ~p3Notify() { return; } /* Output for retroshare-gui */ -virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type, - std::string &title, std::string &msg); +virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type, std::string &title, std::string &msg); virtual bool NotifyPopupMessage(uint32_t &ptype, std::string &name, std::string &title, std::string &msg); virtual bool NotifyLogMessage(uint32_t &sysid, uint32_t &type, std::string &title, std::string &msg); @@ -85,10 +84,10 @@ virtual bool SetPopupMessageMode(uint32_t ptype, uint32_t mode); virtual bool GetFeedItem(RsFeedItem &item); /* Overloaded from pqiNotify */ -virtual bool AddPopupMessage(uint32_t ptype, std::string name, std::string title, std::string msg); -virtual bool AddSysMessage(uint32_t sysid, uint32_t type, std::string title, std::string msg); -virtual bool AddLogMessage(uint32_t sysid, uint32_t type, std::string title, std::string msg); -virtual bool AddFeedItem(uint32_t type, std::string id1, std::string id2, std::string id3); +virtual bool AddPopupMessage(uint32_t ptype, const std::string& name, const std::string& title, const std::string& msg); +virtual bool AddSysMessage(uint32_t sysid, uint32_t type, const std::string& title, const std::string& msg); +virtual bool AddLogMessage(uint32_t sysid, uint32_t type, const std::string& title, const std::string& msg); +virtual bool AddFeedItem(uint32_t type, const std::string& id1, const std::string& id2, const std::string& id3); virtual bool ClearFeedItems(uint32_t type); private: diff --git a/libretroshare/src/pqi/pqinotify.h b/libretroshare/src/pqi/pqinotify.h index ab30afacd..12db382c7 100644 --- a/libretroshare/src/pqi/pqinotify.h +++ b/libretroshare/src/pqi/pqinotify.h @@ -40,10 +40,10 @@ class pqiNotify virtual ~pqiNotify() { return; } /* Input from libretroshare */ -virtual bool AddPopupMessage(uint32_t ptype, std::string name, std::string title, std::string msg) = 0; -virtual bool AddSysMessage(uint32_t sysid, uint32_t type, std::string title, std::string msg) = 0; -virtual bool AddLogMessage(uint32_t sysid, uint32_t type, std::string title, std::string msg) = 0; -virtual bool AddFeedItem(uint32_t type, std::string id1, std::string id2, std::string id3) = 0; +virtual bool AddPopupMessage(uint32_t ptype, const std::string& name, const std::string& title, const std::string& msg) = 0; +virtual bool AddSysMessage(uint32_t sysid, uint32_t type, const std::string& title, const std::string& msg) = 0; +virtual bool AddLogMessage(uint32_t sysid, uint32_t type, const std::string& title, const std::string& msg) = 0; +virtual bool AddFeedItem(uint32_t type, const std::string& id1, const std::string& id2, const std::string& id3) = 0; virtual bool ClearFeedItems(uint32_t type) = 0; }; diff --git a/libretroshare/src/services/p3blogs.cc b/libretroshare/src/services/p3blogs.cc index fffa28fe3..c865282f2 100644 --- a/libretroshare/src/services/p3blogs.cc +++ b/libretroshare/src/services/p3blogs.cc @@ -292,14 +292,14 @@ const uint32_t DOWNLOAD_PERIOD = 7 * 24 * 3600; * */ -bool p3Blogs::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std::string id, bool historical) +bool p3Blogs::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, const std::string& id, bool historical) { return true; } #include "pqi/pqinotify.h" -bool p3Blogs::locked_eventNewMsg(GroupInfo *grp, RsDistribMsg *msg, std::string id, bool historical) +bool p3Blogs::locked_eventNewMsg(GroupInfo *grp, RsDistribMsg *msg, const std::string& id, bool historical) { std::string grpId = msg->grpId; std::string msgId = msg->msgId; diff --git a/libretroshare/src/services/p3blogs.h b/libretroshare/src/services/p3blogs.h index ec468a1ba..e6bfc5aa1 100644 --- a/libretroshare/src/services/p3blogs.h +++ b/libretroshare/src/services/p3blogs.h @@ -115,8 +115,8 @@ virtual bool isReply(BlogMsgInfo& info); protected: virtual void locked_notifyGroupChanged(GroupInfo &info, uint32_t flags, bool historical); -virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string, bool historical); -virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, std::string, bool historical); +virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, const std::string&, bool historical); +virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, const std::string&, bool historical); /****************************************/ diff --git a/libretroshare/src/services/p3channels.cc b/libretroshare/src/services/p3channels.cc index 281c8f9a0..3ec1e4d6e 100644 --- a/libretroshare/src/services/p3channels.cc +++ b/libretroshare/src/services/p3channels.cc @@ -727,7 +727,7 @@ const uint32_t DOWNLOAD_PERIOD = 7 * 24 * 3600; * on a subscription to a channel.. */ -bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std::string id, bool historical) +bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, const std::string& id, bool historical) { std::string grpId = msg->grpId; std::string msgId = msg->msgId; @@ -882,7 +882,7 @@ bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std #include "pqi/pqinotify.h" -bool p3Channels::locked_eventNewMsg(GroupInfo *grp, RsDistribMsg *msg, std::string id, bool historical) +bool p3Channels::locked_eventNewMsg(GroupInfo *grp, RsDistribMsg *msg, const std::string& id, bool historical) { std::string grpId = msg->grpId; std::string msgId = msg->msgId; diff --git a/libretroshare/src/services/p3channels.h b/libretroshare/src/services/p3channels.h index 7b130ef14..89b4ad326 100644 --- a/libretroshare/src/services/p3channels.h +++ b/libretroshare/src/services/p3channels.h @@ -92,8 +92,8 @@ virtual bool channelGetAutoDl(const std::string& chId, bool& autoDl); protected: virtual void locked_notifyGroupChanged(GroupInfo &info, uint32_t flags, bool historical); -virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string, bool historical); -virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, std::string, bool historical); +virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, const std::string&, bool historical); +virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, const std::string&, bool historical); /****************************************/ diff --git a/libretroshare/src/services/p3distrib.cc b/libretroshare/src/services/p3distrib.cc index bb1484140..16877ecf1 100644 --- a/libretroshare/src/services/p3distrib.cc +++ b/libretroshare/src/services/p3distrib.cc @@ -912,39 +912,39 @@ void p3GroupDistrib::run() /* called once the thread is started */ bool isLocal = false; bool isHistorical = false; { - RsStackMutex stack(distribMtx); - if(!mHistoricalCaches){ + RsStackMutex stack(distribMtx); + if(!mHistoricalCaches){ - if(mPendingHistCaches.size() > 0){ + if(mPendingHistCaches.size() > 0){ -// std::cerr << "loaded pending caches: " << mPendingHistCaches.size() << std::endl; - CacheDataPending &pendingCache = mPendingHistCaches.front(); - cache = pendingCache.mData; - isLocal = pendingCache.mLocal; - isHistorical = pendingCache.mHistorical; +// std::cerr << "loaded pending caches: " << mPendingHistCaches.size() << std::endl; + CacheDataPending &pendingCache = mPendingHistCaches.front(); + cache = pendingCache.mData; + isLocal = pendingCache.mLocal; + isHistorical = pendingCache.mHistorical; - validCache = true; - mPendingHistCaches.pop_front(); - } - else if (mPendingCaches.size() > 0) - { - CacheDataPending &pendingCache = mPendingCaches.front(); - cache = pendingCache.mData; - isLocal = pendingCache.mLocal; - isHistorical = pendingCache.mHistorical; + validCache = true; + mPendingHistCaches.pop_front(); + } + else if (mPendingCaches.size() > 0) + { + CacheDataPending &pendingCache = mPendingCaches.front(); + cache = pendingCache.mData; + isLocal = pendingCache.mLocal; + isHistorical = pendingCache.mHistorical; - validCache = true; - mPendingCaches.pop_front(); + validCache = true; + mPendingCaches.pop_front(); #ifdef DISTRIB_THREAD_DEBUG - std::cerr << "p3GroupDistrib::run() found pendingCache"; - std::cerr << std::endl; + std::cerr << "p3GroupDistrib::run() found pendingCache"; + std::cerr << std::endl; #endif + } } } - } if (validCache) { loadAnyCache(cache, isLocal, isHistorical); @@ -1000,16 +1000,15 @@ int p3GroupDistrib::loadAnyCache(const CacheData &data, bool local, bool his std::cerr << "Cid: " << data.cid.type << ":" << data.cid.subid << std::endl; #endif - if (data.cid.subid == 1) - { - - cidPair = std::make_pair(data.pid, data.cid.subid); - loadFileGroups(file, data.pid, local, historical, cidPair); - } - else - { - loadFileMsgs(file, data.cid.subid, data.pid, data.recvd, local, historical); - } + if (data.cid.subid == 1) + { + cidPair = std::make_pair(data.pid, data.cid.subid); + loadFileGroups(file, data.pid, local, historical, cidPair); + } + else + { + loadFileMsgs(file, data.cid.subid, data.pid, data.recvd, local, historical); + } return true; } @@ -1141,9 +1140,7 @@ void p3GroupDistrib::loadFileMsgs(const std::string &filename, uint16_t cacheSub RsDistribSignedMsg *newMsg; std::string grpId; - - - while(NULL != (item = store->GetItem())) + while(isRunning() && (NULL != (item = store->GetItem()))) { #ifdef DISTRIB_DEBUG std::cerr << "p3GroupDistrib::loadFileMsgs() Got Item:"; @@ -1157,13 +1154,11 @@ void p3GroupDistrib::loadFileMsgs(const std::string &filename, uint16_t cacheSub grpId = newMsg->grpId; if(loadMsg(newMsg, src, local, historical)) { - if(cache) { msgCacheMap.insert(grpCachePair(grpId, pCacheId(src, cacheSubId))); } } - } else { @@ -1198,8 +1193,6 @@ void p3GroupDistrib::loadFileMsgs(const std::string &filename, uint16_t cacheSub mMsgHistPending.push_back(grpCachePair(failedCacheId, failedCache)); } - - if (local) { /* now we create a map of time -> subid @@ -1277,8 +1270,6 @@ void p3GroupDistrib::locked_loadFileMsgs(const std::string &filename, uint16_t c RsDistribSignedMsg *newMsg; std::string grpId; - - while(NULL != (item = store->GetItem())) { #ifdef DISTRIB_DEBUG @@ -1293,13 +1284,11 @@ void p3GroupDistrib::locked_loadFileMsgs(const std::string &filename, uint16_t c grpId = newMsg->grpId; if(locked_loadMsg(newMsg, src, local, historical)) { - if(cache) { msgCacheMap.insert(grpCachePair(grpId, pCacheId(src, cacheSubId))); } } - } else { @@ -1332,8 +1321,6 @@ void p3GroupDistrib::locked_loadFileMsgs(const std::string &filename, uint16_t c mMsgHistPending.push_back(grpCachePair(failedCacheId, failedCache)); } - - if (local) { /* now we create a map of time -> subid @@ -1519,18 +1506,15 @@ bool p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey, bool historical) { #ifdef DISTRIB_DEBUG - - std::cerr << "p3GroupDistrib::loadGroupKey() Group for key not found: discarding"; - std::cerr << std::endl; + std::cerr << "p3GroupDistrib::loadGroupKey() Group for key not found: discarding"; + std::cerr << std::endl; #endif - delete newKey; - newKey = NULL; - return false; - + delete newKey; + newKey = NULL; + return false; } - /* have the group -> add in the key */ bool updateOk = false; if (newKey->key.keyFlags & RSTLV_KEY_DISTRIB_ADMIN) @@ -1549,7 +1533,7 @@ bool p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey, bool historical) } else { - if(!locked_updateGroupPublishKey(it->second, newKey)) + if(!locked_updateGroupPublishKey(it->second, newKey)) { #ifdef DISTRIB_DEBUG std::cerr << "p3GroupDistrib::loadGroupKey() Failed Publish Key Update"; @@ -1559,27 +1543,22 @@ bool p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey, bool historical) else { updateOk = true; - } - - } - if (updateOk) - locked_notifyGroupChanged(it->second, GRP_LOAD_KEY, historical); - - + if (updateOk) + locked_notifyGroupChanged(it->second, GRP_LOAD_KEY, historical); #ifdef DISTRIB_DEBUG std::cerr << "p3GroupDistrib::loadGroupKey() Done - Cleaning up."; std::cerr << std::endl; #endif -// if(!updateOk) - delete newKey; +// if(!updateOk) + delete newKey; - newKey = NULL; - return updateOk; + newKey = NULL; + return updateOk; } @@ -1620,7 +1599,6 @@ bool p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, const std::string &src, return false; } - /****************** check the msg ******************/ /* check for duplicate message, do this first to ensure minimal signature validations. * therefore, duplicateMsg... could potentially be called on a dodgey msg (not a big problem!) @@ -1651,26 +1629,24 @@ bool p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, const std::string &src, return false; } - void *temp_ptr = newMsg->packet.bin_data; - int temp_len = newMsg->packet.bin_len; + void *temp_ptr = newMsg->packet.bin_data; + int temp_len = newMsg->packet.bin_len; if(git->second.grpFlags & RS_DISTRIB_ENCRYPTED){ + void *out_data = NULL; + int out_len = 0; - void *out_data = NULL; - int out_len = 0; - - if(decrypt(out_data, out_len, newMsg->packet.bin_data, newMsg->packet.bin_len, newMsg->grpId)){ - newMsg->packet.TlvShallowClear(); - newMsg->packet.setBinData(out_data, out_len); - delete[] (unsigned char*) out_data; - + if(decrypt(out_data, out_len, newMsg->packet.bin_data, newMsg->packet.bin_len, newMsg->grpId)){ + newMsg->packet.TlvShallowClear(); + newMsg->packet.setBinData(out_data, out_len); + delete[] (unsigned char*) out_data; }else{ + if((out_data != NULL) && (out_len != 0)) + delete[] (unsigned char*) out_data; - if((out_data != NULL) && (out_len != 0)) - delete[] (unsigned char*) out_data; #ifdef DISTRIB_DEBUG - std::cerr << "p3GroupDistrib::loadMsg() Failed to decrypt" << std::endl; - std::cerr << std::endl; + std::cerr << "p3GroupDistrib::loadMsg() Failed to decrypt" << std::endl; + std::cerr << std::endl; #endif return false; } @@ -1718,7 +1694,6 @@ bool p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, const std::string &src, std::cerr << std::endl; #endif - /* Callback for any derived classes to play with */ locked_eventNewMsg(&(git->second), msg, src, historical); @@ -1731,10 +1706,10 @@ bool p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, const std::string &src, std::cerr << std::endl; #endif - if(git->second.grpFlags & RS_DISTRIB_ENCRYPTED){ - newMsg->packet.TlvClear(); - newMsg->packet.setBinData(temp_ptr, temp_len); - } + if(git->second.grpFlags & RS_DISTRIB_ENCRYPTED){ + newMsg->packet.TlvClear(); + newMsg->packet.setBinData(temp_ptr, temp_len); + } locked_toPublishMsg(newMsg); } @@ -4302,8 +4277,7 @@ bool p3GroupDistrib::locked_choosePublishKey(GroupInfo &info) /********************/ -bool p3GroupDistrib::locked_validateDistribSignedMsg( - GroupInfo &info, RsDistribSignedMsg *newMsg) +bool p3GroupDistrib::locked_validateDistribSignedMsg(GroupInfo &info, RsDistribSignedMsg *newMsg) { #ifdef DISTRIB_DEBUG std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg()"; @@ -4351,12 +4325,11 @@ bool p3GroupDistrib::locked_validateDistribSignedMsg( return false; } - /* decode key */ const unsigned char *keyptr = (const unsigned char *) kit->second.keyData.bin_data; long keylen = kit->second.keyData.bin_len; unsigned int siglen = newMsg->publishSignature.signData.bin_len; - unsigned char *sigbuf = (unsigned char *) newMsg->publishSignature.signData.bin_data; + unsigned char *sigbuf = (unsigned char *) newMsg->publishSignature.signData.bin_data; #ifdef DISTRIB_DEBUG std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg() Decode Key"; @@ -4397,14 +4370,13 @@ bool p3GroupDistrib::locked_validateDistribSignedMsg( EVP_PKEY_free(signKey); EVP_MD_CTX_destroy(mdctx); - /* now verify Personal signature */ - if ((signOk == 1) && ((info.grpFlags & RS_DISTRIB_AUTHEN_MASK) & RS_DISTRIB_AUTHEN_REQ)) + if ((signOk == 1) && ((info.grpFlags & RS_DISTRIB_AUTHEN_MASK) & RS_DISTRIB_AUTHEN_REQ)) { - unsigned int personalsiglen = - newMsg->personalSignature.signData.bin_len; - unsigned char *personalsigbuf = (unsigned char *) - newMsg->personalSignature.signData.bin_data; + unsigned int personalsiglen = + newMsg->personalSignature.signData.bin_len; + unsigned char *personalsigbuf = (unsigned char *) + newMsg->personalSignature.signData.bin_data; RsPeerDetails signerDetails; std::string gpg_fpr; @@ -4413,20 +4385,20 @@ bool p3GroupDistrib::locked_validateDistribSignedMsg( gpg_fpr = signerDetails.fpr; } - bool gpgSign = AuthGPG::getAuthGPG()->VerifySignBin( - newMsg->packet.bin_data, newMsg->packet.bin_len, - personalsigbuf, personalsiglen, gpg_fpr); - if (gpgSign) { - #ifdef DISTRIB_DEBUG - std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg() Success for gpg signature." << std::endl; - #endif - signOk = 1; - } else { - #ifdef DISTRIB_DEBUG - std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg() Fail for gpg signature." << std::endl; - #endif - signOk = 0; - } + bool gpgSign = AuthGPG::getAuthGPG()->VerifySignBin( + newMsg->packet.bin_data, newMsg->packet.bin_len, + personalsigbuf, personalsiglen, gpg_fpr); + if (gpgSign) { +#ifdef DISTRIB_DEBUG + std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg() Success for gpg signature." << std::endl; +#endif + signOk = 1; + } else { +#ifdef DISTRIB_DEBUG + std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg() Fail for gpg signature." << std::endl; +#endif + signOk = 0; + } } if (signOk == 1) diff --git a/libretroshare/src/services/p3distrib.h b/libretroshare/src/services/p3distrib.h index 6520436c0..738fd1c74 100644 --- a/libretroshare/src/services/p3distrib.h +++ b/libretroshare/src/services/p3distrib.h @@ -580,7 +580,7 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu * @param historical: is this msg from an historical cache * @return successfully executed or not */ - virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, std::string id, bool historical) = 0; + virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, const std::string& id, bool historical) = 0; /*! * Inheriting class should implement this as a response to a new msg arriving @@ -590,7 +590,7 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu * @param historical: is this msg from an historical cache * @return */ - virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string id, bool historical) = 0; + virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, const std::string& id, bool historical) = 0; /***************************************************************************************/ /********************************* p3Config ********************************************/ diff --git a/libretroshare/src/services/p3forums.cc b/libretroshare/src/services/p3forums.cc index f379f6d07..45d3c9b2a 100644 --- a/libretroshare/src/services/p3forums.cc +++ b/libretroshare/src/services/p3forums.cc @@ -634,12 +634,12 @@ void p3Forums::locked_notifyGroupChanged(GroupInfo &grp, uint32_t flags, bool h return p3GroupDistrib::locked_notifyGroupChanged(grp, flags, historical); } -bool p3Forums::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std::string id, bool historical) +bool p3Forums::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, const std::string& id, bool historical) { return true; } -bool p3Forums::locked_eventNewMsg(GroupInfo *grp, RsDistribMsg *msg, std::string id, bool historical) +bool p3Forums::locked_eventNewMsg(GroupInfo *grp, RsDistribMsg *msg, const std::string& id, bool historical) { std::string grpId = msg->grpId; std::string msgId = msg->msgId; diff --git a/libretroshare/src/services/p3forums.h b/libretroshare/src/services/p3forums.h index ecf300dc4..b68b0dd24 100644 --- a/libretroshare/src/services/p3forums.h +++ b/libretroshare/src/services/p3forums.h @@ -69,8 +69,8 @@ virtual bool getMessageCount(const std::string &fId, unsigned int &newCount, uns /***************************************************************************************/ virtual void locked_notifyGroupChanged(GroupInfo &grp, uint32_t flags, bool historical); -virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, std::string, bool historical); -virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string, bool historical); +virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, const std::string&, bool historical); +virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, const std::string&, bool historical); /****************************************/