737 changes: 0 additions & 737 deletions python/plugins/plugin_installer/installer_data.py

This file was deleted.

949 changes: 0 additions & 949 deletions python/plugins/plugin_installer/installer_gui.py

This file was deleted.

192 changes: 0 additions & 192 deletions python/plugins/plugin_installer/installer_plugin.py

This file was deleted.

13 changes: 0 additions & 13 deletions python/plugins/plugin_installer/metadata.txt

This file was deleted.

Binary file not shown.
Binary file removed python/plugins/plugin_installer/pluginStable.png
Binary file not shown.
Binary file removed python/plugins/plugin_installer/plugin_installer.png
Binary file not shown.
Binary file removed python/plugins/plugin_installer/qgis-icon.png
Binary file not shown.
694 changes: 0 additions & 694 deletions python/plugins/plugin_installer/qgsplugininstallerbase.ui

This file was deleted.

200 changes: 0 additions & 200 deletions python/plugins/plugin_installer/qgsplugininstallerfetchingbase.ui

This file was deleted.

124 changes: 0 additions & 124 deletions python/plugins/plugin_installer/qgsplugininstallerinstallingbase.ui

This file was deleted.

120 changes: 0 additions & 120 deletions python/plugins/plugin_installer/qgsplugininstalleroldreposbase.ui

This file was deleted.

155 changes: 0 additions & 155 deletions python/plugins/plugin_installer/qgsplugininstallerpluginerrorbase.ui

This file was deleted.

243 changes: 0 additions & 243 deletions python/plugins/plugin_installer/qgsplugininstallerrepositorybase.ui

This file was deleted.

Binary file removed python/plugins/plugin_installer/repoConnected.png
Binary file not shown.
Binary file removed python/plugins/plugin_installer/repoDisabled.png
Binary file not shown.
Binary file removed python/plugins/plugin_installer/repoUnavailable.png
Binary file not shown.
11 changes: 0 additions & 11 deletions python/plugins/plugin_installer/resources.qrc

This file was deleted.

89 changes: 0 additions & 89 deletions python/plugins/plugin_installer/unzip.py

This file was deleted.

140 changes: 0 additions & 140 deletions python/plugins/plugin_installer/version_compare.py

This file was deleted.

208 changes: 112 additions & 96 deletions src/app/qgspluginregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ QgisPlugin *QgsPluginRegistry::plugin( QString key )
{
QMap<QString, QgsPluginMetadata>::iterator it = mPlugins.find( key );
if ( it == mPlugins.end() )
return 0;
return NULL;

// note: not used by python plugins

Expand All @@ -109,7 +109,12 @@ QgisPlugin *QgsPluginRegistry::plugin( QString key )

bool QgsPluginRegistry::isPythonPlugin( QString key )
{
return mPythonUtils && mPythonUtils->isEnabled() && mPythonUtils->isPluginLoaded( key );
if ( mPythonUtils && mPythonUtils->isEnabled() )
{
if ( mPythonUtils->isPluginLoaded( key ) )
return true;
}
return false;
}

void QgsPluginRegistry::addPlugin( QString key, QgsPluginMetadata metadata )
Expand Down Expand Up @@ -267,20 +272,30 @@ void QgsPluginRegistry::loadPythonPlugin( QString packageName )

void QgsPluginRegistry::loadCppPlugin( QString theFullPathName )
{
// first check to see if its already loaded
QSettings settings;

QString baseName = QFileInfo( theFullPathName ).baseName();

// first check to see if its already loaded
if ( isLoaded( baseName ) )
{
// plugin is loaded
// QMessageBox::warning(this, "Already Loaded", description + " is already loaded");
return;
}

QLibrary myLib( theFullPathName );
if ( !myLib.load() )

QString myError; //we will only show detailed diagnostics if something went wrong
myError += QObject::tr( "Library name is %1\n" ).arg( myLib.fileName() );

bool loaded = myLib.load();
if ( !loaded )
{
QgsMessageLog::logMessage( QObject::tr( "Failed to load %1 (Reason: %2)" ).arg( myLib.fileName() ).arg( myLib.errorString() ), QObject::tr( "Plugins" ) );
return;
}

QString myError( QObject::tr( "Library name is %1\n" ).arg( myLib.fileName() ) );

myError += QObject::tr( "Attempting to resolve the classFactory function\n" );

type_t *pType = ( type_t * ) cast_to_fptr( myLib.resolve( "type" ) );
Expand All @@ -294,57 +309,59 @@ void QgsPluginRegistry::loadCppPlugin( QString theFullPathName )
{
// UI only -- doesn't use mapcanvas
create_ui *cf = ( create_ui * ) cast_to_fptr( myLib.resolve( "classFactory" ) );
if ( !cf )
{
QgsMessageLog::logMessage( QObject::tr( "Unable to find the class factory for %1." ).arg( theFullPathName ), QObject::tr( "Plugins" ) );
break;
}

QSettings settings;
QgisPlugin *pl = cf( mQgisInterface );
if ( !pl )
{
// something went wrong
QMessageBox::warning( mQgisInterface->mainWindow(), QObject::tr( "Error Loading Plugin" ),
QObject::tr( "There was an error loading a plugin."
"The following diagnostic information may help the QGIS developers resolve the issue:\n%1." )
.arg( myError ) );
//disable it to the qsettings file [ts]
settings.setValue( "/Plugins/" + baseName, false );
break;
}

pl->initGui();
// add it to the plugin registry
addPlugin( baseName, QgsPluginMetadata( myLib.fileName(), pName(), pl ) );
//add it to the qsettings file [ts]
settings.setValue( "/Plugins/" + baseName, true );
QgsMessageLog::logMessage( QObject::tr( "Loaded %1 (Path: %2)" ).arg( pName() ).arg( myLib.fileName() ), QObject::tr( "Plugins" ), QgsMessageLog::INFO );

QObject *o = dynamic_cast<QObject *>( pl );
if ( !o )
break;

QgsDebugMsg( QString( "plugin object name: %1" ).arg( o->objectName() ) );
if ( o->objectName().isEmpty() )
if ( cf )
{
QgisPlugin *pl = cf( mQgisInterface );
if ( pl )
{
pl->initGui();
// add it to the plugin registry
addPlugin( baseName, QgsPluginMetadata( myLib.fileName(), pName(), pl ) );
//add it to the qsettings file [ts]
settings.setValue( "/Plugins/" + baseName, true );
QgsMessageLog::logMessage( QObject::tr( "Loaded %1 (Path: %2)" ).arg( pName() ).arg( myLib.fileName() ), QObject::tr( "Plugins" ), QgsMessageLog::INFO );

QObject *o = dynamic_cast<QObject *>( pl );
if ( o )
{
QgsDebugMsg( QString( "plugin object name: %1" ).arg( o->objectName() ) );
if ( o->objectName().isEmpty() )
{
#ifndef WIN32
baseName = baseName.mid( 3 );
baseName = baseName.mid( 3 );
#endif
QgsDebugMsg( QString( "object name to %1" ).arg( baseName ) );
o->setObjectName( QString( "qgis_plugin_%1" ).arg( baseName ) );
QgsDebugMsg( QString( "plugin object name now: %1" ).arg( o->objectName() ) );
}

if ( !o->parent() )
{
QgsDebugMsg( QString( "setting plugin parent" ) );
o->setParent( QgisApp::instance() );
QgsDebugMsg( QString( "object name to %1" ).arg( baseName ) );
o->setObjectName( QString( "qgis_plugin_%1" ).arg( baseName ) );
QgsDebugMsg( QString( "plugin object name now: %1" ).arg( o->objectName() ) );
}

if ( !o->parent() )
{
QgsDebugMsg( QString( "setting plugin parent" ) );
o->setParent( QgisApp::instance() );
}
else
{
QgsDebugMsg( QString( "plugin parent already set" ) );
}
}
}
else
{
// something went wrong
QMessageBox::warning( mQgisInterface->mainWindow(), QObject::tr( "Error Loading Plugin" ),
QObject::tr( "There was an error loading a plugin."
"The following diagnostic information may help the QGIS developers resolve the issue:\n%1." )
.arg( myError ) );
//disable it to the qsettings file [ts]
settings.setValue( "/Plugins/" + baseName, false );
}
}
else
{
QgsDebugMsg( QString( "plugin parent already set" ) );
QgsMessageLog::logMessage( QObject::tr( "Unable to find the class factory for %1." ).arg( theFullPathName ), QObject::tr( "Plugins" ) );
}

}
break;
default:
Expand Down Expand Up @@ -434,64 +451,62 @@ void QgsPluginRegistry::restoreSessionPlugins( QString thePluginDirString )
}
}

if ( !mPythonUtils || !mPythonUtils->isEnabled() )
return;

// check for python plugins system-wide
QStringList pluginList = mPythonUtils->pluginList();
QgsDebugMsg( "Loading python plugins" );

QStringList corePlugins = QStringList();
corePlugins << "plugin_installer";
corePlugins << "fTools";
corePlugins << "GdalTools";
corePlugins << "db_manager";

// make the required core plugins enabled by default:
for ( int i = 0; i < corePlugins.size(); i++ )
if ( mPythonUtils && mPythonUtils->isEnabled() )
{
if ( !mySettings.contains( "/PythonPlugins/" + corePlugins[i] ) )
{
mySettings.setValue( "/PythonPlugins/" + corePlugins[i], true );
}
}
// check for python plugins system-wide
QStringList pluginList = mPythonUtils->pluginList();
QgsDebugMsg( "Loading python plugins" );

for ( int i = 0; i < pluginList.size(); i++ )
{
QString packageName = pluginList[i];
QStringList corePlugins = QStringList();
corePlugins << "fTools";
corePlugins << "GdalTools";
corePlugins << "db_manager";

// TODO: apply better solution for #5879
// start - temporary fix for issue #5879
if ( QgsApplication::isRunningFromBuildDir() )
// make the required core plugins enabled by default:
for ( int i = 0; i < corePlugins.size(); i++ )
{
if ( corePlugins.contains( packageName ) )
if ( !mySettings.contains( "/PythonPlugins/" + corePlugins[i] ) )
{
QgsApplication::setPkgDataPath( QString( "" ) );
}
else
{
QgsApplication::setPkgDataPath( QgsApplication::buildSourcePath() );
mySettings.setValue( "/PythonPlugins/" + corePlugins[i], true );
}
}
// end - temporary fix for issue #5879, more below

if ( checkPythonPlugin( packageName ) )
for ( int i = 0; i < pluginList.size(); i++ )
{
// check if the plugin was active on last session
QString packageName = pluginList[i];

if ( mySettings.value( "/PythonPlugins/" + packageName ).toBool() )
// TODO: apply better solution for #5879
// start - temporary fix for issue #5879
if ( QgsApplication::isRunningFromBuildDir() )
{
loadPythonPlugin( packageName );
if ( corePlugins.contains( packageName ) )
{
QgsApplication::setPkgDataPath( QString( "" ) );
}
else
{
QgsApplication::setPkgDataPath( QgsApplication::buildSourcePath() );
}
}
}
}
// end - temporary fix for issue #5879, more below

// start - temporary fix for issue #5879, more above
if ( QgsApplication::isRunningFromBuildDir() )
{
QgsApplication::setPkgDataPath( QgsApplication::buildSourcePath() );
if ( checkPythonPlugin( packageName ) )
{
// check if the plugin was active on last session

if ( mySettings.value( "/PythonPlugins/" + packageName ).toBool() )
{
loadPythonPlugin( packageName );
}
}
}
// start - temporary fix for issue #5879, more above
if ( QgsApplication::isRunningFromBuildDir() )
{
QgsApplication::setPkgDataPath( QgsApplication::buildSourcePath() );
}
// end - temporary fix for issue #5879
}
// end - temporary fix for issue #5879

QgsDebugMsg( "Plugin loading completed" );
}
Expand All @@ -500,7 +515,8 @@ void QgsPluginRegistry::restoreSessionPlugins( QString thePluginDirString )
bool QgsPluginRegistry::checkCppPlugin( QString pluginFullPath )
{
QLibrary myLib( pluginFullPath );
if ( !myLib.load() )
bool loaded = myLib.load();
if ( ! loaded )
{
QgsMessageLog::logMessage( QObject::tr( "Failed to load %1 (Reason: %2)" ).arg( myLib.fileName() ).arg( myLib.errorString() ), QObject::tr( "Plugins" ) );
return false;
Expand All @@ -511,7 +527,7 @@ bool QgsPluginRegistry::checkCppPlugin( QString pluginFullPath )
category_t * myCategory = ( category_t * ) cast_to_fptr( myLib.resolve( "category" ) );
version_t * myVersion = ( version_t * ) cast_to_fptr( myLib.resolve( "version" ) );

if ( myName && myDescription && myVersion && myCategory )
if ( myName && myDescription && myVersion && myCategory )
return true;

QgsDebugMsg( "Failed to get name, description, category or type for " + myLib.fileName() );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgspluginregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class QString;
*
* plugin key is:
* - C++ plugins: base name of plugin library, e.g. libgrassplugin
* - Python plugins: module name (directory) of plugin, e.g. plugin_installer
* - Python plugins: module name (directory) of plugin, e.g. db_manager
*/
class QgsPluginRegistry
{
Expand Down