[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r1311 - in gnunet-gtk: . src/common src/include src/plugins
From: |
grothoff |
Subject: |
[GNUnet-SVN] r1311 - in gnunet-gtk: . src/common src/include src/plugins/fs |
Date: |
Thu, 7 Jul 2005 16:43:23 -0700 (PDT) |
Author: grothoff
Date: 2005-07-07 16:43:14 -0700 (Thu, 07 Jul 2005)
New Revision: 1311
Modified:
gnunet-gtk/TODO
gnunet-gtk/src/common/helper.c
gnunet-gtk/src/include/platform.h
gnunet-gtk/src/plugins/fs/collection.c
gnunet-gtk/src/plugins/fs/download.c
gnunet-gtk/src/plugins/fs/fs.h
gnunet-gtk/src/plugins/fs/namespace.c
Log:
collections, some more namespace work, debugging
Modified: gnunet-gtk/TODO
===================================================================
--- gnunet-gtk/TODO 2005-07-07 23:36:42 UTC (rev 1310)
+++ gnunet-gtk/TODO 2005-07-07 23:43:14 UTC (rev 1311)
@@ -1,24 +1,17 @@
-Important (for 0.7.0):
-* bugs:
- - figure out where seemingly spurious "pending" downloads come from
- - why can the "file sharing" tab not be selected first
- (I can select first "General" and then "file sharing"!,
- glade shows no difference between the two!!!)
-* implement advanced FS operations:
- - create namespace [ medium, CG ]
- * minor FIXMEs: root entry, minor FIXMEs, error hanlding
- - delete namespace [ medium, CG ]
- - publish to namespace [ easy, CG ]
- - publish update [ easy, CG ]
- - start collection [ easy, CG ]
- * enable stop collection!
- * need visual feedback for collection status!
- - stop collection [ easy, CG ]
- * enable start collection!
+0.7.0 (all of these can go under "known limitations", that
+ is, they are not release-critical IMO):
+1) stats integration (daemon+own module for graphical stats)
+2) update interval is not parsed
+3) update namespace content (not implemented)
+4) code cleanup (lots of repetition of code in fs plugin)
+5) various minor memory leaks in models (esp. on shutdown)
+6) figure out where seemingly spurious "pending" downloads
+ come from (still there?)
+7) why can the "file sharing" tab not be selected first
+ (I can select first "General" and then "file sharing"!,
+ glade shows no difference between the two!!!)
-
-Later (0.7.1):
-0) stats integration (daemon+own module for graphical stats) [ medium ]
+Later (0.7.1+):
1) auto-rename downloaded files
to better names (user feedback!?) [ medium ]
2) create directory from known file IDs [ medium ]
@@ -27,8 +20,10 @@
4) more help-texts (glade) [ easy ]
5) highlight completed downloads [ easy ]
6) highlight active downloads in search list [ easy ]
-7) pop-up dialogs / context menus [ medium ]
+7) pop-up dialogs / context menus (show extra information,
+ in particular full metadata) [ medium ]
8) chat [ difficult ]
+9) show content of current collection
gnunet-gtk wishlist (from pre-0.7.0 days):
Modified: gnunet-gtk/src/common/helper.c
===================================================================
--- gnunet-gtk/src/common/helper.c 2005-07-07 23:36:42 UTC (rev 1310)
+++ gnunet-gtk/src/common/helper.c 2005-07-07 23:43:14 UTC (rev 1311)
@@ -257,6 +257,7 @@
Plugin * plug = user_data;
void * method;
+ method = NULL;
while (plug != NULL) {
method = trybindDynamicMethod(plug->library,
"",
@@ -283,8 +284,7 @@
typedef void (*PlainCall)();
-static Plugin * loadPlugin(const char * name,
- Plugin * next) {
+static void loadPlugin(const char * name) {
Plugin * p;
void * lib;
PlainCall init;
@@ -295,29 +295,27 @@
LOG(LOG_WARNING,
_("Failed to load plugin '%s'\n"),
name);
- return next;
+ return;
}
p = MALLOC(sizeof(Plugin));
p->name = STRDUP(name);
- p->next = next;
+ p->next = plugin;
p->library = lib;
+ plugin = p;
init = trybindDynamicMethod(lib,
"init_",
name);
if (init != NULL)
init();
-
- return p;
}
-static Plugin * loadPlugins(const char * names,
- Plugin * plug) {
+static void loadPlugins(const char * names) {
char * dup;
char * next;
const char * pos;
if (names == NULL)
- return plug;
+ return;
dup = STRDUP(names);
next = dup;
@@ -338,11 +336,10 @@
LOG(LOG_DEBUG,
"Loading plugin '%s'\n",
pos);
- plug = loadPlugin(pos, plug);
+ loadPlugin(pos);
}
} while (next != NULL);
FREE(dup);
- return plug;
}
static void unloadPlugin(Plugin * plug) {
@@ -392,7 +389,7 @@
"PLUGINS");
if (load == NULL)
load = STRDUP("about daemon fs");
- plugin = loadPlugins(load, NULL);
+ loadPlugins(load);
FREE(load);
connectGladeWithPlugins(mainXML);
Modified: gnunet-gtk/src/include/platform.h
===================================================================
--- gnunet-gtk/src/include/platform.h 2005-07-07 23:36:42 UTC (rev 1310)
+++ gnunet-gtk/src/include/platform.h 2005-07-07 23:43:14 UTC (rev 1311)
@@ -37,7 +37,7 @@
#define _(a) gettext(a)
-#define UNREF(a) LOG(LOG_DEBUG, "unref %s:%u\n", __FILE__, __LINE__);
g_object_unref(a)
+#define UNREF(a) /*LOG(LOG_DEBUG, "unref %s:%u\n", __FILE__, __LINE__);*/
g_object_unref(a)
#include "plibc.h"
Modified: gnunet-gtk/src/plugins/fs/collection.c
===================================================================
--- gnunet-gtk/src/plugins/fs/collection.c 2005-07-07 23:36:42 UTC (rev
1310)
+++ gnunet-gtk/src/plugins/fs/collection.c 2005-07-07 23:43:14 UTC (rev
1311)
@@ -30,25 +30,232 @@
#include "collection.h"
#include <extractor.h>
-void create_collection_clicked(GtkWidget * dummy1,
- GtkWidget * dummy2) {
- /*
- FSUI_startCollection(ctx,
- unsigned int anonymityLevel,
- cron_t updateInterval,
- const char * name,
- const struct ECRS_MetaData * meta);
+static GladeXML * metaXML;
+
+
+
+/**
+ * FIXME: somehow this function is not called
+ * when the button is clicked.
*/
+void
+on_collectionDialogMetaDataAddButton_clicked(gpointer dummy,
+ GtkWidget * uploadButton) {
+ GtkWidget * metaList;
+ GtkWidget * entryLine;
+ GtkWidget * typeCB;
+ const char * value;
+ EXTRACTOR_KeywordType type;
+ GtkListStore * metamodel;
+ GtkListStore * typemodel;
+ GtkTreeIter iter;
+ char * stype;
+
+ metaList = glade_xml_get_widget(metaXML,
+ "collectionMetaDataTreeView");
+ metamodel
+ = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(metaList)));
+
+ entryLine = glade_xml_get_widget(metaXML,
+ "collectionMetaDataValueEntry");
+ value = gtk_entry_get_text(GTK_ENTRY(entryLine));
+ typeCB = glade_xml_get_widget(metaXML,
+ "collectionMetaDataTypeComboBox");
+ typemodel
+ = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(typeCB)));
+ if (! gtk_combo_box_get_active_iter(GTK_COMBO_BOX(typeCB),
+ &iter))
+ return; /* oops */
+ gtk_tree_model_get(GTK_TREE_MODEL(typemodel),
+ &iter,
+ META_STYPE, &stype,
+ META_TYPE, &type,
+ -1);
+ gtk_list_store_append(metamodel,
+ &iter);
+ gtk_list_store_set(metamodel,
+ &iter,
+ META_TYPE, type,
+ META_STYPE, stype,
+ META_VALUE, value,
+ -1);
+ gtk_entry_set_text(GTK_ENTRY(entryLine), "");
}
-void collectionDelete_clicked(GtkWidget * dummy1,
+
+void createCollection_clicked(GtkWidget * dummy1,
+ GtkWidget * dummy2) {
+ GtkWidget * w;
+ const char * collectionName;
+ GtkWidget * nameLine;
+ GtkWidget * metaList;
+ GtkWidget * dialog;
+ GtkWidget * metaType;
+ GtkWidget * spin;
+ GtkListStore * metamodel;
+ GtkCellRenderer * renderer;
+ GtkListStore * keywordTypeModel;
+ GtkTreeIter iter;
+ struct ECRS_MetaData * meta;
+ EXTRACTOR_KeywordType type;
+ const char * stype;
+ char * mvalue;
+ struct ECRS_URI * root;
+ cron_t updateInterval;
+ const char * updateIntervalString;
+
+ metaXML
+ = glade_xml_new(getGladeFileName(),
+ "createCollectionDialog",
+ NULL);
+ connectGladeWithPlugins(metaXML);
+ dialog = glade_xml_get_widget(metaXML,
+ "createCollectionDialog");
+ metamodel
+ = gtk_list_store_new(META_NUM,
+ G_TYPE_INT,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+ metaList = glade_xml_get_widget(metaXML,
+ "collectionMetaDataTreeView");
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(metaList),
+ -1,
+ _("Category"),
+ renderer,
+ "text", META_STYPE,
+ NULL);
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(metaList),
+ -1,
+ _("Value"),
+ renderer,
+ "text", META_VALUE,
+ NULL);
+ gtk_tree_view_set_model(GTK_TREE_VIEW(metaList),
+ GTK_TREE_MODEL(metamodel));
+ keywordTypeModel
+ = gtk_list_store_new(KTYPE_NUM,
+ G_TYPE_STRING,
+ G_TYPE_INT);
+ metaType
+ = glade_xml_get_widget(metaXML,
+ "collectionMetaTypeComboBox");
+ gtk_combo_box_set_model(GTK_COMBO_BOX(metaType),
+ GTK_TREE_MODEL(keywordTypeModel));
+ for (type=0;type<EXTRACTOR_getHighestKeywordTypeNumber();type++) {
+ stype = EXTRACTOR_getKeywordTypeAsString(type);
+ gtk_list_store_append(keywordTypeModel,
+ &iter);
+ gtk_list_store_set(keywordTypeModel,
+ &iter,
+ KTYPE_STRING, stype,
+ KTYPE_TYPE, type,
+ -1);
+ }
+ renderer = gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(metaType),
+ renderer,
+ FALSE);
+ gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(metaType),
+ renderer,
+ "text", KTYPE_STRING);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(metaType),
+ 0);
+ gtk_dialog_set_default_response(GTK_DIALOG(dialog),
+ GTK_RESPONSE_OK);
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ meta = ECRS_createMetaData();
+ if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(metamodel),
+ &iter)) {
+ do {
+ gtk_tree_model_get(GTK_TREE_MODEL(metamodel),
+ &iter,
+ META_TYPE, &type,
+ META_VALUE, &mvalue,
+ -1);
+ ECRS_addToMetaData(meta,
+ type,
+ mvalue);
+ } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(metamodel),
+ &iter));
+ }
+ spin = glade_xml_get_widget(metaXML,
+ "collectionAnonymityLevel");
+ nameLine
+ = glade_xml_get_widget(metaXML,
+ "collectionUpdateIntervalComboBoxEntry");
+ nameLine
+ = gtk_bin_get_child(GTK_BIN(nameLine));
+ updateIntervalString
+ = gtk_entry_get_text(GTK_ENTRY(nameLine));
+ updateInterval = 0; /* FIXME */
+ nameLine = glade_xml_get_widget(metaXML,
+ "collectionIdentifierEntry");
+ collectionName
+ = gtk_entry_get_text(GTK_ENTRY(nameLine));
+ root = NULL;
+ if (OK == FSUI_startCollection(ctx,
+ gtk_spin_button_get_value_as_int
+ (GTK_SPIN_BUTTON(spin)),
+ updateInterval,
+ collectionName,
+ meta)) {
+ w = glade_xml_get_widget(getMainXML(),
+ "createCollection");
+ gtk_widget_set_sensitive(w, FALSE);
+ w = glade_xml_get_widget(getMainXML(),
+ "deleteCollection");
+ gtk_widget_set_sensitive(w, TRUE);
+ } else {
+ GtkWidget * dialog;
+
+ dialog = gtk_message_dialog_new
+ (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Failed to start collection '%s' (consult logs)."),
+ collectionName);
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ }
+ ECRS_freeMetaData(meta);
+ }
+ gtk_widget_destroy(dialog);
+ UNREF(metaXML);
+ metaXML = NULL;
+}
+
+void deleteCollection_clicked(GtkWidget * dummy1,
GtkWidget * dummy2) {
- FSUI_stopCollection(ctx);
- /* fixme: disable stop collection button,
- enable start collection button! */
+ GtkWidget * w;
+
+ if (OK == FSUI_stopCollection(ctx)) {
+ w = glade_xml_get_widget(getMainXML(),
+ "createCollection");
+ gtk_widget_set_sensitive(w, TRUE);
+ w = glade_xml_get_widget(getMainXML(),
+ "deleteCollection");
+ gtk_widget_set_sensitive(w, FALSE);
+ infoMessage(NO,
+ _("Collection stopped.\n"));
+ } else {
+ infoMessage(YES,
+ _("Failed to stop collection (consult logs).\n"));
+ }
}
void fs_collection_start() {
+ GtkWidget * w;
+
+ if (NULL != FSUI_getCollection(ctx))
+ w = glade_xml_get_widget(getMainXML(),
+ "createCollection");
+ else
+ w = glade_xml_get_widget(getMainXML(),
+ "deleteCollection");
+ gtk_widget_set_sensitive(w, FALSE);
}
void fs_collection_stop() {
Modified: gnunet-gtk/src/plugins/fs/download.c
===================================================================
--- gnunet-gtk/src/plugins/fs/download.c 2005-07-07 23:36:42 UTC (rev
1310)
+++ gnunet-gtk/src/plugins/fs/download.c 2005-07-07 23:43:14 UTC (rev
1311)
@@ -100,10 +100,10 @@
return OK;
}
-static void initiateDownload(GtkTreeModel *model,
+static void initiateDownload(GtkTreeModel * model,
GtkTreePath * path,
GtkTreeIter * iter,
- GtkTreeStore * tree) {
+ gpointer unused) {
struct ECRS_URI * uri;
struct ECRS_MetaData * meta;
char * filename;
@@ -235,7 +235,7 @@
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
gtk_tree_selection_selected_foreach
(selection,
- (GtkTreeSelectionForeachFunc) &initiateDownload,
+ &initiateDownload,
NULL);
}
Modified: gnunet-gtk/src/plugins/fs/fs.h
===================================================================
--- gnunet-gtk/src/plugins/fs/fs.h 2005-07-07 23:36:42 UTC (rev 1310)
+++ gnunet-gtk/src/plugins/fs/fs.h 2005-07-07 23:43:14 UTC (rev 1311)
@@ -64,6 +64,7 @@
NAMESPACE_SIZE,
NAMESPACE_URISTRING,
NAMESPACE_URI,
+ NAMESPACE_META,
NAMESPACE_NUM
};
Modified: gnunet-gtk/src/plugins/fs/namespace.c
===================================================================
--- gnunet-gtk/src/plugins/fs/namespace.c 2005-07-07 23:36:42 UTC (rev
1310)
+++ gnunet-gtk/src/plugins/fs/namespace.c 2005-07-07 23:43:14 UTC (rev
1311)
@@ -1,4 +1,4 @@
-/*
+ /*
This file is part of GNUnet.
(C) 2005 Christian Grothoff (and other contributing authors)
@@ -206,6 +206,7 @@
NAMESPACE_SIZE, size,
NAMESPACE_URISTRING, uriString,
NAMESPACE_URI, ECRS_dupUri(fi->uri),
+ NAMESPACE_META, ECRS_dupMetaData(fi->meta),
-1);
FREE(filename);
FREE(uriString);
@@ -725,24 +726,144 @@
FREE(list);
}
+typedef struct {
+ unsigned int anonymityLevel;
+ char * namespaceName;
+ cron_t updateInterval;
+ HashCode512 * lastId;
+ HashCode512 thisId;
+ HashCode512 * nextId;
+ struct ECRS_MetaData * meta;
+} IUC;
+/**
+ * Publish the selected file in the
+ * selected namespace.
+ */
+static void initiateUpload(GtkTreeModel * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter,
+ gpointer data) {
+ IUC * cls = data;
+ struct ECRS_URI * resultURI;
+ struct ECRS_URI * dst;
+ struct ECRS_MetaData * ometa;
+ struct ECRS_MetaData * meta;
+ NamespaceList * list;
+ ECRS_FileInfo fi;
+ dst = NULL;
+ meta = cls->meta;
+ gtk_tree_model_get(model,
+ iter,
+ NAMESPACE_URI, &dst,
+ NAMESPACE_META, &ometa,
+ -1);
+ /* FIXME: we may want to optionally combine the metadata from the
+ original file ID (ometa) with the new metadata (cls->meta) here;
+ or if we limit us to one file at a time, show the original
+ metadata immediately with the dialog. */
+
+ if (dst == NULL) {
+ BREAK();
+ return;
+ }
+ if (OK == FSUI_addToNamespace(ctx,
+ cls->anonymityLevel,
+ cls->namespaceName,
+ cls->updateInterval,
+ cls->lastId,
+ &cls->thisId,
+ cls->nextId,
+ dst,
+ meta,
+ &resultURI)) {
+ list = head;
+ while ( (list != NULL) &&
+ (0 != strcmp(cls->namespaceName,
+ list->name)) )
+ list = list->next;
+ if (list == NULL) {
+ BREAK();
+ } else {
+ /* update namespace content list! */
+ fi.uri = resultURI;
+ fi.meta = meta;
+ addNamespaceContentToModel(list->model,
+ &fi,
+ &cls->thisId,
+ cls->nextId,
+ cls->updateInterval,
+ cls->updateInterval
+ + cronTime(NULL) );
+ }
+ ECRS_freeUri(resultURI);
+ } else {
+ infoMessage(YES,
+ _("Failed to insert content into namespace "
+ "(consult logs).\n"));
+ }
+}
+
void on_namespaceInsertButton_clicked(GtkWidget * dummy1,
GtkWidget * dummy2) {
const char * identifierName;
+ NamespaceList * list;
GtkWidget * nameLine;
+ GtkWidget * page;
+ GtkWidget * notebook;
GtkWidget * metaList;
GtkWidget * dialog;
GtkWidget * spin;
+ GtkWidget * update;
GtkListStore * metamodel;
GtkCellRenderer * renderer;
GtkTreeIter iter;
struct ECRS_MetaData * meta;
EXTRACTOR_KeywordType type;
char * mvalue;
- HashCode512 identifier;
+ HashCode512 nextId;
+ GtkWidget * contentList;
+ GtkTreeSelection * selection;
+ IUC cls;
+ gint num;
- /* FIXME */
+ contentList
+ = glade_xml_get_widget(getMainXML(),
+ "availableContentList");
+ selection
+ = gtk_tree_view_get_selection(GTK_TREE_VIEW(contentList));
+ if (0 == gtk_tree_selection_count_selected_rows(selection)) {
+ /* IMPROVE-ME: disable the menu item
+ as long as this may happen! */
+ dialog = gtk_message_dialog_new
+ (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("You must select some available content for publication first!"));
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ return;
+ }
+
+ notebook
+ = glade_xml_get_widget(getMainXML(),
+ "localNamespacesNotebook");
+ num = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
+ GNUNET_ASSERT(num != -1);
+ page =gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
+ num);
+ list = head;
+ while ( (list != NULL) &&
+ (list->namespacepage != page) )
+ list = list->next;
+ if (list == NULL) {
+ BREAK();
+ return;
+ }
+ cls.namespaceName = list->name;
+
metaXML
= glade_xml_new(getGladeFileName(),
"namespaceMetaDataDialog",
@@ -792,7 +913,9 @@
&iter));
}
spin = glade_xml_get_widget(metaXML,
- "namespaceAnonymityspinbutton");
+ "anonymitySpinButton");
+ cls.anonymityLevel
+ = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));
nameLine = glade_xml_get_widget(metaXML,
"namespaceContentIdentifierEntry");
identifierName = gtk_entry_get_text(GTK_ENTRY(nameLine));
@@ -800,9 +923,32 @@
identifierName = "";
hash(identifierName,
strlen(identifierName),
- &identifier);
+ &cls.thisId);
+ cls.lastId = NULL;
+ nameLine = glade_xml_get_widget(metaXML,
+ "nextIdentifierEntry");
+ identifierName = gtk_entry_get_text(GTK_ENTRY(nameLine));
+ if ( (identifierName == NULL) ||
+ (strlen(identifierName) == 0)) {
+ cls.nextId = NULL;
+ } else {
+ hash(identifierName,
+ strlen(identifierName),
+ &nextId);
+ cls.nextId = &nextId;
+ }
+ cls.meta = meta;
+ update = glade_xml_get_widget(metaXML,
+ "updateIntervalComboBoxEntry");
+ cls.updateInterval = 0; /* FIXME */
+ gtk_tree_selection_selected_foreach
+ (selection,
+ &initiateUpload,
+ &cls);
+
+ ECRS_freeMetaData(meta);
}
gtk_widget_destroy(dialog);
UNREF(metaXML);
@@ -811,7 +957,16 @@
void on_namespaceUpdateButton_clicked(GtkWidget * dummy1,
GtkWidget * dummy2) {
- /* FIXME */
+ GtkWidget * dialog;
+
+ dialog = gtk_message_dialog_new
+ (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Not implemented!"));
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
}
@@ -829,6 +984,7 @@
G_TYPE_STRING, /* name */
G_TYPE_UINT64, /* size */
G_TYPE_STRING, /* uri-string */
+ G_TYPE_POINTER,
G_TYPE_POINTER); /* uri */
gtk_tree_view_set_model(GTK_TREE_VIEW(contentList),
GTK_TREE_MODEL(model));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r1311 - in gnunet-gtk: . src/common src/include src/plugins/fs,
grothoff <=