34#define MAX_MESSAGE_LENGTH 1024
36#define XSTRINGIFY(x) STRINGIFY (x)
38#define STRINGIFY(x) (#x)
262 "Incoming call from `%s'. Please /accept %u or /cancel %u the call.\n"),
285 _ (
"Call from `%s' terminated\n"),
317 _ (
"Call from `%s' suspended by other user\n"),
323 _ (
"Call from `%s' resumed by other user\n"),
341 _ (
"Ego `%s' no longer available, phone is now down.\n"),
354 fprintf (stderr,
"%s",
_ (
"Failed to setup phone (internal error)\n"));
366 "Phone active at `%s'. Type `/help' for a list of available commands\n"),
389 _ (
"Resolved address of `%s'. Now ringing other party.\n"),
396 fprintf (stdout,
_ (
"Connection established to `%s'\n"),
peer_name);
402 fprintf (stdout,
_ (
"Failed to resolve `%s'\n"),
peer_name);
409 fprintf (stdout,
_ (
"Call to `%s' terminated\n"),
peer_name);
418 _ (
"Connection to `%s' suspended (by other user)\n"),
425 _ (
"Connection to `%s' resumed (by other user)\n"),
430 fprintf (stdout,
_ (
"Error with the call, restarting it\n"));
499 fprintf (stderr,
_ (
"Unknown command `%s'\n"),
msg);
513 fprintf (stderr,
_ (
"Ego `%s' not available\n"),
ego_name);
519 _ (
"You are calling someone else already, hang up first!\n"));
525 fprintf (stderr,
_ (
"Ego `%s' not available\n"),
ego_name);
536 "You are answering call from `%s', hang up or suspend that call first!\n"),
546 fprintf (stderr,
_ (
"Call recipient missing.\n"));
577 _ (
"You are calling someone else already, hang up first!\n"));
594 "You are answering call from `%s', hang up or suspend that call first!\n"),
605 fprintf (stderr,
_ (
"There is no incoming call to accept here!\n"));
608 if ((NULL != cl->
next) || (NULL !=
args))
613 if (0 == strcmp (buf,
args))
620 _ (
"There is no incoming call `%s' to accept right now!\n"),
647 fprintf (stdout,
"%s",
_ (
"We currently do not have an address.\n"));
650 fprintf (stdout,
"%s\n",
address);
671 "We are currently trying to locate the private key for the ego `%s'.\n"),
678 "We are listening for incoming calls for ego `%s' on line `%s'.\n"),
685 _ (
"You are having a conversation with `%s'.\n"),
694 "We had an internal error setting up our phone line. You can still make calls.\n"));
703 _ (
"We are trying to find the network address to call `%s'.\n"),
709 _ (
"We are calling `%s', their phone should be ringing.\n"),
715 _ (
"You are having a conversation with `%s'.\n"),
726 fprintf (stdout,
"%s",
_ (
"Calls waiting:\n"));
736 fprintf (stdout,
"%s",
"\n");
759 _ (
"There is no call that could be suspended right now.\n"));
775 _ (
"There is no call that could be suspended right now.\n"));
809 _ (
"There is no call that could be resumed right now.\n"));
824 _ (
"There is no call that could be resumed right now.\n"));
833 _ (
"Already talking with `%s', cannot resume a call right now.\n"),
841 fprintf (stderr,
_ (
"There is no incoming call to resume here!\n"));
844 if ((NULL != cl->
next) || (NULL !=
args))
849 if (0 == strcmp (buf,
args))
856 _ (
"There is no incoming call `%s' to resume right now!\n"),
889 _ (
"There is no call that could be cancelled right now.\n"));
897 fprintf (stderr,
_ (
"There is no incoming call to refuse here!\n"));
900 if ((NULL != cl->
next) || (NULL !=
args))
905 if (0 == strcmp (buf,
args))
912 _ (
"There is no incoming call `%s' to refuse right now!\n"),
939 "Use `/address' to find out which address this phone should have in GNS") },
943 gettext_noop (
"Use `/accept #NUM' to accept incoming call #NUM") },
946 gettext_noop (
"Use `/suspend' to suspend the active call") },
950 "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 gettext_noop (
"Use `/cancel' to reject or terminate a call") },
956 gettext_noop (
"Use `/status' to print status information") },
959 gettext_noop (
"Use `/quit' to terminate gnunet-conversation") },
962 gettext_noop (
"Use `/help command' to get help for a specific command") },
964 { NULL, NULL, NULL },
979 while ((NULL !=
args) && (0 != strlen (
args)) &&
990 fprintf (stdout,
"%s",
"Available commands:\n");
996 fprintf (stdout,
"%s",
"\n");
1056 if (message[str_len - 1] ==
'\n')
1057 message[str_len - 1] =
'\0';
1058 if (message[str_len - 2] ==
'\r')
1059 message[str_len - 2] =
'\0';
1060 if (0 == strlen (message))
1069 while (isspace ((
unsigned char) *ptr))
1122 fprintf (stdout,
_ (
"Name of our ego changed to `%s'\n"),
name);
1132 fprintf (stdout,
_ (
"Our ego `%s' was deleted!\n"),
ego_name);
1153 const char *cfgfile,
1164 fprintf (stderr,
"%s",
_ (
"You must specify the NAME of an ego to use\n"));
1191 gettext_noop (
"sets the NAME of the ego to use for the caller ID"),
1197 "sets the LINE to use for the phone"),
1203 flags = fcntl (0, F_GETFL, 0);
1204 flags |= O_NONBLOCK;
1205 if (0 != fcntl (0, F_SETFL, flags))
1213 "gnunet-conversation",
1215 "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
Final status code.
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 struct GNUNET_CRYPTO_PublicKey peer_key
Public key of active conversation partner (if any).
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 phone_event_handler(void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code, struct GNUNET_CONVERSATION_Caller *caller, const struct GNUNET_CRYPTO_PublicKey *caller_id)
Function called with an event emitted by a 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 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_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.
#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.
const char * GNUNET_GNSRECORD_pkey_to_zkey(const struct GNUNET_CRYPTO_PublicKey *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.
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.
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.
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,...
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_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_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_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.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
unsigned int caller_num
Unique number of the call.
struct GNUNET_CRYPTO_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...
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.
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.