void NetworkDialog::denyFriend() { QTreeWidgetItem *wi = getCurrentNeighbour(); RsPgpId peer_id( wi->text(COLUMN_PEERID).toStdString() ); rsPeers->removeFriend(peer_id) ; securedUpdateDisplay(); }
void NetworkDialog::changeEvent(QEvent *e) { QWidget::changeEvent(e); switch (e->type()) { case QEvent::StyleChange: securedUpdateDisplay(); break; default: // remove compiler warnings break; } }
/** 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( 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.onlyTrustedKeys, SIGNAL(clicked()), this, SLOT(securedUpdateDisplay())); /* hide the Tree +/- */ ui.connectTreeWidget -> setRootIsDecorated( false ); ui.connectTreeWidget -> setColumnCount(6); /* Set header resize modes and initial section sizes */ QHeaderView * _header = ui.connectTreeWidget->header () ; QHeaderView_setSectionResizeModeColumn(_header, COLUMN_CHECK, QHeaderView::Custom); QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEERNAME, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(_header, COLUMN_I_AUTH_PEER, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEER_AUTH_ME, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEERID, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(_header, COLUMN_LAST_USED, QHeaderView::Interactive); _header->model()->setHeaderData(COLUMN_CHECK, Qt::Horizontal, tr("")); _header->model()->setHeaderData(COLUMN_PEERNAME, Qt::Horizontal, tr("Name")); _header->model()->setHeaderData(COLUMN_I_AUTH_PEER, Qt::Horizontal, tr("Trust level")); _header->model()->setHeaderData(COLUMN_PEER_AUTH_ME, Qt::Horizontal, tr("Did peer authenticate you")); _header->model()->setHeaderData(COLUMN_PEERID, Qt::Horizontal, tr("Cert Id")); _header->model()->setHeaderData(COLUMN_LAST_USED, Qt::Horizontal, tr("Last used")); _header->model()->setHeaderData(COLUMN_CHECK, Qt::Horizontal, tr(" Do you accept connections signed by this key?"),Qt::ToolTipRole); _header->model()->setHeaderData(COLUMN_PEERNAME, Qt::Horizontal, tr("Name of the key"),Qt::ToolTipRole); _header->model()->setHeaderData(COLUMN_I_AUTH_PEER, Qt::Horizontal, tr("This column indicates trust level and whether you signed their PGP key"),Qt::ToolTipRole); _header->model()->setHeaderData(COLUMN_PEER_AUTH_ME, Qt::Horizontal, tr("Did that peer sign your PGP key"),Qt::ToolTipRole); _header->model()->setHeaderData(COLUMN_PEERID, Qt::Horizontal, tr("Certificat ID"),Qt::ToolTipRole); _header->model()->setHeaderData(COLUMN_LAST_USED, Qt::Horizontal, tr("Since when I use this certificate"),Qt::ToolTipRole); _header->resizeSection ( COLUMN_CHECK, 25 ); _header->resizeSection ( COLUMN_PEERNAME, 200 ); _header->resizeSection ( COLUMN_I_AUTH_PEER, 200 ); _header->resizeSection ( COLUMN_PEER_AUTH_ME, 200 ); _header->resizeSection ( COLUMN_LAST_USED, 75 ); // set header text aligment QTreeWidgetItem * headerItem = ui.connectTreeWidget->headerItem(); headerItem->setTextAlignment(COLUMN_CHECK, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(COLUMN_PEERNAME, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(COLUMN_I_AUTH_PEER, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(COLUMN_PEER_AUTH_ME, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(COLUMN_PEERID, Qt::AlignVCenter); headerItem->setTextAlignment(COLUMN_LAST_USED, Qt::AlignVCenter); headerItem->setText(0,QString()) ; ui.connectTreeWidget->sortItems( COLUMN_PEERNAME, Qt::AscendingOrder ); // ui.networkTab->addTab(new TrustView(),QString(tr("Authentication matrix"))); // ui.networkTab->addTab(networkview = new NetworkView(),QString(tr("Network View"))); ui.onlyTrustedKeys->setMinimumWidth(20); 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(); }
int main(int argc, char *argv[]) { #ifdef WINDOWS_SYS // The current directory of the application is changed when using the native dialog on Windows // This is a quick fix until libretroshare is using a absolute path in the portable Version #if QT_VERSION >= QT_VERSION_CHECK (5, 3, 0) // Do we need a solution in v0.6? #endif #if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) && QT_VERSION < QT_VERSION_CHECK (5, 3, 0) typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options); typedef QString (*_qt_filedialog_open_filename_hook) (QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options); typedef QString (*_qt_filedialog_save_filename_hook) (QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options); typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options); extern Q_GUI_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook; extern Q_GUI_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook; extern Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook; extern Q_GUI_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook; qt_filedialog_open_filename_hook = filedialog_open_filename_hook; qt_filedialog_open_filenames_hook = filedialog_open_filenames_hook; qt_filedialog_save_filename_hook = filedialog_save_filename_hook; qt_filedialog_existing_directory_hook = filedialog_existing_directory_hook; #endif #if QT_VERSION < QT_VERSION_CHECK (5, 0, 0) extern bool Q_GUI_EXPORT qt_use_native_dialogs; qt_use_native_dialogs = false; #endif { /* 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); Q_INIT_RESOURCE(icons); // This is needed to allocate rsNotify, so that it can be used to ask for PGP passphrase // RsControl::earlyInitNotificationSystem() ; NotifyQt *notify = NotifyQt::Create(); rsNotify->registerNotifyClient(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 PGP keys are mentioned 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(":/icons/logo_128.png")); int ret = msgBox.exec(); if(ret == QMessageBox::Cancel) return 0 ; if(ret == QMessageBox::Ok) { if(!RsAccounts::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(":/icons/logo_128.png")); switch (initResult) { case RS_INIT_AUTH_FAILED: std::cerr << "RsInit::InitRetroShare AuthGPG::InitAuth failed" << std::endl; mb.setText(QObject::tr("Initialization failed. Wrong or missing installation of PGP.")); break; default: /* Unexpected return code */ std::cerr << "RsInit::InitRetroShare unexpected return code " << initResult << std::endl; mb.setText(QObject::tr("An unexpected error occurred. 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(RsAccounts::ConfigDirectory().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/logo/logo_splash.png")/* , Qt::WindowStaysOnTopHint*/); switch (initResult) { case RS_INIT_OK: { /* Login Dialog */ /* check for existing Certificate */ bool genCert = false; std::list<RsPeerId> accountIds; if (RsAccounts::GetAccountIds(accountIds) && (accountIds.size() > 0)) { StartDialog sd; if (sd.exec() == QDialog::Rejected) { return 1; } /* if we're logged in */ genCert = sd.requestedNewCert(); } else { genCert = true; } if (genCert) { GenCertDialog gd(false); if (gd.exec () == QDialog::Rejected) { return 1; } } splashScreen.show(); } break; case RS_INIT_HAVE_ACCOUNT: { splashScreen.show(); splashScreen.showMessage(rshare.translate("SplashScreen", "Load profile"), Qt::AlignHCenter | Qt::AlignBottom); RsPeerId preferredId; RsAccounts::GetPreferredAccountId(preferredId); // true: note auto-login is active Rshare::loadCertificate(preferredId, true); } 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 (!RsControl::instance()->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); SoundManager::initDefault(); #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(retroshareLinkActivated(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->retroshareLinkActivated(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") ; qRegisterMetaType<RsPeerId>("RsPeerId") ; std::cerr << "connecting signals and slots" << std::endl ; QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->transfersDialog->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ; QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; 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(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ; 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->friendsDialog->networkDialog,SLOT(setLogInfo(QString))) ; QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->friendsDialog->networkView,SLOT(update()),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. WebuiPage::checkStartWebui(); /* dive into the endless loop */ int ti = rshare.exec(); delete w ; WebuiPage::checkShutdownWebui(); if (eventReceiver) { /* Destroy event receiver */ delete eventReceiver; eventReceiver = NULL; } /* cleanup */ ChatDialog::cleanupChat(); #ifdef RS_ENABLE_GXS RsGxsUpdateBroadcast::cleanup(); #endif RsControl::instance()->rsGlobalShutDown(); delete(soundManager); soundManager = NULL; Settings->sync(); delete(Settings); return ti ; }