2007-11-14 22:18:48 -05:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare QT Gui is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006, crypton
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#include <QtGui>
|
|
|
|
#include <QObject>
|
|
|
|
#include <rshare.h>
|
|
|
|
#include <gui/MainWindow.h>
|
|
|
|
#include <gui/StartDialog.h>
|
|
|
|
#include <gui/GenCertDialog.h>
|
2008-08-15 13:49:57 -04:00
|
|
|
#include <Gui/Preferences/Rsharesettings.h>
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/*** WINDOWS DON'T LIKE THIS - REDEFINES VER numbers.
|
|
|
|
#include <gui/qskinobject/qskinobject.h>
|
|
|
|
****/
|
|
|
|
|
|
|
|
#include <util/process.h>
|
|
|
|
#include <util/string.h>
|
|
|
|
#include "rsiface/rsiface.h"
|
|
|
|
|
|
|
|
#include "rsiface/notifyqt.h"
|
|
|
|
|
|
|
|
RsIface *rsiface = NULL;
|
|
|
|
RsControl *rsicontrol = NULL;
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
|
|
|
|
QStringList args = char_array_to_stringlist(argv+1, argc-1);
|
|
|
|
|
|
|
|
Q_INIT_RESOURCE(images);
|
|
|
|
|
|
|
|
rsiface = NULL;
|
|
|
|
|
|
|
|
/* RetroShare Core Objects */
|
|
|
|
RsInit *config = InitRsConfig();
|
|
|
|
bool okStart = InitRetroShare(argc, argv, config);
|
2008-06-14 09:24:22 -04:00
|
|
|
bool startMinimised = RsConfigStartMinimised(config);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
/* Setup The GUI Stuff */
|
|
|
|
Rshare rshare(args, argc, argv,
|
|
|
|
QString(RsConfigDirectory(config)));
|
|
|
|
|
|
|
|
/* Login Dialog */
|
|
|
|
if (!okStart)
|
|
|
|
{
|
|
|
|
/* check for existing Certificate */
|
|
|
|
std::string userName;
|
|
|
|
|
|
|
|
StartDialog *sd = NULL;
|
|
|
|
bool genCert = false;
|
|
|
|
if (ValidateCertificate(config, userName))
|
|
|
|
{
|
|
|
|
sd = new StartDialog(config);
|
|
|
|
sd->show();
|
|
|
|
|
|
|
|
while(sd -> isVisible())
|
|
|
|
{
|
|
|
|
rshare.processEvents();
|
|
|
|
#ifdef WIN32
|
|
|
|
Sleep(10);
|
|
|
|
#else // __LINUX__
|
|
|
|
usleep(10000);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we're logged in */
|
|
|
|
genCert = sd->requestedNewCert();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
genCert = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (genCert)
|
|
|
|
{
|
|
|
|
GenCertDialog *gd = new GenCertDialog(config);
|
|
|
|
|
|
|
|
gd->show();
|
|
|
|
|
|
|
|
while(gd -> isVisible())
|
|
|
|
{
|
|
|
|
rshare.processEvents();
|
|
|
|
#ifdef WIN32
|
|
|
|
Sleep(10);
|
|
|
|
#else // __LINUX__
|
|
|
|
usleep(10000);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* don't save auto login details */
|
|
|
|
LoadCertificates(config, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
NotifyQt *notify = new NotifyQt();
|
|
|
|
RsIface *iface = createRsIface(*notify);
|
|
|
|
RsControl *rsServer = createRsControl(*iface, *notify);
|
|
|
|
|
|
|
|
notify->setRsIface(iface);
|
|
|
|
|
|
|
|
/* save to the global variables */
|
|
|
|
rsiface = iface;
|
|
|
|
rsicontrol = rsServer;
|
|
|
|
|
|
|
|
rsServer -> StartupRetroShare(config);
|
|
|
|
CleanupRsConfig(config);
|
|
|
|
|
|
|
|
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);
|
|
|
|
notify->setDirDialog(w->sharedfilesDialog);
|
|
|
|
notify->setTransfersDialog(w->transfersDialog);
|
|
|
|
notify->setChatDialog(w->chatDialog);
|
|
|
|
notify->setMessagesDialog(w->messagesDialog);
|
|
|
|
notify->setChannelsDialog(w->channelsDialog);
|
|
|
|
notify->setMessengerWindow(w->messengerWindow);
|
|
|
|
|
2008-08-15 13:49:57 -04:00
|
|
|
/* only show window, if not startMinimized */
|
|
|
|
/*if (!startMinimised)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
w->show();
|
2008-06-14 09:24:22 -04:00
|
|
|
//skinWindow->show();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-08-15 13:49:57 -04:00
|
|
|
}*/
|
|
|
|
/* Run Retroshare */
|
|
|
|
int ret = rshare.run();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
2008-08-15 13:49:57 -04:00
|
|
|
/* dive into the endless loop */
|
|
|
|
return ret;
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|