int PluginLoop(void*){ WatchHandle watch = CreateWatch("*", "*", "*"); while(running){ Notification notif; if(GetNotification(¬if, 0)){ PLUGIN_INFO("notification received: %d.\n", notif.type); int res = 0; switch (notif.type) { case kShutdown: running = false; break; case kWatch: PluginInfo info; res = GetPluginInfo(notif.content.watch.plugin, &info); PLUGIN_INFO("plugin %s(%s) available\n", info.name, info.version); if(watch == notif.content.watch.handle && notif.content.watch.plugin_state == kPluginAvailable) { Connect(notif.content.watch.plugin); } break; default: break; } // process notification } } return 0; }
// plugin API void SetUniqueID(PluginHandle plugin, UInt32 uid) { // check existing plugins for(PluginCallbackList::iterator iter = s_pluginCallbacks.begin(); iter != s_pluginCallbacks.end(); ++iter) { if(iter->hadUID && (iter->uid == uid)) { UInt32 collidingID = iter - s_pluginCallbacks.begin(); _ERROR("plugin serialization UID collision (uid = %08X, plugins = %d %d)", plugin, uid, collidingID); } } PluginCallbacks * info = GetPluginInfo(plugin); ASSERT(!info->hadUID); info->uid = uid; info->hadUID = true; }
bool Plugin::SaveToCache() { PluginInfo Info = {sizeof(Info)}; GetPluginInfo(&Info); auto& PlCache = *ConfigProvider().PlCacheCfg(); SCOPED_ACTION(auto)(PlCache.ScopedTransaction()); PlCache.DeleteCache(m_strCacheName); unsigned __int64 id = PlCache.CreateCache(m_strCacheName); { bool bPreload = (Info.Flags & PF_PRELOAD); PlCache.SetPreload(id, bPreload); WorkFlags.Change(PIWF_PRELOADED, bPreload); if (bPreload) { PlCache.EndTransaction(); return true; } } { string strCurPluginID; os::FAR_FIND_DATA fdata; os::GetFindDataEx(m_strModuleName, fdata); strCurPluginID = str_printf( L"%I64x%x%x", fdata.nFileSize, fdata.ftCreationTime.dwLowDateTime, fdata.ftLastWriteTime.dwLowDateTime ); PlCache.SetSignature(id, strCurPluginID); } for (size_t i = 0; i < Info.DiskMenu.Count; i++) { PlCache.SetDiskMenuItem(id, i, Info.DiskMenu.Strings[i], GuidToStr(Info.DiskMenu.Guids[i])); } for (size_t i = 0; i < Info.PluginMenu.Count; i++) { PlCache.SetPluginsMenuItem(id, i, Info.PluginMenu.Strings[i], GuidToStr(Info.PluginMenu.Guids[i])); } for (size_t i = 0; i < Info.PluginConfig.Count; i++) { PlCache.SetPluginsConfigMenuItem(id, i, Info.PluginConfig.Strings[i], GuidToStr(Info.PluginConfig.Guids[i])); } PlCache.SetCommandPrefix(id, NullToEmpty(Info.CommandPrefix)); PlCache.SetFlags(id, Info.Flags); PlCache.SetMinFarVersion(id, &MinFarVersion); PlCache.SetGuid(id, m_strGuid); PlCache.SetVersion(id, &PluginVersion); PlCache.SetTitle(id, strTitle); PlCache.SetDescription(id, strDescription); PlCache.SetAuthor(id, strAuthor); m_model->SaveExportsToCache(PlCache, id, Exports); return true; }
void SetFormDeleteCallback(PluginHandle plugin, SKSESerializationInterface::FormDeleteCallback callback) { GetPluginInfo(plugin)->formDelete = callback; }
void SetLoadCallback(PluginHandle plugin, SKSESerializationInterface::EventCallback callback) { GetPluginInfo(plugin)->load = callback; }
void SetSaveCallback(PluginHandle plugin, SKSESerializationInterface::EventCallback callback) { GetPluginInfo(plugin)->save = callback; }
void SetRevertCallback(PluginHandle plugin, SKSESerializationInterface::EventCallback callback) { GetPluginInfo(plugin)->revert = callback; }
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; }
udPluginInfo udUmlGeneratorPlugin::GetInfo() { return GetPluginInfo(); }
MockCSIPlugin::MockCSIPlugin() { EXPECT_CALL(*this, GetPluginInfo(_, _, _)) .WillRepeatedly(Return(Status::OK)); // Enable all plugin capabilities by default for testing with the test CSI // plugin in forwarding mode. EXPECT_CALL(*this, GetPluginCapabilities(_, _, _)) .WillRepeatedly(Invoke([]( ServerContext* context, const csi::v0::GetPluginCapabilitiesRequest* request, csi::v0::GetPluginCapabilitiesResponse* response) { response->add_capabilities()->mutable_service()->set_type( csi::v0::PluginCapability::Service::CONTROLLER_SERVICE); return Status::OK; })); EXPECT_CALL(*this, Probe(_, _, _)) .WillRepeatedly(Return(Status::OK)); EXPECT_CALL(*this, CreateVolume(_, _, _)) .WillRepeatedly(Return(Status::OK)); EXPECT_CALL(*this, DeleteVolume(_, _, _)) .WillRepeatedly(Return(Status::OK)); EXPECT_CALL(*this, ControllerPublishVolume(_, _, _)) .WillRepeatedly(Return(Status::OK)); EXPECT_CALL(*this, ControllerUnpublishVolume(_, _, _)) .WillRepeatedly(Return(Status::OK)); EXPECT_CALL(*this, ValidateVolumeCapabilities(_, _, _)) .WillRepeatedly(Return(Status::OK)); EXPECT_CALL(*this, ListVolumes(_, _, _)) .WillRepeatedly(Return(Status::OK)); EXPECT_CALL(*this, GetCapacity(_, _, _)) .WillRepeatedly(Return(Status::OK)); // Enable all controller capabilities by default for testing with the test CSI // plugin in forwarding mode. EXPECT_CALL(*this, ControllerGetCapabilities(_, _, _)) .WillRepeatedly(Invoke([]( ServerContext* context, const csi::v0::ControllerGetCapabilitiesRequest* request, csi::v0::ControllerGetCapabilitiesResponse* response) { response->add_capabilities()->mutable_rpc()->set_type( csi::v0::ControllerServiceCapability::RPC::CREATE_DELETE_VOLUME); response->add_capabilities()->mutable_rpc()->set_type( csi::v0::ControllerServiceCapability::RPC::PUBLISH_UNPUBLISH_VOLUME); response->add_capabilities()->mutable_rpc()->set_type( csi::v0::ControllerServiceCapability::RPC::GET_CAPACITY); response->add_capabilities()->mutable_rpc()->set_type( csi::v0::ControllerServiceCapability::RPC::LIST_VOLUMES); return Status::OK; })); EXPECT_CALL(*this, NodeStageVolume(_, _, _)) .WillRepeatedly(Return(Status::OK)); EXPECT_CALL(*this, NodeUnstageVolume(_, _, _)) .WillRepeatedly(Return(Status::OK)); EXPECT_CALL(*this, NodePublishVolume(_, _, _)) .WillRepeatedly(Return(Status::OK)); EXPECT_CALL(*this, NodeUnpublishVolume(_, _, _)) .WillRepeatedly(Return(Status::OK)); EXPECT_CALL(*this, NodeGetId(_, _, _)) .WillRepeatedly(Return(Status::OK)); // Enable all node capabilities by default for testing with the test CSI // plugin in forwarding mode. EXPECT_CALL(*this, NodeGetCapabilities(_, _, _)) .WillRepeatedly(Invoke([]( ServerContext* context, const csi::v0::NodeGetCapabilitiesRequest* request, csi::v0::NodeGetCapabilitiesResponse* response) { response->add_capabilities()->mutable_rpc()->set_type( csi::v0::NodeServiceCapability::RPC::STAGE_UNSTAGE_VOLUME); return Status::OK; })); }
static LRESULT CALLBACK ToolbarParentWndProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { WNDPROC lpOldProc; PluginInfo *plugin; LPNMHDR lpnm; LPNMTOOLBAR lptb; lpOldProc = (WNDPROC)GetProp( hDlg, "oldproc" ); plugin = GetPluginInfo(hDlg); lpnm = (LPNMHDR) lParam; lptb = (LPNMTOOLBAR) lParam; switch(msg) { case WM_NOTIFY: { int nIndex; if (lpnm->code == TBN_BEGINADJUST) { nIndex = SendMessage(plugin->hToolbar, TB_COMMANDTOINDEX, IDC_PGPKEYS, 0); SendMessage(plugin->hToolbar, TB_DELETEBUTTON, nIndex, 0); plugin->nPGPKeysButton = -1; } if (lpnm->code == TBN_ENDADJUST) { TBBUTTON tbb[1]; HIMAGELIST hilToolbar; int nX; int nY; LRESULT lResult; lResult = CallWindowProc(lpOldProc, hDlg, msg, wParam, lParam); hilToolbar = (HIMAGELIST) SendMessage(plugin->hToolbar, TB_GETIMAGELIST, 0, 0); ImageList_GetIconSize(hilToolbar, &nX, &nY); if ((nX < 20) && !(plugin->bSmallIcons)) AddMainToolbarButtons(plugin); else if ((nX > 20) && plugin->bSmallIcons) AddMainToolbarButtons(plugin); else { tbb[0].iBitmap = plugin->nPGPKeysImage; tbb[0].idCommand = IDC_PGPKEYS; tbb[0].fsState = TBSTATE_ENABLED; tbb[0].fsStyle = TBSTYLE_BUTTON; tbb[0].dwData = 0; tbb[0].iString = plugin->nPGPKeysString; SendMessage(plugin->hToolbar, TB_ADDBUTTONS, 1, (LPARAM) &tbb); plugin->nPGPKeysButton = SendMessage(plugin->hToolbar, TB_COMMANDTOINDEX, IDC_PGPKEYS, 0); } return lResult; } break; } } return CallWindowProc(lpOldProc, hDlg, msg, wParam, lParam); }
LRESULT CALLBACK MainWndProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { WNDPROC lpOldProc; PluginInfo *plugin; lpOldProc = (WNDPROC)GetProp( hDlg, "oldproc" ); plugin = GetPluginInfo(hDlg); if (plugin != NULL) { if (msg == plugin->nPurgeCacheMsg) { PGPclPurgeCachedPassphrase(wParam); return TRUE; } } switch(msg) { case WM_SETTINGCHANGE: case WM_PALETTECHANGED: case WM_FONTCHANGE: case WM_SYSCOLORCHANGE: { HIMAGELIST hilToolbar; int nIndex; LRESULT lResult; lResult = CommonWndProc(hDlg, msg, wParam, lParam); nIndex = SendMessage(plugin->hToolbar, TB_COMMANDTOINDEX, IDC_PGPKEYS, 0); SendMessage(plugin->hToolbar, TB_DELETEBUTTON, nIndex, 0); plugin->nPGPKeysButton = -1; hilToolbar = (HIMAGELIST) SendMessage(plugin->hToolbar, TB_GETIMAGELIST, 0, 0); ImageList_Remove(hilToolbar, plugin->nPGPKeysImage); AddMainToolbarButtons(plugin); return lResult; } case WM_DESTROY: { KillTimer(hDlg, WATCH_TOOLBAR_TIMER); break; } case WM_PARENTNOTIFY: if (LOWORD(wParam) == WM_CREATE) CreateMainWindowGUI(hDlg, plugin); break; case WM_TIMER: if (wParam == WATCH_TOOLBAR_TIMER) { int nState; nState = SendMessage(plugin->hToolbar, TB_GETSTATE, IDC_PGPKEYS, 0); if (nState & TBSTATE_ENABLED) return 0; nState |= TBSTATE_ENABLED; SendMessage(plugin->hToolbar, TB_SETSTATE, IDC_PGPKEYS, MAKELONG(nState, 0)); return 0; } break; case WM_INITMENUPOPUP: { int nOptions; MENUITEMINFO menuInfo; char szOptions[256]; char szMenu[256]; LRESULT lResult; // For some reason, the old window proc disables the // menu items in the PGP popup menu. We'll enable // the items after the old proc disables them if ((HMENU) wParam == plugin->hPGPMenu) { lResult = CallWindowProc(lpOldProc, hDlg, msg, wParam, lParam); EnableMenuItem(plugin->hPGPMenu, IDC_PREFS, MF_BYCOMMAND | MF_ENABLED); EnableMenuItem(plugin->hPGPMenu, IDC_PGPKEYS, MF_BYCOMMAND | MF_ENABLED); return lResult; } else if (plugin->bOE5) { UIGetString(szOptions, 254, IDS_MENU_OEOPTIONS); nOptions = GetMenuItemCount((HMENU) wParam); menuInfo.cbSize = sizeof(MENUITEMINFO); menuInfo.fMask = MIIM_TYPE | MIIM_SUBMENU | MIIM_ID; menuInfo.dwTypeData = szMenu; menuInfo.cch = 255; GetMenuItemInfo((HMENU) wParam, nOptions - 1, TRUE, &menuInfo); if (!strcmp(szMenu, szOptions)) { lResult = CallWindowProc(lpOldProc, hDlg, msg, wParam, lParam); strcpy(szMenu, "&PGP"); menuInfo.cbSize = sizeof(MENUITEMINFO); menuInfo.fMask = MIIM_TYPE | MIIM_ID | MIIM_SUBMENU | MIIM_STATE; menuInfo.fType = MFT_STRING; menuInfo.fState = MFS_ENABLED; menuInfo.wID = IDC_PGPMENU; menuInfo.hSubMenu = plugin->hPGPMenu; menuInfo.dwTypeData = szMenu; InsertMenuItem((HMENU) wParam, nOptions, TRUE, &menuInfo); plugin->nPGPPosition = nOptions; return lResult; } else if (!strcmp(szMenu, "&PGP")) { lResult = CallWindowProc(lpOldProc, hDlg, msg, wParam, lParam); DestroyMenu(plugin->hPGPMenu); plugin->hPGPMenu = CreatePopupMenu(); UIGetString(szMenu, 254, IDS_MENU_PREFS); AppendMenu(plugin->hPGPMenu, MF_STRING, IDC_PREFS, szMenu); UIGetString(szMenu, 254, IDS_MENU_PGPKEYS); AppendMenu(plugin->hPGPMenu, MF_STRING, IDC_PGPKEYS, szMenu); menuInfo.cbSize = sizeof(MENUITEMINFO); menuInfo.fMask = MIIM_SUBMENU | MIIM_STATE; menuInfo.fState = MFS_ENABLED; menuInfo.hSubMenu = plugin->hPGPMenu; SetMenuItemInfo((HMENU) wParam, IDC_PGPMENU, FALSE, &menuInfo); menuInfo.fMask = MIIM_STATE; SetMenuItemInfo(plugin->hPGPMenu, IDC_PREFS, FALSE, &menuInfo); SetMenuItemInfo(plugin->hPGPMenu, IDC_PGPKEYS, FALSE, &menuInfo); return lResult; } } break; } } return CommonWndProc(hDlg, msg, wParam, lParam); }
//--------------------------------------------------------------------------- // tTVPSusiePlugin //--------------------------------------------------------------------------- tTVPSusiePlugin::tTVPSusiePlugin(HINSTANCE inst, const char *api) { ModuleInstance = inst; // get functions *(FARPROC*)&GetPluginInfo = GetProcAddress(inst, "GetPluginInfo"); *(FARPROC*)&IsSupported = GetProcAddress(inst, "IsSupported"); *(FARPROC*)&GetPicture = GetProcAddress(inst, "GetPicture"); *(FARPROC*)&GetArchiveInfo = GetProcAddress(inst, "GetArchiveInfo"); *(FARPROC*)&GetFile = GetProcAddress(inst, "GetFile"); if(!memcmp(api, "00IN", 4)) { if(!GetPluginInfo || !IsSupported || !GetPicture) TVPThrowExceptionMessage(TVPNotSusiePlugin); } else if(!memcmp(api, "00AM", 4)) { if(!GetPluginInfo || !IsSupported || !GetArchiveInfo || !GetFile) TVPThrowExceptionMessage(TVPNotSusiePlugin); } else { TVPThrowInternalError; } // check API version and dump copyright information char buffer[256]; char buffer2[256]; if(GetPluginInfo(0, buffer, 255) >= 4) { if(memcmp(buffer, api, 4)) TVPThrowExceptionMessage(TVPNotSusiePlugin); } else { TVPThrowExceptionMessage(TVPNotSusiePlugin); } memset(buffer, 0, 256); GetPluginInfo(1, buffer, 255); if(buffer[0]) TVPAddImportantLog(TJS_W("(info) Susie plugin info : ") + ttstr(buffer)); // retrieve format information tjs_int i; for(i = 0; ; i++) { int r = GetPluginInfo(2*i + 2, buffer, 255); if(r == 0) break; buffer[255] = 0; // here buffer contains exetension information such as "*.JPG" "*.RGB;*.Q0" strlwr(buffer); // split buffer to each extensions char *p = buffer; while((p = strstr(p, "*.")) != NULL) { p++; char *b2 = buffer2; while(*p && *p != ' ' && *p != ';') { *b2 = *p; b2++; p++; } *b2 = 0; Extensions.push_back(ttstr(buffer2)); } } };
int PluginLoop(void *) { PLUGIN_INFO("thread started"); g_plugin->OnThreadEntry(); unsigned int last_time = Base::Time::GetTimeMs(); while(g_running) { Notification notif; if(GetNotification(¬if, g_plugin->IdleDt())) { // PLUGIN_INFO("notification received: %d.", notif.type); g_plugin->OnNotification(notif); switch(notif.type) { case kShutdown: g_plugin->OnShutdown(notif.content.shutdown); g_running = false; break; case kWatch: { PluginInfo info; if(0 == GetPluginInfo(notif.content.watch.plugin, &info)) { PLUGIN_INFO("watch plugin match %s(%s) for %p", info.name, info.version, notif.content.watch.handle); } else { PLUGIN_WARN("unknown plugin match for %p", notif.content.connection.endpoint); } g_plugin->OnWatchMatch(notif.content.watch); break; } case kConfigChanged: g_plugin->OnConfigChange(notif.content.config); break; case kEstablished: { PluginInfo info; if(0 == GetPluginInfo(notif.content.connection.endpoint, &info)) { PLUGIN_INFO("connected to %s(%s)", info.name, info.version); } else { PLUGIN_WARN("connected to unknown plugin %p", notif.content.connection.endpoint); } g_plugin->OnConnected(notif.content.connection); break; } case kConnected: { PluginInfo info; if(0 == GetPluginInfo(notif.content.connection.endpoint, &info)) { PLUGIN_INFO("plugin connected %s(%s)", info.name, info.version); } else { PLUGIN_WARN("unknown plugin connected %p", notif.content.connection.endpoint); } g_plugin->OnPluginConnected(notif.content.connection); break; } case kDisconnected: PluginInfo info; if(0 == GetPluginInfo(notif.content.connection.endpoint, &info)) { PLUGIN_INFO("plugin disconnected %s(%s)", info.name, info.version); } else { PLUGIN_WARN("unknown plugin disconnected %p", notif.content.connection.endpoint); } g_plugin->OnDisconnected(notif.content.connection); break; case kRecvReady: g_plugin->OnRecvReady(notif.content.connection); default: break; } } unsigned int now = Base::Time::GetTimeMs(); unsigned int dt = now - last_time; g_plugin->OnUpdate(dt); last_time = now; } g_plugin->OnThreadExit(); PLUGIN_INFO("thread exiting"); return 0; }