disco.c
changeset 63 d644c08bbc27
parent 60 db0a96df96b5
equal deleted inserted replaced
62:f4ad0e7bf1ef 63:d644c08bbc27
    20 
    20 
    21 #include <glib.h>
    21 #include <glib.h>
    22 #include <loudmouth/loudmouth.h>
    22 #include <loudmouth/loudmouth.h>
    23 #include <string.h>
    23 #include <string.h>
    24 
    24 
    25 #include <mcabber/commands.h>
    25 //#include <mcabber/caps.h>
    26 #include <mcabber/logprint.h>
    26 #include <mcabber/commands.h>      // cmd_add (), cmd_del ()
    27 #include <mcabber/utils.h>
    27 #include <mcabber/compl.h>         // compl_new_category (), compl_del_category (), compl_add_category_word ()
    28 #include <mcabber/hooks.h>
    28 #include <mcabber/hbuf.h>          // HBB_PREFIX_INFO
    29 #include <mcabber/xmpp.h>
    29 #include <mcabber/hooks.h>         // hk_add_handler (), hk_del_handler (), HOOK_PRE_DISCONNECT, HOOK_HANDLER_RESULT_*
    30 #include <mcabber/compl.h>
    30 #include <mcabber/logprint.h>      // scr_log_print ()
    31 #include <mcabber/xmpp_defines.h>
    31 #include <mcabber/modules.h>       // module_info_t
    32 #include <mcabber/screen.h>
    32 #include <mcabber/roster.h>        // buddy_getjid (), buddy_gettype (), current_buddy, BUDDATA ()
    33 #include <mcabber/hbuf.h>
    33 #include <mcabber/screen.h>        // scr_write_incoming_message ()
    34 #include <mcabber/modules.h>
    34 #include <mcabber/utils.h>         // to_utf8 (), free_arg_lst (), jidtodisp ()
    35 #include <mcabber/caps.h>
    35 #include <mcabber/xmpp.h>          // xmpp_is_online (), lconnection
       
    36 #include <mcabber/xmpp_defines.h>  // NS_DISCO_INFO, NS_DISCO_ITEMS
    36 
    37 
    37 #include "disco.h"
    38 #include "disco.h"
    38 
    39 
    39 #include "config.h"
    40 #include "config.h"
    40 
    41 
    85 
    86 
    86 //
    87 //
    87 // globals
    88 // globals
    88 //
    89 //
    89 
    90 
    90 #ifdef MCABBER_API_HAVE_CMD_ID
    91 #ifdef HAVE_MCABBER_CMD_ID
    91 static gpointer disco_cmid     = NULL;
    92 static gpointer disco_cmid     = NULL;
    92 #endif
    93 #endif
    93 static guint    disco_cid      = 0;
    94 static guint    disco_cid      = 0;
    94 static guint    disco_hid      = 0;
    95 static guint    disco_hid      = 0;
    95 static GSList * disco_requests = NULL;
    96 static GSList * disco_requests = NULL;
   548 			if (current_buddy) {
   549 			if (current_buddy) {
   549 				gpointer bud = BUDDATA(current_buddy);
   550 				gpointer bud = BUDDATA(current_buddy);
   550 				if (bud) {
   551 				if (bud) {
   551 					guint type = buddy_gettype (bud);
   552 					guint type = buddy_gettype (bud);
   552 					if (type != ROSTER_TYPE_GROUP && type != ROSTER_TYPE_SPECIAL)
   553 					if (type != ROSTER_TYPE_GROUP && type != ROSTER_TYPE_SPECIAL)
   553 						to = g_strdup (buddy_getjid (bud)); // XXX memleak!
   554 						to = g_strdup (buddy_getjid (bud));
   554 				}
   555 				}
   555 			}
   556 			}
   556 		}
   557 		}
   557 
   558 
   558 		if (!to) {
   559 		if (!to) {
   609 }
   610 }
   610 
   611 
   611 void disco_init (void)
   612 void disco_init (void)
   612 {
   613 {
   613 	// completion
   614 	// completion
   614 #ifdef MCABBER_API_HAVE_COMPL_FLAGS
   615 #ifdef HAVE_MCABBER_COMPLETION_FLAGS
   615 	disco_cid = compl_new_category (COMPL_FLAGS_SORT);
   616 	disco_cid = compl_new_category (COMPL_FLAGS_SORT);
   616 #else
   617 #else
   617 	disco_cid = compl_new_category ();
   618 	disco_cid = compl_new_category ();
   618 #endif
   619 #endif
   619 	if (disco_cid) {
   620 	if (disco_cid) {
   623 
   624 
   624 	// hook handler
   625 	// hook handler
   625 	disco_hid = hk_add_handler (disco_hh, HOOK_PRE_DISCONNECT, G_PRIORITY_DEFAULT, NULL);
   626 	disco_hid = hk_add_handler (disco_hh, HOOK_PRE_DISCONNECT, G_PRIORITY_DEFAULT, NULL);
   626 
   627 
   627 	// command
   628 	// command
   628 #ifndef MCABBER_API_HAVE_CMD_ID
   629 #ifndef HAVE_MCABBER_CMD_ID
   629 	cmd_add ("disco", "", disco_cid, COMPL_JID, do_disco, NULL);
   630 	cmd_add ("disco", "", disco_cid, COMPL_JID, do_disco, NULL);
   630 #else
   631 #else
   631 	disco_cmid = cmd_add ("disco", "", disco_cid, COMPL_JID, do_disco, NULL);
   632 	disco_cmid = cmd_add ("disco", "", disco_cid, COMPL_JID, do_disco, NULL);
   632 #endif
   633 #endif
   633 
   634 
   635 }
   636 }
   636 
   637 
   637 void disco_uninit (void)
   638 void disco_uninit (void)
   638 {
   639 {
   639 	// command
   640 	// command
   640 #ifndef MCABBER_API_HAVE_CMD_ID
   641 #ifndef HAVE_MCABBER_CMD_ID
   641 	cmd_del ("disco");
   642 	cmd_del ("disco");
   642 #else
   643 #else
   643 	if (disco_cmid)
   644 	if (disco_cmid)
   644 		cmd_del (disco_cmid);
   645 		cmd_del (disco_cmid);
   645 #endif
   646 #endif