mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
Improvements to the photoservice & underlying GS test service.
- added PublishTS and AuthorID to GropuMetaData. - added Mod & Set Flags to PhotoData. (mainly for the GUI). - added "isNew" parameter to sumbitPhoto/Album calls. - support modifications to Photos. - improved Photo Thumbnail handling. (still not right). - added LATEST msg search in GxsService. - added ATTRIB flags to rsphoto.h git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@5238 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7a22d4fe69
commit
8af268e8c8
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
@ -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<std::string>::const_iterator it;
|
||||
std::map<std::string, RsMsgMetaData>::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<std::string, std::pair<std::string, uint32_t> > origMsgTs;
|
||||
std::map<std::string, std::pair<std::string, uint32_t> >::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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ bool p3PhotoService::groupShareKeys(const std::string &groupId, std::list<std::s
|
||||
|
||||
|
||||
/* details are updated in album - to choose Album ID, and storage path */
|
||||
bool p3PhotoService::submitAlbumDetails(RsPhotoAlbum &album)
|
||||
bool p3PhotoService::submitAlbumDetails(RsPhotoAlbum &album, bool isNew)
|
||||
{
|
||||
/* check if its a modification or a new album */
|
||||
|
||||
@ -397,8 +397,15 @@ bool p3PhotoService::submitAlbumDetails(RsPhotoAlbum &album)
|
||||
|
||||
/* generate a temp id */
|
||||
album.mMeta.mGroupId = genRandomId();
|
||||
// TODO.
|
||||
//album.mMeta.mPublishTs = time(NULL);
|
||||
|
||||
std::cerr << "p3PhotoService::submitAlbumDetails() Generated New GroupID: " << album.mMeta.mGroupId;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
album.mModFlags = 0; // These are always cleared.
|
||||
|
||||
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
mUpdated = true;
|
||||
@ -410,7 +417,7 @@ bool p3PhotoService::submitAlbumDetails(RsPhotoAlbum &album)
|
||||
}
|
||||
|
||||
|
||||
bool p3PhotoService::submitPhoto(RsPhotoPhoto &photo)
|
||||
bool p3PhotoService::submitPhoto(RsPhotoPhoto &photo, bool isNew)
|
||||
{
|
||||
if (photo.mMeta.mGroupId.empty())
|
||||
{
|
||||
@ -420,14 +427,28 @@ bool p3PhotoService::submitPhoto(RsPhotoPhoto &photo)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check if its a mod or new photo */
|
||||
if (photo.mMeta.mMsgId.empty())
|
||||
{
|
||||
/* new photo */
|
||||
/* generate a new id */
|
||||
photo.mMeta.mMsgId = genRandomId();
|
||||
photo.mMeta.mPublishTs = time(NULL);
|
||||
|
||||
/* generate a temp id */
|
||||
photo.mMeta.mMsgId = genRandomId();
|
||||
if (isNew)
|
||||
{
|
||||
/* new (Original Msg) photo */
|
||||
photo.mMeta.mOrigMsgId = photo.mMeta.mMsgId;
|
||||
std::cerr << "p3PhotoService::submitPhoto() New Msg";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "p3PhotoService::submitPhoto() Updated Msg";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
photo.mModFlags = 0; // These are always cleared.
|
||||
|
||||
std::cerr << "p3PhotoService::submitPhoto() OrigMsgId: " << photo.mMeta.mOrigMsgId;
|
||||
std::cerr << " MsgId: " << photo.mMeta.mMsgId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
@ -567,8 +588,7 @@ bool RsPhotoThumbnail::copyFrom(const RsPhotoThumbnail &nail)
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
free(data);
|
||||
size = 0;
|
||||
deleteImage();
|
||||
}
|
||||
|
||||
if ((!nail.data) || (nail.size == 0))
|
||||
@ -584,3 +604,47 @@ bool RsPhotoThumbnail::copyFrom(const RsPhotoThumbnail &nail)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RsPhotoThumbnail::deleteImage()
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
free(data);
|
||||
data = NULL;
|
||||
size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
RsPhotoPhoto::RsPhotoPhoto()
|
||||
:mSetFlags(0), mOrder(0), mMode(0), mModFlags(0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RsPhotoAlbum::RsPhotoAlbum()
|
||||
:mMode(0), mSetFlags(0), mModFlags(0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsPhotoPhoto &photo)
|
||||
{
|
||||
out << "RsPhotoPhoto [ ";
|
||||
out << "Title: " << photo.mMeta.mMsgName;
|
||||
out << "]";
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsPhotoAlbum &album)
|
||||
{
|
||||
out << "RsPhotoAlbum [ ";
|
||||
out << "Title: " << album.mMeta.mGroupName;
|
||||
out << "]";
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
@ -120,8 +120,8 @@ virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>&
|
||||
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user