diff --git a/libretroshare/src/retroshare/rsidentity.h b/libretroshare/src/retroshare/rsidentity.h index 3820354c5..115de483f 100644 --- a/libretroshare/src/retroshare/rsidentity.h +++ b/libretroshare/src/retroshare/rsidentity.h @@ -64,6 +64,7 @@ #define RSGXS_MSG_STATUS_MASK 0x000f #define RSGXS_MSG_STATUS_READ 0x0001 #define RSGXS_MSG_STATUS_UNREAD_BY_USER 0x0002 +#define RSGXS_MSG_STATUS_PROCESSED 0x0004 // By the Service. @@ -94,12 +95,17 @@ class RsGroupMetaData mMsgCount = 0; mLastPost = 0; mGroupStatus = 0; + + //mPublishTs = 0; } std::string mGroupId; std::string mGroupName; uint32_t mGroupFlags; + time_t mPublishTs; // Mandatory. + std::string mAuthorId; // Optional. + // BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG. uint32_t mSubscribeFlags; diff --git a/libretroshare/src/retroshare/rsphoto.h b/libretroshare/src/retroshare/rsphoto.h index 70ccbd607..8fc78771a 100644 --- a/libretroshare/src/retroshare/rsphoto.h +++ b/libretroshare/src/retroshare/rsphoto.h @@ -47,6 +47,7 @@ class RsPhotoThumbnail RsPhotoThumbnail() :data(NULL), size(0), type("N/A") { return; } + bool deleteImage(); bool copyFrom(const RsPhotoThumbnail &nail); // Holds Thumbnail image. @@ -55,17 +56,38 @@ class RsPhotoThumbnail std::string type; }; + +/* If these flags are no set - the Photo inherits values from the Album + */ + +#define RSPHOTO_FLAGS_ATTRIB_TITLE 0x0001 +#define RSPHOTO_FLAGS_ATTRIB_CAPTION 0x0002 +#define RSPHOTO_FLAGS_ATTRIB_DESC 0x0004 +#define RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER 0x0008 +#define RSPHOTO_FLAGS_ATTRIB_WHERE 0x0010 +#define RSPHOTO_FLAGS_ATTRIB_WHEN 0x0020 +#define RSPHOTO_FLAGS_ATTRIB_OTHER 0x0040 +#define RSPHOTO_FLAGS_ATTRIB_CATEGORY 0x0080 +#define RSPHOTO_FLAGS_ATTRIB_HASHTAGS 0x0100 +#define RSPHOTO_FLAGS_ATTRIB_ORDER 0x0200 +#define RSPHOTO_FLAGS_ATTRIB_THUMBNAIL 0x0400 +#define RSPHOTO_FLAGS_ATTRIB_MODE 0x0800 +#define RSPHOTO_FLAGS_ATTRIB_AUTHOR 0x1000 // PUSH UP ORDER +#define RSPHOTO_FLAGS_ATTRIB_PHOTO 0x2000 // PUSH UP ORDER. + + class RsPhotoPhoto { public: RsMsgMetaData mMeta; + RsPhotoPhoto(); + // THESE ARE IN THE META DATA. //std::string mAlbumId; //std::string mId; //std::string mTitle; // only used by Album. - std::string mCaption; std::string mDescription; std::string mPhotographer; @@ -76,12 +98,17 @@ class RsPhotoPhoto std::string mHashTags; + uint32_t mSetFlags; + int mOrder; RsPhotoThumbnail mThumbnail; int mMode; + + // These are not saved. std::string path; // if in Mode NEW. + uint32_t mModFlags; }; class RsPhotoAlbumShare @@ -98,6 +125,7 @@ class RsPhotoAlbumShare class RsPhotoAlbum { public: + RsPhotoAlbum(); RsGroupMetaData mMeta; @@ -121,8 +149,15 @@ class RsPhotoAlbum std::string mPhotoPath; RsPhotoAlbumShare mShareOptions; + + // These aren't saved. + uint32_t mSetFlags; + uint32_t mModFlags; }; +std::ostream &operator<<(std::ostream &out, const RsPhotoPhoto &photo); +std::ostream &operator<<(std::ostream &out, const RsPhotoAlbum &album); + class RsPhoto: public RsTokenService { @@ -177,8 +212,8 @@ virtual bool getAlbum(const uint32_t &token, RsPhotoAlbum &album) = 0; virtual bool getPhoto(const uint32_t &token, RsPhotoPhoto &photo) = 0; /* details are updated in album - to choose Album ID, and storage path */ -virtual bool submitAlbumDetails(RsPhotoAlbum &album) = 0; -virtual bool submitPhoto(RsPhotoPhoto &photo) = 0; +virtual bool submitAlbumDetails(RsPhotoAlbum &album, bool isNew) = 0; +virtual bool submitPhoto(RsPhotoPhoto &photo, bool isNew) = 0; }; diff --git a/libretroshare/src/services/p3gxsservice.cc b/libretroshare/src/services/p3gxsservice.cc index 27ee1e7c1..ca741bc8c 100644 --- a/libretroshare/src/services/p3gxsservice.cc +++ b/libretroshare/src/services/p3gxsservice.cc @@ -379,43 +379,104 @@ bool GxsDataProxy::getMsgList( uint32_t &token, const RsTokReqOptions &opt * 1) No Flags => All Messages in those Groups. * */ + std::cerr << "GxsDataProxy::getMsgList()"; + std::cerr << std::endl; + bool onlyOrigMsgs = false; + bool onlyLatestMsgs = false; + // Can only choose one of these two. if (opts.mOptions & RS_TOKREQOPT_MSG_ORIGMSG) { onlyOrigMsgs = true; } + else if (opts.mOptions & RS_TOKREQOPT_MSG_LATEST) + { + std::cerr << "GxsDataProxy::getMsgList() REQUESTED LATEST!!!"; + std::cerr << std::endl; - std::cerr << "GxsDataProxy::getMsgList()"; - std::cerr << std::endl; + onlyLatestMsgs = true; + } std::list::const_iterator it; std::map::iterator mit; for(it = groupIds.begin(); it != groupIds.end(); it++) { - for(mit = mMsgMetaData.begin(); mit != mMsgMetaData.end(); mit++) + if (onlyLatestMsgs) // THIS ONE IS HARD -> LOTS OF COMP. { - if (mit->second.mGroupId == *it) + // RUN THROUGH ALL MSGS... in map origId -> TS. + std::map > origMsgTs; + std::map >::iterator oit; + for(mit = mMsgMetaData.begin(); mit != mMsgMetaData.end(); mit++) { - bool add = false; - - if (onlyOrigMsgs) + if (mit->second.mGroupId != *it) { - if (mit->second.mMsgId == mit->second.mOrigMsgId) + continue; + } + + oit = origMsgTs.find(mit->second.mOrigMsgId); + bool addMsg = false; + if (oit == origMsgTs.end()) + { + std::cerr << "GxsDataProxy::getMsgList() Found New OrigMsgId: "; + std::cerr << mit->second.mOrigMsgId; + std::cerr << " MsgId: " << mit->second.mMsgId; + std::cerr << " TS: " << mit->second.mPublishTs; + std::cerr << std::endl; + + addMsg = true; + } + // check timestamps. + else if (oit->second.second < mit->second.mPublishTs) + { + std::cerr << "GxsDataProxy::getMsgList() Found Later Msg. OrigMsgId: "; + std::cerr << mit->second.mOrigMsgId; + std::cerr << " MsgId: " << mit->second.mMsgId; + std::cerr << " TS: " << mit->second.mPublishTs; + + addMsg = true; + } + + if (addMsg) + { + // add as latest. (overwriting if necessary) + origMsgTs[mit->second.mOrigMsgId] = std::make_pair(mit->second.mMsgId, mit->second.mPublishTs); + } + } + + // Add the discovered Latest Msgs. + for(oit = origMsgTs.begin(); oit != origMsgTs.end(); oit++) + { + outMsgIds.push_back(oit->second.first); + } + + } + else // ALL OTHER CASES. + { + for(mit = mMsgMetaData.begin(); mit != mMsgMetaData.end(); mit++) + { + if (mit->second.mGroupId == *it) + { + bool add = false; + + if (onlyOrigMsgs) { + if (mit->second.mMsgId == mit->second.mOrigMsgId) + { + add = true; + } + } + else + { add = true; } - } - else - { - add = true; - } - - if (add) - { - outMsgIds.push_back(mit->first); + + if (add) + { + outMsgIds.push_back(mit->first); + } } } } diff --git a/libretroshare/src/services/p3photoservice.cc b/libretroshare/src/services/p3photoservice.cc index c44b6c53b..19624c027 100644 --- a/libretroshare/src/services/p3photoservice.cc +++ b/libretroshare/src/services/p3photoservice.cc @@ -384,7 +384,7 @@ bool p3PhotoService::groupShareKeys(const std::string &groupId, std::list& /* details are updated in album - to choose Album ID, and storage path */ -virtual bool submitAlbumDetails(RsPhotoAlbum &album); -virtual bool submitPhoto(RsPhotoPhoto &photo); +virtual bool submitAlbumDetails(RsPhotoAlbum &album, bool isNew); +virtual bool submitPhoto(RsPhotoPhoto &photo, bool isNew);