// ----------------------------------------------------------------------------- // ServiceDisabledL // ----------------------------------------------------------------------------- // void CCCEPluginManager::ServiceDisabledL( TUid aImplementationUid ) { CCELOGSTRING("CCCEPluginManager::ServiceDisabledL" ); CCCEPlugin* plugin( NULL ); for( TInt i=0; i<iPluginArray.Count(); i++ ) { TUid oldPlugin = iPluginArray[i]->Type(); if( oldPlugin.iUid == aImplementationUid.iUid ) { plugin = iPluginArray[i]; i = iPluginArray.Count(); } } if( !plugin ) { CCELOGSTRING("CCCEPluginManager:: No plugin found" ); User::Leave( KErrNotFound ); } else if( iCallContainer.CountCalls( aImplementationUid ) ) { CCELOGSTRING("CCCEPluginManager:: Plugin found with ongoing calls" ); plugin->SetReleaseWhenIdle( ETrue ); } else { CCELOGSTRING("CCCEPluginManager:: Plugin found" ); plugin->SetReleaseWhenIdle( ETrue ); RemovePlugin( aImplementationUid ); } }
void cPluginManager::UnloadPluginsNow() { m_Hooks.clear(); while (!m_Plugins.empty()) { RemovePlugin(m_Plugins.begin()->second); } m_Commands.clear(); m_ConsoleCommands.clear(); }
bool cPluginManager::AddPlugin(cPlugin * a_Plugin) { m_Plugins[a_Plugin->GetDirectory()] = a_Plugin; if (a_Plugin->Initialize()) { // Initialization OK return true; } // Initialization failed RemovePlugin(a_Plugin); // Also undoes any registrations that Initialize() might have made return false; }
void LDesktopPluginSpace::addDesktopPlugin(QString plugID){ //This is used for generic plugins (QWidget-based) if(DEBUG){ qDebug() << "Adding Desktop Plugin:" << plugID; } LDPlugin *plug = NewDP::createPlugin(plugID, this); if(plug==0){ return; } //invalid plugin //plug->setAttribute(Qt::WA_TranslucentBackground); plug->setWhatsThis(plugID); //Now get the saved geometry for the plugin QRect geom = plug->gridGeometry(); //grid coordinates if(geom.isNull()){ //Try the old format (might be slight drift between sessions if the grid size changes) geom = plug->loadPluginGeometry(); //in pixel coords if(!geom.isNull()){ geom = geomToGrid(geom); } //convert to grid coordinates } if(DEBUG){ qDebug() << "Saved plugin geom:" << geom << plugID; } //Now determine the position to put it if(geom.isNull()){ //No previous location - need to calculate initial geom QSize sz = plug->defaultPluginSize(); //in grid coordinates geom.setSize(sz); //if an applauncher - add from top-left, otherwise add in from bottom-right if(plugID.startsWith("applauncher")){ geom = findOpenSpot(geom.width(), geom.height() ); } else{ geom = findOpenSpot(geom.width(), geom.height(), RoundUp(this->height()/GRIDSIZE), RoundUp(this->width()/GRIDSIZE), true); } }else if(!ValidGeometry(plugID, gridToGeom(geom)) ){ //Find a new location for the plugin (saved location is invalid) geom = findOpenSpot(geom.width(), geom.height(), geom.y(), geom.x(), false); //try to get it within the same general area first } if(geom.x() < 0 || geom.y() < 0){ qDebug() << "No available space for desktop plugin:" << plugID << " - IGNORING"; delete plug; }else{ if(DEBUG){ qDebug() << " - New Plugin Geometry (grid):" << geom; } //Now place the item in the proper spot/size plug->setGridGeometry(geom); //save for later MovePlugin(plug, gridToGeom(geom)); //plug->setGeometry( gridToGeom(geom) ); plug->show(); if(DEBUG){ qDebug() << " - New Plugin Geometry (px):" << plug->geometry(); } ITEMS << plug; connect(plug, SIGNAL(StartMoving(QString)), this, SLOT(StartItemMove(QString)) ); connect(plug, SIGNAL(StartResizing(QString)), this, SLOT(StartItemResize(QString)) ); connect(plug, SIGNAL(RemovePlugin(QString)), this, SLOT(RemoveItem(QString)) ); connect(plug, SIGNAL(IncreaseIconSize()), this, SIGNAL(IncreaseIcons()) ); connect(plug, SIGNAL(DecreaseIconSize()), this, SIGNAL(DecreaseIcons()) ); connect(plug, SIGNAL(CloseDesktopMenu()), this, SIGNAL(HideDesktopMenu()) ); } }
void cPluginManager::Tick(float a_Dt) { while (!m_DisablePluginList.empty()) { RemovePlugin(m_DisablePluginList.front()); m_DisablePluginList.pop_front(); } if (m_bReloadPlugins) { ReloadPluginsNow(); } HookMap::iterator Plugins = m_Hooks.find(HOOK_TICK); if (Plugins != m_Hooks.end()) { for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { (*itr)->Tick(a_Dt); } } }
void LDesktopPluginSpace::addDesktopPlugin(QString plugID){ //This is used for generic plugins (QWidget-based) if(DEBUG){ qDebug() << "Adding Desktop Plugin:" << plugID; } LDPlugin *plug = NewDP::createPlugin(plugID, this); plug->setWhatsThis(plugID); //Now get the geometry for the plugin QRect geom = plug->loadPluginGeometry(); //in pixel coords if(!geom.isNull()){ geom = geomToGrid(geom); } //convert to grid coordinates if(geom.isNull()){ //No previous location - need to calculate initial geom QSize sz = plug->defaultPluginSize(); //in grid coordinates geom.setSize(sz); geom = findOpenSpot(geom.width(), geom.height() ); }else if(!ValidGeometry(plugID, gridToGeom(geom)) ){ //Find a new location for the plugin (saved location is invalid) geom = findOpenSpot(geom.width(), geom.height(), geom.y(), geom.x(), false); //try to get it within the same general area first } if(geom.x() < 0 || geom.y() < 0){ qDebug() << "No available space for desktop plugin:" << plugID << " - IGNORING"; delete plug; }else{ if(DEBUG){ qDebug() << " - New Plugin Geometry (grid):" << geom; } //Now place the item in the proper spot/size MovePlugin(plug, gridToGeom(geom)); //plug->setGeometry( gridToGeom(geom) ); plug->show(); if(DEBUG){ qDebug() << " - New Plugin Geometry (px):" << plug->geometry(); } ITEMS << plug; connect(plug, SIGNAL(StartMoving(QString)), this, SLOT(StartItemMove(QString)) ); connect(plug, SIGNAL(StartResizing(QString)), this, SLOT(StartItemResize(QString)) ); connect(plug, SIGNAL(RemovePlugin(QString)), this, SLOT(RemoveItem(QString)) ); connect(plug, SIGNAL(IncreaseIconSize()), this, SIGNAL(IncreaseIcons()) ); connect(plug, SIGNAL(DecreaseIconSize()), this, SIGNAL(DecreaseIcons()) ); connect(plug, SIGNAL(CloseDesktopMenu()), this, SIGNAL(HideDesktopMenu()) ); } }
void Application::UnloadPlugin( PluginPtr plugin ) { if ( plugin ) { RemovePlugin( plugin ); plugin->Terminate(); // Unload the DLL the plugin was loaded from. DynamicLibPtr ptrLib = m_DynamicLibSubsystem->GetLibrary( plugin->FileName ); if ( ptrLib ) { DestroyPluginFP destroyPluginFunc = (DestroyPluginFP)ptrLib->GetSymbol( "DestroyPlugin" ); if ( destroyPluginFunc != NULL ) { // Unload the plugin and all of the types that are associated with the plugin. destroyPluginFunc(); } else { std::cerr << "Application::UnloadPlugin: Could not find \"DestroyPlugin\" method in library \""; std::wcerr << ptrLib->FileName.get(); std::cerr << "\"" << std::endl; } // Don't forget to call DynamicLibSubsystem::Flush to actually // release the libraries from memory. m_DynamicLibSubsystem->Unload( ptrLib ); } else { std::cerr << "Application::UnloadPlugin: Could not find library with filename: \""; std::wcerr << plugin->FileName.get(); std::cerr << "\"" << std::endl; } } }
foreach(PluginsListIter, i, m_Plugins) { RemovePlugin(*i); }
BOOL OpenThemeClass(HWND hwnd, char szFilename[], CBZDATA * pCBZData, char szClassName[]) { PLUGIN_LIST List; char szError[128], tempText[64]; int i, i2, index; HWND hwndControl; PAPPLYFN pApplyFn; if (!runParser(szFilename, szClassName, &List, szError)) { PSUTErrorFunc(NULLHANDLE, "Error", "OpenThemeClass", szError, 0UL); return FALSE; } //Clear the current selected plugins by placing them back into the // AvailablePlugins ListBox hwndControl = WinWindowFromID(hwnd, LBID_SELECTEDPLUGINS); index = (SHORT) WinSendMsg(hwndControl, LM_QUERYITEMCOUNT, MPFROMLONG(0), MPFROMLONG(0)); for (i = 0; i < index; i++) { hwndControl = WinWindowFromID(hwnd, LBID_SELECTEDPLUGINS); //Save the text so it can be added to Available Plugin Listbox WinSendMsg(hwndControl, LM_QUERYITEMTEXT, MPFROM2SHORT((SHORT) 0, 64), MPFROMP((PSZ) tempText)); //remove item from Selected Plugin ListBox WinSendMsg(hwndControl, LM_DELETEITEM, MPFROMSHORT((SHORT) 0), MPFROMLONG(0)); //Add the item to the Available Plugins ListBox hwndControl = WinWindowFromID(hwnd, LBID_AVAILABLEPLUGINS); i2 = (SHORT) WinSendMsg(hwndControl, LM_INSERTITEM, MPFROMSHORT((SHORT) LIT_SORTASCENDING), MPFROMP((PSZ) tempText)); //Add the dll name to the AvailablePluginsDLL ListBox at the correct index strcpy(tempText, pCBZData->Plugins[0].szPluginDLL); hwndControl = WinWindowFromID(hwnd, LBID_AVAILABLEPLUGINDLLS); WinSendMsg(hwndControl, LM_INSERTITEM, MPFROMSHORT((SHORT) i2), MPFROMP((PSZ) tempText)); //remove the plugin from the pTBData structure if (!RemovePlugin(pCBZData, 0)) { PSUTErrorFunc(hwnd, "Error", "OpenThemeClass", "Error Removing Plugin!", 0UL); //Put it back in Selected Plugin ListBox? break; } } //Try selecting each plugin from the themeFile out of the AvailablePlugins ListBox for (i = 0; i < List.cbPlugins; i++) { hwndControl = WinWindowFromID(hwnd, LBID_AVAILABLEPLUGINDLLS); //find the index of the plugin in the AvailablePlugins ListBox index = (SHORT) WinSendMsg(hwndControl, LM_SEARCHSTRING, MPFROM2SHORT(LSS_CASESENSITIVE, LIT_FIRST), MPFROMP(List.pPluginAttributes[i].szPluginName)); if (index == LIT_NONE) //Plugin not found { PSUTErrorFunc(hwnd, "Error", "OpenThemeClass - Plugin Not Found", List.pPluginAttributes[i].szPluginName, 0UL); break; } hwndControl = WinWindowFromID(hwnd, LBID_AVAILABLEPLUGINS); //Get the text from the Available Plugin ListBox WinSendMsg(hwndControl, LM_QUERYITEMTEXT, MPFROM2SHORT((SHORT) index, 64), MPFROMP((PSZ) tempText)); //remove the selected item from the Available Plugins ListBox WinSendMsg(hwndControl, LM_DELETEITEM, MPFROMSHORT((SHORT) index), MPFROMLONG(0)); //Add the queried text to the Selected Plugin ListBox hwndControl = WinWindowFromID(hwnd, LBID_SELECTEDPLUGINS); i2 = (SHORT) WinSendMsg(hwndControl, LM_INSERTITEM, MPFROMSHORT((SHORT) LIT_END), MPFROMP((PSZ) tempText)); //Get the selected plugin DLL name from the AvailablePluginDLLS listbox hwndControl = WinWindowFromID(hwnd, LBID_AVAILABLEPLUGINDLLS); WinSendMsg(hwndControl, LM_QUERYITEMTEXT, MPFROM2SHORT((SHORT) index, 64), MPFROMP((PSZ) tempText)); //remove it from the AvailablePluginDLLS listbox WinSendMsg(hwndControl, LM_DELETEITEM, MPFROMSHORT((SHORT) index), MPFROMLONG(0)); if (!AddPlugin(hwnd, pCBZData, List.pPluginAttributes[i].szPluginName, "")) { //Error in AddPlugin... Put the plugin back into AvailableListbox? DosBeep(500, 50); } if (DosQueryProcAddr(pCBZData->Plugins[pCBZData->cbPlugins - 1].hModDll, 0, "CBZApply", (PFN *) & pApplyFn) == NO_ERROR) { //check return code from this to make sure it was sucessful.. if not disable the plugin pApplyFn(szClassName, (List.pPluginAttributes[i].keyValue), List.pPluginAttributes[i].cbAttributes, List.pPluginAttributes[i].enabledState, pCBZData->Plugins[i].pData); } else { PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "Failed Querying Procedure Address for CBZApply", 0UL); } } CBZFreePLUGIN_LIST(&List); return TRUE; }
void AppLauncherPlugin::loadButton(){ QString def = this->ID().section("::",1,50).section("---",0,0).simplified(); QString path = this->readSetting("applicationpath",def).toString(); //use the default if necessary //qDebug() << "Default Application Launcher:" << def << path; bool ok = QFile::exists(path); if(!ok){ emit RemovePlugin(this->ID()); return;} int icosize = this->height()-4 - 2.2*button->fontMetrics().height(); button->setFixedSize( this->width()-4, this->height()-4); button->setIconSize( QSize(icosize,icosize) ); QString txt; if(path.endsWith(".desktop") && ok){ XDGDesktop file = LXDG::loadDesktopFile(path, ok); if(path.isEmpty() || !QFile::exists(path) || !ok){ button->setWhatsThis(""); button->setIcon( QIcon(LXDG::findIcon("quickopen-file","").pixmap(QSize(icosize,icosize)).scaledToHeight(icosize, Qt::SmoothTransformation) ) ); txt = tr("Click to Set"); if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); } }else{ button->setWhatsThis(file.filePath); button->setIcon( QIcon(LXDG::findIcon(file.icon,"quickopen").pixmap(QSize(icosize,icosize)).scaledToHeight(icosize, Qt::SmoothTransformation) ) ); txt = file.name; if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); } watcher->addPath(file.filePath); //make sure to update this shortcut if the file changes } }else if(ok){ QFileInfo info(path); button->setWhatsThis(info.absoluteFilePath()); if(info.isDir()){ button->setIcon( LXDG::findIcon("folder","") ); }else if(LUtils::imageExtensions().contains(info.suffix().toLower()) ){ button->setIcon( QIcon(QPixmap(path).scaled(256,256)) ); //max size for thumbnails in memory }else{ button->setIcon( QIcon(LXDG::findMimeIcon(path).pixmap(QSize(icosize,icosize)).scaledToHeight(icosize, Qt::SmoothTransformation) ) ); } txt = info.fileName(); if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); } watcher->addPath(path); //make sure to update this shortcut if the file changes }else{ //InValid File button->setWhatsThis(""); button->setIcon( QIcon(LXDG::findIcon("quickopen","").pixmap(QSize(icosize,icosize)).scaledToHeight(icosize, Qt::SmoothTransformation) ) ); button->setText( tr("Click to Set") ); if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); } } //If the file is a symlink, put the overlay on the icon if(QFileInfo(path).isSymLink()){ QImage img = button->icon().pixmap(QSize(icosize,icosize)).toImage(); int oSize = icosize/3; //overlay size QPixmap overlay = LXDG::findIcon("emblem-symbolic-link").pixmap(oSize,oSize).scaled(oSize,oSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); QPainter painter(&img); painter.drawPixmap(icosize-oSize,icosize-oSize,overlay); //put it in the bottom-right corner button->setIcon( QIcon(QPixmap::fromImage(img)) ); } //Now adjust the visible text as necessary based on font/grid sizing button->setToolTip(txt); //Double check that the visual icon size matches the requested size - otherwise upscale the icon if(button->fontMetrics().width(txt) > (button->width()-OUTMARGIN) ){ //Text too long, try to show it on two lines //txt = button->fontMetrics().elidedText(txt, Qt::ElideRight, 2*(button->width()-OUTMARGIN), Qt::TextWordWrap); txt =txt.section(" ",0,2).replace(" ","\n"); //First take care of any natural breaks //Go through and combine any lines if(txt.contains("\n")){ //need to check each line QStringList txtL = txt.split("\n"); for(int i=0; i<txtL.length(); i++){ if(( i+1<txtL.length()) && (button->fontMetrics().width(txtL[i]) < button->width()/2) ){ txtL[i] = txtL[i]+" "+txtL[i+1]; txtL.removeAt(i+1); } } txt = txtL.join("\n").section("\n",0,2); } if(txt.contains("\n")){ //need to check each line QStringList txtL = txt.split("\n"); for(int i=0; i<txtL.length(); i++){ if(i>1){ txtL.removeAt(i); i--; } //Only take the first two lines else{ txtL[i] = button->fontMetrics().elidedText(txtL[i], Qt::ElideRight, (button->width()-OUTMARGIN) ); } } txt = txtL.join("\n"); }else{ txt = this->fontMetrics().elidedText(txt,Qt::ElideRight, 2*(button->width()-OUTMARGIN)); //Now split the line in half for the two lines txt.insert( ((txt.count())/2), "\n"); } } if(!txt.contains("\n")){ txt.append("\n "); } //always use two lines //qDebug() << " - Setting Button Text:" << txt; button->setText(txt); QTimer::singleShot(100, this, SLOT(update()) ); //Make sure to re-draw the image in a moment }