int xchat_plugin_init (xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { xchat_plugin_get_info (plugin_name, plugin_desc, plugin_version, NULL); ph = plugin_handle; if (notify_init ("XChat-GNOME OSD")) { /* FIXME: multi-head! */ GtkIconTheme *theme = gtk_icon_theme_get_default (); notify_icon = gtk_icon_theme_load_icon (theme, "xchat-gnome", 48, 0, NULL); xchat_hook_print (ph, "Channel Msg Hilight", XCHAT_PRI_NORM, new_msg_cb, NULL); xchat_hook_print (ph, "Channel Action Hilight", XCHAT_PRI_NORM, new_action_cb, NULL); xchat_hook_print (ph, "Private Message", XCHAT_PRI_NORM, private_msg_cb, NULL); xchat_hook_print (ph, "Private Message to Dialog", XCHAT_PRI_NORM, private_msg_cb, NULL); xchat_print (ph, _("OSD loaded\n")); return TRUE; } else { xchat_print (ph, _("OSD initialization failed\n")); } return FALSE; }
int xchat_plugin_init (xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { /* we need to save this for use with any xchat_* functions */ ph = plugin_handle; /* tell xchat our info */ *plugin_name = name; *plugin_desc = desc; *plugin_version = version; xchat_hook_command (ph, "SASL", XCHAT_PRI_NORM, sasl_cmd_cb, sasl_help, 0); xchat_hook_print (ph, "Connected", XCHAT_PRI_NORM, connect_cb, NULL); /* xchat_hook_print (ph, "Disconnected", XCHAT_PRI_NORM, disconnect_cb, NULL); */ xchat_hook_server (ph, "CAP", XCHAT_PRI_NORM, cap_cb, NULL); xchat_hook_server (ph, "RAW LINE", XCHAT_PRI_NORM, server_cb, NULL); xchat_hook_server (ph, "903", XCHAT_PRI_NORM, authend_cb, NULL); xchat_hook_server (ph, "904", XCHAT_PRI_NORM, authend_cb, NULL); xchat_hook_server (ph, "905", XCHAT_PRI_NORM, authend_cb, NULL); xchat_hook_server (ph, "906", XCHAT_PRI_NORM, authend_cb, NULL); xchat_hook_server (ph, "907", XCHAT_PRI_NORM, authend_cb, NULL); xchat_printf (ph, "%s plugin loaded\n", name); return 1; }
static VALUE static_ruby_xchat_hook_print( VALUE klass, VALUE name, VALUE priority ) { char *s_name; int i_priority; xchat_hook *hook; VALUE v_hook; Check_Type( name, T_STRING ); Check_Type( priority, T_FIXNUM ); s_name = StringValueCStr( name ); i_priority = FIX2INT( priority ); hook = xchat_hook_print( static_plugin_handle, s_name, i_priority, static_ruby_custom_print_hook, (void*)name ); v_hook = Data_Wrap_Struct( static_xchat_hook_klass, NULL, NULL, hook ); return v_hook; }
int xchat_plugin_init (xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { gboolean success; xchat_plugin_get_info (plugin_name, plugin_desc, plugin_version, NULL); ph = plugin_handle; success = init_dbus (); if (success) { xchat_hook_print (ph, "Motd", XCHAT_PRI_NORM, connected_cb, NULL); xchat_hook_print (ph, "MOTD Skipped", XCHAT_PRI_NORM, connected_cb, NULL); xchat_find_set_context (ph); xchat_printf (ph, _("%s loaded successfully\n"), NET_MONITOR_NAME); } return success; }
int xchat_plugin_init (xchat_plugin * plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { ph = plugin_handle; *plugin_name = "XDCC"; *plugin_desc = "Very simple XDCC server"; *plugin_version = "0.1"; xchat_hook_command (ph, "XDCC", XCHAT_PRI_NORM, xdcc_command, 0, 0); xchat_hook_print (ph, "CTCP Generic", XCHAT_PRI_NORM, ctcp_cb, 0); xchat_hook_print (ph, "CTCP Generic to Channel", XCHAT_PRI_NORM, ctcp_cb, 0); xdcc_load (); xchat_print (ph, "XDCC loaded. Type /XDCC for help.\n"); return 1; }
int xchat_plugin_init (xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { ph = plugin_handle; *plugin_name = name; *plugin_desc = desc; *plugin_version = version; /* this is required for the very first run */ if (xchat_pluginpref_get_int (ph, "limit") == -1) { xchat_pluginpref_set_int (ph, "limit", DEFAULT_LIMIT); } xchat_hook_command (ph, "CHECKSUM", XCHAT_PRI_NORM, checksum, "Usage: /CHECKSUM GET|SET", 0); xchat_hook_print (ph, "DCC RECV Complete", XCHAT_PRI_NORM, dccrecv_cb, NULL); xchat_hook_print (ph, "DCC Offer", XCHAT_PRI_NORM, dccoffer_cb, NULL); xchat_printf (ph, "%s plugin loaded\n", name); return 1; }
/* Xchat::Internal::hook_print(name, priority, callback, [userdata]) */ static XS (XS_Xchat_hook_print) { char *name; int pri; SV *callback; SV *userdata; xchat_hook *hook; HookData *data; dXSARGS; if (items != 4) { xchat_print (ph, "Usage: Xchat::Internal::hook_print(name, priority, callback, userdata)"); } else { name = SvPV_nolen (ST (0)); pri = (int) SvIV (ST (1)); callback = ST (2); data = NULL; userdata = ST (3); data = malloc (sizeof (HookData)); if (data == NULL) { XSRETURN_UNDEF; } data->callback = sv_mortalcopy (callback); SvREFCNT_inc (data->callback); data->userdata = sv_mortalcopy (userdata); SvREFCNT_inc (data->userdata); data->depth = 0; data->package = NULL; hook = xchat_hook_print (ph, name, pri, print_cb, data); XSRETURN_IV (PTR2IV (hook)); } }
/* XChat::Internal::hook_print(name, priority, callback, [userdata]) */ static XS (XS_XChat_hook_print) { char *name; int pri; SV *callback; SV *userdata; SV *package; xchat_hook *hook; HookData *data; dXSARGS; if (items != 5) { xchat_print (ph, "Usage: XChat::Internal::hook_print(name, priority, callback, userdata, package)"); } else { name = SvPV_nolen (ST (0)); pri = (int) SvIV (ST (1)); callback = ST (2); data = NULL; userdata = ST (3); package = ST (4); data = malloc (sizeof (HookData)); if (data == NULL) { XSRETURN_UNDEF; } data->callback = newSVsv (callback); data->userdata = newSVsv (userdata); data->depth = 0; data->package = newSVsv (package); hook = xchat_hook_print (ph, name, pri, print_cb, data); XSRETURN_IV (PTR2IV (hook)); } }
int tray_plugin_init (xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { /* we need to save this for use with any xchat_* functions */ ph = plugin_handle; *plugin_name = ""; *plugin_desc = ""; *plugin_version = ""; xchat_hook_print (ph, "Channel Msg Hilight", -1, tray_hilight_cb, NULL); xchat_hook_print (ph, "Channel Action Hilight", -1, tray_hilight_cb, NULL); xchat_hook_print (ph, "Channel Message", -1, tray_message_cb, NULL); xchat_hook_print (ph, "Channel Action", -1, tray_message_cb, NULL); xchat_hook_print (ph, "Channel Notice", -1, tray_message_cb, NULL); xchat_hook_print (ph, "Private Message", -1, tray_priv_cb, NULL); xchat_hook_print (ph, "Private Message to Dialog", -1, tray_priv_cb, NULL); xchat_hook_print (ph, "Notice", -1, tray_priv_cb, NULL); xchat_hook_print (ph, "Invited", -1, tray_invited_cb, NULL); xchat_hook_print (ph, "DCC Offer", -1, tray_dcc_cb, NULL); xchat_hook_print (ph, "Focus Window", -1, tray_focus_cb, NULL); if (prefs.gui_tray) tray_init (); return 1; /* return 1 for success */ }
/* * lua: xchat.hook_print(name, func_name, prio, data) * desc: Registers a function to trap any print events. The event names may * be any available in the "Advanced > Text Events" window. There are * also some extra "special" events you may hook using this function, * see: http://xchat.org/docs/plugin20.html#xchat_hook_print * ret: true... or false if something went wrong while registering hook * args: * * name (string): the name of the new command * * prio (number): use one of the xchat.PRIO_* * * func_name (string): the lua function to be called when command is * entered * * data (table): table with strings, numbers and booleans, which will * be passed to func_name as last argument. */ static int lxc_hook_print(lua_State *L) { xchat_hook *hook; struct lxc_hooks *hooks, *h; struct lxc_States *st; struct lxc_cbdata *cb = malloc(sizeof(struct lxc_cbdata)); const char *name, *func; double prio; if (!cb) { luaL_error(L, "lxc_hook_print(): failed to malloc: %s", strerror(errno)); return 0; } if (lua_gettop(L) < 4) /* expand to 4 args if necessary */ lua_settop(L, 4); name = luaL_checkstring(L, 1); func = luaL_checkstring(L, 2); if (lua_type(L, 3) == LUA_TNIL) prio = XCHAT_PRI_NORM; else prio = luaL_checknumber(L, 3); cb->state = L; cb->func = func; cb->data = NULL; cb->hook = NULL; if (lxc_get_userdata(4, cb) == 0) lua_pushboolean(L, 0); else { h = malloc(sizeof(struct lxc_hooks)); if (!h) { xchat_printf(ph, "lxc_hook_print(): failed to malloc: %s", strerror(errno)); lua_pushboolean(L, 0); return 1; } hook = xchat_hook_print(ph, name, prio, lxc_run_print, cb); h->hook = hook; h->name = name; h->next = NULL; st = lxc_states; while (st) { if (st->state == L) { if (!st->hooks) st->hooks = h; else { hooks = st->hooks; while (hooks->next) hooks = hooks->next; hooks->next = h; } break; } st = st->next; } lua_pushboolean(L, 1); } return 1; }