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 
41 
46 
51 
56 
61 };
62 
63 
64 
73 
78 
83 
88 
93 
98 
103 
108 
112  uint32_t cid;
113 
118 };
119 
120 
129 
134 };
135 
136 
153 
158 
163 
168 
173 
178 
183 
188 
193 
198 };
199 
200 
206 static void
208 
209 
217 static void
219  size_t data_size,
220  const void *data)
221 {
222  struct GNUNET_CONVERSATION_Caller *caller = cls;
223  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
224  struct GNUNET_MQ_Envelope *e;
225  struct ClientAudioMessage *am;
226 
227  e = GNUNET_MQ_msg_extra(am,
228  data_size,
230  am->cid = caller->cid;
231  GNUNET_memcpy(&am[1],
232  data,
233  data_size);
234  GNUNET_MQ_send(phone->mq,
235  e);
236 }
237 
238 
245 static void
247  const struct ClientPhoneRingMessage *ring)
248 {
249  struct GNUNET_CONVERSATION_Phone *phone = cls;
250  struct GNUNET_CONVERSATION_Caller *caller;
251 
252  switch (phone->state)
253  {
254  case PS_REGISTER:
255  GNUNET_assert(0);
256  break;
257 
258  case PS_READY:
259  caller = GNUNET_new(struct GNUNET_CONVERSATION_Caller);
260  caller->phone = phone;
262  phone->caller_tail,
263  caller);
264  caller->caller_id = ring->caller_id;
265  caller->cid = ring->cid;
266  caller->state = CS_RINGING;
267  phone->event_handler(phone->event_handler_cls,
269  caller,
270  &caller->caller_id);
271  break;
272  }
273 }
274 
275 
283 static struct GNUNET_CONVERSATION_Caller *
285  uint32_t cid)
286 {
287  struct GNUNET_CONVERSATION_Caller *caller;
288 
289  for (caller = phone->caller_head; NULL != caller; caller = caller->next)
290  if (cid == caller->cid)
291  return caller;
292  return NULL;
293 }
294 
295 
302 static void
304  const struct ClientPhoneHangupMessage *hang)
305 {
306  struct GNUNET_CONVERSATION_Phone *phone = cls;
307  struct GNUNET_CONVERSATION_Caller *caller;
308 
309  caller = find_caller(phone,
310  hang->cid);
311  if (NULL == caller)
312  {
314  "Received HANG_UP message for unknown caller ID %u\n",
315  (unsigned int)hang->cid);
316  return;
317  }
318 
320  "Received HANG_UP message, terminating call with `%s'\n",
322  switch (caller->state)
323  {
324  case CS_RINGING:
325  phone->event_handler(phone->event_handler_cls,
327  caller,
328  &caller->caller_id);
329  break;
330 
331  case CS_ACTIVE:
332  caller->speaker->disable_speaker(caller->speaker->cls);
333  caller->mic->disable_microphone(caller->mic->cls);
334  phone->event_handler(phone->event_handler_cls,
336  caller,
337  &caller->caller_id);
338  break;
339 
340  case CS_CALLEE_SUSPENDED:
341  case CS_CALLER_SUSPENDED:
342  case CS_BOTH_SUSPENDED:
343  phone->event_handler(phone->event_handler_cls,
345  caller,
346  &caller->caller_id);
347  break;
348  }
350  phone->caller_tail,
351  caller);
352  GNUNET_free(caller);
353 }
354 
355 
362 static void
364  const struct ClientPhoneSuspendMessage *suspend)
365 {
366  struct GNUNET_CONVERSATION_Phone *phone = cls;
367  struct GNUNET_CONVERSATION_Caller *caller;
368 
369  caller = find_caller(phone,
370  suspend->cid);
371  if (NULL == caller)
372  return;
373  switch (caller->state)
374  {
375  case CS_RINGING:
376  GNUNET_break_op(0);
377  break;
378 
379  case CS_ACTIVE:
380  caller->state = CS_CALLER_SUSPENDED;
381  caller->speaker->disable_speaker(caller->speaker->cls);
382  caller->mic->disable_microphone(caller->mic->cls);
383  caller->event_handler(caller->event_handler_cls,
385  break;
386 
387  case CS_CALLEE_SUSPENDED:
388  caller->state = CS_BOTH_SUSPENDED;
389  caller->event_handler(caller->event_handler_cls,
391  break;
392 
393  case CS_CALLER_SUSPENDED:
394  case CS_BOTH_SUSPENDED:
395  GNUNET_break_op(0);
396  break;
397  }
398 }
399 
400 
407 static void
409  const struct ClientPhoneResumeMessage *resume)
410 {
411  struct GNUNET_CONVERSATION_Phone *phone = cls;
412  struct GNUNET_CONVERSATION_Caller *caller;
413 
414  caller = find_caller(phone,
415  resume->cid);
416  if (NULL == caller)
417  return;
418  switch (caller->state)
419  {
420  case CS_RINGING:
421  GNUNET_break_op(0);
422  break;
423 
424  case CS_ACTIVE:
425  case CS_CALLEE_SUSPENDED:
426  GNUNET_break_op(0);
427  break;
428 
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 
439  case CS_BOTH_SUSPENDED:
440  caller->state = CS_CALLEE_SUSPENDED;
441  caller->event_handler(caller->event_handler_cls,
443  break;
444  }
445 }
446 
447 
455 static int
457  const struct ClientAudioMessage *am)
458 {
459  (void)cls;
460  (void)am;
461 
462  /* any variable-size payload is OK */
463  return GNUNET_OK;
464 }
465 
466 
473 static void
475  const struct ClientAudioMessage *am)
476 {
477  struct GNUNET_CONVERSATION_Phone *phone = cls;
478  struct GNUNET_CONVERSATION_Caller *caller;
479 
480  caller = find_caller(phone,
481  am->cid);
482  if (NULL == caller)
483  return;
484  switch (caller->state)
485  {
486  case CS_RINGING:
487  GNUNET_break_op(0);
488  break;
489 
490  case CS_ACTIVE:
491  caller->speaker->play(caller->speaker->cls,
492  ntohs(am->header.size) - sizeof(struct ClientAudioMessage),
493  &am[1]);
494  break;
495 
496  case CS_CALLEE_SUSPENDED:
497  case CS_CALLER_SUSPENDED:
498  case CS_BOTH_SUSPENDED:
499  break;
500  }
501 }
502 
503 
510 static void
512  enum GNUNET_MQ_Error error)
513 {
514  struct GNUNET_CONVERSATION_Phone *phone = cls;
515 
516  (void)error;
518  _("Connection to conversation service lost, trying to reconnect\n"));
519  reconnect_phone(phone);
520 }
521 
522 
528 static void
530 {
531  struct GNUNET_CONVERSATION_Caller *caller;
532 
533  while (NULL != (caller = phone->caller_head))
534  {
535  /* make sure mic/speaker are disabled *before* callback */
536  if (CS_ACTIVE == caller->state)
537  {
538  caller->speaker->disable_speaker(caller->speaker->cls);
539  caller->mic->disable_microphone(caller->mic->cls);
540  caller->state = CS_CALLER_SUSPENDED;
541  }
542  phone->event_handler(phone->event_handler_cls,
544  caller,
545  &caller->caller_id);
547  }
548 }
549 
550 
556 static void
558 {
559  struct GNUNET_MQ_MessageHandler handlers[] = {
560  GNUNET_MQ_hd_fixed_size(phone_ring,
562  struct ClientPhoneRingMessage,
563  phone),
564  GNUNET_MQ_hd_fixed_size(phone_hangup,
567  phone),
568  GNUNET_MQ_hd_fixed_size(phone_suspend,
571  phone),
572  GNUNET_MQ_hd_fixed_size(phone_resume,
575  phone),
576  GNUNET_MQ_hd_var_size(phone_audio,
578  struct ClientAudioMessage,
579  phone),
581  };
582  struct GNUNET_MQ_Envelope *e;
583  struct ClientPhoneRegisterMessage *reg;
584 
585  clean_up_callers(phone);
586  if (NULL != phone->mq)
587  {
588  GNUNET_MQ_destroy(phone->mq);
589  phone->mq = NULL;
590  }
591  phone->state = PS_REGISTER;
592  phone->mq = GNUNET_CLIENT_connect(phone->cfg,
593  "conversation",
594  handlers,
596  phone);
597  if (NULL == phone->mq)
598  return;
599  e = GNUNET_MQ_msg(reg,
601  reg->line_port = phone->my_record.line_port;
602  GNUNET_MQ_send(phone->mq,
603  e);
604  phone->state = PS_READY;
605 }
606 
607 
620  const struct GNUNET_IDENTITY_Ego *ego,
622  void *event_handler_cls)
623 {
625  char *line;
626  struct GNUNET_HashCode line_port;
627 
628  if (GNUNET_OK !=
630  "CONVERSATION",
631  "LINE",
632  &line))
633  {
635  "CONVERSATION",
636  "LINE");
637  return NULL;
638  }
639  GNUNET_CRYPTO_hash(line,
640  strlen(line),
641  &line_port);
642  phone = GNUNET_new(struct GNUNET_CONVERSATION_Phone);
643  if (GNUNET_OK !=
645  &phone->my_record.peer))
646  {
647  GNUNET_break(0);
648  GNUNET_free(phone);
649  return NULL;
650  }
651  phone->cfg = cfg;
653  phone->event_handler = event_handler;
655  phone->ns = GNUNET_NAMESTORE_connect(cfg);
656  phone->my_record.version = htonl(1);
657  phone->my_record.reserved = htonl(0);
658  phone->my_record.line_port = line_port;
659  reconnect_phone(phone);
660  if ((NULL == phone->mq) ||
661  (NULL == phone->ns))
662  {
663  GNUNET_break(0);
665  return NULL;
666  }
667  return phone;
668 }
669 
670 
679 void
681  struct GNUNET_GNSRECORD_Data *rd)
682 {
683  rd->data = &phone->my_record;
684  rd->expiration_time = 0;
685  rd->data_size = sizeof(struct GNUNET_CONVERSATION_PhoneRecord);
688 }
689 
690 
701 void
704  void *event_handler_cls,
707 {
708  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
709  struct GNUNET_MQ_Envelope *e;
710  struct ClientPhonePickupMessage *pick;
711 
712  GNUNET_assert(CS_RINGING == caller->state);
713  caller->speaker = speaker;
714  caller->mic = mic;
715  e = GNUNET_MQ_msg(pick,
717  pick->cid = caller->cid;
718  GNUNET_MQ_send(phone->mq,
719  e);
720  caller->state = CS_ACTIVE;
721  caller->event_handler = event_handler;
723  caller->speaker->enable_speaker(caller->speaker->cls);
724  caller->mic->enable_microphone(caller->mic->cls,
726  caller);
727 }
728 
729 
736 void
738 {
739  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
740  struct GNUNET_MQ_Envelope *e;
741  struct ClientPhoneHangupMessage *hang;
742 
743  switch (caller->state)
744  {
745  case CS_ACTIVE:
746  caller->speaker->disable_speaker(caller->speaker->cls);
747  caller->mic->disable_microphone(caller->mic->cls);
748  break;
749 
750  default:
751  break;
752  }
754  phone->caller_tail,
755  caller);
756  e = GNUNET_MQ_msg(hang,
758  hang->cid = caller->cid;
759  GNUNET_MQ_send(phone->mq,
760  e);
761  GNUNET_free(caller);
762 }
763 
764 
770 void
772 {
773  clean_up_callers(phone);
774  if (NULL != phone->ns)
775  {
777  phone->ns = NULL;
778  }
779  if (NULL != phone->mq)
780  {
781  GNUNET_MQ_destroy(phone->mq);
782  phone->mq = NULL;
783  }
784  GNUNET_free(phone);
785 }
786 
787 
795 void
797 {
798  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
799  struct GNUNET_MQ_Envelope *e;
800  struct ClientPhoneSuspendMessage *suspend;
801 
802  GNUNET_assert((CS_ACTIVE == caller->state) ||
803  (CS_CALLER_SUSPENDED == caller->state));
804  if (CS_ACTIVE == caller->state)
805  {
806  caller->speaker->disable_speaker(caller->speaker->cls);
807  caller->mic->disable_microphone(caller->mic->cls);
808  }
809  caller->speaker = NULL;
810  caller->mic = NULL;
811  e = GNUNET_MQ_msg(suspend,
813  suspend->cid = caller->cid;
814  GNUNET_MQ_send(phone->mq,
815  e);
816  if (CS_ACTIVE == caller->state)
817  caller->state = CS_CALLEE_SUSPENDED;
818  else
819  caller->state = CS_BOTH_SUSPENDED;
820 }
821 
822 
830 void
834 {
835  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
836  struct GNUNET_MQ_Envelope *e;
837  struct ClientPhoneResumeMessage *resume;
838 
839  GNUNET_assert((CS_CALLEE_SUSPENDED == caller->state) ||
840  (CS_BOTH_SUSPENDED == caller->state));
841  caller->speaker = speaker;
842  caller->mic = mic;
843  e = GNUNET_MQ_msg(resume,
845  resume->cid = caller->cid;
846  GNUNET_MQ_send(phone->mq,
847  e);
848  if (CS_CALLEE_SUSPENDED == caller->state)
849  {
850  caller->state = CS_ACTIVE;
851  caller->speaker->enable_speaker(caller->speaker->cls);
852  caller->mic->enable_microphone(caller->mic->cls,
854  caller);
855  }
856  else
857  {
858  caller->state = CS_CALLER_SUSPENDED;
859  }
860 }
861 
862 /* 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:138
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:900
GNUNET_MQ_Error
Error codes for the queue.
struct GNUNET_CRYPTO_EcdsaPublicKey caller_id
Who is calling us?
Definition: conversation.h:104
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:173
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:553
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:68
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:145
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:237
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:163
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:99
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:82
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:128
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:84
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:155
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:83
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:89
We are the callee and the phone is ringing.
#define GNUNET_log(kind,...)
Message Client <-> Service to transmit the audio.
Definition: conversation.h:180
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:821
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO.
Definition: conversation.h:184
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:351
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:111
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:121
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:190