2012-02-13 13:22:35 -05:00
|
|
|
/*
|
|
|
|
* libretroshare/src/services: p3idservice.h
|
|
|
|
*
|
|
|
|
* Identity interface for RetroShare.
|
|
|
|
*
|
|
|
|
* Copyright 2012-2012 by 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".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef P3_IDENTITY_SERVICE_HEADER
|
|
|
|
#define P3_IDENTITY_SERVICE_HEADER
|
|
|
|
|
|
|
|
#include "services/p3service.h"
|
2012-06-07 13:10:47 -04:00
|
|
|
#include "services/p3gxsservice.h"
|
2012-02-13 13:22:35 -05:00
|
|
|
|
|
|
|
#include "retroshare/rsidentity.h"
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
/*
|
2012-06-07 13:10:47 -04:00
|
|
|
* Identity Service
|
2012-02-13 13:22:35 -05:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
class IdDataProxy: public GxsDataProxy
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
bool getGroup(const std::string &id, RsIdGroup &group);
|
|
|
|
bool getMsg(const std::string &id, RsIdMsg &msg);
|
|
|
|
|
|
|
|
bool addGroup(const RsIdGroup &group);
|
|
|
|
bool addMsg(const RsIdMsg &msg);
|
|
|
|
|
|
|
|
/* These Functions must be overloaded to complete the service */
|
|
|
|
virtual bool convertGroupToMetaData(void *groupData, RsGroupMetaData &meta);
|
|
|
|
virtual bool convertMsgToMetaData(void *msgData, RsMsgMetaData &meta);
|
|
|
|
};
|
2012-06-07 13:10:47 -04:00
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
|
|
|
|
class p3IdService: public p3GxsDataService, public RsIdentity
|
2012-02-13 13:22:35 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
p3IdService(uint16_t type);
|
|
|
|
|
|
|
|
virtual int tick();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2012-06-07 13:10:47 -04:00
|
|
|
|
|
|
|
/* changed? */
|
|
|
|
virtual bool updated();
|
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
/* From RsTokenService */
|
|
|
|
/* Data Requests */
|
|
|
|
virtual bool requestGroupInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds);
|
|
|
|
virtual bool requestMsgInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds);
|
|
|
|
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &msgIds);
|
|
|
|
|
|
|
|
/* Generic Lists */
|
|
|
|
virtual bool getGroupList( const uint32_t &token, std::list<std::string> &groupIds);
|
|
|
|
virtual bool getMsgList( const uint32_t &token, std::list<std::string> &msgIds);
|
|
|
|
|
|
|
|
/* Generic Summary */
|
|
|
|
virtual bool getGroupSummary( const uint32_t &token, std::list<RsGroupMetaData> &groupInfo);
|
|
|
|
virtual bool getMsgSummary( const uint32_t &token, std::list<RsMsgMetaData> &msgInfo);
|
|
|
|
|
|
|
|
/* Actual Data -> specific to Interface */
|
2012-07-06 19:14:18 -04:00
|
|
|
virtual bool getGroupData(const uint32_t &token, RsIdGroup &group);
|
|
|
|
virtual bool getMsgData(const uint32_t &token, RsIdMsg &msg);
|
2012-06-13 20:27:28 -04:00
|
|
|
|
|
|
|
/* Poll */
|
|
|
|
virtual uint32_t requestStatus(const uint32_t token);
|
|
|
|
|
|
|
|
/* Cancel Request */
|
|
|
|
virtual bool cancelRequest(const uint32_t &token);
|
|
|
|
|
2012-07-06 19:14:18 -04:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2012-06-13 20:27:28 -04:00
|
|
|
virtual bool setMessageStatus(const std::string &msgId, const uint32_t status, const uint32_t statusMask);
|
2012-07-06 19:14:18 -04:00
|
|
|
virtual bool setGroupStatus(const std::string &groupId, const uint32_t status, const uint32_t statusMask);
|
|
|
|
virtual bool setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask);
|
|
|
|
virtual bool setMessageServiceString(const std::string &msgId, const std::string &str);
|
|
|
|
virtual bool setGroupServiceString(const std::string &grpId, const std::string &str);
|
2012-06-13 20:27:28 -04:00
|
|
|
|
|
|
|
virtual bool groupRestoreKeys(const std::string &groupId);
|
|
|
|
virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>& peers);
|
|
|
|
|
2012-07-06 19:14:18 -04:00
|
|
|
virtual bool createGroup(uint32_t &token, RsIdGroup &group, bool isNew);
|
|
|
|
virtual bool createMsg(uint32_t &token, RsIdMsg &msg, bool isNew);
|
2012-06-13 20:27:28 -04:00
|
|
|
|
|
|
|
|
2012-07-06 19:14:18 -04:00
|
|
|
private:
|
2012-06-07 13:10:47 -04:00
|
|
|
|
2012-02-13 13:22:35 -05:00
|
|
|
virtual void generateDummyData();
|
|
|
|
|
|
|
|
std::string genRandomId();
|
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
IdDataProxy *mIdProxy;
|
|
|
|
|
2012-02-13 13:22:35 -05:00
|
|
|
RsMutex mIdMtx;
|
|
|
|
|
|
|
|
/***** below here is locked *****/
|
|
|
|
|
|
|
|
bool mUpdated;
|
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
#if 0
|
2012-02-13 13:22:35 -05:00
|
|
|
std::map<std::string, RsIdData> mIds;
|
|
|
|
std::map<std::string, std::map<std::string, RsIdOpinion> > mOpinions;
|
|
|
|
|
|
|
|
std::map<std::string, RsIdReputation> mReputations; // this is created locally.
|
2012-06-13 20:27:28 -04:00
|
|
|
#endif
|
2012-02-13 13:22:35 -05:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|