GNUnet  0.10.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 
65 
70 {
71 
76 
81 
86 
91 
96 
101 
106 
111 
115  uint32_t cid;
116 
121 
122 };
123 
124 
129 {
134 
139 
140 };
141 
142 
155 {
160 
165 
170 
175 
180 
185 
190 
195 
200 
205 
206 };
207 
208 
214 static void
216 
217 
225 static void
227  size_t data_size,
228  const void *data)
229 {
230  struct GNUNET_CONVERSATION_Caller *caller = cls;
231  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
232  struct GNUNET_MQ_Envelope *e;
233  struct ClientAudioMessage *am;
234 
235  e = GNUNET_MQ_msg_extra (am,
236  data_size,
238  am->cid = caller->cid;
239  GNUNET_memcpy (&am[1],
240  data,
241  data_size);
242  GNUNET_MQ_send (phone->mq,
243  e);
244 }
245 
246 
253 static void
254 handle_phone_ring (void *cls,
255  const struct ClientPhoneRingMessage *ring)
256 {
257  struct GNUNET_CONVERSATION_Phone *phone = cls;
258  struct GNUNET_CONVERSATION_Caller *caller;
259 
260  switch (phone->state)
261  {
262  case PS_REGISTER:
263  GNUNET_assert (0);
264  break;
265  case PS_READY:
266  caller = GNUNET_new (struct GNUNET_CONVERSATION_Caller);
267  caller->phone = phone;
269  phone->caller_tail,
270  caller);
271  caller->caller_id = ring->caller_id;
272  caller->cid = ring->cid;
273  caller->state = CS_RINGING;
274  phone->event_handler (phone->event_handler_cls,
276  caller,
277  &caller->caller_id);
278  break;
279  }
280 }
281 
282 
290 static struct GNUNET_CONVERSATION_Caller *
292  uint32_t cid)
293 {
294  struct GNUNET_CONVERSATION_Caller *caller;
295 
296  for (caller = phone->caller_head;NULL != caller;caller = caller->next)
297  if (cid == caller->cid)
298  return caller;
299  return NULL;
300 }
301 
302 
309 static void
311  const struct ClientPhoneHangupMessage *hang)
312 {
313  struct GNUNET_CONVERSATION_Phone *phone = cls;
314  struct GNUNET_CONVERSATION_Caller *caller;
315 
316  caller = find_caller (phone,
317  hang->cid);
318  if (NULL == caller)
319  {
321  "Received HANG_UP message for unknown caller ID %u\n",
322  (unsigned int) hang->cid);
323  return;
324  }
325 
327  "Received HANG_UP message, terminating call with `%s'\n",
329  switch (caller->state)
330  {
331  case CS_RINGING:
332  phone->event_handler (phone->event_handler_cls,
334  caller,
335  &caller->caller_id);
336  break;
337  case CS_ACTIVE:
338  caller->speaker->disable_speaker (caller->speaker->cls);
339  caller->mic->disable_microphone (caller->mic->cls);
340  phone->event_handler (phone->event_handler_cls,
342  caller,
343  &caller->caller_id);
344  break;
345  case CS_CALLEE_SUSPENDED:
346  case CS_CALLER_SUSPENDED:
347  case CS_BOTH_SUSPENDED:
348  phone->event_handler (phone->event_handler_cls,
350  caller,
351  &caller->caller_id);
352  break;
353  }
355  phone->caller_tail,
356  caller);
357  GNUNET_free (caller);
358 }
359 
360 
367 static void
369  const struct ClientPhoneSuspendMessage *suspend)
370 {
371  struct GNUNET_CONVERSATION_Phone *phone = cls;
372  struct GNUNET_CONVERSATION_Caller *caller;
373 
374  caller = find_caller (phone,
375  suspend->cid);
376  if (NULL == caller)
377  return;
378  switch (caller->state)
379  {
380  case CS_RINGING:
381  GNUNET_break_op (0);
382  break;
383  case CS_ACTIVE:
384  caller->state = CS_CALLER_SUSPENDED;
385  caller->speaker->disable_speaker (caller->speaker->cls);
386  caller->mic->disable_microphone (caller->mic->cls);
387  caller->event_handler (caller->event_handler_cls,
389  break;
390  case CS_CALLEE_SUSPENDED:
391  caller->state = CS_BOTH_SUSPENDED;
392  caller->event_handler (caller->event_handler_cls,
394  break;
395  case CS_CALLER_SUSPENDED:
396  case CS_BOTH_SUSPENDED:
397  GNUNET_break_op (0);
398  break;
399  }
400 }
401 
402 
409 static void
411  const struct ClientPhoneResumeMessage *resume)
412 {
413  struct GNUNET_CONVERSATION_Phone *phone = cls;
414  struct GNUNET_CONVERSATION_Caller *caller;
415 
416  caller = find_caller (phone,
417  resume->cid);
418  if (NULL == caller)
419  return;
420  switch (caller->state)
421  {
422  case CS_RINGING:
423  GNUNET_break_op (0);
424  break;
425  case CS_ACTIVE:
426  case CS_CALLEE_SUSPENDED:
427  GNUNET_break_op (0);
428  break;
429  case CS_CALLER_SUSPENDED:
430  caller->state = CS_ACTIVE;
431  caller->speaker->enable_speaker (caller->speaker->cls);
432  caller->mic->enable_microphone (caller->mic->cls,
434  caller);
435  caller->event_handler (caller->event_handler_cls,
437  break;
438  case CS_BOTH_SUSPENDED:
439  caller->state = CS_CALLEE_SUSPENDED;
440  caller->event_handler (caller->event_handler_cls,
442  break;
443  }
444 }
445 
446 
454 static int
455 check_phone_audio (void *cls,
456  const struct ClientAudioMessage *am)
457 {
458  (void) cls;
459  (void) am;
460 
461  /* any variable-size payload is OK */
462  return GNUNET_OK;
463 }
464 
465 
472 static void
474  const struct ClientAudioMessage *am)
475 {
476  struct GNUNET_CONVERSATION_Phone *phone = cls;
477  struct GNUNET_CONVERSATION_Caller *caller;
478 
479  caller = find_caller (phone,
480  am->cid);
481  if (NULL == caller)
482  return;
483  switch (caller->state)
484  {
485  case CS_RINGING:
486  GNUNET_break_op (0);
487  break;
488  case CS_ACTIVE:
489  caller->speaker->play (caller->speaker->cls,
490  ntohs (am->header.size) - sizeof (struct ClientAudioMessage),
491  &am[1]);
492  break;
493  case CS_CALLEE_SUSPENDED:
494  case CS_CALLER_SUSPENDED:
495  case CS_BOTH_SUSPENDED:
496  break;
497  }
498 }
499 
500 
507 static void
509  enum GNUNET_MQ_Error error)
510 {
511  struct GNUNET_CONVERSATION_Phone *phone = cls;
512 
513  (void) error;
515  _("Connection to conversation service lost, trying to reconnect\n"));
516  reconnect_phone (phone);
517 }
518 
519 
525 static void
527 {
528  struct GNUNET_CONVERSATION_Caller *caller;
529 
530  while (NULL != (caller = phone->caller_head))
531  {
532  /* make sure mic/speaker are disabled *before* callback */
533  if (CS_ACTIVE == caller->state)
534  {
535  caller->speaker->disable_speaker (caller->speaker->cls);
536  caller->mic->disable_microphone (caller->mic->cls);
537  caller->state = CS_CALLER_SUSPENDED;
538  }
539  phone->event_handler (phone->event_handler_cls,
541  caller,
542  &caller->caller_id);
544  }
545 }
546 
547 
553 static void
555 {
556  struct GNUNET_MQ_MessageHandler handlers[] = {
557  GNUNET_MQ_hd_fixed_size (phone_ring,
559  struct ClientPhoneRingMessage,
560  phone),
561  GNUNET_MQ_hd_fixed_size (phone_hangup,
564  phone),
565  GNUNET_MQ_hd_fixed_size (phone_suspend,
568  phone),
569  GNUNET_MQ_hd_fixed_size (phone_resume,
572  phone),
573  GNUNET_MQ_hd_var_size (phone_audio,
575  struct ClientAudioMessage,
576  phone),
578  };
579  struct GNUNET_MQ_Envelope *e;
580  struct ClientPhoneRegisterMessage *reg;
581 
582  clean_up_callers (phone);
583  if (NULL != phone->mq)
584  {
585  GNUNET_MQ_destroy (phone->mq);
586  phone->mq = NULL;
587  }
588  phone->state = PS_REGISTER;
589  phone->mq = GNUNET_CLIENT_connect (phone->cfg,
590  "conversation",
591  handlers,
593  phone);
594  if (NULL == phone->mq)
595  return;
596  e = GNUNET_MQ_msg (reg,
598  reg->line_port = phone->my_record.line_port;
599  GNUNET_MQ_send (phone->mq,
600  e);
601  phone->state = PS_READY;
602 }
603 
604 
617  const struct GNUNET_IDENTITY_Ego *ego,
619  void *event_handler_cls)
620 {
622  char *line;
623  struct GNUNET_HashCode line_port;
624 
625  if (GNUNET_OK !=
627  "CONVERSATION",
628  "LINE",
629  &line))
630  {
632  "CONVERSATION",
633  "LINE");
634  return NULL;
635  }
636  GNUNET_CRYPTO_hash (line,
637  strlen (line),
638  &line_port);
639  phone = GNUNET_new (struct GNUNET_CONVERSATION_Phone);
640  if (GNUNET_OK !=
642  &phone->my_record.peer))
643  {
644  GNUNET_break (0);
645  GNUNET_free (phone);
646  return NULL;
647  }
648  phone->cfg = cfg;
650  phone->event_handler = event_handler;
652  phone->ns = GNUNET_NAMESTORE_connect (cfg);
653  phone->my_record.version = htonl (1);
654  phone->my_record.reserved = htonl (0);
655  phone->my_record.line_port = line_port;
656  reconnect_phone (phone);
657  if ( (NULL == phone->mq) ||
658  (NULL == phone->ns) )
659  {
660  GNUNET_break (0);
662  return NULL;
663  }
664  return phone;
665 }
666 
667 
676 void
678  struct GNUNET_GNSRECORD_Data *rd)
679 {
680  rd->data = &phone->my_record;
681  rd->expiration_time = 0;
682  rd->data_size = sizeof (struct GNUNET_CONVERSATION_PhoneRecord);
685 }
686 
687 
698 void
701  void *event_handler_cls,
704 {
705  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
706  struct GNUNET_MQ_Envelope *e;
707  struct ClientPhonePickupMessage *pick;
708 
709  GNUNET_assert (CS_RINGING == caller->state);
710  caller->speaker = speaker;
711  caller->mic = mic;
712  e = GNUNET_MQ_msg (pick,
714  pick->cid = caller->cid;
715  GNUNET_MQ_send (phone->mq,
716  e);
717  caller->state = CS_ACTIVE;
718  caller->event_handler = event_handler;
720  caller->speaker->enable_speaker (caller->speaker->cls);
721  caller->mic->enable_microphone (caller->mic->cls,
723  caller);
724 }
725 
726 
733 void
735 {
736  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
737  struct GNUNET_MQ_Envelope *e;
738  struct ClientPhoneHangupMessage *hang;
739 
740  switch (caller->state)
741  {
742  case CS_ACTIVE:
743  caller->speaker->disable_speaker (caller->speaker->cls);
744  caller->mic->disable_microphone (caller->mic->cls);
745  break;
746  default:
747  break;
748  }
750  phone->caller_tail,
751  caller);
752  e = GNUNET_MQ_msg (hang,
754  hang->cid = caller->cid;
755  GNUNET_MQ_send (phone->mq,
756  e);
757  GNUNET_free (caller);
758 }
759 
760 
766 void
768 {
769  clean_up_callers (phone);
770  if (NULL != phone->ns)
771  {
773  phone->ns = NULL;
774  }
775  if (NULL != phone->mq)
776  {
777  GNUNET_MQ_destroy (phone->mq);
778  phone->mq = NULL;
779  }
780  GNUNET_free (phone);
781 }
782 
783 
791 void
793 {
794  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
795  struct GNUNET_MQ_Envelope *e;
796  struct ClientPhoneSuspendMessage *suspend;
797 
798  GNUNET_assert ( (CS_ACTIVE == caller->state) ||
799  (CS_CALLER_SUSPENDED == caller->state) );
800  if (CS_ACTIVE == caller->state)
801  {
802  caller->speaker->disable_speaker (caller->speaker->cls);
803  caller->mic->disable_microphone (caller->mic->cls);
804  }
805  caller->speaker = NULL;
806  caller->mic = NULL;
807  e = GNUNET_MQ_msg (suspend,
809  suspend->cid = caller->cid;
810  GNUNET_MQ_send (phone->mq,
811  e);
812  if (CS_ACTIVE == caller->state)
813  caller->state = CS_CALLEE_SUSPENDED;
814  else
815  caller->state = CS_BOTH_SUSPENDED;
816 }
817 
818 
826 void
830 {
831  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
832  struct GNUNET_MQ_Envelope *e;
833  struct ClientPhoneResumeMessage *resume;
834 
835  GNUNET_assert ( (CS_CALLEE_SUSPENDED == caller->state) ||
836  (CS_BOTH_SUSPENDED == caller->state) );
837  caller->speaker = speaker;
838  caller->mic = mic;
839  e = GNUNET_MQ_msg (resume,
841  resume->cid = caller->cid;
842  GNUNET_MQ_send (phone->mq,
843  e);
844  if (CS_CALLEE_SUSPENDED == caller->state)
845  {
846  caller->state = CS_ACTIVE;
847  caller->speaker->enable_speaker (caller->speaker->cls);
848  caller->mic->enable_microphone (caller->mic->cls,
850  caller);
851  }
852  else
853  {
854  caller->state = CS_CALLER_SUSPENDED;
855  }
856 }
857 
858 /* 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:146
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.
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:901
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.
#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:185
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:556
GNUNET_SPEAKER_PlayCallback play
Play audio.
#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:78
#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:154
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:208
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.
#define GNUNET_memcpy(dst, src, n)
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:174
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:44
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_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
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:135
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:165
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:193
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:198
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:116
uint32_t data
The data value.
static size_t data_size
Number of bytes in data.
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:127
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:204