gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3115 - in gnunet-qt/src: common include plugins/general


From: durner
Subject: [GNUnet-SVN] r3115 - in gnunet-qt/src: common include plugins/general
Date: Thu, 13 Jul 2006 09:42:04 -0700 (PDT)

Author: durner
Date: 2006-07-13 09:41:59 -0700 (Thu, 13 Jul 2006)
New Revision: 3115

Modified:
   gnunet-qt/src/common/gstring.cc
   gnunet-qt/src/include/gnunet_qt_common.h
   gnunet-qt/src/plugins/general/checkDaemonThread.cc
   gnunet-qt/src/plugins/general/checkDaemonThread.h
Log:
don't use invalid buffer

Modified: gnunet-qt/src/common/gstring.cc
===================================================================
--- gnunet-qt/src/common/gstring.cc     2006-07-09 20:58:59 UTC (rev 3114)
+++ gnunet-qt/src/common/gstring.cc     2006-07-13 16:41:59 UTC (rev 3115)
@@ -24,8 +24,49 @@
  * @author Nils Durner
  */
 
+#include <QByteArray>
+#include <string.h>
+
 #include "gnunet_qt_common.h"
 
+GString::GString(const char *str) : QString(str)
+{
+  cstr = NULL;
+}
+
+GString::GString() : QString()
+{
+  cstr = NULL;
+}
+
+GString::~GString()
+{
+  if (cstr)
+    ::free(cstr);
+}
+
+GString &GString::operator=(GString &src)
+{
+  ((QString) (*this)) = (QString) src;
+}
+
+GString &GString::operator=(QString &src)
+{
+  QString::operator=(src);
+  return *this;
+}
+
+GString &GString::operator=(QString src)
+{
+  QString::operator=(src);
+  return *this;
+}
+
+GString::GString(QString &src) : QString(src)
+{
+  cstr = NULL;
+}
+
 /**
  * @brief Capitalize every word in this string
  */
@@ -57,4 +98,11 @@
   }
 }
 
+char *GString::toCString()
+{
+  QByteArray bytes = toLocal8Bit();
+  
+  return cstr = strdup(bytes.data());
+}
+
 /* end of gstring.cc */

Modified: gnunet-qt/src/include/gnunet_qt_common.h
===================================================================
--- gnunet-qt/src/include/gnunet_qt_common.h    2006-07-09 20:58:59 UTC (rev 
3114)
+++ gnunet-qt/src/include/gnunet_qt_common.h    2006-07-13 16:41:59 UTC (rev 
3115)
@@ -72,12 +72,25 @@
 class GString : public QString
 {
 public:
-  GString(const char *str) : QString(str) {};
+  GString();
+  GString(const char *str);
+  GString(QString &src);
+  ~GString();
+  GString &operator=(GString &src);
+  GString &operator=(QString src);
+  GString &operator=(QString &src);
 
   /**
    * @brief Capitalize every word in this string
    */
   void proper();
+  
+ /**
+  * @brief Return the content as C sting
+  */
+ char *toCString();
+protected:
+  char *cstr;
 };
 
 typedef GPlugin *(*InitPlugin) ();

Modified: gnunet-qt/src/plugins/general/checkDaemonThread.cc
===================================================================
--- gnunet-qt/src/plugins/general/checkDaemonThread.cc  2006-07-09 20:58:59 UTC 
(rev 3114)
+++ gnunet-qt/src/plugins/general/checkDaemonThread.cc  2006-07-13 16:41:59 UTC 
(rev 3115)
@@ -31,6 +31,13 @@
 
 #include "checkDaemonThread.h"
 
+
+GGNUnetAppDesc &GGNUnetAppDesc::operator=(GGNUnetAppDesc src)
+{
+  strApp = src.strApp;
+  strDesc = src.strDesc;
+}
+
 GCheckDaemonThread::GCheckDaemonThread(QObject *parent) : QThread(parent)
 {
   checkAppsIn = 1;
@@ -57,7 +64,7 @@
       if (sock)
       {
         char *apps = getConfigurationOptionValue(sock, "GNUNETD", 
"APPLICATIONS");
-        QString strApps = QString::fromLocal8Bit(apps);
+        QString strApps = GString::fromLocal8Bit(apps);
         QStringList appList = strApps.split(QRegExp("\\s+"));
   
         int count = appList.count();
@@ -66,9 +73,9 @@
           GGNUnetAppDesc appDesc;
           
           appDesc.strApp = appList.takeFirst();
-          char *app = appDesc.strApp.toLocal8Bit().data();
+          char *app = appDesc.strApp.toCString();
           char *desc = getConfigurationOptionValue(sock, "ABOUT", app);        
-          appDesc.strDesc = QString::fromLocal8Bit(desc);
+          appDesc.strDesc = GString::fromLocal8Bit(desc);
           descs->append(appDesc);
   
           FREENONNULL(desc);

Modified: gnunet-qt/src/plugins/general/checkDaemonThread.h
===================================================================
--- gnunet-qt/src/plugins/general/checkDaemonThread.h   2006-07-09 20:58:59 UTC 
(rev 3114)
+++ gnunet-qt/src/plugins/general/checkDaemonThread.h   2006-07-13 16:41:59 UTC 
(rev 3115)
@@ -32,11 +32,18 @@
 #include <QThread>
 #include <QList>
 
-typedef struct
+#include "gnunet_qt_common.h"
+
+class GGNUnetAppDesc
 {
-  QString strApp, strDesc;
-} GGNUnetAppDesc;
+public:
+  GGNUnetAppDesc(){};
+  GGNUnetAppDesc &operator=(GGNUnetAppDesc src);
+  virtual ~GGNUnetAppDesc(){};
 
+  GString strApp, strDesc;
+};
+
 typedef QList<GGNUnetAppDesc> GGNUnetAppDescs;
 
 class GCheckDaemonThread : public QThread





reply via email to

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