diff options
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/main_window.cpp | 27 | ||||
-rw-r--r-- | ui/qt/main_window.h | 7 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 11 | ||||
-rw-r--r-- | ui/qt/wireshark_application.cpp | 47 | ||||
-rw-r--r-- | ui/qt/wireshark_application.h | 15 |
5 files changed, 104 insertions, 3 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index d193dde993..c2cba0c6f1 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -320,6 +320,9 @@ MainWindow::MainWindow(QWidget *parent) : // iterates over *all* of our children, looking for matching "on_" slots. // The fewer children we have at this point the better. main_ui_->setupUi(this); +#ifdef HAVE_SOFTWARE_UPDATE + update_action_ = new QAction(tr("Check for Updates" UTF8_HORIZONTAL_ELLIPSIS), main_ui_->menuHelp); +#endif setWindowIcon(wsApp->normalIcon()); setTitlebarForCaptureFile(); setMenusForCaptureFile(); @@ -361,6 +364,13 @@ MainWindow::MainWindow(QWidget *parent) : connect(wsApp, SIGNAL(updateRecentCaptureStatus(const QString &, qint64, bool)), this, SLOT(updateRecentCaptures())); updateRecentCaptures(); +#ifdef HAVE_SOFTWARE_UPDATE + connect(wsApp, SIGNAL(softwareUpdateRequested()), this, SLOT(softwareUpdateRequested()), + Qt::BlockingQueuedConnection); + connect(wsApp, SIGNAL(softwareUpdateClose()), this, SLOT(close()), + Qt::BlockingQueuedConnection); +#endif + df_combo_box_ = new DisplayFilterCombo(); const DisplayFilterEdit *df_edit = dynamic_cast<DisplayFilterEdit *>(df_combo_box_->lineEdit()); connect(df_edit, SIGNAL(pushFilterSyntaxStatus(const QString&)), @@ -449,9 +459,8 @@ MainWindow::MainWindow(QWidget *parent) : #ifdef HAVE_SOFTWARE_UPDATE QAction *update_sep = main_ui_->menuHelp->insertSeparator(main_ui_->actionHelpAbout); - QAction *update_action = new QAction(tr("Check for Updates" UTF8_HORIZONTAL_ELLIPSIS), main_ui_->menuHelp); - main_ui_->menuHelp->insertAction(update_sep, update_action); - connect(update_action, SIGNAL(triggered()), this, SLOT(checkForUpdates())); + main_ui_->menuHelp->insertAction(update_sep, update_action_); + connect(update_action_, SIGNAL(triggered()), this, SLOT(checkForUpdates())); #endif master_split_.setObjectName("splitterMaster"); extra_split_.setObjectName("splitterExtra"); @@ -2090,6 +2099,11 @@ void MainWindow::setMenusForCaptureFile(bool force_disable) } main_ui_->actionViewReload->setEnabled(enable); + +#ifdef HAVE_SOFTWARE_UPDATE + // We might want to enable or disable automatic checks here as well. + update_action_->setEnabled(!can_save); +#endif } void MainWindow::setMenusForCaptureInProgress(bool capture_in_progress) { @@ -2116,6 +2130,10 @@ void MainWindow::setMenusForCaptureInProgress(bool capture_in_progress) { main_ui_->menuFileSet->setEnabled(!capture_in_progress); main_ui_->actionFileQuit->setEnabled(true); +#ifdef HAVE_SOFTWARE_UPDATE + // We might want to enable or disable automatic checks here as well. + update_action_->setEnabled(!capture_in_progress); +#endif main_ui_->actionStatisticsCaptureFileProperties->setEnabled(capture_in_progress); @@ -2140,6 +2158,9 @@ void MainWindow::setMenusForCaptureInProgress(bool capture_in_progress) { void MainWindow::setMenusForCaptureStopping() { main_ui_->actionFileQuit->setEnabled(false); +#ifdef HAVE_SOFTWARE_UPDATE + update_action_->setEnabled(false); +#endif main_ui_->actionStatisticsCaptureFileProperties->setEnabled(false); #ifdef HAVE_LIBPCAP main_ui_->actionCaptureStart->setChecked(false); diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index cda9116ebb..a020befe12 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -182,6 +182,9 @@ private: QMenu *dock_menu_; #endif +#ifdef HAVE_SOFTWARE_UPDATE + QAction *update_action_; +#endif QWidget* getLayoutWidget(layout_pane_content_e type); @@ -358,6 +361,10 @@ private slots: void byteViewTabChanged(int tab_index); +#ifdef HAVE_SOFTWARE_UPDATE + void softwareUpdateRequested(); +#endif + // Automatically connected slots ("on_<object>_<signal>"). // // The slots below follow the naming conventaion described in diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 79e8a25433..b1e6526248 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -1651,6 +1651,17 @@ void MainWindow::byteViewTabChanged(int tab_index) } } +#ifdef HAVE_SOFTWARE_UPDATE +void MainWindow::softwareUpdateRequested() { + // We could call testCaptureFileClose here, but that would give us yet + // another dialog. Just try again later. + if (capture_file_.capFile() && capture_file_.capFile()->state != FILE_CLOSED) { + wsApp->rejectSoftwareUpdate(); + } +} +#endif + + // File Menu void MainWindow::on_actionFileOpen_triggered() diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp index 0cc9d8867f..7552dc8377 100644 --- a/ui/qt/wireshark_application.cpp +++ b/ui/qt/wireshark_application.cpp @@ -196,6 +196,21 @@ extern "C" void menu_recent_file_write_all(FILE *rf) { } } +#ifdef HAVE_SOFTWARE_UPDATE +/** Check to see if Wireshark can shut down safely (e.g. offer to save the + * current capture). + */ +extern "C" int software_update_can_shutdown_callback(void) { + return wsApp->softwareUpdateCanShutdown(); +} + +/** Shut down Wireshark in preparation for an upgrade. + */ +extern "C" void software_update_shutdown_request_callback(void) { + wsApp->softwareUpdateShutdownRequest(); +} +#endif // HAVE_SOFTWARE_UPDATE + // Check each recent item in a separate thread so that we don't hang while // calling stat(). This is called periodically because files and entire // volumes can disappear and reappear at any time. @@ -682,6 +697,9 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) : #endif qApp->setStyleSheet(app_style_sheet); +#ifdef HAVE_SOFTWARE_UPDATE + connect(this, SIGNAL(softwareUpdateQuit()), this, SLOT(quit()), Qt::QueuedConnection); +#endif connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(cleanup())); } @@ -1148,6 +1166,35 @@ void WiresharkApplication::doTriggerMenuItem(MainMenuItem menuItem) } } +#ifdef HAVE_SOFTWARE_UPDATE +bool WiresharkApplication::softwareUpdateCanShutdown() { + software_update_ok_ = true; + // At this point the update is ready to install, but WinSparkle has + // not yet run the installer. We need to close our "Wireshark is + // running" mutexes along with those of our child processes, e.g. + // dumpcap. + + // Step 1: See if we have any open files. + emit softwareUpdateRequested(); + if (software_update_ok_ == true) { + + // Step 2: Close the "running" mutexes. + emit softwareUpdateClose(); + close_app_running_mutex(); + } + return software_update_ok_; +} + +void WiresharkApplication::softwareUpdateShutdownRequest() { + // At this point the installer has been launched. Neither Wireshark nor + // its children should have any "Wireshark is running" mutexes open. + // The main window should be closed. + + // Step 3: Quit. + emit softwareUpdateQuit(); +} +#endif + /* * Editor modelines * diff --git a/ui/qt/wireshark_application.h b/ui/qt/wireshark_application.h index 58b489badf..6f26a90f99 100644 --- a/ui/qt/wireshark_application.h +++ b/ui/qt/wireshark_application.h @@ -124,6 +124,11 @@ public: const QString windowTitleString(QStringList title_parts); const QString windowTitleString(QString title_part) { return windowTitleString(QStringList() << title_part); } void applyCustomColorsFromRecent(); +#ifdef HAVE_SOFTWARE_UPDATE + void rejectSoftwareUpdate() { software_update_ok_ = false; } + bool softwareUpdateCanShutdown(); + void softwareUpdateShutdownRequest(); +#endif QTranslator translator; QTranslator translatorQt; @@ -145,6 +150,10 @@ private: static QString window_title_separator_; QList<AppSignal> app_signals_; int active_captures_; +#ifdef HAVE_SOFTWARE_UPDATE + bool software_update_ok_; +#endif + void storeCustomColorsInRecent(); protected: @@ -171,6 +180,12 @@ signals: void checkDisplayFilter(); void fieldsChanged(); void reloadLuaPlugins(); +#ifdef HAVE_SOFTWARE_UPDATE + // Each of these are called from a separate thread. + void softwareUpdateRequested(); + void softwareUpdateClose(); + void softwareUpdateQuit(); +#endif void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata); void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata); |