36 #define MAX_MESSAGE_LENGTH 1024
38 #define XSTRINGIFY(x) STRINGIFY (x)
40 #define STRINGIFY(x) (#x)
264 "Incoming call from `%s'. Please /accept %u or /cancel %u the call.\n"),
287 _ (
"Call from `%s' terminated\n"),
319 _ (
"Call from `%s' suspended by other user\n"),
325 _ (
"Call from `%s' resumed by other user\n"),
343 _ (
"Ego `%s' no longer available, phone is now down.\n"),
356 fprintf (stderr,
"%s",
_ (
"Failed to setup phone (internal error)\n"));
368 "Phone active at `%s'. Type `/help' for a list of available commands\n"),
391 _ (
"Resolved address of `%s'. Now ringing other party.\n"),
398 fprintf (stdout,
_ (
"Connection established to `%s'\n"),
peer_name);
404 fprintf (stdout,
_ (
"Failed to resolve `%s'\n"),
peer_name);
411 fprintf (stdout,
_ (
"Call to `%s' terminated\n"),
peer_name);
420 _ (
"Connection to `%s' suspended (by other user)\n"),
427 _ (
"Connection to `%s' resumed (by other user)\n"),
432 fprintf (stdout,
_ (
"Error with the call, restarting it\n"));
501 fprintf (stderr,
_ (
"Unknown command `%s'\n"),
msg);
515 fprintf (stderr,
_ (
"Ego `%s' not available\n"),
ego_name);
521 _ (
"You are calling someone else already, hang up first!\n"));
527 fprintf (stderr,
_ (
"Ego `%s' not available\n"),
ego_name);
538 "You are answering call from `%s', hang up or suspend that call first!\n"),
548 fprintf (stderr,
_ (
"Call recipient missing.\n"));
579 _ (
"You are calling someone else already, hang up first!\n"));
596 "You are answering call from `%s', hang up or suspend that call first!\n"),
607 fprintf (stderr,
_ (
"There is no incoming call to accept here!\n"));
610 if ((NULL != cl->
next) || (NULL !=
args))
622 _ (
"There is no incoming call `%s' to accept right now!\n"),
649 fprintf (stdout,
"%s",
_ (
"We currently do not have an address.\n"));
652 fprintf (stdout,
"%s\n",
address);
673 "We are currently trying to locate the private key for the ego `%s'.\n"),
680 "We are listening for incoming calls for ego `%s' on line `%s'.\n"),
687 _ (
"You are having a conversation with `%s'.\n"),
696 "We had an internal error setting up our phone line. You can still make calls.\n"));
705 _ (
"We are trying to find the network address to call `%s'.\n"),
711 _ (
"We are calling `%s', their phone should be ringing.\n"),
717 _ (
"You are having a conversation with `%s'.\n"),
728 fprintf (stdout,
"%s",
_ (
"Calls waiting:\n"));
738 fprintf (stdout,
"%s",
"\n");
761 _ (
"There is no call that could be suspended right now.\n"));
777 _ (
"There is no call that could be suspended right now.\n"));
811 _ (
"There is no call that could be resumed right now.\n"));
826 _ (
"There is no call that could be resumed right now.\n"));
835 _ (
"Already talking with `%s', cannot resume a call right now.\n"),
843 fprintf (stderr,
_ (
"There is no incoming call to resume here!\n"));
846 if ((NULL != cl->
next) || (NULL !=
args))
858 _ (
"There is no incoming call `%s' to resume right now!\n"),
891 _ (
"There is no call that could be cancelled right now.\n"));
899 fprintf (stderr,
_ (
"There is no incoming call to refuse here!\n"));
902 if ((NULL != cl->
next) || (NULL !=
args))
914 _ (
"There is no incoming call `%s' to refuse right now!\n"),
941 "Use `/address' to find out which address this phone should have in GNS") },
945 gettext_noop (
"Use `/accept #NUM' to accept incoming call #NUM") },
948 gettext_noop (
"Use `/suspend' to suspend the active call") },
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.") },
955 gettext_noop (
"Use `/cancel' to reject or terminate a call") },
958 gettext_noop (
"Use `/status' to print status information") },
961 gettext_noop (
"Use `/quit' to terminate gnunet-conversation") },
964 gettext_noop (
"Use `/help command' to get help for a specific command") },
966 { NULL, NULL, NULL },
981 while ((NULL !=
args) && (0 != strlen (
args)) &&
992 fprintf (stdout,
"%s",
"Available commands:\n");
998 fprintf (stdout,
"%s",
"\n");
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))
1071 while (isspace ((
unsigned char) *ptr))
1124 fprintf (stdout,
_ (
"Name of our ego changed to `%s'\n"),
name);
1134 fprintf (stdout,
_ (
"Our ego `%s' was deleted!\n"),
ego_name);
1155 const char *cfgfile,
1166 fprintf (stderr,
"%s",
_ (
"You must specify the NAME of an ego to use\n"));
1193 gettext_noop (
"sets the NAME of the ego to use for the caller ID"),
1199 "sets the LINE to use for the phone"),
1205 flags = fcntl (0, F_GETFL, 0);
1206 flags |= O_NONBLOCK;
1207 if (0 != fcntl (0, F_SETFL, flags))
1216 "gnunet-conversation",
1218 "Enables having a conversation with other GNUnet users."),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MessageHeader * msg
PhoneState
Possible states of a phone.
CallState
Possible states of the phone.
#define gettext_noop(String)
static int ret
Return value of the commandline.
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_IDENTITY_PublicKey peer_key
Public key of active conversation partner (if any).
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_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 void phone_event_handler(void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code, struct GNUNET_CONVERSATION_Caller *caller, const struct GNUNET_IDENTITY_PublicKey *caller_id)
Function called with an event emitted by a phone.
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.
int main(int argc, char *const *argv)
The main function to conversation.
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 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_GNSRECORD_Data rd[50]
The record data under a single label.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
API to the conversation service.
API that can be used to manipulate GNS record data.
API that can be used to store naming information on a GNUnet node;.
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.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing 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_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_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.
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.
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.
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.
#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.
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.
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the 'value' of a record to a string.
const char * GNUNET_GNSRECORD_pkey_to_zkey(const struct GNUNET_IDENTITY_PublicKey *pkey)
Convert public key to the respective absolute domain name in the ".zkey" pTLD.
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.
#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.
#define GNUNET_free_nz(ptr)
Wrapper around free.
void GNUNET_MICROPHONE_destroy(struct GNUNET_MICROPHONE_Handle *microphone)
Destroy a microphone.
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.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(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,...
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
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...
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.
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,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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.
void GNUNET_SPEAKER_destroy(struct GNUNET_SPEAKER_Handle *speaker)
Destroy a speaker.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
unsigned int caller_num
Unique number of the call.
struct GNUNET_IDENTITY_PublicKey caller_id
Public key identifying the caller.
struct CallList * next
A DLL.
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...
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.
An identity key as per LSD0001.
A microphone is a device that can capture or otherwise produce audio data.
Entry in list of pending tasks.
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.