types
[oweals/gnunet.git] / src / include / gnunet_client_lib.h
index 6a77aa391c4e23f7557b02b456accc98e183777b..fd9291598333318ab05fc070796b65b734040d8b 100644 (file)
@@ -37,7 +37,7 @@ extern "C"
 
 #include "gnunet_common.h"
 #include "gnunet_configuration_lib.h"
-#include "gnunet_network_lib.h"
+#include "gnunet_connection_lib.h"
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_time_lib.h"
 
@@ -59,7 +59,7 @@ struct GNUNET_CLIENT_Connection *GNUNET_CLIENT_connect (struct
                                                         *sched,
                                                         const char
                                                         *service_name,
-                                                        struct
+                                                        const struct
                                                         GNUNET_CONFIGURATION_Handle
                                                         *cfg);
 
@@ -85,7 +85,6 @@ typedef void (*GNUNET_CLIENT_MessageHandler) (void *cls,
 /**
  * Read from the service.
  *
- * @param sched scheduler to use
  * @param sock the service
  * @param handler function to call with the message
  * @param cls closure for handler
@@ -109,21 +108,44 @@ void GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock,
  * @param notify_cls closure for notify
  * @return NULL if someone else is already waiting to be notified
  *         non-NULL if the notify callback was queued (can be used to cancel
- *         using GNUNET_NETWORK_notify_transmit_ready_cancel)
+ *         using GNUNET_CONNECTION_notify_transmit_ready_cancel)
  */
-struct GNUNET_NETWORK_TransmitHandle
+struct GNUNET_CONNECTION_TransmitHandle
   *GNUNET_CLIENT_notify_transmit_ready (struct GNUNET_CLIENT_Connection *sock,
                                         size_t size,
                                         struct GNUNET_TIME_Relative timeout,
-                                        GNUNET_NETWORK_TransmitReadyNotify
+                                        GNUNET_CONNECTION_TransmitReadyNotify
                                         notify, void *notify_cls);
 
 
+
+/**
+ * Convenience API that combines sending a request
+ * to the service and waiting for a response.
+ * If either operation times out, the callback
+ * will be called with a "NULL" response (in which
+ * case the connection should probably be destroyed).
+ *
+ * @param sock connection to use
+ * @param hdr message to transmit
+ * @param timeout when to give up (for both transmission
+ *         and for waiting for a response)
+ * @param rn function to call with the response
+ * @param rn_cls closure for rn 
+ */
+void
+GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection *sock,
+                                        const struct GNUNET_MessageHeader *hdr,
+                                        struct GNUNET_TIME_Relative timeout,
+                                        GNUNET_CLIENT_MessageHandler rn,
+                                        void *rn_cls);
+
+
+
 /**
  * Request that the service should shutdown.
  * Afterwards, the connection should be disconnected.
  *
- * @param sched scheduler to use
  * @param sock the socket connected to the service
  */
 void GNUNET_CLIENT_service_shutdown (struct GNUNET_CLIENT_Connection *sock);
@@ -143,7 +165,7 @@ void GNUNET_CLIENT_service_shutdown (struct GNUNET_CLIENT_Connection *sock);
  */
 void GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched,
                                  const char *service,
-                                 struct GNUNET_CONFIGURATION_Handle *cfg,
+                                 const struct GNUNET_CONFIGURATION_Handle *cfg,
                                  struct GNUNET_TIME_Relative timeout,
                                  GNUNET_SCHEDULER_Task task, void *task_cls);