mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -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
|
@ -21,6 +21,7 @@
|
|||
|
||||
|
||||
#include <rshare.h>
|
||||
#include <rsiface/rsinit.h>
|
||||
#include "GenCertDialog.h"
|
||||
#include "gui/Preferences/rsharesettings.h"
|
||||
#include <QFileDialog>
|
||||
|
@ -33,8 +34,8 @@
|
|||
|
||||
|
||||
/** Default constructor */
|
||||
GenCertDialog::GenCertDialog(RsInit *conf, QWidget *parent, Qt::WFlags flags)
|
||||
: QDialog(parent, flags), rsConfig(conf)
|
||||
GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags)
|
||||
: QDialog(parent, flags)
|
||||
{
|
||||
/* Invoke Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
@ -124,7 +125,7 @@ void GenCertDialog::genPerson()
|
|||
return;
|
||||
}
|
||||
|
||||
bool okGen = RsGenerateCertificate(rsConfig, genName, genOrg, genLoc, genCountry, passwd, err);
|
||||
bool okGen = RsInit::RsGenerateCertificate(genName, genOrg, genLoc, genCountry, passwd, err);
|
||||
|
||||
if (okGen)
|
||||
{
|
||||
|
@ -155,7 +156,7 @@ void GenCertDialog::selectFriend()
|
|||
|
||||
std::string fname, userName;
|
||||
fname = fileName.toStdString();
|
||||
if (ValidateTrustedUser(rsConfig, fname, userName))
|
||||
if (RsInit::ValidateTrustedUser(fname, userName))
|
||||
{
|
||||
ui.genFriend -> setText(QString::fromStdString(userName));
|
||||
}
|
||||
|
@ -177,7 +178,7 @@ void GenCertDialog::checkChanged(int i)
|
|||
/* invalidate selection */
|
||||
std::string fname = "";
|
||||
std::string userName = "";
|
||||
ValidateTrustedUser(rsConfig, fname, userName);
|
||||
RsInit::ValidateTrustedUser(fname, userName);
|
||||
ui.genFriend -> setText("<None Selected>");
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +188,7 @@ void GenCertDialog::loadCertificates()
|
|||
{
|
||||
bool autoSave = false;
|
||||
/* Final stage of loading */
|
||||
if (LoadCertificates(rsConfig, autoSave))
|
||||
if (RsInit::LoadCertificates(autoSave))
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class GenCertDialog : public QDialog
|
|||
|
||||
public:
|
||||
/** Default constructor */
|
||||
GenCertDialog(RsInit *config, QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
GenCertDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
/** Default destructor */
|
||||
|
||||
//~GenCertDialog();
|
||||
|
@ -63,8 +63,6 @@ private:
|
|||
|
||||
/** Qt Designer generated object */
|
||||
Ui::GenCertDialog ui;
|
||||
|
||||
RsInit *rsConfig;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
****************************************************************/
|
||||
|
||||
#include <rshare.h>
|
||||
#include <rsiface/rsinit.h>
|
||||
#include "StartDialog.h"
|
||||
#include "GenCertDialog.h"
|
||||
#include "LogoBar.h"
|
||||
|
@ -33,8 +34,8 @@
|
|||
|
||||
|
||||
/** Default constructor */
|
||||
StartDialog::StartDialog(RsInit *conf, QWidget *parent, Qt::WFlags flags)
|
||||
: QMainWindow(parent, flags), rsConfig(conf), reqNewCert(false)
|
||||
StartDialog::StartDialog(QWidget *parent, Qt::WFlags flags)
|
||||
: QMainWindow(parent, flags), reqNewCert(false)
|
||||
{
|
||||
/* Invoke Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
@ -69,7 +70,7 @@ StartDialog::StartDialog(RsInit *conf, QWidget *parent, Qt::WFlags flags)
|
|||
/* load the Certificate File name */
|
||||
std::string userName;
|
||||
|
||||
if (ValidateCertificate(rsConfig, userName))
|
||||
if (RsInit::ValidateCertificate(userName))
|
||||
{
|
||||
/* just need to enter password */
|
||||
ui.loadName->setText(QString::fromStdString(userName));
|
||||
|
@ -120,7 +121,7 @@ void StartDialog::closeinfodlg()
|
|||
void StartDialog::loadPerson()
|
||||
{
|
||||
std::string passwd = ui.loadPasswd->text().toStdString();
|
||||
LoadPassword(rsConfig, passwd);
|
||||
RsInit::LoadPassword(passwd);
|
||||
loadCertificates();
|
||||
}
|
||||
|
||||
|
@ -128,7 +129,7 @@ void StartDialog::loadCertificates()
|
|||
{
|
||||
bool autoSave = (Qt::Checked == ui.autoBox -> checkState());
|
||||
/* Final stage of loading */
|
||||
if (LoadCertificates(rsConfig, autoSave))
|
||||
if (RsInit::LoadCertificates(autoSave))
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class StartDialog : public QMainWindow
|
|||
|
||||
public:
|
||||
/** Default constructor */
|
||||
StartDialog(RsInit *config, QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
StartDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
/** Default destructor */
|
||||
//~StartDialog();
|
||||
|
||||
|
@ -83,8 +83,6 @@ private:
|
|||
#endif
|
||||
**************/
|
||||
|
||||
RsInit *rsConfig;
|
||||
|
||||
bool reqNewCert;
|
||||
};
|
||||
|
||||
|
|
|
@ -102,6 +102,9 @@ void InviteDialog::emailbutton()
|
|||
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
|
@ -13,22 +13,10 @@
|
|||
<string>Invite a Friend</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="leftMargin" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<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" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="2" >
|
||||
|
@ -46,17 +34,25 @@
|
|||
</item>
|
||||
<item row="1" column="0" colspan="7" >
|
||||
<widget class="QTextEdit" name="emailText" >
|
||||
<property name="font" >
|
||||
<font>
|
||||
<family>Courier New</family>
|
||||
<pointsize>10</pointsize>
|
||||
<kerning>false</kerning>
|
||||
</font>
|
||||
</property>
|
||||
<property name="readOnly" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<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; }
|
||||
</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>
|
||||
</property>
|
||||
<property name="acceptRichText" >
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -484,7 +480,7 @@ p, li { white-space: pre-wrap; }
|
|||
</palette>
|
||||
</property>
|
||||
<property name="styleSheet" >
|
||||
<string>background-image: url(:/images/invitefriendlabel.png);</string>
|
||||
<string notr="true" >background-image: url(:/images/invitefriendlabel.png);</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<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" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
|
@ -553,7 +549,7 @@ p, li { white-space: pre-wrap; }
|
|||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
|
@ -566,7 +562,7 @@ p, li { white-space: pre-wrap; }
|
|||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
//#include <util/process.h>
|
||||
#include <util/stringutil.h>
|
||||
#include "rsiface/rsinit.h"
|
||||
#include "rsiface/rsiface.h"
|
||||
#include "rsiface/notifyqt.h"
|
||||
|
||||
|
@ -49,8 +50,8 @@ int main(int argc, char *argv[])
|
|||
rsiface = NULL;
|
||||
|
||||
/* RetroShare Core Objects */
|
||||
RsInit *config = InitRsConfig();
|
||||
bool okStart = InitRetroShare(argc, argv, config);
|
||||
RsInit::InitRsConfig();
|
||||
bool okStart = RsInit::InitRetroShare(argc, argv);
|
||||
|
||||
/*
|
||||
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 */
|
||||
Rshare rshare(args, argc, argv,
|
||||
QString(RsConfigDirectory(config)));
|
||||
QString(RsInit::RsConfigDirectory()));
|
||||
|
||||
/* Login Dialog */
|
||||
if (!okStart)
|
||||
{
|
||||
/* check for existing Certificate */
|
||||
std::string userName;
|
||||
|
||||
StartDialog *sd = NULL;
|
||||
/* check for existing Certificate */
|
||||
std::string userName;
|
||||
|
||||
StartDialog *sd = NULL;
|
||||
bool genCert = false;
|
||||
if (ValidateCertificate(config, userName))
|
||||
if (RsInit::ValidateCertificate(userName))
|
||||
{
|
||||
sd = new StartDialog(config);
|
||||
sd->show();
|
||||
sd = new StartDialog();
|
||||
sd->show();
|
||||
|
||||
while(sd -> isVisible())
|
||||
{
|
||||
rshare.processEvents();
|
||||
while(sd -> isVisible())
|
||||
{
|
||||
rshare.processEvents();
|
||||
#ifdef WIN32
|
||||
Sleep(10);
|
||||
Sleep(10);
|
||||
#else // __LINUX__
|
||||
usleep(10000);
|
||||
usleep(10000);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* if we're logged in */
|
||||
genCert = sd->requestedNewCert();
|
||||
/* if we're logged in */
|
||||
genCert = sd->requestedNewCert();
|
||||
}
|
||||
else
|
||||
{
|
||||
genCert = true;
|
||||
genCert = true;
|
||||
}
|
||||
|
||||
if (genCert)
|
||||
{
|
||||
GenCertDialog *gd = new GenCertDialog(config);
|
||||
GenCertDialog *gd = new GenCertDialog();
|
||||
|
||||
gd->show();
|
||||
gd->show();
|
||||
|
||||
while(gd -> isVisible())
|
||||
{
|
||||
rshare.processEvents();
|
||||
while(gd -> isVisible())
|
||||
{
|
||||
rshare.processEvents();
|
||||
#ifdef WIN32
|
||||
Sleep(10);
|
||||
Sleep(10);
|
||||
#else // __LINUX__
|
||||
usleep(10000);
|
||||
usleep(10000);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* don't save auto login details */
|
||||
LoadCertificates(config, false);
|
||||
RsInit::LoadCertificates(false);
|
||||
}
|
||||
|
||||
NotifyQt *notify = new NotifyQt();
|
||||
RsIface *iface = createRsIface(*notify);
|
||||
RsControl *rsServer = createRsControl(*iface, *notify);
|
||||
NotifyQt *notify = new NotifyQt();
|
||||
RsIface *iface = createRsIface(*notify);
|
||||
RsControl *rsServer = createRsControl(*iface, *notify);
|
||||
|
||||
notify->setRsIface(iface);
|
||||
notify->setRsIface(iface);
|
||||
|
||||
/* save to the global variables */
|
||||
rsiface = iface;
|
||||
rsicontrol = rsServer;
|
||||
|
||||
rsServer -> StartupRetroShare(config);
|
||||
CleanupRsConfig(config);
|
||||
rsServer->StartupRetroShare();
|
||||
RsInit::passwd="" ;
|
||||
// CleanupRsConfig(config);
|
||||
|
||||
MainWindow *w = new MainWindow;
|
||||
MainWindow *w = new MainWindow;
|
||||
//QMainWindow *skinWindow = new QMainWindow();
|
||||
|
||||
|
||||
//skinWindow->resize(w->size().width()+15,w->size().width()+15);
|
||||
//skinWindow->setWindowTitle(w->windowTitle());
|
||||
//skinWindow->setCentralWidget(w);
|
||||
|
||||
|
||||
/* Attach the Dialogs, to the Notify Class */
|
||||
notify->setNetworkDialog(w->networkDialog);
|
||||
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&))) ;
|
||||
|
||||
/* only show window, if not startMinimized */
|
||||
if (!startMinimised)
|
||||
if (!startMinimised)
|
||||
{
|
||||
|
||||
|
||||
w->show();
|
||||
//skinWindow->show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* Run Retroshare */
|
||||
//int ret = rshare.run();
|
||||
|
||||
/* Run Retroshare */
|
||||
//int ret = rshare.run();
|
||||
|
||||
/* Startup a Timer to keep the gui's updated */
|
||||
QTimer *timer = new QTimer(w);
|
||||
timer -> connect(timer, SIGNAL(timeout()), notify, SLOT(UpdateGUI()));
|
||||
timer->start(1000);
|
||||
|
||||
/* dive into the endless loop */
|
||||
// return ret;
|
||||
return rshare.exec();
|
||||
timer->start(1000);
|
||||
|
||||
/* dive into the endless loop */
|
||||
// return ret;
|
||||
return rshare.exec();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -142,48 +142,48 @@ class RsControl /* The Main Interface Class - for controlling the server */
|
|||
{
|
||||
public:
|
||||
|
||||
RsControl(RsIface &i, NotifyBase &callback)
|
||||
:cb(callback), rsIface(i) { return; }
|
||||
RsControl(RsIface &i, NotifyBase &callback)
|
||||
:cb(callback), rsIface(i) { return; }
|
||||
|
||||
virtual ~RsControl() { return; }
|
||||
virtual ~RsControl() { return; }
|
||||
|
||||
/* Real Startup Fn */
|
||||
virtual int StartupRetroShare(RsInit *config) = 0;
|
||||
/* Real Startup Fn */
|
||||
virtual int StartupRetroShare() = 0;
|
||||
|
||||
/****************************************/
|
||||
/****************************************/
|
||||
|
||||
/* 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 SetInMsg(std::string id, bool in) = 0; /* friend : msg receipients */
|
||||
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 SetInRecommend(std::string id, bool in) = 0; /* file : recommended file */
|
||||
virtual int ClearInChat() = 0;
|
||||
virtual int ClearInMsg() = 0;
|
||||
virtual int ClearInBroadcast() = 0;
|
||||
virtual int ClearInSubscribe() = 0;
|
||||
virtual int ClearInRecommend() = 0;
|
||||
/* 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 SetInMsg(std::string id, bool in) = 0; /* friend : msg receipients */
|
||||
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 SetInRecommend(std::string id, bool in) = 0; /* file : recommended file */
|
||||
virtual int ClearInChat() = 0;
|
||||
virtual int ClearInMsg() = 0;
|
||||
virtual int ClearInBroadcast() = 0;
|
||||
virtual int ClearInSubscribe() = 0;
|
||||
virtual int ClearInRecommend() = 0;
|
||||
|
||||
virtual bool IsInChat(std::string id) = 0; /* friend : chat msgs */
|
||||
virtual bool IsInMsg(std::string id) = 0; /* friend : msg recpts*/
|
||||
virtual bool IsInChat(std::string id) = 0; /* friend : chat msgs */
|
||||
virtual bool IsInMsg(std::string id) = 0; /* friend : msg recpts*/
|
||||
|
||||
/****************************************/
|
||||
/* Config */
|
||||
/****************************************/
|
||||
/* Config */
|
||||
|
||||
virtual int ConfigSetDataRates( int total, int indiv ) = 0;
|
||||
virtual int ConfigGetDataRates( float &inKb, float &outKb) = 0;
|
||||
virtual int ConfigSetBootPrompt( bool on ) = 0;
|
||||
virtual void ConfigFinalSave( ) = 0;
|
||||
virtual void rsGlobalShutDown( ) = 0;
|
||||
virtual int ConfigSetDataRates( int total, int indiv ) = 0;
|
||||
virtual int ConfigGetDataRates( float &inKb, float &outKb) = 0;
|
||||
virtual int ConfigSetBootPrompt( bool on ) = 0;
|
||||
virtual void ConfigFinalSave( ) = 0;
|
||||
virtual void rsGlobalShutDown( ) = 0;
|
||||
|
||||
/****************************************/
|
||||
/****************************************/
|
||||
|
||||
NotifyBase &getNotify() { return cb; }
|
||||
RsIface &getIface() { return rsIface; }
|
||||
NotifyBase &getNotify() { return cb; }
|
||||
RsIface &getIface() { return rsIface; }
|
||||
|
||||
private:
|
||||
NotifyBase &cb;
|
||||
RsIface &rsIface;
|
||||
NotifyBase &cb;
|
||||
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;
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue