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>
|
2009-12-14 12:13:10 -05:00
|
|
|
#include <gui/settings/rsharesettings.h>
|
2009-05-07 18:43:11 -04:00
|
|
|
#include <gui/connect/ConfCertDialog.h>
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/*** WINDOWS DON'T LIKE THIS - REDEFINES VER numbers.
|
|
|
|
#include <gui/qskinobject/qskinobject.h>
|
|
|
|
****/
|
|
|
|
|
2008-08-15 15:03:50 -04:00
|
|
|
#include <util/stringutil.h>
|
2009-02-08 09:30:28 -05:00
|
|
|
#include "rsiface/rsinit.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
#include "rsiface/rsiface.h"
|
2009-12-30 20:34:23 -05:00
|
|
|
#include "gui/notifyqt.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
|
|
|
|
QStringList args = char_array_to_stringlist(argv+1, argc-1);
|
|
|
|
|
|
|
|
Q_INIT_RESOURCE(images);
|
|
|
|
|
|
|
|
rsiface = NULL;
|
|
|
|
|
2009-11-05 14:38:10 -05:00
|
|
|
NotifyQt *notify = new NotifyQt();
|
|
|
|
createRsIface(*notify);
|
|
|
|
createRsControl(*rsiface, *notify);
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/* RetroShare Core Objects */
|
2009-02-08 09:30:28 -05:00
|
|
|
RsInit::InitRsConfig();
|
|
|
|
bool okStart = RsInit::InitRetroShare(argc, argv);
|
2010-05-20 17:53:27 -04:00
|
|
|
|
|
|
|
/* create global settings object */
|
|
|
|
RshareSettings::Create ();
|
|
|
|
|
2008-09-18 11:15:09 -04:00
|
|
|
/*
|
|
|
|
Function RsConfigMinimised is not available in SVN, so I commented it out.
|
2008-06-14 09:24:22 -04:00
|
|
|
bool startMinimised = RsConfigStartMinimised(config);
|
2008-09-18 11:15:09 -04:00
|
|
|
*/
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-05-09 09:38:46 -04:00
|
|
|
//bool startMinimized = false;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* Setup The GUI Stuff */
|
|
|
|
Rshare rshare(args, argc, argv,
|
2009-07-30 17:48:54 -04:00
|
|
|
QString::fromStdString(RsInit::RsConfigDirectory()));
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* Login Dialog */
|
|
|
|
if (!okStart)
|
|
|
|
{
|
2009-02-08 09:30:28 -05:00
|
|
|
/* check for existing Certificate */
|
|
|
|
std::string userName;
|
|
|
|
|
|
|
|
StartDialog *sd = NULL;
|
2007-11-14 22:18:48 -05:00
|
|
|
bool genCert = false;
|
2009-07-30 17:48:54 -04:00
|
|
|
std::list<std::string> accountIds;
|
|
|
|
if (RsInit::getAccountIds(accountIds) && (accountIds.size() > 0))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2009-02-08 09:30:28 -05:00
|
|
|
sd = new StartDialog();
|
|
|
|
sd->show();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
while(sd -> isVisible())
|
|
|
|
{
|
|
|
|
rshare.processEvents();
|
2007-11-14 22:18:48 -05:00
|
|
|
#ifdef WIN32
|
2009-02-08 09:30:28 -05:00
|
|
|
Sleep(10);
|
2007-11-14 22:18:48 -05:00
|
|
|
#else // __LINUX__
|
2009-02-08 09:30:28 -05:00
|
|
|
usleep(10000);
|
2007-11-14 22:18:48 -05:00
|
|
|
#endif
|
2009-02-08 09:30:28 -05:00
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
/* if we're logged in */
|
|
|
|
genCert = sd->requestedNewCert();
|
2010-05-02 09:12:46 -04:00
|
|
|
delete (sd);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-08 09:30:28 -05:00
|
|
|
genCert = true;
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (genCert)
|
|
|
|
{
|
2010-05-02 09:12:46 -04:00
|
|
|
GenCertDialog gd;
|
|
|
|
gd.exec ();
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-04-08 11:51:10 -04: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
|
|
|
|
RsInit::LoadCertificates(true);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2009-07-30 17:48:54 -04:00
|
|
|
rsicontrol->StartupRetroShare();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-05-02 20:09:55 -04:00
|
|
|
MainWindow *w = MainWindow::Create ();
|
2009-01-22 16:06:54 -05: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 16:10:53 -04:00
|
|
|
|
|
|
|
qRegisterMetaType<FileDetail>("FileDetail") ;
|
|
|
|
|
2009-03-15 18:45:40 -04:00
|
|
|
std::cerr << "connecting signals and slots" << std::endl ;
|
2009-08-16 16:10:53 -04: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 16:49:48 -04:00
|
|
|
QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ;
|
2009-08-16 16:10:53 -04: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 18:09:47 -04:00
|
|
|
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool) )) ;
|
2009-08-16 16:10:53 -04:00
|
|
|
QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ;
|
2010-04-27 08:25:12 -04:00
|
|
|
QObject::connect(notify,SIGNAL(friendsChanged()) ,w->messengerWindow ,SLOT(updateMessengerDisplay() )) ;
|
2009-08-16 16:10:53 -04:00
|
|
|
QObject::connect(notify,SIGNAL(friendsChanged()) ,w->peersDialog ,SLOT(insertPeers() )) ;
|
|
|
|
QObject::connect(notify,SIGNAL(neighborsChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ;
|
|
|
|
QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ;
|
|
|
|
QObject::connect(notify,SIGNAL(configChanged()) ,w->messagesDialog ,SLOT(displayConfig() )) ;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-09-29 16:37:20 -04:00
|
|
|
QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->peersDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool)));
|
2009-11-05 14:38:10 -05:00
|
|
|
QObject::connect(notify,SIGNAL(peerHasNewCustomStateString(const QString&)),w->peersDialog,SLOT(updatePeersCustomStateString(const QString&)));
|
2009-09-30 16:53:18 -04:00
|
|
|
QObject::connect(notify,SIGNAL(peerHasNewAvatar(const QString&)),w->peersDialog,SLOT(updatePeersAvatar(const QString&)));
|
2009-09-30 18:30:57 -04:00
|
|
|
QObject::connect(notify,SIGNAL(ownAvatarChanged()),w->peersDialog,SLOT(updateAvatar()));
|
2010-02-15 13:44:35 -05:00
|
|
|
QObject::connect(notify,SIGNAL(ownAvatarChanged()),w->messengerWindow,SLOT(updateAvatar()));
|
2009-10-05 15:07:02 -04:00
|
|
|
QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->peersDialog,SLOT(loadmypersonalstatus()));
|
2010-02-23 17:26:38 -05:00
|
|
|
QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->messengerWindow,SLOT(loadmystatusmessage()));
|
2009-10-05 15:07:02 -04:00
|
|
|
|
2009-05-05 15:50:45 -04:00
|
|
|
QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)),w->networkDialog,SLOT(setLogInfo(QString))) ;
|
2010-02-07 13:10:12 -05:00
|
|
|
QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ;
|
2009-05-05 09:18:53 -04:00
|
|
|
|
2009-05-07 18:43:11 -04:00
|
|
|
QObject::connect(ConfCertDialog::instance(),SIGNAL(configChanged()),w->networkDialog,SLOT(insertConnect())) ;
|
2009-05-15 08:07:37 -04:00
|
|
|
QObject::connect(w->peersDialog,SIGNAL(friendsUpdated()),w->networkDialog,SLOT(insertConnect())) ;
|
2010-04-10 10:56:34 -04:00
|
|
|
QObject::connect(w->peersDialog,SIGNAL(notifyGroupChat(const QString&,const QString&)),w,SLOT(displaySystrayMsg(const QString&,const QString&)),Qt::QueuedConnection) ;
|
2009-07-13 10:01:49 -04:00
|
|
|
|
2010-04-15 08:02:23 -04:00
|
|
|
QObject::connect(w->messengerWindow,SIGNAL(startChat(QTreeWidgetItem* )),w->peersDialog,SLOT(chatfriend(QTreeWidgetItem* ))) ;
|
2010-04-27 08:25:12 -04:00
|
|
|
QObject::connect(w->idle, SIGNAL(secondsIdle(int)), w->messengerWindow, SLOT(checkAndSetIdle(int)));
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2010-05-09 17:58:28 -04:00
|
|
|
/* only show window, if not startMinimized */
|
2010-05-20 17:53:27 -04:00
|
|
|
if(!Settings->value(QString::fromUtf8("StartMinimized"), false).toBool())
|
2010-05-09 17:58:28 -04:00
|
|
|
{
|
2009-02-08 09:30:28 -05:00
|
|
|
|
2010-05-09 17:58:28 -04:00
|
|
|
w->show();
|
|
|
|
}
|
2008-10-18 12:02:06 -04:00
|
|
|
}
|
2009-02-08 09:30:28 -05:00
|
|
|
|
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()));
|
2009-02-08 09:30:28 -05:00
|
|
|
timer->start(1000);
|
|
|
|
|
|
|
|
/* dive into the endless loop */
|
|
|
|
// return ret;
|
2010-05-20 17:53:27 -04:00
|
|
|
int ti = rshare.exec();
|
|
|
|
delete w ;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->sync();
|
|
|
|
delete Settings;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
return ti ;
|
|
|
|
}
|