mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-05 13:19:32 -04:00
Turned RsInit into a static class, and changed retroshare invite so that it does not contain signatures anymore.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1022 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b9abc24e5c
commit
78c07ca367
18 changed files with 589 additions and 464 deletions
|
@ -667,7 +667,9 @@ bool ftTransferModule::locked_tickPeerTransfer(peerInfo &info)
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else mFlag = 1;
|
else mFlag = 1;
|
||||||
|
|
||||||
|
return true ;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,48 +142,48 @@ class RsControl /* The Main Interface Class - for controlling the server */
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RsControl(RsIface &i, NotifyBase &callback)
|
RsControl(RsIface &i, NotifyBase &callback)
|
||||||
:cb(callback), rsIface(i) { return; }
|
:cb(callback), rsIface(i) { return; }
|
||||||
|
|
||||||
virtual ~RsControl() { return; }
|
virtual ~RsControl() { return; }
|
||||||
|
|
||||||
/* Real Startup Fn */
|
/* Real Startup Fn */
|
||||||
virtual int StartupRetroShare(RsInit *config) = 0;
|
virtual int StartupRetroShare() = 0;
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
|
||||||
/* Flagging Persons / Channels / Files in or out of a set (CheckLists) */
|
/* Flagging Persons / Channels / Files in or out of a set (CheckLists) */
|
||||||
virtual int SetInChat(std::string id, bool in) = 0; /* friend : chat msgs */
|
virtual int SetInChat(std::string id, bool in) = 0; /* friend : chat msgs */
|
||||||
virtual int SetInMsg(std::string id, bool in) = 0; /* friend : msg receipients */
|
virtual int SetInMsg(std::string id, bool in) = 0; /* friend : msg receipients */
|
||||||
virtual int SetInBroadcast(std::string id, bool in) = 0; /* channel : channel broadcast */
|
virtual int SetInBroadcast(std::string id, bool in) = 0; /* channel : channel broadcast */
|
||||||
virtual int SetInSubscribe(std::string id, bool in) = 0; /* channel : subscribed channels */
|
virtual int SetInSubscribe(std::string id, bool in) = 0; /* channel : subscribed channels */
|
||||||
virtual int SetInRecommend(std::string id, bool in) = 0; /* file : recommended file */
|
virtual int SetInRecommend(std::string id, bool in) = 0; /* file : recommended file */
|
||||||
virtual int ClearInChat() = 0;
|
virtual int ClearInChat() = 0;
|
||||||
virtual int ClearInMsg() = 0;
|
virtual int ClearInMsg() = 0;
|
||||||
virtual int ClearInBroadcast() = 0;
|
virtual int ClearInBroadcast() = 0;
|
||||||
virtual int ClearInSubscribe() = 0;
|
virtual int ClearInSubscribe() = 0;
|
||||||
virtual int ClearInRecommend() = 0;
|
virtual int ClearInRecommend() = 0;
|
||||||
|
|
||||||
virtual bool IsInChat(std::string id) = 0; /* friend : chat msgs */
|
virtual bool IsInChat(std::string id) = 0; /* friend : chat msgs */
|
||||||
virtual bool IsInMsg(std::string id) = 0; /* friend : msg recpts*/
|
virtual bool IsInMsg(std::string id) = 0; /* friend : msg recpts*/
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* Config */
|
/* Config */
|
||||||
|
|
||||||
virtual int ConfigSetDataRates( int total, int indiv ) = 0;
|
virtual int ConfigSetDataRates( int total, int indiv ) = 0;
|
||||||
virtual int ConfigGetDataRates( float &inKb, float &outKb) = 0;
|
virtual int ConfigGetDataRates( float &inKb, float &outKb) = 0;
|
||||||
virtual int ConfigSetBootPrompt( bool on ) = 0;
|
virtual int ConfigSetBootPrompt( bool on ) = 0;
|
||||||
virtual void ConfigFinalSave( ) = 0;
|
virtual void ConfigFinalSave( ) = 0;
|
||||||
virtual void rsGlobalShutDown( ) = 0;
|
virtual void rsGlobalShutDown( ) = 0;
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
|
||||||
NotifyBase &getNotify() { return cb; }
|
NotifyBase &getNotify() { return cb; }
|
||||||
RsIface &getIface() { return rsIface; }
|
RsIface &getIface() { return rsIface; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NotifyBase &cb;
|
NotifyBase &cb;
|
||||||
RsIface &rsIface;
|
RsIface &rsIface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
63
libretroshare/src/rsiface/rsinit.h
Normal file
63
libretroshare/src/rsiface/rsinit.h
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
/* Initialisation Class (not publicly disclosed to RsIFace) */
|
||||||
|
|
||||||
|
class RsInit
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/* Commandline/Directory options */
|
||||||
|
|
||||||
|
static const char *RsConfigDirectory() ;
|
||||||
|
|
||||||
|
static bool setStartMinimised() ;
|
||||||
|
static int InitRetroShare(int argcIgnored, char **argvIgnored) ;
|
||||||
|
static int LoadCertificates(bool autoLoginNT) ;
|
||||||
|
static bool ValidateCertificate(std::string &userName) ;
|
||||||
|
static bool ValidateTrustedUser(std::string fname, std::string &userName) ;
|
||||||
|
static bool LoadPassword(std::string passwd) ;
|
||||||
|
static bool RsGenerateCertificate(std::string name, std::string org, std::string loc, std::string country, std::string passwd, std::string &errString);
|
||||||
|
static void load_check_basedir() ;
|
||||||
|
static int create_configinit() ;
|
||||||
|
static bool RsStoreAutoLogin() ;
|
||||||
|
static bool RsTryAutoLogin() ;
|
||||||
|
static bool RsClearAutoLogin(std::string basedir) ;
|
||||||
|
static void InitRsConfig() ;
|
||||||
|
|
||||||
|
static std::string getHomePath() ;
|
||||||
|
|
||||||
|
/* Key Parameters that must be set before
|
||||||
|
* RetroShare will start up:
|
||||||
|
*/
|
||||||
|
static std::string load_cert;
|
||||||
|
static std::string load_key;
|
||||||
|
static std::string passwd;
|
||||||
|
|
||||||
|
static bool havePasswd; /* for Commandline password */
|
||||||
|
static bool autoLogin; /* autoLogin allowed */
|
||||||
|
static bool startMinimised; /* Icon or Full Window */
|
||||||
|
|
||||||
|
/* Win/Unix Differences */
|
||||||
|
static char dirSeperator;
|
||||||
|
|
||||||
|
/* Directories */
|
||||||
|
static std::string basedir;
|
||||||
|
static std::string homePath;
|
||||||
|
|
||||||
|
/* Listening Port */
|
||||||
|
static bool forceExtPort;
|
||||||
|
static bool forceLocalAddr;
|
||||||
|
static unsigned short port;
|
||||||
|
static char inet[256];
|
||||||
|
|
||||||
|
/* Logging */
|
||||||
|
static bool haveLogFile;
|
||||||
|
static bool outStderr;
|
||||||
|
static bool haveDebugLevel;
|
||||||
|
static int debugLevel;
|
||||||
|
static char logfname[1024];
|
||||||
|
|
||||||
|
static bool firsttime_run;
|
||||||
|
static bool load_trustedpeer;
|
||||||
|
static std::string load_trustedpeer_file;
|
||||||
|
|
||||||
|
static bool udpListenerOnly;
|
||||||
|
};
|
||||||
|
|
|
@ -45,6 +45,7 @@ RsFiles *rsFiles = NULL;
|
||||||
#include "util/rsdebug.h"
|
#include "util/rsdebug.h"
|
||||||
#include "util/rsdir.h"
|
#include "util/rsdir.h"
|
||||||
|
|
||||||
|
#include "rsiface/rsinit.h"
|
||||||
#include "upnp/upnphandler.h"
|
#include "upnp/upnphandler.h"
|
||||||
#include "dht/opendhtmgr.h"
|
#include "dht/opendhtmgr.h"
|
||||||
|
|
||||||
|
@ -108,10 +109,44 @@ static const std::string configCaFile = "cacerts.pem";
|
||||||
static const std::string configLogFileName = "retro.log";
|
static const std::string configLogFileName = "retro.log";
|
||||||
static const std::string configHelpName = "retro.htm";
|
static const std::string configHelpName = "retro.htm";
|
||||||
|
|
||||||
|
std::string RsInit::load_cert;
|
||||||
|
std::string RsInit::load_key;
|
||||||
|
std::string RsInit::passwd;
|
||||||
|
|
||||||
|
bool RsInit::havePasswd; /* for Commandline password */
|
||||||
|
bool RsInit::autoLogin; /* autoLogin allowed */
|
||||||
|
bool RsInit::startMinimised; /* Icon or Full Window */
|
||||||
|
|
||||||
|
/* Win/Unix Differences */
|
||||||
|
char RsInit::dirSeperator;
|
||||||
|
|
||||||
|
/* Directories */
|
||||||
|
std::string RsInit::basedir;
|
||||||
|
std::string RsInit::homePath;
|
||||||
|
|
||||||
|
/* Listening Port */
|
||||||
|
bool RsInit::forceExtPort;
|
||||||
|
bool RsInit::forceLocalAddr;
|
||||||
|
unsigned short RsInit::port;
|
||||||
|
char RsInit::inet[256];
|
||||||
|
|
||||||
|
/* Logging */
|
||||||
|
bool RsInit::haveLogFile;
|
||||||
|
bool RsInit::outStderr;
|
||||||
|
bool RsInit::haveDebugLevel;
|
||||||
|
int RsInit::debugLevel;
|
||||||
|
char RsInit::logfname[1024];
|
||||||
|
|
||||||
|
bool RsInit::firsttime_run;
|
||||||
|
bool RsInit::load_trustedpeer;
|
||||||
|
std::string RsInit::load_trustedpeer_file;
|
||||||
|
|
||||||
|
bool RsInit::udpListenerOnly;
|
||||||
|
|
||||||
|
|
||||||
/* Helper Functions */
|
/* Helper Functions */
|
||||||
void load_check_basedir(RsInit *config);
|
//void load_check_basedir(RsInit *config);
|
||||||
int create_configinit(RsInit *config);
|
//int create_configinit(RsInit *config);
|
||||||
|
|
||||||
RsControl *createRsControl(RsIface &iface, NotifyBase ¬ify)
|
RsControl *createRsControl(RsIface &iface, NotifyBase ¬ify)
|
||||||
{
|
{
|
||||||
|
@ -119,47 +154,45 @@ RsControl *createRsControl(RsIface &iface, NotifyBase ¬ify)
|
||||||
return srv;
|
return srv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CleanupRsConfig(RsInit *config)
|
//void CleanupRsConfig(RsInit *config)
|
||||||
{
|
//{
|
||||||
delete config;
|
// delete config;
|
||||||
}
|
//}
|
||||||
|
|
||||||
static std::string getHomePath();
|
static std::string getHomePath();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RsInit *InitRsConfig()
|
void RsInit::InitRsConfig()
|
||||||
{
|
{
|
||||||
RsInit *config = new RsInit();
|
load_trustedpeer = false;
|
||||||
|
firsttime_run = false;
|
||||||
|
port = 7812; // default port.
|
||||||
|
forceLocalAddr = false;
|
||||||
|
haveLogFile = false;
|
||||||
|
outStderr = false;
|
||||||
|
forceExtPort = false;
|
||||||
|
|
||||||
config -> load_trustedpeer = false;
|
strcpy(inet, "127.0.0.1");
|
||||||
config -> firsttime_run = false;
|
strcpy(logfname, "");
|
||||||
config -> port = 7812; // default port.
|
|
||||||
config -> forceLocalAddr = false;
|
|
||||||
config -> haveLogFile = false;
|
|
||||||
config -> outStderr = false;
|
|
||||||
config -> forceExtPort = false;
|
|
||||||
|
|
||||||
strcpy(config->inet, "127.0.0.1");
|
autoLogin = true; // Always on now.
|
||||||
strcpy(config->logfname, "");
|
startMinimised = false;
|
||||||
|
passwd = "";
|
||||||
config -> autoLogin = true; // Always on now.
|
havePasswd = false;
|
||||||
config -> startMinimised = false;
|
haveDebugLevel = false;
|
||||||
config -> passwd = "";
|
debugLevel = PQL_WARNING;
|
||||||
config -> havePasswd = false;
|
udpListenerOnly = false;
|
||||||
config -> haveDebugLevel = false;
|
|
||||||
config -> debugLevel = PQL_WARNING;
|
|
||||||
config -> udpListenerOnly = false;
|
|
||||||
|
|
||||||
#ifndef WINDOWS_SYS
|
#ifndef WINDOWS_SYS
|
||||||
config -> dirSeperator = '/'; // For unix.
|
dirSeperator = '/'; // For unix.
|
||||||
#else
|
#else
|
||||||
config -> dirSeperator = '\\'; // For windows.
|
dirSeperator = '\\'; // For windows.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* setup the homePath (default save location) */
|
/* setup the homePath (default save location) */
|
||||||
|
|
||||||
config -> homePath = getHomePath();
|
homePath = getHomePath();
|
||||||
|
|
||||||
/* Setup the Debugging */
|
/* Setup the Debugging */
|
||||||
// setup debugging for desired zones.
|
// setup debugging for desired zones.
|
||||||
|
@ -188,26 +221,21 @@ RsInit *InitRsConfig()
|
||||||
//setZoneLevel(PQL_DEBUG_BASIC, 25915); // fltkserver
|
//setZoneLevel(PQL_DEBUG_BASIC, 25915); // fltkserver
|
||||||
//setZoneLevel(PQL_DEBUG_BASIC, 47659); // fldxsrvr
|
//setZoneLevel(PQL_DEBUG_BASIC, 47659); // fldxsrvr
|
||||||
//setZoneLevel(PQL_DEBUG_BASIC, 49787); // pqissllistener
|
//setZoneLevel(PQL_DEBUG_BASIC, 49787); // pqissllistener
|
||||||
|
|
||||||
return config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *RsConfigDirectory(RsInit *config)
|
const char *RsInit::RsConfigDirectory()
|
||||||
{
|
{
|
||||||
return (config->basedir).c_str();
|
return basedir.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsConfigStartMinimised(RsInit *config)
|
bool RsInit::setStartMinimised()
|
||||||
{
|
{
|
||||||
return config->startMinimised;
|
return startMinimised;
|
||||||
}
|
}
|
||||||
|
|
||||||
//int InitRetroShare(int argc, char **argv, RsInit *config)
|
|
||||||
//{
|
|
||||||
|
|
||||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
#ifndef WINDOWS_SYS
|
#ifndef WINDOWS_SYS
|
||||||
int InitRetroShare(int argc, char **argv, RsInit *config)
|
int RsInit::InitRetroShare(int argc, char **argv)
|
||||||
{
|
{
|
||||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
#else
|
#else
|
||||||
|
@ -218,7 +246,7 @@ int InitRetroShare(int argc, char **argv, RsInit *config)
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int InitRetroShare(int argcIgnored, char **argvIgnored, RsInit *config)
|
int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* THIS IS A HACK TO ALLOW WINDOWS TO ACCEPT COMMANDLINE ARGUMENTS */
|
/* THIS IS A HACK TO ALLOW WINDOWS TO ACCEPT COMMANDLINE ARGUMENTS */
|
||||||
|
@ -228,7 +256,7 @@ int InitRetroShare(int argcIgnored, char **argvIgnored, RsInit *config)
|
||||||
|
|
||||||
int argc;
|
int argc;
|
||||||
char *argv[MAX_ARGS];
|
char *argv[MAX_ARGS];
|
||||||
char *wholeline = GetCommandLine();
|
char *wholeline = (char*)GetCommandLine();
|
||||||
int cmdlen = strlen(wholeline);
|
int cmdlen = strlen(wholeline);
|
||||||
// duplicate line, so we can put in spaces..
|
// duplicate line, so we can put in spaces..
|
||||||
char dupline[cmdlen+1];
|
char dupline[cmdlen+1];
|
||||||
|
@ -273,64 +301,64 @@ int InitRetroShare(int argcIgnored, char **argvIgnored, RsInit *config)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 'a':
|
case 'a':
|
||||||
config->autoLogin = true;
|
autoLogin = true;
|
||||||
config->startMinimised = true;
|
startMinimised = true;
|
||||||
std::cerr << "AutoLogin Allowed / Start Minimised On";
|
std::cerr << "AutoLogin Allowed / Start Minimised On";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
config->startMinimised = true;
|
startMinimised = true;
|
||||||
std::cerr << "Start Minimised On";
|
std::cerr << "Start Minimised On";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
strncpy(config->logfname, optarg, 1024);
|
strncpy(logfname, optarg, 1024);
|
||||||
std::cerr << "LogFile (" << config->logfname;
|
std::cerr << "LogFile (" << logfname;
|
||||||
std::cerr << ") Selected" << std::endl;
|
std::cerr << ") Selected" << std::endl;
|
||||||
config->haveLogFile = true;
|
haveLogFile = true;
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
config->passwd = optarg;
|
passwd = optarg;
|
||||||
std::cerr << "Password Specified(" << config->passwd;
|
std::cerr << "Password Specified(" << passwd;
|
||||||
std::cerr << ") Selected" << std::endl;
|
std::cerr << ") Selected" << std::endl;
|
||||||
config->havePasswd = true;
|
havePasswd = true;
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
strncpy(config->inet, optarg, 256);
|
strncpy(inet, optarg, 256);
|
||||||
std::cerr << "New Inet Addr(" << config->inet;
|
std::cerr << "New Inet Addr(" << inet;
|
||||||
std::cerr << ") Selected" << std::endl;
|
std::cerr << ") Selected" << std::endl;
|
||||||
config->forceLocalAddr = true;
|
forceLocalAddr = true;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
config->port = atoi(optarg);
|
port = atoi(optarg);
|
||||||
std::cerr << "New Listening Port(" << config->port;
|
std::cerr << "New Listening Port(" << port;
|
||||||
std::cerr << ") Selected" << std::endl;
|
std::cerr << ") Selected" << std::endl;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
config->basedir = optarg;
|
basedir = optarg;
|
||||||
std::cerr << "New Base Config Dir(";
|
std::cerr << "New Base Config Dir(";
|
||||||
std::cerr << config->basedir;
|
std::cerr << basedir;
|
||||||
std::cerr << ") Selected" << std::endl;
|
std::cerr << ") Selected" << std::endl;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
config->outStderr = true;
|
outStderr = true;
|
||||||
config->haveLogFile = false;
|
haveLogFile = false;
|
||||||
std::cerr << "Output to Stderr";
|
std::cerr << "Output to Stderr";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
config->haveDebugLevel = true;
|
haveDebugLevel = true;
|
||||||
config->debugLevel = atoi(optarg);
|
debugLevel = atoi(optarg);
|
||||||
std::cerr << "Opt for new Debug Level";
|
std::cerr << "Opt for new Debug Level";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
config->udpListenerOnly = true;
|
udpListenerOnly = true;
|
||||||
std::cerr << "Opt for only udpListener";
|
std::cerr << "Opt for only udpListener";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
config->forceExtPort = true;
|
forceExtPort = true;
|
||||||
std::cerr << "Opt for External Port Mode";
|
std::cerr << "Opt for External Port Mode";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
break;
|
break;
|
||||||
|
@ -361,28 +389,28 @@ int InitRetroShare(int argcIgnored, char **argvIgnored, RsInit *config)
|
||||||
|
|
||||||
|
|
||||||
// set the default Debug Level...
|
// set the default Debug Level...
|
||||||
if (config->haveDebugLevel)
|
if (haveDebugLevel)
|
||||||
{
|
{
|
||||||
if ((config->debugLevel > 0) &&
|
if ((debugLevel > 0) &&
|
||||||
(config->debugLevel <= PQL_DEBUG_ALL))
|
(debugLevel <= PQL_DEBUG_ALL))
|
||||||
{
|
{
|
||||||
std::cerr << "Setting Debug Level to: ";
|
std::cerr << "Setting Debug Level to: ";
|
||||||
std::cerr << config->debugLevel;
|
std::cerr << debugLevel;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
setOutputLevel(config->debugLevel);
|
setOutputLevel(debugLevel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "Ignoring Invalid Debug Level: ";
|
std::cerr << "Ignoring Invalid Debug Level: ";
|
||||||
std::cerr << config->debugLevel;
|
std::cerr << debugLevel;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the debug file.
|
// set the debug file.
|
||||||
if (config->haveLogFile)
|
if (haveLogFile)
|
||||||
{
|
{
|
||||||
setDebugFile(config->logfname);
|
setDebugFile(logfname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
@ -408,7 +436,7 @@ int InitRetroShare(int argcIgnored, char **argvIgnored, RsInit *config)
|
||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
// first check config directories, and set bootstrap values.
|
// first check config directories, and set bootstrap values.
|
||||||
load_check_basedir(config);
|
load_check_basedir();
|
||||||
|
|
||||||
// SWITCH off the SIGPIPE - kills process on Linux.
|
// SWITCH off the SIGPIPE - kills process on Linux.
|
||||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
@ -437,7 +465,7 @@ int InitRetroShare(int argcIgnored, char **argvIgnored, RsInit *config)
|
||||||
/* do a null init to allow the SSL libray to startup! */
|
/* do a null init to allow the SSL libray to startup! */
|
||||||
/**************** PQI_USE_XPGP ******************/
|
/**************** PQI_USE_XPGP ******************/
|
||||||
#if defined(PQI_USE_XPGP)
|
#if defined(PQI_USE_XPGP)
|
||||||
if (LoadCheckXPGPandGetName(config->load_cert.c_str(), userName, userId))
|
if (LoadCheckXPGPandGetName(load_cert.c_str(), userName, userId))
|
||||||
{
|
{
|
||||||
std::cerr << "Existing Name: " << userName << std::endl;
|
std::cerr << "Existing Name: " << userName << std::endl;
|
||||||
std::cerr << "Existing Id: " << userId << std::endl;
|
std::cerr << "Existing Id: " << userId << std::endl;
|
||||||
|
@ -473,11 +501,11 @@ int InitRetroShare(int argcIgnored, char **argvIgnored, RsInit *config)
|
||||||
/* if existing user, and havePasswd .... we can skip the login prompt */
|
/* if existing user, and havePasswd .... we can skip the login prompt */
|
||||||
if (existingUser)
|
if (existingUser)
|
||||||
{
|
{
|
||||||
if (config -> havePasswd)
|
if (havePasswd)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (RsTryAutoLogin(config))
|
if (RsTryAutoLogin())
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -486,11 +514,12 @@ int InitRetroShare(int argcIgnored, char **argvIgnored, RsInit *config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const std::string& RsServer::certificateFileName() { return RsInit::load_cert ; }
|
||||||
/*
|
/*
|
||||||
* The Real RetroShare Startup Function.
|
* The Real RetroShare Startup Function.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int RsServer::StartupRetroShare(RsInit *config)
|
int RsServer::StartupRetroShare()
|
||||||
{
|
{
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/* STARTUP procedure */
|
/* STARTUP procedure */
|
||||||
|
@ -523,15 +552,15 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
/* set the debugging to crashMode */
|
/* set the debugging to crashMode */
|
||||||
if ((!config->haveLogFile) && (!config->outStderr))
|
if ((!RsInit::haveLogFile) && (!RsInit::outStderr))
|
||||||
{
|
{
|
||||||
std::string crashfile = config->basedir + config->dirSeperator;
|
std::string crashfile = RsInit::basedir + RsInit::dirSeperator;
|
||||||
crashfile += configLogFileName;
|
crashfile += configLogFileName;
|
||||||
setDebugCrashMode(crashfile.c_str());
|
setDebugCrashMode(crashfile.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long flags = 0;
|
unsigned long flags = 0;
|
||||||
if (config->udpListenerOnly)
|
if (RsInit::udpListenerOnly)
|
||||||
{
|
{
|
||||||
flags |= PQIPERSON_NO_LISTENER;
|
flags |= PQIPERSON_NO_LISTENER;
|
||||||
}
|
}
|
||||||
|
@ -540,10 +569,10 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||||
|
|
||||||
// Load up Certificates, and Old Configuration (if present)
|
// Load up Certificates, and Old Configuration (if present)
|
||||||
|
|
||||||
std::string certConfigFile = config->basedir.c_str();
|
std::string certConfigFile = RsInit::basedir.c_str();
|
||||||
std::string certNeighDir = config->basedir.c_str();
|
std::string certNeighDir = RsInit::basedir.c_str();
|
||||||
std::string emergencySaveDir = config->basedir.c_str();
|
std::string emergencySaveDir = RsInit::basedir.c_str();
|
||||||
std::string emergencyPartialsDir = config->basedir.c_str();
|
std::string emergencyPartialsDir = RsInit::basedir.c_str();
|
||||||
if (certConfigFile != "")
|
if (certConfigFile != "")
|
||||||
{
|
{
|
||||||
certConfigFile += "/";
|
certConfigFile += "/";
|
||||||
|
@ -581,7 +610,7 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||||
|
|
||||||
mConnMgr = new p3ConnectMgr(mAuthMgr);
|
mConnMgr = new p3ConnectMgr(mAuthMgr);
|
||||||
pqiNetAssistFirewall *mUpnpMgr = new upnphandler();
|
pqiNetAssistFirewall *mUpnpMgr = new upnphandler();
|
||||||
p3DhtMgr *mDhtMgr = new OpenDHTMgr(ownId, mConnMgr, config->basedir);
|
p3DhtMgr *mDhtMgr = new OpenDHTMgr(ownId, mConnMgr, RsInit::basedir);
|
||||||
|
|
||||||
SecurityPolicy *none = secpolicy_create();
|
SecurityPolicy *none = secpolicy_create();
|
||||||
pqih = new pqisslpersongrp(none, flags);
|
pqih = new pqisslpersongrp(none, flags);
|
||||||
|
@ -590,7 +619,7 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||||
/****** New Ft Server **** !!! */
|
/****** New Ft Server **** !!! */
|
||||||
ftserver = new ftServer(mAuthMgr, mConnMgr);
|
ftserver = new ftServer(mAuthMgr, mConnMgr);
|
||||||
ftserver->setP3Interface(pqih);
|
ftserver->setP3Interface(pqih);
|
||||||
ftserver->setConfigDirectory(config->basedir);
|
ftserver->setConfigDirectory(RsInit::basedir);
|
||||||
|
|
||||||
ftserver->SetupFtServer(&(getNotify()));
|
ftserver->SetupFtServer(&(getNotify()));
|
||||||
CacheStrapper *mCacheStrapper = ftserver->getCacheStrapper();
|
CacheStrapper *mCacheStrapper = ftserver->getCacheStrapper();
|
||||||
|
@ -605,7 +634,7 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||||
rsFiles = ftserver;
|
rsFiles = ftserver;
|
||||||
|
|
||||||
|
|
||||||
mConfigMgr = new p3ConfigMgr(mAuthMgr, config->basedir, "rs-v0.4.cfg", "rs-v0.4.sgn");
|
mConfigMgr = new p3ConfigMgr(mAuthMgr, RsInit::basedir, "rs-v0.4.cfg", "rs-v0.4.sgn");
|
||||||
mGeneralConfig = new p3GeneralConfig();
|
mGeneralConfig = new p3GeneralConfig();
|
||||||
|
|
||||||
/* create Services */
|
/* create Services */
|
||||||
|
@ -618,8 +647,8 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||||
pqih -> addService(chatSrv);
|
pqih -> addService(chatSrv);
|
||||||
|
|
||||||
/* create Cache Services */
|
/* create Cache Services */
|
||||||
std::string config_dir = config->basedir;
|
std::string config_dir = RsInit::basedir;
|
||||||
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";
|
||||||
std::string channelsdir = config_dir + "/channels";
|
std::string channelsdir = config_dir + "/channels";
|
||||||
|
|
||||||
|
@ -766,7 +795,7 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||||
/* Force Any Configuration before Startup (After Load) */
|
/* Force Any Configuration before Startup (After Load) */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
if (config->forceLocalAddr)
|
if (RsInit::forceLocalAddr)
|
||||||
{
|
{
|
||||||
struct sockaddr_in laddr;
|
struct sockaddr_in laddr;
|
||||||
|
|
||||||
|
@ -774,28 +803,28 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||||
sockaddr_clear(&laddr);
|
sockaddr_clear(&laddr);
|
||||||
|
|
||||||
laddr.sin_family = AF_INET;
|
laddr.sin_family = AF_INET;
|
||||||
laddr.sin_port = htons(config->port);
|
laddr.sin_port = htons(RsInit::port);
|
||||||
|
|
||||||
// universal
|
// universal
|
||||||
laddr.sin_addr.s_addr = inet_addr(config->inet);
|
laddr.sin_addr.s_addr = inet_addr(RsInit::inet);
|
||||||
|
|
||||||
mConnMgr->setLocalAddress(ownId, laddr);
|
mConnMgr->setLocalAddress(ownId, laddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config->forceExtPort)
|
if (RsInit::forceExtPort)
|
||||||
{
|
{
|
||||||
mConnMgr->setOwnNetConfig(RS_NET_MODE_EXT, RS_VIS_STATE_STD);
|
mConnMgr->setOwnNetConfig(RS_NET_MODE_EXT, RS_VIS_STATE_STD);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* must load the trusted_peer before setting up the pqipersongrp */
|
/* must load the trusted_peer before setting up the pqipersongrp */
|
||||||
if (config->firsttime_run)
|
if (firsttime_run)
|
||||||
{
|
{
|
||||||
/* at this point we want to load and start the trusted peer -> if selected */
|
/* at this point we want to load and start the trusted peer -> if selected */
|
||||||
if (config->load_trustedpeer)
|
if (load_trustedpeer)
|
||||||
{
|
{
|
||||||
/* sslroot does further checks */
|
/* sslroot does further checks */
|
||||||
sslr -> loadInitialTrustedPeer(config->load_trustedpeer_file);
|
sslr -> loadInitialTrustedPeer(load_trustedpeer_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -865,17 +894,17 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||||
|
|
||||||
|
|
||||||
/* put a welcome message in! */
|
/* put a welcome message in! */
|
||||||
if (config->firsttime_run)
|
if (RsInit::firsttime_run)
|
||||||
{
|
{
|
||||||
msgSrv->loadWelcomeMsg();
|
msgSrv->loadWelcomeMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
// load up the help page
|
// load up the help page
|
||||||
std::string helppage = config->basedir + config->dirSeperator;
|
std::string helppage = RsInit::basedir + RsInit::dirSeperator;
|
||||||
helppage += configHelpName;
|
helppage += configHelpName;
|
||||||
|
|
||||||
/* for DHT/UPnP stuff */
|
/* for DHT/UPnP stuff */
|
||||||
//InitNetworking(config->basedir + "/kadc.ini");
|
//InitNetworking(basedir + "/kadc.ini");
|
||||||
|
|
||||||
/* Startup this thread! */
|
/* Startup this thread! */
|
||||||
createThread(*this);
|
createThread(*this);
|
||||||
|
@ -886,36 +915,34 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int LoadCertificates(RsInit *config, bool autoLoginNT)
|
int RsInit::LoadCertificates(bool autoLoginNT)
|
||||||
{
|
{
|
||||||
if (config->load_cert == "")
|
if (load_cert == "")
|
||||||
{
|
{
|
||||||
std::cerr << "RetroShare needs a certificate" << std::endl;
|
std::cerr << "RetroShare needs a certificate" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config->load_key == "")
|
if (load_key == "")
|
||||||
{
|
{
|
||||||
std::cerr << "RetroShare needs a key" << std::endl;
|
std::cerr << "RetroShare needs a key" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!config->havePasswd) || (config->passwd == ""))
|
if ((!havePasswd) || (passwd == ""))
|
||||||
{
|
{
|
||||||
std::cerr << "RetroShare needs a Password" << std::endl;
|
std::cerr << "RetroShare needs a Password" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ca_loc = config->basedir + config->dirSeperator;
|
std::string ca_loc = basedir + dirSeperator;
|
||||||
ca_loc += configCaFile;
|
ca_loc += configCaFile;
|
||||||
|
|
||||||
p3AuthMgr *authMgr = getAuthMgr();
|
p3AuthMgr *authMgr = getAuthMgr();
|
||||||
|
|
||||||
/**************** PQI_USE_XPGP ******************/
|
/**************** PQI_USE_XPGP ******************/
|
||||||
#if defined(PQI_USE_XPGP)
|
#if defined(PQI_USE_XPGP)
|
||||||
if (0 < authMgr -> InitAuth(config->load_cert.c_str(),
|
if (0 < authMgr -> InitAuth(load_cert.c_str(), load_key.c_str(),passwd.c_str()))
|
||||||
config->load_key.c_str(),
|
|
||||||
config->passwd.c_str()))
|
|
||||||
#else /* X509 Certificates */
|
#else /* X509 Certificates */
|
||||||
/**************** PQI_USE_XPGP ******************/
|
/**************** PQI_USE_XPGP ******************/
|
||||||
/* The SSL + PGP version will require
|
/* The SSL + PGP version will require
|
||||||
|
@ -923,8 +950,7 @@ int LoadCertificates(RsInit *config, bool autoLoginNT)
|
||||||
* padding with NULLs
|
* padding with NULLs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (0 < authMgr -> InitAuth(config->load_cert.c_str(),
|
if (0 < authMgr -> InitAuth(load_cert.c_str(), NULL, passwd.c_str()))
|
||||||
NULL, config->passwd.c_str()))
|
|
||||||
#endif /* X509 Certificates */
|
#endif /* X509 Certificates */
|
||||||
/**************** PQI_USE_XPGP ******************/
|
/**************** PQI_USE_XPGP ******************/
|
||||||
|
|
||||||
|
@ -934,11 +960,11 @@ int LoadCertificates(RsInit *config, bool autoLoginNT)
|
||||||
std::cerr << "RetroShare will AutoLogin next time";
|
std::cerr << "RetroShare will AutoLogin next time";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
RsStoreAutoLogin(config);
|
RsStoreAutoLogin();
|
||||||
}
|
}
|
||||||
/* wipe password */
|
/* wipe password */
|
||||||
config->passwd = "";
|
passwd = "";
|
||||||
create_configinit(config);
|
create_configinit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -957,9 +983,9 @@ int LoadCertificates(RsInit *config, bool autoLoginNT)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Assistance for Login */
|
/* Assistance for Login */
|
||||||
bool ValidateCertificate(RsInit *config, std::string &userName)
|
bool RsInit::ValidateCertificate(std::string &userName)
|
||||||
{
|
{
|
||||||
std::string fname = config->load_cert;
|
std::string fname = load_cert;
|
||||||
std::string userId;
|
std::string userId;
|
||||||
if (fname != "")
|
if (fname != "")
|
||||||
{
|
{
|
||||||
|
@ -976,7 +1002,7 @@ bool ValidateCertificate(RsInit *config, std::string &userName)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ValidateTrustedUser(RsInit *config, std::string fname, std::string &userName)
|
bool RsInit::ValidateTrustedUser(std::string fname, std::string &userName)
|
||||||
{
|
{
|
||||||
std::string userId;
|
std::string userId;
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
|
@ -990,20 +1016,20 @@ bool ValidateTrustedUser(RsInit *config, std::string fname, std::string &userNam
|
||||||
|
|
||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
config -> load_trustedpeer = true;
|
load_trustedpeer = true;
|
||||||
config -> load_trustedpeer_file = fname;
|
load_trustedpeer_file = fname;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
config -> load_trustedpeer = false;
|
load_trustedpeer = false;
|
||||||
}
|
}
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadPassword(RsInit *config, std::string passwd)
|
bool RsInit::LoadPassword(std::string _passwd)
|
||||||
{
|
{
|
||||||
config -> passwd = passwd;
|
passwd = _passwd;
|
||||||
config -> havePasswd = true;
|
havePasswd = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1012,7 +1038,7 @@ bool LoadPassword(RsInit *config, std::string passwd)
|
||||||
* (2) returns false if fails, with error msg to errString.
|
* (2) returns false if fails, with error msg to errString.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool RsGenerateCertificate(RsInit *config,
|
bool RsInit::RsGenerateCertificate(
|
||||||
std::string name,
|
std::string name,
|
||||||
std::string org,
|
std::string org,
|
||||||
std::string loc,
|
std::string loc,
|
||||||
|
@ -1042,8 +1068,8 @@ bool RsGenerateCertificate(RsInit *config,
|
||||||
int nbits = 2048;
|
int nbits = 2048;
|
||||||
|
|
||||||
// Create the filename.
|
// Create the filename.
|
||||||
std::string basename = config->basedir + config->dirSeperator;
|
std::string basename = basedir + dirSeperator;
|
||||||
basename += configKeyDir + config->dirSeperator;
|
basename += configKeyDir + dirSeperator;
|
||||||
basename += "user";
|
basename += "user";
|
||||||
|
|
||||||
std::string key_name = basename + "_pk.pem";
|
std::string key_name = basename + "_pk.pem";
|
||||||
|
@ -1081,11 +1107,11 @@ bool RsGenerateCertificate(RsInit *config,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* if we get here .... then save details to the configuration class */
|
/* if we get here .... then save details to the configuration class */
|
||||||
config -> load_cert = cert_name;
|
load_cert = cert_name;
|
||||||
config -> load_key = key_name;
|
load_key = key_name;
|
||||||
config -> passwd = passwd;
|
passwd = passwd;
|
||||||
config -> havePasswd = true;
|
havePasswd = true;
|
||||||
config -> firsttime_run = true;
|
firsttime_run = true;
|
||||||
|
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
|
@ -1100,11 +1126,11 @@ bool RsGenerateCertificate(RsInit *config,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void load_check_basedir(RsInit *config)
|
void RsInit::load_check_basedir()
|
||||||
{
|
{
|
||||||
// get the default configuration location.
|
// get the default configuration location.
|
||||||
|
|
||||||
if (config->basedir == "")
|
if (basedir == "")
|
||||||
{
|
{
|
||||||
// if unix. homedir + /.pqiPGPrc
|
// if unix. homedir + /.pqiPGPrc
|
||||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
@ -1119,8 +1145,8 @@ void load_check_basedir(RsInit *config)
|
||||||
std::cerr << "\tcannot determine $HOME dir" <<std::endl;
|
std::cerr << "\tcannot determine $HOME dir" <<std::endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
config->basedir = h;
|
basedir = h;
|
||||||
config->basedir += "/.pqiPGPrc";
|
basedir += "/.pqiPGPrc";
|
||||||
#else
|
#else
|
||||||
char *h = getenv("APPDATA");
|
char *h = getenv("APPDATA");
|
||||||
std::cerr << "retroShare::basedir() -> $APPDATA = ";
|
std::cerr << "retroShare::basedir() -> $APPDATA = ";
|
||||||
|
@ -1137,41 +1163,41 @@ void load_check_basedir(RsInit *config)
|
||||||
std::cerr << "load_check_basedir() getEnv Error --Win95/98?";
|
std::cerr << "load_check_basedir() getEnv Error --Win95/98?";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
config->basedir="C:\\Retro";
|
basedir="C:\\Retro";
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
config->basedir = h;
|
basedir = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!RsDirUtil::checkCreateDirectory(config->basedir))
|
if (!RsDirUtil::checkCreateDirectory(basedir))
|
||||||
{
|
{
|
||||||
std::cerr << "Cannot Create BaseConfig Dir" << std::endl;
|
std::cerr << "Cannot Create BaseConfig Dir" << std::endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
config->basedir += "\\RetroShare";
|
basedir += "\\RetroShare";
|
||||||
#endif
|
#endif
|
||||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string subdir1 = config->basedir + config->dirSeperator;
|
std::string subdir1 = basedir + dirSeperator;
|
||||||
std::string subdir2 = subdir1;
|
std::string subdir2 = subdir1;
|
||||||
subdir1 += configKeyDir;
|
subdir1 += configKeyDir;
|
||||||
subdir2 += configCertDir;
|
subdir2 += configCertDir;
|
||||||
|
|
||||||
std::string subdir3 = config->basedir + config->dirSeperator;
|
std::string subdir3 = basedir + dirSeperator;
|
||||||
subdir3 += "cache";
|
subdir3 += "cache";
|
||||||
|
|
||||||
std::string subdir4 = subdir3 + config->dirSeperator;
|
std::string subdir4 = subdir3 + dirSeperator;
|
||||||
std::string subdir5 = subdir3 + config->dirSeperator;
|
std::string subdir5 = subdir3 + dirSeperator;
|
||||||
subdir4 += "local";
|
subdir4 += "local";
|
||||||
subdir5 += "remote";
|
subdir5 += "remote";
|
||||||
|
|
||||||
// fatal if cannot find/create.
|
// fatal if cannot find/create.
|
||||||
std::cerr << "Checking For Directories" << std::endl;
|
std::cerr << "Checking For Directories" << std::endl;
|
||||||
if (!RsDirUtil::checkCreateDirectory(config->basedir))
|
if (!RsDirUtil::checkCreateDirectory(basedir))
|
||||||
{
|
{
|
||||||
std::cerr << "Cannot Create BaseConfig Dir" << std::endl;
|
std::cerr << "Cannot Create BaseConfig Dir" << std::endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -1205,7 +1231,7 @@ void load_check_basedir(RsInit *config)
|
||||||
// have a config directories.
|
// have a config directories.
|
||||||
|
|
||||||
// Check for config file.
|
// Check for config file.
|
||||||
std::string initfile = config->basedir + config->dirSeperator;
|
std::string initfile = basedir + dirSeperator;
|
||||||
initfile += configInitFile;
|
initfile += configInitFile;
|
||||||
|
|
||||||
// open and read in the lines.
|
// open and read in the lines.
|
||||||
|
@ -1217,15 +1243,15 @@ void load_check_basedir(RsInit *config)
|
||||||
{
|
{
|
||||||
if (NULL != fgets(path, 1024, ifd))
|
if (NULL != fgets(path, 1024, ifd))
|
||||||
{
|
{
|
||||||
for(i = 0; (path[i] != '\0') && (path[i] != '\n'); i++);
|
for(i = 0; (path[i] != '\0') && (path[i] != '\n'); i++) {}
|
||||||
path[i] = '\0';
|
path[i] = '\0';
|
||||||
config->load_cert = path;
|
load_cert = path;
|
||||||
}
|
}
|
||||||
if (NULL != fgets(path, 1024, ifd))
|
if (NULL != fgets(path, 1024, ifd))
|
||||||
{
|
{
|
||||||
for(i = 0; (path[i] != '\0') && (path[i] != '\n'); i++);
|
for(i = 0; (path[i] != '\0') && (path[i] != '\n'); i++) {}
|
||||||
path[i] = '\0';
|
path[i] = '\0';
|
||||||
config->load_key = path;
|
load_key = path;
|
||||||
}
|
}
|
||||||
fclose(ifd);
|
fclose(ifd);
|
||||||
}
|
}
|
||||||
|
@ -1236,10 +1262,10 @@ void load_check_basedir(RsInit *config)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int create_configinit(RsInit *config)
|
int RsInit::create_configinit()
|
||||||
{
|
{
|
||||||
// Check for config file.
|
// Check for config file.
|
||||||
std::string initfile = config->basedir + config->dirSeperator;
|
std::string initfile = basedir + dirSeperator;
|
||||||
initfile += configInitFile;
|
initfile += configInitFile;
|
||||||
|
|
||||||
// open and read in the lines.
|
// open and read in the lines.
|
||||||
|
@ -1247,13 +1273,13 @@ int create_configinit(RsInit *config)
|
||||||
|
|
||||||
if (ifd != NULL)
|
if (ifd != NULL)
|
||||||
{
|
{
|
||||||
fprintf(ifd, "%s\n", config->load_cert.c_str());
|
fprintf(ifd, "%s\n", load_cert.c_str());
|
||||||
fprintf(ifd, "%s\n", config->load_key.c_str());
|
fprintf(ifd, "%s\n", load_key.c_str());
|
||||||
fclose(ifd);
|
fclose(ifd);
|
||||||
|
|
||||||
std::cerr << "Creating Init File: " << initfile << std::endl;
|
std::cerr << "Creating Init File: " << initfile << std::endl;
|
||||||
std::cerr << "\tLoad Cert: " << config->load_cert << std::endl;
|
std::cerr << "\tLoad Cert: " << load_cert << std::endl;
|
||||||
std::cerr << "\tLoad Key: " << config->load_key << std::endl;
|
std::cerr << "\tLoad Key: " << load_key << std::endl;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1302,7 +1328,7 @@ int check_create_directory(std::string dir)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
std::string getHomePath()
|
std::string RsInit::getHomePath()
|
||||||
{
|
{
|
||||||
std::string home;
|
std::string home;
|
||||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
@ -1362,7 +1388,7 @@ std::string make_path_unix(std::string path)
|
||||||
|
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <Wincrypt.h>
|
#include <wincrypt.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1372,7 +1398,7 @@ class CRYPTPROTECT_PROMPTSTRUCT;
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef A_VIRER
|
||||||
typedef struct _CRYPTPROTECT_PROMPTSTRUCT {
|
typedef struct _CRYPTPROTECT_PROMPTSTRUCT {
|
||||||
DWORD cbSize;
|
DWORD cbSize;
|
||||||
DWORD dwPromptFlags;
|
DWORD dwPromptFlags;
|
||||||
|
@ -1380,6 +1406,7 @@ typedef struct _CRYPTPROTECT_PROMPTSTRUCT {
|
||||||
LPCWSTR szPrompt;
|
LPCWSTR szPrompt;
|
||||||
} CRYPTPROTECT_PROMPTSTRUCT,
|
} CRYPTPROTECT_PROMPTSTRUCT,
|
||||||
*PCRYPTPROTECT_PROMPTSTRUCT;
|
*PCRYPTPROTECT_PROMPTSTRUCT;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* definitions for the two functions */
|
/* definitions for the two functions */
|
||||||
__declspec (dllimport)
|
__declspec (dllimport)
|
||||||
|
@ -1417,7 +1444,7 @@ extern BOOL WINAPI CryptUnprotectData(
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool RsStoreAutoLogin(RsInit *config)
|
bool RsInit::RsStoreAutoLogin()
|
||||||
{
|
{
|
||||||
std::cerr << "RsStoreAutoLogin()" << std::endl;
|
std::cerr << "RsStoreAutoLogin()" << std::endl;
|
||||||
/* Windows only */
|
/* Windows only */
|
||||||
|
@ -1426,12 +1453,12 @@ bool RsStoreAutoLogin(RsInit *config)
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
/* store password encrypted in a file */
|
/* store password encrypted in a file */
|
||||||
std::string entropy = config->load_cert;
|
std::string entropy = load_cert;
|
||||||
|
|
||||||
DATA_BLOB DataIn;
|
DATA_BLOB DataIn;
|
||||||
DATA_BLOB DataEnt;
|
DATA_BLOB DataEnt;
|
||||||
DATA_BLOB DataOut;
|
DATA_BLOB DataOut;
|
||||||
BYTE *pbDataInput = (BYTE *) strdup(config->passwd.c_str());
|
BYTE *pbDataInput = (BYTE *) strdup(passwd.c_str());
|
||||||
DWORD cbDataInput = strlen((char *)pbDataInput)+1;
|
DWORD cbDataInput = strlen((char *)pbDataInput)+1;
|
||||||
BYTE *pbDataEnt =(BYTE *) strdup(entropy.c_str());
|
BYTE *pbDataEnt =(BYTE *) strdup(entropy.c_str());
|
||||||
DWORD cbDataEnt = strlen((char *)pbDataEnt)+1;
|
DWORD cbDataEnt = strlen((char *)pbDataEnt)+1;
|
||||||
|
@ -1476,8 +1503,8 @@ bool RsStoreAutoLogin(RsInit *config)
|
||||||
**********/
|
**********/
|
||||||
|
|
||||||
/* save the data to the file */
|
/* save the data to the file */
|
||||||
std::string passwdfile = config->basedir;
|
std::string passwdfile = basedir;
|
||||||
passwdfile += config->dirSeperator;
|
passwdfile += dirSeperator;
|
||||||
passwdfile += "help.dta";
|
passwdfile += "help.dta";
|
||||||
|
|
||||||
//std::cerr << "Save to: " << passwdfile;
|
//std::cerr << "Save to: " << passwdfile;
|
||||||
|
@ -1511,7 +1538,7 @@ bool RsStoreAutoLogin(RsInit *config)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool RsTryAutoLogin(RsInit *config)
|
bool RsInit::RsTryAutoLogin()
|
||||||
{
|
{
|
||||||
std::cerr << "RsTryAutoLogin()" << std::endl;
|
std::cerr << "RsTryAutoLogin()" << std::endl;
|
||||||
/* Windows only */
|
/* Windows only */
|
||||||
|
@ -1520,18 +1547,18 @@ bool RsTryAutoLogin(RsInit *config)
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
/* Require a AutoLogin flag in the config to do this */
|
/* Require a AutoLogin flag in the config to do this */
|
||||||
if (!config->autoLogin)
|
if (!autoLogin)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* try to load from file */
|
/* try to load from file */
|
||||||
std::string entropy = config->load_cert;
|
std::string entropy = load_cert;
|
||||||
/* get the data out */
|
/* get the data out */
|
||||||
|
|
||||||
/* open the data to the file */
|
/* open the data to the file */
|
||||||
std::string passwdfile = config->basedir;
|
std::string passwdfile = basedir;
|
||||||
passwdfile += config->dirSeperator;
|
passwdfile += dirSeperator;
|
||||||
passwdfile += "help.dta";
|
passwdfile += "help.dta";
|
||||||
|
|
||||||
DATA_BLOB DataIn;
|
DATA_BLOB DataIn;
|
||||||
|
@ -1611,8 +1638,8 @@ bool RsTryAutoLogin(RsInit *config)
|
||||||
{
|
{
|
||||||
//std::cerr << "The decrypted data is: " << DataOut.pbData;
|
//std::cerr << "The decrypted data is: " << DataOut.pbData;
|
||||||
//std::cerr << std::endl;
|
//std::cerr << std::endl;
|
||||||
config -> passwd = (char *) DataOut.pbData;
|
passwd = (char *) DataOut.pbData;
|
||||||
config -> havePasswd = true;
|
havePasswd = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1635,7 +1662,7 @@ bool RsTryAutoLogin(RsInit *config)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsClearAutoLogin(std::string basedir)
|
bool RsInit::RsClearAutoLogin(std::string basedir)
|
||||||
{
|
{
|
||||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
#ifndef WINDOWS_SYS /* UNIX */
|
#ifndef WINDOWS_SYS /* UNIX */
|
||||||
|
|
|
@ -48,10 +48,10 @@
|
||||||
|
|
||||||
/* The init functions are actually Defined in p3face-startup.cc
|
/* The init functions are actually Defined in p3face-startup.cc
|
||||||
*/
|
*/
|
||||||
RsInit *InitRsConfig();
|
//RsInit *InitRsConfig();
|
||||||
void CleanupRsConfig(RsInit *);
|
//void CleanupRsConfig(RsInit *);
|
||||||
int InitRetroShare(int argc, char **argv, RsInit *config);
|
//int InitRetroShare(int argc, char **argv, RsInit *config);
|
||||||
int LoadCertificates(RsInit *config);
|
//int LoadCertificates(RsInit *config);
|
||||||
|
|
||||||
RsControl *createRsControl(RsIface &iface, NotifyBase ¬ify);
|
RsControl *createRsControl(RsIface &iface, NotifyBase ¬ify);
|
||||||
|
|
||||||
|
@ -59,128 +59,130 @@ RsControl *createRsControl(RsIface &iface, NotifyBase ¬ify);
|
||||||
class RsServer: public RsControl, public RsThread
|
class RsServer: public RsControl, public RsThread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* p3face-startup.cc: init... */
|
/* p3face-startup.cc: init... */
|
||||||
virtual int StartupRetroShare(RsInit *config);
|
virtual int StartupRetroShare();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* p3face.cc: main loop / util fns / locking. */
|
/* p3face.cc: main loop / util fns / locking. */
|
||||||
|
|
||||||
RsServer(RsIface &i, NotifyBase &callback);
|
RsServer(RsIface &i, NotifyBase &callback);
|
||||||
virtual ~RsServer();
|
virtual ~RsServer();
|
||||||
|
|
||||||
/* Thread Fn: Run the Core */
|
/* Thread Fn: Run the Core */
|
||||||
virtual void run();
|
virtual void run();
|
||||||
|
|
||||||
public: // no longer private:!!!
|
public: // no longer private:!!!
|
||||||
/* locking stuff */
|
/* locking stuff */
|
||||||
void lockRsCore()
|
void lockRsCore()
|
||||||
{
|
{
|
||||||
// std::cerr << "RsServer::lockRsCore()" << std::endl;
|
// std::cerr << "RsServer::lockRsCore()" << std::endl;
|
||||||
coreMutex.lock();
|
coreMutex.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void unlockRsCore()
|
void unlockRsCore()
|
||||||
{
|
{
|
||||||
// std::cerr << "RsServer::unlockRsCore()" << std::endl;
|
// std::cerr << "RsServer::unlockRsCore()" << std::endl;
|
||||||
coreMutex.unlock();
|
coreMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/* mutex */
|
/* mutex */
|
||||||
RsMutex coreMutex;
|
RsMutex coreMutex;
|
||||||
|
|
||||||
/* General Internal Helper Functions
|
/* General Internal Helper Functions
|
||||||
(Must be Locked)
|
(Must be Locked)
|
||||||
*/
|
*/
|
||||||
#if 0
|
#if 0
|
||||||
cert *intFindCert(RsCertId id);
|
cert *intFindCert(RsCertId id);
|
||||||
RsCertId intGetCertId(cert *c);
|
RsCertId intGetCertId(cert *c);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* p3face-msg Operations */
|
/* p3face-msg Operations */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* Flagging Persons / Channels / Files in or out of a set (CheckLists) */
|
virtual const std::string& certificateFileName() ;
|
||||||
virtual int SetInChat(std::string id, bool in); /* friend : chat msgs */
|
|
||||||
virtual int SetInMsg(std::string id, bool in); /* friend : msg receipients */
|
|
||||||
virtual int SetInBroadcast(std::string id, bool in); /* channel : channel broadcast */
|
|
||||||
virtual int SetInSubscribe(std::string id, bool in); /* channel : subscribed channels */
|
|
||||||
virtual int SetInRecommend(std::string id, bool in); /* file : recommended file */
|
|
||||||
virtual int ClearInChat();
|
|
||||||
virtual int ClearInMsg();
|
|
||||||
virtual int ClearInBroadcast();
|
|
||||||
virtual int ClearInSubscribe();
|
|
||||||
virtual int ClearInRecommend();
|
|
||||||
|
|
||||||
virtual bool IsInChat(std::string id); /* friend : chat msgs */
|
/* Flagging Persons / Channels / Files in or out of a set (CheckLists) */
|
||||||
virtual bool IsInMsg(std::string id); /* friend : msg recpts*/
|
virtual int SetInChat(std::string id, bool in); /* friend : chat msgs */
|
||||||
|
virtual int SetInMsg(std::string id, bool in); /* friend : msg receipients */
|
||||||
|
virtual int SetInBroadcast(std::string id, bool in); /* channel : channel broadcast */
|
||||||
|
virtual int SetInSubscribe(std::string id, bool in); /* channel : subscribed channels */
|
||||||
|
virtual int SetInRecommend(std::string id, bool in); /* file : recommended file */
|
||||||
|
virtual int ClearInChat();
|
||||||
|
virtual int ClearInMsg();
|
||||||
|
virtual int ClearInBroadcast();
|
||||||
|
virtual int ClearInSubscribe();
|
||||||
|
virtual int ClearInRecommend();
|
||||||
|
|
||||||
|
virtual bool IsInChat(std::string id); /* friend : chat msgs */
|
||||||
|
virtual bool IsInMsg(std::string id); /* friend : msg recpts*/
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::list<std::string> mInChatList, mInMsgList;
|
std::list<std::string> mInChatList, mInMsgList;
|
||||||
|
|
||||||
void initRsMI(RsMsgItem *msg, MessageInfo &mi);
|
|
||||||
|
|
||||||
/****************************************/
|
void initRsMI(RsMsgItem *msg, MessageInfo &mi);
|
||||||
/****************************************/
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
/****************************************/
|
||||||
|
/****************************************/
|
||||||
public:
|
public:
|
||||||
/* Config */
|
/* Config */
|
||||||
|
|
||||||
virtual int ConfigGetDataRates(float &inKb, float &outKb);
|
virtual int ConfigGetDataRates(float &inKb, float &outKb);
|
||||||
virtual int ConfigSetDataRates( int total, int indiv );
|
virtual int ConfigSetDataRates( int total, int indiv );
|
||||||
virtual int ConfigSetBootPrompt( bool on );
|
virtual int ConfigSetBootPrompt( bool on );
|
||||||
|
|
||||||
virtual void ConfigFinalSave( );
|
virtual void ConfigFinalSave( );
|
||||||
|
|
||||||
/************* Rs shut down function: in upnp 'port lease time' bug *****************/
|
/************* Rs shut down function: in upnp 'port lease time' bug *****************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is responsible for ensuring Retroshare exits in a legal state:
|
* This function is responsible for ensuring Retroshare exits in a legal state:
|
||||||
* i.e. releases all held resources and saves current configuration
|
* i.e. releases all held resources and saves current configuration
|
||||||
*/
|
*/
|
||||||
virtual void rsGlobalShutDown( );
|
virtual void rsGlobalShutDown( );
|
||||||
private:
|
private:
|
||||||
int UpdateAllConfig();
|
int UpdateAllConfig();
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// The real Server Parts.
|
// The real Server Parts.
|
||||||
|
|
||||||
//filedexserver *server;
|
//filedexserver *server;
|
||||||
ftServer *ftserver;
|
ftServer *ftserver;
|
||||||
|
|
||||||
p3ConnectMgr *mConnMgr;
|
p3ConnectMgr *mConnMgr;
|
||||||
p3AuthMgr *mAuthMgr;
|
p3AuthMgr *mAuthMgr;
|
||||||
|
|
||||||
pqipersongrp *pqih;
|
pqipersongrp *pqih;
|
||||||
|
|
||||||
//sslroot *sslr;
|
//sslroot *sslr;
|
||||||
|
|
||||||
/* services */
|
/* services */
|
||||||
p3disc *ad;
|
p3disc *ad;
|
||||||
p3MsgService *msgSrv;
|
p3MsgService *msgSrv;
|
||||||
p3ChatService *chatSrv;
|
p3ChatService *chatSrv;
|
||||||
|
|
||||||
/* caches (that need ticking) */
|
/* caches (that need ticking) */
|
||||||
p3Ranking *mRanking;
|
p3Ranking *mRanking;
|
||||||
p3Qblog *mQblog;
|
p3Qblog *mQblog;
|
||||||
|
|
||||||
/* Config */
|
/* Config */
|
||||||
p3ConfigMgr *mConfigMgr;
|
p3ConfigMgr *mConfigMgr;
|
||||||
p3GeneralConfig *mGeneralConfig;
|
p3GeneralConfig *mGeneralConfig;
|
||||||
|
|
||||||
// Worker Data.....
|
// Worker Data.....
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -190,53 +192,4 @@ int UpdateAllConfig();
|
||||||
|
|
||||||
std::string make_path_unix(std::string winpath);
|
std::string make_path_unix(std::string winpath);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Initialisation Class (not publicly disclosed to RsIFace) */
|
|
||||||
|
|
||||||
class RsInit
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/* Commandline/Directory options */
|
|
||||||
|
|
||||||
/* Key Parameters that must be set before
|
|
||||||
* RetroShare will start up:
|
|
||||||
*/
|
|
||||||
std::string load_cert;
|
|
||||||
std::string load_key;
|
|
||||||
std::string passwd;
|
|
||||||
|
|
||||||
bool havePasswd; /* for Commandline password */
|
|
||||||
bool autoLogin; /* autoLogin allowed */
|
|
||||||
bool startMinimised; /* Icon or Full Window */
|
|
||||||
|
|
||||||
/* Win/Unix Differences */
|
|
||||||
char dirSeperator;
|
|
||||||
|
|
||||||
/* Directories */
|
|
||||||
std::string basedir;
|
|
||||||
std::string homePath;
|
|
||||||
|
|
||||||
/* Listening Port */
|
|
||||||
bool forceExtPort;
|
|
||||||
bool forceLocalAddr;
|
|
||||||
unsigned short port;
|
|
||||||
char inet[256];
|
|
||||||
|
|
||||||
/* Logging */
|
|
||||||
bool haveLogFile;
|
|
||||||
bool outStderr;
|
|
||||||
bool haveDebugLevel;
|
|
||||||
int debugLevel;
|
|
||||||
char logfname[1024];
|
|
||||||
|
|
||||||
bool firsttime_run;
|
|
||||||
bool load_trustedpeer;
|
|
||||||
std::string load_trustedpeer_file;
|
|
||||||
|
|
||||||
bool udpListenerOnly;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,8 +24,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "rsserver/p3peers.h"
|
#include "rsserver/p3peers.h"
|
||||||
|
#include "rsserver/p3face.h"
|
||||||
#include "pqi/p3connmgr.h"
|
#include "pqi/p3connmgr.h"
|
||||||
#include "pqi/p3authmgr.h"
|
#include "pqi/p3authmgr.h"
|
||||||
|
#include <rsiface/rsinit.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -566,7 +568,20 @@ std::string p3Peers::GetRetroshareInvite()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string ownId = mAuthMgr->OwnId();
|
std::string ownId = mAuthMgr->OwnId();
|
||||||
std::string certstr = mAuthMgr->SaveCertificateToString(ownId);
|
//std::string certstr = mAuthMgr->SaveCertificateToString(ownId);
|
||||||
|
|
||||||
|
std::string certstr ;
|
||||||
|
FILE *fcert = fopen(RsInit::load_cert.c_str(), "r");
|
||||||
|
char *line = NULL;
|
||||||
|
size_t len = 0 ;
|
||||||
|
|
||||||
|
if(fcert == NULL)
|
||||||
|
return "Error: could not open certificate file." ;
|
||||||
|
|
||||||
|
while(getline(&line,&len,fcert) > 0)
|
||||||
|
certstr += std::string(line) ;
|
||||||
|
fclose(fcert) ;
|
||||||
|
|
||||||
std::string name = mAuthMgr->getName(ownId);
|
std::string name = mAuthMgr->getName(ownId);
|
||||||
|
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
|
|
|
@ -78,11 +78,11 @@ public:
|
||||||
}
|
}
|
||||||
****/
|
****/
|
||||||
|
|
||||||
ftFileStatus(std::string name_in, std::string hash_in, uint64_t size_in,
|
ftFileStatus(const std::string& name_in, const std::string& hash_in, uint64_t size_in,
|
||||||
std::string destpath_in, uint32_t mode_in)
|
const std::string& destpath_in, uint32_t mode_in)
|
||||||
:name(name_in), hash(hash_in), destpath(destpath_in), size(size_in), ftMode(mode_in),
|
:name(name_in), hash(hash_in), destpath(destpath_in), size(size_in), ftMode(mode_in),
|
||||||
status(PQIFILE_INIT), mode(0), rate(0), fd(NULL), total_size(0), recv_size(0),
|
status(PQIFILE_INIT), mode(0), rate(0), fd(NULL), total_size(0), recv_size(0),
|
||||||
req_loc(0), req_size(0), lastTS(0), lastDelta(0)
|
req_loc(0), req_size(0), lastTS(0), lastDelta(0),file_name(""),id("")
|
||||||
{
|
{
|
||||||
/* not set ...
|
/* not set ...
|
||||||
* id,
|
* id,
|
||||||
|
@ -92,11 +92,11 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ftFileStatus(std::string id_in, std::string name_in, std::string hash_in, uint64_t size_in,
|
ftFileStatus(const std::string& id_in, const std::string& name_in, const std::string& hash_in, uint64_t size_in,
|
||||||
std::string destpath_in, uint32_t mode_in)
|
const std::string& destpath_in, uint32_t mode_in)
|
||||||
:id(id_in), name(name_in), hash(hash_in), destpath(destpath_in), size(size_in), ftMode(mode_in),
|
:id(id_in), name(name_in), hash(hash_in), destpath(destpath_in), size(size_in), ftMode(mode_in),
|
||||||
status(PQIFILE_INIT), mode(0), rate(0), fd(NULL), total_size(0), recv_size(0),
|
status(PQIFILE_INIT), mode(0), rate(0), fd(NULL), total_size(0), recv_size(0),
|
||||||
req_loc(0), req_size(0), lastTS(0), lastDelta(0)
|
req_loc(0), req_size(0), lastTS(0), lastDelta(0),file_name("")
|
||||||
{
|
{
|
||||||
/* not set ...
|
/* not set ...
|
||||||
* id,
|
* id,
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <rshare.h>
|
#include <rshare.h>
|
||||||
|
#include <rsiface/rsinit.h>
|
||||||
#include "GenCertDialog.h"
|
#include "GenCertDialog.h"
|
||||||
#include "gui/Preferences/rsharesettings.h"
|
#include "gui/Preferences/rsharesettings.h"
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
@ -33,8 +34,8 @@
|
||||||
|
|
||||||
|
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
GenCertDialog::GenCertDialog(RsInit *conf, QWidget *parent, Qt::WFlags flags)
|
GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags)
|
||||||
: QDialog(parent, flags), rsConfig(conf)
|
: QDialog(parent, flags)
|
||||||
{
|
{
|
||||||
/* Invoke Qt Designer generated QObject setup routine */
|
/* Invoke Qt Designer generated QObject setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
@ -124,7 +125,7 @@ void GenCertDialog::genPerson()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool okGen = RsGenerateCertificate(rsConfig, genName, genOrg, genLoc, genCountry, passwd, err);
|
bool okGen = RsInit::RsGenerateCertificate(genName, genOrg, genLoc, genCountry, passwd, err);
|
||||||
|
|
||||||
if (okGen)
|
if (okGen)
|
||||||
{
|
{
|
||||||
|
@ -155,7 +156,7 @@ void GenCertDialog::selectFriend()
|
||||||
|
|
||||||
std::string fname, userName;
|
std::string fname, userName;
|
||||||
fname = fileName.toStdString();
|
fname = fileName.toStdString();
|
||||||
if (ValidateTrustedUser(rsConfig, fname, userName))
|
if (RsInit::ValidateTrustedUser(fname, userName))
|
||||||
{
|
{
|
||||||
ui.genFriend -> setText(QString::fromStdString(userName));
|
ui.genFriend -> setText(QString::fromStdString(userName));
|
||||||
}
|
}
|
||||||
|
@ -177,7 +178,7 @@ void GenCertDialog::checkChanged(int i)
|
||||||
/* invalidate selection */
|
/* invalidate selection */
|
||||||
std::string fname = "";
|
std::string fname = "";
|
||||||
std::string userName = "";
|
std::string userName = "";
|
||||||
ValidateTrustedUser(rsConfig, fname, userName);
|
RsInit::ValidateTrustedUser(fname, userName);
|
||||||
ui.genFriend -> setText("<None Selected>");
|
ui.genFriend -> setText("<None Selected>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +188,7 @@ void GenCertDialog::loadCertificates()
|
||||||
{
|
{
|
||||||
bool autoSave = false;
|
bool autoSave = false;
|
||||||
/* Final stage of loading */
|
/* Final stage of loading */
|
||||||
if (LoadCertificates(rsConfig, autoSave))
|
if (RsInit::LoadCertificates(autoSave))
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class GenCertDialog : public QDialog
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
GenCertDialog(RsInit *config, QWidget *parent = 0, Qt::WFlags flags = 0);
|
GenCertDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||||
/** Default destructor */
|
/** Default destructor */
|
||||||
|
|
||||||
//~GenCertDialog();
|
//~GenCertDialog();
|
||||||
|
@ -63,8 +63,6 @@ private:
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::GenCertDialog ui;
|
Ui::GenCertDialog ui;
|
||||||
|
|
||||||
RsInit *rsConfig;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
#include <rshare.h>
|
#include <rshare.h>
|
||||||
|
#include <rsiface/rsinit.h>
|
||||||
#include "StartDialog.h"
|
#include "StartDialog.h"
|
||||||
#include "GenCertDialog.h"
|
#include "GenCertDialog.h"
|
||||||
#include "LogoBar.h"
|
#include "LogoBar.h"
|
||||||
|
@ -33,8 +34,8 @@
|
||||||
|
|
||||||
|
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
StartDialog::StartDialog(RsInit *conf, QWidget *parent, Qt::WFlags flags)
|
StartDialog::StartDialog(QWidget *parent, Qt::WFlags flags)
|
||||||
: QMainWindow(parent, flags), rsConfig(conf), reqNewCert(false)
|
: QMainWindow(parent, flags), reqNewCert(false)
|
||||||
{
|
{
|
||||||
/* Invoke Qt Designer generated QObject setup routine */
|
/* Invoke Qt Designer generated QObject setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
@ -69,7 +70,7 @@ StartDialog::StartDialog(RsInit *conf, QWidget *parent, Qt::WFlags flags)
|
||||||
/* load the Certificate File name */
|
/* load the Certificate File name */
|
||||||
std::string userName;
|
std::string userName;
|
||||||
|
|
||||||
if (ValidateCertificate(rsConfig, userName))
|
if (RsInit::ValidateCertificate(userName))
|
||||||
{
|
{
|
||||||
/* just need to enter password */
|
/* just need to enter password */
|
||||||
ui.loadName->setText(QString::fromStdString(userName));
|
ui.loadName->setText(QString::fromStdString(userName));
|
||||||
|
@ -120,7 +121,7 @@ void StartDialog::closeinfodlg()
|
||||||
void StartDialog::loadPerson()
|
void StartDialog::loadPerson()
|
||||||
{
|
{
|
||||||
std::string passwd = ui.loadPasswd->text().toStdString();
|
std::string passwd = ui.loadPasswd->text().toStdString();
|
||||||
LoadPassword(rsConfig, passwd);
|
RsInit::LoadPassword(passwd);
|
||||||
loadCertificates();
|
loadCertificates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +129,7 @@ void StartDialog::loadCertificates()
|
||||||
{
|
{
|
||||||
bool autoSave = (Qt::Checked == ui.autoBox -> checkState());
|
bool autoSave = (Qt::Checked == ui.autoBox -> checkState());
|
||||||
/* Final stage of loading */
|
/* Final stage of loading */
|
||||||
if (LoadCertificates(rsConfig, autoSave))
|
if (RsInit::LoadCertificates(autoSave))
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ class StartDialog : public QMainWindow
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
StartDialog(RsInit *config, QWidget *parent = 0, Qt::WFlags flags = 0);
|
StartDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||||
/** Default destructor */
|
/** Default destructor */
|
||||||
//~StartDialog();
|
//~StartDialog();
|
||||||
|
|
||||||
|
@ -83,8 +83,6 @@ private:
|
||||||
#endif
|
#endif
|
||||||
**************/
|
**************/
|
||||||
|
|
||||||
RsInit *rsConfig;
|
|
||||||
|
|
||||||
bool reqNewCert;
|
bool reqNewCert;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,9 @@ void InviteDialog::emailbutton()
|
||||||
|
|
||||||
void InviteDialog::setInfo(std::string invite)
|
void InviteDialog::setInfo(std::string invite)
|
||||||
{
|
{
|
||||||
|
// ui.emailText->setCurrentFont(QFont("TypeWriter",10)) ;
|
||||||
|
// ui.emailText->currentFont().setLetterSpacing(QFont::AbsoluteSpacing,1) ;
|
||||||
|
// ui.emailText->currentFont().setStyleHint(QFont::TypeWriter,QFont::Courier) ;
|
||||||
ui.emailText->setText(QString::fromStdString(invite));
|
ui.emailText->setText(QString::fromStdString(invite));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,22 +13,10 @@
|
||||||
<string>Invite a Friend</string>
|
<string>Invite a Friend</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" >
|
<layout class="QGridLayout" >
|
||||||
<property name="leftMargin" >
|
<property name="margin" >
|
||||||
<number>9</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin" >
|
<property name="spacing" >
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin" >
|
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin" >
|
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<property name="horizontalSpacing" >
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="verticalSpacing" >
|
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="2" column="2" >
|
<item row="2" column="2" >
|
||||||
|
@ -46,17 +34,25 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="7" >
|
<item row="1" column="0" colspan="7" >
|
||||||
<widget class="QTextEdit" name="emailText" >
|
<widget class="QTextEdit" name="emailText" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<family>Courier New</family>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<kerning>false</kerning>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
<property name="readOnly" >
|
<property name="readOnly" >
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="html" >
|
<property name="html" >
|
||||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
|
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
p, li { white-space: pre-wrap; }
|
p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
|
</style></head><body style=" font-family:'Courier New'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Arial'; font-size:8pt;"></p></body></html></string>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Arial'; font-size:8pt;"></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="acceptRichText" >
|
<property name="acceptRichText" >
|
||||||
<bool>true</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -484,7 +480,7 @@ p, li { white-space: pre-wrap; }
|
||||||
</palette>
|
</palette>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet" >
|
<property name="styleSheet" >
|
||||||
<string>background-image: url(:/images/invitefriendlabel.png);</string>
|
<string notr="true" >background-image: url(:/images/invitefriendlabel.png);</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
|
@ -520,7 +516,7 @@ p, li { white-space: pre-wrap; }
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0" >
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>40</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
|
@ -553,7 +549,7 @@ p, li { white-space: pre-wrap; }
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0" >
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>40</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
|
@ -566,7 +562,7 @@ p, li { white-space: pre-wrap; }
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0" >
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>40</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
//#include <util/process.h>
|
//#include <util/process.h>
|
||||||
#include <util/stringutil.h>
|
#include <util/stringutil.h>
|
||||||
|
#include "rsiface/rsinit.h"
|
||||||
#include "rsiface/rsiface.h"
|
#include "rsiface/rsiface.h"
|
||||||
#include "rsiface/notifyqt.h"
|
#include "rsiface/notifyqt.h"
|
||||||
|
|
||||||
|
@ -49,8 +50,8 @@ int main(int argc, char *argv[])
|
||||||
rsiface = NULL;
|
rsiface = NULL;
|
||||||
|
|
||||||
/* RetroShare Core Objects */
|
/* RetroShare Core Objects */
|
||||||
RsInit *config = InitRsConfig();
|
RsInit::InitRsConfig();
|
||||||
bool okStart = InitRetroShare(argc, argv, config);
|
bool okStart = RsInit::InitRetroShare(argc, argv);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function RsConfigMinimised is not available in SVN, so I commented it out.
|
Function RsConfigMinimised is not available in SVN, so I commented it out.
|
||||||
|
@ -61,84 +62,83 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* Setup The GUI Stuff */
|
/* Setup The GUI Stuff */
|
||||||
Rshare rshare(args, argc, argv,
|
Rshare rshare(args, argc, argv,
|
||||||
QString(RsConfigDirectory(config)));
|
QString(RsInit::RsConfigDirectory()));
|
||||||
|
|
||||||
/* Login Dialog */
|
/* Login Dialog */
|
||||||
if (!okStart)
|
if (!okStart)
|
||||||
{
|
{
|
||||||
/* check for existing Certificate */
|
/* check for existing Certificate */
|
||||||
std::string userName;
|
std::string userName;
|
||||||
|
|
||||||
StartDialog *sd = NULL;
|
StartDialog *sd = NULL;
|
||||||
bool genCert = false;
|
bool genCert = false;
|
||||||
if (ValidateCertificate(config, userName))
|
if (RsInit::ValidateCertificate(userName))
|
||||||
{
|
{
|
||||||
sd = new StartDialog(config);
|
sd = new StartDialog();
|
||||||
sd->show();
|
sd->show();
|
||||||
|
|
||||||
while(sd -> isVisible())
|
while(sd -> isVisible())
|
||||||
{
|
{
|
||||||
rshare.processEvents();
|
rshare.processEvents();
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
#else // __LINUX__
|
#else // __LINUX__
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we're logged in */
|
/* if we're logged in */
|
||||||
genCert = sd->requestedNewCert();
|
genCert = sd->requestedNewCert();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
genCert = true;
|
genCert = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (genCert)
|
if (genCert)
|
||||||
{
|
{
|
||||||
GenCertDialog *gd = new GenCertDialog(config);
|
GenCertDialog *gd = new GenCertDialog();
|
||||||
|
|
||||||
gd->show();
|
gd->show();
|
||||||
|
|
||||||
while(gd -> isVisible())
|
while(gd -> isVisible())
|
||||||
{
|
{
|
||||||
rshare.processEvents();
|
rshare.processEvents();
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
#else // __LINUX__
|
#else // __LINUX__
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* don't save auto login details */
|
/* don't save auto login details */
|
||||||
LoadCertificates(config, false);
|
RsInit::LoadCertificates(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
NotifyQt *notify = new NotifyQt();
|
NotifyQt *notify = new NotifyQt();
|
||||||
RsIface *iface = createRsIface(*notify);
|
RsIface *iface = createRsIface(*notify);
|
||||||
RsControl *rsServer = createRsControl(*iface, *notify);
|
RsControl *rsServer = createRsControl(*iface, *notify);
|
||||||
|
|
||||||
notify->setRsIface(iface);
|
notify->setRsIface(iface);
|
||||||
|
|
||||||
/* save to the global variables */
|
/* save to the global variables */
|
||||||
rsiface = iface;
|
rsiface = iface;
|
||||||
rsicontrol = rsServer;
|
rsicontrol = rsServer;
|
||||||
|
|
||||||
rsServer -> StartupRetroShare(config);
|
rsServer->StartupRetroShare();
|
||||||
CleanupRsConfig(config);
|
RsInit::passwd="" ;
|
||||||
|
// CleanupRsConfig(config);
|
||||||
|
|
||||||
MainWindow *w = new MainWindow;
|
MainWindow *w = new MainWindow;
|
||||||
//QMainWindow *skinWindow = new QMainWindow();
|
//QMainWindow *skinWindow = new QMainWindow();
|
||||||
|
|
||||||
//skinWindow->resize(w->size().width()+15,w->size().width()+15);
|
//skinWindow->resize(w->size().width()+15,w->size().width()+15);
|
||||||
//skinWindow->setWindowTitle(w->windowTitle());
|
//skinWindow->setWindowTitle(w->windowTitle());
|
||||||
//skinWindow->setCentralWidget(w);
|
//skinWindow->setCentralWidget(w);
|
||||||
|
|
||||||
/* Attach the Dialogs, to the Notify Class */
|
/* Attach the Dialogs, to the Notify Class */
|
||||||
notify->setNetworkDialog(w->networkDialog);
|
notify->setNetworkDialog(w->networkDialog);
|
||||||
notify->setPeersDialog(w->peersDialog);
|
notify->setPeersDialog(w->peersDialog);
|
||||||
|
@ -155,25 +155,25 @@ int main(int argc, char *argv[])
|
||||||
QObject::connect(notify,SIGNAL(hashingInfo(const QString&)),w,SLOT(updateHashingInfo(const QString&))) ;
|
QObject::connect(notify,SIGNAL(hashingInfo(const QString&)),w,SLOT(updateHashingInfo(const QString&))) ;
|
||||||
|
|
||||||
/* only show window, if not startMinimized */
|
/* only show window, if not startMinimized */
|
||||||
if (!startMinimised)
|
if (!startMinimised)
|
||||||
{
|
{
|
||||||
|
|
||||||
w->show();
|
w->show();
|
||||||
//skinWindow->show();
|
//skinWindow->show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run Retroshare */
|
/* Run Retroshare */
|
||||||
//int ret = rshare.run();
|
//int ret = rshare.run();
|
||||||
|
|
||||||
/* Startup a Timer to keep the gui's updated */
|
/* Startup a Timer to keep the gui's updated */
|
||||||
QTimer *timer = new QTimer(w);
|
QTimer *timer = new QTimer(w);
|
||||||
timer -> connect(timer, SIGNAL(timeout()), notify, SLOT(UpdateGUI()));
|
timer -> connect(timer, SIGNAL(timeout()), notify, SLOT(UpdateGUI()));
|
||||||
timer->start(1000);
|
timer->start(1000);
|
||||||
|
|
||||||
/* dive into the endless loop */
|
/* dive into the endless loop */
|
||||||
// return ret;
|
// return ret;
|
||||||
return rshare.exec();
|
return rshare.exec();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,48 +142,48 @@ class RsControl /* The Main Interface Class - for controlling the server */
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RsControl(RsIface &i, NotifyBase &callback)
|
RsControl(RsIface &i, NotifyBase &callback)
|
||||||
:cb(callback), rsIface(i) { return; }
|
:cb(callback), rsIface(i) { return; }
|
||||||
|
|
||||||
virtual ~RsControl() { return; }
|
virtual ~RsControl() { return; }
|
||||||
|
|
||||||
/* Real Startup Fn */
|
/* Real Startup Fn */
|
||||||
virtual int StartupRetroShare(RsInit *config) = 0;
|
virtual int StartupRetroShare() = 0;
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
|
||||||
/* Flagging Persons / Channels / Files in or out of a set (CheckLists) */
|
/* Flagging Persons / Channels / Files in or out of a set (CheckLists) */
|
||||||
virtual int SetInChat(std::string id, bool in) = 0; /* friend : chat msgs */
|
virtual int SetInChat(std::string id, bool in) = 0; /* friend : chat msgs */
|
||||||
virtual int SetInMsg(std::string id, bool in) = 0; /* friend : msg receipients */
|
virtual int SetInMsg(std::string id, bool in) = 0; /* friend : msg receipients */
|
||||||
virtual int SetInBroadcast(std::string id, bool in) = 0; /* channel : channel broadcast */
|
virtual int SetInBroadcast(std::string id, bool in) = 0; /* channel : channel broadcast */
|
||||||
virtual int SetInSubscribe(std::string id, bool in) = 0; /* channel : subscribed channels */
|
virtual int SetInSubscribe(std::string id, bool in) = 0; /* channel : subscribed channels */
|
||||||
virtual int SetInRecommend(std::string id, bool in) = 0; /* file : recommended file */
|
virtual int SetInRecommend(std::string id, bool in) = 0; /* file : recommended file */
|
||||||
virtual int ClearInChat() = 0;
|
virtual int ClearInChat() = 0;
|
||||||
virtual int ClearInMsg() = 0;
|
virtual int ClearInMsg() = 0;
|
||||||
virtual int ClearInBroadcast() = 0;
|
virtual int ClearInBroadcast() = 0;
|
||||||
virtual int ClearInSubscribe() = 0;
|
virtual int ClearInSubscribe() = 0;
|
||||||
virtual int ClearInRecommend() = 0;
|
virtual int ClearInRecommend() = 0;
|
||||||
|
|
||||||
virtual bool IsInChat(std::string id) = 0; /* friend : chat msgs */
|
virtual bool IsInChat(std::string id) = 0; /* friend : chat msgs */
|
||||||
virtual bool IsInMsg(std::string id) = 0; /* friend : msg recpts*/
|
virtual bool IsInMsg(std::string id) = 0; /* friend : msg recpts*/
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* Config */
|
/* Config */
|
||||||
|
|
||||||
virtual int ConfigSetDataRates( int total, int indiv ) = 0;
|
virtual int ConfigSetDataRates( int total, int indiv ) = 0;
|
||||||
virtual int ConfigGetDataRates( float &inKb, float &outKb) = 0;
|
virtual int ConfigGetDataRates( float &inKb, float &outKb) = 0;
|
||||||
virtual int ConfigSetBootPrompt( bool on ) = 0;
|
virtual int ConfigSetBootPrompt( bool on ) = 0;
|
||||||
virtual void ConfigFinalSave( ) = 0;
|
virtual void ConfigFinalSave( ) = 0;
|
||||||
virtual void rsGlobalShutDown( ) = 0;
|
virtual void rsGlobalShutDown( ) = 0;
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
|
||||||
NotifyBase &getNotify() { return cb; }
|
NotifyBase &getNotify() { return cb; }
|
||||||
RsIface &getIface() { return rsIface; }
|
RsIface &getIface() { return rsIface; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NotifyBase &cb;
|
NotifyBase &cb;
|
||||||
RsIface &rsIface;
|
RsIface &rsIface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
63
retroshare-gui/src/rsiface/rsinit.h
Normal file
63
retroshare-gui/src/rsiface/rsinit.h
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
/* Initialisation Class (not publicly disclosed to RsIFace) */
|
||||||
|
|
||||||
|
class RsInit
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/* Commandline/Directory options */
|
||||||
|
|
||||||
|
static const char *RsConfigDirectory() ;
|
||||||
|
|
||||||
|
static bool setStartMinimised() ;
|
||||||
|
static int InitRetroShare(int argcIgnored, char **argvIgnored) ;
|
||||||
|
static int LoadCertificates(bool autoLoginNT) ;
|
||||||
|
static bool ValidateCertificate(std::string &userName) ;
|
||||||
|
static bool ValidateTrustedUser(std::string fname, std::string &userName) ;
|
||||||
|
static bool LoadPassword(std::string passwd) ;
|
||||||
|
static bool RsGenerateCertificate(std::string name, std::string org, std::string loc, std::string country, std::string passwd, std::string &errString);
|
||||||
|
static void load_check_basedir() ;
|
||||||
|
static int create_configinit() ;
|
||||||
|
static bool RsStoreAutoLogin() ;
|
||||||
|
static bool RsTryAutoLogin() ;
|
||||||
|
static bool RsClearAutoLogin(std::string basedir) ;
|
||||||
|
static void InitRsConfig() ;
|
||||||
|
|
||||||
|
static std::string getHomePath() ;
|
||||||
|
|
||||||
|
/* Key Parameters that must be set before
|
||||||
|
* RetroShare will start up:
|
||||||
|
*/
|
||||||
|
static std::string load_cert;
|
||||||
|
static std::string load_key;
|
||||||
|
static std::string passwd;
|
||||||
|
|
||||||
|
static bool havePasswd; /* for Commandline password */
|
||||||
|
static bool autoLogin; /* autoLogin allowed */
|
||||||
|
static bool startMinimised; /* Icon or Full Window */
|
||||||
|
|
||||||
|
/* Win/Unix Differences */
|
||||||
|
static char dirSeperator;
|
||||||
|
|
||||||
|
/* Directories */
|
||||||
|
static std::string basedir;
|
||||||
|
static std::string homePath;
|
||||||
|
|
||||||
|
/* Listening Port */
|
||||||
|
static bool forceExtPort;
|
||||||
|
static bool forceLocalAddr;
|
||||||
|
static unsigned short port;
|
||||||
|
static char inet[256];
|
||||||
|
|
||||||
|
/* Logging */
|
||||||
|
static bool haveLogFile;
|
||||||
|
static bool outStderr;
|
||||||
|
static bool haveDebugLevel;
|
||||||
|
static int debugLevel;
|
||||||
|
static char logfname[1024];
|
||||||
|
|
||||||
|
static bool firsttime_run;
|
||||||
|
static bool load_trustedpeer;
|
||||||
|
static std::string load_trustedpeer_file;
|
||||||
|
|
||||||
|
static bool udpListenerOnly;
|
||||||
|
};
|
||||||
|
|
|
@ -35,7 +35,10 @@ win32-x-g++ {
|
||||||
LIBS += -L${HOME}/.wine/drive_c/pthreads/lib -lpthreadGCE2
|
LIBS += -L${HOME}/.wine/drive_c/pthreads/lib -lpthreadGCE2
|
||||||
LIBS += -lws2_32 -luuid -lole32 -liphlpapi -lcrypt32 -gdi32
|
LIBS += -lws2_32 -luuid -lole32 -liphlpapi -lcrypt32 -gdi32
|
||||||
LIBS += -lole32 -lwinmm
|
LIBS += -lole32 -lwinmm
|
||||||
|
|
||||||
RC_FILE = gui/images/retroshare_win.rc
|
RC_FILE = gui/images/retroshare_win.rc
|
||||||
|
|
||||||
|
DEFINES *= WIN32
|
||||||
}
|
}
|
||||||
|
|
||||||
#################################### Windows #####################################
|
#################################### Windows #####################################
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "rsiface/rsiface.h" /* definition of iface */
|
#include "rsiface/rsiface.h" /* definition of iface */
|
||||||
|
#include "rsiface/rsinit.h" /* definition of iface */
|
||||||
|
|
||||||
#include "notifytxt.h"
|
#include "notifytxt.h"
|
||||||
|
|
||||||
|
@ -69,15 +70,15 @@ int main(int argc, char **argv)
|
||||||
* LoadPassword(...) set password for existing certificate.
|
* LoadPassword(...) set password for existing certificate.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
RsInit *config = InitRsConfig();
|
RsInit::InitRsConfig();
|
||||||
InitRetroShare(argc, argv, config);
|
RsInit::InitRetroShare(argc, argv);
|
||||||
|
|
||||||
/* load password should be called at this point: LoadPassword()
|
/* load password should be called at this point: LoadPassword()
|
||||||
* otherwise loaded from commandline.
|
* otherwise loaded from commandline.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Key + Certificate are loaded into libretroshare */
|
/* Key + Certificate are loaded into libretroshare */
|
||||||
LoadCertificates(config, false);
|
RsInit::LoadCertificates(false);
|
||||||
|
|
||||||
/* Now setup the libretroshare interface objs
|
/* Now setup the libretroshare interface objs
|
||||||
* You will need to create you own NotifyXXX class
|
* You will need to create you own NotifyXXX class
|
||||||
|
@ -91,8 +92,9 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* Start-up libretroshare server threads */
|
/* Start-up libretroshare server threads */
|
||||||
|
|
||||||
rsServer -> StartupRetroShare(config);
|
rsServer -> StartupRetroShare();
|
||||||
CleanupRsConfig(config);
|
RsInit::passwd = "" ;
|
||||||
|
//CleanupRsConfig(config);
|
||||||
|
|
||||||
/* pass control to the GUI */
|
/* pass control to the GUI */
|
||||||
while(1)
|
while(1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue