GNUnet 0.25.2-12-g8d1cef5f6
 
Loading...
Searching...
No Matches
gnunet-conversation.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2013 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 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
30
34#define MAX_MESSAGE_LENGTH 1024
35
36#define XSTRINGIFY(x) STRINGIFY (x)
37
38#define STRINGIFY(x) (#x)
39
65
66
92
93
98{
102 struct CallList *prev;
103
107 struct CallList *next;
108
113
118
122 unsigned int caller_num;
123};
124
125
130
135
140static struct CallList *cl_active;
141
145static struct CallList *cl_head;
146
150static struct CallList *cl_tail;
151
155static char *line;
156
161
166
171
176
181
186
190static char *ego_name;
191
196
200static char *peer_name;
201
206
211
216
220static unsigned int caller_num_gen;
221
225static char *address;
226
230static int verbose;
231
232
241static void
244 struct GNUNET_CONVERSATION_Caller *caller,
245 const struct GNUNET_CRYPTO_BlindablePublicKey *caller_id)
246{
247 struct CallList *cl;
248
249 (void) cls;
250 switch (code)
251 {
253 /*
254 * FIXME: we should be playing our ringtones from contrib/sounds now!
255 *
256 ring_my_bell();
257 *
258 * see https://gstreamer.freedesktop.org/documentation/application-development/highlevel/playback-components.html on how to play a wav using the gst framework being used here
259 */fprintf (
260 stdout,
261 _ (
262 "Incoming call from `%s'. Please /accept %u or /cancel %u the call.\n"),
266 cl = GNUNET_new (struct CallList);
267 cl->caller = caller;
268 cl->caller_id = *caller_id;
271 break;
272
274 for (cl = cl_head; NULL != cl; cl = cl->next)
275 if (caller == cl->caller)
276 break;
277 if ((NULL == cl) && (caller == cl_active->caller))
278 cl = cl_active;
279 if (NULL == cl)
280 {
281 GNUNET_break (0);
282 return;
283 }
284 fprintf (stdout,
285 _ ("Call from `%s' terminated\n"),
287 if (cl == cl_active)
288 {
289 cl_active = NULL;
291 }
292 else
293 {
295 }
296 GNUNET_free (cl);
297 break;
298 }
299}
300
301
308static void
310{
311 struct CallList *cl = cls;
312
313 switch (code)
314 {
316 fprintf (stdout,
317 _ ("Call from `%s' suspended by other user\n"),
319 break;
320
322 fprintf (stdout,
323 _ ("Call from `%s' resumed by other user\n"),
325 break;
326 }
327}
328
329
333static void
335{
337
338 if (NULL == my_caller_id)
339 {
340 fprintf (stderr,
341 _ ("Ego `%s' no longer available, phone is now down.\n"),
342 ego_name);
344 return;
345 }
346 GNUNET_assert (NULL == phone);
350 NULL);
351 /* FIXME: get record and print full GNS record info later here... */
352 if (NULL == phone)
353 {
354 fprintf (stderr, "%s", _ ("Failed to setup phone (internal error)\n"));
356 }
357 else
358 {
361 address =
363 fprintf (
364 stdout,
365 _ (
366 "Phone active at `%s'. Type `/help' for a list of available commands\n"),
367 address);
369 }
370}
371
372
379static void
381{
382 (void) cls;
383
384 switch (code)
385 {
388 fprintf (stdout,
389 _ ("Resolved address of `%s'. Now ringing other party.\n"),
390 peer_name);
392 break;
393
396 fprintf (stdout, _ ("Connection established to `%s'\n"), peer_name);
398 break;
399
402 fprintf (stdout, _ ("Failed to resolve `%s'\n"), peer_name);
404 peer_name = NULL;
405 call = NULL;
406 break;
407
409 fprintf (stdout, _ ("Call to `%s' terminated\n"), peer_name);
411 peer_name = NULL;
412 call = NULL;
413 break;
414
417 fprintf (stdout,
418 _ ("Connection to `%s' suspended (by other user)\n"),
419 peer_name);
420 break;
421
424 fprintf (stdout,
425 _ ("Connection to `%s' resumed (by other user)\n"),
426 peer_name);
427 break;
428
430 fprintf (stdout, _ ("Error with the call, restarting it\n"));
432 peer_name = NULL;
433 call = NULL;
434 break;
435 }
436}
437
438
444typedef void (*ActionFunction) (const char *arguments);
445
446
451{
455 const char *command;
456
461
465 const char *helptext;
466};
467
468
474static void
475do_help (const char *args);
476
477
483static void
484do_quit (const char *args)
485{
486 (void) args;
488}
489
490
496static void
497do_unknown (const char *msg)
498{
499 fprintf (stderr, _ ("Unknown command `%s'\n"), msg);
500}
501
502
508static void
509do_call (const char *arg)
510{
511 if (NULL == my_caller_id)
512 {
513 fprintf (stderr, _ ("Ego `%s' not available\n"), ego_name);
514 return;
515 }
516 if (NULL != call)
517 {
518 fprintf (stderr,
519 _ ("You are calling someone else already, hang up first!\n"));
520 return;
521 }
522 switch (phone_state)
523 {
524 case PS_LOOKUP_EGO:
525 fprintf (stderr, _ ("Ego `%s' not available\n"), ego_name);
526 return;
527
528 case PS_LISTEN:
529 /* ok to call! */
530 break;
531
532 case PS_ACCEPTED:
533 fprintf (
534 stderr,
535 _ (
536 "You are answering call from `%s', hang up or suspend that call first!\n"),
538 return;
539
540 case PS_ERROR:
541 /* ok to call */
542 break;
543 }
544 if (NULL == arg)
545 {
546 fprintf (stderr, _ ("Call recipient missing.\n"));
547 do_help ("/call");
548 return;
549 }
550 peer_name = GNUNET_strdup (arg);
552 GNUNET_assert (NULL == call);
555 arg,
556 speaker,
557 mic,
559 NULL);
560}
561
562
568static void
569do_accept (const char *args)
570{
571 struct CallList *cl;
572 char buf[32];
573
574 if ((NULL != call) && (CS_SUSPENDED != call_state))
575 {
576 fprintf (stderr,
577 _ ("You are calling someone else already, hang up first!\n"));
578 return;
579 }
580 switch (phone_state)
581 {
582 case PS_LOOKUP_EGO:
583 GNUNET_break (0);
584 break;
585
586 case PS_LISTEN:
587 /* this is the expected state */
588 break;
589
590 case PS_ACCEPTED:
591 fprintf (
592 stderr,
593 _ (
594 "You are answering call from `%s', hang up or suspend that call first!\n"),
596 return;
597
598 case PS_ERROR:
599 GNUNET_break (0);
600 break;
601 }
602 cl = cl_head;
603 if (NULL == cl)
604 {
605 fprintf (stderr, _ ("There is no incoming call to accept here!\n"));
606 return;
607 }
608 if ((NULL != cl->next) || (NULL != args))
609 {
610 for (cl = cl_head; NULL != cl; cl = cl->next)
611 {
612 GNUNET_snprintf (buf, sizeof(buf), "%u", cl->caller_num);
613 if (0 == strcmp (buf, args))
614 break;
615 }
616 }
617 if (NULL == cl)
618 {
619 fprintf (stderr,
620 _ ("There is no incoming call `%s' to accept right now!\n"),
621 args);
622 return;
623 }
625 cl_active = cl;
626 peer_key = cl->caller_id;
630 cl,
631 speaker,
632 mic);
633}
634
635
641static void
642do_address (const char *args)
643{
644 (void) args;
645 if (NULL == address)
646 {
647 fprintf (stdout, "%s", _ ("We currently do not have an address.\n"));
648 return;
649 }
650 fprintf (stdout, "%s\n", address);
651}
652
653
659static void
660do_status (const char *args)
661{
662 struct CallList *cl;
663
664 (void) args;
665 switch (phone_state)
666 {
667 case PS_LOOKUP_EGO:
668 fprintf (
669 stdout,
670 _ (
671 "We are currently trying to locate the private key for the ego `%s'.\n")
672 ,
673 ego_name);
674 break;
675
676 case PS_LISTEN:
677 fprintf (stdout,
678 _ (
679 "We are listening for incoming calls for ego `%s' on line `%s'.\n"),
680 ego_name,
681 line);
682 break;
683
684 case PS_ACCEPTED:
685 fprintf (stdout,
686 _ ("You are having a conversation with `%s'.\n"),
688 ;
689 break;
690
691 case PS_ERROR:
692 fprintf (
693 stdout,
694 _ (
695 "We had an internal error setting up our phone line. You can still make calls.\n"));
696 break;
697 }
698 if (NULL != call)
699 {
700 switch (call_state)
701 {
702 case CS_RESOLVING:
703 fprintf (stdout,
704 _ ("We are trying to find the network address to call `%s'.\n"),
705 peer_name);
706 break;
707
708 case CS_RINGING:
709 fprintf (stdout,
710 _ ("We are calling `%s', their phone should be ringing.\n"),
711 peer_name);
712 break;
713
714 case CS_CONNECTED:
715 fprintf (stdout,
716 _ ("You are having a conversation with `%s'.\n"),
717 peer_name);
718 break;
719
720 case CS_SUSPENDED:
721 /* ok to accept incoming call right now */
722 break;
723 }
724 }
725 if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail)))
726 {
727 fprintf (stdout, "%s", _ ("Calls waiting:\n"));
728 for (cl = cl_head; NULL != cl; cl = cl->next)
729 {
730 if (cl == cl_active)
731 continue;
732 fprintf (stdout,
733 _ ("#%u: `%s'\n"),
734 cl->caller_num,
736 }
737 fprintf (stdout, "%s", "\n");
738 }
739}
740
741
747static void
748do_suspend (const char *args)
749{
750 (void) args;
751 if (NULL != call)
752 {
753 switch (call_state)
754 {
755 case CS_RESOLVING:
756 case CS_RINGING:
757 case CS_SUSPENDED:
758 fprintf (stderr,
759 "%s",
760 _ ("There is no call that could be suspended right now.\n"));
761 return;
762
763 case CS_CONNECTED:
766 return;
767 }
768 }
769 switch (phone_state)
770 {
771 case PS_LOOKUP_EGO:
772 case PS_LISTEN:
773 case PS_ERROR:
774 fprintf (stderr,
775 "%s",
776 _ ("There is no call that could be suspended right now.\n"));
777 return;
778
779 case PS_ACCEPTED:
780 /* expected state, do rejection logic */
781 break;
782 }
783 GNUNET_assert (NULL != cl_active);
785 cl_active = NULL;
787}
788
789
795static void
796do_resume (const char *args)
797{
798 struct CallList *cl;
799 char buf[32];
800
801 if (NULL != call)
802 {
803 switch (call_state)
804 {
805 case CS_RESOLVING:
806 case CS_RINGING:
807 case CS_CONNECTED:
808 fprintf (stderr,
809 "%s",
810 _ ("There is no call that could be resumed right now.\n"));
811 return;
812
813 case CS_SUSPENDED:
816 return;
817 }
818 }
819 switch (phone_state)
820 {
821 case PS_LOOKUP_EGO:
822 case PS_ERROR:
823 fprintf (stderr,
824 "%s",
825 _ ("There is no call that could be resumed right now.\n"));
826 return;
827
828 case PS_LISTEN:
829 /* expected state, do resume logic */
830 break;
831
832 case PS_ACCEPTED:
833 fprintf (stderr,
834 _ ("Already talking with `%s', cannot resume a call right now.\n"),
836 return;
837 }
838 GNUNET_assert (NULL == cl_active);
839 cl = cl_head;
840 if (NULL == cl)
841 {
842 fprintf (stderr, _ ("There is no incoming call to resume here!\n"));
843 return;
844 }
845 if ((NULL != cl->next) || (NULL != args))
846 {
847 for (cl = cl_head; NULL != cl; cl = cl->next)
848 {
849 GNUNET_snprintf (buf, sizeof(buf), "%u", cl->caller_num);
850 if (0 == strcmp (buf, args))
851 break;
852 }
853 }
854 if (NULL == cl)
855 {
856 fprintf (stderr,
857 _ ("There is no incoming call `%s' to resume right now!\n"),
858 args);
859 return;
860 }
861 cl_active = cl;
864}
865
866
872static void
873do_reject (const char *args)
874{
875 struct CallList *cl;
876 char buf[32];
877
878 if (NULL != call)
879 {
881 call = NULL;
882 return;
883 }
884 switch (phone_state)
885 {
886 case PS_LOOKUP_EGO:
887 case PS_ERROR:
888 fprintf (stderr,
889 "%s",
890 _ ("There is no call that could be cancelled right now.\n"));
891 return;
892
893 case PS_LISTEN:
894 /* look for active incoming calls to refuse */
895 cl = cl_head;
896 if (NULL == cl)
897 {
898 fprintf (stderr, _ ("There is no incoming call to refuse here!\n"));
899 return;
900 }
901 if ((NULL != cl->next) || (NULL != args))
902 {
903 for (cl = cl_head; NULL != cl; cl = cl->next)
904 {
905 GNUNET_snprintf (buf, sizeof(buf), "%u", cl->caller_num);
906 if (0 == strcmp (buf, args))
907 break;
908 }
909 }
910 if (NULL == cl)
911 {
912 fprintf (stderr,
913 _ ("There is no incoming call `%s' to refuse right now!\n"),
914 args);
915 return;
916 }
919 GNUNET_free (cl);
920 break;
921
922 case PS_ACCEPTED:
923 /* expected state, do rejection logic */
924 GNUNET_assert (NULL != cl_active);
926 cl_active = NULL;
928 break;
929 }
930}
931
932
936static struct VoipCommand commands[] = {
937 { "/address",
938 &do_address,
940 "Use `/address' to find out which address this phone should have in GNS")}
941 ,
942 { "/call", &do_call, gettext_noop ("Use `/call USER.gnu' to call USER") },
943 { "/accept",
944 &do_accept,
945 gettext_noop ("Use `/accept #NUM' to accept incoming call #NUM") },
946 { "/suspend",
947 &do_suspend,
948 gettext_noop ("Use `/suspend' to suspend the active call") },
949 { "/resume",
950 &do_resume,
952 "Use `/resume [#NUM]' to resume a call, #NUM is needed to resume incoming calls, no argument is needed to resume the current outgoing call.") },
953 { "/cancel",
954 &do_reject,
955 gettext_noop ("Use `/cancel' to reject or terminate a call") },
956 { "/status",
957 &do_status,
958 gettext_noop ("Use `/status' to print status information") },
959 { "/quit",
960 &do_quit,
961 gettext_noop ("Use `/quit' to terminate gnunet-conversation") },
962 { "/help",
963 &do_help,
964 gettext_noop ("Use `/help command' to get help for a specific command") },
965 { "", &do_unknown, NULL },
966 { NULL, NULL, NULL },
967};
968
969
975static void
976do_help (const char *args)
977{
978 unsigned int i;
979
980 i = 0;
981 while ((NULL != args) && (0 != strlen (args)) &&
982 (commands[i].Action != &do_help))
983 {
984 if (0 == strncasecmp (&args[1], &commands[i].command[1], strlen (args) - 1))
985 {
986 fprintf (stdout, "%s\n", gettext (commands[i].helptext));
987 return;
988 }
989 i++;
990 }
991 i = 0;
992 fprintf (stdout, "%s", "Available commands:\n");
993 while (commands[i].Action != &do_help)
994 {
995 fprintf (stdout, "%s\n", gettext (commands[i].command));
996 i++;
997 }
998 fprintf (stdout, "%s", "\n");
999 fprintf (stdout, "%s\n", gettext (commands[i].helptext));
1000}
1001
1002
1008static void
1009do_stop_task (void *cls)
1010{
1011 (void) cls;
1012 if (NULL != call)
1013 {
1015 call = NULL;
1016 }
1017 if (NULL != phone)
1018 {
1020 phone = NULL;
1021 }
1022 if (NULL != handle_cmd_task)
1023 {
1025 handle_cmd_task = NULL;
1026 }
1027 if (NULL != id)
1028 {
1030 id = NULL;
1031 }
1033 speaker = NULL;
1035 mic = NULL;
1037 ego_name = NULL;
1039 peer_name = NULL;
1041}
1042
1043
1050static void
1051handle_command_string (char *message, size_t str_len)
1052{
1053 size_t i;
1054 const char *ptr;
1055
1056 if (0 == str_len)
1057 return;
1058 if (message[str_len - 1] == '\n')
1059 message[str_len - 1] = '\0';
1060 if (message[str_len - 2] == '\r')
1061 message[str_len - 2] = '\0';
1062 if (0 == strlen (message))
1063 return;
1064 i = 0;
1065 while (
1066 (NULL != commands[i].command) &&
1067 (0 !=
1068 strncasecmp (commands[i].command, message, strlen (commands[i].command))))
1069 i++;
1070 ptr = &message[strlen (commands[i].command)];
1071 while (isspace ((unsigned char) *ptr))
1072 ptr++;
1073 if ('\0' == *ptr)
1074 ptr = NULL;
1075 commands[i].Action (ptr);
1076}
1077
1078
1084static void
1086{
1087 char message[MAX_MESSAGE_LENGTH + 1];
1088
1089 (void) cls;
1092 stdin_fh,
1094 NULL);
1095 /* read message from command line and handle it */
1096 memset (message, 0, MAX_MESSAGE_LENGTH + 1);
1097 if (NULL == fgets (message, MAX_MESSAGE_LENGTH, stdin))
1098 return;
1099 handle_command_string (message, strlen (message));
1100}
1101
1102
1111static void
1112identity_cb (void *cls,
1113 struct GNUNET_IDENTITY_Ego *ego,
1114 void **ctx,
1115 const char *name)
1116{
1117 (void) cls;
1118 (void) ctx;
1119 if (NULL == name)
1120 return;
1121 if (ego == my_caller_id)
1122 {
1123 if (verbose)
1124 fprintf (stdout, _ ("Name of our ego changed to `%s'\n"), name);
1127 return;
1128 }
1129 if (0 != strcmp (name, ego_name))
1130 return;
1131 if (NULL == ego)
1132 {
1133 if (verbose)
1134 fprintf (stdout, _ ("Our ego `%s' was deleted!\n"), ego_name);
1135 my_caller_id = NULL;
1136 return;
1137 }
1138 my_caller_id = ego;
1139 GNUNET_CONFIGURATION_set_value_string (cfg, "CONVERSATION", "LINE", line);
1140 start_phone ();
1141}
1142
1143
1152static void
1153run (void *cls,
1154 char *const *args,
1155 const char *cfgfile,
1156 const struct GNUNET_CONFIGURATION_Handle *c)
1157{
1158 (void) cls;
1159 (void) args;
1160 (void) cfgfile;
1164 if (NULL == ego_name)
1165 {
1166 fprintf (stderr, "%s", _ ("You must specify the NAME of an ego to use\n"));
1167 return;
1168 }
1173 NULL);
1175}
1176
1177
1185int
1186main (int argc, char *const *argv)
1187{
1190 'e',
1191 "ego",
1192 "NAME",
1193 gettext_noop ("sets the NAME of the ego to use for the caller ID"),
1194 &ego_name),
1196 "phone",
1197 "LINE",
1198 gettext_noop (
1199 "sets the LINE to use for the phone"),
1200 &line),
1202 int ret;
1203
1204 int flags;
1205 flags = fcntl (0, F_GETFL, 0);
1206 flags |= O_NONBLOCK;
1207 if (0 != fcntl (0, F_SETFL, flags))
1210
1211 ret =
1213 argc,
1214 argv,
1215 "gnunet-conversation",
1216 gettext_noop (
1217 "Enables having a conversation with other GNUnet users."),
1218 options,
1219 &run,
1220 NULL);
1221 if (NULL != cfg)
1222 {
1224 cfg = NULL;
1225 }
1226 return (GNUNET_OK == ret) ? 0 : 1;
1227}
1228
1229
1230/* end of gnunet-conversation.c */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition 002.c:5
struct GNUNET_MessageHeader * msg
Definition 005.c:2
PhoneState
Possible states of a phone.
CallState
Possible states of the phone.
int main()
Program to simulate results from GCP_get_desirability_of_path() for various plausible inputs.
#define gettext_noop(String)
Definition gettext.h:74
#define gettext(Msgid)
Definition gettext.h:50
static int ret
Final status code.
Definition gnunet-arm.c:93
static void do_suspend(const char *args)
Suspending a call.
static void do_status(const char *args)
Accepting an incoming call.
static int verbose
Be verbose.
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).
static void do_address(const char *args)
Print address information for this phone.
static struct GNUNET_IDENTITY_Ego * my_caller_id
Our ego.
static struct CallList * cl_active
Caller handle (for active incoming call).
static void do_quit(const char *args)
Terminate the client.
static void do_call(const char *arg)
Initiating a new call.
static enum CallState call_state
Our call's current state.
void(* ActionFunction)(const char *arguments)
Function declareation for executing a action.
static struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
static void do_help(const char *args)
Action function to print help for the command shell.
static void handle_command_string(char *message, size_t str_len)
Handle user command.
static unsigned int caller_num_gen
Counts the number of incoming calls we have had so far.
static enum PhoneState phone_state
Our phone's current state.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static char * ego_name
Name of our ego.
static char * address
GNS address for this phone.
static void start_phone()
Start our phone.
static void handle_command(void *cls)
Task to handle commands from the terminal.
static char * line
Desired phone line (string to be converted to a hash).
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run by the scheduler.
static void do_stop_task(void *cls)
Task run during shutdown.
static void call_event_handler(void *cls, enum GNUNET_CONVERSATION_CallEventCode code)
Function called with an event emitted by a call.
static struct GNUNET_SPEAKER_Handle * speaker
Our speaker.
static struct GNUNET_CRYPTO_BlindablePublicKey peer_key
Public key of active conversation partner (if any).
static struct GNUNET_DISK_FileHandle * stdin_fh
File handle for stdin.
static void caller_event_handler(void *cls, enum GNUNET_CONVERSATION_CallerEventCode code)
Function called with an event emitted by a caller.
@ CS_SUSPENDED
The call is currently suspended (by us).
@ CS_CONNECTED
The other party accepted our call and we are now connected.
@ CS_RESOLVING
We are looking up some other participant.
@ CS_RINGING
We are now ringing the other participant.
#define MAX_MESSAGE_LENGTH
Maximum length allowed for the command line input.
static struct GNUNET_SCHEDULER_Task * handle_cmd_task
Task which handles the commands.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
static void do_accept(const char *args)
Accepting an incoming call.
static void do_reject(const char *args)
Rejecting a call.
static char * peer_name
Name of active conversation partner (if any).
static void identity_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
Function called by identity service with information about egos.
static struct CallList * cl_tail
Tail of calls waiting to be accepted.
static struct CallList * cl_head
Head of calls waiting to be accepted.
static struct GNUNET_CONVERSATION_Phone * phone
Phone handle.
static void do_unknown(const char *msg)
Handler for unknown command.
static void do_resume(const char *args)
Resuming a call.
static void phone_event_handler(void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code, struct GNUNET_CONVERSATION_Caller *caller, const struct GNUNET_CRYPTO_BlindablePublicKey *caller_id)
Function called with an event emitted by a phone.
static struct VoipCommand commands[]
List of supported commands.
@ PS_ERROR
Internal error.
@ PS_ACCEPTED
We accepted an incoming phone call.
@ PS_LOOKUP_EGO
We're waiting for our own idenitty.
@ PS_LISTEN
We're listening for calls.
static struct GNUNET_FS_Handle * ctx
static char * name
Name (label) of the records to list.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
API to the conversation service.
API that can be used to manipulate GNS record data.
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
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.
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.
void GNUNET_CONVERSATION_call_suspend(struct GNUNET_CONVERSATION_Call *call)
Pause a call.
void GNUNET_CONVERSATION_caller_suspend(struct GNUNET_CONVERSATION_Caller *caller)
Pause conversation of an active call.
void GNUNET_CONVERSATION_call_resume(struct GNUNET_CONVERSATION_Call *call, struct GNUNET_SPEAKER_Handle *speaker, struct GNUNET_MICROPHONE_Handle *mic)
Resumes a call after GNUNET_CONVERSATION_call_suspend.
struct GNUNET_CONVERSATION_Call * GNUNET_CONVERSATION_call_start(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_IDENTITY_Ego *caller_id, const char *callee, struct GNUNET_SPEAKER_Handle *speaker, struct GNUNET_MICROPHONE_Handle *mic, GNUNET_CONVERSATION_CallEventHandler event_handler, void *event_handler_cls)
Call the phone of another user.
void GNUNET_CONVERSATION_call_stop(struct GNUNET_CONVERSATION_Call *call)
Terminate a call.
void GNUNET_CONVERSATION_phone_destroy(struct GNUNET_CONVERSATION_Phone *phone)
Destroys a phone.
GNUNET_CONVERSATION_CallerEventCode
Information about the current status of a call.
GNUNET_CONVERSATION_PhoneEventCode
Information about active callers to a phone.
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.
void GNUNET_CONVERSATION_caller_hang_up(struct GNUNET_CONVERSATION_Caller *caller)
Hang up up a (possibly ringing) phone.
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.
GNUNET_CONVERSATION_CallEventCode
Information about the current status of a call.
@ GNUNET_CONVERSATION_EC_CALLER_RESUME
We are the callee and the caller resumed the call.
@ GNUNET_CONVERSATION_EC_CALLER_SUSPEND
We are the callee and the caller suspended the call.
@ GNUNET_CONVERSATION_EC_PHONE_HUNG_UP
The conversation was terminated by the caller.
@ GNUNET_CONVERSATION_EC_PHONE_RING
We are the callee and the phone is ringing.
@ GNUNET_CONVERSATION_EC_CALL_SUSPENDED
We are the caller and the callee suspended the call.
@ GNUNET_CONVERSATION_EC_CALL_GNS_FAIL
We are the caller and failed to locate a phone record in GNS.
@ GNUNET_CONVERSATION_EC_CALL_PICKED_UP
We are the caller and are now ready to talk as the callee picked up.
@ GNUNET_CONVERSATION_EC_CALL_RESUMED
We are the caller and the callee suspended the call.
@ GNUNET_CONVERSATION_EC_CALL_RINGING
We are the caller and are now ringing the other party (GNS lookup succeeded).
@ GNUNET_CONVERSATION_EC_CALL_ERROR
We had an error handing the call, and are now restarting it (back to lookup).
@ GNUNET_CONVERSATION_EC_CALL_HUNG_UP
We are the caller and the callee called GNUNET_CONVERSATION_caller_hang_up.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_get_handle_from_int_fd(int fno)
Get a handle from a native integer FD.
Definition disk.c:1354
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_GETOPT_OPTION_END
Marker for the end of the list of options.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
const char * GNUNET_GNSRECORD_pkey_to_zkey(const struct GNUNET_CRYPTO_BlindablePublicKey *pkey)
Convert public key to the respective absolute domain name in the ".zkey" pTLD.
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the binary value data of a record of type type to a human-readable string.
Definition gnsrecord.c:147
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
@ GNUNET_SCHEDULER_PRIORITY_UI
Run with priority for interactive tasks.
@ GNUNET_OK
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MICROPHONE_destroy(struct GNUNET_MICROPHONE_Handle *microphone)
Destroy a microphone.
Definition microphone.c:195
struct GNUNET_MICROPHONE_Handle * GNUNET_MICROPHONE_create_from_hardware(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a microphone that corresponds to the microphone hardware of our system.
Definition microphone.c:172
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition program.c:407
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition scheduler.c:567
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_file(struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
Definition scheduler.c:1661
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition scheduler.c:1339
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:980
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority.
Definition scheduler.c:1231
struct GNUNET_SPEAKER_Handle * GNUNET_SPEAKER_create_from_hardware(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a speaker that corresponds to the speaker hardware of our system.
Definition speaker.c:160
void GNUNET_SPEAKER_destroy(struct GNUNET_SPEAKER_Handle *speaker)
Destroy a speaker.
Definition speaker.c:184
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define _(String)
GNU gettext support macro.
Definition platform.h:179
List of incoming calls.
unsigned int caller_num
Unique number of the call.
struct CallList * next
A DLL.
struct GNUNET_CRYPTO_BlindablePublicKey caller_id
Public key identifying the caller.
struct GNUNET_CONVERSATION_Caller * caller
Handle to hang up or activate.
struct CallList * prev
A DLL.
Handle for an outgoing call.
A caller is the handle we have for an incoming call.
A phone is a device that can ring to signal an incoming call and that you can pick up to answer the c...
An identity key as per LSD0001.
Handle used to access files (and pipes).
Definition of a command line option.
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.
Handle for an ego.
Definition identity.h:37
Handle for the service.
A microphone is a device that can capture or otherwise produce audio data.
Entry in list of pending tasks.
Definition scheduler.c:136
A speaker is a device that can play or record audio data.
Structure which defines a command.
const char * helptext
Help text for the command.
const char * command
Command the user needs to enter.
ActionFunction Action
Function to call on command.