pep.c
changeset 4 b24eab8a6515
parent 2 d55fe04d7f35
child 6 f579d9637195
equal deleted inserted replaced
3:f28f6e8211ed 4:b24eab8a6515
     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
    20  */
    20  */
    21 
    21 
    22 #include <glib.h>
    22 #include <glib.h>
    23 #include <gmodule.h>
    23 #include <gmodule.h>
    24 #include <loudmouth/loudmouth.h>
    24 #include <loudmouth/loudmouth.h>
    25 #include <strings.h>
    25 #include <string.h>
    26 
    26 
    27 #include "xmpp.h"
    27 #include "xmpp.h"
    28 #include "hooks.h"
    28 #include "hooks.h"
    29 #include "pep.h"
    29 #include "pep.h"
    30 
    30 
   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: */