159 } |
159 } |
160 |
160 |
161 // release handlers before reconnect |
161 // release handlers before reconnect |
162 static void pep_hh (guint32 hid, hk_arg_t *args, gpointer userdata) |
162 static void pep_hh (guint32 hid, hk_arg_t *args, gpointer userdata) |
163 { |
163 { |
164 #ifdef HOOK_POST_CONNECT |
|
165 if (hid == HOOK_POST_CONNECT) |
164 if (hid == HOOK_POST_CONNECT) |
166 pep_register_handlers (); |
165 pep_register_handlers (); |
167 else if (hid == HOOK_PRE_DISCONNECT) |
166 else if (hid == HOOK_PRE_DISCONNECT) |
168 pep_unregister_handlers (); |
167 pep_unregister_handlers (); |
169 #else |
|
170 hk_arg_t *arg; |
|
171 |
|
172 for (arg = args; arg->name; ++arg) { |
|
173 if (!strcmp (arg->name, "hook")) { |
|
174 if (!strcmp (arg->value, "hook-pre-disconnect")) |
|
175 pep_unregister_handlers (); |
|
176 else if (!strcmp (arg->value, "hook-post-connect")) |
|
177 pep_register_handlers (); |
|
178 return; |
|
179 } |
|
180 } |
|
181 #endif |
|
182 } |
168 } |
183 |
169 |
184 const gchar *g_module_check_init (GModule *module) |
170 const gchar *g_module_check_init (GModule *module) |
185 { |
171 { |
186 // create handlers |
172 // create handlers |
187 pep_message_handler = lm_message_handler_new (pep_message_event_handler, NULL, NULL); |
173 pep_message_handler = lm_message_handler_new (pep_message_event_handler, NULL, NULL); |
188 pep_iq_handler = lm_message_handler_new (pep_iq_pubsub_handler, NULL, NULL); |
174 pep_iq_handler = lm_message_handler_new (pep_iq_pubsub_handler, NULL, NULL); |
189 |
175 |
190 // register hook handler |
176 // register hook handler |
191 #ifdef HOOK_POST_CONNECT |
|
192 hk_add_handler (pep_hh, HOOK_POST_CONNECT | HOOK_PRE_DISCONNECT, NULL); |
177 hk_add_handler (pep_hh, HOOK_POST_CONNECT | HOOK_PRE_DISCONNECT, NULL); |
193 #else |
|
194 hk_add_handler (pep_hh, HOOK_INTERNAL, NULL); |
|
195 #endif |
|
196 |
178 |
197 // register handlers to connection |
179 // register handlers to connection |
198 pep_register_handlers (); |
180 pep_register_handlers (); |
199 |
181 |
200 return NULL; |
182 return NULL; |