Merge of branch v0.6-rssocialnet 7419 to 7488. Changes from electron and myself:

- added possibility to modify groups (e.g. edit circles)
- fixed mismatched free/delete in fimonitor.cc, authssl.cc, pqibin.cc (saving encrypted hash cache file)
- improved plugin interface class to allow plugins to access GXS objects.
- added method to un-register notify clients from RsNotify
- fixed pqisslproxy for windows, due to win not properly supporting sockets in non blocking mode.
- removed static members form RsInitConfig and made RsAccounts object a pointer. This prevents plugin initialisation problems at symbol resolving time.
- removed bool return from p3IdService::getOwnIds()



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7492 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-08-25 21:07:07 +00:00
parent 906efa6f6c
commit f6db432c74
24 changed files with 525 additions and 322 deletions

View File

@ -159,7 +159,7 @@ HashCache::HashCache(const std::string& path)
std::string s((char *)decrypted_data,decrypted_data_size) ; std::string s((char *)decrypted_data,decrypted_data_size) ;
f = new std::istringstream(s) ; f = new std::istringstream(s) ;
delete[] (unsigned char *)decrypted_data ; free(decrypted_data) ;
} }
else else
{ {

View File

@ -109,7 +109,8 @@ PUBLIC_HEADERS = retroshare/rsdisc.h \
HEADERS += plugins/pluginmanager.h \ HEADERS += plugins/pluginmanager.h \
plugins/dlfcn_win32.h \ plugins/dlfcn_win32.h \
serialiser/rspluginitems.h serialiser/rspluginitems.h \
util/rsinitedptr.h
HEADERS += $$PUBLIC_HEADERS HEADERS += $$PUBLIC_HEADERS

View File

@ -406,9 +406,11 @@ void RsPluginManager::registerClientServices(p3ServiceServer *pqih)
std::cerr << " Registering pqi services." << std::endl; std::cerr << " Registering pqi services." << std::endl;
for(uint32_t i=0;i<_plugins.size();++i) 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; 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) if( _plugins[i].plugin->rs_cache_service() != NULL)
ConfigMgr->addConfiguration(_plugins[i].plugin->configurationFileName(), _plugins[i].plugin->rs_cache_service()); ConfigMgr->addConfiguration(_plugins[i].plugin->configurationFileName(), _plugins[i].plugin->rs_cache_service());
else if(_plugins[i].plugin->rs_pqi_service() != NULL) //else if(_plugins[i].plugin->rs_pqi_service() != NULL)
ConfigMgr->addConfiguration(_plugins[i].plugin->configurationFileName(), _plugins[i].plugin->rs_pqi_service()); // 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 else
continue ; continue ;

View File

@ -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 // 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); net_ekl = htonl(eklen);
memcpy((unsigned char*)out + out_offset, &net_ekl, size_net_ekl); 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 // now encrypt actual data
if(!EVP_SealUpdate(&ctx, (unsigned char*) out + out_offset, &out_currOffset, (unsigned char*) in, inlen)) { if(!EVP_SealUpdate(&ctx, (unsigned char*) out + out_offset, &out_currOffset, (unsigned char*) in, inlen)) {
free(ek); free(ek);
delete[] (unsigned char*) out; free(out);
out = NULL; out = NULL;
return false; return false;
} }
@ -1279,7 +1279,7 @@ bool AuthSSLimpl::encrypt(void *&out, int &outlen, const void *in, int inlen,
// add padding // add padding
if(!EVP_SealFinal(&ctx, (unsigned char*) out + out_offset, &out_currOffset)) { if(!EVP_SealFinal(&ctx, (unsigned char*) out + out_offset, &out_currOffset)) {
free(ek); free(ek);
delete[] (unsigned char*) out; free(out) ;
out = NULL; out = NULL;
return false; return false;
} }
@ -1360,11 +1360,11 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen)
return false; 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)) { if(!EVP_OpenUpdate(&ctx, (unsigned char*) out, &out_currOffset, (unsigned char*)in + in_offset, inlen - in_offset)) {
free(ek); free(ek);
delete[] (unsigned char*) out; free(out) ;
out = NULL; out = NULL;
return false; 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)) { if(!EVP_OpenFinal(&ctx, (unsigned char*)out + out_currOffset, &out_currOffset)) {
free(ek); free(ek);
delete[] (unsigned char*) out; free(out) ;
out = NULL; out = NULL;
return false; return false;
} }

View File

@ -26,6 +26,7 @@
#include "pqi/p3notify.h" #include "pqi/p3notify.h"
#include <stdint.h> #include <stdint.h>
#include <algorithm>
RsNotify *rsNotify = NULL ; RsNotify *rsNotify = NULL ;
@ -284,3 +285,16 @@ void p3Notify::registerNotifyClient(NotifyClient *cl)
notifyClients.push_back(cl) ; notifyClients.push_back(cl) ;
} }
bool p3Notify::unregisterNotifyClient(NotifyClient *nc)
{
std::list<NotifyClient*>::iterator it = std::find(notifyClients.begin(), notifyClients.end(), nc);
if(it != notifyClients.end())
{
notifyClients.erase(it);
return true;
}
else
{
return false;
}
}

View File

@ -70,6 +70,7 @@ class p3Notify: public RsNotify
virtual ~p3Notify() { return; } virtual ~p3Notify() { return; }
virtual void registerNotifyClient(NotifyClient *nc) ; virtual void registerNotifyClient(NotifyClient *nc) ;
virtual bool unregisterNotifyClient(NotifyClient *nc) ;
/* Pull output methods for retroshare-gui */ /* Pull output methods for retroshare-gui */
virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type, std::string &title, std::string &msg); virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type, std::string &title, std::string &msg);

View File

@ -185,7 +185,7 @@ BinEncryptedFileInterface::~BinEncryptedFileInterface()
{ {
if((sizeData > 0) && data != NULL) if((sizeData > 0) && data != NULL)
{ {
delete[] data; free(data);
} }
} }
@ -193,7 +193,7 @@ BinEncryptedFileInterface::~BinEncryptedFileInterface()
int BinEncryptedFileInterface::senddata(void* data, int len) int BinEncryptedFileInterface::senddata(void* data, int len)
{ {
char* encrytedData = NULL; void* encrytedData = NULL;
int encDataLen = 0; int encDataLen = 0;
// encrypt using own ssl public key // encrypt using own ssl public key
@ -205,8 +205,8 @@ int BinEncryptedFileInterface::senddata(void* data, int len)
if((encDataLen > 0) && (encrytedData != NULL)) if((encDataLen > 0) && (encrytedData != NULL))
{ {
BinFileInterface::senddata(encrytedData, encDataLen); BinFileInterface::senddata((unsigned char *)encrytedData, encDataLen);
delete[] encrytedData; free(encrytedData);
} }
else else
{ {
@ -288,7 +288,7 @@ int BinEncryptedFileInterface::close()
{ {
if(data != NULL) if(data != NULL)
{ {
delete[] data; free(data);
sizeData = 0; sizeData = 0;
haveData = false; haveData = false;
cpyCount = 0; cpyCount = 0;

View File

@ -214,10 +214,45 @@ int pqisslproxy::Proxy_Method_Response()
char method_response[2]; char method_response[2];
// read from the socket. /*
first it was:
int recvd = recv(sockfd, method_response, 2, MSG_WAITALL); 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) 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)) if ((recvd == -1) && (errno == EAGAIN))
{ {
@ -228,9 +263,30 @@ int pqisslproxy::Proxy_Method_Response()
return 0; return 0;
} }
else if (recvd == -1)
{
#ifdef PROXY_DEBUG #ifdef PROXY_DEBUG
std::cerr << "pqisslproxy::Proxy_Method_Response() Error recving response"; std::cerr << "pqisslproxy::Proxy_Method_Response() recv error peek";
std::cerr << std::endl;
#endif
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; std::cerr << std::endl;
#endif #endif
return -1; return -1;
@ -345,9 +401,20 @@ int pqisslproxy::Proxy_Connection_Complete()
char socks_response[MAX_SOCKS_REQUEST_LEN]; 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) 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)) if ((recvd == -1) && (errno == EAGAIN))
{ {
#ifdef PROXY_DEBUG #ifdef PROXY_DEBUG
@ -356,7 +423,28 @@ int pqisslproxy::Proxy_Connection_Complete()
#endif #endif
return 0; return 0;
} }
else if (recvd == -1)
{
#ifdef PROXY_DEBUG
std::cerr << "pqisslproxy::Proxy_Connection_Complete() recv error peek";
std::cerr << std::endl;
#endif
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 #ifdef PROXY_DEBUG
std::cerr << "pqisslproxy::Proxy_Connection_Complete() recv error"; std::cerr << "pqisslproxy::Proxy_Connection_Complete() recv error";
std::cerr << std::endl; std::cerr << std::endl;
@ -429,10 +517,20 @@ int pqisslproxy::Proxy_Connection_Complete()
} }
// read the remaining bytes. // test how many bytes can be read
recvd = recv(sockfd, &(socks_response[5]), address_bytes + 1, MSG_WAITALL); // address_bytes - 1 + 2... recvd = recv(sockfd, &(socks_response[5]), address_bytes + 1, MSG_PEEK); // address_bytes - 1 + 2...
if (recvd != address_bytes + 1) 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)) if ((recvd == -1) && (errno == EAGAIN))
{ {
#ifdef PROXY_DEBUG #ifdef PROXY_DEBUG
@ -442,10 +540,31 @@ int pqisslproxy::Proxy_Connection_Complete()
// Waiting - shouldn't happen. // Waiting - shouldn't happen.
return 0; return 0;
} }
else if (recvd == -1)
{
#ifdef PROXY_DEBUG #ifdef PROXY_DEBUG
std::cerr << "pqisslproxy::Proxy_Connection_Complete() ERROR recving(2)"; std::cerr << "pqisslproxy::Proxy_Connection_Complete() ERROR recving(2)";
std::cerr << std::endl; std::cerr << std::endl;
#endif
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 #endif
return -1; return -1;
} }

View File

@ -131,8 +131,10 @@ virtual bool getCirclePersonalIdList(std::list<RsGxsCircleId> &circleIds) = 0;
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsCircleGroup> &groups) = 0; virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsCircleGroup> &groups) = 0;
/* make new group */ /* make new group */
virtual bool createGroup(uint32_t& token, RsGxsCircleGroup &group) = 0; virtual void createGroup(uint32_t& token, RsGxsCircleGroup &group) = 0;
/* update an existing group */
virtual void updateGroup(uint32_t &token, RsGxsCircleGroup &group) = 0;
}; };

View File

@ -209,7 +209,7 @@ public:
//virtual bool getNickname(const RsGxsId &id, std::string &nickname) = 0; //virtual bool getNickname(const RsGxsId &id, std::string &nickname) = 0;
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details) = 0; virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details) = 0;
virtual bool getOwnIds(std::list<RsGxsId> &ownIds) = 0; virtual void getOwnIds(std::list<RsGxsId> &ownIds) = 0;
// //
virtual bool submitOpinion(uint32_t& token, const RsGxsId &id, virtual bool submitOpinion(uint32_t& token, const RsGxsId &id,

View File

@ -162,6 +162,8 @@ class RsNotify
public: public:
/* registration of notifies clients */ /* registration of notifies clients */
virtual void registerNotifyClient(NotifyClient *nc) = 0; virtual void registerNotifyClient(NotifyClient *nc) = 0;
/* returns true if NotifyClient was found */
virtual bool unregisterNotifyClient(NotifyClient *nc) = 0;
/* Pull methods for retroshare-gui */ /* Pull methods for retroshare-gui */
/* this should probably go into a different service. */ /* this should probably go into a different service. */

View File

@ -287,8 +287,9 @@ class RsPeers
virtual ~RsPeers() { return; } virtual ~RsPeers() { return; }
/* Updates ... */ /* Updates ... */
virtual bool FriendsChanged() = 0; // not implemented
virtual bool OthersChanged() = 0; //virtual bool FriendsChanged() = 0;
//virtual bool OthersChanged() = 0;
/* Peer Details (Net & Auth) */ /* Peer Details (Net & Auth) */
virtual const RsPeerId& getOwnId() = 0; virtual const RsPeerId& getOwnId() = 0;

View File

@ -33,6 +33,7 @@
#include "retroshare/rspeers.h" #include "retroshare/rspeers.h"
#include "retroshare/rsfiles.h" #include "retroshare/rsfiles.h"
#include "util/rsversion.h" #include "util/rsversion.h"
#include "util/rsinitedptr.h"
class RsPluginHandler ; class RsPluginHandler ;
extern RsPluginHandler *rsPlugins ; extern RsPluginHandler *rsPlugins ;
@ -62,6 +63,13 @@ class SoundEvents;
class FeedNotify; class FeedNotify;
class ChatWidget; class ChatWidget;
class ChatWidgetHolder; 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 // Plugin API version. Not used yet, but will be in the future the
// main value that decides for compatibility. // main value that decides for compatibility.
@ -88,20 +96,22 @@ class RsPluginHandler;
* *
*/ */
class RsPlugInInterfaces { class RsPlugInInterfaces {
public: public:
RsUtil::inited_ptr<RsPeers> mPeers;
RsUtil::inited_ptr<RsFiles> mFiles;
RsUtil::inited_ptr<RsMsgs> mMsgs;
RsUtil::inited_ptr<RsTurtle> mTurtle;
RsUtil::inited_ptr<RsDisc> mDisc;
RsUtil::inited_ptr<RsDht> mDht;
RsUtil::inited_ptr<RsNotify> mNotify;
RsPlugInInterfaces() // gxs
{ std::string mGxsDir;
memset(this,0,sizeof(RsPlugInInterfaces)) ; // zero all pointers. RsUtil::inited_ptr<RsIdentity> mIdentity;
} RsUtil::inited_ptr<RsNxsNetMgr> mRsNxsNetMgr;
RsPeers *mPeers; RsUtil::inited_ptr<RsGxsIdExchange> mGxsIdService;
RsFiles *mFiles; RsUtil::inited_ptr<RsGcxs> mGxsCirlces;
RsMsgs *mMsgs; RsUtil::inited_ptr<PgpAuxUtils> mPgpAuxUtils;
RsTurtle *mTurtle;
RsDisc *mDisc;
RsDht *mDht;
RsNotify *mNotify;
}; };
class RsPlugin class RsPlugin
@ -119,7 +129,11 @@ class RsPlugin
// exchange of data, such as chat, messages, etc. // exchange of data, such as chat, messages, etc.
// Example plugin: VOIP // 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 ; } virtual uint16_t rs_service_id() const { return 0 ; }
// Shutdown // Shutdown

View File

@ -53,7 +53,7 @@
#include <openssl/ssl.h> #include <openssl/ssl.h>
// Global singleton declaration of data. // Global singleton declaration of data.
RsAccountsDetail rsAccounts; RsAccountsDetail *rsAccounts;
/* Uses private class - so must be hidden */ /* Uses private class - so must be hidden */
static bool checkAccount(std::string accountdir, AccountDetails &account,std::map<std::string,std::vector<std::string> >& unsupported_keys); static bool checkAccount(std::string accountdir, AccountDetails &account,std::map<std::string,std::vector<std::string> >& 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; std::cerr << "issuerName: " << account.mPgpId << " id: " << account.mSslId << std::endl;
#endif #endif
if(! rsAccounts.GetPGPLoginDetails(account.mPgpId, account.mPgpName, account.mPgpEmail)) if(! rsAccounts->GetPGPLoginDetails(account.mPgpId, account.mPgpName, account.mPgpEmail))
return false ; return false ;
if(!AuthGPG::getAuthGPG()->haveSecretKey(account.mPgpId)) if(!AuthGPG::getAuthGPG()->haveSecretKey(account.mPgpId))
@ -1242,74 +1242,74 @@ std::string RsAccountsDetail::getHomePath()
********************************************************************************/ ********************************************************************************/
// Directories. // Directories.
std::string RsAccounts::ConfigDirectory() { return rsAccounts.PathBaseDirectory(); } std::string RsAccounts::ConfigDirectory() { return rsAccounts->PathBaseDirectory(); }
std::string RsAccounts::DataDirectory() { return rsAccounts.PathDataDirectory(); } std::string RsAccounts::DataDirectory() { return rsAccounts->PathDataDirectory(); }
std::string RsAccounts::PGPDirectory() { return rsAccounts.PathPGPDirectory(); } std::string RsAccounts::PGPDirectory() { return rsAccounts->PathPGPDirectory(); }
std::string RsAccounts::AccountDirectory() { return rsAccounts.PathAccountDirectory(); } std::string RsAccounts::AccountDirectory() { return rsAccounts->PathAccountDirectory(); }
// PGP Accounts. // PGP Accounts.
int RsAccounts::GetPGPLogins(std::list<RsPgpId> &pgpIds) int RsAccounts::GetPGPLogins(std::list<RsPgpId> &pgpIds)
{ {
return rsAccounts.GetPGPLogins(pgpIds); return rsAccounts->GetPGPLogins(pgpIds);
} }
int RsAccounts::GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email) 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) 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. // PGP Support Functions.
bool RsAccounts::ExportIdentity(const std::string& fname,const RsPgpId& pgp_id) 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) 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<std::string,std::vector<std::string> > &unsupported_keys) void RsAccounts::GetUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys)
{ {
return rsAccounts.getUnsupportedKeys(unsupported_keys); return rsAccounts->getUnsupportedKeys(unsupported_keys);
} }
bool RsAccounts::CopyGnuPGKeyrings() bool RsAccounts::CopyGnuPGKeyrings()
{ {
return rsAccounts.copyGnuPGKeyrings(); return rsAccounts->copyGnuPGKeyrings();
} }
// Rs Accounts // Rs Accounts
bool RsAccounts::SelectAccount(const RsPeerId &id) bool RsAccounts::SelectAccount(const RsPeerId &id)
{ {
return rsAccounts.selectId(id); return rsAccounts->selectId(id);
} }
bool RsAccounts::GetPreferredAccountId(RsPeerId &id) bool RsAccounts::GetPreferredAccountId(RsPeerId &id)
{ {
return rsAccounts.getPreferredAccountId(id); return rsAccounts->getPreferredAccountId(id);
} }
bool RsAccounts::GetAccountIds(std::list<RsPeerId> &ids) bool RsAccounts::GetAccountIds(std::list<RsPeerId> &ids)
{ {
return rsAccounts.getAccountIds(ids); return rsAccounts->getAccountIds(ids);
} }
bool RsAccounts::GetAccountDetails(const RsPeerId &id, bool RsAccounts::GetAccountDetails(const RsPeerId &id,
RsPgpId &pgpId, std::string &pgpName, RsPgpId &pgpId, std::string &pgpName,
std::string &pgpEmail, std::string &location) 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) 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);
} }
/********************************************************************************* /*********************************************************************************

View File

@ -147,5 +147,5 @@ class RsAccountsDetail
}; };
// Global singleton declaration of data. // Global singleton declaration of data.
extern RsAccountsDetail rsAccounts; extern RsAccountsDetail *rsAccounts;

View File

@ -81,56 +81,56 @@
// #define AUTHSSL_DEBUG // #define AUTHSSL_DEBUG
// #define FIM_DEBUG // #define FIM_DEBUG
//std::map<std::string,std::vector<std::string> > RsInit::unsupported_keys ; //std::map<std::string,std::vector<std::string> > RsInit::unsupported_keys ;
class RsInitConfig class RsInitConfig
{ {
public: public:
static RsFileHash main_executable_hash; RsFileHash main_executable_hash;
#ifdef WINDOWS_SYS #ifdef WINDOWS_SYS
static bool portable; bool portable;
static bool isWindowsXP; bool isWindowsXP;
#endif #endif
static rs_lock_handle_t lockHandle; rs_lock_handle_t lockHandle;
static std::string passwd; std::string passwd;
static std::string gxs_passwd; std::string gxs_passwd;
static bool autoLogin; /* autoLogin allowed */ bool autoLogin; /* autoLogin allowed */
static bool startMinimised; /* Icon or Full Window */ bool startMinimised; /* Icon or Full Window */
/* Key Parameters that must be set before /* Key Parameters that must be set before
* RetroShare will start up: * RetroShare will start up:
*/ */
/* Listening Port */ /* Listening Port */
static bool forceExtPort; bool forceExtPort;
static bool forceLocalAddr; bool forceLocalAddr;
static unsigned short port; unsigned short port;
static std::string inet ; std::string inet ;
/* v0.6 features */ /* v0.6 features */
static bool hiddenNodeSet; bool hiddenNodeSet;
static std::string hiddenNodeAddress; std::string hiddenNodeAddress;
static uint16_t hiddenNodePort; uint16_t hiddenNodePort;
/* Logging */ /* Logging */
static bool haveLogFile; bool haveLogFile;
static bool outStderr; bool outStderr;
static int debugLevel; int debugLevel;
static std::string logfname; std::string logfname;
static bool load_trustedpeer; bool load_trustedpeer;
static std::string load_trustedpeer_file; 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; const int p3facestartupzone = 47238;
@ -145,78 +145,49 @@ const int p3facestartupzone = 47238;
static const std::string configLogFileName = "retro.log"; static const std::string configLogFileName = "retro.log";
static const int SSLPWD_LEN = 64; static const int SSLPWD_LEN = 64;
RsFileHash RsInitConfig::main_executable_hash; void RsInit::InitRsConfig()
{
rs_lock_handle_t RsInitConfig::lockHandle; rsInitConfig = new RsInitConfig ;
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 */ /* Directories */
#ifdef WINDOWS_SYS #ifdef WINDOWS_SYS
bool RsInitConfig::portable = false; rsInitConfig->portable = false;
bool RsInitConfig::isWindowsXP = false; rsInitConfig->isWindowsXP = false;
#endif #endif
/* Listening Port */
bool RsInitConfig::forceExtPort;
bool RsInitConfig::forceLocalAddr;
unsigned short RsInitConfig::port;
std::string RsInitConfig::inet;
/* v0.6 features */ /* v0.6 features */
bool RsInitConfig::hiddenNodeSet = false; 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()
{
#ifndef WINDOWS_SYS #ifndef WINDOWS_SYS
RsInitConfig::lockHandle = -1; rsInitConfig->lockHandle = -1;
#else #else
RsInitConfig::lockHandle = NULL; rsInitConfig->lockHandle = NULL;
#endif #endif
RsInitConfig::load_trustedpeer = false; rsInitConfig->load_trustedpeer = false;
RsInitConfig::port = 0 ; rsInitConfig->port = 0 ;
RsInitConfig::forceLocalAddr = false; rsInitConfig->forceLocalAddr = false;
RsInitConfig::haveLogFile = false; rsInitConfig->haveLogFile = false;
RsInitConfig::outStderr = false; rsInitConfig->outStderr = false;
RsInitConfig::forceExtPort = false; rsInitConfig->forceExtPort = false;
RsInitConfig::inet = std::string("127.0.0.1"); rsInitConfig->inet = std::string("127.0.0.1");
RsInitConfig::autoLogin = false; // . rsInitConfig->autoLogin = false; // .
RsInitConfig::startMinimised = false; rsInitConfig->startMinimised = false;
RsInitConfig::passwd = ""; rsInitConfig->passwd = "";
RsInitConfig::debugLevel = PQL_WARNING; rsInitConfig->debugLevel = PQL_WARNING;
RsInitConfig::udpListenerOnly = false; rsInitConfig->udpListenerOnly = false;
/* setup the homePath (default save location) */ /* setup the homePath (default save location) */
// RsInitConfig::homePath = getHomePath(); // rsInitConfig->homePath = getHomePath();
#ifdef WINDOWS_SYS #ifdef WINDOWS_SYS
// test for portable version // test for portable version
if (GetFileAttributes(L"portable") != (DWORD) -1) { if (GetFileAttributes(L"portable") != (DWORD) -1) {
// use portable version // use portable version
RsInitConfig::portable = true; rsInitConfig->portable = true;
} }
// test for Windows XP // test for Windows XP
@ -228,20 +199,20 @@ void RsInit::InitRsConfig()
if (osvi.dwMajorVersion == 5) { if (osvi.dwMajorVersion == 5) {
if (osvi.dwMinorVersion == 1) { if (osvi.dwMinorVersion == 1) {
/* Windows XP */ /* Windows XP */
RsInitConfig::isWindowsXP = true; rsInitConfig->isWindowsXP = true;
} else if (osvi.dwMinorVersion == 2) { } else if (osvi.dwMinorVersion == 2) {
SYSTEM_INFO si; SYSTEM_INFO si;
memset(&si, 0, sizeof(si)); memset(&si, 0, sizeof(si));
GetSystemInfo(&si); GetSystemInfo(&si);
if (osvi.wProductType == VER_NT_WORKSTATION && si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) { if (osvi.wProductType == VER_NT_WORKSTATION && si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) {
/* Windows XP Professional x64 Edition */ /* Windows XP Professional x64 Edition */
RsInitConfig::isWindowsXP = true; rsInitConfig->isWindowsXP = true;
} }
} }
} }
} }
if (RsInitConfig::isWindowsXP) { if (rsInitConfig->isWindowsXP) {
std::cerr << "Running Windows XP" << std::endl; std::cerr << "Running Windows XP" << std::endl;
} else { } else {
std::cerr << "Not running Windows XP" << std::endl; 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 /* 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. needs an argument. If it is followed by a '::' the argument is optional.
*/ */
//RsInitConfig::logfname = "" ; //rsInitConfig->logfname = "" ;
//RsInitConfig::inet = "" ; //rsInitConfig->inet = "" ;
#ifdef __APPLE__ #ifdef __APPLE__
/* HACK to avoid stupid OSX Finder behaviour /* HACK to avoid stupid OSX Finder behaviour
@ -377,20 +348,20 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
argstream as(argc,argv) ; argstream as(argc,argv) ;
as >> option('a',"auto-login" ,RsInitConfig::autoLogin ,"AutoLogin (Windows Only) + StartMinimised") as >> option('a',"auto-login" ,rsInitConfig->autoLogin ,"AutoLogin (Windows Only) + StartMinimised")
>> option('m',"minimized" ,RsInitConfig::startMinimised ,"Start minimized." ) >> option('m',"minimized" ,rsInitConfig->startMinimised ,"Start minimized." )
>> option('s',"stderr" ,RsInitConfig::outStderr ,"output to stderr instead of log file." ) >> option('s',"stderr" ,rsInitConfig->outStderr ,"output to stderr instead of log file." )
>> option('u',"udp" ,RsInitConfig::udpListenerOnly,"Only listen to UDP." ) >> option('u',"udp" ,rsInitConfig->udpListenerOnly,"Only listen to UDP." )
>> option('e',"external-port" ,RsInitConfig::forceExtPort ,"Use a forwarded external port." ) >> option('e',"external-port" ,rsInitConfig->forceExtPort ,"Use a forwarded external port." )
>> parameter('l',"log-file" ,RsInitConfig::logfname ,"logfile" ,"Set Log filename." ,false) >> parameter('l',"log-file" ,rsInitConfig->logfname ,"logfile" ,"Set Log filename." ,false)
>> parameter('d',"debug-level" ,RsInitConfig::debugLevel ,"level" ,"Set debug level." ,false) >> parameter('d',"debug-level" ,rsInitConfig->debugLevel ,"level" ,"Set debug level." ,false)
>> parameter('w',"password" ,RsInitConfig::passwd ,"password" ,"Set Login Password." ,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('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('p',"port" ,rsInitConfig->port ,"port", "Set listenning port to use." ,false)
>> parameter('c',"base-dir" ,opt_base_dir ,"directory", "Set base directory." ,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('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 #ifdef LOCALNET_TESTING
>> parameter('R',"restrict-port" ,portRestrictions ,"port1-port2","Apply port restriction" ,false) >> parameter('R',"restrict-port" ,portRestrictions ,"port1-port2","Apply port restriction" ,false)
#endif #endif
@ -398,10 +369,10 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
as.defaultErrorHandling(true) ; as.defaultErrorHandling(true) ;
if(RsInitConfig::autoLogin) RsInitConfig::startMinimised = true ; if(rsInitConfig->autoLogin) rsInitConfig->startMinimised = true ;
if(RsInitConfig::outStderr) RsInitConfig::haveLogFile = false ; if(rsInitConfig->outStderr) rsInitConfig->haveLogFile = false ;
if(!RsInitConfig::logfname.empty()) RsInitConfig::haveLogFile = true; if(!rsInitConfig->logfname.empty()) rsInitConfig->haveLogFile = true;
if(RsInitConfig::inet != "127.0.0.1") RsInitConfig::forceLocalAddr = true; if(rsInitConfig->inet != "127.0.0.1") rsInitConfig->forceLocalAddr = true;
#ifdef LOCALNET_TESTING #ifdef LOCALNET_TESTING
if(!portRestrictions.empty()) doPortRestrictions = true; if(!portRestrictions.empty()) doPortRestrictions = true;
#endif #endif
@ -446,29 +417,29 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
} }
#endif #endif
setOutputLevel(RsInitConfig::debugLevel); setOutputLevel(rsInitConfig->debugLevel);
// // set the default Debug Level... // // set the default Debug Level...
// if (RsInitConfig::haveDebugLevel) // if (rsInitConfig->haveDebugLevel)
// { // {
// if ((RsInitConfig::debugLevel > 0) && // if ((rsInitConfig->debugLevel > 0) &&
// (RsInitConfig::debugLevel <= PQL_DEBUG_ALL)) // (rsInitConfig->debugLevel <= PQL_DEBUG_ALL))
// { // {
// std::cerr << "Setting Debug Level to: "; // std::cerr << "Setting Debug Level to: ";
// std::cerr << RsInitConfig::debugLevel; // std::cerr << rsInitConfig->debugLevel;
// std::cerr << std::endl; // std::cerr << std::endl;
// } // }
// else // else
// { // {
// std::cerr << "Ignoring Invalid Debug Level: "; // std::cerr << "Ignoring Invalid Debug Level: ";
// std::cerr << RsInitConfig::debugLevel; // std::cerr << rsInitConfig->debugLevel;
// std::cerr << std::endl; // std::cerr << std::endl;
// } // }
// } // }
// set the debug file. // set the debug file.
if (RsInitConfig::haveLogFile) if (rsInitConfig->haveLogFile)
setDebugFile(RsInitConfig::logfname.c_str()); setDebugFile(rsInitConfig->logfname.c_str());
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ /******************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS #ifndef WINDOWS_SYS
@ -519,10 +490,10 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
uint64_t tmp_size ; uint64_t tmp_size ;
std::string tmp_name ; 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; std::cerr << "Cannot hash executable! Plugins will not be loaded correctly." << std::endl;
else 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. /* At this point we want to.
* 1) Load up Dase Directory. * 1) Load up Dase Directory.
@ -534,12 +505,14 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
AuthSSL::AuthSSLInit(); AuthSSL::AuthSSLInit();
AuthSSL::getAuthSSL() -> InitAuth(NULL, NULL, NULL); AuthSSL::getAuthSSL() -> InitAuth(NULL, NULL, NULL);
rsAccounts = new RsAccountsDetail() ;
// first check config directories, and set bootstrap values. // 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 ; return RS_INIT_BASE_DIR_ERROR ;
// Setup PGP stuff. // Setup PGP stuff.
std::string pgp_dir = rsAccounts.PathPGPDirectory(); std::string pgp_dir = rsAccounts->PathPGPDirectory();
if(!RsDirUtil::checkCreateDirectory(pgp_dir)) if(!RsDirUtil::checkCreateDirectory(pgp_dir))
throw std::runtime_error("Cannot create pgp directory " + 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"); pgp_dir + "/lock");
// load Accounts. // load Accounts.
if (!rsAccounts.loadAccounts()) if (!rsAccounts->loadAccounts())
{ {
return RS_INIT_NO_KEYRING ; return RS_INIT_NO_KEYRING ;
} }
@ -558,7 +531,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
// choose alternative account. // choose alternative account.
if(prefUserString != "") 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 << "Invalid User name/GPG id/SSL id: not found in list";
std::cerr << std::endl; std::cerr << std::endl;
@ -568,16 +541,16 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
/* check that we have selected someone */ /* check that we have selected someone */
RsPeerId preferredId; RsPeerId preferredId;
bool existingUser = rsAccounts.getPreferredAccountId(preferredId); bool existingUser = rsAccounts->getPreferredAccountId(preferredId);
if (existingUser) if (existingUser)
{ {
if (RsInitConfig::passwd != "") if (rsInitConfig->passwd != "")
{ {
return RS_INIT_HAVE_ACCOUNT; return RS_INIT_HAVE_ACCOUNT;
} }
if(RsLoginHandler::getSSLPassword(preferredId,false,RsInitConfig::passwd)) if(RsLoginHandler::getSSLPassword(preferredId,false,rsInitConfig->passwd))
{ {
RsInit::setAutoLogin(true); RsInit::setAutoLogin(true);
std::cerr << "Autologin has succeeded" << std::endl; 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"; const std::string lockFile = accountDir + "/" + "lock";
lockFilePath = lockFile; 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() void RsInit::UnlockConfigDirectory()
{ {
RsDirUtil::releaseLockFile(RsInitConfig::lockHandle) ; RsDirUtil::releaseLockFile(rsInitConfig->lockHandle) ;
} }
@ -631,7 +604,7 @@ bool RsInit::collectEntropy(uint32_t n)
/* Login SSL */ /* Login SSL */
bool RsInit::LoadPassword(const std::string& inPwd) bool RsInit::LoadPassword(const std::string& inPwd)
{ {
RsInitConfig::passwd = inPwd; rsInitConfig->passwd = inPwd;
return true; return true;
} }
@ -647,14 +620,14 @@ bool RsInit::LoadPassword(const std::string& inPwd)
*/ */
int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath) int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath)
{ {
if (!rsAccounts.lockPreferredAccount()) if (!rsAccounts->lockPreferredAccount())
{ {
return 3; // invalid PreferredAccount. return 3; // invalid PreferredAccount.
} }
// Logic that used to be external to RsInit... // Logic that used to be external to RsInit...
RsPeerId accountId; RsPeerId accountId;
if (!rsAccounts.getPreferredAccountId(accountId)) if (!rsAccounts->getPreferredAccountId(accountId))
{ {
return 3; // invalid PreferredAccount; return 3; // invalid PreferredAccount;
} }
@ -662,13 +635,13 @@ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath
RsPgpId pgpId; RsPgpId pgpId;
std::string pgpName, pgpEmail, location; 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; return 3; // invalid PreferredAccount;
if (!rsAccounts.SelectPGPAccount(pgpId)) if (!rsAccounts->SelectPGPAccount(pgpId))
return 3; // PGP Error. return 3; // PGP Error.
int retVal = LockConfigDirectory(rsAccounts.PathAccountDirectory(), lockFilePath); int retVal = LockConfigDirectory(rsAccounts->PathAccountDirectory(), lockFilePath);
if(retVal != 0) if(retVal != 0)
return retVal; return retVal;
@ -694,20 +667,20 @@ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath
int RsInit::LoadCertificates(bool autoLoginNT) int RsInit::LoadCertificates(bool autoLoginNT)
{ {
RsPeerId preferredId; RsPeerId preferredId;
if (!rsAccounts.getPreferredAccountId(preferredId)) if (!rsAccounts->getPreferredAccountId(preferredId))
{ {
std::cerr << "No Account Selected" << std::endl; std::cerr << "No Account Selected" << std::endl;
return 0; return 0;
} }
if (rsAccounts.PathCertFile() == "") if (rsAccounts->PathCertFile() == "")
{ {
std::cerr << "RetroShare needs a certificate" << std::endl; std::cerr << "RetroShare needs a certificate" << std::endl;
return 0; return 0;
} }
if (rsAccounts.PathKeyFile() == "") if (rsAccounts->PathKeyFile() == "")
{ {
std::cerr << "RetroShare needs a key" << std::endl; std::cerr << "RetroShare needs a key" << std::endl;
return 0; return 0;
@ -715,21 +688,21 @@ int RsInit::LoadCertificates(bool autoLoginNT)
//check if password is already in memory //check if password is already in memory
if(RsInitConfig::passwd == "") { if(rsInitConfig->passwd == "") {
if (RsLoginHandler::getSSLPassword(preferredId,true,RsInitConfig::passwd) == false) { if (RsLoginHandler::getSSLPassword(preferredId,true,rsInitConfig->passwd) == false) {
std::cerr << "RsLoginHandler::getSSLPassword() Failed!"; std::cerr << "RsLoginHandler::getSSLPassword() Failed!";
return 0 ; return 0 ;
} }
} else { } else {
if (RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile(preferredId,RsInitConfig::passwd) == false) { if (RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile(preferredId,rsInitConfig->passwd) == false) {
std::cerr << "RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile() Failed!"; std::cerr << "RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile() Failed!";
return 0; 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!"; std::cerr << "SSL Auth Failed!";
return 0 ; return 0 ;
@ -740,25 +713,25 @@ int RsInit::LoadCertificates(bool autoLoginNT)
std::cerr << "RetroShare will AutoLogin next time"; std::cerr << "RetroShare will AutoLogin next time";
std::cerr << std::endl; std::cerr << std::endl;
RsLoginHandler::enableAutoLogin(preferredId,RsInitConfig::passwd); RsLoginHandler::enableAutoLogin(preferredId,rsInitConfig->passwd);
RsInitConfig::autoLogin = true ; rsInitConfig->autoLogin = true ;
} }
/* wipe out password */ /* wipe out password */
// store pword to allow gxs use it to services' key their databases // store pword to allow gxs use it to services' key their databases
// ideally gxs should have its own password // ideally gxs should have its own password
RsInitConfig::gxs_passwd = RsInitConfig::passwd; rsInitConfig->gxs_passwd = rsInitConfig->passwd;
RsInitConfig::passwd = ""; rsInitConfig->passwd = "";
rsAccounts.storePreferredAccount(); rsAccounts->storePreferredAccount();
return 1; return 1;
} }
bool RsInit::RsClearAutoLogin() bool RsInit::RsClearAutoLogin()
{ {
RsPeerId preferredId; RsPeerId preferredId;
if (!rsAccounts.getPreferredAccountId(preferredId)) if (!rsAccounts->getPreferredAccountId(preferredId))
{ {
std::cerr << "RsInit::RsClearAutoLogin() No Account Selected" << std::endl; std::cerr << "RsInit::RsClearAutoLogin() No Account Selected" << std::endl;
return 0; return 0;
@ -770,7 +743,7 @@ bool RsInit::RsClearAutoLogin()
bool RsInit::isPortable() bool RsInit::isPortable()
{ {
#ifdef WINDOWS_SYS #ifdef WINDOWS_SYS
return RsInitConfig::portable; return rsInitConfig->portable;
#else #else
return false; return false;
#endif #endif
@ -779,7 +752,7 @@ bool RsInit::isPortable()
bool RsInit::isWindowsXP() bool RsInit::isWindowsXP()
{ {
#ifdef WINDOWS_SYS #ifdef WINDOWS_SYS
return RsInitConfig::isWindowsXP; return rsInitConfig->isWindowsXP;
#else #else
return false; return false;
#endif #endif
@ -787,12 +760,12 @@ bool RsInit::isWindowsXP()
bool RsInit::getStartMinimised() bool RsInit::getStartMinimised()
{ {
return RsInitConfig::startMinimised; return rsInitConfig->startMinimised;
} }
std::string RsInit::getRetroShareLink() std::string RsInit::getRetroShareLink()
{ {
return RsInitConfig::RetroShareLink; return rsInitConfig->RetroShareLink;
} }
int RsInit::getSslPwdLen(){ int RsInit::getSslPwdLen(){
@ -800,20 +773,20 @@ int RsInit::getSslPwdLen(){
} }
bool RsInit::getAutoLogin(){ bool RsInit::getAutoLogin(){
return RsInitConfig::autoLogin; return rsInitConfig->autoLogin;
} }
void RsInit::setAutoLogin(bool autoLogin){ void RsInit::setAutoLogin(bool autoLogin){
RsInitConfig::autoLogin = autoLogin; rsInitConfig->autoLogin = autoLogin;
} }
/* Setup Hidden Location; */ /* Setup Hidden Location; */
bool RsInit::SetHiddenLocation(const std::string& hiddenaddress, uint16_t port) bool RsInit::SetHiddenLocation(const std::string& hiddenaddress, uint16_t port)
{ {
/* parse the bugger (todo) */ /* parse the bugger (todo) */
RsInitConfig::hiddenNodeSet = true; rsInitConfig->hiddenNodeSet = true;
RsInitConfig::hiddenNodeAddress = hiddenaddress; rsInitConfig->hiddenNodeAddress = hiddenaddress;
RsInitConfig::hiddenNodePort = port; rsInitConfig->hiddenNodePort = port;
return true; return true;
} }
@ -991,15 +964,15 @@ int RsServer::StartupRetroShare()
/* set the debugging to crashMode */ /* set the debugging to crashMode */
std::cerr << "set the debugging to crashMode." << std::endl; 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; crashfile += "/" + configLogFileName;
setDebugCrashMode(crashfile.c_str()); setDebugCrashMode(crashfile.c_str());
} }
unsigned long flags = 0; unsigned long flags = 0;
if (RsInitConfig::udpListenerOnly) if (rsInitConfig->udpListenerOnly)
{ {
flags |= PQIPERSON_NO_LISTENER; flags |= PQIPERSON_NO_LISTENER;
} }
@ -1008,8 +981,8 @@ int RsServer::StartupRetroShare()
// Load up Certificates, and Old Configuration (if present) // Load up Certificates, and Old Configuration (if present)
std::cerr << "Load up Certificates, and Old Configuration (if present)." << std::endl; std::cerr << "Load up Certificates, and Old Configuration (if present)." << std::endl;
std::string emergencySaveDir = rsAccounts.PathAccountDirectory(); std::string emergencySaveDir = rsAccounts->PathAccountDirectory();
std::string emergencyPartialsDir = rsAccounts.PathAccountDirectory(); std::string emergencyPartialsDir = rsAccounts->PathAccountDirectory();
if (emergencySaveDir != "") if (emergencySaveDir != "")
{ {
emergencySaveDir += "/"; emergencySaveDir += "/";
@ -1023,13 +996,13 @@ int RsServer::StartupRetroShare()
/**************************************************************************/ /**************************************************************************/
std::cerr << "Load Configuration" << std::endl; std::cerr << "Load Configuration" << std::endl;
mConfigMgr = new p3ConfigMgr(rsAccounts.PathAccountDirectory()); mConfigMgr = new p3ConfigMgr(rsAccounts->PathAccountDirectory());
mGeneralConfig = new p3GeneralConfig(); mGeneralConfig = new p3GeneralConfig();
// Get configuration options from rsAccounts. // Get configuration options from rsAccounts.
bool isHiddenNode = false; bool isHiddenNode = false;
bool isFirstTimeRun = false; bool isFirstTimeRun = false;
rsAccounts.getAccountOptions(isHiddenNode, isFirstTimeRun); rsAccounts->getAccountOptions(isHiddenNode, isFirstTimeRun);
/**************************************************************************/ /**************************************************************************/
/* setup classes / structures */ /* setup classes / structures */
@ -1058,14 +1031,14 @@ int RsServer::StartupRetroShare()
// for (std::list<std::string>::iterator sslIdsIt = sslIds.begin(); sslIdsIt != sslIds.end(); sslIdsIt++) { // for (std::list<std::string>::iterator sslIdsIt = sslIds.begin(); sslIdsIt != sslIds.end(); sslIdsIt++) {
// mConnMgr->addFriend(*sslIdsIt); // mConnMgr->addFriend(*sslIdsIt);
// } // }
//p3DhtMgr *mDhtMgr = new OpenDHTMgr(ownId, mConnMgr, RsInitConfig::configDir); //p3DhtMgr *mDhtMgr = new OpenDHTMgr(ownId, mConnMgr, rsInitConfig->configDir);
/**************************** BITDHT ***********************************/ /**************************** BITDHT ***********************************/
// Make up an address. XXX // Make up an address. XXX
struct sockaddr_in tmpladdr; struct sockaddr_in tmpladdr;
sockaddr_clear(&tmpladdr); sockaddr_clear(&tmpladdr);
tmpladdr.sin_port = htons(RsInitConfig::port); tmpladdr.sin_port = htons(rsInitConfig->port);
#ifdef LOCALNET_TESTING #ifdef LOCALNET_TESTING
@ -1101,7 +1074,7 @@ int RsServer::StartupRetroShare()
#define BITDHT_BOOTSTRAP_FILENAME "bdboot.txt" #define BITDHT_BOOTSTRAP_FILENAME "bdboot.txt"
std::string bootstrapfile = rsAccounts.PathAccountDirectory(); std::string bootstrapfile = rsAccounts->PathAccountDirectory();
if (bootstrapfile != "") if (bootstrapfile != "")
{ {
bootstrapfile += "/"; bootstrapfile += "/";
@ -1118,7 +1091,7 @@ int RsServer::StartupRetroShare()
if (!RsDirUtil::checkFile(bootstrapfile,tmp_size,true)) if (!RsDirUtil::checkFile(bootstrapfile,tmp_size,true))
{ {
std::cerr << "DHT bootstrap file not in ConfigDir: " << bootstrapfile << std::endl; std::cerr << "DHT bootstrap file not in ConfigDir: " << bootstrapfile << std::endl;
std::string installfile = rsAccounts.PathDataDirectory(); std::string installfile = rsAccounts->PathDataDirectory();
installfile += "/"; installfile += "/";
installfile += BITDHT_BOOTSTRAP_FILENAME; installfile += BITDHT_BOOTSTRAP_FILENAME;
@ -1182,7 +1155,7 @@ int RsServer::StartupRetroShare()
#ifdef LOCALNET_TESTING #ifdef LOCALNET_TESTING
// // HACK Proxy Port near Dht Port - For Relay 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); // sndladdr.sin_port = htons(rndport);
rsFixedUdpStack *mProxyStack = new rsFixedUdpStack(UDP_TEST_RESTRICTED_LAYER, sndladdr); rsFixedUdpStack *mProxyStack = new rsFixedUdpStack(UDP_TEST_RESTRICTED_LAYER, sndladdr);
@ -1235,7 +1208,7 @@ int RsServer::StartupRetroShare()
/****** New Ft Server **** !!! */ /****** New Ft Server **** !!! */
ftServer *ftserver = new ftServer(mPeerMgr, serviceCtrl); ftServer *ftserver = new ftServer(mPeerMgr, serviceCtrl);
ftserver->setConfigDirectory(rsAccounts.PathAccountDirectory()); ftserver->setConfigDirectory(rsAccounts->PathAccountDirectory());
ftserver->SetupFtServer() ; ftserver->SetupFtServer() ;
CacheStrapper *mCacheStrapper = ftserver->getCacheStrapper(); CacheStrapper *mCacheStrapper = ftserver->getCacheStrapper();
@ -1252,7 +1225,7 @@ int RsServer::StartupRetroShare()
/* create Cache Services */ /* create Cache Services */
std::string config_dir = rsAccounts.PathAccountDirectory(); std::string config_dir = rsAccounts->PathAccountDirectory();
std::string localcachedir = config_dir + "/cache/local"; std::string localcachedir = config_dir + "/cache/local";
std::string remotecachedir = config_dir + "/cache/remote"; std::string remotecachedir = config_dir + "/cache/remote";
@ -1261,7 +1234,7 @@ int RsServer::StartupRetroShare()
#ifndef WINDOWS_SYS #ifndef WINDOWS_SYS
plugins_directories.push_back(std::string("/usr/lib/retroshare/extensions6/")) ; plugins_directories.push_back(std::string("/usr/lib/retroshare/extensions6/")) ;
#endif #endif
std::string extensions_dir = rsAccounts.PathBaseDirectory() + "/extensions6/" ; std::string extensions_dir = rsAccounts->PathBaseDirectory() + "/extensions6/" ;
plugins_directories.push_back(extensions_dir) ; plugins_directories.push_back(extensions_dir) ;
if(!RsDirUtil::checkCreateDirectory(extensions_dir)) if(!RsDirUtil::checkCreateDirectory(extensions_dir))
@ -1272,7 +1245,7 @@ int RsServer::StartupRetroShare()
// possible entries include: /usr/lib/retroshare, ~/.retroshare/extensions/, etc. // possible entries include: /usr/lib/retroshare, ~/.retroshare/extensions/, etc.
#endif #endif
mPluginsManager = new RsPluginManager(RsInitConfig::main_executable_hash) ; mPluginsManager = new RsPluginManager(rsInitConfig->main_executable_hash) ;
rsPlugins = mPluginsManager ; rsPlugins = mPluginsManager ;
mConfigMgr->addConfiguration("plugins.cfg", mPluginsManager); mConfigMgr->addConfiguration("plugins.cfg", mPluginsManager);
mPluginsManager->loadConfiguration() ; mPluginsManager->loadConfiguration() ;
@ -1283,10 +1256,16 @@ int RsServer::StartupRetroShare()
mPluginsManager->setCacheDirectories(localcachedir,remotecachedir) ; mPluginsManager->setCacheDirectories(localcachedir,remotecachedir) ;
mPluginsManager->setServiceControl(serviceCtrl) ; mPluginsManager->setServiceControl(serviceCtrl) ;
// std::cerr << "rsinitconf (core 1) = " << (void*)rsInitConfig<<std::endl;
// std::cerr << "gxs_passwd (core 1) = " << (void*)&rsInitConfig->gxs_passwd<<" \"" << rsInitConfig->gxs_passwd << "\""<< std::endl;
// Now load the plugins. This parses the available SO/DLL files for known symbols. // Now load the plugins. This parses the available SO/DLL files for known symbols.
// //
mPluginsManager->loadPlugins(plugins_directories) ; mPluginsManager->loadPlugins(plugins_directories) ;
// std::cerr << "rsinitconf (core 1) = " << (void*)rsInitConfig<<std::endl;
// std::cerr << "gxs_passwd (core 2) = " << (void*)&rsInitConfig->gxs_passwd<< " \"" << rsInitConfig->gxs_passwd << "\""<< std::endl;
// Also load some plugins explicitly. This is helpful for // Also load some plugins explicitly. This is helpful for
// - developping plugins // - developping plugins
// //
@ -1300,7 +1279,7 @@ int RsServer::StartupRetroShare()
#ifdef RS_ENABLE_GXS #ifdef RS_ENABLE_GXS
std::string currGxsDir = rsAccounts.PathAccountDirectory() + "/gxs"; std::string currGxsDir = rsAccounts->PathAccountDirectory() + "/gxs";
RsDirUtil::checkCreateDirectory(currGxsDir); RsDirUtil::checkCreateDirectory(currGxsDir);
RsNxsNetMgr* nxsMgr = new RsNxsNetMgrImpl(serviceCtrl); RsNxsNetMgr* nxsMgr = new RsNxsNetMgrImpl(serviceCtrl);
@ -1308,7 +1287,7 @@ int RsServer::StartupRetroShare()
/**** Identity service ****/ /**** Identity service ****/
RsGeneralDataService* gxsid_ds = new RsDataService(currGxsDir + "/", "gxsid_db", 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 // init gxs services
PgpAuxUtils *pgpAuxUtils = new PgpAuxUtilsImpl(); PgpAuxUtils *pgpAuxUtils = new PgpAuxUtilsImpl();
@ -1316,7 +1295,7 @@ int RsServer::StartupRetroShare()
// circles created here, as needed by Ids. // circles created here, as needed by Ids.
RsGeneralDataService* gxscircles_ds = new RsDataService(currGxsDir + "/", "gxscircles_db", 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. // create GxsCircles - early, as IDs need it.
mGxsCircles = new p3GxsCircles(gxscircles_ds, NULL, mGxsIdService, pgpAuxUtils); mGxsCircles = new p3GxsCircles(gxscircles_ds, NULL, mGxsIdService, pgpAuxUtils);
@ -1345,7 +1324,7 @@ int RsServer::StartupRetroShare()
RsGeneralDataService* posted_ds = new RsDataService(currGxsDir + "/", "posted_db", RsGeneralDataService* posted_ds = new RsDataService(currGxsDir + "/", "posted_db",
RS_SERVICE_GXS_TYPE_POSTED, RS_SERVICE_GXS_TYPE_POSTED,
NULL, RsInitConfig::gxs_passwd); NULL, rsInitConfig->gxs_passwd);
mPosted = new p3Posted(posted_ds, NULL, mGxsIdService); mPosted = new p3Posted(posted_ds, NULL, mGxsIdService);
@ -1361,7 +1340,7 @@ int RsServer::StartupRetroShare()
RsGeneralDataService* wiki_ds = new RsDataService(currGxsDir + "/", "wiki_db", RsGeneralDataService* wiki_ds = new RsDataService(currGxsDir + "/", "wiki_db",
RS_SERVICE_GXS_TYPE_WIKI, RS_SERVICE_GXS_TYPE_WIKI,
NULL, RsInitConfig::gxs_passwd); NULL, rsInitConfig->gxs_passwd);
mWiki = new p3Wiki(wiki_ds, NULL, mGxsIdService); mWiki = new p3Wiki(wiki_ds, NULL, mGxsIdService);
@ -1376,7 +1355,7 @@ int RsServer::StartupRetroShare()
/**** Forum GXS service ****/ /**** Forum GXS service ****/
RsGeneralDataService* gxsforums_ds = new RsDataService(currGxsDir + "/", "gxsforums_db", 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); mGxsForums = new p3GxsForums(gxsforums_ds, NULL, mGxsIdService);
@ -1392,7 +1371,7 @@ int RsServer::StartupRetroShare()
/**** Channel GXS service ****/ /**** Channel GXS service ****/
RsGeneralDataService* gxschannels_ds = new RsDataService(currGxsDir + "/", "gxschannels_db", 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); mGxsChannels = new p3GxsChannels(gxschannels_ds, NULL, mGxsIdService);
@ -1408,7 +1387,7 @@ int RsServer::StartupRetroShare()
#if 0 // PHOTO IS DISABLED FOR THE MOMENT #if 0 // PHOTO IS DISABLED FOR THE MOMENT
/**** Photo service ****/ /**** Photo service ****/
RsGeneralDataService* photo_ds = new RsDataService(currGxsDir + "/", "photoV2_db", 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 // init gxs services
mPhoto = new p3PhotoService(photo_ds, NULL, mGxsIdService); mPhoto = new p3PhotoService(photo_ds, NULL, mGxsIdService);
@ -1425,7 +1404,7 @@ int RsServer::StartupRetroShare()
/**** Wire GXS service ****/ /**** Wire GXS service ****/
RsGeneralDataService* wire_ds = new RsDataService(currGxsDir + "/", "wire_db", RsGeneralDataService* wire_ds = new RsDataService(currGxsDir + "/", "wire_db",
RS_SERVICE_GXS_TYPE_WIRE, RS_SERVICE_GXS_TYPE_WIRE,
NULL, RsInitConfig::gxs_passwd); NULL, rsInitConfig->gxs_passwd);
mWire = new p3Wire(wire_ds, NULL, mGxsIdService); mWire = new p3Wire(wire_ds, NULL, mGxsIdService);
@ -1446,7 +1425,7 @@ int RsServer::StartupRetroShare()
//pqih->addService(photo_ns, true); //pqih->addService(photo_ns, true);
// remove pword from memory // remove pword from memory
RsInitConfig::gxs_passwd = ""; rsInitConfig->gxs_passwd = "";
#endif // RS_ENABLE_GXS. #endif // RS_ENABLE_GXS.
@ -1498,7 +1477,13 @@ int RsServer::StartupRetroShare()
interfaces.mDisc = rsDisc; interfaces.mDisc = rsDisc;
interfaces.mDht = rsDht; interfaces.mDht = rsDht;
interfaces.mNotify = mNotify; 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); mPluginsManager->setInterfaces(interfaces);
// now add plugin objects inside the loop: // 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; std::cerr << "Force Any Configuration before Startup (After Load)" << std::endl;
if (RsInitConfig::forceLocalAddr) if (rsInitConfig->forceLocalAddr)
{ {
struct sockaddr_storage laddr; struct sockaddr_storage laddr;
@ -1646,24 +1631,24 @@ int RsServer::StartupRetroShare()
struct sockaddr_in *lap = (struct sockaddr_in *) &laddr; struct sockaddr_in *lap = (struct sockaddr_in *) &laddr;
lap->sin_family = AF_INET; lap->sin_family = AF_INET;
lap->sin_port = htons(RsInitConfig::port); lap->sin_port = htons(rsInitConfig->port);
// universal // 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); mPeerMgr->setLocalAddress(ownId, laddr);
} }
if (RsInitConfig::forceExtPort) if (rsInitConfig->forceExtPort)
{ {
mPeerMgr->setOwnNetworkMode(RS_NET_MODE_EXT); mPeerMgr->setOwnNetworkMode(RS_NET_MODE_EXT);
mPeerMgr->setOwnVisState(RS_VS_DISC_FULL, RS_VS_DHT_FULL); 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) else if (isHiddenNode)
{ {

View File

@ -689,11 +689,11 @@ bool RsLoginHandler::getSSLPasswdFromGPGFile(const RsPeerId& ssl_id,std::string&
std::string RsLoginHandler::getSSLPasswdFileName(const RsPeerId& /*ssl_id*/) 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*/) std::string RsLoginHandler::getAutologinFileName(const RsPeerId& /*ssl_id*/)
{ {
return rsAccounts.PathAccountKeysDirectory() + "/" + "help.dta" ; return rsAccounts->PathAccountKeysDirectory() + "/" + "help.dta" ;
} }

View File

@ -220,9 +220,15 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
#endif #endif
// for new circles we need to add them to the list. // for new circles we need to add them to the list.
// 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 ******/ RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/
RsGxsCircleId tempId(git->toStdString()); mCircleCache.erase(RsGxsCircleId(*git));
mCircleExternalIdList.push_back(tempId); }
} }
} }
} }
@ -419,7 +425,7 @@ bool p3GxsCircles::getGroupData(const uint32_t &token, std::vector<RsGxsCircleGr
/********************************************************************************/ /********************************************************************************/
/********************************************************************************/ /********************************************************************************/
bool p3GxsCircles::createGroup(uint32_t& token, RsGxsCircleGroup &group) void p3GxsCircles::createGroup(uint32_t& token, RsGxsCircleGroup &group)
{ {
#ifdef DEBUG_CIRCLES #ifdef DEBUG_CIRCLES
std::cerr << "p3GxsCircles::createGroup()"; std::cerr << "p3GxsCircles::createGroup()";
@ -432,7 +438,15 @@ bool p3GxsCircles::createGroup(uint32_t& token, RsGxsCircleGroup &group)
item->convertFrom(group); item->convertFrom(group);
RsGenExchange::publishGroup(token, item); 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*/) 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); item->meta.mCircleId = RsGxsCircleId(item->meta.mGroupId);
} }
{ // the advantage of adding the id to the list now is, that we know the cirlce type at this point
RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/ // this is not the case in NotifyChanges()
addCircleIdToList(RsGxsCircleId(item->meta.mGroupId), item->meta.mCircleType);
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()));
}
}
return SERVICE_CREATE_SUCCESS; return SERVICE_CREATE_SUCCESS;
} }
@ -602,23 +607,15 @@ bool p3GxsCircles::load_CircleIdList(uint32_t token)
if(ok) if(ok)
{ {
// Save List // Save List
std::list<RsGroupMetaData>::iterator it; {
RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/ RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/
mCirclePersonalIdList.clear(); mCirclePersonalIdList.clear();
mCircleExternalIdList.clear(); mCircleExternalIdList.clear();
}
for(it = groups.begin(); it != groups.end(); it++) for(std::list<RsGroupMetaData>::iterator it = groups.begin(); it != groups.end(); it++)
{ {
RsGxsCircleId tempId(it->mGroupId.toStdString()); addCircleIdToList(RsGxsCircleId(it->mGroupId), it->mCircleType);
if (it->mCircleType == GXS_CIRCLE_TYPE_LOCAL)
{
mCirclePersonalIdList.push_back(tempId);
}
else
{
mCircleExternalIdList.push_back(tempId);
}
} }
} }
else else
@ -1261,6 +1258,24 @@ bool p3GxsCircles::checkCircleCacheForAutoSubscribe(RsGxsCircleCache &cache)
return false; 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 #ifdef HANDLE_SUBCIRCLES

View File

@ -40,6 +40,35 @@
#include <map> #include <map>
#include <string> #include <string>
// 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 * Circles Identity Service
* *
@ -152,7 +181,8 @@ virtual RsServiceInfo getServiceInfo();
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsCircleGroup> &groups); virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsCircleGroup> &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, p3IdService *mIdentities; // Needed for constructing Circle Info,
PgpAuxUtils *mPgpUtils; 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 */ RsMutex mCircleMtx; /* Locked Below Here */
std::list<RsGxsCircleId> mCircleExternalIdList; std::list<RsGxsCircleId> mCircleExternalIdList;

View File

@ -311,12 +311,10 @@ bool p3IdService:: getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
} }
bool p3IdService:: getOwnIds(std::list<RsGxsId> &ownIds) void p3IdService::getOwnIds(std::list<RsGxsId> &ownIds)
{ {
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/ RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
ownIds = mOwnIds; 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. // copy meta data to be sure its all the same.
//item->group.mMeta = item->meta; //item->group.mMeta = item->meta;
// Reload in a little bit. // do it like p3gxscircles: save the new grp id
// HACK to get it to work. // this allows the user interface
RsTickEvent::schedule_in(GXSID_EVENT_CACHEOWNIDS, OWNID_RELOAD_DELAY); // 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; return createStatus;
} }

View File

@ -257,7 +257,7 @@ virtual bool deleteGroup(uint32_t& token, RsGxsIdGroup &group);
//virtual bool getNickname(const RsGxsId &id, std::string &nickname); //virtual bool getNickname(const RsGxsId &id, std::string &nickname);
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details); virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details);
virtual bool getOwnIds(std::list<RsGxsId> &ownIds); virtual void getOwnIds(std::list<RsGxsId> &ownIds);

View File

@ -161,13 +161,13 @@ bool RsDiscSpace::checkForDiscSpace(RsDiscSpace::DiscLocation loc)
#endif #endif
break ; 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 #ifdef DEBUG_RSDISCSPACE
std::cerr << " path = " << RsInit::RsConfigDirectory() << std::endl ; std::cerr << " path = " << RsInit::RsConfigDirectory() << std::endl ;
#endif #endif
break ; 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 #ifdef DEBUG_RSDISCSPACE
std::cerr << " path = " << RsInit::RsPGPDirectory() << std::endl ; std::cerr << " path = " << RsInit::RsPGPDirectory() << std::endl ;
#endif #endif

View File

@ -1,6 +1,9 @@
QT += network xml script QT += network xml script
CONFIG += qt gui uic qrc resources idle bitdht 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) { greaterThan(QT_MAJOR_VERSION, 4) {
# Qt 5 # Qt 5
QT += uitools widgets multimedia printsupport QT += uitools widgets multimedia printsupport
@ -144,6 +147,11 @@ win32-x-g++ {
#################################### Windows ##################################### #################################### Windows #####################################
win32 { win32 {
debug {
# show console output
CONFIG += console
}
# Switch on extra warnings # Switch on extra warnings
QMAKE_CFLAGS += -Wextra QMAKE_CFLAGS += -Wextra
QMAKE_CXXFLAGS += -Wextra QMAKE_CXXFLAGS += -Wextra