static gboolean plugin_fd_cb (GIOChannel *source, GIOCondition condition, xchat_hook *hook) { int flags = 0, ret; typedef int (xchat_fd_cb2) (int fd, int flags, void *user_data, GIOChannel *); if (condition & G_IO_IN) flags |= XCHAT_FD_READ; if (condition & G_IO_OUT) flags |= XCHAT_FD_WRITE; if (condition & G_IO_PRI) flags |= XCHAT_FD_EXCEPTION; ret = ((xchat_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! */ xchat_unhook (hook->pl, hook); } return ret; }
static XS (XS_Xchat_unhook) { xchat_hook *hook; HookData *userdata; int retCount = 0; dXSARGS; if (items != 1) { xchat_print (ph, "Usage: Xchat::unhook(hook)"); } else { hook = INT2PTR (xchat_hook *, SvUV (ST (0))); userdata = (HookData *) xchat_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 timer_del(timer *tim) { timer_list = g_slist_remove(timer_list, tim); free(tim->command); xchat_unhook(ph, tim->hook); free(tim); }
static int plugin_free(xchat_plugin *pl, int do_deinit, int allow_refuse) { GSList *list, *next; xchat_hook *hook; xchat_deinit_func *deinit_func; // fake plugin added by xchat_plugingui_add() if (pl->fake) goto xit; // run the plugin's deinit routine, if any if (do_deinit && pl->deinit_callback != nullptr) { deinit_func = (xchat_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 = (xchat_hook*)list->data; next = list->next; if (hook->pl == pl) xchat_unhook(nullptr, hook); list = next; } #ifdef USE_PLUGIN if (pl->handle) #ifdef USE_GMODULE g_module_close((GModule*)pl->handle); #else dlclose(pl->handle); #endif #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(pl->filename); free(pl); plugin_list = g_slist_remove(plugin_list, pl); #ifdef USE_PLUGIN fe_pluginlist_update(); #endif return TRUE; }
void ScriptData::cancelSleep() { if ( m_pSleepHook != 0 ) { xchat_unhook( the_plugin, m_pSleepHook ); m_pSleepHook = 0; } }
void ScriptData::putAtSleep( Falcon::numeric seconds ) { if( m_pSleepHook != 0 ) { xchat_unhook( the_plugin, m_pSleepHook ); } int slt = (int)(seconds*1000); m_pSleepHook = xchat_hook_timer( the_plugin, slt, mod_sleep_timer_cb, this ); }
static VALUE static_ruby_xchat_unhook( VALUE klass, VALUE hook_id ) { xchat_hook *hook; Data_Get_Struct( hook_id, xchat_hook, hook ); xchat_unhook( static_plugin_handle, hook ); return Qnil; }
/* * lua: xchat.unhook(name) * desc: unhooks a previously hooked hook * ret: true if the hook existed, else false.. * args: * * name (string): name of a registered hook (e.g. with * xchat.hook_command("whois", ... ) you would unhook "whois" * ... see timer warnings... there's currently just one "timer" * to unhook */ static int lxc_unhook(lua_State *L) { struct lxc_States *state; struct lxc_hooks *hooks, *h, *prev_hook; struct lxc_cbdata *cb; struct lxc_userdata *ud, *u; int done = 0; const char *name = luaL_checkstring(L, 1); prev_hook = NULL; state = lxc_states; while (state) { if (state->state == L) { hooks = state->hooks; while (hooks) { if (strcasecmp(hooks->name, name) == 0) { h = hooks; if (prev_hook) prev_hook->next = hooks->next; else state->hooks = hooks->next; cb = xchat_unhook(ph, h->hook); if (cb) { ud = cb->data; while (ud) { u = ud; ud = ud->next; free(u); } free(cb); } free(h); done = 1; break; } prev_hook = hooks; hooks = hooks->next; } break; } state = state->next; } lua_pushboolean(L, done); return 1; }
static void lxc_unhook_timer(lua_State *L, xchat_hook *hook) { struct lxc_States *state; struct lxc_hooks *hooks, *h, *prev_hook; struct lxc_cbdata *cb; struct lxc_userdata *ud, *u; prev_hook = NULL; state = lxc_states; while (state) { if (state->state == L) { hooks = state->hooks; while (hooks) { if (hooks->hook == hook) { h = hooks; if (prev_hook) prev_hook->next = hooks->next; else state->hooks = hooks->next; cb = xchat_unhook(ph, h->hook); if (cb) { ud = cb->data; while (ud) { u = ud; ud = ud->next; free(u); } free(cb); } free(h); return; } prev_hook = hooks; hooks = hooks->next; } break; } state = state->next; } }
void lxc_unload_script(struct lxc_States *state) { struct lxc_hooks *hooks, *h; struct lxc_cbdata *cb; struct lxc_userdata *ud, *u; lua_State *L = state->state; lua_pushstring(L, "xchat_unload"); lua_gettable(L, LUA_GLOBALSINDEX); if (lua_type(L, -1) == LUA_TFUNCTION) { if (lua_pcall(L, 0, 0, 0)) { xchat_printf(ph, "Lua plugin: error while unloading script %s", lua_tostring(L, -1)); lua_pop(L, 1); } } if (state->gui) xchat_plugingui_remove(ph, state->gui); state->gui = NULL; hooks = state->hooks; while (hooks) { h = hooks; hooks = hooks->next; cb = xchat_unhook(ph, h->hook); if (cb) { ud = cb->data; while (ud) { u = ud; ud = ud->next; free(u); } free(cb); } free(h); } lua_close(state->state); }
static int plugin_timeout_cb(xchat_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 = ((xchat_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! xchat_unhook(hook->pl, hook); } return ret; }
void ScriptData::unhookAll() { cancelSleep(); for( int i = 0; i < m_hooks->length(); i++ ) { Falcon::CoreObject *hook = m_hooks->at( i ).asObject(); XChatHook *xh = (XChatHook *) hook->getUserData(); // the hook may have already dis-hooked itself. if ( xh != 0 ) { xchat_unhook( the_plugin, xh->hook() ); // void the hook hook->setUserData( (Falcon::FalconData*)0 ); delete xh; } } // empty the array of hooks m_hooks->resize( 0 ); // notice that this also causes the hook object to be reclaimable, // in case the script has dropped them too. }