gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r3002 - in gnunet-qt: . pixmaps src/plugins src/plugins/gen


From: durner
Subject: [GNUnet-SVN] r3002 - in gnunet-qt: . pixmaps src/plugins src/plugins/general
Date: Sat, 10 Jun 2006 06:02:59 -0700 (PDT)

Author: durner
Date: 2006-06-10 06:02:39 -0700 (Sat, 10 Jun 2006)
New Revision: 3002

Added:
   gnunet-qt/pixmaps/connected.png
   gnunet-qt/pixmaps/error.png
   gnunet-qt/pixmaps/gnunet-gtk-general.png
   gnunet-qt/pixmaps/not-connected.png
   gnunet-qt/pixmaps/start.png
   gnunet-qt/src/plugins/general/
   gnunet-qt/src/plugins/general/checkDaemonThread.cc
   gnunet-qt/src/plugins/general/checkDaemonThread.h
   gnunet-qt/src/plugins/general/general.cc
   gnunet-qt/src/plugins/general/general.h
   gnunet-qt/src/plugins/general/general.pro.in
   gnunet-qt/src/plugins/general/general.ui
   gnunet-qt/src/plugins/general/startStopThread.cc
   gnunet-qt/src/plugins/general/startStopThread.h
Modified:
   gnunet-qt/configure.ac
   gnunet-qt/pixmaps/pixmaps.qrc
   gnunet-qt/src/plugins/plugins.pro.in
Log:
add gnunetd status plugin ("General" tab)

Modified: gnunet-qt/configure.ac
===================================================================
--- gnunet-qt/configure.ac      2006-06-10 11:11:42 UTC (rev 3001)
+++ gnunet-qt/configure.ac      2006-06-10 13:02:39 UTC (rev 3002)
@@ -123,6 +123,7 @@
 src/core/core.pro
 src/plugins/plugins.pro
 src/plugins/about/about.pro
+src/plugins/general/general.pro
 ])
 
 

Added: gnunet-qt/pixmaps/connected.png
===================================================================
(Binary files differ)


Property changes on: gnunet-qt/pixmaps/connected.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: gnunet-qt/pixmaps/error.png
===================================================================
(Binary files differ)


Property changes on: gnunet-qt/pixmaps/error.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: gnunet-qt/pixmaps/gnunet-gtk-general.png
===================================================================
(Binary files differ)


Property changes on: gnunet-qt/pixmaps/gnunet-gtk-general.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: gnunet-qt/pixmaps/not-connected.png
===================================================================
(Binary files differ)


Property changes on: gnunet-qt/pixmaps/not-connected.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: gnunet-qt/pixmaps/pixmaps.qrc
===================================================================
--- gnunet-qt/pixmaps/pixmaps.qrc       2006-06-10 11:11:42 UTC (rev 3001)
+++ gnunet-qt/pixmaps/pixmaps.qrc       2006-06-10 13:02:39 UTC (rev 3002)
@@ -1,7 +1,13 @@
 <RCC>
     <qresource prefix="/pixmaps" >
+        <file>clock.png</file>
+        <file>connected.png</file>
+        <file>error.png</file>
+        <file>gnunet-gtk-general.png</file>
         <file>gnunet-gtk-welcome.png</file>
         <file>gnunet-logo-small.png</file>
         <file>gnunet-qt-logo.png</file>
+        <file>not-connected.png</file>
+        <file>start.png</file>
     </qresource>
 </RCC>

Added: gnunet-qt/pixmaps/start.png
===================================================================
(Binary files differ)


Property changes on: gnunet-qt/pixmaps/start.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: gnunet-qt/src/plugins/general/checkDaemonThread.cc
===================================================================
--- gnunet-qt/src/plugins/general/checkDaemonThread.cc  2006-06-10 11:11:42 UTC 
(rev 3001)
+++ gnunet-qt/src/plugins/general/checkDaemonThread.cc  2006-06-10 13:02:39 UTC 
(rev 3002)
@@ -0,0 +1,94 @@
+/*
+     This file is part of gnunet-qt.
+     (C) 2006 Nils Durner (and other contributing authors)
+
+     gnunet-qt 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, or (at your
+     option) any later version.
+
+     gnunet-qt 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 GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/plugins/general/checkDaemonThread.cc
+ * @brief Thread to check whether gnunetd is running and what applications are
+ *        loaded
+ * @author Nils Durner
+ */
+
+#include <GNUnet/gnunet_util.h>
+#include <GNUnet/gnunet_getoption_lib.h>
+#include <QStringList>
+
+#include "checkDaemonThread.h"
+
+GCheckDaemonThread::GCheckDaemonThread(QObject *parent) : QThread(parent)
+{
+  checkAppsIn = 1;
+}
+
+GCheckDaemonThread::~GCheckDaemonThread()
+{
+  wait();
+}
+
+void GCheckDaemonThread::run()
+{
+  bool check;
+
+  check = (checkGNUnetDaemonRunning() == YES);
+  if (check)
+  {  
+    checkAppsIn--;
+    if (checkAppsIn == 0)
+    {
+      GGNUnetAppDescs *descs = new GGNUnetAppDescs();
+      GNUNET_TCP_SOCKET *sock = getClientSocket();
+      
+      if (sock)
+      {
+        char *apps = getConfigurationOptionValue(sock, "GNUNETD", 
"APPLICATIONS");
+        QString strApps = QString::fromLocal8Bit(apps);
+        QStringList appList = strApps.split(QRegExp("\\s+"));
+  
+        int count = appList.count();
+        while(count)
+        { 
+          GGNUnetAppDesc appDesc;
+          
+          appDesc.strApp = appList.takeFirst();
+          char *app = appDesc.strApp.toLocal8Bit().data();
+          char *desc = getConfigurationOptionValue(sock, "ABOUT", app);        
+          appDesc.strDesc = QString::fromLocal8Bit(desc);
+          descs->append(appDesc);
+  
+          FREENONNULL(desc);
+  
+          count--;
+        }
+        
+        FREE(apps);
+        releaseClientSocket(sock);
+
+        checkAppsIn = 20; // 5 minutes / 15 seconds = 20 runs
+      }
+      else
+        checkAppsIn = 1;
+      
+      emit applications(descs);      
+    }
+  }
+  
+  emit running(check);
+}
+
+/* end of checkDaemonThread.cc */

Added: gnunet-qt/src/plugins/general/checkDaemonThread.h
===================================================================
--- gnunet-qt/src/plugins/general/checkDaemonThread.h   2006-06-10 11:11:42 UTC 
(rev 3001)
+++ gnunet-qt/src/plugins/general/checkDaemonThread.h   2006-06-10 13:02:39 UTC 
(rev 3002)
@@ -0,0 +1,58 @@
+/*
+     This file is part of gnunet-qt.
+     (C) 2006 Nils Durner (and other contributing authors)
+
+     gnunet-qt 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, or (at your
+     option) any later version.
+
+     gnunet-qt 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 GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/plugins/general/checkDaemonThread.h
+ * @brief Thread to check whether gnunetd is running and what applications are
+ *        loaded
+ * @author Nils Durner
+ */
+
+#ifndef CHECKDAEMONTHREAD_H_
+#define CHECKDAEMONTHREAD_H_
+
+#include <QString>
+#include <QThread>
+#include <QList>
+
+typedef struct
+{
+  QString strApp, strDesc;
+} GGNUnetAppDesc;
+
+typedef QList<GGNUnetAppDesc> GGNUnetAppDescs;
+
+class GCheckDaemonThread : public QThread
+{
+  Q_OBJECT
+public:
+  GCheckDaemonThread(QObject *parent = NULL);
+  ~GCheckDaemonThread();
+  void run();
+  
+  int checkAppsIn;
+signals:
+  void running(bool isRunning);
+  void applications(GGNUnetAppDescs *apps);
+};
+
+#endif /*CHECKDAEMONTHREAD_H_*/
+
+/* end of checkDaemonThread.h */

Added: gnunet-qt/src/plugins/general/general.cc
===================================================================
--- gnunet-qt/src/plugins/general/general.cc    2006-06-10 11:11:42 UTC (rev 
3001)
+++ gnunet-qt/src/plugins/general/general.cc    2006-06-10 13:02:39 UTC (rev 
3002)
@@ -0,0 +1,184 @@
+/*
+     This file is part of gnunet-qt.
+     (C) 2006 Nils Durner (and other contributing authors)
+
+     gnunet-qt 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, or (at your
+     option) any later version.
+
+     gnunet-qt 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 GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/plugins/about/general.cc
+ * @brief gnunet-qt's general tab
+ * @author Nils Durner
+ */
+
+#include <QPicture>
+
+#include <QStringList>
+#include "general.h"
+
+GGeneralPlugin::GGeneralPlugin() : GPlugin()
+{
+  setupUi(this);
+
+  QStringList headerList;
+  headerList << tr("Application") << tr("Description");
+  treeApps->setHeaderLabels(headerList);
+
+  connect(pbStartStop, SIGNAL(clicked(bool)), SLOT(startStopDaemon(bool)));
+  connect(&startStopThread, SIGNAL(finished(bool)), this, 
SLOT(startStopDone(bool)));
+  connect(&timer, SIGNAL(timeout()), this, SLOT(checkDaemon()));
+  connect(&checkDaemonThread, SIGNAL(running(bool)), this, 
SLOT(running(bool)));
+  connect(&checkDaemonThread, SIGNAL(applications(GGNUnetAppDescs *)), this,
+    SLOT(applications(GGNUnetAppDescs *)));
+  connect(&checkDaemonThread, SIGNAL(finished()), this, 
SLOT(checkDaemonDone()));
+
+  pbStartStop->setEnabled(false);
+  runs = 0;
+  isRunning = pending = false;
+
+  timer.setSingleShot(true);
+  timer.start(0);
+}
+
+void GGeneralPlugin::startStopDaemon(bool unused)
+{
+  pbStartStop->setEnabled(false);
+  startStopThread.start(!isRunning);
+}
+
+void GGeneralPlugin::updateUi()
+{
+  QPixmap *pic = new QPixmap();
+  
+  if (pending)
+    return;
+  
+  if (isRunning)
+  {
+    pbStartStop->setText(tr("Stop process"));
+    lblProcessStatus->setText(tr("Server background process is running"));
+    pic->load(":/pixmaps/connected.png");
+  }
+  else
+  {
+    pbStartStop->setText(tr("Start process"));
+    lblProcessStatus->setText(tr("Server background process is not running"));
+    pic->load(":/pixmaps/not-connected.png");
+  }
+
+  lblProcessIcon->setPixmap(*pic);
+  pbStartStop->setEnabled(true);
+}
+
+void GGeneralPlugin::startStopDone(bool success)
+{
+  QString strStatus;
+  QPixmap *icon = new QPixmap();
+  
+  if (success)
+  {
+    if (isRunning)
+      strStatus = tr("Terminating server...");
+    else
+      strStatus = tr("Launching server...");
+    
+    icon->load(":/pixmaps/clock.png");
+    pbStartStop->setEnabled(false);
+
+    pending = true;
+    timer.setInterval(5000);
+  }
+  else
+  {
+    if (isRunning)
+      strStatus = tr("Terminating server failed");
+    else
+      strStatus = tr("Launching server failed");
+      
+    icon->load(":/pixmaps/error.png");
+  }
+      
+  emit setStatusText(icon, strStatus);  
+}
+
+void GGeneralPlugin::applications(GGNUnetAppDescs *apps)
+{
+  int count = apps->count();
+  QTreeWidgetItem *item;
+  
+  treeApps->clear();
+  while(count)
+  {
+    GGNUnetAppDesc desc = apps->takeFirst();
+    item = new QTreeWidgetItem();
+    
+    item->setText(0, desc.strApp);
+    item->setText(1, desc.strDesc);
+    treeApps->addTopLevelItem(item);
+    
+    count--;
+  }
+  
+  delete apps;
+}
+
+void GGeneralPlugin::checkDaemon()
+{
+  checkDaemonThread.start();
+}
+
+void GGeneralPlugin::checkDaemonDone()
+{
+  runs = 0;
+  timer.start(pending ? 5000 : 15000);
+}
+
+void GGeneralPlugin::running(bool isRunning)
+{
+  if (this->isRunning != isRunning || timer.interval() == 0)
+  {
+    if (pending)
+    {
+      QPixmap icon;
+      
+      pending = false;
+      icon.load(":/pixmaps/gnunet-logo-small.png");
+      
+      emit setStatusText(&icon, isRunning ? tr("Server launched") :
+        tr("Server terminated"));
+    }
+    
+    this->isRunning = isRunning;
+    updateUi();
+  }
+}
+
+extern "C"
+{
+  
+  GNUNETQT_API GPlugin *init_plugin()
+  {
+    return new GGeneralPlugin;
+  }
+  
+  GNUNETQT_API void shutdown_plugin(GPlugin *plugin)
+  {
+    delete (GGeneralPlugin *) plugin;
+  }
+  
+} // extern "C"
+
+/* end of general.cc */

Added: gnunet-qt/src/plugins/general/general.h
===================================================================
--- gnunet-qt/src/plugins/general/general.h     2006-06-10 11:11:42 UTC (rev 
3001)
+++ gnunet-qt/src/plugins/general/general.h     2006-06-10 13:02:39 UTC (rev 
3002)
@@ -0,0 +1,62 @@
+/*
+     This file is part of gnunet-qt.
+     (C) 2006 Nils Durner (and other contributing authors)
+
+     gnunet-qt 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, or (at your
+     option) any later version.
+
+     gnunet-qt 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 GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/plugins/general/general.h
+ * @brief gnunet-qt's general tab
+ * @author Nils Durner
+ */
+
+#ifndef GENERAL_H_
+#define GENERAL_H_
+
+#include <QTimer>
+
+#include "ui_general.h"
+#include "gnunet_qt_common.h"
+#include "startStopThread.h"
+#include "checkDaemonThread.h"
+
+class GGeneralPlugin : public GPlugin, public Ui::WndGeneral
+{
+  Q_OBJECT
+
+public:
+  GGeneralPlugin();
+protected:
+  void updateUi();
+  
+  GStartStopThread startStopThread;
+  GCheckDaemonThread checkDaemonThread;
+  QTimer timer;
+  int runs;
+  bool isRunning, pending;
+protected slots:
+  void startStopDaemon(bool unused);
+  void startStopDone(bool success);
+  void applications(GGNUnetAppDescs *apps);
+  void running(bool isRunning);
+  void checkDaemon();
+  void checkDaemonDone();
+};
+
+#endif /*GENERAL_H_*/
+
+/* end of general.h */

Added: gnunet-qt/src/plugins/general/general.pro.in
===================================================================
--- gnunet-qt/src/plugins/general/general.pro.in        2006-06-10 11:11:42 UTC 
(rev 3001)
+++ gnunet-qt/src/plugins/general/general.pro.in        2006-06-10 13:02:39 UTC 
(rev 3002)
@@ -0,0 +1,13 @@
+TEMPLATE = lib
+TARGET = libgnunetqtmodule_general
+INCLUDEPATH = ../../include .
+DLLDESTDIR = .
+LIBS = -lgnunetutil -lgnunetgetoption_api -L../../common -lgnunetqt_common
+QMAKE_LFLAGS += -shared @LDFLAGS@
+QMAKE_LIBS += @LIBS@
+QMAKE_CFLAGS += @CPPFLAGS@
+QMAKE_CXXFLAGS += @CXXFLAGS@
+
+SOURCES = general.cc startStopThread.cc checkDaemonThread.cc
+HEADERS = general.h startStopThread.h checkDaemonThread.h 
../../include/gnunet_qt_common.h
+FORMS = general.ui
\ No newline at end of file

Added: gnunet-qt/src/plugins/general/general.ui
===================================================================
--- gnunet-qt/src/plugins/general/general.ui    2006-06-10 11:11:42 UTC (rev 
3001)
+++ gnunet-qt/src/plugins/general/general.ui    2006-06-10 13:02:39 UTC (rev 
3002)
@@ -0,0 +1,183 @@
+<ui version="4.0" >
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>WndGeneral</class>
+ <widget class="QWidget" name="WndGeneral" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>558</width>
+    <height>454</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>General</string>
+  </property>
+  <property name="windowIcon" >
+   <iconset resource="../../../pixmaps/pixmaps.qrc" 
>:/pixmaps/gnunet-gtk-general.png</iconset>
+  </property>
+  <layout class="QVBoxLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item>
+    <widget class="QGroupBox" name="boxGnunetd" >
+     <property name="sizePolicy" >
+      <sizepolicy>
+       <hsizetype>7</hsizetype>
+       <vsizetype>1</vsizetype>
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="title" >
+      <string>Server process</string>
+     </property>
+     <property name="alignment" >
+      <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+     </property>
+     <property name="flat" >
+      <bool>false</bool>
+     </property>
+     <property name="checkable" >
+      <bool>false</bool>
+     </property>
+     <layout class="QHBoxLayout" >
+      <property name="margin" >
+       <number>9</number>
+      </property>
+      <property name="spacing" >
+       <number>6</number>
+      </property>
+      <item>
+       <layout class="QHBoxLayout" >
+        <property name="margin" >
+         <number>0</number>
+        </property>
+        <property name="spacing" >
+         <number>6</number>
+        </property>
+        <item>
+         <widget class="QLabel" name="lblProcessIcon" >
+          <property name="sizePolicy" >
+           <sizepolicy>
+            <hsizetype>1</hsizetype>
+            <vsizetype>1</vsizetype>
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="maximumSize" >
+           <size>
+            <width>16</width>
+            <height>16777215</height>
+           </size>
+          </property>
+          <property name="text" >
+           <string/>
+          </property>
+          <property name="pixmap" >
+           <pixmap resource="../../../pixmaps/pixmaps.qrc" 
>:/pixmaps/not-connected.png</pixmap>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="lblProcessStatus" >
+          <property name="text" >
+           <string>Server background process is not running</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer>
+          <property name="orientation" >
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" >
+           <size>
+            <width>40</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+        <item>
+         <widget class="QPushButton" name="pbStartStop" >
+          <property name="sizePolicy" >
+           <sizepolicy>
+            <hsizetype>1</hsizetype>
+            <vsizetype>0</vsizetype>
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text" >
+           <string>Start process</string>
+          </property>
+          <property name="icon" >
+           <iconset resource="../../../pixmaps/pixmaps.qrc" 
>:/pixmaps/start.png</iconset>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox" >
+     <property name="title" >
+      <string>Running applications</string>
+     </property>
+     <layout class="QVBoxLayout" >
+      <property name="margin" >
+       <number>9</number>
+      </property>
+      <property name="spacing" >
+       <number>6</number>
+      </property>
+      <item>
+       <widget class="QTreeWidget" name="treeApps" >
+        <property name="alternatingRowColors" >
+         <bool>true</bool>
+        </property>
+        <property name="selectionMode" >
+         <enum>QAbstractItemView::NoSelection</enum>
+        </property>
+        <property name="rootIsDecorated" >
+         <bool>false</bool>
+        </property>
+        <property name="itemsExpandable" >
+         <bool>false</bool>
+        </property>
+        <property name="columnCount" >
+         <number>2</number>
+        </property>
+        <column>
+         <property name="text" >
+          <string>0</string>
+         </property>
+        </column>
+        <column>
+         <property name="text" >
+          <string>1</string>
+         </property>
+        </column>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <resources>
+  <include location="../../../pixmaps/pixmaps.qrc" />
+ </resources>
+ <connections/>
+</ui>

Added: gnunet-qt/src/plugins/general/startStopThread.cc
===================================================================
--- gnunet-qt/src/plugins/general/startStopThread.cc    2006-06-10 11:11:42 UTC 
(rev 3001)
+++ gnunet-qt/src/plugins/general/startStopThread.cc    2006-06-10 13:02:39 UTC 
(rev 3002)
@@ -0,0 +1,58 @@
+/*
+     This file is part of gnunet-qt.
+     (C) 2006 Nils Durner (and other contributing authors)
+
+     gnunet-qt 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, or (at your
+     option) any later version.
+
+     gnunet-qt 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 GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/plugins/general/startStopThread.cc
+ * @brief Thread to start or stop gnunetd without blocking the UI
+ * @author Nils Durner
+ */
+
+#include <GNUnet/gnunet_util.h>
+
+#include "startStopThread.h"
+
+GStartStopThread::GStartStopThread(QObject *parent) : QThread(parent)
+{
+}
+
+GStartStopThread::~GStartStopThread()
+{
+  wait();
+}
+
+void GStartStopThread::start(bool doStart)
+{
+  this->doStart = doStart;
+  QThread::start();
+}
+
+void GStartStopThread::run()
+{
+  bool ret;
+  
+  if (doStart)
+    ret = startGNUnetDaemon(YES) != SYSERR;
+  else
+    ret = stopGNUnetDaemon() != SYSERR;
+    
+  emit finished(ret);
+}
+
+/* end of startStopThread.cc */

Added: gnunet-qt/src/plugins/general/startStopThread.h
===================================================================
--- gnunet-qt/src/plugins/general/startStopThread.h     2006-06-10 11:11:42 UTC 
(rev 3001)
+++ gnunet-qt/src/plugins/general/startStopThread.h     2006-06-10 13:02:39 UTC 
(rev 3002)
@@ -0,0 +1,49 @@
+/*
+     This file is part of gnunet-qt.
+     (C) 2006 Nils Durner (and other contributing authors)
+
+     gnunet-qt 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, or (at your
+     option) any later version.
+
+     gnunet-qt 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 GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/plugins/general/startStopThread.h
+ * @brief Thread to start or stop gnunetd without blocking the UI
+ * @author Nils Durner
+ */
+
+#ifndef STARTSTOPTHREAD_H_
+#define STARTSTOPTHREAD_H_
+
+#include <QThread>
+
+class GStartStopThread : protected QThread
+{
+  Q_OBJECT
+public:
+  GStartStopThread(QObject *parent = NULL);
+  ~GStartStopThread();
+  void start(bool doStart);
+  void run();
+signals:
+  void finished(bool success);
+protected:
+  bool doStart;
+  int numRun;
+};
+
+#endif /*STARTSTOPTHREAD_H_*/
+
+/* end of startStopThread.h */

Modified: gnunet-qt/src/plugins/plugins.pro.in
===================================================================
--- gnunet-qt/src/plugins/plugins.pro.in        2006-06-10 11:11:42 UTC (rev 
3001)
+++ gnunet-qt/src/plugins/plugins.pro.in        2006-06-10 13:02:39 UTC (rev 
3002)
@@ -1,2 +1,2 @@
 TEMPLATE = subdirs
-SUBDIRS = about
\ No newline at end of file
+SUBDIRS = about general
\ No newline at end of file





reply via email to

[Prev in Thread] Current Thread [Next in Thread]