示例#1
0
QgsAuthMethod *QgsAuthMethodRegistry::authMethod( const QString &authMethodKey )
{
  // load the plugin
  QString lib = library( authMethodKey );

#ifdef TESTAUTHMETHODLIB
  const char *cLib = lib.toUtf8();

  // test code to help debug auth method plugin loading problems
  //  void *handle = dlopen(cLib, RTLD_LAZY);
  void *handle = dlopen( cOgrLib, RTLD_LAZY | RTLD_GLOBAL );
  if ( !handle )
  {
    QgsLogger::warning( "Error in dlopen" );
  }
  else
  {
    QgsDebugMsg( "dlopen suceeded" );
    dlclose( handle );
  }

#endif
  // load the auth method
  QLibrary myLib( lib );

  QgsDebugMsg( "Auth method library name is " + myLib.fileName() );
  if ( !myLib.load() )
  {
    QgsMessageLog::logMessage( QObject::tr( "Failed to load %1: %2" ).arg( lib, myLib.errorString() ) );
    return 0;
  }

  classFactoryFunction_t *classFactory = ( classFactoryFunction_t * ) cast_to_fptr( myLib.resolve( "classFactory" ) );
  if ( !classFactory )
  {
    QgsDebugMsg( QString( "Failed to load %1: no classFactory method" ).arg( lib ) );
    return 0;
  }

  QgsAuthMethod *authMethod = classFactory();
  if ( !authMethod )
  {
    QgsMessageLog::logMessage( QObject::tr( "Unable to instantiate the auth method plugin %1" ).arg( lib ) );
    myLib.unload();
    return 0;
  }

  QgsDebugMsg( QString( "Instantiated the auth method plugin: %1" ).arg( authMethod->key() ) );
  return authMethod;
}
示例#2
0
void QgsAuthConfigSelect::loadConfig()
{
  clearConfig();
  if ( !mAuthCfg.isEmpty() && mConfigs.contains( mAuthCfg ) )
  {
    QgsAuthMethodConfig config = mConfigs.value( mAuthCfg );
    QgsAuthMethod *authmethod = QgsAuthManager::instance()->configAuthMethod( mAuthCfg );
    QString methoddesc = tr( "Missing authentication method description" );
    if ( authmethod )
    {
      methoddesc = authmethod->description();
    }
    cmbConfigSelect->setToolTip( tr( "<ul><li><b>Method type:</b> %1</li>"
                                     "<li><b>Configuration ID:</b> %2</li></ul>" ).arg( methoddesc, config.id( ) ) );
    btnConfigEdit->setEnabled( true );
    btnConfigRemove->setEnabled( true );
  }
  emit selectedConfigIdChanged( mAuthCfg );
}
示例#3
0
void QgsAuthConfigSelect::loadConfig()
{
  clearConfig();
  if ( !mAuthCfg.isEmpty() && mConfigs.contains( mAuthCfg ) )
  {
    QgsAuthMethodConfig config = mConfigs.value( mAuthCfg );
    QgsAuthMethod * authmethod = QgsAuthManager::instance()->configAuthMethod( mAuthCfg );
    QString methoddesc = tr( "Missing authentication method description" );
    if ( authmethod )
    {
      methoddesc = authmethod->description();
    }
    leConfigMethodDesc->setText( methoddesc );
    leConfigMethodDesc->setCursorPosition( 0 ); // left justify
    leConfigId->setText( config.id() );
    btnConfigEdit->setEnabled( true );
    btnConfigRemove->setEnabled( true );
  }
  emit selectedConfigIdChanged( mAuthCfg );
}