-never store NICKs anywhere but in '+', do not display nicks in gnunet-namestore
[oweals/gnunet.git] / src / namestore / namestore_api.c
index c053869080602309139f0716a471361ee694ee6d..c089929a64c40652ce979d45063c275e2e6d7fdb 100644 (file)
@@ -33,6 +33,7 @@
 #include "gnunet_dnsparser_lib.h"
 #include "gnunet_arm_service.h"
 #include "gnunet_signatures.h"
+#include "gnunet_gns_service.h"
 #include "gnunet_namestore_service.h"
 #include "namestore.h"
 
@@ -265,8 +266,9 @@ handle_record_store_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
   const char *emsg;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Received `%s'\n",
-       "RECORD_STORE_RESPONSE");
+       "Received `%s' with result %i\n",
+       "RECORD_STORE_RESPONSE",
+       ntohl (msg->op_result));
   /* TODO: add actual error message from namestore to response... */
   res = ntohl (msg->op_result);
   if (GNUNET_SYSERR == res)
@@ -457,7 +459,9 @@ handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
   case GNUNET_NO:
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "Namestore has no result for zone to name mapping \n");
-    break;
+    if (NULL != qe->proc)
+      qe->proc (qe->proc_cls, &msg->zone, NULL, 0, NULL);
+    return GNUNET_NO;
   case GNUNET_YES:
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "Namestore has result for zone to name mapping \n");
@@ -995,7 +999,7 @@ GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h)
  * @param rd_count number of records in the 'rd' array
  * @param rd array of records with data to store
  * @param cont continuation to call when done
- * @param cont_cls closure for 'cont'
+ * @param cont_cls closure for @a cont
  * @return handle to abort the request
  */
 struct GNUNET_NAMESTORE_QueueEntry *
@@ -1065,6 +1069,34 @@ GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h,
   return qe;
 }
 
+/**
+ * Set the desired nick name for a zone
+ *
+ * @param h handle to the namestore
+ * @param pkey private key of the zone
+ * @param nick the nick name to set
+ * @param cont continuation to call when done
+ * @param cont_cls closure for 'cont'
+ * @return handle to abort the request
+ */
+struct GNUNET_NAMESTORE_QueueEntry *
+GNUNET_NAMESTORE_set_nick (struct GNUNET_NAMESTORE_Handle *h,
+                           const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
+                           const char *nick,
+                           GNUNET_NAMESTORE_ContinuationWithStatus cont,
+                           void *cont_cls)
+{
+  struct GNUNET_GNSRECORD_Data rd;
+
+  memset (&rd, 0, sizeof (rd));
+  rd.data = nick;
+  rd.data_size = strlen (nick) +1;
+  rd.record_type = GNUNET_GNSRECORD_TYPE_NICK;
+  rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
+  rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE;
+  return GNUNET_NAMESTORE_records_store(h, pkey, GNUNET_GNS_MASTERZONE_STR, 1, &rd, cont, cont_cls);
+}
+
 
 /**
  * Lookup an item in the namestore.