44 QgsAuthMethodRegistry::QgsAuthMethodRegistry(
const QString& pluginPath )
50 char **argv = qApp->argv();
52 int bin = appDir.
findRev(
"/bin", -1,
false );
54 QString mLibraryDirectory = baseDir +
"/lib";
56 mLibraryDirectory = 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(
"*authmethod.so" ) );
66 QgsDebugMsg(
QString(
"Checking for auth method plugins in: %1" ).arg( mLibraryDirectory.path() ) );
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" );
81 QString filePattern = getenv(
"QGIS_AUTHMETHOD_FILE" );
89 while ( it.hasNext() )
95 if ( fileRegexp.
indexIn( fi.fileName() ) == -1 )
97 QgsDebugMsg(
"auth method " + fi.fileName() +
" skipped because doesn't match pattern " + filePattern );
105 QgsDebugMsg(
QString(
"Checking %1: ...invalid (lib not loadable): %2" ).arg( myLib.fileName(), myLib.errorString() ) );
113 QgsDebugMsg(
QString(
"Checking %1: ...invalid (no isAuthMethod method)" ).arg( myLib.fileName() ) );
118 if ( !isAuthMethod() )
120 QgsDebugMsg(
QString(
"Checking %1: ...invalid (not an auth method)" ).arg( myLib.fileName() ) );
128 QgsDebugMsg(
QString(
"Checking %1: ...invalid (no description method)" ).arg( myLib.fileName() ) );
135 QgsDebugMsg(
QString(
"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();
178 QString const & authMethodKey )
180 QgsAuthMethodRegistry::AuthMethods::const_iterator i =
181 metaData.find( authMethodKey );
183 if ( i != metaData.end() )
206 AuthMethods::const_iterator it = mAuthMethods.begin();
208 if ( mAuthMethods.empty() )
210 return QObject::tr(
"No authentication method plugins are available." );
220 while ( it != mAuthMethods.end() )
227 list += it->second->description();
251 return mLibraryDirectory;
256 mLibraryDirectory = path;
268 #ifdef TESTAUTHMETHODLIB 269 const char *cLib = lib.
toUtf8();
273 void *handle = dlopen( cOgrLib, RTLD_LAZY | RTLD_GLOBAL );
324 return editFactory( parent );
327 #if QT_VERSION >= 0x050000 384 for ( AuthMethods::const_iterator it = mAuthMethods.begin(); it != mAuthMethods.end(); ++it )
int findRev(QChar c, int i, bool cs) const
virtual void setTitle(const QString &title)=0
set title for the messages
QStringList authMethodList() const
Return list of available auth methods by their keys.
static void warning(const QString &msg)
Goes to qWarning.
void * function(const QString &authMethodKey, const QString &functionName)
Get pointer to auth method function.
QgsAuthMethod * authMethod(const QString &authMethodKey)
Create an instance of the auth method.
static QgsMessageOutput * createMessageOutput()
function that returns new class derived from QgsMessageOutput (don't forget to delete it then if show...
QString tr(const char *sourceText, const char *disambiguation, int n)
A registry / canonical manager of authentication methods.
void setPattern(const QString &pattern)
int indexIn(const QString &str, int offset, CaretMode caretMode) const
void append(const T &value)
QWidget * editWidget(const QString &authMethodKey, QWidget *parent=nullptr)
Return the auth method capabilities.
QString pluginList(bool asHtml=false) const
Return list of auth method plugins found.
static void logMessage(const QString &message, const QString &tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
virtual void setMessage(const QString &message, MessageType msgType)=0
set message, it won't be displayed until
const QDir & libraryDirectory() const
Return library directory where plugins are found.
std::map< QString, QgsAuthMethodMetadata * > AuthMethods
Type for auth method metadata associative container.
virtual void showMessage(bool blocking=true)=0
display the message to the user and deletes itself
void cleanupAuthMethod_t()
QLibrary * authMethodLibrary(const QString &authMethodKey) const
Return the library object associated with an auth method key.
Abstract base class for authentication method plugins.
void * resolve(const char *symbol)
const QgsAuthMethodMetadata * authMethodMetadata(const QString &authMethodKey) const
Return metadata of the auth method or nullptr if not found.
void setLibraryDirectory(const QDir &path)
Set library directory where to search for plugins.
static QgsAuthMethodMetadata * findMetadata_(QgsAuthMethodRegistry::AuthMethods const &metaData, QString const &authMethodKey)
Convenience function for finding any existing auth methods that match "authMethodKey".
virtual QString key() const =0
A non-translated short name representing the auth method.
QString library(const QString &authMethodKey) const
Return path for the library of the auth method.
QString left(int n) const
QgsAuthMethod * classFactoryFunction_t()
QWidget * editFactoryFunction_t(QWidget *parent)
void(*)() cast_to_fptr(void *p)
Interface for showing messages from QGIS in GUI independent way.
static QgsAuthMethodRegistry * instance(const QString &pluginPath=QString::null)
Means of accessing canonical single instance.
virtual ~QgsAuthMethodRegistry()
Virtual dectructor.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QByteArray toAscii() const
QString errorString() const
QByteArray toUtf8() const