2012-05-21 18:07:43 -04:00
|
|
|
#ifndef RSGENEXCHANGE_H
|
|
|
|
#define RSGENEXCHANGE_H
|
|
|
|
|
2012-07-22 17:38:15 -04:00
|
|
|
/*
|
2012-08-06 17:00:38 -04:00
|
|
|
* libretroshare/src/gxs: rsgenexchange.h
|
2012-07-22 17:38:15 -04:00
|
|
|
*
|
|
|
|
* RetroShare C++ Interface.
|
|
|
|
*
|
|
|
|
* Copyright 2012-2012 by Christopher Evi-Parker, Robert Fernie
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-06-07 16:43:12 -04:00
|
|
|
#include <queue>
|
2012-08-25 11:48:55 -04:00
|
|
|
#include <ctime>
|
2012-05-21 18:07:43 -04:00
|
|
|
|
|
|
|
#include "rsgxs.h"
|
2012-07-05 17:26:14 -04:00
|
|
|
#include "rsgds.h"
|
|
|
|
#include "rsnxs.h"
|
2013-02-28 16:58:38 -05:00
|
|
|
#include "retroshare/rsgxsiface.h"
|
2012-07-05 17:26:14 -04:00
|
|
|
#include "rsgxsdataaccess.h"
|
2012-08-03 02:39:50 -04:00
|
|
|
#include "rsnxsobserver.h"
|
2012-07-05 17:26:14 -04:00
|
|
|
#include "retroshare/rsgxsservice.h"
|
2012-06-07 16:43:12 -04:00
|
|
|
#include "serialiser/rsnxsitems.h"
|
2013-03-21 19:17:24 -04:00
|
|
|
#include "rsgxsutil.h"
|
2012-06-07 16:43:12 -04:00
|
|
|
|
2013-03-23 10:13:15 -04:00
|
|
|
#define DEFAULT_MSG_STORE_PERIOD 60*60*24*30 // 1 month
|
2013-03-20 18:26:24 -04:00
|
|
|
|
2013-03-06 18:33:23 -05:00
|
|
|
template<class GxsItem, typename Identity = std::string>
|
2013-03-11 12:04:25 -04:00
|
|
|
class GxsPendingItem
|
2013-03-06 18:33:23 -05:00
|
|
|
{
|
|
|
|
public:
|
2013-03-11 12:04:25 -04:00
|
|
|
GxsPendingItem(GxsItem item, Identity id) :
|
2013-03-06 18:33:23 -05:00
|
|
|
mItem(item), mId(id), mAttempts(0)
|
|
|
|
{}
|
|
|
|
|
2013-03-11 12:04:25 -04:00
|
|
|
GxsPendingItem(const GxsPendingItem& gpsi)
|
2013-03-06 18:33:23 -05:00
|
|
|
{
|
|
|
|
this->mItem = gpsi.mItem;
|
|
|
|
this->mId = gpsi.mId;
|
|
|
|
this->mAttempts = gpsi.mAttempts;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const Identity& id)
|
|
|
|
{
|
|
|
|
return this->mId == id;
|
|
|
|
}
|
|
|
|
|
|
|
|
GxsItem mItem;
|
|
|
|
Identity mId;
|
|
|
|
uint8_t mAttempts;
|
|
|
|
};
|
|
|
|
|
2013-03-11 12:04:25 -04:00
|
|
|
class GxsGrpPendingSign
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
GxsGrpPendingSign(RsGxsGrpItem* item, uint32_t token): mLastAttemptTS(0), mStartTS(time(NULL)), mToken(token),
|
2013-09-15 17:18:20 -04:00
|
|
|
mItem(item), mHaveKeys(false), mIsUpdate(false)
|
2013-03-11 12:04:25 -04:00
|
|
|
{}
|
|
|
|
|
|
|
|
time_t mLastAttemptTS, mStartTS;
|
|
|
|
uint32_t mToken;
|
|
|
|
RsGxsGrpItem* mItem;
|
|
|
|
bool mHaveKeys; // mKeys->first == true if key present
|
2013-09-15 17:18:20 -04:00
|
|
|
bool mIsUpdate;
|
2013-03-11 12:04:25 -04:00
|
|
|
RsTlvSecurityKeySet mPrivateKeys;
|
|
|
|
RsTlvSecurityKeySet mPublicKeys;
|
|
|
|
};
|
|
|
|
|
2012-07-22 17:38:15 -04:00
|
|
|
typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgItem*> > GxsMsgDataMap;
|
|
|
|
typedef std::map<RsGxsGroupId, RsGxsGrpItem*> GxsGroupDataMap;
|
2012-11-13 17:36:06 -05:00
|
|
|
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMsgItem*> > GxsMsgRelatedDataMap;
|
2013-02-28 16:58:38 -05:00
|
|
|
|
2012-07-05 17:26:14 -04:00
|
|
|
/*!
|
|
|
|
* This should form the parent class to \n
|
|
|
|
* all gxs services. This provides access to service's msg/grp data \n
|
|
|
|
* management/publishing/sync features
|
|
|
|
*
|
|
|
|
* Features: \n
|
2012-10-23 17:52:51 -04:00
|
|
|
* a. Data Access: \n
|
|
|
|
* Provided by handle to RsTokenService. This ensure consistency \n
|
|
|
|
* of requests and hiearchy of groups -> then messages which are \n
|
|
|
|
* sectioned by group ids. \n
|
|
|
|
* The one caveat is that redemption of tokens are done through \n
|
|
|
|
* the backend of this class \n
|
|
|
|
* b. Publishing: \n
|
|
|
|
* Methods are provided to publish msg and group items and also make \n
|
|
|
|
* changes to meta information of both item types \n
|
|
|
|
* c. Sync/Notification: \n
|
|
|
|
* Also notifications are made here on receipt of new data from \n
|
2012-07-05 17:26:14 -04:00
|
|
|
* connected peers
|
|
|
|
*/
|
2012-10-28 14:40:01 -04:00
|
|
|
|
|
|
|
class RsGixs;
|
|
|
|
|
2013-02-28 16:58:38 -05:00
|
|
|
class RsGenExchange : public RsNxsObserver, public RsThread, public RsGxsIface
|
2012-05-21 18:07:43 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2013-03-06 18:33:23 -05:00
|
|
|
/// used by class derived for RsGenExchange to indicate if service create passed or not
|
2013-03-11 12:04:25 -04:00
|
|
|
enum ServiceCreate_Return { SERVICE_CREATE_SUCCESS, SERVICE_CREATE_FAIL, SERVICE_CREATE_FAIL_TRY_LATER } ;
|
2013-03-06 18:33:23 -05:00
|
|
|
|
2012-07-05 17:26:14 -04:00
|
|
|
/*!
|
2012-10-23 17:52:51 -04:00
|
|
|
* Constructs a RsGenExchange object, the owner ship of gds, ns, and serviceserialiser passes \n
|
2012-07-05 17:26:14 -04:00
|
|
|
* onto the constructed object
|
|
|
|
* @param gds Data service needed to act as store of message
|
|
|
|
* @param ns Network service needed to synchronise data with rs peers
|
|
|
|
* @param serviceSerialiser The users service needs this \n
|
|
|
|
* in order for gen exchange to deal with its data types
|
2012-10-23 17:52:51 -04:00
|
|
|
* @param mServType This should be service type used by the serialiser
|
2013-03-24 15:21:30 -04:00
|
|
|
* @param gixs This is used for verification of msgs and groups received by Gen Exchange using identities.
|
2012-11-10 18:42:38 -05:00
|
|
|
* @param authenPolicy This determines the authentication used for verfying authorship of msgs and groups
|
2012-07-05 17:26:14 -04:00
|
|
|
*/
|
2012-11-10 18:42:38 -05:00
|
|
|
RsGenExchange(RsGeneralDataService* gds, RsNetworkExchangeService* ns,
|
2013-03-24 15:21:30 -04:00
|
|
|
RsSerialType* serviceSerialiser, uint16_t mServType, RsGixs* gixs, uint32_t authenPolicy,
|
2013-03-20 18:26:24 -04:00
|
|
|
uint32_t messageStorePeriod = DEFAULT_MSG_STORE_PERIOD);
|
2012-07-05 17:26:14 -04:00
|
|
|
|
|
|
|
virtual ~RsGenExchange();
|
|
|
|
|
2012-07-17 17:27:43 -04:00
|
|
|
/** S: Observer implementation **/
|
|
|
|
|
2012-07-05 17:26:14 -04:00
|
|
|
/*!
|
|
|
|
* @param messages messages are deleted after function returns
|
|
|
|
*/
|
2012-08-06 17:00:38 -04:00
|
|
|
void notifyNewMessages(std::vector<RsNxsMsg*>& messages);
|
2012-07-05 17:26:14 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @param messages messages are deleted after function returns
|
|
|
|
*/
|
|
|
|
void notifyNewGroups(std::vector<RsNxsGrp*>& groups);
|
|
|
|
|
2012-07-17 17:27:43 -04:00
|
|
|
/** E: Observer implementation **/
|
2012-07-05 17:26:14 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* This is called by Gxs service runner
|
|
|
|
* periodically, use to implement non
|
|
|
|
* blocking calls
|
|
|
|
*/
|
|
|
|
void tick();
|
|
|
|
|
2012-10-15 14:52:47 -04:00
|
|
|
/*!
|
|
|
|
* Any backgroup processing needed by
|
|
|
|
*/
|
|
|
|
virtual void service_tick() = 0;
|
|
|
|
|
2012-07-05 17:26:14 -04:00
|
|
|
/*!
|
|
|
|
*
|
|
|
|
* @return handle to token service handle for making
|
|
|
|
* request to this gxs service
|
|
|
|
*/
|
2012-10-05 14:12:52 -04:00
|
|
|
RsTokenService* getTokenService();
|
2012-07-05 17:26:14 -04:00
|
|
|
|
2012-11-03 21:38:48 -04:00
|
|
|
void run();
|
|
|
|
|
2012-11-10 18:42:38 -05:00
|
|
|
/*!
|
|
|
|
* Policy bit pattern portion
|
|
|
|
*/
|
|
|
|
enum PrivacyBitPos { PUBLIC_GRP_BITS, RESTRICTED_GRP_BITS, PRIVATE_GRP_BITS, GRP_OPTION_BITS } ;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Convenience function for setting bit patterns of the individual privacy level authentication
|
|
|
|
* policy and group options
|
|
|
|
* @param flag the bit pattern (and policy) set for the privacy policy
|
2013-03-06 18:33:23 -05:00
|
|
|
* @param authenFlag Only the policy portion chosen will be modified with 'flag',
|
|
|
|
* the origianl flags in the indicated bit position (pos) are over-written
|
|
|
|
* @param pos The policy bit portion to modify
|
2012-11-10 18:42:38 -05:00
|
|
|
* @see PrivacyBitPos
|
|
|
|
*/
|
|
|
|
static bool setAuthenPolicyFlag(const uint8_t& flag, uint32_t& authenFlag, const PrivacyBitPos& pos);
|
|
|
|
|
2012-10-15 16:31:56 -04:00
|
|
|
public:
|
2012-07-05 17:26:14 -04:00
|
|
|
|
|
|
|
/** data access functions **/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Retrieve group list for a given token
|
|
|
|
* @param token
|
|
|
|
* @param groupIds
|
|
|
|
* @return false if token cannot be redeemed, if false you may have tried to redeem when not ready
|
|
|
|
*/
|
2012-07-22 17:38:15 -04:00
|
|
|
bool getGroupList(const uint32_t &token, std::list<RsGxsGroupId> &groupIds);
|
2012-07-05 17:26:14 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Retrieve msg list for a given token sectioned by group Ids
|
|
|
|
* @param token token to be redeemed
|
|
|
|
* @param msgIds a map of grpId -> msgList (vector)
|
2012-11-13 17:36:06 -05:00
|
|
|
* @return false if could not redeem token
|
2012-07-05 17:26:14 -04:00
|
|
|
*/
|
2012-07-22 17:38:15 -04:00
|
|
|
bool getMsgList(const uint32_t &token, GxsMsgIdResult &msgIds);
|
2012-07-05 17:26:14 -04:00
|
|
|
|
2012-11-13 17:36:06 -05:00
|
|
|
/*!
|
|
|
|
* Retrieve msg list for a given token for message related info
|
|
|
|
* @param token token to be redeemed
|
|
|
|
* @param msgIds a map of RsGxsGrpMsgIdPair -> msgList (vector)
|
|
|
|
* @return false if could not redeem token
|
|
|
|
*/
|
|
|
|
bool getMsgRelatedList(const uint32_t &token, MsgRelatedIdResult& msgIds);
|
|
|
|
|
2012-07-05 17:26:14 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* retrieve group meta data associated to a request token
|
|
|
|
* @param token
|
|
|
|
* @param groupInfo
|
2012-11-13 17:36:06 -05:00
|
|
|
* @return false if could not redeem token
|
2012-07-05 17:26:14 -04:00
|
|
|
*/
|
|
|
|
bool getGroupMeta(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* retrieves message meta data associated to a request token
|
|
|
|
* @param token token to be redeemed
|
|
|
|
* @param msgInfo the meta data to be retrieved for token store here
|
|
|
|
*/
|
2012-07-22 17:38:15 -04:00
|
|
|
bool getMsgMeta(const uint32_t &token, GxsMsgMetaMap &msgInfo);
|
2012-07-05 17:26:14 -04:00
|
|
|
|
2012-11-13 17:36:06 -05:00
|
|
|
/*!
|
|
|
|
* Retrieve msg meta for a given token for message related info
|
|
|
|
* @param token token to be redeemed
|
|
|
|
* @param msgIds a map of RsGxsGrpMsgIdPair -> msgList (vector)
|
|
|
|
* @return false if could not redeem token
|
|
|
|
*/
|
|
|
|
bool getMsgRelatedMeta(const uint32_t &token, GxsMsgRelatedMetaMap& msgMeta);
|
|
|
|
|
2012-10-15 16:31:56 -04:00
|
|
|
|
2013-02-28 16:58:38 -05:00
|
|
|
/*!
|
|
|
|
* Gxs services should call this for automatic handling of
|
|
|
|
* changes, send
|
|
|
|
* @param changes
|
|
|
|
*/
|
|
|
|
virtual void receiveChanges(std::vector<RsGxsNotify*>& changes);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Checks to see if a change has been received for
|
|
|
|
* for a message or group
|
|
|
|
* @param willCallGrpChanged if this is set to true, group changed function will return list
|
|
|
|
* groups that have changed, if false, the group changed list is cleared
|
|
|
|
* @param willCallMsgChanged if this is set to true, msgChanged function will return map
|
|
|
|
* messages that have changed, if false, the message changed map is cleared
|
|
|
|
* @return true if a change has occured for msg or group
|
|
|
|
* @see groupsChanged
|
|
|
|
* @see msgsChanged
|
|
|
|
*/
|
|
|
|
bool updated(bool willCallGrpChanged = false, bool willCallMsgChanged = false);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* The groups changed. \n
|
|
|
|
* class can reimplement to use to tailor
|
|
|
|
* the group actually set for ui notification.
|
|
|
|
* If receivedChanges is not passed RsGxsNotify changes
|
|
|
|
* this function does nothing
|
|
|
|
* @param grpIds returns list of grpIds that have changed
|
|
|
|
* @see updated
|
|
|
|
*/
|
|
|
|
void groupsChanged(std::list<RsGxsGroupId>& grpIds);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* The msg changed. \n
|
|
|
|
* class can reimplement to use to tailor
|
|
|
|
* the msg actually set for ui notification.
|
|
|
|
* If receivedChanges is not passed RsGxsNotify changes
|
|
|
|
* this function does nothing
|
|
|
|
* @param msgs returns map of message ids that have changed
|
|
|
|
* @see updated
|
|
|
|
*/
|
|
|
|
void msgsChanged(std::map<RsGxsGroupId,
|
|
|
|
std::vector<RsGxsMessageId> >& msgs);
|
2012-10-15 16:31:56 -04:00
|
|
|
|
|
|
|
|
2013-02-28 16:58:38 -05:00
|
|
|
bool subscribeToGroup(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe);
|
2013-03-06 18:33:23 -05:00
|
|
|
|
2013-03-23 10:07:52 -04:00
|
|
|
/*!
|
|
|
|
* Gets service statistic for a given services
|
|
|
|
* @param token value to to retrieve requested stats
|
|
|
|
* @param stats the status
|
|
|
|
* @return true if token exists false otherwise
|
|
|
|
*/
|
|
|
|
bool getServiceStatistic(const uint32_t& token, GxsServiceStatistic& stats);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Get group statistic
|
|
|
|
* @param token to be redeemed
|
|
|
|
* @param stats the stats associated to token requ
|
|
|
|
* @return true if token is false otherwise
|
|
|
|
*/
|
|
|
|
bool getGroupStatistic(const uint32_t& token, GxsGroupStatistic& stats);
|
2012-10-15 16:31:56 -04:00
|
|
|
|
2013-03-23 10:07:52 -04:00
|
|
|
protected:
|
2012-10-15 16:31:56 -04:00
|
|
|
|
2012-07-05 17:26:14 -04:00
|
|
|
/*!
|
|
|
|
* retrieves group data associated to a request token
|
|
|
|
* @param token token to be redeemed for grpitem retrieval
|
|
|
|
* @param grpItem the items to be retrieved for token are stored here
|
|
|
|
*/
|
2012-08-12 16:46:21 -04:00
|
|
|
bool getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem*>& grpItem);
|
2012-07-05 17:26:14 -04:00
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
template<class GrpType>
|
|
|
|
bool getGroupDataT(const uint32_t &token, std::vector<GrpType*>& grpItem)
|
|
|
|
{
|
|
|
|
std::vector<RsGxsGrpItem*> items;
|
|
|
|
bool ok = getGroupData(token, items);
|
|
|
|
std::vector<RsGxsGrpItem*>::iterator vit = items.begin();
|
|
|
|
|
|
|
|
for(; vit != items.end(); vit++)
|
|
|
|
{
|
|
|
|
RsGxsGrpItem* gi = *vit;
|
|
|
|
|
|
|
|
GrpType* item = dynamic_cast<GrpType*>(gi);
|
|
|
|
|
|
|
|
if(item)
|
|
|
|
{
|
|
|
|
grpItem.push_back(item);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#ifdef GXS_DEBUG
|
|
|
|
std::cerr << "\nRsGenExchange::getGroupDataT(): Wrong type!\n";
|
|
|
|
#endif
|
|
|
|
delete gi;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2013-03-04 15:26:48 -05:00
|
|
|
public:
|
2013-06-04 17:00:43 -04:00
|
|
|
|
2012-07-05 17:26:14 -04:00
|
|
|
/*!
|
|
|
|
* retrieves message data associated to a request token
|
|
|
|
* @param token token to be redeemed for message item retrieval
|
|
|
|
* @param msgItems
|
|
|
|
*/
|
2012-07-22 17:38:15 -04:00
|
|
|
bool getMsgData(const uint32_t &token, GxsMsgDataMap& msgItems);
|
2012-07-05 17:26:14 -04:00
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
template <class MsgType>
|
|
|
|
bool getMsgDataT(const uint32_t &token, std::map<RsGxsGroupId,
|
|
|
|
std::vector<MsgType*> >& msgItems)
|
|
|
|
{
|
|
|
|
GxsMsgDataMap msgData;
|
|
|
|
bool ok = getMsgData(token, msgData);
|
|
|
|
|
|
|
|
GxsMsgDataMap::iterator mit = msgData.begin();
|
|
|
|
|
|
|
|
for(; mit != msgData.end(); mit++)
|
|
|
|
{
|
|
|
|
const RsGxsGroupId& grpId = mit->first;
|
|
|
|
std::vector<RsGxsMsgItem*>& mv = mit->second;
|
|
|
|
std::vector<RsGxsMsgItem*>::iterator vit = mv.begin();
|
|
|
|
for(; vit != mv.end(); vit++)
|
|
|
|
{
|
|
|
|
RsGxsMsgItem* mi = *vit;
|
|
|
|
MsgType* mt = dynamic_cast<MsgType*>(mi);
|
|
|
|
|
|
|
|
if(mt != NULL)
|
|
|
|
{
|
|
|
|
msgItems[grpId].push_back(mt);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cerr << "RsGenExchange::getMsgDataT(): bad cast to msg type" << std::endl;
|
|
|
|
delete mi;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2012-11-13 17:36:06 -05:00
|
|
|
/*!
|
|
|
|
* retrieves message related data associated to a request token
|
|
|
|
* @param token token to be redeemed for message item retrieval
|
|
|
|
* @param msgItems
|
|
|
|
*/
|
|
|
|
bool getMsgRelatedData(const uint32_t &token, GxsMsgRelatedDataMap& msgItems);
|
|
|
|
|
2013-03-04 15:26:48 -05:00
|
|
|
protected:
|
|
|
|
|
2012-11-13 17:36:06 -05:00
|
|
|
/*!
|
|
|
|
* Convenience template function for retrieve
|
|
|
|
* msg related data from
|
|
|
|
* @param GxsMsgType This represent derived msg class type of the service (i.e. msg type that derives from RsGxsMsgItem
|
|
|
|
* @param MsgType Represents the final type the core data is converted to
|
|
|
|
* @param token token to be redeemed
|
|
|
|
*/
|
|
|
|
template <class GxsMsgType, class MsgType>
|
|
|
|
bool getMsgRelatedDataT(const uint32_t &token, std::map<RsGxsGrpMsgIdPair, std::vector<MsgType> > &msgItems)
|
|
|
|
{
|
|
|
|
|
|
|
|
RsStackMutex stack(mGenMtx);
|
|
|
|
NxsMsgRelatedDataResult msgResult;
|
|
|
|
bool ok = mDataAccess->getMsgRelatedData(token, msgResult);
|
|
|
|
NxsMsgRelatedDataResult::iterator mit = msgResult.begin();
|
|
|
|
|
|
|
|
if(ok)
|
|
|
|
{
|
|
|
|
for(; mit != msgResult.end(); mit++)
|
|
|
|
{
|
|
|
|
std::vector<MsgType> gxsMsgItems;
|
|
|
|
const RsGxsGrpMsgIdPair& msgId = mit->first;
|
|
|
|
std::vector<RsNxsMsg*>& nxsMsgsV = mit->second;
|
|
|
|
std::vector<RsNxsMsg*>::iterator vit
|
|
|
|
= nxsMsgsV.begin();
|
|
|
|
for(; vit != nxsMsgsV.end(); vit++)
|
|
|
|
{
|
|
|
|
RsNxsMsg*& msg = *vit;
|
2013-03-23 10:07:52 -04:00
|
|
|
RsItem* item = NULL;
|
2012-11-13 17:36:06 -05:00
|
|
|
|
2013-03-23 10:07:52 -04:00
|
|
|
if(msg->msg.bin_len != 0)
|
|
|
|
item = mSerialiser->deserialise(msg->msg.bin_data,
|
2012-11-13 17:36:06 -05:00
|
|
|
&msg->msg.bin_len);
|
2013-03-23 10:07:52 -04:00
|
|
|
|
|
|
|
GxsMsgType* mItem = NULL;
|
|
|
|
|
|
|
|
if(item)
|
|
|
|
mItem = dynamic_cast<GxsMsgType*>(item);
|
2012-11-13 17:36:06 -05:00
|
|
|
|
2013-02-07 18:04:16 -05:00
|
|
|
if(mItem == NULL)
|
|
|
|
{
|
2012-11-13 17:36:06 -05:00
|
|
|
delete msg;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
mItem->meta = *((*vit)->metaData); // get meta info from nxs msg
|
|
|
|
// GxsMsgType m = (*mItem); // doesn't work! don't know why, even with overloading done.
|
|
|
|
MsgType theServMsg = (MsgType)*mItem;
|
|
|
|
gxsMsgItems.push_back(theServMsg);
|
|
|
|
delete msg;
|
|
|
|
}
|
|
|
|
msgItems[msgId] = gxsMsgItems;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2013-03-15 16:46:49 -04:00
|
|
|
public:
|
2012-10-15 14:52:47 -04:00
|
|
|
/*!
|
|
|
|
* Assigns a token value to passed integer
|
|
|
|
* The status of the token can still be queried from request status feature
|
|
|
|
* @warning the token space is shared with RsGenExchange backend, so do not
|
|
|
|
* modify tokens except does you have created by calling generatePublicToken()
|
|
|
|
* @return token
|
|
|
|
*/
|
|
|
|
uint32_t generatePublicToken();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Updates the status of associate token
|
|
|
|
* @warning the token space is shared with RsGenExchange backend, so do not
|
|
|
|
* modify tokens except does you have created by calling generatePublicToken()
|
|
|
|
* @param token
|
|
|
|
* @param status
|
|
|
|
* @return false if token could not be found, true if token disposed of
|
|
|
|
*/
|
|
|
|
bool updatePublicRequestStatus(const uint32_t &token, const uint32_t &status);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* This gets rid of a publicly issued token
|
|
|
|
* @param token
|
|
|
|
* @return false if token could not found, true if token is disposed of
|
|
|
|
*/
|
|
|
|
bool disposeOfPublicToken(const uint32_t &token);
|
|
|
|
|
2013-03-15 16:46:49 -04:00
|
|
|
protected:
|
2012-10-15 14:52:47 -04:00
|
|
|
/*!
|
|
|
|
* This gives access to the data store which hold msgs and groups
|
|
|
|
* for the service
|
|
|
|
* @return Data store for retrieving msgs and groups
|
|
|
|
*/
|
|
|
|
RsGeneralDataService* getDataStore();
|
|
|
|
|
2012-10-23 17:52:51 -04:00
|
|
|
/*!
|
|
|
|
* Retrieve keys for a given group, \n
|
2012-12-02 14:40:17 -05:00
|
|
|
* call is blocking retrieval from underlying db
|
2012-10-23 17:52:51 -04:00
|
|
|
* @warning under normal circumstance a service should not need this
|
|
|
|
* @param grpId the id of the group to retrieve keys for
|
2013-03-06 18:33:23 -05:00
|
|
|
* @param keys set to the retrieved keys
|
2012-10-23 17:52:51 -04:00
|
|
|
* @return false if group does not exist or grpId is empty
|
|
|
|
*/
|
|
|
|
bool getGroupKeys(const RsGxsGroupId& grpId, RsTlvSecurityKeySet& keySet);
|
|
|
|
|
2012-08-18 06:01:35 -04:00
|
|
|
public:
|
|
|
|
|
|
|
|
/*!
|
2012-08-25 11:48:55 -04:00
|
|
|
* This allows the client service to acknowledge that their msgs has \n
|
2012-08-18 06:01:35 -04:00
|
|
|
* been created/modified and retrieve the create/modified msg ids
|
|
|
|
* @param token the token related to modification/create request
|
|
|
|
* @param msgIds map of grpid->msgIds of message created/modified
|
|
|
|
* @return true if token exists false otherwise
|
|
|
|
*/
|
2012-08-21 17:32:07 -04:00
|
|
|
bool acknowledgeTokenMsg(const uint32_t& token, RsGxsGrpMsgIdPair& msgId);
|
2012-08-18 06:01:35 -04:00
|
|
|
|
|
|
|
/*!
|
2012-11-02 19:35:10 -04:00
|
|
|
* This allows the client service to acknowledge that their grps has \n
|
2012-08-18 06:01:35 -04:00
|
|
|
* been created/modified and retrieve the create/modified grp ids
|
|
|
|
* @param token the token related to modification/create request
|
|
|
|
* @param msgIds vector of ids of groups created/modified
|
|
|
|
* @return true if token exists false otherwise
|
|
|
|
*/
|
|
|
|
bool acknowledgeTokenGrp(const uint32_t& token, RsGxsGroupId& grpId);
|
|
|
|
|
2012-07-22 17:38:15 -04:00
|
|
|
protected:
|
2012-07-05 17:26:14 -04:00
|
|
|
|
|
|
|
/** Modifications **/
|
|
|
|
|
|
|
|
/*!
|
2012-08-25 11:48:55 -04:00
|
|
|
* Enables publication of a group item \n
|
|
|
|
* This will induce a related change message \n
|
|
|
|
* Ownership of item passes to this rsgenexchange \n
|
2012-08-18 06:01:35 -04:00
|
|
|
* @param token
|
2012-07-05 17:26:14 -04:00
|
|
|
* @param grpItem
|
|
|
|
*/
|
2012-08-21 17:32:07 -04:00
|
|
|
void publishGroup(uint32_t& token, RsGxsGrpItem* grpItem);
|
2012-07-05 17:26:14 -04:00
|
|
|
|
2013-09-15 17:18:20 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Updates an existing group item \n
|
2013-10-05 07:36:31 -04:00
|
|
|
* This will induce a related change message \n
|
|
|
|
* Ownership of item passes to this rsgenexchange \n
|
|
|
|
* @param token
|
|
|
|
* @param grpItem
|
|
|
|
*/
|
2014-02-16 17:28:23 -05:00
|
|
|
void updateGroup(uint32_t& token, RsGxsGrpItem* grpItem);
|
2013-09-15 17:18:20 -04:00
|
|
|
|
2013-03-04 15:26:48 -05:00
|
|
|
public:
|
2012-07-05 17:26:14 -04:00
|
|
|
/*!
|
2012-08-25 11:48:55 -04:00
|
|
|
* Enables publication of a message item \n
|
|
|
|
* Setting mOrigMsgId meta member to blank \n
|
|
|
|
* leads to this msg being an original msg \n
|
|
|
|
* if mOrigMsgId is not blank the msgId then this msg is \n
|
|
|
|
* considered a versioned msg \n
|
2012-07-26 17:48:54 -04:00
|
|
|
* Ownership of item passes to this rsgenexchange
|
2012-08-18 06:01:35 -04:00
|
|
|
* @param token
|
2012-07-05 17:26:14 -04:00
|
|
|
* @param msgItem
|
|
|
|
*/
|
2012-08-21 17:32:07 -04:00
|
|
|
void publishMsg(uint32_t& token, RsGxsMsgItem* msgItem);
|
|
|
|
|
2013-03-04 15:26:48 -05:00
|
|
|
protected:
|
2012-11-03 21:38:48 -04:00
|
|
|
/*!
|
|
|
|
* This represents the group before its signature is calculated
|
|
|
|
* Reimplement this function if you need to access keys to further extend
|
|
|
|
* security of your group items using keyset properties
|
2013-03-08 14:55:59 -05:00
|
|
|
* Derived service should return one of three ServiceCreate_Return enum values below
|
2012-11-03 21:38:48 -04:00
|
|
|
* @warning do not modify keySet!
|
|
|
|
* @param grp The group which is stored by GXS prior
|
|
|
|
* service can make specific modifications need
|
|
|
|
* in particular access to its keys and meta
|
|
|
|
* @param keySet this is the key set used to define the group
|
|
|
|
* contains private and public admin and publish keys
|
|
|
|
* (use key flags to distinguish)
|
2013-03-08 14:55:59 -05:00
|
|
|
* @return SERVICE_CREATE_SUCCESS, SERVICE_CREATE_FAIL, SERVICE_FAIL_TRY_LATER
|
2012-11-03 21:38:48 -04:00
|
|
|
*/
|
2013-03-08 14:55:59 -05:00
|
|
|
virtual ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet);
|
2012-11-03 21:38:48 -04:00
|
|
|
|
2012-10-15 16:31:56 -04:00
|
|
|
public:
|
|
|
|
|
2012-08-21 17:32:07 -04:00
|
|
|
/*!
|
|
|
|
* sets the group subscribe flag
|
|
|
|
* @param token this is set to token value associated to this request
|
2012-11-02 19:35:10 -04:00
|
|
|
* @param grpId Id of group whose subscribe file will be changed
|
|
|
|
* @param status
|
|
|
|
* @param mask
|
2012-08-21 17:32:07 -04:00
|
|
|
*/
|
2012-10-21 11:48:18 -04:00
|
|
|
void setGroupSubscribeFlags(uint32_t& token, const RsGxsGroupId& grpId, const uint32_t& status, const uint32_t& mask);
|
2012-08-21 17:32:07 -04:00
|
|
|
|
2012-11-02 19:35:10 -04:00
|
|
|
/*!
|
|
|
|
* sets the group subscribe flag
|
|
|
|
* @param token this is set to token value associated to this request
|
|
|
|
* @param grpId Id of group whose subscribe file will be changed
|
|
|
|
* @param status
|
|
|
|
* @param mask
|
|
|
|
*/
|
2012-10-21 11:48:18 -04:00
|
|
|
void setGroupStatusFlags(uint32_t& token, const RsGxsGroupId& grpId, const uint32_t& status, const uint32_t& mask);
|
2012-08-21 17:32:07 -04:00
|
|
|
|
2012-11-02 19:35:10 -04:00
|
|
|
/*!
|
|
|
|
* sets the group service string
|
|
|
|
* @param token this is set to token value associated to this request
|
|
|
|
* @param grpId Id of group whose subscribe file will be changed
|
|
|
|
* @param servString
|
|
|
|
*/
|
2012-08-21 17:32:07 -04:00
|
|
|
void setGroupServiceString(uint32_t& token, const RsGxsGroupId& grpId, const std::string& servString);
|
|
|
|
|
2012-11-02 19:35:10 -04:00
|
|
|
/*!
|
2012-12-08 16:50:13 -05:00
|
|
|
* sets the msg status flag
|
|
|
|
* @param token this is set to token value associated to this request
|
|
|
|
* @param grpId Id of group whose subscribe file will be changed
|
|
|
|
* @param status
|
|
|
|
* @param mask Mask to apply to status flag
|
|
|
|
*/
|
2012-10-21 11:48:18 -04:00
|
|
|
void setMsgStatusFlags(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, const uint32_t& status, const uint32_t& mask);
|
2012-08-21 17:32:07 -04:00
|
|
|
|
2012-11-02 19:35:10 -04:00
|
|
|
/*!
|
2012-12-08 16:50:13 -05:00
|
|
|
* sets the message service string
|
|
|
|
* @param token this is set to token value associated to this request
|
|
|
|
* @param msgId Id of message whose service string will be changed
|
|
|
|
* @param servString The service string to set msg to
|
|
|
|
*/
|
2012-08-21 17:32:07 -04:00
|
|
|
void setMsgServiceString(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, const std::string& servString );
|
|
|
|
|
2012-07-05 17:26:14 -04:00
|
|
|
protected:
|
|
|
|
|
|
|
|
/** Notifications **/
|
|
|
|
|
|
|
|
/*!
|
2012-07-22 17:38:15 -04:00
|
|
|
* This confirms this class as an abstract one that \n
|
2012-07-05 17:26:14 -04:00
|
|
|
* should not be instantiated \n
|
|
|
|
* The deriving class should implement this function \n
|
2012-07-22 17:38:15 -04:00
|
|
|
* as it is called by the backend GXS system to \n
|
2012-07-05 17:26:14 -04:00
|
|
|
* update client of changes which should \n
|
2012-07-22 17:38:15 -04:00
|
|
|
* instigate client to retrieve new content from the system
|
2012-11-17 09:35:21 -05:00
|
|
|
* Note! For newly received message and groups, bit 0xf00 is set to
|
|
|
|
* GXS_SERV::GXS_MSG_STATUS_UNPROCESSED and GXS_SERV::GXS_MSG_STATUS_UNREAD
|
2012-07-05 17:26:14 -04:00
|
|
|
* @param changes the changes that have occured to data held by this service
|
|
|
|
*/
|
2012-07-26 17:48:54 -04:00
|
|
|
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) = 0;
|
2012-07-18 17:35:41 -04:00
|
|
|
|
2012-08-06 17:00:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2012-07-22 17:38:15 -04:00
|
|
|
|
2012-07-18 17:35:41 -04:00
|
|
|
void processRecvdData();
|
|
|
|
|
|
|
|
void processRecvdMessages();
|
|
|
|
|
|
|
|
void processRecvdGroups();
|
|
|
|
|
2012-08-12 16:46:21 -04:00
|
|
|
void publishGrps();
|
|
|
|
|
2013-09-15 17:18:20 -04:00
|
|
|
void processGroupUpdatePublish();
|
|
|
|
|
2012-08-12 16:46:21 -04:00
|
|
|
void publishMsgs();
|
|
|
|
|
2012-08-21 17:32:07 -04:00
|
|
|
/*!
|
|
|
|
* processes msg local meta changes
|
|
|
|
*/
|
|
|
|
void processMsgMetaChanges();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Processes group local meta changes
|
|
|
|
*/
|
|
|
|
void processGrpMetaChanges();
|
|
|
|
|
2012-11-17 09:35:21 -05:00
|
|
|
/*!
|
|
|
|
* Convenience function for properly applying masks for status and subscribe flag
|
|
|
|
* of a group.
|
|
|
|
* @warning mask entry is removed from grpCv
|
|
|
|
*/
|
|
|
|
bool processGrpMask(const RsGxsGroupId& grpId, ContentValue& grpCv);
|
|
|
|
|
2012-11-02 19:35:10 -04:00
|
|
|
/*!
|
|
|
|
* This completes the creation of an instance on RsNxsGrp
|
2012-11-11 18:45:22 -05:00
|
|
|
* by assigning it a groupId and signature via SHA1 and EVP_sign respectively \n
|
2012-11-02 19:35:10 -04:00
|
|
|
* @param grp Nxs group to create
|
2013-03-08 14:55:59 -05:00
|
|
|
* @return CREATE_SUCCESS for success, CREATE_FAIL for fail,
|
|
|
|
* CREATE_FAIL_TRY_LATER for Id sign key not avail (but requested)
|
2012-11-02 19:35:10 -04:00
|
|
|
*/
|
2013-03-08 14:55:59 -05:00
|
|
|
uint8_t createGroup(RsNxsGrp* grp, RsTlvSecurityKeySet& privateKeySet, RsTlvSecurityKeySet& publicKeySet);
|
2012-11-02 19:35:10 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* This completes the creation of an instance on RsNxsMsg
|
|
|
|
* by assigning it a groupId and signature via SHA1 and EVP_sign respectively
|
|
|
|
* What signatures are calculated are based on the authentication policy
|
|
|
|
* of the service
|
|
|
|
* @param msg the Nxs message to create
|
2013-03-06 18:33:23 -05:00
|
|
|
* CREATE_FAIL, CREATE_SUCCESS, CREATE_ID_SIGN_NOT_AVAIL
|
|
|
|
* @return CREATE_SUCCESS for success, CREATE_FAIL for fail,
|
2013-03-08 14:55:59 -05:00
|
|
|
* CREATE_FAIL_TRY_LATER for Id sign key not avail (but requested)
|
2012-11-02 19:35:10 -04:00
|
|
|
*/
|
2013-03-06 18:33:23 -05:00
|
|
|
int createMessage(RsNxsMsg* msg);
|
2012-08-12 16:46:21 -04:00
|
|
|
|
2012-11-11 18:45:22 -05:00
|
|
|
/*!
|
|
|
|
* convenience function to create sign
|
|
|
|
* @param signSet signatures are stored here
|
|
|
|
* @param msgData message data to be signed
|
|
|
|
* @param grpMeta the meta data for group the message belongs to
|
2013-03-06 18:33:23 -05:00
|
|
|
* @return SIGN_SUCCESS for success, SIGN_FAIL for fail,
|
2013-03-08 14:55:59 -05:00
|
|
|
* SIGN_FAIL_TRY_LATER for Id sign key not avail (but requested), try later
|
2012-11-11 18:45:22 -05:00
|
|
|
*/
|
2013-03-06 18:33:23 -05:00
|
|
|
int createMsgSignatures(RsTlvKeySignatureSet& signSet, RsTlvBinaryData& msgData,
|
2012-11-11 18:45:22 -05:00
|
|
|
const RsGxsMsgMetaData& msgMeta, RsGxsGrpMetaData& grpMeta);
|
|
|
|
|
2013-03-08 14:55:59 -05:00
|
|
|
/*!
|
|
|
|
* convenience function to create sign for groups
|
|
|
|
* @param signSet signatures are stored here
|
|
|
|
* @param grpData group data to be signed
|
|
|
|
* @param grpMeta the meta data for group to be signed
|
|
|
|
* @return SIGN_SUCCESS for success, SIGN_FAIL for fail,
|
|
|
|
* SIGN_FAIL_TRY_LATER for Id sign key not avail (but requested), try later
|
|
|
|
*/
|
|
|
|
int createGroupSignatures(RsTlvKeySignatureSet& signSet, RsTlvBinaryData& grpData,
|
|
|
|
RsGxsGrpMetaData& grpMeta);
|
|
|
|
|
2012-09-17 18:08:23 -04:00
|
|
|
/*!
|
|
|
|
* check meta change is legal
|
|
|
|
* @return false if meta change is not legal
|
|
|
|
*/
|
|
|
|
bool locked_validateGrpMetaChange(GrpLocMetaData&);
|
|
|
|
|
2012-11-03 21:38:48 -04:00
|
|
|
/*!
|
|
|
|
* Generate a set of keys that can define a GXS group
|
2013-02-07 18:04:16 -05:00
|
|
|
* @param privatekeySet contains private generated keys
|
2013-10-06 17:07:31 -04:00
|
|
|
* @param publickeySet contains public generated keys (counterpart of private)
|
2013-02-07 18:04:16 -05:00
|
|
|
* @param genPublicKeys should publish key pair also be generated
|
2012-11-03 21:38:48 -04:00
|
|
|
*/
|
2013-02-07 18:04:16 -05:00
|
|
|
void generateGroupKeys(RsTlvSecurityKeySet& privatekeySet, RsTlvSecurityKeySet& publickeySet, bool genPublishKeys);
|
2012-11-03 21:38:48 -04:00
|
|
|
|
2013-10-06 17:07:31 -04:00
|
|
|
/*!
|
|
|
|
* Generate public set of keys from their private counterparts
|
|
|
|
* No keys will be generated if one fails
|
|
|
|
* @param privatekeySet contains private generated keys
|
|
|
|
* @param publickeySet contains public generated keys (counterpart of private)
|
|
|
|
* @return false if key gen failed for a key set
|
|
|
|
*/
|
|
|
|
void generatePublicFromPrivateKeys(const RsTlvSecurityKeySet& privatekeySet, RsTlvSecurityKeySet& publickeySet);
|
|
|
|
|
2012-11-10 18:42:38 -05:00
|
|
|
/*!
|
2013-03-10 11:08:04 -04:00
|
|
|
* Attempts to validate msg signatures
|
2012-11-10 18:42:38 -05:00
|
|
|
* @param msg message to be validated
|
|
|
|
* @param grpFlag the flag for the group the message belongs to
|
2013-03-10 11:08:04 -04:00
|
|
|
* @param grpKeySet the key set user has for the message's group
|
2013-03-06 18:33:23 -05:00
|
|
|
* @return VALIDATE_SUCCESS for success, VALIDATE_FAIL for fail,
|
|
|
|
* VALIDATE_ID_SIGN_NOT_AVAIL for Id sign key not avail (but requested)
|
2012-11-10 18:42:38 -05:00
|
|
|
*/
|
2013-03-06 18:33:23 -05:00
|
|
|
int validateMsg(RsNxsMsg* msg, const uint32_t& grpFlag, RsTlvSecurityKeySet& grpKeySet);
|
2012-11-10 18:42:38 -05:00
|
|
|
|
2013-03-10 11:08:04 -04:00
|
|
|
/*!
|
|
|
|
* Attempts to validate group signatures
|
|
|
|
* @param grp group to be validated
|
|
|
|
* @param grpKeySet the keys set user has for the group
|
|
|
|
* @return VALIDATE_SUCCESS for success, VALIDATE_FAIL for fail,
|
|
|
|
* VALIDATE_ID_SIGN_NOT_AVAIL for Id sign key not avail (but requested)
|
|
|
|
*/
|
|
|
|
int validateGrp(RsNxsGrp* grp, RsTlvSecurityKeySet& grpKeySet);
|
|
|
|
|
2012-11-11 18:45:22 -05:00
|
|
|
/*!
|
|
|
|
* Checks flag against a given privacy bit block
|
|
|
|
* @param pos Determines 8 bit wide privacy block to check
|
|
|
|
* @param flag the flag to and(&) against
|
|
|
|
* @param the result of the (bit-block & flag)
|
|
|
|
*/
|
2013-03-08 14:55:59 -05:00
|
|
|
bool checkAuthenFlag(const PrivacyBitPos& pos, const uint8_t& flag) const;
|
2012-11-10 18:42:38 -05:00
|
|
|
|
2012-11-11 18:45:22 -05:00
|
|
|
void groupShareKeys(std::list<std::string> peers);
|
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
static void computeHash(const RsTlvBinaryData& data, std::string& hash);
|
|
|
|
|
2013-09-11 16:42:56 -04:00
|
|
|
/*!
|
|
|
|
* Checks validation of recently received groups to be
|
|
|
|
* updated
|
|
|
|
*/
|
|
|
|
void performUpdateValidation();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Checks if the update is valid (i.e. the new admin signature is by the old admin key)
|
|
|
|
* @param oldGrp the old group to be updated (must have meta data member initialised)
|
|
|
|
* @param newGrp the new group that updates the old group (must have meta data member initialised)
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
bool updateValid(RsGxsGrpMetaData& oldGrp, RsNxsGrp& newGrp) const;
|
|
|
|
|
2013-10-05 07:36:31 -04:00
|
|
|
/*!
|
2013-10-06 17:07:31 -04:00
|
|
|
* convenience function for checking private publish and admin keys are present
|
2013-10-05 07:36:31 -04:00
|
|
|
* @param keySet The keys set to split into a private and public set
|
2013-10-06 17:07:31 -04:00
|
|
|
* @return false, if private admin and publish keys cannot be found, true otherwise
|
2013-10-05 07:36:31 -04:00
|
|
|
*/
|
2013-10-06 17:07:31 -04:00
|
|
|
bool checkKeys(const RsTlvSecurityKeySet& keySet);
|
2013-10-05 07:36:31 -04:00
|
|
|
|
2012-07-05 17:26:14 -04:00
|
|
|
private:
|
|
|
|
|
2012-07-26 17:48:54 -04:00
|
|
|
RsMutex mGenMtx;
|
2012-07-05 17:26:14 -04:00
|
|
|
RsGxsDataAccess* mDataAccess;
|
|
|
|
RsGeneralDataService* mDataStore;
|
|
|
|
RsNetworkExchangeService *mNetService;
|
|
|
|
RsSerialType *mSerialiser;
|
2013-03-08 14:55:59 -05:00
|
|
|
/// service type
|
|
|
|
uint16_t mServType;
|
2012-10-23 17:52:51 -04:00
|
|
|
RsGixs* mGixs;
|
2012-07-05 17:26:14 -04:00
|
|
|
|
|
|
|
std::vector<RsNxsMsg*> mReceivedMsgs;
|
2013-03-10 11:08:04 -04:00
|
|
|
|
2013-03-11 12:04:25 -04:00
|
|
|
typedef std::vector<GxsPendingItem<RsNxsGrp*, RsGxsGroupId> > NxsGrpPendValidVect;
|
2013-03-10 11:08:04 -04:00
|
|
|
NxsGrpPendValidVect mReceivedGrps;
|
2012-07-05 17:26:14 -04:00
|
|
|
|
2013-03-11 12:04:25 -04:00
|
|
|
std::vector<GxsGrpPendingSign> mGrpsToPublish;
|
|
|
|
typedef std::vector<GxsGrpPendingSign> NxsGrpSignPendVect;
|
|
|
|
|
2012-08-18 06:01:35 -04:00
|
|
|
std::map<uint32_t, RsGxsMsgItem*> mMsgsToPublish;
|
|
|
|
|
2012-08-21 17:32:07 -04:00
|
|
|
std::map<uint32_t, RsGxsGrpMsgIdPair > mMsgNotify;
|
|
|
|
std::map<uint32_t, RsGxsGroupId> mGrpNotify;
|
|
|
|
|
|
|
|
// for loc meta changes
|
|
|
|
std::map<uint32_t, GrpLocMetaData > mGrpLocMetaMap;
|
|
|
|
std::map<uint32_t, MsgLocMetaData> mMsgLocMetaMap;
|
2012-07-26 17:48:54 -04:00
|
|
|
|
|
|
|
std::vector<RsGxsNotify*> mNotifications;
|
|
|
|
|
2013-03-08 14:55:59 -05:00
|
|
|
|
2012-07-26 17:48:54 -04:00
|
|
|
|
2012-11-10 18:42:38 -05:00
|
|
|
/// authentication policy
|
|
|
|
uint32_t mAuthenPolicy;
|
|
|
|
|
2013-03-11 12:04:25 -04:00
|
|
|
std::map<uint32_t, GxsPendingItem<RsGxsMsgItem*, uint32_t> >
|
2013-03-06 18:33:23 -05:00
|
|
|
mMsgPendingSign;
|
|
|
|
|
2013-03-11 12:04:25 -04:00
|
|
|
std::vector<GxsPendingItem<RsNxsMsg*, RsGxsGrpMsgIdPair> > mMsgPendingValidate;
|
|
|
|
typedef std::vector<GxsPendingItem<RsNxsMsg*, RsGxsGrpMsgIdPair> > NxsMsgPendingVect;
|
|
|
|
|
2013-03-06 18:33:23 -05:00
|
|
|
|
2013-03-20 18:26:24 -04:00
|
|
|
const uint32_t MESSAGE_STORE_PERIOD;
|
2012-07-05 17:26:14 -04:00
|
|
|
|
2013-03-21 19:17:24 -04:00
|
|
|
bool mCleaning;
|
|
|
|
time_t mLastClean;
|
|
|
|
RsGxsMessageCleanUp* mMsgCleanUp;
|
|
|
|
|
2013-06-04 17:00:43 -04:00
|
|
|
|
|
|
|
bool mChecking, mCheckStarted;
|
|
|
|
time_t mLastCheck;
|
|
|
|
RsGxsIntegrityCheck* mIntegrityCheck;
|
|
|
|
|
2012-07-05 17:26:14 -04:00
|
|
|
private:
|
2012-05-21 18:07:43 -04:00
|
|
|
|
2012-07-28 16:01:30 -04:00
|
|
|
std::vector<RsGxsNotify*> mChanges;
|
2013-02-28 16:58:38 -05:00
|
|
|
std::vector<RsGxsGroupChange*> mGroupChange;
|
|
|
|
std::vector<RsGxsMsgChange*> mMsgChange;
|
2013-03-06 18:33:23 -05:00
|
|
|
|
|
|
|
const uint8_t CREATE_FAIL, CREATE_SUCCESS, CREATE_FAIL_TRY_LATER, SIGN_MAX_ATTEMPTS;
|
|
|
|
const uint8_t SIGN_FAIL, SIGN_SUCCESS, SIGN_FAIL_TRY_LATER;
|
|
|
|
const uint8_t VALIDATE_FAIL, VALIDATE_SUCCESS, VALIDATE_FAIL_TRY_LATER, VALIDATE_MAX_ATTEMPTS;
|
2013-09-11 16:42:56 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2013-09-15 17:18:20 -04:00
|
|
|
std::vector<GroupUpdate> mGroupUpdates, mPeersGroupUpdate;
|
|
|
|
|
|
|
|
std::vector<GroupUpdatePublish> mGroupUpdatePublish;
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // RSGENEXCHANGE_H
|