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