mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Basic code change over from VEG => Real GXS service.
Still doesn't compile yet, mainly headers and the like to fix. NB: Interface Mismatch between RsGenExchange (vector) and individual result for getGroupData() / getMsgData() git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5689 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
35bff312a7
commit
c5d750c0ea
@ -46,6 +46,13 @@ RsIdentity *rsIdentity = NULL;
|
||||
/******************* Startup / Tick ******************************************/
|
||||
/********************************************************************************/
|
||||
|
||||
p3IdService::p3IdService(RsGeneralDataService *gds, RsNetworkExchangeService *nes)
|
||||
: RsIdentity(this), RsGenExchange(gds, nes, NULL, RS_SERVICE_GXSV1_TYPE_IDENTITY),
|
||||
mIdMtx("p3IdService")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
p3IdService::p3IdService(uint16_t type)
|
||||
:p3GxsDataService(type, new IdDataProxy()), mIdMtx("p3IdService"), mUpdated(true)
|
||||
{
|
||||
@ -55,348 +62,191 @@ p3IdService::p3IdService(uint16_t type)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int p3IdService::tick()
|
||||
int p3IdService::internal_tick()
|
||||
{
|
||||
std::cerr << "p3IdService::tick()";
|
||||
std::cerr << "p3IdService::internal_tick()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
fakeprocessrequests();
|
||||
// Disable for now.
|
||||
// background_tick();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool p3IdService::updated()
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
if (mUpdated)
|
||||
{
|
||||
mUpdated = false;
|
||||
return true;
|
||||
}
|
||||
/********************************************************************************/
|
||||
/******************* RsIdentity Interface ***************************************/
|
||||
/********************************************************************************/
|
||||
|
||||
bool p3IdService:: getNickname(const RsId &id, std::string &nickname)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3IdService:: getIdDetails(const RsId &id, RsIdentityDetails &details)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3IdService:: getOwnIds(std::list<RsId> &ownIds)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Data Requests */
|
||||
bool p3IdService::requestGroupInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds)
|
||||
//
|
||||
bool p3IdService::submitOpinion(uint32_t& token, RsIdOpinion &opinion)
|
||||
{
|
||||
generateToken(token);
|
||||
std::cerr << "p3IdService::requestGroupInfo() gets Token: " << token << std::endl;
|
||||
storeRequest(token, ansType, opts, GXS_REQUEST_TYPE_GROUPS, groupIds);
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3IdService::requestMsgInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds)
|
||||
bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters ¶ms)
|
||||
{
|
||||
generateToken(token);
|
||||
std::cerr << "p3IdService::requestMsgInfo() gets Token: " << token << std::endl;
|
||||
storeRequest(token, ansType, opts, GXS_REQUEST_TYPE_MSGS, groupIds);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3IdService::requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &msgIds)
|
||||
{
|
||||
generateToken(token);
|
||||
std::cerr << "p3IdService::requestMsgRelatedInfo() gets Token: " << token << std::endl;
|
||||
storeRequest(token, ansType, opts, GXS_REQUEST_TYPE_MSGRELATED, msgIds);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Generic Lists */
|
||||
bool p3IdService::getGroupList( const uint32_t &token, std::list<std::string> &groupIds)
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t reqtype;
|
||||
uint32_t anstype;
|
||||
time_t ts;
|
||||
checkRequestStatus(token, status, reqtype, anstype, ts);
|
||||
|
||||
if (anstype != RS_TOKREQ_ANSTYPE_LIST)
|
||||
{
|
||||
std::cerr << "p3IdService::getGroupList() ERROR AnsType Wrong" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (reqtype != GXS_REQUEST_TYPE_GROUPS)
|
||||
{
|
||||
std::cerr << "p3IdService::getGroupList() ERROR ReqType Wrong" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (status != GXS_REQUEST_STATUS_COMPLETE)
|
||||
{
|
||||
std::cerr << "p3IdService::getGroupList() ERROR Status Incomplete" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ans = loadRequestOutList(token, groupIds);
|
||||
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
|
||||
|
||||
return ans;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************/
|
||||
/******************* RsGixs Interface ***************************************/
|
||||
/********************************************************************************/
|
||||
|
||||
|
||||
bool p3IdService::getMsgList( const uint32_t &token, std::list<std::string> &msgIds)
|
||||
bool p3IdService::haveKey(const GxsId &id)
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t reqtype;
|
||||
uint32_t anstype;
|
||||
time_t ts;
|
||||
checkRequestStatus(token, status, reqtype, anstype, ts);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (anstype != RS_TOKREQ_ANSTYPE_LIST)
|
||||
{
|
||||
std::cerr << "p3IdService::getMsgList() ERROR AnsType Wrong" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((reqtype != GXS_REQUEST_TYPE_MSGS) && (reqtype != GXS_REQUEST_TYPE_MSGRELATED))
|
||||
{
|
||||
std::cerr << "p3IdService::getMsgList() ERROR ReqType Wrong" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (status != GXS_REQUEST_STATUS_COMPLETE)
|
||||
{
|
||||
std::cerr << "p3IdService::getMsgList() ERROR Status Incomplete" << std::endl;
|
||||
return false;
|
||||
}
|
||||
bool p3IdService::havePrivateKey(const GxsId &id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ans = loadRequestOutList(token, msgIds);
|
||||
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
|
||||
bool p3IdService::requestKey(const GxsId &id, const std::list<PeerId> &peers)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return ans;
|
||||
int p3IdService::getKey(const GxsId &id, TlvSecurityKey &key)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int p3IdService::getPrivateKey(const GxsId &id, TlvSecurityKey &key)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* Generic Summary */
|
||||
bool p3IdService::getGroupSummary( const uint32_t &token, std::list<RsGroupMetaData> &groupInfo)
|
||||
/********************************************************************************/
|
||||
/******************* RsGixsReputation ***************************************/
|
||||
/********************************************************************************/
|
||||
|
||||
bool p3IdService::getReputation(const GxsId &id, const GixsReputation &rep)
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t reqtype;
|
||||
uint32_t anstype;
|
||||
time_t ts;
|
||||
checkRequestStatus(token, status, reqtype, anstype, ts);
|
||||
|
||||
if (anstype != RS_TOKREQ_ANSTYPE_SUMMARY)
|
||||
{
|
||||
std::cerr << "p3IdService::getGroupSummary() ERROR AnsType Wrong" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (reqtype != GXS_REQUEST_TYPE_GROUPS)
|
||||
{
|
||||
std::cerr << "p3IdService::getGroupSummary() ERROR ReqType Wrong" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (status != GXS_REQUEST_STATUS_COMPLETE)
|
||||
{
|
||||
std::cerr << "p3IdService::getGroupSummary() ERROR Status Incomplete" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::list<std::string> groupIds;
|
||||
bool ans = loadRequestOutList(token, groupIds);
|
||||
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
|
||||
|
||||
/* convert to RsGroupMetaData */
|
||||
mProxy->getGroupSummary(groupIds, groupInfo);
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
bool p3IdService::getMsgSummary( const uint32_t &token, std::list<RsMsgMetaData> &msgInfo)
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t reqtype;
|
||||
uint32_t anstype;
|
||||
time_t ts;
|
||||
checkRequestStatus(token, status, reqtype, anstype, ts);
|
||||
|
||||
if (anstype != RS_TOKREQ_ANSTYPE_SUMMARY)
|
||||
{
|
||||
std::cerr << "p3IdService::getMsgSummary() ERROR AnsType Wrong" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((reqtype != GXS_REQUEST_TYPE_MSGS) && (reqtype != GXS_REQUEST_TYPE_MSGRELATED))
|
||||
{
|
||||
std::cerr << "p3IdService::getMsgSummary() ERROR ReqType Wrong" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (status != GXS_REQUEST_STATUS_COMPLETE)
|
||||
{
|
||||
std::cerr << "p3IdService::getMsgSummary() ERROR Status Incomplete" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::list<std::string> msgIds;
|
||||
bool ans = loadRequestOutList(token, msgIds);
|
||||
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
|
||||
|
||||
/* convert to RsMsgMetaData */
|
||||
mProxy->getMsgSummary(msgIds, msgInfo);
|
||||
|
||||
return ans;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Specific Service Data */
|
||||
/********************************************************************************/
|
||||
/******************* Get/Set Data ******************************************/
|
||||
/********************************************************************************/
|
||||
|
||||
bool p3IdService::getGroupData(const uint32_t &token, RsIdGroup &group)
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t reqtype;
|
||||
uint32_t anstype;
|
||||
time_t ts;
|
||||
checkRequestStatus(token, status, reqtype, anstype, ts);
|
||||
|
||||
|
||||
if (anstype != RS_TOKREQ_ANSTYPE_DATA)
|
||||
{
|
||||
std::cerr << "p3IdService::getGroupData() ERROR AnsType Wrong" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (reqtype != GXS_REQUEST_TYPE_GROUPS)
|
||||
{
|
||||
std::cerr << "p3IdService::getGroupData() ERROR ReqType Wrong" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (status != GXS_REQUEST_STATUS_COMPLETE)
|
||||
{
|
||||
std::cerr << "p3IdService::getGroupData() ERROR Status Incomplete" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string id;
|
||||
if (!popRequestOutList(token, id))
|
||||
{
|
||||
/* finished */
|
||||
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* convert to RsIdGroup */
|
||||
bool ans = mIdProxy->getGroup(id, group);
|
||||
return ans;
|
||||
// MISMATCH BETWEEN RsGenExchange (vector) and individual result here.
|
||||
#if 0
|
||||
std::vector<RsGxsGrpItem*> grpData;
|
||||
bool ok = RsGenExchange::getGroupData(token, grpData);
|
||||
|
||||
if(ok)
|
||||
{
|
||||
std::vector<RsGxsGrpItem*>::iterator vit = grpData.begin();
|
||||
|
||||
for(; vit != grpData.end(); vit++)
|
||||
{
|
||||
RsGxsIdGroupItem* item = dynamic_cast<RsGxsIdGroupItem*>(*vit);
|
||||
RsIdGroup group = item->group;
|
||||
group.mMeta = item->meta
|
||||
groups.push_back(group);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool p3IdService::getMsgData(const uint32_t &token, RsIdMsg &msg)
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t reqtype;
|
||||
uint32_t anstype;
|
||||
time_t ts;
|
||||
checkRequestStatus(token, status, reqtype, anstype, ts);
|
||||
|
||||
|
||||
if (anstype != RS_TOKREQ_ANSTYPE_DATA)
|
||||
// MISMATCH BETWEEN RsGenExchange (vector) and individual result here.
|
||||
#if 0
|
||||
GxsMsgDataMap msgData;
|
||||
bool ok = RsGenExchange::getMsgData(token, msgData);
|
||||
|
||||
if(ok)
|
||||
{
|
||||
std::cerr << "p3IdService::getMsgData() ERROR AnsType Wrong" << std::endl;
|
||||
return false;
|
||||
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++)
|
||||
{
|
||||
RsGxsIdMsgItem* item = dynamic_cast<RsGxsIdMsgItem*>(*vit);
|
||||
|
||||
if(item)
|
||||
{
|
||||
RsIdMsg msg = item->msg;
|
||||
msg.mMeta = item->meta;
|
||||
msgs[grpId].push_back(msg);
|
||||
delete item;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Not a IdMsg Item, deleting!" << std::endl;
|
||||
delete *vit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((reqtype != GXS_REQUEST_TYPE_MSGS) && (reqtype != GXS_REQUEST_TYPE_MSGRELATED))
|
||||
{
|
||||
std::cerr << "p3IdService::getMsgData() ERROR ReqType Wrong" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (status != GXS_REQUEST_STATUS_COMPLETE)
|
||||
{
|
||||
std::cerr << "p3IdService::getMsgData() ERROR Status Incomplete" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string id;
|
||||
if (!popRequestOutList(token, id))
|
||||
{
|
||||
/* finished */
|
||||
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* convert to RsIdMsg */
|
||||
bool ans = mIdProxy->getMsg(id, msg);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Poll */
|
||||
uint32_t p3IdService::requestStatus(const uint32_t token)
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t reqtype;
|
||||
uint32_t anstype;
|
||||
time_t ts;
|
||||
checkRequestStatus(token, status, reqtype, anstype, ts);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/* Cancel Request */
|
||||
bool p3IdService::cancelRequest(const uint32_t &token)
|
||||
{
|
||||
return clearRequest(token);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
bool p3IdService::setMessageStatus(const std::string &msgId, const uint32_t status, const uint32_t statusMask)
|
||||
{
|
||||
return mIdProxy->setMessageStatus(msgId, status, statusMask);
|
||||
}
|
||||
|
||||
bool p3IdService::setGroupStatus(const std::string &groupId, const uint32_t status, const uint32_t statusMask)
|
||||
{
|
||||
return mIdProxy->setGroupStatus(groupId, status, statusMask);
|
||||
}
|
||||
|
||||
bool p3IdService::setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask)
|
||||
{
|
||||
return mIdProxy->setGroupSubscribeFlags(groupId, subscribeFlags, subscribeMask);
|
||||
}
|
||||
|
||||
bool p3IdService::setMessageServiceString(const std::string &msgId, const std::string &str)
|
||||
{
|
||||
return mIdProxy->setMessageServiceString(msgId, str);
|
||||
}
|
||||
|
||||
bool p3IdService::setGroupServiceString(const std::string &grpId, const std::string &str)
|
||||
{
|
||||
return mIdProxy->setGroupServiceString(grpId, str);
|
||||
}
|
||||
|
||||
|
||||
bool p3IdService::groupRestoreKeys(const std::string &groupId)
|
||||
{
|
||||
return ok;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3IdService::groupShareKeys(const std::string &groupId, std::list<std::string>& peers)
|
||||
/********************************************************************************/
|
||||
/********************************************************************************/
|
||||
/********************************************************************************/
|
||||
|
||||
bool p3IdService::createGroup(uint32_t& token, RsIdGroup &group)
|
||||
{
|
||||
return false;
|
||||
RsGxsIdGroupItem* item = new RsGxsIdGroupItem();
|
||||
item->group = group;
|
||||
item->meta = group.mMeta;
|
||||
RsGenExchange::publishGroup(token, item);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3IdService::createMsg(uint32_t& token, RsIdMsg &msg)
|
||||
{
|
||||
RsGxsIdMsgItem* item = new RsGxsIdMsgItem();
|
||||
item->msg = msg;
|
||||
item->meta = msg.mMeta;
|
||||
RsGenExchange::publishMsg(token, item);
|
||||
return true;
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
/************************************************************************************/
|
||||
/************************************************************************************/
|
||||
/************************************************************************************/
|
||||
/************************************************************************************/
|
||||
/************************************************************************************/
|
||||
|
||||
|
||||
std::string p3IdService::genRandomId()
|
||||
{
|
||||
std::string randomId;
|
||||
@ -408,296 +258,6 @@ std::string p3IdService::genRandomId()
|
||||
return randomId;
|
||||
}
|
||||
|
||||
bool p3IdService::createGroup(uint32_t &token, RsIdGroup &group, bool isNew)
|
||||
{
|
||||
if (group.mMeta.mGroupId.empty())
|
||||
{
|
||||
/* new photo */
|
||||
|
||||
/* generate a temp id */
|
||||
group.mMeta.mGroupId = genRandomId();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "p3IdService::createGroup() Group with existing Id... dropping";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
mUpdated = true;
|
||||
mIdProxy->addGroup(group);
|
||||
}
|
||||
|
||||
// Fake a request to return the GroupMetaData.
|
||||
generateToken(token);
|
||||
uint32_t ansType = RS_TOKREQ_ANSTYPE_SUMMARY;
|
||||
RsTokReqOptions opts; // NULL is good.
|
||||
std::list<std::string> groupIds;
|
||||
groupIds.push_back(group.mMeta.mGroupId); // It will just return this one.
|
||||
|
||||
std::cerr << "p3IdService::createGroup() Generating Request Token: " << token << std::endl;
|
||||
storeRequest(token, ansType, opts, GXS_REQUEST_TYPE_GROUPS, groupIds);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool p3IdService::createMsg(uint32_t &token, RsIdMsg &msg, bool isNew)
|
||||
{
|
||||
if (msg.mMeta.mGroupId.empty())
|
||||
{
|
||||
/* new photo */
|
||||
std::cerr << "p3IdService::createMsg() Missing MsgID";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check if its a mod or new msg */
|
||||
if (msg.mMeta.mOrigMsgId.empty())
|
||||
{
|
||||
std::cerr << "p3IdService::createMsg() New Msg";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* new msg, generate a new OrigMsgId */
|
||||
msg.mMeta.mOrigMsgId = genRandomId();
|
||||
msg.mMeta.mMsgId = msg.mMeta.mOrigMsgId;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "p3IdService::createMsg() Modified Msg";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* mod msg, keep orig msg id, generate a new MsgId */
|
||||
msg.mMeta.mMsgId = genRandomId();
|
||||
}
|
||||
|
||||
std::cerr << "p3IdService::createMsg() GroupId: " << msg.mMeta.mGroupId;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3IdService::createMsg() MsgId: " << msg.mMeta.mMsgId;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3IdService::createMsg() OrigMsgId: " << msg.mMeta.mOrigMsgId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
mUpdated = true;
|
||||
mIdProxy->addMsg(msg);
|
||||
}
|
||||
|
||||
// Fake a request to return the MsgMetaData.
|
||||
generateToken(token);
|
||||
uint32_t ansType = RS_TOKREQ_ANSTYPE_SUMMARY;
|
||||
RsTokReqOptions opts; // NULL is good.
|
||||
std::list<std::string> msgIds;
|
||||
msgIds.push_back(msg.mMeta.mMsgId); // It will just return this one.
|
||||
|
||||
std::cerr << "p3IdService::createMsg() Generating Request Token: " << token << std::endl;
|
||||
storeRequest(token, ansType, opts, GXS_REQUEST_TYPE_MSGRELATED, msgIds);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
|
||||
|
||||
bool IdDataProxy::getGroup(const std::string &id, RsIdGroup &group)
|
||||
{
|
||||
void *groupData = NULL;
|
||||
RsGroupMetaData meta;
|
||||
if (getGroupData(id, groupData) && getGroupSummary(id, meta))
|
||||
{
|
||||
RsIdGroup *pG = (RsIdGroup *) groupData;
|
||||
group = *pG;
|
||||
|
||||
// update definitive version of the metadata.
|
||||
group.mMeta = meta;
|
||||
|
||||
std::cerr << "IdDataProxy::getGroup() Id: " << id;
|
||||
std::cerr << " MetaData: " << meta << " DataPointer: " << groupData;
|
||||
std::cerr << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::cerr << "IdDataProxy::getGroup() FAILED Id: " << id;
|
||||
std::cerr << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IdDataProxy::getMsg(const std::string &id, RsIdMsg &msg)
|
||||
{
|
||||
void *msgData = NULL;
|
||||
RsMsgMetaData meta;
|
||||
if (getMsgData(id, msgData) && getMsgSummary(id, meta))
|
||||
{
|
||||
RsIdMsg *pM = (RsIdMsg *) msgData;
|
||||
// Shallow copy of thumbnail.
|
||||
msg = *pM;
|
||||
|
||||
// update definitive version of the metadata.
|
||||
msg.mMeta = meta;
|
||||
|
||||
std::cerr << "IdDataProxy::getMsg() Id: " << id;
|
||||
std::cerr << " MetaData: " << meta << " DataPointer: " << msgData;
|
||||
std::cerr << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::cerr << "IdDataProxy::getMsg() FAILED Id: " << id;
|
||||
std::cerr << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IdDataProxy::addGroup(const RsIdGroup &group)
|
||||
{
|
||||
// Make duplicate.
|
||||
RsIdGroup *pG = new RsIdGroup();
|
||||
*pG = group;
|
||||
|
||||
std::cerr << "IdDataProxy::addGroup()";
|
||||
std::cerr << " MetaData: " << pG->mMeta << " DataPointer: " << pG;
|
||||
std::cerr << std::endl;
|
||||
|
||||
return createGroup(pG);
|
||||
}
|
||||
|
||||
|
||||
bool IdDataProxy::addMsg(const RsIdMsg &msg)
|
||||
{
|
||||
// Make duplicate.
|
||||
RsIdMsg *pM = new RsIdMsg();
|
||||
*pM = msg;
|
||||
|
||||
std::cerr << "IdDataProxy::addMsg()";
|
||||
std::cerr << " MetaData: " << pM->mMeta << " DataPointer: " << pM;
|
||||
std::cerr << std::endl;
|
||||
|
||||
return createMsg(pM);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* These Functions must be overloaded to complete the service */
|
||||
bool IdDataProxy::convertGroupToMetaData(void *groupData, RsGroupMetaData &meta)
|
||||
{
|
||||
RsIdGroup *group = (RsIdGroup *) groupData;
|
||||
meta = group->mMeta;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IdDataProxy::convertMsgToMetaData(void *msgData, RsMsgMetaData &meta)
|
||||
{
|
||||
RsIdMsg *page = (RsIdMsg *) msgData;
|
||||
meta = page->mMeta;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************************************************/
|
||||
/************************************************************************************/
|
||||
/************************************************************************************/
|
||||
/************************************************************************************/
|
||||
/************************************************************************************/
|
||||
|
||||
#if 0
|
||||
|
||||
/* details are updated */
|
||||
bool p3IdService::updateIdentity(RsIdData &data)
|
||||
{
|
||||
if (data.mKeyId.empty())
|
||||
{
|
||||
/* new photo */
|
||||
|
||||
/* generate a temp id */
|
||||
data.mKeyId = genRandomId();
|
||||
|
||||
if (data.mIdType & RSID_TYPE_REALID)
|
||||
{
|
||||
data.mGpgIdHash = genRandomId();
|
||||
}
|
||||
else
|
||||
{
|
||||
data.mGpgIdHash = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
mUpdated = true;
|
||||
|
||||
/* add / modify */
|
||||
mIds[data.mKeyId] = data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool p3IdService::updateOpinion(RsIdOpinion &opinion)
|
||||
{
|
||||
if (opinion.mKeyId.empty())
|
||||
{
|
||||
/* new photo */
|
||||
std::cerr << "p3IdService::updateOpinion() Missing KeyId";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check if its a mod or new page */
|
||||
if (opinion.mPeerId.empty())
|
||||
{
|
||||
std::cerr << "p3IdService::updateOpinion() Missing PeerId";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cerr << "p3IdService::updateOpinion() KeyId: " << opinion.mKeyId;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3IdService::updateOpinion() PeerId: " << opinion.mPeerId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
mUpdated = true;
|
||||
|
||||
std::map<std::string, std::map<std::string, RsIdOpinion> >::iterator it;
|
||||
std::map<std::string, RsIdOpinion>::iterator oit;
|
||||
|
||||
it = mOpinions.find(opinion.mKeyId);
|
||||
if (it == mOpinions.end())
|
||||
{
|
||||
std::map<std::string, RsIdOpinion> emptyMap;
|
||||
mOpinions[opinion.mKeyId] = emptyMap;
|
||||
|
||||
it = mOpinions.find(opinion.mKeyId);
|
||||
}
|
||||
|
||||
(it->second)[opinion.mPeerId] = opinion;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void p3IdService::generateDummyData()
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
@ -89,6 +89,20 @@ class p3IdService: public RsIdentity, public RsGxsIdExchange
|
||||
/* TODO */
|
||||
|
||||
|
||||
/**************** RsIdentity External Interface.
|
||||
* Notes:
|
||||
*/
|
||||
|
||||
|
||||
virtual bool getNickname(const RsId &id, std::string &nickname);
|
||||
virtual bool getIdDetails(const RsId &id, RsIdentityDetails &details);
|
||||
virtual bool getOwnIds(std::list<RsId> &ownIds);
|
||||
|
||||
//
|
||||
virtual bool submitOpinion(uint32_t& token, RsIdOpinion &opinion);
|
||||
virtual bool createIdentity(uint32_t& token, RsIdentityParameters ¶ms);
|
||||
|
||||
|
||||
/**************** RsGixs Implementation
|
||||
* Notes:
|
||||
* Interface is only suggestion at the moment, will be changed as necessary.
|
||||
|
Loading…
Reference in New Issue
Block a user