+static void
+op_recv_zone_add_place_result (void *cls, int64_t result,
+ const void *err_msg, uint16_t err_msg_size)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received zone add place result: %" PRId64 ".\n", result);
+
+ struct ZoneAddPlaceHandle *add_plc = cls;
+ if (NULL != add_plc->result_cb)
+ add_plc->result_cb (add_plc->result_cls, result, err_msg, err_msg_size);
+
+ GNUNET_free (add_plc);
+}
+
+
+/**
+ * Advertise @e place in the GNS zone of @e ego.
+ *
+ * @param app
+ * Application handle.
+ * @param ego
+ * Ego.
+ * @param place_pub_key
+ * Public key of place to add.
+ * @param name
+ * The name for the PLACE record to put in the zone.
+ * @param password
+ * Password used to encrypt the record or NULL to keep it cleartext.
+ * @param relay_count
+ * Number of elements in the @a relays array.
+ * @param relays
+ * List of relays to put in the PLACE record to advertise
+ * as entry points to the place in addition to the origin.
+ * @param expiration_time
+ * Expiration time of the record, use 0 to remove the record.
+ * @param result_cb
+ * Function called with the result of the operation.
+ * @param result_cls
+ * Closure for @a result_cb
+ *
+ * @return #GNUNET_OK if the request was sent,
+ * #GNUNET_SYSERR on error, e.g. the name/password is too long.
+ */
+int
+GNUNET_SOCIAL_zone_add_place (const struct GNUNET_SOCIAL_App *app,
+ const struct GNUNET_SOCIAL_Ego *ego,
+ const char *name,
+ const char *password,
+ const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
+ const struct GNUNET_PeerIdentity *origin,
+ uint32_t relay_count,
+ const struct GNUNET_PeerIdentity *relays,
+ struct GNUNET_TIME_Absolute expiration_time,
+ GNUNET_ResultCallback result_cb,
+ void *result_cls)
+{
+ struct ZoneAddPlaceRequest *preq;
+ size_t name_size = strlen (name) + 1;
+ size_t password_size = strlen (password) + 1;
+ size_t relay_size = relay_count * sizeof (*relays);
+ size_t payload_size = name_size + password_size + relay_size;
+
+ if (GNUNET_MAX_MESSAGE_SIZE < sizeof (*preq) + payload_size)
+ return GNUNET_SYSERR;
+
+ struct GNUNET_MQ_Envelope *
+ env = GNUNET_MQ_msg_extra (preq, payload_size,
+ GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_PLACE);
+ preq->expiration_time = GNUNET_htonll (expiration_time.abs_value_us);
+ preq->ego_pub_key = ego->pub_key;
+ preq->place_pub_key = *place_pub_key;
+ preq->origin = *origin;
+ preq->relay_count = htonl (relay_count);
+
+ char *p = (char *) &preq[1];
+ GNUNET_memcpy (p, name, name_size);
+ p += name_size;
+ GNUNET_memcpy (p, password, password_size);
+ p += password_size;
+ GNUNET_memcpy (p, relays, relay_size);
+
+ struct ZoneAddPlaceHandle * add_plc = GNUNET_malloc (sizeof (*add_plc));
+ add_plc->result_cb = result_cb;
+ add_plc->result_cls = result_cls;
+
+ preq->op_id = GNUNET_htonll (GNUNET_OP_add (app->op,
+ op_recv_zone_add_place_result,
+ add_plc, NULL));
+
+ GNUNET_MQ_send (app->mq, env);
+ return GNUNET_OK;
+}
+
+
+static void
+op_recv_zone_add_nym_result (void *cls, int64_t result,
+ const void *err_msg, uint16_t err_msg_size)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received zone add nym result: %" PRId64 ".\n", result);
+
+ struct ZoneAddNymHandle *add_nym = cls;
+ if (NULL != add_nym->result_cb)
+ add_nym->result_cb (add_nym->result_cls, result, err_msg, err_msg_size);
+
+ GNUNET_free (add_nym);
+}
+
+