#include "platform.h"
#include <stdio.h>
#include "gnunet_util_lib.h"
#include "gnunet_messenger_service.h"
Go to the source code of this file.
Macros | |
#define | MAX_BUFFER_SIZE 60000 |
Functions | |
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 | idle (void *cls) |
Initial task to startup application. 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 |
struct GNUNET_SCHEDULER_Task * | read_task |
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 60000 |
Definition at line 161 of file gnunet-messenger.c.
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.
[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 46 of file gnunet-messenger.c.
References GNUNET_MESSENGER_Message::body, GNUNET_free, GNUNET_h2s(), GNUNET_i2s_full(), GNUNET_MESSENGER_contact_get_name(), GNUNET_MESSENGER_FLAG_PRIVATE, GNUNET_MESSENGER_FLAG_SENT, GNUNET_MESSENGER_get_name(), GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_name_of_kind(), GNUNET_MESSENGER_send_message(), GNUNET_sh2s(), GNUNET_strdup, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, messenger, name, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageBody::peer, GNUNET_MESSENGER_MessageHeader::previous, response, GNUNET_MESSENGER_MessageHeader::sender_id, GNUNET_MESSENGER_MessageText::text, and GNUNET_MESSENGER_MessageBody::text.
Referenced by on_ego_lookup(), and run().
|
static |
Task to shut down this application.
[in,out] | cls | Closure |
Definition at line 140 of file gnunet-messenger.c.
References ego_lookup, 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 227 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 164 of file gnunet-messenger.c.
References 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 185 of file gnunet-messenger.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_iterate_members(), GNUNET_MESSENGER_KIND_TEXT, GNUNET_MESSENGER_send_message(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), GNUNET_YES, GNUNET_MESSENGER_Message::header, iterate_send_private_message(), GNUNET_MESSENGER_MessageHeader::kind, listen_stdio(), MAX_BUFFER_SIZE, private_mode, read_task, GNUNET_MESSENGER_MessageText::text, and GNUNET_MESSENGER_MessageBody::text.
Referenced by listen_stdio().
|
static |
Initial task to startup application.
[in,out] | cls | Closure |
Definition at line 249 of file gnunet-messenger.c.
References GNUNET_SCHEDULER_add_now(), listen_stdio(), and read_task.
Referenced by on_identity().
|
static |
Function called when an identity is retrieved.
[in,out] | cls | Closure |
[in,out] | handle | Handle of messenger service |
Definition at line 272 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_delayed_with_priority(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_SCHEDULER_shutdown(), GNUNET_TIME_relative_get_zero_(), handle, idle(), key, messenger, name, GNUNET_PeerIdentity::public_key, room_key, shutdown_hook(), and shutdown_task.
Referenced by on_ego_lookup(), and run().
|
static |
Definition at line 331 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 355 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 389 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_PROGRAM_run(), options, private_mode, room_key, and run().
const struct GNUNET_CONFIGURATION_Handle* config |
Definition at line 32 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 33 of file gnunet-messenger.c.
Referenced by on_ego_lookup(), on_identity(), on_message(), run(), and shutdown_hook().
struct GNUNET_SCHEDULER_Task* read_task |
Definition at line 131 of file gnunet-messenger.c.
Referenced by idle(), listen_stdio(), proto_read_kx(), read_stdio(), and shutdown_hook().
struct GNUNET_IDENTITY_EgoLookup* ego_lookup |
Definition at line 132 of file gnunet-messenger.c.
Referenced by on_ego_lookup(), run(), and shutdown_hook().
int private_mode |
Definition at line 177 of file gnunet-messenger.c.
Referenced by main(), and read_stdio().
char* door_id |
Definition at line 259 of file gnunet-messenger.c.
Referenced by main(), and on_identity().
char* ego_name |
Definition at line 260 of file gnunet-messenger.c.
Referenced by identity_zone_cb(), main(), on_ego_lookup(), and run().
char* room_key |
Definition at line 261 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 263 of file gnunet-messenger.c.
Referenced by continuation_print(), on_identity(), and run().