[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r1290 - in gnunet-gtk: . src/plugins/fs
From: |
grothoff |
Subject: |
[GNUnet-SVN] r1290 - in gnunet-gtk: . src/plugins/fs |
Date: |
Tue, 5 Jul 2005 20:51:17 -0700 (PDT) |
Author: grothoff
Date: 2005-07-05 20:51:07 -0700 (Tue, 05 Jul 2005)
New Revision: 1290
Added:
gnunet-gtk/src/plugins/fs/collection.c
gnunet-gtk/src/plugins/fs/collection.h
Modified:
gnunet-gtk/TODO
gnunet-gtk/gnunet-gtk.glade
gnunet-gtk/src/plugins/fs/Makefile.am
gnunet-gtk/src/plugins/fs/fs.c
gnunet-gtk/src/plugins/fs/namespace.c
gnunet-gtk/src/plugins/fs/upload.c
Log:
update
Modified: gnunet-gtk/TODO
===================================================================
--- gnunet-gtk/TODO 2005-07-06 00:22:20 UTC (rev 1289)
+++ gnunet-gtk/TODO 2005-07-06 03:51:07 UTC (rev 1290)
@@ -5,13 +5,9 @@
(I can select first "General" and then "file sharing"!,
glade shows no difference between the two!!!)
* implement advanced FS operations:
- - update views [ medium, CG ]
- * data for known identifiers
- * data for in-namespace identifiers
- create namespace [ medium, CG ]
- * open dialog
- * actual creation
- * update tab
+ * 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 ]
Modified: gnunet-gtk/gnunet-gtk.glade
===================================================================
--- gnunet-gtk/gnunet-gtk.glade 2005-07-06 00:22:20 UTC (rev 1289)
+++ gnunet-gtk/gnunet-gtk.glade 2005-07-06 03:51:07 UTC (rev 1290)
@@ -4533,7 +4533,7 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkTreeView" id="treeview2">
+ <widget class="GtkTreeView"
id="namespaceMetaDataDialogMetaDataList">
<property agent="glademm"
name="cxx_visibility">public</property>
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Select entries
and use the context menu (right click) in order to delete keywords.</property>
@@ -4612,7 +4612,7 @@
</child>
<child>
- <widget class="GtkComboBox" id="combobox1">
+ <widget class="GtkComboBox"
id="namespaceMetaDataDialogMetaTypeComboBox">
<property agent="glademm" name="cxx_visibility">public</property>
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
@@ -4714,7 +4714,7 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkTreeView" id="treeview4">
+ <widget class="GtkTreeView"
id="namespaceMetaDataDialogKeywordList">
<property agent="glademm"
name="cxx_visibility">public</property>
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Metadata
describing the namespace (used in advertisements). Use the context menu
(right-click) to delete selected entries.</property>
Modified: gnunet-gtk/src/plugins/fs/Makefile.am
===================================================================
--- gnunet-gtk/src/plugins/fs/Makefile.am 2005-07-06 00:22:20 UTC (rev
1289)
+++ gnunet-gtk/src/plugins/fs/Makefile.am 2005-07-06 03:51:07 UTC (rev
1290)
@@ -10,6 +10,7 @@
libgnunetgtkmodule_fs.la
libgnunetgtkmodule_fs_la_SOURCES = \
+ collection.c collection.h \
download.c download.h \
fs.c fs.h \
namespace.c namespace.h \
Added: gnunet-gtk/src/plugins/fs/collection.c
===================================================================
--- gnunet-gtk/src/plugins/fs/collection.c 2005-07-06 00:22:20 UTC (rev
1289)
+++ gnunet-gtk/src/plugins/fs/collection.c 2005-07-06 03:51:07 UTC (rev
1290)
@@ -0,0 +1,57 @@
+/*
+ This file is part of GNUnet.
+ (C) 2005 Christian Grothoff (and other contributing authors)
+
+ GNUnet 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 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/fs/collection.c
+ * @brief code for operations with collections
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunetgtk_common.h"
+#include "fs.h"
+#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);
+ */
+}
+
+void collectionDelete_clicked(GtkWidget * dummy1,
+ GtkWidget * dummy2) {
+ FSUI_stopCollection(ctx);
+ /* fixme: disable stop collection button,
+ enable start collection button! */
+}
+
+void fs_collection_start() {
+}
+
+void fs_collection_stop() {
+}
+
+/* end of collection.c */
Added: gnunet-gtk/src/plugins/fs/collection.h
===================================================================
--- gnunet-gtk/src/plugins/fs/collection.h 2005-07-06 00:22:20 UTC (rev
1289)
+++ gnunet-gtk/src/plugins/fs/collection.h 2005-07-06 03:51:07 UTC (rev
1290)
@@ -0,0 +1,34 @@
+/*
+ This file is part of GNUnet.
+ (C) 2005 Christian Grothoff (and other contributing authors)
+
+ GNUnet 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 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/fs/collection.h
+ * @brief code for dealing with collections
+ * @author Christian Grothoff
+ */
+
+#ifndef GTK_COLLECTION_H
+#define GTK_COLLECTION_H
+
+void fs_collection_start(void);
+
+void fs_collection_stop(void);
+
+#endif
Modified: gnunet-gtk/src/plugins/fs/fs.c
===================================================================
--- gnunet-gtk/src/plugins/fs/fs.c 2005-07-06 00:22:20 UTC (rev 1289)
+++ gnunet-gtk/src/plugins/fs/fs.c 2005-07-06 03:51:07 UTC (rev 1290)
@@ -30,6 +30,7 @@
#include "download.h"
#include "search.h"
#include "upload.h"
+#include "collection.h"
#include "namespace.h"
#include <GNUnet/gnunet_fsui_lib.h>
@@ -140,6 +141,7 @@
YES,
&eventProcessor,
NULL);
+ fs_collection_start();
fs_search_start();
fs_download_start();
fs_upload_start();
@@ -155,6 +157,7 @@
fs_download_stop();
fs_search_stop();
fs_namespace_stop();
+ fs_collection_stop();
sig = SEMAPHORE_NEW(0);
if (0 != PTHREAD_CREATE(&doneThread,
(PThreadMain)&shutdownCode,
Modified: gnunet-gtk/src/plugins/fs/namespace.c
===================================================================
--- gnunet-gtk/src/plugins/fs/namespace.c 2005-07-06 00:22:20 UTC (rev
1289)
+++ gnunet-gtk/src/plugins/fs/namespace.c 2005-07-06 03:51:07 UTC (rev
1290)
@@ -54,7 +54,7 @@
GtkWidget * child;
GtkWidget * resultList;
GtkCellRenderer * renderer;
- GtkTreeStore * tree;
+ GtkListStore * model;
GladeXML * namespaceXML;
namespaceXML
@@ -70,7 +70,7 @@
"namespaceAnonymitySpinButton");
if (treeview != NULL)
(*treeview) = GTK_WIDGET(GTK_TREE_VIEW(resultList));
- tree =
+ model =
gtk_list_store_new(IN_NAMESPACE_NUM,
G_TYPE_STRING, /* (file)name */
G_TYPE_UINT64, /* size */
@@ -83,7 +83,7 @@
G_TYPE_POINTER, /* URI */
G_TYPE_POINTER); /* META */
gtk_tree_view_set_model(GTK_TREE_VIEW(resultList),
- GTK_TREE_MODEL(tree));
+ GTK_TREE_MODEL(model));
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
-1,
@@ -152,18 +152,61 @@
return child;
}
-
-
/**
* Add the given content to the globally available
- * content model.
+ * content model. Check that it is not already
+ * present!
*/
static int updateView(const ECRS_FileInfo * fi,
const HashCode512 * key,
void * closure) {
- GtkTreeView * model = GTK_TREE_VIEW(closure);
- /* model is also a gtk list store! */
- /* FIXME! */
+ GtkTreeModel * model = GTK_TREE_MODEL(closure);
+ struct ECRS_URI * euri;
+ GtkTreeIter iter;
+ char * filename;
+ char * uriString;
+ unsigned long long size;
+
+ if (gtk_tree_model_get_iter_first(model,
+ &iter)) {
+ do {
+ gtk_tree_model_get(model,
+ &iter,
+ NAMESPACE_URI, &euri,
+ -1);
+ if (ECRS_equalsUri(euri,
+ fi->uri))
+ return OK; /* already listed */
+ } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(model),
+ &iter));
+ }
+ filename = ECRS_getFirstFromMetaData(fi->meta,
+ EXTRACTOR_FILENAME,
+ EXTRACTOR_TITLE,
+ EXTRACTOR_DESCRIPTION,
+ EXTRACTOR_SUBJECT,
+ EXTRACTOR_ARTIST,
+ EXTRACTOR_AUTHOR,
+ EXTRACTOR_PUBLISHER,
+ EXTRACTOR_CREATOR,
+ EXTRACTOR_PRODUCER,
+ EXTRACTOR_UNKNOWN,
+ -1);
+ if (filename == NULL)
+ filename = STRDUP(_("no name given"));
+ size = ECRS_fileSize(fi->uri);
+ uriString = ECRS_uriToString(fi->uri);
+ gtk_list_store_append(GTK_LIST_STORE(model),
+ &iter);
+ gtk_list_store_set(GTK_LIST_STORE(model),
+ &iter,
+ NAMESPACE_FILENAME, filename,
+ NAMESPACE_SIZE, size,
+ NAMESPACE_URISTRING, uriString,
+ NAMESPACE_URI, ECRS_dupUri(fi->uri),
+ -1);
+ FREE(filename);
+ FREE(uriString);
return OK;
}
@@ -200,14 +243,80 @@
* @return OK to continue iteration, SYSERR to abort
*/
static int addNamespaceContentToModel(void * cls,
- const ECRS_FileInfo * uri,
+ const ECRS_FileInfo * fi,
const HashCode512 * lastId,
const HashCode512 * nextId,
cron_t publicationFrequency,
cron_t nextPublicationTime) {
- GtkListStore * model = model;
- /* FIXME */
+ GtkListStore * model = GTK_LIST_STORE(cls);
+ GtkTreeIter iter;
+ char * filename;
+ char * desc;
+ char * mime;
+ char * uriString;
+ EncName last;
+ EncName next;
+ char * freq;
+ char * date;
+ unsigned long long size;
+ TIME_T t;
+ filename = ECRS_getFirstFromMetaData(fi->meta,
+ EXTRACTOR_FILENAME,
+ EXTRACTOR_TITLE,
+ EXTRACTOR_ARTIST,
+ EXTRACTOR_AUTHOR,
+ EXTRACTOR_PUBLISHER,
+ EXTRACTOR_CREATOR,
+ EXTRACTOR_PRODUCER,
+ EXTRACTOR_UNKNOWN,
+ -1);
+ if (filename == NULL)
+ filename = STRDUP(_("no name given"));
+ desc = ECRS_getFirstFromMetaData(fi->meta,
+ EXTRACTOR_DESCRIPTION,
+ EXTRACTOR_GENRE,
+ EXTRACTOR_ALBUM,
+ EXTRACTOR_COMMENT,
+ EXTRACTOR_SUBJECT,
+ EXTRACTOR_FORMAT,
+ EXTRACTOR_SIZE,
+ EXTRACTOR_KEYWORDS,
+ -1);
+ if (desc == NULL)
+ desc = STRDUP("");
+ mime = ECRS_getFromMetaData(fi->meta,
+ EXTRACTOR_MIMETYPE);
+ if (mime == NULL)
+ mime = STRDUP(_("unknown"));
+ size = ECRS_fileSize(fi->uri);
+ uriString = ECRS_uriToString(fi->uri);
+ hash2enc(lastId, &last);
+ hash2enc(nextId, &next);
+ t = nextPublicationTime / cronSECONDS;
+ date = GN_CTIME(&t);
+ freq = timeIntervalToFancyString(publicationFrequency);
+ gtk_list_store_append(model,
+ &iter);
+ gtk_list_store_set(model,
+ &iter,
+ IN_NAMESPACE_FILENAME, filename,
+ IN_NAMESPACE_SIZE, size,
+ IN_NAMESPACE_DESCRIPTION, desc,
+ IN_NAMESPACE_MIMETYPE, mime,
+ IN_NAMESPACE_LAST_STRING, &last,
+ IN_NAMESPACE_NEXT_STRING, &next,
+ IN_NAMESPACE_PUB_FREQ_STRING, freq,
+ IN_NAMESPACE_PUB_DATE_STRING, date,
+ IN_NAMESPACE_URI, ECRS_dupUri(fi->uri),
+ IN_NAMESPACE_META, ECRS_dupMetaData(fi->meta),
+ -1);
+ FREE(filename);
+ FREE(uriString);
+ FREE(freq);
+ FREE(date);
+ FREE(mime);
+
return OK;
}
@@ -260,13 +369,188 @@
return OK;
}
+/**
+ * FIXME: refactor code to share keyword/metadata list
+ * and model creation with upload and collection!
+ */
void create_namespace_clicked(GtkWidget * dummy1,
GtkWidget * dummy2) {
- /* FIXME */
- /* open dialog to enter namespace meta
- data; then create namespace; finally
- open tab */
+ const char * namespaceName;
+ GladeXML * metaXML;
+ GtkWidget * nameLine;
+ GtkWidget * metaList;
+ GtkWidget * keywordList;
+ GtkWidget * dialog;
+ GtkWidget * metaType;
+ GtkWidget * spin;
+ GtkListStore * metamodel;
+ GtkListStore * keymodel;
+ GtkCellRenderer * renderer;
+ GtkListStore * keywordTypeModel;
+ GtkTreeIter iter;
+ struct ECRS_MetaData * meta;
+ EXTRACTOR_KeywordType type;
+ struct ECRS_URI * keywordURI;
+ const char * stype;
+ char * mvalue;
+ char ** keywords;
+ unsigned int kpos;
+ unsigned int ksize;
+ struct ECRS_URI * root;
+ HashCode512 namespaceId;
+ HashCode512 rootEntry;
+ metaXML
+ = glade_xml_new(getGladeFileName(),
+ "namespaceMetaDataDialog",
+ NULL);
+ connectGladeWithPlugins(metaXML);
+ dialog = glade_xml_get_widget(metaXML,
+ "namespaceMetaDataDialog");
+ metamodel
+ = gtk_list_store_new(META_NUM,
+ G_TYPE_INT,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+ metaList = glade_xml_get_widget(metaXML,
+ "namespaceMetaDataDialogMetaDataList");
+ 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));
+ keymodel
+ = gtk_list_store_new(1,
+ G_TYPE_STRING);
+ keywordList = glade_xml_get_widget(metaXML,
+ "namespaceMetaDataDialogKeywordList");
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(keywordList),
+ -1,
+ _("Keyword"),
+ renderer,
+ "text", 0,
+ NULL);
+ gtk_tree_view_set_model(GTK_TREE_VIEW(keywordList),
+ GTK_TREE_MODEL(keymodel));
+ keywordTypeModel
+ = gtk_list_store_new(KTYPE_NUM,
+ G_TYPE_STRING,
+ G_TYPE_INT);
+ metaType
+ = glade_xml_get_widget(metaXML,
+ "namespaceMetaDataDialogMetaTypeComboBox");
+ 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_CANCEL) {
+ 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));
+ }
+ keywords = NULL;
+ ksize = 0;
+ GROW(keywords,
+ ksize,
+ 64);
+ kpos = 0;
+ if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(keymodel),
+ &iter)) {
+ do {
+ gtk_tree_model_get(GTK_TREE_MODEL(keymodel),
+ &iter,
+ 0, &mvalue,
+ -1);
+ keywords[kpos++] = mvalue;
+ if (kpos == ksize)
+ GROW(keywords,
+ ksize,
+ kpos*2);
+ } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(keymodel),
+ &iter));
+ }
+ keywords[kpos] = NULL;
+
+ keywordURI = ECRS_keywordsToUri((const char**)keywords);
+ while (kpos > 0)
+ FREE(keywords[--kpos]);
+ GROW(keywords,
+ ksize,
+ 0);
+ spin = glade_xml_get_widget(getMainXML(),
+ "namespaceAnonymityspinbutton");
+ nameLine = glade_xml_get_widget(getMainXML(),
+ "namespaceNameEntry");
+ namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine));
+ hash("FIXME", 5, &rootEntry); /* FIXME: need to fix glade file! */
+ root = NULL;
+ if (OK == FSUI_createNamespace(ctx,
+ gtk_spin_button_get_value_as_int
+ (GTK_SPIN_BUTTON(spin)),
+ namespaceName,
+ meta,
+ keywordURI,
+ &rootEntry,
+ &root)) {
+ ECRS_getNamespaceId(root,
+ &namespaceId);
+ addTabForNamespace(NULL,
+ namespaceName,
+ &namespaceId,
+ meta,
+ 0);
+ } else {
+ /* FIXME: give user feedback on failure! */
+ }
+ ECRS_freeUri(root);
+ ECRS_freeMetaData(meta);
+ ECRS_freeUri(keywordURI);
+ }
+ gtk_widget_destroy(dialog);
+ UNREF(metaXML);
+ metaXML = NULL;
}
void namespaceDelete_clicked(GtkWidget * dummy1,
Modified: gnunet-gtk/src/plugins/fs/upload.c
===================================================================
--- gnunet-gtk/src/plugins/fs/upload.c 2005-07-06 00:22:20 UTC (rev 1289)
+++ gnunet-gtk/src/plugins/fs/upload.c 2005-07-06 03:51:07 UTC (rev 1290)
@@ -673,7 +673,7 @@
metaXML = NULL;
}
-static char *selectFile() {
+static char * selectFile() {
#ifndef MINGW
GtkWidget *dialog;
GladeXML * uploadXML;
@@ -708,14 +708,14 @@
UNREF(uploadXML);
return ret;
#else /* MINGW */
- return plibc_ChooseDir(_("Choose the file or directory you want to
publish."),
- BIF_BROWSEINCLUDEFILES | BIF_USENEWUI | BIF_SHAREABLE |
BIF_NONEWFOLDERBUTTON);
+ return plibc_ChooseDir(_("Choose the file or directory you want to
publish."),
+ BIF_BROWSEINCLUDEFILES | BIF_USENEWUI | BIF_SHAREABLE
| BIF_NONEWFOLDERBUTTON);
#endif /* MINGW */
}
void on_mainFileSharingInsertBrowseButton_clicked(GtkWidget * browseButton,
gpointer dummy) {
- char *filename;
+ char *filename;
GtkWidget * uploadLine;
GtkWidget * entry;
GtkListStore * model;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r1290 - in gnunet-gtk: . src/plugins/fs,
grothoff <=