diff options
Diffstat (limited to 'src/application.c')
-rw-r--r-- | src/application.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/application.c b/src/application.c index 0db05bb..e73d9de 100644 --- a/src/application.c +++ b/src/application.c | |||
@@ -79,6 +79,8 @@ application_init(MESSENGER_Application *app, | |||
79 | 79 | ||
80 | app->ui.mobile = FALSE; | 80 | app->ui.mobile = FALSE; |
81 | 81 | ||
82 | app->ui.bindings = g_hash_table_new(g_direct_hash, g_direct_equal); | ||
83 | |||
82 | g_application_add_main_option( | 84 | g_application_add_main_option( |
83 | G_APPLICATION(app->application), | 85 | G_APPLICATION(app->application), |
84 | "mobile", | 86 | "mobile", |
@@ -138,6 +140,8 @@ application_run(MESSENGER_Application *app) | |||
138 | 140 | ||
139 | pthread_join(app->chat.tid, NULL); | 141 | pthread_join(app->chat.tid, NULL); |
140 | 142 | ||
143 | g_hash_table_destroy(app->ui.bindings); | ||
144 | |||
141 | notify_uninit(); | 145 | notify_uninit(); |
142 | 146 | ||
143 | g_object_unref(app->application); | 147 | g_object_unref(app->application); |
@@ -147,7 +151,8 @@ typedef struct MESSENGER_ApplicationEventCall | |||
147 | { | 151 | { |
148 | MESSENGER_Application *app; | 152 | MESSENGER_Application *app; |
149 | MESSENGER_ApplicationEvent event; | 153 | MESSENGER_ApplicationEvent event; |
150 | void *cls; | 154 | int argc; |
155 | void **argv; | ||
151 | } MESSENGER_ApplicationEventCall; | 156 | } MESSENGER_ApplicationEventCall; |
152 | 157 | ||
153 | static gboolean | 158 | static gboolean |
@@ -156,7 +161,10 @@ _application_event_call(gpointer user_data) | |||
156 | MESSENGER_ApplicationEventCall *call; | 161 | MESSENGER_ApplicationEventCall *call; |
157 | 162 | ||
158 | call = (MESSENGER_ApplicationEventCall*) user_data; | 163 | call = (MESSENGER_ApplicationEventCall*) user_data; |
159 | call->event(call->app, call->cls); | 164 | call->event(call->app, call->argc, call->argv); |
165 | |||
166 | if (call->argc > 0) | ||
167 | GNUNET_free(call->argv); | ||
160 | 168 | ||
161 | GNUNET_free(call); | 169 | GNUNET_free(call); |
162 | return FALSE; | 170 | return FALSE; |
@@ -165,7 +173,8 @@ _application_event_call(gpointer user_data) | |||
165 | void | 173 | void |
166 | application_call_event(MESSENGER_Application *app, | 174 | application_call_event(MESSENGER_Application *app, |
167 | MESSENGER_ApplicationEvent event, | 175 | MESSENGER_ApplicationEvent event, |
168 | void *cls) | 176 | int argc, |
177 | void **argv) | ||
169 | { | 178 | { |
170 | MESSENGER_ApplicationEventCall *call; | 179 | MESSENGER_ApplicationEventCall *call; |
171 | 180 | ||
@@ -175,7 +184,17 @@ application_call_event(MESSENGER_Application *app, | |||
175 | 184 | ||
176 | call->app = app; | 185 | call->app = app; |
177 | call->event = event; | 186 | call->event = event; |
178 | call->cls = cls; | 187 | call->argc = argc; |
188 | call->argv = NULL; | ||
189 | |||
190 | if (call->argc > 0) | ||
191 | { | ||
192 | call->argv = GNUNET_new_array(call->argc, void*); | ||
193 | |||
194 | for (int i = 0; i < call->argc; i++) { | ||
195 | call->argv[i] = argv[i]; | ||
196 | } | ||
197 | } | ||
179 | 198 | ||
180 | g_idle_add(_application_event_call, call); | 199 | g_idle_add(_application_event_call, call); |
181 | } | 200 | } |