diff --git a/libretroshare/src/dbase/fimonitor.cc b/libretroshare/src/dbase/fimonitor.cc index 7bed3aaf0..085fbd54f 100644 --- a/libretroshare/src/dbase/fimonitor.cc +++ b/libretroshare/src/dbase/fimonitor.cc @@ -159,7 +159,7 @@ HashCache::HashCache(const std::string& path) std::string s((char *)decrypted_data,decrypted_data_size) ; f = new std::istringstream(s) ; - delete[] (unsigned char *)decrypted_data ; + free(decrypted_data) ; } else { diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 913f6e4ad..82e1d789b 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -109,7 +109,8 @@ PUBLIC_HEADERS = retroshare/rsdisc.h \ HEADERS += plugins/pluginmanager.h \ plugins/dlfcn_win32.h \ - serialiser/rspluginitems.h + serialiser/rspluginitems.h \ + util/rsinitedptr.h HEADERS += $$PUBLIC_HEADERS diff --git a/libretroshare/src/plugins/pluginmanager.cc b/libretroshare/src/plugins/pluginmanager.cc index 257bf04dd..0889677ac 100644 --- a/libretroshare/src/plugins/pluginmanager.cc +++ b/libretroshare/src/plugins/pluginmanager.cc @@ -406,9 +406,11 @@ void RsPluginManager::registerClientServices(p3ServiceServer *pqih) std::cerr << " Registering pqi services." << std::endl; for(uint32_t i=0;i<_plugins.size();++i) - if(_plugins[i].plugin != NULL && _plugins[i].plugin->rs_pqi_service() != NULL) + //if(_plugins[i].plugin != NULL && _plugins[i].plugin->rs_pqi_service() != NULL) + if(_plugins[i].plugin != NULL && _plugins[i].plugin->p3_service() != NULL) { - pqih->addService(_plugins[i].plugin->rs_pqi_service(), true) ; + //pqih->addService(_plugins[i].plugin->rs_pqi_service(), true) ; + pqih->addService(_plugins[i].plugin->p3_service(), true) ; std::cerr << " Added pqi service for plugin " << _plugins[i].plugin->getPluginName() << std::endl; } } @@ -422,8 +424,10 @@ void RsPluginManager::addConfigurations(p3ConfigMgr *ConfigMgr) { if( _plugins[i].plugin->rs_cache_service() != NULL) ConfigMgr->addConfiguration(_plugins[i].plugin->configurationFileName(), _plugins[i].plugin->rs_cache_service()); - else if(_plugins[i].plugin->rs_pqi_service() != NULL) - ConfigMgr->addConfiguration(_plugins[i].plugin->configurationFileName(), _plugins[i].plugin->rs_pqi_service()); + //else if(_plugins[i].plugin->rs_pqi_service() != NULL) + // ConfigMgr->addConfiguration(_plugins[i].plugin->configurationFileName(), _plugins[i].plugin->rs_pqi_service()); + else if(_plugins[i].plugin->p3_config() != NULL) + ConfigMgr->addConfiguration(_plugins[i].plugin->configurationFileName(), _plugins[i].plugin->p3_config()); else continue ; diff --git a/libretroshare/src/pqi/authssl.cc b/libretroshare/src/pqi/authssl.cc index 4892ca38c..305ceb0ba 100644 --- a/libretroshare/src/pqi/authssl.cc +++ b/libretroshare/src/pqi/authssl.cc @@ -1253,7 +1253,7 @@ bool AuthSSLimpl::encrypt(void *&out, int &outlen, const void *in, int inlen, } // now assign memory to out accounting for data, and cipher block size, key length, and key length val - out = new unsigned char[inlen + cipher_block_size + size_net_ekl + eklen + EVP_MAX_IV_LENGTH]; + out = (unsigned char*)malloc(inlen + cipher_block_size + size_net_ekl + eklen + EVP_MAX_IV_LENGTH); net_ekl = htonl(eklen); memcpy((unsigned char*)out + out_offset, &net_ekl, size_net_ekl); @@ -1268,7 +1268,7 @@ bool AuthSSLimpl::encrypt(void *&out, int &outlen, const void *in, int inlen, // now encrypt actual data if(!EVP_SealUpdate(&ctx, (unsigned char*) out + out_offset, &out_currOffset, (unsigned char*) in, inlen)) { free(ek); - delete[] (unsigned char*) out; + free(out); out = NULL; return false; } @@ -1279,7 +1279,7 @@ bool AuthSSLimpl::encrypt(void *&out, int &outlen, const void *in, int inlen, // add padding if(!EVP_SealFinal(&ctx, (unsigned char*) out + out_offset, &out_currOffset)) { free(ek); - delete[] (unsigned char*) out; + free(out) ; out = NULL; return false; } @@ -1360,11 +1360,11 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen) return false; } - out = new unsigned char[inlen - in_offset]; + out = (unsigned char*)malloc(inlen - in_offset); if(!EVP_OpenUpdate(&ctx, (unsigned char*) out, &out_currOffset, (unsigned char*)in + in_offset, inlen - in_offset)) { free(ek); - delete[] (unsigned char*) out; + free(out) ; out = NULL; return false; } @@ -1374,7 +1374,7 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen) if(!EVP_OpenFinal(&ctx, (unsigned char*)out + out_currOffset, &out_currOffset)) { free(ek); - delete[] (unsigned char*) out; + free(out) ; out = NULL; return false; } @@ -1386,9 +1386,9 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen) EVP_CIPHER_CTX_cleanup(&ctx); - #ifdef AUTHSSL_DEBUG - std::cerr << "AuthSSLimpl::decrypt() finished with outlen : " << outlen << std::endl; - #endif +#ifdef AUTHSSL_DEBUG + std::cerr << "AuthSSLimpl::decrypt() finished with outlen : " << outlen << std::endl; +#endif return true; } diff --git a/libretroshare/src/pqi/p3notify.cc b/libretroshare/src/pqi/p3notify.cc index 4ba899b17..f6d337756 100644 --- a/libretroshare/src/pqi/p3notify.cc +++ b/libretroshare/src/pqi/p3notify.cc @@ -26,6 +26,7 @@ #include "pqi/p3notify.h" #include +#include RsNotify *rsNotify = NULL ; @@ -284,3 +285,16 @@ void p3Notify::registerNotifyClient(NotifyClient *cl) notifyClients.push_back(cl) ; } +bool p3Notify::unregisterNotifyClient(NotifyClient *nc) +{ + std::list::iterator it = std::find(notifyClients.begin(), notifyClients.end(), nc); + if(it != notifyClients.end()) + { + notifyClients.erase(it); + return true; + } + else + { + return false; + } +} diff --git a/libretroshare/src/pqi/p3notify.h b/libretroshare/src/pqi/p3notify.h index 74d72f5fc..c5a4b5eaa 100644 --- a/libretroshare/src/pqi/p3notify.h +++ b/libretroshare/src/pqi/p3notify.h @@ -70,6 +70,7 @@ class p3Notify: public RsNotify virtual ~p3Notify() { return; } virtual void registerNotifyClient(NotifyClient *nc) ; + virtual bool unregisterNotifyClient(NotifyClient *nc) ; /* Pull output methods for retroshare-gui */ virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type, std::string &title, std::string &msg); diff --git a/libretroshare/src/pqi/pqibin.cc b/libretroshare/src/pqi/pqibin.cc index b77ab9c4a..3c9ed7731 100644 --- a/libretroshare/src/pqi/pqibin.cc +++ b/libretroshare/src/pqi/pqibin.cc @@ -185,7 +185,7 @@ BinEncryptedFileInterface::~BinEncryptedFileInterface() { if((sizeData > 0) && data != NULL) { - delete[] data; + free(data); } } @@ -193,7 +193,7 @@ BinEncryptedFileInterface::~BinEncryptedFileInterface() int BinEncryptedFileInterface::senddata(void* data, int len) { - char* encrytedData = NULL; + void* encrytedData = NULL; int encDataLen = 0; // encrypt using own ssl public key @@ -205,8 +205,8 @@ int BinEncryptedFileInterface::senddata(void* data, int len) if((encDataLen > 0) && (encrytedData != NULL)) { - BinFileInterface::senddata(encrytedData, encDataLen); - delete[] encrytedData; + BinFileInterface::senddata((unsigned char *)encrytedData, encDataLen); + free(encrytedData); } else { @@ -288,7 +288,7 @@ int BinEncryptedFileInterface::close() { if(data != NULL) { - delete[] data; + free(data); sizeData = 0; haveData = false; cpyCount = 0; diff --git a/libretroshare/src/pqi/pqisslproxy.cc b/libretroshare/src/pqi/pqisslproxy.cc index 943da38fa..f9e678d22 100755 --- a/libretroshare/src/pqi/pqisslproxy.cc +++ b/libretroshare/src/pqi/pqisslproxy.cc @@ -214,10 +214,45 @@ int pqisslproxy::Proxy_Method_Response() char method_response[2]; - // read from the socket. - int recvd = recv(sockfd, method_response, 2, MSG_WAITALL); + /* + first it was: + + int recvd = recv(sockfd, method_response, 2, MSG_WAITALL); + + this does not work on windows, because the socket is in nonblocking mode + the winsock reference says about the recv function and MSG_WAITALL: + + "Note that if the underlying transport does not support MSG_WAITALL, + or if the socket is in a non-blocking mode, then this call will fail with WSAEOPNOTSUPP." + + now it is a two step process: + + int recvd = recv(sockfd, method_response, 2, MSG_PEEK); // test how many bytes are in the input queue + if (enaugh bytes available){ + recvd = recv(sockfd, method_response, 2, 0); + } + + this does not work on windows: + if ((recvd == -1) && (errno == EAGAIN)) return TRY_AGAIN_LATER; + + instead have to do: + if ((recvd == -1) && (WSAGetLastError() == WSAEWOULDBLOCK)) return TRY_AGAIN_LATER; + */ + + // test how many bytes can be read from the queue + int recvd = recv(sockfd, method_response, 2, MSG_PEEK); if (recvd != 2) { +#ifdef WINDOWS_SYS + if ((recvd == -1) && (WSAGetLastError() == WSAEWOULDBLOCK)) + { +#ifdef PROXY_DEBUG + std::cerr << "pqisslproxy::Proxy_Method_Response() waiting for more data (windows)"; + std::cerr << std::endl; +#endif + return 0; + } +#endif if ((recvd == -1) && (errno == EAGAIN)) { @@ -227,15 +262,36 @@ int pqisslproxy::Proxy_Method_Response() #endif return 0; - } - + } + else if (recvd == -1) + { #ifdef PROXY_DEBUG - std::cerr << "pqisslproxy::Proxy_Method_Response() Error recving response"; - std::cerr << std::endl; + std::cerr << "pqisslproxy::Proxy_Method_Response() recv error peek"; + std::cerr << std::endl; #endif - return -1; + return -1; + } + else + { +#ifdef PROXY_DEBUG + std::cerr << "pqisslproxy::Proxy_Method_Response() waiting for more data"; + std::cerr << std::endl; +#endif + return 0; + } } + // read the bytes + recvd = recv(sockfd, method_response, 2, 0); + if (recvd != 2) + { +#ifdef PROXY_DEBUG + std::cerr << "pqisslproxy::Proxy_Method_Response() recv error"; + std::cerr << std::endl; +#endif + return -1; + } + // does it make sense? if (method_response[0] != 0x05) { @@ -345,9 +401,20 @@ int pqisslproxy::Proxy_Connection_Complete() char socks_response[MAX_SOCKS_REQUEST_LEN]; - int recvd = recv(sockfd, socks_response, 5, MSG_WAITALL); + // test how many bytes can be read + int recvd = recv(sockfd, socks_response, 5, MSG_PEEK); if (recvd != 5) { +#ifdef WINDOWS_SYS + if ((recvd == -1) && (WSAGetLastError() == WSAEWOULDBLOCK)) + { +#ifdef PROXY_DEBUG + std::cerr << "pqisslproxy::Proxy_Connection_Complete() waiting for more data (windows)"; + std::cerr << std::endl; +#endif + return 0; + } +#endif if ((recvd == -1) && (errno == EAGAIN)) { #ifdef PROXY_DEBUG @@ -356,13 +423,34 @@ int pqisslproxy::Proxy_Connection_Complete() #endif return 0; } - + else if (recvd == -1) + { #ifdef PROXY_DEBUG - std::cerr << "pqisslproxy::Proxy_Connection_Complete() recv error"; - std::cerr << std::endl; + std::cerr << "pqisslproxy::Proxy_Connection_Complete() recv error peek"; + std::cerr << std::endl; #endif - return -1; + return -1; + } + else + { +#ifdef PROXY_DEBUG + std::cerr << "pqisslproxy::Proxy_Connection_Complete() waiting for more data"; + std::cerr << std::endl; +#endif + return 0; + } } + + // read the bytes + recvd = recv(sockfd, socks_response, 5, 0); + if (recvd != 5) + { +#ifdef PROXY_DEBUG + std::cerr << "pqisslproxy::Proxy_Connection_Complete() recv error"; + std::cerr << std::endl; +#endif + return -1; + } // error checking. if (socks_response[0] != 0x05) @@ -429,10 +517,20 @@ int pqisslproxy::Proxy_Connection_Complete() } - // read the remaining bytes. - recvd = recv(sockfd, &(socks_response[5]), address_bytes + 1, MSG_WAITALL); // address_bytes - 1 + 2... + // test how many bytes can be read + recvd = recv(sockfd, &(socks_response[5]), address_bytes + 1, MSG_PEEK); // address_bytes - 1 + 2... if (recvd != address_bytes + 1) { +#ifdef WINDOWS_SYS + if((recvd == -1) && (WSAGetLastError() == WSAEWOULDBLOCK)) + { +#ifdef PROXY_DEBUG + std::cerr << "pqisslproxy::Proxy_Connection_Complete() waiting for more data(2) (windows)"; + std::cerr << std::endl; +#endif + return 0; + } +#endif if ((recvd == -1) && (errno == EAGAIN)) { #ifdef PROXY_DEBUG @@ -442,14 +540,35 @@ int pqisslproxy::Proxy_Connection_Complete() // Waiting - shouldn't happen. return 0; } - + else if (recvd == -1) + { #ifdef PROXY_DEBUG - std::cerr << "pqisslproxy::Proxy_Connection_Complete() ERROR recving(2)"; - std::cerr << std::endl; + std::cerr << "pqisslproxy::Proxy_Connection_Complete() ERROR recving(2)"; + std::cerr << std::endl; #endif - return -1; + return -1; + } + else + { +#ifdef PROXY_DEBUG + std::cerr << "pqisslproxy::Proxy_Connection_Complete() waiting for more data(2)"; + std::cerr << std::endl; +#endif + return 0; + } } + // read the bytes + recvd = recv(sockfd, &(socks_response[5]), address_bytes + 1, 0); // address_bytes - 1 + 2... + if (recvd != address_bytes + 1) + { +#ifdef PROXY_DEBUG + std::cerr << "pqisslproxy::Proxy_Connection_Complete() recv error (2)"; + std::cerr << std::endl; +#endif + return -1; + } + #ifdef PROXY_DEBUG std::cerr << "pqisslproxy::Proxy_Connection_Complete() Received String: "; for(int i = 0; i < 4 + address_bytes + 2; i++) diff --git a/libretroshare/src/retroshare/rsgxscircles.h b/libretroshare/src/retroshare/rsgxscircles.h index 1cf44b75f..3ce9a9c4e 100644 --- a/libretroshare/src/retroshare/rsgxscircles.h +++ b/libretroshare/src/retroshare/rsgxscircles.h @@ -130,9 +130,11 @@ virtual bool getCirclePersonalIdList(std::list &circleIds) = 0; /* standard load */ virtual bool getGroupData(const uint32_t &token, std::vector &groups) = 0; - /* make new group */ -virtual bool createGroup(uint32_t& token, RsGxsCircleGroup &group) = 0; + /* make new group */ +virtual void createGroup(uint32_t& token, RsGxsCircleGroup &group) = 0; + /* update an existing group */ +virtual void updateGroup(uint32_t &token, RsGxsCircleGroup &group) = 0; }; diff --git a/libretroshare/src/retroshare/rsidentity.h b/libretroshare/src/retroshare/rsidentity.h index 53ed4474d..6f9721d18 100644 --- a/libretroshare/src/retroshare/rsidentity.h +++ b/libretroshare/src/retroshare/rsidentity.h @@ -209,7 +209,7 @@ public: //virtual bool getNickname(const RsGxsId &id, std::string &nickname) = 0; virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details) = 0; -virtual bool getOwnIds(std::list &ownIds) = 0; +virtual void getOwnIds(std::list &ownIds) = 0; // virtual bool submitOpinion(uint32_t& token, const RsGxsId &id, diff --git a/libretroshare/src/retroshare/rsnotify.h b/libretroshare/src/retroshare/rsnotify.h index ef6239152..3bd4b6432 100644 --- a/libretroshare/src/retroshare/rsnotify.h +++ b/libretroshare/src/retroshare/rsnotify.h @@ -162,6 +162,8 @@ class RsNotify public: /* registration of notifies clients */ virtual void registerNotifyClient(NotifyClient *nc) = 0; + /* returns true if NotifyClient was found */ + virtual bool unregisterNotifyClient(NotifyClient *nc) = 0; /* Pull methods for retroshare-gui */ /* this should probably go into a different service. */ diff --git a/libretroshare/src/retroshare/rspeers.h b/libretroshare/src/retroshare/rspeers.h index 972367fcc..35059e57d 100644 --- a/libretroshare/src/retroshare/rspeers.h +++ b/libretroshare/src/retroshare/rspeers.h @@ -287,8 +287,9 @@ class RsPeers virtual ~RsPeers() { return; } /* Updates ... */ - virtual bool FriendsChanged() = 0; - virtual bool OthersChanged() = 0; + // not implemented + //virtual bool FriendsChanged() = 0; + //virtual bool OthersChanged() = 0; /* Peer Details (Net & Auth) */ virtual const RsPeerId& getOwnId() = 0; diff --git a/libretroshare/src/retroshare/rsplugin.h b/libretroshare/src/retroshare/rsplugin.h index 318aa3e77..ff957418a 100644 --- a/libretroshare/src/retroshare/rsplugin.h +++ b/libretroshare/src/retroshare/rsplugin.h @@ -33,6 +33,7 @@ #include "retroshare/rspeers.h" #include "retroshare/rsfiles.h" #include "util/rsversion.h" +#include "util/rsinitedptr.h" class RsPluginHandler ; extern RsPluginHandler *rsPlugins ; @@ -62,6 +63,13 @@ class SoundEvents; class FeedNotify; class ChatWidget; class ChatWidgetHolder; +// for gxs based plugins +class RsIdentity; +class RsNxsNetMgr; +class RsGxsIdExchange; +class RsGcxs; +class PgpAuxUtils; +class p3Config; // Plugin API version. Not used yet, but will be in the future the // main value that decides for compatibility. @@ -88,20 +96,22 @@ class RsPluginHandler; * */ class RsPlugInInterfaces { - public: + RsUtil::inited_ptr mPeers; + RsUtil::inited_ptr mFiles; + RsUtil::inited_ptr mMsgs; + RsUtil::inited_ptr mTurtle; + RsUtil::inited_ptr mDisc; + RsUtil::inited_ptr mDht; + RsUtil::inited_ptr mNotify; - RsPlugInInterfaces() - { - memset(this,0,sizeof(RsPlugInInterfaces)) ; // zero all pointers. - } - RsPeers *mPeers; - RsFiles *mFiles; - RsMsgs *mMsgs; - RsTurtle *mTurtle; - RsDisc *mDisc; - RsDht *mDht; - RsNotify *mNotify; + // gxs + std::string mGxsDir; + RsUtil::inited_ptr mIdentity; + RsUtil::inited_ptr mRsNxsNetMgr; + RsUtil::inited_ptr mGxsIdService; + RsUtil::inited_ptr mGxsCirlces; + RsUtil::inited_ptr mPgpAuxUtils; }; class RsPlugin @@ -119,7 +129,11 @@ class RsPlugin // exchange of data, such as chat, messages, etc. // Example plugin: VOIP // - virtual RsPQIService *rs_pqi_service() const { return NULL ; } + //virtual RsPQIService *rs_pqi_service() const { return NULL ; } + // gxs netservice is not a RsPQIService + // so have two fns which result in the same gxs netservice to be returned + virtual p3Service *p3_service() const { return NULL ; } + virtual p3Config *p3_config() const { return NULL ; } virtual uint16_t rs_service_id() const { return 0 ; } // Shutdown diff --git a/libretroshare/src/rsserver/rsaccounts.cc b/libretroshare/src/rsserver/rsaccounts.cc index d6aeb0845..a341c0a39 100644 --- a/libretroshare/src/rsserver/rsaccounts.cc +++ b/libretroshare/src/rsserver/rsaccounts.cc @@ -53,7 +53,7 @@ #include // Global singleton declaration of data. -RsAccountsDetail rsAccounts; +RsAccountsDetail *rsAccounts; /* Uses private class - so must be hidden */ static bool checkAccount(std::string accountdir, AccountDetails &account,std::map >& unsupported_keys); @@ -636,7 +636,7 @@ static bool checkAccount(std::string accountdir, AccountDetails &account,std::ma std::cerr << "issuerName: " << account.mPgpId << " id: " << account.mSslId << std::endl; #endif - if(! rsAccounts.GetPGPLoginDetails(account.mPgpId, account.mPgpName, account.mPgpEmail)) + if(! rsAccounts->GetPGPLoginDetails(account.mPgpId, account.mPgpName, account.mPgpEmail)) return false ; if(!AuthGPG::getAuthGPG()->haveSecretKey(account.mPgpId)) @@ -1242,74 +1242,74 @@ std::string RsAccountsDetail::getHomePath() ********************************************************************************/ // Directories. -std::string RsAccounts::ConfigDirectory() { return rsAccounts.PathBaseDirectory(); } -std::string RsAccounts::DataDirectory() { return rsAccounts.PathDataDirectory(); } -std::string RsAccounts::PGPDirectory() { return rsAccounts.PathPGPDirectory(); } -std::string RsAccounts::AccountDirectory() { return rsAccounts.PathAccountDirectory(); } +std::string RsAccounts::ConfigDirectory() { return rsAccounts->PathBaseDirectory(); } +std::string RsAccounts::DataDirectory() { return rsAccounts->PathDataDirectory(); } +std::string RsAccounts::PGPDirectory() { return rsAccounts->PathPGPDirectory(); } +std::string RsAccounts::AccountDirectory() { return rsAccounts->PathAccountDirectory(); } // PGP Accounts. int RsAccounts::GetPGPLogins(std::list &pgpIds) { - return rsAccounts.GetPGPLogins(pgpIds); + return rsAccounts->GetPGPLogins(pgpIds); } int RsAccounts::GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email) { - return rsAccounts.GetPGPLoginDetails(id, name, email); + return rsAccounts->GetPGPLoginDetails(id, name, email); } bool RsAccounts::GeneratePGPCertificate(const std::string &name, const std::string& email, const std::string& passwd, RsPgpId &pgpId, std::string &errString) { - return rsAccounts.GeneratePGPCertificate(name, email, passwd, pgpId, errString); + return rsAccounts->GeneratePGPCertificate(name, email, passwd, pgpId, errString); } // PGP Support Functions. bool RsAccounts::ExportIdentity(const std::string& fname,const RsPgpId& pgp_id) { - return rsAccounts.exportIdentity(fname,pgp_id); + return rsAccounts->exportIdentity(fname,pgp_id); } bool RsAccounts::ImportIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) { - return rsAccounts.importIdentity(fname,imported_pgp_id,import_error); + return rsAccounts->importIdentity(fname,imported_pgp_id,import_error); } void RsAccounts::GetUnsupportedKeys(std::map > &unsupported_keys) { - return rsAccounts.getUnsupportedKeys(unsupported_keys); + return rsAccounts->getUnsupportedKeys(unsupported_keys); } bool RsAccounts::CopyGnuPGKeyrings() { - return rsAccounts.copyGnuPGKeyrings(); + return rsAccounts->copyGnuPGKeyrings(); } // Rs Accounts bool RsAccounts::SelectAccount(const RsPeerId &id) { - return rsAccounts.selectId(id); + return rsAccounts->selectId(id); } bool RsAccounts::GetPreferredAccountId(RsPeerId &id) { - return rsAccounts.getPreferredAccountId(id); + return rsAccounts->getPreferredAccountId(id); } bool RsAccounts::GetAccountIds(std::list &ids) { - return rsAccounts.getAccountIds(ids); + return rsAccounts->getAccountIds(ids); } bool RsAccounts::GetAccountDetails(const RsPeerId &id, RsPgpId &pgpId, std::string &pgpName, std::string &pgpEmail, std::string &location) { - return rsAccounts.getAccountDetails(id, pgpId, pgpName, pgpEmail, location); + return rsAccounts->getAccountDetails(id, pgpId, pgpName, pgpEmail, location); } bool RsAccounts::GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString) { - return rsAccounts.GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, passwd, sslId, errString); + return rsAccounts->GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, passwd, sslId, errString); } /********************************************************************************* diff --git a/libretroshare/src/rsserver/rsaccounts.h b/libretroshare/src/rsserver/rsaccounts.h index 5299140b6..7764d9863 100644 --- a/libretroshare/src/rsserver/rsaccounts.h +++ b/libretroshare/src/rsserver/rsaccounts.h @@ -147,5 +147,5 @@ class RsAccountsDetail }; // Global singleton declaration of data. -extern RsAccountsDetail rsAccounts; +extern RsAccountsDetail *rsAccounts; diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 9fdc041d7..52c97b4fe 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -81,56 +81,56 @@ // #define AUTHSSL_DEBUG // #define FIM_DEBUG - //std::map > RsInit::unsupported_keys ; class RsInitConfig { public: - static RsFileHash main_executable_hash; + RsFileHash main_executable_hash; #ifdef WINDOWS_SYS - static bool portable; - static bool isWindowsXP; + bool portable; + bool isWindowsXP; #endif - static rs_lock_handle_t lockHandle; + rs_lock_handle_t lockHandle; - static std::string passwd; - static std::string gxs_passwd; + std::string passwd; + std::string gxs_passwd; - static bool autoLogin; /* autoLogin allowed */ - static bool startMinimised; /* Icon or Full Window */ + bool autoLogin; /* autoLogin allowed */ + bool startMinimised; /* Icon or Full Window */ - /* Key Parameters that must be set before - * RetroShare will start up: - */ + /* Key Parameters that must be set before + * RetroShare will start up: + */ - /* Listening Port */ - static bool forceExtPort; - static bool forceLocalAddr; - static unsigned short port; - static std::string inet ; + /* Listening Port */ + bool forceExtPort; + bool forceLocalAddr; + unsigned short port; + std::string inet ; /* v0.6 features */ - static bool hiddenNodeSet; - static std::string hiddenNodeAddress; - static uint16_t hiddenNodePort; + bool hiddenNodeSet; + std::string hiddenNodeAddress; + uint16_t hiddenNodePort; - /* Logging */ - static bool haveLogFile; - static bool outStderr; - static int debugLevel; - static std::string logfname; + /* Logging */ + bool haveLogFile; + bool outStderr; + int debugLevel; + std::string logfname; - static bool load_trustedpeer; - static std::string load_trustedpeer_file; + bool load_trustedpeer; + std::string load_trustedpeer_file; - static bool udpListenerOnly; + bool udpListenerOnly; - static std::string RetroShareLink; + std::string RetroShareLink; }; +static RsInitConfig *rsInitConfig = NULL; const int p3facestartupzone = 47238; @@ -145,78 +145,49 @@ const int p3facestartupzone = 47238; static const std::string configLogFileName = "retro.log"; static const int SSLPWD_LEN = 64; -RsFileHash RsInitConfig::main_executable_hash; - -rs_lock_handle_t RsInitConfig::lockHandle; - -std::string RsInitConfig::passwd; -std::string RsInitConfig::gxs_passwd; - -bool RsInitConfig::autoLogin; /* autoLogin allowed */ -bool RsInitConfig::startMinimised; /* Icon or Full Window */ -std::string RsInitConfig::RetroShareLink; - -/* Directories */ -#ifdef WINDOWS_SYS -bool RsInitConfig::portable = false; -bool RsInitConfig::isWindowsXP = false; -#endif - -/* Listening Port */ -bool RsInitConfig::forceExtPort; -bool RsInitConfig::forceLocalAddr; -unsigned short RsInitConfig::port; -std::string RsInitConfig::inet; - -/* v0.6 features */ -bool RsInitConfig::hiddenNodeSet = false; -std::string RsInitConfig::hiddenNodeAddress; -uint16_t RsInitConfig::hiddenNodePort; - -/* Logging */ -bool RsInitConfig::haveLogFile; -bool RsInitConfig::outStderr; -int RsInitConfig::debugLevel; -std::string RsInitConfig::logfname; - -bool RsInitConfig::load_trustedpeer; -std::string RsInitConfig::load_trustedpeer_file; - -bool RsInitConfig::udpListenerOnly; - - void RsInit::InitRsConfig() { + rsInitConfig = new RsInitConfig ; + + /* Directories */ +#ifdef WINDOWS_SYS + rsInitConfig->portable = false; + rsInitConfig->isWindowsXP = false; +#endif + /* v0.6 features */ + rsInitConfig->hiddenNodeSet = false; + + #ifndef WINDOWS_SYS - RsInitConfig::lockHandle = -1; + rsInitConfig->lockHandle = -1; #else - RsInitConfig::lockHandle = NULL; + rsInitConfig->lockHandle = NULL; #endif - RsInitConfig::load_trustedpeer = false; - RsInitConfig::port = 0 ; - RsInitConfig::forceLocalAddr = false; - RsInitConfig::haveLogFile = false; - RsInitConfig::outStderr = false; - RsInitConfig::forceExtPort = false; + rsInitConfig->load_trustedpeer = false; + rsInitConfig->port = 0 ; + rsInitConfig->forceLocalAddr = false; + rsInitConfig->haveLogFile = false; + rsInitConfig->outStderr = false; + rsInitConfig->forceExtPort = false; - RsInitConfig::inet = std::string("127.0.0.1"); + rsInitConfig->inet = std::string("127.0.0.1"); - RsInitConfig::autoLogin = false; // . - RsInitConfig::startMinimised = false; - RsInitConfig::passwd = ""; - RsInitConfig::debugLevel = PQL_WARNING; - RsInitConfig::udpListenerOnly = false; + rsInitConfig->autoLogin = false; // . + rsInitConfig->startMinimised = false; + rsInitConfig->passwd = ""; + rsInitConfig->debugLevel = PQL_WARNING; + rsInitConfig->udpListenerOnly = false; /* setup the homePath (default save location) */ -// RsInitConfig::homePath = getHomePath(); + // rsInitConfig->homePath = getHomePath(); #ifdef WINDOWS_SYS // test for portable version if (GetFileAttributes(L"portable") != (DWORD) -1) { // use portable version - RsInitConfig::portable = true; + rsInitConfig->portable = true; } // test for Windows XP @@ -228,20 +199,20 @@ void RsInit::InitRsConfig() if (osvi.dwMajorVersion == 5) { if (osvi.dwMinorVersion == 1) { /* Windows XP */ - RsInitConfig::isWindowsXP = true; + rsInitConfig->isWindowsXP = true; } else if (osvi.dwMinorVersion == 2) { SYSTEM_INFO si; memset(&si, 0, sizeof(si)); GetSystemInfo(&si); if (osvi.wProductType == VER_NT_WORKSTATION && si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) { /* Windows XP Professional x64 Edition */ - RsInitConfig::isWindowsXP = true; + rsInitConfig->isWindowsXP = true; } } } } - if (RsInitConfig::isWindowsXP) { + if (rsInitConfig->isWindowsXP) { std::cerr << "Running Windows XP" << std::endl; } else { std::cerr << "Not running Windows XP" << std::endl; @@ -358,8 +329,8 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck /* getopt info: every availiable option is listed here. if it is followed by a ':' it needs an argument. If it is followed by a '::' the argument is optional. */ - //RsInitConfig::logfname = "" ; - //RsInitConfig::inet = "" ; + //rsInitConfig->logfname = "" ; + //rsInitConfig->inet = "" ; #ifdef __APPLE__ /* HACK to avoid stupid OSX Finder behaviour @@ -377,20 +348,20 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck argstream as(argc,argv) ; - as >> option('a',"auto-login" ,RsInitConfig::autoLogin ,"AutoLogin (Windows Only) + StartMinimised") - >> option('m',"minimized" ,RsInitConfig::startMinimised ,"Start minimized." ) - >> option('s',"stderr" ,RsInitConfig::outStderr ,"output to stderr instead of log file." ) - >> option('u',"udp" ,RsInitConfig::udpListenerOnly,"Only listen to UDP." ) - >> option('e',"external-port" ,RsInitConfig::forceExtPort ,"Use a forwarded external port." ) + as >> option('a',"auto-login" ,rsInitConfig->autoLogin ,"AutoLogin (Windows Only) + StartMinimised") + >> option('m',"minimized" ,rsInitConfig->startMinimised ,"Start minimized." ) + >> option('s',"stderr" ,rsInitConfig->outStderr ,"output to stderr instead of log file." ) + >> option('u',"udp" ,rsInitConfig->udpListenerOnly,"Only listen to UDP." ) + >> option('e',"external-port" ,rsInitConfig->forceExtPort ,"Use a forwarded external port." ) - >> parameter('l',"log-file" ,RsInitConfig::logfname ,"logfile" ,"Set Log filename." ,false) - >> parameter('d',"debug-level" ,RsInitConfig::debugLevel ,"level" ,"Set debug level." ,false) - >> parameter('w',"password" ,RsInitConfig::passwd ,"password" ,"Set Login Password." ,false) - >> parameter('i',"ip-address" ,RsInitConfig::inet ,"nnn.nnn.nnn.nnn", "Set IP address to use." ,false) - >> parameter('p',"port" ,RsInitConfig::port ,"port", "Set listenning port to use." ,false) + >> parameter('l',"log-file" ,rsInitConfig->logfname ,"logfile" ,"Set Log filename." ,false) + >> parameter('d',"debug-level" ,rsInitConfig->debugLevel ,"level" ,"Set debug level." ,false) + >> parameter('w',"password" ,rsInitConfig->passwd ,"password" ,"Set Login Password." ,false) + >> parameter('i',"ip-address" ,rsInitConfig->inet ,"nnn.nnn.nnn.nnn", "Set IP address to use." ,false) + >> parameter('p',"port" ,rsInitConfig->port ,"port", "Set listenning port to use." ,false) >> parameter('c',"base-dir" ,opt_base_dir ,"directory", "Set base directory." ,false) >> parameter('U',"user-id" ,prefUserString ,"ID", "[User Name/GPG id/SSL id] Sets Account to Use, Useful when Autologin is enabled",false) - >> parameter('r',"link" ,RsInitConfig::RetroShareLink ,"retroshare://...", "Use a given Retroshare Link" ,false) + >> parameter('r',"link" ,rsInitConfig->RetroShareLink ,"retroshare://...", "Use a given Retroshare Link" ,false) #ifdef LOCALNET_TESTING >> parameter('R',"restrict-port" ,portRestrictions ,"port1-port2","Apply port restriction" ,false) #endif @@ -398,10 +369,10 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck as.defaultErrorHandling(true) ; - if(RsInitConfig::autoLogin) RsInitConfig::startMinimised = true ; - if(RsInitConfig::outStderr) RsInitConfig::haveLogFile = false ; - if(!RsInitConfig::logfname.empty()) RsInitConfig::haveLogFile = true; - if(RsInitConfig::inet != "127.0.0.1") RsInitConfig::forceLocalAddr = true; + if(rsInitConfig->autoLogin) rsInitConfig->startMinimised = true ; + if(rsInitConfig->outStderr) rsInitConfig->haveLogFile = false ; + if(!rsInitConfig->logfname.empty()) rsInitConfig->haveLogFile = true; + if(rsInitConfig->inet != "127.0.0.1") rsInitConfig->forceLocalAddr = true; #ifdef LOCALNET_TESTING if(!portRestrictions.empty()) doPortRestrictions = true; #endif @@ -446,29 +417,29 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck } #endif - setOutputLevel(RsInitConfig::debugLevel); + setOutputLevel(rsInitConfig->debugLevel); // // set the default Debug Level... -// if (RsInitConfig::haveDebugLevel) +// if (rsInitConfig->haveDebugLevel) // { -// if ((RsInitConfig::debugLevel > 0) && -// (RsInitConfig::debugLevel <= PQL_DEBUG_ALL)) +// if ((rsInitConfig->debugLevel > 0) && +// (rsInitConfig->debugLevel <= PQL_DEBUG_ALL)) // { // std::cerr << "Setting Debug Level to: "; -// std::cerr << RsInitConfig::debugLevel; +// std::cerr << rsInitConfig->debugLevel; // std::cerr << std::endl; // } // else // { // std::cerr << "Ignoring Invalid Debug Level: "; -// std::cerr << RsInitConfig::debugLevel; +// std::cerr << rsInitConfig->debugLevel; // std::cerr << std::endl; // } // } // set the debug file. - if (RsInitConfig::haveLogFile) - setDebugFile(RsInitConfig::logfname.c_str()); + if (rsInitConfig->haveLogFile) + setDebugFile(rsInitConfig->logfname.c_str()); /******************************** WINDOWS/UNIX SPECIFIC PART ******************/ #ifndef WINDOWS_SYS @@ -519,10 +490,10 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck uint64_t tmp_size ; std::string tmp_name ; - if(!RsDirUtil::getFileHash(argv[0],RsInitConfig::main_executable_hash,tmp_size,NULL)) + if(!RsDirUtil::getFileHash(argv[0],rsInitConfig->main_executable_hash,tmp_size,NULL)) std::cerr << "Cannot hash executable! Plugins will not be loaded correctly." << std::endl; else - std::cerr << "Hashed main executable: " << RsInitConfig::main_executable_hash << std::endl; + std::cerr << "Hashed main executable: " << rsInitConfig->main_executable_hash << std::endl; /* At this point we want to. * 1) Load up Dase Directory. @@ -534,12 +505,14 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck AuthSSL::AuthSSLInit(); AuthSSL::getAuthSSL() -> InitAuth(NULL, NULL, NULL); + rsAccounts = new RsAccountsDetail() ; + // first check config directories, and set bootstrap values. - if(!rsAccounts.setupBaseDirectory(opt_base_dir)) + if(!rsAccounts->setupBaseDirectory(opt_base_dir)) return RS_INIT_BASE_DIR_ERROR ; // Setup PGP stuff. - std::string pgp_dir = rsAccounts.PathPGPDirectory(); + std::string pgp_dir = rsAccounts->PathPGPDirectory(); if(!RsDirUtil::checkCreateDirectory(pgp_dir)) throw std::runtime_error("Cannot create pgp directory " + pgp_dir) ; @@ -550,7 +523,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck pgp_dir + "/lock"); // load Accounts. - if (!rsAccounts.loadAccounts()) + if (!rsAccounts->loadAccounts()) { return RS_INIT_NO_KEYRING ; } @@ -558,7 +531,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck // choose alternative account. if(prefUserString != "") { - if (!rsAccounts.selectAccountByString(prefUserString)) + if (!rsAccounts->selectAccountByString(prefUserString)) { std::cerr << "Invalid User name/GPG id/SSL id: not found in list"; std::cerr << std::endl; @@ -568,16 +541,16 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck /* check that we have selected someone */ RsPeerId preferredId; - bool existingUser = rsAccounts.getPreferredAccountId(preferredId); + bool existingUser = rsAccounts->getPreferredAccountId(preferredId); if (existingUser) { - if (RsInitConfig::passwd != "") + if (rsInitConfig->passwd != "") { return RS_INIT_HAVE_ACCOUNT; } - if(RsLoginHandler::getSSLPassword(preferredId,false,RsInitConfig::passwd)) + if(RsLoginHandler::getSSLPassword(preferredId,false,rsInitConfig->passwd)) { RsInit::setAutoLogin(true); std::cerr << "Autologin has succeeded" << std::endl; @@ -603,7 +576,7 @@ int RsInit::LockConfigDirectory(const std::string& accountDir, std::string& lock const std::string lockFile = accountDir + "/" + "lock"; lockFilePath = lockFile; - return RsDirUtil::createLockFile(lockFile,RsInitConfig::lockHandle) ; + return RsDirUtil::createLockFile(lockFile,rsInitConfig->lockHandle) ; } /* @@ -612,7 +585,7 @@ int RsInit::LockConfigDirectory(const std::string& accountDir, std::string& lock */ void RsInit::UnlockConfigDirectory() { - RsDirUtil::releaseLockFile(RsInitConfig::lockHandle) ; + RsDirUtil::releaseLockFile(rsInitConfig->lockHandle) ; } @@ -631,7 +604,7 @@ bool RsInit::collectEntropy(uint32_t n) /* Login SSL */ bool RsInit::LoadPassword(const std::string& inPwd) { - RsInitConfig::passwd = inPwd; + rsInitConfig->passwd = inPwd; return true; } @@ -647,14 +620,14 @@ bool RsInit::LoadPassword(const std::string& inPwd) */ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath) { - if (!rsAccounts.lockPreferredAccount()) + if (!rsAccounts->lockPreferredAccount()) { return 3; // invalid PreferredAccount. } // Logic that used to be external to RsInit... RsPeerId accountId; - if (!rsAccounts.getPreferredAccountId(accountId)) + if (!rsAccounts->getPreferredAccountId(accountId)) { return 3; // invalid PreferredAccount; } @@ -662,13 +635,13 @@ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath RsPgpId pgpId; std::string pgpName, pgpEmail, location; - if (!rsAccounts.getAccountDetails(accountId, pgpId, pgpName, pgpEmail, location)) + if (!rsAccounts->getAccountDetails(accountId, pgpId, pgpName, pgpEmail, location)) return 3; // invalid PreferredAccount; - if (!rsAccounts.SelectPGPAccount(pgpId)) + if (!rsAccounts->SelectPGPAccount(pgpId)) return 3; // PGP Error. - int retVal = LockConfigDirectory(rsAccounts.PathAccountDirectory(), lockFilePath); + int retVal = LockConfigDirectory(rsAccounts->PathAccountDirectory(), lockFilePath); if(retVal != 0) return retVal; @@ -694,20 +667,20 @@ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath int RsInit::LoadCertificates(bool autoLoginNT) { RsPeerId preferredId; - if (!rsAccounts.getPreferredAccountId(preferredId)) + if (!rsAccounts->getPreferredAccountId(preferredId)) { std::cerr << "No Account Selected" << std::endl; return 0; } - if (rsAccounts.PathCertFile() == "") + if (rsAccounts->PathCertFile() == "") { std::cerr << "RetroShare needs a certificate" << std::endl; return 0; } - if (rsAccounts.PathKeyFile() == "") + if (rsAccounts->PathKeyFile() == "") { std::cerr << "RetroShare needs a key" << std::endl; return 0; @@ -715,21 +688,21 @@ int RsInit::LoadCertificates(bool autoLoginNT) //check if password is already in memory - if(RsInitConfig::passwd == "") { - if (RsLoginHandler::getSSLPassword(preferredId,true,RsInitConfig::passwd) == false) { + if(rsInitConfig->passwd == "") { + if (RsLoginHandler::getSSLPassword(preferredId,true,rsInitConfig->passwd) == false) { std::cerr << "RsLoginHandler::getSSLPassword() Failed!"; return 0 ; } } else { - if (RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile(preferredId,RsInitConfig::passwd) == false) { + if (RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile(preferredId,rsInitConfig->passwd) == false) { std::cerr << "RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile() Failed!"; return 0; } } - std::cerr << "rsAccounts.PathKeyFile() : " << rsAccounts.PathKeyFile() << std::endl; + std::cerr << "rsAccounts->PathKeyFile() : " << rsAccounts->PathKeyFile() << std::endl; - if(0 == AuthSSL::getAuthSSL() -> InitAuth(rsAccounts.PathCertFile().c_str(), rsAccounts.PathKeyFile().c_str(), RsInitConfig::passwd.c_str())) + if(0 == AuthSSL::getAuthSSL() -> InitAuth(rsAccounts->PathCertFile().c_str(), rsAccounts->PathKeyFile().c_str(), rsInitConfig->passwd.c_str())) { std::cerr << "SSL Auth Failed!"; return 0 ; @@ -740,25 +713,25 @@ int RsInit::LoadCertificates(bool autoLoginNT) std::cerr << "RetroShare will AutoLogin next time"; std::cerr << std::endl; - RsLoginHandler::enableAutoLogin(preferredId,RsInitConfig::passwd); - RsInitConfig::autoLogin = true ; + RsLoginHandler::enableAutoLogin(preferredId,rsInitConfig->passwd); + rsInitConfig->autoLogin = true ; } /* wipe out password */ // store pword to allow gxs use it to services' key their databases // ideally gxs should have its own password - RsInitConfig::gxs_passwd = RsInitConfig::passwd; - RsInitConfig::passwd = ""; + rsInitConfig->gxs_passwd = rsInitConfig->passwd; + rsInitConfig->passwd = ""; - rsAccounts.storePreferredAccount(); + rsAccounts->storePreferredAccount(); return 1; } bool RsInit::RsClearAutoLogin() { RsPeerId preferredId; - if (!rsAccounts.getPreferredAccountId(preferredId)) + if (!rsAccounts->getPreferredAccountId(preferredId)) { std::cerr << "RsInit::RsClearAutoLogin() No Account Selected" << std::endl; return 0; @@ -770,7 +743,7 @@ bool RsInit::RsClearAutoLogin() bool RsInit::isPortable() { #ifdef WINDOWS_SYS - return RsInitConfig::portable; + return rsInitConfig->portable; #else return false; #endif @@ -779,7 +752,7 @@ bool RsInit::isPortable() bool RsInit::isWindowsXP() { #ifdef WINDOWS_SYS - return RsInitConfig::isWindowsXP; + return rsInitConfig->isWindowsXP; #else return false; #endif @@ -787,12 +760,12 @@ bool RsInit::isWindowsXP() bool RsInit::getStartMinimised() { - return RsInitConfig::startMinimised; + return rsInitConfig->startMinimised; } std::string RsInit::getRetroShareLink() { - return RsInitConfig::RetroShareLink; + return rsInitConfig->RetroShareLink; } int RsInit::getSslPwdLen(){ @@ -800,20 +773,20 @@ int RsInit::getSslPwdLen(){ } bool RsInit::getAutoLogin(){ - return RsInitConfig::autoLogin; + return rsInitConfig->autoLogin; } void RsInit::setAutoLogin(bool autoLogin){ - RsInitConfig::autoLogin = autoLogin; + rsInitConfig->autoLogin = autoLogin; } /* Setup Hidden Location; */ bool RsInit::SetHiddenLocation(const std::string& hiddenaddress, uint16_t port) { /* parse the bugger (todo) */ - RsInitConfig::hiddenNodeSet = true; - RsInitConfig::hiddenNodeAddress = hiddenaddress; - RsInitConfig::hiddenNodePort = port; + rsInitConfig->hiddenNodeSet = true; + rsInitConfig->hiddenNodeAddress = hiddenaddress; + rsInitConfig->hiddenNodePort = port; return true; } @@ -991,15 +964,15 @@ int RsServer::StartupRetroShare() /* set the debugging to crashMode */ std::cerr << "set the debugging to crashMode." << std::endl; - if ((!RsInitConfig::haveLogFile) && (!RsInitConfig::outStderr)) + if ((!rsInitConfig->haveLogFile) && (!rsInitConfig->outStderr)) { - std::string crashfile = rsAccounts.PathAccountDirectory(); + std::string crashfile = rsAccounts->PathAccountDirectory(); crashfile += "/" + configLogFileName; setDebugCrashMode(crashfile.c_str()); } unsigned long flags = 0; - if (RsInitConfig::udpListenerOnly) + if (rsInitConfig->udpListenerOnly) { flags |= PQIPERSON_NO_LISTENER; } @@ -1008,8 +981,8 @@ int RsServer::StartupRetroShare() // Load up Certificates, and Old Configuration (if present) std::cerr << "Load up Certificates, and Old Configuration (if present)." << std::endl; - std::string emergencySaveDir = rsAccounts.PathAccountDirectory(); - std::string emergencyPartialsDir = rsAccounts.PathAccountDirectory(); + std::string emergencySaveDir = rsAccounts->PathAccountDirectory(); + std::string emergencyPartialsDir = rsAccounts->PathAccountDirectory(); if (emergencySaveDir != "") { emergencySaveDir += "/"; @@ -1023,13 +996,13 @@ int RsServer::StartupRetroShare() /**************************************************************************/ std::cerr << "Load Configuration" << std::endl; - mConfigMgr = new p3ConfigMgr(rsAccounts.PathAccountDirectory()); + mConfigMgr = new p3ConfigMgr(rsAccounts->PathAccountDirectory()); mGeneralConfig = new p3GeneralConfig(); // Get configuration options from rsAccounts. bool isHiddenNode = false; bool isFirstTimeRun = false; - rsAccounts.getAccountOptions(isHiddenNode, isFirstTimeRun); + rsAccounts->getAccountOptions(isHiddenNode, isFirstTimeRun); /**************************************************************************/ /* setup classes / structures */ @@ -1058,14 +1031,14 @@ int RsServer::StartupRetroShare() // for (std::list::iterator sslIdsIt = sslIds.begin(); sslIdsIt != sslIds.end(); sslIdsIt++) { // mConnMgr->addFriend(*sslIdsIt); // } - //p3DhtMgr *mDhtMgr = new OpenDHTMgr(ownId, mConnMgr, RsInitConfig::configDir); + //p3DhtMgr *mDhtMgr = new OpenDHTMgr(ownId, mConnMgr, rsInitConfig->configDir); /**************************** BITDHT ***********************************/ // Make up an address. XXX struct sockaddr_in tmpladdr; sockaddr_clear(&tmpladdr); - tmpladdr.sin_port = htons(RsInitConfig::port); + tmpladdr.sin_port = htons(rsInitConfig->port); #ifdef LOCALNET_TESTING @@ -1101,7 +1074,7 @@ int RsServer::StartupRetroShare() #define BITDHT_BOOTSTRAP_FILENAME "bdboot.txt" - std::string bootstrapfile = rsAccounts.PathAccountDirectory(); + std::string bootstrapfile = rsAccounts->PathAccountDirectory(); if (bootstrapfile != "") { bootstrapfile += "/"; @@ -1118,7 +1091,7 @@ int RsServer::StartupRetroShare() if (!RsDirUtil::checkFile(bootstrapfile,tmp_size,true)) { std::cerr << "DHT bootstrap file not in ConfigDir: " << bootstrapfile << std::endl; - std::string installfile = rsAccounts.PathDataDirectory(); + std::string installfile = rsAccounts->PathDataDirectory(); installfile += "/"; installfile += BITDHT_BOOTSTRAP_FILENAME; @@ -1182,7 +1155,7 @@ int RsServer::StartupRetroShare() #ifdef LOCALNET_TESTING // // HACK Proxy Port near Dht Port - For Relay Testing. - // uint16_t rndport = RsInitConfig::port + 3; + // uint16_t rndport = rsInitConfig->port + 3; // sndladdr.sin_port = htons(rndport); rsFixedUdpStack *mProxyStack = new rsFixedUdpStack(UDP_TEST_RESTRICTED_LAYER, sndladdr); @@ -1235,7 +1208,7 @@ int RsServer::StartupRetroShare() /****** New Ft Server **** !!! */ ftServer *ftserver = new ftServer(mPeerMgr, serviceCtrl); - ftserver->setConfigDirectory(rsAccounts.PathAccountDirectory()); + ftserver->setConfigDirectory(rsAccounts->PathAccountDirectory()); ftserver->SetupFtServer() ; CacheStrapper *mCacheStrapper = ftserver->getCacheStrapper(); @@ -1252,7 +1225,7 @@ int RsServer::StartupRetroShare() /* create Cache Services */ - std::string config_dir = rsAccounts.PathAccountDirectory(); + std::string config_dir = rsAccounts->PathAccountDirectory(); std::string localcachedir = config_dir + "/cache/local"; std::string remotecachedir = config_dir + "/cache/remote"; @@ -1261,7 +1234,7 @@ int RsServer::StartupRetroShare() #ifndef WINDOWS_SYS plugins_directories.push_back(std::string("/usr/lib/retroshare/extensions6/")) ; #endif - std::string extensions_dir = rsAccounts.PathBaseDirectory() + "/extensions6/" ; + std::string extensions_dir = rsAccounts->PathBaseDirectory() + "/extensions6/" ; plugins_directories.push_back(extensions_dir) ; if(!RsDirUtil::checkCreateDirectory(extensions_dir)) @@ -1272,7 +1245,7 @@ int RsServer::StartupRetroShare() // possible entries include: /usr/lib/retroshare, ~/.retroshare/extensions/, etc. #endif - mPluginsManager = new RsPluginManager(RsInitConfig::main_executable_hash) ; + mPluginsManager = new RsPluginManager(rsInitConfig->main_executable_hash) ; rsPlugins = mPluginsManager ; mConfigMgr->addConfiguration("plugins.cfg", mPluginsManager); mPluginsManager->loadConfiguration() ; @@ -1283,10 +1256,16 @@ int RsServer::StartupRetroShare() mPluginsManager->setCacheDirectories(localcachedir,remotecachedir) ; mPluginsManager->setServiceControl(serviceCtrl) ; +// std::cerr << "rsinitconf (core 1) = " << (void*)rsInitConfig<gxs_passwd << "\""<< std::endl; + // Now load the plugins. This parses the available SO/DLL files for known symbols. // mPluginsManager->loadPlugins(plugins_directories) ; +// std::cerr << "rsinitconf (core 1) = " << (void*)rsInitConfig<gxs_passwd << "\""<< std::endl; + // Also load some plugins explicitly. This is helpful for // - developping plugins // @@ -1300,7 +1279,7 @@ int RsServer::StartupRetroShare() #ifdef RS_ENABLE_GXS - std::string currGxsDir = rsAccounts.PathAccountDirectory() + "/gxs"; + std::string currGxsDir = rsAccounts->PathAccountDirectory() + "/gxs"; RsDirUtil::checkCreateDirectory(currGxsDir); RsNxsNetMgr* nxsMgr = new RsNxsNetMgrImpl(serviceCtrl); @@ -1308,7 +1287,7 @@ int RsServer::StartupRetroShare() /**** Identity service ****/ RsGeneralDataService* gxsid_ds = new RsDataService(currGxsDir + "/", "gxsid_db", - RS_SERVICE_GXS_TYPE_GXSID, NULL, RsInitConfig::gxs_passwd); + RS_SERVICE_GXS_TYPE_GXSID, NULL, rsInitConfig->gxs_passwd); // init gxs services PgpAuxUtils *pgpAuxUtils = new PgpAuxUtilsImpl(); @@ -1316,7 +1295,7 @@ int RsServer::StartupRetroShare() // circles created here, as needed by Ids. RsGeneralDataService* gxscircles_ds = new RsDataService(currGxsDir + "/", "gxscircles_db", - RS_SERVICE_GXS_TYPE_GXSCIRCLE, NULL, RsInitConfig::gxs_passwd); + RS_SERVICE_GXS_TYPE_GXSCIRCLE, NULL, rsInitConfig->gxs_passwd); // create GxsCircles - early, as IDs need it. mGxsCircles = new p3GxsCircles(gxscircles_ds, NULL, mGxsIdService, pgpAuxUtils); @@ -1345,7 +1324,7 @@ int RsServer::StartupRetroShare() RsGeneralDataService* posted_ds = new RsDataService(currGxsDir + "/", "posted_db", RS_SERVICE_GXS_TYPE_POSTED, - NULL, RsInitConfig::gxs_passwd); + NULL, rsInitConfig->gxs_passwd); mPosted = new p3Posted(posted_ds, NULL, mGxsIdService); @@ -1361,7 +1340,7 @@ int RsServer::StartupRetroShare() RsGeneralDataService* wiki_ds = new RsDataService(currGxsDir + "/", "wiki_db", RS_SERVICE_GXS_TYPE_WIKI, - NULL, RsInitConfig::gxs_passwd); + NULL, rsInitConfig->gxs_passwd); mWiki = new p3Wiki(wiki_ds, NULL, mGxsIdService); @@ -1376,7 +1355,7 @@ int RsServer::StartupRetroShare() /**** Forum GXS service ****/ RsGeneralDataService* gxsforums_ds = new RsDataService(currGxsDir + "/", "gxsforums_db", - RS_SERVICE_GXS_TYPE_FORUMS, NULL, RsInitConfig::gxs_passwd); + RS_SERVICE_GXS_TYPE_FORUMS, NULL, rsInitConfig->gxs_passwd); mGxsForums = new p3GxsForums(gxsforums_ds, NULL, mGxsIdService); @@ -1392,7 +1371,7 @@ int RsServer::StartupRetroShare() /**** Channel GXS service ****/ RsGeneralDataService* gxschannels_ds = new RsDataService(currGxsDir + "/", "gxschannels_db", - RS_SERVICE_GXS_TYPE_CHANNELS, NULL, RsInitConfig::gxs_passwd); + RS_SERVICE_GXS_TYPE_CHANNELS, NULL, rsInitConfig->gxs_passwd); mGxsChannels = new p3GxsChannels(gxschannels_ds, NULL, mGxsIdService); @@ -1408,7 +1387,7 @@ int RsServer::StartupRetroShare() #if 0 // PHOTO IS DISABLED FOR THE MOMENT /**** Photo service ****/ RsGeneralDataService* photo_ds = new RsDataService(currGxsDir + "/", "photoV2_db", - RS_SERVICE_GXS_TYPE_PHOTO, NULL, RsInitConfig::gxs_passwd); + RS_SERVICE_GXS_TYPE_PHOTO, NULL, rsInitConfig->gxs_passwd); // init gxs services mPhoto = new p3PhotoService(photo_ds, NULL, mGxsIdService); @@ -1425,7 +1404,7 @@ int RsServer::StartupRetroShare() /**** Wire GXS service ****/ RsGeneralDataService* wire_ds = new RsDataService(currGxsDir + "/", "wire_db", RS_SERVICE_GXS_TYPE_WIRE, - NULL, RsInitConfig::gxs_passwd); + NULL, rsInitConfig->gxs_passwd); mWire = new p3Wire(wire_ds, NULL, mGxsIdService); @@ -1446,7 +1425,7 @@ int RsServer::StartupRetroShare() //pqih->addService(photo_ns, true); // remove pword from memory - RsInitConfig::gxs_passwd = ""; + rsInitConfig->gxs_passwd = ""; #endif // RS_ENABLE_GXS. @@ -1498,7 +1477,13 @@ int RsServer::StartupRetroShare() interfaces.mDisc = rsDisc; interfaces.mDht = rsDht; interfaces.mNotify = mNotify; - + // gxs + interfaces.mGxsDir = currGxsDir; + interfaces.mIdentity = mGxsIdService; + interfaces.mRsNxsNetMgr = nxsMgr; + interfaces.mGxsIdService = mGxsIdService; + interfaces.mGxsCirlces = mGxsCircles; + interfaces.mPgpAuxUtils = pgpAuxUtils; mPluginsManager->setInterfaces(interfaces); // now add plugin objects inside the loop: @@ -1636,7 +1621,7 @@ int RsServer::StartupRetroShare() /**************************************************************************/ std::cerr << "Force Any Configuration before Startup (After Load)" << std::endl; - if (RsInitConfig::forceLocalAddr) + if (rsInitConfig->forceLocalAddr) { struct sockaddr_storage laddr; @@ -1646,24 +1631,24 @@ int RsServer::StartupRetroShare() struct sockaddr_in *lap = (struct sockaddr_in *) &laddr; lap->sin_family = AF_INET; - lap->sin_port = htons(RsInitConfig::port); + lap->sin_port = htons(rsInitConfig->port); // universal - lap->sin_addr.s_addr = inet_addr(RsInitConfig::inet.c_str()); + lap->sin_addr.s_addr = inet_addr(rsInitConfig->inet.c_str()); mPeerMgr->setLocalAddress(ownId, laddr); } - if (RsInitConfig::forceExtPort) + if (rsInitConfig->forceExtPort) { mPeerMgr->setOwnNetworkMode(RS_NET_MODE_EXT); mPeerMgr->setOwnVisState(RS_VS_DISC_FULL, RS_VS_DHT_FULL); } - if (RsInitConfig::hiddenNodeSet) + if (rsInitConfig->hiddenNodeSet) { - mPeerMgr->setupHiddenNode(RsInitConfig::hiddenNodeAddress, RsInitConfig::hiddenNodePort); + mPeerMgr->setupHiddenNode(rsInitConfig->hiddenNodeAddress, rsInitConfig->hiddenNodePort); } else if (isHiddenNode) { diff --git a/libretroshare/src/rsserver/rsloginhandler.cc b/libretroshare/src/rsserver/rsloginhandler.cc index 29eac30c8..b8b9a66fd 100644 --- a/libretroshare/src/rsserver/rsloginhandler.cc +++ b/libretroshare/src/rsserver/rsloginhandler.cc @@ -689,11 +689,11 @@ bool RsLoginHandler::getSSLPasswdFromGPGFile(const RsPeerId& ssl_id,std::string& std::string RsLoginHandler::getSSLPasswdFileName(const RsPeerId& /*ssl_id*/) { - return rsAccounts.PathAccountKeysDirectory() + "/" + "ssl_passphrase.pgp"; + return rsAccounts->PathAccountKeysDirectory() + "/" + "ssl_passphrase.pgp"; } std::string RsLoginHandler::getAutologinFileName(const RsPeerId& /*ssl_id*/) { - return rsAccounts.PathAccountKeysDirectory() + "/" + "help.dta" ; + return rsAccounts->PathAccountKeysDirectory() + "/" + "help.dta" ; } diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index 96f0a1100..45b1c03a4 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -220,9 +220,15 @@ void p3GxsCircles::notifyChanges(std::vector &changes) #endif // for new circles we need to add them to the list. - RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/ - RsGxsCircleId tempId(git->toStdString()); - mCircleExternalIdList.push_back(tempId); + // we don't know the type of this circle here + // original behavior was to add all ids to the external ids list + addCircleIdToList(RsGxsCircleId(*git), 0); + + // reset the cached circle data for this id + { + RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/ + mCircleCache.erase(RsGxsCircleId(*git)); + } } } } @@ -419,7 +425,7 @@ bool p3GxsCircles::getGroupData(const uint32_t &token, std::vectorconvertFrom(group); RsGenExchange::publishGroup(token, item); - return true; +} + +void p3GxsCircles::updateGroup(uint32_t &token, RsGxsCircleGroup &group) +{ + // note: refresh of circle cache gets triggered in the RsGenExchange::notifyChanges() callback + RsGxsCircleGroupItem* item = new RsGxsCircleGroupItem(); + item->convertFrom(group); + + RsGenExchange::updateGroup(token, item); } RsGenExchange::ServiceCreate_Return p3GxsCircles::service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& /*keySet*/) @@ -457,18 +471,9 @@ RsGenExchange::ServiceCreate_Return p3GxsCircles::service_CreateGroup(RsGxsGrpIt item->meta.mCircleId = RsGxsCircleId(item->meta.mGroupId); } - { - RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/ - - if (item->meta.mCircleType == GXS_CIRCLE_TYPE_LOCAL) - { - mCirclePersonalIdList.push_back(RsGxsCircleId(item->meta.mGroupId.toStdString())); - } - else - { - mCircleExternalIdList.push_back(RsGxsCircleId(item->meta.mGroupId.toStdString())); - } - } + // the advantage of adding the id to the list now is, that we know the cirlce type at this point + // this is not the case in NotifyChanges() + addCircleIdToList(RsGxsCircleId(item->meta.mGroupId), item->meta.mCircleType); return SERVICE_CREATE_SUCCESS; } @@ -596,29 +601,21 @@ bool p3GxsCircles::load_CircleIdList(uint32_t token) std::cerr << std::endl; #endif // DEBUG_CIRCLES - std::list groups; - bool ok = RsGenExchange::getGroupMeta(token, groups); + std::list groups; + bool ok = RsGenExchange::getGroupMeta(token, groups); if(ok) { // Save List - std::list::iterator it; - RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/ + { + RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/ + mCirclePersonalIdList.clear(); + mCircleExternalIdList.clear(); + } - mCirclePersonalIdList.clear(); - mCircleExternalIdList.clear(); - - for(it = groups.begin(); it != groups.end(); it++) + for(std::list::iterator it = groups.begin(); it != groups.end(); it++) { - RsGxsCircleId tempId(it->mGroupId.toStdString()); - if (it->mCircleType == GXS_CIRCLE_TYPE_LOCAL) - { - mCirclePersonalIdList.push_back(tempId); - } - else - { - mCircleExternalIdList.push_back(tempId); - } + addCircleIdToList(RsGxsCircleId(it->mGroupId), it->mCircleType); } } else @@ -1261,6 +1258,24 @@ bool p3GxsCircles::checkCircleCacheForAutoSubscribe(RsGxsCircleCache &cache) return false; } +void p3GxsCircles::addCircleIdToList(const RsGxsCircleId &circleId, uint32_t circleType) +{ + RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/ + + if (circleType == GXS_CIRCLE_TYPE_LOCAL) + { + if(mCirclePersonalIdList.end() == std::find(mCirclePersonalIdList.begin(), mCirclePersonalIdList.end(), circleId)){ + mCirclePersonalIdList.push_back(circleId); + } + } + else + { + if(mCircleExternalIdList.end() == std::find(mCircleExternalIdList.begin(), mCircleExternalIdList.end(), circleId)){ + mCircleExternalIdList.push_back(circleId); + } + } +} + #ifdef HANDLE_SUBCIRCLES diff --git a/libretroshare/src/services/p3gxscircles.h b/libretroshare/src/services/p3gxscircles.h index a6adf3bd9..ca40af234 100644 --- a/libretroshare/src/services/p3gxscircles.h +++ b/libretroshare/src/services/p3gxscircles.h @@ -40,6 +40,35 @@ #include #include +// TODO: +// can now edit circles. this leads to the following situation: +// if someone gets removed from a self.retricted circle, he won't notice +// because he can't receive the updated circle group if he is not part of the group anymore +// +// idea 1: refresh circle groups for example every week +// if a circle was not refreshed since two weeks we can assume we where deleted +// pro: does not leak info, simple to implement, does work even if the network topology changed (unfriending) +// con: delay until we know about the deletion +// +// idea 2: add a field with deleted members to the circle group +// then circle members can tell deleted circle members that they where deleted +// pro: faster notification about deletion +// con: more complicated, leaks info because the deleted member learns who is still a member +// question: how to authenticate the deletion message? +// +// idea 3: make a two phase deletion process +// first add members to a to-delete list +// then wait a week to let the changes propagate +// then remove from allowed peers list +// pro: easy to implement +// con: deletion process is slow +// improvement idea: let only circle groups sync when the member is on he to-delete list +// but don't allow sync of data from other services +// this requires that the netservice knows that he is dealing with a circle group +// +// fact: have to use a timeout mechanism. +// a timeout is the only thing which works even with a two months old backup + /* * Circles Identity Service * @@ -152,7 +181,8 @@ virtual RsServiceInfo getServiceInfo(); virtual bool getGroupData(const uint32_t &token, std::vector &groups); - virtual bool createGroup(uint32_t& token, RsGxsCircleGroup &group); + virtual void createGroup(uint32_t& token, RsGxsCircleGroup &group); + virtual void updateGroup(uint32_t &token, RsGxsCircleGroup &group); /**********************************************/ @@ -198,6 +228,11 @@ virtual RsServiceInfo getServiceInfo(); p3IdService *mIdentities; // Needed for constructing Circle Info, PgpAuxUtils *mPgpUtils; + // put a circle id into the external or personal circle id list + // this function locks the mutex + // if the id is already in the list, it will not be added again + void addCircleIdToList(const RsGxsCircleId& circleId, uint32_t circleType); + RsMutex mCircleMtx; /* Locked Below Here */ std::list mCircleExternalIdList; diff --git a/libretroshare/src/services/p3idservice.cc b/libretroshare/src/services/p3idservice.cc index 7b26b99d6..f504dba8b 100644 --- a/libretroshare/src/services/p3idservice.cc +++ b/libretroshare/src/services/p3idservice.cc @@ -311,12 +311,10 @@ bool p3IdService:: getIdDetails(const RsGxsId &id, RsIdentityDetails &details) } -bool p3IdService:: getOwnIds(std::list &ownIds) +void p3IdService::getOwnIds(std::list &ownIds) { RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/ ownIds = mOwnIds; - - return true; } @@ -2290,9 +2288,13 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(RsGxsGrpIte // copy meta data to be sure its all the same. //item->group.mMeta = item->meta; - // Reload in a little bit. - // HACK to get it to work. - RsTickEvent::schedule_in(GXSID_EVENT_CACHEOWNIDS, OWNID_RELOAD_DELAY); + // do it like p3gxscircles: save the new grp id + // this allows the user interface + // to see the grp id on the list of ownIds immediately after the group was created + { + RsStackMutex stack(mIdMtx); + mOwnIds.push_back(RsGxsId(item->meta.mGroupId)); + } return createStatus; } diff --git a/libretroshare/src/services/p3idservice.h b/libretroshare/src/services/p3idservice.h index cdad71407..22536610f 100644 --- a/libretroshare/src/services/p3idservice.h +++ b/libretroshare/src/services/p3idservice.h @@ -257,7 +257,7 @@ virtual bool deleteGroup(uint32_t& token, RsGxsIdGroup &group); //virtual bool getNickname(const RsGxsId &id, std::string &nickname); virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details); -virtual bool getOwnIds(std::list &ownIds); +virtual void getOwnIds(std::list &ownIds); diff --git a/libretroshare/src/util/rsdiscspace.cc b/libretroshare/src/util/rsdiscspace.cc index 5b5e4ffba..12fea3969 100644 --- a/libretroshare/src/util/rsdiscspace.cc +++ b/libretroshare/src/util/rsdiscspace.cc @@ -161,13 +161,13 @@ bool RsDiscSpace::checkForDiscSpace(RsDiscSpace::DiscLocation loc) #endif break ; - case RS_CONFIG_DIRECTORY: rs = crossSystemDiskStats(rsAccounts.PathAccountDirectory().c_str(),free_blocks,block_size) ; + case RS_CONFIG_DIRECTORY: rs = crossSystemDiskStats(rsAccounts->PathAccountDirectory().c_str(),free_blocks,block_size) ; #ifdef DEBUG_RSDISCSPACE std::cerr << " path = " << RsInit::RsConfigDirectory() << std::endl ; #endif break ; - case RS_PGP_DIRECTORY: rs = crossSystemDiskStats(rsAccounts.PathPGPDirectory().c_str(),free_blocks,block_size) ; + case RS_PGP_DIRECTORY: rs = crossSystemDiskStats(rsAccounts->PathPGPDirectory().c_str(),free_blocks,block_size) ; #ifdef DEBUG_RSDISCSPACE std::cerr << " path = " << RsInit::RsPGPDirectory() << std::endl ; #endif diff --git a/retroshare-gui/src/gui/settings/PluginsPage.cpp b/retroshare-gui/src/gui/settings/PluginsPage.cpp index db196eb5a..f6b4a0cb0 100644 --- a/retroshare-gui/src/gui/settings/PluginsPage.cpp +++ b/retroshare-gui/src/gui/settings/PluginsPage.cpp @@ -144,7 +144,7 @@ PluginsPage::PluginsPage(QWidget * parent, Qt::WindowFlags flags) // todo ui.enableAll->setChecked(rsPlugins->getAllowAllPlugins()); ui.enableAll->setToolTip(tr("Check this for developing plugins. They will not\nbe checked for the hash. However, in normal\ntimes, checking the hash protects you from\nmalicious behavior of crafted plugins.")); - ui.enableAll->setEnabled(false); + ui.enableAll->setEnabled(false); QObject::connect(ui.enableAll,SIGNAL(toggled(bool)),this,SLOT(toggleEnableAll(bool))) ; } diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index b97398f2e..dcfd2809e 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1,6 +1,9 @@ QT += network xml script CONFIG += qt gui uic qrc resources idle bitdht +#QMAKE_CFLAGS += -fmudflap +#LIBS *= /usr/lib/gcc/x86_64-linux-gnu/4.4/libmudflap.a /usr/lib/gcc/x86_64-linux-gnu/4.4/libmudflapth.a + greaterThan(QT_MAJOR_VERSION, 4) { # Qt 5 QT += uitools widgets multimedia printsupport @@ -144,6 +147,11 @@ win32-x-g++ { #################################### Windows ##################################### win32 { + debug { + # show console output + CONFIG += console + } + # Switch on extra warnings QMAKE_CFLAGS += -Wextra QMAKE_CXXFLAGS += -Wextra @@ -484,13 +492,13 @@ HEADERS += rshare.h \ gui/statusbar/dhtstatus.h \ gui/statusbar/ratesstatus.h \ gui/statusbar/hashingstatus.h \ - gui/statusbar/discstatus.h \ - gui/statusbar/SoundStatus.h \ - gui/statusbar/OpModeStatus.h \ - gui/statusbar/ToasterDisable.h \ - gui/advsearch/advancedsearchdialog.h \ - gui/advsearch/expressionwidget.h \ - gui/advsearch/guiexprelement.h \ + gui/statusbar/discstatus.h \ + gui/statusbar/SoundStatus.h \ + gui/statusbar/OpModeStatus.h \ + gui/statusbar/ToasterDisable.h \ + gui/advsearch/advancedsearchdialog.h \ + gui/advsearch/expressionwidget.h \ + gui/advsearch/guiexprelement.h \ gui/elastic/graphwidget.h \ gui/elastic/edge.h \ gui/elastic/arrow.h \ @@ -801,13 +809,13 @@ SOURCES += main.cpp \ gui/statusbar/dhtstatus.cpp \ gui/statusbar/ratesstatus.cpp \ gui/statusbar/hashingstatus.cpp \ - gui/statusbar/discstatus.cpp \ - gui/statusbar/SoundStatus.cpp \ - gui/statusbar/OpModeStatus.cpp \ - gui/statusbar/ToasterDisable.cpp \ - gui/toaster/MessageToaster.cpp \ - gui/toaster/DownloadToaster.cpp \ - gui/toaster/OnlineToaster.cpp \ + gui/statusbar/discstatus.cpp \ + gui/statusbar/SoundStatus.cpp \ + gui/statusbar/OpModeStatus.cpp \ + gui/statusbar/ToasterDisable.cpp \ + gui/toaster/MessageToaster.cpp \ + gui/toaster/DownloadToaster.cpp \ + gui/toaster/OnlineToaster.cpp \ gui/toaster/ChatToaster.cpp \ gui/toaster/GroupChatToaster.cpp \ gui/toaster/ChatLobbyToaster.cpp \