GNUnet  0.11.x
conversation_api.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2013, 2014 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
28 #include "platform.h"
30 #include "conversation.h"
31 
32 
37 {
42 
47 
52 
57 
62 };
63 
64 
69 {
74 
79 
84 
89 
94 
99 
104 
109 
113  uint32_t cid;
114 
119 };
120 
121 
126 {
131 
136 };
137 
138 
151 {
156 
161 
166 
171 
176 
181 
186 
191 
196 
201 };
202 
203 
209 static void
211 
212 
220 static void
222  size_t data_size,
223  const void *data)
224 {
225  struct GNUNET_CONVERSATION_Caller *caller = cls;
226  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
227  struct GNUNET_MQ_Envelope *e;
228  struct ClientAudioMessage *am;
229 
230  e = GNUNET_MQ_msg_extra (am,
231  data_size,
233  am->cid = caller->cid;
234  GNUNET_memcpy (&am[1],
235  data,
236  data_size);
237  GNUNET_MQ_send (phone->mq,
238  e);
239 }
240 
241 
248 static void
249 handle_phone_ring (void *cls,
250  const struct ClientPhoneRingMessage *ring)
251 {
252  struct GNUNET_CONVERSATION_Phone *phone = cls;
253  struct GNUNET_CONVERSATION_Caller *caller;
254 
255  switch (phone->state)
256  {
257  case PS_REGISTER:
258  GNUNET_assert (0);
259  break;
260 
261  case PS_READY:
262  caller = GNUNET_new (struct GNUNET_CONVERSATION_Caller);
263  caller->phone = phone;
265  phone->caller_tail,
266  caller);
267  caller->caller_id = ring->caller_id;
268  caller->cid = ring->cid;
269  caller->state = CS_RINGING;
270  phone->event_handler (phone->event_handler_cls,
272  caller,
273  &caller->caller_id);
274  break;
275  }
276 }
277 
278 
286 static struct GNUNET_CONVERSATION_Caller *
288  uint32_t cid)
289 {
290  struct GNUNET_CONVERSATION_Caller *caller;
291 
292  for (caller = phone->caller_head; NULL != caller; caller = caller->next)
293  if (cid == caller->cid)
294  return caller;
295  return NULL;
296 }
297 
298 
305 static void
307  const struct ClientPhoneHangupMessage *hang)
308 {
309  struct GNUNET_CONVERSATION_Phone *phone = cls;
310  struct GNUNET_CONVERSATION_Caller *caller;
311 
312  caller = find_caller (phone,
313  hang->cid);
314  if (NULL == caller)
315  {
317  "Received HANG_UP message for unknown caller ID %u\n",
318  (unsigned int) hang->cid);
319  return;
320  }
321 
323  "Received HANG_UP message, terminating call with `%s'\n",
325  switch (caller->state)
326  {
327  case CS_RINGING:
328  phone->event_handler (phone->event_handler_cls,
330  caller,
331  &caller->caller_id);
332  break;
333 
334  case CS_ACTIVE:
335  caller->speaker->disable_speaker (caller->speaker->cls);
336  caller->mic->disable_microphone (caller->mic->cls);
337  phone->event_handler (phone->event_handler_cls,
339  caller,
340  &caller->caller_id);
341  break;
342 
343  case CS_CALLEE_SUSPENDED:
344  case CS_CALLER_SUSPENDED:
345  case CS_BOTH_SUSPENDED:
346  phone->event_handler (phone->event_handler_cls,
348  caller,
349  &caller->caller_id);
350  break;
351  }
353  phone->caller_tail,
354  caller);
355  GNUNET_free (caller);
356 }
357 
358 
365 static void
367  const struct ClientPhoneSuspendMessage *suspend)
368 {
369  struct GNUNET_CONVERSATION_Phone *phone = cls;
370  struct GNUNET_CONVERSATION_Caller *caller;
371 
372  caller = find_caller (phone,
373  suspend->cid);
374  if (NULL == caller)
375  return;
376  switch (caller->state)
377  {
378  case CS_RINGING:
379  GNUNET_break_op (0);
380  break;
381 
382  case CS_ACTIVE:
383  caller->state = CS_CALLER_SUSPENDED;
384  caller->speaker->disable_speaker (caller->speaker->cls);
385  caller->mic->disable_microphone (caller->mic->cls);
386  caller->event_handler (caller->event_handler_cls,
388  break;
389 
390  case CS_CALLEE_SUSPENDED:
391  caller->state = CS_BOTH_SUSPENDED;
392  caller->event_handler (caller->event_handler_cls,
394  break;
395 
396  case CS_CALLER_SUSPENDED:
397  case CS_BOTH_SUSPENDED:
398  GNUNET_break_op (0);
399  break;
400  }
401 }
402 
403 
410 static void
412  const struct ClientPhoneResumeMessage *resume)
413 {
414  struct GNUNET_CONVERSATION_Phone *phone = cls;
415  struct GNUNET_CONVERSATION_Caller *caller;
416 
417  caller = find_caller (phone,
418  resume->cid);
419  if (NULL == caller)
420  return;
421  switch (caller->state)
422  {
423  case CS_RINGING:
424  GNUNET_break_op (0);
425  break;
426 
427  case CS_ACTIVE:
428  case CS_CALLEE_SUSPENDED:
429  GNUNET_break_op (0);
430  break;
431 
432  case CS_CALLER_SUSPENDED:
433  caller->state = CS_ACTIVE;
434  caller->speaker->enable_speaker (caller->speaker->cls);
435  caller->mic->enable_microphone (caller->mic->cls,
437  caller);
438  caller->event_handler (caller->event_handler_cls,
440  break;
441 
442  case CS_BOTH_SUSPENDED:
443  caller->state = CS_CALLEE_SUSPENDED;
444  caller->event_handler (caller->event_handler_cls,
446  break;
447  }
448 }
449 
450 
458 static int
459 check_phone_audio (void *cls,
460  const struct ClientAudioMessage *am)
461 {
462  (void) cls;
463  (void) am;
464 
465  /* any variable-size payload is OK */
466  return GNUNET_OK;
467 }
468 
469 
476 static void
478  const struct ClientAudioMessage *am)
479 {
480  struct GNUNET_CONVERSATION_Phone *phone = cls;
481  struct GNUNET_CONVERSATION_Caller *caller;
482 
483  caller = find_caller (phone,
484  am->cid);
485  if (NULL == caller)
486  return;
487  switch (caller->state)
488  {
489  case CS_RINGING:
490  GNUNET_break_op (0);
491  break;
492 
493  case CS_ACTIVE:
494  caller->speaker->play (caller->speaker->cls,
495  ntohs (am->header.size) - sizeof(struct
497  &am[1]);
498  break;
499 
500  case CS_CALLEE_SUSPENDED:
501  case CS_CALLER_SUSPENDED:
502  case CS_BOTH_SUSPENDED:
503  break;
504  }
505 }
506 
507 
514 static void
516  enum GNUNET_MQ_Error error)
517 {
518  struct GNUNET_CONVERSATION_Phone *phone = cls;
519 
520  (void) error;
522  _ (
523  "Connection to conversation service lost, trying to reconnect\n"));
524  reconnect_phone (phone);
525 }
526 
527 
533 static void
535 {
536  struct GNUNET_CONVERSATION_Caller *caller;
537 
538  while (NULL != (caller = phone->caller_head))
539  {
540  /* make sure mic/speaker are disabled *before* callback */
541  if (CS_ACTIVE == caller->state)
542  {
543  caller->speaker->disable_speaker (caller->speaker->cls);
544  caller->mic->disable_microphone (caller->mic->cls);
545  caller->state = CS_CALLER_SUSPENDED;
546  }
547  phone->event_handler (phone->event_handler_cls,
549  caller,
550  &caller->caller_id);
552  }
553 }
554 
555 
561 static void
563 {
564  struct GNUNET_MQ_MessageHandler handlers[] = {
565  GNUNET_MQ_hd_fixed_size (phone_ring,
567  struct ClientPhoneRingMessage,
568  phone),
569  GNUNET_MQ_hd_fixed_size (phone_hangup,
572  phone),
573  GNUNET_MQ_hd_fixed_size (phone_suspend,
576  phone),
577  GNUNET_MQ_hd_fixed_size (phone_resume,
580  phone),
581  GNUNET_MQ_hd_var_size (phone_audio,
583  struct ClientAudioMessage,
584  phone),
586  };
587  struct GNUNET_MQ_Envelope *e;
588  struct ClientPhoneRegisterMessage *reg;
589 
590  clean_up_callers (phone);
591  if (NULL != phone->mq)
592  {
593  GNUNET_MQ_destroy (phone->mq);
594  phone->mq = NULL;
595  }
596  phone->state = PS_REGISTER;
597  phone->mq = GNUNET_CLIENT_connect (phone->cfg,
598  "conversation",
599  handlers,
601  phone);
602  if (NULL == phone->mq)
603  return;
604  e = GNUNET_MQ_msg (reg,
606  reg->line_port = phone->my_record.line_port;
607  GNUNET_MQ_send (phone->mq,
608  e);
609  phone->state = PS_READY;
610 }
611 
612 
625  const struct GNUNET_IDENTITY_Ego *ego,
628  void *event_handler_cls)
629 {
631  char *line;
632  struct GNUNET_HashCode line_port;
633 
634  if (GNUNET_OK !=
636  "CONVERSATION",
637  "LINE",
638  &line))
639  {
641  "CONVERSATION",
642  "LINE");
643  return NULL;
644  }
645  GNUNET_CRYPTO_hash (line,
646  strlen (line),
647  &line_port);
648  phone = GNUNET_new (struct GNUNET_CONVERSATION_Phone);
649  if (GNUNET_OK !=
651  &phone->my_record.peer))
652  {
653  GNUNET_break (0);
654  GNUNET_free (phone);
655  return NULL;
656  }
657  phone->cfg = cfg;
659  phone->event_handler = event_handler;
661  phone->ns = GNUNET_NAMESTORE_connect (cfg);
662  phone->my_record.version = htonl (1);
663  phone->my_record.reserved = htonl (0);
664  phone->my_record.line_port = line_port;
665  reconnect_phone (phone);
666  if ((NULL == phone->mq) ||
667  (NULL == phone->ns))
668  {
669  GNUNET_break (0);
671  return NULL;
672  }
673  return phone;
674 }
675 
676 
685 void
687  struct GNUNET_GNSRECORD_Data *rd)
688 {
689  rd->data = &phone->my_record;
690  rd->expiration_time = 0;
691  rd->data_size = sizeof(struct GNUNET_CONVERSATION_PhoneRecord);
694 }
695 
696 
707 void
711  void *event_handler_cls,
714 {
715  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
716  struct GNUNET_MQ_Envelope *e;
717  struct ClientPhonePickupMessage *pick;
718 
719  GNUNET_assert (CS_RINGING == caller->state);
720  caller->speaker = speaker;
721  caller->mic = mic;
722  e = GNUNET_MQ_msg (pick,
724  pick->cid = caller->cid;
725  GNUNET_MQ_send (phone->mq,
726  e);
727  caller->state = CS_ACTIVE;
728  caller->event_handler = event_handler;
730  caller->speaker->enable_speaker (caller->speaker->cls);
731  caller->mic->enable_microphone (caller->mic->cls,
733  caller);
734 }
735 
736 
743 void
745 {
746  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
747  struct GNUNET_MQ_Envelope *e;
748  struct ClientPhoneHangupMessage *hang;
749 
750  switch (caller->state)
751  {
752  case CS_ACTIVE:
753  caller->speaker->disable_speaker (caller->speaker->cls);
754  caller->mic->disable_microphone (caller->mic->cls);
755  break;
756 
757  default:
758  break;
759  }
761  phone->caller_tail,
762  caller);
763  e = GNUNET_MQ_msg (hang,
765  hang->cid = caller->cid;
766  GNUNET_MQ_send (phone->mq,
767  e);
768  GNUNET_free (caller);
769 }
770 
771 
777 void
779 {
780  clean_up_callers (phone);
781  if (NULL != phone->ns)
782  {
784  phone->ns = NULL;
785  }
786  if (NULL != phone->mq)
787  {
788  GNUNET_MQ_destroy (phone->mq);
789  phone->mq = NULL;
790  }
791  GNUNET_free (phone);
792 }
793 
794 
802 void
804 {
805  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
806  struct GNUNET_MQ_Envelope *e;
807  struct ClientPhoneSuspendMessage *suspend;
808 
809  GNUNET_assert ((CS_ACTIVE == caller->state) ||
810  (CS_CALLER_SUSPENDED == caller->state));
811  if (CS_ACTIVE == caller->state)
812  {
813  caller->speaker->disable_speaker (caller->speaker->cls);
814  caller->mic->disable_microphone (caller->mic->cls);
815  }
816  caller->speaker = NULL;
817  caller->mic = NULL;
818  e = GNUNET_MQ_msg (suspend,
820  suspend->cid = caller->cid;
821  GNUNET_MQ_send (phone->mq,
822  e);
823  if (CS_ACTIVE == caller->state)
824  caller->state = CS_CALLEE_SUSPENDED;
825  else
826  caller->state = CS_BOTH_SUSPENDED;
827 }
828 
829 
837 void
841 {
842  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
843  struct GNUNET_MQ_Envelope *e;
844  struct ClientPhoneResumeMessage *resume;
845 
846  GNUNET_assert ((CS_CALLEE_SUSPENDED == caller->state) ||
847  (CS_BOTH_SUSPENDED == caller->state));
848  caller->speaker = speaker;
849  caller->mic = mic;
850  e = GNUNET_MQ_msg (resume,
852  resume->cid = caller->cid;
853  GNUNET_MQ_send (phone->mq,
854  e);
855  if (CS_CALLEE_SUSPENDED == caller->state)
856  {
857  caller->state = CS_ACTIVE;
858  caller->speaker->enable_speaker (caller->speaker->cls);
859  caller->mic->enable_microphone (caller->mic->cls,
861  caller);
862  }
863  else
864  {
865  caller->state = CS_CALLER_SUSPENDED;
866  }
867 }
868 
869 
870 /* end of conversation_api.c */
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:144
We still need to register the phone.
struct GNUNET_PeerIdentity peer
Identity of the peer hosting the phone service.
The phone is in an active conversation.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
enum PhoneState state
State machine for the phone.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
GNUNET_MQ_Error
Error codes for the queue.
struct GNUNET_CRYPTO_EcdsaPublicKey caller_id
Who is calling us?
Definition: conversation.h:108
constants for network protocols
GNUNET_MICROPHONE_DisableCallback disable_microphone
Turn the microphone off.
GNUNET_CONVERSATION_PhoneEventHandler event_handler
Function to call for phone events.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:181
void GNUNET_CONVERSATION_caller_hang_up(struct GNUNET_CONVERSATION_Caller *caller)
Hang up up a (possibly ringing) phone.
struct GNUNET_SPEAKER_Handle * speaker
Speaker, or NULL if none is attached.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
GNUNET_SPEAKER_PlayCallback play
Play audio.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
We are the callee and the caller resumed the call.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct Experiment * e
GNUNET_MICROPHONE_EnableCallback enable_microphone
Turn on the microphone.
Client -> Service message to register a phone.
Definition: conversation.h:70
void GNUNET_CONVERSATION_phone_get_record(struct GNUNET_CONVERSATION_Phone *phone, struct GNUNET_GNSRECORD_Data *rd)
Fill in a namestore record with the contact information for this phone.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_GNSRECORD_TYPE_PHONE
Record type for a phone (of CONVERSATION).
size_t data_size
Number of bytes in data.
GNUNET_SPEAKER_DisableCallback disable_speaker
Turn the speaker off.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Private ECC key encoded for transmission.
struct GNUNET_CRYPTO_EcdsaPrivateKey my_zone
My GNS zone.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO
Client <-> Server message to send audio data.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP
Client -> Server message to reject/hangup a call.
Client -> Service pick up phone that is ringing.
Definition: conversation.h:151
struct GNUNET_CONVERSATION_Caller * next
We keep all callers in a DLL.
static void clean_up_callers(struct GNUNET_CONVERSATION_Phone *phone)
Clean up all callers of the given phone.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
A phone is a device that can ring to signal an incoming call and that you can pick up to answer the c...
A phone record specifies which peer is hosting a given user and may also specify the phone line that ...
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING
Client <- Server message to indicate a ringing phone.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
Handle for an ego.
Definition: identity.h:245
struct GNUNET_CONVERSATION_Caller * prev
We keep all callers in a DLL.
enum CallerState state
State machine for the phone.
void * event_handler_cls
Closure for event_handler.
struct GNUNET_CONVERSATION_Caller * caller_tail
We keep all callers in a DLL.
const void * data
Binary value stored in the DNS record.
static char * line
Desired phone line (string to be converted to a hash).
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
The phone is ringing (user knows about incoming call).
Client <-> Service hang up phone that may or may not be ringing.
Definition: conversation.h:170
struct GNUNET_MICROPHONE_Handle * mic
Microphone, or NULL if none is attached.
static void handle_phone_suspend(void *cls, const struct ClientPhoneSuspendMessage *suspend)
We received a struct ClientPhoneSuspendMessage.
GNUNET_CONVERSATION_CallerEventHandler event_handler
Function to call for phone events.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
static void handle_phone_audio(void *cls, const struct ClientAudioMessage *am)
We received a struct ClientAudioMessage
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
void * cls
Closure for the callbacks.
Connection to the NAMESTORE service.
uint64_t expiration_time
Expiration time for the DNS record.
We suspended the conversation.
uint32_t cid
Internal handle to identify the caller with the service.
void GNUNET_CONVERSATION_phone_destroy(struct GNUNET_CONVERSATION_Phone *phone)
Destroys a phone.
struct GNUNET_CONVERSATION_PhoneRecord my_record
This phone&#39;s record.
struct GNUNET_CRYPTO_EcdsaPublicKey caller_id
Identity of the person calling us.
static int check_phone_audio(void *cls, const struct ClientAudioMessage *am)
We received a struct ClientAudioMessage, check it is well-formed.
CallerState
Possible states of a caller.
A 512-bit hashcode.
Caller suspended the conversation.
A caller is the handle we have for an incoming call.
Message handler for a specific message type.
GNUNET_SPEAKER_EnableCallback enable_speaker
Turn on the speaker.
static void transmit_phone_audio(void *cls, size_t data_size, const void *data)
Process recorded audio data.
The conversation was terminated by the caller.
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
static struct GNUNET_CONVERSATION_Caller * find_caller(struct GNUNET_CONVERSATION_Phone *phone, uint32_t cid)
Find the record of the caller matching the cid.
We are waiting for calls.
void * cls
Closure for the callbacks.
void GNUNET_CONVERSATION_caller_pick_up(struct GNUNET_CONVERSATION_Caller *caller, GNUNET_CONVERSATION_CallerEventHandler event_handler, void *event_handler_cls, struct GNUNET_SPEAKER_Handle *speaker, struct GNUNET_MICROPHONE_Handle *mic)
Picks up a (ringing) phone.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME
Client <-> Server message to resume connection.
static void reconnect_phone(struct GNUNET_CONVERSATION_Phone *phone)
The phone got disconnected, reconnect to the service.
uint32_t cid
CID, internal caller ID number used in the future to identify which active call we are talking about...
Definition: conversation.h:103
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
const char * GNUNET_GNSRECORD_pkey_to_zkey(const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey)
Convert public key to the respective absolute domain name in the ".zkey" pTLD.
struct GNUNET_HashCode line_port
Phone line / CADET port to register.
Definition: conversation.h:85
Both sides suspended the conversation.
void(* GNUNET_CONVERSATION_PhoneEventHandler)(void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code, struct GNUNET_CONVERSATION_Caller *caller, const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id)
Function called with an event emitted by a phone.
Service <-> Client message for phone was resumed.
Definition: conversation.h:133
static void handle_phone_hangup(void *cls, const struct ClientPhoneHangupMessage *hang)
We received a struct ClientPhoneHangupMessage.
uint32_t version
Version of the phone record, for now always one.
void GNUNET_CONVERSATION_caller_resume(struct GNUNET_CONVERSATION_Caller *caller, struct GNUNET_SPEAKER_Handle *speaker, struct GNUNET_MICROPHONE_Handle *mic)
Resume suspended conversation of a phone.
Handle to a message queue.
Definition: mq.c:85
We are the callee and the caller suspended the call.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER
Client -> Server message to register a phone.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:162
void GNUNET_CONVERSATION_caller_suspend(struct GNUNET_CONVERSATION_Caller *caller)
Pause conversation of an active call.
uint32_t record_type
Type of the GNS/DNS record.
configuration data
Definition: configuration.c:85
struct GNUNET_CONVERSATION_Phone * phone
Our phone.
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
struct GNUNET_CONVERSATION_Phone * GNUNET_CONVERSATION_phone_create(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_IDENTITY_Ego *ego, GNUNET_CONVERSATION_PhoneEventHandler event_handler, void *event_handler_cls)
Create a new phone.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
Service -> Client message for phone is ringing.
Definition: conversation.h:92
We are the callee and the phone is ringing.
#define GNUNET_log(kind,...)
Message Client <-> Service to transmit the audio.
Definition: conversation.h:188
struct GNUNET_HashCode line_port
Phone line (CADET port) to connect to.
static void handle_phone_resume(void *cls, const struct ClientPhoneResumeMessage *resume)
We received a struct ClientPhoneResumeMessage.
void * event_handler_cls
Closure for event_handler.
int GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host&#39;s peer.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO.
Definition: conversation.h:193
static void handle_phone_ring(void *cls, const struct ClientPhoneRingMessage *ring)
We received a struct ClientPhoneRingMessage
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
PhoneState
Possible states of a phone.
A microphone is a device that can capture or otherwise produce audio data.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
struct GNUNET_CONVERSATION_Caller * caller_head
We keep all callers in a DLL.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND
Client <-> Server message to suspend connection.
Service <-> Client message for phone was suspended.
Definition: conversation.h:115
uint32_t data
The data value.
struct GNUNET_NAMESTORE_Handle * ns
Connection to NAMESTORE (for reverse lookup).
A speaker is a device that can play or record audio data.
static void phone_error_handler(void *cls, enum GNUNET_MQ_Error error)
We encountered an error talking with the conversation service.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP
Client -> Server message to reject/hangup a call.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:126
void(* GNUNET_CONVERSATION_CallerEventHandler)(void *cls, enum GNUNET_CONVERSATION_CallerEventCode code)
Function called with an event emitted by a caller.
#define GNUNET_free(ptr)
Wrapper around free.
uint32_t cid
CID, internal caller ID to identify which active call we are sending data to.
Definition: conversation.h:199