255 switch (phone->
state)
292 for (caller = phone->
caller_head; NULL != caller; caller = caller->
next)
293 if (cid == caller->
cid)
317 "Received HANG_UP message for unknown caller ID %u\n",
318 (
unsigned int) hang->
cid);
323 "Received HANG_UP message, terminating call with `%s'\n",
325 switch (caller->
state)
376 switch (caller->
state)
421 switch (caller->
state)
487 switch (caller->
state)
523 "Connection to conversation service lost, trying to reconnect\n"));
591 if (NULL != phone->
mq)
602 if (NULL == phone->
mq)
666 if ((NULL == phone->
mq) ||
750 switch (caller->
state)
781 if (NULL != phone->
ns)
786 if (NULL != phone->
mq)
820 suspend->
cid = caller->
cid;
852 resume->
cid = caller->
cid;
#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.
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.
struct GNUNET_IDENTITY_PublicKey caller_id
Identity of the person calling us.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
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.
GNUNET_MQ_Error
Error codes for the queue.
constants for network protocols
GNUNET_MICROPHONE_DisableCallback disable_microphone
Turn the microphone off.
GNUNET_CONVERSATION_PhoneEventHandler event_handler
Function to call for phone events.
static size_t data_size
Number of bytes in data.
#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.
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.
GNUNET_SPEAKER_PlayCallback play
Play audio.
A private key for an identity as per LSD0001.
#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.
static struct Experiment * e
GNUNET_MICROPHONE_EnableCallback enable_microphone
Turn on the microphone.
Client -> Service message to register a phone.
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.
size_t data_size
Number of bytes in data.
#define GNUNET_GNSRECORD_TYPE_PHONE
Endpoint for conversation.
GNUNET_SPEAKER_DisableCallback disable_speaker
Turn the speaker off.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#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.
enum GNUNET_GenericReturnValue 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.
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...
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...
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.
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.
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's record.
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.
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.
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...
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
struct GNUNET_HashCode line_port
Phone line / CADET port to register.
Both sides suspended the conversation.
struct GNUNET_IDENTITY_PrivateKey my_zone
My GNS zone.
Service <-> Client message for phone was resumed.
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.
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.
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.
We are the callee and the caller suspended the call.
An identity key as per LSD0001.
#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.
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.
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.
const struct GNUNET_IDENTITY_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Service -> Client message for phone is ringing.
We are the callee and the phone is ringing.
#define GNUNET_log(kind,...)
Message Client <-> Service to transmit the audio.
struct GNUNET_HashCode line_port
Phone line (CADET port) to connect to.
struct GNUNET_IDENTITY_PublicKey caller_id
Who is calling us?
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's peer.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO.
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.
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.
void(* GNUNET_CONVERSATION_PhoneEventHandler)(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.
uint32_t reserved
Reserved.
uint32_t data
The data value.
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.
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.