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
This commit is contained in:
thunder2 2011-06-29 22:54:44 +00:00
parent 04ce05025f
commit aab46a5295
11 changed files with 109 additions and 140 deletions

View File

@ -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 ************/
@ -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));

View File

@ -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:

View File

@ -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;
};

View File

@ -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;

View File

@ -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);
/****************************************/

View File

@ -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;

View File

@ -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);
/****************************************/

View File

@ -1002,7 +1002,6 @@ int p3GroupDistrib::loadAnyCache(const CacheData &data, bool local, bool his
if (data.cid.subid == 1)
{
cidPair = std::make_pair(data.pid, data.cid.subid);
loadFileGroups(file, data.pid, local, historical, cidPair);
}
@ -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,7 +1506,6 @@ bool p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey, bool historical)
{
#ifdef DISTRIB_DEBUG
std::cerr << "p3GroupDistrib::loadGroupKey() Group for key not found: discarding";
std::cerr << std::endl;
#endif
@ -1527,10 +1513,8 @@ bool p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey, bool historical)
delete newKey;
newKey = NULL;
return false;
}
/* have the group -> add in the key */
bool updateOk = false;
if (newKey->key.keyFlags & RSTLV_KEY_DISTRIB_ADMIN)
@ -1559,17 +1543,12 @@ bool p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey, bool historical)
else
{
updateOk = true;
}
}
if (updateOk)
locked_notifyGroupChanged(it->second, GRP_LOAD_KEY, historical);
#ifdef DISTRIB_DEBUG
std::cerr << "p3GroupDistrib::loadGroupKey() Done - Cleaning up.";
std::cerr << std::endl;
@ -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!)
@ -1655,7 +1633,6 @@ bool p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, const std::string &src,
int temp_len = newMsg->packet.bin_len;
if(git->second.grpFlags & RS_DISTRIB_ENCRYPTED){
void *out_data = NULL;
int out_len = 0;
@ -1663,11 +1640,10 @@ bool p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, const std::string &src,
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;
#ifdef DISTRIB_DEBUG
std::cerr << "p3GroupDistrib::loadMsg() Failed to decrypt" << std::endl;
std::cerr << std::endl;
@ -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);
@ -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,7 +4325,6 @@ 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;
@ -4397,7 +4370,6 @@ 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))
{

View File

@ -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 ********************************************/

View File

@ -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;

View File

@ -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);
/****************************************/