/** Default constructor */ ConfCertDialog::ConfCertDialog(const std::string& id, QWidget *parent, Qt::WindowFlags flags) : QDialog(parent, flags), mId(id) { /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); ui._useOldFormat_CB->setChecked(true) ; ui.headerFrame->setHeaderImage(QPixmap(":/images/user/identityinfo64.png")); ui.headerFrame->setHeaderText(tr("Friend Details")); ui._chat_CB->hide() ; setAttribute(Qt::WA_DeleteOnClose, true); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(applyDialog())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect(ui.make_friend_button, SIGNAL(clicked()), this, SLOT(makeFriend())); connect(ui.denyFriendButton, SIGNAL(clicked()), this, SLOT(denyFriend())); connect(ui.signKeyButton, SIGNAL(clicked()), this, SLOT(signGPGKey())); connect(ui.trusthelpButton, SIGNAL(clicked()), this, SLOT(showHelpDialog())); connect(ui._shouldAddSignatures_CB, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage())); connect(ui._useOldFormat_CB, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage())); // connect(ui._anonymous_routing_CB, SIGNAL(toggled(bool)), this, SLOT(setServiceFlags())); // connect(ui._discovery_CB, SIGNAL(toggled(bool)), this, SLOT(setServiceFlags())); // connect(ui._forums_channels_CB, SIGNAL(toggled(bool)), this, SLOT(setServiceFlags())); ui.avatar->setFrameType(AvatarWidget::NORMAL_FRAME); MainWindow *w = MainWindow::getInstance(); if (w) { connect(this, SIGNAL(configChanged()), w->getPage(MainWindow::Network), SLOT(insertConnect())); } }
/** Default constructor */ ConfCertDialog::ConfCertDialog(const RsPeerId& id, const RsPgpId &pgp_id, QWidget *parent, Qt::WindowFlags flags) : QDialog(parent, flags), peerId(id), pgpId(pgp_id) { /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); // if(id.isNull()) // ui._useOldFormat_CB->setChecked(true) ; // else // { // ui._useOldFormat_CB->setChecked(false) ; // ui._useOldFormat_CB->setEnabled(false) ; // } ui.headerFrame->setHeaderImage(QPixmap(":/images/user/identityinfo64.png")); ui.headerFrame->setHeaderText(tr("Friend node details")); //ui._chat_CB->hide() ; setAttribute(Qt::WA_DeleteOnClose, true); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(applyDialog())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect(ui._shouldAddSignatures_CB, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage())); //connect(ui.denyFriendButton, SIGNAL(clicked()), this, SLOT(denyFriend())); //connect(ui._shouldAddSignatures_CB_2, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage())); ui.avatar->setFrameType(AvatarWidget::NORMAL_FRAME); MainWindow *w = MainWindow::getInstance(); if (w) { connect(this, SIGNAL(configChanged()), w->getPage(MainWindow::Network), SLOT(insertConnect())); } }
void NetworkDialog::denyFriend() { QTreeWidgetItem *wi = getCurrentNeighbour(); std::string peer_id = wi->text(COLUMN_PEERID).toStdString() ; rsPeers->removeFriend(peer_id) ; insertConnect() ; }
void NetworkDialog::makeFriend() { QTreeWidgetItem *wi = getCurrentNeighbour(); std::string authId = wi->text(9).toStdString() ; rsPeers->AuthCertificate(authId, ""); rsPeers->addFriend(authId); insertConnect() ; }
void NetworkDialog::changeEvent(QEvent *e) { QWidget::changeEvent(e); switch (e->type()) { case QEvent::StyleChange: insertConnect(); break; default: // remove compiler warnings break; } }
void NetworkDialog::deleteCert() { #ifdef TODO // do whatever is needed to remove the certificate completely, hopping this // will eventually remove the signature we've stamped on it. std::cout << "Deleting friend !" << std::endl ; QTreeWidgetItem *wi = getCurrentNeighbour(); std::string peer_id = wi->text(9).toStdString() ; rsPeers->deleteCertificate(peer_id) ; insertConnect() ; #endif }
IPC_RETURN_TYPE IPC_subscribeDisconnect (CONNECT_HANDLE_TYPE handler, void *clientData) { if (!X_IPC_CONNECTED()) { RETURN_ERROR(IPC_Not_Connected); } else { LOCK_CM_MUTEX; insertConnect(&GET_C_GLOBAL(disconnectNotifyList), IPC_DISCONNECT_NOTIFY_MSG, (X_IPC_HND_FN)ipcDisconnectHandler, handler, clientData); UNLOCK_CM_MUTEX; return IPC_OK; } }
/** Default constructor */ ConfCertDialog::ConfCertDialog(const std::string& id, QWidget *parent, Qt::WFlags flags) : QDialog(parent, flags), mId(id) { /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog())); connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(close())); connect(ui.make_friend_button, SIGNAL(clicked()), this, SLOT(makeFriend())); connect(ui.denyFriendButton, SIGNAL(clicked()), this, SLOT(denyFriend())); connect(ui.signKeyButton, SIGNAL(clicked()), this, SLOT(signGPGKey())); connect(ui.trusthelpButton, SIGNAL(clicked()), this, SLOT(showHelpDialog())); connect(ui._shouldAddSignatures_CB, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage())); MainWindow *w = MainWindow::getInstance(); if (w) { connect(this, SIGNAL(configChanged()), w->getPage(MainWindow::Network), SLOT(insertConnect())); } }
void NetworkDialog::updateDisplay() { insertConnect() ; }
void NetworkDialog::removeUnusedKeys() { std::set<RsPgpId> pre_selected ; std::list<RsPgpId> ids ; rsPeers->getGPGAllList(ids) ; RsPeerDetails details ; time_t now = time(NULL) ; time_t THREE_MONTHS = 3*31*24*60*60 ;//3*DayPerMonth*HoursPerDay*MinPerHour*SecPerMin for(std::list<RsPgpId>::const_iterator it(ids.begin());it!=ids.end();++it) { rsPeers->getGPGDetails(*it,details) ; if(rsPeers->haveSecretKey(*it)) { std::cerr << "Skipping public/secret key pair " << *it << std::endl; continue ; } if(now > (time_t) (THREE_MONTHS + details.lastUsed)) { std::cerr << "Adding " << *it << " to pre-selection." << std::endl; pre_selected.insert(*it) ; } } std::set<RsPgpId> selected = FriendSelectionDialog::selectFriends_PGP(NULL, tr("Clean keyring"), tr("The selected keys below haven't been used in the last 3 months. \nDo you want to delete them permanently ? \n\nNotes: Your old keyring will be backed up.\n The removal may fail when running multiple Retroshare instances on the same machine."),FriendSelectionWidget::MODUS_CHECK,FriendSelectionWidget::SHOW_GPG | FriendSelectionWidget::SHOW_NON_FRIEND_GPG, pre_selected) ; std::cerr << "Removing these keys from the keyring: " << std::endl; for(std::set<RsPgpId>::const_iterator it(selected.begin());it!=selected.end();++it) std::cerr << " " << *it << std::endl; std::string backup_file ; uint32_t error_code ; if(selected.empty()) return ; if( rsPeers->removeKeysFromPGPKeyring(selected,backup_file,error_code) ) QMessageBox::information(NULL,tr("Keyring info"),tr("%1 keys have been deleted from your keyring. \nFor security, your keyring was previously backed-up to file \n\n").arg(selected.size())+QString::fromStdString(backup_file) ) ; else { QString error_string ; switch(error_code) { default: case PGP_KEYRING_REMOVAL_ERROR_NO_ERROR: error_string = tr("Unknown error") ; break ; case PGP_KEYRING_REMOVAL_ERROR_CANT_REMOVE_SECRET_KEYS: error_string = tr("Cannot delete secret keys") ; break ; case PGP_KEYRING_REMOVAL_ERROR_CANNOT_WRITE_BACKUP: case PGP_KEYRING_REMOVAL_ERROR_CANNOT_CREATE_BACKUP: error_string = tr("Cannot create backup file. Check for permissions in pgp directory, disk space, etc.") ; break ; case PGP_KEYRING_REMOVAL_ERROR_DATA_INCONSISTENCY: error_string = tr("Data inconsistency in the keyring. This is most probably a bug. Please contact the developers.") ; break ; } QMessageBox::warning(NULL,tr("Keyring info"),tr("Key removal has failed. Your keyring remains intact.\n\nReported error:")+" "+error_string ) ; } insertConnect() ; }
/** Constructor */ NetworkDialog::NetworkDialog(QWidget *parent) : RsAutoUpdatePage(10000,parent) // updates every 10 sec. { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); connect( ui.connecttreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connecttreeWidgetCostumPopupMenu( QPoint ) ) ); connect( ui.connecttreeWidget, SIGNAL( itemSelectionChanged()), ui.unvalidGPGkeyWidget, SLOT( clearSelection() ) ); connect( ui.connecttreeWidget, SIGNAL( itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT( peerdetails () ) ); connect( ui.unvalidGPGkeyWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connecttreeWidgetCostumPopupMenu( QPoint ) ) ); connect( ui.unvalidGPGkeyWidget, SIGNAL( itemSelectionChanged()), ui.connecttreeWidget, SLOT( clearSelection() ) ); connect( ui.unvalidGPGkeyWidget, SIGNAL( itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT( peerdetails () ) ); connect( ui.filterLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterItems(QString))); connect( ui.filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int))); connect( ui.showUnvalidKeys, SIGNAL(clicked()), this, SLOT(insertConnect())); /* hide the Tree +/- */ ui.connecttreeWidget -> setRootIsDecorated( false ); ui.connecttreeWidget -> setColumnCount(5); ui.unvalidGPGkeyWidget-> setColumnCount(5); /* Set header resize modes and initial section sizes */ QHeaderView * _header = ui.connecttreeWidget->header () ; _header->setResizeMode (0, QHeaderView::Custom); _header->setResizeMode (1, QHeaderView::Interactive); _header->setResizeMode (2, QHeaderView::Interactive); _header->setResizeMode (3, QHeaderView::Interactive); _header->setResizeMode (4, QHeaderView::Interactive); _header->resizeSection ( 0, 25 ); _header->resizeSection ( 1, 200 ); _header->resizeSection ( 2, 200 ); _header->resizeSection ( 3, 200 ); // set header text aligment QTreeWidgetItem * headerItem = ui.connecttreeWidget->headerItem(); headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(4, Qt::AlignVCenter); /* hide the Tree +/- */ ui.unvalidGPGkeyWidget -> setRootIsDecorated( false ); /* Set header resize modes and initial section sizes */ ui.unvalidGPGkeyWidget->header()->setResizeMode (0, QHeaderView::Custom); ui.unvalidGPGkeyWidget->header()->setResizeMode (1, QHeaderView::Interactive); ui.unvalidGPGkeyWidget->header()->setResizeMode (2, QHeaderView::Interactive); ui.unvalidGPGkeyWidget->header()->setResizeMode (3, QHeaderView::Interactive); ui.unvalidGPGkeyWidget->header()->setResizeMode (4, QHeaderView::Interactive); ui.unvalidGPGkeyWidget->header()->resizeSection ( 0, 25 ); ui.unvalidGPGkeyWidget->header()->resizeSection ( 1, 200 ); ui.unvalidGPGkeyWidget->header()->resizeSection ( 2, 200 ); ui.unvalidGPGkeyWidget->header()->resizeSection ( 3, 200 ); // set header text aligment ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter); ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter); ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter); ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter); ui.unvalidGPGkeyWidget->headerItem()->setTextAlignment(4, Qt::AlignVCenter); ui.connecttreeWidget->sortItems( 1, Qt::AscendingOrder ); ui.unvalidGPGkeyWidget->sortItems( 1, Qt::AscendingOrder ); // ui.networkTab->addTab(new TrustView(),QString(tr("Authentication matrix"))); // ui.networkTab->addTab(networkview = new NetworkView(),QString(tr("Network View"))); ui.showUnvalidKeys->setMinimumWidth(20); QString version = "-"; std::map<std::string, std::string>::iterator vit; std::map<std::string, std::string> versions; bool retv = rsDisc->getDiscVersions(versions); if (retv && versions.end() != (vit = versions.find(rsPeers->getOwnId()))) { version = QString::fromStdString(vit->second); } QMenu *menu = new QMenu(); //menu->addAction(ui.actionAddFriend); //menu->addAction(ui.actionCopyKey); //menu->addAction(ui.actionExportKey); //menu->addAction(ui.actionCreate_New_Profile); //menu->addSeparator(); menu->addAction(ui.actionTabsright); menu->addAction(ui.actionTabswest); menu->addAction(ui.actionTabssouth); menu->addAction(ui.actionTabsnorth); menu->addSeparator(); menu->addAction(ui.actionTabsTriangular); menu->addAction(ui.actionTabsRounded); //ui.viewButton->setMenu(menu); QTimer *timer2 = new QTimer(this); connect(timer2, SIGNAL(timeout()), this, SLOT(updateNetworkStatus())); timer2->start(1000); /* add filter actions */ ui.filterLineEdit->addFilter(QIcon(), tr("Name"), COLUMN_PEERNAME, tr("Search Name")); ui.filterLineEdit->addFilter(QIcon(), tr("Peer ID"), COLUMN_PEERID, tr("Search Peer ID")); ui.filterLineEdit->setCurrentFilter(COLUMN_PEERNAME); //updateNetworkStatus(); //loadtabsettings(); /* Hide platform specific features */ #ifdef Q_WS_WIN #endif }
int main(int argc, char *argv[]) { #ifdef WINDOWS_SYS { /* Set the current directory to the application dir, because the start dir with autostart from the registry run key is not the exe dir */ QApplication app(argc, argv); QDir::setCurrent(QCoreApplication::applicationDirPath()); } #endif QStringList args = char_array_to_stringlist(argv+1, argc-1); Q_INIT_RESOURCE(images); rsiface = NULL; NotifyQt *notify = NotifyQt::Create(); createRsIface(*notify); createRsControl(*rsiface, *notify); /* RetroShare Core Objects */ RsInit::InitRsConfig(); int initResult = RsInit::InitRetroShare(argc, argv); if(initResult == RS_INIT_NO_KEYRING) // happens when we already have accounts, but no pgp key. This is when switching to the openpgp-sdk version. { QApplication dummyApp (argc, argv); // needed for QMessageBox /* Translate into the desired language */ LanguageSupport::translate(LanguageSupport::defaultLanguageCode()); QMessageBox msgBox; msgBox.setText(QObject::tr("This version of RetroShare is using OpenPGP-SDK. As a side effect, it's not using the system shared PGP keyring, but has it's own keyring shared by all RetroShare instances. <br><br>You do not appear to have such a keyring, although GPG keys are mentionned by existing RetroShare accounts, probably because you just changed to this new version of the software.")); msgBox.setInformativeText(QObject::tr("Choose between:<br><ul><li><b>Ok</b> to copy the existing keyring from gnupg (safest bet), or </li><li><b>Close without saving</b> to start fresh with an empty keyring (you will be asked to create a new PGP key to work with RetroShare, or import a previously saved pgp keypair). </li><li><b>Cancel</b> to quit and forge a keyring by yourself (needs some PGP skills)</li></ul>")); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Discard | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Ok); msgBox.setWindowIcon(QIcon(":/images/rstray3.png")); int ret = msgBox.exec(); if(ret == QMessageBox::Cancel) return 0 ; if(ret == QMessageBox::Ok) { if(!RsInit::copyGnuPGKeyrings()) return 0 ; initResult = RsInit::InitRetroShare(argc, argv); displayWarningAboutDSAKeys() ; } else initResult = RS_INIT_OK ; } if (initResult < 0) { /* Error occured */ QApplication dummyApp (argc, argv); // needed for QMessageBox /* Translate into the desired language */ LanguageSupport::translate(LanguageSupport::defaultLanguageCode()); displayWarningAboutDSAKeys(); QMessageBox mb(QMessageBox::Critical, QObject::tr("RetroShare"), "", QMessageBox::Ok); mb.setWindowIcon(QIcon(":/images/rstray3.png")); switch (initResult) { case RS_INIT_AUTH_FAILED: std::cerr << "RsInit::InitRetroShare AuthGPG::InitAuth failed" << std::endl; mb.setText(QObject::tr("Inititialize failed. Wrong or missing installation of gpg.")); break; default: /* Unexpected return code */ std::cerr << "RsInit::InitRetroShare unexpected return code " << initResult << std::endl; mb.setText(QObject::tr("An unexpected error occured. Please report 'RsInit::InitRetroShare unexpected return code %1'.").arg(initResult)); break; } mb.exec(); return 1; } /* create global settings object path maybe wrong, when no profile exist in this case it can be use only for default values */ RshareSettings::Create (); /* Setup The GUI Stuff */ Rshare rshare(args, argc, argv, QString::fromUtf8(RsInit::RsConfigDirectory().c_str())); std::string url = RsInit::getRetroShareLink(); if (!url.empty()) { /* start with RetroShare link */ EventReceiver eventReceiver; if (eventReceiver.sendRetroShareLink(QString::fromStdString(url))) { return 0; } /* Start RetroShare */ } QSplashScreen splashScreen(QPixmap(":/images/splash.png")/* , Qt::WindowStaysOnTopHint*/); switch (initResult) { case RS_INIT_OK: { /* Login Dialog */ /* check for existing Certificate */ StartDialog *sd = NULL; bool genCert = false; std::list<std::string> accountIds; if (RsInit::getAccountIds(accountIds) && (accountIds.size() > 0)) { sd = new StartDialog(); sd->show(); while(sd -> isVisible()) { rshare.processEvents(); #ifdef WIN32 Sleep(10); #else // __LINUX__ usleep(10000); #endif } /* if we're logged in */ genCert = sd->requestedNewCert(); delete (sd); } else { genCert = true; } if (genCert) { GenCertDialog gd; gd.exec (); } splashScreen.show(); } break; case RS_INIT_HAVE_ACCOUNT: { splashScreen.show(); splashScreen.showMessage(rshare.translate("SplashScreen", "Load profile"), Qt::AlignHCenter | Qt::AlignBottom); 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 std::string lockFile; int retVal = RsInit::LockAndLoadCertificates(true, lockFile); 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\n Lock file:\n") + QString::fromStdString(lockFile)); 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\n Lock file:\n") + QString::fromStdString(lockFile)); 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; } } break; default: /* Unexpected return code */ std::cerr << "RsInit::InitRetroShare unexpected return code " << initResult << std::endl; QMessageBox::warning(0, QObject::tr("RetroShare"), QObject::tr("An unexpected error occured. Please report 'RsInit::InitRetroShare unexpected return code %1'.").arg(initResult)); return 1; } /* recreate global settings object, now with correct path */ RshareSettings::Create(true); Rshare::resetLanguageAndStyle(); SoundManager::create(); splashScreen.showMessage(rshare.translate("SplashScreen", "Load configuration"), Qt::AlignHCenter | Qt::AlignBottom); /* stop Retroshare if startup fails */ if (!rsicontrol->StartupRetroShare()) { std::cerr << "libretroshare failed to startup!" << std::endl; return 1; } Rshare::initPlugins(); splashScreen.showMessage(rshare.translate("SplashScreen", "Create interface"), Qt::AlignHCenter | Qt::AlignBottom); RsharePeerSettings::Create(); Emoticons::load(); if (Settings->value(QString::fromUtf8("FirstRun"), true).toBool()) { splashScreen.hide(); Settings->setValue(QString::fromUtf8("FirstRun"), false); #ifdef __APPLE__ /* For OSX, we set the default to "cleanlooks", as the AQUA style hides some input boxes * only on the first run - as the user might want to change it ;) */ QString osx_style("cleanlooks"); Rshare::setStyle(osx_style); Settings->setInterfaceStyle(osx_style); #endif // This is now disabled - as it doesn't add very much. // Need to make sure that defaults are sensible! #ifdef ENABLE_QUICKSTART_WIZARD QuickStartWizard qstartWizard; qstartWizard.exec(); #endif } MainWindow *w = MainWindow::Create (); splashScreen.finish(w); EventReceiver *eventReceiver = NULL; if (Settings->getRetroShareProtocol()) { /* Create event receiver */ eventReceiver = new EventReceiver; if (eventReceiver->start()) { QObject::connect(eventReceiver, SIGNAL(linkReceived(const QUrl&)), w, SLOT(linkActivated(const QUrl&))); } } if (!url.empty()) { /* Now use link from the command line, because no RetroShare was running */ RetroShareLink link(QString::fromStdString(url)); if (link.valid()) { w->linkActivated(link.toUrl()); } } // 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. // qRegisterMetaType<FileDetail>("FileDetail") ; std::cerr << "connecting signals and slots" << std::endl ; QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ; QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; QObject::connect(notify,SIGNAL(filesPreModChanged(bool)) ,w->sharedfilesDialog ,SLOT(preModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w->sharedfilesDialog ,SLOT(postModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); QObject::connect(notify,SIGNAL(privateChatChanged(int, int)) ,w ,SLOT(privateChatChanged(int, int) )); QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ; QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ; QObject::connect(notify,SIGNAL(messagesTagsChanged()) ,w->messagesDialog ,SLOT(messagesTagsChanged() )) ; QObject::connect(notify,SIGNAL(messagesChanged()) ,w ,SLOT(updateMessages() )) ; QObject::connect(notify,SIGNAL(forumsChanged()) ,w ,SLOT(updateForums() ), Qt::QueuedConnection); QObject::connect(notify,SIGNAL(channelsChanged(int)) ,w ,SLOT(updateChannels(int) ), Qt::QueuedConnection); QObject::connect(notify,SIGNAL(downloadCompleteCountChanged(int)) ,w ,SLOT(updateTransfers(int) )); QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus())); QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->networkDialog,SLOT(setLogInfo(QString))) ; QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->networkDialog,SLOT(updateNewDiscoveryInfo()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ; w->installGroupChatNotifier(); /* only show window, if not startMinimized */ if (RsInit::getStartMinimised() || Settings->getStartMinimized()) { splashScreen.close(); } else { w->show(); } /* 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); notify->enable() ; // enable notification system after GUI creation, to avoid data races in Qt. /* dive into the endless loop */ int ti = rshare.exec(); delete w ; if (eventReceiver) { /* Destroy event receiver */ delete eventReceiver; eventReceiver = NULL; } /* cleanup */ ChatDialog::cleanupChat(); rsicontrol->rsGlobalShutDown(); delete(soundManager); soundManager = NULL; Settings->sync(); delete(Settings); return ti ; }
int main(int argc, char *argv[]) { #ifdef WINDOWS_SYS { /* Set the current directory to the application dir, because the start dir with autostart from the registry run key is not the exe dir */ QApplication app(argc, argv); QDir::setCurrent(QCoreApplication::applicationDirPath()); } #endif QStringList args = char_array_to_stringlist(argv+1, argc-1); Q_INIT_RESOURCE(images); rsiface = NULL; NotifyQt *notify = NotifyQt::Create(); createRsIface(*notify); createRsControl(*rsiface, *notify); /* RetroShare Core Objects */ RsInit::InitRsConfig(); int initResult = RsInit::InitRetroShare(argc, argv); if (initResult < 0) { /* Error occured */ QApplication dummyApp (argc, argv); // needed for QMessageBox QMessageBox mb(QMessageBox::Critical, QObject::tr("RetroShare"), "", QMessageBox::Ok); mb.setWindowIcon(QIcon(":/images/rstray3.png")); switch (initResult) { case RS_INIT_AUTH_FAILED: std::cerr << "RsInit::InitRetroShare AuthGPG::InitAuth failed" << std::endl; mb.setText(QObject::tr("Inititialize failed. Wrong or missing installation of gpg.")); break; default: /* Unexpected return code */ std::cerr << "RsInit::InitRetroShare unexpected return code " << initResult << std::endl; mb.setText(QObject::tr("An unexpected error occured. Please report 'RsInit::InitRetroShare unexpected return code %1'.").arg(initResult)); break; } mb.exec(); return 1; } /* create global settings object path maybe wrong, when no profile exist in this case it can be use only for default values */ RshareSettings::Create (); /* Setup The GUI Stuff */ Rshare rshare(args, argc, argv, QString::fromStdString(RsInit::RsConfigDirectory())); std::string url = RsInit::getRetroShareLink(); if (!url.empty()) { /* start with RetroShare link */ EventReceiver eventReceiver; if (eventReceiver.sendRetroShareLink(QString::fromStdString(url))) { return 0; } /* Start RetroShare */ } QSplashScreen splashScreen(QPixmap(":/images/splash.png")/* , Qt::WindowStaysOnTopHint*/); switch (initResult) { case RS_INIT_OK: { /* Login Dialog */ /* check for existing Certificate */ std::string userName; StartDialog *sd = NULL; bool genCert = false; std::list<std::string> accountIds; if (RsInit::getAccountIds(accountIds) && (accountIds.size() > 0)) { sd = new StartDialog(); sd->show(); while(sd -> isVisible()) { rshare.processEvents(); #ifdef WIN32 Sleep(10); #else // __LINUX__ usleep(10000); #endif } /* if we're logged in */ genCert = sd->requestedNewCert(); delete (sd); } else { genCert = true; } if (genCert) { GenCertDialog gd; gd.exec (); } splashScreen.show(); } break; case RS_INIT_HAVE_ACCOUNT: { splashScreen.show(); splashScreen.showMessage(rshare.translate("SplashScreen", "Load profile"), Qt::AlignHCenter | Qt::AlignBottom); 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 std::string lockFile; int retVal = RsInit::LockAndLoadCertificates(true, lockFile); 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\n Lock file:\n") + QString::fromStdString(lockFile)); 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\n Lock file:\n") + QString::fromStdString(lockFile)); 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; } } break; default: /* Unexpected return code */ std::cerr << "RsInit::InitRetroShare unexpected return code " << initResult << std::endl; QMessageBox::warning(0, QObject::tr("RetroShare"), QObject::tr("An unexpected error occured. Please report 'RsInit::InitRetroShare unexpected return code %1'.").arg(initResult)); return 1; } splashScreen.showMessage(rshare.translate("SplashScreen", "Load configuration"), Qt::AlignHCenter | Qt::AlignBottom); rsicontrol->StartupRetroShare(); splashScreen.showMessage(rshare.translate("SplashScreen", "Create interface"), Qt::AlignHCenter | Qt::AlignBottom); /* recreate global settings object, now with correct path */ RshareSettings::Create (); RsharePeerSettings::Create(); #ifdef MINIMAL_RSGUI MessengerWindow::showYourself(); rshare.setQuitOnLastWindowClosed(true); splashScreen.hide(); #else Emoticons::load(); if (Settings->value(QString::fromUtf8("FirstRun"), true).toBool()) { splashScreen.hide(); Settings->setValue(QString::fromUtf8("FirstRun"), false); QuickStartWizard qstartWizard; qstartWizard.exec(); } MainWindow *w = MainWindow::Create (); splashScreen.finish(w); EventReceiver *eventReceiver = NULL; if (Settings->getRetroShareProtocol()) { /* Create event receiver */ eventReceiver = new EventReceiver; if (eventReceiver->start()) { QObject::connect(eventReceiver, SIGNAL(linkReceived(const QUrl&)), w, SLOT(linkActivated(const QUrl&))); } } if (!url.empty()) { /* Now use link from the command line, because no RetroShare was running */ RetroShareLink link(QString::fromStdString(url)); if (link.valid()) { w->linkActivated(link.toUrl()); } } // 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. // qRegisterMetaType<FileDetail>("FileDetail") ; std::cerr << "connecting signals and slots" << std::endl ; QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ; QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; QObject::connect(notify,SIGNAL(filesPreModChanged(bool)) ,w->sharedfilesDialog ,SLOT(preModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w->sharedfilesDialog ,SLOT(postModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; QObject::connect(notify,SIGNAL(friendsChanged()) ,w->friendsDialog ,SLOT(insertPeers() )) ; QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); QObject::connect(notify,SIGNAL(groupsChanged(int)) ,w->friendsDialog ,SLOT(groupsChanged(int) )); QObject::connect(notify,SIGNAL(privateChatChanged(int, int)) ,w ,SLOT(privateChatChanged(int, int) )); QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ; QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ; QObject::connect(notify,SIGNAL(messagesTagsChanged()) ,w->messagesDialog ,SLOT(messagesTagsChanged() )) ; QObject::connect(notify,SIGNAL(messagesChanged()) ,w ,SLOT(updateMessages() )) ; QObject::connect(notify,SIGNAL(forumsChanged()) ,w ,SLOT(updateForums() ), Qt::QueuedConnection); QObject::connect(notify,SIGNAL(channelsChanged(int)) ,w ,SLOT(updateChannels(int) ), Qt::QueuedConnection); QObject::connect(notify,SIGNAL(downloadCompleteCountChanged(int)) ,w ,SLOT(updateTransfers(int) )); QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus())); QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->networkDialog,SLOT(setLogInfo(QString))) ; QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->networkDialog,SLOT(updateNewDiscoveryInfo()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ; QObject::connect(w->friendsDialog,SIGNAL(friendsUpdated()),w->networkDialog,SLOT(insertConnect())) ; w->installGroupChatNotifier(); /* only show window, if not startMinimized */ if (RsInit::getStartMinimised() || Settings->getStartMinimized()) { splashScreen.close(); } else { w->show(); } /* 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); #endif // MINIMAL_RSGUI /* dive into the endless loop */ int ti = rshare.exec(); #ifndef MINIMAL_RSGUI delete w ; if (eventReceiver) { /* Destroy event receiver */ delete eventReceiver; eventReceiver = NULL; } /* cleanup */ PopupChatDialog::cleanupChat(); #endif // MINIMAL_RSGUI rsicontrol->rsGlobalShutDown(); Settings->sync(); delete Settings; return ti ; }