Skip to content
Permalink
Browse files

[FEATURE] Applied patch #2541 - initial implementing the canBeUninsta…

…lled python plugin method

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13050 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
borysiasty
borysiasty committed Mar 12, 2010
1 parent 3f77549 commit 62c4b422c54e12364e1f499cc4f94c58fee23bc5
@@ -161,6 +161,22 @@ def startPlugin(packageName):
return True


def canUninstallPlugin(packageName):
""" confirm that the plugin can be uninstalled """
global plugins, active_plugins

if not plugins.has_key(packageName): return False
if packageName not in active_plugins: return False

try:
metadata = plugins[packageName]
if "canBeUninstalled" not in dir(metadata):
return True
return bool(metadata.canBeUninstalled())
except:
return False


def unloadPlugin(packageName):
""" unload and delete plugin! """
global plugins, active_plugins
@@ -407,9 +407,12 @@ void QgsPluginManager::unload()
{
if ( mPythonUtils && mPythonUtils->isEnabled() )
{
mPythonUtils->unloadPlugin( baseName );
//disable it to the qsettings file
settings.setValue( "/PythonPlugins/" + baseName, false );
if( mPythonUtils->canUninstallPlugin( baseName ) )
{
mPythonUtils->unloadPlugin( baseName );
//disable it to the qsettings file
settings.setValue( "/PythonPlugins/" + baseName, false );
}
}
}
else // C++ plugin
@@ -81,6 +81,9 @@ class PYTHON_EXPORT QgsPythonUtils
//! @param function one of these strings: name, tpye, version, description
virtual QString getPluginMetadata( QString pluginName, QString function ) = 0;

//! confirm that the plugin can be uninstalled
virtual bool canUninstallPlugin( QString packageName ) = 0;

//! unload plugin
virtual bool unloadPlugin( QString packageName ) = 0;
};
@@ -406,22 +406,26 @@ QString QgsPythonUtilsImpl::getPluginMetadata( QString pluginName, QString funct
return res;
}


bool QgsPythonUtilsImpl::loadPlugin( QString packageName )
{
QString output;
evalString( "qgis.utils.loadPlugin('" + packageName + "')", output );
return ( output == "True" );
}


bool QgsPythonUtilsImpl::startPlugin( QString packageName )
{
QString output;
evalString( "qgis.utils.startPlugin('" + packageName + "')", output );
return ( output == "True" );
}

bool QgsPythonUtilsImpl::canUninstallPlugin( QString packageName )
{
QString output;
evalString( "qgis.utils.canUninstallPlugin('" + packageName + "')", output );
return ( output == "True" );
}

bool QgsPythonUtilsImpl::unloadPlugin( QString packageName )
{
@@ -98,6 +98,9 @@ class QgsPythonUtilsImpl : public QgsPythonUtils
//! @param function one of these strings: name, tpye, version, description
QString getPluginMetadata( QString pluginName, QString function );

//! confirm it is safe to uninstall the plugin
bool canUninstallPlugin( QString packageName );

//! unload plugin
bool unloadPlugin( QString packageName );

0 comments on commit 62c4b42

Please sign in to comment.
You can’t perform that action at this time.