- Implementde server process termination from client UI
authorlvaatamoinen <lassi.vaatamoinen@ixonos.com>
Fri, 8 Jan 2010 15:16:49 +0000 (15:16 +0000)
committerlvaatamoinen <lassi.vaatamoinen@ixonos.com>
Fri, 8 Jan 2010 15:16:49 +0000 (15:16 +0000)
- TODO: Check if we need some clean up after termination.

git-svn-id: file:///svnroot/qtrapids/trunk@60 42ac0dd5-4c8c-4c71-bb3e-ecdfe252ffda

dbus/com.ixonos.qtrapids.xml
src/client/MainWindow.cpp
src/client/MainWindow.h
src/server/TorrentSession.cpp
src/server/TorrentSession.hpp
src/server/main.cpp

index 05d9bbf..ac00a19 100644 (file)
                   value="qtrapids::ParamsMap_t"/>
     </method>
 
+    <method name="terminateSession">
+    </method>
+               
+               <signal name="terminate">
+               </signal>
+               
   </interface>
 
 </node>
index 221ac60..7e33bf4 100644 (file)
@@ -75,6 +75,8 @@ MainWindow::MainWindow() :
        QAction *removeAction = tempMenu->addAction(tr("&Remove"));
        removeAction->setEnabled(false);
        QAction *quitAction = tempMenu->addAction(tr("&Quit"));
+       QAction *stopDaemonAction = tempMenu->addAction(tr("Stop &daemon"));
+       
 
        tempMenu = menuBar->addMenu(tr("&View"));
        QAction *columnsAction = tempMenu->addAction(tr("&Columns"));
@@ -91,6 +93,7 @@ MainWindow::MainWindow() :
        connect(removeAction, SIGNAL(triggered()), this, SLOT(on_removeAction_clicked()));
        connect(this, SIGNAL(itemSelected(bool)), removeAction, SLOT(setEnabled(bool)));
        connect(quitAction, SIGNAL(triggered()), this, SLOT(on_quitAction_clicked()));
+       connect(stopDaemonAction, SIGNAL(triggered()), this, SLOT(on_stopDaemonAction_clicked()));
        connect(columnsAction, SIGNAL(triggered()), this, SLOT(on_columnsAction_clicked()));
        connect(preferencesAction, SIGNAL(triggered()), this, SLOT(on_preferencesAction_clicked()));
        connect(aboutAction, SIGNAL(triggered()), this, SLOT(on_aboutAction_clicked()));
@@ -340,6 +343,12 @@ void MainWindow::on_quitAction_clicked()
 }
 
 
+void MainWindow::on_stopDaemonAction_clicked()
+{
+       server_.terminateSession();
+}
+
+
 void MainWindow::on_columnsAction_clicked()
 {      
        ColumnSelectorDialog *dialog = new ColumnSelectorDialog(dlView_);
index 1c7efd3..7c822e2 100644 (file)
@@ -80,6 +80,7 @@ private slots:
        void on_openAction_clicked();
        void on_removeAction_clicked();
        void on_quitAction_clicked();
+       void on_stopDaemonAction_clicked();
        void on_columnsAction_clicked();
        void on_preferencesAction_clicked();
        void on_aboutAction_clicked();
index 09bde96..b877470 100644 (file)
@@ -23,7 +23,7 @@ TorrentSession::TorrentSession(QObject *parent, QSettings *settings)
        QDBusConnection dbus = QDBusConnection::sessionBus();
        dbus.registerObject("/qtrapids", this);
        dbus.registerService("com.ixonos.qtrapids");
-
+       
        alertWaiter_->allAlerts();
        connect(alertWaiter_, SIGNAL(alert()), this, SLOT(on_alert()));
        alertWaiter_->start();
@@ -248,4 +248,10 @@ qtrapids::ParamsMap_t TorrentSession::getOptions()
 }
 
 
+void TorrentSession::terminateSession()
+{
+       qDebug() << "Terminate called";
+       emit terminate();
+}
+
 } // namespace qtrapids
index 799f62b..66b6b54 100644 (file)
@@ -50,21 +50,21 @@ class TorrentSession : public QObject
        Q_CLASSINFO("D-Bus Interface", "com.ixonos.qtrapids");
 
 public:
-
        TorrentSession(QObject *parent, QSettings *);
 
 public slots:
-
        void getState();
        void addTorrent(const QString &path, const QString &save_path
                        , qtrapids::ParamsMap_t other_params);
        void removeTorrent(const QString &hash);
        void setOptions(qtrapids::ParamsMap_t options);
        qtrapids::ParamsMap_t getOptions();
-
+       void terminateSession();
+       
 signals:
        void alert(qtrapids::TorrentState info, qtrapids::ParamsMap_t other_info);
-
+       void terminate();
+       
 private slots:
        void on_alert();
 
index 7c3ab9f..fbb1283 100644 (file)
@@ -15,5 +15,6 @@ int main(int argc, char *argv[])
 
        QCoreApplication app(argc, argv);
        TorrentSession server(&app, &settings);
+       QObject::connect(&server, SIGNAL(terminate()), &app, SLOT(quit()));
        return app.exec();
 }