disco.c
changeset 5 6411dbdd32be
parent 4 b18eee368baa
child 6 68d54d647b0f
equal deleted inserted replaced
4:b18eee368baa 5:6411dbdd32be
   236 }
   236 }
   237 
   237 
   238 // release handlers before reconnect
   238 // release handlers before reconnect
   239 static void disco_hh (guint32 hid, hk_arg_t *args, gpointer userdata)
   239 static void disco_hh (guint32 hid, hk_arg_t *args, gpointer userdata)
   240 {
   240 {
   241 		hk_arg_t *arg = args;
   241 	hk_arg_t *arg = args;
   242 
   242 
   243 		for (arg = args; arg->name; arg++) {
   243 	for (arg = args; arg->name; arg++) {
   244 				if (!strcmp (arg->name, "hook-pre-disconnect")) {
   244 		if (!strcmp (arg->name, "name") && !strcmp (arg->value, "hook-pre-disconnect")) {
   245 						disco_free_handlers ();
   245 			disco_free_handlers ();
   246 						return;
   246 			return;
   247 				}
   247 		}
   248 		}
   248 	}
   249 }
   249 }
   250 
   250 
   251 const gchar *g_module_check_init(GModule *module)
   251 const gchar *g_module_check_init(GModule *module)
   252 {
   252 {
   253 	disco_handlers = NULL;
   253 	disco_handlers = NULL;
   254 
   254 
   255 	// completion
   255 	// completion
   256 	disco_cid = compl_new_category ();
   256 	disco_cid = compl_new_category ();
   257 	if (disco_cid) {
   257 	if (disco_cid) {
   258 			compl_add_category_word (disco_cid, "info");
   258 		compl_add_category_word (disco_cid, "info");
   259 			compl_add_category_word (disco_cid, "items");
   259 		compl_add_category_word (disco_cid, "items");
   260 	}
   260 	}
   261 
   261 
   262 	// command
   262 	// command
   263 	cmd_add ("disco", "", disco_cid, COMPL_JID, do_disco, NULL);
   263 	cmd_add ("disco", "", disco_cid, COMPL_JID, do_disco, NULL);
   264 
   264 
       
   265 	// register hook handler
       
   266 	hk_add_handler (disco_hh, HOOK_INTERNAL, NULL);
       
   267 
   265 	return NULL;
   268 	return NULL;
   266 }
   269 }
   267 
   270 
   268 void g_module_unload(GModule *module)
   271 void g_module_unload(GModule *module)
   269 {
   272 {
   270 	// release handlers
   273 	// release handlers
   271 	disco_free_handlers ();
   274 	disco_free_handlers ();
   272 
   275 
       
   276 	// remove hook handler
       
   277 	hk_del_handler (disco_hh, NULL);
       
   278 
   273 	// command
   279 	// command
   274 	cmd_del ("disco");
   280 	cmd_del ("disco");
   275 
   281 
   276 	// completion
   282 	// completion
   277 	if (disco_cid)
   283 	if (disco_cid)
   278 			compl_del_category (disco_cid);
   284 		compl_del_category (disco_cid);
   279 }
   285 }
   280 
   286 
   281 /* vim: se ts=4: */
   287 /* vim: se ts=4: */