mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 21:34:10 -05:00
Got message retrieval working for genexchange across gxs chain
- fixed segv bugs for message retrieval and improved data service meta data retrieval - fixed compile for windows (exposed too many of rs internals in interface!) - fixed msg signing functionality and id creation with ssl - still need to complete photoservice gui and local meta change function git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5443 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5425ab36b5
commit
c17460d1b1
@ -44,7 +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");
|
||||
#define KEY_NXS_SERV_STRING std::string("serv_str")
|
||||
|
||||
|
||||
// grp table columns
|
||||
@ -98,6 +98,7 @@
|
||||
#define COL_GRP_NAME 11
|
||||
#define COL_GRP_LAST_POST 12
|
||||
#define COL_ORIG_GRP_ID 13
|
||||
#define COL_GRP_SERV_STRING 14
|
||||
|
||||
// msg col numbers
|
||||
#define COL_PUBLISH_SIGN 5
|
||||
@ -108,6 +109,7 @@
|
||||
#define COL_PARENT_ID 10
|
||||
#define COL_THREAD_ID 11
|
||||
#define COL_MSG_NAME 12
|
||||
#define COL_MSG_SERV_STRING 13
|
||||
|
||||
// generic meta shared col numbers
|
||||
#define COL_GRP_ID 0
|
||||
@ -129,7 +131,7 @@ RsDataService::RsDataService(const std::string &serviceDir, const std::string &d
|
||||
msgMetaColumns.push_back(KEY_IDENTITY_SIGN); msgMetaColumns.push_back(KEY_NXS_IDENTITY); msgMetaColumns.push_back(KEY_PUBLISH_SIGN);
|
||||
msgMetaColumns.push_back(KEY_MSG_ID); msgMetaColumns.push_back(KEY_ORIG_MSG_ID); msgMetaColumns.push_back(KEY_MSG_STATUS);
|
||||
msgMetaColumns.push_back(KEY_CHILD_TS); msgMetaColumns.push_back(KEY_MSG_PARENT_ID); msgMetaColumns.push_back(KEY_MSG_THREAD_ID);
|
||||
msgMetaColumns.push_back(KEY_MSG_NAME);
|
||||
msgMetaColumns.push_back(KEY_MSG_NAME); msgMetaColumns.push_back(KEY_NXS_SERV_STRING);
|
||||
|
||||
// for retrieving actual data
|
||||
msgColumns.push_back(KEY_GRP_ID); msgColumns.push_back(KEY_NXS_FILE); msgColumns.push_back(KEY_NXS_FILE_OFFSET);
|
||||
@ -140,7 +142,7 @@ RsDataService::RsDataService(const std::string &serviceDir, const std::string &d
|
||||
grpMetaColumns.push_back(KEY_IDENTITY_SIGN); grpMetaColumns.push_back(KEY_NXS_IDENTITY); grpMetaColumns.push_back(KEY_ADMIN_SIGN);
|
||||
grpMetaColumns.push_back(KEY_KEY_SET); grpMetaColumns.push_back(KEY_GRP_SUBCR_FLAG); grpMetaColumns.push_back(KEY_GRP_POP);
|
||||
grpMetaColumns.push_back(KEY_MSG_COUNT); grpMetaColumns.push_back(KEY_GRP_STATUS); grpMetaColumns.push_back(KEY_GRP_NAME);
|
||||
grpMetaColumns.push_back(KEY_GRP_LAST_POST); grpMetaColumns.push_back(KEY_ORIG_GRP_ID);
|
||||
grpMetaColumns.push_back(KEY_GRP_LAST_POST); grpMetaColumns.push_back(KEY_ORIG_GRP_ID); grpMetaColumns.push_back(KEY_NXS_SERV_STRING);
|
||||
|
||||
// for retrieving actual grp data
|
||||
grpColumns.push_back(KEY_GRP_ID); grpColumns.push_back(KEY_NXS_FILE); grpColumns.push_back(KEY_NXS_FILE_OFFSET);
|
||||
@ -175,6 +177,7 @@ void RsDataService::initialise(){
|
||||
KEY_MSG_THREAD_ID + " TEXT," +
|
||||
KEY_MSG_PARENT_ID + " TEXT,"+
|
||||
KEY_MSG_NAME + " TEXT," +
|
||||
KEY_NXS_SERV_STRING + " TEXT," +
|
||||
KEY_NXS_FILE_LEN + " INT);");
|
||||
|
||||
// create table for grp data
|
||||
@ -195,6 +198,7 @@ void RsDataService::initialise(){
|
||||
KEY_GRP_STATUS + " INT," +
|
||||
KEY_NXS_IDENTITY + " TEXT," +
|
||||
KEY_ORIG_GRP_ID + " TEXT," +
|
||||
KEY_NXS_SERV_STRING + " TEXT," +
|
||||
KEY_NXS_FLAGS + " INT," +
|
||||
KEY_IDENTITY_SIGN + " BLOB);");
|
||||
|
||||
@ -221,6 +225,7 @@ RsGxsGrpMetaData* RsDataService::getGrpMeta(RetroCursor &c)
|
||||
c.getString(COL_IDENTITY, grpMeta->mAuthorId);
|
||||
c.getString(COL_GRP_NAME, grpMeta->mGroupName);
|
||||
c.getString(COL_ORIG_GRP_ID, grpMeta->mOrigGrpId);
|
||||
c.getString(COL_GRP_SERV_STRING, grpMeta->mServiceString);
|
||||
|
||||
grpMeta->mPublishTs = c.getInt32(COL_TIME_STAMP);
|
||||
grpMeta->mGroupFlags = c.getInt32(COL_NXS_FLAGS);
|
||||
@ -335,6 +340,7 @@ RsGxsMsgMetaData* RsDataService::getMsgMeta(RetroCursor &c)
|
||||
c.getString(COL_ORIG_MSG_ID, msgMeta->mOrigMsgId);
|
||||
c.getString(COL_IDENTITY, msgMeta->mAuthorId);
|
||||
c.getString(COL_MSG_NAME, msgMeta->mMsgName);
|
||||
c.getString(COL_MSG_SERV_STRING, msgMeta->mServiceString);
|
||||
|
||||
if(!msgMeta->mAuthorId.empty()){
|
||||
offset = 0;
|
||||
@ -447,6 +453,7 @@ int RsDataService::storeMessage(std::map<RsNxsMsg *, RsGxsMsgMetaData *> &msg)
|
||||
cv.put(KEY_NXS_FILE_LEN, (int32_t)msgPtr->msg.TlvSize());
|
||||
cv.put(KEY_MSG_ID, msgMetaPtr->mMsgId);
|
||||
cv.put(KEY_GRP_ID, msgMetaPtr->mGroupId);
|
||||
cv.put(KEY_NXS_SERV_STRING, msgMetaPtr->mServiceString);
|
||||
char pubSignData[msgMetaPtr->pubSign.TlvSize()];
|
||||
offset = 0;
|
||||
msgMetaPtr->pubSign.SetTlv(pubSignData, msgMetaPtr->pubSign.TlvSize(), &offset);
|
||||
@ -522,6 +529,7 @@ int RsDataService::storeGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
||||
cv.put(KEY_GRP_ID, grpPtr->grpId);
|
||||
cv.put(KEY_GRP_NAME, grpMetaPtr->mGroupName);
|
||||
cv.put(KEY_ORIG_GRP_ID, grpMetaPtr->mOrigGrpId);
|
||||
cv.put(KEY_NXS_SERV_STRING, grpMetaPtr->mServiceString);
|
||||
cv.put(KEY_NXS_FLAGS, (int32_t)grpMetaPtr->mGroupFlags);
|
||||
cv.put(KEY_TIME_STAMP, (int32_t)grpMetaPtr->mPublishTs);
|
||||
|
||||
@ -580,7 +588,7 @@ int RsDataService::retrieveNxsGrps(std::map<std::string, RsNxsGrp *> &grp, bool
|
||||
{
|
||||
std::vector<RsNxsGrp*> grps;
|
||||
|
||||
retrieveGroups(c, grps, withMeta);
|
||||
retrieveGroups(c, grps);
|
||||
std::vector<RsNxsGrp*>::iterator vit = grps.begin();
|
||||
|
||||
for(; vit != grps.end(); vit++)
|
||||
@ -618,10 +626,27 @@ int RsDataService::retrieveNxsGrps(std::map<std::string, RsNxsGrp *> &grp, bool
|
||||
}
|
||||
}
|
||||
|
||||
if(withMeta)
|
||||
{
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> metaMap;
|
||||
std::map<std::string, RsNxsGrp *>::iterator mit = grp.begin();
|
||||
for(; mit != grp.end(); mit++)
|
||||
metaMap.insert(std::make_pair(mit->first, (RsGxsGrpMetaData*)(NULL)));
|
||||
|
||||
retrieveGxsGrpMetaData(metaMap);
|
||||
|
||||
mit = grp.begin();
|
||||
for(; mit != grp.end(); mit++)
|
||||
{
|
||||
RsNxsGrp* grpPtr = grp[mit->first];
|
||||
grpPtr->metaData = metaMap[mit->first];
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void RsDataService::retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, bool withMeta){
|
||||
void RsDataService::retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps){
|
||||
|
||||
if(c){
|
||||
bool valid = c->moveToFirst();
|
||||
@ -632,12 +657,6 @@ void RsDataService::retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps,
|
||||
// only add the latest grp info
|
||||
if(g)
|
||||
{
|
||||
RsGxsGrpMetaData* meta;
|
||||
|
||||
if(withMeta)
|
||||
meta = getGrpMeta(*c);
|
||||
|
||||
if(meta) g->metaData = meta;
|
||||
grps.push_back(g);
|
||||
}
|
||||
valid = c->moveToNext();
|
||||
@ -645,11 +664,13 @@ void RsDataService::retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps,
|
||||
}
|
||||
}
|
||||
|
||||
int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, bool cache)
|
||||
int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, bool cache, bool withMeta)
|
||||
{
|
||||
|
||||
GxsMsgReq::const_iterator mit = reqIds.begin();
|
||||
|
||||
GxsMsgReq metaReqIds;// collects metaReqIds if needed
|
||||
|
||||
for(; mit != reqIds.end(); mit++)
|
||||
{
|
||||
|
||||
@ -685,7 +706,75 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
||||
|
||||
msg[grpId] = msgSet;
|
||||
msgSet.clear();
|
||||
|
||||
if(withMeta)
|
||||
{
|
||||
std::vector<RsGxsMessageId> msgIds;
|
||||
|
||||
std::vector<RsNxsMsg*>::iterator lit = msgSet.begin(),
|
||||
lit_end = msgSet.end();
|
||||
|
||||
for(; lit != lit_end; lit++)
|
||||
msgIds.push_back( (*lit)->msgId );
|
||||
|
||||
metaReqIds[grpId] = msgIds;
|
||||
}
|
||||
}
|
||||
|
||||
// tres expensive !?
|
||||
if(withMeta)
|
||||
{
|
||||
|
||||
|
||||
GxsMsgMetaResult metaResult;
|
||||
|
||||
// request with meta ids so there is no chance of
|
||||
// a mem leak being left over
|
||||
retrieveGxsMsgMetaData(metaReqIds, metaResult);
|
||||
|
||||
GxsMsgResult::iterator mit2 = msg.begin(), mit2_end = msg.end();
|
||||
|
||||
for(; mit2 != mit2_end; mit2++)
|
||||
{
|
||||
const RsGxsGroupId& grpId = mit2->first;
|
||||
std::vector<RsNxsMsg*>& msgV = msg[grpId];
|
||||
std::vector<RsNxsMsg*>::iterator lit = msgV.begin(),
|
||||
lit_end = msgV.end();
|
||||
|
||||
// as retrieval only attempts to retrieve what was found this elimiates chance
|
||||
// of a memory fault as all are assigned
|
||||
for(; lit != lit_end; lit++)
|
||||
{
|
||||
std::vector<RsGxsMsgMetaData*>& msgMetaV = metaResult[grpId];
|
||||
std::vector<RsGxsMsgMetaData*>::iterator meta_lit = msgMetaV.begin();
|
||||
RsNxsMsg* msgPtr = *lit;
|
||||
for(; meta_lit != msgMetaV.end(); )
|
||||
{
|
||||
RsGxsMsgMetaData* meta = *meta_lit;
|
||||
if(meta->mMsgId == msgPtr->msgId)
|
||||
{
|
||||
msgPtr->metaData = meta;
|
||||
meta_lit = msgMetaV.erase(meta_lit);
|
||||
}else{
|
||||
meta_lit++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<RsGxsMsgMetaData*>& msgMetaV = metaResult[grpId];
|
||||
std::vector<RsGxsMsgMetaData*>::iterator meta_lit;
|
||||
|
||||
// clean up just in case, should not go in here
|
||||
for(meta_lit = msgMetaV.begin(); meta_lit !=
|
||||
msgMetaV.end(); )
|
||||
{
|
||||
RsGxsMsgMetaData* meta = *meta_lit;
|
||||
delete meta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void RsDataService::retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg *> &msgs)
|
||||
@ -696,8 +785,6 @@ void RsDataService::retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg *> &ms
|
||||
|
||||
if(m){
|
||||
msgs.push_back(m);;
|
||||
}else{
|
||||
delete m;
|
||||
}
|
||||
|
||||
valid = c->moveToNext();
|
||||
@ -705,38 +792,60 @@ void RsDataService::retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg *> &ms
|
||||
return;
|
||||
}
|
||||
|
||||
int RsDataService::retrieveGxsMsgMetaData(const std::vector<std::string> &grpIds, GxsMsgMetaResult &msgMeta)
|
||||
int RsDataService::retrieveGxsMsgMetaData(GxsMsgReq& reqIds, GxsMsgMetaResult &msgMeta)
|
||||
{
|
||||
std::vector<std::string>::const_iterator vit = grpIds.begin();
|
||||
GxsMsgReq::iterator mit = reqIds.begin();
|
||||
|
||||
for(; vit != grpIds.end(); vit++)
|
||||
for(; mit != reqIds.end(); mit++)
|
||||
{
|
||||
const std::string& grpId = *vit;
|
||||
|
||||
std::vector<RsGxsMsgMetaData*> meta;
|
||||
const std::string& grpId = mit->first;
|
||||
|
||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, msgMetaColumns, "", KEY_GRP_ID+ "='" + grpId + "'");
|
||||
// if vector empty then request all messages
|
||||
const std::vector<RsGxsMessageId>& msgIdV = mit->second;
|
||||
std::vector<RsGxsMsgMetaData*> metaSet;
|
||||
|
||||
if(c)
|
||||
{
|
||||
bool valid = c->moveToFirst();
|
||||
while(valid){
|
||||
RsGxsMsgMetaData* m = getMsgMeta(*c);
|
||||
if(msgIdV.empty()){
|
||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, msgMetaColumns, KEY_GRP_ID+ "='" + grpId + "'", "");
|
||||
|
||||
if(m){
|
||||
meta.push_back(m);
|
||||
}else{
|
||||
delete m;
|
||||
}
|
||||
valid = c->moveToNext();
|
||||
retrieveMsgMeta(c, metaSet);
|
||||
|
||||
}else{
|
||||
|
||||
// request each grp
|
||||
std::vector<std::string>::const_iterator sit = msgIdV.begin();
|
||||
|
||||
for(; sit!=msgIdV.end();sit++){
|
||||
const std::string& msgId = *sit;
|
||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, msgMetaColumns, KEY_GRP_ID+ "='" + grpId
|
||||
+ "' AND " + KEY_MSG_ID + "='" + msgId + "'", "");
|
||||
|
||||
retrieveMsgMeta(c, metaSet);
|
||||
}
|
||||
}
|
||||
|
||||
msgMeta[grpId] = meta;
|
||||
msgMeta[grpId] = metaSet;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void RsDataService::retrieveMsgMeta(RetroCursor *c, std::vector<RsGxsMsgMetaData *> &msgMeta)
|
||||
{
|
||||
|
||||
if(c)
|
||||
{
|
||||
bool valid = c->moveToFirst();
|
||||
while(valid){
|
||||
RsGxsMsgMetaData* m = getMsgMeta(*c);
|
||||
|
||||
if(m != NULL)
|
||||
msgMeta.push_back(m);
|
||||
|
||||
valid = c->moveToNext();
|
||||
}
|
||||
delete c;
|
||||
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int RsDataService::retrieveGxsGrpMetaData(std::map<std::string, RsGxsGrpMetaData *>& grp)
|
||||
@ -799,12 +908,12 @@ int RsDataService::removeGroups(const std::vector<std::string> &grpIds)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RsDataService::updateGroupMetaData(GrpLocMetaData *meta)
|
||||
int RsDataService::updateGroupMetaData(GrpLocMetaData &meta)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RsDataService::updateMessageMetaData(MsgLocMetaData *metaData)
|
||||
int RsDataService::updateMessageMetaData(MsgLocMetaData &metaData)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "gxs/rsgds.h"
|
||||
#include "util/retrodb.h"
|
||||
|
||||
|
||||
class RsDataService : public RsGeneralDataService
|
||||
{
|
||||
public:
|
||||
@ -44,7 +43,7 @@ public:
|
||||
* @param cache whether to store results of this retrieval in memory for faster later retrieval
|
||||
* @return error code
|
||||
*/
|
||||
int retrieveNxsMsgs(const GxsMsgReq& reqIds, GxsMsgResult& msg, bool cache);
|
||||
int retrieveNxsMsgs(const GxsMsgReq& reqIds, GxsMsgResult& msg, bool cache, bool withMeta = false);
|
||||
|
||||
/*!
|
||||
* Retrieves groups, if empty, retrieves all grps, if map is not empty
|
||||
@ -70,7 +69,7 @@ public:
|
||||
* @param cache whether to store retrieval in mem for faster later retrieval
|
||||
* @return error code
|
||||
*/
|
||||
int retrieveGxsMsgMetaData(const std::vector<RsGxsGroupId>& grpIds, GxsMsgMetaResult& msgMeta);
|
||||
int retrieveGxsMsgMetaData(GxsMsgReq& reqIds, GxsMsgMetaResult& msgMeta);
|
||||
|
||||
/*!
|
||||
* remove msgs in data store
|
||||
@ -115,13 +114,13 @@ public:
|
||||
* @param metaData The meta data item to update
|
||||
* @return error code
|
||||
*/
|
||||
int updateMessageMetaData(MsgLocMetaData* metaData);
|
||||
int updateMessageMetaData(MsgLocMetaData& metaData);
|
||||
|
||||
/*!
|
||||
* @param metaData The meta data item to update
|
||||
* @return error code
|
||||
*/
|
||||
int updateGroupMetaData(GrpLocMetaData* meta);
|
||||
int updateGroupMetaData(GrpLocMetaData& meta);
|
||||
|
||||
|
||||
/*!
|
||||
@ -142,11 +141,18 @@ private:
|
||||
void retrieveMessages(RetroCursor* c, std::vector<RsNxsMsg*>& msgs);
|
||||
|
||||
/*!
|
||||
* Retrieves all the msg results from a cursor
|
||||
* Retrieves all the grp results from a cursor
|
||||
* @param c cursor to result set
|
||||
* @param msgs messages retrieved from cursor are stored here
|
||||
* @param grps groups retrieved from cursor are stored here
|
||||
*/
|
||||
void retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, bool withMeta = false);
|
||||
void retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps);
|
||||
|
||||
/*!
|
||||
* Retrieves all the msg meta results from a cursor
|
||||
* @param c cursor to result set
|
||||
* @param metaSet message metadata retrieved from cursor are stored here
|
||||
*/
|
||||
void retrieveMsgMeta(RetroCursor* c, std::vector<RsGxsMsgMetaData*>& msgMeta);
|
||||
|
||||
/*!
|
||||
* extracts a msg meta item from a cursor at its
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
#include "gxs/rsgxsdata.h"
|
||||
#include "rsgxs.h"
|
||||
#include "util/retrodb.h"
|
||||
|
||||
|
||||
class RsGxsSearchModule {
|
||||
@ -53,6 +54,9 @@ public:
|
||||
*/
|
||||
class MsgLocMetaData {
|
||||
|
||||
public:
|
||||
RsGxsGrpMsgIdPair msgId;
|
||||
ContentValue val;
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -61,11 +65,14 @@ class MsgLocMetaData {
|
||||
*/
|
||||
class GrpLocMetaData {
|
||||
|
||||
public:
|
||||
RsGxsGroupId grpId;
|
||||
ContentValue val;
|
||||
|
||||
};
|
||||
|
||||
//typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq; // <grpId, msgIds>
|
||||
|
||||
//typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgMetaData*> > GxsMsgMetaResult; // <grpId, msg metadatas>
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > NxsMsgDataResult;
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > GxsMsgResult; // <grpId, msgs>
|
||||
|
||||
/*!
|
||||
* The main role of GDS is the preparation and handing out of messages requested from
|
||||
@ -103,7 +110,7 @@ public:
|
||||
* @param cache whether to store results of this retrieval in memory for faster later retrieval
|
||||
* @return error code
|
||||
*/
|
||||
virtual int retrieveNxsMsgs(const GxsMsgReq& reqIds, GxsMsgResult& msg, bool cache) = 0;
|
||||
virtual int retrieveNxsMsgs(const GxsMsgReq& reqIds, GxsMsgResult& msg, bool cache, bool withMeta=false) = 0;
|
||||
|
||||
/*!
|
||||
* Retrieves all groups stored
|
||||
@ -130,7 +137,7 @@ public:
|
||||
* @param cache whether to store retrieval in mem for faster later retrieval
|
||||
* @return error code
|
||||
*/
|
||||
virtual int retrieveGxsMsgMetaData(const std::vector<RsGxsGroupId>& grpIds, GxsMsgMetaResult& msgMeta) = 0;
|
||||
virtual int retrieveGxsMsgMetaData(GxsMsgReq& grpIds, GxsMsgMetaResult& msgMeta) = 0;
|
||||
|
||||
/*!
|
||||
* remove msgs in data store listed in msgIds param
|
||||
@ -174,12 +181,12 @@ public:
|
||||
/*!
|
||||
* @param metaData
|
||||
*/
|
||||
virtual int updateMessageMetaData(MsgLocMetaData* metaData) = 0;
|
||||
virtual int updateMessageMetaData(MsgLocMetaData& metaData) = 0;
|
||||
|
||||
/*!
|
||||
* @param metaData
|
||||
*/
|
||||
virtual int updateGroupMetaData(GrpLocMetaData* meta) = 0;
|
||||
virtual int updateGroupMetaData(GrpLocMetaData& meta) = 0;
|
||||
|
||||
|
||||
/*!
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/rsa.h>
|
||||
|
||||
#include "rsgenexchange.h"
|
||||
#include "gxssecurity.h"
|
||||
@ -177,6 +177,7 @@ bool RsGenExchange::createMessage(RsNxsMsg* msg)
|
||||
metaMap.insert(std::make_pair(id, (RsGxsGrpMetaData*)(NULL)));
|
||||
mDataStore->retrieveGxsGrpMetaData(metaMap);
|
||||
bool ok = true;
|
||||
RSA* rsa_pub = NULL;
|
||||
|
||||
if(!metaMap[id])
|
||||
{
|
||||
@ -198,8 +199,7 @@ bool RsGenExchange::createMessage(RsNxsMsg* msg)
|
||||
for(; mit != mit_end; mit++)
|
||||
{
|
||||
|
||||
pub_key_found = mit->second.keyFlags & (RSTLV_KEY_TYPE_FULL | RSTLV_KEY_DISTRIB_PUBLIC);
|
||||
|
||||
pub_key_found = mit->second.keyFlags & (RSTLV_KEY_DISTRIB_PRIVATE | RSTLV_KEY_TYPE_FULL);
|
||||
if(pub_key_found)
|
||||
break;
|
||||
}
|
||||
@ -207,7 +207,7 @@ bool RsGenExchange::createMessage(RsNxsMsg* msg)
|
||||
if(pub_key_found)
|
||||
{
|
||||
pubKey = &(mit->second);
|
||||
RSA* rsa_pub = GxsSecurity::extractPrivateKey(*pubKey);
|
||||
rsa_pub = GxsSecurity::extractPrivateKey(*pubKey);
|
||||
EVP_PKEY *key_pub = EVP_PKEY_new();
|
||||
EVP_PKEY_assign_RSA(key_pub, rsa_pub);
|
||||
|
||||
@ -229,8 +229,9 @@ bool RsGenExchange::createMessage(RsNxsMsg* msg)
|
||||
|
||||
// clean up
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
//RSA_free(rsa_pub);
|
||||
EVP_PKEY_free(key_pub);
|
||||
RSA_free(rsa_pub);
|
||||
// no need to free rsa key as evp key is considered parent key by SSL
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -314,14 +315,15 @@ bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem
|
||||
|
||||
std::list<RsNxsGrp*>::iterator lit = nxsGrps.begin();
|
||||
|
||||
if(ok)
|
||||
if(ok)
|
||||
{
|
||||
for(; lit != nxsGrps.end(); lit++)
|
||||
{
|
||||
RsTlvBinaryData& data = (*lit)->grp;
|
||||
RsItem* item = mSerialiser->deserialise(data.bin_data, &data.bin_len);
|
||||
|
||||
if(item != NULL){
|
||||
if(item != NULL)
|
||||
{
|
||||
RsGxsGrpItem* gItem = dynamic_cast<RsGxsGrpItem*>(item);
|
||||
gItem->meta = *((*lit)->metaData);
|
||||
grpItem.push_back(gItem);
|
||||
@ -422,11 +424,14 @@ void RsGenExchange::publishMsgs()
|
||||
|
||||
std::map<uint32_t, RsGxsMsgItem*>::iterator mit = mMsgsToPublish.begin();
|
||||
|
||||
for(; mit != mMsgsToPublish.end(); )
|
||||
for(; mit != mMsgsToPublish.end(); mit++)
|
||||
{
|
||||
|
||||
RsNxsMsg* msg = new RsNxsMsg(mServType);
|
||||
RsGxsMsgItem* msgItem = mit->second;
|
||||
|
||||
msg->grpId = msgItem->meta.mGroupId;
|
||||
|
||||
uint32_t size = mSerialiser->size(msgItem);
|
||||
char mData[size];
|
||||
bool ok = mSerialiser->serialise(msgItem, mData, &size);
|
||||
@ -434,13 +439,22 @@ void RsGenExchange::publishMsgs()
|
||||
if(ok)
|
||||
{
|
||||
msg->metaData = new RsGxsMsgMetaData();
|
||||
msg->msg.setBinData(mData, size);
|
||||
*(msg->metaData) = msgItem->meta;
|
||||
size = msg->metaData->serial_size();
|
||||
char metaDataBuff[size];
|
||||
|
||||
msg->metaData->serialise(metaDataBuff, &size);
|
||||
msg->meta.setBinData(metaDataBuff, size);
|
||||
|
||||
ok = createMessage(msg);
|
||||
|
||||
if(ok)
|
||||
ok = mDataAccess->addMsgData(msg);
|
||||
ok = mDataAccess->addMsgData(msg);
|
||||
|
||||
mMsgPublished.insert(std::make_pair(mit->first, std::make_pair(msg->grpId, msg->msgId)));
|
||||
// add to published to allow acknowledgement
|
||||
mMsgPublished.insert(std::make_pair(mit->first, std::make_pair(msg->grpId, msg->msgId)));
|
||||
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenServiceV2::GXS_REQUEST_STATUS_COMPLETE);
|
||||
}
|
||||
|
||||
// if addition failed then delete nxs message
|
||||
@ -488,7 +502,7 @@ void RsGenExchange::publishGrps()
|
||||
createGroup(grp);
|
||||
size = grp->metaData->serial_size();
|
||||
char mData[size];
|
||||
|
||||
grp->metaData->mGroupId = grp->grpId;
|
||||
ok = grp->metaData->serialise(mData, size);
|
||||
grp->meta.setBinData(mData, size);
|
||||
|
||||
@ -520,6 +534,8 @@ void RsGenExchange::publishGrps()
|
||||
// are invalid
|
||||
mGrpsToPublish.clear();
|
||||
}
|
||||
|
||||
|
||||
void RsGenExchange::processRecvdData()
|
||||
{
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
#include "gxs/rsgxsdata.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string>
|
||||
@ -38,8 +38,6 @@
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgReq;
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgIdResult;
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsGxsMsgMetaData*> > GxsMsgMetaResult;
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > NxsMsgDataResult;
|
||||
typedef std::map<RsGxsGroupId, std::vector<RsNxsMsg*> > GxsMsgResult; // <grpId, msgs>
|
||||
|
||||
class RsGxsService
|
||||
{
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "rsgxsdata.h"
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
|
||||
RsGxsGrpMetaData::RsGxsGrpMetaData()
|
||||
{
|
||||
@ -283,6 +284,6 @@ void RsGxsMsgMetaData::operator =(const RsMsgMetaData& rMeta)
|
||||
this->mPublishTs = rMeta.mPublishTs ;
|
||||
this->mThreadId = rMeta.mThreadId;
|
||||
this->mServiceString = rMeta.mServiceString;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <string>
|
||||
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rstlvtypes.h"
|
||||
#include "serialiser/rstlvkeys.h"
|
||||
#include "serialiser/rsgxsitems.h"
|
||||
|
@ -571,6 +571,15 @@ bool RsGxsDataAccess::getGroupData(GroupDataReq* req)
|
||||
{
|
||||
|
||||
std::map<RsGxsGroupId, RsNxsGrp*> grpData;
|
||||
|
||||
std::list<RsGxsGroupId>::iterator lit = req->mGroupIds.begin(),
|
||||
lit_end = req->mGroupIds.end();
|
||||
|
||||
for(; lit != lit_end; lit++)
|
||||
{
|
||||
grpData[*lit] = NULL;
|
||||
}
|
||||
|
||||
bool ok = mDataStore->retrieveNxsGrps(grpData, true, true);
|
||||
|
||||
std::map<RsGxsGroupId, RsNxsGrp*>::iterator mit = grpData.begin();
|
||||
@ -625,7 +634,7 @@ bool RsGxsDataAccess::getGroupList(GroupIdReq* req)
|
||||
bool RsGxsDataAccess::getMsgData(MsgDataReq* req)
|
||||
{
|
||||
GxsMsgResult result;
|
||||
mDataStore->retrieveNxsMsgs(req->mMsgIds, result, true);
|
||||
mDataStore->retrieveNxsMsgs(req->mMsgIds, result, true, true);
|
||||
|
||||
req->mMsgData = result;
|
||||
return true;
|
||||
@ -634,14 +643,8 @@ bool RsGxsDataAccess::getMsgData(MsgDataReq* req)
|
||||
|
||||
bool RsGxsDataAccess::getMsgSummary(MsgMetaReq* req)
|
||||
{
|
||||
GxsMsgMetaResult result;
|
||||
std::vector<RsGxsGroupId> groupIds;
|
||||
GxsMsgReq::iterator mit = req->mMsgIds.begin();
|
||||
for(; mit != req->mMsgIds.end(); mit++)
|
||||
groupIds.push_back(mit->first);
|
||||
|
||||
mDataStore->retrieveGxsMsgMetaData(groupIds, result);
|
||||
|
||||
GxsMsgMetaResult result;
|
||||
mDataStore->retrieveGxsMsgMetaData(req->mMsgIds, result);
|
||||
req->mMsgMetaData = result;
|
||||
|
||||
return true;
|
||||
@ -649,18 +652,13 @@ bool RsGxsDataAccess::getMsgSummary(MsgMetaReq* req)
|
||||
|
||||
bool RsGxsDataAccess::getMsgList(MsgIdReq* req)
|
||||
{
|
||||
GxsMsgMetaResult result;
|
||||
std::vector<RsGxsGroupId> groupIds;
|
||||
GxsMsgReq::iterator mit = req->mMsgIds.begin();
|
||||
GxsMsgMetaResult result;
|
||||
|
||||
const RsTokReqOptionsV2& opts = req->Options;
|
||||
|
||||
for(; mit != req->mMsgIds.end(); mit++)
|
||||
groupIds.push_back(mit->first);
|
||||
|
||||
{
|
||||
RsStackMutex stack(mDataMutex);
|
||||
mDataStore->retrieveGxsMsgMetaData(groupIds, result);
|
||||
mDataStore->retrieveGxsMsgMetaData(req->mMsgIds, result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -727,10 +727,10 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
||||
// get grp id for this transaction
|
||||
RsNxsSyncMsgItem* item = msgItemL.front();
|
||||
const std::string& grpId = item->grpId;
|
||||
std::vector<std::string> grpIdV;
|
||||
grpIdV.push_back(grpId);
|
||||
GxsMsgReq reqIds;
|
||||
reqIds[grpId] = std::vector<RsGxsMessageId>();
|
||||
GxsMsgMetaResult result;
|
||||
mDataStore->retrieveGxsMsgMetaData(grpIdV, result);
|
||||
mDataStore->retrieveGxsMsgMetaData(reqIds, result);
|
||||
std::vector<RsGxsMsgMetaData*> &msgMetaV = result[grpId];
|
||||
|
||||
std::vector<RsGxsMsgMetaData*>::const_iterator vit = msgMetaV.begin();
|
||||
|
@ -26,6 +26,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gxs/rsgds.h"
|
||||
|
||||
class GxsRequest
|
||||
{
|
||||
|
||||
@ -63,7 +65,7 @@ class GroupDataReq : public GxsRequest
|
||||
{
|
||||
|
||||
public:
|
||||
std::list<std::string> mGroupIds;
|
||||
std::list<RsGxsGroupId> mGroupIds;
|
||||
std::list<RsNxsGrp*> mGroupData;
|
||||
};
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rstlvtypes.h"
|
||||
#include "serialiser/rstlvkeys.h"
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
|
||||
#include "rsphotov2items.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include <iostream>
|
||||
|
||||
#define GXS_PHOTO_SERIAL_DEBUG
|
||||
|
||||
|
@ -89,6 +89,7 @@ bool p3PhotoServiceV2::getAlbum(const uint32_t& token, std::vector<RsPhotoAlbum>
|
||||
{
|
||||
RsGxsPhotoAlbumItem* item = dynamic_cast<RsGxsPhotoAlbumItem*>(*vit);
|
||||
RsPhotoAlbum album = item->album;
|
||||
item->album.mMeta = item->meta;
|
||||
album.mMeta = item->album.mMeta;
|
||||
delete item;
|
||||
albums.push_back(album);
|
||||
@ -183,14 +184,14 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -304,11 +304,11 @@ void PhotoAddDialog::publishAlbum()
|
||||
album.mShareOptions.mCommentMode = 0;
|
||||
album.mShareOptions.mResizeMode = 0;
|
||||
|
||||
//album.mMeta.mGroupName = ui.lineEdit_Title->text().toStdString();
|
||||
//album.mCategory = "Unknown";
|
||||
//album.mCaption = ui.lineEdit_Caption->text().toStdString();
|
||||
//album.mWhere = ui.lineEdit_Where->text().toStdString();
|
||||
//album.mWhen = ui.lineEdit_When->text().toStdString();
|
||||
album.mMeta.mGroupName = ui.lineEdit_Title->text().toStdString();
|
||||
album.mCategory = "Unknown";
|
||||
album.mCaption = ui.lineEdit_Caption->text().toStdString();
|
||||
album.mWhere = ui.lineEdit_Where->text().toStdString();
|
||||
album.mWhen = ui.lineEdit_When->text().toStdString();
|
||||
|
||||
/* grab the image from the AlbumDrop */
|
||||
if (ui.AlbumDrop->getPhotoCount() > 0)
|
||||
@ -325,6 +325,7 @@ void PhotoAddDialog::publishAlbum()
|
||||
|
||||
/* call publishPhotos directly */
|
||||
publishPhotos(album.mMeta.mGroupId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -469,9 +470,8 @@ void PhotoAddDialog::loadAlbum(const std::string &albumId)
|
||||
albumIds.push_back(albumId);
|
||||
|
||||
// We need both Album and Photo Data.
|
||||
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, albumIds, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -636,8 +636,20 @@ void PhotoAddDialog::loadRequest(const TokenQueueV2 *queue, const TokenRequestV2
|
||||
}
|
||||
break;
|
||||
case TOKENREQ_MSGINFO:
|
||||
loadPhotoData(req.mToken);
|
||||
break;
|
||||
switch(req.mAnsType)
|
||||
{
|
||||
case RS_TOKREQ_ANSTYPE_DATA:
|
||||
loadPhotoData(req.mToken);
|
||||
break;
|
||||
case RS_TOKREQ_ANSTYPE_ACK:
|
||||
acknowledgeMessage(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "PhotoAddDialog::loadRequest() ERROR: MESSAGE: INVALID ANS TYPE";
|
||||
std::cerr << std::endl;
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
std::cerr << "PhotoAddDialog::loadRequest() ERROR: INVALID TYPE";
|
||||
std::cerr << std::endl;
|
||||
|
@ -487,8 +487,6 @@ bool PhotoDialog::loadAlbumData(const uint32_t &token)
|
||||
std::cerr << "PhotoDialog::loadAlbumData()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
clearAlbums();
|
||||
|
||||
std::vector<RsPhotoAlbum> albums;
|
||||
rsPhotoV2->getAlbum(token, albums);
|
||||
|
||||
@ -643,9 +641,9 @@ void PhotoDialog::loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &r
|
||||
case RS_TOKREQ_ANSTYPE_ACK:
|
||||
acknowledgeMessage(req.mToken);
|
||||
break;
|
||||
//case RS_TOKREQ_ANSTYPE_DATA:
|
||||
// loadPhotoData(req.mToken);
|
||||
// break;
|
||||
case RS_TOKREQ_ANSTYPE_DATA:
|
||||
loadPhotoData(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "PhotoDialog::loadRequest() ERROR: MSG: INVALID ANS TYPE";
|
||||
std::cerr << std::endl;
|
||||
|
@ -141,7 +141,7 @@ void PhotoItem::updateText()
|
||||
if (mAlbumDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_AUTHOR)
|
||||
{
|
||||
// This needs to be fixed!! TODO
|
||||
fromLabel->setText(QString::fromStdString(mAlbumDetails.mMeta.mGroupId));
|
||||
fromLabel->setText(QString::fromStdString(mAlbumDetails.mPhotographer));
|
||||
}
|
||||
|
||||
if (mAlbumDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user