[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4299 - in gnunet-qt/src: common core include plugins/about
From: |
durner |
Subject: |
[GNUnet-SVN] r4299 - in gnunet-qt/src: common core include plugins/about plugins/fs plugins/general |
Date: |
Fri, 12 Jan 2007 12:57:45 -0800 (PST) |
Author: durner
Date: 2007-01-12 12:57:27 -0800 (Fri, 12 Jan 2007)
New Revision: 4299
Added:
gnunet-qt/src/common/stateDB.cc
gnunet-qt/src/common/stateDB.h
Modified:
gnunet-qt/src/common/common.pro.in
gnunet-qt/src/common/pluginLoader.cc
gnunet-qt/src/core/core.pro.in
gnunet-qt/src/core/main.cc
gnunet-qt/src/core/main.h
gnunet-qt/src/include/gnunet_qt_common.h
gnunet-qt/src/plugins/about/about.cc
gnunet-qt/src/plugins/fs/fs-search.cc
gnunet-qt/src/plugins/fs/fs-search.h
gnunet-qt/src/plugins/fs/fs.cc
gnunet-qt/src/plugins/fs/fs.h
gnunet-qt/src/plugins/fs/searchModel.cc
gnunet-qt/src/plugins/fs/searchModel.h
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/startStopThread.cc
gnunet-qt/src/plugins/general/startStopThread.h
Log:
make compiling with GNUnet 0.7.1
Modified: gnunet-qt/src/common/common.pro.in
===================================================================
--- gnunet-qt/src/common/common.pro.in 2007-01-12 08:06:17 UTC (rev 4298)
+++ gnunet-qt/src/common/common.pro.in 2007-01-12 20:57:27 UTC (rev 4299)
@@ -8,8 +8,8 @@
INCLUDEPATH = ../include @INCLUDEPATH@
QMAKE_LIBDIR += @LIBPATH@
-target.path = @prefix@/bin
+target.path = @prefix@/lib
INSTALLS += target
-SOURCES = assert.cc pluginLoader.cc gstring.cc
-HEADERS = pluginLoader.h ../include/gnunet_qt_common.h
\ No newline at end of file
+SOURCES = assert.cc pluginLoader.cc gstring.cc stateDB.cc
+HEADERS = pluginLoader.h stateDB.h ../include/gnunet_qt_common.h
\ No newline at end of file
Modified: gnunet-qt/src/common/pluginLoader.cc
===================================================================
--- gnunet-qt/src/common/pluginLoader.cc 2007-01-12 08:06:17 UTC (rev
4298)
+++ gnunet-qt/src/common/pluginLoader.cc 2007-01-12 20:57:27 UTC (rev
4299)
@@ -31,20 +31,23 @@
unloadAll();
}
-GPlugin *GPluginLoader::load(const QString &strName)
+GPlugin *GPluginLoader::load(const QString &strName,
+ struct GC_Configuration *config, struct GE_Context *errorContext)
{
InitPlugin init;
GPluginSpec spec;
-
+
spec.lib = new QLibrary("libgnunetqtmodule_" + strName);
spec.wnd = NULL;
+ // TODO: error handling, see Jean Michault's mail
+
if (spec.lib)
{
plugins.append(spec);
init = (InitPlugin) spec.lib->resolve("init_plugin");
if (init)
- spec.wnd = init();
+ spec.wnd = init(config, errorContext);
}
return spec.wnd;
Added: gnunet-qt/src/common/stateDB.cc
===================================================================
--- gnunet-qt/src/common/stateDB.cc 2007-01-12 08:06:17 UTC (rev 4298)
+++ gnunet-qt/src/common/stateDB.cc 2007-01-12 20:57:27 UTC (rev 4299)
@@ -0,0 +1,64 @@
+/*
+ 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/common/stateDB.cc
+ * @brief read and write internal data from/to disk
+ * @author Nils Durner
+ */
+
+#include <QDir>
+#include <QFile>
+
+#include "stateDB.h"
+
+GUserStateDB::GUserStateDB(const QString &strDir, QObject *parent) :
QObject(parent)
+{
+ QDir theDir;
+
+ this->strDir = strDir;
+ theDir.mkpath(strDir);
+}
+
+GUserStateDB::~GUserStateDB()
+{
+}
+
+bool GUserStateDB::get(const QString &strKey, QByteArray &data)
+{
+ QFile theFile(strDir + QDir::separator() + strKey);
+ if (theFile.open(QIODevice::WriteOnly))
+ {
+ data = theFile.readAll();
+ return true;
+ }
+
+ return false;
+}
+
+bool GUserStateDB::set(const QString &strKey, const QByteArray &data)
+{
+ QFile theFile(strDir + QDir::separator() + strKey);
+ if (theFile.open(QIODevice::WriteOnly))
+ return theFile.write(data) == data.length();
+
+ return false;
+}
+
Added: gnunet-qt/src/common/stateDB.h
===================================================================
--- gnunet-qt/src/common/stateDB.h 2007-01-12 08:06:17 UTC (rev 4298)
+++ gnunet-qt/src/common/stateDB.h 2007-01-12 20:57:27 UTC (rev 4299)
@@ -0,0 +1,44 @@
+/*
+ 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/common/stateDB.h
+ * @brief read and write internal data from/to disk
+ * @author Nils Durner
+ */
+
+#ifndef GUSERSTATEDB_H_
+#define GUSERSTATEDB_H_
+
+#include <QObject>
+
+class GUserStateDB : public QObject
+{
+public:
+ GUserStateDB(const QString &strDir, QObject *parent = NULL);
+ virtual ~GUserStateDB();
+
+ bool get(const QString &strKey, QByteArray &data);
+ bool set(const QString &strKey, const QByteArray &data);
+protected:
+ QString strDir;
+};
+
+#endif /*GUSERSTATEDB_H_*/
Modified: gnunet-qt/src/core/core.pro.in
===================================================================
--- gnunet-qt/src/core/core.pro.in 2007-01-12 08:06:17 UTC (rev 4298)
+++ gnunet-qt/src/core/core.pro.in 2007-01-12 20:57:27 UTC (rev 4299)
@@ -5,14 +5,14 @@
DEPENDPATH += .
INCLUDEPATH += ../include @top_builddir@ @INCLUDEPATH@ .
QMAKE_LIBDIR += @LIBPATH@
-LIBS += -L../common/ -lgnunetqt_common -lgnunetutil
+LIBS += -L../common/ -lgnunetqt_common -lgnunetutil -lgnunetutil_boot
target.path = @prefix@/bin
INSTALLS += target
# Input
SOURCES += main.cc wndMain.cc
-HEADERS += wndMain.h
+HEADERS += main.h wndMain.h
FORMS += wndMain.ui
RESOURCES += ../../pixmaps/pixmaps.qrc
Modified: gnunet-qt/src/core/main.cc
===================================================================
--- gnunet-qt/src/core/main.cc 2007-01-12 08:06:17 UTC (rev 4298)
+++ gnunet-qt/src/core/main.cc 2007-01-12 20:57:27 UTC (rev 4299)
@@ -27,23 +27,69 @@
#include "config.h"
#include "main.h"
#include "GNUnet/gnunet_util.h"
+#include "GNUnet/gnunet_util_boot.h"
+#include "GNUnet/gnunet_directories.h"
#include <QObject>
-#include <QSettings>
+#include <QMessageBox>
static GApplication *app;
+static char *cfgFilename = DEFAULT_CLIENT_CONFIG_FILE;
+/**
+ * GNUnet's header #defines COMMAND_LINE_OPTION_XXX as call to gettext_noop.
+ * Since we do not link against gettext, but use Qt, we #define gettext_noop
here
+ */
+#ifndef gettext_noop
+ #define gettext_noop(x) app->tr(x).toStdString().c_str()
+#endif
+
+/**
+ * All gnunet-qt command line options
+ */
+static struct CommandLineOption gnunetqtOptions[] = {
+ COMMAND_LINE_OPTION_CFG_FILE(&cfgFilename), /* -c */
+ COMMAND_LINE_OPTION_HELP(gettext_noop("GNUnet Qt user interface.")), /* -h */
+ COMMAND_LINE_OPTION_HOSTNAME, /* -H */
+ COMMAND_LINE_OPTION_LOGGING, /* -L */
+ COMMAND_LINE_OPTION_VERSION(VERSION), /* -v */
+ COMMAND_LINE_OPTION_VERBOSE,
+ COMMAND_LINE_OPTION_END
+};
+
GApplication::GApplication(int argc, char **argv) : QApplication(argc, argv)
{
+ isInit = false;
}
+GApplication::~GApplication()
+{
+ if (isInit)
+ {
+ isInit = false;
+ GNUNET_fini(ectx, cfg);
+ }
+}
+
+bool GApplication::init(int argc, char * const *argv)
+{
+ if (GNUNET_init(argc, argv, "gnunet-qt [OPTIONS]", &cfgFilename,
+ gnunetqtOptions, &ectx, &cfg) == SYSERR)
+ return false;
+
+ isInit = true;
+ strCfgFile = cfgFilename;
+
+ return true;
+}
+
void GApplication::loadPlugins()
{
int count;
+ char *cfgPlugins;
- QSettings settings(".gnunet/gnunet.conf", QSettings::IniFormat);
- // FIXME: default value
- QStringList plugins =
settings.value("GNUNET-QT/PLUGINS").toString().split(QRegExp("\\s+"));
+ GC_get_configuration_value_string(cfg, "GNUNET-QT", "PLUGINS", "about
general fs", &cfgPlugins);
+ QStringList plugins = QString(cfgPlugins).split(QRegExp("\\s+"));
count = plugins.count();
while(count)
@@ -51,12 +97,14 @@
QWidget *child;
QString strPlugin = plugins.takeFirst();
- child = loader.load(strPlugin);
+ child = loader.load(strPlugin, cfg, ectx);
if (child)
wnd.addApplication(child, child->windowIcon(), child->windowTitle());
count--;
}
+
+ FREE(cfgPlugins);
}
void GApplication::showWindow()
@@ -64,74 +112,25 @@
wnd.show();
}
-/**
- * Parse the options, set the timeout.
- * @param argc the number of options
- * @param argv the option list (including keywords)
- * @return SYSERR if we should exit, OK otherwise
- */
-static int parseOptions(int argc, char ** argv)
+int main(int argc, char * const *argv)
{
- int c;
-
- while (1)
- {
- int option_index = 0;
- static struct GNoption long_options[] =
- {
- LONG_DEFAULT_OPTIONS,
- { 0,0,0,0 }
- };
- c = GNgetopt_long(argc,
- argv,
- "c:hH:L:vd",
- long_options,
- &option_index);
- if (c == -1)
- break; /* No more flags to process */
- if (YES == parseDefaultOptions(c, GNoptarg))
- continue;
- switch(c)
- {
- case 'h':
- // FIXME: standard printhelp() requires gettext()
- //printhelp();
- return SYSERR;
- case 'v':
- printf("gnunet-qt v%s\n",
- VERSION);
- return SYSERR;
- default:
- LOG(LOG_FAILURE,
- QObject::tr("Use --help to get a list of
options.\n").toLocal8Bit().data());
- return SYSERR;
- } /* end of parsing commandline */
- } /* while (1) */
- setConfigurationStringList(&argv[GNoptind],
- argc-GNoptind);
- return OK;
-}
-
-int main(int argc, char **argv)
-{
int ret;
-
- app = new GApplication(argc, argv);
- if (SYSERR == initUtil(argc,
- argv,
- &parseOptions))
- return 0;
+ app = new GApplication(argc, (char **) argv);
- app->loadPlugins();
- app->showWindow();
+ if (app->init(argc, argv))
+ {
+ app->loadPlugins();
+ app->showWindow();
- ret = app->exec();
+ ret = app->exec();
+ }
+ else
+ QMessageBox::critical(NULL, app->tr("Error"), app->tr("Initialization
failed."),
+ QMessageBox::Ok, QMessageBox::NoButton);
delete app;
- doneUtil();
-
return ret;
}
Modified: gnunet-qt/src/core/main.h
===================================================================
--- gnunet-qt/src/core/main.h 2007-01-12 08:06:17 UTC (rev 4298)
+++ gnunet-qt/src/core/main.h 2007-01-12 20:57:27 UTC (rev 4299)
@@ -33,14 +33,22 @@
class GApplication: public QApplication
{
+ Q_OBJECT
+
public:
GApplication(int argc, char **argv);
+ virtual ~GApplication();
+ bool init(int argc, char * const *argv);
void loadPlugins();
void showWindow();
protected:
GMainWindow wnd;
GPluginLoader loader;
+ QString strCfgFile;
+ struct GE_Context *ectx;
+ struct GC_Configuration *cfg;
+ bool isInit;
};
#endif /*MAIN_H_*/
Modified: gnunet-qt/src/include/gnunet_qt_common.h
===================================================================
--- gnunet-qt/src/include/gnunet_qt_common.h 2007-01-12 08:06:17 UTC (rev
4298)
+++ gnunet-qt/src/include/gnunet_qt_common.h 2007-01-12 20:57:27 UTC (rev
4299)
@@ -31,6 +31,8 @@
#include <QString>
#include <QLibrary>
+#include "../common/stateDB.h"
+
#define GNUNETQT_ASSERT(cond) do { if (! (cond))
gnunet_qt_assert_quit(__FILE__, __LINE__); } while(0);
#ifdef Q_OS_WIN32
@@ -41,6 +43,8 @@
void gnunet_qt_assert_quit(char *file, int line);
+typedef QList<int> GIntList;
+
typedef struct
{
class QLibrary *lib;
@@ -62,7 +66,8 @@
public:
~GPluginLoader();
- GPlugin *load(const QString &strName);
+ GPlugin *load(const QString &strName, struct GC_Configuration *config,
+ struct GE_Context *errorContext);
void unloadAll();
protected:
@@ -98,7 +103,8 @@
char *cstr;
};
-typedef GPlugin *(*InitPlugin) ();
+typedef GPlugin *(*InitPlugin) (const struct GC_Configuration *config,
+ const struct GE_Context *errorContext);
typedef void (*ShutdownPlugin) (GPlugin *plugin);
Modified: gnunet-qt/src/plugins/about/about.cc
===================================================================
--- gnunet-qt/src/plugins/about/about.cc 2007-01-12 08:06:17 UTC (rev
4298)
+++ gnunet-qt/src/plugins/about/about.cc 2007-01-12 20:57:27 UTC (rev
4299)
@@ -230,7 +230,8 @@
extern "C"
{
-GNUNETQT_API GPlugin *init_plugin()
+GNUNETQT_API GPlugin *init_plugin(struct GC_Configuration *config,
+ struct GE_Context *errorContext)
{
return new GAboutPlugin();
}
Modified: gnunet-qt/src/plugins/fs/fs-search.cc
===================================================================
--- gnunet-qt/src/plugins/fs/fs-search.cc 2007-01-12 08:06:17 UTC (rev
4298)
+++ gnunet-qt/src/plugins/fs/fs-search.cc 2007-01-12 20:57:27 UTC (rev
4299)
@@ -28,13 +28,39 @@
#include <QMenu>
#include <extractor.h>
+#include "gnunet_qt_common.h"
#include "fshelper.h"
#include "fs-search.h"
-GFSSearch::GFSSearch(QTabWidget *tab, struct FSUI_Context *fsuiContext) :
QWidget()
+GFSSearch::GFSSearch(QTabWidget *tab, struct FSUI_Context *fsuiContext,
+ struct GC_Configuration *config, struct GE_Context *errorContext) : QWidget()
{
QHeaderView *header;
- model = new GFSSearchModel(fsuiContext);
+ char *stateDir;
+ QByteArray data;
+ int *colList, colIdx;
+ GIntList cols;
+
+ // get columns to be displayed
+ GC_get_configuration_value_string(config, "GNUNET-QT", "STATE",
+ "~/.gnunet/data/gnunet-qt", &stateDir);
+ GUserStateDB stateDB(stateDir);
+ if (stateDB.get("FS-SEARCH-COLUMNS", data))
+ {
+ colList = (int *) data.data();
+ for (colIdx = 0; colIdx < cols.count() / 2; colIdx++)
+ cols.append(colList[colIdx]);
+ }
+ else
+ {
+ cols.append(EXTRACTOR_FILENAME);
+ cols.append(EXTRACTOR_SIZE);
+ cols.append(EXTRACTOR_MIMETYPE);
+ cols.append((EXTRACTOR_KeywordType)
(EXTRACTOR_getHighestKeywordTypeNumber() + 1));
+ cols.append(EXTRACTOR_THUMBNAIL_DATA);
+ }
+
+ model = new GFSSearchModel(fsuiContext, cols);
setupUi(this);
Modified: gnunet-qt/src/plugins/fs/fs-search.h
===================================================================
--- gnunet-qt/src/plugins/fs/fs-search.h 2007-01-12 08:06:17 UTC (rev
4298)
+++ gnunet-qt/src/plugins/fs/fs-search.h 2007-01-12 20:57:27 UTC (rev
4299)
@@ -38,7 +38,8 @@
Q_OBJECT
public:
- GFSSearch(QTabWidget *tab, struct FSUI_Context *fsuiContext);
+ GFSSearch(QTabWidget *tab, struct FSUI_Context *fsuiContext,
+ struct GC_Configuration *config, struct GE_Context *errorContext);
QString &searchText();
void clear();
void start(GFSEcrsUri &uri, int anonymity);
Modified: gnunet-qt/src/plugins/fs/fs.cc
===================================================================
--- gnunet-qt/src/plugins/fs/fs.cc 2007-01-12 08:06:17 UTC (rev 4298)
+++ gnunet-qt/src/plugins/fs/fs.cc 2007-01-12 20:57:27 UTC (rev 4299)
@@ -32,16 +32,16 @@
#include "fs-search.h"
#include "ecrsuri.h"
-static void *fsuiEventProcessor(void *cls, const FSUI_Event *event, void
*model)
+static void *fsuiEventProcessor(void *cls, const FSUI_Event *event)
{
switch (event->type)
{
case FSUI_search_result:
- ((GFSSearchModel *) model)->addResult(event->data.SearchResult.searchURI,
+ // FIXME
+/* ((GFSSearchModel *)
model)->addResult(event->data.SearchResult.searchURI,
&event->data.SearchResult.fi);
- break;
+*/ break;
default:
- BREAK();
/* FIXME: display/log error */
break;
}
@@ -49,14 +49,20 @@
return NULL;
}
-GFSPlugin::GFSPlugin() : GPlugin()
+GFSPlugin::GFSPlugin(struct GC_Configuration *config,
+ struct GE_Context *errorContext) : GPlugin()
{
setupUi(this);
qRegisterMetaType<GFSEcrsUri>("GFSEcrsUri&");
+ this->config = config;
+ this->errorContext = errorContext;
+
// FSUI
- fsuiContext = FSUI_start("gnunet_qt", YES, fsuiEventProcessor, NULL);
+ /* FIXME: allow user to configure download parallelism */
+ fsuiContext = FSUI_start(errorContext, config, "gnunet_qt", 128, YES,
+ fsuiEventProcessor, NULL);
// Status tab
treeSearches->setModel(&searchesModel);
@@ -80,7 +86,7 @@
{
GFSSearch *ret;
- ret = new GFSSearch(tabResults, fsuiContext);
+ ret = new GFSSearch(tabResults, fsuiContext, config, errorContext);
connect(ret, SIGNAL(closeSearchWnd(GFSSearch *)), this,
SLOT(closeSearchClicked(GFSSearch *)));
@@ -140,14 +146,18 @@
strUri = QString(ECRS_URI_PREFIX) + ECRS_SUBSPACE_INFIX + strNS + "/" +
strSearch;
ustring = strUri.toLocal8Bit().data();
- uri = ECRS_stringToUri(ustring);
+ uri = ECRS_stringToUri(errorContext, ustring);
if (!uri)
- LOG(LOG_ERROR,
+ ;
+ // FIXME
+ /*
+ GE_LOG(errorContext, (GE_KIND) GE_ERROR | GE_USER | GE_IMMEDIATE,
tr("Failed to create namespace URI from `%s'.\n").toLocal8Bit().data(),
ustring);
+ */
}
else
- uri = FSUI_parseCharKeywordURI(strSearch.toLocal8Bit().data());
+ uri = ECRS_parseCharKeywordURI(errorContext,
strSearch.toLocal8Bit().data());
if (uri == NULL)
return;
@@ -177,9 +187,10 @@
extern "C"
{
- GNUNETQT_API GPlugin *init_plugin()
+ GNUNETQT_API GPlugin *init_plugin(struct GC_Configuration *config,
+ struct GE_Context *errorContext)
{
- return new GFSPlugin();
+ return new GFSPlugin(config, errorContext);
}
GNUNETQT_API void shutdown_plugin(GPlugin *plugin)
Modified: gnunet-qt/src/plugins/fs/fs.h
===================================================================
--- gnunet-qt/src/plugins/fs/fs.h 2007-01-12 08:06:17 UTC (rev 4298)
+++ gnunet-qt/src/plugins/fs/fs.h 2007-01-12 20:57:27 UTC (rev 4299)
@@ -39,13 +39,16 @@
Q_OBJECT
public:
- GFSPlugin();
+ GFSPlugin(struct GC_Configuration *config,
+ struct GE_Context *errorContext);
~GFSPlugin();
protected:
GFSSearchesModel searchesModel;
GFSDownloadsModel downloadsModel;
GFSUploadsModel uploadsModel;
struct FSUI_Context *fsuiContext;
+ struct GC_Configuration *config;
+ struct GE_Context *errorContext;
GFSSearch *addSearchWnd(QString strLabel);
protected slots:
Modified: gnunet-qt/src/plugins/fs/searchModel.cc
===================================================================
--- gnunet-qt/src/plugins/fs/searchModel.cc 2007-01-12 08:06:17 UTC (rev
4298)
+++ gnunet-qt/src/plugins/fs/searchModel.cc 2007-01-12 20:57:27 UTC (rev
4299)
@@ -46,36 +46,15 @@
return QVariant();
}
-GFSSearchModel::GFSSearchModel(struct FSUI_Context *context) :
QAbstractItemModel()
+GFSSearchModel::GFSSearchModel(struct FSUI_Context *context, GIntList &cols) :
QAbstractItemModel()
{
- void *columns = NULL;
-
- qRegisterMetaType<QModelIndex>("QModelIndex");
+ GIntList::iterator it;
- if (stateReadContent("gnunet-qt-fs-search-columns", &columns) != -1)
- {
- int count;
- QStringList lst = QString((char *) columns).split(";");
-
- count = lst.count();
- while(count)
- {
- colTypes.append((EXTRACTOR_KeywordType) lst.takeFirst().toInt());
-
- count--;
- }
+ qRegisterMetaType<QModelIndex>("QModelIndex");
- FREE(columns);
- }
- else
- {
- colTypes.append(EXTRACTOR_FILENAME);
- colTypes.append(EXTRACTOR_SIZE);
- colTypes.append(EXTRACTOR_MIMETYPE);
- colTypes.append((EXTRACTOR_KeywordType)
(EXTRACTOR_getHighestKeywordTypeNumber() + 1));
- colTypes.append(EXTRACTOR_THUMBNAIL_DATA);
- }
-
+ for (it = cols.begin(); it != cols.end(); it++)
+ colTypes.append((EXTRACTOR_KeywordType) *it);
+
fsuiContext = context;
}
@@ -170,9 +149,9 @@
void GFSSearchModel::startSearch(GFSEcrsUri &uri, int anonymity)
{
- emit resultsChanged(uri, 0);
+ emit resultsChanged(uri, (int) searchResults.count());
- FSUI_startSearch(fsuiContext, anonymity, uri.uri(), this);
+ FSUI_startSearch(fsuiContext, anonymity, INT_MAX, INT_MAX, uri.uri());
}
static int fsMetaDataIterator(EXTRACTOR_KeywordType type, const char *data,
Modified: gnunet-qt/src/plugins/fs/searchModel.h
===================================================================
--- gnunet-qt/src/plugins/fs/searchModel.h 2007-01-12 08:06:17 UTC (rev
4298)
+++ gnunet-qt/src/plugins/fs/searchModel.h 2007-01-12 20:57:27 UTC (rev
4299)
@@ -35,6 +35,7 @@
#include <extractor.h>
#include "ecrsuri.h"
+#include "gnunet_qt_common.h"
typedef QMultiHash<EXTRACTOR_KeywordType, QByteArray> GFSMetaData;
@@ -43,6 +44,13 @@
public:
GFSEcrsUri uri;
GFSMetaData metaData;
+
+ bool operator==(const GFSSearchResult &other)
+ {
+ if (uri == other.uri)
+ return true;
+ return false;
+ }
};
class GFSSearchModel : public QAbstractItemModel
@@ -50,7 +58,7 @@
Q_OBJECT
public:
- GFSSearchModel(struct FSUI_Context *context);
+ GFSSearchModel(struct FSUI_Context *context, GIntList &cols);
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column, const QModelIndex &parent =
Modified: gnunet-qt/src/plugins/general/checkDaemonThread.cc
===================================================================
--- gnunet-qt/src/plugins/general/checkDaemonThread.cc 2007-01-12 08:06:17 UTC
(rev 4298)
+++ gnunet-qt/src/plugins/general/checkDaemonThread.cc 2007-01-12 20:57:27 UTC
(rev 4299)
@@ -46,8 +46,11 @@
strDesc = src.strDesc;
}
-GCheckDaemonThread::GCheckDaemonThread(QObject *parent) : QThread(parent)
+GCheckDaemonThread::GCheckDaemonThread(struct GC_Configuration *config,
+ struct GE_Context *errorContext, QObject *parent) : QThread(parent)
{
+ this->config = config;
+ this->errorContext = errorContext;
checkAppsIn = 1;
}
@@ -60,14 +63,15 @@
{
bool check;
- check = (checkGNUnetDaemonRunning() == YES);
+ check = (connection_test_running(errorContext, config) == YES);
if (check)
{
checkAppsIn--;
if (checkAppsIn == 0)
{
GGNUnetAppDescs *descs = new GGNUnetAppDescs();
- GNUNET_TCP_SOCKET *sock = getClientSocket();
+ ClientServerConnection *sock = client_connection_create(errorContext,
+ config);
if (sock)
{
@@ -92,7 +96,7 @@
}
FREE(apps);
- releaseClientSocket(sock);
+ connection_destroy(sock);
checkAppsIn = 20; // 5 minutes / 15 seconds = 20 runs
}
Modified: gnunet-qt/src/plugins/general/checkDaemonThread.h
===================================================================
--- gnunet-qt/src/plugins/general/checkDaemonThread.h 2007-01-12 08:06:17 UTC
(rev 4298)
+++ gnunet-qt/src/plugins/general/checkDaemonThread.h 2007-01-12 20:57:27 UTC
(rev 4299)
@@ -37,7 +37,7 @@
class GGNUnetAppDesc
{
public:
- GGNUnetAppDesc(){};
+ GGNUnetAppDesc() {};
GGNUnetAppDesc(const GGNUnetAppDesc &src);
GGNUnetAppDesc &operator=(const GGNUnetAppDesc &src);
virtual ~GGNUnetAppDesc(){};
@@ -51,11 +51,15 @@
{
Q_OBJECT
public:
- GCheckDaemonThread(QObject *parent = NULL);
+ GCheckDaemonThread(struct GC_Configuration *config,
+ struct GE_Context *errorContext, QObject *parent = NULL);
~GCheckDaemonThread();
void run();
int checkAppsIn;
+protected:
+ struct GC_Configuration *config;
+ struct GE_Context *errorContext;
signals:
void running(bool isRunning);
void applications(GGNUnetAppDescs *apps);
Modified: gnunet-qt/src/plugins/general/general.cc
===================================================================
--- gnunet-qt/src/plugins/general/general.cc 2007-01-12 08:06:17 UTC (rev
4298)
+++ gnunet-qt/src/plugins/general/general.cc 2007-01-12 20:57:27 UTC (rev
4299)
@@ -29,21 +29,25 @@
#include <QStringList>
#include "general.h"
-GGeneralPlugin::GGeneralPlugin() : GPlugin()
+GGeneralPlugin::GGeneralPlugin(struct GC_Configuration *config,
+ struct GE_Context *errorContext, QObject *parent) : GPlugin()
{
setupUi(this);
+
+ startStopThread = new GStartStopThread(config, errorContext);
+ checkDaemonThread = new GCheckDaemonThread(config, errorContext);
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(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,
+ 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()));
+ connect(checkDaemonThread, SIGNAL(finished()), this,
SLOT(checkDaemonDone()));
pbStartStop->setEnabled(false);
runs = 0;
@@ -53,10 +57,16 @@
timer.start(0);
}
+GGeneralPlugin::~GGeneralPlugin()
+{
+ delete startStopThread;
+ delete checkDaemonThread;
+}
+
void GGeneralPlugin::startStopDaemon(bool unused)
{
pbStartStop->setEnabled(false);
- startStopThread.start(!isRunning);
+ startStopThread->start(!isRunning);
}
void GGeneralPlugin::updateUi()
@@ -137,7 +147,7 @@
void GGeneralPlugin::checkDaemon()
{
- checkDaemonThread.start();
+ checkDaemonThread->start();
}
void GGeneralPlugin::checkDaemonDone()
@@ -169,9 +179,10 @@
extern "C"
{
- GNUNETQT_API GPlugin *init_plugin()
+ GNUNETQT_API GPlugin *init_plugin(struct GC_Configuration *config,
+ struct GE_Context *errorContext)
{
- return new GGeneralPlugin;
+ return new GGeneralPlugin(config, errorContext);
}
GNUNETQT_API void shutdown_plugin(GPlugin *plugin)
Modified: gnunet-qt/src/plugins/general/general.h
===================================================================
--- gnunet-qt/src/plugins/general/general.h 2007-01-12 08:06:17 UTC (rev
4298)
+++ gnunet-qt/src/plugins/general/general.h 2007-01-12 20:57:27 UTC (rev
4299)
@@ -39,12 +39,14 @@
Q_OBJECT
public:
- GGeneralPlugin();
+ GGeneralPlugin(struct GC_Configuration *config,
+ struct GE_Context *errorContext, QObject *parent = NULL);
+ virtual ~GGeneralPlugin();
protected:
void updateUi();
- GStartStopThread startStopThread;
- GCheckDaemonThread checkDaemonThread;
+ GStartStopThread *startStopThread;
+ GCheckDaemonThread *checkDaemonThread;
QTimer timer;
int runs;
bool isRunning, pending;
Modified: gnunet-qt/src/plugins/general/general.pro.in
===================================================================
--- gnunet-qt/src/plugins/general/general.pro.in 2007-01-12 08:06:17 UTC
(rev 4298)
+++ gnunet-qt/src/plugins/general/general.pro.in 2007-01-12 20:57:27 UTC
(rev 4299)
@@ -4,7 +4,7 @@
CONFIG += @QT_CONFIG@ dll
INCLUDEPATH = ../../include .
DLLDESTDIR = .
-LIBS = -lgnunetutil -lgnunetgetoption_api -L../../common -lgnunetqt_common
+LIBS = -lgnunetutil -lgnunetgetoption_api -L../../common -lgnunetqt_common
-lgnunetutil_network_client
QMAKE_LFLAGS += -shared
target.path = @prefix@/lib
Modified: gnunet-qt/src/plugins/general/startStopThread.cc
===================================================================
--- gnunet-qt/src/plugins/general/startStopThread.cc 2007-01-12 08:06:17 UTC
(rev 4298)
+++ gnunet-qt/src/plugins/general/startStopThread.cc 2007-01-12 20:57:27 UTC
(rev 4299)
@@ -25,11 +25,15 @@
*/
#include <GNUnet/gnunet_util.h>
+#include <GNUnet/gnunet_util_network_client.h>
#include "startStopThread.h"
-GStartStopThread::GStartStopThread(QObject *parent) : QThread(parent)
+GStartStopThread::GStartStopThread(struct GC_Configuration *config,
+ struct GE_Context *errorContext, QObject *parent) : QThread(parent)
{
+ this->config = config;
+ this->errorContext = errorContext;
}
GStartStopThread::~GStartStopThread()
@@ -48,10 +52,15 @@
bool ret;
if (doStart)
- ret = startGNUnetDaemon(YES) != SYSERR;
+ ret = os_daemon_start(errorContext, config, NULL, YES) != SYSERR;
else
- ret = stopGNUnetDaemon() != SYSERR;
+ {
+ struct ClientServerConnection * sock;
+ sock = client_connection_create(errorContext, config);
+ ret = connection_request_shutdown(sock) != OK;
+ }
+
emit finished(ret);
}
Modified: gnunet-qt/src/plugins/general/startStopThread.h
===================================================================
--- gnunet-qt/src/plugins/general/startStopThread.h 2007-01-12 08:06:17 UTC
(rev 4298)
+++ gnunet-qt/src/plugins/general/startStopThread.h 2007-01-12 20:57:27 UTC
(rev 4299)
@@ -33,7 +33,8 @@
{
Q_OBJECT
public:
- GStartStopThread(QObject *parent = NULL);
+ GStartStopThread(struct GC_Configuration *config,
+ struct GE_Context *errorContext, QObject *parent = NULL);
~GStartStopThread();
void start(bool doStart);
void run();
@@ -42,6 +43,8 @@
protected:
bool doStart;
int numRun;
+ struct GC_Configuration *config;
+ struct GE_Context *errorContext;
};
#endif /*STARTSTOPTHREAD_H_*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4299 - in gnunet-qt/src: common core include plugins/about plugins/fs plugins/general,
durner <=