static gboolean plugin_fd_cb (GIOChannel *source, GIOCondition condition, hexchat_hook *hook) { int flags = 0, ret; typedef int (hexchat_fd_cb2) (int fd, int flags, void *user_data, GIOChannel *); if (condition & G_IO_IN) flags |= HEXCHAT_FD_READ; if (condition & G_IO_OUT) flags |= HEXCHAT_FD_WRITE; if (condition & G_IO_PRI) flags |= HEXCHAT_FD_EXCEPTION; ret = ((hexchat_fd_cb2 *)hook->callback) (hook->pri, flags, hook->userdata, source); /* the callback might have already unhooked it! */ if (!g_slist_find (hook_list, hook) || hook->type == HOOK_DELETED) return 0; if (ret == 0) { hook->tag = 0; /* avoid fe_input_remove, returning 0 is enough! */ hexchat_unhook (hook->pl, hook); } return ret; }
static XS (XS_Xchat_unhook) { hexchat_hook *hook; HookData *userdata; int retCount = 0; dXSARGS; if (items != 1) { hexchat_print (ph, "Usage: Xchat::unhook(hook)"); } else { hook = INT2PTR (hexchat_hook *, SvUV (ST (0))); userdata = (HookData *) hexchat_unhook (ph, hook); if (userdata != NULL) { if (userdata->callback != NULL) { SvREFCNT_dec (userdata->callback); } if (userdata->userdata != NULL) { XPUSHs (sv_mortalcopy (userdata->userdata)); SvREFCNT_dec (userdata->userdata); retCount = 1; } if (userdata->package != NULL) { SvREFCNT_dec (userdata->package); } free (userdata); } XSRETURN (retCount); } XSRETURN_EMPTY; }
static void free_hook(hook_info *hook) { if(hook->state) luaL_unref(hook->state, LUA_REGISTRYINDEX, hook->ref); if(hook->hook) hexchat_unhook(ph, hook->hook); g_free(hook); }
static int plugin_free (hexchat_plugin *pl, int do_deinit, int allow_refuse) { GSList *list, *next; hexchat_hook *hook; hexchat_deinit_func *deinit_func; /* fake plugin added by hexchat_plugingui_add() */ if (pl->fake) goto xit; /* run the plugin's deinit routine, if any */ if (do_deinit && pl->deinit_callback != NULL) { deinit_func = pl->deinit_callback; if (!deinit_func (pl) && allow_refuse) return FALSE; } /* remove all of this plugin's hooks */ list = hook_list; while (list) { hook = list->data; next = list->next; if (hook->pl == pl) hexchat_unhook (NULL, hook); list = next; } #ifdef USE_PLUGIN if (pl->handle) g_module_close (pl->handle); #endif xit: if (pl->free_strings) { if (pl->name) free (pl->name); if (pl->desc) free (pl->desc); if (pl->version) free (pl->version); } if (pl->filename) free ((char *)pl->filename); free (pl); plugin_list = g_slist_remove (plugin_list, pl); #ifdef USE_PLUGIN fe_pluginlist_update (); #endif return TRUE; }
static int plugin_timeout_cb (hexchat_hook *hook) { int ret; /* timer_cb's context starts as front-most-tab */ hook->pl->context = current_sess; /* call the plugin's timeout function */ ret = ((hexchat_timer_cb *)hook->callback) (hook->userdata); /* the callback might have already unhooked it! */ if (!g_slist_find (hook_list, hook) || hook->type == HOOK_DELETED) return 0; if (ret == 0) { hook->tag = 0; /* avoid fe_timeout_remove, returning 0 is enough! */ hexchat_unhook (hook->pl, hook); } return ret; }
int hexchat_plugin_deinit(hexchat_plugin *plugin_handle) { /******************************************/ /****** Remove the Icon from the tray *****/ /******************************************/ StopBlink(g_hXchatWnd, 1, g_hIcons[0]); RemoveIcon(g_hXchatWnd, 1); /*******************************************/ /*******************************************/ /*******************************************/ if(g_dwPrefs & (1<<PREF_DNSIT)) { DWORD dwStyle; dwStyle = GetWindowLong(g_hXchatWnd, GWL_STYLE); dwStyle &= ~(1<<WS_CHILD); SetWindowLongPtr(g_hXchatWnd, GWL_STYLE, (LONG_PTR)dwStyle); SetWindowLongPtr(g_hXchatWnd, GWL_HWNDPARENT, NULL); } /******************************************/ /****** Unload our resources **************/ /******************************************/ DestroyMenu(g_hTrayMenu); for(int i = 0; i <= 11; i++) { DestroyIcon(g_hIcons[i]); } /******************************************/ /****** Remove our window hook ************/ /******************************************/ SetWindowLongPtr(g_hXchatWnd, GWLP_WNDPROC, (LONG_PTR)g_hOldProc); /******************************************/ /****** Remove our hotkey, and destroy ****/ /****** the window that receives its ****/ /****** messages ****/ /******************************************/ UnregisterHotKey(g_hHotkeyWnd, 1); DestroyWindow(g_hHotkeyWnd); DestroyWindow(g_hPrefDlg); /******************************************/ /************* Clean up Isle 7 ************/ /******************************************/ if(sdAlertNum()) { sdCloseAlerts(); } /******************************************/ /****** remove our hexchat_hook_*s **********/ /******************************************/ while(!g_vHooks.empty()) { if(g_vHooks.back() != NULL) { hexchat_unhook(ph, g_vHooks.back()); } g_vHooks.pop_back(); } return 1; }