gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r8493 - in gnunet-qt/src/plugins: general stats


From: gnunet
Subject: [GNUnet-SVN] r8493 - in gnunet-qt/src/plugins: general stats
Date: Mon, 8 Jun 2009 13:13:08 -0600

Author: durner
Date: 2009-06-08 13:13:08 -0600 (Mon, 08 Jun 2009)
New Revision: 8493

Modified:
   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/stats/statsThread.cc
Log:
fix QTimer warnings

Modified: gnunet-qt/src/plugins/general/checkDaemonThread.cc
===================================================================
--- gnunet-qt/src/plugins/general/checkDaemonThread.cc  2009-06-07 19:40:59 UTC 
(rev 8492)
+++ gnunet-qt/src/plugins/general/checkDaemonThread.cc  2009-06-08 19:13:08 UTC 
(rev 8493)
@@ -33,10 +33,10 @@
 
 
 GGNUnetAppDesc &GGNUnetAppDesc::operator=(const GGNUnetAppDesc &src)
-{ 
+{
   strApp = src.strApp;
   strDesc = src.strDesc;
-  
+
   return *this;
 }
 
@@ -52,6 +52,7 @@
   this->config = config;
   this->errorContext = errorContext;
   checkAppsIn = 1;
+  stopRequested = false;
 }
 
 GCheckDaemonThread::~GCheckDaemonThread()
@@ -63,55 +64,69 @@
 {
   bool check;
 
-  check = (GNUNET_test_daemon_running(errorContext, config) == GNUNET_YES);
-  if (check)
-  {  
-    checkAppsIn--;
-    if (checkAppsIn == 0)
+  while (!stopRequested)
+  {
+    GNUNET_CronTime sleepEnd;
+
+    check = (GNUNET_test_daemon_running(errorContext, config) == GNUNET_YES);
+    if (check)
     {
-      GGNUnetAppDescs *descs = new GGNUnetAppDescs();
-      GNUNET_ClientServerConnection *sock = 
GNUNET_client_connection_create(errorContext,
-        config);
-      
-      if (sock)
+      checkAppsIn--;
+      if (checkAppsIn == 0)
       {
-        char *apps = GNUNET_get_daemon_configuration_value(sock, "GNUNETD", 
"APPLICATIONS");
-        
-        if (apps)
+        GGNUnetAppDescs *descs = new GGNUnetAppDescs();
+        GNUNET_ClientServerConnection *sock = 
GNUNET_client_connection_create(errorContext,
+          config);
+
+        if (sock)
         {
-          QString strApps = GString::fromLocal8Bit(apps);
-          QStringList appList = strApps.split(QRegExp("\\s+"));
-    
-          int count = appList.count();
-          while(count)
-          { 
-            GGNUnetAppDesc appDesc;
-            
-            appDesc.strApp = appList.takeFirst();
-            char *app = appDesc.strApp.toCString();
-            char *desc = GNUNET_get_daemon_configuration_value(sock, "ABOUT", 
app);
-            appDesc.strDesc = GString::fromLocal8Bit(desc);
-            descs->append(appDesc);
-    
-            GNUNET_free_non_null(desc);
-    
-            count--;
+          char *apps = GNUNET_get_daemon_configuration_value(sock, "GNUNETD", 
"APPLICATIONS");
+
+          if (apps)
+          {
+            QString strApps = GString::fromLocal8Bit(apps);
+            QStringList appList = strApps.split(QRegExp("\\s+"));
+
+            int count = appList.count();
+            while(count)
+            {
+              GGNUnetAppDesc appDesc;
+
+              appDesc.strApp = appList.takeFirst();
+              char *app = appDesc.strApp.toCString();
+              char *desc = GNUNET_get_daemon_configuration_value(sock, 
"ABOUT", app);
+              appDesc.strDesc = GString::fromLocal8Bit(desc);
+              descs->append(appDesc);
+
+              GNUNET_free_non_null(desc);
+
+              count--;
+            }
+
+            GNUNET_free(apps);
           }
-          
-          GNUNET_free(apps);
+          GNUNET_client_connection_destroy(sock);
+
+          checkAppsIn = 20; // 5 minutes / 15 seconds = 20 runs
         }
-        GNUNET_client_connection_destroy(sock);
+        else
+          checkAppsIn = 1;
 
-        checkAppsIn = 20; // 5 minutes / 15 seconds = 20 runs
+        emit applications(descs);
       }
-      else
-        checkAppsIn = 1;
-      
-      emit applications(descs);      
     }
+
+    emit running(check);
+
+    sleepEnd = GNUNET_get_time() + 5 * GNUNET_CRON_SECONDS;
+    while (!stopRequested && sleepEnd < GNUNET_get_time())
+      usleep(100);
   }
-  
-  emit running(check);
 }
 
+void GCheckDaemonThread::stop()
+{
+  stopRequested = true;
+}
+
 /* end of checkDaemonThread.cc */

Modified: gnunet-qt/src/plugins/general/checkDaemonThread.h
===================================================================
--- gnunet-qt/src/plugins/general/checkDaemonThread.h   2009-06-07 19:40:59 UTC 
(rev 8492)
+++ gnunet-qt/src/plugins/general/checkDaemonThread.h   2009-06-08 19:13:08 UTC 
(rev 8493)
@@ -41,7 +41,7 @@
   GGNUnetAppDesc(const GGNUnetAppDesc &src);
   GGNUnetAppDesc &operator=(const GGNUnetAppDesc &src);
   virtual ~GGNUnetAppDesc(){};
-  
+
   GString strApp, strDesc;
 };
 
@@ -55,8 +55,10 @@
     struct GNUNET_GE_Context *errorContext, QObject *parent = NULL);
   ~GCheckDaemonThread();
   void run();
-  
+  void stop();
+
   int checkAppsIn;
+  bool stopRequested;
 protected:
   struct GNUNET_GC_Configuration *config;
   struct GNUNET_GE_Context *errorContext;

Modified: gnunet-qt/src/plugins/general/general.cc
===================================================================
--- gnunet-qt/src/plugins/general/general.cc    2009-06-07 19:40:59 UTC (rev 
8492)
+++ gnunet-qt/src/plugins/general/general.cc    2009-06-08 19:13:08 UTC (rev 
8493)
@@ -45,7 +45,6 @@
 
   connect(pbStartStop, SIGNAL(clicked(bool)), SLOT(startStopDaemon()));
   connect(startStopThread, SIGNAL(finished(bool, QString)), this, 
SLOT(startStopDone(bool, QString)));
-  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 *)));
@@ -54,9 +53,6 @@
   pbStartStop->setEnabled(false);
   runs = 0;
   isRunning = pending = false;
-
-  timer.setSingleShot(true);
-  timer.start(0);
 }
 
 GGeneralPlugin::~GGeneralPlugin()
@@ -113,7 +109,6 @@
     pbStartStop->setEnabled(false);
 
     pending = true;
-    timer.setInterval(5000);
   }
   else
   {
@@ -157,12 +152,11 @@
 void GGeneralPlugin::checkDaemonDone()
 {
   runs = 0;
-  timer.start(pending ? 5000 : 15000);
 }
 
 void GGeneralPlugin::running(bool isRunning)
 {
-  if (this->isRunning != isRunning || timer.interval() == 0)
+  if (this->isRunning != isRunning)
   {
     if (pending)
     {

Modified: gnunet-qt/src/plugins/general/general.h
===================================================================
--- gnunet-qt/src/plugins/general/general.h     2009-06-07 19:40:59 UTC (rev 
8492)
+++ gnunet-qt/src/plugins/general/general.h     2009-06-08 19:13:08 UTC (rev 
8493)
@@ -50,10 +50,9 @@
 
 protected:
   void updateUi();
-  
+
   GStartStopThread *startStopThread;
   GCheckDaemonThread *checkDaemonThread;
-  QTimer timer;
   int runs;
   bool isRunning, pending;
 protected slots:

Modified: gnunet-qt/src/plugins/stats/statsThread.cc
===================================================================
--- gnunet-qt/src/plugins/stats/statsThread.cc  2009-06-07 19:40:59 UTC (rev 
8492)
+++ gnunet-qt/src/plugins/stats/statsThread.cc  2009-06-08 19:13:08 UTC (rev 
8493)
@@ -35,7 +35,7 @@
 {
   this->config = config;
   this->errorContext = errorContext;
-  
+
   stopSignalled = false;
 }
 
@@ -47,14 +47,14 @@
 bool GStatsThread::processStat(const char *name, unsigned long long value)
 {
    emit stat(QString::fromUtf8(name), value);
-   
+
    return !stopSignalled;
 }
 
 void GStatsThread::run()
 {
   int res;
-  QTime timer;
+  GNUNET_CronTime end;
   struct GNUNET_ClientServerConnection *sock;
 
   sock = GNUNET_client_connection_create(errorContext, config);
@@ -67,19 +67,19 @@
 
   while (! stopSignalled)
   {
-    timer.start();
+    end = GNUNET_get_time() + 1 * GNUNET_CRON_SECONDS;
     res = GNUNET_STATS_get_statistics(errorContext,
             sock,
-            &acquireStatistics, 
+            &acquireStatistics,
             this);
     if (res != GNUNET_OK)
       GNUNET_GE_LOG(errorContext, (GNUNET_GE_KIND) (GNUNET_GE_ERROR | 
GNUNET_GE_USER | GNUNET_GE_IMMEDIATE),
         qPrintable(tr("Error reading information from background process 
gnunetd.")));
 
-    while (timer.elapsed() < 1000 && !stopSignalled)
+    while (GNUNET_get_time() < end && !stopSignalled)
       msleep(100);
   }
-  
+
   GNUNET_client_connection_destroy(sock);
 }
 





reply via email to

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