Removed configuration type (uint32) as its not needed or really used.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7212 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2014-03-29 05:20:57 +00:00
parent 190988c3cc
commit 0e6302ac6a
21 changed files with 66 additions and 118 deletions

View File

@ -620,7 +620,7 @@ void CacheStore::locked_storeCacheEntry(const RsCacheData &data)
********************************* CacheStrapper ********************************/
CacheStrapper::CacheStrapper(p3ServiceControl *sc, uint32_t ftServiceId)
:p3Config(CONFIG_TYPE_CACHE), mServiceCtrl(sc), mFtServiceId(ftServiceId),
:p3Config(), mServiceCtrl(sc), mFtServiceId(ftServiceId),
csMtx("CacheStrapper")
{
return;

View File

@ -83,7 +83,7 @@ virtual int dhtInfoCallback(const bdId *id, uint32_t type, uint32_t flags, std::
p3BitDht::p3BitDht(const RsPeerId& id, pqiConnectCb *cb, p3NetMgr *nm,
UdpStack *udpstack, std::string bootstrapfile)
:p3Config(CONFIG_TYPE_BITDHT), pqiNetAssistConnect(id, cb), mNetMgr(nm), dhtMtx("p3BitDht")
:p3Config(), pqiNetAssistConnect(id, cb), mNetMgr(nm), dhtMtx("p3BitDht")
{
mDhtStunner = NULL;
mProxyStunner = NULL;

View File

@ -99,7 +99,7 @@ ftFileControl::ftFileControl(std::string fname,
}
ftController::ftController(CacheStrapper *cs, ftDataMultiplex *dm, p3ServiceControl *sc, uint32_t ftServiceId)
:CacheTransfer(cs), p3Config(CONFIG_TYPE_FT_CONTROL),
:CacheTransfer(cs), p3Config(),
last_save_time(0),
last_clean_time(0),
mDataplex(dm),

View File

@ -123,7 +123,7 @@ bool ftFiStore::search(const RsFileHash &hash, FileSearchFlags hintflags, FileIn
ftFiMonitor::ftFiMonitor(CacheStrapper *cs,std::string cachedir, const RsPeerId& pid,const std::string& config_dir)
:FileIndexMonitor(cs,cachedir, pid,config_dir), p3Config(CONFIG_TYPE_FT_SHARED)
:FileIndexMonitor(cs,cachedir, pid,config_dir), p3Config()
{
return;
}

View File

@ -41,7 +41,7 @@
*****/
ftExtraList::ftExtraList()
:p3Config(CONFIG_TYPE_FT_EXTRA_LIST), extMutex("p3Config")
:p3Config(), extMutex("p3Config")
{
return;
}

View File

@ -44,7 +44,7 @@ RsGxsNetService::RsGxsNetService(uint16_t servType, RsGeneralDataService *gds,
RsNxsNetMgr *netMgr, RsNxsObserver *nxsObs,
const RsServiceInfo serviceInfo,
RsGixsReputation* reputations, RsGcxs* circles, bool grpAutoSync)
: p3ThreadedService(), p3Config(servType), mTransactionN(0),
: p3ThreadedService(), p3Config(), mTransactionN(0),
mObserver(nxsObs), mDataStore(gds), mServType(servType),
mTransactionTimeOut(TRANSAC_TIMEOUT), mNetMgr(netMgr), mNxsMutex("RsGxsNetService"),
mSyncTs(0), mSYNC_PERIOD(SYNC_PERIOD), mCircles(circles), mReputations(reputations), mGrpAutoSync(grpAutoSync), mGrpServerUpdateItem(NULL),

View File

@ -41,7 +41,7 @@ typedef RsPlugin *(*RetroSharePluginEntry)(void) ;
RsPluginHandler *rsPlugins ;
RsPluginManager::RsPluginManager(const RsFileHash &hash)
: p3Config(CONFIG_TYPE_PLUGINS),_current_executable_hash(hash)
: p3Config(),_current_executable_hash(hash)
{
_allow_all_plugins = false ;
}
@ -525,16 +525,16 @@ bool RsPluginManager::saveList(bool& cleanup, std::list<RsItem*>& list)
return true;
}
RsCacheService::RsCacheService(uint16_t service_type,uint32_t config_type,uint32_t tick_delay, RsPluginHandler* pgHandler)
RsCacheService::RsCacheService(uint16_t service_type,uint32_t tick_delay, RsPluginHandler* pgHandler)
: CacheSource(service_type, true, pgHandler->getFileServer()->getCacheStrapper(), pgHandler->getLocalCacheDir()),
CacheStore (service_type, true, pgHandler->getFileServer()->getCacheStrapper(), pgHandler->getFileServer()->getCacheTransfer(), pgHandler->getRemoteCacheDir()),
p3Config(config_type), // CONFIG_TYPE_RANK_LINK
p3Config(),
_tick_delay_in_seconds(tick_delay)
{
}
RsPQIService::RsPQIService(uint16_t service_type,uint32_t config_type,uint32_t /*tick_delay_in_seconds*/, RsPluginHandler* /*pgHandler*/)
: p3Service(),p3Config(config_type)
RsPQIService::RsPQIService(uint16_t service_type,uint32_t /*tick_delay_in_seconds*/, RsPluginHandler* /*pgHandler*/)
: p3Service(),p3Config()
{
}

View File

@ -9,7 +9,7 @@
class RsCacheService: public CacheSource, public CacheStore, public p3Config
{
public:
RsCacheService(uint16_t type,uint32_t config_type,uint32_t tick_delay_in_seconds, RsPluginHandler* pgHandler) ;
RsCacheService(uint16_t type,uint32_t tick_delay_in_seconds, RsPluginHandler* pgHandler) ;
uint32_t tickDelay() const { return _tick_delay_in_seconds ; }
virtual void tick() {}

View File

@ -9,7 +9,7 @@
class RsPQIService: public p3Service, public p3Config
{
public:
RsPQIService(uint16_t type,uint32_t config_type,uint32_t tick_delay_in_seconds, RsPluginHandler* pgHandler) ;
RsPQIService(uint16_t type,uint32_t tick_delay_in_seconds, RsPluginHandler* pgHandler) ;
uint32_t tickDelay() const { return _tick_delay_in_seconds ; }
virtual int tick() = 0 ;

View File

@ -121,12 +121,12 @@ void AuthGPG::exit()
}
AuthGPG::AuthGPG(const std::string& path_to_public_keyring,const std::string& path_to_secret_keyring,const std::string& path_to_trustdb,const std::string& pgp_lock_file)
:p3Config(CONFIG_TYPE_AUTHGPG),
PGPHandler(path_to_public_keyring,path_to_secret_keyring,path_to_trustdb,pgp_lock_file),
gpgMtxService("AuthGPG-service"),
gpgMtxEngine("AuthGPG-engine"),
gpgMtxData("AuthGPG-data"),
gpgKeySelected(false)
:p3Config(),
PGPHandler(path_to_public_keyring,path_to_secret_keyring,path_to_trustdb,pgp_lock_file),
gpgMtxService("AuthGPG-service"),
gpgMtxEngine("AuthGPG-engine"),
gpgMtxData("AuthGPG-data"),
gpgKeySelected(false)
{
_force_sync_database = false ;
start();

View File

@ -276,7 +276,7 @@ sslcert::sslcert(X509 *x509, const RsPeerId& pid)
AuthSSLimpl::AuthSSLimpl()
: p3Config(CONFIG_TYPE_AUTHSSL), sslctx(NULL),
: p3Config(), sslctx(NULL),
mOwnCert(NULL), sslMtx("AuthSSL"), mOwnPrivateKey(NULL), mOwnPublicKey(NULL), init(0)
{
}

View File

@ -57,10 +57,10 @@ void p3ConfigMgr::tick()
RsStackMutex stack(cfgMtx); /***** LOCK STACK MUTEX ****/
/* iterate through and check if any have changed */
std::map<uint32_t, pqiConfig *>::iterator it;
for(it = configs.begin(); it != configs.end(); it++)
std::list<pqiConfig *>::iterator it;
for(it = mConfigs.begin(); it != mConfigs.end(); it++)
{
if (it->second->HasConfigChanged(0))
if ((*it)->HasConfigChanged(0))
{
#ifdef CONFIG_DEBUG
@ -104,17 +104,17 @@ void p3ConfigMgr::saveConfig()
RsStackMutex stack(cfgMtx); /***** LOCK STACK MUTEX ****/
std::map<uint32_t, pqiConfig *>::iterator it;
for(it = configs.begin(); it != configs.end(); it++)
std::list<pqiConfig *>::iterator it;
for(it = mConfigs.begin(); it != mConfigs.end(); it++)
{
if (it->second->HasConfigChanged(1))
if ((*it)->HasConfigChanged(1))
{
#ifdef CONFIG_DEBUG
std::cerr << "p3ConfigMgr::globalSaveConfig() Saving Element: ";
std::cerr << it->first;
std::cerr << std::endl;
#endif
ok &= it->second->saveConfiguration();
ok &= (*it)->saveConfiguration();
}
/* save metaconfig */
}
@ -131,9 +131,9 @@ void p3ConfigMgr::loadConfiguration()
void p3ConfigMgr::loadConfig()
{
std::map<uint32_t, pqiConfig *>::iterator cit;
RsFileHash dummyHash ;
for (cit = configs.begin(); cit != configs.end(); cit++)
std::list<pqiConfig *>::iterator cit;
RsFileHash dummyHash ;
for (cit = mConfigs.begin(); cit != mConfigs.end(); cit++)
{
#ifdef CONFIG_DEBUG
std::cerr << "p3ConfigMgr::loadConfig() Element: ";
@ -141,11 +141,11 @@ void p3ConfigMgr::loadConfig()
std::cerr << std::endl;
#endif
cit->second->loadConfiguration(dummyHash);
(*cit)->loadConfiguration(dummyHash);
/* force config to NOT CHANGED */
cit->second->HasConfigChanged(0);
cit->second->HasConfigChanged(1);
(*cit)->HasConfigChanged(0);
(*cit)->HasConfigChanged(1);
}
return;
@ -165,16 +165,20 @@ void p3ConfigMgr::addConfiguration(std::string file, pqiConfig *conf)
filename += "config/";
filename += file;
conf->setFilename(filename);
std::map<uint32_t, pqiConfig *>::iterator cit = configs.find(conf->Type());
if (cit != configs.end())
std::list<pqiConfig *>::iterator cit = std::find(mConfigs.begin(),mConfigs.end(),conf);
if (cit != mConfigs.end())
{
std::cerr << "p3Config::addConfiguration() WARNING: type " << conf->Type();
std::cerr << " with filename " << filename;
std::cerr << " already added with filename " << cit->second->Filename() << std::endl;
std::cerr << "p3Config::addConfiguration() Config already added";
std::cerr << std::endl;
std::cerr << "\tOriginal filename " << (*cit)->Filename();
std::cerr << std::endl;
std::cerr << "\tIgnoring new filename " << filename;
std::cerr << std::endl;
return;
}
configs[conf->Type()] = conf;
conf->setFilename(filename);
mConfigs.push_back(conf);
}
@ -188,8 +192,8 @@ void p3ConfigMgr::completeConfiguration()
p3Config::p3Config(uint32_t t)
:pqiConfig(t)
p3Config::p3Config()
:pqiConfig()
{
return;
}
@ -407,7 +411,7 @@ bool p3Config::saveConfig()
/**************************** CONFIGURATION CLASSES ********************/
p3GeneralConfig::p3GeneralConfig()
:p3Config(CONFIG_TYPE_GENERAL)
:p3Config()
{
return;
}
@ -544,8 +548,8 @@ bool p3GeneralConfig::loadList(std::list<RsItem *>& load)
* only the Indication and hash really need it
*/
pqiConfig::pqiConfig(uint32_t t)
: cfgMtx("pqiConfig"), ConfInd(2), type(t)
pqiConfig::pqiConfig()
: cfgMtx("pqiConfig"), ConfInd(2)
{
return;
}
@ -555,12 +559,6 @@ pqiConfig::~pqiConfig()
return;
}
uint32_t pqiConfig::Type()
{
RsStackMutex stack(cfgMtx); /***** LOCK STACK MUTEX ****/
return type;
}
const std::string& pqiConfig::Filename()
{
RsStackMutex stack(cfgMtx); /***** LOCK STACK MUTEX ****/

View File

@ -30,6 +30,7 @@
#include <string>
#include <map>
#include <set>
#include "pqi/pqi_base.h"
#include "pqi/pqiindic.h"
@ -59,48 +60,9 @@
*
*********************/
const uint32_t CONFIG_TYPE_GENERAL = 0x0001;
const uint32_t CONFIG_TYPE_PEERS = 0x0002;
const uint32_t CONFIG_TYPE_FSERVER = 0x0003;
const uint32_t CONFIG_TYPE_MSGS = 0x0004;
const uint32_t CONFIG_TYPE_AUTHGPG = 0x0006;
/* new FileTransfer */
const uint32_t CONFIG_TYPE_FT_SHARED = 0x0007;
const uint32_t CONFIG_TYPE_FT_EXTRA_LIST= 0x0008;
const uint32_t CONFIG_TYPE_FT_CONTROL = 0x0009;
const uint32_t CONFIG_TYPE_FT_DWLQUEUE = 0x000A;
const uint32_t CONFIG_TYPE_P3DISC = 0x000B;
const uint32_t CONFIG_TYPE_AUTHSSL = 0x000C;
/* wish these ids where higher...
* may move when switch to v0.5
*/
const uint32_t CONFIG_TYPE_CHAT = 0x0012;
const uint32_t CONFIG_TYPE_STATUS = 0x0013;
const uint32_t CONFIG_TYPE_PLUGINS = 0x0014;
const uint32_t CONFIG_TYPE_HISTORY = 0x0015;
/// turtle router
const uint32_t CONFIG_TYPE_TURTLE = 0x0020;
/// dht (relay stuff mainly)
const uint32_t CONFIG_TYPE_BITDHT = 0x0030;
/* standard services */
const uint32_t CONFIG_TYPE_QBLOG = 0x0101;
const uint32_t CONFIG_TYPE_FORUMS = 0x0102;
const uint32_t CONFIG_TYPE_CHANNELS = 0x0103;
const uint32_t CONFIG_TYPE_GXS_REPUTATION = 0x0200;
/* CACHE ID Must be at the END so that other configurations
* are loaded First (Cache Config --> Cache Loading)
*/
const uint32_t CONFIG_TYPE_CACHE = 0xff01;
class p3ConfigMgr;
@ -114,7 +76,7 @@ class p3ConfigMgr;
class pqiConfig
{
public:
pqiConfig(uint32_t t);
pqiConfig();
virtual ~pqiConfig();
/**
@ -129,12 +91,6 @@ virtual bool loadConfiguration(RsFileHash &loadHash) = 0;
*/
virtual bool saveConfiguration() = 0;
/**
* The type of configuration, see ids where this class is declared
* @see p3cfgmgr.h
*/
uint32_t Type();
/**
* The name of the configuration file
*/
@ -170,17 +126,13 @@ void setHash(const RsFileHash& h);
Indicator ConfInd;
uint32_t type;
std::string filename;
RsFileHash hash;
friend class p3ConfigMgr;
/* so it can access:
* setFilename() and HasConfigChanged()
*/
};
@ -244,12 +196,12 @@ class p3ConfigMgr
*/
void loadConfig();
const std::string basedir;
const std::string basedir;
RsMutex cfgMtx; /* below is protected */
bool mConfigSaveActive;
std::map<uint32_t, pqiConfig *> configs;
bool mConfigSaveActive;
std::list<pqiConfig *> mConfigs;
};
@ -266,7 +218,7 @@ class p3Config: public pqiConfig
{
public:
p3Config(uint32_t t);
p3Config();
virtual bool loadConfiguration(RsFileHash &loadHash);
virtual bool saveConfiguration();

View File

@ -41,7 +41,7 @@
RsHistory *rsHistory = NULL;
p3HistoryMgr::p3HistoryMgr()
: p3Config(CONFIG_TYPE_HISTORY), mHistoryMtx("p3HistoryMgr")
: p3Config(), mHistoryMtx("p3HistoryMgr")
{
nextMsgId = 1;

View File

@ -109,7 +109,7 @@ std::string textPeerConnectState(peerState &state)
p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const RsPgpId& gpg_own_id, const std::string& gpg_own_name, const std::string& ssl_own_location)
:p3Config(CONFIG_TYPE_PEERS), mPeerMtx("p3PeerMgr"), mStatusChanged(false)
:p3Config(), mPeerMtx("p3PeerMgr"), mStatusChanged(false)
{
{

View File

@ -1630,7 +1630,6 @@ int RsServer::StartupRetroShare()
mConfigMgr->addConfiguration("peers.cfg", mPeerMgr);
mConfigMgr->addConfiguration("general.cfg", mGeneralConfig);
mConfigMgr->addConfiguration("cache.cfg", mCacheStrapper);
mConfigMgr->addConfiguration("msgs.cfg", msgSrv);
mConfigMgr->addConfiguration("chat.cfg", chatSrv);
mConfigMgr->addConfiguration("p3History.cfg", mHistoryMgr);
@ -1645,7 +1644,6 @@ int RsServer::StartupRetroShare()
#endif
#ifdef RS_ENABLE_GXS
mConfigMgr->addConfiguration("identity.cfg", gxsid_ns);
mConfigMgr->addConfiguration("gxsforums.cfg", gxsforums_ns);
mConfigMgr->addConfiguration("gxschannels.cfg", gxschannels_ns);
@ -1654,7 +1652,6 @@ int RsServer::StartupRetroShare()
mConfigMgr->addConfiguration("wire.cfg", wire_ns);
mConfigMgr->addConfiguration("wiki.cfg", wiki_ns);
mConfigMgr->addConfiguration("photo.cfg", photo_ns);
#endif
mPluginsManager->addConfigurations(mConfigMgr) ;
@ -1666,13 +1663,14 @@ int RsServer::StartupRetroShare()
/**************************************************************************/
std::cerr << "(2) Load configuration files" << std::endl;
mConfigMgr->loadConfiguration();
/* NOTE: CacheStrapper's load causes Cache Files to be
* loaded into all the CacheStores/Sources. This happens
* after all the other configurations have happened.
*/
mConfigMgr->addConfiguration("cache.cfg", mCacheStrapper);
mConfigMgr->loadConfiguration();
/**************************************************************************/
/* trigger generalConfig loading for classes that require it */
/**************************************************************************/

View File

@ -76,7 +76,7 @@ static const uint32_t MAX_MESSAGES_PER_SECONDS_NUMBER = 5 ; // max number o
static const uint32_t MAX_MESSAGES_PER_SECONDS_PERIOD = 10 ; // duration window for max number of messages before messages get dropped.
p3ChatService::p3ChatService(p3ServiceControl *sc, p3LinkMgr *lm, p3HistoryMgr *historyMgr)
:p3Service(), p3Config(CONFIG_TYPE_CHAT), mChatMtx("p3ChatService"), mServiceCtrl(sc), mLinkMgr(lm) , mHistoryMgr(historyMgr)
:p3Service(), p3Config(), mChatMtx("p3ChatService"), mServiceCtrl(sc), mLinkMgr(lm) , mHistoryMgr(historyMgr)
{
_serializer = new RsChatSerialiser() ;
_own_avatar = NULL ;

View File

@ -123,7 +123,7 @@ uint32_t ConvertToSerialised(int32_t value, bool limit)
p3GxsReputation::p3GxsReputation(p3LinkMgr *lm)
:p3Service(), p3Config(CONFIG_TYPE_GXS_REPUTATION),
:p3Service(), p3Config(),
mReputationMtx("p3GxsReputation"), mLinkMgr(lm)
{
addSerialType(new RsGxsReputationSerialiser());

View File

@ -76,7 +76,7 @@ static const uint8_t ENCRYPTED_MSG_PROTOCOL_VERSION_01 = 0x37 ;
p3MsgService::p3MsgService(p3ServiceControl *sc)
:p3Service(), p3Config(CONFIG_TYPE_MSGS),
:p3Service(), p3Config(),
mServiceCtrl(sc), mMsgMtx("p3MsgService"), mMsgUniqueId(time(NULL))
{
_serialiser = new RsMsgSerialiser();

View File

@ -48,7 +48,7 @@ std::ostream& operator<<(std::ostream& out, const StatusInfo& si)
RsStatus *rsStatus = NULL;
p3StatusService::p3StatusService(p3ServiceControl *sc)
:p3Service(), p3Config(CONFIG_TYPE_STATUS), mServiceCtrl(sc), mStatusMtx("p3StatusService")
:p3Service(), p3Config(), mServiceCtrl(sc), mStatusMtx("p3StatusService")
{
addSerialType(new RsStatusSerialiser());

View File

@ -99,7 +99,7 @@ static const int MAX_TR_FORWARD_PER_SEC_LOWER_LIMIT = 10 ;
static const int DISTANCE_SQUEEZING_POWER = 8 ;
p3turtle::p3turtle(p3LinkMgr *lm)
:p3Service(), p3Config(CONFIG_TYPE_TURTLE), mLinkMgr(lm), mTurtleMtx("p3turtle")
:p3Service(), p3Config(), mLinkMgr(lm), mTurtleMtx("p3turtle")
{
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/