Link namesotre to libgnunetgnsrecord too
[oweals/gnunet.git] / src / include / gnunet_conversation_service.h
index 098cec9ab88f1589864ccee62e68e67a210cd6c0..70dd013d6d0000f5b58d13f3fc72fcd975c492de 100644 (file)
@@ -1,17 +1,17 @@
 /*
   This file is part of GNUnet
   (C) 2013 Christian Grothoff (and other contributing authors)
-  
+
   GNUnet is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published
   by the Free Software Foundation; either version 3, or (at your
   option) any later version.
-  
+
   GNUnet is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.
-  
+
   You should have received a copy of the GNU General Public License
   along with GNUnet; see the file COPYING.  If not, write to the
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * @author Andreas Fuchs
  * @author Christian Grothoff
  *
+ *
+ * NOTE: This API is deliberately deceptively simple; the idea
+ * is that advanced features (such as answering machines) will
+ * be done with a separate service (an answering machine service)
+ * with its own APIs; the speaker/microphone abstractions are
+ * used to facilitate plugging in custom logic for implementing
+ * such a service later by creating "software" versions of
+ * speakers and microphones that record to disk or play a file.
+ * Notifications about missed calls should similarly be done
+ * using a separate service; CONVERSATION is supposed to be just
+ * the "bare bones" voice service.
+ *
+ * Meta data passing is supported so that advanced services
+ * can identify themselves appropriately.
+ *
+ * As this is supposed to be a "secure" service, caller ID is of
+ * course provided as part of the basic implementation, as only the
+ * CONVERSATION service can know for sure who it is that we are
+ * talking to.
+ *
  * TODO:
  * - call waiting
  * - put on hold
@@ -41,210 +61,44 @@ extern "C"
 #endif
 
 #include "gnunet_util_lib.h"
+#include "gnunet_identity_service.h"
+#include "gnunet_namestore_service.h"
+#include "gnunet_speaker_lib.h"
+#include "gnunet_microphone_lib.h"
+
 
 /**
  * Version of the conversation API.
  */
-#define GNUNET_CONVERSATION_VERSION 0x00000001
-
-
-enum GNUNET_CONVERSATION_RejectReason
-{
-  GNUNET_CONVERSATION_REJECT_REASON_GENERIC = 0,
-  GNUNET_CONVERSATION_REJECT_REASON_NOT_AVAILABLE,
-  GNUNET_CONVERSATION_REJECT_REASON_NO_CLIENT,
-  GNUNET_CONVERSATION_REJECT_REASON_ACTIVE_CALL,
-  GNUNET_CONVERSATION_REJECT_REASON_NOT_WANTED,
-  GNUNET_CONVERSATION_REJECT_REASON_NO_ANSWER
-
-};
-
-
-enum GNUNET_CONVERSATION_NotificationType
-{
-  GNUNET_CONVERSATION_NT_SERVICE_BLOCKED = 0,
-  GNUNET_CONVERSATION_NT_NO_PEER,
-  GNUNET_CONVERSATION_NT_NO_ANSWER,
-  GNUNET_CONVERSATION_NT_AVAILABLE_AGAIN,
-  GNUNET_CONVERSATION_NT_CALL_ACCEPTED,
-  GNUNET_CONVERSATION_NT_CALL_TERMINATED
-};
+#define GNUNET_CONVERSATION_VERSION 0x00000002
 
 
 /**
- *
+ * A phone record specifies which peer is hosting a given user and
+ * may also specify the phone line that is used (typically zero).
+ * The version is also right now always zero.
  */
-struct GNUNET_CONVERSATION_MissedCall
+struct GNUNET_CONVERSATION_PhoneRecord
 {
-  struct GNUNET_PeerIdentity peer;
-  struct GNUNET_TIME_Absolute time; 
-};
-
-
-struct GNUNET_CONVERSATION_MissedCallNotification
-{
-  int number;
-  struct GNUNET_CONVERSATION_MissedCall *calls;
-};
-
-struct GNUNET_CONVERSATION_CallInformation;
 
-struct GNUNET_CONVERSATION_Handle;
-
-
-/**
- * Method called whenever a call is incoming
- *
- * @param cls closure
- * @param handle to the conversation session
- * @param caller peer that calls you
- */
-typedef void (GNUNET_CONVERSATION_CallHandler) (void *cls,
-                                               struct GNUNET_CONVERSATION_Handle *handle,
-                                               const struct GNUNET_PeerIdentity *caller);
-
-
-/**
- * Method called whenever a call is rejected
- *
- * @param cls closure
- * @param handle to the conversation session
- * @param reason reason given for rejecting the call
- * @param peer peer that rejected your call
- */
-typedef void (GNUNET_CONVERSATION_RejectHandler) (void *cls,
-                                                 struct GNUNET_CONVERSATION_Handle *handle,
-                                                 enum GNUNET_CONVERSATION_RejectReason reason,
-                                                 const struct GNUNET_PeerIdentity *peer);
-
-
-/**
- * Method called whenever a notification is there
- *
- * @param cls closure
- * @param handle to the conversation session
- * @param type the type of the notification
- * @param peer peer that the notification is about
- */
-typedef void (GNUNET_CONVERSATION_NotificationHandler) (void *cls,
-                                                       struct GNUNET_CONVERSATION_Handle *handle,
-                                                       enum GNUNET_CONVERSATION_NotificationType type,
-                                                       const struct GNUNET_PeerIdentity *peer);
-
-
-/**
- * Method called whenever a notification for missed calls is there
- *
- * @param cls closure
- * @param handle to the conversation session
- * @param missed_calls a list of missed calls
- */
-typedef void (GNUNET_CONVERSATION_MissedCallHandler) (void *cls,
-                                                     struct GNUNET_CONVERSATION_Handle *handle,
-                                                     struct GNUNET_CONVERSATION_MissedCallNotification *missed_calls);
-
-
-/**
- * Connect to the VoIP service
- *
- * @param cfg configuration
- * @param cls NULL
- * @param call_handler the callback which is called when a call is incoming
- * @param reject_handler the callback which is called when a call is rejected
- * @param notification_handler the callback which is called when there is a notification
- * @param missed_call_handler the callback which is called when the service notifies the client about missed clients
- * @return handle to the connection to the conversation service
- */
-struct GNUNET_CONVERSATION_Handle *
-GNUNET_CONVERSATION_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 
-                            void *cls,
-                            GNUNET_CONVERSATION_CallHandler call_handler,
-                            GNUNET_CONVERSATION_RejectHandler reject_handler,
-                            GNUNET_CONVERSATION_NotificationHandler notification_handler,
-                            GNUNET_CONVERSATION_MissedCallHandler missed_call_handler);
-
-
-/**
- * Disconnect from the VoIP service
- *
- * @param handle handle to the VoIP connection
- */
-void
-GNUNET_CONVERSATION_disconnect (struct GNUNET_CONVERSATION_Handle *handle);
-
-
-/**
- * Establish a call
- *
- * @param handle handle to the VoIP connection
- * @param callee the peer (PeerIdentity or GNS name) to call
- * @param doGnsLookup 0 = no GNS lookup or 1  = GNS lookup
- */
-void
-GNUNET_CONVERSATION_call (struct GNUNET_CONVERSATION_Handle *handle, 
-                         const char *callee,
-                         int doGnsLookup);
-
-
-/**
- * Terminate the active call
- *
- * @param handle handle to the VoIP connection
- */
-void 
-GNUNET_CONVERSATION_hangup (struct GNUNET_CONVERSATION_Handle *handle);
-
-
-/**
- * Accept an incoming call
- *
- * @param handle handle to the VoIP connection
- */
-void
-GNUNET_CONVERSATION_accept (struct GNUNET_CONVERSATION_Handle *handle);
-
-
-/**
- * Reject an incoming call
- *
- * @param handle handle to the VoIP connection
- */
-void
-GNUNET_CONVERSATION_reject (struct GNUNET_CONVERSATION_Handle *handle);
-
-
-
-////////////////////////////////////////////////////////////////////
-////////////////////////// NEW API /////////////////////////////////
-////////////////////////////////////////////////////////////////////
-
-/* 
-   NOTE: This API is deliberately deceptively simple; the idea
-   is that advanced features (such as answering machines) will
-   be done with a separate service (an answering machine service)
-   with its own APIs; the speaker/microphone abstractions are
-   used to facilitate plugging in custom logic for implementing
-   such a service later by creating "software" versions of
-   speakers and microphones that record to disk or play a file.
-   Notifications about missed calls should similarly be done
-   using a separate service; CONVERSATION is supposed to be just
-   the "bare bones" voice service.
-
-   Meta data passing is supported so that advanced services
-   can identify themselves appropriately.
+  /**
+   * Version of the phone record, for now always zero.  We may
+   * use other versions for anonymously hosted phone lines in
+   * the future.
+   */
+  uint32_t version GNUNET_PACKED;
 
-   As this is supposed to be a "secure" service, caller ID is of
-   course provided as part of the basic implementation, as only the
-   CONVERSATION service can know for sure who it is that we are
-   talking to.
- */
+  /**
+   * Phone line to use at the peer.
+   */
+  uint32_t line GNUNET_PACKED;
 
+  /**
+   * Identity of the peer hosting the phone service.
+   */
+  struct GNUNET_PeerIdentity peer;
 
-#include "gnunet_util_lib.h"
-#include "gnunet_identity_service.h"
-#include "gnunet_namestore_service.h"
-#include "gnunet_speaker_lib.h"
-#include "gnunet_microphone_lib.h"
+};
 
 
 /**
@@ -255,11 +109,17 @@ GNUNET_CONVERSATION_reject (struct GNUNET_CONVERSATION_Handle *handle);
 enum GNUNET_CONVERSATION_EventCode
 {
   /**
-   * The phone is ringing, caller ID is provided in the varargs as 
+   * The phone is ringing, caller ID is provided in the varargs as
    * a `const char *`.  The caller ID will be a GNS name.
    */
   GNUNET_CONVERSATION_EC_RING,
-  
+
+  /**
+   * We are the caller and are now ringing the other party.
+   * The varargs will be empty.
+   */
+  GNUNET_CONVERSATION_EC_RINGING,
+
   /**
    * We are ready to talk, metadata about the call may be supplied
    * as a `const char *` in the varargs.
@@ -267,21 +127,27 @@ enum GNUNET_CONVERSATION_EventCode
   GNUNET_CONVERSATION_EC_READY,
 
   /**
-   * We failed to locate a phone record in GNS.
+   * We failed to locate a phone record in GNS.  After this invocation,
+   * the respective call handle will be automatically destroyed and the
+   * client must no longer call #GNUNET_CONVERSATION_call_stop.
    */
   GNUNET_CONVERSATION_EC_GNS_FAIL,
 
   /**
-   * The phone is busy.  Varargs will be empty.
+   * The phone is busy.  Varargs will be empty.   After this invocation,
+   * the respective call handle will be automatically destroyed and the
+   * client must no longer call #GNUNET_CONVERSATION_call_stop.
    */
   GNUNET_CONVERSATION_EC_BUSY,
-  
+
   /**
-   * The conversation was terminated, a reason may be supplied
-   * as a `const char *` in the varargs.
+   * The conversation was terminated, a reason may be supplied as a
+   * `const char *` in the varargs.  After this invocation, the
+   * respective call handle will be automatically destroyed and the
+   * client must no longer call #GNUNET_CONVERSATION_call_stop.
    */
   GNUNET_CONVERSATION_EC_TERMINATED
-  
+
 };
 
 
@@ -337,11 +203,11 @@ GNUNET_CONVERSATION_phone_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
  */
 void
 GNUNET_CONVERSATION_phone_get_record (struct GNUNET_CONVERSATION_Phone *phone,
-                                     struct GNUNET_NAMESTORE_RecordData *rd);
+                                     struct GNUNET_GNSRECORD_Data *rd);
 
 
 /**
- * Picks up a (ringing) phone.  This will connect the speaker 
+ * Picks up a (ringing) phone.  This will connect the speaker
  * to the microphone of the other party, and vice versa.
  *
  * @param phone phone to pick up
@@ -350,10 +216,10 @@ GNUNET_CONVERSATION_phone_get_record (struct GNUNET_CONVERSATION_Phone *phone,
  * @param mic microphone to use
  */
 void
-GNUNET_CONVERSTATION_phone_pick_up (struct GNUNET_CONVERSATION_Phone *phone,
-                                   const char *metadata,
-                                   struct GNUNET_SPEAKER_Handle *speaker,
-                                   struct GNUNET_MICROPHONE_Handle *mic);
+GNUNET_CONVERSATION_phone_pick_up (struct GNUNET_CONVERSATION_Phone *phone,
+                                   const char *metadata,
+                                   struct GNUNET_SPEAKER_Handle *speaker,
+                                   struct GNUNET_MICROPHONE_Handle *mic);
 
 
 /**
@@ -364,8 +230,8 @@ GNUNET_CONVERSTATION_phone_pick_up (struct GNUNET_CONVERSATION_Phone *phone,
  * @param reason text we give to the other party about why we terminated the conversation
  */
 void
-GNUNET_CONVERSTATION_phone_hang_up (struct GNUNET_CONVERSATION_Phone *phone,
-                                   const char *reason);
+GNUNET_CONVERSATION_phone_hang_up (struct GNUNET_CONVERSATION_Phone *phone,
+                                   const char *reason);
 
 
 /**