gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r28460 - in gnunet-gtk: contrib src/fs


From: gnunet
Subject: [GNUnet-SVN] r28460 - in gnunet-gtk: contrib src/fs
Date: Thu, 8 Aug 2013 11:36:04 +0200

Author: grothoff
Date: 2013-08-08 11:36:04 +0200 (Thu, 08 Aug 2013)
New Revision: 28460

Modified:
   gnunet-gtk/contrib/gnunet_fs_gtk_publish_dialog.glade
   gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c
Log:
-fixes to use identity properly in publish dialog

Modified: gnunet-gtk/contrib/gnunet_fs_gtk_publish_dialog.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_publish_dialog.glade       2013-08-08 
09:13:37 UTC (rev 28459)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_publish_dialog.glade       2013-08-08 
09:36:04 UTC (rev 28460)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <requires lib="gtk+" version="2.20"/>
+  <requires lib="gtk+" version="2.24"/>
   <!-- interface-naming-policy project-wide -->
   <object class="GtkTreeStore" 
id="GNUNET_GTK_file_sharing_publishing_tree_store">
     <columns>
@@ -22,26 +22,11 @@
       <column type="guint"/>
     </columns>
   </object>
-  <object class="GtkTreeStore" id="GNUNET_GTK_indentifiers_treestore">
-    <columns>
-      <!-- column-name Identifier -->
-      <column type="gchararray"/>
-      <!-- column-name UpdateIdentifier -->
-      <column type="gchararray"/>
-      <!-- column-name Description -->
-      <column type="gchararray"/>
-      <!-- column-name PathToOriginal -->
-      <column type="gchararray"/>
-      <!-- column-name IdentifierMarkedUp -->
-      <column type="gchararray"/>
-    </columns>
-  </object>
   <object class="GtkWindow" id="GNUNET_GTK_master_publish_dialog">
     <property name="height_request">500</property>
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Publish content on 
GNUnet</property>
     <property name="window_position">center-on-parent</property>
-    <property name="destroy_with_parent">True</property>
     <signal name="delete-event" 
handler="GNUNET_GTK_master_publish_dialog_delete_event_cb" swapped="no"/>
     <child>
       <object class="GtkVBox" id="GNUNET_GTK_master_publish_dialog_vbox">
@@ -339,6 +324,30 @@
                             <child>
                               <placeholder/>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -415,16 +424,18 @@
                           <object class="GtkCheckButton" 
id="GNUNET_GTK_master_publish_dialog_own_checkbox">
                             <property name="label" translatable="yes">Publish 
in your own namespace</property>
                             <property name="visible">True</property>
+                            <property name="sensitive">False</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
-                            <property name="tooltip_text" 
translatable="yes">Sign the publication with your private key (pseudonym), and 
give it an identifier, under which it will be found in your namespace.
-Other users will be able to browse anything you publish in your namespace (if 
you maintain a root element), or get separate files from your namespace by 
their identifiers, and be assured that these files come from the same 
(anonymous) publisher.
+                            <property name="tooltip_text" 
translatable="yes">Sign the publication with one of your pseudonyms, and give 
it an identifier, under which it will be found in your namespace.
 
-Unless specifically disabled in the configuration file, global namespace 
publications will also advertise your namespace, if you enable both global and 
private namespace publication.
+Using a pseudonym that you also use in a different context (i.e. GNS), may 
allow an adversary to link you to this publication, even if you selected 
anonymous pubishing. 
+Thus, you must keep your pseudonyms for anonymous publishing separate from all 
other alter egos you may use within GNUnet.
 
-Despite all that, private namespace publications are just as anonymous as 
global namespace publications.
+Once other users discover your namespace, they will be able to get files from 
your namespace by their identifiers, and be assured that these files all come 
from the same publisher.
 
-Publishing in both global and private namespaces will not double storage 
requirements for published files.</property>
+Publishing in both global and private namespaces will not double storage 
requirements for published files.
+</property>
                             <property name="draw_indicator">True</property>
                             <signal name="toggled" 
handler="GNUNET_GTK_master_publish_dialog_own_checkbox_toggled_cb" 
swapped="no"/>
                           </object>
@@ -435,13 +446,16 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkLabel" 
id="GNUNET_GTK_master_publish_dialog_own_label">
+                          <object class="GtkComboBox" 
id="GNUNET_GTK_master_publish_dialog_ego_combobox">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="label">&lt;filled with the name of 
selected default namespace&gt;</property>
+                            <property 
name="model">GNUNET_GTK_master_publish_dialog_ego_liststore</property>
+                            <property name="has_entry">True</property>
+                            <property name="entry_text_column">0</property>
+                            <signal name="changed" 
handler="GNUNET_GTK_master_publish_dialog_ego_combobox_changed_cb" 
swapped="no"/>
                           </object>
                           <packing>
-                            <property name="expand">False</property>
+                            <property name="expand">True</property>
                             <property name="fill">True</property>
                             <property name="position">1</property>
                           </packing>
@@ -465,6 +479,7 @@
                               <object class="GtkLabel" 
id="GNUNET_GTK_master_publish_dialog_identifier_label">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
+                                <property name="tooltip_text" 
translatable="yes">Name under which the publication will appear in your 
namespace. Equivalent to the keyword that is used when publishing in the global 
namespace.</property>
                                 <property name="xalign">0</property>
                                 <property name="label" 
translatable="yes">Identifier:</property>
                               </object>
@@ -477,6 +492,7 @@
                             <child>
                               <object class="GtkEntry" 
id="GNUNET_GTK_master_publish_dialog_identifier_entry">
                                 <property name="visible">True</property>
+                                <property name="sensitive">False</property>
                                 <property name="can_focus">True</property>
                                 <property name="tooltip_text" 
translatable="yes">Identifier under which this publication will be found in 
your namespace.
 Publications made in your namespace use only these identifiers, one per 
publication, instead of keywords.
@@ -505,6 +521,7 @@
                           <object class="GtkExpander" 
id="GNUNET_GTK_master_publish_dialog_previous_identifiers_expander">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
+                            <property name="tooltip_text" 
translatable="yes">Here you can find a list of previous publications you made 
in this namespace. This may be convenient if you want to publish an 
update.</property>
                             <child>
                               <placeholder/>
                             </child>
@@ -532,7 +549,7 @@
                               <object class="GtkTreeView" 
id="GNUNET_GTK_master_publish_dialog_previous_identifiers_treeview">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
-                                <property 
name="model">GNUNET_GTK_indentifiers_treestore</property>
+                                <property 
name="model">GNUNET_GTK_update_identifiers_treestore</property>
                                 <property 
name="headers_clickable">False</property>
                                 <property 
name="expander_column">GNUNET_GTK_master_publish_dialog_previous_identifiers_treeview_id_column</property>
                                 <property name="enable_search">False</property>
@@ -590,9 +607,12 @@
                               <object class="GtkCheckButton" 
id="GNUNET_GTK_master_publish_dialog_updateable_checkbox">
                                 <property name="label" translatable="yes">Make 
publication updateable</property>
                                 <property name="visible">True</property>
+                                <property name="sensitive">False</property>
                                 <property name="can_focus">True</property>
                                 <property 
name="receives_default">False</property>
-                                <property name="tooltip_text" 
translatable="yes">Enable and specify an update identifier to make this 
publication updateable.</property>
+                                <property name="tooltip_text" 
translatable="yes">With the update mechanism, you can publish updates to a file 
that will be automatically located when a users searches for the original 
identifier.
+
+To enable updates, you must check this box and specify an update 
identifier.</property>
                                 <property name="draw_indicator">True</property>
                                 <signal name="toggled" 
handler="GNUNET_GTK_master_publish_dialog_updateable_checkbox_toggled_cb" 
swapped="no"/>
                               </object>
@@ -620,6 +640,7 @@
                               <object class="GtkLabel" 
id="GNUNET_GTK_master_publish_dialog_update_id_label">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
+                                <property name="tooltip_text" 
translatable="yes">Identifier under which you "promise" to publish an update to 
this publication at a later time.</property>
                                 <property name="label" 
translatable="yes">Update identifier:</property>
                               </object>
                               <packing>
@@ -631,6 +652,7 @@
                             <child>
                               <object class="GtkEntry" 
id="GNUNET_GTK_master_publish_dialog_update_id_entry">
                                 <property name="visible">True</property>
+                                <property name="sensitive">False</property>
                                 <property name="can_focus">True</property>
                                 <property name="tooltip_text" 
translatable="yes">Identifier under which the updated version will be published 
later.
 GNUnet clients will use it to try to find updated version of this publication 
automatically.
@@ -746,6 +768,33 @@
       </object>
     </child>
   </object>
+  <object class="GtkListStore" 
id="GNUNET_GTK_master_publish_dialog_ego_liststore">
+    <columns>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+      <!-- column-name ego -->
+      <column type="gpointer"/>
+    </columns>
+  </object>
+  <object class="GtkTreeStore" id="GNUNET_GTK_update_identifiers_treestore">
+    <columns>
+      <!-- column-name Identifier -->
+      <column type="gchararray"/>
+      <!-- column-name UpdateIdentifier -->
+      <column type="gchararray"/>
+      <!-- column-name Description -->
+      <column type="gchararray"/>
+      <!-- column-name PathToOriginal -->
+      <column type="gchararray"/>
+      <!-- column-name IdentifierMarkedUp -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
+  <object class="GtkImage" id="left_stock_image">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="stock">gtk-go-back</property>
+  </object>
   <object class="GtkImage" id="new_stock_image">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -756,11 +805,6 @@
     <property name="can_focus">False</property>
     <property name="stock">gtk-go-forward</property>
   </object>
-  <object class="GtkImage" id="left_stock_image">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="stock">gtk-go-back</property>
-  </object>
   <object class="GtkSizeGroup" 
id="GNUNET_GTK_master_publish_dialog_labels_sizegroup">
     <widgets>
       <widget name="GNUNET_GTK_master_publish_dialog_identifier_label"/>

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c    2013-08-08 09:13:37 UTC 
(rev 28459)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c    2013-08-08 09:36:04 UTC 
(rev 28460)
@@ -119,6 +119,25 @@
 
 
 /**
+ * The columns in the "GNUNET_GTK_master_publish_dialog_ego_liststore"
+ */
+enum EGO_ModelColumns
+  {
+
+    /** 
+     * A gchararray.
+     */  
+    EGO_MC_NAME = 0,
+
+    /**
+     * A 'struct GNUNET_IDENTIFIER_Ego'.
+     */
+    EGO_MC_EGO = 1
+
+  };
+
+
+/**
  * Context we create when we are scanning a directory.
  */
 struct AddDirClientContext;
@@ -129,10 +148,16 @@
  */
 struct MainPublishingDialogContext
 {
+
   /**
    * Main builder for the publishing dialog.
    */
   GtkBuilder *builder;
+
+  /**
+   * Connection to the identity service.
+   */ 
+  struct GNUNET_IDENTITY_Handle *identity;
   
   /**
    * Handle to the main window of the publishing dialog.
@@ -195,12 +220,6 @@
   GtkWidget *own_checkbox;
 
   /**
-   * The label that shows name of the default namespace (if no default
-   * namespace is selected, shows appropriate message).
-   */
-  GtkWidget *own_label;
-
-  /**
    * Treeview that shows previously-used identifiers and possible update IDs.
    */
   GtkTreeView *identifiers_treeview;
@@ -451,8 +470,10 @@
      their windows are closed */
   if ( (gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter)) && 
        (pub_in_global || pub_in_own) &&
-       ((!pub_in_own) || ((NULL != ns_id) && ('\0' != ns_id[0]))) &&
-       (ctx->adddir_head == NULL) )
+       ((!pub_in_own) || ( (NULL != ctx->ns) && 
+                          (NULL != ns_id) &&
+                          ('\0' != ns_id[0])) ) &&
+       (NULL == ctx->adddir_head) )
     gtk_widget_set_sensitive (ctx->execute_button, TRUE);
   else
     gtk_widget_set_sensitive (ctx->execute_button, FALSE);
@@ -464,6 +485,7 @@
     gtk_widget_set_sensitive (ctx->cancel_button, FALSE);
 }
 
+
 /**
  * Update selectivity of up/down/left/right buttons in the master dialog.
  *
@@ -684,7 +706,7 @@
       copy_entry (ctx, tm, &child, &cnewpos, GNUNET_NO);
       path = gtk_tree_row_reference_get_path (crr);
       gtk_tree_row_reference_free (crr);
-      GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &child, path));
+      GNUNET_assert (gtk_tree_model_get_iter (tm, &child, path));
       gtk_tree_path_free (path);
     }
     while (gtk_tree_model_iter_next (tm, &child));
@@ -696,7 +718,7 @@
     path = gtk_tree_row_reference_get_path (rr);
     gtk_tree_row_reference_free (rr);
     gtk_tree_view_expand_to_path (ctx->file_info_treeview, path);
-    GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, newpos, path));
+    GNUNET_assert (gtk_tree_model_get_iter (tm, newpos, path));
     gtk_tree_path_free (path);
     gtk_tree_selection_select_iter (ctx->file_info_selection, newpos);
     update_selectivity_edit (ctx);
@@ -2039,7 +2061,7 @@
     }
     while (gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter));
   gtk_tree_store_clear (GTK_TREE_STORE (ctx->file_info_treemodel));
-
+  GNUNET_IDENTITY_disconnect (ctx->identity);
   gtk_widget_destroy (GTK_WIDGET (ctx->master_pubdialog));
   g_object_unref (G_OBJECT (ctx->builder));
   GNUNET_free_non_null (ctx->ns_name);
@@ -2067,16 +2089,20 @@
  */
 static int
 insert_advertisement (void *cls, struct GNUNET_FS_FileInformation *fi,
-    uint64_t length, struct GNUNET_CONTAINER_MetaData *meta,
-    struct GNUNET_FS_Uri **uri,
-    struct GNUNET_FS_BlockOptions *bo, int *do_index,
-    void **client_info)
+                     uint64_t length, 
+                     struct GNUNET_CONTAINER_MetaData *meta,
+                     struct GNUNET_FS_Uri **uri,
+                     struct GNUNET_FS_BlockOptions *bo, 
+                     int *do_index,
+                     void **client_info)
 {
   struct MainPublishingDialogContext *ctx = cls;
   struct GNUNET_CRYPTO_EccPublicKey pub;
   struct GNUNET_FS_Uri *sks_uri;
   char *sks_uri_string;
 
+  if (NULL == ctx->ns)
+    return GNUNET_SYSERR;
   GNUNET_IDENTITY_ego_get_public_key (ctx->ns, &pub);
   sks_uri = GNUNET_FS_uri_sks_create (&pub, "/");
   sks_uri_string = GNUNET_FS_uri_to_string (sks_uri);
@@ -2085,8 +2111,10 @@
     return GNUNET_SYSERR;
 
   GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>",
-      EXTRACTOR_METATYPE_URI, EXTRACTOR_METAFORMAT_UTF8,
-      "text/plain", sks_uri_string, strlen (sks_uri_string) + 1);
+                                    EXTRACTOR_METATYPE_URI, 
EXTRACTOR_METAFORMAT_UTF8,
+                                    "text/plain", 
+                                    sks_uri_string,
+                                    strlen (sks_uri_string) + 1);
   GNUNET_free (sks_uri_string);
   return GNUNET_SYSERR;
 }
@@ -2175,7 +2203,6 @@
       fi = get_file_information (ctx->file_info_treemodel, &iter);
       if (do_global && do_own && !disable_ads_insertion)
         GNUNET_FS_file_information_inspect (fi, insert_advertisement, ctx);
-      /* FIXME-FEATURE-BUG-MINOR: should we convert namespace id and uid from 
UTF8? */
       GNUNET_FS_publish_start (GNUNET_FS_GTK_get_fs_handle (), 
                               fi,
                               GNUNET_IDENTITY_ego_get_private_key (ns),
@@ -2356,7 +2383,9 @@
 
   g_value_init (&gv, G_TYPE_BOOLEAN);
   g_value_set_boolean (&gv, expanded);
-  gtk_container_child_set_property (GTK_CONTAINER (ctx->vpaned), 
ctx->bottom_frame, "resize", &gv);
+  gtk_container_child_set_property (GTK_CONTAINER (ctx->vpaned),
+                                   ctx->bottom_frame, 
+                                   "resize", &gv);
   paned_pos = gtk_paned_get_position (GTK_PANED (ctx->vpaned));
   paned_pos = paned_pos + (scrolled_allocation.height * (expanded ? -1 : 1));
   gtk_paned_set_position (GTK_PANED (ctx->vpaned), paned_pos);
@@ -2449,7 +2478,9 @@
     urilen = 0;
 
   mdbuf = NULL;
-  mdsize = GNUNET_CONTAINER_meta_data_serialize (last_meta, &mdbuf, 64*1024, 
GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
+  mdsize = GNUNET_CONTAINER_meta_data_serialize (last_meta, 
+                                                &mdbuf, 64*1024,
+                                                
GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
   if (0 > mdsize)
     mdsize = 0;
 
@@ -2535,18 +2566,19 @@
                                       next_id,
                                       &add_updateable_to_ts,
                                        &sc);
-  if ((sc.update_called == GNUNET_NO) && (next_id != NULL) &&
+  if ((sc.update_called == GNUNET_NO) && 
+      (NULL != next_id) &&
       (strlen (next_id) > 0))
   {
     /* add leaf */
     displaytext = g_strdup_printf ("<b>%s</b>", next_id);
     gtk_tree_store_insert_with_values (uc->ts, &titer, &iter, G_MAXINT,
-        IDENTIFIERS_MC_ID, next_id,
-        IDENTIFIERS_MC_UPDATE_ID, NULL,
-        IDENTIFIERS_MC_DESCRIPTION, NULL,
-        IDENTIFIERS_MC_PATH_TO_ORIGINAL, NULL,
-        IDENTIFIERS_MC_ID_MARKED_UP, displaytext,
-        -1);
+                                      IDENTIFIERS_MC_ID, next_id,
+                                      IDENTIFIERS_MC_UPDATE_ID, NULL,
+                                      IDENTIFIERS_MC_DESCRIPTION, NULL,
+                                      IDENTIFIERS_MC_PATH_TO_ORIGINAL, NULL,
+                                      IDENTIFIERS_MC_ID_MARKED_UP, displaytext,
+                                      -1);
     g_free (displaytext);
   }
 }
@@ -2572,34 +2604,146 @@
 
 
 /**
- * Add all updateable entries of the current namespace to the
- * tree store.
+ * User changed the selected namespace.  Check if it is valid,
+ * and if so, update the rest of the dialog accordingly.
  *
- * @param cls the 'GtkTreeStore' to update
- * @param name name of the namespace to add
- * @param id identity of the namespace to add
+ * @param combo the namespace selection combo box
+ * @param user_data the 'struct MainPublishingDialogContext'
  */
-static void
-add_namespace_to_ts (GtkTreeStore *ts, 
-                    struct GNUNET_IDENTITY_Ego *ns)
+void
+GNUNET_GTK_master_publish_dialog_ego_combobox_changed_cb (GtkComboBox *combo,
+                                                         gpointer user_data)
 {
+  struct MainPublishingDialogContext *ctx = user_data;
+  GtkTreeIter iter;
+  GtkTreeStore *ts;
+  GtkTreeModel *tm;
+  struct GNUNET_IDENTITY_Ego *ego;
   struct UpdateableContext uc;
 
+  ts = GTK_TREE_STORE (gtk_builder_get_object (ctx->builder,
+                                              
"GNUNET_GTK_update_identifiers_treestore"));
+  gtk_tree_store_clear (ts);
+  if (! gtk_combo_box_get_active_iter (combo, &iter))
+  {
+    /* entry unselected, etc. */
+    ctx->ns = NULL;
+    gtk_widget_set_sensitive (ctx->identifier_entry, FALSE);
+    gtk_widget_set_sensitive (ctx->updateable_checkbox, FALSE);
+    gtk_widget_set_sensitive (ctx->update_id_entry, FALSE);
+    update_selectivity_execute_cancel (ctx);
+    return;
+  }
+  tm = GTK_TREE_MODEL (gtk_builder_get_object (ctx->builder,
+                                              
"GNUNET_GTK_master_publish_dialog_ego_liststore"));
+  gtk_tree_model_get (tm, &iter,
+                     EGO_MC_EGO, &ego,
+                     -1);
+  if (NULL == ego)
+  {
+    GNUNET_break (0);
+    gtk_widget_set_sensitive (ctx->identifier_entry, FALSE);
+    gtk_widget_set_sensitive (ctx->updateable_checkbox, FALSE);
+    gtk_widget_set_sensitive (ctx->update_id_entry, FALSE);
+    update_selectivity_execute_cancel (ctx);
+    return;
+  }
+  ctx->ns = ego;
   uc.parent = NULL;
   uc.ts = ts;
-  uc.ns = ns;
+  uc.ns = ego;
   uc.update_called = GNUNET_NO;
   uc.seen = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
+
   GNUNET_FS_namespace_list_updateable (GNUNET_FS_GTK_get_fs_handle (), 
-                                      GNUNET_IDENTITY_ego_get_private_key 
(uc.ns),
+                                      GNUNET_IDENTITY_ego_get_private_key 
(ego),
                                       NULL,
-                                      &add_updateable_to_ts, &uc);
-  GNUNET_CONTAINER_multihashmap_iterate (uc.seen, free_seen_paths, NULL);
+                                      &add_updateable_to_ts,
+                                      &uc);
+  GNUNET_CONTAINER_multihashmap_iterate (uc.seen, &free_seen_paths, NULL);
   GNUNET_CONTAINER_multihashmap_destroy (uc.seen);
+  gtk_widget_set_sensitive (ctx->identifier_entry, TRUE);
+  gtk_widget_set_sensitive (ctx->updateable_checkbox, TRUE);
+  gtk_widget_set_sensitive (ctx->update_id_entry, TRUE);
+  update_selectivity_execute_cancel (ctx);
 }
 
 
 /**
+ * Add all updateable entries of the current namespace to the
+ * tree store.
+ *
+ * @param cls our 'struct MainPublishingDialogContext'
+ * @param ego identity of the namespace to add
+ * @param ego_ctx where to store context data 
+ * @param name name of the namespace to add
+ */
+static void
+add_namespace_to_ts (void *cls,
+                    struct GNUNET_IDENTITY_Ego *ego,
+                    void **ego_ctx,
+                    const char *name)
+{
+  struct MainPublishingDialogContext *ctx = cls;
+  GtkListStore *ls;
+  GtkTreePath *path;
+  GtkTreeRowReference *rr;
+  GtkTreeIter iter;
+  gboolean have_ns;
+
+  if (NULL == ego)
+    return; /* nothing to be done */
+  ls = GTK_LIST_STORE (gtk_builder_get_object (ctx->builder,
+                                              
"GNUNET_GTK_master_publish_dialog_ego_liststore"));
+  rr = *ego_ctx;
+  if (NULL == rr)
+  {
+    /* insert operation */
+    GNUNET_assert (NULL != name);
+    gtk_list_store_insert_with_values (ls, 
+                                      &iter, G_MAXINT,
+                                      EGO_MC_NAME, name,
+                                      EGO_MC_EGO, ego,
+                                      -1);
+    path = gtk_tree_model_get_path (GTK_TREE_MODEL (ls),
+                                   &iter);
+    rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ls), 
+                                    path);
+    gtk_tree_path_free (path);
+    *ego_ctx = rr;
+  }
+  else if (NULL == name)
+  {
+    /* delete operation */
+    path = gtk_tree_row_reference_get_path (rr);
+    gtk_tree_row_reference_free (rr);
+    GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ls),
+                                           &iter, path));
+    gtk_tree_path_free (path);
+    gtk_list_store_remove (ls, &iter);
+    *ego_ctx = NULL;
+  }
+  else
+  {
+    /* rename operation */
+    path = gtk_tree_row_reference_get_path (rr);
+    GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), 
+                                           &iter, path));
+    gtk_list_store_set (ls, 
+                       &iter, G_MAXINT,
+                       EGO_MC_NAME, name,
+                       -1);
+    gtk_tree_path_free (path);  
+  }
+  have_ns = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls), &iter);
+  gtk_widget_set_sensitive (ctx->own_checkbox, have_ns);
+  gtk_widget_set_sensitive (ctx->identifier_entry, have_ns);
+  gtk_widget_set_sensitive (ctx->updateable_checkbox, have_ns);
+  gtk_widget_set_sensitive (ctx->update_id_entry, have_ns);
+}
+
+
+/**
  * Run the file-publishing operation (by opening the master publishing dialog).
  * 
  * @param dummy widget that triggered the action
@@ -2610,9 +2754,8 @@
                                               gpointer user_data)
 {
   struct MainPublishingDialogContext *ctx;
-/*  GtkTreeView *pseudonym_treeview;*/
   const struct GNUNET_CONFIGURATION_Handle *cfg;
-  gboolean have_ns;
+  GtkWidget *toplevel;
   int updateable_enabled;
   int own_enabled;
   int global_enabled;
@@ -2642,7 +2785,7 @@
   ctx->execute_button = GTK_WIDGET (gtk_builder_get_object
       (ctx->builder, "GNUNET_GTK_master_publish_dialog_execute_button"));
   ctx->cancel_button = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder , "GNUNET_GTK_master_publish_dialog_cancel_button"));
+      (ctx->builder, "GNUNET_GTK_master_publish_dialog_cancel_button"));
   ctx->file_info_treeview = GTK_TREE_VIEW (gtk_builder_get_object
       (ctx->builder, 
"GNUNET_GTK_master_publish_dialog_file_information_tree_view"));
   ctx->file_info_selection = gtk_tree_view_get_selection 
(ctx->file_info_treeview);
@@ -2652,20 +2795,18 @@
                   (ctx->builder, "GNUNET_GTK_master_publish_dialog"));
 
   ctx->global_checkbox = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder , "GNUNET_GTK_master_publish_dialog_global_checkbox"));
+      (ctx->builder, "GNUNET_GTK_master_publish_dialog_global_checkbox"));
   ctx->own_checkbox = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder , "GNUNET_GTK_master_publish_dialog_own_checkbox"));
-  ctx->own_label = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder , "GNUNET_GTK_master_publish_dialog_own_label"));
+      (ctx->builder, "GNUNET_GTK_master_publish_dialog_own_checkbox"));
   ctx->updateable_checkbox = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder , "GNUNET_GTK_master_publish_dialog_updateable_checkbox"));
+      (ctx->builder, "GNUNET_GTK_master_publish_dialog_updateable_checkbox"));
   ctx->update_id_entry = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder , "GNUNET_GTK_master_publish_dialog_update_id_entry"));
+      (ctx->builder, "GNUNET_GTK_master_publish_dialog_update_id_entry"));
 
   ctx->own_vbox = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder , "GNUNET_GTK_master_publish_dialog_own_vbox"));
+      (ctx->builder, "GNUNET_GTK_master_publish_dialog_own_vbox"));
   ctx->update_id_hbox = GTK_WIDGET (gtk_builder_get_object
-      (ctx->builder , "GNUNET_GTK_master_publish_dialog_update_id_hbox"));
+      (ctx->builder, "GNUNET_GTK_master_publish_dialog_update_id_hbox"));
 
   ctx->identifiers_expander = GTK_WIDGET (gtk_builder_get_object 
(ctx->builder, 
"GNUNET_GTK_master_publish_dialog_previous_identifiers_expander"));
   ctx->vpaned = GTK_WIDGET (gtk_builder_get_object (ctx->builder, 
"GNUNET_GTK_master_publish_dialog_vpaned"));
@@ -2687,50 +2828,10 @@
                     G_CALLBACK (identifiers_selection_changed_cb), ctx);
 
   cfg = GNUNET_FS_GTK_get_configuration ();
-#if FIXME_MIGRATE_TO_IDENTITY_SERVICE
-  if (GNUNET_OK != 
-      GNUNET_CONFIGURATION_get_value_string (cfg,
-                                            "gnunet-fs-gtk",
-                                            "DEFAULT_NAMESPACE",
-                                            &ctx->ns_name))
-    ctx->ns_name = NULL;
-  else
-  {
-    ctx->ns = GNUNET_FS_namespace_open_existing (GNUNET_FS_GTK_get_fs_handle 
(), 
-                                                ctx->ns_name);
-    if (NULL == ctx->ns)
-      GNUNET_free (ctx->ns_name);
-  }
-#endif
-  have_ns = (NULL != ctx->ns);
+  ctx->identity = GNUNET_IDENTITY_connect (cfg,
+                                          &add_namespace_to_ts,
+                                          ctx);
 
-  gtk_widget_set_sensitive (ctx->own_checkbox, have_ns);
-  gtk_widget_set_sensitive (ctx->identifier_entry, have_ns);
-  gtk_widget_set_sensitive (ctx->updateable_checkbox, have_ns);
-  gtk_widget_set_sensitive (ctx->update_id_entry, have_ns);
-  if (ctx->ns)
-  {
-    gtk_label_set_text (GTK_LABEL (ctx->own_label), ctx->ns_name);
-    gtk_widget_set_tooltip_text (ctx->own_label, _(
-        "This is the label of your namespace that will be used for "
-        "publication, if you enable that option.\n"
-        "This label will not be part of the publication.\n"
-        "If you don't like this label, use Namespace Organizer to change it."
-        ));
-    add_namespace_to_ts (GTK_TREE_STORE (ctx->identifiers_treemodel), ctx->ns);
-    gtk_tree_view_expand_all (ctx->identifiers_treeview);
-  }
-  else
-  {
-    gtk_label_set_text (GTK_LABEL (ctx->own_label),
-        _("<no namespace is selected>"));
-    gtk_widget_set_tooltip_text (ctx->own_label, _(
-        "Namespace publication is unavailable, no namespace is selected.\n"
-        "Try to close this dialog, open Namespace Organizer dialog, and "
-        "select a namespace from a list of namespaces you own.\n"
-        "You may need to create one, if you don't have any."
-        ));
-  }
 
   updateable_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg,
       "gnunet-fs-gtk", "MAKE_UPDATEABLE_PUBLICATIONS_BY_DEFAULT");
@@ -2756,6 +2857,10 @@
       GNUNET_YES == global_enabled);
 
   /* show dialog */
+  toplevel = gtk_widget_get_toplevel (dummy);
+  if (GTK_IS_WINDOW (toplevel))
+    gtk_window_set_transient_for (GTK_WINDOW (ctx->master_pubdialog), 
+                                 GTK_WINDOW (toplevel));
   gtk_window_present (GTK_WINDOW (ctx->master_pubdialog));
 }
 




reply via email to

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