1 /* |
1 /* |
2 * disco.c -- Service discovery requests |
2 * pep.c -- Common pep routines |
3 * |
3 * |
4 * Copyrigth (C) 2009 Myhailo Danylenko <isbear@ukrpost.net> |
4 * Copyrigth (C) 2009 Myhailo Danylenko <isbear@ukrpost.net> |
5 * |
5 * |
6 * This program is free software; you can redistribute it and/or modify |
6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License as published by |
7 * it under the terms of the GNU General Public License as published by |
133 // release handlers before reconnect |
133 // release handlers before reconnect |
134 static void pep_hh (guint32 hid, hk_arg_t *args, gpointer userdata) |
134 static void pep_hh (guint32 hid, hk_arg_t *args, gpointer userdata) |
135 { |
135 { |
136 hk_arg_t *arg = args; |
136 hk_arg_t *arg = args; |
137 |
137 |
138 for (arg = args; arg->name; arg++) { |
138 for (arg = args; arg->name; ++arg) { |
139 if (!strcmp (arg->name, "hook")) { |
139 if (!strcmp (arg->name, "hook")) { |
140 if (!strcmp (arg->value, "hook-pre-disconnect")) |
140 if (!strcmp (arg->value, "hook-pre-disconnect")) |
141 pep_unregister_handlers (); |
141 pep_unregister_handlers (); |
142 else if (!strcmp (arg->value, "hook-post-connect")) |
142 else if (!strcmp (arg->value, "hook-post-connect")) |
143 pep_register_handlers (); |
143 pep_register_handlers (); |
144 return; |
144 return; |
145 } |
145 } |
146 } |
146 } |
147 } |
147 } |
148 |
148 |
149 const gchar *g_module_check_init(GModule *module) |
149 const gchar *g_module_check_init (GModule *module) |
150 { |
150 { |
151 // register hook handler |
151 // register hook handler |
152 hk_add_handler (pep_hh, HOOK_INTERNAL, NULL); |
152 hk_add_handler (pep_hh, HOOK_INTERNAL, NULL); |
153 |
153 |
154 pep_register_handlers (); |
154 pep_register_handlers (); |
155 |
155 |
156 return NULL; |
156 return NULL; |
157 } |
157 } |
158 |
158 |
159 void g_module_unload(GModule *module) |
159 void g_module_unload (GModule *module) |
160 { |
160 { |
161 // release handlers |
161 // release handlers |
162 pep_unregister_handlers (); |
162 pep_unregister_handlers (); |
|
163 |
163 if (pep_message_handler) |
164 if (pep_message_handler) |
164 lm_message_handler_unref (pep_message_handler); |
165 lm_message_handler_unref (pep_message_handler); |
165 pep_message_handler = NULL; |
166 pep_message_handler = NULL; |
166 |
167 |
167 // remove hook |
168 // remove hook |
168 hk_del_handler (pep_hh, NULL); |
169 hk_del_handler (pep_hh, NULL); |
169 } |
170 } |
170 |
171 |
171 /* vim: se ts=4: */ |
172 /* vim: se ts=4 sw=4: */ |