gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r12496 - gnunet gnunet-gtk/src


From: gnunet
Subject: [GNUnet-SVN] r12496 - gnunet gnunet-gtk/src
Date: Sat, 7 Aug 2010 23:46:01 +0200

Author: grothoff
Date: 2010-08-07 23:46:01 +0200 (Sat, 07 Aug 2010)
New Revision: 12496

Modified:
   gnunet-gtk/src/common.h
   gnunet-gtk/src/gnunet-gtk.c
   gnunet-gtk/src/main_window_file_search.c
   gnunet/TODO
Log:
done

Modified: gnunet/TODO
===================================================================
--- gnunet/TODO 2010-08-07 21:45:14 UTC (rev 12495)
+++ gnunet/TODO 2010-08-07 21:46:01 UTC (rev 12496)
@@ -20,12 +20,7 @@
 * GNUNET-GTK: [CG]
   - namespaces:
     + namespace search
-      / fill namespace list in dialog, use if selected
-      / NS list in search dialog should use colors to offset our own 
namespaces from the others
       / double-clicking on NS list in search dialog should move 'root' to 
keyword line
-      / right-clicking on NS list in search dialog should open menu that 
allows 
-        \ viewing full meta data 
-        \ deletion of namespace info
   - bugs:
     + handle 'lost parent' case for recursive downloads (need to move 
children!)
     + clean up TreeStores in main_window_file_publish on dialog close
@@ -181,3 +176,8 @@
   - [./transport/gnunet-service-transport.c:173]: (style) struct or union 
member 'TransportPlugin::rebuild' is never used (related to TCP not refreshing 
external addresses?)
 * BLOCKS:
   - testcase would be nice...
+* GNUNET-GTK:
+  - NS list in search dialog should use colors to offset our own namespaces 
from the others
+  - right-clicking on NS list in search dialog should open menu that allows 
+    * viewing full meta data 
+    * deletion of namespace info

Modified: gnunet-gtk/src/common.h
===================================================================
--- gnunet-gtk/src/common.h     2010-08-07 21:45:14 UTC (rev 12495)
+++ gnunet-gtk/src/common.h     2010-08-07 21:46:01 UTC (rev 12496)
@@ -99,6 +99,13 @@
 
 
 /**
+ * Get cfg.
+ */
+const struct GNUNET_CONFIGURATION_Handle *
+GNUNET_GTK_get_configuration (void);
+
+
+/**
  * Return handle for file-sharing operations.
  * @return NULL on error
  */

Modified: gnunet-gtk/src/gnunet-gtk.c
===================================================================
--- gnunet-gtk/src/gnunet-gtk.c 2010-08-07 21:45:14 UTC (rev 12495)
+++ gnunet-gtk/src/gnunet-gtk.c 2010-08-07 21:46:01 UTC (rev 12496)
@@ -113,6 +113,11 @@
   GtkBuilder *builder; 
 
   /**
+   * Our configuration.
+   */
+  const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+  /**
    * Handle for file-sharing operations.
    */
   struct GNUNET_FS_Handle *fs;
@@ -326,7 +331,16 @@
   return mc->plugins;
 }
 
+/**
+ * Get cfg.
+ */
+const struct GNUNET_CONFIGURATION_Handle *
+GNUNET_GTK_get_configuration (void)
+{
+  return mc->cfg;
+}
 
+
 /**
  * Callback invoked if the application is supposed to exit.
  */
@@ -542,6 +556,7 @@
   mc->gml = g_main_loop_new (NULL, TRUE);
   mc->gmc = g_main_loop_get_context (mc->gml);
   mc->sched = sched;  
+  mc->cfg = cfg;
   if (mc->builder == NULL)
     return;
 

Modified: gnunet-gtk/src/main_window_file_search.c
===================================================================
--- gnunet-gtk/src/main_window_file_search.c    2010-08-07 21:45:14 UTC (rev 
12495)
+++ gnunet-gtk/src/main_window_file_search.c    2010-08-07 21:46:01 UTC (rev 
12496)
@@ -40,6 +40,11 @@
   const char *keywords;
   char *emsg;
   struct GNUNET_FS_Uri *uri;
+  GNUNET_HashCode *nsid;
+  GtkTreeModel *ls;
+  GtkTreeView *tv;
+  GtkTreeSelection *sel;
+  GtkTreeIter iter;
 
   query = GTK_ENTRY (gtk_builder_get_object (builder,
                                             
"GNUNET_GTK_search_dialog_keyword_entry"));
@@ -48,29 +53,38 @@
   namespace = GTK_TREE_VIEW (gtk_builder_get_object (builder,
                                                     
"GNUNET_GTK_search_dialog_namespace_tree_view"));
   keywords = gtk_entry_get_text (query);
-  /* FIXME: check if namespace was selected */
-#if 0
+  nsid = NULL;
+  tv = GTK_TREE_VIEW (gtk_builder_get_object (builder,
+                                             
"GNUNET_GTK_search_dialog_namespace_tree_view"));
+  sel = gtk_tree_view_get_selection (tv); 
   if (TRUE ==
-      gtk_list_model_get_active_iter (model,
-                                     &iter))
+      gtk_tree_selection_get_selected (sel,
+                                      &ls,
+                                      &iter))
+    gtk_tree_model_get (ls, &iter,
+                       2, &nsid,
+                       -1);
+  if (nsid != NULL)
     {
-      gtk_list_model_get (model, &iter,
-                          NS_SEARCH_DESCRIPTION, &descStr, 
-                         NS_SEARCH_NAME, &nsName, 
-                         -1);
-      // ...
-    }      
-#endif
-  emsg = NULL;
-  uri = GNUNET_FS_uri_ksk_create (keywords, &emsg);
-  if (uri == NULL)
+      uri = GNUNET_FS_uri_sks_create_from_nsid (nsid,
+                                               keywords);    
+      GNUNET_assert (uri != NULL);
+    }
+  else    
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                 _("Invalid keyword string `%s': %s"),
-                 keywords,
-                 emsg);
-      GNUNET_free_non_null (emsg);
-      return;
+      emsg = NULL;
+      uri = GNUNET_FS_uri_ksk_create (keywords, &emsg);    
+      if (uri == NULL)
+       {
+         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                     (nsid != NULL) 
+                     ? _("Invalid namespace identifier `%s': %s")
+                     : _("Invalid keyword string `%s': %s"),
+                     keywords,
+                     emsg);
+         GNUNET_free_non_null (emsg);
+         return;
+       }
     }
   GNUNET_FS_search_start (GNUNET_GTK_get_fs_handle (),
                          uri,
@@ -81,7 +95,76 @@
 }
 
 
+
 /**
+ * Add pseudonym data to list store
+ *
+ * @param cls closure (the 'GtkListStore')
+ * @param pseudonym hash code of public key of pseudonym
+ * @param md meta data known about the pseudonym
+ * @param rating the local rating of the pseudonym
+ * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
+ */
+static int
+add_namespace_to_ls (void *cls,
+                    const GNUNET_HashCode *
+                    pseudonym,
+                    const struct
+                    GNUNET_CONTAINER_MetaData * md,
+                    int rating)
+{
+  GtkListStore *ls = cls;
+  char *root;
+  char *ns_name;
+  GNUNET_HashCode *nsid;
+  char *description;
+  char *uris;
+  char *emsg;
+  struct GNUNET_FS_Uri *uri;
+  GtkTreeIter iter;
+  
+  ns_name = GNUNET_PSEUDONYM_id_to_name (GNUNET_GTK_get_configuration (),
+                                        pseudonym);
+  nsid = GNUNET_malloc (sizeof (GNUNET_HashCode));
+  *nsid = *pseudonym;
+  root = NULL;
+  uris = GNUNET_CONTAINER_meta_data_get_by_type (md,
+                                                EXTRACTOR_METATYPE_URI);
+  if (uris != NULL)
+    {
+      emsg = NULL;
+      uri = GNUNET_FS_uri_parse (uris, &emsg);
+      if (uri == NULL)
+       GNUNET_free (emsg);
+      root = GNUNET_FS_uri_sks_get_content_id (uri);
+      GNUNET_FS_uri_destroy (uri);
+    }
+  description = GNUNET_CONTAINER_meta_data_get_first_by_types (md,
+                                                              
EXTRACTOR_METATYPE_TITLE,
+                                                              
EXTRACTOR_METATYPE_BOOK_TITLE,
+                                                              
EXTRACTOR_METATYPE_DESCRIPTION,
+                                                              
EXTRACTOR_METATYPE_SUMMARY,
+                                                              
EXTRACTOR_METATYPE_ALBUM,
+                                                              
EXTRACTOR_METATYPE_COMMENT,
+                                                              
EXTRACTOR_METATYPE_SUBJECT,
+                                                              
EXTRACTOR_METATYPE_KEYWORDS
+                                                              -1);
+  gtk_list_store_insert_with_values (ls,
+                                    &iter,
+                                    G_MAXINT,
+                                    0, ns_name,
+                                    1, root,
+                                    2, nsid,
+                                    3, description,
+                                    -1);
+  GNUNET_free (ns_name);
+  GNUNET_free_non_null (root);
+  GNUNET_free_non_null (description);
+  return GNUNET_OK;
+}
+
+
+/**
  * Search selected in 'file' menu.
  */
 void
@@ -99,8 +182,11 @@
                                           "GNUNET_GTK_search_dialog"));
   ls = GTK_LIST_STORE (gtk_builder_get_object (builder,
                                               
"GNUNET_GTK_namespace_list_store"));
-  /* FIXME: populate 'ls' */
+  GNUNET_PSEUDONYM_list_all (GNUNET_GTK_get_configuration (),
+                            &add_namespace_to_ls,
+                            ls);
   gtk_dialog_run (GTK_DIALOG (ad));
+  /* FIXME: free nsids from 'ls' */
   gtk_widget_destroy (ad);
   g_object_unref (G_OBJECT (builder));
   builder = NULL;




reply via email to

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