44 QgsAuthMethodRegistry::QgsAuthMethodRegistry( 
const QString &pluginPath )
 
   50   char **argv = qApp->argv();
 
   51   QString appDir = argv[0];
 
   52   int bin = appDir.findRev( 
"/bin", -1, 
false );
 
   53   QString baseDir = appDir.left( bin );
 
   54   QString mLibraryDirectory = baseDir + 
"/lib";
 
   56   mLibraryDirectory.setPath( pluginPath );
 
   57   mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
 
   58   mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
 
   60 #if defined(Q_OS_WIN) || defined(__CYGWIN__) 
   61   mLibraryDirectory.setNameFilters( QStringList( 
"*authmethod.dll" ) );
 
   63   mLibraryDirectory.setNameFilters( QStringList( QStringLiteral( 
"*authmethod*.so" ) ) );
 
   66   QgsDebugMsgLevel( QStringLiteral( 
"Checking for auth method plugins in: %1" ).arg( mLibraryDirectory.path() ), 2 );
 
   68   if ( mLibraryDirectory.count() == 0 )
 
   70     QString msg = QObject::tr( 
"No QGIS auth method plugins found in:\n%1\n" ).arg( mLibraryDirectory.path() );
 
   71     msg += QObject::tr( 
"No authentication methods can be used. Check your QGIS installation" );
 
   74     output->
setTitle( QObject::tr( 
"No Authentication Methods" ) );
 
   81   QString filePattern = getenv( 
"QGIS_AUTHMETHOD_FILE" );
 
   83   if ( !filePattern.isEmpty() )
 
   85     fileRegexp.setPattern( filePattern );
 
   88   QListIterator<QFileInfo> it( mLibraryDirectory.entryInfoList() );
 
   89   while ( it.hasNext() )
 
   91     QFileInfo fi( it.next() );
 
   93     if ( !fileRegexp.isEmpty() )
 
   95       if ( fileRegexp.indexIn( fi.fileName() ) == -1 )
 
   97         QgsDebugMsg( 
"auth method " + fi.fileName() + 
" skipped because doesn't match pattern " + filePattern );
 
  102     QLibrary myLib( fi.filePath() );
 
  105       QgsDebugMsg( QStringLiteral( 
"Checking %1: ...invalid (lib not loadable): %2" ).arg( myLib.fileName(), myLib.errorString() ) );
 
  113       QgsDebugMsg( QStringLiteral( 
"Checking %1: ...invalid (no isAuthMethod method)" ).arg( myLib.fileName() ) );
 
  118     if ( !isAuthMethod() )
 
  120       QgsDebugMsg( QStringLiteral( 
"Checking %1: ...invalid (not an auth method)" ).arg( myLib.fileName() ) );
 
  128       QgsDebugMsg( QStringLiteral( 
"Checking %1: ...invalid (no description method)" ).arg( myLib.fileName() ) );
 
  135       QgsDebugMsg( QStringLiteral( 
"Checking %1: ...invalid (no authMethodKey method)" ).arg( myLib.fileName() ) );
 
  150   AuthMethods::const_iterator it = mAuthMethods.begin();
 
  152   while ( it != mAuthMethods.end() )
 
  155     QString lib = it->second->library();
 
  156     QLibrary myLib( lib );
 
  157     if ( myLib.isLoaded() )
 
  179     QString 
const &authMethodKey )
 
  181   QgsAuthMethodRegistry::AuthMethods::const_iterator i =
 
  182     metaData.find( authMethodKey );
 
  184   if ( i != metaData.end() )
 
  207   AuthMethods::const_iterator it = mAuthMethods.begin();
 
  209   if ( mAuthMethods.empty() )
 
  211     return QObject::tr( 
"No authentication method plugins are available." );
 
  218     list += QLatin1String( 
"<ol>" );
 
  221   while ( it != mAuthMethods.end() )
 
  225       list += QLatin1String( 
"<li>" );
 
  228     list += it->second->description();
 
  232       list += QLatin1String( 
"<br></li>" );
 
  244     list += QLatin1String( 
"</ol>" );
 
  252   return mLibraryDirectory;
 
  257   mLibraryDirectory = path;
 
  267   QString lib = 
library( authMethodKey );
 
  269 #ifdef TESTAUTHMETHODLIB 
  270   const char *cLib = lib.toUtf8();
 
  274   void *handle = dlopen( cOgrLib, RTLD_LAZY | RTLD_GLOBAL );
 
  281     QgsDebugMsg( QStringLiteral( 
"dlopen succeeded" ) );
 
  287   QLibrary myLib( lib );
 
  299     QgsDebugMsg( QStringLiteral( 
"Failed to load %1: no classFactory method" ).arg( lib ) );
 
  303   std::unique_ptr< QgsAuthMethod > 
authMethod( classFactory() );
 
  325   return editFactory( parent );
 
  329     QString 
const &functionName )
 
  331   QLibrary myLib( 
library( authMethodKey ) );
 
  337     return myLib.resolve( functionName.toLatin1().data() );
 
  341     QgsDebugMsg( 
"Cannot load library: " + myLib.errorString() );
 
  348   std::unique_ptr< QLibrary > myLib( 
new QLibrary( 
library( authMethodKey ) ) );
 
  355   QgsDebugMsg( 
"Cannot load library: " + myLib->errorString() );
 
  362   for ( AuthMethods::const_iterator it = mAuthMethods.begin(); it != mAuthMethods.end(); ++it )
 
  364     lst.append( it->first );
 
  371   return findMetadata_( mAuthMethods, authMethodKey );
 
A registry / canonical manager of authentication methods.
const QgsAuthMethodMetadata * authMethodMetadata(const QString &authMethodKey) const
Returns metadata of the auth method or nullptr if not found.
static QgsAuthMethodRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QWidget * editWidget(const QString &authMethodKey, QWidget *parent=nullptr)
Returns the GUI edit widget associated with the auth method.
std::unique_ptr< QLibrary > authMethodLibrary(const QString &authMethodKey) const
Returns the library object associated with an auth method key.
std::unique_ptr< QgsAuthMethod > authMethod(const QString &authMethodKey)
Create an instance of the auth method.
QString pluginList(bool asHtml=false) const
Returns list of auth method plugins found.
void setLibraryDirectory(const QDir &path)
Sets library directory where to search for plugins.
QFunctionPointer function(const QString &authMethodKey, const QString &functionName)
Gets pointer to auth method function.
QDir libraryDirectory() const
Returns library directory where plugins are found.
virtual ~QgsAuthMethodRegistry()
Virtual dectructor.
QString library(const QString &authMethodKey) const
Returns path for the library of the auth method.
QStringList authMethodList() const
Returns list of available auth methods by their keys.
std::map< QString, QgsAuthMethodMetadata * > AuthMethods
Type for auth method metadata associative container.
Abstract base class for authentication method plugins.
static void warning(const QString &msg)
Goes to qWarning.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
Interface for showing messages from QGIS in GUI independent way.
virtual void showMessage(bool blocking=true)=0
display the message to the user and deletes itself
static QgsMessageOutput * createMessageOutput()
function that returns new class derived from QgsMessageOutput (don't forget to delete it then if show...
virtual void setMessage(const QString &message, MessageType msgType)=0
Sets message, it won't be displayed until.
virtual void setTitle(const QString &title)=0
Sets title for the messages.
void cleanupAuthMethod_t()
QWidget * editFactoryFunction_t(QWidget *parent)
QgsAuthMethod * classFactoryFunction_t()
#define QgsDebugMsgLevel(str, level)