laptop power supply dead, commiting,

added tokens to submissions, got it working
added generic service string to meta
added msg and grp creation
 

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5439 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2012-08-18 10:01:35 +00:00
parent 34ffb229e4
commit 5425ab36b5
19 changed files with 500 additions and 77 deletions

View file

@ -44,6 +44,7 @@
#define KEY_TIME_STAMP std::string("timeStamp")
#define KEY_NXS_FLAGS std::string("flags")
#define KEY_NXS_META std::string("meta")
#define KEY_NXS_SERV_STRING std::string("serv_str");
// grp table columns

View file

@ -63,33 +63,184 @@ void RsGenExchange::tick()
publishMsgs();
notifyChanges(mNotifications);
mNotifications.clear();
notifyChanges(mNotifications);
mNotifications.clear();
}
bool RsGenExchange::acknowledgeTokenMsg(const uint32_t& token,
std::pair<RsGxsGroupId, RsGxsMessageId>& msgId)
{
RsStackMutex stack(mGenMtx);
std::map<uint32_t, std::pair<RsGxsGroupId, RsGxsMessageId> >::iterator mit =
mMsgPublished.find(token);
if(mit == mMsgPublished.end())
return false;
msgId = mit->second;
// no dump token as client has ackowledged its completion
mDataAccess->disposeOfPublicToken(token);
return true;
}
bool RsGenExchange::acknowledgeTokenGrp(const uint32_t& token,
RsGxsGroupId& grpId)
{
RsStackMutex stack(mGenMtx);
std::map<uint32_t, RsGxsGroupId >::iterator mit =
mGrpPublished.find(token);
if(mit == mGrpPublished.end())
return false;
grpId = mit->second;
// no dump token as client has ackowledged its completion
mDataAccess->disposeOfPublicToken(token);
return true;
}
void RsGenExchange::createGroup(RsNxsGrp *grp)
{
/* create Keys */
// admin keys
RSA *rsa_admin = RSA_generate_key(2048, 65537, NULL, NULL);
RSA *rsa_admin_pub = RSAPublicKey_dup(rsa_admin);
// publish keys
RSA *rsa_publish = RSA_generate_key(2048, 65537, NULL, NULL);
RSA *rsa_publish_pub = RSAPublicKey_dup(rsa_admin);
/* set keys */
RsTlvSecurityKey adminKey;
RsTlvSecurityKey adminKey, privAdminKey;
/* set publish keys */
RsTlvSecurityKey pubKey, privPubKey;
GxsSecurity::setRSAPublicKey(adminKey, rsa_admin_pub);
GxsSecurity::setRSAPrivateKey(privAdminKey, rsa_admin);
GxsSecurity::setRSAPublicKey(pubKey, rsa_publish_pub);
GxsSecurity::setRSAPrivateKey(privPubKey, rsa_publish);
// for now all public
adminKey.keyFlags = RSTLV_KEY_DISTRIB_ADMIN | RSTLV_KEY_TYPE_PUBLIC_ONLY;
privAdminKey.keyFlags = RSTLV_KEY_DISTRIB_ADMIN | RSTLV_KEY_TYPE_FULL;
// for now all public
pubKey.keyFlags = RSTLV_KEY_DISTRIB_PUBLIC | RSTLV_KEY_TYPE_PUBLIC_ONLY;
privPubKey.keyFlags = RSTLV_KEY_DISTRIB_PRIVATE | RSTLV_KEY_TYPE_FULL;
adminKey.startTS = time(NULL);
adminKey.endTS = 0; /* no end */
RsGxsGrpMetaData* meta = grp->metaData;
/* add keys to grp */
meta->keys.keys[adminKey.keyId] = adminKey;
meta->keys.keys[privAdminKey.keyId] = privAdminKey;
meta->keys.keys[pubKey.keyId] = pubKey;
meta->keys.keys[privPubKey.keyId] = privPubKey;
meta->mGroupId = adminKey.keyId;
grp->grpId = meta->mGroupId;
adminKey.TlvClear();
privAdminKey.TlvClear();
privPubKey.TlvClear();
pubKey.TlvClear();
// free the private key for now, as it is not in use
RSA_free(rsa_admin);
RSA_free(rsa_admin_pub);
RSA_free(rsa_publish);
RSA_free(rsa_publish_pub);
}
bool RsGenExchange::createMessage(RsNxsMsg* msg)
{
const RsGxsGroupId& id = msg->grpId;
std::map<RsGxsGroupId, RsGxsGrpMetaData*> metaMap;
metaMap.insert(std::make_pair(id, (RsGxsGrpMetaData*)(NULL)));
mDataStore->retrieveGxsGrpMetaData(metaMap);
bool ok = true;
if(!metaMap[id])
{
return false;
}
else
{
// get publish key
RsGxsGrpMetaData* meta = metaMap[id];
// public and shared is publish key
RsTlvSecurityKeySet& keys = meta->keys;
RsTlvSecurityKey* pubKey;
std::map<std::string, RsTlvSecurityKey>::iterator mit =
keys.keys.begin(), mit_end = keys.keys.end();
bool pub_key_found = false;
for(; mit != mit_end; mit++)
{
pub_key_found = mit->second.keyFlags & (RSTLV_KEY_TYPE_FULL | RSTLV_KEY_DISTRIB_PUBLIC);
if(pub_key_found)
break;
}
if(pub_key_found)
{
pubKey = &(mit->second);
RSA* rsa_pub = GxsSecurity::extractPrivateKey(*pubKey);
EVP_PKEY *key_pub = EVP_PKEY_new();
EVP_PKEY_assign_RSA(key_pub, rsa_pub);
/* calc and check signature */
EVP_MD_CTX *mdctx = EVP_MD_CTX_create();
ok = EVP_SignInit(mdctx, EVP_sha1()) == 1;
ok = EVP_SignUpdate(mdctx, msg->msg.bin_data, msg->msg.bin_len) == 1;
unsigned int siglen = EVP_PKEY_size(key_pub);
unsigned char sigbuf[siglen];
ok = EVP_SignFinal(mdctx, sigbuf, &siglen, key_pub) == 1;
RsGxsMsgMetaData &meta = *(msg->metaData);
meta.pubSign.signData.setBinData(sigbuf, siglen);
meta.pubSign.keyId = pubKey->keyId;
msg->metaData->mMsgId = msg->msgId = GxsSecurity::getBinDataSign(sigbuf, siglen);
// clean up
EVP_MD_CTX_destroy(mdctx);
EVP_PKEY_free(key_pub);
RSA_free(rsa_pub);
}
else
{
ok = false;
}
delete meta;
}
return ok;
}
@ -242,21 +393,25 @@ void RsGenExchange::notifyNewMessages(std::vector<RsNxsMsg *>& messages)
}
bool RsGenExchange::publishGroup(RsGxsGrpItem *grpItem)
bool RsGenExchange::publishGroup(uint32_t& token, RsGxsGrpItem *grpItem)
{
RsStackMutex stack(mGenMtx);
mGrpsToPublish.push_back(grpItem);
RsStackMutex stack(mGenMtx);
token = mDataAccess->generatePublicToken();
mGrpsToPublish.insert(std::make_pair(token, grpItem));
return true;
}
bool RsGenExchange::publishMsg(RsGxsMsgItem *msgItem)
bool RsGenExchange::publishMsg(uint32_t& token, RsGxsMsgItem *msgItem)
{
RsStackMutex stack(mGenMtx);
mMsgsToPublish.push_back(msgItem);
token = mDataAccess->generatePublicToken();
mMsgsToPublish.insert(std::make_pair(token, msgItem));
return true;
}
@ -265,13 +420,13 @@ void RsGenExchange::publishMsgs()
{
RsStackMutex stack(mGenMtx);
std::vector<RsGxsMsgItem*>::iterator vit = mMsgsToPublish.begin();
std::map<uint32_t, RsGxsMsgItem*>::iterator mit = mMsgsToPublish.begin();
for(; vit != mMsgsToPublish.end(); )
for(; mit != mMsgsToPublish.end(); )
{
RsNxsMsg* msg = new RsNxsMsg(mServType);
RsGxsMsgItem* msgItem = *vit;
RsGxsMsgItem* msgItem = mit->second;
uint32_t size = mSerialiser->size(msgItem);
char mData[size];
bool ok = mSerialiser->serialise(msgItem, mData, &size);
@ -280,21 +435,21 @@ void RsGenExchange::publishMsgs()
{
msg->metaData = new RsGxsMsgMetaData();
*(msg->metaData) = msgItem->meta;
ok = mDataAccess->addMsgData(msg);
ok = createMessage(msg);
if(ok)
{
RsGxsMsgChange* mc = new RsGxsMsgChange();
mNotifications.push_back(mc);
}
ok = mDataAccess->addMsgData(msg);
mMsgPublished.insert(std::make_pair(mit->first, std::make_pair(msg->grpId, msg->msgId)));
}
// if addition failed then delete nxs message
if(!ok)
{
#ifdef GEN_EXCH_DEBUG
std::cerr << "RsGenExchange::publishMsgs() failed to serialise msg " << std::endl;
std::cerr << "RsGenExchange::publishMsgs() failed to publish msg " << std::endl;
#endif
mMsgPublished.insert(std::make_pair(mit->first, std::make_pair(RsGxsGroupId(""), RsGxsMessageId(""))));
delete msg;
continue;
@ -313,13 +468,13 @@ void RsGenExchange::publishGrps()
RsStackMutex stack(mGenMtx);
std::vector<RsGxsGrpItem*>::iterator vit = mGrpsToPublish.begin();
std::map<uint32_t, RsGxsGrpItem*>::iterator mit = mGrpsToPublish.begin();
for(; vit != mGrpsToPublish.end();)
for(; mit != mGrpsToPublish.end(); mit++)
{
RsNxsGrp* grp = new RsNxsGrp(mServType);
RsGxsGrpItem* grpItem = *vit;
RsGxsGrpItem* grpItem = mit->second;
uint32_t size = mSerialiser->size(grpItem);
char gData[size];
@ -330,11 +485,18 @@ void RsGenExchange::publishGrps()
{
grp->metaData = new RsGxsGrpMetaData();
*(grp->metaData) = grpItem->meta;
createGroup(grp);
createGroup(grp);
size = grp->metaData->serial_size();
char mData[size];
ok = grp->metaData->serialise(mData, size);
grp->meta.setBinData(mData, size);
ok = mDataAccess->addGroupData(grp);
RsGxsGroupChange* gc = new RsGxsGroupChange();
gc->grpIdList.push_back(grp->grpId);
mNotifications.push_back(gc);
// add to published to allow acknowledgement
mGrpPublished.insert(std::make_pair(mit->first, grp->grpId));
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenServiceV2::GXS_REQUEST_STATUS_COMPLETE);
}
if(!ok)
@ -344,12 +506,14 @@ void RsGenExchange::publishGrps()
std::cerr << "RsGenExchange::publishGrps() failed to publish grp " << std::endl;
#endif
delete grp;
// add to published to allow acknowledgement, grpid is empty as grp creation failed
mGrpPublished.insert(std::make_pair(mit->first, RsGxsGroupId("")));
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenServiceV2::GXS_REQUEST_STATUS_FAILED);
continue;
}
delete grpItem;
vit = mGrpsToPublish.erase(vit);
}
// clear grp list as we're done publishing them and entries

View file

@ -152,6 +152,26 @@ protected:
*/
bool getMsgData(const uint32_t &token, GxsMsgDataMap& msgItems);
public:
/*!
* This allows the client service to acknowledge that their msgs has
* been created/modified and retrieve the create/modified msg ids
* @param token the token related to modification/create request
* @param msgIds map of grpid->msgIds of message created/modified
* @return true if token exists false otherwise
*/
bool acknowledgeTokenMsg(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId);
/*!
* This allows the client service to acknowledge that their grps has
* been created/modified and retrieve the create/modified grp ids
* @param token the token related to modification/create request
* @param msgIds vector of ids of groups created/modified
* @return true if token exists false otherwise
*/
bool acknowledgeTokenGrp(const uint32_t& token, RsGxsGroupId& grpId);
protected:
/** Modifications **/
@ -161,20 +181,20 @@ protected:
* If the item exists already this is simply versioned
* This will induce a related change message
* Ownership of item passes to this rsgenexchange
* @param token
* @param grpItem
* @param
*/
bool publishGroup(RsGxsGrpItem* grpItem);
bool publishGroup(uint32_t& token, RsGxsGrpItem* grpItem);
/*!
* Enables publication of a message item
* If the item exists already this is simply versioned
* This will induce a related a change message
* Ownership of item passes to this rsgenexchange
* @param token
* @param msgItem
* @return false if msg creation failed.
*/
bool publishMsg(RsGxsMsgItem* msgItem);
bool publishMsg(uint32_t& token, RsGxsMsgItem* msgItem);
protected:
@ -208,6 +228,7 @@ private:
void publishMsgs();
void createGroup(RsNxsGrp* grp);
bool createMessage(RsNxsMsg* msg);
private:
@ -220,8 +241,11 @@ private:
std::vector<RsNxsMsg*> mReceivedMsgs;
std::vector<RsNxsGrp*> mReceivedGrps;
std::vector<RsGxsGrpItem*> mGrpsToPublish;
std::vector<RsGxsMsgItem*> mMsgsToPublish;
std::map<uint32_t, RsGxsGrpItem*> mGrpsToPublish;
std::map<uint32_t, RsGxsMsgItem*> mMsgsToPublish;
std::map<uint32_t, std::pair<RsGxsGroupId, RsGxsMessageId> > mMsgPublished;
std::map<uint32_t, RsGxsGroupId> mGrpPublished;
std::vector<RsGxsNotify*> mNotifications;

View file

@ -42,6 +42,8 @@ uint32_t RsGxsGrpMetaData::serial_size()
s += 4;
s += 4;
s += GetTlvStringSize(mAuthorId);
s += GetTlvStringSize(mServiceString);
s += adminSign.TlvSize();
s += keys.TlvSize();
s += idSign.TlvSize();
@ -55,6 +57,7 @@ void RsGxsGrpMetaData::clear(){
mOrigGrpId.clear();
mAuthorId.clear();
mGroupName.clear();
mServiceString.clear();
mPublishTs = 0;
mGroupFlags = 0;
mPop = 0;
@ -98,6 +101,7 @@ bool RsGxsGrpMetaData::serialise(void *data, uint32_t &pktsize)
ok &= setRawUInt32(data, tlvsize, &offset, mGroupFlags);
ok &= setRawUInt32(data, tlvsize, &offset, mPublishTs);
ok &= SetTlvString(data, tlvsize, &offset, 0, mAuthorId);
ok &= SetTlvString(data, tlvsize, &offset, 0, mServiceString);
ok &= adminSign.SetTlv(data, tlvsize, &offset);
ok &= keys.SetTlv(data, tlvsize, &offset);
@ -124,6 +128,7 @@ bool RsGxsGrpMetaData::deserialise(void *data, uint32_t &pktsize)
ok &= getRawUInt32(data, pktsize, &offset, &mGroupFlags);
ok &= getRawUInt32(data, pktsize, &offset, &mPublishTs);
ok &= GetTlvString(data, pktsize, &offset, 0, mAuthorId);
ok &= GetTlvString(data, pktsize, &offset, 0, mServiceString);
ok &= adminSign.GetTlv(data, pktsize, &offset);
ok &= keys.GetTlv(data, pktsize, &offset);
@ -147,6 +152,7 @@ uint32_t RsGxsMsgMetaData::serial_size()
s += GetTlvStringSize(mParentId);
s += GetTlvStringSize(mOrigMsgId);
s += GetTlvStringSize(mAuthorId);
s += GetTlvStringSize(mServiceString);
s += pubSign.TlvSize();
s += idSign.TlvSize();
@ -166,6 +172,7 @@ void RsGxsMsgMetaData::clear()
mAuthorId.clear();
mOrigMsgId.clear();
mMsgName.clear();
mServiceString.clear();
pubSign.TlvClear();
idSign.TlvClear();
@ -205,6 +212,7 @@ bool RsGxsMsgMetaData::serialise(void *data, uint32_t *size)
ok &= SetTlvString(data, *size, &offset, 0, mParentId);
ok &= SetTlvString(data, *size, &offset, 0, mOrigMsgId);
ok &= SetTlvString(data, *size, &offset, 0, mAuthorId);
ok &= SetTlvString(data, *size, &offset, 0, mServiceString);
ok &= pubSign.SetTlv(data, *size, &offset);
ok &= idSign.SetTlv(data, *size, &offset);
@ -233,6 +241,7 @@ bool RsGxsMsgMetaData::deserialise(void *data, uint32_t *size)
ok &= GetTlvString(data, *size, &offset, 0, mParentId);
ok &= GetTlvString(data, *size, &offset, 0, mOrigMsgId);
ok &= GetTlvString(data, *size, &offset, 0, mAuthorId);
ok &= GetTlvString(data, *size, &offset, 0, mServiceString);
ok &= pubSign.GetTlv(data, *size, &offset);
ok &= idSign.GetTlv(data, *size, &offset);
@ -257,6 +266,7 @@ void RsGxsGrpMetaData::operator =(const RsGroupMetaData& rMeta)
this->mPublishTs = rMeta.mPublishTs;
this->mSubscribeFlags = rMeta.mSubscribeFlags;
this->mGroupName = rMeta.mGroupName;
this->mServiceString = rMeta.mServiceString;
}
void RsGxsMsgMetaData::operator =(const RsMsgMetaData& rMeta)
@ -272,6 +282,7 @@ void RsGxsMsgMetaData::operator =(const RsMsgMetaData& rMeta)
this->mParentId = rMeta.mParentId ;
this->mPublishTs = rMeta.mPublishTs ;
this->mThreadId = rMeta.mThreadId;
this->mServiceString = rMeta.mServiceString;
}

View file

@ -64,7 +64,7 @@ public:
RsTlvSecurityKeySet keys;
RsTlvKeySignature idSign;
std::string mServiceString;
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
@ -103,6 +103,8 @@ public:
RsTlvKeySignature pubSign;
RsTlvKeySignature idSign;
std::string mServiceString;
std::string mMsgName;
time_t mPublishTs;
uint32_t mMsgFlags; // Whats this for?

View file

@ -229,6 +229,14 @@ uint32_t RsGxsDataAccess::requestStatus(uint32_t token)
uint32_t reqtype;
uint32_t anstype;
time_t ts;
{
RsStackMutex stack(mDataMutex);
// first check public tokens
if(mPublicToken.find(token) != mPublicToken.end())
return mPublicToken[token];
}
checkRequestStatus(token, status, reqtype, anstype, ts);
return status;
@ -911,7 +919,8 @@ bool RsGxsDataAccess::addMsgData(RsNxsMsg* msg) {
void RsGxsDataAccess::tokenList(std::list<uint32_t>& tokens) {
void RsGxsDataAccess::tokenList(std::list<uint32_t>& tokens)
{
RsStackMutex stack(mDataMutex);
@ -924,7 +933,8 @@ void RsGxsDataAccess::tokenList(std::list<uint32_t>& tokens) {
}
bool RsGxsDataAccess::locked_updateRequestStatus(const uint32_t& token,
const uint32_t& status) {
const uint32_t& status)
{
GxsRequest* req = locked_retrieveRequest(token);
@ -936,6 +946,59 @@ bool RsGxsDataAccess::locked_updateRequestStatus(const uint32_t& token,
return true;
}
uint32_t RsGxsDataAccess::generatePublicToken()
{
uint32_t token;
generateToken(token);
{
RsStackMutex stack(mDataMutex);
mPublicToken[token] = RsTokenServiceV2::GXS_REQUEST_STATUS_PENDING;
}
return token;
}
bool RsGxsDataAccess::updatePublicRequestStatus(const uint32_t& token,
const uint32_t& status)
{
RsStackMutex stack(mDataMutex);
std::map<uint32_t, uint32_t>::iterator mit = mPublicToken.find(token);
if(mit != mPublicToken.end())
{
mit->second = status;
}
else
{
return false;
}
return true;
}
bool RsGxsDataAccess::disposeOfPublicToken(const uint32_t& token)
{
RsStackMutex stack(mDataMutex);
std::map<uint32_t, uint32_t>::iterator mit = mPublicToken.find(token);
if(mit != mPublicToken.end())
{
mPublicToken.erase(mit);
}
else
{
return false;
}
return true;
}
bool RsGxsDataAccess::checkMsgFilter(const RsTokReqOptionsV2& opts, const RsGxsMsgMetaData* meta) const
{
bool statusMatch = false;

View file

@ -104,6 +104,7 @@ public:
/** E: RsTokenService **/
public:
/*!
@ -248,6 +249,30 @@ private:
*/
void cleanseMetaFilter(MsgMetaFilter& filter);
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();
/*!
* Update
* @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 */
@ -318,6 +343,7 @@ private:
RsGeneralDataService* mDataStore;
uint32_t mNextToken;
std::map<uint32_t, uint32_t> mPublicToken;
std::map<uint32_t, GxsRequest*> mRequests;
RsMutex mDataMutex;

View file

@ -63,6 +63,7 @@
#define RS_TOKREQ_ANSTYPE_LIST 0x0001
#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002
#define RS_TOKREQ_ANSTYPE_DATA 0x0003
#define RS_TOKREQ_ANSTYPE_ACK 0x0004

View file

@ -261,7 +261,7 @@ public:
* @param album The album to be submitted
* @return false if submission failed
*/
virtual bool submitAlbumDetails(RsPhotoAlbum &album) = 0;
virtual bool submitAlbumDetails(uint32_t& token, RsPhotoAlbum &album) = 0;
/*!
* This RsGenExchange service will be alerted to this photo as \n
@ -270,7 +270,27 @@ public:
* @param photo photo to submit
* @return
*/
virtual bool submitPhoto(RsPhotoPhoto &photo) = 0;
virtual bool submitPhoto(uint32_t& token, RsPhotoPhoto &photo) = 0;
/*!
* This allows the client service to acknowledge that their msgs has
* been created/modified and retrieve the create/modified msg ids
* @param token the token related to modification/create request
* @param msgIds map of grpid->msgIds of message created/modified
* @return true if token exists false otherwise
*/
virtual bool acknowledgeMsg(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId) = 0;
/*!
* This allows the client service to acknowledge that their grps has
* been created/modified and retrieve the create/modified grp ids
* @param token the token related to modification/create request
* @param msgIds vector of ids of groups created/modified
* @return true if token exists false otherwise
*/
virtual bool acknowledgeGrp(const uint32_t& token, RsGxsGroupId& grpId) = 0;
};

View file

@ -31,7 +31,6 @@
uint32_t RsGxsPhotoSerialiser::size(RsItem* item)
{
RsGxsPhotoPhotoItem* ppItem = NULL;
RsGxsPhotoAlbumItem* paItem = NULL;

View file

@ -44,8 +44,9 @@ public:
RsGxsPhotoAlbumItem(): RsGxsGrpItem(RS_SERVICE_TYPE_PHOTO,
RS_PKT_SUBTYPE_PHOTO_ITEM) { return;}
virtual ~RsGxsPhotoAlbumItem() { return;}
virtual void clear();
void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
@ -58,8 +59,8 @@ public:
RsGxsPhotoPhotoItem(): RsGxsMsgItem(RS_SERVICE_TYPE_PHOTO,
RS_PKT_SUBTYPE_PHOTO_SHOW_ITEM) {return; }
virtual void clear();
virtual ~RsGxsPhotoPhotoItem() { return;}
void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
RsPhotoPhoto photo;
};

View file

@ -136,12 +136,12 @@ bool p3PhotoServiceV2::getPhoto(const uint32_t& token, PhotoResult& photos)
}
bool p3PhotoServiceV2::submitAlbumDetails(RsPhotoAlbum& album)
bool p3PhotoServiceV2::submitAlbumDetails(uint32_t& token, RsPhotoAlbum& album)
{
RsGxsPhotoAlbumItem* albumItem = new RsGxsPhotoAlbumItem();
albumItem->album = album;
albumItem->meta = album.mMeta;
return RsGenExchange::publishGroup(albumItem);
return RsGenExchange::publishGroup(token, albumItem);
}
@ -170,13 +170,27 @@ void p3PhotoServiceV2::notifyChanges(std::vector<RsGxsNotify*>& changes)
}
}
bool p3PhotoServiceV2::submitPhoto(RsPhotoPhoto& photo)
bool p3PhotoServiceV2::submitPhoto(uint32_t& token, RsPhotoPhoto& photo)
{
RsGxsPhotoPhotoItem* photoItem = new RsGxsPhotoPhotoItem();
photoItem->photo = photo;
photoItem->meta = photo.mMeta;
return RsGenExchange::publishMsg(photoItem);
return RsGenExchange::publishMsg(token, photoItem);
}
bool p3PhotoServiceV2::acknowledgeMsg(const uint32_t& token,
std::pair<RsGxsGroupId, RsGxsMessageId>& msgId)
{
return RsGenExchange::acknowledgeTokenMsg(token, msgId);
}
bool p3PhotoServiceV2::acknowledgeGrp(const uint32_t& token,
RsGxsGroupId& grpId)
{
return RsGenExchange::acknowledgeTokenGrp(token, grpId);
}

View file

@ -78,8 +78,26 @@ public:
/** Modifications **/
bool submitAlbumDetails(RsPhotoAlbum &album);
bool submitPhoto(RsPhotoPhoto &photo);
bool submitAlbumDetails(uint32_t& token, RsPhotoAlbum &album);
bool submitPhoto(uint32_t& token, RsPhotoPhoto &photo);
/*!
* This allows the client service to acknowledge that their msgs has
* been created/modified and retrieve the create/modified msg ids
* @param token the token related to modification/create request
* @param msgIds map of grpid->msgIds of message created/modified
* @return true if token exists false otherwise
*/
bool acknowledgeMsg(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId);
/*!
* This allows the client service to acknowledge that their grps has
* been created/modified and retrieve the create/modified grp ids
* @param token the token related to modification/create request
* @param msgIds vector of ids of groups created/modified
* @return true if token exists false otherwise
*/
bool acknowledgeGrp(const uint32_t& token, RsGxsGroupId& grpId);
private: