gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r28650 - gnunet-gtk/src/setup


From: gnunet
Subject: [GNUnet-SVN] r28650 - gnunet-gtk/src/setup
Date: Thu, 15 Aug 2013 13:29:41 +0200

Author: grothoff
Date: 2013-08-15 13:29:41 +0200 (Thu, 15 Aug 2013)
New Revision: 28650

Modified:
   gnunet-gtk/src/setup/gnunet-setup-gns.c
Log:
-update gnunet-setup for new GNS crypto (#3001_
)

Modified: gnunet-gtk/src/setup/gnunet-setup-gns.c
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup-gns.c     2013-08-15 11:12:11 UTC (rev 
28649)
+++ gnunet-gtk/src/setup/gnunet-setup-gns.c     2013-08-15 11:29:41 UTC (rev 
28650)
@@ -318,11 +318,6 @@
 static struct MoveOperationContext *moc_tail;
 
 /**
- * Name of our zone as a string.
- */
-static char *zone_as_string;
-
-/**
  * Handle to the namestore.
  */
 static struct GNUNET_NAMESTORE_Handle *namestore;
@@ -353,11 +348,6 @@
 static struct GNUNET_CRYPTO_EccPublicKey pubkey;
 
 /**
- * Short hash of the public key of the zone we are currently editing.
- */ 
-static struct GNUNET_CRYPTO_ShortHashCode zone;
-
-/**
  * Pseudonym of the current zone we are editing.
  */
 static char *current_pseudonym;
@@ -408,7 +398,7 @@
   pseu = gtk_entry_get_text (GTK_ENTRY(entry));    
   GNUNET_asprintf (&str,
                   "gnunet://gns/%s/%s\n",
-                  zone_as_string,
+                  GNUNET_NAMESTORE_z2s (&pubkey),
                   pseu);
   if (0 != QRinput_append (qri,
                           QR_MODE_8,
@@ -767,26 +757,13 @@
  * Process a record that was stored in the namestore.
  *
  * @param cls closure
- * @param zone_key public key of the zone
- * @param freshness when does the corresponding block in the DHT expire (until
- *               when should we never do a DHT lookup for the same name 
again)?; 
- *               GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any type 
in the namestore,
- *               or the expiration time of the block in the namestore (even if 
there are zero
- *               records matching the desired record type)
- * @param name name that is being mapped (at most 255 characters long)
  * @param rd_count number of entries in 'rd' array
  * @param rd array of records with data to store
- * @param signature signature of the record block, NULL if signature is 
unavailable (i.e. 
- *        because the user queried for a particular record type only)
  */
 static void
 merge_with_existing_records (void *cls,
-                            const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
-                            struct GNUNET_TIME_Absolute freshness,             
            
-                            const char *name,
                             unsigned int rd_count,
-                            const struct GNUNET_NAMESTORE_RecordData *rd,
-                            const struct GNUNET_CRYPTO_EccSignature *signature)
+                            const struct GNUNET_NAMESTORE_RecordData *rd)
 {
   struct MoveOperationContext *moc = cls;
   struct EditDialogContext *edc = moc->edc;
@@ -812,12 +789,12 @@
   /* FIXME: sanity-check merge... */
   oc = GNUNET_new (struct OperationContext);
   GNUNET_CONTAINER_DLL_insert (oc_head, oc_tail, oc);
-  oc->qe = GNUNET_NAMESTORE_record_put_by_authority (namestore, 
-                                                    moc->pk,
-                                                    edc->name,
-                                                    rd_count + 1,
-                                                    rd_new,
-                                                    &operation_done_cont, oc);
+  oc->qe = GNUNET_NAMESTORE_records_store (namestore, 
+                                          moc->pk,
+                                          edc->name,
+                                          rd_count + 1,
+                                          rd_new,
+                                          &operation_done_cont, oc);
   GNUNET_CRYPTO_ecc_key_free (moc->pk);
   GNUNET_free (moc->data);
   GNUNET_free (moc);
@@ -826,6 +803,41 @@
 
 
 /**
+ * Process an encrypted that was stored in the namestore for
+ * merging.
+ *
+ * @param cls closure
+ * @param block block to decrypt
+ */
+static void
+decrypt_block_for_merge (void *cls,
+                        const struct GNUNET_NAMESTORE_Block *block)
+{
+  struct MoveOperationContext *moc = cls;
+  struct GNUNET_CRYPTO_EccPublicKey pubkey;
+
+  GNUNET_CRYPTO_ecc_key_get_public (moc->pk,
+                                   &pubkey);
+  if (GNUNET_OK !=
+      GNUNET_NAMESTORE_block_decrypt (block,
+                                     &pubkey,
+                                     moc->edc->name,
+                                     &merge_with_existing_records,
+                                     moc))
+  {
+    show_error_message (_("Failed to decode existing record in target zone"),
+                       _("Failed to add new record."));
+    GNUNET_CRYPTO_ecc_key_free (moc->pk);
+    GNUNET_free (moc->data);
+    free_edit_dialog_context (moc->edc);
+    GNUNET_free (moc);
+    return;
+  }
+}
+
+
+
+/**
  * The edit dialog completed; update the namestore and the 
  * view based on the new values in 'edc'.
  *
@@ -893,11 +905,11 @@
       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);
+      oc->qe = GNUNET_NAMESTORE_records_store (namestore, 
+                                              pkey, edc->name,
+                                              rd_count + 1,
+                                              rd_new,
+                                              &operation_done_cont, oc);
     }
     else
     {
@@ -919,11 +931,11 @@
        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);
+       oc->qe = GNUNET_NAMESTORE_records_store (namestore, 
+                                                pkey, edc->name,
+                                                rd_count,
+                                                rd_new,
+                                                &operation_done_cont, oc);
       }
       else
       {
@@ -933,11 +945,11 @@
        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);
+       oc->qe = GNUNET_NAMESTORE_records_store (namestore, 
+                                                pkey, edc->name,
+                                                rd_count + 1,
+                                                rd_new,
+                                                &operation_done_cont, oc);
       }
     }
     else
@@ -945,8 +957,7 @@
       char *keyfile;
       struct GNUNET_CRYPTO_EccPrivateKey *pk;
       struct MoveOperationContext *moc;
-      struct GNUNET_CRYPTO_ShortHashCode target_zone_hash;
-      struct GNUNET_CRYPTO_EccPublicKey pubkey;
+      struct GNUNET_HashCode query;
       
       /* determine target zone */
       if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
@@ -971,22 +982,20 @@
                            NULL);
        break;
       }
-      GNUNET_CRYPTO_ecc_key_get_public (pk, &pubkey);
-      GNUNET_CRYPTO_short_hash (&pubkey,
-                               sizeof (struct GNUNET_CRYPTO_EccPublicKey),
-                               &target_zone_hash);
+      GNUNET_NAMESTORE_query_from_private_key (pk,
+                                              edc->name,
+                                              &query);
       moc = GNUNET_new (struct MoveOperationContext);
       moc->data = data;
       moc->rd = rd;
       moc->edc = edc;
       moc->pk = pk;
       GNUNET_CONTAINER_DLL_insert (moc_head, moc_tail, moc);
-      moc->qe = GNUNET_NAMESTORE_lookup_record (namestore, 
-                                               &target_zone_hash,
-                                               edc->name,
-                                               0 /* all */,
-                                               &merge_with_existing_records,
-                                               moc);      
+
+      moc->qe = GNUNET_NAMESTORE_lookup_block (namestore, 
+                                              &query,
+                                              &decrypt_block_for_merge,
+                                              moc);      
       /* zone changed, remove record from old zone, add to new zone! */
       if (GNUNET_YES == edc->old_record_in_namestore)
       {
@@ -998,12 +1007,12 @@
        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);
-
+       oc->qe = GNUNET_NAMESTORE_records_store (namestore, 
+                                                pkey, edc->name,
+                                                rd_count - 1,
+                                                rd_new,
+                                                &operation_done_cont, oc);
+       
       }
       return;
     }
@@ -1536,21 +1545,21 @@
     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);
+    oc->qe = GNUNET_NAMESTORE_records_store (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);
+    oc->qe = GNUNET_NAMESTORE_records_store (namestore, 
+                                            pkey, name,
+                                            0, NULL,
+                                            &operation_done_cont, oc);
   }
   g_free (name);
 
@@ -1627,11 +1636,12 @@
     } 
     oc = GNUNET_new (struct OperationContext);
     GNUNET_CONTAINER_DLL_insert (oc_head, oc_tail, oc);
-    oc->qe = GNUNET_NAMESTORE_record_put_by_authority (namestore, 
-                                                      pkey, "+",
-                                                      total,
-                                                      rd_new,
-                                                      &operation_done_cont, 
oc);
+    oc->qe = GNUNET_NAMESTORE_records_store (namestore, 
+                                            pkey, 
+                                            GNUNET_GNS_MASTERZONE_STR,
+                                            total,
+                                            rd_new,
+                                            &operation_done_cont, oc);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
                "New Pseudonym is `%s' %u\n",
                (char *) pseu, rd_new[off].data_size);
@@ -1661,10 +1671,12 @@
 {
   GtkClipboard *cb;
 
-  if (NULL == zone_as_string)
+  if (NULL == pkey)
     return;
   cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
-  gtk_clipboard_set_text (cb, zone_as_string, -1);
+  gtk_clipboard_set_text (cb, 
+                         GNUNET_NAMESTORE_z2s (&pubkey),
+                         -1);
 }
 
 
@@ -1700,25 +1712,17 @@
  * widgets accordingly. 
  *
  * @param NULL
- * @param zone_key public key of the zone
- * @param freshness when does the corresponding block in the DHT expire (until
- *               when should we never do a DHT lookup for the same name 
again)?; 
- *               GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any type 
in the namestore,
- *               or the expiration time of the block in the namestore (even if 
there are zero
- *               records matching the desired record type)
+ * @param zone_key private key of the zone
  * @param name name that is being mapped (at most 255 characters long)
  * @param rd_count number of entries in 'rd' array
  * @param rd array of records with data to store
- * @param signature signature of the record block, NULL as we are monitoring
  */
 static void
 zone_iteration_proc (void *cls,
-                    const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
-                    struct GNUNET_TIME_Absolute expire,
+                    const struct GNUNET_CRYPTO_EccPrivateKey *zone_key,
                     const char *name,
                     unsigned int rd_count,
-                    const struct GNUNET_NAMESTORE_RecordData *rd,
-                    const struct GNUNET_CRYPTO_EccSignature *signature)
+                    const struct GNUNET_NAMESTORE_RecordData *rd)
 {
   GtkTreeRowReference *rr;
   GtkTreePath *path;
@@ -1731,7 +1735,6 @@
   gboolean time_is_relative;
   gboolean public;
   guint64 exp_t;
-  struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc;
   GtkEntry *pseu_entry;
   struct GNUNET_HashCode name_hash;
   struct RecordInfo *ri;
@@ -1754,10 +1757,9 @@
                name);
     return;
   }
-  GNUNET_CRYPTO_short_hash_to_enc (&zone, &shenc);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
-             "Zone `%s' iteration result `%s', %u records\n",
-             &shenc, name, rd_count);
+             "Zone iteration result `%s', %u records\n",
+             name, rd_count);
   GNUNET_CRYPTO_hash (name,
                      strlen (name),
                      &name_hash);
@@ -1919,7 +1921,6 @@
   char *keyfile;
   struct GNUNET_CRYPTO_EccPrivateKey *pk;
   char *emsg;
-  struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc;
   char *label;
   GtkTreeIter toplevel;
 
@@ -1958,14 +1959,8 @@
   }
   pkey = pk;
   GNUNET_CRYPTO_ecc_key_get_public (pkey, &pubkey);
-  GNUNET_CRYPTO_short_hash (&pubkey,
-                            sizeof (struct GNUNET_CRYPTO_EccPublicKey),
-                            &zone);
-  GNUNET_CRYPTO_short_hash_to_enc(&zone, &shenc);
-
-  zone_as_string = GNUNET_strdup ((char *) &shenc);
   label = g_markup_printf_escaped (_("<b>Editing zone %s</b>"),
-                                  zone_as_string);
+                                  GNUNET_NAMESTORE_z2s (&pubkey));
   gtk_label_set_markup (GTK_LABEL (GNUNET_SETUP_get_object 
("GNUNET_setup_gns_zone_label")),
                        label);
   g_free (label);
@@ -1984,7 +1979,7 @@
 #if HAVE_QRENCODE_H
   setup_qrcode ();
 #endif
-  zmon = GNUNET_NAMESTORE_zone_monitor_start (cfg, &zone,
+  zmon = GNUNET_NAMESTORE_zone_monitor_start (cfg, pk,
                                              &zone_iteration_proc,
                                              &zone_sync_proc,
                                              NULL);




reply via email to

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