Removed references to postedVEG from GxsGroupDialog and associated classes and PostedDialog (GUI does not work now but does not crash)

Removed V2 references: TokenQueueV2 and RsTokReqOptionsV2 are now TokenQueue and RsTokReqOptions and renamed file
Added initialisation of Posted back end service successfully
Added new msg status flags  GXS_SERV::MSG_STATUS_UNPROCESSED and ::MSG_STATUS_UNREAD



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5707 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2012-10-21 19:45:35 +00:00
parent dcb64f6631
commit c518bd2f19
44 changed files with 2379 additions and 3761 deletions

View file

@ -36,7 +36,7 @@
#include "serialiser/rsnxsitems.h"
#include "gxs/rsgxsdata.h"
#include "rsgxs.h"
#include "util/retrodb.h"
#include "util/contentvalue.h"
class RsGxsSearchModule {

View file

@ -109,6 +109,7 @@ public:
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
// normally READ / UNREAD flags. LOCAL Data.
uint32_t mMsgStatus;
time_t mChildTs;

File diff suppressed because it is too large Load diff

View file

@ -1,367 +1,367 @@
#ifndef RSGXSDATAACCESS_H
#define RSGXSDATAACCESS_H
/*
* libretroshare/src/retroshare: rsgxsdataaccess.cc
*
* RetroShare C++ Interface.
*
* Copyright 2012-2012 by Robert Fernie, Christopher Evi-Parker
*
* 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".
*
*/
#include "rstokenservice.h"
#include "rsgxsrequesttypes.h"
#include "rsgds.h"
typedef std::map< RsGxsGroupId, std::map<RsGxsMessageId, RsGxsMsgMetaData*> > MsgMetaFilter;
class RsGxsDataAccess : public RsTokenService
{
public:
RsGxsDataAccess(RsGeneralDataService* ds);
virtual ~RsGxsDataAccess() { return ;}
public:
/** S: RsTokenService **/
/*!
* Use this to request group related information
* @param token The token returned for the request, store this value to pool for request completion
* @param ansType The type of result (e.g. group data, meta, ids)
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
* @param groupIds group id to request info for
* @return
*/
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const std::list<RsGxsGroupId> &groupIds);
/*!
* Use this to request all group related info
* @param token The token returned for the request, store this value to pool for request completion
* @param ansType The type of result (e.g. group data, meta, ids)
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
* @return
*/
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts);
/*!
* Use this to get msg related information, store this value to pole for request completion
* @param token The token returned for the request
* @param ansType The type of result wanted
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
* @return true if request successful false otherwise
*/
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const GxsMsgReq& msgIds);
/*!
* Use this to get msg related information, store this value to pole for request completion
* @param token The token returned for the request
* @param ansType The type of result wanted
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
* @param groupIds The ids of the groups to get, this retrieve all the msgs info for each grpId in list
* @return true if request successful false otherwise
*/
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const std::list<RsGxsGroupId>& grpIds);
/*!
* For requesting msgs related to a given msg id within a group
* @param token The token returned for the request
* @param ansType The type of result wanted
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
* @return true if request successful false otherwise
*/
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const RsGxsGrpMsgIdPair &msgIds);
/* Poll */
uint32_t requestStatus(const uint32_t token);
/* Cancel Request */
bool cancelRequest(const uint32_t &token);
/** E: RsTokenService **/
public:
/*!
* This adds a groups to the gxs data base, this is a blocking call
* Responsibility for grp still lies with callee \n
* If function returns successfully DataAccess can be queried for grp
* @param grp the group to add, responsibility grp passed lies with callee
* @return false if group cound not be added
*/
bool addGroupData(RsNxsGrp* grp);
/*!
* This adds a group to the gxs data base, this is a blocking call \n
* Responsibility for msg still lies with callee \n
* If function returns successfully DataAccess can be queried for msg
* @param msg the msg to add
* @return false if msg could not be added, true otherwise
*/
bool addMsgData(RsNxsMsg* msg);
public:
/*!
* This must be called periodically to progress requests
*/
void processRequests();
/*!
* Retrieve group list for a given token
* @param token request token to be redeemed
* @param groupIds
* @param msgIds
* @return false if token cannot be redeemed, if false you may have tried to redeem when not ready
*/
bool getGroupList(const uint32_t &token, std::list<std::string> &groupIds);
/*!
*
* @param token request token to be redeemed
* @param msgIds
*/
bool getMsgList(const uint32_t &token, GxsMsgIdResult &msgIds);
/*!
* @param token request token to be redeemed
* @param groupInfo
*/
bool getGroupSummary(const uint32_t &token, std::list<RsGxsGrpMetaData*> &groupInfo);
/*!
*
* @param token request token to be redeemed
* @param msgInfo
*/
bool getMsgSummary(const uint32_t &token, GxsMsgMetaResult &msgInfo);
/*!
*
* @param token request token to be redeemed
* @param grpData
*/
bool getGroupData(const uint32_t &token, std::list<RsNxsGrp*>& grpData);
/*!
*
* @param token request token to be redeemed
* @param msgData
* @return false if data cannot be found for token
*/
bool getMsgData(const uint32_t &token, NxsMsgDataResult& msgData);
private:
/** helper functions to implement token service **/
/*!
* Assigns a token value to passed integer
* @param token is assigned a unique token value
*/
void generateToken(uint32_t &token);
/*!
*
* @param token the value of the token for the request object handle wanted
* @return the request associated to this token
*/
GxsRequest* locked_retrieveRequest(const uint32_t& token);
/*!
* Add a gxs request to queue
* @param req gxs request to add
*/
void storeRequest(GxsRequest* req);
/*!
* convenience function to setting members of request
* @param req
* @param token
* @param ansType
* @param opts
*/
void setReq(GxsRequest* req,const uint32_t &token, const uint32_t& ansType, const RsTokReqOptionsV2 &opts) const;
/*!
* Remove request for request queue
* Request is deleted
* @param token the token associated to the request
* @return true if token successfully cleared, false if token does not exist
*/
bool clearRequest(const uint32_t &token);
/*!
* Updates the status flag of a request
* @param token the token value of the request to set
* @param status the status to set
* @return
*/
bool locked_updateRequestStatus(const uint32_t &token, const uint32_t &status);
/*!
* Use to query the status and other values of a given token
* @param token the toke of the request to check for
* @param status set to current status of request
* @param reqtype set to request type of request
* @param anstype set to to anstype of request
* @param ts time stamp
* @return false if token does not exist, true otherwise
*/
bool checkRequestStatus(const uint32_t &token, uint32_t &status, uint32_t &reqtype, uint32_t &anstype, time_t &ts);
// special ones for testing (not in final design)
/*!
* Get list of active tokens of this token service
* @param tokens sets to list of token contained in this tokenservice
*/
void tokenList(std::list<uint32_t> &tokens);
/*!
* Convenience function to delete the ids
* @param filter the meta filter to clean
*/
void cleanseMsgMetaMap(GxsMsgMetaResult& result);
public:
/*!
* Assigns a token value to passed integer
* The status of the token can still be queried from request status feature
* @param token is assigned a unique token value
*/
uint32_t generatePublicToken();
/*!
* Updates the status of associate token
* @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 disposed of
*/
bool disposeOfPublicToken(const uint32_t &token);
private:
/* These perform the actual blocking retrieval of data */
/*!
* Attempts to retrieve group id list from data store
* @param req
* @return false if unsuccessful, true otherwise
*/
bool getGroupList(GroupIdReq* req);
/*!
* Attempts to retrieve msg id list from data store
* Computationally/CPU-Bandwidth expensive
* @param req
* @return false if unsuccessful, true otherwise
*/
bool getMsgList(MsgIdReq* req);
/*!
* Attempts to retrieve group meta data from data store
* @param req
* @return false if unsuccessful, true otherwise
*/
bool getGroupSummary(GroupMetaReq* req);
/*!
* Attempts to retrieve msg meta data from data store
* @param req
* @return false if unsuccessful, true otherwise
*/
bool getMsgSummary(MsgMetaReq* req);
/*!
* Attempts to retrieve group data from data store
* @param req The request specifying data to retrieve
* @return false if unsuccessful, true otherwise
*/
bool getGroupData(GroupDataReq* req);
/*!
* Attempts to retrieve message data from data store
* @param req The request specifying data to retrieve
* @return false if unsuccessful, true otherwise
*/
bool getMsgData(MsgDataReq* req);
/*!
* Attempts to retrieve messages related to msgIds of associated equest
* @param token request token to be redeemed
* @param msgIds
* @return false if data cannot be found for token
*/
bool getMsgRelatedInfo(MsgRelatedInfoReq* req);
/*!
* This filter msgs based of options supplied (at the moment just status masks)
* @param msgIds The msgsIds to filter
* @param opts the request options set by user
* @param meta The accompanying meta information for msg, ids
*/
void filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOptionsV2& opts, const MsgMetaFilter& meta) const;
/*!
* This applies the options to the meta to find out if the given message satisfies
* them
* @param opts options containing filters to check
* @param meta meta containing currently defined options for msg
* @return true if msg meta passes all options
*/
bool checkMsgFilter(const RsTokReqOptionsV2& opts, const RsGxsMsgMetaData* meta) const;
/*!
* This is a filter method which applies the request options to the list of ids
* requested
* @param msgIds the msg ids for filter to be applied to
* @param opts the options used to parameterise the id filter
* @param msgIdsOut the left overs ids after filter is applied to msgIds
*/
bool getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptionsV2& opts, GxsMsgReq& msgIdsOut);
private:
RsGeneralDataService* mDataStore;
uint32_t mNextToken;
std::map<uint32_t, uint32_t> mPublicToken;
std::map<uint32_t, GxsRequest*> mRequests;
RsMutex mDataMutex;
};
#endif // RSGXSDATAACCESS_H
#ifndef RSGXSDATAACCESS_H
#define RSGXSDATAACCESS_H
/*
* libretroshare/src/retroshare: rsgxsdataaccess.cc
*
* RetroShare C++ Interface.
*
* Copyright 2012-2012 by Robert Fernie, Christopher Evi-Parker
*
* 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".
*
*/
#include "rstokenservice.h"
#include "rsgxsrequesttypes.h"
#include "rsgds.h"
typedef std::map< RsGxsGroupId, std::map<RsGxsMessageId, RsGxsMsgMetaData*> > MsgMetaFilter;
class RsGxsDataAccess : public RsTokenService
{
public:
RsGxsDataAccess(RsGeneralDataService* ds);
virtual ~RsGxsDataAccess() { return ;}
public:
/** S: RsTokenService **/
/*!
* Use this to request group related information
* @param token The token returned for the request, store this value to pool for request completion
* @param ansType The type of result (e.g. group data, meta, ids)
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
* @param groupIds group id to request info for
* @return
*/
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId> &groupIds);
/*!
* Use this to request all group related info
* @param token The token returned for the request, store this value to pool for request completion
* @param ansType The type of result (e.g. group data, meta, ids)
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
* @return
*/
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts);
/*!
* Use this to get msg related information, store this value to pole for request completion
* @param token The token returned for the request
* @param ansType The type of result wanted
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
* @return true if request successful false otherwise
*/
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const GxsMsgReq& msgIds);
/*!
* Use this to get msg related information, store this value to pole for request completion
* @param token The token returned for the request
* @param ansType The type of result wanted
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
* @param groupIds The ids of the groups to get, this retrieve all the msgs info for each grpId in list
* @return true if request successful false otherwise
*/
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId>& grpIds);
/*!
* For requesting msgs related to a given msg id within a group
* @param token The token returned for the request
* @param ansType The type of result wanted
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
* @return true if request successful false otherwise
*/
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const RsGxsGrpMsgIdPair &msgIds);
/* Poll */
uint32_t requestStatus(const uint32_t token);
/* Cancel Request */
bool cancelRequest(const uint32_t &token);
/** E: RsTokenService **/
public:
/*!
* This adds a groups to the gxs data base, this is a blocking call
* Responsibility for grp still lies with callee \n
* If function returns successfully DataAccess can be queried for grp
* @param grp the group to add, responsibility grp passed lies with callee
* @return false if group cound not be added
*/
bool addGroupData(RsNxsGrp* grp);
/*!
* This adds a group to the gxs data base, this is a blocking call \n
* Responsibility for msg still lies with callee \n
* If function returns successfully DataAccess can be queried for msg
* @param msg the msg to add
* @return false if msg could not be added, true otherwise
*/
bool addMsgData(RsNxsMsg* msg);
public:
/*!
* This must be called periodically to progress requests
*/
void processRequests();
/*!
* Retrieve group list for a given token
* @param token request token to be redeemed
* @param groupIds
* @param msgIds
* @return false if token cannot be redeemed, if false you may have tried to redeem when not ready
*/
bool getGroupList(const uint32_t &token, std::list<std::string> &groupIds);
/*!
*
* @param token request token to be redeemed
* @param msgIds
*/
bool getMsgList(const uint32_t &token, GxsMsgIdResult &msgIds);
/*!
* @param token request token to be redeemed
* @param groupInfo
*/
bool getGroupSummary(const uint32_t &token, std::list<RsGxsGrpMetaData*> &groupInfo);
/*!
*
* @param token request token to be redeemed
* @param msgInfo
*/
bool getMsgSummary(const uint32_t &token, GxsMsgMetaResult &msgInfo);
/*!
*
* @param token request token to be redeemed
* @param grpData
*/
bool getGroupData(const uint32_t &token, std::list<RsNxsGrp*>& grpData);
/*!
*
* @param token request token to be redeemed
* @param msgData
* @return false if data cannot be found for token
*/
bool getMsgData(const uint32_t &token, NxsMsgDataResult& msgData);
private:
/** helper functions to implement token service **/
/*!
* Assigns a token value to passed integer
* @param token is assigned a unique token value
*/
void generateToken(uint32_t &token);
/*!
*
* @param token the value of the token for the request object handle wanted
* @return the request associated to this token
*/
GxsRequest* locked_retrieveRequest(const uint32_t& token);
/*!
* Add a gxs request to queue
* @param req gxs request to add
*/
void storeRequest(GxsRequest* req);
/*!
* convenience function to setting members of request
* @param req
* @param token
* @param ansType
* @param opts
*/
void setReq(GxsRequest* req,const uint32_t &token, const uint32_t& ansType, const RsTokReqOptions &opts) const;
/*!
* Remove request for request queue
* Request is deleted
* @param token the token associated to the request
* @return true if token successfully cleared, false if token does not exist
*/
bool clearRequest(const uint32_t &token);
/*!
* Updates the status flag of a request
* @param token the token value of the request to set
* @param status the status to set
* @return
*/
bool locked_updateRequestStatus(const uint32_t &token, const uint32_t &status);
/*!
* Use to query the status and other values of a given token
* @param token the toke of the request to check for
* @param status set to current status of request
* @param reqtype set to request type of request
* @param anstype set to to anstype of request
* @param ts time stamp
* @return false if token does not exist, true otherwise
*/
bool checkRequestStatus(const uint32_t &token, uint32_t &status, uint32_t &reqtype, uint32_t &anstype, time_t &ts);
// special ones for testing (not in final design)
/*!
* Get list of active tokens of this token service
* @param tokens sets to list of token contained in this tokenservice
*/
void tokenList(std::list<uint32_t> &tokens);
/*!
* Convenience function to delete the ids
* @param filter the meta filter to clean
*/
void cleanseMsgMetaMap(GxsMsgMetaResult& result);
public:
/*!
* Assigns a token value to passed integer
* The status of the token can still be queried from request status feature
* @param token is assigned a unique token value
*/
uint32_t generatePublicToken();
/*!
* Updates the status of associate token
* @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 disposed of
*/
bool disposeOfPublicToken(const uint32_t &token);
private:
/* These perform the actual blocking retrieval of data */
/*!
* Attempts to retrieve group id list from data store
* @param req
* @return false if unsuccessful, true otherwise
*/
bool getGroupList(GroupIdReq* req);
/*!
* Attempts to retrieve msg id list from data store
* Computationally/CPU-Bandwidth expensive
* @param req
* @return false if unsuccessful, true otherwise
*/
bool getMsgList(MsgIdReq* req);
/*!
* Attempts to retrieve group meta data from data store
* @param req
* @return false if unsuccessful, true otherwise
*/
bool getGroupSummary(GroupMetaReq* req);
/*!
* Attempts to retrieve msg meta data from data store
* @param req
* @return false if unsuccessful, true otherwise
*/
bool getMsgSummary(MsgMetaReq* req);
/*!
* Attempts to retrieve group data from data store
* @param req The request specifying data to retrieve
* @return false if unsuccessful, true otherwise
*/
bool getGroupData(GroupDataReq* req);
/*!
* Attempts to retrieve message data from data store
* @param req The request specifying data to retrieve
* @return false if unsuccessful, true otherwise
*/
bool getMsgData(MsgDataReq* req);
/*!
* Attempts to retrieve messages related to msgIds of associated equest
* @param token request token to be redeemed
* @param msgIds
* @return false if data cannot be found for token
*/
bool getMsgRelatedInfo(MsgRelatedInfoReq* req);
/*!
* This filter msgs based of options supplied (at the moment just status masks)
* @param msgIds The msgsIds to filter
* @param opts the request options set by user
* @param meta The accompanying meta information for msg, ids
*/
void filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOptions& opts, const MsgMetaFilter& meta) const;
/*!
* This applies the options to the meta to find out if the given message satisfies
* them
* @param opts options containing filters to check
* @param meta meta containing currently defined options for msg
* @return true if msg meta passes all options
*/
bool checkMsgFilter(const RsTokReqOptions& opts, const RsGxsMsgMetaData* meta) const;
/*!
* This is a filter method which applies the request options to the list of ids
* requested
* @param msgIds the msg ids for filter to be applied to
* @param opts the options used to parameterise the id filter
* @param msgIdsOut the left overs ids after filter is applied to msgIds
*/
bool getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions& opts, GxsMsgReq& msgIdsOut);
private:
RsGeneralDataService* mDataStore;
uint32_t mNextToken;
std::map<uint32_t, uint32_t> mPublicToken;
std::map<uint32_t, GxsRequest*> mRequests;
RsMutex mDataMutex;
};
#endif // RSGXSDATAACCESS_H

View file

@ -3,13 +3,22 @@
#include "inttypes.h"
// this serves a single point of call for definining grp and msg modes
// GXS. These modes say
/**
* The GXS_SERV namespace serves a single point of reference for definining grp and msg flags
* Declared and defined here are:
* - privacy flags which define the level of privacy that can be given \n
* to a group
* - authentication types which defined types of authentication needed for a given message to
* confirm its authenticity
* - subscription flags: This used only locally by the peer to subscription status to a \n
* a group
* -
*/
namespace GXS_SERV {
/** privacy **/
/** START privacy **/
static const uint32_t FLAG_PRIVACY_MASK = 0x0000000f;
@ -22,9 +31,9 @@ namespace GXS_SERV {
// anyone can publish, publish key pair not needed
static const uint32_t FLAG_PRIVACY_PUBLIC = 0x00000004;
/** privacy **/
/** END privacy **/
/** authentication **/
/** START authentication **/
static const uint32_t FLAG_AUTHEN_MASK = 0x000000f0;
@ -40,10 +49,10 @@ namespace GXS_SERV {
// pgp sign identity
static const uint32_t FLAG_AUTHEN_PGP_IDENTITY = 0x00000080;
/** authentication **/
/** END authentication **/
// Subscription Flags. (LOCAL)
/** START Subscription Flags. (LOCAL) **/
static const uint32_t GROUP_SUBSCRIBE_ADMIN = 0x00000001;
@ -55,6 +64,16 @@ namespace GXS_SERV {
static const uint32_t GROUP_SUBSCRIBE_MASK = 0x0000000f;
/** END Subscription Flags. (LOCAL) **/
/** START GXS Msg status flags **/
static const uint32_t GXS_MSG_STATUS_UNPROCESSED = 0x000000100;
static const uint32_t GXS_MSG_STATUS_UNREAD = 0x00000200;
/** END GXS Msg status flags **/
}

View file

@ -1267,7 +1267,7 @@ NxsTransaction::~NxsTransaction(){
/* Net Manager */
RsNxsNetMgrImpl::RsNxsNetMgrImpl(p3LinkMgr *lMgr)
: mLinkMgr(lMgr)
: mLinkMgr(lMgr), mNxsNetMgrMtx("RsNxsNetMgrImpl")
{
}
@ -1275,6 +1275,7 @@ RsNxsNetMgrImpl::RsNxsNetMgrImpl(p3LinkMgr *lMgr)
std::string RsNxsNetMgrImpl::getOwnId()
{
RsStackMutex stack(mNxsNetMgrMtx);
return mLinkMgr->getOwnId();
}
@ -1283,7 +1284,10 @@ void RsNxsNetMgrImpl::getOnlineList(std::set<std::string> &ssl_peers)
ssl_peers.clear();
std::list<std::string> pList;
mLinkMgr->getOnlineList(pList);
{
RsStackMutex stack(mNxsNetMgrMtx);
mLinkMgr->getOnlineList(pList);
}
std::list<std::string>::const_iterator lit = pList.begin();

View file

@ -103,6 +103,7 @@ public:
private:
p3LinkMgr* mLinkMgr;
RsMutex mNxsNetMgrMtx;
};

View file

@ -26,6 +26,7 @@
*
*/
#include "gxs/rstokenservice.h"
#include "gxs/rsgds.h"
class GxsRequest
@ -40,7 +41,7 @@ public:
uint32_t ansType;
uint32_t reqType;
RsTokReqOptionsV2 Options;
RsTokReqOptions Options;
uint32_t status;
};

View file

@ -68,10 +68,10 @@
* This class provides useful generic support for GXS style services.
* I expect much of this will be incorporated into the base GXS.
*/
class RsTokReqOptionsV2
class RsTokReqOptions
{
public:
RsTokReqOptionsV2()
RsTokReqOptions()
{
mOptions = 0;
mStatusFilter = 0; mStatusMask = 0; mSubscribeFilter = 0;
@ -86,6 +86,7 @@ uint32_t mOptions;
uint32_t mStatusFilter;
uint32_t mStatusMask;
// use
uint32_t mMsgFlagMask, mMsgFlagFilter;
uint32_t mReqType;
@ -97,6 +98,8 @@ time_t mBefore;
time_t mAfter;
};
std::ostream &operator<<(std::ostream &out, const RsGroupMetaData &meta);
std::ostream &operator<<(std::ostream &out, const RsMsgMetaData &meta);
/*!
* A proxy class for requesting generic service data for GXS
@ -129,7 +132,7 @@ public:
* @param groupIds group id to request info for
* @return
*/
virtual bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const std::list<RsGxsGroupId> &groupIds) = 0;
virtual bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId> &groupIds) = 0;
/*!
* Use this to request all group related info
@ -138,7 +141,7 @@ public:
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
* @return
*/
virtual bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts) = 0;
virtual bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts) = 0;
/*!
* Use this to get msg related information, store this value to pole for request completion
@ -148,7 +151,7 @@ public:
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
* @return true if request successful false otherwise
*/
virtual bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const GxsMsgReq& msgIds) = 0;
virtual bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const GxsMsgReq& msgIds) = 0;
/*!
* Use this to get msg related information, store this value to pole for request completion
@ -158,7 +161,7 @@ public:
* @param groupIds The ids of the groups to get, this retrieve all the msgs info for each grpId in list
* @return true if request successful false otherwise
*/
virtual bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const std::list<RsGxsGroupId>& msgIds) = 0;
virtual bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId>& msgIds) = 0;
/*!
* For requesting msgs related to a given msg id within a group
@ -168,7 +171,7 @@ public:
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
* @return true if request successful false otherwise
*/
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptionsV2 &opts, const RsGxsGrpMsgIdPair& msgIds) = 0;
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const RsGxsGrpMsgIdPair& msgIds) = 0;
/* Poll */

View file

@ -527,6 +527,7 @@ HEADERS += retroshare/rsgame.h \
serialiser/rsbanlistitems.cc \
serialiser/rsbwctrlitems.cc \
serialiser/rstunnelitems.cc
SOURCES += services/p3channels.cc \
services/p3chatservice.cc \
services/p3disc.cc \
@ -580,7 +581,7 @@ HEADERS += retroshare/rsgame.h \
}
# new gxs cache system
newcache {
newcache {
HEADERS += serialiser/rsnxsitems.h \
gxs/rsgds.h \
gxs/rsgxs.h \
@ -603,6 +604,7 @@ HEADERS += retroshare/rsgame.h \
gxs/rsgxsifaceimpl.h \
services/p3posted.h \
retroshare/rsposted.h \
serialiser/rsposteditems.h
SOURCES += serialiser/rsnxsitems.cc \
@ -621,22 +623,23 @@ HEADERS += retroshare/rsgame.h \
gxs/gxssecurity.cc \
gxs/rsgxsifaceimpl.cc \
services/p3posted.cc \
serialiser/rsposteditems.cc
# Identity Service
HEADERS += retroshare/rsidentity.h \
gxs/rsgixs.h \
services/p3idservice.h \
serialiser/rsgxsiditems.h \
serialiser/rsgxsiditems.h
SOURCES += services/p3idservice.cc \
SOURCES += services/p3idservice.cc
# serialiser/rsgxsiditems.cc \
# Wiki Service
HEADERS += retroshare/rswiki.h \
services/p3wiki.h \
serialiser/rswikiitems.h \
serialiser/rswikiitems.h
SOURCES += services/p3wiki.cc \
SOURCES += services/p3wiki.cc
# serialiser/rswikiitems.cc \
}
@ -645,30 +648,20 @@ HEADERS += retroshare/rsgame.h \
HEADERS += services/p3photoserviceV2.h \
retroshare/rsphotoVEG.h \
services/p3gxsserviceVEG.h \
retroshare/rsidentityVEG.h \
services/p3wikiserviceVEG.h \
retroshare/rswikiVEG.h \
retroshare/rswireVEG.h \
services/p3wireVEG.h \
services/p3idserviceVEG.h \
retroshare/rsforumsVEG.h \
services/p3forumsVEG.h \
retroshare/rspostedVEG.h \
services/p3postedVEG.h
services/p3forumsVEG.h
# Do I need this?
#serialiser/rsphotoitemsVEG.h \
SOURCES += services/p3gxsserviceVEG.cc \
services/p3wikiserviceVEG.cc \
services/p3wireVEG.cc \
services/p3idserviceVEG.cc \
services/p3forumsVEG.cc \
services/p3postedVEG.cc
services/p3forumsVEG.cc
# Do I need this?
# serialiser/rsphotoitemsVEG.cc \
}

View file

@ -7,7 +7,7 @@
*
* RetroShare C++ Interface.
*
* Copyright 2008-2012 by Robert Fernie.
* Copyright 2008-2012 by Robert Fernie, Christopher Evi-Parker
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -33,10 +33,10 @@
#include "gxs/rstokenservice.h"
#include "gxs/rsgxsifaceimpl.h"
/* The Main Interface Class - for information about your Peers */
class RsPostedVEG;
extern RsPostedVEG *rsPostedVEG;
class RsPosted;
extern RsPosted *rsPosted;
/* The Main Interface Class - for information about your Peers */
class RsPostedGroup
{
@ -45,19 +45,9 @@ class RsPostedGroup
RsPostedGroup() { return; }
};
class RsPostedMsg
{
public:
RsPostedMsg(uint32_t t)
:postedType(t) { return; }
RsMsgMetaData mMeta;
uint32_t postedType;
};
#define RSPOSTED_MSGTYPE_POST 0x0001
#define RSPOSTED_MSGTYPE_VOTE 0x0002
#define RSPOSTED_MSGTYPE_COMMENT 0x0004
//#define RSPOSTED_MSGTYPE_POST 0x0001
//#define RSPOSTED_MSGTYPE_VOTE 0x0002
//#define RSPOSTED_MSGTYPE_COMMENT 0x0004
#define RSPOSTED_PERIOD_YEAR 1
#define RSPOSTED_PERIOD_MONTH 2
@ -70,44 +60,13 @@ class RsPostedMsg
#define RSPOSTED_VIEWMODE_HOT 3
#define RSPOSTED_VIEWMODE_COMMENTS 4
class RsPostedPost;
class RsPostedComment;
class RsPostedVote;
class RsPostedPost: public RsPostedMsg
{
public:
RsPostedPost(): RsPostedMsg(RSPOSTED_MSGTYPE_POST)
{
mMeta.mMsgFlags = RSPOSTED_MSGTYPE_POST;
return;
}
std::string mLink;
std::string mNotes;
};
class RsPostedVote: public RsPostedMsg
{
public:
RsPostedVote(): RsPostedMsg(RSPOSTED_MSGTYPE_VOTE)
{
mMeta.mMsgFlags = RSPOSTED_MSGTYPE_VOTE;
return;
}
};
class RsPostedComment: public RsPostedMsg
{
public:
RsPostedComment(): RsPostedMsg(RSPOSTED_MSGTYPE_COMMENT)
{
mMeta.mMsgFlags = RSPOSTED_MSGTYPE_COMMENT;
return;
}
std::string mComment;
};
typedef std::map<RsGxsGroupId, std::vector<RsPostedPost> > PostedPostResult;
typedef std::map<RsGxsGroupId, std::vector<RsPostedComment> > PostedCommentResult;
typedef std::map<RsGxsGroupId, std::vector<RsPostedVote> > PostedVoteResult;
std::ostream &operator<<(std::ostream &out, const RsPostedGroup &group);
std::ostream &operator<<(std::ostream &out, const RsPostedPost &post);
@ -119,15 +78,19 @@ class RsPosted : public RsGxsIfaceImpl
{
public:
static const uint32_t FLAG_MSGTYPE_POST;
static const uint32_t FLAG_MSGTYPE_VOTE;
static const uint32_t FLAG_MSGTYPE_COMMENT;
RsPosted(RsGenExchange* gxs) : RsGxsIfaceImpl(gxs) { return; }
virtual ~RsPosted() { return; }
/* Specific Service Data */
virtual RsTokenService* getToken() = 0;
virtual bool getGroup(const uint32_t &token, RsPostedGroup &group) = 0;
virtual bool getPost(const uint32_t &token, RsPostedPost &post) = 0;
virtual bool getComment(const uint32_t &token, RsPostedComment &comment) = 0;
virtual bool getGroup(const uint32_t &token, std::vector<RsPostedGroup> &group) = 0;
virtual bool getPost(const uint32_t &token, PostedPostResult &post) = 0;
virtual bool getComment(const uint32_t &token, PostedCommentResult &comment) = 0;
virtual bool submitGroup(uint32_t &token, RsPostedGroup &group) = 0;
virtual bool submitPost(uint32_t &token, RsPostedPost &post) = 0;
@ -136,20 +99,48 @@ virtual bool submitComment(uint32_t &token, RsPostedComment &comment) = 0;
// Special Ranking Request.
virtual bool requestRanking(uint32_t &token, RsGxsGroupId groupId) = 0;
virtual bool getRankedPost(const uint32_t &token, RsPostedPost &post) = 0;
virtual bool extractPostedCache() = 0;
// Control Ranking Calculations.
virtual bool setViewMode(uint32_t mode) = 0;
virtual bool setViewPeriod(uint32_t period) = 0;
virtual bool setViewRange(uint32_t first, uint32_t count) = 0;
// exposed for testing...
virtual float calcPostScore(uint32_t& token, const RsGxsMessageId) = 0;
};
class RsPostedPost
{
public:
RsPostedPost()
{
mMeta.mMsgFlags = RsPosted::FLAG_MSGTYPE_POST;
return;
}
RsMsgMetaData mMeta;
std::string mLink;
std::string mNotes;
};
class RsPostedVote
{
public:
RsPostedVote()
{
mMeta.mMsgFlags = RsPosted::FLAG_MSGTYPE_VOTE;
return;
}
RsMsgMetaData mMeta;
};
class RsPostedComment
{
public:
RsPostedComment()
{
mMeta.mMsgFlags = RsPosted::FLAG_MSGTYPE_COMMENT;
return;
}
std::string mComment;
RsMsgMetaData mMeta;
};
#endif // RSPOSTED_H

View file

@ -1813,17 +1813,18 @@ RsTurtle *rsTurtle = NULL ;
#ifdef ENABLE_GXS_CORE
#include "gxs/gxscoreserver.h"
#include "services/p3photoserviceV2.h"
#include "gxs/rsdataservice.h"
#include "gxs/rsgxsnetservice.h"
#endif
#ifdef ENABLE_GXS_SERVICES
#include "services/p3photoserviceV2.h"
#include "services/p3posted.h"
#include "services/p3wikiserviceVEG.h"
#include "services/p3wireVEG.h"
#include "services/p3idserviceVEG.h"
#include "services/p3forumsVEG.h"
#include "services/p3postedVEG.h"
#endif
#ifndef PQI_DISABLE_TUNNEL
@ -2266,41 +2267,7 @@ int RsServer::StartupRetroShare()
mPluginsManager->registerClientServices(pqih) ;
mPluginsManager->registerCacheServices() ;
#ifdef ENABLE_GXS_CORE
p3PhotoServiceV2 *mPhotoV2 = NULL;
// first prep the core
RsDirUtil::checkCreateDirectory(mLinkMgr->getOwnId());
RsGeneralDataService* photo_ds = new RsDataService("./" + mLinkMgr->getOwnId() + "/", "photoV2_db",
RS_SERVICE_GXSV1_TYPE_PHOTO, NULL);
photo_ds->resetDataStore();
// init gxs services
mPhotoV2 = new p3PhotoServiceV2(photo_ds, NULL);
// TODO need net manager
RsGxsNetService* photo_ns = new RsGxsNetService(
RS_SERVICE_GXSV1_TYPE_PHOTO, photo_ds, new RsNxsNetMgrImpl(mLinkMgr), mPhotoV2);
GxsCoreServer* mGxsCore = new GxsCoreServer();
mGxsCore->addService(mPhotoV2);
// cores read start up servers !
// start nxs core core server
createThread(*photo_ns);
// start up gxs core server
createThread(*mGxsCore);
pqih->addService(photo_ns);
#endif
#ifdef ENABLE_GXS_SERVICES
@ -2315,12 +2282,69 @@ int RsServer::StartupRetroShare()
// Testing New Cache Services.
p3ForumsVEG *mForumsV2 = new p3ForumsVEG(RS_SERVICE_GXSV1_TYPE_FORUMS);
pqih -> addService(mForumsV2);
// Testing New Cache Services.
p3PostedServiceVEG *mPosted = new p3PostedServiceVEG(RS_SERVICE_GXSV1_TYPE_POSTED);
pqih -> addService(mPosted);
// TODO: temporary to store GXS service data, remove
RsDirUtil::checkCreateDirectory(mLinkMgr->getOwnId());
RsNxsNetMgr* nxsMgr = new RsNxsNetMgrImpl(mLinkMgr);
/**** Photo service ****/
p3PhotoServiceV2 *mPhotoV2 = NULL;
RsGeneralDataService* photo_ds = new RsDataService("./" + mLinkMgr->getOwnId() + "/", "photoV2_db",
RS_SERVICE_GXSV1_TYPE_PHOTO, NULL);
photo_ds->resetDataStore(); //TODO: remove, new service data per RS session, for testing
// init gxs services
mPhotoV2 = new p3PhotoServiceV2(photo_ds, NULL);
// create GXS photo service
RsGxsNetService* photo_ns = new RsGxsNetService(
RS_SERVICE_GXSV1_TYPE_PHOTO, photo_ds, nxsMgr, mPhotoV2);
/**** Posted GXS service ****/
p3Posted *mPosted = NULL;
RsGeneralDataService* posted_ds = new RsDataService("./" + mLinkMgr->getOwnId()+ "/", "posted_db",
RS_SERVICE_GXSV1_TYPE_POSTED);
posted_ds->resetDataStore(); //TODO: remove, new service data per RS session, for testing
mPosted = new p3Posted(posted_ds, NULL);
// create GXS photo service
RsGxsNetService* posted_ns = new RsGxsNetService(
RS_SERVICE_GXSV1_TYPE_POSTED, posted_ds, nxsMgr, mPosted);
#endif // ENABLE_GXS_SERVICES
#ifdef ENABLE_GXS_CORE
/*** start up GXS core runner ***/
GxsCoreServer* mGxsCore = new GxsCoreServer();
mGxsCore->addService(mPhotoV2);
mGxsCore->addService(mPosted);
// cores ready start up GXS net servers
createThread(*photo_ns);
createThread(*posted_ns);
// now add to p3service
pqih->addService(photo_ns);
pqih->addService(posted_ns);
// start up gxs core server
createThread(*mGxsCore);
#endif
#ifndef RS_RELEASE
p3GameLauncher *gameLauncher = new p3GameLauncher(mLinkMgr);
@ -2578,14 +2602,15 @@ int RsServer::StartupRetroShare()
rsForums = mForums;
rsChannels = mChannels;
rsPhotoV2 = mPhotoV2;
#ifdef ENABLE_GXS_SERVICES
// Testing of new cache system interfaces.
rsWikiVEG = mWikis;
rsWireVEG = mWire;
rsForumsVEG = mForumsV2;
rsPostedVEG = mPosted;
rsPosted = mPosted;
rsPhotoV2 = mPhotoV2;
#endif // ENABLE_GXS_SERVICES

View file

@ -36,41 +36,41 @@ class RsGxsMsgMetaData;
class RsGroupMetaData
{
public:
public:
RsGroupMetaData()
{
mGroupFlags = 0;
mSubscribeFlags = 0;
RsGroupMetaData()
{
mGroupFlags = 0;
mSubscribeFlags = 0;
mPop = 0;
mMsgCount = 0;
mLastPost = 0;
mGroupStatus = 0;
mPop = 0;
mMsgCount = 0;
mLastPost = 0;
mGroupStatus = 0;
//mPublishTs = 0;
}
//mPublishTs = 0;
}
void operator =(const RsGxsGrpMetaData& rGxsMeta);
void operator =(const RsGxsGrpMetaData& rGxsMeta);
std::string mGroupId;
std::string mGroupName;
uint32_t mGroupFlags;
uint32_t mSignFlags; // Combination of RSGXS_GROUP_SIGN_PUBLISH_MASK & RSGXS_GROUP_SIGN_AUTHOR_MASK.
std::string mGroupId;
std::string mGroupName;
uint32_t mGroupFlags;
uint32_t mSignFlags; // Combination of RSGXS_GROUP_SIGN_PUBLISH_MASK & RSGXS_GROUP_SIGN_AUTHOR_MASK.
time_t mPublishTs; // Mandatory.
std::string mAuthorId; // Optional.
time_t mPublishTs; // Mandatory.
std::string mAuthorId; // Optional.
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
uint32_t mSubscribeFlags;
uint32_t mSubscribeFlags;
uint32_t mPop; // HOW DO WE DO THIS NOW.
uint32_t mMsgCount; // ???
time_t mLastPost; // ???
uint32_t mPop; // HOW DO WE DO THIS NOW.
uint32_t mMsgCount; // ???
time_t mLastPost; // ???
uint32_t mGroupStatus;
std::string mServiceString; // Service Specific Free-Form extra storage.
uint32_t mGroupStatus;
std::string mServiceString; // Service Specific Free-Form extra storage.
};
@ -79,38 +79,43 @@ class RsGroupMetaData
class RsMsgMetaData
{
public:
RsMsgMetaData()
{
mPublishTs = 0;
mMsgFlags = 0;
mMsgStatus = 0;
mChildTs = 0;
}
public:
void operator =(const RsGxsMsgMetaData& rGxsMeta);
RsMsgMetaData()
{
mPublishTs = 0;
mMsgFlags = 0;
mMsgStatus = 0;
mChildTs = 0;
}
void operator =(const RsGxsMsgMetaData& rGxsMeta);
std::string mGroupId;
std::string mMsgId;
std::string mGroupId;
std::string mMsgId;
std::string mThreadId;
std::string mParentId;
std::string mOrigMsgId;
std::string mThreadId;
std::string mParentId;
std::string mOrigMsgId;
std::string mAuthorId;
std::string mAuthorId;
std::string mMsgName;
time_t mPublishTs;
std::string mMsgName;
time_t mPublishTs;
uint32_t mMsgFlags; // Whats this for?
/// the first 16 bits for service, last 16 for GXS
uint32_t mMsgFlags;
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
// normally READ / UNREAD flags. LOCAL Data.
uint32_t mMsgStatus;
time_t mChildTs;
std::string mServiceString; // Service Specific Free-Form extra storage.
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
// normally READ / UNREAD flags. LOCAL Data.
/// the first 16 bits for service, last 16 for GXS
uint32_t mMsgStatus;
time_t mChildTs;
std::string mServiceString; // Service Specific Free-Form extra storage.
};

View file

@ -1445,23 +1445,23 @@ bool p3GxsDataServiceVEG::fakeprocessrequests()
#if 0 // DISABLED AND MOVED TO GXS CODE.
std::ostream &operator<<(std::ostream &out, const RsGroupMetaData &meta)
{
out << "[ GroupId: " << meta.mGroupId << " Name: " << meta.mGroupName << " ]";
return out;
}
//std::ostream &operator<<(std::ostream &out, const RsGroupMetaData &meta)
//{
// out << "[ GroupId: " << meta.mGroupId << " Name: " << meta.mGroupName << " ]";
// return out;
//}
std::ostream &operator<<(std::ostream &out, const RsMsgMetaData &meta)
{
out << "[ GroupId: " << meta.mGroupId << " MsgId: " << meta.mMsgId;
out << " Name: " << meta.mMsgName;
out << " OrigMsgId: " << meta.mOrigMsgId;
out << " ThreadId: " << meta.mThreadId;
out << " ParentId: " << meta.mParentId;
out << " AuthorId: " << meta.mAuthorId;
out << " Name: " << meta.mMsgName << " ]";
return out;
}
//std::ostream &operator<<(std::ostream &out, const RsMsgMetaData &meta)
//{
// out << "[ GroupId: " << meta.mGroupId << " MsgId: " << meta.mMsgId;
// out << " Name: " << meta.mMsgName;
// out << " OrigMsgId: " << meta.mOrigMsgId;
// out << " ThreadId: " << meta.mThreadId;
// out << " ParentId: " << meta.mParentId;
// out << " AuthorId: " << meta.mAuthorId;
// out << " Name: " << meta.mMsgName << " ]";
// return out;
//}
#endif

View file

@ -499,7 +499,7 @@ bool p3IdService::cache_start_load()
}
uint32_t ansType = RS_TOKREQ_ANSTYPE_DATA;
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
uint32_t token = 0;
RsGenExchange::getTokenService()->requestGroupInfo(token, ansType, opts, groupIds);
@ -971,7 +971,7 @@ bool p3IdService::background_requestGroups()
}
uint32_t ansType = RS_TOKREQ_ANSTYPE_SUMMARY;
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
std::list<std::string> groupIds;
/**
@ -1034,7 +1034,7 @@ bool p3IdService::background_requestNewMessages()
}
uint32_t ansType = RS_TOKREQ_ANSTYPE_SUMMARY;
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
token = 0;
/* TODO
@ -1319,7 +1319,7 @@ bool p3IdService::background_FullCalcRequest()
/* request the summary info from the parents */
uint32_t ansType = RS_TOKREQ_ANSTYPE_DATA;
uint32_t token = 0;
RsTokReqOptionsV2 opts;
RsTokReqOptions opts;
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
RsGenExchange::getTokenService()->requestMsgInfo(token, ansType, opts, groupIds);

View file

@ -1,4 +1,11 @@
#include "p3posted.h"
#include "serialiser/rsposteditems.h"
const uint32_t RsPosted::FLAG_MSGTYPE_COMMENT = 0x0001;
const uint32_t RsPosted::FLAG_MSGTYPE_POST = 0x0002;
const uint32_t RsPosted::FLAG_MSGTYPE_VOTE = 0x0004;
RsPosted *rsPosted = NULL;
p3Posted::p3Posted(RsGeneralDataService *gds, RsNetworkExchangeService *nes)
: RsGenExchange(gds, nes, NULL, RS_SERVICE_GXSV1_TYPE_POSTED), RsPosted(this)
@ -10,39 +17,147 @@ void p3Posted::notifyChanges(std::vector<RsGxsNotify *> &changes)
receiveChanges(changes);
}
bool p3Posted::getGroup(const uint32_t &token, RsPostedGroup &group)
void p3Posted::service_tick()
{
}
bool p3Posted::getPost(const uint32_t &token, RsPostedPost &post)
bool p3Posted::getGroup(const uint32_t &token, std::vector<RsPostedGroup> &groups)
{
std::vector<RsGxsGrpItem*> grpData;
bool ok = RsGenExchange::getGroupData(token, grpData);
if(ok)
{
std::vector<RsGxsGrpItem*>::iterator vit = grpData.begin();
for(; vit != grpData.end(); vit++)
{
RsGxsPostedGroupItem* item = dynamic_cast<RsGxsPostedGroupItem*>(*vit);
RsPostedGroup grp = item->mGroup;
item->mGroup.mMeta = item->meta;
grp.mMeta = item->mGroup.mMeta;
delete item;
groups.push_back(grp);
}
}
return ok;
}
bool p3Posted::getComment(const uint32_t &token, RsPostedComment &comment)
bool p3Posted::getPost(const uint32_t &token, PostedPostResult &posts)
{
GxsMsgDataMap msgData;
bool ok = RsGenExchange::getMsgData(token, msgData);
if(ok)
{
GxsMsgDataMap::iterator mit = msgData.begin();
for(; mit != msgData.end(); mit++)
{
RsGxsGroupId grpId = mit->first;
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
for(; vit != msgItems.end(); vit++)
{
RsGxsPostedPostItem* item = dynamic_cast<RsGxsPostedPostItem*>(*vit);
if(item)
{
RsPostedPost post = item->mPost;
post.mMeta = item->meta;
posts[grpId].push_back(post);
delete item;
}else
{
std::cerr << "Not a post Item, deleting!" << std::endl;
delete *vit;
}
}
}
}
return ok;
}
bool p3Posted::getComment(const uint32_t &token, PostedCommentResult &comments)
{
GxsMsgDataMap msgData;
bool ok = RsGenExchange::getMsgData(token, msgData);
if(ok)
{
GxsMsgDataMap::iterator mit = msgData.begin();
for(; mit != msgData.end(); mit++)
{
RsGxsGroupId grpId = mit->first;
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
for(; vit != msgItems.end(); vit++)
{
RsGxsPostedCommentItem* item = dynamic_cast<RsGxsPostedCommentItem*>(*vit);
if(item)
{
RsPostedComment comment = item->mComment;
comment.mMeta = item->meta;
comments[grpId].push_back(comment);
delete item;
}else
{
std::cerr << "Not a comment Item, deleting!" << std::endl;
delete *vit;
}
}
}
}
return ok;
}
bool p3Posted::submitGroup(uint32_t &token, RsPostedGroup &group)
{
RsGxsPostedGroupItem* grpItem = new RsGxsPostedGroupItem();
grpItem->mGroup = group;
grpItem->meta = group.mMeta;
RsGenExchange::publishGroup(token, grpItem);
return true;
}
bool p3Posted::submitPost(uint32_t &token, RsPostedPost &post)
{
RsGxsPostedPostItem* postItem = new RsGxsPostedPostItem();
postItem->mPost = post;
postItem->meta = post.mMeta;
postItem->meta.mMsgFlags |= FLAG_MSGTYPE_POST;
RsGenExchange::publishMsg(token, postItem);
return true;
}
bool p3Posted::submitVote(uint32_t &token, RsPostedVote &vote)
{
RsGxsPostedVoteItem* voteItem = new RsGxsPostedVoteItem();
voteItem->mVote = vote;
voteItem->meta = vote.mMeta;
voteItem->meta.mMsgFlags |= FLAG_MSGTYPE_POST;
RsGenExchange::publishMsg(token, voteItem);
return true;
}
bool p3Posted::submitComment(uint32_t &token, RsPostedComment &comment)
{
RsGxsPostedCommentItem* commentItem = new RsGxsPostedCommentItem();
commentItem->mComment = comment;
commentItem->meta = comment.mMeta;
commentItem->meta.mMsgFlags |= FLAG_MSGTYPE_COMMENT;
RsGenExchange::publishMsg(token, commentItem);
return true;
}
// Special Ranking Request.
@ -50,36 +165,3 @@ bool p3Posted::requestRanking(uint32_t &token, RsGxsGroupId groupId)
{
}
bool p3Posted::getRankedPost(const uint32_t &token, RsPostedPost &post)
{
}
bool p3Posted::extractPostedCache()
{
}
// Control Ranking Calculations.
bool p3Posted::setViewMode(uint32_t mode)
{
}
bool p3Posted::setViewPeriod(uint32_t period)
{
}
bool p3Posted::setViewRange(uint32_t first, uint32_t count)
{
}
// exposed for testing...
float p3Posted::calcPostScore(uint32_t& token, const RsGxsMessageId)
{
}

View file

@ -22,11 +22,13 @@ protected:
*/
void notifyChanges(std::vector<RsGxsNotify*>& changes) ;
void service_tick();
public:
bool getGroup(const uint32_t &token, RsPostedGroup &group);
bool getPost(const uint32_t &token, RsPostedPost &post) ;
bool getComment(const uint32_t &token, RsPostedComment &comment) ;
bool getGroup(const uint32_t &token, std::vector<RsPostedGroup> &group);
bool getPost(const uint32_t &token, PostedPostResult& posts) ;
bool getComment(const uint32_t &token, PostedCommentResult& comments) ;
bool submitGroup(uint32_t &token, RsPostedGroup &group);
bool submitPost(uint32_t &token, RsPostedPost &post);
@ -35,18 +37,12 @@ public:
// Special Ranking Request.
bool requestRanking(uint32_t &token, RsGxsGroupId groupId) ;
bool getRankedPost(const uint32_t &token, RsPostedPost &post) ;
bool extractPostedCache() ;
// Control Ranking Calculations.
bool setViewMode(uint32_t mode);
bool setViewPeriod(uint32_t period);
bool setViewRange(uint32_t first, uint32_t count);
// bool setViewMode(uint32_t mode);
// bool setViewPeriod(uint32_t period);
// bool setViewRange(uint32_t first, uint32_t count);
// exposed for testing...
float calcPostScore(uint32_t& token, const RsGxsMessageId);
};
#endif // P3POSTED_H