mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge branch 'master' of https://github.com/RetroShare/RetroShare
This commit is contained in:
commit
4a50a62cc8
@ -24,11 +24,19 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*****
|
||||||
|
* #define RS_DATA_SERVICE_DEBUG 1
|
||||||
|
* #define RS_DATA_SERVICE_DEBUG_TIME 1
|
||||||
|
****/
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <util/rsdir.h>
|
#include <util/rsdir.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
#include <util/rsscopetimer.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "rsdataservice.h"
|
#include "rsdataservice.h"
|
||||||
|
|
||||||
#define MSG_TABLE_NAME std::string("MESSAGES")
|
#define MSG_TABLE_NAME std::string("MESSAGES")
|
||||||
@ -141,10 +149,6 @@
|
|||||||
#define COL_IDENTITY 4
|
#define COL_IDENTITY 4
|
||||||
#define COL_HASH 5
|
#define COL_HASH 5
|
||||||
|
|
||||||
/*****
|
|
||||||
* #define RS_DATA_SERVICE_DEBUG 1
|
|
||||||
****/
|
|
||||||
|
|
||||||
const std::string RsGeneralDataService::GRP_META_SERV_STRING = KEY_NXS_SERV_STRING;
|
const std::string RsGeneralDataService::GRP_META_SERV_STRING = KEY_NXS_SERV_STRING;
|
||||||
const std::string RsGeneralDataService::GRP_META_STATUS = KEY_GRP_STATUS;
|
const std::string RsGeneralDataService::GRP_META_STATUS = KEY_GRP_STATUS;
|
||||||
const std::string RsGeneralDataService::GRP_META_SUBSCRIBE_FLAG = KEY_GRP_SUBCR_FLAG;
|
const std::string RsGeneralDataService::GRP_META_SUBSCRIBE_FLAG = KEY_GRP_SUBCR_FLAG;
|
||||||
@ -157,8 +161,8 @@ const uint32_t RsGeneralDataService::GXS_MAX_ITEM_SIZE = 1572864; // 1.5 Mbytes
|
|||||||
|
|
||||||
RsDataService::RsDataService(const std::string &serviceDir, const std::string &dbName, uint16_t serviceType,
|
RsDataService::RsDataService(const std::string &serviceDir, const std::string &dbName, uint16_t serviceType,
|
||||||
RsGxsSearchModule * /* mod */, const std::string& key)
|
RsGxsSearchModule * /* mod */, const std::string& key)
|
||||||
: RsGeneralDataService(), mDbMutex("RsDataService"), mServiceDir(serviceDir), mDbName(mServiceDir + "/" + dbName), mServType(serviceType),
|
: RsGeneralDataService(), mDbMutex("RsDataService"), mServiceDir(serviceDir), mDbName(dbName), mDbPath(mServiceDir + "/" + dbName), mServType(serviceType),
|
||||||
mDb( new RetroDb(mDbName, RetroDb::OPEN_READWRITE_CREATE, key)) {
|
mDb( new RetroDb(mDbPath, RetroDb::OPEN_READWRITE_CREATE, key)) {
|
||||||
|
|
||||||
initialise();
|
initialise();
|
||||||
|
|
||||||
@ -900,7 +904,13 @@ bool RsDataService::validSize(RsNxsGrp* grp) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool withMeta, bool /* cache */){
|
int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool withMeta, bool /* cache */)
|
||||||
|
{
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
RsScopeTimer timer("");
|
||||||
|
int resultCount = 0;
|
||||||
|
int requestedGroups = grp.size();
|
||||||
|
#endif
|
||||||
|
|
||||||
if(grp.empty()){
|
if(grp.empty()){
|
||||||
|
|
||||||
@ -914,6 +924,10 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
|||||||
locked_retrieveGroups(c, grps);
|
locked_retrieveGroups(c, grps);
|
||||||
std::vector<RsNxsGrp*>::iterator vit = grps.begin();
|
std::vector<RsNxsGrp*>::iterator vit = grps.begin();
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
resultCount = grps.size();
|
||||||
|
#endif
|
||||||
|
|
||||||
for(; vit != grps.end(); ++vit)
|
for(; vit != grps.end(); ++vit)
|
||||||
{
|
{
|
||||||
grp[(*vit)->grpId] = *vit;
|
grp[(*vit)->grpId] = *vit;
|
||||||
@ -943,6 +957,10 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
|||||||
{
|
{
|
||||||
RsNxsGrp* ng = grps.front();
|
RsNxsGrp* ng = grps.front();
|
||||||
grp[ng->grpId] = ng;
|
grp[ng->grpId] = ng;
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
++resultCount;
|
||||||
|
#endif
|
||||||
}else{
|
}else{
|
||||||
toRemove.push_back(grpId);
|
toRemove.push_back(grpId);
|
||||||
}
|
}
|
||||||
@ -958,6 +976,10 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
std::cerr << "RsDataService::retrieveNxsGrps() " << mDbName << ", Requests: " << requestedGroups << ", Results: " << resultCount << ", Time: " << timer.duration() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(withMeta && !grp.empty())
|
if(withMeta && !grp.empty())
|
||||||
{
|
{
|
||||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> metaMap;
|
std::map<RsGxsGroupId, RsGxsGrpMetaData*> metaMap;
|
||||||
@ -980,6 +1002,10 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
std::cerr << "RsDataService::retrieveNxsGrps() " << mDbName << ", Time with meta: " << timer.duration() << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -1005,6 +1031,10 @@ void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>
|
|||||||
|
|
||||||
int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, bool /* cache */, bool withMeta)
|
int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, bool /* cache */, bool withMeta)
|
||||||
{
|
{
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
RsScopeTimer timer("");
|
||||||
|
int resultCount = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
GxsMsgReq::const_iterator mit = reqIds.begin();
|
GxsMsgReq::const_iterator mit = reqIds.begin();
|
||||||
|
|
||||||
@ -1026,8 +1056,14 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
|||||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, msgColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
|
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, msgColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
|
||||||
|
|
||||||
if(c)
|
if(c)
|
||||||
|
{
|
||||||
locked_retrieveMessages(c, msgSet);
|
locked_retrieveMessages(c, msgSet);
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
resultCount += msgSet.size();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
delete c;
|
delete c;
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
@ -1043,8 +1079,14 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
|||||||
+ "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", "");
|
+ "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", "");
|
||||||
|
|
||||||
if(c)
|
if(c)
|
||||||
|
{
|
||||||
locked_retrieveMessages(c, msgSet);
|
locked_retrieveMessages(c, msgSet);
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
resultCount += c->getResultCount();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1066,6 +1108,10 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
|||||||
msgSet.clear();
|
msgSet.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
std::cerr << "RsDataService::retrieveNxsMsgs() " << mDbName << ", Requests: " << reqIds.size() << ", Results: " << resultCount << ", Time: " << timer.duration() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
// tres expensive !?
|
// tres expensive !?
|
||||||
if(withMeta)
|
if(withMeta)
|
||||||
{
|
{
|
||||||
@ -1117,6 +1163,10 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b
|
|||||||
meta_lit = msgMetaV.erase(meta_lit);
|
meta_lit = msgMetaV.erase(meta_lit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
std::cerr << "RsDataService::retrieveNxsMsgs() " << mDbName << ", Time with meta: " << timer.duration() << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -1129,7 +1179,7 @@ void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg
|
|||||||
RsNxsMsg* m = locked_getMessage(*c);
|
RsNxsMsg* m = locked_getMessage(*c);
|
||||||
|
|
||||||
if(m){
|
if(m){
|
||||||
msgs.push_back(m);;
|
msgs.push_back(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
valid = c->moveToNext();
|
valid = c->moveToNext();
|
||||||
@ -1139,9 +1189,13 @@ void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg
|
|||||||
|
|
||||||
int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaResult &msgMeta)
|
int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaResult &msgMeta)
|
||||||
{
|
{
|
||||||
|
|
||||||
RsStackMutex stack(mDbMutex);
|
RsStackMutex stack(mDbMutex);
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
RsScopeTimer timer("");
|
||||||
|
int resultCount = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
GxsMsgReq::const_iterator mit = reqIds.begin();
|
GxsMsgReq::const_iterator mit = reqIds.begin();
|
||||||
|
|
||||||
for(; mit != reqIds.end(); ++mit)
|
for(; mit != reqIds.end(); ++mit)
|
||||||
@ -1156,8 +1210,14 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
|
|||||||
if(msgIdV.empty()){
|
if(msgIdV.empty()){
|
||||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, msgMetaColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
|
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, msgMetaColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
|
||||||
|
|
||||||
locked_retrieveMsgMeta(c, metaSet);
|
if (c)
|
||||||
|
{
|
||||||
|
locked_retrieveMsgMeta(c, metaSet);
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
resultCount += metaSet.size();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
// request each grp
|
// request each grp
|
||||||
@ -1168,13 +1228,24 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
|
|||||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, msgMetaColumns, KEY_GRP_ID+ "='" + grpId.toStdString()
|
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, msgMetaColumns, KEY_GRP_ID+ "='" + grpId.toStdString()
|
||||||
+ "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", "");
|
+ "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", "");
|
||||||
|
|
||||||
locked_retrieveMsgMeta(c, metaSet);
|
if (c)
|
||||||
|
{
|
||||||
|
locked_retrieveMsgMeta(c, metaSet);
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
resultCount += c->getResultCount();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msgMeta[grpId] = metaSet;
|
msgMeta[grpId] = metaSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
std::cerr << "RsDataService::retrieveGxsMsgMetaData() " << mDbName << ", Requests: " << reqIds.size() << ", Results: " << resultCount << ", Time: " << timer.duration() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1205,6 +1276,10 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaDat
|
|||||||
|
|
||||||
RsStackMutex stack(mDbMutex);
|
RsStackMutex stack(mDbMutex);
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
RsScopeTimer timer("");
|
||||||
|
#endif
|
||||||
|
|
||||||
if(grp.empty()){
|
if(grp.empty()){
|
||||||
|
|
||||||
#ifdef RS_DATA_SERVICE_DEBUG
|
#ifdef RS_DATA_SERVICE_DEBUG
|
||||||
@ -1260,6 +1335,9 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaDat
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
std::cerr << "RsDataService::retrieveGxsGrpMetaData() " << mDbName << ", Time: " << timer.duration() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1450,6 +1528,11 @@ int RsDataService::retrieveGroupIds(std::vector<RsGxsGroupId> &grpIds)
|
|||||||
{
|
{
|
||||||
RsStackMutex stack(mDbMutex);
|
RsStackMutex stack(mDbMutex);
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
RsScopeTimer timer("");
|
||||||
|
int resultCount = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, grpIdColumn, "", "");
|
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, grpIdColumn, "", "");
|
||||||
|
|
||||||
if(c)
|
if(c)
|
||||||
@ -1462,6 +1545,10 @@ int RsDataService::retrieveGroupIds(std::vector<RsGxsGroupId> &grpIds)
|
|||||||
c->getString(0, grpId);
|
c->getString(0, grpId);
|
||||||
grpIds.push_back(RsGxsGroupId(grpId));
|
grpIds.push_back(RsGxsGroupId(grpId));
|
||||||
valid = c->moveToNext();
|
valid = c->moveToNext();
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
++resultCount;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
delete c;
|
delete c;
|
||||||
}else
|
}else
|
||||||
@ -1469,11 +1556,19 @@ int RsDataService::retrieveGroupIds(std::vector<RsGxsGroupId> &grpIds)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
std::cerr << "RsDataService::retrieveGroupIds() " << mDbName << ", Results: " << resultCount << ", Time: " << timer.duration() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId,
|
int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgIds)
|
||||||
RsGxsMessageId::std_vector& msgIds) {
|
{
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
RsScopeTimer timer("");
|
||||||
|
int resultCount = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, mMsgIdColumn, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
|
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, mMsgIdColumn, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
|
||||||
|
|
||||||
@ -1491,6 +1586,10 @@ int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId,
|
|||||||
|
|
||||||
msgIds.push_back(RsGxsMessageId(msgId));
|
msgIds.push_back(RsGxsMessageId(msgId));
|
||||||
valid = c->moveToNext();
|
valid = c->moveToNext();
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
++resultCount;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
delete c;
|
delete c;
|
||||||
}else
|
}else
|
||||||
@ -1498,6 +1597,10 @@ int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||||
|
std::cerr << "RsDataService::retrieveNxsGrps() " << mDbName << ", Results: " << resultCount << ", Time: " << timer.duration() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,9 @@ private:
|
|||||||
std::list<std::string> grpMetaColumns;
|
std::list<std::string> grpMetaColumns;
|
||||||
std::list<std::string> grpIdColumn;
|
std::list<std::string> grpIdColumn;
|
||||||
|
|
||||||
std::string mServiceDir, mDbName;
|
std::string mServiceDir;
|
||||||
|
std::string mDbName;
|
||||||
|
std::string mDbPath;
|
||||||
uint16_t mServType;
|
uint16_t mServType;
|
||||||
|
|
||||||
RetroDb* mDb;
|
RetroDb* mDb;
|
||||||
|
@ -235,6 +235,10 @@ void RsGxsNetService::syncWithPeers()
|
|||||||
|
|
||||||
std::set<RsPeerId> peers;
|
std::set<RsPeerId> peers;
|
||||||
mNetMgr->getOnlineList(mServiceInfo.mServiceType, peers);
|
mNetMgr->getOnlineList(mServiceInfo.mServiceType, peers);
|
||||||
|
if (peers.empty()) {
|
||||||
|
// nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::set<RsPeerId>::iterator sit = peers.begin();
|
std::set<RsPeerId>::iterator sit = peers.begin();
|
||||||
|
|
||||||
|
@ -483,6 +483,7 @@ HEADERS += util/folderiterator.h \
|
|||||||
util/rsmemcache.h \
|
util/rsmemcache.h \
|
||||||
util/rstickevent.h \
|
util/rstickevent.h \
|
||||||
util/rsrecogn.h \
|
util/rsrecogn.h \
|
||||||
|
util/rsscopetimer.h
|
||||||
|
|
||||||
SOURCES += dbase/cachestrapper.cc \
|
SOURCES += dbase/cachestrapper.cc \
|
||||||
dbase/fimonitor.cc \
|
dbase/fimonitor.cc \
|
||||||
@ -632,6 +633,7 @@ SOURCES += util/folderiterator.cc \
|
|||||||
util/rsrandom.cc \
|
util/rsrandom.cc \
|
||||||
util/rstickevent.cc \
|
util/rstickevent.cc \
|
||||||
util/rsrecogn.cc \
|
util/rsrecogn.cc \
|
||||||
|
util/rsscopetimer.cc
|
||||||
|
|
||||||
|
|
||||||
upnp_miniupnpc {
|
upnp_miniupnpc {
|
||||||
|
@ -1322,7 +1322,9 @@ int pqissl::Authorise_SSL_Connection()
|
|||||||
|
|
||||||
if(!rsBanList->isAddressAccepted(remote_addr,checking_flags,&check_result))
|
if(!rsBanList->isAddressAccepted(remote_addr,checking_flags,&check_result))
|
||||||
{
|
{
|
||||||
std::cerr << "(SS) connection attempt from banned IP address " << sockaddr_storage_iptostring(remote_addr) << ". Refusing it. Reason: " << check_result << ". Attack??" << std::endl;
|
std::cerr << "(SS) refusing connection attempt from IP address " << sockaddr_storage_iptostring(remote_addr) << ". Reason: " <<
|
||||||
|
((check_result == RSBANLIST_CHECK_RESULT_NOT_WHITELISTED)?"not whitelisted (peer requires whitelist)":"blacklisted") << std::endl;
|
||||||
|
|
||||||
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_IP_BLACKLISTED, PeerId().toStdString(), sockaddr_storage_iptostring(remote_addr), "", "", check_result);
|
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_IP_BLACKLISTED, PeerId().toStdString(), sockaddr_storage_iptostring(remote_addr), "", "", check_result);
|
||||||
reset_locked();
|
reset_locked();
|
||||||
return 0 ;
|
return 0 ;
|
||||||
|
59
libretroshare/src/util/rsscopetimer.cc
Normal file
59
libretroshare/src/util/rsscopetimer.cc
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* libretroshare/src/util: rsscopetimer.cc
|
||||||
|
*
|
||||||
|
* 3P/PQI network interface for RetroShare.
|
||||||
|
*
|
||||||
|
* Copyright 2013- by Cyril Soler
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License Version 2 as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include "rsscopetimer.h"
|
||||||
|
|
||||||
|
RsScopeTimer::RsScopeTimer(const std::string& name)
|
||||||
|
{
|
||||||
|
_name = name ;
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
|
||||||
|
RsScopeTimer::~RsScopeTimer()
|
||||||
|
{
|
||||||
|
if (!_name.empty())
|
||||||
|
{
|
||||||
|
std::cerr << "Time for \"" << _name << "\": " << duration() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double RsScopeTimer::currentTime()
|
||||||
|
{
|
||||||
|
timeval tv ;
|
||||||
|
gettimeofday(&tv,NULL) ;
|
||||||
|
return (tv.tv_sec % 10000) + tv.tv_usec/1000000.0f ; // the %1000 is here to allow double precision to cover the decimals.
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsScopeTimer::start()
|
||||||
|
{
|
||||||
|
_seconds = currentTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
double RsScopeTimer::duration()
|
||||||
|
{
|
||||||
|
return currentTime() - _seconds;
|
||||||
|
}
|
@ -31,29 +31,22 @@
|
|||||||
// callToMeasure() ;
|
// callToMeasure() ;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
#include <sys/time.h>
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class RsScopeTimer
|
class RsScopeTimer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsScopeTimer(const std::string& name)
|
RsScopeTimer(const std::string& name);
|
||||||
{
|
~RsScopeTimer();
|
||||||
timeval tv ;
|
|
||||||
gettimeofday(&tv,NULL) ;
|
|
||||||
_seconds = (tv.tv_sec % 10000) + tv.tv_usec/1000000.0f ; // the %1000 is here to allow double precision to cover the decimals.
|
|
||||||
_name = name ;
|
|
||||||
}
|
|
||||||
|
|
||||||
~RsScopeTimer()
|
void start();
|
||||||
{
|
double duration();
|
||||||
timeval tv ;
|
|
||||||
gettimeofday(&tv,NULL) ;
|
|
||||||
double ss = (tv.tv_sec % 10000) + tv.tv_usec/1000000.0f ;
|
|
||||||
|
|
||||||
std::cerr << "Time for \"" << _name << "\": " << ss - _seconds << std::endl;
|
private:
|
||||||
}
|
double currentTime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _name ;
|
std::string _name ;
|
||||||
double _seconds ;
|
double _seconds ;
|
||||||
};
|
};
|
||||||
|
@ -44,14 +44,14 @@ PostedListWidget::PostedListWidget(const RsGxsGroupId &postedId, QWidget *parent
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
/* Setup UI helper */
|
/* Setup UI helper */
|
||||||
|
mStateHelper->addWidget(mTokenTypeAllPosts, ui->hotSortButton);
|
||||||
|
mStateHelper->addWidget(mTokenTypeAllPosts, ui->newSortButton);
|
||||||
|
mStateHelper->addWidget(mTokenTypeAllPosts, ui->topSortButton);
|
||||||
|
|
||||||
mStateHelper->addWidget(mTokenTypePosts, ui->hotSortButton);
|
mStateHelper->addWidget(mTokenTypePosts, ui->hotSortButton);
|
||||||
mStateHelper->addWidget(mTokenTypePosts, ui->newSortButton);
|
mStateHelper->addWidget(mTokenTypePosts, ui->newSortButton);
|
||||||
mStateHelper->addWidget(mTokenTypePosts, ui->topSortButton);
|
mStateHelper->addWidget(mTokenTypePosts, ui->topSortButton);
|
||||||
|
|
||||||
mStateHelper->addWidget(mTokenTypeRelatedPosts, ui->hotSortButton);
|
|
||||||
mStateHelper->addWidget(mTokenTypeRelatedPosts, ui->newSortButton);
|
|
||||||
mStateHelper->addWidget(mTokenTypeRelatedPosts, ui->topSortButton);
|
|
||||||
|
|
||||||
mStateHelper->addWidget(mTokenTypeGroupData, ui->submitPostButton);
|
mStateHelper->addWidget(mTokenTypeGroupData, ui->submitPostButton);
|
||||||
mStateHelper->addWidget(mTokenTypeGroupData, ui->subscribeToolButton);
|
mStateHelper->addWidget(mTokenTypeGroupData, ui->subscribeToolButton);
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ void PostedListWidget::processSettings(bool /*load*/)
|
|||||||
|
|
||||||
QIcon PostedListWidget::groupIcon()
|
QIcon PostedListWidget::groupIcon()
|
||||||
{
|
{
|
||||||
if (mStateHelper->isLoading(mTokenTypeGroupData) || mStateHelper->isLoading(mTokenTypePosts)) {
|
if (mStateHelper->isLoading(mTokenTypeGroupData) || mStateHelper->isLoading(mTokenTypeAllPosts)) {
|
||||||
// return QIcon(":/images/kalarm.png");
|
// return QIcon(":/images/kalarm.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,7 +526,7 @@ bool PostedListWidget::insertGroupData(const uint32_t &token, RsGroupMetaData &m
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedListWidget::insertPosts(const uint32_t &token, GxsMessageFramePostThread */*thread*/)
|
void PostedListWidget::insertAllPosts(const uint32_t &token, GxsMessageFramePostThread */*thread*/)
|
||||||
{
|
{
|
||||||
std::vector<RsPostedPost> posts;
|
std::vector<RsPostedPost> posts;
|
||||||
rsPosted->getPostData(token, posts);
|
rsPosted->getPostData(token, posts);
|
||||||
@ -541,10 +541,10 @@ void PostedListWidget::insertPosts(const uint32_t &token, GxsMessageFramePostThr
|
|||||||
applyRanking();
|
applyRanking();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedListWidget::insertRelatedPosts(const uint32_t &token)
|
void PostedListWidget::insertPosts(const uint32_t &token)
|
||||||
{
|
{
|
||||||
std::vector<RsPostedPost> posts;
|
std::vector<RsPostedPost> posts;
|
||||||
rsPosted->getRelatedPosts(token, posts);
|
rsPosted->getPostData(token, posts);
|
||||||
|
|
||||||
std::vector<RsPostedPost>::iterator vit;
|
std::vector<RsPostedPost>::iterator vit;
|
||||||
for(vit = posts.begin(); vit != posts.end(); ++vit)
|
for(vit = posts.begin(); vit != posts.end(); ++vit)
|
||||||
|
@ -60,8 +60,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
/* GxsMessageFramePostWidget */
|
/* GxsMessageFramePostWidget */
|
||||||
virtual bool insertGroupData(const uint32_t &token, RsGroupMetaData &metaData);
|
virtual bool insertGroupData(const uint32_t &token, RsGroupMetaData &metaData);
|
||||||
virtual void insertPosts(const uint32_t &token, GxsMessageFramePostThread *thread);
|
virtual void insertAllPosts(const uint32_t &token, GxsMessageFramePostThread *thread);
|
||||||
virtual void insertRelatedPosts(const uint32_t &token);
|
virtual void insertPosts(const uint32_t &token);
|
||||||
virtual void clearPosts();
|
virtual void clearPosts();
|
||||||
virtual bool navigatePostItem(const RsGxsMessageId& msgId);
|
virtual bool navigatePostItem(const RsGxsMessageId& msgId);
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ GxsMessageFramePostWidget::GxsMessageFramePostWidget(RsGxsIfaceHelper *ifaceImpl
|
|||||||
mFillThread = NULL;
|
mFillThread = NULL;
|
||||||
|
|
||||||
mTokenTypeGroupData = nextTokenType();
|
mTokenTypeGroupData = nextTokenType();
|
||||||
|
mTokenTypeAllPosts = nextTokenType();
|
||||||
mTokenTypePosts = nextTokenType();
|
mTokenTypePosts = nextTokenType();
|
||||||
mTokenTypeRelatedPosts = nextTokenType();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsMessageFramePostWidget::~GxsMessageFramePostWidget()
|
GxsMessageFramePostWidget::~GxsMessageFramePostWidget()
|
||||||
@ -76,7 +76,7 @@ bool GxsMessageFramePostWidget::navigate(const RsGxsMessageId &msgId)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mStateHelper->isLoading(mTokenTypePosts) || mStateHelper->isLoading(mTokenTypeRelatedPosts)) {
|
if (mStateHelper->isLoading(mTokenTypeAllPosts) || mStateHelper->isLoading(mTokenTypePosts)) {
|
||||||
mNavigatePendingMsgId = msgId;
|
mNavigatePendingMsgId = msgId;
|
||||||
|
|
||||||
/* No information if group is available */
|
/* No information if group is available */
|
||||||
@ -88,7 +88,7 @@ bool GxsMessageFramePostWidget::navigate(const RsGxsMessageId &msgId)
|
|||||||
|
|
||||||
bool GxsMessageFramePostWidget::isLoading()
|
bool GxsMessageFramePostWidget::isLoading()
|
||||||
{
|
{
|
||||||
if (mStateHelper->isLoading(mTokenTypePosts) || mStateHelper->isLoading(mTokenTypeRelatedPosts)) {
|
if (mStateHelper->isLoading(mTokenTypeAllPosts) || mStateHelper->isLoading(mTokenTypePosts)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ void GxsMessageFramePostWidget::updateDisplay(bool complete)
|
|||||||
if (complete) {
|
if (complete) {
|
||||||
/* Fill complete */
|
/* Fill complete */
|
||||||
requestGroupData();
|
requestGroupData();
|
||||||
requestPosts();
|
requestAllPosts();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,14 +118,14 @@ void GxsMessageFramePostWidget::updateDisplay(bool complete)
|
|||||||
if (!groupId().isNull() && std::find(grpIds.begin(), grpIds.end(), groupId()) != grpIds.end()) {
|
if (!groupId().isNull() && std::find(grpIds.begin(), grpIds.end(), groupId()) != grpIds.end()) {
|
||||||
updateGroup = true;
|
updateGroup = true;
|
||||||
/* Do we need to fill all posts? */
|
/* Do we need to fill all posts? */
|
||||||
requestPosts();
|
requestAllPosts();
|
||||||
} else {
|
} else {
|
||||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgs;
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgs;
|
||||||
getAllMsgIds(msgs);
|
getAllMsgIds(msgs);
|
||||||
if (!msgs.empty()) {
|
if (!msgs.empty()) {
|
||||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mit = msgs.find(groupId());
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mit = msgs.find(groupId());
|
||||||
if (mit != msgs.end()) {
|
if (mit != msgs.end()) {
|
||||||
requestRelatedPosts(mit->second);
|
requestPosts(mit->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ void GxsMessageFramePostWidget::fillThreadFinished()
|
|||||||
/* Current thread has finished */
|
/* Current thread has finished */
|
||||||
mFillThread = NULL;
|
mFillThread = NULL;
|
||||||
|
|
||||||
mStateHelper->setLoading(mTokenTypePosts, false);
|
mStateHelper->setLoading(mTokenTypeAllPosts, false);
|
||||||
emit groupChanged(this);
|
emit groupChanged(this);
|
||||||
|
|
||||||
if (!mNavigatePendingMsgId.isNull()) {
|
if (!mNavigatePendingMsgId.isNull()) {
|
||||||
@ -258,10 +258,10 @@ void GxsMessageFramePostWidget::loadGroupData(const uint32_t &token)
|
|||||||
emit groupChanged(this);
|
emit groupChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsMessageFramePostWidget::requestPosts()
|
void GxsMessageFramePostWidget::requestAllPosts()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_DEBUG
|
#ifdef ENABLE_DEBUG
|
||||||
std::cerr << "GxsMessageFramePostWidget::requestPosts()";
|
std::cerr << "GxsMessageFramePostWidget::requestAllPosts()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ void GxsMessageFramePostWidget::requestPosts()
|
|||||||
|
|
||||||
/* Request all posts */
|
/* Request all posts */
|
||||||
|
|
||||||
mTokenQueue->cancelActiveRequestTokens(mTokenTypePosts);
|
mTokenQueue->cancelActiveRequestTokens(mTokenTypeAllPosts);
|
||||||
|
|
||||||
if (mFillThread) {
|
if (mFillThread) {
|
||||||
/* Stop current fill thread */
|
/* Stop current fill thread */
|
||||||
@ -277,20 +277,20 @@ void GxsMessageFramePostWidget::requestPosts()
|
|||||||
mFillThread = NULL;
|
mFillThread = NULL;
|
||||||
thread->stop(false);
|
thread->stop(false);
|
||||||
|
|
||||||
mStateHelper->setLoading(mTokenTypePosts, false);
|
mStateHelper->setLoading(mTokenTypeAllPosts, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearPosts();
|
clearPosts();
|
||||||
|
|
||||||
if (groupId().isNull()) {
|
if (groupId().isNull()) {
|
||||||
mStateHelper->setActive(mTokenTypePosts, false);
|
mStateHelper->setActive(mTokenTypeAllPosts, false);
|
||||||
mStateHelper->setLoading(mTokenTypePosts, false);
|
mStateHelper->setLoading(mTokenTypeAllPosts, false);
|
||||||
mStateHelper->clear(mTokenTypePosts);
|
mStateHelper->clear(mTokenTypeAllPosts);
|
||||||
emit groupChanged(this);
|
emit groupChanged(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mStateHelper->setLoading(mTokenTypePosts, true);
|
mStateHelper->setLoading(mTokenTypeAllPosts, true);
|
||||||
emit groupChanged(this);
|
emit groupChanged(this);
|
||||||
|
|
||||||
std::list<RsGxsGroupId> groupIds;
|
std::list<RsGxsGroupId> groupIds;
|
||||||
@ -300,17 +300,17 @@ void GxsMessageFramePostWidget::requestPosts()
|
|||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, mTokenTypePosts);
|
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, mTokenTypeAllPosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsMessageFramePostWidget::loadPosts(const uint32_t &token)
|
void GxsMessageFramePostWidget::loadAllPosts(const uint32_t &token)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_DEBUG
|
#ifdef ENABLE_DEBUG
|
||||||
std::cerr << "GxsMessageFramePostWidget::loadPosts()";
|
std::cerr << "GxsMessageFramePostWidget::loadAllPosts()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mStateHelper->setActive(mTokenTypePosts, true);
|
mStateHelper->setActive(mTokenTypeAllPosts, true);
|
||||||
|
|
||||||
if (useThread()) {
|
if (useThread()) {
|
||||||
/* Create fill thread */
|
/* Create fill thread */
|
||||||
@ -321,15 +321,15 @@ void GxsMessageFramePostWidget::loadPosts(const uint32_t &token)
|
|||||||
connect(mFillThread, SIGNAL(addPost(QVariant,bool,int,int)), this, SLOT(fillThreadAddPost(QVariant,bool,int,int)), Qt::BlockingQueuedConnection);
|
connect(mFillThread, SIGNAL(addPost(QVariant,bool,int,int)), this, SLOT(fillThreadAddPost(QVariant,bool,int,int)), Qt::BlockingQueuedConnection);
|
||||||
|
|
||||||
#ifdef ENABLE_DEBUG
|
#ifdef ENABLE_DEBUG
|
||||||
std::cerr << "GxsMessageFramePostWidget::loadPosts() Start fill thread" << std::endl;
|
std::cerr << "GxsMessageFramePostWidget::loadAllPosts() Start fill thread" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Start thread */
|
/* Start thread */
|
||||||
mFillThread->start();
|
mFillThread->start();
|
||||||
} else {
|
} else {
|
||||||
insertPosts(token, NULL);
|
insertAllPosts(token, NULL);
|
||||||
|
|
||||||
mStateHelper->setLoading(mTokenTypePosts, false);
|
mStateHelper->setLoading(mTokenTypeAllPosts, false);
|
||||||
|
|
||||||
if (!mNavigatePendingMsgId.isNull()) {
|
if (!mNavigatePendingMsgId.isNull()) {
|
||||||
navigate(mNavigatePendingMsgId);
|
navigate(mNavigatePendingMsgId);
|
||||||
@ -341,21 +341,21 @@ void GxsMessageFramePostWidget::loadPosts(const uint32_t &token)
|
|||||||
emit groupChanged(this);
|
emit groupChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsMessageFramePostWidget::requestRelatedPosts(const std::vector<RsGxsMessageId> &msgIds)
|
void GxsMessageFramePostWidget::requestPosts(const std::vector<RsGxsMessageId> &msgIds)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_DEBUG
|
#ifdef ENABLE_DEBUG
|
||||||
std::cerr << "GxsMessageFramePostWidget::requestRelatedPosts()";
|
std::cerr << "GxsMessageFramePostWidget::requestPosts()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mNavigatePendingMsgId.clear();
|
mNavigatePendingMsgId.clear();
|
||||||
|
|
||||||
mTokenQueue->cancelActiveRequestTokens(mTokenTypeRelatedPosts);
|
mTokenQueue->cancelActiveRequestTokens(mTokenTypePosts);
|
||||||
|
|
||||||
if (groupId().isNull()) {
|
if (groupId().isNull()) {
|
||||||
mStateHelper->setActive(mTokenTypeRelatedPosts, false);
|
mStateHelper->setActive(mTokenTypePosts, false);
|
||||||
mStateHelper->setLoading(mTokenTypeRelatedPosts, false);
|
mStateHelper->setLoading(mTokenTypePosts, false);
|
||||||
mStateHelper->clear(mTokenTypeRelatedPosts);
|
mStateHelper->clear(mTokenTypePosts);
|
||||||
emit groupChanged(this);
|
emit groupChanged(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -364,33 +364,30 @@ void GxsMessageFramePostWidget::requestRelatedPosts(const std::vector<RsGxsMessa
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mStateHelper->setLoading(mTokenTypeRelatedPosts, true);
|
mStateHelper->setLoading(mTokenTypePosts, true);
|
||||||
emit groupChanged(this);
|
emit groupChanged(this);
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||||
opts.mOptions = RS_TOKREQOPT_MSG_VERSIONS;
|
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
std::vector<RsGxsGrpMsgIdPair> relatedMsgIds;
|
GxsMsgReq requestMsgIds;
|
||||||
for (std::vector<RsGxsMessageId>::const_iterator msgIt = msgIds.begin(); msgIt != msgIds.end(); ++msgIt) {
|
requestMsgIds[groupId()] = msgIds;
|
||||||
relatedMsgIds.push_back(RsGxsGrpMsgIdPair(groupId(), *msgIt));
|
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, requestMsgIds, mTokenTypePosts);
|
||||||
}
|
|
||||||
mTokenQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, relatedMsgIds, mTokenTypeRelatedPosts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsMessageFramePostWidget::loadRelatedPosts(const uint32_t &token)
|
void GxsMessageFramePostWidget::loadPosts(const uint32_t &token)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_DEBUG
|
#ifdef ENABLE_DEBUG
|
||||||
std::cerr << "GxsMessageFramePostWidget::loadRelatedPosts()";
|
std::cerr << "GxsMessageFramePostWidget::loadPosts()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mStateHelper->setActive(mTokenTypeRelatedPosts, true);
|
mStateHelper->setActive(mTokenTypePosts, true);
|
||||||
|
|
||||||
insertRelatedPosts(token);
|
insertPosts(token);
|
||||||
|
|
||||||
mStateHelper->setLoading(mTokenTypeRelatedPosts, false);
|
mStateHelper->setLoading(mTokenTypePosts, false);
|
||||||
emit groupChanged(this);
|
emit groupChanged(this);
|
||||||
|
|
||||||
if (!mNavigatePendingMsgId.isNull()) {
|
if (!mNavigatePendingMsgId.isNull()) {
|
||||||
@ -414,13 +411,13 @@ void GxsMessageFramePostWidget::loadRequest(const TokenQueue *queue, const Token
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.mUserType == mTokenTypePosts) {
|
if (req.mUserType == mTokenTypeAllPosts) {
|
||||||
loadPosts(req.mToken);
|
loadAllPosts(req.mToken);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.mUserType == mTokenTypeRelatedPosts) {
|
if (req.mUserType == mTokenTypePosts) {
|
||||||
loadRelatedPosts(req.mToken);
|
loadPosts(req.mToken);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -465,7 +462,7 @@ void GxsMessageFramePostThread::run()
|
|||||||
std::cerr << "GxsMessageFramePostThread::run()" << std::endl;
|
std::cerr << "GxsMessageFramePostThread::run()" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mParent->insertPosts(mToken, this);
|
mParent->insertAllPosts(mToken, this);
|
||||||
|
|
||||||
#ifdef ENABLE_DEBUG
|
#ifdef ENABLE_DEBUG
|
||||||
std::cerr << "GxsMessageFramePostThread::run() stopped: " << (stopped() ? "yes" : "no") << std::endl;
|
std::cerr << "GxsMessageFramePostThread::run() stopped: " << (stopped() ? "yes" : "no") << std::endl;
|
||||||
|
@ -68,13 +68,13 @@ protected:
|
|||||||
void loadGroupData(const uint32_t &token);
|
void loadGroupData(const uint32_t &token);
|
||||||
virtual bool insertGroupData(const uint32_t &token, RsGroupMetaData &metaData) = 0;
|
virtual bool insertGroupData(const uint32_t &token, RsGroupMetaData &metaData) = 0;
|
||||||
|
|
||||||
void requestPosts();
|
void requestAllPosts();
|
||||||
void loadPosts(const uint32_t &token);
|
void loadAllPosts(const uint32_t &token);
|
||||||
virtual void insertPosts(const uint32_t &token, GxsMessageFramePostThread *thread) = 0;
|
virtual void insertAllPosts(const uint32_t &token, GxsMessageFramePostThread *thread) = 0;
|
||||||
|
|
||||||
void requestRelatedPosts(const std::vector<RsGxsMessageId> &msgIds);
|
void requestPosts(const std::vector<RsGxsMessageId> &msgIds);
|
||||||
void loadRelatedPosts(const uint32_t &token);
|
void loadPosts(const uint32_t &token);
|
||||||
virtual void insertRelatedPosts(const uint32_t &token) = 0;
|
virtual void insertPosts(const uint32_t &token) = 0;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void fillThreadFinished();
|
void fillThreadFinished();
|
||||||
@ -82,8 +82,8 @@ private slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32_t mTokenTypeGroupData;
|
uint32_t mTokenTypeGroupData;
|
||||||
|
uint32_t mTokenTypeAllPosts;
|
||||||
uint32_t mTokenTypePosts;
|
uint32_t mTokenTypePosts;
|
||||||
uint32_t mTokenTypeRelatedPosts;
|
|
||||||
RsGxsMessageId mNavigatePendingMsgId;
|
RsGxsMessageId mNavigatePendingMsgId;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -55,11 +55,11 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
|
|||||||
|
|
||||||
/* Setup UI helper */
|
/* Setup UI helper */
|
||||||
|
|
||||||
mStateHelper->addWidget(mTokenTypePosts, ui->progressBar, UISTATE_LOADING_VISIBLE);
|
mStateHelper->addWidget(mTokenTypeAllPosts, ui->progressBar, UISTATE_LOADING_VISIBLE);
|
||||||
mStateHelper->addWidget(mTokenTypePosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
|
mStateHelper->addWidget(mTokenTypeAllPosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
|
||||||
mStateHelper->addWidget(mTokenTypePosts, ui->filterLineEdit);
|
mStateHelper->addWidget(mTokenTypeAllPosts, ui->filterLineEdit);
|
||||||
|
|
||||||
mStateHelper->addWidget(mTokenTypeRelatedPosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
|
mStateHelper->addWidget(mTokenTypePosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
|
||||||
|
|
||||||
mStateHelper->addLoadPlaceholder(mTokenTypeGroupData, ui->nameLabel);
|
mStateHelper->addLoadPlaceholder(mTokenTypeGroupData, ui->nameLabel);
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ void GxsChannelPostsWidget::groupNameChanged(const QString &name)
|
|||||||
|
|
||||||
QIcon GxsChannelPostsWidget::groupIcon()
|
QIcon GxsChannelPostsWidget::groupIcon()
|
||||||
{
|
{
|
||||||
if (mStateHelper->isLoading(mTokenTypeGroupData) || mStateHelper->isLoading(mTokenTypePosts)) {
|
if (mStateHelper->isLoading(mTokenTypeGroupData) || mStateHelper->isLoading(mTokenTypeAllPosts)) {
|
||||||
return QIcon(":/images/kalarm.png");
|
return QIcon(":/images/kalarm.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,7 +488,7 @@ bool GxsChannelPostsWidget::insertGroupData(const uint32_t &token, RsGroupMetaDa
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::insertPosts(const uint32_t &token, GxsMessageFramePostThread *thread)
|
void GxsChannelPostsWidget::insertAllPosts(const uint32_t &token, GxsMessageFramePostThread *thread)
|
||||||
{
|
{
|
||||||
std::vector<RsGxsChannelPost> posts;
|
std::vector<RsGxsChannelPost> posts;
|
||||||
rsGxsChannels->getPostData(token, posts);
|
rsGxsChannels->getPostData(token, posts);
|
||||||
@ -496,10 +496,10 @@ void GxsChannelPostsWidget::insertPosts(const uint32_t &token, GxsMessageFramePo
|
|||||||
insertChannelPosts(posts, thread, false);
|
insertChannelPosts(posts, thread, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::insertRelatedPosts(const uint32_t &token)
|
void GxsChannelPostsWidget::insertPosts(const uint32_t &token)
|
||||||
{
|
{
|
||||||
std::vector<RsGxsChannelPost> posts;
|
std::vector<RsGxsChannelPost> posts;
|
||||||
rsGxsChannels->getRelatedPosts(token, posts);
|
rsGxsChannels->getPostData(token, posts);
|
||||||
|
|
||||||
insertChannelPosts(posts, NULL, true);
|
insertChannelPosts(posts, NULL, true);
|
||||||
}
|
}
|
||||||
|
@ -67,8 +67,8 @@ protected:
|
|||||||
/* GxsMessageFramePostWidget */
|
/* GxsMessageFramePostWidget */
|
||||||
virtual void groupNameChanged(const QString &name);
|
virtual void groupNameChanged(const QString &name);
|
||||||
virtual bool insertGroupData(const uint32_t &token, RsGroupMetaData &metaData);
|
virtual bool insertGroupData(const uint32_t &token, RsGroupMetaData &metaData);
|
||||||
virtual void insertPosts(const uint32_t &token, GxsMessageFramePostThread *thread);
|
virtual void insertAllPosts(const uint32_t &token, GxsMessageFramePostThread *thread);
|
||||||
virtual void insertRelatedPosts(const uint32_t &token);
|
virtual void insertPosts(const uint32_t &token);
|
||||||
virtual void clearPosts();
|
virtual void clearPosts();
|
||||||
virtual bool useThread() { return mUseThread; }
|
virtual bool useThread() { return mUseThread; }
|
||||||
virtual void fillThreadCreatePost(const QVariant &post, bool related, int current, int count);
|
virtual void fillThreadCreatePost(const QVariant &post, bool related, int current, int count);
|
||||||
|
Loading…
Reference in New Issue
Block a user