Merge pull request #642 from G10h4ck/ccleanup

Documentation and code cleanup
This commit is contained in:
csoler 2017-01-13 10:24:28 +01:00 committed by GitHub
commit e4960e07c8
5 changed files with 30 additions and 62 deletions

View File

@ -238,11 +238,12 @@ void RsGenExchange::tick()
bool RsGenExchange::messagePublicationTest(const RsGxsMsgMetaData& meta) bool RsGenExchange::messagePublicationTest(const RsGxsMsgMetaData& meta)
{ {
time_t now = time(NULL) ; time_t st = MESSAGE_STORE_PERIOD;
if(mNetService) st = mNetService->getKeepAge(meta.mGroupId, st);
time_t storageTimeLimit = meta.mPublishTs + st;
uint32_t store_limit = (mNetService == NULL)?MESSAGE_STORE_PERIOD:mNetService->getKeepAge(meta.mGroupId,MESSAGE_STORE_PERIOD) ; return meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP ||
storageTimeLimit == 0 || storageTimeLimit >= time(NULL);
return meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP || store_limit == 0 || meta.mPublishTs + store_limit >= now ;
} }
bool RsGenExchange::acknowledgeTokenMsg(const uint32_t& token, bool RsGenExchange::acknowledgeTokenMsg(const uint32_t& token,

View File

@ -428,11 +428,10 @@ protected:
public: public:
/*! /*!
* Assigns a token value to passed integer * Generate a new token, the status of the token can be queried from request
* The status of the token can still be queried from request status feature * status feature.
* @warning the token space is shared with RsGenExchange backend, so do not * @attention the token space is shared with RsGenExchange backend.
* modify tokens except does you have created by calling generatePublicToken() * @return Generated token
* @return token
*/ */
uint32_t generatePublicToken(); uint32_t generatePublicToken();
@ -486,7 +485,7 @@ public:
* This allows the client service to acknowledge that their grps has \n * This allows the client service to acknowledge that their grps has \n
* been created/modified and retrieve the create/modified grp ids * been created/modified and retrieve the create/modified grp ids
* @param token the token related to modification/create request * @param token the token related to modification/create request
* @param msgIds vector of ids of groups created/modified * @param grpId ids of created/modified group
* @return true if token exists false otherwise * @return true if token exists false otherwise
*/ */
bool acknowledgeTokenGrp(const uint32_t& token, RsGxsGroupId& grpId); bool acknowledgeTokenGrp(const uint32_t& token, RsGxsGroupId& grpId);

View File

@ -34,26 +34,11 @@ class RsGxsGrpMetaData;
class RsGxsMsgMetaData; class RsGxsMsgMetaData;
class RsGroupMetaData struct RsGroupMetaData
{ {
public: RsGroupMetaData() : mGroupFlags(0), mSignFlags(0), mPublishTs(0),
mCircleType(0), mAuthenFlags(0), mSubscribeFlags(0), mPop(0),
RsGroupMetaData() mVisibleMsgCount(0), mLastPost(0), mGroupStatus(0) {}
{
mGroupFlags = 0;
mSignFlags = 0;
mSubscribeFlags = 0;
mPop = 0;
mVisibleMsgCount = 0;
mLastPost = 0;
mGroupStatus = 0;
mCircleType = 0;
mAuthenFlags = 0;
mPublishTs = 0;
}
void operator =(const RsGxsGrpMetaData& rGxsMeta); void operator =(const RsGxsGrpMetaData& rGxsMeta);
@ -90,19 +75,9 @@ public:
class RsMsgMetaData struct RsMsgMetaData
{ {
RsMsgMetaData() : mPublishTs(0), mMsgFlags(0), mMsgStatus(0), mChildTs(0) {}
public:
RsMsgMetaData()
{
mPublishTs = 0;
mMsgFlags = 0;
mMsgStatus = 0;
mChildTs = 0;
}
void operator =(const RsGxsMsgMetaData& rGxsMeta); void operator =(const RsGxsMsgMetaData& rGxsMeta);

View File

@ -11,22 +11,17 @@ typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > GxsMsgMetaMap;
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsMsgMetaData> > GxsMsgRelatedMetaMap; typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsMsgMetaData> > GxsMsgRelatedMetaMap;
/*! /*!
* The aim of this class is to abstract * The aim of this class is to abstract how changes are represented so they can
* how changes are represented so * be determined outside the client API without explcitly enumerating all
* they can be determined outside the * possible changes at the interface
* client API without explcitly
* enumerating all possible changes
* at the interface
*/ */
class RsGxsNotify struct RsGxsNotify
{ {
public: enum NotifyType
{ TYPE_PUBLISH, TYPE_RECEIVE, TYPE_PROCESSED, TYPE_PUBLISHKEY };
enum NotifyType { TYPE_PUBLISH, TYPE_RECEIVE, TYPE_PROCESSED, TYPE_PUBLISHKEY }; virtual ~RsGxsNotify() {}
virtual ~RsGxsNotify() {return; }
virtual NotifyType getType() = 0; virtual NotifyType getType() = 0;
}; };
/*! /*!

View File

@ -53,17 +53,15 @@ const uint32_t GXSFORUMS_MSG_STORE_PERIOD = 60*60*24*31*12; // 12 months / 1 yea
/******************* Startup / Tick ******************************************/ /******************* Startup / Tick ******************************************/
/********************************************************************************/ /********************************************************************************/
p3GxsForums::p3GxsForums(RsGeneralDataService *gds, RsNetworkExchangeService *nes, RsGixs* gixs) p3GxsForums::p3GxsForums( RsGeneralDataService *gds,
: RsGenExchange(gds, nes, new RsGxsForumSerialiser(), RS_SERVICE_GXS_TYPE_FORUMS, gixs, forumsAuthenPolicy(), GXSFORUMS_MSG_STORE_PERIOD), RsGxsForums(this) RsNetworkExchangeService *nes, RsGixs* gixs ) :
RsGenExchange( gds, nes, new RsGxsForumSerialiser(),
RS_SERVICE_GXS_TYPE_FORUMS, gixs, forumsAuthenPolicy(),
GXSFORUMS_MSG_STORE_PERIOD),
RsGxsForums(this), mGenToken(0), mGenActive(false), mGenCount(0)
{ {
// For Dummy Msgs.
mGenActive = false;
mGenCount = 0;
mGenToken = 0;
// Test Data disabled in Repo. // Test Data disabled in Repo.
//RsTickEvent::schedule_in(FORUM_TESTEVENT_DUMMYDATA, DUMMYDATA_PERIOD); //RsTickEvent::schedule_in(FORUM_TESTEVENT_DUMMYDATA, DUMMYDATA_PERIOD);
} }