2012-01-11 23:01:29 +00:00
|
|
|
#ifndef RSGDP_H
|
|
|
|
#define RSGDP_H
|
|
|
|
|
2012-01-15 13:07:31 +00: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 23:20:53 +00:00
|
|
|
#include <set>
|
|
|
|
#include <map>
|
2012-01-11 23:01:29 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "inttypes.h"
|
2012-01-19 23:32:27 +00:00
|
|
|
#include "rsgnp.h"
|
2012-01-11 23:01:29 +00:00
|
|
|
|
2012-04-01 21:10:55 +00:00
|
|
|
#include "gxs/rsgxs.h"
|
2012-01-15 13:07:31 +00:00
|
|
|
|
|
|
|
|
2012-04-01 21:10:55 +00:00
|
|
|
class RsGxsSignedMsg {
|
|
|
|
|
|
|
|
|
|
|
|
RsGxsMsgId mMsgId;
|
|
|
|
RsTlvBinaryData mMsgData;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Might be better off simply sending request codes
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class RsGxsSearch {
|
|
|
|
|
|
|
|
/*!
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
virtual int code() = 0;
|
|
|
|
};
|
|
|
|
|
2012-01-15 13:07:31 +00:00
|
|
|
/*!
|
2012-02-12 15:29:49 +00:00
|
|
|
* The main role of GDS is the preparation and handing out of messages requested from
|
2012-01-19 23:32:27 +00:00
|
|
|
* RsGeneralExchangeService and RsGeneralExchangeService
|
2012-02-12 15:18:05 +00: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 23:20:53 +00:00
|
|
|
*
|
2012-01-19 23:32:27 +00:00
|
|
|
* It also acts as a layer between RsGeneralStorageService and its parent RsGeneralExchangeService
|
2012-01-18 23:20:53 +00:00
|
|
|
* thus allowing for non-blocking requests, etc.
|
|
|
|
* It also provides caching ability
|
2012-01-19 23:32:27 +00: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 15:18:05 +00: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 21:10:55 +00:00
|
|
|
* Please note all function are blocking.
|
2012-01-11 23:01:29 +00:00
|
|
|
*/
|
2012-01-18 23:20:53 +00:00
|
|
|
class RsGeneralDataService
|
2012-01-11 23:01:29 +00:00
|
|
|
{
|
2012-04-01 21:10:55 +00:00
|
|
|
|
2012-01-11 23:01:29 +00:00
|
|
|
public:
|
2012-01-18 23:20:53 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Retrieves signed message
|
|
|
|
* @param msgGrp this contains grp and the message to retrieve
|
2012-04-01 21:10:55 +00:00
|
|
|
* @return error code
|
2012-01-18 23:20:53 +00:00
|
|
|
*/
|
2012-04-01 21:10:55 +00:00
|
|
|
virtual int retrieveMsgs(const std::list<RsGxsMsgId>& msgId, std::set<RsGxsMsg*> msg, bool cache) = 0;
|
2012-02-24 21:15:08 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Retrieves a group item by grpId
|
|
|
|
* @param grpId the ID of the group to retrieve
|
2012-04-01 21:10:55 +00:00
|
|
|
* @return error code
|
2012-02-24 21:15:08 +00:00
|
|
|
*/
|
2012-04-01 21:10:55 +00:00
|
|
|
virtual int retrieveGrps(const std::list<RsGxsGrpId>& grpId, std::set<RsGxsGroup*> grp, bool cache) = 0;
|
2012-01-18 23:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* allows for more complex queries specific to the service
|
2012-04-01 21:10:55 +00:00
|
|
|
* BLOBs type columns will not be searched
|
|
|
|
* @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 23:20:53 +00:00
|
|
|
*/
|
2012-04-01 21:10:55 +00:00
|
|
|
virtual int searchMsgs(RsGxsSearch* search, std::list<RsMsgId>& msgId) = 0;
|
2012-01-18 23:20:53 +00:00
|
|
|
|
|
|
|
/*!
|
2012-04-01 21:10:55 +00:00
|
|
|
* allows for more complex queries specific to the associated service
|
|
|
|
* BLOBs type columns will not be searched
|
|
|
|
* @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 23:20:53 +00:00
|
|
|
*/
|
2012-04-01 21:10:55 +00:00
|
|
|
virtual int searchGrps(RsGxsSearch* search, std::list<RsGroupId>& grpId) = 0;
|
2012-01-18 23:20:53 +00:00
|
|
|
|
|
|
|
/*!
|
2012-04-01 21:10:55 +00:00
|
|
|
* @return the cache size set for this RsGeneralDataService
|
2012-01-18 23:20:53 +00:00
|
|
|
*/
|
2012-04-01 21:10:55 +00:00
|
|
|
virtual uint32_t cacheSize() const;
|
2012-01-18 23:20:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2012-04-01 21:10:55 +00:00
|
|
|
* Stores a list signed messages into data store
|
|
|
|
* @param msg list of signed messages to store
|
|
|
|
* @return error code
|
2012-01-18 23:20:53 +00:00
|
|
|
*/
|
2012-04-01 21:10:55 +00:00
|
|
|
virtual int storeMessage(std::set<RsGxsSignedMsg*> msg) = 0;
|
2012-01-18 23:20:53 +00:00
|
|
|
|
|
|
|
/*!
|
2012-04-01 21:10:55 +00:00
|
|
|
* Stores a list of groups in data store
|
|
|
|
* @param msg list of messages
|
|
|
|
* @return error code
|
2012-01-18 23:20:53 +00:00
|
|
|
*/
|
2012-04-01 21:10:55 +00:00
|
|
|
virtual int storeGroup(std::set<RsGxsGroup*> grp) = 0;
|
2012-01-18 23:20:53 +00:00
|
|
|
|
|
|
|
/*!
|
2012-04-01 21:10:55 +00:00
|
|
|
* Retrieves group ids
|
|
|
|
* @param grpIds
|
2012-01-18 23:20:53 +00:00
|
|
|
*/
|
2012-04-01 21:10:55 +00:00
|
|
|
virtual void retrieveGrpIds(std::list<std::string>& grpIds) = 0;
|
2012-01-11 23:01:29 +00:00
|
|
|
|
2012-01-18 23:20:53 +00:00
|
|
|
|
|
|
|
/*!
|
2012-04-01 21:10:55 +00:00
|
|
|
* Retrieves msg ids
|
2012-01-18 23:20:53 +00:00
|
|
|
*/
|
2012-04-01 21:10:55 +00:00
|
|
|
virtual void retrieveMsgIds(std::list<std::string>& msgIds) = 0;
|
2012-01-11 23:01:29 +00:00
|
|
|
|
|
|
|
|
2012-04-01 21:10:55 +00:00
|
|
|
protected:
|
2012-01-18 23:20:53 +00:00
|
|
|
|
2012-01-11 23:01:29 +00:00
|
|
|
|
|
|
|
/*!
|
2012-04-01 21:10:55 +00:00
|
|
|
* Retrieves signed message
|
2012-01-18 23:20:53 +00:00
|
|
|
* @param msgGrp this contains grp and the message to retrieve
|
2012-04-01 21:10:55 +00:00
|
|
|
* @return request code to be redeemed later
|
2012-01-18 23:20:53 +00:00
|
|
|
*/
|
2012-04-01 21:10:55 +00:00
|
|
|
virtual int retrieveMsgs(const std::list<RsGxsMsgId>& msgId, std::set<RsGxsMsg*> msg) = 0;
|
2012-01-18 23:20:53 +00:00
|
|
|
|
|
|
|
/*!
|
2012-04-01 21:10:55 +00:00
|
|
|
* Retrieves a group item by grpId
|
|
|
|
* @param grpId the ID of the group to retrieve
|
|
|
|
* @return request code to be redeemed later
|
2012-01-18 23:20:53 +00:00
|
|
|
*/
|
2012-04-01 21:10:55 +00:00
|
|
|
virtual int retrieveGrps(const std::list<RsGxsGrpId>& grpId, std::set<RsGxsGroup*> grp) = 0;
|
2012-01-18 23:20:53 +00:00
|
|
|
|
2012-01-11 23:01:29 +00:00
|
|
|
|
2012-04-01 21:10:55 +00:00
|
|
|
};
|
2012-01-11 23:01:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // RSGDP_H
|