b3PluginManager::~b3PluginManager() { while (m_data->m_pluginMap.size()) { int* pluginUidPtr = m_data->m_pluginMap.getAtIndex(0); if (pluginUidPtr) { int pluginUid = *pluginUidPtr; unloadPlugin(*pluginUidPtr); } } delete m_data->m_physicsDirect; m_data->m_pluginMap.clear(); m_data->m_plugins.exitHandles(); delete m_data; }
void finiCore (void) { CompPlugin *p; while (core.displays) removeDisplay (core.displays); if (core.watchPollFds) free (core.watchPollFds); while ((p = popPlugin ())) unloadPlugin (p); XDestroyRegion (core.outputRegion); XDestroyRegion (core.tmpRegion); }
int elektraNotificationClose (KDB * kdb) { // Make sure kdb is not null if (!kdb) { ELEKTRA_LOG_WARNING ("kdb was not set"); return 0; } // Make sure open was called if (!kdb->notificationPlugin) { ELEKTRA_LOG_WARNING ("elektraNotificationOpen not called before elektraPluginClose"); return 0; } Plugin * notificationPlugin = kdb->notificationPlugin; // Unmount the plugin int result = unmountGlobalPlugin (kdb, notificationPlugin); if (!result) { return 0; } // Unload the notification plugin result = unloadPlugin (notificationPlugin); if (!result) { return 0; } // Close notification for plugins pluginsCloseNotification (kdb); elektraFree (kdb->notificationCallbackContext); kdb->notificationPlugin = NULL; kdb->notificationCallbackContext = NULL; return 1; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //controltype_label_destroy //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int controltype_label_destroy(control *c) { int i; //Get the details controltype_label_details *details = (controltype_label_details *) c->controldetails; //Delete the agents for (i = 0; i < CONTROLTYPE_LABEL_AGENT_COUNT; i++) agent_destroy(&details->agents[i]); unloadPlugin(&details->module_info, NULL); //Destroy the window window_destroy(&c->windowptr); //Delete the details delete (controltype_label_details *) c->controldetails; return 0; }
void CPluginMngr::clear() { CPlugin**a = &head; while (*a) unloadPlugin(a); m_Finalized = false; if (pNatives) { delete [] pNatives; pNatives = NULL; } List<ke::AString *>::iterator iter = m_BlockList.begin(); while (iter != m_BlockList.end()) { delete (*iter); iter = m_BlockList.erase(iter); } m_BlockList.clear(); }
PluginLoader<T>::~PluginLoader(){ if(loaded()){ unloadPlugin(); } return; }
void PluginManager::unloadAllPlugins() { while (!mLibs.empty()) unloadPlugin((*mLibs.begin()).first); }
/** * Modifies the directory, recursivity or plugins of the filter. */ void Filter::modifyFilter(QString url, bool recursive, QStringList pluginFilenames) { QFileInfoExt dirExt(url); bool modified = false; bool watcherWasRunning = isRunning(); if (isRunning()) stop(); // directory if (m_url != url) { m_url = url; m_dir = dirExt.absoluteFilePath(); modified = true; } // recursivity if (m_recursive != recursive) { m_recursive = recursive; modified = true; } // plugins // unload the plugins we don't want anymore for (int i = m_pluginFilenames.count(); i > 0; i--) { QString pluginFilename = m_pluginFilenames[i - 1]; if (pluginFilenames.contains(pluginFilename)) continue; // keep this one unloadPlugin(pluginFilename); modified = true; } // load the new ones if (m_pluginFilenames != pluginFilenames) { if (!pluginFilenames.isEmpty()) { for (int i = 0; i < pluginFilenames.count(); i++) { QString pluginFilename = pluginFilenames[i]; if (m_pluginFilenames.contains(pluginFilename)) continue; // keep this one, we already have it loadPlugin(pluginFilename); modified = true; } } } if (modified) { // do we have a watcher? if (m_watcherP) { delete m_watcherP; m_watcherP = NULL; } // if at least one plugin was loaded, create the watcher for the given directory // (if existing) if (!m_parentP && !m_plugins.isEmpty() && !m_url.isEmpty() && dirExt.exists()) m_watcherP = new Watcher(m_url, recursive, this); } if (watcherWasRunning) start(); if (modified) rescanDirectory(); // force a refresh of the filtered files }
static void updatePlugins (CompDisplay *d) { CompOption *o; CompPlugin *p, **pop = 0; int nPop, i, j; d->dirtyPluginList = FALSE; o = &d->opt[COMP_DISPLAY_OPTION_ACTIVE_PLUGINS]; for (i = 0; i < d->plugin.list.nValue && i < o->value.list.nValue; i++) { if (strcmp (d->plugin.list.value[i].s, o->value.list.value[i].s)) break; } nPop = d->plugin.list.nValue - i; if (nPop) { pop = malloc (sizeof (CompPlugin *) * nPop); if (!pop) { (*d->setDisplayOption) (d, o->name, &d->plugin); return; } } for (j = 0; j < nPop; j++) { pop[j] = popPlugin (); d->plugin.list.nValue--; free (d->plugin.list.value[d->plugin.list.nValue].s); } for (; i < o->value.list.nValue; i++) { p = 0; for (j = 0; j < nPop; j++) { if (pop[j] && strcmp (pop[j]->vTable->name, o->value.list.value[i].s) == 0) { if (pushPlugin (pop[j])) { p = pop[j]; pop[j] = 0; break; } } } if (p == 0) { p = loadPlugin (o->value.list.value[i].s); if (p) { if (!pushPlugin (p)) { unloadPlugin (p); p = 0; } } } if (p) { CompOptionValue *value; value = realloc (d->plugin.list.value, sizeof (CompOption) * (d->plugin.list.nValue + 1)); if (value) { value[d->plugin.list.nValue].s = strdup (p->vTable->name); d->plugin.list.value = value; d->plugin.list.nValue++; } else { p = popPlugin (); unloadPlugin (p); } } } for (j = 0; j < nPop; j++) { if (pop[j]) unloadPlugin (pop[j]); } if (nPop) free (pop); (*d->setDisplayOption) (d, o->name, &d->plugin); }
int PluginCollection::unloadPlugin(const QString& name) { return unloadPlugin(plugin(name)); }
bool Plugin::loadPlugin(const std::string& name, const std::string& path, std::string alias) { LIBRARY_HANDLE lhandle = NULL; pfms fhandle = NULL; if (name.empty() || (name.find('/') != std::string::npos) || (name.find('\\') != std::string::npos)) { LOG(INFO, "Plugin", "Invalid name: " + name); return false; } if (alias.empty()) { alias = name; } if (!path.empty()) { std::string file; file = path + '/' + name + LIBRARY_EXTENSION; struct stat st; int statr = stat(file.c_str(), &st); if ((statr == 0) && !(st.st_mode & S_IFDIR)) { LOG(INFO, "Plugin", "Loading: " + file); lhandle = LIBRARY_LOAD(file.c_str()); } else { LOG(INFO, "Plugin", "Could not find: " + file); return false; } } else { LOG(INFO, "Plugin", "Loading built-in: " + name); lhandle = LIBRARY_SELF(); } if (lhandle == NULL) { LOG(INFO, "Plugin", "Could not load: " + name); LOG(INFO, "Plugin", LIBRARY_ERROR()); return false; } m_libraryHandles[alias] = lhandle; *reinterpret_cast<void**>(&fhandle) = (void*)LIBRARY_SYMBOL(lhandle, (name + "_init").c_str()); if (fhandle == NULL) { LOG(INFO, "Plugin", "Could not get init function handle!"); unloadPlugin(alias); return false; } fhandle(&plugin_api_pointers); return true; }
MainWindow::~MainWindow() { // Unloading plugin leaves Arial font 'hanging' in font cache, that causes bad things. unloadPlugin(); delete mUi; }
bool Plugin::loadPlugin(const std::string name, const std::string file) { LIBRARY_HANDLE lhandle = NULL; #ifdef FADOR_PLUGIN void (*fhandle)(mineserver_pointer_struct*) = NULL; #else void (*fhandle)(Mineserver*) = NULL; #endif if (!file.empty()) { LOG(INFO, "Plugin", "Loading plugin `"+name+"' (`"+file+"')..."); struct stat st; int statr = stat(file.c_str(), &st); if ((statr == 0) && !(st.st_mode & S_IFDIR)) { lhandle = LIBRARY_LOAD(file.c_str()); } else { LOG(INFO, "Plugin", "Could not find `"+file+"', trying `"+file+LIBRARY_EXTENSION+"'."); statr = stat((file+LIBRARY_EXTENSION).c_str(), &st); if ((statr == 0) && !(st.st_mode & S_IFDIR)) { lhandle = LIBRARY_LOAD((file+LIBRARY_EXTENSION).c_str()); } else { LOG(INFO, "Plugin", "Could not find `"+file+LIBRARY_EXTENSION+"'!"); return false; } } } else { LOG(INFO, "Plugin", "Loading plugin `"+name+"' (built in)..."); lhandle = LIBRARY_SELF(); } if (lhandle == NULL) { LOG(INFO, "Plugin", "Could not load plugin `"+name+"'!"); LOG(INFO, "Plugin", LIBRARY_ERROR()); return false; } m_libraryHandles[name] = lhandle; #ifdef FADOR_PLUGIN fhandle = (void (*)(mineserver_pointer_struct*)) LIBRARY_SYMBOL(lhandle, (name+"_init").c_str()); #else fhandle = (void (*)(Mineserver*)) LIBRARY_SYMBOL(lhandle, (name+"_init").c_str()); #endif if (fhandle == NULL) { LOG(INFO, "Plugin", "Could not get init function handle!"); unloadPlugin(name); return false; } #ifdef FADOR_PLUGIN fhandle(&plugin_api_pointers); #else fhandle(Mineserver::get()); #endif return true; }
InputPlugin::~InputPlugin() { closePlugin(); unloadPlugin(); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //controltype_label_message //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int controltype_label_message(control *c, int tokencount, char *tokens[]) { // token strings enum { T_NONE = 0, T_STYLE , T_VALIGN , T_HALIGN , T_HASTITLE , T_LOCKPOS , T_PLUGINLOAD , T_PLUGINUNLOAD , T_PLUGINSETPOS , T_PLUGINSHOW , T_PLUGINABOUT }; extern char szWPStyle []; static struct token_check controltype_label_property_tokens[] = { { szWPStyle, T_STYLE , 1 }, { "VAlign", T_VALIGN , 1 }, { "HAlign", T_HALIGN , 1 }, { "HasTitleBar", T_HASTITLE , 1 }, { "IsLocked", T_LOCKPOS , 1 }, { NULL } }; static struct token_check controltype_label_plugin_property_tokens[] = { { "IsVisible", T_PLUGINSHOW , 1 }, { "Position", T_PLUGINSETPOS , 2 }, { NULL } }; static struct token_check controltype_label_plugin_tokens[] = { { "Load", T_PLUGINLOAD , 1 }, { "Unload", T_PLUGINUNLOAD , 1 }, { "About", T_PLUGINABOUT , 0 }, { szBActionPluginSetProperty, (UINT_PTR)controltype_label_plugin_property_tokens , 2 }, { NULL } }; static struct token_check controltype_label_message_tokens[] = { { szBActionSetControlProperty, (UINT_PTR)controltype_label_property_tokens, 2 }, { szBActionPlugin, (UINT_PTR)controltype_label_plugin_tokens, 2 }, { NULL } }; // ----------------- //Get the details controltype_label_details *details = (controltype_label_details *) c->controldetails; //If set control details int i; int curtok = 2; switch (token_check(controltype_label_message_tokens, &curtok, tokencount, tokens)) { // ----------------- case T_STYLE: if (-1 != (i = get_string_index(tokens[curtok], szStyleNames))) { c->windowptr->style = i; style_draw_invalidate(c); return 0; } break; // ----------------- case T_HALIGN: if (-1 != (i = get_string_index(tokens[curtok], label_haligns))) { details->halign = i; controltype_label_updatesettings(details); style_draw_invalidate(c); return 0; } break; // ----------------- case T_VALIGN: if (-1 != (i = get_string_index(tokens[curtok], label_valigns))) { details->valign = i; controltype_label_updatesettings(details); style_draw_invalidate(c); return 0; } break; // ----------------- case T_HASTITLE: if (details->is_frame && config_set_bool(tokens[curtok], &details->has_titlebar)) { style_draw_invalidate(c); return 0; } break; // ----------------- case T_LOCKPOS: if (details->is_frame && config_set_bool(tokens[curtok], &details->is_locked)) return 0; break; // ----------------- case T_PLUGINLOAD: if (details->is_frame) { char *plugin_name = tokens[curtok]; if (0 == strcmp(plugin_name, "*browse*")) { // "open file" dialog plugin_name = dialog_file("Plugins\0*.dll\0", "Add Plugin" , NULL, ".dll", false); if (NULL == plugin_name) { //message_override = true; return 2; } } ModuleInfo * m = loadPlugin(&details->module_info, c->windowptr->hwnd, plugin_name); if (m) { variables_set(false, "LastPlugin", m->module_name); return 0; } } break; // ----------------- case T_PLUGINUNLOAD: if (unloadPlugin(&details->module_info, tokens[curtok])) return 0; break; // ----------------- case T_PLUGINSETPOS: { int x, y; if (config_set_int(tokens[curtok], &x) && config_set_int(tokens[1+curtok], &y) && plugin_setpos(details->plugin_info, tokens[-2+curtok], x, y) ) return 0; return 0; // dont generate an error here... } break; // ----------------- case T_PLUGINSHOW: { bool show; if (plugin_getset_show_state(details->plugin_info, tokens[-2+curtok], config_set_bool(tokens[curtok], &show) ? show : 2) ) return 0; return 0; // dont generate an error here... } break; // ----------------- case T_PLUGINABOUT: { aboutPlugins(details->module_info, c->controlname); return 0; } break; // ----------------- //Must be an agent message default: return agent_controlmessage(c, tokencount, tokens, CONTROLTYPE_LABEL_AGENT_COUNT, details->agents, controltype_label_agentnames, controltype_label_agenttypes); } return 1; }