diff options
Diffstat (limited to 'src/chat/messenger.c')
-rw-r--r-- | src/chat/messenger.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/chat/messenger.c b/src/chat/messenger.c index 56dc016..2996af3 100644 --- a/src/chat/messenger.c +++ b/src/chat/messenger.c | |||
@@ -24,4 +24,65 @@ | |||
24 | 24 | ||
25 | #include "messenger.h" | 25 | #include "messenger.h" |
26 | 26 | ||
27 | #include "../event.h" | ||
27 | 28 | ||
29 | static void | ||
30 | _chat_messenger_idle(void *cls) | ||
31 | { | ||
32 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | ||
33 | |||
34 | if (MESSENGER_NONE == app->chat.signal) | ||
35 | { | ||
36 | app->chat.messenger.idle = GNUNET_SCHEDULER_add_delayed_with_priority( | ||
37 | GNUNET_TIME_relative_get_second_(), | ||
38 | GNUNET_SCHEDULER_PRIORITY_IDLE, | ||
39 | &_chat_messenger_idle, | ||
40 | app | ||
41 | ); | ||
42 | |||
43 | return; | ||
44 | } | ||
45 | |||
46 | GNUNET_CHAT_stop(app->chat.messenger.handle); | ||
47 | app->chat.messenger.handle = NULL; | ||
48 | |||
49 | if (MESSENGER_QUIT != app->chat.signal) | ||
50 | GNUNET_SCHEDULER_shutdown(); | ||
51 | } | ||
52 | |||
53 | static int | ||
54 | _chat_messenger_message(void *cls, | ||
55 | UNUSED struct GNUNET_CHAT_Context *context, | ||
56 | const struct GNUNET_CHAT_Message *message) | ||
57 | { | ||
58 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | ||
59 | |||
60 | if (GNUNET_CHAT_KIND_LOGIN == GNUNET_CHAT_message_get_kind(message)) | ||
61 | application_call_event(app, event_update_profile); | ||
62 | |||
63 | return GNUNET_YES; | ||
64 | } | ||
65 | |||
66 | void | ||
67 | chat_messenger_run(void *cls, | ||
68 | UNUSED char *const *args, | ||
69 | UNUSED const char *cfgfile, | ||
70 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
71 | { | ||
72 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | ||
73 | |||
74 | app->chat.messenger.handle = GNUNET_CHAT_start( | ||
75 | cfg, | ||
76 | "messenger-gtk", | ||
77 | "test", | ||
78 | &_chat_messenger_message, | ||
79 | app | ||
80 | ); | ||
81 | |||
82 | app->chat.messenger.idle = GNUNET_SCHEDULER_add_delayed_with_priority( | ||
83 | GNUNET_TIME_relative_get_zero_(), | ||
84 | GNUNET_SCHEDULER_PRIORITY_IDLE, | ||
85 | &_chat_messenger_idle, | ||
86 | app | ||
87 | ); | ||
88 | } | ||