gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r27886 - in gnunet-gtk: contrib src/setup


From: gnunet
Subject: [GNUnet-SVN] r27886 - in gnunet-gtk: contrib src/setup
Date: Wed, 10 Jul 2013 16:35:48 +0200

Author: grothoff
Date: 2013-07-10 16:35:48 +0200 (Wed, 10 Jul 2013)
New Revision: 27886

Modified:
   gnunet-gtk/contrib/gnunet_setup_gtk_main_window.glade
   gnunet-gtk/src/setup/gnunet-setup-gns.c
Log:
-fixes towards working zone editor

Modified: gnunet-gtk/contrib/gnunet_setup_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_setup_gtk_main_window.glade       2013-07-10 
14:23:19 UTC (rev 27885)
+++ gnunet-gtk/contrib/gnunet_setup_gtk_main_window.glade       2013-07-10 
14:35:48 UTC (rev 27886)
@@ -4519,7 +4519,7 @@
                               <object class="GtkCellRendererCombo" 
id="GNUNET_setup_gns_type_cellrenderercombo">
                                 <property 
name="model">GNUNET_setup_gns_type_liststore</property>
                                 <property name="text_column">1</property>
-                                <signal name="edited" 
handler="GNUNET_setup_gns_type_cellrenderercombo_edited_cb" swapped="no"/>
+                                <signal name="changed" 
handler="GNUNET_setup_gns_type_cellrenderercombo_changed_cb" swapped="no"/>
                               </object>
                               <attributes>
                                 <attribute name="visible">10</attribute>
@@ -4741,6 +4741,8 @@
       <column type="gboolean"/>
       <!-- column-name name_is_editable -->
       <column type="gboolean"/>
+      <!-- column-name record_offset -->
+      <column type="guint"/>
     </columns>
   </object>
   <object class="GtkListStore" id="GNUNET_setup_gns_type_liststore">

Modified: gnunet-gtk/src/setup/gnunet-setup-gns.c
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup-gns.c     2013-07-10 14:23:19 UTC (rev 
27885)
+++ gnunet-gtk/src/setup/gnunet-setup-gns.c     2013-07-10 14:35:48 UTC (rev 
27886)
@@ -153,7 +153,12 @@
   /**
    * A gboolean; TRUE if the name is editable (dummy line).
    */
-  GNS_TREESTORE_COL_NAME_IS_EDITABLE
+  GNS_TREESTORE_COL_NAME_IS_EDITABLE,
+
+  /**
+   * A guint; offset of this record in the array.
+   */
+  GNS_TREESTORE_COL_RECORD_OFFSET
 };
 
 
@@ -568,7 +573,6 @@
 }
 
 
-
 /**
  * Load a particular zone into the main tree view.
  *
@@ -593,7 +597,7 @@
   GtkWindow *main_window;
   GtkDialog *dialog;
 
-  /* FIXME: consider replacing with widget in the main window */
+  /* TODO: consider replacing with widget in the main window */
   main_window = GTK_WINDOW (GNUNET_SETUP_get_object ("GNUNET_setup_dialog"));
   dialog = GTK_DIALOG(gtk_message_dialog_new (main_window,
                                              GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -608,157 +612,6 @@
 
 
 /**
- * Remove selected record from the namestore.
- * 
- * @param edc identifying record to remove
- */
-static void
-remove_record_at_offset (struct EditDialogContext *edc)
-{
-  struct RecordInfo *ri = edc->ri;
-  struct OperationContext *oc;
-  
-  if ( (NULL == ri) ||
-       (edc->off >= ri->rd_count) )
-  {
-    GNUNET_break (0);
-    return;
-  }
-  
-  {
-    struct GNUNET_NAMESTORE_RecordData rd_old[ri->rd_count];
-    struct GNUNET_NAMESTORE_RecordData rd_new[ri->rd_count - 1];
-
-    /* Removing a single record */
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Removing single record for name `%s'\n", 
-               edc->name);
-    GNUNET_break (GNUNET_OK ==
-                 GNUNET_NAMESTORE_records_deserialize (ri->data_size,
-                                                       ri->data,
-                                                       ri->rd_count,
-                                                       rd_old));
-    GNUNET_assert (edc->off < ri->rd_count);
-    memcpy (rd_new, rd_old, (ri->rd_count - 1) * sizeof (struct 
GNUNET_NAMESTORE_RecordData));
-    rd_new[edc->off] = rd_old[ri->rd_count - 1];
-    oc = GNUNET_new (struct OperationContext);
-    GNUNET_CONTAINER_DLL_insert (oc_head, oc_tail, oc);
-    oc->qe = GNUNET_NAMESTORE_record_put_by_authority (namestore, 
-                                                      pkey, edc->name,
-                                                      ri->rd_count - 1,
-                                                      rd_new,
-                                                      &operation_done_cont, 
oc);
-  }
-}
-
-
-
-/**
- * Remove a record from the model.  If the given iter identifies an
- * entire 'name', remove all records under that name.
- * 
- * @param iter identifying record(s) to remove
- */
-static void
-remove_records_by_iter (GtkTreeIter *iter)
-{
-  GtkTreeIter parent;
-  char *name;
-  struct GNUNET_HashCode name_hash;
-  struct RecordInfo *ri;
-  struct OperationContext *oc;
-  
-  gtk_tree_model_get (tm, iter,
-                     GNS_TREESTORE_COL_NAME, &name,
-                     -1);
-  GNUNET_CRYPTO_hash (name, strlen (name), &name_hash);
-  ri = GNUNET_CONTAINER_multihashmap_get (n2r,
-                                         &name_hash);
-  GNUNET_assert (NULL != ri);
-  
-  if ( (gtk_tree_model_iter_parent (tm, &parent, iter)) &&
-       (ri->rd_count > 0) )
-  {
-    struct GNUNET_NAMESTORE_RecordData rd_old[ri->rd_count];
-    struct GNUNET_NAMESTORE_RecordData rd_new[ri->rd_count - 1];
-    struct GNUNET_NAMESTORE_RecordData rd;
-    unsigned int off;
-    int n_type;
-    gboolean n_public;
-    guint64 n_exp_time;
-    gboolean n_is_relative;
-    gboolean n_is_shadow;
-    char *n_value;
-
-    /* Removing a single record */
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-               "Removing single record for name `%s'\n", 
-               name);
-    GNUNET_break (GNUNET_OK ==
-                 GNUNET_NAMESTORE_records_deserialize (ri->data_size,
-                                                       ri->data,
-                                                       ri->rd_count,
-                                                       rd_old));
-    gtk_tree_model_get (tm, iter,
-                       GNS_TREESTORE_COL_RECORD_TYPE, &n_type,
-                       GNS_TREESTORE_COL_IS_PUBLIC, &n_public,
-                       GNS_TREESTORE_COL_EXP_TIME, &n_exp_time,
-                       GNS_TREESTORE_COL_EXP_TIME_IS_REL, &n_is_relative,
-                       GNS_TREESTORE_COL_IS_SHADOW, &n_is_shadow,
-                       GNS_TREESTORE_COL_VAL_AS_STR, &n_value,
-                       -1);
-    /* valid name */
-    if (n_public)
-      rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
-    else
-      rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY | GNUNET_NAMESTORE_RF_PRIVATE;
-    if (n_is_relative)
-      rd.flags |= GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION;
-    if (n_is_shadow)
-      rd.flags |= GNUNET_NAMESTORE_RF_SHADOW_RECORD;
-    rd.record_type = n_type;
-    rd.expiration_time = n_exp_time;
-    if (GNUNET_OK !=
-       GNUNET_NAMESTORE_string_to_value (n_type, n_value,
-                                         (void**)&rd.data, &rd.data_size))
-    {
-      /* can't remove, value invalid */
-      GNUNET_assert (0);
-      g_free (n_value);
-      g_free (name);
-      return;
-    }
-    for (off=0;off<ri->rd_count;off++)
-      if (GNUNET_YES ==
-         GNUNET_NAMESTORE_records_cmp (&rd,
-                                       &rd_old[off]))
-       break;
-    GNUNET_assert (off != ri->rd_count);
-    memcpy (rd_new, rd_old, (ri->rd_count - 1) * sizeof (struct 
GNUNET_NAMESTORE_RecordData));
-    rd_new[off] = rd_old[ri->rd_count - 1];
-    oc = GNUNET_new (struct OperationContext);
-    GNUNET_CONTAINER_DLL_insert (oc_head, oc_tail, oc);
-    oc->qe = GNUNET_NAMESTORE_record_put_by_authority (namestore, 
-                                                      pkey, name,
-                                                      ri->rd_count - 1,
-                                                      rd_new,
-                                                      &operation_done_cont, 
oc);
-    g_free (n_value);
-  }
-  else
-  {
-    oc = GNUNET_new (struct OperationContext);
-    GNUNET_CONTAINER_DLL_insert (oc_head, oc_tail, oc);
-    oc->qe = GNUNET_NAMESTORE_record_put_by_authority (namestore, 
-                                                      pkey, name,
-                                                      0, NULL,
-                                                      &operation_done_cont, 
oc);
-  }
-  g_free (name);
-}
-
-
-/**
  * Release resources of an edit dialog context.
  *
  * @param edc resources to free
@@ -784,13 +637,68 @@
 edit_dialog_continuation (struct EditDialogContext *edc,
                          GtkResponseType ret)
 {
+  struct RecordInfo *ri = edc->ri;
+  unsigned int rd_count = (NULL == ri) ? 0 : ri->rd_count;
+  struct GNUNET_NAMESTORE_RecordData rd_old[rd_count];
+  struct GNUNET_NAMESTORE_RecordData rd;
+  void *data;
+  size_t data_size;
+  struct OperationContext *oc;
+    
+  if ( (NULL != ri) &&
+       (GNUNET_OK !=
+       GNUNET_NAMESTORE_records_deserialize (ri->data_size,
+                                             ri->data,
+                                             ri->rd_count,
+                                             rd_old)) )
+  {
+    GNUNET_break (0);
+    free_edit_dialog_context (edc);
+    return;
+  }
+  if ( (GTK_RESPONSE_CANCEL == ret) ||
+       (GTK_RESPONSE_DELETE_EVENT == ret) )
+  {
+    free_edit_dialog_context (edc);
+    return;
+  }
+  if (GNUNET_OK != GNUNET_NAMESTORE_string_to_value (edc->record_type, 
edc->n_value, 
+                                                    &data, &data_size))    
+  {
+    GNUNET_break (0);
+    free_edit_dialog_context (edc);
+    return;
+  }
+  if (edc->n_public)
+    rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
+  else
+    rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY | GNUNET_NAMESTORE_RF_PRIVATE;
+  if (edc->n_is_shadow)
+    rd.flags |= GNUNET_NAMESTORE_RF_SHADOW_RECORD;
+  rd.record_type = edc->record_type;
+  rd.expiration_time = edc->n_exp_time;
+  if (edc->n_is_relative)
+    rd.flags |= GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION;
+  rd.data_size = data_size;
+  rd.data = data;
   switch (ret)
   {
   case GTK_RESPONSE_REJECT: /* code for 'delete' */
     if (GNUNET_YES == edc->old_record_in_namestore)
     {
       /* remove item from tree view and namestore */
-      remove_record_at_offset (edc);
+      struct GNUNET_NAMESTORE_RecordData rd_new[rd_count - 1];
+
+      GNUNET_assert (NULL != ri);     
+      memcpy (rd_new, rd_old, (rd_count - 1) * sizeof (struct 
GNUNET_NAMESTORE_RecordData));
+      rd_new[edc->off] = rd_old[rd_count - 1];
+      oc = GNUNET_new (struct OperationContext);
+      GNUNET_CONTAINER_DLL_insert (oc_head, oc_tail, oc);
+      oc->qe = GNUNET_NAMESTORE_record_put_by_authority (namestore, 
+                                                        pkey, edc->name,
+                                                        rd_count + 1,
+                                                        rd_new,
+                                                        &operation_done_cont, 
oc);
     }
     else
     {
@@ -798,10 +706,6 @@
       GNUNET_break (0);
     }
     break;
-  case GTK_RESPONSE_CANCEL:
-  case GTK_RESPONSE_DELETE_EVENT: /* window deletion counts as 'cancel' */
-    /* do nothing */
-    break;
   case GTK_RESPONSE_OK:
     /* update model */
     if (0 == strcmp (edc->new_zone_option,
@@ -809,13 +713,32 @@
     {
       if (GNUNET_YES == edc->old_record_in_namestore)
       {
-       /* replace record in database with that from model */
-       GNUNET_break (0); // not implemented
+       struct GNUNET_NAMESTORE_RecordData rd_new[rd_count];
+       
+       GNUNET_assert (NULL != ri);
+       memcpy (rd_new, rd_old, rd_count * sizeof (struct 
GNUNET_NAMESTORE_RecordData));
+       rd_new[edc->off] = rd;
+       oc = GNUNET_new (struct OperationContext);
+       GNUNET_CONTAINER_DLL_insert (oc_head, oc_tail, oc);
+       oc->qe = GNUNET_NAMESTORE_record_put_by_authority (namestore, 
+                                                          pkey, edc->name,
+                                                          rd_count,
+                                                          rd_new,
+                                                          
&operation_done_cont, oc);
       }
       else
       {
-       /* add record in database based on model */
-       GNUNET_break (0); // not implemented
+       struct GNUNET_NAMESTORE_RecordData rd_new[rd_count + 1];
+       
+       memcpy (rd_new, rd_old, rd_count * sizeof (struct 
GNUNET_NAMESTORE_RecordData));
+       rd_new[rd_count] = rd;
+       oc = GNUNET_new (struct OperationContext);
+       GNUNET_CONTAINER_DLL_insert (oc_head, oc_tail, oc);
+       oc->qe = GNUNET_NAMESTORE_record_put_by_authority (namestore, 
+                                                          pkey, edc->name,
+                                                          rd_count + 1,
+                                                          rd_new,
+                                                          
&operation_done_cont, oc);
       }
     }
     else
@@ -826,8 +749,19 @@
       /* zone changed, remove record from old zone, add to new zone! */
       if (GNUNET_YES == edc->old_record_in_namestore)
       {
-       /* remove item from tree view and namestore */
-       remove_record_at_offset (edc);
+       /* remove item from tree view and namestore */  
+       struct GNUNET_NAMESTORE_RecordData rd_new[rd_count - 1];
+       
+       GNUNET_assert (NULL != ri);
+       memcpy (rd_new, rd_old, (rd_count - 1) * sizeof (struct 
GNUNET_NAMESTORE_RecordData));
+       rd_new[edc->off] = rd_old[rd_count - 1];
+       oc = GNUNET_new (struct OperationContext);
+       GNUNET_CONTAINER_DLL_insert (oc_head, oc_tail, oc);
+       oc->qe = GNUNET_NAMESTORE_record_put_by_authority (namestore, 
+                                                          pkey, edc->name,
+                                                          rd_count + 1,
+                                                          rd_new,
+                                                          
&operation_done_cont, oc);
       }
 
       /* now add item to target zone */
@@ -851,23 +785,23 @@
       {
        show_error_message (_("Failed to load private key for target zone"),
                            NULL);
-       return;
+       break;
       }
       GNUNET_break (0); // not implemented
       /* FIXME: get target zone records, merge with new one, commit! */
       GNUNET_CRYPTO_ecc_key_free (pk);
-      return;
+      break;
     }
     break;
   default:
     GNUNET_break (0);
     break;
   }
+  GNUNET_free (data);
   free_edit_dialog_context (edc);
 }
 
 
-
 /**
  * Launch a record editing dialog.
  *
@@ -974,13 +908,11 @@
   GtkTreeSelection *sel;
   gint n_type;
   gchar *n_name;
-  unsigned int off;
+  guint off;
   struct RecordInfo *ri;
   GtkTreeIter iter;
+  struct GNUNET_HashCode name_hash;
 
-  /* FIXME: not this easy! Row may still be a 'fresh' row (user
-     can right-click anywhere, right? -- maybe suppress pop-up
-     in that case?? */
   sel = gtk_tree_view_get_selection (tv);
   if (! gtk_tree_selection_get_selected (sel, NULL, &iter))
   {
@@ -991,18 +923,27 @@
   gtk_tree_model_get (tm, &iter,
                      GNS_TREESTORE_COL_NAME, &n_name,
                      GNS_TREESTORE_COL_RECORD_TYPE, &n_type,
+                     GNS_TREESTORE_COL_RECORD_OFFSET, &off,
                      -1);
-  // FIXME: determine 'off', 'ri', ...
-  // Idea: simply store 'off' in model!
-  off = 42;
-  ri = NULL;
+  if (NULL == n_name)
+  {
+    GNUNET_break (0);
+    return;
+  }
+  GNUNET_CRYPTO_hash (n_name, strlen (n_name), &name_hash);
+  ri = GNUNET_CONTAINER_multihashmap_get (n2r, &name_hash);
+  if ( (NULL == ri) ||
+       (off >= ri->rd_count) )
+  {
+    GNUNET_break (0);
+    return;
+  }
   launch_edit_dialog (n_type, n_name,
                      ri, off);
   g_free (n_name);
 }
 
 
-
 /**
  * The user has selected a new record type.  Update the
  * model and then start the 'edit' dialog.
@@ -1013,20 +954,28 @@
  * @param user_data unused
  */
 void
-GNUNET_setup_gns_type_cellrenderercombo_edited_cb (GtkCellRendererCombo *combo,
-                                                  gchar *path,
-                                                  gchar *new_text,
-                                                  gpointer user_data)
+GNUNET_setup_gns_type_cellrenderercombo_changed_cb (GtkCellRendererCombo 
*combo,
+                                                   gchar *path_string,
+                                                   GtkTreeIter *new_iter,
+                                                   gpointer user_data)
 {
+  GtkListStore *ls;
+  gchar *new_text;
   GtkTreeIter it;
   guint type;
   char *name_str;
   struct GNUNET_HashCode name_hash;
   struct RecordInfo *ri;
 
+  ls = GTK_LIST_STORE (GNUNET_SETUP_get_object 
("GNUNET_setup_gns_type_liststore"));
+  gtk_tree_model_get (GTK_TREE_MODEL (ls), new_iter, 
+                     1, &new_text,
+                     -1);
+
   if (0 == strcmp (new_text, _(NEW_RECORD_STR)))
   {
     GNUNET_break (0);
+    g_free (new_text);
     return; /* no record type was selected */
   }
   type = GNUNET_NAMESTORE_typename_to_number (new_text);
@@ -1037,22 +986,25 @@
                new_text);
     show_error_message (_("Unsupported record type"),
                        new_text);
+    g_free (new_text);
     return;
   }
   /* check if this is a new record */
-  gtk_tree_model_get_iter_from_string (tm, &it, path);
+  gtk_tree_model_get_iter_from_string (tm, &it, path_string);
   gtk_tree_model_get (tm, &it,
                      GNS_TREESTORE_COL_NAME, &name_str,
                      -1);
   if (NULL == name_str)
   {
     GNUNET_break (0);
+    g_free (new_text);
     return;
   }
   GNUNET_CRYPTO_hash (name_str, strlen (name_str), &name_hash);
   ri = GNUNET_CONTAINER_multihashmap_get (n2r, &name_hash);
   launch_edit_dialog (type, name_str, ri, UINT_MAX);
   g_free (name_str);
+  g_free (new_text);
 }
 
 
@@ -1119,6 +1071,7 @@
                                     GNS_TREESTORE_COL_IS_RECORD_ROW, FALSE,
                                     GNS_TREESTORE_COL_TYPE_IS_EDITABLE, FALSE,
                                     GNS_TREESTORE_COL_NAME_IS_EDITABLE, TRUE,
+                                    GNS_TREESTORE_COL_RECORD_OFFSET, UINT_MAX,
                                     -1);
 }
 
@@ -1218,23 +1171,116 @@
                                                   GdkEventKey *event, 
                                                   gpointer user_data)
 {
-  GtkTreeIter it;
+  GtkTreeIter iter;
   GtkTreeSelection *sel;
   int not_dummy;
+  GtkTreeIter parent;
+  char *name;
+  struct GNUNET_HashCode name_hash;
+  struct RecordInfo *ri;
+  struct OperationContext *oc;
 
   /* Check for delete key */
   if ( (GDK_KEY_PRESS != event->type) ||
        (GDK_KEY_Delete != event->keyval) ) 
     return FALSE;
   sel = gtk_tree_view_get_selection(tv);
-  if (! gtk_tree_selection_get_selected (sel, NULL, &it))
+  if (! gtk_tree_selection_get_selected (sel, NULL, &iter))
     return TRUE; /* nothing selected */  
-  gtk_tree_model_get (tm, &it, 
+  gtk_tree_model_get (tm, &iter, 
                      GNS_TREESTORE_COL_NOT_DUMMY_ROW, &not_dummy, 
+                     GNS_TREESTORE_COL_NAME, &name,
                      -1);
   if (GNUNET_NO == not_dummy)
+  {
+    g_free (name);
     return TRUE; /* do not delete the dummy line */
-  remove_records_by_iter (&it);
+  }
+  GNUNET_CRYPTO_hash (name, strlen (name), &name_hash);
+  ri = GNUNET_CONTAINER_multihashmap_get (n2r,
+                                         &name_hash);
+  GNUNET_assert (NULL != ri);
+  
+  if ( (gtk_tree_model_iter_parent (tm, &parent, &iter)) &&
+       (ri->rd_count > 0) )
+  {
+    struct GNUNET_NAMESTORE_RecordData rd_old[ri->rd_count];
+    struct GNUNET_NAMESTORE_RecordData rd_new[ri->rd_count - 1];
+    struct GNUNET_NAMESTORE_RecordData rd;
+    unsigned int off;
+    int n_type;
+    gboolean n_public;
+    guint64 n_exp_time;
+    gboolean n_is_relative;
+    gboolean n_is_shadow;
+    char *n_value;
+
+    /* Removing a single record */
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Removing single record for name `%s'\n", 
+               name);
+    GNUNET_break (GNUNET_OK ==
+                 GNUNET_NAMESTORE_records_deserialize (ri->data_size,
+                                                       ri->data,
+                                                       ri->rd_count,
+                                                       rd_old));
+    gtk_tree_model_get (tm, &iter,
+                       GNS_TREESTORE_COL_RECORD_TYPE, &n_type,
+                       GNS_TREESTORE_COL_IS_PUBLIC, &n_public,
+                       GNS_TREESTORE_COL_EXP_TIME, &n_exp_time,
+                       GNS_TREESTORE_COL_EXP_TIME_IS_REL, &n_is_relative,
+                       GNS_TREESTORE_COL_IS_SHADOW, &n_is_shadow,
+                       GNS_TREESTORE_COL_VAL_AS_STR, &n_value,
+                       -1);
+    /* valid name */
+    if (n_public)
+      rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
+    else
+      rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY | GNUNET_NAMESTORE_RF_PRIVATE;
+    if (n_is_relative)
+      rd.flags |= GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION;
+    if (n_is_shadow)
+      rd.flags |= GNUNET_NAMESTORE_RF_SHADOW_RECORD;
+    rd.record_type = n_type;
+    rd.expiration_time = n_exp_time;
+    if (GNUNET_OK !=
+       GNUNET_NAMESTORE_string_to_value (n_type, n_value,
+                                         (void**)&rd.data, &rd.data_size))
+    {
+      /* can't remove, value invalid */
+      GNUNET_assert (0);
+      g_free (n_value);
+      g_free (name);
+      return TRUE;
+    }
+    for (off=0;off<ri->rd_count;off++)
+      if (GNUNET_YES ==
+         GNUNET_NAMESTORE_records_cmp (&rd,
+                                       &rd_old[off]))
+       break;
+    GNUNET_assert (off != ri->rd_count);
+    memcpy (rd_new, rd_old, (ri->rd_count - 1) * sizeof (struct 
GNUNET_NAMESTORE_RecordData));
+    rd_new[off] = rd_old[ri->rd_count - 1];
+    oc = GNUNET_new (struct OperationContext);
+    GNUNET_CONTAINER_DLL_insert (oc_head, oc_tail, oc);
+    oc->qe = GNUNET_NAMESTORE_record_put_by_authority (namestore, 
+                                                      pkey, name,
+                                                      ri->rd_count - 1,
+                                                      rd_new,
+                                                      &operation_done_cont, 
oc);
+    g_free (n_value);
+  }
+  else
+  {
+    oc = GNUNET_new (struct OperationContext);
+    GNUNET_CONTAINER_DLL_insert (oc_head, oc_tail, oc);
+    oc->qe = GNUNET_NAMESTORE_record_put_by_authority (namestore, 
+                                                      pkey, name,
+                                                      0, NULL,
+                                                      &operation_done_cont, 
oc);
+  }
+  g_free (name);
+
   return TRUE;
 }
 
@@ -1450,13 +1496,7 @@
     gtk_tree_path_free (path);
     /* remove all records, we'll re-add those that are left next */
     if (gtk_tree_model_iter_children (tm, &iter_record, &iter_name))
-    {
-      do
-      {
-        gtk_tree_store_remove (ts, &iter_record);
-      }
-      while (gtk_tree_model_iter_next (tm, &iter_record));
-    }
+      while (gtk_tree_store_remove (ts, &iter_record)) ;
   }
   else
   {
@@ -1470,6 +1510,7 @@
                        GNS_TREESTORE_COL_IS_RECORD_ROW, TRUE,
                        GNS_TREESTORE_COL_NOT_DUMMY_ROW, FALSE,
                        GNS_TREESTORE_COL_TYPE_IS_EDITABLE, TRUE,
+                       GNS_TREESTORE_COL_RECORD_OFFSET, UINT_MAX,
                        -1);
     
     path = gtk_tree_model_get_path (tm,
@@ -1503,7 +1544,7 @@
   ri->data_size = GNUNET_NAMESTORE_records_get_size (rd_count, rd);
   if (0 != ri->data_size)
     ri->data = GNUNET_malloc (ri->data_size);
-  GNUNET_break (GNUNET_OK ==
+  GNUNET_break (ri->data_size ==
                GNUNET_NAMESTORE_records_serialize (rd_count, rd,
                                                    ri->data_size, ri->data));
 
@@ -1570,6 +1611,7 @@
                                       GNS_TREESTORE_COL_VAL_AS_STR, val,
                                       GNS_TREESTORE_COL_IS_RECORD_ROW, TRUE,
                                       GNS_TREESTORE_COL_NOT_DUMMY_ROW, TRUE,
+                                      GNS_TREESTORE_COL_RECORD_OFFSET, (guint) 
c,                                    
                                       -1);    
     GNUNET_free (type_str);
     GNUNET_free (val);
@@ -1649,6 +1691,7 @@
                                      GNS_TREESTORE_COL_NOT_DUMMY_ROW, FALSE,
                                     GNS_TREESTORE_COL_TYPE_IS_EDITABLE, FALSE,
                                     GNS_TREESTORE_COL_NAME_IS_EDITABLE, TRUE,
+                                    GNS_TREESTORE_COL_RECORD_OFFSET, UINT_MAX,
                                      -1);
   /* Load zone from namestore! */
 #if HAVE_QRENCODE_H




reply via email to

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