Added msg sync unit test

- not passing yet but almost, more tweaking needed 
TODO: identity and circle vet test
- added retrieve msg id for convenience
- updated .pro file

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7303 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2014-04-26 10:07:25 +00:00
parent 4cab2aaa65
commit c6059906d0
11 changed files with 333 additions and 25 deletions

View file

@ -191,6 +191,8 @@ RsDataService::RsDataService(const std::string &serviceDir, const std::string &d
mMsgOffSetColumns.push_back(KEY_NXS_FILE_LEN);
grpIdColumn.push_back(KEY_GRP_ID);
mMsgIdColumn.push_back(KEY_MSG_ID);
}
RsDataService::~RsDataService(){
@ -1344,6 +1346,32 @@ int RsDataService::retrieveGroupIds(std::vector<RsGxsGroupId> &grpIds)
return 1;
}
int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId,
RsGxsMessageId::std_vector& msgIds) {
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, mMsgIdColumn, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
if(c)
{
bool valid = c->moveToFirst();
while(valid)
{
std::string msgId;
c->getString(0, msgId);
msgIds.push_back(RsGxsMessageId(msgId));
valid = c->moveToNext();
}
delete c;
}else
{
return 0;
}
return 1;
}
bool RsDataService::locked_updateMessageEntries(const MsgUpdates& updates)
{
// start a transaction

View file

@ -113,6 +113,14 @@ public:
*/
int retrieveGroupIds(std::vector<RsGxsGroupId> &grpIds);
/*!
* Retrives all msg ids in store
* @param grpId groupId of message ids to retrieve
* @param msgId msgsids retrieved
* @return error code
*/
int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgId);
/*!
* @return the cache size set for this RsGeneralDataService in bytes
*/
@ -249,6 +257,7 @@ private:
std::list<std::string> msgColumns;
std::list<std::string> msgMetaColumns;
std::list<std::string> mMsgOffSetColumns;
std::list<std::string> mMsgIdColumn;
std::list<std::string> grpColumns;
std::list<std::string> grpMetaColumns;

View file

@ -118,6 +118,7 @@ public:
public:
typedef std::map<RsNxsGrp*, RsGxsGrpMetaData*> GrpStoreMap;
typedef std::map<RsNxsMsg*, RsGxsMsgMetaData*> MsgStoreMap;
RsGeneralDataService(){}
virtual ~RsGeneralDataService(){return;}
@ -179,6 +180,14 @@ public:
*/
virtual int retrieveGroupIds(std::vector<RsGxsGroupId>& grpIds) = 0;
/*!
* Retrives all msg ids in store
* @param grpId groupId of message ids to retrieve
* @param msgId msgsids retrieved
* @return error code
*/
virtual int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgId) = 0;
/*!
* @return the cache size set for this RsGeneralDataService in bytes
*/