2012-05-17 18:45:48 -04:00
|
|
|
#ifndef RSGDS_H
|
|
|
|
#define RSGDS_H
|
2012-01-11 18:01:29 -05:00
|
|
|
|
2012-01-15 08:07:31 -05:00
|
|
|
/*
|
|
|
|
* libretroshare/src/gxp: gxp.h
|
|
|
|
*
|
|
|
|
* General Data service, interface for RetroShare.
|
|
|
|
*
|
|
|
|
* Copyright 2011-2011 by Robert Fernie, Evi-Parker Christopher
|
|
|
|
*
|
|
|
|
* 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-01-18 18:20:53 -05:00
|
|
|
#include <set>
|
|
|
|
#include <map>
|
2012-01-11 18:01:29 -05:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "inttypes.h"
|
|
|
|
|
2012-05-17 18:45:48 -04:00
|
|
|
#include "serialiser/rsgxsitems.h"
|
|
|
|
#include "serialiser/rsnxsitems.h"
|
2012-01-15 08:07:31 -05:00
|
|
|
|
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
class RsGxsSearchModule {
|
2012-04-01 17:10:55 -04:00
|
|
|
|
2012-06-11 17:56:23 -04:00
|
|
|
public:
|
|
|
|
|
|
|
|
virtual ~RsGxsSearchModule();
|
|
|
|
|
|
|
|
virtual bool searchMsg(const RsGxsSearch&, RsGxsMsg* msg) = 0;
|
|
|
|
virtual bool searchGroup(const RsGxsSearch&, RsGxsGroup* grp) = 0;
|
|
|
|
|
|
|
|
};
|
2012-04-01 17:10:55 -04:00
|
|
|
|
|
|
|
|
2012-01-15 08:07:31 -05:00
|
|
|
/*!
|
2012-02-12 10:29:49 -05:00
|
|
|
* The main role of GDS is the preparation and handing out of messages requested from
|
2012-01-19 18:32:27 -05:00
|
|
|
* RsGeneralExchangeService and RsGeneralExchangeService
|
2012-02-12 10:18:05 -05:00
|
|
|
* It is important to note that no actual messages are passed by this interface as its is expected
|
|
|
|
* architecturally to pass messages to the service via a call back
|
2012-01-18 18:20:53 -05:00
|
|
|
*
|
2012-01-19 18:32:27 -05:00
|
|
|
* It also acts as a layer between RsGeneralStorageService and its parent RsGeneralExchangeService
|
2012-01-18 18:20:53 -05:00
|
|
|
* thus allowing for non-blocking requests, etc.
|
|
|
|
* It also provides caching ability
|
2012-01-19 18:32:27 -05:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Caching feature:
|
|
|
|
* - A cache index should be maintained which is faster than normal message request
|
|
|
|
* - This should allow fast retrieval of message based on grp id or msg id
|
2012-02-12 10:18:05 -05:00
|
|
|
*
|
|
|
|
* Identity Exchange Service:
|
|
|
|
* - As this is the point where data is accessed by both the GNP and GXS the identities
|
|
|
|
* used to decrypt, encrypt and verify is handle here.
|
|
|
|
*
|
2012-04-01 17:10:55 -04:00
|
|
|
* Please note all function are blocking.
|
2012-01-11 18:01:29 -05:00
|
|
|
*/
|
2012-01-18 18:20:53 -05:00
|
|
|
class RsGeneralDataService
|
2012-01-11 18:01:29 -05:00
|
|
|
{
|
2012-04-01 17:10:55 -04:00
|
|
|
|
2012-01-11 18:01:29 -05:00
|
|
|
public:
|
2012-01-18 18:20:53 -05:00
|
|
|
|
2012-06-05 10:46:18 -04:00
|
|
|
virtual ~RsGeneralDataService(){return;};
|
2012-01-18 18:20:53 -05:00
|
|
|
/*!
|
|
|
|
* Retrieves signed message
|
2012-05-21 18:07:43 -04:00
|
|
|
* @param grpId
|
2012-05-17 18:45:48 -04:00
|
|
|
* @param msg result of msg retrieval
|
|
|
|
* @param cache whether to store retrieval in memory for faster later retrieval
|
2012-04-01 17:10:55 -04:00
|
|
|
* @return error code
|
2012-01-18 18:20:53 -05:00
|
|
|
*/
|
2012-06-03 14:09:38 -04:00
|
|
|
virtual int retrieveMsgs(const std::string& grpId, std::map<std::string, RsNxsMsg*>& msg, bool cache) = 0;
|
2012-02-24 16:15:08 -05:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Retrieves a group item by grpId
|
2012-05-17 18:45:48 -04:00
|
|
|
* @param grpId the Id of the groups to retrieve
|
|
|
|
* @param grp results of retrieval
|
|
|
|
* @param cache whether to store retrieval in mem for faster later retrieval
|
2012-04-01 17:10:55 -04:00
|
|
|
* @return error code
|
2012-02-24 16:15:08 -05:00
|
|
|
*/
|
2012-05-24 18:38:59 -04:00
|
|
|
virtual int retrieveGrps(std::map<std::string, RsNxsGrp*>& grp, bool cache) = 0;
|
2012-05-17 18:45:48 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @param grpId the id of the group to get versions for
|
|
|
|
* @param cache whether to store the result in memory
|
|
|
|
* @param errCode
|
|
|
|
*/
|
2012-05-24 18:38:59 -04:00
|
|
|
virtual int retrieveGrpVersions(const std::string& grpId, std::set<RsNxsGrp*>& grp, bool cache) = 0;
|
2012-05-17 18:45:48 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
/*!
|
|
|
|
* @param grpId the id of the group to retrieve
|
|
|
|
* @return NULL if group does not exist or pointer to grp if found
|
|
|
|
*/
|
|
|
|
virtual RsNxsGrp* retrieveGrpVersion(const RsGxsGrpId& grpId) = 0;
|
2012-01-18 18:20:53 -05:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* allows for more complex queries specific to the service
|
2012-04-01 17:10:55 -04:00
|
|
|
* @param search generally stores parameters needed for query
|
|
|
|
* @param msgId is set with msg ids which satisfy the gxs search
|
|
|
|
* @return error code
|
2012-01-18 18:20:53 -05:00
|
|
|
*/
|
2012-05-17 18:45:48 -04:00
|
|
|
virtual int searchMsgs(RsGxsSearch* search, std::list<RsGxsSrchResMsgCtx*>& result) = 0;
|
2012-01-18 18:20:53 -05:00
|
|
|
|
|
|
|
/*!
|
2012-04-01 17:10:55 -04:00
|
|
|
* allows for more complex queries specific to the associated service
|
|
|
|
* @param search generally stores parameters needed for query
|
|
|
|
* @param msgId is set with msg ids which satisfy the gxs search
|
|
|
|
* @return error code
|
2012-01-18 18:20:53 -05:00
|
|
|
*/
|
2012-05-17 18:45:48 -04:00
|
|
|
virtual int searchGrps(RsGxsSearch* search, std::list<RsGxsSrchResGrpCtx*>& result) = 0;
|
2012-01-18 18:20:53 -05:00
|
|
|
|
2012-06-03 14:09:38 -04:00
|
|
|
/*!
|
|
|
|
* remove msgs in data store listed in msgIds param
|
|
|
|
* @param msgIds ids of messages to be removed
|
|
|
|
* @return error code
|
|
|
|
*/
|
|
|
|
virtual int removeMsgs(const std::list<RsGxsMsgId>& msgIds) = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* remove groups in data store listed in grpIds param
|
|
|
|
* @param grpIds ids of groups to be removed
|
|
|
|
* @return error code
|
|
|
|
*/
|
|
|
|
virtual int removeGroups(const std::list<RsGxsGrpId>& grpIds) = 0;
|
|
|
|
|
2012-01-18 18:20:53 -05:00
|
|
|
/*!
|
2012-05-21 18:07:43 -04:00
|
|
|
* @return the cache size set for this RsGeneralDataService in bytes
|
2012-01-18 18:20:53 -05:00
|
|
|
*/
|
2012-05-21 18:07:43 -04:00
|
|
|
virtual uint32_t cacheSize() const = 0;
|
2012-01-18 18:20:53 -05:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
/*!
|
|
|
|
* @param size size of cache to set in bytes
|
|
|
|
*/
|
|
|
|
virtual int setCacheSize(uint32_t size) = 0;
|
2012-01-18 18:20:53 -05:00
|
|
|
|
|
|
|
/*!
|
2012-04-01 17:10:55 -04:00
|
|
|
* Stores a list signed messages into data store
|
|
|
|
* @param msg list of signed messages to store
|
|
|
|
* @return error code
|
2012-01-18 18:20:53 -05:00
|
|
|
*/
|
2012-05-17 18:45:48 -04:00
|
|
|
virtual int storeMessage(std::set<RsNxsMsg*>& msg) = 0;
|
2012-01-18 18:20:53 -05:00
|
|
|
|
|
|
|
/*!
|
2012-04-01 17:10:55 -04:00
|
|
|
* Stores a list of groups in data store
|
|
|
|
* @param msg list of messages
|
|
|
|
* @return error code
|
2012-01-18 18:20:53 -05:00
|
|
|
*/
|
2012-05-17 18:45:48 -04:00
|
|
|
virtual int storeGroup(std::set<RsNxsGrp*>& grp) = 0;
|
2012-01-18 18:20:53 -05:00
|
|
|
|
2012-06-03 14:09:38 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Completely clear out data stored in
|
|
|
|
* and returns this to a state
|
|
|
|
* as it was when first constructed
|
|
|
|
*/
|
|
|
|
virtual int resetDataStore() = 0;
|
|
|
|
|
2012-04-01 17:10:55 -04:00
|
|
|
};
|
2012-01-11 18:01:29 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-17 18:45:48 -04:00
|
|
|
#endif // RSGDS_H
|