From f420bb46447b53837f04d2b1b46ba8168d2d6768 Mon Sep 17 00:00:00 2001 From: Phenom Date: Wed, 26 Sep 2018 17:36:33 +0200 Subject: [PATCH 01/39] Fix qmake warnings: Makefile.libretroshare:3811: warning: overriding recipe for target 'temp/linux-g++/obj/hashstream.o' Makefile.libretroshare:3772: warning: ignoring old recipe for target 'temp/linux-g++/obj/hashstream.o' --- libretroshare/src/libretroshare.pro | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 4bafccec7..632f905b4 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -530,10 +530,9 @@ SOURCES += ft/ftchunkmap.cc \ ft/ftturtlefiletransferitem.cc SOURCES += crypto/chacha20.cpp \ - crypto/rsaes.cc \ - crypto/hashstream.cc\ - crypto/hashstream.cc \ - crypto/rscrypto.cpp + crypto/hashstream.cc\ + crypto/rsaes.cc \ + crypto/rscrypto.cpp SOURCES += chat/distantchat.cc \ chat/p3chatservice.cc \ From 590edb72f4645b3081b21ffe4f90d54c0c652fa3 Mon Sep 17 00:00:00 2001 From: Phenom Date: Wed, 26 Sep 2018 17:44:32 +0200 Subject: [PATCH 02/39] Fix qmake warnings: Makefile.retroshare-gui:7593: warning: overriding recipe for target 'temp/moc/moc_TorProcess_p.cpp' Makefile.retroshare-gui:7572: warning: ignoring old recipe for target 'temp/moc/moc_TorProcess_p.cpp' --- retroshare-gui/src/retroshare-gui.pro | 37 +++++++++++++-------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index e6e75db9e..b5fa1960d 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -283,25 +283,24 @@ wikipoos { # Tor controller HEADERS += TorControl/AddOnionCommand.h \ - TorControl/AuthenticateCommand.h \ - TorControl/GetConfCommand.h \ - TorControl/HiddenService.h \ - TorControl/ProtocolInfoCommand.h \ - TorControl/SetConfCommand.h \ - TorControl/TorControlCommand.h \ - TorControl/TorControl.h \ - TorControl/TorControlSocket.h \ - TorControl/TorManager.h \ - TorControl/TorProcess.h \ - TorControl/TorProcess_p.h \ - TorControl/TorSocket.h \ - TorControl/Useful.h \ - TorControl/CryptoKey.h \ - TorControl/PendingOperation.h \ - TorControl/SecureRNG.h \ - TorControl/Settings.h \ - TorControl/StrUtil.h \ - TorControl/TorProcess_p.h + TorControl/AuthenticateCommand.h \ + TorControl/CryptoKey.h \ + TorControl/GetConfCommand.h \ + TorControl/HiddenService.h \ + TorControl/PendingOperation.h \ + TorControl/ProtocolInfoCommand.h \ + TorControl/SecureRNG.h \ + TorControl/SetConfCommand.h \ + TorControl/Settings.h \ + TorControl/StrUtil.h \ + TorControl/TorControl.h \ + TorControl/TorControlCommand.h \ + TorControl/TorControlSocket.h \ + TorControl/TorManager.h \ + TorControl/TorProcess.h \ + TorControl/TorProcess_p.h \ + TorControl/TorSocket.h \ + TorControl/Useful.h SOURCES += TorControl/AddOnionCommand.cpp \ TorControl/AuthenticateCommand.cpp \ From aec68c2269cc1f6c706a6c487c0233cecfc70f80 Mon Sep 17 00:00:00 2001 From: Phenom Date: Wed, 26 Sep 2018 17:55:58 +0200 Subject: [PATCH 03/39] Fix qmake double using retroshare.pri From 544b4af4c23da1c73aaef3ad357975e30562a00f --- libretroshare/src/libretroshare.pro | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 632f905b4..dc56e20c2 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -17,10 +17,6 @@ ################################################################################ !include("../../retroshare.pri"): error("Could not include file ../../retroshare.pri") -TEMPLATE = lib -CONFIG += staticlib -!include("../../retroshare.pri"): error("Could not include file ../../retroshare.pri") - TEMPLATE = lib CONFIG += staticlib CONFIG -= qt From a6e3273ecbb7176bf7d74d53dacadb8a83648b1c Mon Sep 17 00:00:00 2001 From: Phenom Date: Wed, 26 Sep 2018 18:02:04 +0200 Subject: [PATCH 04/39] Fix qmake double use_libretroshare.pri --- retroshare-gui/src/retroshare-gui.pro | 3 ++- retroshare-nogui/src/retroshare-nogui.pro | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index b5fa1960d..e83ad180c 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -15,6 +15,8 @@ libresapihttpserver { HEADERS *= gui/settings/WebuiPage.h SOURCES *= gui/settings/WebuiPage.cpp FORMS *= gui/settings/WebuiPage.ui +} else { + !include("../../libretroshare/src/use_libretroshare.pri"):error("Including") } rs_jsonapi { @@ -23,7 +25,6 @@ rs_jsonapi { FORMS *= gui/settings/JsonApiPage.ui } -!include("../../libretroshare/src/use_libretroshare.pri"):error("Including") FORMS += TorControl/TorControlWindow.ui SOURCES += TorControl/TorControlWindow.cpp diff --git a/retroshare-nogui/src/retroshare-nogui.pro b/retroshare-nogui/src/retroshare-nogui.pro index 05f5e99e1..ef335e48f 100644 --- a/retroshare-nogui/src/retroshare-nogui.pro +++ b/retroshare-nogui/src/retroshare-nogui.pro @@ -12,9 +12,10 @@ libresapihttpserver { HEADERS += TerminalApiClient.h SOURCES += TerminalApiClient.cpp +} else { + !include("../../libretroshare/src/use_libretroshare.pri"):error("Including") } -!include("../../libretroshare/src/use_libretroshare.pri"):error("Including") ################################# Linux ########################################## From 1383846364412e6ef2951156281c8ff5d16136b1 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 27 Sep 2018 13:42:49 +0200 Subject: [PATCH 05/39] added extra list view in own files. --- .../src/file_sharing/dir_hierarchy.cc | 7 +- .../src/file_sharing/file_sharing_defaults.h | 1 + libretroshare/src/file_sharing/p3filelists.cc | 112 ++++++++++++++++-- libretroshare/src/file_sharing/p3filelists.h | 9 +- libretroshare/src/ft/ftextralist.cc | 29 +++-- libretroshare/src/ft/ftextralist.h | 7 ++ libretroshare/src/ft/ftserver.cc | 3 + libretroshare/src/retroshare/rstypes.h | 1 + retroshare-gui/src/gui/RemoteDirModel.cpp | 4 +- 9 files changed, 149 insertions(+), 24 deletions(-) diff --git a/libretroshare/src/file_sharing/dir_hierarchy.cc b/libretroshare/src/file_sharing/dir_hierarchy.cc index 743176e38..b6208eb57 100644 --- a/libretroshare/src/file_sharing/dir_hierarchy.cc +++ b/libretroshare/src/file_sharing/dir_hierarchy.cc @@ -865,7 +865,7 @@ void InternalFileHierarchyStorage::print() const for(uint32_t i=0;itype() == FileStorageNode::TYPE_DIR) @@ -1183,6 +1183,11 @@ bool InternalFileHierarchyStorage::load(const std::string& fname) } free(buffer) ; + std::string err_str ; + + if(!check(err_str)) + std::cerr << "(EE) Error while loading file hierarchy " << fname << std::endl; + return true ; } catch(read_error& e) diff --git a/libretroshare/src/file_sharing/file_sharing_defaults.h b/libretroshare/src/file_sharing/file_sharing_defaults.h index 6633e348f..75f19075a 100644 --- a/libretroshare/src/file_sharing/file_sharing_defaults.h +++ b/libretroshare/src/file_sharing/file_sharing_defaults.h @@ -25,6 +25,7 @@ static const uint32_t DELAY_BETWEEN_DIRECTORY_UPDATES = 600 ; // 10 m static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORY_SYNC_REQ = 120 ; // 2 minutes static const uint32_t DELAY_BETWEEN_LOCAL_DIRECTORIES_TS_UPDATE = 20 ; // 20 sec. But we only update for real if something has changed. static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORIES_SWEEP = 60 ; // 60 sec. +static const uint32_t DELAY_BETWEEN_EXTRA_FILES_CACHE_UPDATES = 2 ; // 2 sec. static const uint32_t DELAY_BEFORE_DELETE_NON_EMPTY_REMOTE_DIR = 60*24*86400 ; // delete non empty remoe directories after 60 days of inactivity static const uint32_t DELAY_BEFORE_DELETE_EMPTY_REMOTE_DIR = 5*24*86400 ; // delete empty remote directories after 5 days of inactivity diff --git a/libretroshare/src/file_sharing/p3filelists.cc b/libretroshare/src/file_sharing/p3filelists.cc index 156490e18..c6ee048be 100644 --- a/libretroshare/src/file_sharing/p3filelists.cc +++ b/libretroshare/src/file_sharing/p3filelists.cc @@ -38,6 +38,7 @@ //#define DEBUG_P3FILELISTS 1 #define DEBUG_CONTENT_FILTERING 1 +#define DEBUG_FILE_HIERARCHY 1 static const uint32_t P3FILELISTS_UPDATE_FLAG_NOTHING_CHANGED = 0x0000 ; static const uint32_t P3FILELISTS_UPDATE_FLAG_REMOTE_MAP_CHANGED = 0x0001 ; @@ -71,6 +72,7 @@ p3FileDatabase::p3FileDatabase(p3ServiceControl *mpeers) mUpdateFlags = P3FILELISTS_UPDATE_FLAG_NOTHING_CHANGED ; mLastRemoteDirSweepTS = 0 ; + mLastExtraFilesCacheUpdate = 0; mLastCleanupTime = 0 ; mLastDataRecvTS = 0 ; mTrustFriendNodesForBannedFiles = TRUST_FRIEND_NODES_FOR_BANNED_FILES_DEFAULT; @@ -884,6 +886,8 @@ void p3FileDatabase::requestDirUpdate(void *ref) } } +// Finds the pointer to the sub-element #row under element ref. + bool p3FileDatabase::findChildPointer( void *ref, int row, void *& result, FileSearchFlags flags ) const { @@ -891,10 +895,10 @@ bool p3FileDatabase::findChildPointer( void *ref, int row, void *& result, { if(flags & RS_FILE_HINTS_LOCAL) { - if(row != 0) + if(row != 0 && row != 1) return false ; - convertEntryIndexToPointer(0,0,result); + convertEntryIndexToPointer(0,row,result); return true ; } @@ -913,12 +917,18 @@ bool p3FileDatabase::findChildPointer( void *ref, int row, void *& result, convertPointerToEntryIndex(ref,e,fi); // check consistency - if( (fi == 0 && !(flags & RS_FILE_HINTS_LOCAL)) || (fi > 0 && (flags & RS_FILE_HINTS_LOCAL))) + if( (fi == 0 && !(flags & RS_FILE_HINTS_LOCAL)) || (fi > 1 && (flags & RS_FILE_HINTS_LOCAL))) { P3FILELISTS_ERROR() << "(EE) remote request on local index or local request on remote index. This should not happen." << std::endl; return false ; } - DirectoryStorage *storage = (fi==0)? ((DirectoryStorage*)mLocalSharedDirs) : ((DirectoryStorage*)mRemoteDirectories[fi-1]); + + if(fi==1 && (flags & RS_FILE_HINTS_LOCAL)) // extra list + { + convertEntryIndexToPointer(row+1,1,result); + return true; + } + DirectoryStorage *storage = (flags & RS_FILE_HINTS_LOCAL)? ((DirectoryStorage*)mLocalSharedDirs) : ((DirectoryStorage*)mRemoteDirectories[fi-1]); // Case where the index is the top of a single person. Can be us, or a friend. @@ -950,6 +960,65 @@ int p3FileDatabase::getSharedDirStatistics(const RsPeerId& pid,SharedDirStats& s } } +void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIndex e,DirDetails& d) const +{ + // update the cache of extra files if last requested too long ago + + time_t now = time(NULL); + + if(mLastExtraFilesCacheUpdate + DELAY_BETWEEN_EXTRA_FILES_CACHE_UPDATES <= now) + { + mExtraFiles->getExtraFileList(mExtraFilesCache); + mLastExtraFilesCacheUpdate = now; + } + + // + + if(e == 0) // "virtual extra files directory" => create a dir with as many child as they are extra files + { + d.parent = NULL ; + + d.prow = 0;//fi-1 ; + d.type = DIR_TYPE_DIR; + d.hash.clear() ; + d.count = mExtraFilesCache.size(); + d.max_mtime = time(NULL); + d.mtime = time(NULL); + d.name = "Temporary shared files"; + d.path = "/"; + d.ref = ref ; + + for(uint32_t i=0;i(i,1,stub.ref); // local shared files from extra list + + d.children.push_back(stub); + } + } + else // extra file. Just query the corresponding data from ftExtra + { + d.prow = 1;//fi-1 ; + d.type = DIR_TYPE_FILE; + + FileInfo& f(mExtraFilesCache[(int)e-1]) ; + + d.hash = f.hash; + d.count = 0; + d.max_mtime = time(NULL); + d.mtime = time(NULL); + d.name = f.fname; + d.path = "/"; + d.ref = ref ; + + convertEntryIndexToPointer(0,1,d.parent) ; + } + + d.id = RsPeerId(); +} + // This function converts a pointer into directory details, to be used by the AbstractItemModel for browsing the files. int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags flags) const { @@ -975,10 +1044,8 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags { d.ref = NULL ; d.type = DIR_TYPE_ROOT; - d.count = 1; d.parent = NULL; d.prow = -1; - d.ref = NULL; d.name = "root"; d.hash.clear() ; d.path = ""; @@ -989,13 +1056,26 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags if(flags & RS_FILE_HINTS_LOCAL) { void *p; - convertEntryIndexToPointer(0,0,p); + { + convertEntryIndexToPointer(0,0,p); // root of own directories DirStub stub; stub.type = DIR_TYPE_PERSON; stub.name = mServCtrl->getOwnId().toStdString(); stub.ref = p; d.children.push_back(stub); + } + { + convertEntryIndexToPointer(0,1,p); // local shared files from extra list + DirStub stub; + stub.type = DIR_TYPE_PERSON; + stub.name = "Temporary shared files"; + stub.ref = p; + + d.children.push_back(stub); + } + + } else for(uint32_t i=0;i(ref,e,fi); // check consistency - if( (fi == 0 && !(flags & RS_FILE_HINTS_LOCAL)) || (fi > 0 && (flags & RS_FILE_HINTS_LOCAL))) + if( (fi == 0 && !(flags & RS_FILE_HINTS_LOCAL)) || (fi > 1 && (flags & RS_FILE_HINTS_LOCAL))) { P3FILELISTS_ERROR() << "(EE) remote request on local index or local request on remote index. This should not happen." << std::endl; return false ; } - DirectoryStorage *storage = (fi==0)? ((DirectoryStorage*)mLocalSharedDirs) : ((DirectoryStorage*)mRemoteDirectories[fi-1]); + + if((flags & RS_FILE_HINTS_LOCAL) && fi == 1) // extra list + { + getExtraFilesDirDetails(ref,e,d); + +#ifdef DEBUG_FILE_HIERARCHY + P3FILELISTS_DEBUG() << "ExtractData: ref=" << ref << ", flags=" << flags << " : returning this: " << std::endl; + P3FILELISTS_DEBUG() << d << std::endl; +#endif + return true; + } + + + DirectoryStorage *storage = (flags & RS_FILE_HINTS_LOCAL)? ((DirectoryStorage*)mLocalSharedDirs) : ((DirectoryStorage*)mRemoteDirectories[fi-1]); // Case where the index is the top of a single person. Can be us, or a friend. diff --git a/libretroshare/src/file_sharing/p3filelists.h b/libretroshare/src/file_sharing/p3filelists.h index a8ac377ea..8e35c0bf2 100644 --- a/libretroshare/src/file_sharing/p3filelists.h +++ b/libretroshare/src/file_sharing/p3filelists.h @@ -45,6 +45,7 @@ #pragma once #include "ft/ftsearch.h" +#include "ft/ftextralist.h" #include "retroshare/rsfiles.h" #include "services/p3service.h" @@ -87,9 +88,10 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub // [...] more to add here }; - explicit p3FileDatabase(p3ServiceControl *mpeers) ; + explicit p3FileDatabase(p3ServiceControl *mpeers); ~p3FileDatabase(); + void setExtraList(ftExtraList *f) { mExtraFiles = f ; } /*! * \brief forceSyncWithPeers * @@ -169,6 +171,7 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub bool hashingProcessPaused(); protected: + void getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIndex e,DirDetails& d) const; int filterResults(const std::list& firesults,std::list& results,FileSearchFlags flags,const RsPeerId& peer_id) const; std::string makeRemoteFileName(const RsPeerId& pid) const; @@ -219,8 +222,8 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub std::vector mRemoteDirectories ; LocalDirectoryStorage *mLocalSharedDirs ; - LocalDirectoryUpdater *mLocalDirWatcher ; + ftExtraList *mExtraFiles; // utility functions to make/get a pointer out of an (EntryIndex,PeerId) pair. This is further documented in the .cc @@ -268,6 +271,8 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub std::map mPrimaryBanList ; // primary list (user controlled) of files banned from FT search and forwarding. map std::map mPeerBannedFiles ; // records of which files other peers ban, stored as H(H(f)) std::set mBannedFileList ; // list of banned hashes. This include original hashs and H(H(f)) when coming from friends. + mutable std::vector mExtraFilesCache; // cache for extra files, to avoid requesting them too often. + mutable time_t mLastExtraFilesCacheUpdate ; bool mTrustFriendNodesForBannedFiles ; bool mBannedFileListNeedsUpdate; time_t mLastPrimaryBanListChangeTimeStamp; diff --git a/libretroshare/src/ft/ftextralist.cc b/libretroshare/src/ft/ftextralist.cc index cf5a4f603..a8ad41b23 100644 --- a/libretroshare/src/ft/ftextralist.cc +++ b/libretroshare/src/ft/ftextralist.cc @@ -96,7 +96,7 @@ void ftExtraList::hashAFile() FileDetails details; { - RsStackMutex stack(extMutex); + RS_STACK_MUTEX(extMutex); if (mToHash.empty()) return; @@ -116,7 +116,7 @@ void ftExtraList::hashAFile() if (RsDirUtil::hashFile(details.info.path, details.info.fname, details.info.hash, details.info.size)) { - RsStackMutex stack(extMutex); + RS_STACK_MUTEX(extMutex); /* stick it in the available queue */ mFiles[details.info.hash] = details; @@ -146,7 +146,7 @@ bool ftExtraList::addExtraFile(std::string path, const RsFileHash& hash, std::cerr << std::endl; #endif - RsStackMutex stack(extMutex); + RS_STACK_MUTEX(extMutex); FileDetails details; @@ -179,7 +179,7 @@ bool ftExtraList::removeExtraFile(const RsFileHash& hash, TransferRequestFlags f std::cerr << std::endl; #endif - RsStackMutex stack(extMutex); + RS_STACK_MUTEX(extMutex); mHashOfHash.erase(makeEncryptedHash(hash)) ; @@ -230,7 +230,7 @@ bool ftExtraList::cleanupOldFiles() std::cerr << std::endl; #endif - RsStackMutex stack(extMutex); + RS_STACK_MUTEX(extMutex); time_t now = time(NULL); @@ -286,7 +286,7 @@ bool ftExtraList::hashExtraFile(std::string path, uint32_t period, TransferRequ #endif /* add into queue */ - RsStackMutex stack(extMutex); + RS_STACK_MUTEX(extMutex); FileDetails details(path, period, flags); details.info.age = time(NULL) + period; @@ -305,7 +305,7 @@ bool ftExtraList::hashExtraFileDone(std::string path, FileInfo &info) RsFileHash hash; { /* Find in the path->hash map */ - RsStackMutex stack(extMutex); + RS_STACK_MUTEX(extMutex); std::map::iterator it; if (mHashedList.end() == (it = mHashedList.find(path))) @@ -420,7 +420,7 @@ bool ftExtraList::saveList(bool &cleanup, std::list& sList) std::cerr << std::endl; #endif - RsStackMutex stack(extMutex); + RS_STACK_MUTEX(extMutex); std::map::const_iterator it; @@ -489,8 +489,8 @@ bool ftExtraList::loadList(std::list& load) /* add into system */ FileDetails file; - RsStackMutex stack(extMutex); - + RS_STACK_MUTEX(extMutex); + FileDetails details; details.info.path = fi->file.path; @@ -513,3 +513,12 @@ bool ftExtraList::loadList(std::list& load) return true; } +void ftExtraList::getExtraFileList(std::vector& files) const +{ + RS_STACK_MUTEX(extMutex); + + files.clear(); + + for(auto it(mFiles.begin());it!=mFiles.end();++it) + files.push_back(it->second.info); +} diff --git a/libretroshare/src/ft/ftextralist.h b/libretroshare/src/ft/ftextralist.h index 5832b33fd..8f6b3cbd2 100644 --- a/libretroshare/src/ft/ftextralist.h +++ b/libretroshare/src/ft/ftextralist.h @@ -137,6 +137,12 @@ public: **/ virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const; + /*! + * \brief getExtraFileList + * Retrieves the list for display purposes + */ + void getExtraFileList(std::vector& files) const ; + /*** * Thread Main Loop **/ @@ -146,6 +152,7 @@ public: * Configuration - store extra files. * **/ + protected: virtual RsSerialiser *setupSerialiser(); virtual bool saveList(bool &cleanup, std::list&); diff --git a/libretroshare/src/ft/ftserver.cc b/libretroshare/src/ft/ftserver.cc index 182964446..cf81cbcc8 100644 --- a/libretroshare/src/ft/ftserver.cc +++ b/libretroshare/src/ft/ftserver.cc @@ -174,8 +174,11 @@ void ftServer::SetupFtServer() void ftServer::connectToFileDatabase(p3FileDatabase *fdb) { mFileDatabase = fdb ; + mFtSearch->addSearchMode(fdb, RS_FILE_HINTS_LOCAL); // due to a bug in addSearchModule, modules can only be added one by one. Using | between flags wont work. mFtSearch->addSearchMode(fdb, RS_FILE_HINTS_REMOTE); + + mFileDatabase->setExtraList(mFtExtra); } void ftServer::connectToTurtleRouter(p3turtle *fts) { diff --git a/libretroshare/src/retroshare/rstypes.h b/libretroshare/src/retroshare/rstypes.h index b1b35748c..9b480f6f8 100644 --- a/libretroshare/src/retroshare/rstypes.h +++ b/libretroshare/src/retroshare/rstypes.h @@ -160,6 +160,7 @@ struct PeerBandwidthLimits : RsSerializable #define DIR_TYPE_PERSON 0x02 #define DIR_TYPE_DIR 0x04 #define DIR_TYPE_FILE 0x08 +#define DIR_TYPE_EXTRA 0x10 /* flags for Directry request - * two types; diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index 22fb0af5b..8eee722c7 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -1158,9 +1158,9 @@ void FlatStyle_RDM::postMods() bool RetroshareDirModel::requestDirDetails(void *ref, bool remote,DirDetails& d) const { -#ifdef RDM_DEBUG +//#ifdef RDM_DEBUG std::cerr << "RequestDirDetails:: ref = " << ref << ", remote=" << remote << std::endl; -#endif +//#endif // We look in cache and re-use the last result if the reference and remote are the same. From 7ab7c7db93a4287d801a8c52ba590b84f23b5f57 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 27 Sep 2018 16:53:08 +0200 Subject: [PATCH 06/39] added possibility to remove extra shared file --- libretroshare/src/file_sharing/p3filelists.cc | 41 +++++++-- libretroshare/src/file_sharing/p3filelists.h | 5 +- libretroshare/src/ft/ftextralist.cc | 4 +- libretroshare/src/ft/ftextralist.h | 2 +- libretroshare/src/ft/ftserver.cc | 9 +- libretroshare/src/ft/ftserver.h | 2 +- libretroshare/src/retroshare/rsfiles.h | 2 +- libretroshare/src/retroshare/rstypes.h | 2 +- libretroshare/src/services/p3gxschannels.cc | 4 +- .../gui/FileTransfer/SharedFilesDialog.cpp | 92 ++++++++++++------- .../src/gui/FileTransfer/SharedFilesDialog.h | 2 + retroshare-gui/src/gui/RemoteDirModel.cpp | 27 +++--- retroshare-gui/src/gui/feeds/SubFileItem.cpp | 2 +- 13 files changed, 125 insertions(+), 69 deletions(-) diff --git a/libretroshare/src/file_sharing/p3filelists.cc b/libretroshare/src/file_sharing/p3filelists.cc index c6ee048be..4a0b92d4f 100644 --- a/libretroshare/src/file_sharing/p3filelists.cc +++ b/libretroshare/src/file_sharing/p3filelists.cc @@ -37,8 +37,8 @@ #define P3FILELISTS_ERROR() std::cerr << "***ERROR***" << " : FILE_LISTS : " << __FUNCTION__ << " : " //#define DEBUG_P3FILELISTS 1 -#define DEBUG_CONTENT_FILTERING 1 -#define DEBUG_FILE_HIERARCHY 1 +//#define DEBUG_CONTENT_FILTERING 1 +//#define DEBUG_FILE_HIERARCHY 1 static const uint32_t P3FILELISTS_UPDATE_FLAG_NOTHING_CHANGED = 0x0000 ; static const uint32_t P3FILELISTS_UPDATE_FLAG_REMOTE_MAP_CHANGED = 0x0001 ; @@ -960,6 +960,14 @@ int p3FileDatabase::getSharedDirStatistics(const RsPeerId& pid,SharedDirStats& s } } +void p3FileDatabase::removeExtraFile(const RsFileHash& hash) +{ + RS_STACK_MUTEX(mFLSMtx) ; + + mExtraFiles->removeExtraFile(hash); + mLastExtraFilesCacheUpdate = 0 ; // forced cache reload +} + void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIndex e,DirDetails& d) const { // update the cache of extra files if last requested too long ago @@ -1001,7 +1009,7 @@ void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIn else // extra file. Just query the corresponding data from ftExtra { d.prow = 1;//fi-1 ; - d.type = DIR_TYPE_FILE; + d.type = DIR_TYPE_EXTRA_FILE; FileInfo& f(mExtraFilesCache[(int)e-1]) ; @@ -1068,7 +1076,7 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags { convertEntryIndexToPointer(0,1,p); // local shared files from extra list DirStub stub; - stub.type = DIR_TYPE_PERSON; + stub.type = DIR_TYPE_PERSON; // not totally exact, but used as a trick. stub.name = "Temporary shared files"; stub.ref = p; @@ -1179,7 +1187,7 @@ int p3FileDatabase::RequestDirDetails(const RsPeerId &/*uid*/, const std::string // NOT_IMPLEMENTED(); // return 0; //} -uint32_t p3FileDatabase::getType(void *ref) const +uint32_t p3FileDatabase::getType(void *ref,FileSearchFlags flags) const { RS_STACK_MUTEX(mFLSMtx) ; @@ -1194,12 +1202,25 @@ uint32_t p3FileDatabase::getType(void *ref) const if(e == 0) return DIR_TYPE_PERSON ; - if(fi == 0 && mLocalSharedDirs != NULL) - return mLocalSharedDirs->getEntryType(e) ; - else if(fi-1 < mRemoteDirectories.size() && mRemoteDirectories[fi-1]!=NULL) - return mRemoteDirectories[fi-1]->getEntryType(e) ; - else + if(flags & RS_FILE_HINTS_LOCAL) + { + if(fi == 0 && mLocalSharedDirs != NULL) + return mLocalSharedDirs->getEntryType(e) ; + + if(fi == 1) + return DIR_TYPE_EXTRA_FILE; + + P3FILELISTS_ERROR() << " Cannot determine type of entry " << ref << std::endl; return DIR_TYPE_ROOT ;// some failure case. Should not happen + } + else + { + if(fi-1 < mRemoteDirectories.size() && mRemoteDirectories[fi-1]!=NULL) + return mRemoteDirectories[fi-1]->getEntryType(e) ; + + P3FILELISTS_ERROR() << " Cannot determine type of entry " << ref << std::endl; + return DIR_TYPE_ROOT ;// some failure case. Should not happen + } } void p3FileDatabase::forceDirectoryCheck() // Force re-sweep the directories and see what's changed diff --git a/libretroshare/src/file_sharing/p3filelists.h b/libretroshare/src/file_sharing/p3filelists.h index 8e35c0bf2..b6d88328a 100644 --- a/libretroshare/src/file_sharing/p3filelists.h +++ b/libretroshare/src/file_sharing/p3filelists.h @@ -109,6 +109,9 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub virtual int SearchKeywords(const std::list& keywords, std::list& results,FileSearchFlags flags,const RsPeerId& peer_id) ; virtual int SearchBoolExp(RsRegularExpression::Expression *exp, std::list& results,FileSearchFlags flags,const RsPeerId& peer_id) const ; + // Extra file list + virtual void removeExtraFile(const RsFileHash& hash); + // Interface for browsing dir hierarchy // @@ -121,7 +124,7 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub void requestDirUpdate(void *ref) ; // triggers an update. Used when browsing. int RequestDirDetails(void *, DirDetails&, FileSearchFlags) const ; - uint32_t getType(void *) const ; + uint32_t getType(void *, FileSearchFlags flags) const ; // proxy method used by the web UI. Dont't delete! int RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails &details)const; diff --git a/libretroshare/src/ft/ftextralist.cc b/libretroshare/src/ft/ftextralist.cc index a8ad41b23..d15a848bb 100644 --- a/libretroshare/src/ft/ftextralist.cc +++ b/libretroshare/src/ft/ftextralist.cc @@ -166,11 +166,9 @@ bool ftExtraList::addExtraFile(std::string path, const RsFileHash& hash, return true; } -bool ftExtraList::removeExtraFile(const RsFileHash& hash, TransferRequestFlags flags) +bool ftExtraList::removeExtraFile(const RsFileHash& hash) { /* remove unused parameter warnings */ - (void) flags; - #ifdef DEBUG_ELIST std::cerr << "ftExtraList::removeExtraFile()"; std::cerr << " hash: " << hash; diff --git a/libretroshare/src/ft/ftextralist.h b/libretroshare/src/ft/ftextralist.h index 8f6b3cbd2..bc470e677 100644 --- a/libretroshare/src/ft/ftextralist.h +++ b/libretroshare/src/ft/ftextralist.h @@ -117,7 +117,7 @@ public: bool addExtraFile(std::string path, const RsFileHash &hash, uint64_t size, uint32_t period, TransferRequestFlags flags); - bool removeExtraFile(const RsFileHash& hash, TransferRequestFlags flags); + bool removeExtraFile(const RsFileHash& hash); bool moveExtraFile(std::string fname, const RsFileHash& hash, uint64_t size, std::string destpath); diff --git a/libretroshare/src/ft/ftserver.cc b/libretroshare/src/ft/ftserver.cc index cf81cbcc8..227f84d23 100644 --- a/libretroshare/src/ft/ftserver.cc +++ b/libretroshare/src/ft/ftserver.cc @@ -677,9 +677,10 @@ bool ftServer::ExtraFileAdd(std::string fname, const RsFileHash& hash, uint64_t return mFtExtra->addExtraFile(fname, hash, size, period, flags); } -bool ftServer::ExtraFileRemove(const RsFileHash& hash, TransferRequestFlags flags) +bool ftServer::ExtraFileRemove(const RsFileHash& hash) { - return mFtExtra->removeExtraFile(hash, flags); + mFileDatabase->removeExtraFile(hash); + return true; } bool ftServer::ExtraFileHash(std::string localpath, uint32_t period, TransferRequestFlags flags) @@ -714,9 +715,9 @@ int ftServer::RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags { return mFileDatabase->RequestDirDetails(ref,details,flags) ; } -uint32_t ftServer::getType(void *ref, FileSearchFlags /* flags */) +uint32_t ftServer::getType(void *ref, FileSearchFlags flags) { - return mFileDatabase->getType(ref) ; + return mFileDatabase->getType(ref,flags) ; } /***************************************************************/ /******************** Search Interface *************************/ diff --git a/libretroshare/src/ft/ftserver.h b/libretroshare/src/ft/ftserver.h index c15c991fc..167ac72dd 100644 --- a/libretroshare/src/ft/ftserver.h +++ b/libretroshare/src/ft/ftserver.h @@ -180,7 +180,7 @@ public: * Extra List Access ***/ virtual bool ExtraFileAdd(std::string fname, const RsFileHash& hash, uint64_t size, uint32_t period, TransferRequestFlags flags); - virtual bool ExtraFileRemove(const RsFileHash& hash, TransferRequestFlags flags); + virtual bool ExtraFileRemove(const RsFileHash& hash); virtual bool ExtraFileHash(std::string localpath, uint32_t period, TransferRequestFlags flags); virtual bool ExtraFileStatus(std::string localpath, FileInfo &info); virtual bool ExtraFileMove(std::string fname, const RsFileHash& hash, uint64_t size, std::string destpath); diff --git a/libretroshare/src/retroshare/rsfiles.h b/libretroshare/src/retroshare/rsfiles.h index 1a77cb829..9d5231042 100644 --- a/libretroshare/src/retroshare/rsfiles.h +++ b/libretroshare/src/retroshare/rsfiles.h @@ -409,7 +409,7 @@ public: * Extra List Access ***/ //virtual bool ExtraFileAdd(std::string fname, std::string hash, uint64_t size, uint32_t period, TransferRequestFlags flags) = 0; - virtual bool ExtraFileRemove(const RsFileHash& hash, TransferRequestFlags flags) = 0; + virtual bool ExtraFileRemove(const RsFileHash& hash) = 0; virtual bool ExtraFileHash(std::string localpath, uint32_t period, TransferRequestFlags flags) = 0; virtual bool ExtraFileStatus(std::string localpath, FileInfo &info) = 0; virtual bool ExtraFileMove(std::string fname, const RsFileHash& hash, uint64_t size, std::string destpath) = 0; diff --git a/libretroshare/src/retroshare/rstypes.h b/libretroshare/src/retroshare/rstypes.h index 9b480f6f8..71a994cc1 100644 --- a/libretroshare/src/retroshare/rstypes.h +++ b/libretroshare/src/retroshare/rstypes.h @@ -160,7 +160,7 @@ struct PeerBandwidthLimits : RsSerializable #define DIR_TYPE_PERSON 0x02 #define DIR_TYPE_DIR 0x04 #define DIR_TYPE_FILE 0x08 -#define DIR_TYPE_EXTRA 0x10 +#define DIR_TYPE_EXTRA_FILE 0x10 /* flags for Directry request - * two types; diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index 386fe4ee0..534fcfaba 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -1291,9 +1291,9 @@ bool p3GxsChannels::ExtraFileHash(const std::string& path) bool p3GxsChannels::ExtraFileRemove(const RsFileHash &hash) { - TransferRequestFlags tflags = RS_FILE_REQ_ANONYMOUS_ROUTING | RS_FILE_REQ_EXTRA; + //TransferRequestFlags tflags = RS_FILE_REQ_ANONYMOUS_ROUTING | RS_FILE_REQ_EXTRA; RsFileHash fh = RsFileHash(hash); - return rsFiles->ExtraFileRemove(fh, tflags); + return rsFiles->ExtraFileRemove(fh); } diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index cbb420eba..c1ba31b50 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -76,6 +76,7 @@ #define IMAGE_COLLOPEN ":/images/library.png" #define IMAGE_EDITSHARE ":/images/edit_16.png" #define IMAGE_MYFILES ":/icons/svg/folders1.svg" +#define IMAGE_REMOVE ":/images/deletemail24.png" /*define viewType_CB value */ #define VIEW_TYPE_TREE 0 @@ -229,6 +230,9 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD sendlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links" ), this ); connect( sendlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinkTo( ) ) ); + removeExtraFileAct = new QAction(QIcon(IMAGE_REMOVE), tr( "Stop sharing this file" ), this ); + connect( removeExtraFileAct , SIGNAL( triggered() ), this, SLOT( removeExtraFile() ) ); + collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this) ; connect(collCreateAct,SIGNAL(triggered()),this,SLOT(collCreate())) ; collModifAct= new QAction(QIcon(IMAGE_COLLMODIF), tr("Modify Collection..."), this) ; @@ -1093,7 +1097,7 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point ) currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ; int type = model->getType(midx) ; - if (type != DIR_TYPE_DIR && type != DIR_TYPE_FILE) return; + if (type != DIR_TYPE_DIR && type != DIR_TYPE_FILE && type != DIR_TYPE_EXTRA_FILE) return; QMenu contextMnu(this) ; @@ -1127,58 +1131,70 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point ) contextMnu.addMenu(&collectionMenu) ; contextMnu.addSeparator() ;//------------------------------------ contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ; + break; + + case DIR_TYPE_EXTRA_FILE: + contextMnu.addAction(openfileAct) ; + contextMnu.addSeparator() ;//------------------------------------ + contextMnu.addAction(copylinkAct) ; + contextMnu.addAction(sendlinkAct) ; + contextMnu.addAction(removeExtraFileAct) ; + break ; default : return ; } - GxsChannelDialog *channelDialog = dynamic_cast(MainWindow::getPage(MainWindow::Channels)); - QMenu shareChannelMenu(tr("Share on channel...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards - - if(channelDialog != NULL) + if(type != DIR_TYPE_EXTRA_FILE) { - shareChannelMenu.setIcon(QIcon(IMAGE_CHANNEL)); + GxsChannelDialog *channelDialog = dynamic_cast(MainWindow::getPage(MainWindow::Channels)); + QMenu shareChannelMenu(tr("Share on channel...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards - std::map grp_metas ; - channelDialog->getGroupList(grp_metas) ; + if(channelDialog != NULL) + { + shareChannelMenu.setIcon(QIcon(IMAGE_CHANNEL)); - std::vector > grplist ; // I dont use a std::map because two or more channels may have the same name. + std::map grp_metas ; + channelDialog->getGroupList(grp_metas) ; - for(auto it(grp_metas.begin());it!=grp_metas.end();++it) - if(IS_GROUP_PUBLISHER((*it).second.mSubscribeFlags) && IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags)) - grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId)); + std::vector > grplist ; // I dont use a std::map because two or more channels may have the same name. - std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ; + for(auto it(grp_metas.begin());it!=grp_metas.end();++it) + if(IS_GROUP_PUBLISHER((*it).second.mSubscribeFlags) && IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags)) + grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId)); - for(auto it(grplist.begin());it!=grplist.end();++it) + std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ; + + for(auto it(grplist.begin());it!=grplist.end();++it) shareChannelMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareOnChannel()))->setData(QString::fromStdString((*it).second.toStdString())) ; - contextMnu.addMenu(&shareChannelMenu) ; - } + contextMnu.addMenu(&shareChannelMenu) ; + } - GxsForumsDialog *forumsDialog = dynamic_cast(MainWindow::getPage(MainWindow::Forums)); - QMenu shareForumMenu(tr("Share on forum...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards + GxsForumsDialog *forumsDialog = dynamic_cast(MainWindow::getPage(MainWindow::Forums)); + QMenu shareForumMenu(tr("Share on forum...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards - if(forumsDialog != NULL) - { - shareForumMenu.setIcon(QIcon(IMAGE_FORUMS)); + if(forumsDialog != NULL) + { + shareForumMenu.setIcon(QIcon(IMAGE_FORUMS)); - std::map grp_metas ; - forumsDialog->getGroupList(grp_metas) ; + std::map grp_metas ; + forumsDialog->getGroupList(grp_metas) ; - std::vector > grplist ; // I dont use a std::map because two or more channels may have the same name. + std::vector > grplist ; // I dont use a std::map because two or more channels may have the same name. - for(auto it(grp_metas.begin());it!=grp_metas.end();++it) - if(IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags)) - grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId)); + for(auto it(grp_metas.begin());it!=grp_metas.end();++it) + if(IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags)) + grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId)); - std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ; + std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ; - for(auto it(grplist.begin());it!=grplist.end();++it) - shareForumMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareInForum()))->setData(QString::fromStdString((*it).second.toStdString())) ; + for(auto it(grplist.begin());it!=grplist.end();++it) + shareForumMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareInForum()))->setData(QString::fromStdString((*it).second.toStdString())) ; - contextMnu.addMenu(&shareForumMenu) ; + contextMnu.addMenu(&shareForumMenu) ; + } } contextMnu.exec(QCursor::pos()) ; @@ -1564,6 +1580,20 @@ void SharedFilesDialog::FilterItems() #endif } +void SharedFilesDialog::removeExtraFile() +{ + std::list files_info ; + + model->getFileInfoFromIndexList(getSelected(),files_info); + + for(auto it(files_info.begin());it!=files_info.end();++it) + { + std::cerr << "removing file " << (*it).name << ", hash = " << (*it).hash << std::endl; + + rsFiles->ExtraFileRemove((*it).hash); + } +} + #ifdef DEPRECATED_CODE bool SharedFilesDialog::flat_FilterItem(const QModelIndex &index, const QString &text, int /*level*/) { diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h index 0d35260ee..ae231ee93 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h @@ -66,6 +66,7 @@ private slots: void copyLink(); void copyLinkhtml(); void sendLinkTo(); + void removeExtraFile(); void collCreate(); void collModif(); @@ -122,6 +123,7 @@ protected: QAction* sendlinkAct; QAction* sendchatlinkAct; QAction* copylinkhtmlAct; + QAction* removeExtraFileAct; QAction *collCreateAct; QAction *collModifAct; diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index 8eee722c7..a754cf328 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -162,7 +162,7 @@ bool TreeStyle_RDM::hasChildren(const QModelIndex &parent) const return false; } - if (details.type == DIR_TYPE_FILE) + if (details.type == DIR_TYPE_FILE || details.type == DIR_TYPE_EXTRA_FILE) { #ifdef RDM_DEBUG std::cerr << "lookup FILE -> false"; @@ -220,7 +220,7 @@ int TreeStyle_RDM::rowCount(const QModelIndex &parent) const #endif return 0; } - if (details.type == DIR_TYPE_FILE) + if (details.type == DIR_TYPE_FILE || details.type == DIR_TYPE_EXTRA_FILE) { #ifdef RDM_DEBUG std::cerr << "lookup FILE: 0"; @@ -425,7 +425,7 @@ QVariant RetroshareDirModel::decorationRole(const DirDetails& details,int coln) else return QIcon(categoryIcon); } - else if (details.type == DIR_TYPE_FILE) /* File */ + else if (details.type == DIR_TYPE_FILE || details.type == DIR_TYPE_EXTRA_FILE) /* File */ { // extensions predefined if(details.hash.isNull()) @@ -506,7 +506,7 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const return QString() ; } } - else if (details.type == DIR_TYPE_FILE) /* File */ + else if (details.type == DIR_TYPE_FILE || details.type == DIR_TYPE_EXTRA_FILE) /* File */ { switch(coln) { @@ -598,7 +598,7 @@ QString FlatStyle_RDM::computeDirectoryPath(const DirDetails& details) const QVariant FlatStyle_RDM::displayRole(const DirDetails& details,int coln) const { - if (details.type == DIR_TYPE_FILE) /* File */ + if (details.type == DIR_TYPE_FILE || details.type == DIR_TYPE_EXTRA_FILE) /* File */ switch(coln) { case COLUMN_NAME: return QString::fromUtf8(details.name.c_str()); @@ -654,7 +654,7 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails& return QString(); } } - else if (details.type == DIR_TYPE_FILE) /* File */ + else if (details.type == DIR_TYPE_FILE || details.type == DIR_TYPE_EXTRA_FILE) /* File */ { switch(coln) { @@ -707,7 +707,7 @@ QVariant FlatStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails& * Dir : name, (0) count, (0) path, (0) ts */ - if (details.type == DIR_TYPE_FILE) /* File */ + if (details.type == DIR_TYPE_FILE || details.type == DIR_TYPE_EXTRA_FILE) /* File */ { switch(coln) { @@ -769,7 +769,7 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const if (role == Qt::TextColorRole) { - if(details.type == DIR_TYPE_FILE && details.hash.isNull()) + if((details.type == DIR_TYPE_FILE || details.type == DIR_TYPE_EXTRA_FILE) && details.hash.isNull()) return QVariant(QColor(Qt::green)) ; else if(ageIndicator != IND_ALWAYS && details.max_mtime + ageIndicator < time(NULL)) return QVariant(QColor(Qt::gray)) ; @@ -1083,6 +1083,7 @@ Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const case DIR_TYPE_PERSON: return isNewerThanEpoque(details.max_mtime)? (Qt::ItemIsEnabled):(Qt::NoItemFlags) ; case DIR_TYPE_DIR: return Qt::ItemIsSelectable | Qt::ItemIsEnabled; case DIR_TYPE_FILE: return Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled; + case DIR_TYPE_EXTRA_FILE: return Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled; } return Qt::ItemIsSelectable; @@ -1158,9 +1159,9 @@ void FlatStyle_RDM::postMods() bool RetroshareDirModel::requestDirDetails(void *ref, bool remote,DirDetails& d) const { -//#ifdef RDM_DEBUG +#ifdef RDM_DEBUG std::cerr << "RequestDirDetails:: ref = " << ref << ", remote=" << remote << std::endl; -//#endif +#endif // We look in cache and re-use the last result if the reference and remote are the same. @@ -1400,7 +1401,7 @@ void RetroshareDirModel::openSelected(const QModelIndexList &qmil) QDir dir(QString::fromUtf8((*it).path.c_str())); QString dest; - if ((*it).type & DIR_TYPE_FILE) { + if ((*it).type & DIR_TYPE_FILE || (*it).type & DIR_TYPE_EXTRA_FILE) { dest = dir.absoluteFilePath(QString::fromUtf8(it->name.c_str())); } else if ((*it).type & DIR_TYPE_DIR) { dest = dir.absolutePath(); @@ -1509,7 +1510,7 @@ void RetroshareDirModel::filterItems(const std::list& keywords,uint mFilteredPointers.insert(p) ; ++found ; - while(det.type == DIR_TYPE_FILE || det.type == DIR_TYPE_DIR) + while(det.type == DIR_TYPE_FILE || det.type == DIR_TYPE_EXTRA_FILE || det.type == DIR_TYPE_DIR) { p = det.parent ; rsFiles->RequestDirDetails( p, det, flags); @@ -1555,7 +1556,7 @@ QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) con std::cerr << "Path: " << details.path << std::endl; #endif - if (details.type != DIR_TYPE_FILE) + if (details.type != DIR_TYPE_FILE && details.type != DIR_TYPE_EXTRA_FILE) { #ifdef RDM_DEBUG std::cerr << "RetroshareDirModel::mimeData() Not File" << std::endl; diff --git a/retroshare-gui/src/gui/feeds/SubFileItem.cpp b/retroshare-gui/src/gui/feeds/SubFileItem.cpp index 0e3350127..3b6ec3896 100644 --- a/retroshare-gui/src/gui/feeds/SubFileItem.cpp +++ b/retroshare-gui/src/gui/feeds/SubFileItem.cpp @@ -561,7 +561,7 @@ void SubFileItem::cancel() if (((mType == SFI_TYPE_ATTACH) || (mType == SFI_TYPE_CHANNEL)) && (mFlag & SFI_FLAG_CREATE)) { hide(); - rsFiles->ExtraFileRemove(FileHash(), RS_FILE_REQ_ANONYMOUS_ROUTING | RS_FILE_REQ_EXTRA); + rsFiles->ExtraFileRemove(FileHash());//, RS_FILE_REQ_ANONYMOUS_ROUTING | RS_FILE_REQ_EXTRA); mPath = ""; } else From c77a28c17af73896bb1d9732fb9eeab4ac943fe6 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 27 Sep 2018 21:20:06 +0200 Subject: [PATCH 07/39] added proper notification when removing an extra file --- libretroshare/src/file_sharing/p3filelists.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libretroshare/src/file_sharing/p3filelists.cc b/libretroshare/src/file_sharing/p3filelists.cc index 4a0b92d4f..6331c6c03 100644 --- a/libretroshare/src/file_sharing/p3filelists.cc +++ b/libretroshare/src/file_sharing/p3filelists.cc @@ -962,10 +962,14 @@ int p3FileDatabase::getSharedDirStatistics(const RsPeerId& pid,SharedDirStats& s void p3FileDatabase::removeExtraFile(const RsFileHash& hash) { + { RS_STACK_MUTEX(mFLSMtx) ; mExtraFiles->removeExtraFile(hash); mLastExtraFilesCacheUpdate = 0 ; // forced cache reload + } + + RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_LOCAL, 0); } void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIndex e,DirDetails& d) const From 2610f62e419f8a347af37fc71982c9008c3a67e8 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 27 Sep 2018 21:42:21 +0200 Subject: [PATCH 08/39] fixed display of temporary shared file text --- libretroshare/src/file_sharing/p3filelists.cc | 11 ++++++----- retroshare-gui/src/gui/RemoteDirModel.cpp | 11 +++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libretroshare/src/file_sharing/p3filelists.cc b/libretroshare/src/file_sharing/p3filelists.cc index 6331c6c03..c64b89069 100644 --- a/libretroshare/src/file_sharing/p3filelists.cc +++ b/libretroshare/src/file_sharing/p3filelists.cc @@ -991,12 +991,12 @@ void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIn d.parent = NULL ; d.prow = 0;//fi-1 ; - d.type = DIR_TYPE_DIR; + d.type = DIR_TYPE_PERSON; d.hash.clear() ; d.count = mExtraFilesCache.size(); d.max_mtime = time(NULL); d.mtime = time(NULL); - d.name = "Temporary shared files"; + d.name = "Extra List"; d.path = "/"; d.ref = ref ; @@ -1021,13 +1021,14 @@ void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIn d.count = 0; d.max_mtime = time(NULL); d.mtime = time(NULL); - d.name = f.fname; - d.path = "/"; + d.name = f.path; // so that the UI shows the complete path, since the parent directory is not really a directory. + d.path = f.path; d.ref = ref ; convertEntryIndexToPointer(0,1,d.parent) ; } + d.flags = DIR_FLAGS_ANONYMOUS_DOWNLOAD ; d.id = RsPeerId(); } @@ -1081,7 +1082,7 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags convertEntryIndexToPointer(0,1,p); // local shared files from extra list DirStub stub; stub.type = DIR_TYPE_PERSON; // not totally exact, but used as a trick. - stub.name = "Temporary shared files"; + stub.name = "Extra List"; stub.ref = p; d.children.push_back(stub); diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index a754cf328..2d9820690 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -457,13 +457,12 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const QString res ; if(RemoteMode) - { res = QString::fromUtf8(rsPeers->getPeerName(details.id).c_str()); - } - else - { - res = tr("My files"); - } + else if(details.id == rsPeers->getOwnId()) + res = tr("My files"); + else + res = tr("Temporary shared files"); + return res ; } case COLUMN_FILENB: { From e1698429de4e997003104146fdb774137a2a319e Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 27 Sep 2018 21:46:00 +0200 Subject: [PATCH 09/39] fixed display of size --- libretroshare/src/file_sharing/p3filelists.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretroshare/src/file_sharing/p3filelists.cc b/libretroshare/src/file_sharing/p3filelists.cc index c64b89069..ab76bec52 100644 --- a/libretroshare/src/file_sharing/p3filelists.cc +++ b/libretroshare/src/file_sharing/p3filelists.cc @@ -1018,7 +1018,7 @@ void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIn FileInfo& f(mExtraFilesCache[(int)e-1]) ; d.hash = f.hash; - d.count = 0; + d.count = f.size; d.max_mtime = time(NULL); d.mtime = time(NULL); d.name = f.path; // so that the UI shows the complete path, since the parent directory is not really a directory. From 54ec49dc032d057ffd8de702d2a0fb0b7d131aec Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 27 Sep 2018 21:56:41 +0200 Subject: [PATCH 10/39] make extra shared file list appear only when non empty --- libretroshare/src/file_sharing/p3filelists.cc | 2 ++ libretroshare/src/ft/ftextralist.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libretroshare/src/file_sharing/p3filelists.cc b/libretroshare/src/file_sharing/p3filelists.cc index ab76bec52..c8b5749d9 100644 --- a/libretroshare/src/file_sharing/p3filelists.cc +++ b/libretroshare/src/file_sharing/p3filelists.cc @@ -1078,6 +1078,8 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags stub.ref = p; d.children.push_back(stub); } + + if(mExtraFiles->size() > 0) { convertEntryIndexToPointer(0,1,p); // local shared files from extra list DirStub stub; diff --git a/libretroshare/src/ft/ftextralist.h b/libretroshare/src/ft/ftextralist.h index bc470e677..6d89cfe7b 100644 --- a/libretroshare/src/ft/ftextralist.h +++ b/libretroshare/src/ft/ftextralist.h @@ -122,6 +122,8 @@ public: std::string destpath); + uint32_t size() const { return mFiles.size() ; } + /*** * Hash file, and add to the files, * file is removed after period. From 752275f813c866ab72cefd706d72539027b5608a Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 27 Sep 2018 22:14:00 +0200 Subject: [PATCH 11/39] fixed various display bugs in extra file list --- libretroshare/src/file_sharing/p3filelists.cc | 4 ++-- libretroshare/src/ft/ftextralist.cc | 3 +-- retroshare-gui/src/gui/RemoteDirModel.cpp | 14 ++++++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/libretroshare/src/file_sharing/p3filelists.cc b/libretroshare/src/file_sharing/p3filelists.cc index c8b5749d9..8da837bc6 100644 --- a/libretroshare/src/file_sharing/p3filelists.cc +++ b/libretroshare/src/file_sharing/p3filelists.cc @@ -1019,8 +1019,8 @@ void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIn d.hash = f.hash; d.count = f.size; - d.max_mtime = time(NULL); - d.mtime = time(NULL); + d.max_mtime = 0; // this is irrelevant + d.mtime = 0; // this is irrelevant d.name = f.path; // so that the UI shows the complete path, since the parent directory is not really a directory. d.path = f.path; d.ref = ref ; diff --git a/libretroshare/src/ft/ftextralist.cc b/libretroshare/src/ft/ftextralist.cc index d15a848bb..2c8152d3e 100644 --- a/libretroshare/src/ft/ftextralist.cc +++ b/libretroshare/src/ft/ftextralist.cc @@ -113,8 +113,7 @@ void ftExtraList::hashAFile() /* hash it! */ std::string name, hash; //uint64_t size; - if (RsDirUtil::hashFile(details.info.path, details.info.fname, - details.info.hash, details.info.size)) + if (RsDirUtil::hashFile(details.info.path, details.info.fname, details.info.hash, details.info.size)) { RS_STACK_MUTEX(extMutex); diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index 2d9820690..e0da77b2e 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -470,8 +470,10 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const if(RemoteMode) rsFiles->getSharedDirStatistics(details.id,stats) ; - else + else if(details.id == rsPeers->getOwnId()) rsFiles->getSharedDirStatistics(rsPeers->getOwnId(),stats) ; + else + stats.total_number_of_files = details.count; if(stats.total_number_of_files > 0) { @@ -487,8 +489,10 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const if(RemoteMode) rsFiles->getSharedDirStatistics(details.id,stats) ; - else + else if(details.id == rsPeers->getOwnId()) rsFiles->getSharedDirStatistics(rsPeers->getOwnId(),stats) ; + else + return QString(); if(stats.total_shared_size > 0) return misc::friendlyUnit(stats.total_shared_size) ; @@ -498,6 +502,8 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const case COLUMN_AGE: if(!isNewerThanEpoque(details.max_mtime)) return QString(); + else if(details.id != rsPeers->getOwnId()) + return QString(); else return misc::timeRelativeToNow(details.max_mtime); @@ -516,7 +522,7 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const case COLUMN_SIZE: return misc::friendlyUnit(details.count); case COLUMN_AGE: - return misc::timeRelativeToNow(details.max_mtime); + return (details.type == DIR_TYPE_FILE)?(misc::timeRelativeToNow(details.max_mtime)):QString(); case COLUMN_FRIEND_ACCESS: return QVariant(); case COLUMN_WN_VISU_DIR: @@ -795,7 +801,7 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const return decorationRole(details,coln) ; if(role == Qt::ToolTipRole) - if(!isNewerThanEpoque(details.max_mtime)) + if(!isNewerThanEpoque(details.max_mtime) && details.type == DIR_TYPE_PERSON) return tr("This node hasn't sent any directory information yet.") ; /***************** From 4578b4403aec43b107d6e54143e2edcf9b2b6cc4 Mon Sep 17 00:00:00 2001 From: Josep-San Date: Fri, 28 Sep 2018 15:38:39 +0200 Subject: [PATCH 12/39] Added context menu for Upload list headers to hide/show columns. --- .../src/gui/FileTransfer/TransfersDialog.cpp | 55 ++++++++++++++++++- .../src/gui/FileTransfer/TransfersDialog.h | 18 +++++- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index 0ecc55ac2..d2953cb22 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -826,6 +826,9 @@ TransfersDialog::TransfersDialog(QWidget *parent) QHeaderView *qhvDLList = ui.downloadList->header(); qhvDLList->setContextMenuPolicy(Qt::CustomContextMenu); connect(qhvDLList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(downloadListHeaderCustomPopupMenu(QPoint))); + QHeaderView *qhvULList = ui.uploadsList->header(); + qhvULList->setContextMenuPolicy(Qt::CustomContextMenu); + connect(qhvULList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(uploadsListHeaderCustomPopupMenu(QPoint))); // Why disable autoscroll ? // With disabled autoscroll, the treeview doesn't scroll with cursor move @@ -1006,7 +1009,7 @@ TransfersDialog::TransfersDialog(QWidget *parent) collOpenAct = new QAction(QIcon(IMAGE_COLLOPEN), tr( "Download from collection file..." ), this ); connect(collOpenAct, SIGNAL(triggered()), this, SLOT(collOpen())); - /** Setup the actions for the header context menu */ + /** Setup the actions for the download header context menu */ showDLSizeAct= new QAction(tr("Size"),this); showDLSizeAct->setCheckable(true); showDLSizeAct->setToolTip(tr("Show Size Column")); connect(showDLSizeAct,SIGNAL(triggered(bool)),this,SLOT(setShowDLSizeColumn(bool))) ; @@ -1044,6 +1047,26 @@ TransfersDialog::TransfersDialog(QWidget *parent) showDLPath->setCheckable(true); showDLPath->setToolTip(tr("Show Path Column")); connect(showDLPath,SIGNAL(triggered(bool)),this,SLOT(setShowDLPath(bool))) ; + /** Setup the actions for the upload header context menu */ + showULPeerAct= new QAction(tr("Peer"),this); + showULPeerAct->setCheckable(true); showULPeerAct->setToolTip(tr("Show Peer Column")); + connect(showULPeerAct,SIGNAL(triggered(bool)),this,SLOT(setShowULPeerColumn(bool))) ; + showULSizeAct= new QAction(tr("Size"),this); + showULSizeAct->setCheckable(true); showULSizeAct->setToolTip(tr("Show Peer Column")); + connect(showULSizeAct,SIGNAL(triggered(bool)),this,SLOT(setShowULSizeColumn(bool))) ; + showULTransferredAct= new QAction(tr("Transferred"),this); + showULTransferredAct->setCheckable(true); showULTransferredAct->setToolTip(tr("Show Transferred Column")); + connect(showULTransferredAct,SIGNAL(triggered(bool)),this,SLOT(setShowULTransferredColumn(bool))) ; + showULSpeedAct= new QAction(tr("Speed"),this); + showULSpeedAct->setCheckable(true); showULSpeedAct->setToolTip(tr("Show Speed Column")); + connect(showULSpeedAct,SIGNAL(triggered(bool)),this,SLOT(setShowULSpeedColumn(bool))) ; + showULProgressAct= new QAction(tr("Progress"),this); + showULProgressAct->setCheckable(true); showULProgressAct->setToolTip(tr("Show Progress Column")); + connect(showULProgressAct,SIGNAL(triggered(bool)),this,SLOT(setShowULProgressColumn(bool))) ; + showULHashAct= new QAction(tr("Hash"),this); + showULHashAct->setCheckable(true); showULHashAct->setToolTip(tr("Show Hash Column")); + connect(showULHashAct,SIGNAL(triggered(bool)),this,SLOT(setShowULHashColumn(bool))) ; + /** Setup the actions for the upload context menu */ ulOpenFolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this); connect(ulOpenFolderAct, SIGNAL(triggered()), this, SLOT(ulOpenFolder())); @@ -1420,6 +1443,29 @@ void TransfersDialog::uploadsListCustomPopupMenu( QPoint /*point*/ ) contextMnu.exec(QCursor::pos()); } +void TransfersDialog::uploadsListHeaderCustomPopupMenu( QPoint /*point*/ ) +{ + std::cerr << "TransfersDialog::uploadsListHeaderCustomPopupMenu()" << std::endl; + QMenu contextMnu( this ); + + showULPeerAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UPEER)); + showULSizeAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_USIZE)); + showULTransferredAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UTRANSFERRED)); + showULSpeedAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_ULSPEED)); + showULProgressAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UPROGRESS)); + showULHashAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UHASH)); + + QMenu *menu = contextMnu.addMenu(tr("Columns")); + menu->addAction(showULPeerAct); + menu->addAction(showULSizeAct); + menu->addAction(showULTransferredAct); + menu->addAction(showULSpeedAct); + menu->addAction(showULProgressAct); + menu->addAction(showULHashAct); + + contextMnu.exec(QCursor::pos()); +} + void TransfersDialog::chooseDestinationDirectory() { QString dest_dir = QFileDialog::getExistingDirectory(this,tr("Choose directory")) ; @@ -2791,6 +2837,13 @@ void TransfersDialog::setShowDLIDColumn (bool show) { ui.downloadList-> void TransfersDialog::setShowDLLastDLColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_LASTDL, !show); } void TransfersDialog::setShowDLPath (bool show) { ui.downloadList->setColumnHidden(COLUMN_PATH, !show); } +void TransfersDialog::setShowULPeerColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_UPEER, !show); } +void TransfersDialog::setShowULSizeColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_USIZE, !show); } +void TransfersDialog::setShowULTransferredColumn(bool show) { ui.uploadsList->setColumnHidden(COLUMN_UTRANSFERRED, !show); } +void TransfersDialog::setShowULSpeedColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_ULSPEED, !show); } +void TransfersDialog::setShowULProgressColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_UPROGRESS, !show); } +void TransfersDialog::setShowULHashColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_UHASH, !show); } + void TransfersDialog::expandAllDL() { ui.downloadList->expandAll(); diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h index f98a96daa..1e7b27814 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h @@ -92,6 +92,7 @@ private slots: void downloadListCustomPopupMenu( QPoint point ); void downloadListHeaderCustomPopupMenu( QPoint point ); void uploadsListCustomPopupMenu( QPoint point ); + void uploadsListHeaderCustomPopupMenu (QPoint point ); void cancel(); void forceCheck(); @@ -158,6 +159,13 @@ private slots: void setShowDLLastDLColumn(bool show); void setShowDLPath(bool show); + void setShowULPeerColumn(bool show); + void setShowULSizeColumn(bool show); + void setShowULTransferredColumn(bool show); + void setShowULSpeedColumn(bool show); + void setShowULProgressColumn(bool show); + void setShowULHashColumn(bool show); + void filterChanged(const QString &text); signals: @@ -217,7 +225,7 @@ private: QAction *collViewAct; QAction *collOpenAct; - /** Defines the actions for the header context menu */ + /** Defines the actions for the header context menu in download */ QAction* showDLSizeAct; QAction* showDLCompleteAct; QAction* showDLDLSpeedAct; @@ -235,6 +243,14 @@ private: QAction* ulOpenFolderAct; QAction* ulCopyLinkAct; + /** Defines the actions for the header context menu in upload*/ + QAction* showULPeerAct; + QAction* showULSizeAct; + QAction* showULTransferredAct; + QAction* showULSpeedAct; + QAction* showULProgressAct; + QAction* showULHashAct; + bool m_bProcessSettings; void processSettings(bool bLoad); From 443dbdfbef03e3b7ee728bba3819152607c0c7ee Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 29 Sep 2018 19:04:23 +0200 Subject: [PATCH 13/39] fixed small bug breaking display of flat mode in files --- libretroshare/src/file_sharing/p3filelists.cc | 6 +++--- retroshare-gui/src/gui/RemoteDirModel.cpp | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/file_sharing/p3filelists.cc b/libretroshare/src/file_sharing/p3filelists.cc index 8da837bc6..32482106f 100644 --- a/libretroshare/src/file_sharing/p3filelists.cc +++ b/libretroshare/src/file_sharing/p3filelists.cc @@ -996,7 +996,7 @@ void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIn d.count = mExtraFilesCache.size(); d.max_mtime = time(NULL); d.mtime = time(NULL); - d.name = "Extra List"; + d.name = "[Extra List]"; d.path = "/"; d.ref = ref ; @@ -1005,7 +1005,7 @@ void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIn DirStub stub; stub.type = DIR_TYPE_FILE; stub.name = mExtraFilesCache[i].fname; - convertEntryIndexToPointer(i,1,stub.ref); // local shared files from extra list + convertEntryIndexToPointer(i+1,1,stub.ref); // local shared files from extra list d.children.push_back(stub); } @@ -1084,7 +1084,7 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags convertEntryIndexToPointer(0,1,p); // local shared files from extra list DirStub stub; stub.type = DIR_TYPE_PERSON; // not totally exact, but used as a trick. - stub.name = "Extra List"; + stub.name = "[Extra List]"; stub.ref = p; d.children.push_back(stub); diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index e0da77b2e..658b944fb 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -1663,7 +1663,7 @@ void FlatStyle_RDM::updateRefs() if (requestDirDetails(ref, RemoteMode,details)) { - if(details.type == DIR_TYPE_FILE) // only push files, not directories nor persons. + if(details.type == DIR_TYPE_FILE || details.type == DIR_TYPE_EXTRA_FILE) // only push files, not directories nor persons. _ref_entries.push_back(ref) ; #ifdef RDM_DEBUG std::cerr << "FlatStyle_RDM::postMods(): adding ref " << ref << std::endl; @@ -1689,6 +1689,9 @@ void FlatStyle_RDM::updateRefs() std::cerr << "reference tab contains " << std::dec << _ref_entries.size() << " files" << std::endl; } + if(_ref_stack.empty()) + _needs_update = false ; + RetroshareDirModel::postMods() ; } From 1839d23df110e1b602f9526fc564a0192ba03deb Mon Sep 17 00:00:00 2001 From: Phenom Date: Thu, 15 Feb 2018 16:51:35 +0100 Subject: [PATCH 14/39] Fix Gcc Warning hashstream.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /libretroshare/src/crypto/hashstream.cc:38: warning: friend declaration ‘template librs::crypto::HashStream& librs::crypto::operator<<(librs::crypto::HashStream&, const T&)’ is not visible to explicit specialization HashStream& operator<<(HashStream& u,const std::string& s) /libretroshare/src/crypto/hashstream.cc:44: warning: friend declaration ‘template librs::crypto::HashStream& librs::crypto::operator<<(librs::crypto::HashStream&, const T&)’ is not visible to explicit specialization HashStream& operator<<(HashStream& u,const uint64_t& n) /libretroshare/src/crypto/hashstream.cc:58: warning: friend declaration ‘template librs::crypto::HashStream& librs::crypto::operator<<(librs::crypto::HashStream&, const T&)’ is not visible to explicit specialization HashStream& operator<<(HashStream& u,const uint32_t& n) /libretroshare/src/crypto/hashstream.cc:72: warning: friend declaration ‘template librs::crypto::HashStream& librs::crypto::operator<<(librs::crypto::HashStream&, const T&)’ is not visible to explicit specialization HashStream& operator<<(HashStream& u,const uint8_t& n) --- libretroshare/src/crypto/hashstream.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libretroshare/src/crypto/hashstream.h b/libretroshare/src/crypto/hashstream.h index fe276b6b4..2a09935d0 100644 --- a/libretroshare/src/crypto/hashstream.h +++ b/libretroshare/src/crypto/hashstream.h @@ -28,6 +28,11 @@ namespace librs { namespace crypto { + // Forward declare the class + class HashStream; + // Forward declare the template operator + template HashStream& operator<<(HashStream& u, const T&); + class HashStream { public: From 6ef72f551d244c88b514f9237edf9ca0327d89d5 Mon Sep 17 00:00:00 2001 From: Phenom Date: Wed, 14 Feb 2018 19:24:24 +0100 Subject: [PATCH 15/39] Fix Gcc Warning in authssl.cc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /libretroshare/src/pqi/authssl.cc:160: warning: ‘void dyn_destroy_function(CRYPTO_dynlock_value*, const char*, int)’ defined but not used [-Wunused-function] static void dyn_destroy_function(struct CRYPTO_dynlock_value *l, const char */*file*/, int /*line*/) /libretroshare/src/pqi/authssl.cc:143: warning: ‘void dyn_lock_function(int, CRYPTO_dynlock_value*, const char*, int)’ defined but not used [-Wunused-function] static void dyn_lock_function(int mode, struct CRYPTO_dynlock_value *l, const char */*file*/, int /*line*/) /libretroshare/src/pqi/authssl.cc:121: warning: ‘CRYPTO_dynlock_value* dyn_create_function(const char*, int)’ defined but not used [-Wunused- function] static struct CRYPTO_dynlock_value *dyn_create_function(const char */ *file*/, int /*line*/) /libretroshare/src/pqi/authssl.cc:106: warning: ‘long unsigned int id_function()’ defined but not used [-Wunused-function] static unsigned long id_function(void) /libretroshare/src/pqi/authssl.cc:92: warning: ‘void locking_function(int, int, const char*, int)’ defined but not used [- Wunused-function] static void locking_function(int mode, int n, const char */*file*/, int /*line*/) --- libretroshare/src/pqi/authssl.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/pqi/authssl.cc b/libretroshare/src/pqi/authssl.cc index a885c3318..797786783 100644 --- a/libretroshare/src/pqi/authssl.cc +++ b/libretroshare/src/pqi/authssl.cc @@ -71,6 +71,7 @@ struct CRYPTO_dynlock_value pthread_mutex_t mutex; }; +# if OPENSSL_VERSION_NUMBER < 0x10100000L /** * OpenSSL locking function. * @@ -88,7 +89,9 @@ static void locking_function(int mode, int n, const char */*file*/, int /*line*/ pthread_mutex_unlock(&mutex_buf[n]); } } +#endif +# if OPENSSL_VERSION_NUMBER < 0x10100000L /** * OpenSSL uniq id function. * @@ -102,7 +105,9 @@ static unsigned long id_function(void) return (unsigned long) pthread_self(); #endif } +#endif +# if OPENSSL_VERSION_NUMBER < 0x10100000L /** * OpenSSL allocate and initialize dynamic crypto lock. * @@ -121,7 +126,9 @@ static struct CRYPTO_dynlock_value *dyn_create_function(const char */*file*/, in return value; } +#endif +# if OPENSSL_VERSION_NUMBER < 0x10100000L /** * OpenSSL dynamic locking function. * @@ -139,7 +146,9 @@ static void dyn_lock_function(int mode, struct CRYPTO_dynlock_value *l, const ch pthread_mutex_unlock(&l->mutex); } } +#endif +# if OPENSSL_VERSION_NUMBER < 0x10100000L /** * OpenSSL destroy dynamic crypto lock. * @@ -153,6 +162,7 @@ static void dyn_destroy_function(struct CRYPTO_dynlock_value *l, const char */*f pthread_mutex_destroy(&l->mutex); free(l); } +#endif /** * Initialize TLS library. @@ -169,6 +179,7 @@ bool tls_init() for (int i = 0; i < CRYPTO_num_locks(); i++) { pthread_mutex_init(&mutex_buf[i], NULL); } +# if OPENSSL_VERSION_NUMBER < 0x10100000L /* static locks callbacks */ CRYPTO_set_locking_callback(locking_function); CRYPTO_set_id_callback(id_function); @@ -176,8 +187,8 @@ bool tls_init() CRYPTO_set_dynlock_create_callback(dyn_create_function); CRYPTO_set_dynlock_lock_callback(dyn_lock_function); CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function); - - return true; +#endif + return true; } /** From d401fdfb40d4423234a9589d0e428676ba667954 Mon Sep 17 00:00:00 2001 From: Phenom Date: Sun, 30 Sep 2018 14:31:53 +0200 Subject: [PATCH 16/39] Fix Gcc Warning: /libresapi/src/api/RsControlModule.cpp:588: warning: no return statement in function returning non-void [-Wreturn-type] --- libresapi/src/api/RsControlModule.cpp | 6 +++--- libresapi/src/api/RsControlModule.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libresapi/src/api/RsControlModule.cpp b/libresapi/src/api/RsControlModule.cpp index 66ea7caf6..debd3ce34 100644 --- a/libresapi/src/api/RsControlModule.cpp +++ b/libresapi/src/api/RsControlModule.cpp @@ -486,7 +486,7 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp) resp.setFail("hidden_port out of range. It must fit into uint16!"); return; } - hidden_port = p; + hidden_port = static_cast(p); } RsPgpId pgp_id; @@ -527,7 +527,7 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp) RsInit::SetHiddenLocation(hidden_address, hidden_port, false); } - std::string ssl_password = RSRandom::random_alphaNumericString(RsInit::getSslPwdLen()) ; + std::string ssl_password = RSRandom::random_alphaNumericString(static_cast(RsInit::getSslPwdLen())) ; /* GenerateSSLCertificate - selects the PGP Account */ //RsInit::SelectGPGAccount(PGPId); @@ -581,7 +581,7 @@ bool RsControlModule::askForDeferredSelfSignature(const void *data, const uint32 } } -bool RsControlModule::requestShutdown() +void RsControlModule::requestShutdown() { RS_STACK_MUTEX(mExitFlagMtx); mProcessShouldExit = true; diff --git a/libresapi/src/api/RsControlModule.h b/libresapi/src/api/RsControlModule.h index e9886f7bc..587a753a3 100644 --- a/libresapi/src/api/RsControlModule.h +++ b/libresapi/src/api/RsControlModule.h @@ -50,7 +50,7 @@ public: // full_control: set to true if this module should handle rsinit and login // set to false if rsinit is handled by the Qt gui RsControlModule(int argc, char **argv, StateTokenServer* sts, ApiServer* apiserver, bool full_control); - ~RsControlModule(); + ~RsControlModule() override; // returns true if the process should terminate bool processShouldExit(); @@ -62,12 +62,12 @@ public: virtual bool askForPassword(const std::string &title, const std::string& key_details, bool prev_is_bad , std::string& password,bool& canceled) override; virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result, std::string reason = "") override; - virtual bool requestShutdown(); + virtual void requestShutdown(); protected: // from RsThread // wee need a thread to call into things which block like askForPassword() - virtual void run(); + virtual void run() override; private: void handleRunState(Request& req, Response& resp); From 83a987936d2e175a218d62dcae5fe833abb7d8e5 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 3 Oct 2018 15:02:37 +0200 Subject: [PATCH 17/39] when replying to a msg, always select an ID to author the msg that was in the destination list --- retroshare-gui/src/gui/msgs/MessageComposer.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index a402ee3b9..0ef3223f4 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -1172,6 +1172,17 @@ MessageComposer *MessageComposer::replyMsg(const std::string &msgId, bool all) if(!msgInfo.rspeerid_srcId.isNull()) msgComposer->addRecipient(MessageComposer::TO, msgInfo.rspeerid_srcId); if(!msgInfo.rsgxsid_srcId.isNull()) msgComposer->addRecipient(MessageComposer::TO, msgInfo.rsgxsid_srcId); + // make sure the current ID is among the ones the msg was actually sent to. + for(auto it(msgInfo.rsgxsid_msgto.begin());it!=msgInfo.rsgxsid_msgto.end();++it) + if(rsIdentity->isOwnId(*it)) + { + msgComposer->ui.respond_to_CB->setDefaultId(*it) ; + break ; + } + // Note: another solution is to do + // msgComposer->ui.respond_to_CB->setIdConstraintSet(msgInfo.rsgxsid_msgto); // always choose one of the destinations to originate the response! + // but that prevent any use of IDs tht are not in the destination set to be chosen to author the msg. + if (all) { RsPeerId ownId = rsPeers->getOwnId(); From 81fc3b7921083566f78614d3e5cbd51be7ee68cf Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 3 Oct 2018 15:25:53 +0200 Subject: [PATCH 18/39] select GxsIds as default list to chose msg destination from --- libretroshare/src/retroshare/rsidentity.h | 1 + libretroshare/src/services/p3idservice.cc | 8 +++++++- libretroshare/src/services/p3idservice.h | 1 + retroshare-gui/src/gui/msgs/MessageComposer.cpp | 5 ++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/retroshare/rsidentity.h b/libretroshare/src/retroshare/rsidentity.h index 1fca93e3d..84688c142 100644 --- a/libretroshare/src/retroshare/rsidentity.h +++ b/libretroshare/src/retroshare/rsidentity.h @@ -377,6 +377,7 @@ struct RsIdentity : RsGxsIfaceHelper virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ; virtual bool isARegularContact(const RsGxsId& id) = 0 ; + virtual uint32_t nbRegularContacts() =0; virtual bool serialiseIdentityToMemory( const RsGxsId& id, std::string& radix_string ) = 0; diff --git a/libretroshare/src/services/p3idservice.cc b/libretroshare/src/services/p3idservice.cc index c6c4d19f6..b42950d0a 100644 --- a/libretroshare/src/services/p3idservice.cc +++ b/libretroshare/src/services/p3idservice.cc @@ -224,7 +224,13 @@ uint32_t p3IdService::idAuthenPolicy() return policy; } -bool p3IdService::isARegularContact(const RsGxsId& id) +uint32_t p3IdService::nbRegularContacts() +{ + RsStackMutex stack(mIdMtx); + return mContacts.size(); +} + +bool p3IdService::isARegularContact(const RsGxsId& id) { RsStackMutex stack(mIdMtx); return mContacts.find(id) != mContacts.end() ; diff --git a/libretroshare/src/services/p3idservice.h b/libretroshare/src/services/p3idservice.h index 107f19319..17d62c9ce 100644 --- a/libretroshare/src/services/p3idservice.h +++ b/libretroshare/src/services/p3idservice.h @@ -281,6 +281,7 @@ public: virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) ; virtual bool isARegularContact(const RsGxsId& id) ; + virtual uint32_t nbRegularContacts() ; virtual time_t getLastUsageTS(const RsGxsId &id) ; /**************** RsGixs Implementation ***************/ diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 0ef3223f4..e461d63e3 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -268,7 +268,10 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) ui.filterComboBox->addItem(tr("Friend Nodes")); ui.filterComboBox->addItem(tr("All people")); ui.filterComboBox->addItem(tr("My contacts")); - ui.filterComboBox->setCurrentIndex(3); + ui.filterComboBox->setCurrentIndex(2); + + if(rsIdentity->nbRegularContacts() > 0) + ui.filterComboBox->setCurrentIndex(3); connect(ui.comboStyle, SIGNAL(activated(int)),this, SLOT(changeFormatType(int))); connect(ui.comboFont, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &))); From 6c4d1c34e373b62745998a6c5936107f833f596e Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 4 Oct 2018 18:49:27 +0200 Subject: [PATCH 19/39] fixed removal of "share on channel"/"share on forum" menu entries in own files --- retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index c1ba31b50..58effb773 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -1146,10 +1146,12 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point ) return ; } + QMenu shareChannelMenu(tr("Share on channel...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards + QMenu shareForumMenu(tr("Share on forum...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards + if(type != DIR_TYPE_EXTRA_FILE) { GxsChannelDialog *channelDialog = dynamic_cast(MainWindow::getPage(MainWindow::Channels)); - QMenu shareChannelMenu(tr("Share on channel...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards if(channelDialog != NULL) { @@ -1173,7 +1175,6 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point ) } GxsForumsDialog *forumsDialog = dynamic_cast(MainWindow::getPage(MainWindow::Forums)); - QMenu shareForumMenu(tr("Share on forum...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards if(forumsDialog != NULL) { From fb21e427be5e88ce05aea5f7addaecebf8995f8a Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 4 Oct 2018 19:14:21 +0200 Subject: [PATCH 20/39] removed saving of GxsTrans configuration in class destructor, causing lock up when quitting RS --- libretroshare/src/gxstrans/p3gxstrans.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/gxstrans/p3gxstrans.cc b/libretroshare/src/gxstrans/p3gxstrans.cc index c57b24fbc..c58a514bb 100644 --- a/libretroshare/src/gxstrans/p3gxstrans.cc +++ b/libretroshare/src/gxstrans/p3gxstrans.cc @@ -33,7 +33,8 @@ const uint32_t p3GxsTrans::MAX_DELAY_BETWEEN_CLEANUPS = 900; // every 15 mins. C p3GxsTrans::~p3GxsTrans() { - p3Config::saveConfiguration(); + // (cyril) this cannot be called here! There's chances the thread that saves configs will be dead already! + //p3Config::saveConfiguration(); { RS_STACK_MUTEX(mIngoingMutex); From c6d0203557a11d95e0112193af7133c098872e77 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 4 Oct 2018 19:22:49 +0200 Subject: [PATCH 21/39] added debug output to see which config files are loaded/saved --- libretroshare/src/pqi/p3cfgmgr.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/pqi/p3cfgmgr.cc b/libretroshare/src/pqi/p3cfgmgr.cc index d41a47c80..346e0b99b 100644 --- a/libretroshare/src/pqi/p3cfgmgr.cc +++ b/libretroshare/src/pqi/p3cfgmgr.cc @@ -318,6 +318,7 @@ bool p3Config::loadAttempt(const std::string& cfgFname,const std::string& signFn if(signatureRead != signatureStored) return false; + std::cerr << "(II) Loaded configuration file " << cfgFname << std::endl; return true; } @@ -328,7 +329,6 @@ bool p3Config::saveConfiguration() bool p3Config::saveConfig() { - bool cleanup = true; std::list toSave; saveList(cleanup, toSave); @@ -343,6 +343,7 @@ bool p3Config::saveConfig() std::string cfgFname = Filename(); std::string signFname = Filename() + ".sgn"; + std::cerr << "(II) Saving configuration file " << cfgFname << std::endl; uint32_t bioflags = BIN_FLAGS_HASH_DATA | BIN_FLAGS_WRITEABLE; uint32_t stream_flags = BIN_FLAGS_WRITEABLE; From 285158db5fe9d5955f46a869ce1cbefcd1bcd2b8 Mon Sep 17 00:00:00 2001 From: sehraf Date: Wed, 3 Oct 2018 21:34:55 +0200 Subject: [PATCH 22/39] jsonapi: access messages (mail) --- libretroshare/src/retroshare/rsmsgs.h | 132 ++++++++++++++++++-------- 1 file changed, 93 insertions(+), 39 deletions(-) diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index a459a489c..6926bce95 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -165,9 +165,8 @@ class MessageInfo_v2 int count; /* file count */ }; -class MessageInfo +struct MessageInfo : RsSerializable { -public: MessageInfo(): msgflags(0), size(0), count(0), ts(0) {} std::string msgId; @@ -199,13 +198,42 @@ public: int count; /* file count */ int ts; + + // RsSerializable interface + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(msgId); + + RS_SERIAL_PROCESS(rspeerid_srcId); + RS_SERIAL_PROCESS(rsgxsid_srcId); + + RS_SERIAL_PROCESS(msgflags); + + RS_SERIAL_PROCESS(rspeerid_msgto); + RS_SERIAL_PROCESS(rspeerid_msgcc); + RS_SERIAL_PROCESS(rspeerid_msgbcc); + + RS_SERIAL_PROCESS(rsgxsid_msgto); + RS_SERIAL_PROCESS(rsgxsid_msgcc); + RS_SERIAL_PROCESS(rsgxsid_msgcc); + + RS_SERIAL_PROCESS(title); + RS_SERIAL_PROCESS(msg); + + RS_SERIAL_PROCESS(attach_title); + RS_SERIAL_PROCESS(attach_comment); + RS_SERIAL_PROCESS(files); + + RS_SERIAL_PROCESS(size); + RS_SERIAL_PROCESS(count); + + RS_SERIAL_PROCESS(ts); + } }; -class MsgInfoSummary +struct MsgInfoSummary : RsSerializable { - public: - MsgInfoSummary(): msgflags(0), count(0), ts(0) {} + MsgInfoSummary() : msgflags(0), count(0), ts(0) {} std::string msgId; RsPeerId srcId; @@ -216,6 +244,18 @@ class MsgInfoSummary int count; /* file count */ time_t ts; + + // RsSerializable interface + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(msgId); + RS_SERIAL_PROCESS(srcId); + + RS_SERIAL_PROCESS(msgflags); + + RS_SERIAL_PROCESS(title); + RS_SERIAL_PROCESS(count); + RS_SERIAL_PROCESS(ts); + } }; class MsgTagInfo @@ -444,52 +484,66 @@ public: RsMsgs() {} virtual ~RsMsgs() {} -/****************************************/ -/* Message Items */ -/****************************************/ + /****************************************/ + /* Message Items */ + /****************************************/ -virtual bool getMessageSummaries(std::list &msgList) = 0; -virtual bool getMessage(const std::string &mId, Rs::Msgs::MessageInfo &msg) = 0; -virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox) = 0; + /** + * @brief getMessageSummaries + * @jsonapi{de22velopment} + * @param[out] msgList + * @return always true + */ + virtual bool getMessageSummaries(std::list &msgList) = 0; -virtual bool MessageSend(Rs::Msgs::MessageInfo &info) = 0; -virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag) = 0; -virtual bool MessageToDraft(Rs::Msgs::MessageInfo &info, const std::string &msgParentId) = 0; -virtual bool MessageToTrash(const std::string &mid, bool bTrash) = 0; -virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId) = 0; + /** + * @brief getMessage + * @jsonapi{dev22elopment} + * @param[in] mId message ID to lookup + * @param[out] msg + * @return true on success + */ + virtual bool getMessage(const std::string &mId, Rs::Msgs::MessageInfo &msg) = 0; + virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox) = 0; -virtual bool MessageDelete(const std::string &mid) = 0; -virtual bool MessageRead(const std::string &mid, bool unreadByUser) = 0; -virtual bool MessageReplied(const std::string &mid, bool replied) = 0; -virtual bool MessageForwarded(const std::string &mid, bool forwarded) = 0; -virtual bool MessageStar(const std::string &mid, bool mark) = 0; -virtual bool MessageLoadEmbeddedImages(const std::string &mid, bool load) = 0; + virtual bool MessageSend(Rs::Msgs::MessageInfo &info) = 0; + virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag) = 0; + virtual bool MessageToDraft(Rs::Msgs::MessageInfo &info, const std::string &msgParentId) = 0; + virtual bool MessageToTrash(const std::string &mid, bool bTrash) = 0; + virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId) = 0; -/* message tagging */ + virtual bool MessageDelete(const std::string &mid) = 0; + virtual bool MessageRead(const std::string &mid, bool unreadByUser) = 0; + virtual bool MessageReplied(const std::string &mid, bool replied) = 0; + virtual bool MessageForwarded(const std::string &mid, bool forwarded) = 0; + virtual bool MessageStar(const std::string &mid, bool mark) = 0; + virtual bool MessageLoadEmbeddedImages(const std::string &mid, bool load) = 0; -virtual bool getMessageTagTypes(Rs::Msgs::MsgTagType& tags) = 0; -/* set == false && tagId == 0 --> remove all */ -virtual bool setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color) = 0; -virtual bool removeMessageTagType(uint32_t tagId) = 0; + /* message tagging */ -virtual bool getMessageTag(const std::string &msgId, Rs::Msgs::MsgTagInfo& info) = 0; -virtual bool setMessageTag(const std::string &msgId, uint32_t tagId, bool set) = 0; + virtual bool getMessageTagTypes(Rs::Msgs::MsgTagType& tags) = 0; + /* set == false && tagId == 0 --> remove all */ + virtual bool setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color) = 0; + virtual bool removeMessageTagType(uint32_t tagId) = 0; -virtual bool resetMessageStandardTagTypes(Rs::Msgs::MsgTagType& tags) = 0; + virtual bool getMessageTag(const std::string &msgId, Rs::Msgs::MsgTagInfo& info) = 0; + virtual bool setMessageTag(const std::string &msgId, uint32_t tagId, bool set) = 0; -/****************************************/ -/* Private distant messages */ -/****************************************/ + virtual bool resetMessageStandardTagTypes(Rs::Msgs::MsgTagType& tags) = 0; + + /****************************************/ + /* Private distant messages */ + /****************************************/ virtual uint32_t getDistantMessagingPermissionFlags()=0 ; virtual void setDistantMessagingPermissionFlags(uint32_t flags)=0 ; -/****************************************/ -/* Chat */ -/****************************************/ -// sendChat for broadcast, private, lobby and private distant chat -// note: for lobby chat, you first have to subscribe to a lobby -// for private distant chat, it is reqired to have an active distant chat session + /****************************************/ + /* Chat */ + /****************************************/ + // sendChat for broadcast, private, lobby and private distant chat + // note: for lobby chat, you first have to subscribe to a lobby + // for private distant chat, it is reqired to have an active distant chat session /** * @brief sendChat send a chat message to a given id From 150af40e09e04306a8a5113268af195778a1113e Mon Sep 17 00:00:00 2001 From: sehraf Date: Wed, 3 Oct 2018 21:52:54 +0200 Subject: [PATCH 23/39] jsonapi: convert and add getMessageCount --- libretroshare/src/retroshare/rsmsgs.h | 16 ++++++++-- libretroshare/src/rsserver/p3msgs.cc | 4 +-- libretroshare/src/rsserver/p3msgs.h | 2 +- libretroshare/src/services/p3msgservice.cc | 29 +++++++++---------- libretroshare/src/services/p3msgservice.h | 2 +- .../src/gui/msgs/MessageUserNotify.cpp | 5 ++-- 6 files changed, 34 insertions(+), 24 deletions(-) diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index 6926bce95..a5a1ecc94 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -490,7 +490,7 @@ public: /** * @brief getMessageSummaries - * @jsonapi{de22velopment} + * @jsonapi{development} * @param[out] msgList * @return always true */ @@ -498,13 +498,23 @@ public: /** * @brief getMessage - * @jsonapi{dev22elopment} + * @jsonapi{development} * @param[in] mId message ID to lookup * @param[out] msg * @return true on success */ virtual bool getMessage(const std::string &mId, Rs::Msgs::MessageInfo &msg) = 0; - virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox) = 0; + /** + * @brief getMessageCount + * @jsonapi{development} + * @param[out] nInbox + * @param[out] nInboxNew + * @param[out] nOutbox + * @param[out] nDraftbox + * @param[out] nSentbox + * @param[out] nTrashbox + */ + virtual void getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox) = 0; virtual bool MessageSend(Rs::Msgs::MessageInfo &info) = 0; virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag) = 0; diff --git a/libretroshare/src/rsserver/p3msgs.cc b/libretroshare/src/rsserver/p3msgs.cc index da2220912..1db8788ef 100644 --- a/libretroshare/src/rsserver/p3msgs.cc +++ b/libretroshare/src/rsserver/p3msgs.cc @@ -287,9 +287,9 @@ bool p3Msgs::getMessage(const std::string &mid, MessageInfo &msg) return mMsgSrv->getMessage(mid, msg); } -void p3Msgs::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox) +void p3Msgs::getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox) { - mMsgSrv->getMessageCount(pnInbox, pnInboxNew, pnOutbox, pnDraftbox, pnSentbox, pnTrashbox); + mMsgSrv->getMessageCount(nInbox, nInboxNew, nOutbox, nDraftbox, nSentbox, nTrashbox); } /****************************************/ diff --git a/libretroshare/src/rsserver/p3msgs.h b/libretroshare/src/rsserver/p3msgs.h index edd5911a8..7e092c51d 100644 --- a/libretroshare/src/rsserver/p3msgs.h +++ b/libretroshare/src/rsserver/p3msgs.h @@ -52,7 +52,7 @@ class p3Msgs: public RsMsgs */ virtual bool getMessageSummaries(std::list &msgList); virtual bool getMessage(const std::string &mId, Rs::Msgs::MessageInfo &msg); - virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox); + virtual void getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox); virtual bool MessageSend(Rs::Msgs::MessageInfo &info); virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag); diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index 5b270749b..83cd3bbe0 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -857,16 +857,16 @@ bool p3MsgService::getMessage(const std::string &mId, MessageInfo &msg) return true; } -void p3MsgService::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox) +void p3MsgService::getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox) { RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/ - if (pnInbox) *pnInbox = 0; - if (pnInboxNew) *pnInboxNew = 0; - if (pnOutbox) *pnOutbox = 0; - if (pnDraftbox) *pnDraftbox = 0; - if (pnSentbox) *pnSentbox = 0; - if (pnTrashbox) *pnTrashbox = 0; + nInbox = 0; + nInboxNew = 0; + nOutbox = 0; + nDraftbox = 0; + nSentbox = 0; + nTrashbox = 0; std::map::iterator mit; std::map *apMsg [2] = { &imsg, &msgOutgoing }; @@ -877,24 +877,23 @@ void p3MsgService::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxN initRsMIS(mit->second, mis); if (mis.msgflags & RS_MSG_TRASH) { - if (pnTrashbox) ++(*pnTrashbox); + ++nTrashbox; continue; } switch (mis.msgflags & RS_MSG_BOXMASK) { case RS_MSG_INBOX: - if (pnInbox) ++(*pnInbox); - if ((mis.msgflags & RS_MSG_NEW) == RS_MSG_NEW) { - if (pnInboxNew) ++(*pnInboxNew); - } + ++nInbox; + if ((mis.msgflags & RS_MSG_NEW) == RS_MSG_NEW) + ++nInboxNew; break; case RS_MSG_OUTBOX: - if (pnOutbox) ++(*pnOutbox); + ++nOutbox; break; case RS_MSG_DRAFTBOX: - if (pnDraftbox) ++(*pnDraftbox); + ++nDraftbox; break; case RS_MSG_SENTBOX: - if (pnSentbox) ++(*pnSentbox); + ++nSentbox; break; } } diff --git a/libretroshare/src/services/p3msgservice.h b/libretroshare/src/services/p3msgservice.h index 32f087ad0..9b2189e76 100644 --- a/libretroshare/src/services/p3msgservice.h +++ b/libretroshare/src/services/p3msgservice.h @@ -62,7 +62,7 @@ public: /* External Interface */ bool getMessageSummaries(std::list &msgList); bool getMessage(const std::string &mid, Rs::Msgs::MessageInfo &msg); - void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox); + void getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox); bool decryptMessage(const std::string& mid) ; bool removeMsgId(const std::string &mid); diff --git a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp index ce2363cb9..a5d53b5e2 100644 --- a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp +++ b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp @@ -51,8 +51,9 @@ QIcon MessageUserNotify::getMainIcon(bool hasNew) unsigned int MessageUserNotify::getNewCount() { - unsigned int newInboxCount = 0; - rsMail->getMessageCount(NULL, &newInboxCount, NULL, NULL, NULL, NULL); + uint32_t newInboxCount = 0; + uint32_t a, b, c, d, e; // dummies + rsMail->getMessageCount(a, newInboxCount, b, c, d, e); return newInboxCount; } From 70678ad508a5af2bd29c0279313fd15146297eff Mon Sep 17 00:00:00 2001 From: sehraf Date: Thu, 4 Oct 2018 22:42:34 +0200 Subject: [PATCH 24/39] jsonapi: fix std::map --- libretroshare/src/serialiser/rstypeserializer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/serialiser/rstypeserializer.h b/libretroshare/src/serialiser/rstypeserializer.h index fc13d42e4..c327c6923 100644 --- a/libretroshare/src/serialiser/rstypeserializer.h +++ b/libretroshare/src/serialiser/rstypeserializer.h @@ -290,11 +290,11 @@ struct RsTypeSerializer // Use same allocator to avoid deep copy RsGenericSerializer::SerializeContext kCtx( nullptr, 0, ctx.mFlags, &allocator ); - serial_process(j, kCtx, const_cast(kv.first), "key"); + serial_process(j, kCtx, const_cast(kv.first), "key"); RsGenericSerializer::SerializeContext vCtx( nullptr, 0, ctx.mFlags, &allocator ); - serial_process(j, vCtx, const_cast(kv.second), "value"); + serial_process(j, vCtx, const_cast(kv.second), "value"); if(kCtx.mOk && vCtx.mOk) { From 897c8e0a8a7a82648197469d112e85eb1bf6a170 Mon Sep 17 00:00:00 2001 From: sehraf Date: Thu, 4 Oct 2018 21:26:03 +0200 Subject: [PATCH 25/39] jsonapi: more rsMsg functions --- libretroshare/src/retroshare/rsmsgs.h | 112 ++++++++++++++++-- .../src/serialiser/rstypeserializer.h | 8 +- 2 files changed, 107 insertions(+), 13 deletions(-) diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index a5a1ecc94..2f377792c 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -258,23 +258,27 @@ struct MsgInfoSummary : RsSerializable } }; -class MsgTagInfo +struct MsgTagInfo : RsSerializable { -public: - MsgTagInfo() {} - std::string msgId; std::list tagIds; + + // RsSerializable interface + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(msgId); + RS_SERIAL_PROCESS(tagIds); + } }; -class MsgTagType +struct MsgTagType : RsSerializable { -public: - MsgTagType() {} - /* map containing tagId -> pair (text, rgb color) */ std::map > types; + // RsSerializable interface + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(types); + } }; } //namespace Rs @@ -516,21 +520,111 @@ public: */ virtual void getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox) = 0; + /** + * @brief MessageSend + * @jsonapi{development} + * @param[in] info + * @return always true + */ virtual bool MessageSend(Rs::Msgs::MessageInfo &info) = 0; + + /** + * @brief SystemMessage + * @jsonapi{development} + * @param[in] title + * @param[in] message + * @param[in] systemFlag + * @return true on success + */ virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag) = 0; + + /** + * @brief MessageToDraft + * @jsonapi{development} + * @param[in] info + * @param[in] msgParentId + * @return true on success + */ virtual bool MessageToDraft(Rs::Msgs::MessageInfo &info, const std::string &msgParentId) = 0; + + /** + * @brief MessageToTrash + * @jsonapi{development} + * @param[in] mid + * @param[in] bTrash + * @return true on success + */ virtual bool MessageToTrash(const std::string &mid, bool bTrash) = 0; + + /** + * @brief getMsgParentId + * @jsonapi{development} + * @param[in] msgId + * @param[out] msgParentId + * @return true on success + */ virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId) = 0; + /** + * @brief MessageDelete + * @jsonapi{development} + * @param[in] mid + * @return true on success + */ virtual bool MessageDelete(const std::string &mid) = 0; + + /** + * @brief MessageRead + * @jsonapi{development} + * @param[in] mid + * @param[in] unreadByUser + * @return true on success + */ virtual bool MessageRead(const std::string &mid, bool unreadByUser) = 0; + + /** + * @brief MessageReplied + * @jsonapi{development} + * @param[in] mid + * @param[in] replied + * @return true on success + */ virtual bool MessageReplied(const std::string &mid, bool replied) = 0; + + /** + * @brief MessageForwarded + * @jsonapi{development} + * @param[in] mid + * @param[in] forwarded + * @return true on success + */ virtual bool MessageForwarded(const std::string &mid, bool forwarded) = 0; + + /** + * @brief MessageStar + * @jsonapi{development} + * @param[in] mid + * @param[in] mark + * @return true on success + */ virtual bool MessageStar(const std::string &mid, bool mark) = 0; + + /** + * @brief MessageLoadEmbeddedImages + * @jsonapi{development} + * @param[in] mid + * @param[in] load + * @return true on success + */ virtual bool MessageLoadEmbeddedImages(const std::string &mid, bool load) = 0; /* message tagging */ - + /** + * @brief getMessageTagTypes + * @jsonapi{development} + * @param[out] tags + * @return always true + */ virtual bool getMessageTagTypes(Rs::Msgs::MsgTagType& tags) = 0; /* set == false && tagId == 0 --> remove all */ virtual bool setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color) = 0; diff --git a/libretroshare/src/serialiser/rstypeserializer.h b/libretroshare/src/serialiser/rstypeserializer.h index c327c6923..2f36d7bd3 100644 --- a/libretroshare/src/serialiser/rstypeserializer.h +++ b/libretroshare/src/serialiser/rstypeserializer.h @@ -394,8 +394,8 @@ struct RsTypeSerializer RsGenericSerializer::SerializeContext lCtx( nullptr, 0, ctx.mFlags, &allocator ); - serial_process(j, ctx, p.first, "first"); - serial_process(j, ctx, p.second, "second"); + serial_process(j, lCtx, p.first, "first"); + serial_process(j, lCtx, p.second, "second"); rapidjson::Value key; key.SetString(memberName.c_str(), memberName.length(), allocator); @@ -434,8 +434,8 @@ struct RsTypeSerializer RsGenericSerializer::SerializeContext lCtx(nullptr, 0, ctx.mFlags); lCtx.mJson.SetObject() = v; // Beware of move semantic!! - serial_process(j, ctx, p.first, "first"); - serial_process(j, ctx, p.second, "second"); + serial_process(j, lCtx, p.first, "first"); + serial_process(j, lCtx, p.second, "second"); ctx.mOk &= lCtx.mOk; break; From 500eb7f518a94eb76d37f42e5f51cdbdb915fade Mon Sep 17 00:00:00 2001 From: sehraf Date: Thu, 4 Oct 2018 23:24:06 +0200 Subject: [PATCH 26/39] jsonapi: add rsMsg tagging functions --- libretroshare/src/retroshare/rsmsgs.h | 40 ++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index 2f377792c..77f317b93 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -626,13 +626,51 @@ public: * @return always true */ virtual bool getMessageTagTypes(Rs::Msgs::MsgTagType& tags) = 0; - /* set == false && tagId == 0 --> remove all */ + + /** + * @brief setMessageTagType + * @jsonapi{development} + * @param[in] tagId + * @param[in] text + * @param[in] rgb_color + * @return true on success + */ virtual bool setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color) = 0; + + /** + * @brief removeMessageTagType + * @jsonapi{development} + * @param[in] tagId + * @return true on success + */ virtual bool removeMessageTagType(uint32_t tagId) = 0; + /** + * @brief getMessageTag + * @jsonapi{development} + * @param[in] msgId + * @param[out] info + * @return true on success + */ virtual bool getMessageTag(const std::string &msgId, Rs::Msgs::MsgTagInfo& info) = 0; + + /** + * @brief setMessageTag + * set == false && tagId == 0 --> remove all + * @jsonapi{development} + * @param[in] msgId + * @param[in] tagId + * @param[in] set + * @return true on success + */ virtual bool setMessageTag(const std::string &msgId, uint32_t tagId, bool set) = 0; + /** + * @brief resetMessageStandardTagTypes + * @jsonapi{development} + * @param[out] tags + * @return always true + */ virtual bool resetMessageStandardTagTypes(Rs::Msgs::MsgTagType& tags) = 0; /****************************************/ From 6dabb81dc0137fbe52dea550a226018ed023d33e Mon Sep 17 00:00:00 2001 From: sehraf Date: Thu, 4 Oct 2018 23:25:23 +0200 Subject: [PATCH 27/39] rsMsg: unify parameter name --- libretroshare/src/retroshare/rsmsgs.h | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index 77f317b93..479d68592 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -503,11 +503,11 @@ public: /** * @brief getMessage * @jsonapi{development} - * @param[in] mId message ID to lookup + * @param[in] msgId message ID to lookup * @param[out] msg * @return true on success */ - virtual bool getMessage(const std::string &mId, Rs::Msgs::MessageInfo &msg) = 0; + virtual bool getMessage(const std::string &msgId, Rs::Msgs::MessageInfo &msg) = 0; /** * @brief getMessageCount * @jsonapi{development} @@ -550,11 +550,11 @@ public: /** * @brief MessageToTrash * @jsonapi{development} - * @param[in] mid + * @param[in] msgId * @param[in] bTrash * @return true on success */ - virtual bool MessageToTrash(const std::string &mid, bool bTrash) = 0; + virtual bool MessageToTrash(const std::string &msgId, bool bTrash) = 0; /** * @brief getMsgParentId @@ -568,55 +568,55 @@ public: /** * @brief MessageDelete * @jsonapi{development} - * @param[in] mid + * @param[in] msgId * @return true on success */ - virtual bool MessageDelete(const std::string &mid) = 0; + virtual bool MessageDelete(const std::string &msgId) = 0; /** * @brief MessageRead * @jsonapi{development} - * @param[in] mid + * @param[in] msgId * @param[in] unreadByUser * @return true on success */ - virtual bool MessageRead(const std::string &mid, bool unreadByUser) = 0; + virtual bool MessageRead(const std::string &msgId, bool unreadByUser) = 0; /** * @brief MessageReplied * @jsonapi{development} - * @param[in] mid + * @param[in] msgId * @param[in] replied * @return true on success */ - virtual bool MessageReplied(const std::string &mid, bool replied) = 0; + virtual bool MessageReplied(const std::string &msgId, bool replied) = 0; /** * @brief MessageForwarded * @jsonapi{development} - * @param[in] mid + * @param[in] msgId * @param[in] forwarded * @return true on success */ - virtual bool MessageForwarded(const std::string &mid, bool forwarded) = 0; + virtual bool MessageForwarded(const std::string &msgId, bool forwarded) = 0; /** * @brief MessageStar * @jsonapi{development} - * @param[in] mid + * @param[in] msgId * @param[in] mark * @return true on success */ - virtual bool MessageStar(const std::string &mid, bool mark) = 0; + virtual bool MessageStar(const std::string &msgId, bool mark) = 0; /** * @brief MessageLoadEmbeddedImages * @jsonapi{development} - * @param[in] mid + * @param[in] msgId * @param[in] load * @return true on success */ - virtual bool MessageLoadEmbeddedImages(const std::string &mid, bool load) = 0; + virtual bool MessageLoadEmbeddedImages(const std::string &msgId, bool load) = 0; /* message tagging */ /** From 4de049820866d83b7dd40084adf7db23cd79acb2 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 5 Oct 2018 16:54:36 +0200 Subject: [PATCH 28/39] fixed bad signature checking code for config files --- libretroshare/src/pqi/p3cfgmgr.cc | 33 ++++++++++++++++++++----------- libretroshare/src/pqi/pqibin.h | 1 - libretroshare/src/util/rsprint.cc | 27 +++++++++++++++++++++++++ libretroshare/src/util/rsprint.h | 1 + 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/libretroshare/src/pqi/p3cfgmgr.cc b/libretroshare/src/pqi/p3cfgmgr.cc index d41a47c80..687e643bf 100644 --- a/libretroshare/src/pqi/p3cfgmgr.cc +++ b/libretroshare/src/pqi/p3cfgmgr.cc @@ -299,26 +299,37 @@ bool p3Config::loadAttempt(const std::string& cfgFname,const std::string& signFn /* set hash */ setHash(bio->gethash()); + // In order to check the signature that is stored on disk, we compute the hash of the current data (which should match the hash of the data on disc because we just read it), + // and validate the signature from the disk on this data. + std::string signatureRead; RsFileHash strHash(Hash()); - AuthSSL::getAuthSSL()->SignData(strHash.toByteArray(), RsFileHash::SIZE_IN_BYTES, signatureRead); - BinMemInterface *signbio = new BinMemInterface(signatureRead.size(), BIN_FLAGS_READABLE); + BinFileInterface bfi(signFname.c_str(), BIN_FLAGS_READABLE); - if(!signbio->readfromfile(signFname.c_str())) - { - delete signbio; + if(bfi.getFileSize() == 0) + return false ; + + RsTemporaryMemory mem(bfi.getFileSize()) ; + + if(!bfi.readdata(mem,mem.size())) return false; + + // signature is stored as ascii so we need to convert it back to binary + + RsTemporaryMemory mem2(bfi.getFileSize()/2) ; + + if(!RsUtil::HexToBin(std::string((char*)(unsigned char*)mem,mem.size()),mem2,mem2.size())) + { + std::cerr << "Input string is not a Hex string!!"<< std::endl; + return false ; } - std::string signatureStored((char *) signbio->memptr(), signbio->memsize()); + bool signature_checks = AuthSSL::getAuthSSL()->VerifyOwnSignBin(strHash.toByteArray(), RsFileHash::SIZE_IN_BYTES,mem2,mem2.size()); - delete signbio; + std::cerr << "(II) checked signature of config file " << cfgFname << ": " << (signature_checks?"OK":"Wrong!") << std::endl; - if(signatureRead != signatureStored) - return false; - - return true; + return signature_checks; } bool p3Config::saveConfiguration() diff --git a/libretroshare/src/pqi/pqibin.h b/libretroshare/src/pqi/pqibin.h index b8cbb1c58..349a049ba 100644 --- a/libretroshare/src/pqi/pqibin.h +++ b/libretroshare/src/pqi/pqibin.h @@ -69,7 +69,6 @@ virtual bool bandwidthLimited() { return false; } virtual RsFileHash gethash(); virtual uint64_t bytecount(); -protected: virtual uint64_t getFileSize(); private: diff --git a/libretroshare/src/util/rsprint.cc b/libretroshare/src/util/rsprint.cc index dca3d925c..88ee27ca5 100644 --- a/libretroshare/src/util/rsprint.cc +++ b/libretroshare/src/util/rsprint.cc @@ -104,6 +104,33 @@ std::string RsUtil::HashId(const std::string &id, bool reverse) return hash; } +static int toHalfByte(char u,bool& ok) +{ + if(u >= 'a' && u <= 'f') return u-'a' + 0xa; + if(u >= 'A' && u <= 'F') return u-'A' + 0xa; + if(u >= '0' && u <= '9') return u-'0' + 0x0; + + ok = false ; + + return 0; +} + +bool RsUtil::HexToBin(const std::string& input,unsigned char *data, const uint32_t len) +{ + if(input.size() & 1) + return false ; + + if(len != input.size()/2) + return false ; + + bool ok = true ; + + for(uint32_t i=0;(i0 and len>max_len, only the first "max_len" bytes are writen to the string and "..." is happened. std::string BinToHex(const unsigned char *arr, const uint32_t len, uint32_t max_len=0); +bool HexToBin(const std::string& input,unsigned char *data, const uint32_t len); std::string NumberToString(uint64_t n, bool hex=false); std::string HashId(const std::string &id, bool reverse = false); std::vector BinToSha256(const std::vector &in); From dbd52c0c9c79d96d82d46c2fb804ec4cccfa3465 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 5 Oct 2018 17:01:54 +0200 Subject: [PATCH 29/39] fixed bug in previous commit --- libretroshare/src/pqi/p3cfgmgr.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/pqi/p3cfgmgr.cc b/libretroshare/src/pqi/p3cfgmgr.cc index 687e643bf..f7f7f6ebf 100644 --- a/libretroshare/src/pqi/p3cfgmgr.cc +++ b/libretroshare/src/pqi/p3cfgmgr.cc @@ -300,7 +300,8 @@ bool p3Config::loadAttempt(const std::string& cfgFname,const std::string& signFn setHash(bio->gethash()); // In order to check the signature that is stored on disk, we compute the hash of the current data (which should match the hash of the data on disc because we just read it), - // and validate the signature from the disk on this data. + // and validate the signature from the disk on this data. The config file data is therefore hashed twice. Not a security issue, but + // this is a bit inelegant. std::string signatureRead; RsFileHash strHash(Hash()); From 41aa675a9b83caae1322af4a24ad4f262a0c63bf Mon Sep 17 00:00:00 2001 From: G10h4ck Date: Sat, 6 Oct 2018 02:41:35 +0200 Subject: [PATCH 30/39] Avoid travis breakage due to outdated qt55 depend --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4b0278d19..b02445b39 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,8 +19,8 @@ before_install: - if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install -y build-essential libssl-dev libsqlcipher-dev libbz2-dev libmicrohttpd-dev libsqlite3-dev libupnp-dev pkg-config qt5-default libxss-dev qtmultimedia5-dev libqt5x11extras5-dev libqt5designer5 libxapian-dev qttools5-dev; fi - if [ $TRAVIS_OS_NAME == osx ]; then brew update ; fi - - if [ $TRAVIS_OS_NAME == osx ]; then brew install qt55 openssl miniupnpc libmicrohttpd sqlcipher xapian; fi - - if [ $TRAVIS_OS_NAME == osx ]; then brew link --force qt55 ; fi + - if [ $TRAVIS_OS_NAME == osx ]; then brew install qt openssl miniupnpc libmicrohttpd sqlcipher xapian; fi + - if [ $TRAVIS_OS_NAME == osx ]; then brew link --force qt ; fi - wget https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz - tar -xf v1.1.0.tar.gz From 137bd9cd6db2c1fe64baea363bcdc307d2640128 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sat, 6 Oct 2018 23:50:29 +0200 Subject: [PATCH 31/39] jsonapi: fix nested std types --- libretroshare/src/serialiser/rstypeserializer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/serialiser/rstypeserializer.h b/libretroshare/src/serialiser/rstypeserializer.h index 2f36d7bd3..a71a8468c 100644 --- a/libretroshare/src/serialiser/rstypeserializer.h +++ b/libretroshare/src/serialiser/rstypeserializer.h @@ -532,7 +532,7 @@ struct RsTypeSerializer for(uint32_t i=0; i(j,ctx,tmp,memberName); + serial_process(j,ctx,tmp,memberName); v.insert(tmp); } break; @@ -590,7 +590,7 @@ struct RsTypeSerializer for(uint32_t i=0;i(j,ctx,tmp,memberName); + serial_process(j,ctx,tmp,memberName); v.push_back(tmp); } break; From 329050a9c25bd2286b6941b675a383c1c63d2041 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sun, 7 Oct 2018 01:34:05 +0200 Subject: [PATCH 32/39] Use safer rstime_t instead of time_t Avoid problems to serialization on different platforms, without breaking nested STL containers serialization. The conversion have been made with sed, and checked with grep, plus kdiff3 visual ispection, plus rutime tests, so it should be fine. --- libretroshare/src/chat/distributedchat.cc | 88 +++++++++---------- libretroshare/src/chat/distributedchat.h | 10 +-- libretroshare/src/chat/p3chatservice.cc | 4 +- libretroshare/src/chat/rschatitems.cc | 2 +- libretroshare/src/deep_search/deep_search.h | 4 +- libretroshare/src/dht/connectstatebox.cc | 12 +-- libretroshare/src/dht/connectstatebox.h | 10 +-- libretroshare/src/dht/p3bitdht.h | 16 ++-- libretroshare/src/dht/p3bitdht_interface.cc | 4 +- libretroshare/src/dht/p3bitdht_peernet.cc | 14 +-- libretroshare/src/file_sharing/README.txt | 4 +- .../src/file_sharing/dir_hierarchy.cc | 16 ++-- .../src/file_sharing/dir_hierarchy.h | 22 ++--- .../src/file_sharing/directory_storage.cc | 20 ++--- .../src/file_sharing/directory_storage.h | 27 +++--- .../src/file_sharing/directory_updater.cc | 6 +- .../src/file_sharing/directory_updater.h | 5 +- libretroshare/src/file_sharing/hash_cache.cc | 8 +- libretroshare/src/file_sharing/hash_cache.h | 7 +- libretroshare/src/file_sharing/p3filelists.cc | 26 +++--- libretroshare/src/file_sharing/p3filelists.h | 16 ++-- .../src/file_sharing/rsfilelistitems.cc | 2 +- libretroshare/src/ft/ftchunkmap.cc | 8 +- libretroshare/src/ft/ftchunkmap.h | 8 +- libretroshare/src/ft/ftcontroller.cc | 8 +- libretroshare/src/ft/ftcontroller.h | 6 +- libretroshare/src/ft/ftdatamultiplex.cc | 16 ++-- libretroshare/src/ft/ftdatamultiplex.h | 6 +- libretroshare/src/ft/ftextralist.cc | 12 +-- libretroshare/src/ft/ftextralist.h | 3 +- libretroshare/src/ft/ftfilecreator.cc | 10 +-- libretroshare/src/ft/ftfilecreator.h | 8 +- libretroshare/src/ft/ftfileprovider.cc | 12 +-- libretroshare/src/ft/ftfileprovider.h | 10 +-- libretroshare/src/ft/ftserver.cc | 20 ++--- libretroshare/src/ft/ftserver.h | 4 +- libretroshare/src/ft/fttransfermodule.cc | 8 +- libretroshare/src/ft/fttransfermodule.h | 10 +-- libretroshare/src/grouter/groutercache.h | 2 +- libretroshare/src/grouter/grouteritems.cc | 10 +-- libretroshare/src/grouter/grouteritems.h | 2 +- libretroshare/src/grouter/groutermatrix.cc | 12 +-- libretroshare/src/grouter/groutermatrix.h | 4 +- libretroshare/src/grouter/groutertypes.h | 18 ++-- libretroshare/src/grouter/p3grouter.cc | 16 ++-- libretroshare/src/grouter/p3grouter.h | 14 +-- libretroshare/src/gxs/db_acadeeb.h | 2 +- libretroshare/src/gxs/db_gixp.h | 2 +- libretroshare/src/gxs/db_gxp.h | 8 +- libretroshare/src/gxs/rsdataservice.cc | 2 +- libretroshare/src/gxs/rsdataservice.h | 2 +- libretroshare/src/gxs/rsgds.h | 2 +- libretroshare/src/gxs/rsgenexchange.cc | 12 +-- libretroshare/src/gxs/rsgenexchange.h | 14 +-- libretroshare/src/gxs/rsgixs.h | 4 +- libretroshare/src/gxs/rsgxsdata.h | 8 +- libretroshare/src/gxs/rsgxsdataaccess.cc | 18 ++-- libretroshare/src/gxs/rsgxsdataaccess.h | 2 +- libretroshare/src/gxs/rsgxsnetservice.cc | 34 +++---- libretroshare/src/gxs/rsgxsnetservice.h | 12 +-- libretroshare/src/gxs/rsgxsnettunnel.cc | 2 +- libretroshare/src/gxs/rsgxsnettunnel.h | 6 +- libretroshare/src/gxs/rsgxsnetutils.cc | 6 +- libretroshare/src/gxs/rsgxsnetutils.h | 10 +-- libretroshare/src/gxs/rsgxsutil.cc | 4 +- libretroshare/src/gxs/rsnxs.h | 4 +- libretroshare/src/gxstrans/p3gxstrans.cc | 2 +- libretroshare/src/gxstrans/p3gxstrans.h | 6 +- libretroshare/src/gxstunnel/p3gxstunnel.cc | 16 ++-- libretroshare/src/gxstunnel/p3gxstunnel.h | 8 +- .../src/gxstunnel/rsgxstunnelitems.cc | 2 +- libretroshare/src/jsonapi/jsonapiitems.h | 2 +- libretroshare/src/pgp/pgphandler.cc | 4 +- libretroshare/src/pgp/pgphandler.h | 8 +- libretroshare/src/plugins/pluginmanager.cc | 2 +- libretroshare/src/plugins/pluginmanager.h | 2 +- libretroshare/src/pqi/authgpg.cc | 2 +- libretroshare/src/pqi/authgpg.h | 2 +- libretroshare/src/pqi/p3dhtmgr.cc | 20 ++--- libretroshare/src/pqi/p3dhtmgr.h | 10 +-- libretroshare/src/pqi/p3historymgr.cc | 6 +- libretroshare/src/pqi/p3historymgr.h | 2 +- libretroshare/src/pqi/p3linkmgr.cc | 14 +-- libretroshare/src/pqi/p3linkmgr.h | 18 ++-- libretroshare/src/pqi/p3netmgr.cc | 12 +-- libretroshare/src/pqi/p3netmgr.h | 4 +- libretroshare/src/pqi/p3peermgr.cc | 18 ++-- libretroshare/src/pqi/p3peermgr.h | 10 +-- libretroshare/src/pqi/pqibin.h | 3 +- libretroshare/src/pqi/pqihandler.cc | 4 +- libretroshare/src/pqi/pqihandler.h | 6 +- libretroshare/src/pqi/pqiipset.cc | 4 +- libretroshare/src/pqi/pqiipset.h | 3 +- libretroshare/src/pqi/pqinetstatebox.cc | 10 +-- libretroshare/src/pqi/pqinetstatebox.h | 14 +-- libretroshare/src/pqi/pqiperson.h | 4 +- libretroshare/src/pqi/pqissl.cc | 2 +- libretroshare/src/pqi/pqissl.h | 6 +- libretroshare/src/pqi/pqissllistener.cc | 2 +- libretroshare/src/pqi/pqissllistener.h | 2 +- libretroshare/src/pqi/pqistreamer.cc | 8 +- libretroshare/src/pqi/pqistreamer.h | 10 +-- libretroshare/src/retroshare/rsbanlist.h | 3 +- libretroshare/src/retroshare/rsconfig.h | 6 +- libretroshare/src/retroshare/rsdht.h | 18 ++-- libretroshare/src/retroshare/rsexpr.h | 4 +- libretroshare/src/retroshare/rsfiles.h | 5 +- libretroshare/src/retroshare/rsgrouter.h | 6 +- libretroshare/src/retroshare/rsgxschannels.h | 2 +- libretroshare/src/retroshare/rsgxsdistsync.h | 4 +- libretroshare/src/retroshare/rsgxsiface.h | 4 +- .../src/retroshare/rsgxsifacetypes.h | 9 +- libretroshare/src/retroshare/rsidentity.h | 12 +-- libretroshare/src/retroshare/rsmsgs.h | 10 +-- libretroshare/src/retroshare/rspeers.h | 3 +- libretroshare/src/retroshare/rsplugin.h | 4 +- libretroshare/src/retroshare/rsposted.h | 2 +- libretroshare/src/retroshare/rsstatus.h | 2 +- libretroshare/src/retroshare/rstokenservice.h | 4 +- libretroshare/src/retroshare/rstypes.h | 3 +- libretroshare/src/rsitems/rsbanlistitems.cc | 2 +- libretroshare/src/rsitems/rsbanlistitems.h | 2 +- libretroshare/src/rsitems/rsgxsiditems.h | 2 +- libretroshare/src/rsitems/rsgxsitems.h | 4 +- .../src/rsitems/rsgxsreputationitems.cc | 2 +- libretroshare/src/rsitems/rsgxsupdateitems.h | 4 +- libretroshare/src/rsitems/rsmsgitems.cc | 2 +- libretroshare/src/rsserver/p3face-config.cc | 2 +- libretroshare/src/rsserver/p3face-server.cc | 6 +- libretroshare/src/rsserver/p3msgs.cc | 2 +- libretroshare/src/rsserver/p3peers.cc | 2 +- libretroshare/src/rsserver/rstypes.cc | 2 +- libretroshare/src/serialiser/rsbaseserial.cc | 4 +- libretroshare/src/serialiser/rsbaseserial.h | 8 +- .../src/serialiser/rsmailtransportitems.cc | 2 +- libretroshare/src/serialiser/rsserial.cc | 4 +- libretroshare/src/serialiser/rsserializer.h | 2 +- .../src/serialiser/rstypeserializer.cc | 36 +++----- .../src/services/autoproxy/p3i2pbob.cc | 2 +- .../src/services/autoproxy/p3i2pbob.h | 4 +- libretroshare/src/services/p3banlist.cc | 24 ++--- libretroshare/src/services/p3banlist.h | 8 +- libretroshare/src/services/p3bwctrl.cc | 10 +-- libretroshare/src/services/p3bwctrl.h | 8 +- libretroshare/src/services/p3discovery2.h | 2 +- libretroshare/src/services/p3gxschannels.cc | 12 +-- libretroshare/src/services/p3gxschannels.h | 4 +- libretroshare/src/services/p3gxscircles.cc | 4 +- libretroshare/src/services/p3gxscircles.h | 8 +- libretroshare/src/services/p3gxsforums.cc | 4 +- libretroshare/src/services/p3gxsforums.h | 2 +- libretroshare/src/services/p3gxsreputation.cc | 30 +++---- libretroshare/src/services/p3gxsreputation.h | 26 +++--- libretroshare/src/services/p3heartbeat.cc | 2 +- libretroshare/src/services/p3heartbeat.h | 2 +- libretroshare/src/services/p3idservice.cc | 42 ++++----- libretroshare/src/services/p3idservice.h | 22 ++--- libretroshare/src/services/p3msgservice.cc | 6 +- libretroshare/src/services/p3msgservice.h | 4 +- libretroshare/src/services/p3posted.cc | 8 +- libretroshare/src/services/p3rtt.cc | 6 +- libretroshare/src/services/p3rtt.h | 2 +- libretroshare/src/services/p3service.cc | 2 +- libretroshare/src/services/p3statusservice.cc | 2 +- libretroshare/src/tcponudp/tcpstream.cc | 4 +- libretroshare/src/tcponudp/tou.cc | 2 +- libretroshare/src/tcponudp/udprelay.cc | 6 +- libretroshare/src/tcponudp/udprelay.h | 6 +- libretroshare/src/tcponudp/udpstunner.cc | 26 +++--- libretroshare/src/tcponudp/udpstunner.h | 16 ++-- libretroshare/src/tests/dbase/ficachetest.cc | 2 +- libretroshare/src/tests/dbase/fisavetest.cc | 4 +- libretroshare/src/tests/dbase/fitest2.cc | 8 +- .../src/tests/ft/ftcontrollertest.cc | 4 +- libretroshare/src/tests/ft/ftserver2test.cc | 4 +- libretroshare/src/tests/ft/ftserver3test.cc | 2 +- .../gxs/gen_exchange/genexchangetester.cpp | 12 +-- libretroshare/src/tests/pqi/conn_harness.cc | 10 +-- libretroshare/src/tests/pqi/conn_test.cc | 6 +- libretroshare/src/tests/pqi/dht_test.cc | 6 +- .../src/tests/pqi/p3connmgr_connect_test.cc | 8 +- .../src/tests/pqi/p3connmgr_reset_test.cc | 6 +- libretroshare/src/tests/pqi/pqiipset_test.cc | 2 +- libretroshare/src/tests/pqi/pqiqos_test.cc | 8 +- libretroshare/src/tests/pqi/testconnect.cc | 4 +- .../src/tests/serialiser/distribitem_test.cc | 4 +- .../src/tests/serialiser/tlvrandom_test.cc | 6 +- libretroshare/src/tests/tcponudp/bidir_tou.cc | 2 +- .../src/tests/tcponudp/stacks_tou.cc | 2 +- libretroshare/src/tests/tcponudp/timed_tou.cc | 2 +- .../src/tests/util/testretrocursor.cpp | 2 +- libretroshare/src/tests/util/testretrodb.cpp | 2 +- libretroshare/src/turtle/p3turtle.cc | 60 ++++++------- libretroshare/src/turtle/p3turtle.h | 10 +-- libretroshare/src/unused/p3dsdv.cc | 18 ++-- libretroshare/src/unused/p3dsdv.h | 4 +- libretroshare/src/unused/pqiarchive.cc | 2 +- libretroshare/src/unused/rsdsdv.h | 4 +- libretroshare/src/upnp/UPnPBase.cpp | 6 +- libretroshare/src/upnp/upnputil.c | 4 +- libretroshare/src/util/dnsresolver.cc | 10 +-- libretroshare/src/util/dnsresolver.h | 2 +- libretroshare/src/util/extaddrfinder.cc | 4 +- libretroshare/src/util/extaddrfinder.h | 2 +- libretroshare/src/util/folderiterator.cc | 6 +- libretroshare/src/util/folderiterator.h | 9 +- libretroshare/src/util/retrodb.cc | 6 +- libretroshare/src/util/rsdebug.cc | 6 +- libretroshare/src/util/rsdiscspace.cc | 6 +- libretroshare/src/util/rsdiscspace.h | 2 +- libretroshare/src/util/rsmemcache.h | 42 ++++----- libretroshare/src/util/rsprint.cc | 2 +- libretroshare/src/util/rsrandom.cc | 2 +- libretroshare/src/util/rsrecogn.cc | 2 +- libretroshare/src/util/rsthreads.cc | 4 +- libretroshare/src/util/rsthreads.h | 4 +- libretroshare/src/util/rstickevent.cc | 12 +-- libretroshare/src/util/rstickevent.h | 8 +- libretroshare/src/util/rstime.h | 19 +++- libretroshare/src/util/smallobject.cc | 4 +- libretroshare/src/zeroconf/p3zcnatassist.h | 2 +- libretroshare/src/zeroconf/p3zeroconf.cc | 12 +-- libretroshare/src/zeroconf/p3zeroconf.h | 14 +-- 223 files changed, 930 insertions(+), 911 deletions(-) diff --git a/libretroshare/src/chat/distributedchat.cc b/libretroshare/src/chat/distributedchat.cc index 0c7a765de..5bc640fd7 100644 --- a/libretroshare/src/chat/distributedchat.cc +++ b/libretroshare/src/chat/distributedchat.cc @@ -40,16 +40,16 @@ //#define DEBUG_CHAT_LOBBIES 1 static const int CONNECTION_CHALLENGE_MAX_COUNT = 20 ; // sends a connection challenge every 20 messages -static const time_t CONNECTION_CHALLENGE_MAX_MSG_AGE = 30 ; // maximum age of a message to be used in a connection challenge +static const rstime_t CONNECTION_CHALLENGE_MAX_MSG_AGE = 30 ; // maximum age of a message to be used in a connection challenge static const int CONNECTION_CHALLENGE_MIN_DELAY = 15 ; // sends a connection at most every 15 seconds static const int LOBBY_CACHE_CLEANING_PERIOD = 10 ; // clean lobby caches every 10 secs (remove old messages) -static const time_t MAX_KEEP_MSG_RECORD = 1200 ; // keep msg record for 1200 secs max. -static const time_t MAX_KEEP_INACTIVE_NICKNAME = 180 ; // keep inactive nicknames for 3 mn max. -static const time_t MAX_DELAY_BETWEEN_LOBBY_KEEP_ALIVE = 120 ; // send keep alive packet every 2 minutes. -static const time_t MAX_KEEP_PUBLIC_LOBBY_RECORD = 60 ; // keep inactive lobbies records for 60 secs max. -static const time_t MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ = 20 ; // don't ask for lobby list more than once every 30 secs. -static const time_t LOBBY_LIST_AUTO_UPDATE_TIME = 121 ; // regularly ask for available lobbies every 5 minutes, to allow auto-subscribe to work +static const rstime_t MAX_KEEP_MSG_RECORD = 1200 ; // keep msg record for 1200 secs max. +static const rstime_t MAX_KEEP_INACTIVE_NICKNAME = 180 ; // keep inactive nicknames for 3 mn max. +static const rstime_t MAX_DELAY_BETWEEN_LOBBY_KEEP_ALIVE = 120 ; // send keep alive packet every 2 minutes. +static const rstime_t MAX_KEEP_PUBLIC_LOBBY_RECORD = 60 ; // keep inactive lobbies records for 60 secs max. +static const rstime_t MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ = 20 ; // don't ask for lobby list more than once every 30 secs. +static const rstime_t LOBBY_LIST_AUTO_UPDATE_TIME = 121 ; // regularly ask for available lobbies every 5 minutes, to allow auto-subscribe to work static const uint32_t MAX_ALLOWED_LOBBIES_IN_LIST_WARNING = 50 ; //static const uint32_t MAX_MESSAGES_PER_SECONDS_NUMBER = 5 ; // max number of messages from a given peer in a window for duration below @@ -71,10 +71,10 @@ DistributedChatService::DistributedChatService(uint32_t serv_type,p3ServiceContr void DistributedChatService::flush() { - static time_t last_clean_time_lobby = 0 ; - static time_t last_req_chat_lobby_list = 0 ; + static rstime_t last_clean_time_lobby = 0 ; + static rstime_t last_req_chat_lobby_list = 0 ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(last_clean_time_lobby + LOBBY_CACHE_CLEANING_PERIOD < now) { @@ -117,19 +117,19 @@ bool DistributedChatService::handleRecvChatLobbyMsgItem(RsChatMsgItem *ci) if(cli == NULL) return true ; // the item is handled correctly if it's not a lobby item ;-) - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; - if(now+100 > (time_t) cli->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep plus 100 seconds ! It's too old, and is going to make an echo! + if(now+100 > (rstime_t) cli->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep plus 100 seconds ! It's too old, and is going to make an echo! { - std::cerr << "Received severely outdated lobby event item (" << now - (time_t)cli->sendTime << " in the past)! Dropping it!" << std::endl; + std::cerr << "Received severely outdated lobby event item (" << now - (rstime_t)cli->sendTime << " in the past)! Dropping it!" << std::endl; std::cerr << "Message item is:" << std::endl; cli->print(std::cerr) ; std::cerr << std::endl; return false ; } - if(now+600 < (time_t) cli->sendTime) // the message is from the future. Drop it. more than 10 minutes + if(now+600 < (rstime_t) cli->sendTime) // the message is from the future. Drop it. more than 10 minutes { - std::cerr << "Received event item from the future (" << (time_t)cli->sendTime - now << " seconds in the future)! Dropping it!" << std::endl; + std::cerr << "Received event item from the future (" << (rstime_t)cli->sendTime - now << " seconds in the future)! Dropping it!" << std::endl; std::cerr << "Message item is:" << std::endl; cli->print(std::cerr) ; std::cerr << std::endl; @@ -292,7 +292,7 @@ bool DistributedChatService::getVirtualPeerId(const ChatLobbyId& id,ChatLobbyVir void DistributedChatService::locked_printDebugInfo() const { std::cerr << "Recorded lobbies: " << std::endl; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; for( std::map::const_iterator it(_chat_lobbys.begin()) ;it!=_chat_lobbys.end();++it) { @@ -307,7 +307,7 @@ void DistributedChatService::locked_printDebugInfo() const std::cerr << " Last activity\t: " << now - it->second.last_activity << " seconds ago." << std::endl; std::cerr << " Cached messages\t: " << it->second.msg_cache.size() << std::endl; - for(std::map::const_iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end();++it2) + for(std::map::const_iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end();++it2) std::cerr << " " << std::hex << it2->first << std::dec << " time=" << now - it2->second << " secs ago" << std::endl; std::cerr << " Participating friends: " << std::endl; @@ -317,7 +317,7 @@ void DistributedChatService::locked_printDebugInfo() const std::cerr << " Participating nick names: " << std::endl; - for(std::map::const_iterator it2(it->second.gxs_ids.begin());it2!=it->second.gxs_ids.end();++it2) + for(std::map::const_iterator it2(it->second.gxs_ids.begin());it2!=it->second.gxs_ids.end();++it2) std::cerr << " " << it2->first << ": " << now - it2->second << " secs ago" << std::endl; } @@ -339,7 +339,7 @@ void DistributedChatService::locked_printDebugInfo() const bool DistributedChatService::locked_bouncingObjectCheck(RsChatLobbyBouncingObject *obj,const RsPeerId& peer_id,uint32_t lobby_count) { - static std::map > message_counts ; + static std::map > message_counts ; std::ostringstream os ; os << obj->lobby_id ; @@ -375,14 +375,14 @@ bool DistributedChatService::locked_bouncingObjectCheck(RsChatLobbyBouncingObjec #ifdef DEBUG_CHAT_LOBBIES std::cerr << "lobby_count=" << lobby_count << std::endl; std::cerr << "Got msg for peer " << pid << std::dec << ". Limit is " << max_cnt << ". List is " ; - for(std::list::const_iterator it(message_counts[pid].begin());it!=message_counts[pid].end();++it) + for(std::list::const_iterator it(message_counts[pid].begin());it!=message_counts[pid].end();++it) std::cerr << *it << " " ; std::cerr << std::endl; #endif - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; - std::list& lst = message_counts[pid] ; + std::list& lst = message_counts[pid] ; // Clean old messages time stamps from the list. // @@ -501,7 +501,7 @@ void DistributedChatService::handleRecvChatLobbyList(RsChatLobbyListItem *item) std::cerr << "Received chat lobby list from friend " << item->PeerId() << ", " << item->lobbies.size() << " elements." << std::endl; #endif { - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/ @@ -677,7 +677,7 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem * #ifdef DEBUG_CHAT_LOBBIES std::cerr << "Received ChatLobbyEvent item of type " << (int)(item->event_type) << ", and string=" << item->string1 << std::endl; #endif - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(rsReputations->overallReputationLevel(item->signature.keyId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) { @@ -713,17 +713,17 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem * } addTimeShiftStatistics((int)now - (int)item->sendTime) ; - if(now+100 > (time_t) item->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep minus 100 seconds ! It's too old, and is going to make an echo! + if(now+100 > (rstime_t) item->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep minus 100 seconds ! It's too old, and is going to make an echo! { - std::cerr << "Received severely outdated lobby event item (" << now - (time_t)item->sendTime << " in the past)! Dropping it!" << std::endl; + std::cerr << "Received severely outdated lobby event item (" << now - (rstime_t)item->sendTime << " in the past)! Dropping it!" << std::endl; std::cerr << "Message item is:" << std::endl; item->print(std::cerr) ; std::cerr << std::endl; return ; } - if(now+600 < (time_t) item->sendTime) // the message is from the future more than 10 minutes + if(now+600 < (rstime_t) item->sendTime) // the message is from the future more than 10 minutes { - std::cerr << "Received event item from the future (" << (time_t)item->sendTime - now << " seconds in the future)! Dropping it!" << std::endl; + std::cerr << "Received event item from the future (" << (rstime_t)item->sendTime - now << " seconds in the future)! Dropping it!" << std::endl; std::cerr << "Message item is:" << std::endl; item->print(std::cerr) ; std::cerr << std::endl; @@ -751,7 +751,7 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem * if(it != _chat_lobbys.end()) { - std::map::iterator it2(it->second.gxs_ids.find(item->signature.keyId)) ; + std::map::iterator it2(it->second.gxs_ids.find(item->signature.keyId)) ; if(it2 != it->second.gxs_ids.end()) { @@ -815,7 +815,7 @@ void DistributedChatService::getListOfNearbyChatLobbies(std::vectorsecond) ; } - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(now > MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ + last_visible_lobby_info_request_time) { @@ -843,7 +843,7 @@ void DistributedChatService::getListOfNearbyChatLobbies(std::vector::iterator it2(lobby.msg_cache.find(item->msg_id)) ; + std::map::iterator it2(lobby.msg_cache.find(item->msg_id)) ; if(it2 != lobby.msg_cache.end()) // found! { @@ -1097,7 +1097,7 @@ void DistributedChatService::handleConnectionChallenge(RsChatLobbyConnectChallen std::cerr << " Peer Id = " << item->PeerId() << std::endl; #endif - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; ChatLobbyId lobby_id ; const RsPeerId& ownId = rsPeers->getOwnId(); @@ -1106,7 +1106,7 @@ void DistributedChatService::handleConnectionChallenge(RsChatLobbyConnectChallen RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/ for(std::map::iterator it(_chat_lobbys.begin());it!=_chat_lobbys.end() && !found;++it) - for(std::map::const_iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end() && !found;++it2) + for(std::map::const_iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end() && !found;++it2) if(it2->second + CONNECTION_CHALLENGE_MAX_MSG_AGE + 5 > now) // any msg not older than 5 seconds plus max challenge count is fine. { uint64_t code = makeConnexionChallengeCode(ownId,it->first,it2->first) ; @@ -1156,10 +1156,10 @@ void DistributedChatService::sendConnectionChallenge(ChatLobbyId lobby_id) return ; } - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; ChatLobbyMsgId msg_id = 0 ; - for(std::map::const_iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end();++it2) + for(std::map::const_iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end();++it2) if(it2->second + CONNECTION_CHALLENGE_MAX_MSG_AGE > now) // any msg not older than 20 seconds is fine. { msg_id = it2->first ; @@ -1431,7 +1431,7 @@ bool DistributedChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id,const #ifdef DEBUG_CHAT_LOBBIES std::cerr << " Creating new Lobby entry." << std::endl; #endif - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; ChatLobbyEntry entry ; entry.participating_friends.insert(it->second.peer_id) ; @@ -1555,7 +1555,7 @@ bool DistributedChatService::joinVisibleChatLobby(const ChatLobbyId& lobby_id,co #ifdef DEBUG_CHAT_LOBBIES std::cerr << " Creating new lobby entry." << std::endl; #endif - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; ChatLobbyEntry entry ; @@ -1604,7 +1604,7 @@ ChatLobbyId DistributedChatService::createChatLobby(const std::string& lobby_nam #ifdef DEBUG_CHAT_LOBBIES std::cerr << " New (unique) ID: " << std::hex << lobby_id << std::dec << std::endl; #endif - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; ChatLobbyEntry entry ; entry.lobby_flags = lobby_flags ; @@ -1859,20 +1859,20 @@ void DistributedChatService::cleanLobbyCaches() { RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/ - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; // 1 - clean cache of all lobbies and participating nicknames. // for(std::map::iterator it = _chat_lobbys.begin();it!=_chat_lobbys.end();++it) { - for(std::map::iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end();) + for(std::map::iterator it2(it->second.msg_cache.begin());it2!=it->second.msg_cache.end();) if(it2->second + MAX_KEEP_MSG_RECORD < now) { #ifdef DEBUG_CHAT_LOBBIES std::cerr << " removing old msg 0x" << std::hex << it2->first << ", time=" << std::dec << now - it2->second << " secs ago" << std::endl; #endif - std::map::iterator tmp(it2) ; + std::map::iterator tmp(it2) ; ++tmp ; it->second.msg_cache.erase(it2) ; it2 = tmp ; @@ -1882,14 +1882,14 @@ void DistributedChatService::cleanLobbyCaches() bool changed = false ; - for(std::map::iterator it2(it->second.gxs_ids.begin());it2!=it->second.gxs_ids.end();) + for(std::map::iterator it2(it->second.gxs_ids.begin());it2!=it->second.gxs_ids.end();) if(it2->second + MAX_KEEP_INACTIVE_NICKNAME < now) { #ifdef DEBUG_CHAT_LOBBIES std::cerr << " removing inactive nickname 0x" << std::hex << it2->first << ", time=" << std::dec << now - it2->second << " secs ago" << std::endl; #endif - std::map::iterator tmp(it2) ; + std::map::iterator tmp(it2) ; ++tmp ; it->second.gxs_ids.erase(it2) ; it2 = tmp ; diff --git a/libretroshare/src/chat/distributedchat.h b/libretroshare/src/chat/distributedchat.h index f0db7f649..61a5c1b4d 100644 --- a/libretroshare/src/chat/distributedchat.h +++ b/libretroshare/src/chat/distributedchat.h @@ -135,11 +135,11 @@ class DistributedChatService class ChatLobbyEntry: public ChatLobbyInfo { public: - std::map msg_cache ; + std::map msg_cache ; RsPeerId virtual_peer_id ; int connexion_challenge_count ; - time_t last_connexion_challenge_time ; - time_t last_keep_alive_packet_time ; + rstime_t last_connexion_challenge_time ; + rstime_t last_keep_alive_packet_time ; std::set previously_known_peers ; }; @@ -152,8 +152,8 @@ class DistributedChatService // RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE float _time_shift_average ; - time_t last_lobby_challenge_time ; // prevents bruteforce attack - time_t last_visible_lobby_info_request_time ; // allows to ask for updates + rstime_t last_lobby_challenge_time ; // prevents bruteforce attack + rstime_t last_visible_lobby_info_request_time ; // allows to ask for updates bool _should_reset_lobby_counts ; RsGxsId _default_identity; std::map _lobby_default_identity; diff --git a/libretroshare/src/chat/p3chatservice.cc b/libretroshare/src/chat/p3chatservice.cc index 08267f6be..c5674ee90 100644 --- a/libretroshare/src/chat/p3chatservice.cc +++ b/libretroshare/src/chat/p3chatservice.cc @@ -521,12 +521,12 @@ class MsgCounter public: MsgCounter() {} - void clean(time_t max_time) + void clean(rstime_t max_time) { while(!recv_times.empty() && recv_times.front() < max_time) recv_times.pop_front() ; } - std::list recv_times ; + std::list recv_times ; }; void p3ChatService::handleIncomingItem(RsItem *item) diff --git a/libretroshare/src/chat/rschatitems.cc b/libretroshare/src/chat/rschatitems.cc index bd79f6821..55cd6cd88 100644 --- a/libretroshare/src/chat/rschatitems.cc +++ b/libretroshare/src/chat/rschatitems.cc @@ -21,7 +21,7 @@ *******************************************************************************/ #include -#include +#include "util/rstime.h" #include "serialiser/rsbaseserial.h" #include "serialiser/rstlvbase.h" diff --git a/libretroshare/src/deep_search/deep_search.h b/libretroshare/src/deep_search/deep_search.h index edbf546e9..e9cb84b8b 100644 --- a/libretroshare/src/deep_search/deep_search.h +++ b/libretroshare/src/deep_search/deep_search.h @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -#include +#include "util/rstime.h" #include #include @@ -261,7 +261,7 @@ private: return dbDir; } - static std::string timetToXapianDate(const time_t& time) + static std::string timetToXapianDate(const rstime_t& time) { char date[] = "YYYYMMDD\0"; std::strftime(date, 9, "%Y%m%d", std::gmtime(&time)); diff --git a/libretroshare/src/dht/connectstatebox.cc b/libretroshare/src/dht/connectstatebox.cc index a5b0d44cb..1d30be3cb 100644 --- a/libretroshare/src/dht/connectstatebox.cc +++ b/libretroshare/src/dht/connectstatebox.cc @@ -80,7 +80,7 @@ PeerConnectStateBox::PeerConnectStateBox() { //mPeerId = id; - time_t now = time(NULL); + rstime_t now = time(NULL); mState = CSB_START; mNetState = CSB_NETSTATE_UNKNOWN; mStateTS = now; @@ -241,7 +241,7 @@ void PeerConnectStateBox::stateMsg(std::ostream &out, std::string msg, uint32_t std::string PeerConnectStateBox::connectState() const { std::string str = StateAsString(mState); - time_t now = time(NULL); + rstime_t now = time(NULL); std::string out; rs_sprintf(out, "%s(%lu/%lu) for %ld secs", str.c_str(), mNoAttempts, mNoFailedAttempts, now - mStateTS); if ( (mState == CSB_CONNECTED) || (mState == CSB_DIRECT_ATTEMPT) || @@ -358,7 +358,7 @@ uint32_t PeerConnectStateBox::connectCb(uint32_t cbtype, uint32_t netmode, uint3 uint32_t PeerConnectStateBox::connectCb_direct() { uint32_t retval = 0; - time_t now = time(NULL); + rstime_t now = time(NULL); switch(mState) { @@ -497,7 +497,7 @@ uint32_t PeerConnectStateBox::connectCb_unreachable() proxyPortMode = CSB_ACTION_DHT_PORT; } - time_t now = time(NULL); + rstime_t now = time(NULL); switch(mState) { @@ -782,7 +782,7 @@ uint32_t PeerConnectStateBox::updateCb(uint32_t update) */ /* DO Connect / Disconnect Updates ... very specific! */ - time_t now = time(NULL); + rstime_t now = time(NULL); switch(update) { case CSB_UPDATE_CONNECTED: @@ -1035,7 +1035,7 @@ bool PeerConnectStateBox::storeProxyPortChoice(uint32_t flags, bool useProxyPort bool PeerConnectStateBox::getProxyPortChoice() { #ifdef DEBUG_CONNECTBOX - time_t now = time(NULL); + rstime_t now = time(NULL); std::cerr << "PeerConnectStateBox::getProxyPortChoice() Using ConnectLogic Info from: "; std::cerr << now-mProxyPortTS << " ago. Flags: " << mProxyPortFlags; diff --git a/libretroshare/src/dht/connectstatebox.h b/libretroshare/src/dht/connectstatebox.h index 15334c284..b50c50683 100644 --- a/libretroshare/src/dht/connectstatebox.h +++ b/libretroshare/src/dht/connectstatebox.h @@ -72,7 +72,7 @@ #include #include -#include +#include "util/rstime.h" #include class PeerConnectStateBox @@ -104,16 +104,16 @@ class PeerConnectStateBox uint32_t mState; uint32_t mNetState; - time_t mStateTS; + rstime_t mStateTS; uint32_t mNoAttempts; uint32_t mNoFailedAttempts; - time_t mNextAttemptTS; - time_t mAttemptLength; + rstime_t mNextAttemptTS; + rstime_t mAttemptLength; // ProxyPort Storage. uint32_t mProxyPortFlags; bool mProxyPortChoice; - time_t mProxyPortTS; + rstime_t mProxyPortTS; }; diff --git a/libretroshare/src/dht/p3bitdht.h b/libretroshare/src/dht/p3bitdht.h index 2935fcf16..c1ebf378c 100644 --- a/libretroshare/src/dht/p3bitdht.h +++ b/libretroshare/src/dht/p3bitdht.h @@ -52,7 +52,7 @@ class DhtPeerDetails /* direct from the DHT! */ uint32_t mDhtState; // One of RSDHT_PEERDHT_[...] - time_t mDhtUpdateTS; + rstime_t mDhtUpdateTS; /* internal state */ PeerConnectStateBox mConnectLogic; @@ -66,9 +66,9 @@ class DhtPeerDetails struct sockaddr_in mPeerConnectAddr; uint32_t mPeerConnectPoint; - time_t mPeerConnectUdpTS; - time_t mPeerConnectTS; - time_t mPeerConnectClosedTS; + rstime_t mPeerConnectUdpTS; + rstime_t mPeerConnectTS; + rstime_t mPeerConnectClosedTS; bool mExclusiveProxyLock; @@ -80,7 +80,7 @@ class DhtPeerDetails uint32_t mPeerReqState; uint32_t mPeerReqMode; bdId mPeerReqProxyId; - time_t mPeerReqTS; + rstime_t mPeerReqTS; /* Callback Info */ std::string mPeerCbMsg; @@ -88,7 +88,7 @@ class DhtPeerDetails uint32_t mPeerCbPoint; bdId mPeerCbProxyId; bdId mPeerCbDestId; - time_t mPeerCbTS; + rstime_t mPeerCbTS; }; @@ -331,7 +331,7 @@ private: float mDhtReadRate; float mDhtWriteRate; - time_t mLastDataRateUpdate; + rstime_t mLastDataRateUpdate; /*********************************************************************************************** @@ -380,7 +380,7 @@ private: RsPeerId mOwnRsId; bdNodeId mOwnDhtId; - time_t mMinuteTS; + rstime_t mMinuteTS; /* translation maps */ std::map mTransToNodeId; diff --git a/libretroshare/src/dht/p3bitdht_interface.cc b/libretroshare/src/dht/p3bitdht_interface.cc index 1b7ff35f5..b9a015bbd 100644 --- a/libretroshare/src/dht/p3bitdht_interface.cc +++ b/libretroshare/src/dht/p3bitdht_interface.cc @@ -204,7 +204,7 @@ void p3BitDht::updateDataRates() RsStackMutex stack(dhtMtx); /********* LOCKED *********/ - time_t now = time(NULL); + rstime_t now = time(NULL); float period = now - mLastDataRateUpdate; #define RATE_FACTOR (0.75) @@ -380,7 +380,7 @@ RsDhtRelayProxy::RsDhtRelayProxy() mCreateTS = 0; //uint32_t mDataSize; - //time_t mLastBandwidthTS; + //rstime_t mLastBandwidthTS; } diff --git a/libretroshare/src/dht/p3bitdht_peernet.cc b/libretroshare/src/dht/p3bitdht_peernet.cc index 4be52dfa5..e4c266279 100644 --- a/libretroshare/src/dht/p3bitdht_peernet.cc +++ b/libretroshare/src/dht/p3bitdht_peernet.cc @@ -249,7 +249,7 @@ int p3BitDht::PeerCallback(const bdId *id, uint32_t status) } - time_t now = time(NULL); + rstime_t now = time(NULL); dpd->mDhtUpdateTS = now; return 1; @@ -510,7 +510,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId */ bdId peerId; - time_t now = time(NULL); + rstime_t now = time(NULL); switch(point) { @@ -1101,7 +1101,7 @@ int p3BitDht::tick() minuteTick(); #ifdef DEBUG_PEERNET_COMMON - time_t now = time(NULL); + rstime_t now = time(NULL); std::cerr << "p3BitDht::tick() TIME: " << ctime(&now) << std::endl; std::cerr.flush(); #endif @@ -1114,7 +1114,7 @@ int p3BitDht::tick() int p3BitDht::minuteTick() { - time_t now = time(NULL); + rstime_t now = time(NULL); int deltaT = 0; { @@ -1164,7 +1164,7 @@ int p3BitDht::doActions() std::cerr << "p3BitDht::doActions()" << std::endl; #endif - time_t now = time(NULL); + rstime_t now = time(NULL); while(mActions.size() > 0) { @@ -1727,7 +1727,7 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode) RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ - time_t now = time(NULL); + rstime_t now = time(NULL); /* check if they are in our friend list */ DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(peerId->id), RSDHT_PEERTYPE_FRIEND); @@ -2171,7 +2171,7 @@ int p3BitDht::removeRelayConnection(const bdId *srcId, const bdId *destId) void p3BitDht::monitorConnections() { RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ - time_t now = time(NULL); + rstime_t now = time(NULL); std::map::iterator it; diff --git a/libretroshare/src/file_sharing/README.txt b/libretroshare/src/file_sharing/README.txt index 1b6cccb2b..947cf64be 100644 --- a/libretroshare/src/file_sharing/README.txt +++ b/libretroshare/src/file_sharing/README.txt @@ -90,10 +90,10 @@ Classes - std::string name - RsFileHash hash - uint64_t size - - time_t Last modification time + - rstime_t Last modification time LocalFileInfo: public FileInfo - - time_t Last data access time + - rstime_t Last data access time - uint64_t Total data uploaded - uint32_t ShareFlags diff --git a/libretroshare/src/file_sharing/dir_hierarchy.cc b/libretroshare/src/file_sharing/dir_hierarchy.cc index b6208eb57..6522da2cd 100644 --- a/libretroshare/src/file_sharing/dir_hierarchy.cc +++ b/libretroshare/src/file_sharing/dir_hierarchy.cc @@ -21,7 +21,7 @@ ******************************************************************************/ #include #include -#include +#include "util/rstime.h" #include "util/rsdir.h" #include "util/rsprint.h" #include "retroshare/rsexpr.h" @@ -356,7 +356,7 @@ bool InternalFileHierarchyStorage::updateHash(const DirectoryStorage::EntryIndex return true; } -bool InternalFileHierarchyStorage::updateFile(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash, const std::string& fname,uint64_t size, const time_t modf_time) +bool InternalFileHierarchyStorage::updateFile(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash, const std::string& fname,uint64_t size, const rstime_t modf_time) { if(!checkIndex(file_index,FileStorageNode::TYPE_FILE)) { @@ -427,7 +427,7 @@ DirectoryStorage::EntryIndex InternalFileHierarchyStorage::allocateNewIndex() return mNodes.size()-1 ; } -bool InternalFileHierarchyStorage::updateDirEntry(const DirectoryStorage::EntryIndex& indx,const std::string& dir_name,time_t most_recent_time,time_t dir_modtime,const std::vector& subdirs_hash,const std::vector& subfiles_array) +bool InternalFileHierarchyStorage::updateDirEntry(const DirectoryStorage::EntryIndex& indx,const std::string& dir_name,rstime_t most_recent_time,rstime_t dir_modtime,const std::vector& subdirs_hash,const std::vector& subfiles_array) { if(!checkIndex(indx,FileStorageNode::TYPE_DIR)) { @@ -599,7 +599,7 @@ void InternalFileHierarchyStorage::getStatistics(SharedDirStats& stats) const stats.total_shared_size = mTotalSize ; } -bool InternalFileHierarchyStorage::getTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* m) const +bool InternalFileHierarchyStorage::getTS(const DirectoryStorage::EntryIndex& index,rstime_t& TS,rstime_t DirEntry::* m) const { if(!checkIndex(index,FileStorageNode::TYPE_DIR)) { @@ -614,7 +614,7 @@ bool InternalFileHierarchyStorage::getTS(const DirectoryStorage::EntryIndex& ind return true; } -bool InternalFileHierarchyStorage::setTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* m) +bool InternalFileHierarchyStorage::setTS(const DirectoryStorage::EntryIndex& index,rstime_t& TS,rstime_t DirEntry::* m) { if(!checkIndex(index,FileStorageNode::TYPE_DIR)) { @@ -631,11 +631,11 @@ bool InternalFileHierarchyStorage::setTS(const DirectoryStorage::EntryIndex& ind // Do a complete recursive sweep over sub-directories and files, and update the lst modf TS. This could be also performed by a cleanup method. -time_t InternalFileHierarchyStorage::recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index,bool& unfinished_files_present) +rstime_t InternalFileHierarchyStorage::recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index,bool& unfinished_files_present) { DirEntry& d(*static_cast(mNodes[dir_index])) ; - time_t largest_modf_time = d.dir_modtime ; + rstime_t largest_modf_time = d.dir_modtime ; unfinished_files_present = false ; for(uint32_t i=0;i subdirs ; std::vector subfiles ; - time_t dir_modtime; - time_t dir_most_recent_time;// recursive most recent modification time, including files and subdirs in the entire hierarchy below. - time_t dir_update_time; // last time the information was updated for that directory. Includes subdirs indexes and subfile info. + rstime_t dir_modtime; + rstime_t dir_most_recent_time;// recursive most recent modification time, including files and subdirs in the entire hierarchy below. + rstime_t dir_update_time; // last time the information was updated for that directory. Includes subdirs indexes and subfile info. }; // class stuff @@ -95,18 +95,18 @@ public: bool checkIndex(DirectoryStorage::EntryIndex indx,uint8_t type) const; bool updateSubFilesList(const DirectoryStorage::EntryIndex& indx,const std::map& subfiles,std::map& new_files); bool updateHash(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash); - bool updateFile(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash, const std::string& fname,uint64_t size, const time_t modf_time); - bool updateDirEntry(const DirectoryStorage::EntryIndex& indx, const std::string& dir_name, time_t most_recent_time, time_t dir_modtime, const std::vector &subdirs_hash, const std::vector &subfiles_array); + bool updateFile(const DirectoryStorage::EntryIndex& file_index,const RsFileHash& hash, const std::string& fname,uint64_t size, const rstime_t modf_time); + bool updateDirEntry(const DirectoryStorage::EntryIndex& indx, const std::string& dir_name, rstime_t most_recent_time, rstime_t dir_modtime, const std::vector &subdirs_hash, const std::vector &subfiles_array); // TS get/set functions. Take one of the class members as argument. - bool getTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* ) const; - bool setTS(const DirectoryStorage::EntryIndex& index,time_t& TS,time_t DirEntry::* ) ; + bool getTS(const DirectoryStorage::EntryIndex& index,rstime_t& TS,rstime_t DirEntry::* ) const; + bool setTS(const DirectoryStorage::EntryIndex& index,rstime_t& TS,rstime_t DirEntry::* ) ; // Do a complete recursive sweep over sub-directories and files, and update the lst modf TS. This could be also performed by a cleanup method. // Also keeps the high level statistics up to date. - time_t recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index, bool &unfinished_files_present); + rstime_t recursUpdateLastModfTime(const DirectoryStorage::EntryIndex& dir_index, bool &unfinished_files_present); // hash stuff diff --git a/libretroshare/src/file_sharing/directory_storage.cc b/libretroshare/src/file_sharing/directory_storage.cc index a0164a94b..2e328e61e 100644 --- a/libretroshare/src/file_sharing/directory_storage.cc +++ b/libretroshare/src/file_sharing/directory_storage.cc @@ -20,7 +20,7 @@ * * ******************************************************************************/ #include -#include +#include "util/rstime.h" #include "serialiser/rstlvbinary.h" #include "retroshare/rspeers.h" #include "util/rsdir.h" @@ -71,7 +71,7 @@ DirectoryStorage::DirIterator ::operator bool() const { return **this != Directo RsFileHash DirectoryStorage::FileIterator::hash() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_hash):RsFileHash(); } uint64_t DirectoryStorage::FileIterator::size() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_size):0; } std::string DirectoryStorage::FileIterator::name() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_name):std::string(); } -time_t DirectoryStorage::FileIterator::modtime() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_modtime):0; } +rstime_t DirectoryStorage::FileIterator::modtime() const { const InternalFileHierarchyStorage::FileEntry *f = mStorage->getFileEntry(**this) ; return f?(f->file_modtime):0; } std::string DirectoryStorage::DirIterator::name() const { const InternalFileHierarchyStorage::DirEntry *d = mStorage->getDirEntry(**this) ; return d?(d->dir_name):std::string(); } @@ -119,13 +119,13 @@ uint32_t DirectoryStorage::getEntryType(const EntryIndex& indx) } } -bool DirectoryStorage::getDirectoryUpdateTime (EntryIndex index,time_t& update_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,update_TS,&InternalFileHierarchyStorage::DirEntry::dir_update_time ); } -bool DirectoryStorage::getDirectoryRecursModTime(EntryIndex index,time_t& rec_md_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,rec_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_most_recent_time); } -bool DirectoryStorage::getDirectoryLocalModTime (EntryIndex index,time_t& loc_md_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,loc_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_modtime ); } +bool DirectoryStorage::getDirectoryUpdateTime (EntryIndex index,rstime_t& update_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,update_TS,&InternalFileHierarchyStorage::DirEntry::dir_update_time ); } +bool DirectoryStorage::getDirectoryRecursModTime(EntryIndex index,rstime_t& rec_md_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,rec_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_most_recent_time); } +bool DirectoryStorage::getDirectoryLocalModTime (EntryIndex index,rstime_t& loc_md_TS) const { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->getTS(index,loc_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_modtime ); } -bool DirectoryStorage::setDirectoryUpdateTime (EntryIndex index,time_t update_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,update_TS,&InternalFileHierarchyStorage::DirEntry::dir_update_time ); } -bool DirectoryStorage::setDirectoryRecursModTime(EntryIndex index,time_t rec_md_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,rec_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_most_recent_time); } -bool DirectoryStorage::setDirectoryLocalModTime (EntryIndex index,time_t loc_md_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,loc_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_modtime ); } +bool DirectoryStorage::setDirectoryUpdateTime (EntryIndex index,rstime_t update_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,update_TS,&InternalFileHierarchyStorage::DirEntry::dir_update_time ); } +bool DirectoryStorage::setDirectoryRecursModTime(EntryIndex index,rstime_t rec_md_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,rec_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_most_recent_time); } +bool DirectoryStorage::setDirectoryLocalModTime (EntryIndex index,rstime_t loc_md_TS) { RS_STACK_MUTEX(mDirStorageMtx) ; return mFileHierarchy->setTS(index,loc_md_TS,&InternalFileHierarchyStorage::DirEntry::dir_modtime ); } bool DirectoryStorage::updateSubDirectoryList(const EntryIndex& indx, const std::set &subdirs, const RsFileHash& hash_salt) { @@ -281,7 +281,7 @@ bool DirectoryStorage::getIndexFromDirHash(const RsFileHash& hash,EntryIndex& in void DirectoryStorage::checkSave() { - time_t now = time(NULL); + rstime_t now = time(NULL); if(mChanged && mLastSavedTime + MIN_INTERVAL_BETWEEN_REMOTE_DIRECTORY_SAVE < now) { @@ -489,7 +489,7 @@ void LocalDirectoryStorage::updateTimeStamps() bool unfinished_files_below ; - time_t last_modf_time = mFileHierarchy->recursUpdateLastModfTime(EntryIndex(0),unfinished_files_below) ; + rstime_t last_modf_time = mFileHierarchy->recursUpdateLastModfTime(EntryIndex(0),unfinished_files_below) ; mTSChanged = false ; #ifdef DEBUG_LOCAL_DIRECTORY_STORAGE diff --git a/libretroshare/src/file_sharing/directory_storage.h b/libretroshare/src/file_sharing/directory_storage.h index e7c4d14b7..670682be3 100644 --- a/libretroshare/src/file_sharing/directory_storage.h +++ b/libretroshare/src/file_sharing/directory_storage.h @@ -27,6 +27,7 @@ #include "retroshare/rsids.h" #include "retroshare/rsfiles.h" +#include "util/rstime.h" #define NOT_IMPLEMENTED() { std::cerr << __PRETTY_FUNCTION__ << ": not yet implemented." << std::endl; } @@ -52,13 +53,13 @@ class DirectoryStorage // gets/sets the various time stamps: // - bool getDirectoryRecursModTime(EntryIndex index,time_t& recurs_max_modf_TS) const ; // last modification time, computed recursively over all subfiles and directories - bool getDirectoryLocalModTime (EntryIndex index,time_t& motime_TS) const ; // last modification time for that index only - bool getDirectoryUpdateTime (EntryIndex index,time_t& update_TS) const ; // last time the entry was updated. This is only used on the RemoteDirectoryStorage side. + bool getDirectoryRecursModTime(EntryIndex index,rstime_t& recurs_max_modf_TS) const ; // last modification time, computed recursively over all subfiles and directories + bool getDirectoryLocalModTime (EntryIndex index,rstime_t& motime_TS) const ; // last modification time for that index only + bool getDirectoryUpdateTime (EntryIndex index,rstime_t& update_TS) const ; // last time the entry was updated. This is only used on the RemoteDirectoryStorage side. - bool setDirectoryRecursModTime(EntryIndex index,time_t recurs_max_modf_TS) ; - bool setDirectoryLocalModTime (EntryIndex index,time_t modtime_TS) ; - bool setDirectoryUpdateTime (EntryIndex index,time_t update_TS) ; + bool setDirectoryRecursModTime(EntryIndex index,rstime_t recurs_max_modf_TS) ; + bool setDirectoryLocalModTime (EntryIndex index,rstime_t modtime_TS) ; + bool setDirectoryUpdateTime (EntryIndex index,rstime_t update_TS) ; uint32_t getEntryType(const EntryIndex& indx) ; // WARNING: returns DIR_TYPE_*, not the internal directory storage stuff. virtual bool extractData(const EntryIndex& indx,DirDetails& d); @@ -81,8 +82,8 @@ class DirectoryStorage // info about the directory that is pointed by the iterator std::string name() const ; - time_t last_modif_time() const ; // last time a file in this directory or in the directories below has been modified. - time_t last_update_time() const ; // last time this directory was updated + rstime_t last_modif_time() const ; // last time a file in this directory or in the directories below has been modified. + rstime_t last_update_time() const ; // last time this directory was updated private: EntryIndex mParentIndex ; // index of the parent dir. uint32_t mDirTabIndex ; // index in the vector of subdirs. @@ -106,7 +107,7 @@ class DirectoryStorage std::string name() const ; uint64_t size() const ; RsFileHash hash() const ; - time_t modtime() const ; + rstime_t modtime() const ; private: EntryIndex mParentIndex ; // index of the parent dir. @@ -117,7 +118,7 @@ class DirectoryStorage struct FileTS { uint64_t size ; - time_t modtime; + rstime_t modtime; }; EntryIndex root() const ; // returns the index of the root directory entry. This is generally 0. @@ -171,7 +172,7 @@ class DirectoryStorage InternalFileHierarchyStorage *mFileHierarchy ; - time_t mLastSavedTime ; + rstime_t mLastSavedTime ; bool mChanged ; std::string mFileName; }; @@ -198,7 +199,7 @@ public: * returns the last time a sweep has been done over the directory in order to check update TS. * \return */ - time_t& lastSweepTime() { return mLastSweepTime ; } + rstime_t& lastSweepTime() { return mLastSweepTime ; } /*! * \brief searchHash @@ -212,7 +213,7 @@ public: virtual int searchHash(const RsFileHash& hash, EntryIndex& results) const ; private: - time_t mLastSweepTime ; + rstime_t mLastSweepTime ; }; class LocalDirectoryStorage: public DirectoryStorage diff --git a/libretroshare/src/file_sharing/directory_updater.cc b/libretroshare/src/file_sharing/directory_updater.cc index 3bf125839..59209f7e8 100644 --- a/libretroshare/src/file_sharing/directory_updater.cc +++ b/libretroshare/src/file_sharing/directory_updater.cc @@ -64,7 +64,7 @@ void LocalDirectoryUpdater::setEnabled(bool b) void LocalDirectoryUpdater::data_tick() { - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if (mIsEnabled || mForceUpdate) { @@ -190,14 +190,14 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(const std::string& cumulated_p librs::util::FolderIterator dirIt(cumulated_path,mFollowSymLinks,false); // disallow symbolic links and files from the future. - time_t dir_local_mod_time ; + rstime_t dir_local_mod_time ; if(!mSharedDirectories->getDirectoryLocalModTime(indx,dir_local_mod_time)) { std::cerr << "(EE) Cannot get local mod time for dir index " << indx << std::endl; return; } - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(mNeedsFullRecheck || dirIt.dir_modtime() > dir_local_mod_time) // the > is because we may have changed the virtual name, and therefore the TS wont match. // we only want to detect when the directory has changed on the disk diff --git a/libretroshare/src/file_sharing/directory_updater.h b/libretroshare/src/file_sharing/directory_updater.h index 366e1330e..4338d2386 100644 --- a/libretroshare/src/file_sharing/directory_updater.h +++ b/libretroshare/src/file_sharing/directory_updater.h @@ -27,6 +27,7 @@ // #include "file_sharing/hash_cache.h" #include "file_sharing/directory_storage.h" +#include "util/rstime.h" class LocalDirectoryUpdater: public HashStorageClient, public RsTickingThread { @@ -77,8 +78,8 @@ private: RsFileHash mHashSalt ; - time_t mLastSweepTime; - time_t mLastTSUpdateTime; + rstime_t mLastSweepTime; + rstime_t mLastTSUpdateTime; uint32_t mDelayBetweenDirectoryUpdates; bool mIsEnabled ; diff --git a/libretroshare/src/file_sharing/hash_cache.cc b/libretroshare/src/file_sharing/hash_cache.cc index d40f49581..222bb81e0 100644 --- a/libretroshare/src/file_sharing/hash_cache.cc +++ b/libretroshare/src/file_sharing/hash_cache.cc @@ -232,7 +232,7 @@ void HashStorage::data_tick() job.client->hash_callback(job.client_param, job.full_path, hash, size); } -bool HashStorage::requestHash(const std::string& full_path,uint64_t size,time_t mod_time,RsFileHash& known_hash,HashStorageClient *c,uint32_t client_param) +bool HashStorage::requestHash(const std::string& full_path,uint64_t size,rstime_t mod_time,RsFileHash& known_hash,HashStorageClient *c,uint32_t client_param) { // check if the hash is up to date w.r.t. cache. @@ -243,7 +243,7 @@ bool HashStorage::requestHash(const std::string& full_path,uint64_t size,time_t std::string real_path = RsDirUtil::removeSymLinks(full_path) ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; std::map::iterator it = mFiles.find(real_path) ; // On windows we compare the time up to +/- 3600 seconds. This avoids re-hashing files in case of daylight saving change. @@ -318,8 +318,8 @@ void HashStorage::clean() { RS_STACK_MUTEX(mHashMtx) ; - time_t now = time(NULL) ; - time_t duration = mMaxStorageDurationDays * 24 * 3600 ; // seconds + rstime_t now = time(NULL) ; + rstime_t duration = mMaxStorageDurationDays * 24 * 3600 ; // seconds #ifdef HASHSTORAGE_DEBUG std::cerr << "Cleaning hash cache." << std::endl ; diff --git a/libretroshare/src/file_sharing/hash_cache.h b/libretroshare/src/file_sharing/hash_cache.h index f9123b998..3cf8f6c3a 100644 --- a/libretroshare/src/file_sharing/hash_cache.h +++ b/libretroshare/src/file_sharing/hash_cache.h @@ -26,6 +26,7 @@ #include #include "util/rsthreads.h" #include "retroshare/rsfiles.h" +#include "util/rstime.h" /*! * \brief The HashStorageClient class @@ -65,7 +66,7 @@ public: * * \return true if the supplied hash info is up to date. */ - bool requestHash(const std::string& full_path, uint64_t size, time_t mod_time, RsFileHash& known_hash, HashStorageClient *c, uint32_t client_param) ; + bool requestHash(const std::string& full_path, uint64_t size, rstime_t mod_time, RsFileHash& known_hash, HashStorageClient *c, uint32_t client_param) ; struct HashStorageInfo { @@ -120,7 +121,7 @@ private: uint64_t size ; HashStorageClient *client; uint32_t client_param ; - time_t ts; + rstime_t ts; }; // current work @@ -136,7 +137,7 @@ private: uint64_t mTotalSizeToHash ; uint64_t mTotalHashedSize ; uint64_t mTotalFilesToHash ; - time_t mLastSaveTime ; + rstime_t mLastSaveTime ; // The following is used to estimate hashing speed. diff --git a/libretroshare/src/file_sharing/p3filelists.cc b/libretroshare/src/file_sharing/p3filelists.cc index 32482106f..a4b8f2d0b 100644 --- a/libretroshare/src/file_sharing/p3filelists.cc +++ b/libretroshare/src/file_sharing/p3filelists.cc @@ -171,7 +171,7 @@ int p3FileDatabase::tick() tickRecv() ; tickSend() ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; // cleanup // - remove/delete shared file lists for people who are not friend anymore @@ -183,7 +183,7 @@ int p3FileDatabase::tick() mLastCleanupTime = now ; } - static time_t last_print_time = 0; + static rstime_t last_print_time = 0; if(last_print_time + 20 < now) { @@ -604,15 +604,15 @@ void p3FileDatabase::cleanup() for(std::list::const_iterator it(friend_lst.begin());it!=friend_lst.end();++it) friend_set.insert(*it) ; } - time_t now = time(NULL); + rstime_t now = time(NULL); for(uint32_t i=0;igetDirectoryRecursModTime(0,recurs_mod_time) ; - time_t last_contact = 0 ; + rstime_t last_contact = 0 ; RsPeerDetails pd ; if(rsPeers->getPeerDetails(mRemoteDirectories[i]->peerId(),pd)) last_contact = pd.lastConnect ; @@ -976,7 +976,7 @@ void p3FileDatabase::getExtraFilesDirDetails(void *ref,DirectoryStorage::EntryIn { // update the cache of extra files if last requested too long ago - time_t now = time(NULL); + rstime_t now = time(NULL); if(mLastExtraFilesCacheUpdate + DELAY_BETWEEN_EXTRA_FILES_CACHE_UPDATES <= now) { @@ -1627,7 +1627,7 @@ void p3FileDatabase::handleDirSyncRequest(RsFileListsSyncRequestItem *item) } else { - time_t local_recurs_max_time ; + rstime_t local_recurs_max_time ; mLocalSharedDirs->getDirectoryRecursModTime(entry_index,local_recurs_max_time) ; if(item->last_known_recurs_modf_TS != local_recurs_max_time) // normally, should be "<", but since we provided the TS it should be equal, so != is more robust. @@ -1792,7 +1792,7 @@ void p3FileDatabase::handleDirSyncResponse(RsFileListsSyncResponseItem*& sitem) sitem = item ; } - time_t now = time(NULL); + rstime_t now = time(NULL); // check the hash. If anything goes wrong (in the chunking for instance) the hash will not match @@ -1899,7 +1899,7 @@ void p3FileDatabase::handleDirSyncResponse(RsFileListsSyncResponseItem*& sitem) void p3FileDatabase::locked_recursSweepRemoteDirectory(RemoteDirectoryStorage *rds,DirectoryStorage::EntryIndex e,int depth) { - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; //std::string indent(2*depth,' ') ; @@ -1912,7 +1912,7 @@ void p3FileDatabase::locked_recursSweepRemoteDirectory(RemoteDirectoryStorage *r P3FILELISTS_DEBUG() << "currently at entry index " << e << std::endl; #endif - time_t local_update_TS; + rstime_t local_update_TS; if(!rds->getDirectoryUpdateTime(e,local_update_TS)) { @@ -1959,9 +1959,9 @@ p3FileDatabase::DirSyncRequestId p3FileDatabase::makeDirSyncReqId(const RsPeerId bool p3FileDatabase::locked_generateAndSendSyncRequest(RemoteDirectoryStorage *rds,const DirectoryStorage::EntryIndex& e) { RsFileHash entry_hash ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; - time_t max_known_recurs_modf_time ; + rstime_t max_known_recurs_modf_time ; if(!rds->getDirectoryRecursModTime(e,max_known_recurs_modf_time)) { @@ -2118,7 +2118,7 @@ void p3FileDatabase::checkSendBannedFilesInfo() P3FILELISTS_DEBUG() << " Checking banned files information: " << std::endl; #endif - time_t now = time(NULL); + rstime_t now = time(NULL); std::list online_friends ; rsPeers->getOnlineList(online_friends); diff --git a/libretroshare/src/file_sharing/p3filelists.h b/libretroshare/src/file_sharing/p3filelists.h index b6d88328a..9b2b1be29 100644 --- a/libretroshare/src/file_sharing/p3filelists.h +++ b/libretroshare/src/file_sharing/p3filelists.h @@ -48,7 +48,7 @@ #include "ft/ftextralist.h" #include "retroshare/rsfiles.h" #include "services/p3service.h" - +#include "util/rstime.h" #include "file_sharing/hash_cache.h" #include "file_sharing/directory_storage.h" @@ -71,7 +71,7 @@ struct PeerBannedFilesEntry { std::set mBannedHashOfHash; uint32_t mSessionId ; // used for when a friend sends multiple packets in separate items. - time_t mLastSent; + rstime_t mLastSent; }; class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, public RsSharedFileService @@ -246,11 +246,11 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub struct DirSyncRequestData { RsPeerId peer_id ; - time_t request_TS ; + rstime_t request_TS ; uint32_t flags ; }; - time_t mLastRemoteDirSweepTS ; // TS for friend list update + rstime_t mLastRemoteDirSweepTS ; // TS for friend list update std::map mPendingSyncRequests ; // pending requests, waiting for an answer std::map mPartialResponseItems; @@ -265,8 +265,8 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub mutable RsMutex mFLSMtx ; uint32_t mUpdateFlags ; std::string mFileSharingDir ; - time_t mLastCleanupTime; - time_t mLastDataRecvTS ; + rstime_t mLastCleanupTime; + rstime_t mLastDataRecvTS ; // File filtering. Not explicitly related to shared files, but has its place here // @@ -275,10 +275,10 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub std::map mPeerBannedFiles ; // records of which files other peers ban, stored as H(H(f)) std::set mBannedFileList ; // list of banned hashes. This include original hashs and H(H(f)) when coming from friends. mutable std::vector mExtraFilesCache; // cache for extra files, to avoid requesting them too often. - mutable time_t mLastExtraFilesCacheUpdate ; + mutable rstime_t mLastExtraFilesCacheUpdate ; bool mTrustFriendNodesForBannedFiles ; bool mBannedFileListNeedsUpdate; - time_t mLastPrimaryBanListChangeTimeStamp; + rstime_t mLastPrimaryBanListChangeTimeStamp; void locked_sendBanInfo(const RsPeerId& pid); void handleBannedFilesInfo(RsFileListsBannedHashesItem *item); diff --git a/libretroshare/src/file_sharing/rsfilelistitems.cc b/libretroshare/src/file_sharing/rsfilelistitems.cc index c443d1f3a..9e9253915 100644 --- a/libretroshare/src/file_sharing/rsfilelistitems.cc +++ b/libretroshare/src/file_sharing/rsfilelistitems.cc @@ -54,7 +54,7 @@ template<> void RsTypeSerializer::serial_process(RsGenericSerializer::SerializeJ { RsTypeSerializer::serial_process (j,ctx,TLV_TYPE_STR_NAME,entry.filename ,"entry.file_name") ; RsTypeSerializer::serial_process(j,ctx, entry.size ,"entry.size") ; - RsTypeSerializer::serial_process (j,ctx, entry.ban_time_stamp,"entry.ban_time_stamp") ; + RsTypeSerializer::serial_process (j,ctx, entry.ban_time_stamp,"entry.ban_time_stamp") ; } RsItem *RsFileListsSerialiser::create_item(uint16_t service,uint8_t type) const { diff --git a/libretroshare/src/ft/ftchunkmap.cc b/libretroshare/src/ft/ftchunkmap.cc index 622926c7a..8b0c60007 100644 --- a/libretroshare/src/ft/ftchunkmap.cc +++ b/libretroshare/src/ft/ftchunkmap.cc @@ -31,7 +31,7 @@ #include #include "retroshare/rspeers.h" #include "ftchunkmap.h" -#include +#include "util/rstime.h" static const uint32_t SOURCE_CHUNK_MAP_UPDATE_PERIOD = 60 ; //! TTL for chunkmap info static const uint32_t INACTIVE_CHUNK_TIME_LAPSE = 3600 ; //! TTL for an inactive chunk @@ -264,7 +264,7 @@ bool ChunkMap::reAskPendingChunk( const RsPeerId& peer_id, if(_map[i] == FileChunksInfo::CHUNK_OUTSTANDING) return false ; - time_t now = time(NULL); + rstime_t now = time(NULL); for(std::map::iterator it(_slices_to_download.begin());it!=_slices_to_download.end();++it) for(std::map::iterator it2(it->second._slices.begin());it2!=it->second._slices.end();++it2) @@ -400,7 +400,7 @@ bool ChunkMap::getDataChunk(const RsPeerId& peer_id,uint32_t size_hint,ftChunk& void ChunkMap::removeInactiveChunks(std::vector& to_remove) { to_remove.clear() ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; for(std::map::iterator it(_slices_to_download.begin());it!=_slices_to_download.end();) if(now - it->second._last_data_received > (int)INACTIVE_CHUNK_TIME_LAPSE) @@ -573,7 +573,7 @@ uint32_t ChunkMap::getAvailableChunk(const RsPeerId& peer_id,bool& map_is_too_ol // useful to get a new map that will also be full, but because we need to be careful not to mislead information, // we still keep asking. // - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if((!peer_chunks->is_full) && ((int)now - (int)peer_chunks->TS > (int)SOURCE_CHUNK_MAP_UPDATE_PERIOD)) { diff --git a/libretroshare/src/ft/ftchunkmap.h b/libretroshare/src/ft/ftchunkmap.h index a9307b966..a9e7eb900 100644 --- a/libretroshare/src/ft/ftchunkmap.h +++ b/libretroshare/src/ft/ftchunkmap.h @@ -63,7 +63,7 @@ class ftChunk uint64_t offset; // current offset of the slice uint64_t size; // size remaining to download OffsetInFile id ; // id of the chunk. Equal to the starting offset of the chunk - time_t ts; // time of last data received + rstime_t ts; // time of last data received int *ref_cnt; // shared counter of number of sub-blocks. Used when a slice gets split. RsPeerId peer_id ; }; @@ -98,20 +98,20 @@ struct ChunkDownloadInfo struct SliceRequestInfo { uint32_t size ; // size of the slice - time_t request_time ; // last request time + rstime_t request_time ; // last request time std::set peers ; // peers the slice was requested to. Normally only one, except at the end of the file. }; std::map _slices ; uint32_t _remains ; - time_t _last_data_received ; + rstime_t _last_data_received ; }; class SourceChunksInfo { public: CompressedChunkMap cmap ; //! map of what the peer has/doens't have - time_t TS ; //! last update time for this info + rstime_t TS ; //! last update time for this info bool is_full ; //! is the map full ? In such a case, re-asking for it is unnecessary. // Returns true if the offset is starting in a mapped chunk. diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index bb0a56588..06e8a0e9c 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -61,7 +61,7 @@ #include "rsitems/rsconfigitems.h" #include #include /* for (u)sleep() */ -#include +#include "util/rstime.h" /****** * #define CONTROL_DEBUG 1 @@ -226,7 +226,7 @@ void ftController::data_tick() doPending = (mFtActive) && (!mFtPendingDone); } - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(now > last_save_time + SAVE_TRANSFERS_DELAY) { IndicateConfigChanged() ; @@ -421,11 +421,11 @@ void ftController::checkDownloadQueue() // Check for inactive transfers, and queued transfers with online sources. // - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; for(std::map::const_iterator it(mDownloads.begin());it!=mDownloads.end() ;++it) if( it->second->mState != ftFileControl::QUEUED && (it->second->mState == ftFileControl::PAUSED - || now > it->second->mTransfer->lastActvTimeStamp() + (time_t)MAX_TIME_INACTIVE_REQUEUED)) + || now > it->second->mTransfer->lastActvTimeStamp() + (rstime_t)MAX_TIME_INACTIVE_REQUEUED)) { inactive_transfers.push_back(it->second) ; } diff --git a/libretroshare/src/ft/ftcontroller.h b/libretroshare/src/ft/ftcontroller.h index 6564ae7be..d183ab85e 100644 --- a/libretroshare/src/ft/ftcontroller.h +++ b/libretroshare/src/ft/ftcontroller.h @@ -83,7 +83,7 @@ class ftFileControl RsFileHash mHash; uint64_t mSize; TransferRequestFlags mFlags; - time_t mCreateTime; + rstime_t mCreateTime; uint32_t mQueuePriority ; uint32_t mQueuePosition ; }; @@ -226,8 +226,8 @@ class ftController: public RsTickingThread, public pqiServiceMonitor, public p3C bool setPeerState(ftTransferModule *tm, const RsPeerId& id, uint32_t maxrate, bool online); - time_t last_save_time ; - time_t last_clean_time ; + rstime_t last_save_time ; + rstime_t last_clean_time ; /* pointers to other components */ ftSearch *mSearch; diff --git a/libretroshare/src/ft/ftdatamultiplex.cc b/libretroshare/src/ft/ftdatamultiplex.cc index 56cdd9f52..de8f1261c 100644 --- a/libretroshare/src/ft/ftdatamultiplex.cc +++ b/libretroshare/src/ft/ftdatamultiplex.cc @@ -34,7 +34,7 @@ #include "util/rsdir.h" #include "util/rsmemory.h" #include -#include +#include "util/rstime.h" /* For Thread Behaviour */ const uint32_t DMULTIPLEX_MIN = 10; /* 10 msec sleep */ @@ -452,7 +452,7 @@ bool ftDataMultiplex::recvSingleChunkCRC(const RsPeerId& peerId, const RsFileHas // remove this chunk from the request list as well. Sha1CacheEntry& sha1cache(_cached_sha1maps[hash]) ; - std::map >::iterator it2(sha1cache._to_ask.find(chunk_number)) ; + std::map >::iterator it2(sha1cache._to_ask.find(chunk_number)) ; if(it2 != sha1cache._to_ask.end()) sha1cache._to_ask.erase(it2) ; @@ -943,7 +943,7 @@ bool ftDataMultiplex::sendSingleChunkCRCRequests(const RsFileHash& hash, const s for(uint32_t i=0;i& list(ce._to_ask[to_ask[i]]) ; + std::pair& list(ce._to_ask[to_ask[i]]) ; list.first = 0 ; // set last request time to 0 } return true ; @@ -953,7 +953,7 @@ void ftDataMultiplex::handlePendingCrcRequests() { RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/ - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; uint32_t n=0 ; // Go through the list of currently handled hashes. For each of them, @@ -966,7 +966,7 @@ void ftDataMultiplex::handlePendingCrcRequests() // for(std::map::iterator it(_cached_sha1maps.begin());it!=_cached_sha1maps.end();++it) - for(std::map >::iterator it2(it->second._to_ask.begin());it2!=it->second._to_ask.end();++it2) + for(std::map >::iterator it2(it->second._to_ask.begin());it2!=it->second._to_ask.end();++it2) if(it2->second.first + MAX_CHECKING_CHUNK_WAIT_DELAY < now) // is the last request old enough? { #ifdef MPLEX_DEBUG @@ -986,14 +986,14 @@ void ftDataMultiplex::handlePendingCrcRequests() // RsPeerId best_source ; - time_t oldest_timestamp = now ; + rstime_t oldest_timestamp = now ; for(uint32_t i=0;i::const_iterator it3(it2->second.second.find(sources[i])) ; + std::map::const_iterator it3(it2->second.second.find(sources[i])) ; if(it3 == it2->second.second.end()) // source not found. So this one is surely the oldest one to have been requested. { @@ -1044,7 +1044,7 @@ void ftDataMultiplex::deleteUnusedServers() RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/ //scan the uploads list in ftdatamultiplex and delete the items which time out - time_t now = time(NULL); + rstime_t now = time(NULL); for(std::map::iterator sit(mServers.begin());sit != mServers.end();) if(sit->second->purgeOldPeers(now,10)) diff --git a/libretroshare/src/ft/ftdatamultiplex.h b/libretroshare/src/ft/ftdatamultiplex.h index 57acda1f2..019940b63 100644 --- a/libretroshare/src/ft/ftdatamultiplex.h +++ b/libretroshare/src/ft/ftdatamultiplex.h @@ -74,15 +74,15 @@ class ftRequest void *mData; }; -typedef std::map ChunkCheckSumSourceList ; +typedef std::map ChunkCheckSumSourceList ; class Sha1CacheEntry { public: Sha1Map _map ; // Map of available sha1 sums for every chunk. - time_t last_activity ; // This is used for removing unused entries. + rstime_t last_activity ; // This is used for removing unused entries. std::vector _received ; // received chunk ids. To bedispatched. - std::map > _to_ask ; // Chunks to ask to sources. + std::map > _to_ask ; // Chunks to ask to sources. }; class ftDataMultiplex: public ftDataRecv, public RsQueueThread diff --git a/libretroshare/src/ft/ftextralist.cc b/libretroshare/src/ft/ftextralist.cc index 2c8152d3e..558e9ff4d 100644 --- a/libretroshare/src/ft/ftextralist.cc +++ b/libretroshare/src/ft/ftextralist.cc @@ -32,7 +32,7 @@ #include "util/rstime.h" #include #include /* for (u)sleep() */ -#include +#include "util/rstime.h" /****** * #define DEBUG_ELIST 1 @@ -49,7 +49,7 @@ ftExtraList::ftExtraList() void ftExtraList::data_tick() { bool todo = false; - time_t now = time(NULL); + rstime_t now = time(NULL); { RsStackMutex stack(extMutex); @@ -229,12 +229,12 @@ bool ftExtraList::cleanupOldFiles() RS_STACK_MUTEX(extMutex); - time_t now = time(NULL); + rstime_t now = time(NULL); std::list toRemove; for( std::map::iterator it = mFiles.begin(); it != mFiles.end(); ++it) /* check timestamps */ - if ((time_t)it->second.info.age < now) + if ((rstime_t)it->second.info.age < now) toRemove.push_back(it->first); if (toRemove.size() > 0) @@ -450,7 +450,7 @@ bool ftExtraList::loadList(std::list& load) std::cerr << std::endl; #endif - time_t ts = time(NULL); + rstime_t ts = time(NULL); std::list::iterator it; @@ -475,7 +475,7 @@ bool ftExtraList::loadList(std::list& load) fclose(fd); fd = NULL ; - if (ts > (time_t)fi->file.age) + if (ts > (rstime_t)fi->file.age) { /* to old */ cleanupEntry(fi->file.path, TransferRequestFlags(fi->flags)); diff --git a/libretroshare/src/ft/ftextralist.h b/libretroshare/src/ft/ftextralist.h index 6d89cfe7b..39a9b635c 100644 --- a/libretroshare/src/ft/ftextralist.h +++ b/libretroshare/src/ft/ftextralist.h @@ -58,6 +58,7 @@ #include "util/rsthreads.h" #include "retroshare/rsfiles.h" #include "pqi/p3cfgmgr.h" +#include "util/rstime.h" class FileDetails { @@ -177,7 +178,7 @@ private: std::map mFiles; std::map mHashOfHash; /* sha1(hash) map so as to answer requests to encrypted transfers */ - time_t cleanup ; + rstime_t cleanup ; }; diff --git a/libretroshare/src/ft/ftfilecreator.cc b/libretroshare/src/ft/ftfilecreator.cc index fc25fe426..f792be958 100644 --- a/libretroshare/src/ft/ftfilecreator.cc +++ b/libretroshare/src/ft/ftfilecreator.cc @@ -27,7 +27,7 @@ #include "ftfilecreator.h" #include #include -#include +#include "util/rstime.h" #include #include #include @@ -63,7 +63,7 @@ ftFileCreator::ftFileCreator(const std::string& path, uint64_t size, const RsFil std::cerr << std::endl; #endif RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/ - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; _creation_time = now ; struct stat64 buf; @@ -143,12 +143,12 @@ bool ftFileCreator::getFileData(const RsPeerId& peer_id,uint64_t offset, uint32_ return false ; } -time_t ftFileCreator::creationTimeStamp() +rstime_t ftFileCreator::creationTimeStamp() { RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/ return _creation_time ; } -time_t ftFileCreator::lastRecvTimeStamp() +rstime_t ftFileCreator::lastRecvTimeStamp() { RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/ return _last_recv_time_t ; @@ -520,7 +520,7 @@ bool ftFileCreator::getMissingChunk(const RsPeerId& peer_id,uint32_t size_hint,u locked_printChunkMap(); #endif source_chunk_map_needed = false ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; // 0 - is there a faulting chunk that would need to be asked again ? diff --git a/libretroshare/src/ft/ftfilecreator.h b/libretroshare/src/ft/ftfilecreator.h index 004558307..01a990414 100644 --- a/libretroshare/src/ft/ftfilecreator.h +++ b/libretroshare/src/ft/ftfilecreator.h @@ -103,8 +103,8 @@ class ftFileCreator: public ftFileProvider void getSourcesList(uint32_t chunk_number,std::vector& sources) ; // Returns resets the time stamp of the last data receive. - time_t lastRecvTimeStamp() ; - time_t creationTimeStamp() ; + rstime_t lastRecvTimeStamp() ; + rstime_t creationTimeStamp() ; // actually store data in the file, and update chunks info // @@ -144,8 +144,8 @@ class ftFileCreator: public ftFileProvider ChunkMap chunkMap ; - time_t _last_recv_time_t ; /// last time stamp when data was received. Used for queue control. - time_t _creation_time ; /// time at which the file creator was created. Used to spot long-inactive transfers. + rstime_t _last_recv_time_t ; /// last time stamp when data was received. Used for queue control. + rstime_t _creation_time ; /// time at which the file creator was created. Used to spot long-inactive transfers. }; #endif // FT_FILE_CREATOR_HEADER diff --git a/libretroshare/src/ft/ftfileprovider.cc b/libretroshare/src/ft/ftfileprovider.cc index 543464515..0660a9bca 100644 --- a/libretroshare/src/ft/ftfileprovider.cc +++ b/libretroshare/src/ft/ftfileprovider.cc @@ -29,7 +29,7 @@ #include "util/rsdir.h" #include #include -#include +#include "util/rstime.h" /******** * #define DEBUG_FT_FILE_PROVIDER 1 @@ -41,7 +41,7 @@ #include #endif -static const time_t UPLOAD_CHUNK_MAPS_TIME = 20 ; // time to ask for a new chunkmap from uploaders in seconds. +static const rstime_t UPLOAD_CHUNK_MAPS_TIME = 20 ; // time to ask for a new chunkmap from uploaders in seconds. ftFileProvider::ftFileProvider(const std::string& path, uint64_t size, const RsFileHash& hash) : mSize(size), hash(hash), file_name(path), fd(NULL), ftcMutex("ftFileProvider") @@ -122,7 +122,7 @@ bool ftFileProvider::FileDetails(FileInfo &info) return true; } -bool ftFileProvider::purgeOldPeers(time_t now,uint32_t max_duration) +bool ftFileProvider::purgeOldPeers(rstime_t now,uint32_t max_duration) { RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/ @@ -232,7 +232,7 @@ bool ftFileProvider::getFileData(const RsPeerId& peer_id,uint64_t offset, uint32 // This creates the peer info, and updates it. // - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; uploading_peers[peer_id].updateStatus(offset,data_size,now) ; #ifdef DEBUG_TRANSFERS @@ -254,7 +254,7 @@ bool ftFileProvider::getFileData(const RsPeerId& peer_id,uint64_t offset, uint32 return 1; } -void ftFileProvider::PeerUploadInfo::updateStatus(uint64_t offset,uint32_t data_size,time_t now) +void ftFileProvider::PeerUploadInfo::updateStatus(uint64_t offset,uint32_t data_size,rstime_t now) { lastTS = now ; long int diff = (long int)now - (long int)lastTS_t ; // in bytes/s. Average over multiple samples @@ -293,7 +293,7 @@ void ftFileProvider::getClientMap(const RsPeerId& peer_id,CompressedChunkMap& cm PeerUploadInfo& pui(uploading_peers[peer_id]) ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(now - pui.client_chunk_map_stamp > UPLOAD_CHUNK_MAPS_TIME) { diff --git a/libretroshare/src/ft/ftfileprovider.h b/libretroshare/src/ft/ftfileprovider.h index f0d9d60d1..4ed0dbec9 100644 --- a/libretroshare/src/ft/ftfileprovider.h +++ b/libretroshare/src/ft/ftfileprovider.h @@ -65,7 +65,7 @@ class ftFileProvider // Removes inactive peers from the client list. Returns true if all peers have been removed. // - bool purgeOldPeers(time_t now,uint32_t max_duration) ; + bool purgeOldPeers(rstime_t now,uint32_t max_duration) ; const RsFileHash& fileHash() const { return hash ; } const std::string& fileName() const { return file_name ; } @@ -88,12 +88,12 @@ class ftFileProvider PeerUploadInfo() : req_loc(0),req_size(1), lastTS_t(0), lastTS(0),transfer_rate(0), total_size(0), client_chunk_map_stamp(0) {} - void updateStatus(uint64_t offset,uint32_t data_size,time_t now) ; + void updateStatus(uint64_t offset,uint32_t data_size,rstime_t now) ; uint64_t req_loc; uint32_t req_size; - time_t lastTS_t; // used for estimating transfer rate. - time_t lastTS; // last update time (for purging) + rstime_t lastTS_t; // used for estimating transfer rate. + rstime_t lastTS; // last update time (for purging) // these two are used for speed estimation float transfer_rate ; @@ -101,7 +101,7 @@ class ftFileProvider // Info about what the downloading peer already has CompressedChunkMap client_chunk_map ; - time_t client_chunk_map_stamp ; + rstime_t client_chunk_map_stamp ; }; // Contains statistics (speed, peer name, etc.) of all uploading peers for that file. diff --git a/libretroshare/src/ft/ftserver.cc b/libretroshare/src/ft/ftserver.cc index 227f84d23..04d55e0ef 100644 --- a/libretroshare/src/ft/ftserver.cc +++ b/libretroshare/src/ft/ftserver.cc @@ -52,7 +52,7 @@ #include "util/rsprint.h" #include -#include +#include "util/rstime.h" /*** * #define SERVER_DEBUG 1 @@ -62,8 +62,8 @@ #define FTSERVER_DEBUG() std::cerr << time(NULL) << " : FILE_SERVER : " << __FUNCTION__ << " : " #define FTSERVER_ERROR() std::cerr << "(EE) FILE_SERVER ERROR : " -static const time_t FILE_TRANSFER_LOW_PRIORITY_TASKS_PERIOD = 5 ; // low priority tasks handling every 5 seconds -static const time_t FILE_TRANSFER_MAX_DELAY_BEFORE_DROP_USAGE_RECORD = 10 ; // keep usage records for 10 secs at most. +static const rstime_t FILE_TRANSFER_LOW_PRIORITY_TASKS_PERIOD = 5 ; // low priority tasks handling every 5 seconds +static const rstime_t FILE_TRANSFER_MAX_DELAY_BEFORE_DROP_USAGE_RECORD = 10 ; // keep usage records for 10 secs at most. /* Setup */ ftServer::ftServer(p3PeerMgr *pm, p3ServiceControl *sc) @@ -1625,8 +1625,8 @@ int ftServer::tick() if(handleIncoming()) moreToTick = true; - static time_t last_law_priority_tasks_handling_time = 0 ; - time_t now = time(NULL) ; + static rstime_t last_law_priority_tasks_handling_time = 0 ; + rstime_t now = time(NULL) ; if(last_law_priority_tasks_handling_time + FILE_TRANSFER_LOW_PRIORITY_TASKS_PERIOD < now) { @@ -1666,10 +1666,10 @@ bool ftServer::checkUploadLimit(const RsPeerId& pid,const RsFileHash& hash) // Find the latest records for this pid. - std::map& tmap(mUploadLimitMap[pid]) ; - std::map::iterator it ; + std::map& tmap(mUploadLimitMap[pid]) ; + std::map::iterator it ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; // If the limit has been decresed, we arbitrarily drop some ongoing slots. @@ -1694,7 +1694,7 @@ bool ftServer::checkUploadLimit(const RsPeerId& pid,const RsFileHash& hash) for(it = tmap.begin();it!=tmap.end() && cleaned<2;) if(it->second + FILE_TRANSFER_MAX_DELAY_BEFORE_DROP_USAGE_RECORD < now) { - std::map::iterator tmp(it) ; + std::map::iterator tmp(it) ; ++tmp; tmap.erase(it) ; it = tmp; @@ -1859,7 +1859,7 @@ bool ftServer::addConfiguration(p3ConfigMgr *cfgmgr) bool ftServer::turtleSearchRequest( const std::string& matchString, const std::function& results)>& multiCallback, - std::time_t maxWait ) + rstime_t maxWait ) { if(matchString.empty()) { diff --git a/libretroshare/src/ft/ftserver.h b/libretroshare/src/ft/ftserver.h index 167ac72dd..5b959c3f0 100644 --- a/libretroshare/src/ft/ftserver.h +++ b/libretroshare/src/ft/ftserver.h @@ -149,7 +149,7 @@ public: virtual bool turtleSearchRequest( const std::string& matchString, const std::function& results)>& multiCallback, - std::time_t maxWait = 300 ); + rstime_t maxWait = 300 ); virtual TurtleSearchRequestId turtleSearch(const std::string& string_to_match) ; virtual TurtleSearchRequestId turtleSearch(const RsRegularExpression::LinearizedExpression& expr) ; @@ -326,7 +326,7 @@ private: std::map mEncryptedHashes ; // This map is such that sha1(it->second) = it->first std::map mEncryptedPeerIds ; // This map holds the hash to be used with each peer id - std::map > mUploadLimitMap ; + std::map > mUploadLimitMap ; /** Store search callbacks with timeout*/ std::map< diff --git a/libretroshare/src/ft/fttransfermodule.cc b/libretroshare/src/ft/fttransfermodule.cc index 136be4653..c7d3f45c9 100644 --- a/libretroshare/src/ft/fttransfermodule.cc +++ b/libretroshare/src/ft/fttransfermodule.cc @@ -23,7 +23,7 @@ * #define FT_DEBUG 1 *****/ -#include +#include "util/rstime.h" #include "retroshare/rsturtle.h" #include "fttransfermodule.h" @@ -285,7 +285,7 @@ void ftTransferModule::resetActvTimeStamp() RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/ _last_activity_time_stamp = time(NULL); } -time_t ftTransferModule::lastActvTimeStamp() +rstime_t ftTransferModule::lastActvTimeStamp() { RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/ return _last_activity_time_stamp ; @@ -693,7 +693,7 @@ void ftTransferModule::adjustSpeed() bool ftTransferModule::locked_tickPeerTransfer(peerInfo &info) { /* how long has it been? */ - time_t ts = time(NULL); + rstime_t ts = time(NULL); int ageRecv = ts - info.recvTS; int ageReq = ts - info.lastTS; @@ -865,7 +865,7 @@ bool ftTransferModule::locked_recvPeerData(peerInfo &info, uint64_t offset, uint std::cerr << std::endl; #endif - time_t ts = time(NULL); + rstime_t ts = time(NULL); info.recvTS = ts; info.nResets = 0; info.state = PQIPEER_DOWNLOADING; diff --git a/libretroshare/src/ft/fttransfermodule.h b/libretroshare/src/ft/fttransfermodule.h index 9999cbdc1..eeb40c6e2 100644 --- a/libretroshare/src/ft/fttransfermodule.h +++ b/libretroshare/src/ft/fttransfermodule.h @@ -76,15 +76,15 @@ public: double desiredRate; double actualRate; - time_t lastTS; /* last Request */ - time_t recvTS; /* last Recv */ + rstime_t lastTS; /* last Request */ + rstime_t recvTS; /* last Recv */ uint32_t lastTransfers; /* data recvd in last second */ uint32_t nResets; /* count to disable non-existant files */ /* rrt rate control */ uint32_t rtt; /* last rtt */ bool rttActive; /* have we initialised an rtt measurement */ - time_t rttStart; /* ts of request */ + rstime_t rttStart; /* ts of request */ uint64_t rttOffset; /* end of request */ float mRateIncrease; /* current rate */ }; @@ -156,7 +156,7 @@ public: void setDownloadPriority(DwlSpeed p) { mPriority =p ; } // read/reset the last time the transfer module was active (either wrote data, or was solicitaded by clients) - time_t lastActvTimeStamp() ; + rstime_t lastActvTimeStamp() ; void resetActvTimeStamp() ; private: @@ -185,7 +185,7 @@ private: double desiredRate; double actualRate; - time_t _last_activity_time_stamp ; + rstime_t _last_activity_time_stamp ; ftFileStatus mFileStatus; //used for pause/resume file transfer diff --git a/libretroshare/src/grouter/groutercache.h b/libretroshare/src/grouter/groutercache.h index e406976b8..cfaa847b8 100644 --- a/libretroshare/src/grouter/groutercache.h +++ b/libretroshare/src/grouter/groutercache.h @@ -50,7 +50,7 @@ class GRouterCacheInfo { public: GRouterCacheInfoFlags flags ; - time_t last_activity ; + rstime_t last_activity ; }; class GRouterCache diff --git a/libretroshare/src/grouter/grouteritems.cc b/libretroshare/src/grouter/grouteritems.cc index 1e098de00..a3df21c82 100644 --- a/libretroshare/src/grouter/grouteritems.cc +++ b/libretroshare/src/grouter/grouteritems.cc @@ -144,10 +144,10 @@ void RsGRouterRoutingInfoItem::serial_process(RsGenericSerializer::SerializeJob RsTypeSerializer::serial_process (j,ctx,peerId,"peerId") ; RsTypeSerializer::serial_process(j,ctx,data_status,"data_status") ; RsTypeSerializer::serial_process(j,ctx,tunnel_status,"tunnel_status") ; - RsTypeSerializer::serial_process (j,ctx,received_time_TS,"received_time_TS") ; - RsTypeSerializer::serial_process (j,ctx,last_sent_TS,"last_sent_TS") ; + RsTypeSerializer::serial_process (j,ctx,received_time_TS,"received_time_TS") ; + RsTypeSerializer::serial_process (j,ctx,last_sent_TS,"last_sent_TS") ; - RsTypeSerializer::serial_process (j,ctx,last_tunnel_request_TS,"last_tunnel_request_TS") ; + RsTypeSerializer::serial_process (j,ctx,last_tunnel_request_TS,"last_tunnel_request_TS") ; RsTypeSerializer::serial_process(j,ctx,sending_attempts,"sending_attempts") ; RsTypeSerializer::serial_process(j,ctx,client_id,"client_id") ; @@ -215,7 +215,7 @@ void RsGRouterMatrixTrackItem::serial_process(RsGenericSerializer::SerializeJob { RsTypeSerializer::serial_process(j,ctx,provider_id,"provider_id") ; RsTypeSerializer::serial_process(j,ctx,message_id,"message_id") ; - RsTypeSerializer::serial_process(j,ctx,time_stamp,"time_stamp") ; + RsTypeSerializer::serial_process(j,ctx,time_stamp,"time_stamp") ; } void RsGRouterMatrixCluesItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) @@ -228,7 +228,7 @@ template<> void RsTypeSerializer::serial_process(RsGenericSerializer::SerializeJ { RsTypeSerializer::serial_process(j,ctx,s.friend_id,name+":friend_id") ; RsTypeSerializer::serial_process (j,ctx,s.weight,name+":weight") ; - RsTypeSerializer::serial_process (j,ctx,s.time_stamp,name+":time_stamp") ; + RsTypeSerializer::serial_process (j,ctx,s.time_stamp,name+":time_stamp") ; } RsGRouterGenericDataItem *RsGRouterGenericDataItem::duplicate() const diff --git a/libretroshare/src/grouter/grouteritems.h b/libretroshare/src/grouter/grouteritems.h index 43b69be7d..baf7c0576 100644 --- a/libretroshare/src/grouter/grouteritems.h +++ b/libretroshare/src/grouter/grouteritems.h @@ -224,7 +224,7 @@ class RsGRouterMatrixTrackItem: public RsGRouterItem // RsGxsMessageId message_id ; RsPeerId provider_id ; - time_t time_stamp ; + rstime_t time_stamp ; }; class RsGRouterMatrixFriendListItem: public RsGRouterItem { diff --git a/libretroshare/src/grouter/groutermatrix.cc b/libretroshare/src/grouter/groutermatrix.cc index 6352a41d9..57db502eb 100644 --- a/libretroshare/src/grouter/groutermatrix.cc +++ b/libretroshare/src/grouter/groutermatrix.cc @@ -36,7 +36,7 @@ GRouterMatrix::GRouterMatrix() bool GRouterMatrix::addTrackingInfo(const RsGxsMessageId& mid,const RsPeerId& source_friend) { - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; RoutingTrackEntry rte ; @@ -57,7 +57,7 @@ bool GRouterMatrix::cleanUp() #ifdef ROUTING_MATRIX_DEBUG std::cerr << "GRouterMatrix::cleanup()" << std::endl; #endif - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; for(std::map::iterator it(_tracking_clues.begin());it!=_tracking_clues.end();) if(it->second.time_stamp + RS_GROUTER_MAX_KEEP_TRACKING_CLUES < now) @@ -84,7 +84,7 @@ bool GRouterMatrix::addRoutingClue(const GRouterKeyId& key_id,const RsPeerId& so // 2 - get the Key map, and add the routing clue. // - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; RoutingMatrixHitEntry rc ; rc.weight = weight ; @@ -179,7 +179,7 @@ void GRouterMatrix::debugDump() const std::cerr << " Proba needs up: " << _proba_need_updating << std::endl; std::cerr << " Known keys: " << _time_combined_hits.size() << std::endl; std::cerr << " Routing events: " << std::endl; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; for(std::map >::const_iterator it(_routing_clues.begin());it!=_routing_clues.end();++it) { @@ -209,7 +209,7 @@ bool GRouterMatrix::computeRoutingProbabilities(const GRouterKeyId& key_id, cons { // Routing probabilities are computed according to routing clues // - // For a given key, each friend has a known set of routing clues (time_t, weight) + // For a given key, each friend has a known set of routing clues (rstime_t, weight) // We combine these to compute a static weight for each friend/key pair. // This is performed in updateRoutingProbabilities() // @@ -271,7 +271,7 @@ bool GRouterMatrix::updateRoutingProbabilities() if(!_proba_need_updating) return false ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; for(std::map >::const_iterator it(_routing_clues.begin());it!=_routing_clues.end();++it) { diff --git a/libretroshare/src/grouter/groutermatrix.h b/libretroshare/src/grouter/groutermatrix.h index cb567b9bc..0a0f3d15e 100644 --- a/libretroshare/src/grouter/groutermatrix.h +++ b/libretroshare/src/grouter/groutermatrix.h @@ -39,13 +39,13 @@ struct RoutingMatrixHitEntry { uint32_t friend_id ; // not the full key. Gets too big otherwise! float weight ; - time_t time_stamp ; + rstime_t time_stamp ; }; struct RoutingTrackEntry { RsPeerId friend_id ; // not the full key. Gets too big otherwise! - time_t time_stamp ; + rstime_t time_stamp ; }; class GRouterMatrix diff --git a/libretroshare/src/grouter/groutertypes.h b/libretroshare/src/grouter/groutertypes.h index ee1bda7dc..23efdbed6 100644 --- a/libretroshare/src/grouter/groutertypes.h +++ b/libretroshare/src/grouter/groutertypes.h @@ -22,7 +22,7 @@ #pragma once #include -#include +#include "util/rstime.h" #include #include "pgp/rscertificate.h" #include "turtle/p3turtle.h" @@ -56,9 +56,9 @@ static const uint32_t MAX_INACTIVE_DATA_PIPE_DELAY = 300 ; // cl static const uint32_t GROUTER_MAX_DUPLICATION_FACTOR = 10 ; // max number of duplicates for a given message to keep in the network static const uint32_t GROUTER_MAX_BRANCHING_FACTOR = 3 ; // max number of branches, for locally forwarding items -static const time_t RS_GROUTER_DEBUG_OUTPUT_PERIOD = 10 ; // Output everything -static const time_t RS_GROUTER_AUTOWASH_PERIOD = 10 ; // Autowash every minute. Not a costly operation. -static const time_t RS_GROUTER_MATRIX_UPDATE_PERIOD = 60*10 ; // Check for key advertising every 10 minutes +static const rstime_t RS_GROUTER_DEBUG_OUTPUT_PERIOD = 10 ; // Output everything +static const rstime_t RS_GROUTER_AUTOWASH_PERIOD = 10 ; // Autowash every minute. Not a costly operation. +static const rstime_t RS_GROUTER_MATRIX_UPDATE_PERIOD = 60*10 ; // Check for key advertising every 10 minutes static const uint32_t GROUTER_ITEM_MAX_CACHE_KEEP_TIME = 2*86400 ; // Cached items are kept for 48 hours at most. static const uint32_t RS_GROUTER_DATA_STATUS_UNKNOWN = 0x0000 ; // unknown. Unused. @@ -79,7 +79,7 @@ class FriendTrialRecord { public: RsPeerId friend_id ; // id of the friend - time_t time_stamp ; // time of the last tried + rstime_t time_stamp ; // time of the last tried float probability ; // probability at which the item was selected uint32_t nb_friends ; // number of friends at the time of sending the item @@ -108,9 +108,9 @@ public: uint32_t data_status ; // pending, waiting, etc. uint32_t tunnel_status ; // status of tunnel handling. - time_t received_time_TS ; // time at which the item was originally received - time_t last_sent_TS ; // last time the item was sent - time_t last_tunnel_request_TS ; // last time tunnels have been asked for this item. + rstime_t received_time_TS ; // time at which the item was originally received + rstime_t last_sent_TS ; // last time the item was sent + rstime_t last_tunnel_request_TS ; // last time tunnels have been asked for this item. uint32_t sending_attempts ; // number of times tunnels have been asked for this peer without success GRouterServiceId client_id ; // service ID of the client. Only valid when origin==OwnId @@ -125,7 +125,7 @@ public: // non serialised data - time_t data_transaction_TS ; + rstime_t data_transaction_TS ; static const uint32_t ROUTING_FLAGS_ALLOW_TUNNELS = 0x0001; static const uint32_t ROUTING_FLAGS_ALLOW_FRIENDS = 0x0002; diff --git a/libretroshare/src/grouter/p3grouter.cc b/libretroshare/src/grouter/p3grouter.cc index eacd3a34f..67787eb88 100644 --- a/libretroshare/src/grouter/p3grouter.cc +++ b/libretroshare/src/grouter/p3grouter.cc @@ -218,7 +218,7 @@ p3GRouter::p3GRouter(p3ServiceControl *sc, RsGixs *is) int p3GRouter::tick() { - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; // Sort incoming service data // @@ -555,7 +555,7 @@ void GRouterTunnelInfo::addVirtualPeer(const TurtleVirtualPeerId& vpid) virtual_peers.insert(vpid) ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(first_tunnel_ok_TS == 0) first_tunnel_ok_TS = now ; last_tunnel_ok_TS = now ; @@ -760,7 +760,7 @@ void p3GRouter::handleTunnels() } #endif - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; std::vector > priority_list ; for(std::map::iterator it=_pending_messages.begin();it!=_pending_messages.end();++it) @@ -893,7 +893,7 @@ void p3GRouter::routePendingObjects() // Which tunnels are available is handled by handleTunnels() // - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; RS_STACK_MUTEX(grMtx) ; #ifdef GROUTER_DEBUG @@ -1220,7 +1220,7 @@ void p3GRouter::locked_collectAvailableFriends(const GRouterKeyId& gxs_id,const void p3GRouter::locked_collectAvailableTunnels(const TurtleFileHash& hash,uint32_t total_duplication,std::map& tunnel_peers_and_duplication_factors) { - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; // Now go through available virtual peers. Select the ones that are interesting, and set them as potential destinations. @@ -1304,7 +1304,7 @@ bool p3GRouter::locked_sendTransactionData(const RsPeerId& pid,const RsGRouterTr void p3GRouter::autoWash() { bool items_deleted = false ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; std::map > failed_msgs ; @@ -2158,7 +2158,7 @@ bool p3GRouter::sendData(const RsGxsId& destination,const GRouterServiceId& clie // GRouterRoutingInfo info ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; info.data_item = data_item ; info.receipt_item = NULL ; @@ -2368,7 +2368,7 @@ void p3GRouter::debugDump() { RS_STACK_MUTEX(grMtx) ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; grouter_debug() << "Full dump of Global Router state: " << std::endl; grouter_debug() << " Owned keys : " << std::endl; diff --git a/libretroshare/src/grouter/p3grouter.h b/libretroshare/src/grouter/p3grouter.h index 935b84a40..fca320843 100644 --- a/libretroshare/src/grouter/p3grouter.h +++ b/libretroshare/src/grouter/p3grouter.h @@ -68,8 +68,8 @@ public: std::set virtual_peers ; - time_t first_tunnel_ok_TS ; // timestamp when 1st tunnel was received. - time_t last_tunnel_ok_TS ; // timestamp when last tunnel was received. + rstime_t first_tunnel_ok_TS ; // timestamp when 1st tunnel was received. + rstime_t last_tunnel_ok_TS ; // timestamp when last tunnel was received. }; class GRouterDataInfo { @@ -87,7 +87,7 @@ public: RsGRouterAbstractMsgItem *addDataChunk(RsGRouterTransactionChunkItem *chunk_item) ; RsGRouterTransactionChunkItem *incoming_data_buffer ; - time_t last_activity_TS ; + rstime_t last_activity_TS ; }; class p3GRouter: public RsGRouter, public RsTurtleClientService, public p3Service, public p3Config @@ -346,10 +346,10 @@ private: bool _changed ; bool _debug_enabled ; - time_t _last_autowash_time ; - time_t _last_matrix_update_time ; - time_t _last_debug_output_time ; - time_t _last_config_changed ; + rstime_t _last_autowash_time ; + rstime_t _last_matrix_update_time ; + rstime_t _last_debug_output_time ; + rstime_t _last_config_changed ; uint64_t _random_salt ; }; diff --git a/libretroshare/src/gxs/db_acadeeb.h b/libretroshare/src/gxs/db_acadeeb.h index 7cbc7d185..806422a30 100644 --- a/libretroshare/src/gxs/db_acadeeb.h +++ b/libretroshare/src/gxs/db_acadeeb.h @@ -53,7 +53,7 @@ class gxp::Paper std::string serialnumber; std::string url; std::list authors; - time_t date; + rstime_t date; uint32_t startpage; uint32_t endpage; std::string language; diff --git a/libretroshare/src/gxs/db_gixp.h b/libretroshare/src/gxs/db_gixp.h index b60ee704d..ef7697d57 100644 --- a/libretroshare/src/gxs/db_gixp.h +++ b/libretroshare/src/gxs/db_gixp.h @@ -73,7 +73,7 @@ class gixp::profile gxip::keyref mKeyId; std::string mName; - time_t mTimestamp; /* superseded by newer timestamps */ + rstime_t mTimestamp; /* superseded by newer timestamps */ uint32_t mProfileType; /* ANONYMOUS (no name, self-signed), PSEUDONYM (self-signed), GPG (name=gpgid, gpgsigned), REVOCATION?? */ gpp::permissions mPermissions; diff --git a/libretroshare/src/gxs/db_gxp.h b/libretroshare/src/gxs/db_gxp.h index d6c2aa933..d536e1fce 100644 --- a/libretroshare/src/gxs/db_gxp.h +++ b/libretroshare/src/gxs/db_gxp.h @@ -157,7 +157,7 @@ class gdp::interface /* query for available groups & messages */ int listgroups(std::list &grpIds); /* response from listmsgs: -1 = invalid parameters, 0 = incomplete list, 1 = all known msgs */ - int listmsgs(const gdp::id grpId, std::list &msgIds, const time_t from, const time_t to, const int maxmsgs); + int listmsgs(const gdp::id grpId, std::list &msgIds, const rstime_t from, const rstime_t to, const int maxmsgs); /* response from requestMsg: YES (available immediately), RETRIEVING (known to exist), * IN_REQUEST (might exist), NOT_AVAILABLE (still might exist) @@ -239,8 +239,8 @@ class gnp::exchange: public gdp::interface /*** IMPLEMENTATION DETAILS ****/ /* Get/Send Messages */ - getAvailableMsgs(gdp::id grpId, time_t from, time_t to); /* request over the network */ - sendAvailableMsgs(std::string peerId, gdp::id grpId, time_t from, time_t to); /* send to peers */ + getAvailableMsgs(gdp::id grpId, rstime_t from, rstime_t to); /* request over the network */ + sendAvailableMsgs(std::string peerId, gdp::id grpId, rstime_t from, rstime_t to); /* send to peers */ requestMessages(std::string peerId, gdp::id grpId, std::list msgIds); sendMessages(std::string peerId, gdp::id grpId, std::list msgIds); /* send to peer, obviously permissions have been checked first */ @@ -284,7 +284,7 @@ class gixp::profile gxip::keyref mKeyId; std::string mPseudonym; - time_t mTimestamp; /* superseded by newer timestamps */ + rstime_t mTimestamp; /* superseded by newer timestamps */ uint32_t mProfileType; /* ANONYMOUS (no name, self-signed), PSEUDONYM (self-signed), GPG (name=gpgname, gpgsigned), REVOCATION?? */ gpp::permissions mPermissions; diff --git a/libretroshare/src/gxs/rsdataservice.cc b/libretroshare/src/gxs/rsdataservice.cc index 1e5f96d69..602e43fe0 100644 --- a/libretroshare/src/gxs/rsdataservice.cc +++ b/libretroshare/src/gxs/rsdataservice.cc @@ -954,7 +954,7 @@ void RsDataService::locked_updateGrpMetaCache(const RsGxsGrpMetaData& meta) void RsDataService::locked_clearGrpMetaCache(const RsGxsGroupId& gid) { - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; auto it = mGrpMetaDataCache.find(gid) ; // We dont actually delete the item, because it might be used by a calling client. diff --git a/libretroshare/src/gxs/rsdataservice.h b/libretroshare/src/gxs/rsdataservice.h index c4a5943a5..572558cd8 100644 --- a/libretroshare/src/gxs/rsdataservice.h +++ b/libretroshare/src/gxs/rsdataservice.h @@ -345,7 +345,7 @@ private: void locked_updateGrpMetaCache(const RsGxsGrpMetaData& meta); std::map mGrpMetaDataCache ; - std::list > mOldCachedItems ; + std::list > mOldCachedItems ; bool mGrpMetaDataCache_ContainsAllDatabase ; }; diff --git a/libretroshare/src/gxs/rsgds.h b/libretroshare/src/gxs/rsgds.h index 84276d7b6..3c63efb2c 100644 --- a/libretroshare/src/gxs/rsgds.h +++ b/libretroshare/src/gxs/rsgds.h @@ -88,7 +88,7 @@ struct RsGroupNetworkStats uint32_t mMaxVisibleCount; bool mGrpAutoSync; bool mAllowMsgSync; - time_t mLastGroupModificationTS; + rstime_t mLastGroupModificationTS; }; typedef std::map > NxsMsgDataResult; diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 3d1c0fc6a..287ac9964 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -124,7 +124,7 @@ RsGenExchange::~RsGenExchange() mGrpsToPublish.clear(); } -bool RsGenExchange::getGroupServerUpdateTS(const RsGxsGroupId& gid, time_t& grp_server_update_TS, time_t& msg_server_update_TS) +bool RsGenExchange::getGroupServerUpdateTS(const RsGxsGroupId& gid, rstime_t& grp_server_update_TS, rstime_t& msg_server_update_TS) { return mNetService->getGroupServerUpdateTS(gid,grp_server_update_TS,msg_server_update_TS) ; } @@ -169,7 +169,7 @@ void RsGenExchange::tick() // implemented service tick function service_tick(); - time_t now = time(NULL); + rstime_t now = time(NULL); if((mLastClean + MSG_CLEANUP_PERIOD < now) || mCleaning) { @@ -259,7 +259,7 @@ bool RsGenExchange::messagePublicationTest(const RsGxsMsgMetaData& meta) uint32_t st = mNetService->getKeepAge(meta.mGroupId); - time_t storageTimeLimit = meta.mPublishTs + st; + rstime_t storageTimeLimit = meta.mPublishTs + st; return meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP || st == 0 || storageTimeLimit >= time(NULL); } @@ -2140,7 +2140,7 @@ void RsGenExchange::publishMsgs() RS_STACK_MUTEX(mGenMtx) ; - time_t now = time(NULL); + rstime_t now = time(NULL); // stick back msgs pending signature typedef std::map > PendSignMap; @@ -2561,7 +2561,7 @@ void RsGenExchange::publishGrps() GxsGrpPendingSign& ggps = *vit; /* do intial checks to see if this entry has expired */ - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; uint32_t token = ggps.mToken; @@ -2869,7 +2869,7 @@ void RsGenExchange::processRecvdMessages() { RS_STACK_MUTEX(mGenMtx) ; - time_t now = time(NULL); + rstime_t now = time(NULL); if(mMsgPendingValidate.empty()) return ; diff --git a/libretroshare/src/gxs/rsgenexchange.h b/libretroshare/src/gxs/rsgenexchange.h index 336eeb4fe..2144c64ae 100644 --- a/libretroshare/src/gxs/rsgenexchange.h +++ b/libretroshare/src/gxs/rsgenexchange.h @@ -23,7 +23,7 @@ #define RSGENEXCHANGE_H #include -#include +#include "util/rstime.h" #include "rsgxs.h" #include "rsgds.h" @@ -39,7 +39,7 @@ template class GxsPendingItem { public: - GxsPendingItem(GxsItem item, Identity id,time_t ts) : + GxsPendingItem(GxsItem item, Identity id,rstime_t ts) : mItem(item), mId(id), mFirstTryTS(ts) {} @@ -50,7 +50,7 @@ public: GxsItem mItem; Identity mId; - time_t mFirstTryTS; + rstime_t mFirstTryTS; }; class GxsGrpPendingSign @@ -61,7 +61,7 @@ public: mItem(item), mHaveKeys(false), mIsUpdate(false) {} - time_t mLastAttemptTS, mStartTS; + rstime_t mLastAttemptTS, mStartTS; uint32_t mToken; RsGxsGrpItem* mItem; bool mHaveKeys; // mKeys->first == true if key present @@ -669,7 +669,7 @@ public: * when needed. Typical use case is forums and circles. * @param gid GroupId the TS is which is requested */ - bool getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) ; + bool getGroupServerUpdateTS(const RsGxsGroupId& gid,rstime_t& grp_server_update_TS,rstime_t& msg_server_update_TS) ; /*! * \brief getDefaultStoragePeriod. All times in seconds. @@ -905,12 +905,12 @@ private: NxsMsgPendingVect mMsgPendingValidate; bool mCleaning; - time_t mLastClean; + rstime_t mLastClean; RsGxsMessageCleanUp* mMsgCleanUp; bool mChecking, mCheckStarted; - time_t mLastCheck; + rstime_t mLastCheck; RsGxsIntegrityCheck* mIntegrityCheck; protected: diff --git a/libretroshare/src/gxs/rsgixs.h b/libretroshare/src/gxs/rsgixs.h index 5f6bc7c55..43cdf059f 100644 --- a/libretroshare/src/gxs/rsgixs.h +++ b/libretroshare/src/gxs/rsgixs.h @@ -221,7 +221,7 @@ class RsGcxs virtual bool isRecipient(const RsGxsCircleId &circleId, const RsGxsGroupId& destination_group, const RsGxsId& id) = 0; - virtual bool getLocalCircleServerUpdateTS(const RsGxsCircleId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) =0; + virtual bool getLocalCircleServerUpdateTS(const RsGxsCircleId& gid,rstime_t& grp_server_update_TS,rstime_t& msg_server_update_TS) =0; }; @@ -234,7 +234,7 @@ public: :RsGenExchange(gds,ns,serviceSerialiser,mServType, gixs, authenPolicy) { return; } virtual ~RsGxsCircleExchange() { return; } - virtual bool getLocalCircleServerUpdateTS(const RsGxsCircleId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) + virtual bool getLocalCircleServerUpdateTS(const RsGxsCircleId& gid,rstime_t& grp_server_update_TS,rstime_t& msg_server_update_TS) { return RsGenExchange::getGroupServerUpdateTS(RsGxsGroupId(gid),grp_server_update_TS,msg_server_update_TS) ; } diff --git a/libretroshare/src/gxs/rsgxsdata.h b/libretroshare/src/gxs/rsgxsdata.h index ff76539cc..282f063fb 100644 --- a/libretroshare/src/gxs/rsgxsdata.h +++ b/libretroshare/src/gxs/rsgxsdata.h @@ -24,9 +24,9 @@ #include -#include +#include "retroshare/rstypes.h" #include "serialiser/rstlvkeys.h" - +#include "util/rstime.h" #include "rsitems/rsgxsitems.h" struct RsGroupMetaData; @@ -110,7 +110,7 @@ public: RsTlvKeySignatureSet signSet; std::string mMsgName; - time_t mPublishTs; + rstime_t mPublishTs; uint32_t mMsgFlags; // used by some services (e.g. by forums to store message moderation flags) // BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG. @@ -119,7 +119,7 @@ public: std::string mServiceString; uint32_t mMsgStatus; uint32_t mMsgSize; - time_t mChildTs; + rstime_t mChildTs; uint32_t recvTS; RsFileHash mHash; bool validated; diff --git a/libretroshare/src/gxs/rsgxsdataaccess.cc b/libretroshare/src/gxs/rsgxsdataaccess.cc index b0219ecb2..a72123f92 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.cc +++ b/libretroshare/src/gxs/rsgxsdataaccess.cc @@ -20,7 +20,7 @@ * * *******************************************************************************/ -#include +#include "util/rstime.h" #include "rsgxsutil.h" #include "rsgxsdataaccess.h" @@ -317,7 +317,7 @@ RsTokenService::GxsRequestStatus RsGxsDataAccess::requestStatus(uint32_t token) RsTokenService::GxsRequestStatus status; uint32_t reqtype; uint32_t anstype; - time_t ts; + rstime_t ts; { RS_STACK_MUTEX(mDataMutex); @@ -717,7 +717,7 @@ GxsRequest* RsGxsDataAccess::locked_retrieveRequest(const uint32_t& token) void RsGxsDataAccess::processRequests() { std::list toClear; - time_t now = time(NULL); + rstime_t now = time(NULL); std::map::iterator it; { @@ -1124,8 +1124,8 @@ bool RsGxsDataAccess::getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions& std::vector::const_iterator vit = metaV.begin(); // RUN THROUGH ALL MSGS... in map origId -> TS. - std::map > origMsgTs; - std::map >::iterator oit; + std::map > origMsgTs; + std::map >::iterator oit; for(; vit != metaV.end(); ++vit) { @@ -1402,8 +1402,8 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req) if (onlyChildMsgs || onlyThreadMsgs) { // RUN THROUGH ALL MSGS... in map origId -> TS. - std::map > origMsgTs; - std::map >::iterator oit; + std::map > origMsgTs; + std::map >::iterator oit; for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta) { @@ -1472,7 +1472,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req) { /* first guess is potentially better than Orig (can't be worse!) */ - time_t latestTs = 0; + rstime_t latestTs = 0; RsGxsMessageId latestMsgId; RsGxsMsgMetaData* latestMeta=NULL; @@ -1760,7 +1760,7 @@ void RsGxsDataAccess::filterGrpList(std::list &grpIds, const RsTok bool RsGxsDataAccess::checkRequestStatus( uint32_t token, GxsRequestStatus& status, uint32_t& reqtype, - uint32_t& anstype, time_t& ts ) + uint32_t& anstype, rstime_t& ts ) { RS_STACK_MUTEX(mDataMutex); diff --git a/libretroshare/src/gxs/rsgxsdataaccess.h b/libretroshare/src/gxs/rsgxsdataaccess.h index df79c1e95..c5bfdf084 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.h +++ b/libretroshare/src/gxs/rsgxsdataaccess.h @@ -314,7 +314,7 @@ private: * @return false if token does not exist, true otherwise */ bool checkRequestStatus( uint32_t token, GxsRequestStatus &status, - uint32_t &reqtype, uint32_t &anstype, time_t &ts); + uint32_t &reqtype, uint32_t &anstype, rstime_t &ts); // special ones for testing (not in final design) /*! diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index df19a900d..2aef9a5e0 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -327,7 +327,7 @@ static const uint32_t service_to_print = RS_SERVICE_GXS_TYPE_CHANNELS ; class nullstream: public std::ostream {}; -static std::string nice_time_stamp(time_t now,time_t TS) +static std::string nice_time_stamp(rstime_t now,rstime_t TS) { if(TS == 0) return "Never" ; @@ -448,8 +448,8 @@ int RsGxsNetService::tick() if(should_notify) processObserverNotifications() ; - time_t now = time(NULL); - time_t elapsed = mSYNC_PERIOD + mSyncTs; + rstime_t now = time(NULL); + rstime_t elapsed = mSYNC_PERIOD + mSyncTs; if((elapsed) < now) { @@ -525,20 +525,20 @@ void RsGxsNetService::rejectMessage(const RsGxsMessageId& msg_id) void RsGxsNetService::cleanRejectedMessages() { RS_STACK_MUTEX(mNxsMutex) ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; #ifdef NXS_NET_DEBUG_0 GXSNETDEBUG___ << "Cleaning rejected messages." << std::endl; #endif - for(std::map::iterator it(mRejectedMessages.begin());it!=mRejectedMessages.end();) + for(std::map::iterator it(mRejectedMessages.begin());it!=mRejectedMessages.end();) if(it->second + REJECTED_MESSAGE_RETRY_DELAY < now) { #ifdef NXS_NET_DEBUG_0 GXSNETDEBUG___ << " message id " << it->first << " should be re-tried. removing from list..." << std::endl; #endif - std::map::iterator tmp = it ; + std::map::iterator tmp = it ; ++tmp ; mRejectedMessages.erase(it) ; it=tmp ; @@ -854,7 +854,7 @@ void RsGxsNetService::syncGrpStatistics() // Go through group statistics and groups without information are re-requested to random peers selected // among the ones who provided the group info. - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; for(auto it(grpMeta.begin());it!=grpMeta.end();++it) { @@ -1591,7 +1591,7 @@ bool RsGxsNetService::loadList(std::list &load) // The delete is done in StoreHere, if necessary std::for_each(load.begin(), load.end(), StoreHere(mClientGrpUpdateMap, mClientMsgUpdateMap, mServerMsgUpdateMap, mServerGrpConfigMap, mGrpServerUpdate)); - time_t now = time(NULL); + rstime_t now = time(NULL); // We reset group statistics here. This is the best place since we know at this point which are all unsubscribed groups. @@ -2018,7 +2018,7 @@ void RsGxsNetService::debugDump() { #ifdef NXS_NET_DEBUG_0 RS_STACK_MUTEX(mNxsMutex) ; - //time_t now = time(NULL) ; + //rstime_t now = time(NULL) ; GXSNETDEBUG___<< "RsGxsNetService::debugDump():" << std::endl; @@ -2160,8 +2160,8 @@ void RsGxsNetService::updateServerSyncTS() // ask to the GxsNetService of circles what the server TS is for that circle. If more recent, we update the serverTS of the // local group - time_t circle_group_server_ts ; - time_t circle_msg_server_ts ; + rstime_t circle_group_server_ts ; + rstime_t circle_msg_server_ts ; // This call needs to be off-mutex, because of self-restricted circles. // Normally we should update as a function of MsgServerUpdateTS and the mRecvTS of the circle, not the global grpServerTS. @@ -2653,7 +2653,7 @@ void RsGxsNetService::locked_processCompletedIncomingTrans(NxsTransaction* tr) GXSNETDEBUG_P_(tr->mTransaction->PeerId()) << " type = msgs." << std::endl; #endif RsGxsGroupId grpId; - //time_t now = time(NULL) ; + //rstime_t now = time(NULL) ; while(tr->mItems.size() > 0) { @@ -3106,7 +3106,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr) } } -void RsGxsNetService::locked_stampPeerGroupUpdateTime(const RsPeerId& pid,const RsGxsGroupId& grpId,time_t tm,uint32_t n_messages) +void RsGxsNetService::locked_stampPeerGroupUpdateTime(const RsPeerId& pid,const RsGxsGroupId& grpId,rstime_t tm,uint32_t n_messages) { RsGxsMsgUpdate& up(mClientMsgUpdateMap[pid]); @@ -4380,7 +4380,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_ uint32_t transN = locked_getTransactionId(); RsGxsCircleId should_encrypt_to_this_circle_id ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; uint32_t max_send_delay = locked_getGrpConfig(item->grpId).msg_req_delay; // we should use "sync" but there's only one variable used in the GUI: the req one. @@ -5024,7 +5024,7 @@ void RsGxsNetService::handleRecvPublishKeys(RsNxsGroupPublishKeyItem *item) } } -bool RsGxsNetService::getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& group_server_update_TS, time_t& msg_server_update_TS) +bool RsGxsNetService::getGroupServerUpdateTS(const RsGxsGroupId& gid,rstime_t& group_server_update_TS, rstime_t& msg_server_update_TS) { RS_STACK_MUTEX(mNxsMutex) ; @@ -5112,7 +5112,7 @@ TurtleRequestId RsGxsNetService::turtleGroupRequest(const RsGxsGroupId& group_id { RS_STACK_MUTEX(mNxsMutex) ; - time_t now = time(NULL); + rstime_t now = time(NULL); auto it = mSearchedGroups.find(group_id) ; if(mSearchedGroups.end() != it && (it->second.ts + MIN_DELAY_BETWEEN_GROUP_SEARCH > now)) @@ -5309,7 +5309,7 @@ bool RsGxsNetService::search( const std::string& substring, if((rit = uQ.find("signFlags")) != uQ.end()) s.mSignFlags = std::stoul(rit->second); if((rit = uQ.find("publishTs")) != uQ.end()) - s.mPublishTs = static_cast(std::stoll(rit->second)); + s.mPublishTs = static_cast(std::stoll(rit->second)); if((rit = uQ.find("authorId")) != uQ.end()) s.mAuthorId = RsGxsId(rit->second); diff --git a/libretroshare/src/gxs/rsgxsnetservice.h b/libretroshare/src/gxs/rsgxsnetservice.h index 67a8ca054..36608fe8c 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.h +++ b/libretroshare/src/gxs/rsgxsnetservice.h @@ -52,14 +52,14 @@ class RsGroupNetworkStatsRecord std::set suppliers ; uint32_t max_visible_count ; - time_t update_TS ; + rstime_t update_TS ; }; struct GroupRequestRecord { GroupRequestRecord(): ts(0), request_id(0) {} - time_t ts ; + rstime_t ts ; TurtleRequestId request_id; }; @@ -188,7 +188,7 @@ public: virtual void rejectMessage(const RsGxsMessageId& msg_id) ; - virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) ; + virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,rstime_t& grp_server_update_TS,rstime_t& msg_server_update_TS) ; virtual bool stampMsgServerUpdateTS(const RsGxsGroupId& gid) ; virtual bool removeGroups(const std::list& groups); virtual bool isDistantPeer(const RsPeerId& pid); @@ -507,7 +507,7 @@ private: * stamp the group info from that particular peer at the given time. */ - void locked_stampPeerGroupUpdateTime(const RsPeerId& pid,const RsGxsGroupId& grpId,time_t tm,uint32_t n_messages) ; + void locked_stampPeerGroupUpdateTime(const RsPeerId& pid,const RsGxsGroupId& grpId,rstime_t tm,uint32_t n_messages) ; /*! * encrypts/decrypts the transaction for the destination circle id. @@ -602,7 +602,7 @@ private: RsGxsServerGrpUpdate mGrpServerUpdate; RsServiceInfo mServiceInfo; - std::map mRejectedMessages; + std::map mRejectedMessages; std::vector mNewGroupsToNotify ; std::vector mNewMessagesToNotify ; @@ -620,7 +620,7 @@ private: std::map mGroupHashCache; std::map mSearchRequests; std::map mSearchedGroups ; - time_t mLastCacheReloadTS ; + rstime_t mLastCacheReloadTS ; }; #endif // RSGXSNETSERVICE_H diff --git a/libretroshare/src/gxs/rsgxsnettunnel.cc b/libretroshare/src/gxs/rsgxsnettunnel.cc index 026ba822b..a952fbf15 100644 --- a/libretroshare/src/gxs/rsgxsnettunnel.cc +++ b/libretroshare/src/gxs/rsgxsnettunnel.cc @@ -732,7 +732,7 @@ void RsGxsNetTunnelService::data_tick() mPendingTurtleItems.pop_front(); } - time_t now = time(NULL); + rstime_t now = time(NULL); // cleanup diff --git a/libretroshare/src/gxs/rsgxsnettunnel.h b/libretroshare/src/gxs/rsgxsnettunnel.h index cbac109a9..145d68fdc 100644 --- a/libretroshare/src/gxs/rsgxsnettunnel.h +++ b/libretroshare/src/gxs/rsgxsnettunnel.h @@ -270,8 +270,8 @@ private: friend class RsGxsTunnelRandomBiasItem ; friend class StoreHere ; - time_t mLastKeepAlive ; - time_t mLastAutoWash ; - time_t mLastDump ; + rstime_t mLastKeepAlive ; + rstime_t mLastAutoWash ; + rstime_t mLastDump ; }; diff --git a/libretroshare/src/gxs/rsgxsnetutils.cc b/libretroshare/src/gxs/rsgxsnetutils.cc index 7195ff519..1b0166f65 100644 --- a/libretroshare/src/gxs/rsgxsnetutils.cc +++ b/libretroshare/src/gxs/rsgxsnetutils.cc @@ -24,11 +24,11 @@ #include "pqi/p3servicecontrol.h" #include "pgp/pgpauxutils.h" - const time_t AuthorPending::EXPIRY_PERIOD_OFFSET = 30; // 30 seconds + const rstime_t AuthorPending::EXPIRY_PERIOD_OFFSET = 30; // 30 seconds const int AuthorPending::MSG_PEND = 1; const int AuthorPending::GRP_PEND = 2; -AuthorPending::AuthorPending(RsGixsReputation* rep, time_t timeStamp) : mRep(rep), mTimeStamp(timeStamp) {} +AuthorPending::AuthorPending(RsGixsReputation* rep, rstime_t timeStamp) : mRep(rep), mTimeStamp(timeStamp) {} AuthorPending::~AuthorPending() {} @@ -197,7 +197,7 @@ void RsNxsNetMgrImpl::getOnlineList(const uint32_t serviceId, std::set mServiceCtrl->getPeersConnected(serviceId, ssl_peers); } -const time_t GrpCircleVetting::EXPIRY_PERIOD_OFFSET = 5; // 10 seconds +const rstime_t GrpCircleVetting::EXPIRY_PERIOD_OFFSET = 5; // 10 seconds const int GrpCircleVetting::GRP_ID_PEND = 1; const int GrpCircleVetting::GRP_ITEM_PEND = 2; const int GrpCircleVetting::MSG_ID_SEND_PEND = 3; diff --git a/libretroshare/src/gxs/rsgxsnetutils.h b/libretroshare/src/gxs/rsgxsnetutils.h index 90ab64cf9..2ed229de0 100644 --- a/libretroshare/src/gxs/rsgxsnetutils.h +++ b/libretroshare/src/gxs/rsgxsnetutils.h @@ -114,9 +114,9 @@ public: static const int MSG_PEND; static const int GRP_PEND; - static const time_t EXPIRY_PERIOD_OFFSET; + static const rstime_t EXPIRY_PERIOD_OFFSET; - AuthorPending(RsGixsReputation* rep, time_t timeStamp); + AuthorPending(RsGixsReputation* rep, rstime_t timeStamp); virtual ~AuthorPending(); virtual int getType() const = 0 ; @@ -144,7 +144,7 @@ protected: private: RsGixsReputation* mRep; - time_t mTimeStamp; + rstime_t mTimeStamp; }; class MsgAuthEntry @@ -237,7 +237,7 @@ class GrpCircleVetting { public: - static const time_t EXPIRY_PERIOD_OFFSET; + static const rstime_t EXPIRY_PERIOD_OFFSET; static const int GRP_ID_PEND; static const int GRP_ITEM_PEND; static const int MSG_ID_SEND_PEND; @@ -255,7 +255,7 @@ protected: RsGcxs* const mCircles; PgpAuxUtils *mPgpUtils; - time_t mTimeStamp; + rstime_t mTimeStamp; }; class GrpCircleIdRequestVetting : public GrpCircleVetting diff --git a/libretroshare/src/gxs/rsgxsutil.cc b/libretroshare/src/gxs/rsgxsutil.cc index 2e7a69079..f678c7966 100644 --- a/libretroshare/src/gxs/rsgxsutil.cc +++ b/libretroshare/src/gxs/rsgxsutil.cc @@ -21,7 +21,7 @@ * * *******************************************************************************/ -#include +#include "util/rstime.h" #include "rsgxsutil.h" #include "retroshare/rsgxsflags.h" @@ -57,7 +57,7 @@ bool RsGxsMessageCleanUp::clean() { uint32_t i = 1; - time_t now = time(NULL); + rstime_t now = time(NULL); #ifdef DEBUG_GXSUTIL uint16_t service_type = mGenExchangeClient->serviceType() ; diff --git a/libretroshare/src/gxs/rsnxs.h b/libretroshare/src/gxs/rsnxs.h index a6044aa46..b94d46200 100644 --- a/libretroshare/src/gxs/rsnxs.h +++ b/libretroshare/src/gxs/rsnxs.h @@ -28,7 +28,7 @@ #include #include -#include +#include "util/rstime.h" #include #include #include @@ -220,7 +220,7 @@ public: * \param tm time stamp computed * \return false if the group is not found, true otherwise */ - virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) =0; + virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,rstime_t& grp_server_update_TS,rstime_t& msg_server_update_TS) =0; /*! * \brief stampMsgServerUpdateTS diff --git a/libretroshare/src/gxstrans/p3gxstrans.cc b/libretroshare/src/gxstrans/p3gxstrans.cc index c58a514bb..34487017c 100644 --- a/libretroshare/src/gxstrans/p3gxstrans.cc +++ b/libretroshare/src/gxstrans/p3gxstrans.cc @@ -482,7 +482,7 @@ void p3GxsTrans::service_tick() { GxsTokenQueue::checkRequests(); - time_t now = time(NULL); + rstime_t now = time(NULL); bool changed = false ; if(mLastMsgCleanup + MAX_DELAY_BETWEEN_CLEANUPS < now) diff --git a/libretroshare/src/gxstrans/p3gxstrans.h b/libretroshare/src/gxstrans/p3gxstrans.h index 9eddf7c31..c730d8177 100644 --- a/libretroshare/src/gxstrans/p3gxstrans.h +++ b/libretroshare/src/gxstrans/p3gxstrans.h @@ -175,7 +175,7 @@ private: */ static const uint32_t MAX_DELAY_BETWEEN_CLEANUPS ; // every 20 mins. Could be less. - time_t mLastMsgCleanup ; + rstime_t mLastMsgCleanup ; /// Define how the backend should handle authentication based on signatures static uint32_t AuthenPolicy(); @@ -272,8 +272,8 @@ private: /** @return true if has passed more then interval seconds between timeStamp * and ref. @param ref by default now is taked as reference. */ - bool static inline olderThen(time_t timeStamp, int32_t interval, - time_t ref = time(NULL)) + bool static inline olderThen(rstime_t timeStamp, int32_t interval, + rstime_t ref = time(NULL)) { return (timeStamp + interval) < ref; } diff --git a/libretroshare/src/gxstunnel/p3gxstunnel.cc b/libretroshare/src/gxstunnel/p3gxstunnel.cc index f6d5cd7fd..264ddbc96 100644 --- a/libretroshare/src/gxstunnel/p3gxstunnel.cc +++ b/libretroshare/src/gxstunnel/p3gxstunnel.cc @@ -101,8 +101,8 @@ int p3GxsTunnelService::tick() { #ifdef DEBUG_GXS_TUNNEL - time_t now = time(NULL); - static time_t last_dump = 0; + rstime_t now = time(NULL); + static rstime_t last_dump = 0; if(now > last_dump + INTERVAL_BETWEEN_DEBUG_DUMP ) { @@ -171,7 +171,7 @@ void p3GxsTunnelService::flush() { RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/ - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; for(std::map::iterator it = pendingGxsTunnelDataItems.begin();it != pendingGxsTunnelDataItems.end();++it) if(now > RS_GXS_TUNNEL_DELAY_BETWEEN_RESEND + it->second.last_sending_attempt) @@ -194,7 +194,7 @@ void p3GxsTunnelService::flush() RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/ - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; for(std::map::iterator it(_gxs_tunnel_contacts.begin());it!=_gxs_tunnel_contacts.end();) { @@ -256,13 +256,13 @@ void p3GxsTunnelService::flush() // clean old received data prints. - for(std::map::iterator it2=it->second.received_data_prints.begin();it2!=it->second.received_data_prints.end();) + for(std::map::iterator it2=it->second.received_data_prints.begin();it2!=it->second.received_data_prints.end();) if(now > it2->second + RS_GXS_TUNNEL_DATA_PRINT_STORAGE_DELAY) { #ifdef DEBUG_GXS_TUNNEL std::cerr << "(II) erasing old data print for message #" << it2->first << " in tunnel " << it->first << std::endl; #endif - std::map::iterator tmp(it2) ; + std::map::iterator tmp(it2) ; ++tmp ; it->second.received_data_prints.erase(it2) ; it2 = tmp ; @@ -1445,7 +1445,7 @@ void p3GxsTunnelService::startClientGxsTunnelConnection(const RsGxsId& to_gxs_id GxsTunnelPeerInfo info ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; info.last_contact = now ; info.last_keep_alive_sent = now ; @@ -1639,7 +1639,7 @@ void p3GxsTunnelService::debug_dump() { RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/ - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; std::cerr << "p3GxsTunnelService::debug_dump()" << std::endl; std::cerr << " Registered client services: " << std::endl; diff --git a/libretroshare/src/gxstunnel/p3gxstunnel.h b/libretroshare/src/gxstunnel/p3gxstunnel.h index e32626c7f..bcbce734a 100644 --- a/libretroshare/src/gxstunnel/p3gxstunnel.h +++ b/libretroshare/src/gxstunnel/p3gxstunnel.h @@ -157,8 +157,8 @@ private: total_received = 0 ; } - time_t last_contact ; // used to keep track of working connexion - time_t last_keep_alive_sent ; // last time we sent a keep alive packet. + rstime_t last_contact ; // used to keep track of working connexion + rstime_t last_keep_alive_sent ; // last time we sent a keep alive packet. unsigned char aes_key[GXS_TUNNEL_AES_KEY_SIZE] ; @@ -169,7 +169,7 @@ private: RsTurtleGenericTunnelItem::Direction direction ; // specifiec wether we are client(managing the tunnel) or server. TurtleFileHash hash ; // hash that is last used. This is necessary for handling tunnel establishment std::set client_services ;// services that used this tunnel - std::map received_data_prints ; // list of recently received messages, to avoid duplicates. Kept for 20 mins at most. + std::map received_data_prints ; // list of recently received messages, to avoid duplicates. Kept for 20 mins at most. uint32_t total_sent ; uint32_t total_received ; }; @@ -191,7 +191,7 @@ private: struct GxsTunnelData { RsGxsTunnelDataItem *data_item ; - time_t last_sending_attempt ; + rstime_t last_sending_attempt ; }; // This maps contains the current peers to talk to with distant chat. diff --git a/libretroshare/src/gxstunnel/rsgxstunnelitems.cc b/libretroshare/src/gxstunnel/rsgxstunnelitems.cc index c43e4baae..f86529c3b 100644 --- a/libretroshare/src/gxstunnel/rsgxstunnelitems.cc +++ b/libretroshare/src/gxstunnel/rsgxstunnelitems.cc @@ -21,7 +21,7 @@ *******************************************************************************/ #include -#include +#include "util/rstime.h" #include "serialiser/rsbaseserial.h" #include "serialiser/rstlvbase.h" #include "serialiser/rstypeserializer.h" diff --git a/libretroshare/src/jsonapi/jsonapiitems.h b/libretroshare/src/jsonapi/jsonapiitems.h index 7e61d4de8..7e26774f9 100644 --- a/libretroshare/src/jsonapi/jsonapiitems.h +++ b/libretroshare/src/jsonapi/jsonapiitems.h @@ -18,7 +18,7 @@ #pragma once #include -#include +#include "util/rstime.h" #include #include diff --git a/libretroshare/src/pgp/pgphandler.cc b/libretroshare/src/pgp/pgphandler.cc index bc80f322f..7769aa4c8 100644 --- a/libretroshare/src/pgp/pgphandler.cc +++ b/libretroshare/src/pgp/pgphandler.cc @@ -601,8 +601,8 @@ const ops_keydata_t *PGPHandler::locked_getPublicKey(const RsPgpId& id,bool stam { if(stamp_the_key) // Should we stamp the key as used? { - static time_t last_update_db_because_of_stamp = 0 ; - time_t now = time(NULL) ; + static rstime_t last_update_db_because_of_stamp = 0 ; + rstime_t now = time(NULL) ; res->second._time_stamp = now ; diff --git a/libretroshare/src/pgp/pgphandler.h b/libretroshare/src/pgp/pgphandler.h index c227ec018..5137d5ba1 100644 --- a/libretroshare/src/pgp/pgphandler.h +++ b/libretroshare/src/pgp/pgphandler.h @@ -57,7 +57,7 @@ class PGPCertificateInfo uint32_t _flags ; uint32_t _type ; - mutable time_t _time_stamp ; // last time the key was used (received, used for signature verification, etc) + mutable rstime_t _time_stamp ; // last time the key was used (received, used for signature verification, etc) PGPFingerprintType _fpr; /* fingerprint */ // RsPgpId _key_id ; @@ -220,9 +220,9 @@ class PGPHandler bool _pubring_changed ; mutable bool _trustdb_changed ; - time_t _pubring_last_update_time ; - time_t _secring_last_update_time ; - time_t _trustdb_last_update_time ; + rstime_t _pubring_last_update_time ; + rstime_t _secring_last_update_time ; + rstime_t _trustdb_last_update_time ; // Helper functions. // diff --git a/libretroshare/src/plugins/pluginmanager.cc b/libretroshare/src/plugins/pluginmanager.cc index ad03bc31c..f2a3c8b29 100644 --- a/libretroshare/src/plugins/pluginmanager.cc +++ b/libretroshare/src/plugins/pluginmanager.cc @@ -421,7 +421,7 @@ RsServiceControl *RsPluginManager::getServiceControl() const assert(_service_control); return _service_control ; } -void RsPluginManager::slowTickPlugins(time_t seconds) +void RsPluginManager::slowTickPlugins(rstime_t seconds) { for(uint32_t i=0;i<_plugins.size();++i) if(_plugins[i].plugin != NULL && _plugins[i].plugin->rs_cache_service() != NULL && (seconds % _plugins[i].plugin->rs_cache_service()->tickDelay() )) diff --git a/libretroshare/src/plugins/pluginmanager.h b/libretroshare/src/plugins/pluginmanager.h index 021a80463..965706bf1 100644 --- a/libretroshare/src/plugins/pluginmanager.h +++ b/libretroshare/src/plugins/pluginmanager.h @@ -78,7 +78,7 @@ class RsPluginManager: public RsPluginHandler, public p3Config virtual void enablePlugin(const RsFileHash& hash) ; virtual void disablePlugin(const RsFileHash &hash) ; - virtual void slowTickPlugins(time_t sec) ; + virtual void slowTickPlugins(rstime_t sec) ; virtual const std::string& getLocalCacheDir() const ; virtual const std::string& getRemoteCacheDir() const ; virtual RsServiceControl *getServiceControl() const ; diff --git a/libretroshare/src/pqi/authgpg.cc b/libretroshare/src/pqi/authgpg.cc index 70735ee83..bf485a2ad 100644 --- a/libretroshare/src/pqi/authgpg.cc +++ b/libretroshare/src/pqi/authgpg.cc @@ -44,7 +44,7 @@ //#define DEBUG_AUTHGPG 1 -//const time_t STORE_KEY_TIMEOUT = 1 * 60 * 60; //store key is call around every hour +//const rstime_t STORE_KEY_TIMEOUT = 1 * 60 * 60; //store key is call around every hour AuthGPG *AuthGPG::_instance = NULL ; diff --git a/libretroshare/src/pqi/authgpg.h b/libretroshare/src/pqi/authgpg.h index 6d3337580..4d9f93ff2 100644 --- a/libretroshare/src/pqi/authgpg.h +++ b/libretroshare/src/pqi/authgpg.h @@ -288,7 +288,7 @@ public: RsMutex gpgMtxData; /* Below is protected via the mutex */ - time_t mStoreKeyTime; + rstime_t mStoreKeyTime; RsPgpId mOwnGpgId; bool gpgKeySelected; diff --git a/libretroshare/src/pqi/p3dhtmgr.cc b/libretroshare/src/pqi/p3dhtmgr.cc index f5435bcde..fa24fa324 100644 --- a/libretroshare/src/pqi/p3dhtmgr.cc +++ b/libretroshare/src/pqi/p3dhtmgr.cc @@ -27,7 +27,7 @@ #include #include #include -#include +#include "util/rstime.h" #include "pqi/p3dhtmgr.h" #include "pqi/p3peermgr.h" @@ -322,7 +322,7 @@ bool p3DhtMgr::notifyPeer(const RsPeerId& id) } - time_t now = time(NULL); + rstime_t now = time(NULL); if (now - it->second.notifyTS < 2 * DHT_NOTIFY_PERIOD) { @@ -578,7 +578,7 @@ void p3DhtMgr::run() int p3DhtMgr::checkOwnDHTKeys() { int repubPeriod = 10000; - time_t now = time(NULL); + rstime_t now = time(NULL); /* in order of importance: * (1) Check for Own Key publish. @@ -777,12 +777,12 @@ int p3DhtMgr::checkPeerDHTKeys() /* iterate through and find min time and suitable candidate */ std::map::iterator it,pit; - time_t now = time(NULL); + rstime_t now = time(NULL); uint32_t period = 0; uint32_t repeatPeriod = 6000; pit = peers.end(); - time_t pTS = now; + rstime_t pTS = now; for(it = peers.begin(); it != peers.end(); it++) { @@ -792,7 +792,7 @@ int p3DhtMgr::checkPeerDHTKeys() continue; } - time_t delta = now - it->second.lastTS; + rstime_t delta = now - it->second.lastTS; if (it->second.state < DHT_PEER_FOUND) { period = DHT_SEARCH_PERIOD; @@ -866,7 +866,7 @@ int p3DhtMgr::checkNotifyDHT() /* iterate through and find min time and suitable candidate */ std::map::iterator it; - time_t now = time(NULL); + rstime_t now = time(NULL); int repeatPeriod = DHT_DEFAULT_PERIOD; /* find the first with a notify flag */ @@ -1084,7 +1084,7 @@ bool p3DhtMgr::getDhtBootstrapList() #endif dhtMtx.lock(); /* LOCK MUTEX */ - time_t now = time(NULL); + rstime_t now = time(NULL); if (now - mLastBootstrapListTS < DHT_MIN_BOOTSTRAP_REQ_PERIOD) { #ifdef DHT_DEBUG @@ -1623,7 +1623,7 @@ bool p3DhtMgr::dhtResultNotify(std::string idhash) std::cerr << RsUtil::BinToHex(idhash) << std::endl; #endif std::map::iterator it; - time_t now = time(NULL); + rstime_t now = time(NULL); /* if notify - we must match on the second hash */ for(it = peers.begin(); (it != peers.end()) && ((it->second).hash2 != idhash); it++) ; @@ -1679,7 +1679,7 @@ bool p3DhtMgr::dhtResultSearch(std::string idhash, bool doCb = false; bool doStun = false; uint32_t stunFlags = 0; - time_t now = time(NULL); + rstime_t now = time(NULL); dhtPeerEntry ent; diff --git a/libretroshare/src/pqi/p3dhtmgr.h b/libretroshare/src/pqi/p3dhtmgr.h index da36df5b2..c2b6675db 100644 --- a/libretroshare/src/pqi/p3dhtmgr.h +++ b/libretroshare/src/pqi/p3dhtmgr.h @@ -80,10 +80,10 @@ class dhtPeerEntry RsPeerId id; uint32_t state; - time_t lastTS; + rstime_t lastTS; uint32_t notifyPending; - time_t notifyTS; + rstime_t notifyTS; struct sockaddr_in laddr, raddr; uint32_t type; /* ADDR_TYPE as defined above */ @@ -231,17 +231,17 @@ std::string randomBootstrapId(); bool mDhtModifications; /* any user requests? */ dhtPeerEntry ownEntry; - time_t ownNotifyTS; + rstime_t ownNotifyTS; std::map peers; std::list stunIds; bool mStunRequired; uint32_t mDhtState; - time_t mDhtActiveTS; + rstime_t mDhtActiveTS; bool mBootstrapAllowed; - time_t mLastBootstrapListTS; + rstime_t mLastBootstrapListTS; }; diff --git a/libretroshare/src/pqi/p3historymgr.cc b/libretroshare/src/pqi/p3historymgr.cc index 00b36a505..fba1711ce 100644 --- a/libretroshare/src/pqi/p3historymgr.cc +++ b/libretroshare/src/pqi/p3historymgr.cc @@ -19,7 +19,7 @@ * along with this program. If not, see . * * * *******************************************************************************/ -#include +#include "util/rstime.h" #include "p3historymgr.h" #include "rsitems/rshistoryitems.h" @@ -68,7 +68,7 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm) { uint32_t addMsgId = 0; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(mLastCleanTime + MSG_HISTORY_CLEANING_PERIOD < now) { @@ -170,7 +170,7 @@ void p3HistoryMgr::cleanOldMessages() #ifdef HISTMGR_DEBUG std::cerr << "****** cleaning old messages." << std::endl; #endif - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; bool changed = false ; for(std::map >::iterator mit = mMessages.begin(); mit != mMessages.end();) diff --git a/libretroshare/src/pqi/p3historymgr.h b/libretroshare/src/pqi/p3historymgr.h index 897688fa8..d18dc5a45 100644 --- a/libretroshare/src/pqi/p3historymgr.h +++ b/libretroshare/src/pqi/p3historymgr.h @@ -88,7 +88,7 @@ private: uint32_t mPrivateSaveCount; uint32_t mMaxStorageDurationSeconds ; - time_t mLastCleanTime ; + rstime_t mLastCleanTime ; std::list saveCleanupList; /* TEMPORARY LIST WHEN SAVING */ diff --git a/libretroshare/src/pqi/p3linkmgr.cc b/libretroshare/src/pqi/p3linkmgr.cc index c380c205b..1d12476fc 100644 --- a/libretroshare/src/pqi/p3linkmgr.cc +++ b/libretroshare/src/pqi/p3linkmgr.cc @@ -327,9 +327,9 @@ void p3LinkMgrIMPL::statusTick() //std::list dummyToRemove; { - time_t now = time(NULL); - time_t oldavail = now - MAX_AVAIL_PERIOD; - time_t retry = now - mRetryPeriod; + rstime_t now = time(NULL); + rstime_t oldavail = now - MAX_AVAIL_PERIOD; + rstime_t retry = now - mRetryPeriod; RsStackMutex stack(mLinkMtx); /****** LOCK MUTEX ******/ std::map::iterator it; @@ -1080,7 +1080,7 @@ void p3LinkMgrIMPL::peerStatus(const RsPeerId& id, const pqiIpAddrSet &addrs, std::map::iterator it; bool isFriend = true; - time_t now = time(NULL); + rstime_t now = time(NULL); peerAddrInfo details; details.type = type; @@ -1658,7 +1658,7 @@ bool p3LinkMgrIMPL::retryConnectTCP(const RsPeerId &id) #define MAX_TCP_ADDR_AGE (3600 * 24 * 14) // two weeks in seconds. -bool p3LinkMgrIMPL::locked_CheckPotentialAddr(const struct sockaddr_storage &addr, time_t age) +bool p3LinkMgrIMPL::locked_CheckPotentialAddr(const struct sockaddr_storage &addr, rstime_t age) { #ifdef LINKMGR_DEBUG std::cerr << "p3LinkMgrIMPL::locked_CheckPotentialAddr("; @@ -1805,7 +1805,7 @@ void p3LinkMgrIMPL::locked_ConnectAttempt_HistoricalAddresses(peerConnectState /* now try historical addresses */ /* try local addresses first */ std::list::const_iterator ait; - time_t now = time(NULL); + rstime_t now = time(NULL); #ifdef LINKMGR_DEBUG std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_HistoricalAddresses()"; @@ -2206,7 +2206,7 @@ void p3LinkMgrIMPL::printPeerLists(std::ostream &out) return; } -bool p3LinkMgrIMPL::checkPotentialAddr(const sockaddr_storage &addr, time_t age) +bool p3LinkMgrIMPL::checkPotentialAddr(const sockaddr_storage &addr, rstime_t age) { RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/ diff --git a/libretroshare/src/pqi/p3linkmgr.h b/libretroshare/src/pqi/p3linkmgr.h index 57638c174..33267d635 100644 --- a/libretroshare/src/pqi/p3linkmgr.h +++ b/libretroshare/src/pqi/p3linkmgr.h @@ -24,7 +24,7 @@ #include "pqi/pqimonitor.h" #include "pqi/pqiipset.h" - +#include "util/rstime.h" #include "pqi/pqiassist.h" #include "pqi/p3cfgmgr.h" @@ -61,7 +61,7 @@ class peerAddrInfo bool found; uint32_t type; pqiIpAddrSet addrs; - time_t ts; + rstime_t ts; }; class peerConnectAddress @@ -74,7 +74,7 @@ class peerConnectAddress uint32_t period; /* UDP only */ uint32_t type; uint32_t flags; /* CB FLAGS defined in pqimonitor.h */ - time_t ts; + rstime_t ts; // Extra Parameters for Relay connections. struct sockaddr_storage proxyaddr; @@ -99,8 +99,8 @@ class peerConnectState uint32_t connecttype; // RS_NET_CONN_TCP_ALL / RS_NET_CONN_UDP_ALL bool actAsServer; - time_t lastavailable; - time_t lastattempt; + rstime_t lastavailable; + rstime_t lastattempt; std::string name; @@ -122,7 +122,7 @@ class peerConnectState /* information about denial */ bool wasDeniedConnection; - time_t deniedTS; + rstime_t deniedTS; bool deniedInConnAttempt; /* is below valid */ peerConnectAddress deniedConnectionAttempt; }; @@ -182,7 +182,7 @@ virtual bool getLocalAddress(struct sockaddr_storage &addr) = 0; virtual void getFriendList(std::list &ssl_peers) = 0; // ONLY used by p3peers.cc USE p3PeerMgr instead. virtual bool getFriendNetStatus(const RsPeerId &id, peerConnectState &state) = 0; // ONLY used by p3peers.cc -virtual bool checkPotentialAddr(const struct sockaddr_storage &addr, time_t age)=0; +virtual bool checkPotentialAddr(const struct sockaddr_storage &addr, rstime_t age)=0; /************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/ virtual int addFriend(const RsPeerId &ssl_id, bool isVisible) = 0; @@ -269,7 +269,7 @@ int removeFriend(const RsPeerId &ssl_id); void printPeerLists(std::ostream &out); -virtual bool checkPotentialAddr(const struct sockaddr_storage &addr, time_t age); +virtual bool checkPotentialAddr(const struct sockaddr_storage &addr, rstime_t age); protected: /* THESE CAN PROBABLY BE REMOVED */ //bool shutdown(); /* blocking shutdown call */ @@ -302,7 +302,7 @@ void locked_ConnectAttempt_ProxyAddress(peerConnectState *peer, const uint32_t bool locked_ConnectAttempt_Complete(peerConnectState *peer); -bool locked_CheckPotentialAddr(const struct sockaddr_storage &addr, time_t age); +bool locked_CheckPotentialAddr(const struct sockaddr_storage &addr, rstime_t age); bool addAddressIfUnique(std::list &addrList, peerConnectAddress &pca, bool pushFront); diff --git a/libretroshare/src/pqi/p3netmgr.cc b/libretroshare/src/pqi/p3netmgr.cc index 162370977..7776fb4bb 100644 --- a/libretroshare/src/pqi/p3netmgr.cc +++ b/libretroshare/src/pqi/p3netmgr.cc @@ -20,7 +20,7 @@ * along with this program. If not, see . * * * *******************************************************************************/ -#include +#include "util/rstime.h" #include #include "pqi/p3netmgr.h" @@ -415,7 +415,7 @@ void p3NetMgrIMPL::netStartup() void p3NetMgrIMPL::tick() { - time_t now = time(NULL); + rstime_t now = time(NULL); bool doSlowTick = false; { RsStackMutex stack(mNetMtx); /************** LOCK MUTEX ***************/ @@ -474,7 +474,7 @@ void p3NetMgrIMPL::netTick() checkNetAddress() ; uint32_t netStatus = 0; - time_t age = 0; + rstime_t age = 0; { RsStackMutex stack(mNetMtx); /************** LOCK MUTEX ***************/ @@ -605,7 +605,7 @@ void p3NetMgrIMPL::netUpnpCheck() /* grab timestamp */ mNetMtx.lock(); /* LOCK MUTEX */ - time_t delta = time(NULL) - mNetInitTS; + rstime_t delta = time(NULL) - mNetInitTS; #if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET) std::cerr << "p3NetMgrIMPL::netUpnpCheck() age: " << delta << std::endl; @@ -616,8 +616,8 @@ void p3NetMgrIMPL::netUpnpCheck() struct sockaddr_storage extAddr; int upnpState = netAssistFirewallActive(); - if (((upnpState == 0) && (delta > (time_t)MAX_UPNP_INIT)) || - ((upnpState > 0) && (delta > (time_t)MAX_UPNP_COMPLETE))) + if (((upnpState == 0) && (delta > (rstime_t)MAX_UPNP_INIT)) || + ((upnpState > 0) && (delta > (rstime_t)MAX_UPNP_COMPLETE))) { #if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET) std::cerr << "p3NetMgrIMPL::netUpnpCheck() "; diff --git a/libretroshare/src/pqi/p3netmgr.h b/libretroshare/src/pqi/p3netmgr.h index 56e9b1778..e16b035b8 100644 --- a/libretroshare/src/pqi/p3netmgr.h +++ b/libretroshare/src/pqi/p3netmgr.h @@ -334,7 +334,7 @@ void netStatusReset_locked(); uint16_t mVsDisc; uint16_t mVsDht; - time_t mNetInitTS; + rstime_t mNetInitTS; uint32_t mNetStatus; bool mStatusChanged; @@ -349,7 +349,7 @@ void netStatusReset_locked(); // Improved NetStatusBox, which uses the Stunners! pqiNetStateBox mNetStateBox; - time_t mLastSlowTickTime; + rstime_t mLastSlowTickTime; uint32_t mOldNatType; uint32_t mOldNatHole; diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index 305bf528c..c9e0efcea 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -289,11 +289,11 @@ bool p3PeerMgrIMPL::setOwnVisState(uint16_t vs_disc, uint16_t vs_dht) void p3PeerMgrIMPL::tick() { - static const time_t INTERVAL_BETWEEN_LOCATION_CLEANING = 300 ; // Remove unused locations and clean IPs every 10 minutes. + static const rstime_t INTERVAL_BETWEEN_LOCATION_CLEANING = 300 ; // Remove unused locations and clean IPs every 10 minutes. - static time_t last_friends_check = time(NULL) ; // first cleaning after 1 hour. + static rstime_t last_friends_check = time(NULL) ; // first cleaning after 1 hour. - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(now > INTERVAL_BETWEEN_LOCATION_CLEANING + last_friends_check ) { @@ -900,7 +900,7 @@ bool p3PeerMgrIMPL::haveOnceConnected() /*******************************************************************/ /*******************************************************************/ -bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg_id, uint32_t netMode, uint16_t vs_disc, uint16_t vs_dht, time_t lastContact,ServicePermissionFlags service_flags) +bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg_id, uint32_t netMode, uint16_t vs_disc, uint16_t vs_dht, rstime_t lastContact,ServicePermissionFlags service_flags) { bool notifyLinkMgr = false; RsPeerId id = input_id ; @@ -1718,7 +1718,7 @@ bool p3PeerMgrIMPL::getExtAddressReportedByFriends(sockaddr_storage &addr, uint8 static bool cleanIpList(std::list& lst,const RsPeerId& pid,p3LinkMgr *link_mgr) { bool changed = false ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; for(std::list::iterator it2(lst.begin());it2 != lst.end();) { @@ -2963,9 +2963,9 @@ bool p3PeerMgrIMPL::removeBannedIps() bool p3PeerMgrIMPL::removeUnusedLocations() { std::list toRemove; - std::map mostRecentTime; + std::map mostRecentTime; - const time_t now = time(NULL); + const rstime_t now = time(NULL); std::list pgpList ; @@ -2978,7 +2978,7 @@ bool p3PeerMgrIMPL::removeUnusedLocations() // First put a sensible number in all PGP ids for(std::list::const_iterator it = pgpList.begin(); it != pgpList.end(); ++it) - mostRecentTime[*it] = (time_t)0; + mostRecentTime[*it] = (rstime_t)0; #ifdef PEER_DEBUG std::cerr << "p3PeerMgr::removeUnusedLocations()" << std::endl; @@ -2987,7 +2987,7 @@ bool p3PeerMgrIMPL::removeUnusedLocations() for( std::map::iterator it = mFriendList.begin(); it != mFriendList.end(); ++it) { - time_t& bst(mostRecentTime[it->second.gpg_id]) ; + rstime_t& bst(mostRecentTime[it->second.gpg_id]) ; bst = std::max(bst,it->second.lastcontact) ; } diff --git a/libretroshare/src/pqi/p3peermgr.h b/libretroshare/src/pqi/p3peermgr.h index 70d74f141..36df3a629 100644 --- a/libretroshare/src/pqi/p3peermgr.h +++ b/libretroshare/src/pqi/p3peermgr.h @@ -65,8 +65,8 @@ const uint32_t RS_NET_FLAGS_TRUSTS_ME = 0x0020; * remove locations offline since 90 days * stopt sending locations via discovery when offline for +30 days */ -const time_t RS_PEER_OFFLINE_DELETE = (90 * 24 * 3600); -const time_t RS_PEER_OFFLINE_NO_DISC = (30 * 24 * 3600); +const rstime_t RS_PEER_OFFLINE_DELETE = (90 * 24 * 3600); +const rstime_t RS_PEER_OFFLINE_NO_DISC = (30 * 24 * 3600); class peerState { @@ -85,7 +85,7 @@ class peerState struct sockaddr_storage serveraddr; std::string dyndns; - time_t lastcontact; + rstime_t lastcontact; /* list of addresses from various sources */ pqiIpAddrSet ipAddrs; @@ -124,7 +124,7 @@ public: uint32_t netMode = RS_NET_MODE_UDP, uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL, - time_t lastContact = 0, + rstime_t lastContact = 0, ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT) ) = 0; virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId) = 0; @@ -241,7 +241,7 @@ public: virtual bool addFriend(const RsPeerId&ssl_id, const RsPgpId&gpg_id, uint32_t netMode = RS_NET_MODE_UDP, uint16_t vsDisc = RS_VS_DISC_FULL, uint16_t vsDht = RS_VS_DHT_FULL, - time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT)); + rstime_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_NODE_PERM_DEFAULT)); virtual bool removeFriend(const RsPeerId &ssl_id, bool removePgpId); virtual bool removeFriend(const RsPgpId &pgp_id); diff --git a/libretroshare/src/pqi/pqibin.h b/libretroshare/src/pqi/pqibin.h index b8cbb1c58..4887da343 100644 --- a/libretroshare/src/pqi/pqibin.h +++ b/libretroshare/src/pqi/pqibin.h @@ -25,6 +25,7 @@ #include "pqi/pqi_base.h" #include "pqi/pqihash.h" +#include "util/rstime.h" #include @@ -228,7 +229,7 @@ virtual RsFileHash gethash(); bool dummyConnected; bool toConnect; uint32_t connectDelta; - time_t connectTS; + rstime_t connectTS; }; diff --git a/libretroshare/src/pqi/pqihandler.cc b/libretroshare/src/pqi/pqihandler.cc index cb7d9f4a2..dcaac8f29 100644 --- a/libretroshare/src/pqi/pqihandler.cc +++ b/libretroshare/src/pqi/pqihandler.cc @@ -22,7 +22,7 @@ #include "pqi/pqihandler.h" #include // for NULL -#include // for time, time_t +#include "util/rstime.h" // for time, rstime_t #include // for sort #include // for dec #include // for string, char_traits, operator+, bas... @@ -121,7 +121,7 @@ int pqihandler::tick() #endif } - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(now > mLastRateCapUpdate + 5) { diff --git a/libretroshare/src/pqi/pqihandler.h b/libretroshare/src/pqi/pqihandler.h index 755b13cfd..31b51feed 100644 --- a/libretroshare/src/pqi/pqihandler.h +++ b/libretroshare/src/pqi/pqihandler.h @@ -23,7 +23,7 @@ #define MRK_PQI_HANDLER_HEADER #include // for uint32_t -#include // for time_t, NULL +#include "util/rstime.h" // for rstime_t, NULL #include // for list #include // for map @@ -121,8 +121,8 @@ protected: float rateTotal_out; uint32_t nb_ticks ; - time_t last_m ; - time_t mLastRateCapUpdate ; + rstime_t last_m ; + rstime_t mLastRateCapUpdate ; float ticks_per_sec ; }; diff --git a/libretroshare/src/pqi/pqiipset.cc b/libretroshare/src/pqi/pqiipset.cc index 8d9017442..6c273b47c 100644 --- a/libretroshare/src/pqi/pqiipset.cc +++ b/libretroshare/src/pqi/pqiipset.cc @@ -19,7 +19,7 @@ * along with this program. If not, see . * * * *******************************************************************************/ -#include +#include "util/rstime.h" #include "pqi/pqiipset.h" #include "util/rsstring.h" @@ -193,7 +193,7 @@ void pqiIpAddrList::loadTlv(RsTlvIpAddrSet &tlvAddrs) const void pqiIpAddrList::printIpAddressList(std::string &out) const { std::list::const_iterator it; - time_t now = time(NULL); + rstime_t now = time(NULL); for(it = mAddrs.begin(); it != mAddrs.end(); ++it) { out += sockaddr_storage_tostring(it->mAddr); diff --git a/libretroshare/src/pqi/pqiipset.h b/libretroshare/src/pqi/pqiipset.h index ef2d8a09a..9f6c31b17 100644 --- a/libretroshare/src/pqi/pqiipset.h +++ b/libretroshare/src/pqi/pqiipset.h @@ -24,6 +24,7 @@ #include "util/rsnet.h" #include "serialiser/rstlvaddrs.h" +#include "util/rstime.h" #define MAX_ADDRESS_LIST_SIZE 10 @@ -34,7 +35,7 @@ class pqiIpAddress bool validAddress() const; struct sockaddr_storage mAddr; - time_t mSeenTime; + rstime_t mSeenTime; uint32_t mSrc; }; diff --git a/libretroshare/src/pqi/pqinetstatebox.cc b/libretroshare/src/pqi/pqinetstatebox.cc index c10e5ed6d..5b711afea 100644 --- a/libretroshare/src/pqi/pqinetstatebox.cc +++ b/libretroshare/src/pqi/pqinetstatebox.cc @@ -23,7 +23,7 @@ #include "retroshare/rsconfig.h" #include "util/rsnet.h" #include "pqi/pqinetstatebox.h" -#include "time.h" +#include "util/rstime.h" #ifdef RS_USE_BITDHT #include "bitdht/bdiface.h" @@ -191,7 +191,7 @@ void pqiNetStateBox::reset() { mStatusOkay = false; - //time_t mStatusTS; + //rstime_t mStatusTS; mNetworkMode = RSNET_NETWORK_UNKNOWN; mNatTypeMode = RSNET_NATTYPE_UNKNOWN; @@ -244,7 +244,7 @@ int pqiNetStateBox::statusOkay() { return 0; } - time_t now = time(NULL); + rstime_t now = time(NULL); if (now - mStatusTS > NETSTATE_TIMEOUT) { return 0; @@ -268,7 +268,7 @@ void pqiNetStateBox::clearOldNetworkData() { #ifdef RS_USE_DHT_STUNNER /* check if any measurements are too old to consider */ - time_t now = time(NULL); + rstime_t now = time(NULL); if (now - mStunProxyTS > NETSTATE_PARAM_TIMEOUT) { mStunProxySet = false; @@ -292,7 +292,7 @@ void pqiNetStateBox::clearOldNetworkData() void pqiNetStateBox::determineNetworkState() { clearOldNetworkData(); - time_t now = time(NULL); + rstime_t now = time(NULL); /* now we use the remaining valid input to determine network state */ diff --git a/libretroshare/src/pqi/pqinetstatebox.h b/libretroshare/src/pqi/pqinetstatebox.h index 615099864..886b7d774 100644 --- a/libretroshare/src/pqi/pqinetstatebox.h +++ b/libretroshare/src/pqi/pqinetstatebox.h @@ -69,7 +69,7 @@ class pqiNetStateBox void workoutNetworkMode(); bool mStatusOkay; - time_t mStatusTS; + rstime_t mStatusTS; uint32_t mNetworkMode; uint32_t mNatTypeMode; @@ -80,35 +80,35 @@ class pqiNetStateBox /* Parameters set externally */ bool mStunDhtSet; - time_t mStunDhtTS; + rstime_t mStunDhtTS; bool mStunDhtStable; struct sockaddr_storage mStunDhtAddr; bool mStunProxySet; - time_t mStunProxyTS; + rstime_t mStunProxyTS; bool mStunProxyStable; bool mStunProxySemiStable; struct sockaddr_storage mStunProxyAddr; bool mDhtSet; - time_t mDhtTS; + rstime_t mDhtTS; bool mDhtOn; bool mDhtActive; bool mUPnPSet; struct sockaddr_storage mUPnPAddr; bool mUPnPActive; - time_t mUPnPTS; + rstime_t mUPnPTS; bool mNatPMPSet; struct sockaddr_storage mNatPMPAddr; bool mNatPMPActive; - time_t mNatPMPTS; + rstime_t mNatPMPTS; bool mWebIPSet; struct sockaddr_storage mWebIPAddr; bool mWebIPActive; - time_t mWebIPTS; + rstime_t mWebIPTS; bool mPortForwardSet; uint16_t mPortForwarded; diff --git a/libretroshare/src/pqi/pqiperson.h b/libretroshare/src/pqi/pqiperson.h index 895af2925..efd57176d 100644 --- a/libretroshare/src/pqi/pqiperson.h +++ b/libretroshare/src/pqi/pqiperson.h @@ -38,7 +38,7 @@ static const int CONNECT_UNREACHABLE = 3; static const int CONNECT_FIREWALLED = 4; static const int CONNECT_FAILED = 5; -static const time_t HEARTBEAT_REPEAT_TIME = 5; +static const rstime_t HEARTBEAT_REPEAT_TIME = 5; #include "pqi/pqiqosstreamer.h" #include "pqi/pqithreadstreamer.h" @@ -167,7 +167,7 @@ private: pqiconnect *activepqi; bool inConnectAttempt; //int waittimes; - time_t lastHeartbeatReceived; // use to track connection failure + rstime_t lastHeartbeatReceived; // use to track connection failure pqipersongrp *pqipg; /* parent for callback */ }; diff --git a/libretroshare/src/pqi/pqissl.cc b/libretroshare/src/pqi/pqissl.cc index 6e2e03a12..ab787e0c0 100644 --- a/libretroshare/src/pqi/pqissl.cc +++ b/libretroshare/src/pqi/pqissl.cc @@ -66,7 +66,7 @@ const int PQISSL_UDP_FLAG = 0x02; //#define PQISSL_LOG_DEBUG2 1 static const int PQISSL_MAX_READ_ZERO_COUNT = 20; -static const time_t PQISSL_MAX_READ_ZERO_TIME = 15; // 15 seconds of no data => reset. (atm HeartBeat pkt sent 5 secs) +static const rstime_t PQISSL_MAX_READ_ZERO_TIME = 15; // 15 seconds of no data => reset. (atm HeartBeat pkt sent 5 secs) static const int PQISSL_SSL_CONNECT_TIMEOUT = 30; diff --git a/libretroshare/src/pqi/pqissl.h b/libretroshare/src/pqi/pqissl.h index 712e06a11..4da1173b1 100644 --- a/libretroshare/src/pqi/pqissl.h +++ b/libretroshare/src/pqi/pqissl.h @@ -195,14 +195,14 @@ bool CheckConnectionTimeout(); int attempt_ts; int n_read_zero; /* a counter to determine if the connection is really dead */ - time_t mReadZeroTS; /* timestamp of first READ_ZERO occurance */ + rstime_t mReadZeroTS; /* timestamp of first READ_ZERO occurance */ int ssl_connect_timeout; /* timeout to ensure that we don't get stuck (can happen on udp!) */ uint32_t mConnectDelay; - time_t mConnectTS; + rstime_t mConnectTS; uint32_t mConnectTimeout; - time_t mTimeoutTS; + rstime_t mTimeoutTS; private: // ssl only fns. diff --git a/libretroshare/src/pqi/pqissllistener.cc b/libretroshare/src/pqi/pqissllistener.cc index 676ac8226..a80e9b572 100644 --- a/libretroshare/src/pqi/pqissllistener.cc +++ b/libretroshare/src/pqi/pqissllistener.cc @@ -658,7 +658,7 @@ int pqissllistenbase::finaliseAccepts() // for each of the incoming sockets.... call continue. std::list::iterator it; - time_t now = time(NULL); + rstime_t now = time(NULL); for(it = accepted_ssl.begin(); it != accepted_ssl.end();) { pqioutput(PQL_DEBUG_BASIC, pqissllistenzone, diff --git a/libretroshare/src/pqi/pqissllistener.h b/libretroshare/src/pqi/pqissllistener.h index 98e3a77e2..8b072d7c5 100644 --- a/libretroshare/src/pqi/pqissllistener.h +++ b/libretroshare/src/pqi/pqissllistener.h @@ -49,7 +49,7 @@ public: RsPeerId mPeerId; sockaddr_storage mAddr; - time_t mAcceptTS; + rstime_t mAcceptTS; }; diff --git a/libretroshare/src/pqi/pqistreamer.cc b/libretroshare/src/pqi/pqistreamer.cc index 9015492a3..92afd528c 100644 --- a/libretroshare/src/pqi/pqistreamer.cc +++ b/libretroshare/src/pqi/pqistreamer.cc @@ -24,7 +24,7 @@ #include // for gettimeofday #include // for free, realloc, exit #include // for memcpy, memset, memcmp -#include // for NULL, time, time_t +#include "util/rstime.h" // for NULL, time, rstime_t #include // for min #include // for operator<<, ostream, basic_ostream #include // for string, allocator, operator<<, oper... @@ -429,7 +429,7 @@ int pqistreamer::handleincomingitem_locked(RsItem *pqi,int len) void pqistreamer::locked_addTrafficClue(const RsItem *pqi,uint32_t pktsize,std::list& lst) { - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(now > mStatisticsTimeStamp) // new chunk => get rid of oldest, replace old list by current list, clear current list. { @@ -453,7 +453,7 @@ void pqistreamer::locked_addTrafficClue(const RsItem *pqi,uint32_t pktsize,std:: lst.push_back(tc) ; } -time_t pqistreamer::getLastIncomingTS() +rstime_t pqistreamer::getLastIncomingTS() { RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/ @@ -553,7 +553,7 @@ int pqistreamer::handleoutgoing_locked() // Checks for inserting a packet slicing probe. We do that to send the other peer the information that packet slicing can be used. // if so, we enable it for the session. This should be removed (because it's unnecessary) when all users have switched to the new version. - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(now > mLastSentPacketSlicingProbe + PQISTREAM_PACKET_SLICING_PROBE_DELAY) { diff --git a/libretroshare/src/pqi/pqistreamer.h b/libretroshare/src/pqi/pqistreamer.h index c9ab558cd..c5b2bc983 100644 --- a/libretroshare/src/pqi/pqistreamer.h +++ b/libretroshare/src/pqi/pqistreamer.h @@ -23,7 +23,7 @@ #define MRK_PQI_STREAMER_HEADER #include // for uint32_t -#include // for time_t +#include "util/rstime.h" // for rstime_t #include // for operator<<, basic_ostream, cerr, endl #include // for list #include // for map @@ -65,7 +65,7 @@ class pqistreamer: public PQInterface virtual RsItem *GetItem(); virtual int status(); - time_t getLastIncomingTS(); // Time of last data packet, for checking a connection is alive. + rstime_t getLastIncomingTS(); // Time of last data packet, for checking a connection is alive. virtual void getRates(RsBwRates &rates); virtual int getQueueSize(bool in); // extracting data. virtual int gatherStatistics(std::list& outqueue_stats,std::list& inqueue_stats); // extracting data. @@ -164,7 +164,7 @@ class pqistreamer: public PQInterface double mAvgDtOut; // average time diff between 2 rounds of sending data double mAvgDtIn; // average time diff between 2 rounds of receiving data - time_t mLastIncomingTs; + rstime_t mLastIncomingTs; // traffic statistics @@ -172,10 +172,10 @@ class pqistreamer: public PQInterface std::list mPreviousStatsChunk_Out ; std::list mCurrentStatsChunk_In ; std::list mCurrentStatsChunk_Out ; - time_t mStatisticsTimeStamp ; + rstime_t mStatisticsTimeStamp ; bool mAcceptsPacketSlicing ; - time_t mLastSentPacketSlicingProbe ; + rstime_t mLastSentPacketSlicingProbe ; void locked_addTrafficClue(const RsItem *pqi, uint32_t pktsize, std::list &lst); RsItem *addPartialPacket_locked(const void *block, uint32_t len, uint32_t slice_packet_id,bool packet_starting,bool packet_ending,uint32_t& total_len); diff --git a/libretroshare/src/retroshare/rsbanlist.h b/libretroshare/src/retroshare/rsbanlist.h index f60b129f9..194186b5f 100644 --- a/libretroshare/src/retroshare/rsbanlist.h +++ b/libretroshare/src/retroshare/rsbanlist.h @@ -22,6 +22,7 @@ #pragma once #include "util/rsnet.h" +#include "util/rstime.h" class RsBanList; extern RsBanList *rsBanList ; @@ -70,7 +71,7 @@ public: uint32_t level; // LOCAL, FRIEND, FoF. bool state ; // true=>active, false=>just stored but inactive int connect_attempts ; // recorded by the BanList service - time_t mTs; + rstime_t mTs; std::string comment ; // }; diff --git a/libretroshare/src/retroshare/rsconfig.h b/libretroshare/src/retroshare/rsconfig.h index f81ff780a..c1b3499b5 100644 --- a/libretroshare/src/retroshare/rsconfig.h +++ b/libretroshare/src/retroshare/rsconfig.h @@ -149,13 +149,13 @@ struct RsConfigDataRates : RsSerializable float mRateMaxIn; float mAllocIn; - time_t mAllocTs; + rstime_t mAllocTs; float mRateOut; float mRateMaxOut; float mAllowedOut; - time_t mAllowedTs; + rstime_t mAllowedTs; int mQueueIn; int mQueueOut; @@ -181,7 +181,7 @@ struct RsConfigDataRates : RsSerializable struct RSTrafficClue : RsSerializable { - time_t TS ; + rstime_t TS ; uint32_t size ; uint8_t priority ; uint16_t service_id ; diff --git a/libretroshare/src/retroshare/rsdht.h b/libretroshare/src/retroshare/rsdht.h index 022fb421b..309e851b9 100644 --- a/libretroshare/src/retroshare/rsdht.h +++ b/libretroshare/src/retroshare/rsdht.h @@ -93,9 +93,9 @@ class RsDhtPeer int mBucket; std::string mDhtId; std::string mAddr; - time_t mLastSendTime; - time_t mLastRecvTime; - time_t mFoundTime; + rstime_t mLastSendTime; + rstime_t mLastRecvTime; + rstime_t mFoundTime; uint32_t mPeerFlags; uint32_t mExtraFlags; }; @@ -132,7 +132,7 @@ class RsDhtRelayEnd std::string mLocalAddr; std::string mProxyAddr; std::string mRemoteAddr; - time_t mCreateTS; + rstime_t mCreateTS; }; class RsDhtRelayProxy @@ -145,11 +145,11 @@ class RsDhtRelayProxy double mBandwidth; int mRelayClass; - time_t mLastTS; - time_t mCreateTS; + rstime_t mLastTS; + rstime_t mCreateTS; //uint32_t mDataSize; - //time_t mLastBandwidthTS; + //rstime_t mLastBandwidthTS; }; class RsDhtFilteredPeer @@ -157,8 +157,8 @@ class RsDhtFilteredPeer public: struct sockaddr_in mAddr; uint32_t mFilterFlags; /* reasons why we are filtering */ - time_t mFilterTS; - time_t mLastSeen; + rstime_t mFilterTS; + rstime_t mLastSeen; }; class RsDht diff --git a/libretroshare/src/retroshare/rsexpr.h b/libretroshare/src/retroshare/rsexpr.h index 7c391a4be..562d6e342 100644 --- a/libretroshare/src/retroshare/rsexpr.h +++ b/libretroshare/src/retroshare/rsexpr.h @@ -24,8 +24,10 @@ #include #include #include + #include "util/rsprint.h" #include "retroshare/rstypes.h" +#include "util/rstime.h" /****************************************************************************************** Enumerations defining the Operators usable in the Boolean search expressions @@ -113,7 +115,7 @@ class ExpFileEntry public: virtual const std::string& file_name() const =0; virtual uint64_t file_size() const =0; - virtual time_t file_modtime() const =0; + virtual rstime_t file_modtime() const =0; virtual uint32_t file_popularity() const =0; virtual std::string file_parent_path() const =0; virtual const RsFileHash& file_hash() const =0; diff --git a/libretroshare/src/retroshare/rsfiles.h b/libretroshare/src/retroshare/rsfiles.h index 9d5231042..26aa8552c 100644 --- a/libretroshare/src/retroshare/rsfiles.h +++ b/libretroshare/src/retroshare/rsfiles.h @@ -30,6 +30,7 @@ #include "rstypes.h" #include "serialiser/rsserializable.h" #include "rsturtle.h" +#include "util/rstime.h" class RsFiles; @@ -187,7 +188,7 @@ struct BannedFileEntry uint64_t size ; std::string filename ; - time_t ban_time_stamp; + rstime_t ban_time_stamp; }; class RsFiles @@ -339,7 +340,7 @@ public: virtual bool turtleSearchRequest( const std::string& matchString, const std::function& results)>& multiCallback, - std::time_t maxWait = 300 ) = 0; + rstime_t maxWait = 300 ) = 0; virtual TurtleRequestId turtleSearch(const std::string& string_to_match) = 0; virtual TurtleRequestId turtleSearch( diff --git a/libretroshare/src/retroshare/rsgrouter.h b/libretroshare/src/retroshare/rsgrouter.h index f9a316a40..cfb83bea3 100644 --- a/libretroshare/src/retroshare/rsgrouter.h +++ b/libretroshare/src/retroshare/rsgrouter.h @@ -46,9 +46,9 @@ public: GRouterMsgPropagationId mid ; std::set local_origin; GRouterKeyId destination ; - time_t routing_time; - time_t last_tunnel_attempt_time; - time_t last_sent_time; + rstime_t routing_time; + rstime_t last_tunnel_attempt_time; + rstime_t last_sent_time; bool receipt_available ; uint32_t duplication_factor ; uint32_t data_status ; diff --git a/libretroshare/src/retroshare/rsgxschannels.h b/libretroshare/src/retroshare/rsgxschannels.h index 31bad28b4..be78a8c80 100644 --- a/libretroshare/src/retroshare/rsgxschannels.h +++ b/libretroshare/src/retroshare/rsgxschannels.h @@ -286,7 +286,7 @@ public: virtual bool turtleSearchRequest( const std::string& matchString, const std::function& multiCallback, - std::time_t maxWait = 300 ) = 0; + rstime_t maxWait = 300 ) = 0; ////////////////////////////////////////////////////////////////////////////// /// Distant synchronisation methods /// diff --git a/libretroshare/src/retroshare/rsgxsdistsync.h b/libretroshare/src/retroshare/rsgxsdistsync.h index df597f03a..ab54318b2 100644 --- a/libretroshare/src/retroshare/rsgxsdistsync.h +++ b/libretroshare/src/retroshare/rsgxsdistsync.h @@ -39,7 +39,7 @@ struct RsGxsNetTunnelVirtualPeerInfo virtual ~RsGxsNetTunnelVirtualPeerInfo(){} uint8_t vpid_status ; // status of the peer - time_t last_contact ; // last time some data was sent/recvd + rstime_t last_contact ; // last time some data was sent/recvd uint8_t side ; // client/server uint8_t encryption_master_key[32]; @@ -68,7 +68,7 @@ struct RsGxsNetTunnelGroupInfo GroupPolicy group_policy ; GroupStatus group_status ; - time_t last_contact ; + rstime_t last_contact ; RsFileHash hash ; uint16_t service_id ; diff --git a/libretroshare/src/retroshare/rsgxsiface.h b/libretroshare/src/retroshare/rsgxsiface.h index 7fbf4b691..70876861d 100644 --- a/libretroshare/src/retroshare/rsgxsiface.h +++ b/libretroshare/src/retroshare/rsgxsiface.h @@ -49,9 +49,9 @@ struct RsGxsGroupSummary : RsSerializable RsGxsGroupId mGroupId; std::string mGroupName; RsGxsId mAuthorId; - time_t mPublishTs; + rstime_t mPublishTs; uint32_t mNumberOfMessages; - time_t mLastMessageTs; + rstime_t mLastMessageTs; uint32_t mSignFlags; uint32_t mPopularity; diff --git a/libretroshare/src/retroshare/rsgxsifacetypes.h b/libretroshare/src/retroshare/rsgxsifacetypes.h index 1ee523b6a..72f290c2f 100644 --- a/libretroshare/src/retroshare/rsgxsifacetypes.h +++ b/libretroshare/src/retroshare/rsgxsifacetypes.h @@ -32,6 +32,7 @@ #include "retroshare/rsids.h" #include "serialiser/rsserializable.h" #include "serialiser/rstypeserializer.h" +#include "util/rstime.h" typedef GXSGroupId RsGxsGroupId; typedef Sha1CheckSum RsGxsMessageId; @@ -67,7 +68,7 @@ struct RsGroupMetaData : RsSerializable uint32_t mGroupFlags; // Combination of FLAG_PRIVACY_PRIVATE | FLAG_PRIVACY_RESTRICTED | FLAG_PRIVACY_PUBLIC: diffusion uint32_t mSignFlags; // Combination of RSGXS_GROUP_SIGN_PUBLISH_MASK & RSGXS_GROUP_SIGN_AUTHOR_MASK, i.e. what signatures are required for parent and child msgs - time_t mPublishTs; // Mandatory. + rstime_t mPublishTs; // Mandatory. RsGxsId mAuthorId; // Author of the group. Left to "000....0" if anonymous // for circles @@ -84,7 +85,7 @@ struct RsGroupMetaData : RsSerializable uint32_t mPop; // Popularity = number of friend subscribers uint32_t mVisibleMsgCount; // Max messages reported by friends - time_t mLastPost; // Timestamp for last message. Not used yet. + rstime_t mLastPost; // Timestamp for last message. Not used yet. uint32_t mGroupStatus; std::string mServiceString; // Service Specific Free-Form extra storage. @@ -136,7 +137,7 @@ struct RsMsgMetaData : RsSerializable RsGxsId mAuthorId; std::string mMsgName; - time_t mPublishTs; + rstime_t mPublishTs; /// the lower 16 bits for service, upper 16 bits for GXS uint32_t mMsgFlags; @@ -147,7 +148,7 @@ struct RsMsgMetaData : RsSerializable /// the first 16 bits for service, last 16 for GXS uint32_t mMsgStatus; - time_t mChildTs; + rstime_t mChildTs; std::string mServiceString; // Service Specific Free-Form extra storage. /// @see RsSerializable diff --git a/libretroshare/src/retroshare/rsidentity.h b/libretroshare/src/retroshare/rsidentity.h index 84688c142..98a7b8f05 100644 --- a/libretroshare/src/retroshare/rsidentity.h +++ b/libretroshare/src/retroshare/rsidentity.h @@ -134,7 +134,7 @@ struct RsGxsIdGroup : RsSerializable // Avatar RsGxsImage mImage ; - time_t mLastUsageTS ; + rstime_t mLastUsageTS ; // Not Serialised - for GUI's benefit. bool mPgpKnown; @@ -168,8 +168,8 @@ struct RsRecognTagDetails valid_from(0), valid_to(0), tag_class(0), tag_type(0), is_valid(false), is_pending(false) {} - time_t valid_from; - time_t valid_to; + rstime_t valid_from; + rstime_t valid_to; uint16_t tag_class; uint16_t tag_type; @@ -315,9 +315,9 @@ struct RsIdentityDetails : RsSerializable RsGxsImage mAvatar; - time_t mLastUsageTS; + rstime_t mLastUsageTS; - std::map mUseCases; + std::map mUseCases; /// @see RsSerializable virtual void serial_process(RsGenericSerializer::SerializeJob j, @@ -390,7 +390,7 @@ struct RsIdentity : RsGxsIfaceHelper * \param id * \return */ - virtual time_t getLastUsageTS(const RsGxsId &id) =0; + virtual rstime_t getLastUsageTS(const RsGxsId &id) =0; // Specific RsIdentity Functions.... /* Specific Service Data */ diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index a459a489c..7bb64f3db 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -153,7 +153,7 @@ class MessageInfo_v2 // std::string subject; std::string msg; - time_t time_stamp ; + rstime_t time_stamp ; //std::list headers ; @@ -214,7 +214,7 @@ class MsgInfoSummary std::string title; int count; /* file count */ - time_t ts; + rstime_t ts; }; @@ -382,7 +382,7 @@ public: std::set participating_friends ; // list of direct friend who participate. uint32_t total_number_of_peers ; // total number of particpating peers. Might not be - time_t last_report_time ; // last time the lobby was reported. + rstime_t last_report_time ; // last time the lobby was reported. ChatLobbyFlags lobby_flags ; // see RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC / RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE // RsSerializable interface @@ -410,8 +410,8 @@ public: RsGxsId gxs_id ; // ID to sign messages ChatLobbyFlags lobby_flags ; // see RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC / RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE - std::map gxs_ids ; // list of non direct friend who participate. Used to display only. - time_t last_activity ; // last recorded activity. Useful for removing dead lobbies. + std::map gxs_ids ; // list of non direct friend who participate. Used to display only. + rstime_t last_activity ; // last recorded activity. Useful for removing dead lobbies. // RsSerializable interface public: diff --git a/libretroshare/src/retroshare/rspeers.h b/libretroshare/src/retroshare/rspeers.h index 04634166a..91053941d 100644 --- a/libretroshare/src/retroshare/rspeers.h +++ b/libretroshare/src/retroshare/rspeers.h @@ -30,6 +30,7 @@ #include "retroshare/rsids.h" #include "util/rsurl.h" #include "util/rsdeprecate.h" +#include "util/rstime.h" class RsPeers; @@ -272,7 +273,7 @@ struct RsPeerDetails : RsSerializable /* have we been denied */ bool wasDeniedConnection; - time_t deniedTS; + rstime_t deniedTS; /* linkType */ uint32_t linkType; diff --git a/libretroshare/src/retroshare/rsplugin.h b/libretroshare/src/retroshare/rsplugin.h index af553b785..c8d3364ff 100644 --- a/libretroshare/src/retroshare/rsplugin.h +++ b/libretroshare/src/retroshare/rsplugin.h @@ -21,7 +21,7 @@ *******************************************************************************/ #pragma once -#include +#include "util/rstime.h" #include #include #include @@ -236,7 +236,7 @@ class RsPluginHandler virtual void allowAllPlugins(bool b) = 0 ; virtual bool getAllowAllPlugins() const = 0 ; - virtual void slowTickPlugins(time_t sec) = 0 ; + virtual void slowTickPlugins(rstime_t sec) = 0 ; virtual const std::string& getLocalCacheDir() const =0; virtual const std::string& getRemoteCacheDir() const =0; diff --git a/libretroshare/src/retroshare/rsposted.h b/libretroshare/src/retroshare/rsposted.h index 12d729d7a..60b510d55 100644 --- a/libretroshare/src/retroshare/rsposted.h +++ b/libretroshare/src/retroshare/rsposted.h @@ -119,7 +119,7 @@ class RsPostedPost mNewScore = 0; } - bool calculateScores(time_t ref_time); + bool calculateScores(rstime_t ref_time); RsMsgMetaData mMeta; std::string mLink; diff --git a/libretroshare/src/retroshare/rsstatus.h b/libretroshare/src/retroshare/rsstatus.h index 4698cd8b5..42d90b17d 100644 --- a/libretroshare/src/retroshare/rsstatus.h +++ b/libretroshare/src/retroshare/rsstatus.h @@ -57,7 +57,7 @@ class StatusInfo public: RsPeerId id; uint32_t status; - time_t time_stamp; /// for owner time set, and for their peers time sent + rstime_t time_stamp; /// for owner time set, and for their peers time sent }; diff --git a/libretroshare/src/retroshare/rstokenservice.h b/libretroshare/src/retroshare/rstokenservice.h index 90c0694e6..58314c62f 100644 --- a/libretroshare/src/retroshare/rstokenservice.h +++ b/libretroshare/src/retroshare/rstokenservice.h @@ -103,8 +103,8 @@ struct RsTokReqOptions uint32_t mSubscribeFilter, mSubscribeMask; // Only for Groups. // Time range... again applied after Options. - time_t mBefore; - time_t mAfter; + rstime_t mBefore; + rstime_t mAfter; }; std::ostream &operator<<(std::ostream &out, const RsGroupMetaData &meta); diff --git a/libretroshare/src/retroshare/rstypes.h b/libretroshare/src/retroshare/rstypes.h index 71a994cc1..e7bed4d21 100644 --- a/libretroshare/src/retroshare/rstypes.h +++ b/libretroshare/src/retroshare/rstypes.h @@ -33,6 +33,7 @@ #include #include #include +#include "util/rstime.h" #define USE_NEW_CHUNK_CHECKING_CODE @@ -225,7 +226,7 @@ struct FileInfo : RsSerializable std::vector peers; DwlSpeed priority; - time_t lastTS; + rstime_t lastTS; std::list parent_groups; diff --git a/libretroshare/src/rsitems/rsbanlistitems.cc b/libretroshare/src/rsitems/rsbanlistitems.cc index f5dd9fca8..f283f5b43 100644 --- a/libretroshare/src/rsitems/rsbanlistitems.cc +++ b/libretroshare/src/rsitems/rsbanlistitems.cc @@ -46,7 +46,7 @@ void RsBanListConfigItem::serial_process(RsGenericSerializer::SerializeJob j,RsG { RsTypeSerializer::serial_process(j,ctx,banListType,"type") ; RsTypeSerializer::serial_process (j,ctx,banListPeerId,"peerId") ; - RsTypeSerializer::serial_process (j,ctx,update_time,"update_time") ; + RsTypeSerializer::serial_process (j,ctx,update_time,"update_time") ; RsTypeSerializer::serial_process (j,ctx,banned_peers,"banned_peers") ; } RsItem *RsBanListSerialiser::create_item(uint16_t service_id,uint8_t item_sub_id) const diff --git a/libretroshare/src/rsitems/rsbanlistitems.h b/libretroshare/src/rsitems/rsbanlistitems.h index 2f22a199e..6422340af 100644 --- a/libretroshare/src/rsitems/rsbanlistitems.h +++ b/libretroshare/src/rsitems/rsbanlistitems.h @@ -68,7 +68,7 @@ public: uint32_t banListType ; RsPeerId banListPeerId ; - time_t update_time ; + rstime_t update_time ; RsTlvBanList banned_peers; }; diff --git a/libretroshare/src/rsitems/rsgxsiditems.h b/libretroshare/src/rsitems/rsgxsiditems.h index 61c7500f3..bfcca0946 100644 --- a/libretroshare/src/rsitems/rsgxsiditems.h +++ b/libretroshare/src/rsitems/rsgxsiditems.h @@ -79,7 +79,7 @@ public: virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); - std::map mTimeStamps ; + std::map mTimeStamps ; std::set mContacts ; }; diff --git a/libretroshare/src/rsitems/rsgxsitems.h b/libretroshare/src/rsitems/rsgxsitems.h index 22135f5e5..efc11afbb 100644 --- a/libretroshare/src/rsitems/rsgxsitems.h +++ b/libretroshare/src/rsitems/rsgxsitems.h @@ -25,7 +25,7 @@ #include "rsitems/rsitem.h" #include "rsitems/rsserviceids.h" - +#include "util/rstime.h" #include "retroshare/rsgxsifacetypes.h" std::ostream &operator<<(std::ostream &out, const RsGroupMetaData &meta); @@ -99,7 +99,7 @@ struct TurtleGxsInfo RsGxsId author; std::string name ; std::string description ; - time_t last_post ; + rstime_t last_post ; uint32_t number_of_posts ; }; diff --git a/libretroshare/src/rsitems/rsgxsreputationitems.cc b/libretroshare/src/rsitems/rsgxsreputationitems.cc index 9aa8c6e9c..97d33e3d1 100644 --- a/libretroshare/src/rsitems/rsgxsreputationitems.cc +++ b/libretroshare/src/rsitems/rsgxsreputationitems.cc @@ -20,7 +20,7 @@ * * *******************************************************************************/ #include -#include +#include "util/rstime.h" #include "serialiser/rsbaseserial.h" #include "rsitems/rsgxsreputationitems.h" diff --git a/libretroshare/src/rsitems/rsgxsupdateitems.h b/libretroshare/src/rsitems/rsgxsupdateitems.h index 0ac06920d..9e7a194ac 100644 --- a/libretroshare/src/rsitems/rsgxsupdateitems.h +++ b/libretroshare/src/rsitems/rsgxsupdateitems.h @@ -67,8 +67,8 @@ public: RsTlvPeerIdSet suppliers; // list of friends who feed this group uint32_t max_visible_count ; // max visible count reported by contributing friends - time_t statistics_update_TS ; // last time the max visible count was updated. - time_t last_group_modification_TS ; // last time the group was modified, either in meta data or in the list of messages posted in it. + rstime_t statistics_update_TS ; // last time the max visible count was updated. + rstime_t last_group_modification_TS ; // last time the group was modified, either in meta data or in the list of messages posted in it. }; class RsGxsGrpConfigItem : public RsGxsNetServiceItem, public RsGxsGrpConfig diff --git a/libretroshare/src/rsitems/rsmsgitems.cc b/libretroshare/src/rsitems/rsmsgitems.cc index 32d32dd06..99fc342a5 100644 --- a/libretroshare/src/rsitems/rsmsgitems.cc +++ b/libretroshare/src/rsitems/rsmsgitems.cc @@ -20,7 +20,7 @@ * * *******************************************************************************/ #include -#include +#include "util/rstime.h" #include "serialiser/rsbaseserial.h" #include "serialiser/rstlvbase.h" diff --git a/libretroshare/src/rsserver/p3face-config.cc b/libretroshare/src/rsserver/p3face-config.cc index f01d4589b..da998a16a 100644 --- a/libretroshare/src/rsserver/p3face-config.cc +++ b/libretroshare/src/rsserver/p3face-config.cc @@ -39,7 +39,7 @@ #endif // ifdef RS_JSONAPI #include -#include +#include "util/rstime.h" #include "pqi/p3peermgr.h" #include "pqi/p3netmgr.h" diff --git a/libretroshare/src/rsserver/p3face-server.cc b/libretroshare/src/rsserver/p3face-server.cc index 9be996372..a66be6aa5 100644 --- a/libretroshare/src/rsserver/p3face-server.cc +++ b/libretroshare/src/rsserver/p3face-server.cc @@ -34,7 +34,7 @@ #include "pqi/authssl.h" #include -#include +#include "util/rstime.h" #include "pqi/p3peermgr.h" #include "pqi/p3linkmgr.h" @@ -51,7 +51,7 @@ int rsserverzone = 101; #define WARN_BIG_CYCLE_TIME (0.2) #ifdef WINDOWS_SYS -#include +#include "util/rstime.h" #include #endif @@ -251,7 +251,7 @@ void RsServer::data_tick() /* Tick slow services */ if(rsPlugins) - rsPlugins->slowTickPlugins((time_t)ts); + rsPlugins->slowTickPlugins((rstime_t)ts); // slow update tick as well. // update(); diff --git a/libretroshare/src/rsserver/p3msgs.cc b/libretroshare/src/rsserver/p3msgs.cc index da2220912..ca113f5c1 100644 --- a/libretroshare/src/rsserver/p3msgs.cc +++ b/libretroshare/src/rsserver/p3msgs.cc @@ -26,7 +26,7 @@ //const int p3facemsgzone = 11453; #include -#include +#include "util/rstime.h" #include "retroshare/rstypes.h" #include "rsserver/p3msgs.h" diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index 616884248..d2493d49a 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -745,7 +745,7 @@ bool p3Peers::addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePe * If we are adding an SSL certificate. we flag lastcontact as now. * This will cause the SSL certificate to be retained for 30 days... and give the person a chance to connect! * */ - time_t now = time(NULL); + rstime_t now = time(NULL); return mPeerMgr->addFriend(ssl_id, gpg_id, RS_NET_MODE_UDP, RS_VS_DISC_FULL, RS_VS_DHT_FULL, now, perm_flags); } diff --git a/libretroshare/src/rsserver/rstypes.cc b/libretroshare/src/rsserver/rstypes.cc index 4574c48e8..d804bf6e9 100644 --- a/libretroshare/src/rsserver/rstypes.cc +++ b/libretroshare/src/rsserver/rstypes.cc @@ -32,7 +32,7 @@ #include "retroshare/rstypes.h" #include #include -#include +#include "util/rstime.h" /********************************************************************** diff --git a/libretroshare/src/serialiser/rsbaseserial.cc b/libretroshare/src/serialiser/rsbaseserial.cc index 65528c801..58dadcdb3 100644 --- a/libretroshare/src/serialiser/rsbaseserial.cc +++ b/libretroshare/src/serialiser/rsbaseserial.cc @@ -287,7 +287,7 @@ bool setRawString(void *data, uint32_t size, uint32_t *offset, const std::string return true; } -bool getRawTimeT(const void *data,uint32_t size,uint32_t *offset,time_t& t) +bool getRawTimeT(const void *data,uint32_t size,uint32_t *offset,rstime_t& t) { uint64_t T ; bool res = getRawUInt64(data,size,offset,&T) ; @@ -295,7 +295,7 @@ bool getRawTimeT(const void *data,uint32_t size,uint32_t *offset,time_t& t) return res ; } -bool setRawTimeT(void *data, uint32_t size, uint32_t *offset, const time_t& t) +bool setRawTimeT(void *data, uint32_t size, uint32_t *offset, const rstime_t& t) { return setRawUInt64(data,size,offset,t) ; } diff --git a/libretroshare/src/serialiser/rsbaseserial.h b/libretroshare/src/serialiser/rsbaseserial.h index 512feb393..839932927 100644 --- a/libretroshare/src/serialiser/rsbaseserial.h +++ b/libretroshare/src/serialiser/rsbaseserial.h @@ -25,7 +25,9 @@ #include #include #include -#include + +#include "retroshare/rsids.h" +#include "util/rstime.h" /******************************************************************* * This is at the lowlevel packing routines. They are usually @@ -63,8 +65,8 @@ uint32_t getRawStringSize(const std::string &outStr); bool getRawString(const void *data, uint32_t size, uint32_t *offset, std::string &outStr); bool setRawString(void *data, uint32_t size, uint32_t *offset, const std::string &inStr); -bool getRawTimeT(const void *data, uint32_t size, uint32_t *offset, time_t& outStr); -bool setRawTimeT(void *data, uint32_t size, uint32_t *offset, const time_t& inStr); +bool getRawTimeT(const void *data, uint32_t size, uint32_t *offset, rstime_t& outTime); +bool setRawTimeT(void *data, uint32_t size, uint32_t *offset, const rstime_t& inTime); #endif diff --git a/libretroshare/src/serialiser/rsmailtransportitems.cc b/libretroshare/src/serialiser/rsmailtransportitems.cc index c5594b02a..c7a64fd8e 100644 --- a/libretroshare/src/serialiser/rsmailtransportitems.cc +++ b/libretroshare/src/serialiser/rsmailtransportitems.cc @@ -25,7 +25,7 @@ */ #include -#include +#include "util/rstime.h" #include "serialiser/rsbaseserial.h" #include "serialiser/rsmailtransportitems.h" #include "serialiser/rstlvbase.h" diff --git a/libretroshare/src/serialiser/rsserial.cc b/libretroshare/src/serialiser/rsserial.cc index 0a1a7503f..dda560867 100644 --- a/libretroshare/src/serialiser/rsserial.cc +++ b/libretroshare/src/serialiser/rsserial.cc @@ -75,7 +75,7 @@ class Counter static int total_rsitem_mallocs = 0 ; static int total_rsitem_frees = 0 ; static int total_rsitem_freed = 0 ; - static time_t last_time = 0 ; + static rstime_t last_time = 0 ; void *RsItem::operator new(size_t s) { @@ -85,7 +85,7 @@ void *RsItem::operator new(size_t s) ++size_hits[ s ].v() ; - time_t now = time(NULL); + rstime_t now = time(NULL); ++nb_rsitem_creations ; total_rsitem_mallocs += s ; diff --git a/libretroshare/src/serialiser/rsserializer.h b/libretroshare/src/serialiser/rsserializer.h index 40ccc35e9..e9b60a0aa 100644 --- a/libretroshare/src/serialiser/rsserializer.h +++ b/libretroshare/src/serialiser/rsserializer.h @@ -85,7 +85,7 @@ // // private: // uint32_t count ; // example of an int type. All int sizes are supported -// std::map update_times ; // example of a std::map. All std containers are supported. +// std::map update_times ; // example of a std::map. All std containers are supported. // RsTlvSecurityKey key ; // example of a TlvItem class. // BIGNUM *dh_key; // example of a class that needs its own serializer (see below) // }; diff --git a/libretroshare/src/serialiser/rstypeserializer.cc b/libretroshare/src/serialiser/rstypeserializer.cc index f620f7af0..cb8f1c972 100644 --- a/libretroshare/src/serialiser/rstypeserializer.cc +++ b/libretroshare/src/serialiser/rstypeserializer.cc @@ -27,9 +27,9 @@ #include "serialiser/rsserializable.h" #include "util/radix64.h" #include "util/rsprint.h" +#include "util/rstime.h" #include -#include #include #include // for typeid @@ -93,7 +93,7 @@ template<> bool RsTypeSerializer::serialize(uint8_t data[], uint32_t size, uint3 { return setRawUInt64(data,size,&offset,member); } -template<> bool RsTypeSerializer::serialize(uint8_t data[], uint32_t size, uint32_t &offset, const time_t& member) +template<> bool RsTypeSerializer::serialize(uint8_t data[], uint32_t size, uint32_t &offset, const rstime_t& member) { return setRawTimeT(data,size,&offset,member); } @@ -127,7 +127,7 @@ template<> bool RsTypeSerializer::deserialize(const uint8_t data[], uint32_t siz { return getRawUInt64(data,size,&offset,&member); } -template<> bool RsTypeSerializer::deserialize(const uint8_t data[], uint32_t size, uint32_t &offset, time_t& member) +template<> bool RsTypeSerializer::deserialize(const uint8_t data[], uint32_t size, uint32_t &offset, rstime_t& member) { return getRawTimeT(data,size,&offset,member); } @@ -158,7 +158,7 @@ template<> uint32_t RsTypeSerializer::serial_size(const uint64_t& /* member*/) { return 8; } -template<> uint32_t RsTypeSerializer::serial_size(const time_t& /* member*/) +template<> uint32_t RsTypeSerializer::serial_size(const rstime_t& /* member*/) { return 8; } @@ -187,9 +187,9 @@ template<> void RsTypeSerializer::print_data(const std::string& n, const uint64_ { std::cerr << " [uint64_t ] " << n << ": " << std::to_string(V) << std::endl; } -template<> void RsTypeSerializer::print_data(const std::string& n, const time_t& V) +template<> void RsTypeSerializer::print_data(const std::string& n, const rstime_t& V) { - std::cerr << " [time_t ] " << n << ": " << V << " (" << time(NULL)-V << " secs ago)" << std::endl; + std::cerr << " [rstime_t ] " << n << ": " << V << " (" << time(NULL)-V << " secs ago)" << std::endl; } #define SIMPLE_TO_JSON_DEF(T) \ @@ -210,23 +210,7 @@ template<> bool RsTypeSerializer::to_JSON( const std::string& memberName, \ SIMPLE_TO_JSON_DEF(bool) SIMPLE_TO_JSON_DEF(int32_t) - -template<> bool RsTypeSerializer::to_JSON( const std::string& memberName, - const time_t& member, RsJson& jDoc ) -{ - rapidjson::Document::AllocatorType& allocator = jDoc.GetAllocator(); - - rapidjson::Value key; - key.SetString(memberName.c_str(), memberName.length(), allocator); - - // without this compilation may break depending on how time_t is defined - int64_t tValue = member; - rapidjson::Value value(tValue); - - jDoc.AddMember(key, value, allocator); - - return true; -} +SIMPLE_TO_JSON_DEF(rstime_t) SIMPLE_TO_JSON_DEF(uint8_t) SIMPLE_TO_JSON_DEF(uint16_t) @@ -254,12 +238,12 @@ bool RsTypeSerializer::from_JSON( const std::string& memberName, } template<> /*static*/ -bool RsTypeSerializer::from_JSON( const std::string& memberName, time_t& member, +bool RsTypeSerializer::from_JSON( const std::string& memberName, rstime_t& member, RsJson& jDoc ) { SAFE_GET_JSON_V(); - ret = ret && v.IsInt(); - if(ret) member = v.GetInt(); + ret = ret && v.IsInt64(); + if(ret) member = v.GetInt64(); return ret; } diff --git a/libretroshare/src/services/autoproxy/p3i2pbob.cc b/libretroshare/src/services/autoproxy/p3i2pbob.cc index 390477127..edb09d015 100644 --- a/libretroshare/src/services/autoproxy/p3i2pbob.cc +++ b/libretroshare/src/services/autoproxy/p3i2pbob.cc @@ -58,7 +58,7 @@ static const int sleepFactorSlow = 20; // 1s static struct RsLog::logInfo i2pBobLogInfo = {RsLog::Default, "p3I2pBob"}; -static const time_t selfCheckPeroid = 30; +static const rstime_t selfCheckPeroid = 30; void doSleep(useconds_t timeToSleepMS) { rstime::rs_usleep((useconds_t) (timeToSleepMS * 1000)); diff --git a/libretroshare/src/services/autoproxy/p3i2pbob.h b/libretroshare/src/services/autoproxy/p3i2pbob.h index 27b911262..7bdfe953c 100644 --- a/libretroshare/src/services/autoproxy/p3i2pbob.h +++ b/libretroshare/src/services/autoproxy/p3i2pbob.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include "util/rstime.h" #ifndef WINDOWS_SYS #include #endif @@ -255,7 +255,7 @@ private: p3PeerMgr *mPeerMgr; bool mConfigLoaded; int mSocket; - time_t mLastProxyCheck; + rstime_t mLastProxyCheck; sockaddr_storage mI2PProxyAddr; std::map mCommands; std::string mErrorMsg; diff --git a/libretroshare/src/services/p3banlist.cc b/libretroshare/src/services/p3banlist.cc index eca5afb20..f55343889 100644 --- a/libretroshare/src/services/p3banlist.cc +++ b/libretroshare/src/services/p3banlist.cc @@ -225,7 +225,7 @@ void p3BanList::autoFigureOutBanRanges() for(std::map::iterator it(mBanSet.begin());it!=mBanSet.end();++it) ++range_map[makeBitsRange(it->first,1)].n ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; for(std::map::const_iterator it=range_map.begin();it!=range_map.end();++it) { @@ -561,7 +561,7 @@ int p3BanList::tick() processIncoming(); sendPackets(); - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(mLastDhtInfoRequest + RSBANLIST_DELAY_BETWEEN_TALK_TO_DHT < now) { @@ -574,7 +574,7 @@ int p3BanList::tick() } #ifdef DEBUG_BANLIST - static time_t last_print = 0 ; + static rstime_t last_print = 0 ; if(now > 10+last_print) { @@ -676,7 +676,7 @@ bool p3BanList::recvBanItem(RsBanListItem *item) { bool updated = false; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; std::list::const_iterator it; for(it = item->peerList.mList.begin(); it != item->peerList.mList.end(); ++it) @@ -915,7 +915,7 @@ bool p3BanList::loadList(std::list& load) bool p3BanList::addBanEntry( const RsPeerId &peerId, const sockaddr_storage &dAddr, - int level, uint32_t reason, time_t time_stamp ) + int level, uint32_t reason, rstime_t time_stamp ) { sockaddr_storage addr; sockaddr_storage_copy(dAddr, addr); if(!sockaddr_storage_ipv6_to_ipv4(addr)) @@ -929,7 +929,7 @@ bool p3BanList::addBanEntry( const RsPeerId &peerId, RS_STACK_MUTEX(mBanMtx); - time_t now = time(NULL); + rstime_t now = time(NULL); bool updated = false; #ifdef DEBUG_BANLIST @@ -1034,7 +1034,7 @@ int p3BanList::condenseBanSources_locked() { mBanSet.clear(); - time_t now = time(NULL); + rstime_t now = time(NULL); RsPeerId ownId = mServiceCtrl->getOwnId(); #ifdef DEBUG_BANLIST @@ -1150,8 +1150,8 @@ int p3BanList::condenseBanSources_locked() int p3BanList::sendPackets() { - time_t now = time(NULL); - time_t pt; + rstime_t now = time(NULL); + rstime_t pt; { RsStackMutex stack(mBanMtx); /****** LOCKED MUTEX *******/ pt = mSentListTime; @@ -1210,7 +1210,7 @@ int p3BanList::sendBanSet(const RsPeerId& peerid) RsBanListItem *item = new RsBanListItem(); item->PeerId(peerid); - //time_t now = time(NULL); + //rstime_t now = time(NULL); { RsStackMutex stack(mBanMtx); /****** LOCKED MUTEX *******/ @@ -1236,7 +1236,7 @@ int p3BanList::sendBanSet(const RsPeerId& peerid) int p3BanList::printBanSet_locked(std::ostream &out) { - time_t now = time(NULL); + rstime_t now = time(NULL); out << "p3BanList::printBanSet_locked()"; out << " Only printing active filters (due to user options)."; @@ -1279,7 +1279,7 @@ int p3BanList::printBanSet_locked(std::ostream &out) int p3BanList::printBanSources_locked(std::ostream &out) { - time_t now = time(NULL); + rstime_t now = time(NULL); std::map::const_iterator it; for(it = mBanSources.begin(); it != mBanSources.end(); ++it) diff --git a/libretroshare/src/services/p3banlist.h b/libretroshare/src/services/p3banlist.h index ac22996a9..eac722cda 100644 --- a/libretroshare/src/services/p3banlist.h +++ b/libretroshare/src/services/p3banlist.h @@ -38,7 +38,7 @@ class BanList public: RsPeerId mPeerId; /* from */ - time_t mLastUpdate; + rstime_t mLastUpdate; std::map mBanPeers; }; @@ -111,7 +111,7 @@ public: bool recvBanItem(RsBanListItem *item); bool addBanEntry( const RsPeerId &peerId, const sockaddr_storage &addr, int level, uint32_t reason, - time_t time_stamp ); + rstime_t time_stamp ); void sendBanLists(); int sendBanSet(const RsPeerId& peerid); @@ -145,13 +145,13 @@ private: p3ServiceControl *mServiceCtrl; //p3NetMgr *mNetMgr; - time_t mSentListTime; + rstime_t mSentListTime; std::map mBanSources; std::map mBanSet; std::map mBanRanges; std::map mWhiteListedRanges; - time_t mLastDhtInfoRequest ; + rstime_t mLastDhtInfoRequest ; uint32_t mAutoRangeLimit ; bool mAutoRangeIps ; diff --git a/libretroshare/src/services/p3bwctrl.cc b/libretroshare/src/services/p3bwctrl.cc index 7597c7fc9..65add3935 100644 --- a/libretroshare/src/services/p3bwctrl.cc +++ b/libretroshare/src/services/p3bwctrl.cc @@ -79,7 +79,7 @@ int p3BandwidthControl::tick() #define CHECK_PERIOD 5 - time_t now = time(NULL); + rstime_t now = time(NULL); if (now - mLastCheck > CHECK_PERIOD) { doCheck = true; @@ -121,13 +121,13 @@ bool p3BandwidthControl::checkAvailableBandwidth() mTotalRates = total; - time_t now = time(NULL); + rstime_t now = time(NULL); std::list oldIds; // unused for now! for(bit = mBwMap.begin(); bit != mBwMap.end(); ++bit) { /* check alloc rate */ - //time_t age = now - bit->second.mLastSend; + //rstime_t age = now - bit->second.mLastSend; /* find a matching entry */ it = rateMap.find(bit->first); @@ -191,7 +191,7 @@ bool p3BandwidthControl::checkAvailableBandwidth() bool p3BandwidthControl::processIncoming() { RsItem *item = NULL; - time_t now = time(NULL); + rstime_t now = time(NULL); while(NULL != (item = recvItem())) { @@ -291,7 +291,7 @@ int p3BandwidthControl::printRateInfo_locked(std::ostream &out) out << "p3BandwidthControl::printRateInfo_locked()"; out << std::endl; - //time_t now = time(NULL); + //rstime_t now = time(NULL); out << "Totals: "; out << " In: " << mTotalRates.mRateIn; out << " MaxIn: " << mTotalRates.mMaxRateIn; diff --git a/libretroshare/src/services/p3bwctrl.h b/libretroshare/src/services/p3bwctrl.h index 9b53f2d0d..bd6276d5f 100644 --- a/libretroshare/src/services/p3bwctrl.h +++ b/libretroshare/src/services/p3bwctrl.h @@ -47,14 +47,14 @@ class BwCtrlData /* Rates are floats in KB/s */ RsBwRates mRates; - time_t mRateUpdateTs; + rstime_t mRateUpdateTs; /* these are integers (B/s) */ uint32_t mAllocated; - time_t mLastSend; + rstime_t mLastSend; uint32_t mAllowedOut; - time_t mLastRecvd; + rstime_t mLastRecvd; }; @@ -116,7 +116,7 @@ private: int printRateInfo_locked(std::ostream &out); - time_t mLastCheck; + rstime_t mLastCheck; RsBwRates mTotalRates; std::map mBwMap; diff --git a/libretroshare/src/services/p3discovery2.h b/libretroshare/src/services/p3discovery2.h index a4d90fd5b..5a88f9e92 100644 --- a/libretroshare/src/services/p3discovery2.h +++ b/libretroshare/src/services/p3discovery2.h @@ -140,7 +140,7 @@ virtual void setGPGOperation(AuthGPGOperation *operation); void updatePeers_locked(const SSLID &aboutId); void sendContactInfo_locked(const PGPID &aboutId, const SSLID &toId); - time_t mLastPgpUpdate; + rstime_t mLastPgpUpdate; std::map mFriendList; std::map mLocationMap; diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index 534fcfaba..ba111ddb4 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -139,7 +139,7 @@ struct RsGxsForumNotifyRecordsItem: public RsItem void clear() {} - std::map records; + std::map records; }; class GxsChannelsConfigSerializer : public RsServiceSerializer @@ -181,7 +181,7 @@ bool p3GxsChannels::loadList(std::list& loadList) RsItem *item = loadList.front(); loadList.pop_front(); - time_t now = time(NULL); + rstime_t now = time(NULL); RsGxsForumNotifyRecordsItem *fnr = dynamic_cast(item) ; @@ -340,7 +340,7 @@ void p3GxsChannels::notifyChanges(std::vector &changes) void p3GxsChannels::service_tick() { -static time_t last_dummy_tick = 0; +static rstime_t last_dummy_tick = 0; if (time(NULL) > last_dummy_tick + 5) { @@ -913,9 +913,9 @@ void p3GxsChannels::handleUnprocessedPost(const RsGxsChannelPost &msg) #endif /* check the date is not too old */ - time_t age = time(NULL) - msg.mMeta.mPublishTs; + rstime_t age = time(NULL) - msg.mMeta.mPublishTs; - if (age < (time_t) CHANNEL_DOWNLOAD_PERIOD ) + if (age < (rstime_t) CHANNEL_DOWNLOAD_PERIOD ) { /* start download */ // NOTE WE DON'T HANDLE PRIVATE CHANNELS HERE. @@ -1779,7 +1779,7 @@ bool p3GxsChannels::retrieveDistantGroup(const RsGxsGroupId& group_id,RsGxsChann bool p3GxsChannels::turtleSearchRequest( const std::string& matchString, const std::function& multiCallback, - std::time_t maxWait ) + rstime_t maxWait ) { if(matchString.empty()) { diff --git a/libretroshare/src/services/p3gxschannels.h b/libretroshare/src/services/p3gxschannels.h index 4f24f88b9..d4c85d9bf 100644 --- a/libretroshare/src/services/p3gxschannels.h +++ b/libretroshare/src/services/p3gxschannels.h @@ -113,7 +113,7 @@ virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::strin /// @see RsGxsChannels::turtleSearchRequest virtual bool turtleSearchRequest(const std::string& matchString, const std::function& multiCallback, - std::time_t maxWait = 300 ); + rstime_t maxWait = 300 ); /** * Receive results from turtle search @see RsGenExchange @see RsNxsObserver @@ -249,7 +249,7 @@ bool generateGroup(uint32_t &token, std::string groupName); RsGxsMessageId mGenThreadId; p3GxsCommentService *mCommentService; - std::map mKnownChannels; + std::map mKnownChannels; /** Store search callbacks with timeout*/ std::map< diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index 10e6f3628..ebf979fe7 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -179,7 +179,7 @@ void p3GxsCircles::service_tick() RsTickEvent::tick_events(); GxsTokenQueue::checkRequests(); // GxsTokenQueue handles all requests. - time_t now = time(NULL); + rstime_t now = time(NULL); if(now > mLastCacheMembershipUpdateTS + GXS_CIRCLE_DELAY_TO_CHECK_MEMBERSHIP_UPDATE) { checkCircleCache(); @@ -1280,7 +1280,7 @@ bool p3GxsCircles::checkCircleCache() bool p3GxsCircles::locked_checkCircleCacheForMembershipUpdate(RsGxsCircleCache& cache) { - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(cache.mLastUpdatedMembershipTS + GXS_CIRCLE_DELAY_TO_FORCE_MEMBERSHIP_UPDATE < now) { diff --git a/libretroshare/src/services/p3gxscircles.h b/libretroshare/src/services/p3gxscircles.h index a5a56efc0..8b8cef4a8 100644 --- a/libretroshare/src/services/p3gxscircles.h +++ b/libretroshare/src/services/p3gxscircles.h @@ -125,7 +125,7 @@ class RsGxsCircleMembershipStatus public: RsGxsCircleMembershipStatus() : last_subscription_TS(0), subscription_flags(0) {} - time_t last_subscription_TS ; + rstime_t last_subscription_TS ; uint32_t subscription_flags ; // combination of GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST and GXS_EXTERNAL_CIRCLE_FLAGS_SUBSCRIBED }; @@ -153,13 +153,13 @@ class RsGxsCircleCache uint32_t mGroupStatus; uint32_t mGroupSubscribeFlags; - time_t mUpdateTime; + rstime_t mUpdateTime; #ifdef SUBSCIRCLES std::set mUnprocessedCircles; std::set mProcessedCircles; #endif std::map mMembershipStatus; - time_t mLastUpdatedMembershipTS ; // last time the subscribe messages have been requested. Should be reset when new messages arrive. + rstime_t mLastUpdatedMembershipTS ; // last time the subscribe messages have been requested. Should be reset when new messages arrive. std::set mAllowedGxsIds; // IDs that are allowed in the circle and have requested membership. This is the official members list. std::set mAllowedNodes; @@ -286,7 +286,7 @@ virtual RsServiceInfo getServiceInfo(); void checkDummyIdData(); void generateDummyCircle(); - time_t mLastCacheMembershipUpdateTS ; + rstime_t mLastCacheMembershipUpdateTS ; uint32_t mDummyIdToken; std::list mDummyPgpLinkedIds; diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index 1a348b61c..ccee5ba71 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -110,7 +110,7 @@ struct RsGxsForumNotifyRecordsItem: public RsItem void clear() {} - std::map records; + std::map records; }; class GxsForumsConfigSerializer : public RsServiceSerializer @@ -152,7 +152,7 @@ bool p3GxsForums::loadList(std::list& loadList) RsItem *item = loadList.front(); loadList.pop_front(); - time_t now = time(NULL); + rstime_t now = time(NULL); RsGxsForumNotifyRecordsItem *fnr = dynamic_cast(item) ; diff --git a/libretroshare/src/services/p3gxsforums.h b/libretroshare/src/services/p3gxsforums.h index c6341c333..ef3dd46d8 100644 --- a/libretroshare/src/services/p3gxsforums.h +++ b/libretroshare/src/services/p3gxsforums.h @@ -117,7 +117,7 @@ bool generateGroup(uint32_t &token, std::string groupName); int mGenCount; std::vector mGenRefs; RsGxsMessageId mGenThreadId; - std::map mKnownForums ; + std::map mKnownForums ; }; diff --git a/libretroshare/src/services/p3gxsreputation.cc b/libretroshare/src/services/p3gxsreputation.cc index 01e022c8e..412360d0e 100644 --- a/libretroshare/src/services/p3gxsreputation.cc +++ b/libretroshare/src/services/p3gxsreputation.cc @@ -61,7 +61,7 @@ * - auto-clean reputations for default values * * std::map mReputations. - * std::multimap mUpdated. + * std::multimap mUpdated. * * std::map mConfig; * @@ -187,7 +187,7 @@ int p3GxsReputation::tick() processIncoming(); sendPackets(); - time_t now = time(NULL); + rstime_t now = time(NULL); if(mLastCleanUp + CLEANUP_PERIOD < now) { @@ -217,7 +217,7 @@ int p3GxsReputation::tick() } #ifdef DEBUG_REPUTATION - static time_t last_debug_print = time(NULL) ; + static rstime_t last_debug_print = time(NULL) ; if(now > 10+last_debug_print) { @@ -369,7 +369,7 @@ void p3GxsReputation::cleanup() #ifdef DEBUG_REPUTATION std::cerr << "p3GxsReputation::cleanup() " << std::endl; #endif - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; // We should keep opinions about identities that do not exist anymore, but only rely on the usage TS. That will in particular avoid asking p3idservice about deleted // identities, which would cause an excess of hits to the database. We do it in two steps to avoid a deadlock when calling rsIdentity from here. @@ -546,12 +546,12 @@ bool p3GxsReputation::SendReputations(RsGxsReputationRequestItem *request) #endif RsPeerId peerId = request->PeerId(); - time_t last_update = request->mLastUpdate; - time_t now = time(NULL); + rstime_t last_update = request->mLastUpdate; + rstime_t now = time(NULL); RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/ - std::multimap::iterator tit; + std::multimap::iterator tit; tit = mUpdated.upper_bound(last_update); // could skip some - (fixed below). int count = 0; @@ -741,7 +741,7 @@ bool p3GxsReputation::RecvReputations(RsGxsReputationUpdateItem *item) } -bool p3GxsReputation::updateLatestUpdate(RsPeerId peerid,time_t latest_update) +bool p3GxsReputation::updateLatestUpdate(RsPeerId peerid,rstime_t latest_update) { RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/ @@ -810,7 +810,7 @@ bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, const RsPgpId& own if(gxsid.isNull()) return false ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/ @@ -1047,7 +1047,7 @@ bool p3GxsReputation::setOwnOpinion(const RsGxsId& gxsid, const RsReputations::O return false; } - std::multimap::iterator uit, euit; + std::multimap::iterator uit, euit; uit = mUpdated.lower_bound(reputation.mOwnOpinionTs); euit = mUpdated.upper_bound(reputation.mOwnOpinionTs); for(; uit != euit; ++uit) @@ -1060,7 +1060,7 @@ bool p3GxsReputation::setOwnOpinion(const RsGxsId& gxsid, const RsReputations::O } } - time_t now = time(NULL); + rstime_t now = time(NULL); reputation.mOwnOpinion = opinion; reputation.mOwnOpinionTs = now; reputation.updateReputation(); @@ -1384,8 +1384,8 @@ bool p3GxsReputation::loadReputationSet(RsGxsReputationSetItem *item, const std: int p3GxsReputation::sendPackets() { - time_t now = time(NULL); - time_t requestTime, storeTime; + rstime_t now = time(NULL); + rstime_t requestTime, storeTime; { RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/ requestTime = mRequestTime; @@ -1445,7 +1445,7 @@ void p3GxsReputation::sendReputationRequests() int p3GxsReputation::sendReputationRequest(RsPeerId peerid) { #ifdef DEBUG_REPUTATION - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; std::cerr << " p3GxsReputation::sendReputationRequest(" << peerid << ") " ; #endif @@ -1573,7 +1573,7 @@ std::map rep_copy; RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/ rep_copy = mReputations ; } - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; for(std::map::const_iterator it(rep_copy.begin());it!=rep_copy.end();++it) { diff --git a/libretroshare/src/services/p3gxsreputation.h b/libretroshare/src/services/p3gxsreputation.h index 75d5d628c..d27bb79cc 100644 --- a/libretroshare/src/services/p3gxsreputation.h +++ b/libretroshare/src/services/p3gxsreputation.h @@ -51,13 +51,13 @@ public: :mPeerId(peerId), mLatestUpdate(0), mLastQuery(0) { return; } RsPeerId mPeerId; - time_t mLatestUpdate; - time_t mLastQuery; + rstime_t mLatestUpdate; + rstime_t mLastQuery; }; struct BannedNodeInfo { - time_t last_activity_TS ; // updated everytime a node or one of its former identities is required + rstime_t last_activity_TS ; // updated everytime a node or one of its former identities is required std::set known_identities ; // list of known identities from this node. This is kept for a while, and useful in order to avoid re-asking these keys. }; @@ -74,7 +74,7 @@ public: std::map mOpinions; int32_t mOwnOpinion; - time_t mOwnOpinionTs; + rstime_t mOwnOpinionTs; float mFriendAverage ; uint32_t mFriendsPositive ; // number of positive vites from friends @@ -86,7 +86,7 @@ public: uint32_t mIdentityFlags; - time_t mLastUsedTS ; // last time the reputation was asked. Used to keep track of activity and clean up some reputation data. + rstime_t mLastUsedTS ; // last time the reputation was asked. Used to keep track of activity and clean up some reputation data. }; @@ -144,7 +144,7 @@ private: bool SendReputations(RsGxsReputationRequestItem *request); bool RecvReputations(RsGxsReputationUpdateItem *item); - bool updateLatestUpdate(RsPeerId peerid, time_t latest_update); + bool updateLatestUpdate(RsPeerId peerid, rstime_t latest_update); void updateBannedNodesProxy(); @@ -164,11 +164,11 @@ private: private: RsMutex mReputationMtx; - time_t mLastCleanUp; - time_t mRequestTime; - time_t mStoreTime; - time_t mLastBannedNodesUpdate ; - time_t mLastIdentityFlagsUpdate ; + rstime_t mLastCleanUp; + rstime_t mRequestTime; + rstime_t mStoreTime; + rstime_t mLastBannedNodesUpdate ; + rstime_t mLastIdentityFlagsUpdate ; bool mReputationsUpdated; //float mAutoBanIdentitiesLimit ; @@ -179,7 +179,7 @@ private: // Data for Reputation. std::map mConfig; std::map mReputations; - std::multimap mUpdated; + std::multimap mUpdated; // PGP Ids auto-banned. This is updated regularly. std::map mBannedPgpIds ; @@ -191,7 +191,7 @@ private: uint32_t mMaxPreventReloadBannedIds ; bool mChanged ; // slow version of IndicateConfigChanged(); - time_t mLastReputationConfigSaved ; + rstime_t mLastReputationConfigSaved ; }; #endif //SERVICE_RSGXSREPUTATION_HEADER diff --git a/libretroshare/src/services/p3heartbeat.cc b/libretroshare/src/services/p3heartbeat.cc index e74787812..38426a454 100644 --- a/libretroshare/src/services/p3heartbeat.cc +++ b/libretroshare/src/services/p3heartbeat.cc @@ -19,7 +19,7 @@ * along with this program. If not, see . * * * *******************************************************************************/ -#include +#include "util/rstime.h" #include "services/p3heartbeat.h" #include "rsitems/rsheartbeatitems.h" diff --git a/libretroshare/src/services/p3heartbeat.h b/libretroshare/src/services/p3heartbeat.h index 21dd9b6b7..6dd9f6e5b 100644 --- a/libretroshare/src/services/p3heartbeat.h +++ b/libretroshare/src/services/p3heartbeat.h @@ -53,7 +53,7 @@ virtual RsServiceInfo getServiceInfo(); /* data */ RsMutex mHeartMtx; - time_t mLastHeartbeat; + rstime_t mLastHeartbeat; }; #endif // MRK_SERVICES_HEARTBEAT_H diff --git a/libretroshare/src/services/p3idservice.cc b/libretroshare/src/services/p3idservice.cc index b42950d0a..11cf7d692 100644 --- a/libretroshare/src/services/p3idservice.cc +++ b/libretroshare/src/services/p3idservice.cc @@ -60,11 +60,11 @@ // unused keys are deleted according to some heuristic that should favor known keys, signed keys etc. -static const time_t MAX_KEEP_KEYS_BANNED_DEFAULT = 2 * 86400 ; // get rid of banned ids after 1 days. That gives a chance to un-ban someone before he gets definitely kicked out +static const rstime_t MAX_KEEP_KEYS_BANNED_DEFAULT = 2 * 86400 ; // get rid of banned ids after 1 days. That gives a chance to un-ban someone before he gets definitely kicked out -static const time_t MAX_KEEP_KEYS_DEFAULT = 5 * 86400 ; // default for unsigned identities: 5 days -static const time_t MAX_KEEP_KEYS_SIGNED = 8 * 86400 ; // signed identities by unknown key -static const time_t MAX_KEEP_KEYS_SIGNED_KNOWN = 30 * 86400 ; // signed identities by known node keys +static const rstime_t MAX_KEEP_KEYS_DEFAULT = 5 * 86400 ; // default for unsigned identities: 5 days +static const rstime_t MAX_KEEP_KEYS_SIGNED = 8 * 86400 ; // signed identities by unknown key +static const rstime_t MAX_KEEP_KEYS_SIGNED_KNOWN = 30 * 86400 ; // signed identities by known node keys static const uint32_t MAX_DELAY_BEFORE_CLEANING= 1800 ; // clean old keys every 30 mins @@ -257,7 +257,7 @@ bool p3IdService::setAsRegularContact(const RsGxsId& id,bool b) void p3IdService::slowIndicateConfigChanged() { - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(mLastConfigUpdate + DELAY_BETWEEN_CONFIG_UPDATES < now) { @@ -265,7 +265,7 @@ void p3IdService::slowIndicateConfigChanged() mLastConfigUpdate = now ; } } -time_t p3IdService::locked_getLastUsageTS(const RsGxsId& gxs_id) +rstime_t p3IdService::locked_getLastUsageTS(const RsGxsId& gxs_id) { std::map::const_iterator it = mKeysTS.find(gxs_id) ; @@ -287,7 +287,7 @@ void p3IdService::timeStampKey(const RsGxsId& gxs_id, const RsIdentityUsage& rea RS_STACK_MUTEX(mIdMtx) ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; keyTSInfo& info(mKeysTS[gxs_id]) ; @@ -298,10 +298,10 @@ void p3IdService::timeStampKey(const RsGxsId& gxs_id, const RsIdentityUsage& rea { // This is very costly, but normally the outerloop should never be rolled more than once. - std::map::iterator best_it ; - time_t best_time = now+1; + std::map::iterator best_it ; + rstime_t best_time = now+1; - for(std::map::iterator it(info.usage_map.begin());it!=info.usage_map.end();++it) + for(std::map::iterator it(info.usage_map.begin());it!=info.usage_map.end();++it) if(it->second < best_time) { best_time = it->second ; @@ -323,7 +323,7 @@ bool p3IdService::loadList(std::list& items) { if( (lii = dynamic_cast(*it)) != NULL) { - for(std::map::const_iterator it2 = lii->mTimeStamps.begin();it2!=lii->mTimeStamps.end();++it2) + for(std::map::const_iterator it2 = lii->mTimeStamps.begin();it2!=lii->mTimeStamps.end();++it2) mKeysTS[it2->first].TS = it2->second; mContacts = lii->mContacts ; @@ -405,7 +405,7 @@ public: bool processEntry(RsGxsIdCache& entry) { - time_t now = time(NULL); + rstime_t now = time(NULL); const RsGxsId& gxs_id = entry.details.mId ; bool is_id_banned = rsReputations->isIdentityBanned(gxs_id) ; @@ -430,8 +430,8 @@ public: bool no_ts = (it == mLastUsageTS.end()) ; - time_t last_usage_ts = no_ts?0:(it->second.TS); - time_t max_keep_time = 0; + rstime_t last_usage_ts = no_ts?0:(it->second.TS); + rstime_t max_keep_time = 0; bool should_check = true ; if(no_ts) @@ -523,7 +523,7 @@ void p3IdService::service_tick() RsTickEvent::tick_events(); GxsTokenQueue::checkRequests(); // GxsTokenQueue handles all requests. - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(mLastKeyCleaningTime + MAX_DELAY_BEFORE_CLEANING < now) { @@ -630,7 +630,7 @@ bool p3IdService:: getNickname(const RsGxsId &id, std::string &nickname) } #endif -time_t p3IdService::getLastUsageTS(const RsGxsId &id) +rstime_t p3IdService::getLastUsageTS(const RsGxsId &id) { RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/ return locked_getLastUsageTS(id) ; @@ -2406,7 +2406,7 @@ bool p3IdService::cache_process_recogntaginfo(const RsGxsIdGroupItem *item, std: recogn_extract_taginfo(item, tagItems); - //time_t now = time(NULL); + //rstime_t now = time(NULL); for(it = tagItems.begin(); it != tagItems.end(); ++it) { RsRecognTag info((*it)->tag_class, (*it)->tag_type, false); @@ -3415,8 +3415,8 @@ bool p3IdService::pgphash_handlerequest(uint32_t token) */ #define SECS_PER_DAY (3600 * 24) - time_t age = time(NULL) - ssdata.pgp.lastCheckTs; - time_t wait_period = ssdata.pgp.checkAttempts * SECS_PER_DAY; + rstime_t age = time(NULL) - ssdata.pgp.lastCheckTs; + rstime_t wait_period = ssdata.pgp.checkAttempts * SECS_PER_DAY; if (wait_period > 30 * SECS_PER_DAY) { wait_period = 30 * SECS_PER_DAY; @@ -4003,7 +4003,7 @@ bool p3IdService::recogn_checktag(const RsGxsId &id, const std::string &nickname // ------ // signature is valid. (only if doSignCheck == true) - time_t now = time(NULL); + rstime_t now = time(NULL); isPending = false; // check date range. @@ -4110,7 +4110,7 @@ void p3IdService::generateDummyData() generateDummy_OwnIds(); - time_t age = 0; + rstime_t age = 0; for(int i = 0; i < MAX_KNOWN_PGPIDS; i++) { age += DUMMY_GXSID_DELAY; diff --git a/libretroshare/src/services/p3idservice.h b/libretroshare/src/services/p3idservice.h index 17d62c9ce..3b120d2be 100644 --- a/libretroshare/src/services/p3idservice.h +++ b/libretroshare/src/services/p3idservice.h @@ -103,7 +103,7 @@ virtual bool load(const std::string &input); virtual std::string save() const; bool validatedSignature; - time_t lastCheckTs; + rstime_t lastCheckTs; uint32_t checkAttempts; RsPgpId pgpId; }; @@ -124,8 +124,8 @@ virtual std::string save() const; bool tagValid(int i) const; uint32_t tagFlags; - time_t publishTs; - time_t lastCheckTs; + rstime_t publishTs; + rstime_t lastCheckTs; }; @@ -196,7 +196,7 @@ public: void updateServiceString(std::string serviceString); - time_t mPublishTs; + rstime_t mPublishTs; std::list mRecognTags; // Only partially validated. RsIdentityDetails details; @@ -212,7 +212,7 @@ struct SerialisedIdentityStruct { unsigned char *mMem ; uint32_t mSize ; - time_t mLastUsageTS; + rstime_t mLastUsageTS; }; // Not sure exactly what should be inherited here? @@ -282,7 +282,7 @@ public: virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) ; virtual bool isARegularContact(const RsGxsId& id) ; virtual uint32_t nbRegularContacts() ; - virtual time_t getLastUsageTS(const RsGxsId &id) ; + virtual rstime_t getLastUsageTS(const RsGxsId &id) ; /**************** RsGixs Implementation ***************/ @@ -527,7 +527,7 @@ private: void slowIndicateConfigChanged() ; virtual void timeStampKey(const RsGxsId& id, const RsIdentityUsage& reason) ; - time_t locked_getLastUsageTS(const RsGxsId& gxs_id); + rstime_t locked_getLastUsageTS(const RsGxsId& gxs_id); std::string genRandomId(int len = 20); @@ -570,8 +570,8 @@ private: { keyTSInfo() : TS(0) {} - time_t TS ; - std::map usage_map ; + rstime_t TS ; + std::map usage_map ; }; friend class IdCacheEntryCleaner; @@ -593,8 +593,8 @@ private: PgpAuxUtils *mPgpUtils; - time_t mLastKeyCleaningTime ; - time_t mLastConfigUpdate ; + rstime_t mLastKeyCleaningTime ; + rstime_t mLastConfigUpdate ; bool mOwnIdsLoaded ; uint32_t mMaxKeepKeysBanned ; diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index 5b270749b..ac6b3241c 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -139,8 +139,8 @@ int p3MsgService::tick() incomingMsgs(); - static time_t last_management_time = 0 ; - time_t now = time(NULL) ; + static rstime_t last_management_time = 0 ; + rstime_t now = time(NULL) ; if(now > last_management_time + 5) { @@ -158,7 +158,7 @@ void p3MsgService::cleanListOfReceivedMessageHashes() { RS_STACK_MUTEX(recentlyReceivedMutex); - time_t now = time(NULL); + rstime_t now = time(NULL); for( auto it = mRecentlyReceivedMessageHashes.begin(); it != mRecentlyReceivedMessageHashes.end(); ) diff --git a/libretroshare/src/services/p3msgservice.h b/libretroshare/src/services/p3msgservice.h index 32f087ad0..f1f7fbb18 100644 --- a/libretroshare/src/services/p3msgservice.h +++ b/libretroshare/src/services/p3msgservice.h @@ -116,11 +116,11 @@ public: struct DistantMessengingInvite { - time_t time_of_validity ; + rstime_t time_of_validity ; }; struct DistantMessengingContact { - time_t last_hit_time ; + rstime_t last_hit_time ; RsPeerId virtual_peer_id ; uint32_t status ; bool pending_messages ; diff --git a/libretroshare/src/services/p3posted.cc b/libretroshare/src/services/p3posted.cc index 4d5cced66..4e8ddacf2 100644 --- a/libretroshare/src/services/p3posted.cc +++ b/libretroshare/src/services/p3posted.cc @@ -104,7 +104,7 @@ bool p3Posted::getPostData(const uint32_t &token, std::vector &msg GxsMsgDataMap msgData; bool ok = RsGenExchange::getMsgData(token, msgData); - time_t now = time(NULL); + rstime_t now = time(NULL); if(ok) { @@ -175,7 +175,7 @@ bool p3Posted::getPostData(const uint32_t &token, std::vector &msg { GxsMsgRelatedDataMap msgData; bool ok = RsGenExchange::getMsgRelatedData(token, msgData); - time_t now = time(NULL); + rstime_t now = time(NULL); if(ok) { @@ -224,7 +224,7 @@ bool p3Posted::getPostData(const uint32_t &token, std::vector &msg * */ -bool RsPostedPost::calculateScores(time_t ref_time) +bool RsPostedPost::calculateScores(rstime_t ref_time) { /* so we want to calculate all the scores for this Post. */ @@ -236,7 +236,7 @@ bool RsPostedPost::calculateScores(time_t ref_time) mComments = stats.comments; mHaveVoted = (mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK); - time_t age_secs = ref_time - mMeta.mPublishTs; + rstime_t age_secs = ref_time - mMeta.mPublishTs; #define POSTED_AGESHIFT (2.0) #define POSTED_AGEFACTOR (3600.0) diff --git a/libretroshare/src/services/p3rtt.cc b/libretroshare/src/services/p3rtt.cc index d7fee261d..4c7effe36 100644 --- a/libretroshare/src/services/p3rtt.cc +++ b/libretroshare/src/services/p3rtt.cc @@ -75,7 +75,7 @@ RsRtt *rsRtt = NULL; #ifdef WINDOWS_SYS -#include +#include "util/rstime.h" #include #endif @@ -160,8 +160,8 @@ int p3rtt::status() int p3rtt::sendPackets() { - time_t now = time(NULL); - time_t pt; + rstime_t now = time(NULL); + rstime_t pt; { RsStackMutex stack(mRttMtx); /****** LOCKED MUTEX *******/ pt = mSentPingTime; diff --git a/libretroshare/src/services/p3rtt.h b/libretroshare/src/services/p3rtt.h index 3bc99eacc..80a369d17 100644 --- a/libretroshare/src/services/p3rtt.h +++ b/libretroshare/src/services/p3rtt.h @@ -105,7 +105,7 @@ virtual bool recvItem(RsItem *item); // Overloaded from p3FastService. RttPeerInfo *locked_GetPeerInfo(const RsPeerId& id); std::map mPeerInfo; - time_t mSentPingTime; + rstime_t mSentPingTime; uint32_t mCounter; p3ServiceControl *mServiceCtrl; diff --git a/libretroshare/src/services/p3service.cc b/libretroshare/src/services/p3service.cc index a2b7755c8..54ba176ef 100644 --- a/libretroshare/src/services/p3service.cc +++ b/libretroshare/src/services/p3service.cc @@ -27,7 +27,7 @@ #include #ifdef WINDOWS_SYS -#include +#include "util/rstime.h" #endif /***** diff --git a/libretroshare/src/services/p3statusservice.cc b/libretroshare/src/services/p3statusservice.cc index 7ff736d7b..f3f44cf9b 100644 --- a/libretroshare/src/services/p3statusservice.cc +++ b/libretroshare/src/services/p3statusservice.cc @@ -28,7 +28,7 @@ #include #include #include -#include +#include "util/rstime.h" #include "pqi/p3linkmgr.h" diff --git a/libretroshare/src/tcponudp/tcpstream.cc b/libretroshare/src/tcponudp/tcpstream.cc index 5af0f505d..439f98854 100644 --- a/libretroshare/src/tcponudp/tcpstream.cc +++ b/libretroshare/src/tcponudp/tcpstream.cc @@ -31,7 +31,7 @@ #include #include -#include +#include "util/rstime.h" /* Debugging for STATE change, and Startup SYNs */ #include "util/rsdebug.h" @@ -2597,7 +2597,7 @@ bool TcpStream::isOldSequence(uint32 tst, uint32 curr) } #ifdef WINDOWS_SYS -#include +#include "util/rstime.h" #include #endif diff --git a/libretroshare/src/tcponudp/tou.cc b/libretroshare/src/tcponudp/tou.cc index 4121c6985..0ff394c0a 100644 --- a/libretroshare/src/tcponudp/tou.cc +++ b/libretroshare/src/tcponudp/tou.cc @@ -25,7 +25,7 @@ static const int kInitStreamTable = 5; #include #include -#include +#include "util/rstime.h" #include "udp/udpstack.h" #include "pqi/pqinetwork.h" diff --git a/libretroshare/src/tcponudp/udprelay.cc b/libretroshare/src/tcponudp/udprelay.cc index 8793eb636..fa988ec09 100644 --- a/libretroshare/src/tcponudp/udprelay.cc +++ b/libretroshare/src/tcponudp/udprelay.cc @@ -21,7 +21,7 @@ *******************************************************************************/ #include "udprelay.h" #include -#include +#include "util/rstime.h" #include /* @@ -232,7 +232,7 @@ int UdpRelayReceiver::checkRelays() std::list eraseList; std::map::iterator rit; - time_t now = time(NULL); + rstime_t now = time(NULL); #define BANDWIDTH_FILTER_K (0.8) @@ -1088,7 +1088,7 @@ std::ostream &operator<<(std::ostream &out, const UdpRelayAddrSet &uras) std::ostream &operator<<(std::ostream &out, const UdpRelayProxy &urp) { - time_t now = time(NULL); + rstime_t now = time(NULL); out << "UdpRelayProxy for " << urp.mAddrs; out << std::endl; out << "\tRelayClass: " << urp.mRelayClass; diff --git a/libretroshare/src/tcponudp/udprelay.h b/libretroshare/src/tcponudp/udprelay.h index fda6958d3..ecc65834b 100644 --- a/libretroshare/src/tcponudp/udprelay.h +++ b/libretroshare/src/tcponudp/udprelay.h @@ -51,10 +51,10 @@ class UdpRelayProxy UdpRelayAddrSet mAddrs; double mBandwidth; uint32_t mDataSize; - time_t mLastBandwidthTS; - time_t mLastTS; + rstime_t mLastBandwidthTS; + rstime_t mLastTS; - time_t mStartTS; + rstime_t mStartTS; double mBandwidthLimit; int mRelayClass; diff --git a/libretroshare/src/tcponudp/udpstunner.cc b/libretroshare/src/tcponudp/udpstunner.cc index 8fd1dfd46..f7a0ec47a 100644 --- a/libretroshare/src/tcponudp/udpstunner.cc +++ b/libretroshare/src/tcponudp/udpstunner.cc @@ -21,7 +21,7 @@ *******************************************************************************/ #include "tcponudp/udpstunner.h" #include -#include +#include "util/rstime.h" #include "util/rsrandom.h" #include "util/rsprint.h" @@ -111,7 +111,7 @@ void UdpStunner::SimSymmetricNat() int UdpStunner::grabExclusiveMode(std::string holder) /* returns seconds since last send/recv */ { RsStackMutex stack(stunMtx); /********** LOCK MUTEX *********/ - time_t now = time(NULL); + rstime_t now = time(NULL); #ifdef DEBUG_UDP_STUNNER_FILTER @@ -187,7 +187,7 @@ int UdpStunner::releaseExclusiveMode(std::string holder, bool forceStun) return 0; } - time_t now = time(NULL); + rstime_t now = time(NULL); mExclusiveMode = false; if (forceStun) { @@ -330,7 +330,7 @@ bool UdpStunner::locked_handleStunPkt(void *data, int size, struct sockaddr_in & if (!pkt) return false; - time_t now = time(NULL); + rstime_t now = time(NULL); mStunLastSendAny = now; int sentlen = sendPkt(pkt, len, from, STUN_TTL); free(pkt); @@ -456,7 +456,7 @@ int UdpStunner::doStun(struct sockaddr_in stun_addr) { RsStackMutex stack(stunMtx); /********** LOCK MUTEX *********/ - time_t now = time(NULL); + rstime_t now = time(NULL); mStunLastSendStun = now; mStunLastSendAny = now; } @@ -750,7 +750,7 @@ bool UdpStunner::checkStunDesired() std::cerr << std::endl; #endif - time_t now; + rstime_t now; { RsStackMutex stack(stunMtx); /********** LOCK MUTEX *********/ @@ -800,7 +800,7 @@ bool UdpStunner::checkStunDesired() #define RATE_SCALE (3.0) double stunPeriod = (mTargetStunPeriod / (RATE_SCALE)) * (1.0 + mSuccessRate * (RATE_SCALE - 1.0)); - time_t nextStun = mStunLastRecvResp + (int) stunPeriod; + rstime_t nextStun = mStunLastRecvResp + (int) stunPeriod; #ifdef DEBUG_UDP_STUNNER std::cerr << "UdpStunner::checkStunDesired() TargetStunPeriod: " << mTargetStunPeriod; @@ -834,7 +834,7 @@ bool UdpStunner::attemptStun() { bool found = false; TouStunPeer peer; - time_t now = time(NULL); + rstime_t now = time(NULL); #ifdef DEBUG_UDP_STUNNER std::cerr << "UdpStunner::attemptStun()"; @@ -1000,7 +1000,7 @@ bool UdpStunner::locked_recvdStun(const struct sockaddr_in &remote, const str mSuccessRate += (1.0-TOU_SUCCESS_LPF_FACTOR); - time_t now = time(NULL); + rstime_t now = time(NULL); mStunLastRecvResp = now; mStunLastRecvAny = now; @@ -1025,7 +1025,7 @@ bool UdpStunner::locked_checkExternalAddress() bool found1 = false; bool found2 = false; - time_t now = time(NULL); + rstime_t now = time(NULL); /* iterator backwards - as these are the most recent */ /******** @@ -1048,7 +1048,7 @@ bool UdpStunner::locked_checkExternalAddress() 4) recent age. */ - time_t age = (now - it->lastsend); + rstime_t age = (now - it->lastsend); if (it->response && #ifdef UDPSTUN_ALLOW_LOCALNET ( mAcceptLocalNet || isExternalNet(&(it->eaddr.sin_addr))) && @@ -1132,7 +1132,7 @@ bool UdpStunner::locked_printStunList() #ifdef DEBUG_UDP_STUNNER std::string out = "locked_printStunList()\n"; - time_t now = time(NULL); + rstime_t now = time(NULL); rs_sprintf_append(out, "\tLastSendStun: %ld\n", now - mStunLastSendStun); rs_sprintf_append(out, "\tLastSendAny: %ld\n", now - mStunLastSendAny); rs_sprintf_append(out, "\tLastRecvResp: %ld\n", now - mStunLastRecvResp); @@ -1157,7 +1157,7 @@ bool UdpStunner::locked_printStunList() bool UdpStunner::getStunPeer(int idx, std::string &id, struct sockaddr_in &remote, struct sockaddr_in &eaddr, - uint32_t &failCount, time_t &lastSend) + uint32_t &failCount, rstime_t &lastSend) { RsStackMutex stack(stunMtx); /********** LOCK MUTEX *********/ diff --git a/libretroshare/src/tcponudp/udpstunner.h b/libretroshare/src/tcponudp/udpstunner.h index 1abc48d6e..8365b0fd9 100644 --- a/libretroshare/src/tcponudp/udpstunner.h +++ b/libretroshare/src/tcponudp/udpstunner.h @@ -56,7 +56,7 @@ class TouStunPeer std::string id; struct sockaddr_in remote, eaddr; bool response; - time_t lastsend; + rstime_t lastsend; uint32_t failCount; }; @@ -89,7 +89,7 @@ bool dropStunPeer(const struct sockaddr_in &remote); bool getStunPeer(int idx, std::string &id, struct sockaddr_in &remote, struct sockaddr_in &eaddr, - uint32_t &failCount, time_t &lastSend); + uint32_t &failCount, rstime_t &lastSend); bool needStunPeers(); @@ -125,12 +125,12 @@ bool locked_checkExternalAddress(); bool eaddrKnown; bool eaddrStable; /* if true then usable. if false -> Symmettric NAT */ - time_t eaddrTime; + rstime_t eaddrTime; - time_t mStunLastRecvResp; - time_t mStunLastRecvAny; - time_t mStunLastSendStun; - time_t mStunLastSendAny; + rstime_t mStunLastRecvResp; + rstime_t mStunLastRecvAny; + rstime_t mStunLastSendStun; + rstime_t mStunLastSendAny; std::list mStunList; /* potentials */ @@ -148,7 +148,7 @@ bool locked_checkExternalAddress(); double mSuccessRate; bool mExclusiveMode; /* when this is switched on, the stunner stays silent (and extAddr is maintained) */ - time_t mExclusiveModeTS; + rstime_t mExclusiveModeTS; std::string mExclusiveHolder; bool mForceRestun; diff --git a/libretroshare/src/tests/dbase/ficachetest.cc b/libretroshare/src/tests/dbase/ficachetest.cc index ea8ae2107..3d2c62074 100644 --- a/libretroshare/src/tests/dbase/ficachetest.cc +++ b/libretroshare/src/tests/dbase/ficachetest.cc @@ -48,7 +48,7 @@ void handleQuery(CacheStrapper *csp, RsPeerId pid, int main(int argc, char **argv) { - time_t period = 11; + rstime_t period = 11; RsPeerId pid1("0x0101"); RsPeerId pid2("0x0102"); RsPeerId pid3("0x0103"); diff --git a/libretroshare/src/tests/dbase/fisavetest.cc b/libretroshare/src/tests/dbase/fisavetest.cc index 34a2c2968..94d2905d6 100644 --- a/libretroshare/src/tests/dbase/fisavetest.cc +++ b/libretroshare/src/tests/dbase/fisavetest.cc @@ -24,7 +24,7 @@ #include "dbase/findex.h" #include -FileIndex *createBasicFileIndex(time_t age); +FileIndex *createBasicFileIndex(rstime_t age); int main() { @@ -54,7 +54,7 @@ int main() } -FileIndex *createBasicFileIndex(time_t age) +FileIndex *createBasicFileIndex(rstime_t age) { FileIndex *fi = new FileIndex("A SILLY ID"); diff --git a/libretroshare/src/tests/dbase/fitest2.cc b/libretroshare/src/tests/dbase/fitest2.cc index 534fe0d6e..b3f74775d 100644 --- a/libretroshare/src/tests/dbase/fitest2.cc +++ b/libretroshare/src/tests/dbase/fitest2.cc @@ -25,7 +25,7 @@ #include -FileIndex *createBasicFileIndex(time_t age); +FileIndex *createBasicFileIndex(rstime_t age); int test1(FileIndex *fi); int test2(FileIndex *fi); @@ -44,7 +44,7 @@ int main() int test1(FileIndex *fi) { /* in this test we are going to get the old directories - and update them */ - time_t stamp = 200; + rstime_t stamp = 200; DirEntry *olddir = NULL; FileEntry fe; @@ -92,7 +92,7 @@ int test1(FileIndex *fi) int test2(FileIndex *fi) { /* in this test we are going to simulate that 2 directories have disappeared */ - time_t stamp = 200; + rstime_t stamp = 200; DirEntry *olddir = NULL; FileEntry fe; @@ -154,7 +154,7 @@ int test2(FileIndex *fi) -FileIndex *createBasicFileIndex(time_t age) +FileIndex *createBasicFileIndex(rstime_t age) { FileIndex *fi = new FileIndex("A SILLY ID"); diff --git a/libretroshare/src/tests/ft/ftcontrollertest.cc b/libretroshare/src/tests/ft/ftcontrollertest.cc index 086cbb0a0..00fb95fa2 100644 --- a/libretroshare/src/tests/ft/ftcontrollertest.cc +++ b/libretroshare/src/tests/ft/ftcontrollertest.cc @@ -338,10 +338,10 @@ void *do_server_test_thread(void *data) /************************* TEST 1 ********************** * Check that the extra List has been processed. */ - time_t start = time(NULL); + rstime_t start = time(NULL); FileInfo info, info2; - time_t now = time(NULL); + rstime_t now = time(NULL); std::list::iterator eit; for(eit = mFt->extraList.begin(); eit != mFt->extraList.end(); eit++) { diff --git a/libretroshare/src/tests/ft/ftserver2test.cc b/libretroshare/src/tests/ft/ftserver2test.cc index e59da3ef7..84f4c9937 100644 --- a/libretroshare/src/tests/ft/ftserver2test.cc +++ b/libretroshare/src/tests/ft/ftserver2test.cc @@ -368,10 +368,10 @@ void *do_server_test_thread(void *data) /************************* TEST 1 ********************** * Check that the extra List has been processed. */ - time_t start = time(NULL); + rstime_t start = time(NULL); FileInfo info, info2; - time_t now = time(NULL); + rstime_t now = time(NULL); std::list::iterator eit; for(eit = mFt->extraList.begin(); eit != mFt->extraList.end(); eit++) { diff --git a/libretroshare/src/tests/ft/ftserver3test.cc b/libretroshare/src/tests/ft/ftserver3test.cc index 8100390cf..e887eee6b 100644 --- a/libretroshare/src/tests/ft/ftserver3test.cc +++ b/libretroshare/src/tests/ft/ftserver3test.cc @@ -381,7 +381,7 @@ INITTEST(); void *do_server_test_thread(void *data) { TestData *mFt = (TestData *) data; - time_t startTS = time(NULL); + rstime_t startTS = time(NULL); std::cerr << "do_server_test_thread() running"; std::cerr << std::endl; diff --git a/libretroshare/src/tests/gxs/gen_exchange/genexchangetester.cpp b/libretroshare/src/tests/gxs/gen_exchange/genexchangetester.cpp index 384eba6b3..f46594d9a 100644 --- a/libretroshare/src/tests/gxs/gen_exchange/genexchangetester.cpp +++ b/libretroshare/src/tests/gxs/gen_exchange/genexchangetester.cpp @@ -18,8 +18,8 @@ GenExchangeTest::~GenExchangeTest() void GenExchangeTest::pollForToken(uint32_t token, const RsTokReqOptions &opts, bool fill) { double timeDelta = 0.2; - time_t now = time(NULL); - time_t stopw = now + mPollingTO; + rstime_t now = time(NULL); + rstime_t stopw = now + mPollingTO; while(now < stopw) { @@ -84,8 +84,8 @@ bool GenExchangeTest::pollForMsgAcknowledgement(uint32_t token, { double timeDelta = 0.2; - time_t now = time(NULL); - time_t stopw = now + mPollingTO; + rstime_t now = time(NULL); + rstime_t stopw = now + mPollingTO; while(now < stopw) { @@ -123,8 +123,8 @@ bool GenExchangeTest::pollForGrpAcknowledgement(uint32_t token, RsGxsGroupId& grpId) { double timeDelta = 0.2; - time_t now = time(NULL); - time_t stopw = now + mPollingTO; + rstime_t now = time(NULL); + rstime_t stopw = now + mPollingTO; while(now < stopw) { #ifndef WINDOWS_SYS diff --git a/libretroshare/src/tests/pqi/conn_harness.cc b/libretroshare/src/tests/pqi/conn_harness.cc index 96f4acb69..72da573d4 100644 --- a/libretroshare/src/tests/pqi/conn_harness.cc +++ b/libretroshare/src/tests/pqi/conn_harness.cc @@ -55,7 +55,7 @@ std::list testResetState[NUM_CONN_MAX]; std::list testResetTimes[NUM_CONN_MAX]; uint32_t testConnectAction[NUM_CONN_MAX] = { 0 }; -time_t testConnectPeriod[NUM_CONN_MAX] = { 0 }; +rstime_t testConnectPeriod[NUM_CONN_MAX] = { 0 }; uint32_t defTestConnectAction = TST_ACTION_FAILED; @@ -129,7 +129,7 @@ testConnect::~testConnect() int testConnect::connect(struct sockaddr_in raddr) { int cidx = findWhichConnect(this); - time_t now = time(NULL); + rstime_t now = time(NULL); testConnectState[cidx] |= TST_STATE_CONNECT; testConnectTimes[cidx].push_back(now); @@ -162,7 +162,7 @@ int testConnect::stoplistening() int testConnect::reset() { int cidx = findWhichConnect(this); - time_t now = time(NULL); + rstime_t now = time(NULL); // reset everything except listening. testResetState[cidx].push_back(testConnectState[cidx]); @@ -235,8 +235,8 @@ int testConnect::tick() if (testConnectState[cidx] & TST_STATE_CONNECT) { - time_t now = time(NULL); - time_t cTime = testConnectTimes[cidx].back(); + rstime_t now = time(NULL); + rstime_t cTime = testConnectTimes[cidx].back(); if (now - cTime > testConnectPeriod[cidx]) { diff --git a/libretroshare/src/tests/pqi/conn_test.cc b/libretroshare/src/tests/pqi/conn_test.cc index 8a90b5694..57ffceafe 100644 --- a/libretroshare/src/tests/pqi/conn_test.cc +++ b/libretroshare/src/tests/pqi/conn_test.cc @@ -38,7 +38,7 @@ std::string peerIds[NumOfPeers] = #define STUN_PORT 7777 std::string ownId = "OWNID-AAAA"; -time_t ownPublishTs; +rstime_t ownPublishTs; RsMutex frmMtx; std::list searchIds; @@ -85,7 +85,7 @@ void respondPublish() void respondSearch(p3DhtMgr *mgr, std::string id, uint32_t mode) { std::cerr << "Checking for Search Results" << std::endl; - time_t now = time(NULL); + rstime_t now = time(NULL); bool doNotify = false; bool doOnline = false; std::string notifyId; @@ -268,7 +268,7 @@ virtual void loadConfiguration() int main() { - time_t startTime = time(NULL); + rstime_t startTime = time(NULL); /* setup system */ initTestData(); diff --git a/libretroshare/src/tests/pqi/dht_test.cc b/libretroshare/src/tests/pqi/dht_test.cc index 0fa76adfe..ccfd117b5 100644 --- a/libretroshare/src/tests/pqi/dht_test.cc +++ b/libretroshare/src/tests/pqi/dht_test.cc @@ -31,7 +31,7 @@ std::string peerIds[NumOfPeers] = "PEER10"}; std::string ownId = "AAAA"; -time_t ownPublishTs; +rstime_t ownPublishTs; RsMutex frmMtx; std::list searchIds; @@ -78,7 +78,7 @@ void respondPublish() void respondSearch(p3DhtMgr *mgr, std::string id, uint32_t mode) { std::cerr << "Checking for Search Results" << std::endl; - time_t now = time(NULL); + rstime_t now = time(NULL); bool doNotify = false; bool doOnline = false; std::string notifyId; @@ -205,7 +205,7 @@ virtual bool dhtSearch(std::string id, uint32_t mode) int main() { - time_t startTime = time(NULL); + rstime_t startTime = time(NULL); bool haveOwnAddress = false; /* setup system */ initTestData(); diff --git a/libretroshare/src/tests/pqi/p3connmgr_connect_test.cc b/libretroshare/src/tests/pqi/p3connmgr_connect_test.cc index e2d40fe1a..991fb99f3 100644 --- a/libretroshare/src/tests/pqi/p3connmgr_connect_test.cc +++ b/libretroshare/src/tests/pqi/p3connmgr_connect_test.cc @@ -61,7 +61,7 @@ INITTEST(); #define MAX_TIME_SHORT_TEST 10 #define MAX_TIME_BASIC_TEST 60 -int run_connect_test(time_t timeout); +int run_connect_test(rstime_t timeout); /******************************************************* * @@ -133,7 +133,7 @@ int main(int argc, char **argv) REPORT("p3connmgr_connect_test() SINGLE PEER - NO Addresses"); /* second test, add addresses for peer */ - time_t now = time(NULL); + rstime_t now = time(NULL); pqiIpAddrSet peer1_tst2_addrs; pqiIpAddress paddr; @@ -176,10 +176,10 @@ int main(int argc, char **argv) } /* Generic restart test */ -int run_connect_test(time_t timeout) +int run_connect_test(rstime_t timeout) { /* tick */ - time_t start = time(NULL); + rstime_t start = time(NULL); bool extAddr = false; while ((start > time(NULL) - timeout) && (!extAddr)) diff --git a/libretroshare/src/tests/pqi/p3connmgr_reset_test.cc b/libretroshare/src/tests/pqi/p3connmgr_reset_test.cc index 686e256c9..d5485101a 100644 --- a/libretroshare/src/tests/pqi/p3connmgr_reset_test.cc +++ b/libretroshare/src/tests/pqi/p3connmgr_reset_test.cc @@ -65,7 +65,7 @@ INITTEST(); #define RESTART_EXPECT_UPNP_ADDR 3 #define RESTART_EXPECT_DHT_ADDR 4 -int test_p3connmgr_restart_test(uint32_t expectState, time_t timeout); +int test_p3connmgr_restart_test(uint32_t expectState, rstime_t timeout); #define RESET_VIA_LOCAL_ADDR 1 @@ -235,7 +235,7 @@ int force_reset(uint32_t method) } /* Generic restart test */ -int test_p3connmgr_restart_test(uint32_t expectState, time_t timeout) +int test_p3connmgr_restart_test(uint32_t expectState, rstime_t timeout) { /* force reset network */ struct sockaddr_in tst_addr; @@ -245,7 +245,7 @@ int test_p3connmgr_restart_test(uint32_t expectState, time_t timeout) mConnMgr->setLocalAddress(AuthSSL::getAuthSSL()->OwnId(), tst_addr); /* tick */ - time_t start = time(NULL); + rstime_t start = time(NULL); bool extAddr = false; while ((start > time(NULL) - timeout) && (!extAddr)) diff --git a/libretroshare/src/tests/pqi/pqiipset_test.cc b/libretroshare/src/tests/pqi/pqiipset_test.cc index 6e803a409..893fc5223 100644 --- a/libretroshare/src/tests/pqi/pqiipset_test.cc +++ b/libretroshare/src/tests/pqi/pqiipset_test.cc @@ -94,7 +94,7 @@ bool test_addr_list() const uint32_t expectedListSize = 4; CHECK(list.mAddrs.size() == expectedListSize); - time_t min_time = time(NULL) - expectedListSize + 100; + rstime_t min_time = time(NULL) - expectedListSize + 100; /* expect the most recent ones to appear */ std::list::iterator it; diff --git a/libretroshare/src/tests/pqi/pqiqos_test.cc b/libretroshare/src/tests/pqi/pqiqos_test.cc index 903695c70..eea4846ae 100644 --- a/libretroshare/src/tests/pqi/pqiqos_test.cc +++ b/libretroshare/src/tests/pqi/pqiqos_test.cc @@ -133,10 +133,10 @@ int main() { pqiQoS qos(nb_levels,alpha) ; - static const time_t duration = 60 ; + static const rstime_t duration = 60 ; static const int average_packet_load = 10000 ; - time_t start = time(NULL) ; - time_t now ; + rstime_t start = time(NULL) ; + rstime_t now ; while( (now = time(NULL)) < duration+start ) { @@ -175,7 +175,7 @@ int main() } // print some info - static time_t last = 0 ; + static rstime_t last = 0 ; if(now > last) { qos.print() ; diff --git a/libretroshare/src/tests/pqi/testconnect.cc b/libretroshare/src/tests/pqi/testconnect.cc index bc9193e7b..0dc019c18 100644 --- a/libretroshare/src/tests/pqi/testconnect.cc +++ b/libretroshare/src/tests/pqi/testconnect.cc @@ -116,7 +116,7 @@ testConnect::~testConnect() int testConnect::connect(struct sockaddr_in raddr) { int cidx = findWhichConnect(this); - time_t now = time(NULL); + rstime_t now = time(NULL); testConnectState[cidx] |= TST_STATE_CONNECT; testConnectTimes[cidx].push_back(now); @@ -148,7 +148,7 @@ int testConnect::stoplistening() int testConnect::reset() { int cidx = findWhichConnect(this); - time_t now = time(NULL); + rstime_t now = time(NULL); // reset everything except listening. testResetState[cidx].push_back(testConnectState[cidx]); diff --git a/libretroshare/src/tests/serialiser/distribitem_test.cc b/libretroshare/src/tests/serialiser/distribitem_test.cc index a3d479735..3cc551f0f 100644 --- a/libretroshare/src/tests/serialiser/distribitem_test.cc +++ b/libretroshare/src/tests/serialiser/distribitem_test.cc @@ -24,7 +24,7 @@ */ #include -#include +#include "util/rstime.h" #include "serialiser/rsdistribitems.h" #include "serialiser/rschannelitems.h" #include "serialiser/rsforumitems.h" @@ -46,7 +46,7 @@ INITTEST() RsSerialType* init_item(RsDistribGrp& grp) { - time_t now = time(NULL); + rstime_t now = time(NULL); /* create Keys */ diff --git a/libretroshare/src/tests/serialiser/tlvrandom_test.cc b/libretroshare/src/tests/serialiser/tlvrandom_test.cc index 7452cc559..bed1525f7 100644 --- a/libretroshare/src/tests/serialiser/tlvrandom_test.cc +++ b/libretroshare/src/tests/serialiser/tlvrandom_test.cc @@ -38,7 +38,7 @@ * many deserialisation as possible. */ -#include +#include "util/rstime.h" #include #include #include "serialiser/rstlvbase.h" @@ -74,8 +74,8 @@ int main() exit(1); } - time_t startTs = time(NULL); - time_t endTs = startTs + TEST_LENGTH; + rstime_t startTs = time(NULL); + rstime_t endTs = startTs + TEST_LENGTH; srand(startTs); for(i = 0; i < dsize; i++) diff --git a/libretroshare/src/tests/tcponudp/bidir_tou.cc b/libretroshare/src/tests/tcponudp/bidir_tou.cc index 3b48da639..5075130d9 100644 --- a/libretroshare/src/tests/tcponudp/bidir_tou.cc +++ b/libretroshare/src/tests/tcponudp/bidir_tou.cc @@ -262,7 +262,7 @@ int main(int argc, char **argv) bdnet_fcntl(0, F_SETFL, O_NONBLOCK); bdnet_fcntl(1,F_SETFL,O_NONBLOCK); - time_t lastRead = time(NULL); + rstime_t lastRead = time(NULL); bool doneWrite = false; bool doneRead = false; bool blockread = false; diff --git a/libretroshare/src/tests/tcponudp/stacks_tou.cc b/libretroshare/src/tests/tcponudp/stacks_tou.cc index e8e85b9e7..ece3915b4 100644 --- a/libretroshare/src/tests/tcponudp/stacks_tou.cc +++ b/libretroshare/src/tests/tcponudp/stacks_tou.cc @@ -259,7 +259,7 @@ int main(int argc, char **argv) bdnet_fcntl(0, F_SETFL, O_NONBLOCK); bdnet_fcntl(1,F_SETFL,O_NONBLOCK); - time_t lastRead = time(NULL); + rstime_t lastRead = time(NULL); bool doneWrite = false; bool doneRead = false; bool blockread = false; diff --git a/libretroshare/src/tests/tcponudp/timed_tou.cc b/libretroshare/src/tests/tcponudp/timed_tou.cc index c87917c60..5c89d88e9 100644 --- a/libretroshare/src/tests/tcponudp/timed_tou.cc +++ b/libretroshare/src/tests/tcponudp/timed_tou.cc @@ -198,7 +198,7 @@ int main(int argc, char **argv) bdnet_fcntl(0, F_SETFL, O_NONBLOCK); bdnet_fcntl(1,F_SETFL,O_NONBLOCK); - time_t lastRead = time(NULL); + rstime_t lastRead = time(NULL); bool doneWrite = false; bool doneRead = false; bool blockread = false; diff --git a/libretroshare/src/tests/util/testretrocursor.cpp b/libretroshare/src/tests/util/testretrocursor.cpp index 7c7c7cc1a..78d77e483 100644 --- a/libretroshare/src/tests/util/testretrocursor.cpp +++ b/libretroshare/src/tests/util/testretrocursor.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include "util/rstime.h" #include "retrodb.h" #include "utest.h" diff --git a/libretroshare/src/tests/util/testretrodb.cpp b/libretroshare/src/tests/util/testretrodb.cpp index 84d24c769..37b9d7d84 100644 --- a/libretroshare/src/tests/util/testretrodb.cpp +++ b/libretroshare/src/tests/util/testretrodb.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include "util/rstime.h" #include "retrodb.h" #include "utest.h" diff --git a/libretroshare/src/turtle/p3turtle.cc b/libretroshare/src/turtle/p3turtle.cc index 90274d02d..b552f4ac0 100644 --- a/libretroshare/src/turtle/p3turtle.cc +++ b/libretroshare/src/turtle/p3turtle.cc @@ -56,8 +56,8 @@ #ifdef TUNNEL_STATISTICS static std::vector TS_tunnel_length(8,0) ; -static std::map > > TS_request_time_stamps ; -static std::map > TS_request_bounces ; +static std::map > > TS_request_time_stamps ; +static std::map > TS_request_bounces ; void TS_dumpState() ; #endif @@ -80,14 +80,14 @@ void TS_dumpState() ; // - The total number of TR per second emmited from self will be MAX_TUNNEL_REQS_PER_SECOND / TIME_BETWEEN_TUNNEL_MANAGEMENT_CALLS = 0.5 // - I updated forward probabilities to higher values, and min them to 1/nb_connected_friends to prevent blocking tunnels. // -static const time_t TUNNEL_REQUESTS_LIFE_TIME = 240 ; /// life time for tunnel requests in the cache. -static const time_t SEARCH_REQUESTS_LIFE_TIME = 240 ; /// life time for search requests in the cache -static const time_t REGULAR_TUNNEL_DIGGING_TIME = 300 ; /// maximum interval between two tunnel digging campaigns. -static const time_t MAXIMUM_TUNNEL_IDLE_TIME = 60 ; /// maximum life time of an unused tunnel. -static const time_t EMPTY_TUNNELS_DIGGING_TIME = 50 ; /// look into tunnels regularly every 50 sec. -static const time_t TUNNEL_SPEED_ESTIMATE_LAPSE = 5 ; /// estimate tunnel speed every 5 seconds -static const time_t TUNNEL_CLEANING_LAPS_TIME = 10 ; /// clean tunnels every 10 secs -static const time_t TIME_BETWEEN_TUNNEL_MANAGEMENT_CALLS = 2 ; /// Tunnel management calls every 2 secs. +static const rstime_t TUNNEL_REQUESTS_LIFE_TIME = 240 ; /// life time for tunnel requests in the cache. +static const rstime_t SEARCH_REQUESTS_LIFE_TIME = 240 ; /// life time for search requests in the cache +static const rstime_t REGULAR_TUNNEL_DIGGING_TIME = 300 ; /// maximum interval between two tunnel digging campaigns. +static const rstime_t MAXIMUM_TUNNEL_IDLE_TIME = 60 ; /// maximum life time of an unused tunnel. +static const rstime_t EMPTY_TUNNELS_DIGGING_TIME = 50 ; /// look into tunnels regularly every 50 sec. +static const rstime_t TUNNEL_SPEED_ESTIMATE_LAPSE = 5 ; /// estimate tunnel speed every 5 seconds +static const rstime_t TUNNEL_CLEANING_LAPS_TIME = 10 ; /// clean tunnels every 10 secs +static const rstime_t TIME_BETWEEN_TUNNEL_MANAGEMENT_CALLS = 2 ; /// Tunnel management calls every 2 secs. static const uint32_t MAX_TUNNEL_REQS_PER_SECOND = 1 ; /// maximum number of tunnel requests issued per second. Was 0.5 before static const uint32_t MAX_ALLOWED_SR_IN_CACHE = 120 ; /// maximum number of search requests allowed in cache. That makes 2 per sec. static const uint32_t TURTLE_SEARCH_RESULT_MAX_HITS_FILES =5000 ; /// maximum number of search results forwarded back to the source. @@ -212,10 +212,10 @@ int p3turtle::tick() // handleIncoming(); // handle incoming packets - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; #ifdef TUNNEL_STATISTICS - static time_t last_now = now ; + static rstime_t last_now = now ; if(now - last_now > 2) std::cerr << "******************* WARNING: now - last_now = " << now - last_now << std::endl; last_now = now ; @@ -278,7 +278,7 @@ int p3turtle::tick() #ifdef TUNNEL_STATISTICS // Dump state for debugging, every 20 sec. // - static time_t TS_last_dump = time(NULL) ; + static rstime_t TS_last_dump = time(NULL) ; if(now > 20+TS_last_dump) { @@ -290,7 +290,7 @@ int p3turtle::tick() #ifdef P3TURTLE_DEBUG // Dump state for debugging, every 20 sec. // - static time_t last_dump = time(NULL) ; + static rstime_t last_dump = time(NULL) ; if(now > 20+last_dump) { @@ -362,7 +362,7 @@ void p3turtle::getSourceVirtualPeersList(const TurtleFileHash& hash,std::list& p1,const std::pair& p2) const + virtual bool operator()(const std::pair& p1,const std::pair& p2) const { return p1.second < p2.second ; } @@ -378,8 +378,8 @@ void p3turtle::manageTunnels() // Note: Because REGULAR_TUNNEL_DIGGING_TIME is larger than EMPTY_TUNNELS_DIGGING_TIME, files being downloaded get // re-tunneled in priority. As this happens less, they don't obliterate tunneling for files that have no tunnels yet. - std::vector > hashes_to_digg ; - time_t now = time(NULL) ; + std::vector > hashes_to_digg ; + rstime_t now = time(NULL) ; { RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ @@ -399,16 +399,16 @@ void p3turtle::manageTunnels() float tunnel_keeping_factor = (std::max(1.0f,(float)total_speed/(float)(50*1024)) - 1.0f)*grow_speed + 1.0f ; #ifdef P3TURTLE_DEBUG - std::cerr << "Total speed = " << total_speed << ", tunel factor = " << tunnel_keeping_factor << " new time = " << time_t(REGULAR_TUNNEL_DIGGING_TIME*tunnel_keeping_factor) << std::endl; + std::cerr << "Total speed = " << total_speed << ", tunel factor = " << tunnel_keeping_factor << " new time = " << rstime_t(REGULAR_TUNNEL_DIGGING_TIME*tunnel_keeping_factor) << std::endl; #endif if( (it->second.tunnels.empty() && now >= it->second.last_digg_time+EMPTY_TUNNELS_DIGGING_TIME) - || (it->second.use_aggressive_mode && now >= it->second.last_digg_time + time_t(REGULAR_TUNNEL_DIGGING_TIME*tunnel_keeping_factor))) + || (it->second.use_aggressive_mode && now >= it->second.last_digg_time + rstime_t(REGULAR_TUNNEL_DIGGING_TIME*tunnel_keeping_factor))) { #ifdef P3TURTLE_DEBUG std::cerr << "pushed hash " << it->first << ", for digging. Old = " << now - it->second.last_digg_time << std::endl; #endif - hashes_to_digg.push_back(std::pair(it->first,it->second.last_digg_time)) ; + hashes_to_digg.push_back(std::pair(it->first,it->second.last_digg_time)) ; } } } @@ -493,7 +493,7 @@ void p3turtle::autoWash() // look for tunnels and stored temporary info that have not been used for a while. - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; // Search requests // @@ -501,7 +501,7 @@ void p3turtle::autoWash() RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ for(std::map::iterator it(_search_requests_origins.begin());it!=_search_requests_origins.end();) - if(now > (time_t)(it->second.time_stamp + SEARCH_REQUESTS_LIFE_TIME)) + if(now > (rstime_t)(it->second.time_stamp + SEARCH_REQUESTS_LIFE_TIME)) { #ifdef P3TURTLE_DEBUG std::cerr << " removed search request " << HEX_PRINT(it->first) << ", timeout." << std::endl ; @@ -521,7 +521,7 @@ void p3turtle::autoWash() RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ for(std::map::iterator it(_tunnel_requests_origins.begin());it!=_tunnel_requests_origins.end();) - if(now > (time_t)(it->second.time_stamp + TUNNEL_REQUESTS_LIFE_TIME)) + if(now > (rstime_t)(it->second.time_stamp + TUNNEL_REQUESTS_LIFE_TIME)) { #ifdef P3TURTLE_DEBUG std::cerr << " removed tunnel request " << HEX_PRINT(it->first) << ", timeout." << std::endl ; @@ -542,7 +542,7 @@ void p3turtle::autoWash() std::vector tunnels_to_close ; for(std::map::iterator it(_local_tunnels.begin());it!=_local_tunnels.end();++it) - if(now > (time_t)(it->second.time_stamp + MAXIMUM_TUNNEL_IDLE_TIME)) + if(now > (rstime_t)(it->second.time_stamp + MAXIMUM_TUNNEL_IDLE_TIME)) { #ifdef P3TURTLE_DEBUG std::cerr << " removing tunnel " << HEX_PRINT(it->first) << ": timeout." << std::endl ; @@ -1624,7 +1624,7 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item) std::cerr << "storing tunnel request " << (void*)(item->request_id) << std::endl ; ++TS_tunnel_length[item->depth] ; - TS_request_time_stamps[item->file_hash].push_back(std::pair(time(NULL),item->request_id)) ; + TS_request_time_stamps[item->file_hash].push_back(std::pair(time(NULL),item->request_id)) ; #endif } @@ -2306,7 +2306,7 @@ void p3turtle::getInfo( std::vector >& hashes_info, { RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; hashes_info.clear() ; @@ -2384,7 +2384,7 @@ void p3turtle::dumpState() { RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; std::cerr << std::endl ; std::cerr << "********************** Turtle router dump ******************" << std::endl ; @@ -2435,11 +2435,11 @@ void p3turtle::dumpState() void p3turtle::TS_dumpState() { RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/ - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; std::cerr << "Dumping tunnel statistics:" << std::endl; std::cerr << "TR Bounces: " << TS_request_bounces.size() << std::endl; - for(std::map >::const_iterator it(TS_request_bounces.begin());it!=TS_request_bounces.end();++it) + for(std::map >::const_iterator it(TS_request_bounces.begin());it!=TS_request_bounces.end();++it) { std::cerr << (void*)it->first << ": " ; for(uint32_t i=0;isecond.size();++i) @@ -2453,7 +2453,7 @@ void p3turtle::TS_dumpState() std::cerr << std::endl; std::cerr << "Total different requested files: " << TS_request_time_stamps.size() << std::endl; - for(std::map > >::const_iterator it(TS_request_time_stamps.begin());it!=TS_request_time_stamps.end();++it) + for(std::map > >::const_iterator it(TS_request_time_stamps.begin());it!=TS_request_time_stamps.end();++it) { std::cerr << "hash = " << it->first << ": seconds ago: " ; float average = 0 ; diff --git a/libretroshare/src/turtle/p3turtle.h b/libretroshare/src/turtle/p3turtle.h index 95e48025b..ad60cf7f2 100644 --- a/libretroshare/src/turtle/p3turtle.h +++ b/libretroshare/src/turtle/p3turtle.h @@ -207,7 +207,7 @@ class TurtleHashInfo public: std::vector tunnels ; // list of active tunnel ids for this file hash TurtleRequestId last_request ; // last request for the tunnels of this hash - time_t last_digg_time ; // last time the tunnel digging happenned. + rstime_t last_digg_time ; // last time the tunnel digging happenned. RsTurtleClientService *service ; // client service to which items should be sent. Never NULL. bool use_aggressive_mode ; // allow to re-digg tunnels even when some are already available }; @@ -436,10 +436,10 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config /// List of client services that have regitered. std::map _registered_services ; - time_t _last_clean_time ; - time_t _last_tunnel_management_time ; - time_t _last_tunnel_campaign_time ; - time_t _last_tunnel_speed_estimate_time ; + rstime_t _last_clean_time ; + rstime_t _last_tunnel_management_time ; + rstime_t _last_tunnel_campaign_time ; + rstime_t _last_tunnel_speed_estimate_time ; std::list _online_peers; diff --git a/libretroshare/src/unused/p3dsdv.cc b/libretroshare/src/unused/p3dsdv.cc index b6a3cf057..53880111b 100644 --- a/libretroshare/src/unused/p3dsdv.cc +++ b/libretroshare/src/unused/p3dsdv.cc @@ -21,7 +21,7 @@ *******************************************************************************/ #include #include -#include +#include "util/rstime.h" //#include "serialiser/rsdsdvitems.h" #include "services/p3dsdv.h" @@ -105,8 +105,8 @@ int p3Dsdv::status() int p3Dsdv::sendTables() { - time_t now = time(NULL); - time_t tt, it; + rstime_t now = time(NULL); + rstime_t tt, it; bool updateRequired = false; { RsStackMutex stack(mDsdvMtx); /****** LOCKED MUTEX *******/ @@ -156,7 +156,7 @@ void p3Dsdv::advanceLocalSequenceNumbers() { RsStackMutex stack(mDsdvMtx); /****** LOCKED MUTEX *******/ - time_t now = time(NULL); + rstime_t now = time(NULL); std::map::iterator it; for(it = mTable.begin(); it != mTable.end(); ++it) @@ -317,7 +317,7 @@ int p3Dsdv::handleDSDV(RsDsdvRouteItem *dsdv) /* iterate over the entries */ RsStackMutex stack(mDsdvMtx); /****** LOCKED MUTEX *******/ - time_t now = time(NULL); + rstime_t now = time(NULL); #ifdef DEBUG_DSDV std::cerr << "p3Dsdv::handleDSDV() Received Pkt from: " << dsdv->PeerId(); @@ -458,7 +458,7 @@ int p3Dsdv::selectStableRoutes() /* iterate over the entries */ RsStackMutex stack(mDsdvMtx); /****** LOCKED MUTEX *******/ - time_t now = time(NULL); + rstime_t now = time(NULL); #ifdef DEBUG_DSDV std::cerr << "p3Dsdv::selectStableRoutes()"; @@ -489,7 +489,7 @@ int p3Dsdv::selectStableRoutes() RsPeerId newestId; uint32_t closest = RSDSDV_MAX_DISTANCE + 1; RsPeerId closestId; - time_t closestAge = 0; + rstime_t closestAge = 0; /* find newest sequence number */ for(rit = tit->second.mAllRoutes.begin(); @@ -718,7 +718,7 @@ int p3Dsdv::addDsdvId(RsDsdvId *id, std::string realHash) std::cerr << std::endl; #endif - time_t now = time(NULL); + rstime_t now = time(NULL); /* check for duplicate */ std::map::iterator it; @@ -861,7 +861,7 @@ std::ostream &operator<<(std::ostream &out, const RsDsdvId &id) std::ostream &operator<<(std::ostream &out, const RsDsdvRoute &route) { - time_t now = time(NULL); + rstime_t now = time(NULL); out << "< Seq: " << route.mSequence << " Dist: " << route.mDistance; out << " NextHop: " << route.mNextHop; out << " recvd: " << now-route.mReceived; diff --git a/libretroshare/src/unused/p3dsdv.h b/libretroshare/src/unused/p3dsdv.h index 72327fd22..049ed8695 100644 --- a/libretroshare/src/unused/p3dsdv.h +++ b/libretroshare/src/unused/p3dsdv.h @@ -105,8 +105,8 @@ virtual int getDsdvEntry(const std::string &hash, RsDsdvTableEntry &entry); std::map mTable; - time_t mSentTablesTime; - time_t mSentIncrementTime; + rstime_t mSentTablesTime; + rstime_t mSentIncrementTime; bool mSignificantChanges; diff --git a/libretroshare/src/unused/pqiarchive.cc b/libretroshare/src/unused/pqiarchive.cc index 195d560ae..df7c57f02 100644 --- a/libretroshare/src/unused/pqiarchive.cc +++ b/libretroshare/src/unused/pqiarchive.cc @@ -43,7 +43,7 @@ #include "util/rsdebug.h" #include "util/rsstring.h" -#include +#include "util/rstime.h" const int pqiarchivezone = 9326; diff --git a/libretroshare/src/unused/rsdsdv.h b/libretroshare/src/unused/rsdsdv.h index e2d634a10..308a1c779 100644 --- a/libretroshare/src/unused/rsdsdv.h +++ b/libretroshare/src/unused/rsdsdv.h @@ -57,8 +57,8 @@ class RsDsdvRoute RsPeerId mNextHop; uint32_t mSequence; uint32_t mDistance; - time_t mReceived; - time_t mValidSince; + rstime_t mReceived; + rstime_t mValidSince; }; diff --git a/libretroshare/src/upnp/UPnPBase.cpp b/libretroshare/src/upnp/UPnPBase.cpp index 42904591d..dd99a4bc8 100644 --- a/libretroshare/src/upnp/UPnPBase.cpp +++ b/libretroshare/src/upnp/UPnPBase.cpp @@ -788,7 +788,7 @@ const std::string CUPnPService::GetStateVariable( #ifdef UPNP_DEBUG std::cerr << "CUPnPService::GetStateVariable() pausing in case of an UPnP event incomming."; #endif - time_t begin_time = time(NULL); + rstime_t begin_time = time(NULL); while (true) { if (time(NULL) - begin_time > 7) { break; @@ -1071,7 +1071,7 @@ bool CUPnPControlPoint::AddPortMappings( // Check the number of port mappings before //have a little break in case we just modified the variable, so we have to wait for an event // std::cerr << "GetStateVariable pausing in case of an UPnP event incomming."; -// time_t begin_time = time(NULL); +// rstime_t begin_time = time(NULL); // while (true) { // if (time(NULL) - begin_time > 7) { // break; @@ -1101,7 +1101,7 @@ bool CUPnPControlPoint::AddPortMappings( #ifdef UPNP_DEBUG std::cerr << "CUPnPControlPoint::AddPortMappings() GetStateVariable pausing in case of an UPnP event incomming."; #endif - time_t begin_time = time(NULL); + rstime_t begin_time = time(NULL); while (true) { if (time(NULL) - begin_time > 4) { break; diff --git a/libretroshare/src/upnp/upnputil.c b/libretroshare/src/upnp/upnputil.c index 6d5bf326c..f71cde6c6 100644 --- a/libretroshare/src/upnp/upnputil.c +++ b/libretroshare/src/upnp/upnputil.c @@ -23,7 +23,7 @@ #include "upnp/upnputil.h" #if MINIUPNPC_API_VERSION >= -4//1.0 2008/02/18 -#include +#include "util/rstime.h" #endif /* protofix() checks if protocol is "UDP" or "TCP" @@ -55,7 +55,7 @@ void DisplayInfos(struct UPNPUrls * urls, char lastconnerr[64]; unsigned int uptime; unsigned int brUp, brDown; - time_t timenow, timestarted; + rstime_t timenow, timestarted; int r; #if MINIUPNPC_API_VERSION >= -2//1.4 2010/12/09 const char * servicetype = data->first.servicetype; diff --git a/libretroshare/src/util/dnsresolver.cc b/libretroshare/src/util/dnsresolver.cc index 4807b1322..58d360027 100644 --- a/libretroshare/src/util/dnsresolver.cc +++ b/libretroshare/src/util/dnsresolver.cc @@ -36,10 +36,10 @@ #include #include #include -#include +#include "util/rstime.h" -const time_t MAX_TIME_BEFORE_RETRY = 300 ; /* seconds before retrying an ip address */ -const time_t MAX_KEEP_DNS_ENTRY = 3600 ; /* seconds during which a DNS entry is considered valid */ +const rstime_t MAX_TIME_BEFORE_RETRY = 300 ; /* seconds before retrying an ip address */ +const rstime_t MAX_KEEP_DNS_ENTRY = 3600 ; /* seconds during which a DNS entry is considered valid */ static const std::string ADDR_AGENT = "Mozilla/5.0"; @@ -51,7 +51,7 @@ void *solveDNSEntries(void *p) while(more_to_go) { // get an address request - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; more_to_go = false ; std::string next_call = "" ; @@ -152,7 +152,7 @@ bool DNSResolver::getIPAddressFromString(const std::string& server_name,struct s RsStackMutex mut(_rdnsMtx) ; std::map::iterator it(_addr_map->find(server_name)) ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; AddrInfo *addr_info ; if(it != _addr_map->end()) diff --git a/libretroshare/src/util/dnsresolver.h b/libretroshare/src/util/dnsresolver.h index 9db589825..a85c6cfb1 100644 --- a/libretroshare/src/util/dnsresolver.h +++ b/libretroshare/src/util/dnsresolver.h @@ -50,7 +50,7 @@ class DNSResolver struct AddrInfo { uint32_t state ; // state: Looked-up, not found, have - time_t last_lookup_time ; // last lookup time + rstime_t last_lookup_time ; // last lookup time struct sockaddr_storage addr ; }; friend void *solveDNSEntries(void *p) ; diff --git a/libretroshare/src/util/extaddrfinder.cc b/libretroshare/src/util/extaddrfinder.cc index fbed6fe85..034fef58d 100644 --- a/libretroshare/src/util/extaddrfinder.cc +++ b/libretroshare/src/util/extaddrfinder.cc @@ -36,7 +36,7 @@ #include #include #include -#include +#include "util/rstime.h" const uint32_t MAX_IP_STORE = 300; /* seconds ip address timeout */ @@ -253,7 +253,7 @@ bool ExtAddrFinder::hasValidIP(struct sockaddr_storage &addr) addr = mAddr; } } - time_t delta; + rstime_t delta; { RsStackMutex mut(mAddrMtx) ; //timeout the current ip diff --git a/libretroshare/src/util/extaddrfinder.h b/libretroshare/src/util/extaddrfinder.h index 2b4bd4da3..d0f1db97b 100644 --- a/libretroshare/src/util/extaddrfinder.h +++ b/libretroshare/src/util/extaddrfinder.h @@ -45,7 +45,7 @@ class ExtAddrFinder friend void* doExtAddrSearch(void *p) ; RsMutex mAddrMtx ; - time_t mFoundTS; + rstime_t mFoundTS; struct sockaddr_storage mAddr; bool mFound ; bool mSearching ; diff --git a/libretroshare/src/util/folderiterator.cc b/libretroshare/src/util/folderiterator.cc index 73afebeab..3a390af75 100644 --- a/libretroshare/src/util/folderiterator.cc +++ b/libretroshare/src/util/folderiterator.cc @@ -24,7 +24,7 @@ #include #include #include -#include +#include "util/rstime.h" #ifdef WINDOWS_SYS #include "util/rswin.h" @@ -227,12 +227,12 @@ bool FolderIterator::readdir() #endif } -time_t FolderIterator::dir_modtime() const { return mFolderModTime ; } +rstime_t FolderIterator::dir_modtime() const { return mFolderModTime ; } const std::string& FolderIterator::file_fullpath() { return mFullPath ; } const std::string& FolderIterator::file_name() { return mFileName ; } uint64_t FolderIterator::file_size() { return mFileSize ; } -time_t FolderIterator::file_modtime() { return mFileModTime ; } +rstime_t FolderIterator::file_modtime() { return mFileModTime ; } uint8_t FolderIterator::file_type() { return mType ; } bool FolderIterator::closedir() diff --git a/libretroshare/src/util/folderiterator.h b/libretroshare/src/util/folderiterator.h index 3232a4b47..9117107c3 100644 --- a/libretroshare/src/util/folderiterator.h +++ b/libretroshare/src/util/folderiterator.h @@ -36,6 +36,7 @@ #include #endif +#include "util/rstime.h" namespace librs { namespace util { @@ -52,7 +53,7 @@ public: }; // info about current parent directory - time_t dir_modtime() const ; + rstime_t dir_modtime() const ; // info about directory content @@ -66,7 +67,7 @@ public: const std::string& file_fullpath() ; uint64_t file_size() ; uint8_t file_type() ; - time_t file_modtime() ; + rstime_t file_modtime() ; private: bool is_open; @@ -82,8 +83,8 @@ private: #endif bool updateFileInfo(bool &should_skip) ; - time_t mFileModTime ; - time_t mFolderModTime ; + rstime_t mFileModTime ; + rstime_t mFolderModTime ; uint64_t mFileSize ; uint8_t mType ; std::string mFileName ; diff --git a/libretroshare/src/util/retrodb.cc b/libretroshare/src/util/retrodb.cc index 5a903dd62..57d062812 100644 --- a/libretroshare/src/util/retrodb.cc +++ b/libretroshare/src/util/retrodb.cc @@ -23,7 +23,7 @@ #include #include #include -#include +#include "util/rstime.h" #include #include "retrodb.h" @@ -147,7 +147,7 @@ bool RetroDb::execSQL(const std::string &query){ uint32_t delta = 3; - time_t stamp = time(NULL), now = 0; + rstime_t stamp = time(NULL), now = 0; bool timeOut = false, ok = false; while(!timeOut){ @@ -348,7 +348,7 @@ bool RetroDb::execSQL_bind(const std::string &query, std::list ¶ } uint32_t delta = 3; - time_t stamp = time(NULL), now = 0; + rstime_t stamp = time(NULL), now = 0; bool timeOut = false, ok = false; while(!timeOut){ diff --git a/libretroshare/src/util/rsdebug.cc b/libretroshare/src/util/rsdebug.cc index 434b06363..76c8a0279 100644 --- a/libretroshare/src/util/rsdebug.cc +++ b/libretroshare/src/util/rsdebug.cc @@ -26,7 +26,7 @@ #include #include -#include +#include "util/rstime.h" const int RS_DEBUG_STDERR = 1; /* stuff goes to stderr */ const int RS_DEBUG_LOGFILE = 2; /* stuff goes to logfile */ @@ -147,8 +147,8 @@ void rslog(const RsLog::logLvl lvl, RsLog::logInfo *info, const std::string &msg return; { - RsStackMutex stack(logMtx); /******** LOCKED ****************/ - time_t t = time(NULL); + RS_STACK_MUTEX(logMtx); + rstime_t t = time(NULL); if (debugMode == RS_DEBUG_LOGCRASH) { diff --git a/libretroshare/src/util/rsdiscspace.cc b/libretroshare/src/util/rsdiscspace.cc index bf89d30bb..a394cd4e5 100644 --- a/libretroshare/src/util/rsdiscspace.cc +++ b/libretroshare/src/util/rsdiscspace.cc @@ -21,7 +21,7 @@ *******************************************************************************/ #include #include -#include +#include "util/rstime.h" #include "rsserver/p3face.h" #include "retroshare/rsfiles.h" #include "retroshare/rsiface.h" @@ -49,7 +49,7 @@ * #define DEBUG_RSDISCSPACE */ -time_t RsDiscSpace::_last_check[RS_DIRECTORY_COUNT] = { 0,0,0,0 } ; +rstime_t RsDiscSpace::_last_check[RS_DIRECTORY_COUNT] = { 0,0,0,0 } ; uint32_t RsDiscSpace::_size_limit_mb = 100 ; uint32_t RsDiscSpace::_current_size[RS_DIRECTORY_COUNT] = { 10000,10000,10000,10000 } ; bool RsDiscSpace::_last_res[RS_DIRECTORY_COUNT] = { true,true,true,true }; @@ -142,7 +142,7 @@ bool RsDiscSpace::checkForDiscSpace(RsDiscSpace::DiscLocation loc) if( (_partials_path == "" && loc == RS_PARTIALS_DIRECTORY) || (_download_path == "" && loc == RS_DOWNLOAD_DIRECTORY)) throw std::runtime_error("Download path and partial path not properly set in RsDiscSpace. Please call RsDiscSpace::setPartialsPath() and RsDiscSpace::setDownloadPath()") ; - time_t now = time(NULL) ; + rstime_t now = time(NULL) ; if(_last_check[loc]+DELAY_BETWEEN_CHECKS < now) { diff --git a/libretroshare/src/util/rsdiscspace.h b/libretroshare/src/util/rsdiscspace.h index 1262fd5e4..834561e6a 100644 --- a/libretroshare/src/util/rsdiscspace.h +++ b/libretroshare/src/util/rsdiscspace.h @@ -50,7 +50,7 @@ class RsDiscSpace static RsMutex _mtx ; - static time_t _last_check[RS_DIRECTORY_COUNT] ; + static rstime_t _last_check[RS_DIRECTORY_COUNT] ; static uint32_t _size_limit_mb ; static uint32_t _current_size[RS_DIRECTORY_COUNT] ; static bool _last_res[RS_DIRECTORY_COUNT] ; diff --git a/libretroshare/src/util/rsmemcache.h b/libretroshare/src/util/rsmemcache.h index a0d188295..95249c28e 100644 --- a/libretroshare/src/util/rsmemcache.h +++ b/libretroshare/src/util/rsmemcache.h @@ -23,7 +23,7 @@ #define RS_UTIL_MEM_CACHE #include -#include +#include "util/rstime.h" #include #include #include @@ -73,7 +73,7 @@ public: uint32_t size() const { return mDataMap.size() ; } private: - bool update_lrumap(const Key &key, time_t old_ts, time_t new_ts); + bool update_lrumap(const Key &key, rstime_t old_ts, rstime_t new_ts); bool discard_LRU(int count_to_clear); // internal class. @@ -81,16 +81,16 @@ private: { public: cache_data() { return; } - cache_data(Key in_key, Value in_data, time_t in_ts) + cache_data(Key in_key, Value in_data, rstime_t in_ts) :key(in_key), data(in_data), ts(in_ts) { return; } Key key; Value data; - time_t ts; + rstime_t ts; }; std::map mDataMap; - std::multimap mLruMap; + std::multimap mLruMap; uint32_t mDataCount; uint32_t mMaxSize; std::string mName; @@ -170,8 +170,8 @@ template bool RsMemCache::fetch(const Key &k data = it->second.data; /* update ts on data */ - time_t old_ts = it->second.ts; - time_t new_ts = time(NULL); + rstime_t old_ts = it->second.ts; + rstime_t new_ts = time(NULL); it->second.ts = new_ts; update_lrumap(key, old_ts, new_ts); @@ -209,8 +209,8 @@ template bool RsMemCache::erase(const Key &k /* get timestamps */ - time_t old_ts = it->second.ts; - time_t new_ts = 0; + rstime_t old_ts = it->second.ts; + rstime_t new_ts = 0; // remove from lru. mDataMap.erase(it); @@ -241,7 +241,7 @@ template Value &RsMemCache::ref(const Key &k #endif // DEBUG_RSMEMCACHE // insert operation. - time_t new_ts = 0; + rstime_t new_ts = 0; Value data; mDataMap[key] = cache_data(key, data, new_ts); mDataCount++; @@ -259,8 +259,8 @@ template Value &RsMemCache::ref(const Key &k #endif // DEBUG_RSMEMCACHE /* update ts on data */ - time_t old_ts = it->second.ts; - time_t new_ts = time(NULL); + rstime_t old_ts = it->second.ts; + rstime_t new_ts = time(NULL); it->second.ts = new_ts; update_lrumap(key, old_ts, new_ts); @@ -279,8 +279,8 @@ template bool RsMemCache::store(const Key &k #endif // DEBUG_RSMEMCACHE /* update lrumap entry */ - time_t old_ts = 0; - time_t new_ts = time(NULL); + rstime_t old_ts = 0; + rstime_t new_ts = time(NULL); // For consistency typename std::map::const_iterator it; @@ -309,7 +309,7 @@ template bool RsMemCache::store(const Key &k } -template bool RsMemCache::update_lrumap(const Key &key, time_t old_ts, time_t new_ts) +template bool RsMemCache::update_lrumap(const Key &key, rstime_t old_ts, rstime_t new_ts) { if (old_ts == 0) { @@ -324,9 +324,9 @@ template bool RsMemCache::update_lrumap(cons } /* find old entry */ - typename std::multimap::iterator mit; - typename std::multimap::iterator sit = mLruMap.lower_bound(old_ts); - typename std::multimap::iterator eit = mLruMap.upper_bound(old_ts); + typename std::multimap::iterator mit; + typename std::multimap::iterator sit = mLruMap.lower_bound(old_ts); + typename std::multimap::iterator eit = mLruMap.upper_bound(old_ts); for(mit = sit; mit != eit; ++mit) { @@ -405,7 +405,7 @@ template bool RsMemCache::discard_LRU(int co { while(count_to_clear > 0) { - typename std::multimap::iterator mit = mLruMap.begin(); + typename std::multimap::iterator mit = mLruMap.begin(); if (mit != mLruMap.end()) { Key key = mit->second; @@ -451,8 +451,8 @@ template bool RsMemCache::discard_LRU(int co // These aren't templated functions. template void RsMemCache::printStats(std::ostream &out) { - typename std::multimap::iterator mit = mLruMap.begin(); - time_t age = 0; + typename std::multimap::iterator mit = mLruMap.begin(); + rstime_t age = 0; if (mit != mLruMap.end()) { age = time(NULL) - mit->first; diff --git a/libretroshare/src/util/rsprint.cc b/libretroshare/src/util/rsprint.cc index dca3d925c..63609d6f9 100644 --- a/libretroshare/src/util/rsprint.cc +++ b/libretroshare/src/util/rsprint.cc @@ -28,7 +28,7 @@ #include #ifdef WINDOWS_SYS -#include +#include "util/rstime.h" #include #endif diff --git a/libretroshare/src/util/rsrandom.cc b/libretroshare/src/util/rsrandom.cc index 86f93bf5f..bc358064e 100644 --- a/libretroshare/src/util/rsrandom.cc +++ b/libretroshare/src/util/rsrandom.cc @@ -37,7 +37,7 @@ RsMutex RSRandom::rndMtx("RSRandom") ; // have anyway) // #ifdef WINDOWS_SYS -#include +#include "util/rstime.h" #ifdef WIN_PTHREADS_H static bool auto_seed = RSRandom::seed( (time(NULL) + ((uint32_t) pthread_self())*0x1293fe)^0x18e34a12 ) ; #else diff --git a/libretroshare/src/util/rsrecogn.cc b/libretroshare/src/util/rsrecogn.cc index 581ec9268..b88c7a090 100644 --- a/libretroshare/src/util/rsrecogn.cc +++ b/libretroshare/src/util/rsrecogn.cc @@ -91,7 +91,7 @@ bool RsRecogn::loadSigningKeys(std::map &signM } - time_t now = time(NULL); + rstime_t now = time(NULL); for(int i = 0; i < NUM_RECOGN_SIGN_KEYS; i++) { diff --git a/libretroshare/src/util/rsthreads.cc b/libretroshare/src/util/rsthreads.cc index 755134817..1e3196036 100644 --- a/libretroshare/src/util/rsthreads.cc +++ b/libretroshare/src/util/rsthreads.cc @@ -24,7 +24,7 @@ #include // for usleep() #include // for errno #include -#include +#include "util/rstime.h" #include "util/rstime.h" @@ -265,7 +265,7 @@ void RsQueueThread::data_tick() { doneWork = true; } - time_t now = time(NULL); + rstime_t now = time(NULL); if (doneWork) { mLastWork = now; diff --git a/libretroshare/src/util/rsthreads.h b/libretroshare/src/util/rsthreads.h index dfad45e2c..630c136a8 100644 --- a/libretroshare/src/util/rsthreads.h +++ b/libretroshare/src/util/rsthreads.h @@ -27,7 +27,9 @@ #include #include #include + #include +#include "util/rstime.h" /* RsIface Thread Wrappers */ @@ -309,7 +311,7 @@ private: uint32_t mMinSleep; /* ms */ uint32_t mMaxSleep; /* ms */ uint32_t mLastSleep; /* ms */ - time_t mLastWork; /* secs */ + rstime_t mLastWork; /* secs */ float mRelaxFactor; }; diff --git a/libretroshare/src/util/rstickevent.cc b/libretroshare/src/util/rstickevent.cc index 4c9cdc37b..d596d417c 100644 --- a/libretroshare/src/util/rstickevent.cc +++ b/libretroshare/src/util/rstickevent.cc @@ -33,14 +33,14 @@ void RsTickEvent::tick_events() std::cerr << std::endl; #endif - time_t now = time(NULL); + rstime_t now = time(NULL); { RsStackMutex stack(mEventMtx); /********** STACK LOCKED MTX ******/ #ifdef DEBUG_EVENTS if (!mEvents.empty()) { - std::multimap::iterator it; + std::multimap::iterator it; for(it = mEvents.begin(); it != mEvents.end(); ++it) { @@ -70,7 +70,7 @@ void RsTickEvent::tick_events() RsStackMutex stack(mEventMtx); /********** STACK LOCKED MTX ******/ while((!mEvents.empty()) && (mEvents.begin()->first <= now)) { - std::multimap::iterator it = mEvents.begin(); + std::multimap::iterator it = mEvents.begin(); uint32_t event_type = it->second.mEventType; toProcess.push_back(it->second); mEvents.erase(it); @@ -103,7 +103,7 @@ void RsTickEvent::schedule_now(uint32_t event_type, const std::string &elabel) RsTickEvent::schedule_in(event_type, 0, elabel); } -void RsTickEvent::schedule_event(uint32_t event_type, time_t when, const std::string &elabel) +void RsTickEvent::schedule_event(uint32_t event_type, rstime_t when, const std::string &elabel) { RsStackMutex stack(mEventMtx); /********** STACK LOCKED MTX ******/ mEvents.insert(std::make_pair(when, EventData(event_type, elabel))); @@ -125,7 +125,7 @@ void RsTickEvent::schedule_in(uint32_t event_type, uint32_t in_secs, const std:: std::cerr << std::endl; #endif // DEBUG_EVENTS - time_t event_time = time(NULL) + in_secs; + rstime_t event_time = time(NULL) + in_secs; RsTickEvent::schedule_event(event_type, event_time, elabel); } @@ -156,7 +156,7 @@ int32_t RsTickEvent::event_count(uint32_t event_type) bool RsTickEvent::prev_event_ago(uint32_t event_type, int32_t &age) { RsStackMutex stack(mEventMtx); /********** STACK LOCKED MTX ******/ - std::map::iterator it; + std::map::iterator it; it = mPreviousEvent.find(event_type); if (it == mPreviousEvent.end()) diff --git a/libretroshare/src/util/rstickevent.h b/libretroshare/src/util/rstickevent.h index 4b08d9139..7f2c9188c 100644 --- a/libretroshare/src/util/rstickevent.h +++ b/libretroshare/src/util/rstickevent.h @@ -29,7 +29,7 @@ */ #include -#include +#include "util/rstime.h" #include "util/rsthreads.h" @@ -43,7 +43,7 @@ void tick_events(); void schedule_now(uint32_t event_type); void schedule_now(uint32_t event_type, const std::string &elabel); -void schedule_event(uint32_t event_type, time_t when, const std::string &elabel); +void schedule_event(uint32_t event_type, rstime_t when, const std::string &elabel); void schedule_in(uint32_t event_type, uint32_t in_secs); void schedule_in(uint32_t event_type, uint32_t in_secs, const std::string &elabel); @@ -74,8 +74,8 @@ void note_event_locked(uint32_t event_type); RsMutex mEventMtx; std::map mEventCount; - std::map mPreviousEvent; - std::multimap mEvents; + std::map mPreviousEvent; + std::multimap mEvents; }; #endif // RS_UTIL_TICK_EVENT diff --git a/libretroshare/src/util/rstime.h b/libretroshare/src/util/rstime.h index a9b3dfd5b..b88abc77c 100644 --- a/libretroshare/src/util/rstime.h +++ b/libretroshare/src/util/rstime.h @@ -19,8 +19,25 @@ * along with this program. If not, see . * * * *******************************************************************************/ -#include +#pragma once +#include +#include +#include // Added for comfort of users of this util header + +/** + * Safer alternative to time_t. + * As time_t have not same lenght accross platforms, even though representation + * is not guaranted to be the same but we found it being number of seconds since + * the epoch for time points in all platforms we could test, or plain seconds + * for intervals. + * Still in some platforms it's 32bit long and in other 64bit long. + * To avoid uncompatibility due to different serialzation format use this + * reasonably safe alternative instead. + */ +typedef int64_t rstime_t; + +// Do we really need this? Our names have rs prefix to avoid pollution already! namespace rstime { /*! diff --git a/libretroshare/src/util/smallobject.cc b/libretroshare/src/util/smallobject.cc index 3e1759fed..5559e2af6 100644 --- a/libretroshare/src/util/smallobject.cc +++ b/libretroshare/src/util/smallobject.cc @@ -287,8 +287,8 @@ void *SmallObject::operator new(size_t size) bool print=false ; { RsStackMutex m(_mtx) ; - static time_t last_time = 0 ; - time_t now = time(NULL) ; + static rstime_t last_time = 0 ; + rstime_t now = time(NULL) ; if(now > last_time + 20) { last_time = now ; diff --git a/libretroshare/src/zeroconf/p3zcnatassist.h b/libretroshare/src/zeroconf/p3zcnatassist.h index 9e5bcc313..d103c91d5 100644 --- a/libretroshare/src/zeroconf/p3zcnatassist.h +++ b/libretroshare/src/zeroconf/p3zcnatassist.h @@ -101,7 +101,7 @@ virtual bool statusPortForward(const uint32_t fwdId, PortForwardParams ¶m DNSServiceRef mMappingRef; uint32_t mMappingStatus; - time_t mMappingStatusTS; + rstime_t mMappingStatusTS; }; #endif /* MRK_P3_ZC_NAT_ASSIST_H */ diff --git a/libretroshare/src/zeroconf/p3zeroconf.cc b/libretroshare/src/zeroconf/p3zeroconf.cc index 65aedc7f6..6a29a8934 100644 --- a/libretroshare/src/zeroconf/p3zeroconf.cc +++ b/libretroshare/src/zeroconf/p3zeroconf.cc @@ -359,7 +359,7 @@ void p3ZeroConf::checkServiceFDs() { locked_checkFD(mResolveRef); - time_t age = time(NULL) - mResolveStatusTS; + rstime_t age = time(NULL) - mResolveStatusTS; if (age > ZC_MAX_RESOLVE_TIME) { std::cerr << "p3ZeroConf::checkServiceFDs() Killing very old Resolve request"; @@ -374,7 +374,7 @@ void p3ZeroConf::checkServiceFDs() { locked_checkFD(mQueryRef); - time_t age = time(NULL) - mQueryStatusTS; + rstime_t age = time(NULL) - mQueryStatusTS; if (age > ZC_MAX_QUERY_TIME) { std::cerr << "p3ZeroConf::checkServiceFDs() Killing very old Query request"; @@ -494,7 +494,7 @@ int p3ZeroConf::checkLocationResults() std::cerr << "sslid = " << lr.sslId; std::cerr << std::endl; - time_t now = time(NULL); + rstime_t now = time(NULL); mPeerMgr->addFriend(lr.sslId, lr.gpgId, RS_NET_MODE_UDP, RS_VS_DISC_FULL, RS_VS_DHT_FULL, now); return 1; } @@ -555,7 +555,7 @@ int p3ZeroConf::checkQueryResults() std::cerr << "sslid = " << qr.sslId; std::cerr << std::endl; - time_t now = time(NULL); + rstime_t now = time(NULL); uint32_t flags = RS_CB_FLAG_MODE_TCP; uint32_t source = RS_CB_DHT; // SHOULD ADD NEW SOURCE ZC??? struct sockaddr_storage dummyProxyAddr, dummySrcAddr; @@ -1370,7 +1370,7 @@ class RsZCBrowseDetails RsZCBrowseDetails(); uint32_t mBrowseState; - time_t mBrowseUpdate; + rstime_t mBrowseUpdate; uint32_t mBrowseInterfaceIndex; std::string mBrowserServiceName; @@ -1398,7 +1398,7 @@ class RsZCPeerDetails /* Browse Info */ uint32_t mBrowseState; - time_t mBrowseUpdate; + rstime_t mBrowseUpdate; uint32_t mBrowseInterfaceIndex; std::string mBrowserServiceName; diff --git a/libretroshare/src/zeroconf/p3zeroconf.h b/libretroshare/src/zeroconf/p3zeroconf.h index 9b7e21b5c..317659c4a 100644 --- a/libretroshare/src/zeroconf/p3zeroconf.h +++ b/libretroshare/src/zeroconf/p3zeroconf.h @@ -110,14 +110,14 @@ class zcLocationDetails { public: std::string mSslId; - time_t mFoundTs; + rstime_t mFoundTs; uint32_t mStatus; std::string mHostTarget; std::string mFullName; uint16_t mPort; struct sockaddr_storage mAddress; - time_t mAddrTs; + rstime_t mAddrTs; }; @@ -262,10 +262,10 @@ virtual bool setAttachMode(bool on); uint32_t mResolveStatus; uint32_t mQueryStatus; - time_t mRegisterStatusTS; - time_t mBrowseStatusTS; - time_t mResolveStatusTS; - time_t mQueryStatusTS; + rstime_t mRegisterStatusTS; + rstime_t mBrowseStatusTS; + rstime_t mResolveStatusTS; + rstime_t mQueryStatusTS; std::string mQuerySslId; std::string mQueryGpgId; @@ -277,7 +277,7 @@ std::list mQueryResults; - time_t mMinuteTS; + rstime_t mMinuteTS; std::map mPeerDetails; }; From 77d938bf52bed6aa96dc960f4e0e4f6a527ef967 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sun, 7 Oct 2018 13:07:22 +0200 Subject: [PATCH 33/39] Remove _USE_32BIT_TIME_T windows define Why did we added it in first place? --- libbitdht/src/libbitdht.pro | 2 +- openpgpsdk/src/openpgpsdk.pro | 2 +- plugins/Common/retroshare_plugin.pri | 2 +- retroshare.pri | 2 +- supportlibs/pegmarkdown/pegmarkdown.pro | 2 -- tests/librssimulator/librssimulator.pro | 2 +- tests/unittests/unittests.pro | 2 +- 7 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libbitdht/src/libbitdht.pro b/libbitdht/src/libbitdht.pro index e375c5b90..c607fc58c 100644 --- a/libbitdht/src/libbitdht.pro +++ b/libbitdht/src/libbitdht.pro @@ -78,7 +78,7 @@ win32 { QMAKE_CC = $${QMAKE_CXX} OBJECTS_DIR = temp/obj MOC_DIR = temp/moc - DEFINES *= STATICLIB WIN32_LEAN_AND_MEAN _USE_32BIT_TIME_T + DEFINES *= STATICLIB WIN32_LEAN_AND_MEAN # These have been replaced by _WIN32 && __MINGW32__ #DEFINES *= WINDOWS_SYS WIN32 STATICLIB MINGW diff --git a/openpgpsdk/src/openpgpsdk.pro b/openpgpsdk/src/openpgpsdk.pro index f667a0d23..40bdfca4c 100644 --- a/openpgpsdk/src/openpgpsdk.pro +++ b/openpgpsdk/src/openpgpsdk.pro @@ -23,7 +23,7 @@ win32-g++ { HEADERS += openpgpsdk/opsstring.h SOURCES += openpgpsdk/opsstring.c - DEFINES *= WIN32_LEAN_AND_MEAN _USE_32BIT_TIME_T + DEFINES *= WIN32_LEAN_AND_MEAN # Switch off optimization for release version QMAKE_CXXFLAGS_RELEASE -= -O2 diff --git a/plugins/Common/retroshare_plugin.pri b/plugins/Common/retroshare_plugin.pri index c6124862c..2f4d7a6a1 100644 --- a/plugins/Common/retroshare_plugin.pri +++ b/plugins/Common/retroshare_plugin.pri @@ -44,7 +44,7 @@ win32 { RCC_DIR = temp/qrc UI_DIR = temp/ui - DEFINES += WINDOWS_SYS WIN32 STATICLIB MINGW WIN32_LEAN_AND_MEAN _USE_32BIT_TIME_T + DEFINES += WINDOWS_SYS WIN32 STATICLIB MINGW WIN32_LEAN_AND_MEAN #DEFINES += MINIUPNPC_VERSION=13 # DESTDIR = lib diff --git a/retroshare.pri b/retroshare.pri index 497281134..3ac44e038 100644 --- a/retroshare.pri +++ b/retroshare.pri @@ -531,7 +531,7 @@ win32-g++ { RS_UPNP_LIB = miniupnpc - DEFINES *= NOGDI WIN32 WIN32_LEAN_AND_MEAN WINDOWS_SYS _USE_32BIT_TIME_T + DEFINES *= NOGDI WIN32 WIN32_LEAN_AND_MEAN WINDOWS_SYS # This defines the platform to be WinXP or later and is needed for # getaddrinfo (_WIN32_WINNT_WINXP) diff --git a/supportlibs/pegmarkdown/pegmarkdown.pro b/supportlibs/pegmarkdown/pegmarkdown.pro index cc21ccaf3..02d63d1ab 100644 --- a/supportlibs/pegmarkdown/pegmarkdown.pro +++ b/supportlibs/pegmarkdown/pegmarkdown.pro @@ -44,8 +44,6 @@ win32 { CONFIG += dummy_glib - DEFINES *= _USE_32BIT_TIME_T - # With GCC package 4.8, including io.h either directly or indirectly causes off64_t not to be defined when compiling with -ansi switch DEFINES *= off64_t=_off64_t DEFINES *= off_t=_off_t diff --git a/tests/librssimulator/librssimulator.pro b/tests/librssimulator/librssimulator.pro index 94c942f53..b51a1f212 100644 --- a/tests/librssimulator/librssimulator.pro +++ b/tests/librssimulator/librssimulator.pro @@ -148,7 +148,7 @@ win32 { QMAKE_CC = $${QMAKE_CXX} OBJECTS_DIR = temp/obj MOC_DIR = temp/moc - DEFINES *= WINDOWS_SYS WIN32 STATICLIB MINGW WIN32_LEAN_AND_MEAN _USE_32BIT_TIME_T + DEFINES *= WINDOWS_SYS WIN32 STATICLIB MINGW WIN32_LEAN_AND_MEAN DEFINES *= MINIUPNPC_VERSION=13 # This defines the platform to be WinXP or later and is needed for getaddrinfo (_WIN32_WINNT_WINXP) DEFINES *= WINVER=0x0501 diff --git a/tests/unittests/unittests.pro b/tests/unittests/unittests.pro index c17be5b77..439ca9da9 100644 --- a/tests/unittests/unittests.pro +++ b/tests/unittests/unittests.pro @@ -149,7 +149,7 @@ win32 { LIBS += -luuid -lole32 -liphlpapi -lcrypt32 -lgdi32 LIBS += -lwinmm - DEFINES *= WINDOWS_SYS WIN32_LEAN_AND_MEAN _USE_32BIT_TIME_T + DEFINES *= WINDOWS_SYS WIN32_LEAN_AND_MEAN # create lib directory message(CHK_DIR_EXISTS=$(CHK_DIR_EXISTS)) From ddf31645451a2a113030a653b3f2dcd81fd0bd51 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sun, 7 Oct 2018 13:41:04 +0200 Subject: [PATCH 34/39] Fix ctime(&rstime_t) error on windows rstime_t not neccesary in those cases so use plain time_t instead --- libretroshare/src/dht/p3bitdht_peernet.cc | 2 +- libretroshare/src/upnp/upnputil.c | 2 +- libretroshare/src/util/rsdebug.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/dht/p3bitdht_peernet.cc b/libretroshare/src/dht/p3bitdht_peernet.cc index e4c266279..3d13a591b 100644 --- a/libretroshare/src/dht/p3bitdht_peernet.cc +++ b/libretroshare/src/dht/p3bitdht_peernet.cc @@ -1101,7 +1101,7 @@ int p3BitDht::tick() minuteTick(); #ifdef DEBUG_PEERNET_COMMON - rstime_t now = time(NULL); + time_t now = time(NULL); // Don't use rstime_t here or ctime break on windows std::cerr << "p3BitDht::tick() TIME: " << ctime(&now) << std::endl; std::cerr.flush(); #endif diff --git a/libretroshare/src/upnp/upnputil.c b/libretroshare/src/upnp/upnputil.c index f71cde6c6..8e9177451 100644 --- a/libretroshare/src/upnp/upnputil.c +++ b/libretroshare/src/upnp/upnputil.c @@ -55,7 +55,7 @@ void DisplayInfos(struct UPNPUrls * urls, char lastconnerr[64]; unsigned int uptime; unsigned int brUp, brDown; - rstime_t timenow, timestarted; + time_t timenow, timestarted; // Don't use rstime_t here or ctime break on windows int r; #if MINIUPNPC_API_VERSION >= -2//1.4 2010/12/09 const char * servicetype = data->first.servicetype; diff --git a/libretroshare/src/util/rsdebug.cc b/libretroshare/src/util/rsdebug.cc index 76c8a0279..4c126b656 100644 --- a/libretroshare/src/util/rsdebug.cc +++ b/libretroshare/src/util/rsdebug.cc @@ -148,7 +148,7 @@ void rslog(const RsLog::logLvl lvl, RsLog::logInfo *info, const std::string &msg { RS_STACK_MUTEX(logMtx); - rstime_t t = time(NULL); + time_t t = time(NULL); // Don't use rstime_t here or ctime break on windows if (debugMode == RS_DEBUG_LOGCRASH) { From 72d83643708ba0cde3c207bd63b3149b498e55a1 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sun, 7 Oct 2018 14:03:27 +0200 Subject: [PATCH 35/39] libresapi fix compile error on windows due to time_t usage --- libresapi/src/api/ChatHandler.cpp | 8 ++++---- libresapi/src/api/ChatHandler.h | 3 ++- libresapi/src/api/IdentityHandler.cpp | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libresapi/src/api/ChatHandler.cpp b/libresapi/src/api/ChatHandler.cpp index b7917eb19..a266a8540 100644 --- a/libresapi/src/api/ChatHandler.cpp +++ b/libresapi/src/api/ChatHandler.cpp @@ -132,8 +132,8 @@ public: SendLobbyParticipantsTask(RsIdentity* idservice, ChatHandler::LobbyParticipantsInfo pi): GxsResponseTask(idservice, 0), mParticipantsInfo(pi) { - const std::map& map = mParticipantsInfo.participants; - for(std::map::const_iterator mit = map.begin(); mit != map.end(); ++mit) + const auto& map = mParticipantsInfo.participants; + for(auto mit = map.begin(); mit != map.end(); ++mit) { requestGxsId(mit->first); } @@ -144,8 +144,8 @@ protected: virtual void gxsDoWork(Request &/*req*/, Response &resp) { resp.mDataStream.getStreamToMember(); - const std::map& map = mParticipantsInfo.participants; - for(std::map::const_iterator mit = map.begin(); mit != map.end(); ++mit) + const auto& map = mParticipantsInfo.participants; + for(auto mit = map.begin(); mit != map.end(); ++mit) { StreamBase& stream = resp.mDataStream.getStreamToMember(); double last_active = mit->second; diff --git a/libresapi/src/api/ChatHandler.h b/libresapi/src/api/ChatHandler.h index d635c02dc..57b227a0c 100644 --- a/libresapi/src/api/ChatHandler.h +++ b/libresapi/src/api/ChatHandler.h @@ -26,6 +26,7 @@ #include "StateTokenServer.h" #include #include +#include "util/rstime.h" class RsPeers; class RsIdentity; @@ -117,7 +118,7 @@ public: class LobbyParticipantsInfo{ public: StateToken state_token; - std::map participants; + std::map participants; }; class ChatInfo{ diff --git a/libresapi/src/api/IdentityHandler.cpp b/libresapi/src/api/IdentityHandler.cpp index 9e7228759..71c2c79b4 100644 --- a/libresapi/src/api/IdentityHandler.cpp +++ b/libresapi/src/api/IdentityHandler.cpp @@ -521,7 +521,7 @@ void IdentityHandler::handleGetIdentityDetails(Request& req, Response& resp) StreamBase& usagesStream = resp.mDataStream.getStreamToMember("usages"); usagesStream.getStreamToMember(); - for(std::map::const_iterator it(details.mUseCases.begin()); it != details.mUseCases.end(); ++it) + for(auto it(details.mUseCases.begin()); it != details.mUseCases.end(); ++it) { usagesStream.getStreamToMember() << makeKeyValue("usage_time", (uint32_t)data.mLastUsageTS) From 6db23267c35911d1f3dc37fba76f9b67a56fc3e5 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sun, 7 Oct 2018 14:34:28 +0200 Subject: [PATCH 36/39] retroshare-gui fix windows compilation error due to time_t usage --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 9 +++++---- retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp | 2 +- retroshare-gui/src/gui/chat/ChatWidget.cpp | 4 ++-- .../src/gui/statistics/GxsTransportStatistics.cpp | 2 +- .../src/gui/statistics/GxsTransportStatistics.h | 3 ++- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 5c9bce46b..563a1e1ab 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -44,6 +44,7 @@ #include "retroshare-gui/RsAutoUpdatePage.h" #include "util/misc.h" #include "util/QtVersion.h" +#include "util/rstime.h" #include "retroshare/rsgxsflags.h" #include "retroshare/rsmsgs.h" @@ -1944,11 +1945,11 @@ void IdDialog::insertIdDetails(uint32_t token) rsIdentity->getIdDetails(RsGxsId(data.mMeta.mGroupId),det) ; QString usage_txt ; - std::map rmap ; - for(std::map::const_iterator it(det.mUseCases.begin());it!=det.mUseCases.end();++it) - rmap.insert(std::make_pair(it->second,it->first)) ; + std::map rmap; + for(auto it(det.mUseCases.begin()); it!=det.mUseCases.end(); ++it) + rmap.insert(std::make_pair(it->second,it->first)); - for(std::map::const_iterator it(rmap.begin());it!=rmap.end();++it) + for(auto it(rmap.begin()); it!=rmap.end(); ++it) usage_txt += QString("")+ getHumanReadableDuration(now - data.mLastUsageTS) + " \t: " + createUsageString(it->second) + "
" ; if(usage_txt.isNull()) diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index 3d98a4b62..259faca37 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -574,7 +574,7 @@ void ChatLobbyDialog::updateParticipantsList() delete ui.participantsList->takeTopLevelItem(index); } - for (std::map::const_iterator it2(linfo.gxs_ids.begin()); it2 != linfo.gxs_ids.end(); ++it2) + for (auto it2(linfo.gxs_ids.begin()); it2 != linfo.gxs_ids.end(); ++it2) { QString participant = QString::fromUtf8( (it2->first).toStdString().c_str() ); diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 82add30a4..ef92819f7 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -792,7 +792,7 @@ void ChatWidget::completeNickname(bool reverse) std::list participants; RsIdentityDetails details ; - for ( std::map::const_iterator it = lobby.gxs_ids.begin(); it != lobby.gxs_ids.end(); ++it) + for (auto it = lobby.gxs_ids.begin(); it != lobby.gxs_ids.end(); ++it) { if(rsIdentity->getIdDetails(it->first,details)) participants.push_front(QString::fromUtf8(details.mNickname.c_str())); @@ -859,7 +859,7 @@ QAbstractItemModel *ChatWidget::modelFromPeers() // Get participants list QStringList participants; - for (std::map::const_iterator it = lobby.gxs_ids.begin(); it != lobby.gxs_ids.end(); ++it) + for (auto it = lobby.gxs_ids.begin(); it != lobby.gxs_ids.end(); ++it) { RsIdentityDetails details ; rsIdentity->getIdDetails(it->first,details) ; diff --git a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp index 547b2034d..016e57164 100644 --- a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp @@ -266,7 +266,7 @@ void GxsTransportStatistics::updateContent() groupTreeWidget->addTopLevelItem(item); groupTreeWidget->setItemExpanded(item,openned_groups.find(it->first) != openned_groups.end()); - QString msg_time_string = (stat.last_publish_TS>0)?QString(" (Last msg: %1)").arg(QDateTime::fromTime_t(stat.last_publish_TS).toString()):"" ; + QString msg_time_string = (stat.last_publish_TS>0)?QString(" (Last msg: %1)").arg(QDateTime::fromTime_t((uint)stat.last_publish_TS).toString()):"" ; item->setData(COL_GROUP_NUM_MSGS, Qt::DisplayRole, QString::number(stat.mNumMsgs) + msg_time_string) ; item->setData(COL_GROUP_GRP_ID, Qt::DisplayRole, QString::fromStdString(it->first.toStdString())) ; diff --git a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h index f024edd0f..bbfc00fb3 100644 --- a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h +++ b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h @@ -31,6 +31,7 @@ #include "RsAutoUpdatePage.h" #include "ui_GxsTransportStatistics.h" #include "gui/gxs/RsGxsUpdateBroadcastPage.h" +#include "util/rstime.h" class GxsTransportStatisticsWidget ; class UIStateHelper; @@ -55,7 +56,7 @@ public: bool subscribed ; int popularity ; - time_t last_publish_TS; + rstime_t last_publish_TS; std::map messages_metas ; }; From b7d5944b9c899622bd3cc14e763f159975c61371 Mon Sep 17 00:00:00 2001 From: hunbernd Date: Sun, 7 Oct 2018 21:53:16 +0200 Subject: [PATCH 37/39] Fix building error about losing precision on Win x64 --- libretroshare/src/pgp/rscertificate.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretroshare/src/pgp/rscertificate.cc b/libretroshare/src/pgp/rscertificate.cc index 76e2005b8..4ead10c3e 100644 --- a/libretroshare/src/pgp/rscertificate.cc +++ b/libretroshare/src/pgp/rscertificate.cc @@ -297,7 +297,7 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code) unsigned char *buf2 = buf; uint32_t s = PGPKeyParser::read_125Size(buf); - total_s += 1 + ((unsigned long)buf-(unsigned long)buf2) ; + total_s += 1 + ((size_t)buf-(size_t)buf2) ; if(total_s > size) { From a89c29030a70e9c3e1f260871e99af677450a407 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Mon, 8 Oct 2018 11:56:47 +0200 Subject: [PATCH 38/39] Add missing rstime include in jsonapi --- libretroshare/src/jsonapi/jsonapi.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libretroshare/src/jsonapi/jsonapi.cpp b/libretroshare/src/jsonapi/jsonapi.cpp index ad4fd801b..e9300b250 100644 --- a/libretroshare/src/jsonapi/jsonapi.cpp +++ b/libretroshare/src/jsonapi/jsonapi.cpp @@ -34,6 +34,7 @@ #include "retroshare/rsiface.h" #include "retroshare/rsinit.h" #include "util/rsurl.h" +#include "util/rstime.h" // Generated at compile time #include "jsonapi-includes.inl" From a47eec14e4e7b479f3b3f19a61fa82161441f9b0 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Wed, 10 Oct 2018 21:54:50 +0200 Subject: [PATCH 39/39] Print a warning if deserialized rstime_t is negative --- libretroshare/src/serialiser/rsbaseserial.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/serialiser/rsbaseserial.cc b/libretroshare/src/serialiser/rsbaseserial.cc index 58dadcdb3..968ee877d 100644 --- a/libretroshare/src/serialiser/rsbaseserial.cc +++ b/libretroshare/src/serialiser/rsbaseserial.cc @@ -26,8 +26,10 @@ #include "retroshare/rstypes.h" #include "serialiser/rsbaseserial.h" #include "util/rsnet.h" +#include "util/rstime.h" #include +#include /* UInt8 get/set */ @@ -289,11 +291,15 @@ bool setRawString(void *data, uint32_t size, uint32_t *offset, const std::string bool getRawTimeT(const void *data,uint32_t size,uint32_t *offset,rstime_t& t) { - uint64_t T ; - bool res = getRawUInt64(data,size,offset,&T) ; - t = T ; + uint64_t T; + bool res = getRawUInt64(data,size,offset,&T); + t = T; - return res ; + if(t < 0) // [[unlikely]] + std::cerr << __PRETTY_FUNCTION__ << " got a negative time: " << t + << " this seems fishy, report to the developers!" << std::endl; + + return res; } bool setRawTimeT(void *data, uint32_t size, uint32_t *offset, const rstime_t& t) {