#include <stdio.h>
#include <unistd.h>
#include "gnunet_identity_service.h"
#include "gnunet_messenger_service.h"
#include "gnunet_util_lib.h"
Go to the source code of this file.
Macros | |
#define | MAX_BUFFER_SIZE 57345 |
Functions | |
static void | delay_shutdown (void *cls) |
Delay forced shutdown by input to wait for data processing. More... | |
static void | idle (void *cls) |
Initial task to startup application. More... | |
static void | on_message (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Contact *recipient, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_MessageFlags flags) |
Function called whenever a message is received or sent. More... | |
static void | shutdown_hook (void *cls) |
Task to shut down this application. More... | |
static void | listen_stdio (void *cls) |
Wait for input on STDIO and send it out over the ch. More... | |
static int | iterate_send_private_message (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact) |
static void | read_stdio (void *cls) |
Task run in stdio mode, after some data is available at stdin. More... | |
static void | on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle) |
Function called when an identity is retrieved. More... | |
static void | on_ego_lookup (void *cls, struct GNUNET_IDENTITY_Ego *ego) |
static void | run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
Main function that will be run by the scheduler. More... | |
int | main (int argc, char **argv) |
The main function to obtain messenger information. More... | |
Variables | |
const struct GNUNET_CONFIGURATION_Handle * | config |
struct GNUNET_MESSENGER_Handle * | messenger |
uint64_t | waiting |
struct GNUNET_SCHEDULER_Task * | read_task |
int | silence_flag |
int | talk_mode |
struct GNUNET_IDENTITY_EgoLookup * | ego_lookup |
int | private_mode |
char * | door_id |
char * | ego_name |
char * | room_key |
struct GNUNET_SCHEDULER_Task * | shutdown_task |
#define MAX_BUFFER_SIZE 57345 |
Definition at line 368 of file gnunet-messenger.c.
|
static |
Delay forced shutdown by input to wait for data processing.
[in,out] | cls | Closure |
Definition at line 48 of file gnunet-messenger.c.
References GNUNET_SCHEDULER_shutdown(), read_task, and waiting.
Referenced by on_message(), and read_stdio().
|
static |
Initial task to startup application.
[in,out] | cls | Closure |
Definition at line 477 of file gnunet-messenger.c.
References GNUNET_assert, GNUNET_SCHEDULER_add_now(), GNUNET_YES, listen_stdio(), read_task, silence_flag, and talk_mode.
Referenced by on_message().
|
static |
Function called whenever a message is received or sent.
[in,out] | cls | Closure |
[in] | room | Room |
[in] | sender | Sender of message |
[in] | message | Message |
[in] | hash | Hash of message |
[in] | flags | Flags of message |
Definition at line 73 of file gnunet-messenger.c.
References GNUNET_MESSENGER_MessageConnection::amount, GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageBody::connection, GNUNET_MESSENGER_MessageTalk::data, delay_shutdown(), GNUNET_MESSENGER_MessageBody::deletion, GNUNET_MESSENGER_MessageSubscribe::discourse, GNUNET_MESSENGER_MessageTalk::discourse, GNUNET_MESSENGER_MessageInvite::door, GNUNET_MESSENGER_MessageBody::file, GNUNET_MESSENGER_MessageConnection::flags, GNUNET_free, GNUNET_h2s(), GNUNET_h2s_full(), GNUNET_i2s_full(), GNUNET_MESSENGER_contact_get_name(), GNUNET_MESSENGER_FLAG_PRIVATE, GNUNET_MESSENGER_FLAG_SENT, GNUNET_MESSENGER_FLAG_SUBSCRIPTION_KEEP_ALIVE, GNUNET_MESSENGER_get_name(), GNUNET_MESSENGER_KIND_CONNECTION, GNUNET_MESSENGER_KIND_DELETE, GNUNET_MESSENGER_KIND_FILE, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_INVITE, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_KIND_SUBSCRIBE, GNUNET_MESSENGER_KIND_TAG, GNUNET_MESSENGER_KIND_TALK, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_KIND_TICKET, GNUNET_MESSENGER_name_of_kind(), GNUNET_MESSENGER_send_message(), GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_sh2s(), GNUNET_strdup, GNUNET_TIME_relative_get_second_(), GNUNET_TIME_relative_hton(), GNUNET_YES, GNUNET_MESSENGER_MessageRequest::hash, GNUNET_MESSENGER_MessageDelete::hash, GNUNET_MESSENGER_MessageTag::hash, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageId::id, GNUNET_MESSENGER_MessageBody::id, GNUNET_MESSENGER_MessageTicket::identifier, idle(), GNUNET_MESSENGER_MessageBody::invite, GNUNET_MESSENGER_MessageInvite::key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageTalk::length, GNUNET_MESSENGER_MessageBody::merge, messenger, GNUNET_MESSENGER_MessageBody::miss, name, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageFile::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageMiss::peer, GNUNET_MESSENGER_MessageBody::peer, GNUNET_MESSENGER_MessageHeader::previous, GNUNET_MESSENGER_MessageMerge::previous, read_task, GNUNET_MESSENGER_MessageBody::request, response, GNUNET_MESSENGER_MessageHeader::sender_id, silence_flag, GNUNET_MESSENGER_MessageBody::subscribe, GNUNET_MESSENGER_MessageTag::tag, GNUNET_MESSENGER_MessageBody::tag, GNUNET_MESSENGER_MessageBody::talk, talk_mode, GNUNET_MESSENGER_MessageText::text, GNUNET_MESSENGER_MessageBody::text, GNUNET_MESSENGER_MessageBody::ticket, GNUNET_MESSENGER_MessageFile::uri, and waiting.
Referenced by on_ego_lookup(), and run().
|
static |
Task to shut down this application.
[in,out] | cls | Closure |
Definition at line 343 of file gnunet-messenger.c.
References ego_lookup, GNUNET_assert, GNUNET_IDENTITY_ego_lookup_cancel(), GNUNET_MESSENGER_close_room(), GNUNET_MESSENGER_disconnect(), GNUNET_SCHEDULER_cancel(), messenger, and read_task.
Referenced by on_identity(), and run().
|
static |
Wait for input on STDIO and send it out over the ch.
[in,out] | cls | Closure |
Definition at line 454 of file gnunet-messenger.c.
References GNUNET_NETWORK_fdset_create(), GNUNET_NETWORK_fdset_destroy(), GNUNET_NETWORK_fdset_set_native(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_TIME_UNIT_FOREVER_REL, read_stdio(), and read_task.
Referenced by idle(), and read_stdio().
|
static |
Definition at line 371 of file gnunet-messenger.c.
References GNUNET_assert, GNUNET_MESSENGER_contact_get_key(), GNUNET_MESSENGER_send_message(), and GNUNET_YES.
Referenced by read_stdio().
|
static |
Task run in stdio mode, after some data is available at stdin.
[in,out] | cls | Closure |
Definition at line 396 of file gnunet-messenger.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageTalk::data, delay_shutdown(), GNUNET_MESSENGER_MessageTalk::discourse, GNUNET_assert, GNUNET_MESSENGER_iterate_members(), GNUNET_MESSENGER_KIND_TALK, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_send_message(), GNUNET_SCHEDULER_add_now(), GNUNET_YES, GNUNET_MESSENGER_Message::header, iterate_send_private_message(), GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageTalk::length, listen_stdio(), MAX_BUFFER_SIZE, private_mode, read_task, GNUNET_MESSENGER_MessageBody::talk, talk_mode, GNUNET_MESSENGER_MessageText::text, GNUNET_MESSENGER_MessageBody::text, and waiting.
Referenced by listen_stdio().
|
static |
Function called when an identity is retrieved.
[in,out] | cls | Closure |
[in,out] | handle | Handle of messenger service |
Definition at line 506 of file gnunet-messenger.c.
References door_id, GNUNET_CRYPTO_eddsa_public_key_from_string(), GNUNET_CRYPTO_hash(), GNUNET_MESSENGER_enter_room(), GNUNET_MESSENGER_get_name(), GNUNET_MESSENGER_open_room(), GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_shutdown(), GNUNET_YES, handle, key, messenger, name, GNUNET_PeerIdentity::public_key, read_task, room_key, shutdown_hook(), shutdown_task, silence_flag, talk_mode, and waiting.
Referenced by on_ego_lookup(), and run().
|
static |
Definition at line 573 of file gnunet-messenger.c.
References config, ego_lookup, ego_name, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_MESSENGER_connect(), key, messenger, on_identity(), and on_message().
Referenced by run().
|
static |
Main function that will be run by the scheduler.
[in/out] | cls closure | |
[in] | args | remaining command-line arguments |
[in] | cfgfile | name of the configuration file used (for saving, can be NULL!) |
[in] | cfg | configuration |
Definition at line 598 of file gnunet-messenger.c.
References cfg, config, ego_lookup, ego_name, GNUNET_IDENTITY_ego_lookup(), GNUNET_MESSENGER_connect(), GNUNET_SCHEDULER_add_shutdown(), messenger, on_ego_lookup(), on_identity(), on_message(), shutdown_hook(), and shutdown_task.
Referenced by main().
int main | ( | int | argc, |
char ** | argv | ||
) |
The main function to obtain messenger information.
[in] | argc | number of arguments from the command line |
[in] | argv | command line arguments |
Definition at line 632 of file gnunet-messenger.c.
References GNUNET_GETOPT_CommandLineOption::description, door_id, ego_name, gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), options, private_mode, room_key, run(), silence_flag, and talk_mode.
const struct GNUNET_CONFIGURATION_Handle* config |
Definition at line 33 of file gnunet-messenger.c.
Referenced by create_service(), on_ego_lookup(), run(), set_value(), setup_service(), and start_arm_service().
struct GNUNET_MESSENGER_Handle* messenger |
Definition at line 34 of file gnunet-messenger.c.
Referenced by on_ego_lookup(), on_identity(), on_message(), run(), and shutdown_hook().
uint64_t waiting |
Definition at line 36 of file gnunet-messenger.c.
Referenced by delay_shutdown(), on_identity(), on_message(), and read_stdio().
struct GNUNET_SCHEDULER_Task* read_task |
Definition at line 38 of file gnunet-messenger.c.
Referenced by delay_shutdown(), idle(), listen_stdio(), on_identity(), on_message(), proto_read_kx(), read_stdio(), and shutdown_hook().
int silence_flag |
Definition at line 39 of file gnunet-messenger.c.
Referenced by idle(), main(), on_identity(), and on_message().
int talk_mode |
Definition at line 40 of file gnunet-messenger.c.
Referenced by idle(), main(), on_identity(), on_message(), and read_stdio().
struct GNUNET_IDENTITY_EgoLookup* ego_lookup |
Definition at line 335 of file gnunet-messenger.c.
Referenced by on_ego_lookup(), run(), and shutdown_hook().
int private_mode |
Definition at line 388 of file gnunet-messenger.c.
Referenced by main(), and read_stdio().
char* door_id |
Definition at line 493 of file gnunet-messenger.c.
Referenced by main(), and on_identity().
char* ego_name |
Definition at line 494 of file gnunet-messenger.c.
Referenced by identity_zone_cb(), main(), on_ego_lookup(), and run().
char* room_key |
Definition at line 495 of file gnunet-messenger.c.
Referenced by GNUNET_MESSENGER_cmd_join_room(), main(), and on_identity().
struct GNUNET_SCHEDULER_Task* shutdown_task |
Definition at line 497 of file gnunet-messenger.c.
Referenced by continuation_print(), on_identity(), and run().