fixup serialisation and indentation

This commit is contained in:
drbob 2020-02-15 11:39:29 +11:00
parent d04518fd55
commit 1baa92f60c
2 changed files with 272 additions and 277 deletions

View file

@ -26,88 +26,83 @@
#include "serialiser/rstlvbinary.h" #include "serialiser/rstlvbinary.h"
#include "serialiser/rstypeserializer.h" #include "serialiser/rstypeserializer.h"
#define GXS_PHOTO_SERIAL_DEBUG
RsItem *RsGxsPhotoSerialiser::create_item(uint16_t service, uint8_t item_sub_id) const RsItem *RsGxsPhotoSerialiser::create_item(uint16_t service, uint8_t item_sub_id) const
{ {
if(service != RS_SERVICE_GXS_TYPE_PHOTO) if(service != RS_SERVICE_GXS_TYPE_PHOTO)
return NULL ; return NULL ;
switch(item_sub_id) switch(item_sub_id)
{ {
case RS_PKT_SUBTYPE_PHOTO_COMMENT_ITEM: return new RsGxsPhotoCommentItem() ; case RS_PKT_SUBTYPE_PHOTO_COMMENT_ITEM: return new RsGxsPhotoCommentItem() ;
case RS_PKT_SUBTYPE_PHOTO_SHOW_ITEM: return new RsGxsPhotoPhotoItem() ; case RS_PKT_SUBTYPE_PHOTO_SHOW_ITEM: return new RsGxsPhotoPhotoItem() ;
case RS_PKT_SUBTYPE_PHOTO_ITEM: return new RsGxsPhotoAlbumItem() ; case RS_PKT_SUBTYPE_PHOTO_ITEM: return new RsGxsPhotoAlbumItem() ;
default: default:
return NULL ; return NULL ;
} }
} }
void RsGxsPhotoAlbumItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) void RsGxsPhotoAlbumItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{ {
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_CAPTION, album.mCaption, "mCaption"); RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_CAPTION, album.mCaption, "mCaption");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_CATEGORY, album.mCategory, "mCategory"); RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_CATEGORY, album.mCategory, "mCategory");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR, album.mDescription, "mDescription"); RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR, album.mDescription, "mDescription");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_HASH_TAG, album.mHashTags, "mHashTags"); RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_HASH_TAG, album.mHashTags, "mHashTags");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG, album.mOther, "mOther"); RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG, album.mOther, "mOther");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_PATH, album.mPhotoPath, "mPhotoPath"); RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_PATH, album.mPhotoPath, "mPhotoPath");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME, album.mPhotographer, "mPhotographer"); RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME, album.mPhotographer, "mPhotographer");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DATE, album.mWhen, "mWhen"); RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DATE, album.mWhen, "mWhen");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_LOCATION, album.mWhere, "mWhere"); RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_LOCATION, album.mWhere, "mWhere");
RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, album.mThumbnail.mData, album.mThumbnail.mSize); album.mThumbnail.serial_process(j, ctx);
RsTypeSerializer::serial_process<RsTlvItem>(j, ctx, b, "mThumbnail") ;
} }
void RsGxsPhotoPhotoItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) void RsGxsPhotoPhotoItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{ {
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CAPTION, photo.mCaption, "mCaption"); RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CAPTION, photo.mCaption, "mCaption");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CATEGORY, photo.mCategory, "mCategory"); RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CATEGORY, photo.mCategory, "mCategory");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DESCR, photo.mDescription, "mDescription"); RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DESCR, photo.mDescription, "mDescription");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_HASH_TAG, photo.mHashTags, "mHashTags"); RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_HASH_TAG, photo.mHashTags, "mHashTags");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_MSG, photo.mOther, "mOther"); RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_MSG, photo.mOther, "mOther");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_PIC_AUTH, photo.mPhotographer, "mPhotographer"); RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_PIC_AUTH, photo.mPhotographer, "mPhotographer");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DATE, photo.mWhen, "mWhen"); RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DATE, photo.mWhen, "mWhen");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_LOCATION, photo.mWhere, "mWhere"); RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_LOCATION, photo.mWhere, "mWhere");
RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, photo.mThumbnail.mData, photo.mThumbnail.mSize); photo.mThumbnail.serial_process(j, ctx);
RsTypeSerializer::serial_process<RsTlvItem>(j, ctx, b, "mThumbnail") ;
} }
void RsGxsPhotoCommentItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) void RsGxsPhotoCommentItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{ {
RsTypeSerializer::serial_process (j,ctx,TLV_TYPE_STR_COMMENT,comment.mComment,"mComment"); RsTypeSerializer::serial_process (j,ctx,TLV_TYPE_STR_COMMENT,comment.mComment,"mComment");
RsTypeSerializer::serial_process<uint32_t>(j,ctx,comment.mCommentFlag,"mCommentFlag"); RsTypeSerializer::serial_process<uint32_t>(j,ctx,comment.mCommentFlag,"mCommentFlag");
} }
void RsGxsPhotoAlbumItem::clear() void RsGxsPhotoAlbumItem::clear()
{ {
album.mCaption.clear(); album.mCaption.clear();
album.mCategory.clear(); album.mCategory.clear();
album.mDescription.clear(); album.mDescription.clear();
album.mHashTags.clear(); album.mHashTags.clear();
album.mOther.clear(); album.mOther.clear();
album.mPhotoPath.clear(); album.mPhotoPath.clear();
album.mPhotographer.clear(); album.mPhotographer.clear();
album.mWhen.clear(); album.mWhen.clear();
album.mWhere.clear(); album.mWhere.clear();
album.mThumbnail.clear(); album.mThumbnail.clear();
} }
void RsGxsPhotoCommentItem::clear() void RsGxsPhotoCommentItem::clear()
{ {
comment.mComment.clear(); comment.mComment.clear();
comment.mCommentFlag = 0; comment.mCommentFlag = 0;
} }
void RsGxsPhotoPhotoItem::clear() void RsGxsPhotoPhotoItem::clear()
{ {
photo.mCaption.clear(); photo.mCaption.clear();
photo.mCategory.clear(); photo.mCategory.clear();
photo.mDescription.clear(); photo.mDescription.clear();
photo.mHashTags.clear(); photo.mHashTags.clear();
photo.mOther.clear(); photo.mOther.clear();
photo.mPhotographer.clear(); photo.mPhotographer.clear();
photo.mWhen.clear(); photo.mWhen.clear();
photo.mWhere.clear(); photo.mWhere.clear();
photo.mThumbnail.clear(); photo.mThumbnail.clear();
} }

View file

@ -1,23 +1,23 @@
/******************************************************************************* /*******************************************************************************
* libretroshare/src/services: p3photoservice.cc * * libretroshare/src/services: p3photoservice.cc *
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2008-2012 Robert Fernie,Chris Evi-Parker <retroshare@lunamutt.com>* * Copyright 2008-2012 Robert Fernie,Chris Evi-Parker <retroshare@lunamutt.com>*
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the * * published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. * * License, or (at your option) any later version. *
* * * *
* This program is distributed in the hope that it will be useful, * * This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
* You should have received a copy of the GNU Lesser General Public License * * You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. * * along with this program. If not, see <https://www.gnu.org/licenses/>. *
* * * *
*******************************************************************************/ *******************************************************************************/
#include "p3photoservice.h" #include "p3photoservice.h"
#include "rsitems/rsphotoitems.h" #include "rsitems/rsphotoitems.h"
@ -26,100 +26,100 @@
RsPhoto *rsPhoto = NULL; RsPhoto *rsPhoto = NULL;
const uint32_t RsPhoto::FLAG_MSG_TYPE_MASK = 0x000f; const uint32_t RsPhoto::FLAG_MSG_TYPE_MASK = 0x000f;
const uint32_t RsPhoto::FLAG_MSG_TYPE_PHOTO_POST = 0x0001; const uint32_t RsPhoto::FLAG_MSG_TYPE_PHOTO_POST = 0x0001;
const uint32_t RsPhoto::FLAG_MSG_TYPE_PHOTO_COMMENT = 0x0002; const uint32_t RsPhoto::FLAG_MSG_TYPE_PHOTO_COMMENT = 0x0002;
RsPhotoPhoto::RsPhotoPhoto() RsPhotoPhoto::RsPhotoPhoto()
:mSetFlags(0), mOrder(0), mMode(0), mModFlags(0) :mSetFlags(0), mOrder(0), mMode(0), mModFlags(0)
{ {
return; return;
} }
RsPhotoAlbum::RsPhotoAlbum() RsPhotoAlbum::RsPhotoAlbum()
:mMode(0), mSetFlags(0), mModFlags(0) :mMode(0), mSetFlags(0), mModFlags(0)
{ {
return; return;
} }
RsPhotoComment::RsPhotoComment() RsPhotoComment::RsPhotoComment()
: mComment(""), mCommentFlag(0) { : mComment(""), mCommentFlag(0) {
} }
RsPhotoComment::RsPhotoComment(const RsGxsPhotoCommentItem &comment) RsPhotoComment::RsPhotoComment(const RsGxsPhotoCommentItem &comment)
: mComment(""), mCommentFlag(0) { : mComment(""), mCommentFlag(0) {
*this = comment.comment; *this = comment.comment;
(*this).mMeta = comment.meta; (*this).mMeta = comment.meta;
} }
std::ostream &operator<<(std::ostream &out, const RsPhotoPhoto &photo) std::ostream &operator<<(std::ostream &out, const RsPhotoPhoto &photo)
{ {
out << "RsPhotoPhoto [ "; out << "RsPhotoPhoto [ ";
out << "Title: " << photo.mMeta.mMsgName; out << "Title: " << photo.mMeta.mMsgName;
out << "]"; out << "]";
return out; return out;
} }
std::ostream &operator<<(std::ostream &out, const RsPhotoAlbum &album) std::ostream &operator<<(std::ostream &out, const RsPhotoAlbum &album)
{ {
out << "RsPhotoAlbum [ "; out << "RsPhotoAlbum [ ";
out << "Title: " << album.mMeta.mGroupName; out << "Title: " << album.mMeta.mGroupName;
out << "]"; out << "]";
return out; return out;
} }
p3PhotoService::p3PhotoService(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs) p3PhotoService::p3PhotoService(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs)
: RsGenExchange(gds, nes, new RsGxsPhotoSerialiser(), RS_SERVICE_GXS_TYPE_PHOTO, gixs, photoAuthenPolicy()), : RsGenExchange(gds, nes, new RsGxsPhotoSerialiser(), RS_SERVICE_GXS_TYPE_PHOTO, gixs, photoAuthenPolicy()),
mPhotoMutex(std::string("Photo Mutex")) mPhotoMutex(std::string("Photo Mutex"))
{ {
} }
const std::string GXS_PHOTO_APP_NAME = "gxsphoto"; const std::string GXS_PHOTO_APP_NAME = "gxsphoto";
const uint16_t GXS_PHOTO_APP_MAJOR_VERSION = 1; const uint16_t GXS_PHOTO_APP_MAJOR_VERSION = 1;
const uint16_t GXS_PHOTO_APP_MINOR_VERSION = 0; const uint16_t GXS_PHOTO_APP_MINOR_VERSION = 0;
const uint16_t GXS_PHOTO_MIN_MAJOR_VERSION = 1; const uint16_t GXS_PHOTO_MIN_MAJOR_VERSION = 1;
const uint16_t GXS_PHOTO_MIN_MINOR_VERSION = 0; const uint16_t GXS_PHOTO_MIN_MINOR_VERSION = 0;
RsServiceInfo p3PhotoService::getServiceInfo() RsServiceInfo p3PhotoService::getServiceInfo()
{ {
return RsServiceInfo(RS_SERVICE_GXS_TYPE_PHOTO, return RsServiceInfo(RS_SERVICE_GXS_TYPE_PHOTO,
GXS_PHOTO_APP_NAME, GXS_PHOTO_APP_NAME,
GXS_PHOTO_APP_MAJOR_VERSION, GXS_PHOTO_APP_MAJOR_VERSION,
GXS_PHOTO_APP_MINOR_VERSION, GXS_PHOTO_APP_MINOR_VERSION,
GXS_PHOTO_MIN_MAJOR_VERSION, GXS_PHOTO_MIN_MAJOR_VERSION,
GXS_PHOTO_MIN_MINOR_VERSION); GXS_PHOTO_MIN_MINOR_VERSION);
} }
uint32_t p3PhotoService::photoAuthenPolicy() uint32_t p3PhotoService::photoAuthenPolicy()
{ {
uint32_t policy = 0; uint32_t policy = 0;
uint8_t flag = 0; uint8_t flag = 0;
flag = GXS_SERV::MSG_AUTHEN_ROOT_PUBLISH_SIGN | GXS_SERV::MSG_AUTHEN_CHILD_AUTHOR_SIGN; flag = GXS_SERV::MSG_AUTHEN_ROOT_PUBLISH_SIGN | GXS_SERV::MSG_AUTHEN_CHILD_AUTHOR_SIGN;
RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::PUBLIC_GRP_BITS); RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::PUBLIC_GRP_BITS);
flag |= GXS_SERV::MSG_AUTHEN_CHILD_PUBLISH_SIGN; flag |= GXS_SERV::MSG_AUTHEN_CHILD_PUBLISH_SIGN;
RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::RESTRICTED_GRP_BITS); RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::RESTRICTED_GRP_BITS);
RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::PRIVATE_GRP_BITS); RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::PRIVATE_GRP_BITS);
flag = GXS_SERV::GRP_OPTION_AUTHEN_AUTHOR_SIGN; flag = GXS_SERV::GRP_OPTION_AUTHEN_AUTHOR_SIGN;
RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::GRP_OPTION_BITS); RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::GRP_OPTION_BITS);
return policy; return policy;
} }
bool p3PhotoService::updated() bool p3PhotoService::updated()
{ {
RsStackMutex stack(mPhotoMutex); RsStackMutex stack(mPhotoMutex);
bool changed = (!mGroupChange.empty() || !mMsgChange.empty()); bool changed = (!mGroupChange.empty() || !mMsgChange.empty());
return changed; return changed;
} }
void p3PhotoService::service_tick() void p3PhotoService::service_tick()
@ -131,197 +131,197 @@ void p3PhotoService::service_tick()
void p3PhotoService::groupsChanged(std::list<RsGxsGroupId>& grpIds) void p3PhotoService::groupsChanged(std::list<RsGxsGroupId>& grpIds)
{ {
RsStackMutex stack(mPhotoMutex); RsStackMutex stack(mPhotoMutex);
while(!mGroupChange.empty()) while(!mGroupChange.empty())
{ {
RsGxsGroupChange* gc = mGroupChange.back(); RsGxsGroupChange* gc = mGroupChange.back();
std::list<RsGxsGroupId>& gList = gc->mGrpIdList; std::list<RsGxsGroupId>& gList = gc->mGrpIdList;
std::list<RsGxsGroupId>::iterator lit = gList.begin(); std::list<RsGxsGroupId>::iterator lit = gList.begin();
for(; lit != gList.end(); ++lit) { for(; lit != gList.end(); ++lit) {
grpIds.push_back(*lit); grpIds.push_back(*lit);
} }
mGroupChange.pop_back(); mGroupChange.pop_back();
delete gc; delete gc;
} }
} }
void p3PhotoService::msgsChanged(GxsMsgIdResult& msgs) void p3PhotoService::msgsChanged(GxsMsgIdResult& msgs)
{ {
RsStackMutex stack(mPhotoMutex); RsStackMutex stack(mPhotoMutex);
while(!mMsgChange.empty()) while(!mMsgChange.empty())
{ {
RsGxsMsgChange* mc = mMsgChange.back(); RsGxsMsgChange* mc = mMsgChange.back();
msgs = mc->msgChangeMap; msgs = mc->msgChangeMap;
mMsgChange.pop_back(); mMsgChange.pop_back();
delete mc; delete mc;
} }
} }
RsTokenService* p3PhotoService::getTokenService() { RsTokenService* p3PhotoService::getTokenService() {
return RsGenExchange::getTokenService(); return RsGenExchange::getTokenService();
} }
bool p3PhotoService::getGroupList(const uint32_t& token, bool p3PhotoService::getGroupList(const uint32_t& token,
std::list<RsGxsGroupId>& groupIds) std::list<RsGxsGroupId>& groupIds)
{ {
bool okay = RsGenExchange::getGroupList(token, groupIds); bool okay = RsGenExchange::getGroupList(token, groupIds);
return okay; return okay;
} }
bool p3PhotoService::getMsgList(const uint32_t& token, bool p3PhotoService::getMsgList(const uint32_t& token,
GxsMsgIdResult& msgIds) GxsMsgIdResult& msgIds)
{ {
return RsGenExchange::getMsgList(token, msgIds); return RsGenExchange::getMsgList(token, msgIds);
} }
bool p3PhotoService::getGroupSummary(const uint32_t& token, bool p3PhotoService::getGroupSummary(const uint32_t& token,
std::list<RsGroupMetaData>& groupInfo) std::list<RsGroupMetaData>& groupInfo)
{ {
bool okay = RsGenExchange::getGroupMeta(token, groupInfo); bool okay = RsGenExchange::getGroupMeta(token, groupInfo);
return okay; return okay;
} }
bool p3PhotoService::getMsgSummary(const uint32_t& token, bool p3PhotoService::getMsgSummary(const uint32_t& token,
MsgMetaResult& msgInfo) MsgMetaResult& msgInfo)
{ {
return RsGenExchange::getMsgMeta(token, msgInfo); return RsGenExchange::getMsgMeta(token, msgInfo);
} }
bool p3PhotoService::getAlbum(const uint32_t& token, std::vector<RsPhotoAlbum>& albums) bool p3PhotoService::getAlbum(const uint32_t& token, std::vector<RsPhotoAlbum>& albums)
{ {
std::vector<RsGxsGrpItem*> grpData; std::vector<RsGxsGrpItem*> grpData;
bool ok = RsGenExchange::getGroupData(token, grpData); bool ok = RsGenExchange::getGroupData(token, grpData);
if(ok) if(ok)
{ {
std::vector<RsGxsGrpItem*>::iterator vit = grpData.begin(); std::vector<RsGxsGrpItem*>::iterator vit = grpData.begin();
for(; vit != grpData.end(); ++vit) for(; vit != grpData.end(); ++vit)
{ {
RsGxsPhotoAlbumItem* item = dynamic_cast<RsGxsPhotoAlbumItem*>(*vit); RsGxsPhotoAlbumItem* item = dynamic_cast<RsGxsPhotoAlbumItem*>(*vit);
if (item) if (item)
{ {
RsPhotoAlbum album = item->album; RsPhotoAlbum album = item->album;
item->album.mMeta = item->meta; item->album.mMeta = item->meta;
album.mMeta = item->album.mMeta; album.mMeta = item->album.mMeta;
delete item; delete item;
albums.push_back(album); albums.push_back(album);
} }
else else
{ {
std::cerr << "Not a RsGxsPhotoAlbumItem, deleting!" << std::endl; std::cerr << "Not a RsGxsPhotoAlbumItem, deleting!" << std::endl;
delete *vit; delete *vit;
} }
} }
} }
return ok; return ok;
} }
bool p3PhotoService::getPhoto(const uint32_t& token, PhotoResult& photos) bool p3PhotoService::getPhoto(const uint32_t& token, PhotoResult& photos)
{ {
GxsMsgDataMap msgData; GxsMsgDataMap msgData;
bool ok = RsGenExchange::getMsgData(token, msgData); bool ok = RsGenExchange::getMsgData(token, msgData);
if(ok) if(ok)
{ {
GxsMsgDataMap::iterator mit = msgData.begin(); GxsMsgDataMap::iterator mit = msgData.begin();
for(; mit != msgData.end(); ++mit) for(; mit != msgData.end(); ++mit)
{ {
RsGxsGroupId grpId = mit->first; RsGxsGroupId grpId = mit->first;
std::vector<RsGxsMsgItem*>& msgItems = mit->second; std::vector<RsGxsMsgItem*>& msgItems = mit->second;
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin(); std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
for(; vit != msgItems.end(); ++vit) for(; vit != msgItems.end(); ++vit)
{ {
RsGxsPhotoPhotoItem* item = dynamic_cast<RsGxsPhotoPhotoItem*>(*vit); RsGxsPhotoPhotoItem* item = dynamic_cast<RsGxsPhotoPhotoItem*>(*vit);
if(item) if(item)
{ {
RsPhotoPhoto photo = item->photo; RsPhotoPhoto photo = item->photo;
photo.mMeta = item->meta; photo.mMeta = item->meta;
photos[grpId].push_back(photo); photos[grpId].push_back(photo);
delete item; delete item;
}else }else
{ {
std::cerr << "Not a photo Item, deleting!" << std::endl; std::cerr << "Not a photo Item, deleting!" << std::endl;
delete *vit; delete *vit;
} }
} }
} }
} }
return ok; return ok;
} }
bool p3PhotoService::getPhotoComment(const uint32_t &token, PhotoCommentResult &comments) bool p3PhotoService::getPhotoComment(const uint32_t &token, PhotoCommentResult &comments)
{ {
GxsMsgDataMap msgData; GxsMsgDataMap msgData;
bool ok = RsGenExchange::getMsgData(token, msgData); bool ok = RsGenExchange::getMsgData(token, msgData);
if(ok) if(ok)
{ {
GxsMsgDataMap::iterator mit = msgData.begin(); GxsMsgDataMap::iterator mit = msgData.begin();
for(; mit != msgData.end(); ++mit) for(; mit != msgData.end(); ++mit)
{ {
RsGxsGroupId grpId = mit->first; RsGxsGroupId grpId = mit->first;
std::vector<RsGxsMsgItem*>& msgItems = mit->second; std::vector<RsGxsMsgItem*>& msgItems = mit->second;
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin(); std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
for(; vit != msgItems.end(); ++vit) for(; vit != msgItems.end(); ++vit)
{ {
RsGxsPhotoCommentItem* item = dynamic_cast<RsGxsPhotoCommentItem*>(*vit); RsGxsPhotoCommentItem* item = dynamic_cast<RsGxsPhotoCommentItem*>(*vit);
if(item) if(item)
{ {
RsPhotoComment comment = item->comment; RsPhotoComment comment = item->comment;
comment.mMeta = item->meta; comment.mMeta = item->meta;
comments[grpId].push_back(comment); comments[grpId].push_back(comment);
delete item; delete item;
}else }else
{ {
std::cerr << "Not a comment Item, deleting!" << std::endl; std::cerr << "Not a comment Item, deleting!" << std::endl;
delete *vit; delete *vit;
} }
} }
} }
} }
return ok; return ok;
} }
RsPhotoComment& RsPhotoComment::operator=(const RsGxsPhotoCommentItem& comment) RsPhotoComment& RsPhotoComment::operator=(const RsGxsPhotoCommentItem& comment)
{ {
*this = comment.comment; *this = comment.comment;
return *this; return *this;
} }
bool p3PhotoService::getPhotoRelatedComment(const uint32_t &token, PhotoRelatedCommentResult &comments) bool p3PhotoService::getPhotoRelatedComment(const uint32_t &token, PhotoRelatedCommentResult &comments)
{ {
return RsGenExchange::getMsgRelatedDataT<RsGxsPhotoCommentItem, RsPhotoComment>(token, comments); return RsGenExchange::getMsgRelatedDataT<RsGxsPhotoCommentItem, RsPhotoComment>(token, comments);
} }
bool p3PhotoService::submitAlbumDetails(uint32_t& token, RsPhotoAlbum& album) bool p3PhotoService::submitAlbumDetails(uint32_t& token, RsPhotoAlbum& album)
{ {
RsGxsPhotoAlbumItem* albumItem = new RsGxsPhotoAlbumItem(); RsGxsPhotoAlbumItem* albumItem = new RsGxsPhotoAlbumItem();
albumItem->album = album; albumItem->album = album;
albumItem->meta = album.mMeta; albumItem->meta = album.mMeta;
RsGenExchange::publishGroup(token, albumItem); RsGenExchange::publishGroup(token, albumItem);
return true; return true;
} }
@ -329,72 +329,72 @@ bool p3PhotoService::submitAlbumDetails(uint32_t& token, RsPhotoAlbum& album)
void p3PhotoService::notifyChanges(std::vector<RsGxsNotify*>& changes) void p3PhotoService::notifyChanges(std::vector<RsGxsNotify*>& changes)
{ {
RsStackMutex stack(mPhotoMutex); RsStackMutex stack(mPhotoMutex);
std::vector<RsGxsNotify*>::iterator vit = changes.begin(); std::vector<RsGxsNotify*>::iterator vit = changes.begin();
for(; vit != changes.end(); ++vit) for(; vit != changes.end(); ++vit)
{ {
RsGxsNotify* n = *vit; RsGxsNotify* n = *vit;
RsGxsGroupChange* gc; RsGxsGroupChange* gc;
RsGxsMsgChange* mc; RsGxsMsgChange* mc;
if((mc = dynamic_cast<RsGxsMsgChange*>(n)) != NULL) if((mc = dynamic_cast<RsGxsMsgChange*>(n)) != NULL)
{ {
mMsgChange.push_back(mc); mMsgChange.push_back(mc);
} }
else if((gc = dynamic_cast<RsGxsGroupChange*>(n)) != NULL) else if((gc = dynamic_cast<RsGxsGroupChange*>(n)) != NULL)
{ {
mGroupChange.push_back(gc); mGroupChange.push_back(gc);
} }
else else
{ {
delete n; delete n;
} }
} }
} }
bool p3PhotoService::submitPhoto(uint32_t& token, RsPhotoPhoto& photo) bool p3PhotoService::submitPhoto(uint32_t& token, RsPhotoPhoto& photo)
{ {
RsGxsPhotoPhotoItem* photoItem = new RsGxsPhotoPhotoItem(); RsGxsPhotoPhotoItem* photoItem = new RsGxsPhotoPhotoItem();
photoItem->photo = photo; photoItem->photo = photo;
photoItem->meta = photo.mMeta; photoItem->meta = photo.mMeta;
RsGenExchange::publishMsg(token, photoItem); RsGenExchange::publishMsg(token, photoItem);
return true; return true;
} }
bool p3PhotoService::submitComment(uint32_t &token, RsPhotoComment &comment) bool p3PhotoService::submitComment(uint32_t &token, RsPhotoComment &comment)
{ {
RsGxsPhotoCommentItem* commentItem = new RsGxsPhotoCommentItem(); RsGxsPhotoCommentItem* commentItem = new RsGxsPhotoCommentItem();
commentItem->comment = comment; commentItem->comment = comment;
commentItem->meta = comment.mMeta; commentItem->meta = comment.mMeta;
commentItem->meta.mMsgFlags = FLAG_MSG_TYPE_PHOTO_COMMENT; commentItem->meta.mMsgFlags = FLAG_MSG_TYPE_PHOTO_COMMENT;
RsGenExchange::publishMsg(token, commentItem); RsGenExchange::publishMsg(token, commentItem);
return true; return true;
} }
bool p3PhotoService::acknowledgeMsg(const uint32_t& token, bool p3PhotoService::acknowledgeMsg(const uint32_t& token,
std::pair<RsGxsGroupId, RsGxsMessageId>& msgId) std::pair<RsGxsGroupId, RsGxsMessageId>& msgId)
{ {
return RsGenExchange::acknowledgeTokenMsg(token, msgId); return RsGenExchange::acknowledgeTokenMsg(token, msgId);
} }
bool p3PhotoService::acknowledgeGrp(const uint32_t& token, bool p3PhotoService::acknowledgeGrp(const uint32_t& token,
RsGxsGroupId& grpId) RsGxsGroupId& grpId)
{ {
return RsGenExchange::acknowledgeTokenGrp(token, grpId); return RsGenExchange::acknowledgeTokenGrp(token, grpId);
} }
bool p3PhotoService::subscribeToAlbum(uint32_t &token, const RsGxsGroupId &grpId, bool subscribe) bool p3PhotoService::subscribeToAlbum(uint32_t &token, const RsGxsGroupId &grpId, bool subscribe)
{ {
if(subscribe) if(subscribe)
RsGenExchange::setGroupSubscribeFlags(token, grpId, GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED, GXS_SERV::GROUP_SUBSCRIBE_MASK); RsGenExchange::setGroupSubscribeFlags(token, grpId, GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED, GXS_SERV::GROUP_SUBSCRIBE_MASK);
else else
RsGenExchange::setGroupSubscribeFlags(token, grpId, 0, GXS_SERV::GROUP_SUBSCRIBE_MASK); RsGenExchange::setGroupSubscribeFlags(token, grpId, 0, GXS_SERV::GROUP_SUBSCRIBE_MASK);
return true; return true;
} }