mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-28 00:07:09 -05:00
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:
parent
04ce05025f
commit
aab46a5295
@ -128,7 +128,7 @@ bool p3Notify::SetPopupMessageMode(uint32_t ptype, uint32_t mode)
|
|||||||
|
|
||||||
|
|
||||||
/* Input from libretroshare */
|
/* 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 ************/
|
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.type = ptype;
|
||||||
pmsg.name = name;
|
pmsg.name = name;
|
||||||
pmsg.title = title;
|
pmsg.title = title;
|
||||||
pmsg.msg = msg;
|
pmsg.msg = msg;
|
||||||
|
|
||||||
pendingPopupMsgs.push_back(pmsg);
|
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,
|
bool p3Notify::AddSysMessage(uint32_t sysid, uint32_t type, const std::string& title, const std::string& msg)
|
||||||
std::string title, std::string msg)
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/
|
RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/
|
||||||
|
|
||||||
@ -162,8 +161,7 @@ bool p3Notify::AddSysMessage(uint32_t sysid, uint32_t type,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Notify::AddLogMessage(uint32_t sysid, uint32_t type,
|
bool p3Notify::AddLogMessage(uint32_t sysid, uint32_t type, const std::string& title, const std::string& msg)
|
||||||
std::string title, std::string msg)
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/
|
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 ************/
|
RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/
|
||||||
pendingNewsFeed.push_back(RsFeedItem(type, id1, id2, id3));
|
pendingNewsFeed.push_back(RsFeedItem(type, id1, id2, id3));
|
||||||
|
@ -70,8 +70,7 @@ class p3Notify: public RsNotify, public pqiNotify
|
|||||||
virtual ~p3Notify() { return; }
|
virtual ~p3Notify() { return; }
|
||||||
|
|
||||||
/* Output for retroshare-gui */
|
/* Output for retroshare-gui */
|
||||||
virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type,
|
virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type, std::string &title, std::string &msg);
|
||||||
std::string &title, std::string &msg);
|
|
||||||
virtual bool NotifyPopupMessage(uint32_t &ptype, std::string &name, 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);
|
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);
|
virtual bool GetFeedItem(RsFeedItem &item);
|
||||||
|
|
||||||
/* Overloaded from pqiNotify */
|
/* Overloaded from pqiNotify */
|
||||||
virtual bool AddPopupMessage(uint32_t ptype, std::string name, std::string title, std::string msg);
|
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, std::string title, 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, std::string title, 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, std::string id1, std::string id2, std::string id3);
|
virtual bool AddFeedItem(uint32_t type, const std::string& id1, const std::string& id2, const std::string& id3);
|
||||||
virtual bool ClearFeedItems(uint32_t type);
|
virtual bool ClearFeedItems(uint32_t type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -40,10 +40,10 @@ class pqiNotify
|
|||||||
virtual ~pqiNotify() { return; }
|
virtual ~pqiNotify() { return; }
|
||||||
|
|
||||||
/* Input from libretroshare */
|
/* Input from libretroshare */
|
||||||
virtual bool AddPopupMessage(uint32_t ptype, std::string name, std::string title, std::string msg) = 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, std::string title, 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, std::string title, 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, std::string id1, std::string id2, std::string id3) = 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;
|
virtual bool ClearFeedItems(uint32_t type) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "pqi/pqinotify.h"
|
#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 grpId = msg->grpId;
|
||||||
std::string msgId = msg->msgId;
|
std::string msgId = msg->msgId;
|
||||||
|
@ -115,8 +115,8 @@ virtual bool isReply(BlogMsgInfo& info);
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void locked_notifyGroupChanged(GroupInfo &info, uint32_t flags, bool historical);
|
virtual void locked_notifyGroupChanged(GroupInfo &info, uint32_t flags, bool historical);
|
||||||
virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string, bool historical);
|
virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, const std::string&, bool historical);
|
||||||
virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, std::string, bool historical);
|
virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, const std::string&, bool historical);
|
||||||
|
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
@ -727,7 +727,7 @@ const uint32_t DOWNLOAD_PERIOD = 7 * 24 * 3600;
|
|||||||
* on a subscription to a channel..
|
* 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 grpId = msg->grpId;
|
||||||
std::string msgId = msg->msgId;
|
std::string msgId = msg->msgId;
|
||||||
@ -882,7 +882,7 @@ bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std
|
|||||||
|
|
||||||
#include "pqi/pqinotify.h"
|
#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 grpId = msg->grpId;
|
||||||
std::string msgId = msg->msgId;
|
std::string msgId = msg->msgId;
|
||||||
|
@ -92,8 +92,8 @@ virtual bool channelGetAutoDl(const std::string& chId, bool& autoDl);
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void locked_notifyGroupChanged(GroupInfo &info, uint32_t flags, bool historical);
|
virtual void locked_notifyGroupChanged(GroupInfo &info, uint32_t flags, bool historical);
|
||||||
virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string, bool historical);
|
virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, const std::string&, bool historical);
|
||||||
virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, std::string, bool historical);
|
virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, const std::string&, bool historical);
|
||||||
|
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
@ -912,39 +912,39 @@ void p3GroupDistrib::run() /* called once the thread is started */
|
|||||||
bool isLocal = false;
|
bool isLocal = false;
|
||||||
bool isHistorical = false;
|
bool isHistorical = false;
|
||||||
{
|
{
|
||||||
RsStackMutex stack(distribMtx);
|
RsStackMutex stack(distribMtx);
|
||||||
if(!mHistoricalCaches){
|
if(!mHistoricalCaches){
|
||||||
|
|
||||||
|
|
||||||
if(mPendingHistCaches.size() > 0){
|
if(mPendingHistCaches.size() > 0){
|
||||||
|
|
||||||
// std::cerr << "loaded pending caches: " << mPendingHistCaches.size() << std::endl;
|
// std::cerr << "loaded pending caches: " << mPendingHistCaches.size() << std::endl;
|
||||||
CacheDataPending &pendingCache = mPendingHistCaches.front();
|
CacheDataPending &pendingCache = mPendingHistCaches.front();
|
||||||
cache = pendingCache.mData;
|
cache = pendingCache.mData;
|
||||||
isLocal = pendingCache.mLocal;
|
isLocal = pendingCache.mLocal;
|
||||||
isHistorical = pendingCache.mHistorical;
|
isHistorical = pendingCache.mHistorical;
|
||||||
|
|
||||||
validCache = true;
|
validCache = true;
|
||||||
mPendingHistCaches.pop_front();
|
mPendingHistCaches.pop_front();
|
||||||
}
|
}
|
||||||
else if (mPendingCaches.size() > 0)
|
else if (mPendingCaches.size() > 0)
|
||||||
{
|
{
|
||||||
CacheDataPending &pendingCache = mPendingCaches.front();
|
CacheDataPending &pendingCache = mPendingCaches.front();
|
||||||
cache = pendingCache.mData;
|
cache = pendingCache.mData;
|
||||||
isLocal = pendingCache.mLocal;
|
isLocal = pendingCache.mLocal;
|
||||||
isHistorical = pendingCache.mHistorical;
|
isHistorical = pendingCache.mHistorical;
|
||||||
|
|
||||||
validCache = true;
|
validCache = true;
|
||||||
mPendingCaches.pop_front();
|
mPendingCaches.pop_front();
|
||||||
|
|
||||||
#ifdef DISTRIB_THREAD_DEBUG
|
#ifdef DISTRIB_THREAD_DEBUG
|
||||||
std::cerr << "p3GroupDistrib::run() found pendingCache";
|
std::cerr << "p3GroupDistrib::run() found pendingCache";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (validCache)
|
if (validCache)
|
||||||
{
|
{
|
||||||
loadAnyCache(cache, isLocal, isHistorical);
|
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;
|
std::cerr << "Cid: " << data.cid.type << ":" << data.cid.subid << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (data.cid.subid == 1)
|
if (data.cid.subid == 1)
|
||||||
{
|
{
|
||||||
|
cidPair = std::make_pair(data.pid, data.cid.subid);
|
||||||
cidPair = std::make_pair(data.pid, data.cid.subid);
|
loadFileGroups(file, data.pid, local, historical, cidPair);
|
||||||
loadFileGroups(file, data.pid, local, historical, cidPair);
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
loadFileMsgs(file, data.cid.subid, data.pid, data.recvd, local, historical);
|
||||||
loadFileMsgs(file, data.cid.subid, data.pid, data.recvd, local, historical);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1141,9 +1140,7 @@ void p3GroupDistrib::loadFileMsgs(const std::string &filename, uint16_t cacheSub
|
|||||||
RsDistribSignedMsg *newMsg;
|
RsDistribSignedMsg *newMsg;
|
||||||
std::string grpId;
|
std::string grpId;
|
||||||
|
|
||||||
|
while(isRunning() && (NULL != (item = store->GetItem())))
|
||||||
|
|
||||||
while(NULL != (item = store->GetItem()))
|
|
||||||
{
|
{
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
std::cerr << "p3GroupDistrib::loadFileMsgs() Got Item:";
|
std::cerr << "p3GroupDistrib::loadFileMsgs() Got Item:";
|
||||||
@ -1157,13 +1154,11 @@ void p3GroupDistrib::loadFileMsgs(const std::string &filename, uint16_t cacheSub
|
|||||||
grpId = newMsg->grpId;
|
grpId = newMsg->grpId;
|
||||||
if(loadMsg(newMsg, src, local, historical))
|
if(loadMsg(newMsg, src, local, historical))
|
||||||
{
|
{
|
||||||
|
|
||||||
if(cache)
|
if(cache)
|
||||||
{
|
{
|
||||||
msgCacheMap.insert(grpCachePair(grpId, pCacheId(src, cacheSubId)));
|
msgCacheMap.insert(grpCachePair(grpId, pCacheId(src, cacheSubId)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1198,8 +1193,6 @@ void p3GroupDistrib::loadFileMsgs(const std::string &filename, uint16_t cacheSub
|
|||||||
mMsgHistPending.push_back(grpCachePair(failedCacheId, failedCache));
|
mMsgHistPending.push_back(grpCachePair(failedCacheId, failedCache));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (local)
|
if (local)
|
||||||
{
|
{
|
||||||
/* now we create a map of time -> subid
|
/* 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;
|
RsDistribSignedMsg *newMsg;
|
||||||
std::string grpId;
|
std::string grpId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while(NULL != (item = store->GetItem()))
|
while(NULL != (item = store->GetItem()))
|
||||||
{
|
{
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
@ -1293,13 +1284,11 @@ void p3GroupDistrib::locked_loadFileMsgs(const std::string &filename, uint16_t c
|
|||||||
grpId = newMsg->grpId;
|
grpId = newMsg->grpId;
|
||||||
if(locked_loadMsg(newMsg, src, local, historical))
|
if(locked_loadMsg(newMsg, src, local, historical))
|
||||||
{
|
{
|
||||||
|
|
||||||
if(cache)
|
if(cache)
|
||||||
{
|
{
|
||||||
msgCacheMap.insert(grpCachePair(grpId, pCacheId(src, cacheSubId)));
|
msgCacheMap.insert(grpCachePair(grpId, pCacheId(src, cacheSubId)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1332,8 +1321,6 @@ void p3GroupDistrib::locked_loadFileMsgs(const std::string &filename, uint16_t c
|
|||||||
mMsgHistPending.push_back(grpCachePair(failedCacheId, failedCache));
|
mMsgHistPending.push_back(grpCachePair(failedCacheId, failedCache));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (local)
|
if (local)
|
||||||
{
|
{
|
||||||
/* now we create a map of time -> subid
|
/* now we create a map of time -> subid
|
||||||
@ -1519,18 +1506,15 @@ bool p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey, bool historical)
|
|||||||
{
|
{
|
||||||
|
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
|
std::cerr << "p3GroupDistrib::loadGroupKey() Group for key not found: discarding";
|
||||||
std::cerr << "p3GroupDistrib::loadGroupKey() Group for key not found: discarding";
|
std::cerr << std::endl;
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete newKey;
|
delete newKey;
|
||||||
newKey = NULL;
|
newKey = NULL;
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* have the group -> add in the key */
|
/* have the group -> add in the key */
|
||||||
bool updateOk = false;
|
bool updateOk = false;
|
||||||
if (newKey->key.keyFlags & RSTLV_KEY_DISTRIB_ADMIN)
|
if (newKey->key.keyFlags & RSTLV_KEY_DISTRIB_ADMIN)
|
||||||
@ -1549,7 +1533,7 @@ bool p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey, bool historical)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!locked_updateGroupPublishKey(it->second, newKey))
|
if(!locked_updateGroupPublishKey(it->second, newKey))
|
||||||
{
|
{
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
std::cerr << "p3GroupDistrib::loadGroupKey() Failed Publish Key Update";
|
std::cerr << "p3GroupDistrib::loadGroupKey() Failed Publish Key Update";
|
||||||
@ -1559,27 +1543,22 @@ bool p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey, bool historical)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
updateOk = true;
|
updateOk = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updateOk)
|
if (updateOk)
|
||||||
locked_notifyGroupChanged(it->second, GRP_LOAD_KEY, historical);
|
locked_notifyGroupChanged(it->second, GRP_LOAD_KEY, historical);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
std::cerr << "p3GroupDistrib::loadGroupKey() Done - Cleaning up.";
|
std::cerr << "p3GroupDistrib::loadGroupKey() Done - Cleaning up.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// if(!updateOk)
|
// if(!updateOk)
|
||||||
delete newKey;
|
delete newKey;
|
||||||
|
|
||||||
newKey = NULL;
|
newKey = NULL;
|
||||||
return updateOk;
|
return updateOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1620,7 +1599,6 @@ bool p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, const std::string &src,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************** check the msg ******************/
|
/****************** check the msg ******************/
|
||||||
/* check for duplicate message, do this first to ensure minimal signature validations.
|
/* 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!)
|
* 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *temp_ptr = newMsg->packet.bin_data;
|
void *temp_ptr = newMsg->packet.bin_data;
|
||||||
int temp_len = newMsg->packet.bin_len;
|
int temp_len = newMsg->packet.bin_len;
|
||||||
|
|
||||||
if(git->second.grpFlags & RS_DISTRIB_ENCRYPTED){
|
if(git->second.grpFlags & RS_DISTRIB_ENCRYPTED){
|
||||||
|
void *out_data = NULL;
|
||||||
|
int out_len = 0;
|
||||||
|
|
||||||
void *out_data = NULL;
|
if(decrypt(out_data, out_len, newMsg->packet.bin_data, newMsg->packet.bin_len, newMsg->grpId)){
|
||||||
int out_len = 0;
|
newMsg->packet.TlvShallowClear();
|
||||||
|
newMsg->packet.setBinData(out_data, out_len);
|
||||||
if(decrypt(out_data, out_len, newMsg->packet.bin_data, newMsg->packet.bin_len, newMsg->grpId)){
|
delete[] (unsigned char*) out_data;
|
||||||
newMsg->packet.TlvShallowClear();
|
|
||||||
newMsg->packet.setBinData(out_data, out_len);
|
|
||||||
delete[] (unsigned char*) out_data;
|
|
||||||
|
|
||||||
}else{
|
}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
|
#ifdef DISTRIB_DEBUG
|
||||||
std::cerr << "p3GroupDistrib::loadMsg() Failed to decrypt" << std::endl;
|
std::cerr << "p3GroupDistrib::loadMsg() Failed to decrypt" << std::endl;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1718,7 +1694,6 @@ bool p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, const std::string &src,
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Callback for any derived classes to play with */
|
/* Callback for any derived classes to play with */
|
||||||
locked_eventNewMsg(&(git->second), msg, src, historical);
|
locked_eventNewMsg(&(git->second), msg, src, historical);
|
||||||
|
|
||||||
@ -1731,10 +1706,10 @@ bool p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, const std::string &src,
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(git->second.grpFlags & RS_DISTRIB_ENCRYPTED){
|
if(git->second.grpFlags & RS_DISTRIB_ENCRYPTED){
|
||||||
newMsg->packet.TlvClear();
|
newMsg->packet.TlvClear();
|
||||||
newMsg->packet.setBinData(temp_ptr, temp_len);
|
newMsg->packet.setBinData(temp_ptr, temp_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
locked_toPublishMsg(newMsg);
|
locked_toPublishMsg(newMsg);
|
||||||
}
|
}
|
||||||
@ -4302,8 +4277,7 @@ bool p3GroupDistrib::locked_choosePublishKey(GroupInfo &info)
|
|||||||
|
|
||||||
/********************/
|
/********************/
|
||||||
|
|
||||||
bool p3GroupDistrib::locked_validateDistribSignedMsg(
|
bool p3GroupDistrib::locked_validateDistribSignedMsg(GroupInfo &info, RsDistribSignedMsg *newMsg)
|
||||||
GroupInfo &info, RsDistribSignedMsg *newMsg)
|
|
||||||
{
|
{
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg()";
|
std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg()";
|
||||||
@ -4351,12 +4325,11 @@ bool p3GroupDistrib::locked_validateDistribSignedMsg(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* decode key */
|
/* decode key */
|
||||||
const unsigned char *keyptr = (const unsigned char *) kit->second.keyData.bin_data;
|
const unsigned char *keyptr = (const unsigned char *) kit->second.keyData.bin_data;
|
||||||
long keylen = kit->second.keyData.bin_len;
|
long keylen = kit->second.keyData.bin_len;
|
||||||
unsigned int siglen = newMsg->publishSignature.signData.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
|
#ifdef DISTRIB_DEBUG
|
||||||
std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg() Decode Key";
|
std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg() Decode Key";
|
||||||
@ -4397,14 +4370,13 @@ bool p3GroupDistrib::locked_validateDistribSignedMsg(
|
|||||||
EVP_PKEY_free(signKey);
|
EVP_PKEY_free(signKey);
|
||||||
EVP_MD_CTX_destroy(mdctx);
|
EVP_MD_CTX_destroy(mdctx);
|
||||||
|
|
||||||
|
|
||||||
/* now verify Personal signature */
|
/* 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 =
|
unsigned int personalsiglen =
|
||||||
newMsg->personalSignature.signData.bin_len;
|
newMsg->personalSignature.signData.bin_len;
|
||||||
unsigned char *personalsigbuf = (unsigned char *)
|
unsigned char *personalsigbuf = (unsigned char *)
|
||||||
newMsg->personalSignature.signData.bin_data;
|
newMsg->personalSignature.signData.bin_data;
|
||||||
|
|
||||||
RsPeerDetails signerDetails;
|
RsPeerDetails signerDetails;
|
||||||
std::string gpg_fpr;
|
std::string gpg_fpr;
|
||||||
@ -4413,20 +4385,20 @@ bool p3GroupDistrib::locked_validateDistribSignedMsg(
|
|||||||
gpg_fpr = signerDetails.fpr;
|
gpg_fpr = signerDetails.fpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gpgSign = AuthGPG::getAuthGPG()->VerifySignBin(
|
bool gpgSign = AuthGPG::getAuthGPG()->VerifySignBin(
|
||||||
newMsg->packet.bin_data, newMsg->packet.bin_len,
|
newMsg->packet.bin_data, newMsg->packet.bin_len,
|
||||||
personalsigbuf, personalsiglen, gpg_fpr);
|
personalsigbuf, personalsiglen, gpg_fpr);
|
||||||
if (gpgSign) {
|
if (gpgSign) {
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg() Success for gpg signature." << std::endl;
|
std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg() Success for gpg signature." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
signOk = 1;
|
signOk = 1;
|
||||||
} else {
|
} else {
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg() Fail for gpg signature." << std::endl;
|
std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg() Fail for gpg signature." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
signOk = 0;
|
signOk = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signOk == 1)
|
if (signOk == 1)
|
||||||
|
@ -580,7 +580,7 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu
|
|||||||
* @param historical: is this msg from an historical cache
|
* @param historical: is this msg from an historical cache
|
||||||
* @return successfully executed or not
|
* @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
|
* 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
|
* @param historical: is this msg from an historical cache
|
||||||
* @return
|
* @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 ********************************************/
|
/********************************* p3Config ********************************************/
|
||||||
|
@ -634,12 +634,12 @@ void p3Forums::locked_notifyGroupChanged(GroupInfo &grp, uint32_t flags, bool h
|
|||||||
return p3GroupDistrib::locked_notifyGroupChanged(grp, flags, historical);
|
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;
|
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 grpId = msg->grpId;
|
||||||
std::string msgId = msg->msgId;
|
std::string msgId = msg->msgId;
|
||||||
|
@ -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 void locked_notifyGroupChanged(GroupInfo &grp, uint32_t flags, bool historical);
|
||||||
virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, std::string, bool historical);
|
virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, const std::string&, bool historical);
|
||||||
virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string, bool historical);
|
virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, const std::string&, bool historical);
|
||||||
|
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user