69 char **argv = qApp->argv();
70 QString appDir = argv[0];
71 int bin = appDir.findRev(
"/bin", -1,
false );
72 QString baseDir = appDir.left( bin );
75 mLibraryDirectory = pluginPath;
76 mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
77 mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
79 #if defined(WIN32) || defined(__CYGWIN__)
80 mLibraryDirectory.setNameFilters( QStringList(
"*.dll" ) );
82 mLibraryDirectory.setNameFilters( QStringList(
"*provider.so" ) );
84 mLibraryDirectory.setNameFilters( QStringList(
"*.so" ) );
87 QgsDebugMsg( QString(
"Checking %1 for provider plugins" ).arg( mLibraryDirectory.path() ) );
89 if ( mLibraryDirectory.count() == 0 )
91 QString msg =
QObject::tr(
"No QGIS data provider plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() );
92 msg +=
QObject::tr(
"No vector layers can be loaded. Check your QGIS installation" );
101 QListIterator<QFileInfo> it( mLibraryDirectory.entryInfoList() );
102 while ( it.hasNext() )
104 QFileInfo fi( it.next() );
106 QLibrary myLib( fi.filePath() );
109 QgsDebugMsg( QString(
"Checking %1: ...invalid (lib not loadable): %2" ).arg( myLib.fileName() ).arg( myLib.errorString() ) );
118 QgsDebugMsg( QString(
"Checking %1: ...invalid (has type method)" ).arg( myLib.fileName() ) );
126 QgsDebugMsg( QString(
"Checking %1: ...invalid (no isProvider method)" ).arg( myLib.fileName() ) );
133 QgsDebugMsg( QString(
"Checking %1: ...invalid (not a provider)" ).arg( myLib.fileName() ) );
141 QgsDebugMsg( QString(
"Checking %1: ...invalid (no description method)" ).arg( myLib.fileName() ) );
148 QgsDebugMsg( QString(
"Checking %1: ...invalid (no providerKey method)" ).arg( myLib.fileName() ) );
157 if ( pDatabaseDrivers )
164 if ( pDirectoryDrivers )
171 if ( pProtocolDrivers )
178 if ( pFileVectorFilters )
182 if ( !fileVectorFilters.isEmpty() )
185 QgsDebugMsg( QString(
"Checking %1: ...loaded ok (%2 file filters)" ).arg( myLib.fileName() ).arg( fileVectorFilters.split(
";;" ).count() ) );
195 pBuild( fileRasterFilters );
197 QgsDebugMsg(
"raster filters: " + fileRasterFilters );
198 if ( !fileRasterFilters.isEmpty() )
201 QgsDebugMsg( QString(
"Checking %1: ...loaded ok (%2 file filters)" ).arg( myLib.fileName() ).arg( fileRasterFilters.split(
";;" ).count() ) );
221 QString
const & providerKey )
223 QgsProviderRegistry::Providers::const_iterator i =
224 metaData.find( providerKey );
226 if ( i != metaData.end() )
251 Providers::const_iterator it =
mProviders.begin();
254 return QObject::tr(
"No data provider plugins are available. No vector layers can be loaded" );
266 list += it->second->description();
314 QString lib =
library( providerKey );
316 #ifdef TESTPROVIDERLIB
317 const char *cLib = lib.toUtf8();
321 void *handle = dlopen( cOgrLib, RTLD_LAZY | RTLD_GLOBAL );
334 QLibrary myLib( lib );
336 QgsDebugMsg(
"Library name is " + myLib.fileName() );
346 QgsDebugMsg( QString(
"Failed to load %1: no classFactory method" ).arg( lib ) );
358 QgsDebugMsg( QString(
"Instantiated the data provider plugin: %1" ).arg( dataProvider->
name() ) );
366 QWidget * parent, Qt::WFlags fl )
371 if ( !selectFactory )
374 return selectFactory( parent, fl );
378 QString
const & functionName )
380 QLibrary myLib(
library( providerKey ) );
382 QgsDebugMsg(
"Library name is " + myLib.fileName() );
386 return myLib.resolve( functionName.toAscii().data() );
390 QgsDebugMsg(
"Cannot load library: " + myLib.errorString() );
397 QLibrary *myLib =
new QLibrary(
library( providerKey ) );
399 QgsDebugMsg(
"Library name is " + myLib->fileName() );
404 QgsDebugMsg(
"Cannot load library: " + myLib->errorString() );
413 typedef void registerGui_function( QWidget * parent );
417 registerGui_function *registerGui = ( registerGui_function * )
cast_to_fptr(
function( provider,
"registerGui" ) );
422 registerGui( parent );
456 lst.append( it->first );
469 QgsProviderRegistry::openVector( QString
const & dataSource, QString
const & providerKey )
471 return getProvider( providerKey, dataSource );