gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r1287 - in gnunet-gtk: . src/plugins/fs


From: grothoff
Subject: [GNUnet-SVN] r1287 - in gnunet-gtk: . src/plugins/fs
Date: Tue, 5 Jul 2005 17:14:04 -0700 (PDT)

Author: grothoff
Date: 2005-07-05 17:13:56 -0700 (Tue, 05 Jul 2005)
New Revision: 1287

Added:
   gnunet-gtk/src/plugins/fs/namespace.c
   gnunet-gtk/src/plugins/fs/namespace.h
Modified:
   gnunet-gtk/TODO
   gnunet-gtk/src/plugins/fs/Makefile.am
   gnunet-gtk/src/plugins/fs/fs.c
   gnunet-gtk/src/plugins/fs/fs.h
   gnunet-gtk/src/plugins/fs/search.c
   gnunet-gtk/src/plugins/fs/upload.c
Log:
started with namespace code -- so far UI only

Modified: gnunet-gtk/TODO
===================================================================
--- gnunet-gtk/TODO     2005-07-06 00:13:37 UTC (rev 1286)
+++ gnunet-gtk/TODO     2005-07-06 00:13:56 UTC (rev 1287)
@@ -10,17 +10,16 @@
   - start collection [ medium ]
   - stop collection [ easy ]
   - create directory from arbitrary mix [ medium ]
-* highlight completed downloads [ easy ]
-* highlight active downloads in search list [ easy ]
 
 Later (0.7.1):
+* highlight completed downloads [ easy ]
+* highlight active downloads in search list [ easy ]
 * auto-rename downloaded files to better names (user feedback!?) [ medium ]
 * stats integration [ medium ]
 * available apps [ medium ]
 * more help-texts (glade) [ easy ]
 * pop-up dialogs / context menus [ medium ]
 * chat [ difficult ]
-* look into I18N [ difficult ]
 * disable inactive buttons (if no search/download is selected to
   operate on) [ medium ]
 

Modified: gnunet-gtk/src/plugins/fs/Makefile.am
===================================================================
--- gnunet-gtk/src/plugins/fs/Makefile.am       2005-07-06 00:13:37 UTC (rev 
1286)
+++ gnunet-gtk/src/plugins/fs/Makefile.am       2005-07-06 00:13:56 UTC (rev 
1287)
@@ -8,10 +8,11 @@
  
 plugin_LTLIBRARIES = \
   libgnunetgtkmodule_fs.la
-   
+
 libgnunetgtkmodule_fs_la_SOURCES = \
   download.c download.h \
   fs.c fs.h \
+  namespace.c namespace.h \
   search.c search.h \
   upload.c upload.h
 libgnunetgtkmodule_fs_la_LIBADD = \

Modified: gnunet-gtk/src/plugins/fs/fs.c
===================================================================
--- gnunet-gtk/src/plugins/fs/fs.c      2005-07-06 00:13:37 UTC (rev 1286)
+++ gnunet-gtk/src/plugins/fs/fs.c      2005-07-06 00:13:56 UTC (rev 1287)
@@ -30,6 +30,7 @@
 #include "download.h"
 #include "search.h"
 #include "upload.h"
+#include "namespace.h"
 #include <GNUnet/gnunet_fsui_lib.h>
 
 struct FSUI_Context * ctx;
@@ -126,7 +127,7 @@
   return NULL;
 }
 
-void init_fs(void) {
+void init_fs() {
   GtkWidget * tab;
 
   tab
@@ -142,13 +143,18 @@
   fs_search_start();
   fs_download_start();
   fs_upload_start();
+  fs_namespace_start();
 }
 
-void done_fs(void) {
+void done_fs() {
   PTHREAD_T doneThread;
   Semaphore * sig;
   void * unused;
 
+  fs_upload_stop();
+  fs_download_stop();
+  fs_search_stop();
+  fs_namespace_stop();
   sig = SEMAPHORE_NEW(0);
   if (0 != PTHREAD_CREATE(&doneThread,
                          (PThreadMain)&shutdownCode,

Modified: gnunet-gtk/src/plugins/fs/fs.h
===================================================================
--- gnunet-gtk/src/plugins/fs/fs.h      2005-07-06 00:13:37 UTC (rev 1286)
+++ gnunet-gtk/src/plugins/fs/fs.h      2005-07-06 00:13:56 UTC (rev 1287)
@@ -60,6 +60,29 @@
 };
 
 enum {
+  NAMESPACE_FILENAME = 0,
+  NAMESPACE_SIZE,
+  NAMESPACE_URISTRING,
+  NAMESPACE_URI,
+  NAMESPACE_NUM
+};
+
+enum {
+  IN_NAMESPACE_FILENAME = 0,
+  IN_NAMESPACE_SIZE,
+  IN_NAMESPACE_DESCRIPTION,
+  IN_NAMESPACE_MIMETYPE,
+  IN_NAMESPACE_LAST_STRING,
+  IN_NAMESPACE_NEXT_STRING,
+  IN_NAMESPACE_PUB_FREQ_STRING,
+  IN_NAMESPACE_PUB_DATE_STRING,
+  IN_NAMESPACE_URI,
+  IN_NAMESPACE_META,
+  IN_NAMESPACE_NUM
+};
+
+
+enum {
   UPLOAD_FILENAME = 0,
   UPLOAD_PROGRESS,
   UPLOAD_URISTRING,

Added: gnunet-gtk/src/plugins/fs/namespace.c
===================================================================
--- gnunet-gtk/src/plugins/fs/namespace.c       2005-07-06 00:13:37 UTC (rev 
1286)
+++ gnunet-gtk/src/plugins/fs/namespace.c       2005-07-06 00:13:56 UTC (rev 
1287)
@@ -0,0 +1,336 @@
+/*
+     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/namespace.c
+ * @brief code for operations with namespaces
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunetgtk_common.h"
+#include "fs.h"
+#include "namespace.h"
+#include <extractor.h>
+
+
+
+/**
+ * @brief linked list of pages in the search notebook
+ */
+typedef struct NL {
+  struct NL * next;
+  GtkWidget * treeview;
+  GtkWidget * searchpage;
+  GtkTreeModel * model;
+  GtkWidget * anonymityButton;
+  char * name;
+  HashCode512 id;
+  struct ECRS_MetaData * meta;
+} NamespaceList;
+
+static NamespaceList * head;
+
+static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview,
+                                     GtkWidget ** anonSpin) {
+  GtkWidget * window;
+  GtkWidget * child;
+  GtkWidget * resultList;
+  GtkCellRenderer * renderer;
+  GtkTreeStore * tree;
+  GladeXML * namespaceXML;
+
+  namespaceXML
+    = glade_xml_new(getGladeFileName(),
+                   "namespaceContentFrame", 
+                   NULL);
+  connectGladeWithPlugins(namespaceXML);
+  window = glade_xml_get_widget(namespaceXML,
+                               "namespaceContentFrame");
+  resultList = glade_xml_get_widget(namespaceXML,
+                                   "namespaceContentFrameTreeView");
+  *anonSpin = glade_xml_get_widget(namespaceXML,
+                                  "namespaceAnonymitySpinButton");
+  if (treeview != NULL)
+    (*treeview) = GTK_WIDGET(GTK_TREE_VIEW(resultList));
+  tree =
+    gtk_list_store_new(IN_NAMESPACE_NUM,
+                      G_TYPE_STRING, /* (file)name */
+                      G_TYPE_UINT64,  /* size */
+                      G_TYPE_STRING, /* description */
+                      G_TYPE_STRING, /* mime-type */ 
+                      G_TYPE_STRING, /* last-ID */   
+                      G_TYPE_STRING, /* next-ID */   
+                      G_TYPE_STRING, /* pub-freq */   
+                      G_TYPE_STRING, /* next pub date */   
+                      G_TYPE_POINTER,  /* URI */
+                      G_TYPE_POINTER);  /* META */
+  gtk_tree_view_set_model(GTK_TREE_VIEW(resultList),
+                         GTK_TREE_MODEL(tree));
+  renderer = gtk_cell_renderer_text_new();
+  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
+                                             -1,
+                                             _("Filename"),
+                                             renderer,
+                                             "text", IN_NAMESPACE_FILENAME,
+                                             NULL);
+  renderer = gtk_cell_renderer_text_new();
+  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
+                                             -1,
+                                             _("Filesize"),
+                                             renderer,
+                                             "text", IN_NAMESPACE_SIZE,
+                                             NULL);
+  renderer = gtk_cell_renderer_text_new();
+  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
+                                             -1,
+                                             _("Description"),
+                                             renderer,
+                                             "text", IN_NAMESPACE_DESCRIPTION,
+                                             NULL);
+  renderer = gtk_cell_renderer_text_new();
+  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
+                                             -1,
+                                             _("Mime-type"),
+                                             renderer,
+                                             "text", IN_NAMESPACE_MIMETYPE,
+                                             NULL);
+  renderer = gtk_cell_renderer_text_new();
+  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
+                                             -1,
+                                             _("Last ID"),
+                                             renderer,
+                                             "text", IN_NAMESPACE_LAST_STRING,
+                                             NULL);
+  renderer = gtk_cell_renderer_text_new();
+  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
+                                             -1,
+                                             _("Next ID"),
+                                             renderer,
+                                             "text", IN_NAMESPACE_NEXT_STRING,
+                                             NULL);
+
+
+  renderer = gtk_cell_renderer_text_new();
+  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
+                                             -1,
+                                             _("Publication Frequency"),
+                                             renderer,
+                                             "text", 
IN_NAMESPACE_PUB_FREQ_STRING,
+                                             NULL);
+  renderer = gtk_cell_renderer_text_new();
+  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
+                                             -1,
+                                             _("Next Publication Date"),
+                                             renderer,
+                                             "text", 
IN_NAMESPACE_PUB_DATE_STRING,
+                                             NULL);
+  child = gtk_bin_get_child(GTK_BIN(window));
+  gtk_widget_ref(GTK_WIDGET(child));
+  gtk_container_remove(GTK_CONTAINER(window),
+                      child);
+  gtk_widget_destroy(window);
+  UNREF(namespaceXML);
+
+  return child;
+}
+
+
+
+/**
+ * Add the given content to the globally available
+ * content model.
+ */
+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! */
+  return OK;
+}
+
+/**
+ * Update the list of the globally available content.
+ */
+static void doUpdateContentList(void * unused) {
+  GtkWidget * contentList;
+  GtkTreeModel * model;
+  contentList
+    = glade_xml_get_widget(getMainXML(),
+                          "availableContentList");
+  model
+    = gtk_tree_view_get_model(GTK_TREE_VIEW(contentList));
+  FSUI_listURIs(&updateView,
+               model);
+}
+
+static void updateContentList(void * unused) {
+  gtkSaveCall(&doUpdateContentList, NULL);
+}
+
+
+/**
+ * Update the model that lists the content of a namespace:
+ * add this content.
+ *
+ * @param uri URI of the last content published
+ * @param lastId the ID of the last publication
+ * @param nextId the ID of the next update
+ * @param publicationFrequency how often are updates scheduled?
+ * @param nextPublicationTime the scheduled time for the
+ *  next update (0 for sporadic updates)
+ * @return OK to continue iteration, SYSERR to abort
+ */
+static int addNamespaceContentToModel(void * cls,
+                                     const ECRS_FileInfo * uri,
+                                     const HashCode512 * lastId,
+                                     const HashCode512 * nextId,
+                                     cron_t publicationFrequency,
+                                     cron_t nextPublicationTime) {
+  GtkListStore * model = model;
+  /* FIXME */
+
+  return OK;
+}
+
+/**
+ * Add a tab for the given namespace.
+ */
+static int addTabForNamespace(void * unused,
+                             const char * namespaceName,
+                             const HashCode512 * namespaceId,
+                             const struct ECRS_MetaData * md,
+                             int rating) {
+  
+  NamespaceList * list;
+  GtkWidget * label;
+  GtkWidget * spin;
+  GtkWidget * notebook;
+  GtkListStore * model;
+
+  label = gtk_label_new(namespaceName);
+  list = MALLOC(sizeof(NamespaceList));
+  list->name = STRDUP(namespaceName);
+  list->id = *namespaceId;
+  list->meta = ECRS_dupMetaData(md);
+  list->searchpage
+    = makeNamespaceFrame(&list->treeview,
+                        &spin);
+  list->anonymityButton
+    = spin;
+  model = GTK_LIST_STORE
+    (gtk_tree_view_get_model
+     (GTK_TREE_VIEW(list->treeview)));
+  list->model
+    = GTK_TREE_MODEL(model);
+  list->next
+    = head;
+  head = list;
+  notebook
+    = glade_xml_get_widget(getMainXML(),
+                          "localNamespacesNotebook");
+  gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
+                          list->searchpage,
+                          label);
+  gtk_widget_show(notebook);
+
+  FSUI_listNamespaceContent
+    (ctx,
+     namespaceName,
+     &addNamespaceContentToModel,
+     model);
+  return OK;
+}
+
+void create_namespace_clicked(GtkWidget * dummy1,
+                             GtkWidget * dummy2) {
+  /* FIXME */
+  /* open dialog to enter namespace meta
+     data; then create namespace; finally
+     open tab */
+
+}
+
+void namespaceDelete_clicked(GtkWidget * dummy1,
+                            GtkWidget * dummy2) {
+  /* FIXME */
+  /* find currently active namespace,
+     open window to ask for confirmation,
+     then delete */
+}
+
+
+void fs_namespace_start() {
+  GtkWidget * contentList;
+  GtkListStore * model;
+  GtkCellRenderer * renderer;
+
+  contentList
+    = glade_xml_get_widget(getMainXML(),
+                          "availableContentList");
+
+  model = gtk_list_store_new(NAMESPACE_NUM, 
+                            G_TYPE_STRING, /* name */
+                            G_TYPE_UINT64, /* size */
+                            G_TYPE_STRING, /* uri-string */
+                            G_TYPE_POINTER); /* uri */
+  gtk_tree_view_set_model(GTK_TREE_VIEW(contentList),
+                         GTK_TREE_MODEL(model));
+  renderer = gtk_cell_renderer_text_new();
+  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(contentList),
+                                             -1,
+                                             _("Filename"),
+                                             renderer,
+                                             "text", NAMESPACE_FILENAME,
+                                             NULL);
+  renderer = gtk_cell_renderer_text_new();
+  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(contentList),
+                                             -1,
+                                             _("Filesize"),
+                                             renderer,
+                                             "text", NAMESPACE_SIZE,
+                                             NULL);
+  renderer = gtk_cell_renderer_text_new();
+  gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(contentList),
+                                             -1,
+                                             _("URI"),
+                                             renderer,
+                                             "text", NAMESPACE_URISTRING,
+                                             NULL);    
+  addCronJob(&updateContentList,
+            0,
+            5 * cronMINUTES,
+            NULL);
+  FSUI_listNamespaces(ctx,
+                     YES,
+                     &addTabForNamespace,
+                     NULL);
+}
+
+void fs_namespace_stop() {
+  /* FIXME: free memory! */
+
+  delCronJob(&updateContentList,
+            5 * cronMINUTES,
+            NULL);
+}
+
+/* end of namespace.c */

Added: gnunet-gtk/src/plugins/fs/namespace.h
===================================================================
--- gnunet-gtk/src/plugins/fs/namespace.h       2005-07-06 00:13:37 UTC (rev 
1286)
+++ gnunet-gtk/src/plugins/fs/namespace.h       2005-07-06 00:13:56 UTC (rev 
1287)
@@ -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/namespace.h
+ * @brief code for dealing with namespaces
+ * @author Christian Grothoff
+ */
+
+#ifndef GTK_NAMESPACE_H
+#define GTK_NAMESPACE_H
+
+void fs_namespace_start(void);
+
+void fs_namespace_stop(void);
+
+#endif

Modified: gnunet-gtk/src/plugins/fs/search.c
===================================================================
--- gnunet-gtk/src/plugins/fs/search.c  2005-07-06 00:13:37 UTC (rev 1286)
+++ gnunet-gtk/src/plugins/fs/search.c  2005-07-06 00:13:56 UTC (rev 1287)
@@ -30,7 +30,26 @@
 #include "fs.h"
 #include <extractor.h>
 
+
+
 /**
+ * @brief linked list of pages in the search notebook
+ */
+typedef struct SL {
+  struct SL * next;
+  GtkWidget * treeview;
+  GtkWidget * searchpage;
+  GtkTreeModel * model;
+  GtkWidget * anonymityButton;
+  struct ECRS_URI * uri;
+} SearchList;
+
+static SearchList * head;
+
+static GtkListStore * summary;
+
+
+/**
  * Add an entry to the search tree.
  *
  * @param model the search model
@@ -113,23 +132,6 @@
 }
                          
 
-
-/**
- * @brief linked list of pages in the search notebook
- */
-typedef struct SL {
-  struct SL * next;
-  GtkWidget * treeview;
-  GtkWidget * searchpage;
-  GtkTreeModel * model;
-  GtkWidget * anonymityButton;
-  struct ECRS_URI * uri;
-} SearchList;
-
-static SearchList * head;
-
-static GtkListStore * summary;
-
 GtkWidget * getAnonymityButtonFromTM(GtkTreeModel * model) {
   SearchList * list;
 

Modified: gnunet-gtk/src/plugins/fs/upload.c
===================================================================
--- gnunet-gtk/src/plugins/fs/upload.c  2005-07-06 00:13:37 UTC (rev 1286)
+++ gnunet-gtk/src/plugins/fs/upload.c  2005-07-06 00:13:56 UTC (rev 1287)
@@ -784,6 +784,7 @@
 }
 
 void fs_upload_stop() {
+  /* FIXME: release memory */
 }
 
 /* end of upload.c */





reply via email to

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