2007-11-15 03:18:48 +00: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 <QObject>
|
2010-07-23 18:52:58 +00:00
|
|
|
#include <QMessageBox>
|
2007-11-15 03:18:48 +00:00
|
|
|
#include <rshare.h>
|
2010-06-08 21:38:36 +00:00
|
|
|
#include "gui/MainWindow.h"
|
|
|
|
#include "gui/PeersDialog.h"
|
|
|
|
#include "gui/SearchDialog.h"
|
|
|
|
#include "gui/TransfersDialog.h"
|
|
|
|
#include "gui/MessagesDialog.h"
|
|
|
|
#include "gui/SharedFilesDialog.h"
|
2010-08-28 19:50:38 +00:00
|
|
|
#include "gui/chat/PopupChatDialog.h"
|
2010-06-08 21:38:36 +00:00
|
|
|
#include "gui/MessengerWindow.h"
|
|
|
|
#include "gui/NetworkDialog.h"
|
|
|
|
#include "gui/StartDialog.h"
|
|
|
|
#include "gui/GenCertDialog.h"
|
|
|
|
#include "gui/settings/rsharesettings.h"
|
|
|
|
#include "gui/connect/ConfCertDialog.h"
|
2010-07-17 23:19:43 +00:00
|
|
|
#include "idle/idle.h"
|
2007-11-15 03:18:48 +00:00
|
|
|
|
|
|
|
/*** WINDOWS DON'T LIKE THIS - REDEFINES VER numbers.
|
|
|
|
#include <gui/qskinobject/qskinobject.h>
|
|
|
|
****/
|
|
|
|
|
2008-08-15 19:03:50 +00:00
|
|
|
#include <util/stringutil.h>
|
2010-08-06 09:40:23 +00:00
|
|
|
#include <retroshare/rsinit.h>
|
|
|
|
#include <retroshare/rsiface.h>
|
2009-12-31 01:34:23 +00:00
|
|
|
#include "gui/notifyqt.h"
|
2007-11-15 03:18:48 +00:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
|
|
|
|
QStringList args = char_array_to_stringlist(argv+1, argc-1);
|
|
|
|
|
|
|
|
Q_INIT_RESOURCE(images);
|
|
|
|
|
|
|
|
rsiface = NULL;
|
|
|
|
|
2010-07-18 11:43:39 +00:00
|
|
|
NotifyQt *notify = NotifyQt::Create();
|
2009-11-05 19:38:10 +00:00
|
|
|
createRsIface(*notify);
|
|
|
|
createRsControl(*rsiface, *notify);
|
|
|
|
|
2007-11-15 03:18:48 +00:00
|
|
|
/* RetroShare Core Objects */
|
2009-02-08 14:30:28 +00:00
|
|
|
RsInit::InitRsConfig();
|
|
|
|
bool okStart = RsInit::InitRetroShare(argc, argv);
|
2010-05-20 21:53:27 +00:00
|
|
|
|
2010-06-14 13:32:13 +00:00
|
|
|
/* create global settings object
|
|
|
|
path maybe wrong, when no profile exist
|
|
|
|
in this case it can be use only for default values */
|
2010-05-20 21:53:27 +00:00
|
|
|
RshareSettings::Create ();
|
|
|
|
|
2008-09-18 15:15:09 +00:00
|
|
|
/*
|
|
|
|
Function RsConfigMinimised is not available in SVN, so I commented it out.
|
2008-06-14 13:24:22 +00:00
|
|
|
bool startMinimised = RsConfigStartMinimised(config);
|
2008-09-18 15:15:09 +00:00
|
|
|
*/
|
2007-11-15 03:18:48 +00:00
|
|
|
|
2009-05-09 13:38:46 +00:00
|
|
|
//bool startMinimized = false;
|
2007-11-15 03:18:48 +00:00
|
|
|
|
|
|
|
/* Setup The GUI Stuff */
|
|
|
|
Rshare rshare(args, argc, argv,
|
2009-07-30 21:48:54 +00:00
|
|
|
QString::fromStdString(RsInit::RsConfigDirectory()));
|
2007-11-15 03:18:48 +00:00
|
|
|
|
|
|
|
/* Login Dialog */
|
|
|
|
if (!okStart)
|
|
|
|
{
|
2009-02-08 14:30:28 +00:00
|
|
|
/* check for existing Certificate */
|
|
|
|
std::string userName;
|
|
|
|
|
|
|
|
StartDialog *sd = NULL;
|
2007-11-15 03:18:48 +00:00
|
|
|
bool genCert = false;
|
2009-07-30 21:48:54 +00:00
|
|
|
std::list<std::string> accountIds;
|
|
|
|
if (RsInit::getAccountIds(accountIds) && (accountIds.size() > 0))
|
2007-11-15 03:18:48 +00:00
|
|
|
{
|
2009-02-08 14:30:28 +00:00
|
|
|
sd = new StartDialog();
|
|
|
|
sd->show();
|
2007-11-15 03:18:48 +00:00
|
|
|
|
2009-02-08 14:30:28 +00:00
|
|
|
while(sd -> isVisible())
|
|
|
|
{
|
|
|
|
rshare.processEvents();
|
2007-11-15 03:18:48 +00:00
|
|
|
#ifdef WIN32
|
2009-02-08 14:30:28 +00:00
|
|
|
Sleep(10);
|
2007-11-15 03:18:48 +00:00
|
|
|
#else // __LINUX__
|
2009-02-08 14:30:28 +00:00
|
|
|
usleep(10000);
|
2007-11-15 03:18:48 +00:00
|
|
|
#endif
|
2009-02-08 14:30:28 +00:00
|
|
|
}
|
2007-11-15 03:18:48 +00:00
|
|
|
|
2009-02-08 14:30:28 +00:00
|
|
|
/* if we're logged in */
|
|
|
|
genCert = sd->requestedNewCert();
|
2010-05-02 13:12:46 +00:00
|
|
|
delete (sd);
|
2007-11-15 03:18:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-08 14:30:28 +00:00
|
|
|
genCert = true;
|
2007-11-15 03:18:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (genCert)
|
|
|
|
{
|
2010-05-02 13:12:46 +00:00
|
|
|
GenCertDialog gd;
|
|
|
|
gd.exec ();
|
2007-11-15 03:18:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-04-08 15:51:10 +00:00
|
|
|
|
|
|
|
std::string preferredId, gpgId, gpgName, gpgEmail, sslName;
|
|
|
|
RsInit::getPreferedAccountId(preferredId);
|
|
|
|
|
|
|
|
if (RsInit::getAccountDetails(preferredId,
|
|
|
|
gpgId, gpgName, gpgEmail, sslName))
|
|
|
|
{
|
|
|
|
RsInit::SelectGPGAccount(gpgId);
|
|
|
|
}
|
|
|
|
|
|
|
|
// true: note auto-login is active
|
2010-07-01 20:30:36 +00:00
|
|
|
int retVal = RsInit::LockAndLoadCertificates(true);
|
|
|
|
switch(retVal)
|
|
|
|
{
|
|
|
|
case 0: break;
|
|
|
|
case 1: QMessageBox::warning( 0,
|
|
|
|
QObject::tr("Multiple instances"),
|
|
|
|
QObject::tr("Another RetroShare using the same profile is "
|
|
|
|
"already running on your system. Please close "
|
|
|
|
"that instance first") );
|
|
|
|
return 1;
|
|
|
|
case 2: QMessageBox::critical( 0,
|
|
|
|
QObject::tr("Multiple instances"),
|
|
|
|
QObject::tr("An unexpected error occurred when Retroshare"
|
|
|
|
"tried to acquire the single instance lock") );
|
|
|
|
return 1;
|
|
|
|
case 3: QMessageBox::critical( 0,
|
|
|
|
QObject::tr("Login Failure"),
|
|
|
|
QObject::tr("Maybe password is wrong") );
|
|
|
|
return 1;
|
|
|
|
default: std::cerr << "StartDialog::loadCertificates() unexpected switch value " << retVal << std::endl;
|
|
|
|
}
|
2007-11-15 03:18:48 +00:00
|
|
|
}
|
|
|
|
|
2009-07-30 21:48:54 +00:00
|
|
|
rsicontrol->StartupRetroShare();
|
2007-11-15 03:18:48 +00:00
|
|
|
|
2010-06-14 13:32:13 +00:00
|
|
|
/* recreate global settings object, now with correct path */
|
|
|
|
RshareSettings::Create ();
|
|
|
|
|
2010-05-03 00:09:55 +00:00
|
|
|
MainWindow *w = MainWindow::Create ();
|
2009-01-22 21:06:54 +00:00
|
|
|
|
|
|
|
// I'm using a signal to transfer the hashing info to the mainwindow, because Qt schedules signals properly to
|
|
|
|
// avoid clashes between infos from threads.
|
|
|
|
//
|
2009-08-16 20:10:53 +00:00
|
|
|
|
|
|
|
qRegisterMetaType<FileDetail>("FileDetail") ;
|
|
|
|
|
2009-03-15 22:45:40 +00:00
|
|
|
std::cerr << "connecting signals and slots" << std::endl ;
|
2009-08-16 20:10:53 +00:00
|
|
|
QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ;
|
|
|
|
QObject::connect(notify,SIGNAL(hashingInfoChanged(const QString&)),w ,SLOT(updateHashingInfo(const QString&))) ;
|
2010-05-21 20:49:48 +00:00
|
|
|
QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ;
|
2009-08-16 20:10:53 +00:00
|
|
|
QObject::connect(notify,SIGNAL(filesPreModChanged(bool)) ,w->sharedfilesDialog ,SLOT(preModDirectories(bool) )) ;
|
|
|
|
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w->sharedfilesDialog ,SLOT(postModDirectories(bool) )) ;
|
2010-04-24 22:09:47 +00:00
|
|
|
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool) )) ;
|
2009-08-16 20:10:53 +00:00
|
|
|
QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ;
|
|
|
|
QObject::connect(notify,SIGNAL(friendsChanged()) ,w->peersDialog ,SLOT(insertPeers() )) ;
|
2010-08-31 17:13:52 +00:00
|
|
|
QObject::connect(notify,SIGNAL(chatChanged()) ,w->peersDialog ,SLOT(insertChat() ));
|
2009-08-16 20:10:53 +00:00
|
|
|
QObject::connect(notify,SIGNAL(neighborsChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ;
|
|
|
|
QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ;
|
2010-08-22 22:12:26 +00:00
|
|
|
QObject::connect(notify,SIGNAL(messagesTagsChanged()) ,w->messagesDialog ,SLOT(messagesTagsChanged() )) ;
|
2010-08-09 12:16:21 +00:00
|
|
|
QObject::connect(notify,SIGNAL(messagesChanged()) ,w ,SLOT(updateMessages() )) ;
|
2010-08-09 21:20:34 +00:00
|
|
|
QObject::connect(notify,SIGNAL(forumsChanged()) ,w ,SLOT(updateForums() ), Qt::QueuedConnection);
|
2007-11-15 03:18:48 +00:00
|
|
|
|
2009-09-29 20:37:20 +00:00
|
|
|
QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->peersDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool)));
|
2009-11-05 19:38:10 +00:00
|
|
|
QObject::connect(notify,SIGNAL(peerHasNewCustomStateString(const QString&)),w->peersDialog,SLOT(updatePeersCustomStateString(const QString&)));
|
2009-09-30 20:53:18 +00:00
|
|
|
QObject::connect(notify,SIGNAL(peerHasNewAvatar(const QString&)),w->peersDialog,SLOT(updatePeersAvatar(const QString&)));
|
2009-09-30 22:30:57 +00:00
|
|
|
QObject::connect(notify,SIGNAL(ownAvatarChanged()),w->peersDialog,SLOT(updateAvatar()));
|
2009-10-05 19:07:02 +00:00
|
|
|
QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->peersDialog,SLOT(loadmypersonalstatus()));
|
|
|
|
|
2009-05-05 19:50:45 +00:00
|
|
|
QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)),w->networkDialog,SLOT(setLogInfo(QString))) ;
|
2010-02-07 18:10:12 +00:00
|
|
|
QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ;
|
2009-05-05 13:18:53 +00:00
|
|
|
|
2009-05-07 22:43:11 +00:00
|
|
|
QObject::connect(ConfCertDialog::instance(),SIGNAL(configChanged()),w->networkDialog,SLOT(insertConnect())) ;
|
2009-05-15 12:07:37 +00:00
|
|
|
QObject::connect(w->peersDialog,SIGNAL(friendsUpdated()),w->networkDialog,SLOT(insertConnect())) ;
|
2010-06-15 16:51:48 +00:00
|
|
|
|
|
|
|
w->installGroupChatNotifier();
|
2009-07-13 14:01:49 +00:00
|
|
|
|
2010-06-15 16:51:48 +00:00
|
|
|
/* only show window, if not startMinimized */
|
|
|
|
if(!Settings->value(QString::fromUtf8("StartMinimized"), false).toBool())
|
2007-11-15 03:18:48 +00:00
|
|
|
{
|
2010-06-15 16:51:48 +00:00
|
|
|
w->show();
|
2008-10-18 16:02:06 +00:00
|
|
|
}
|
2009-02-08 14:30:28 +00:00
|
|
|
|
2007-11-15 03:18:48 +00:00
|
|
|
/* Startup a Timer to keep the gui's updated */
|
|
|
|
QTimer *timer = new QTimer(w);
|
|
|
|
timer -> connect(timer, SIGNAL(timeout()), notify, SLOT(UpdateGUI()));
|
2009-02-08 14:30:28 +00:00
|
|
|
timer->start(1000);
|
|
|
|
|
|
|
|
/* dive into the endless loop */
|
2010-05-20 21:53:27 +00:00
|
|
|
int ti = rshare.exec();
|
|
|
|
delete w ;
|
2007-11-15 03:18:48 +00:00
|
|
|
|
2010-06-17 17:39:32 +00:00
|
|
|
/* cleanup */
|
|
|
|
PopupChatDialog::cleanupChat();
|
|
|
|
|
2010-05-29 15:14:25 +00:00
|
|
|
rsicontrol->rsGlobalShutDown();
|
|
|
|
|
2010-05-20 21:53:27 +00:00
|
|
|
Settings->sync();
|
|
|
|
delete Settings;
|
2007-11-15 03:18:48 +00:00
|
|
|
|
2010-05-20 21:53:27 +00:00
|
|
|
return ti ;
|
|
|
|
}
|