BOOL CWin7ControlClientApp::InitInstance() { AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. // Change the registry key under which our settings are stored. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. PluginApp::InitInstance(); //加载注册机 //if(!IsRegisterOK()) return FALSE; //加载所有的插件 LoadAllPlugins(); CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CWin7ControlClientDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CWin7ControlClientView)); AddDocTemplate(pDocTemplate); RegisterAllDocTemplates(); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; m_pMainWnd = pMainFrame; if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; // The main window has been initialized, so show and update it. pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; }
bool OBPlugin::ListAsVector(const char* PluginID, const char* param, vector<string>& vlist) { PluginMapType::iterator itr; bool ret=true; // Make sure the plugins are loaded if (AllPluginsLoaded == 0) { LoadAllPlugins(); } if(PluginID) { if(*PluginID!=0 && strcmp(PluginID, "plugins")) { //List the sub classes of the specified type itr = PluginMap().find(PluginID); if(itr!=PluginMap().end()) { bool onlyIDs = param!=NULL && strstr(param,"ids")!=NULL; //Get map of plugin type (like OBFingerprint) and output its contents PluginMapType Map = itr->second->GetMap(); for(itr=Map.begin(); itr!=Map.end(); ++itr) { if(*(itr->first)=='_')//no listing when ID starts with '_' continue; if(onlyIDs) vlist.push_back(itr->first); else { string txt; if((itr->second)->Display(txt, param, itr->first)) vlist.push_back(txt); } } return true; } ret=false; //asked for a type not available; provide plugin types instead } } //List the plugin types for(itr=PluginMap().begin(); itr!= PluginMap().end(); ++itr) vlist.push_back(itr->first); return ret; }
bool PluginManager::InstallPlugin(const wxString& pluginName, bool forAllUsers, bool askForConfirmation) { if (pluginName.IsEmpty()) return false; wxString actualName = pluginName; Manager::Get()->GetMacrosManager()->ReplaceMacros(actualName); // base name wxString basename = wxFileName(actualName).GetName(); wxString version; if (basename.Contains(_T('-'))) { version = basename.AfterFirst(_T('-')); basename = basename.BeforeFirst(_T('-')); } // Manager::Get()->GetLogManager()->DebugLog(F(_T("InstallPlugin: basename='%s', version=%s"), basename.c_str(), version.c_str())); // if plugin with the same name exists, ask to uninstall first cbPlugin* existingPlugin = FindPluginByName(basename); if (existingPlugin) { if (askForConfirmation) { wxString msg = _("A plugin with the same name is already installed.\n"); if (!version.IsEmpty()) { const PluginInfo* existingInfo = GetPluginInfo(existingPlugin); if (CompareVersions(version, existingInfo->version) < 0) { msg = _("The plugin you are trying to install, is older " "than the one currently installed."); } } if (cbMessageBox(msg + _T('\n') + _("If you want to proceed, the installed plugin will be " "uninstalled first.\n" "Do you want to proceed?"), _("Confirmation"), wxICON_QUESTION | wxYES_NO) == wxID_NO) { return false; } } if (!UninstallPlugin(existingPlugin)) return false; } wxString pluginDir; wxString resourceDir; if (forAllUsers) { pluginDir = ConfigManager::GetFolder(sdPluginsGlobal); resourceDir = ConfigManager::GetFolder(sdDataGlobal); } else { pluginDir = ConfigManager::GetFolder(sdPluginsUser); resourceDir = ConfigManager::GetFolder(sdDataUser); } wxProgressDialog pd(_("Installing: ") + basename, _T("A description wide enough for the dialog ;)"), 5); wxString localName = basename + FileFilters::DYNAMICLIB_DOT_EXT; wxString resourceName = basename + _T(".zip"); wxString settingsOnName = basename + _T(".png"); wxString settingsOffName = basename + _T("-off.png"); if (!platform::windows && resourceName.StartsWith(_T("lib"))) resourceName.Remove(0, 3); if (!platform::windows && settingsOnName.StartsWith(_T("lib"))) settingsOnName.Remove(0, 3); if (!platform::windows && settingsOffName.StartsWith(_T("lib"))) settingsOffName.Remove(0, 3); wxString pluginFilename = pluginDir + _T('/') + localName; // Manager::Get()->GetLogManager()->DebugLog(F(_T("Plugin filename: ") + pluginFilename)); // Manager::Get()->GetLogManager()->DebugLog(F(_T("Plugin resources: ") + ConfigManager::GetDataFolder() + _T('/') + resourceName)); pd.Update(1, _("Extracting plugin")); // extract plugin from bundle if (!ExtractFile(actualName, localName, pluginFilename)) return false; // Manager::Get()->GetLogManager()->DebugLog(F(_T("Extracted plugin"))); pd.Update(2, _("Extracting plugin resources")); // extract resources from bundle if (!ExtractFile(actualName, resourceName, resourceDir + _T('/') + resourceName)) return false; // Manager::Get()->GetLogManager()->DebugLog(F(_T("Extracted resources"))); pd.Update(3, _("Extracting plugin icons for \"Settings\" dialog")); // extract resources from bundle ExtractFile(actualName, settingsOnName, resourceDir + _T("/images/settings/") + settingsOnName, false); // Manager::Get()->GetLogManager()->DebugLog(F(_T("Extracted resources"))); // extract resources from bundle ExtractFile(actualName, settingsOffName, resourceDir + _T("/images/settings/") + settingsOffName, false); // Manager::Get()->GetLogManager()->DebugLog(F(_T("Extracted resources"))); // extract extra files wxArrayString extraFiles; ReadExtraFilesFromManifestFile(localName, extraFiles); for (size_t i = 0; i < extraFiles.GetCount(); ++i) { ExtractFile(actualName, extraFiles[i], resourceDir + _T("/") + extraFiles[i], false); } pd.Update(4, _("Loading plugin")); // bundle extracted; now load the plugin on-the-fly // Manager::Get()->GetLogManager()->DebugLog(F(_T("Loading plugin..."))); ScanForPlugins(pluginDir); LoadAllPlugins(); cbPlugin* plugin = FindPluginByFileName(pluginFilename); const PluginInfo* info = GetPluginInfo(plugin); if (!plugin || !info) { Manager::Get()->GetLogManager()->DebugLog(_T("Failed")); return false; } // Manager::Get()->GetLogManager()->DebugLog(F(_T("Succeeded"))); // inform app to update menus and toolbars pd.Update(5, _("Updating menus and toolbars")); CodeBlocksEvent evt(cbEVT_PLUGIN_INSTALLED); evt.SetPlugin(plugin); Manager::Get()->ProcessEvent(evt); // Manager::Get()->GetLogManager()->DebugLog(F(_T("Menus updated"))); return true; }