Skip to content
Permalink
Browse files

Added getEnv to plugins API

  • Loading branch information
elpaso committed Nov 26, 2014
1 parent 5f44cc5 commit c9d6f4da43449c9a4405b2189236f4548bed11c0
@@ -21,6 +21,7 @@ class QgsServerInterface
virtual QgsRequestHandler* requestHandler( ) = 0 /KeepReference/;
// Tansfer ownership to avoid garbage collector to call dtor
virtual void registerFilter( QgsServerFilter* filter /Transfer/, int priority = 0 ) = 0;
virtual QString getEnv(const QString& name ) const = 0;
// Commented because of problem with typedef QgsServerFiltersMap
// virtual QgsServerFiltersMap filters( ) = 0;

@@ -94,7 +94,7 @@ void printRequestInfos()
}
if ( getenv( "REMOTE_HOST" ) != NULL )
{
QgsMessageLog::logMessage( "remote ip: " + QString( getenv( "REMOTE_ADDR" ) ), "Server", QgsMessageLog::INFO );
QgsMessageLog::logMessage( "remote ip: " + QString( getenv( "REMOTE_HOST" ) ), "Server", QgsMessageLog::INFO );
}
if ( getenv( "REMOTE_USER" ) != NULL )
{
@@ -326,7 +326,11 @@ int main( int argc, char * argv[] )
// Init plugins
if (! QgsServerPlugins::initPlugins( &serverIface ) )
{
QgsMessageLog::logMessage( "No server plugins are available", "Server", QgsMessageLog::INFO );
QgsMessageLog::logMessage( "No server python plugins are available", "Server", QgsMessageLog::INFO );
}
else
{
QgsMessageLog::logMessage( "Server python plugins loaded", "Server", QgsMessageLog::INFO );
}
// Store plugin filters for faster access
QMultiMap<int, QgsServerFilter*> pluginFilters = serverIface.filters();
@@ -364,6 +368,7 @@ int main( int argc, char * argv[] )
QgsServerFiltersMap::const_iterator filtersIterator;
for( filtersIterator = pluginFilters.constBegin(); filtersIterator != pluginFilters.constEnd(); ++filtersIterator)
{
QgsMessageLog::logMessage( QString("Calling filters priority %1").arg( filtersIterator.key() ), "Server", QgsMessageLog::INFO );
filtersIterator.value()->requestReady();
}
#endif
@@ -46,6 +46,8 @@ class QgsServerInterface
virtual QgsRequestHandler* requestHandler( ) = 0;
virtual void registerFilter( QgsServerFilter* filter, int priority = 0 ) = 0;
virtual QgsServerFiltersMap filters( ) = 0;
/*Pass environment variables to python*/
virtual QString getEnv(const QString& name ) const = 0;

};

@@ -27,6 +27,12 @@ QgsServerInterfaceImpl::QgsServerInterfaceImpl( QgsCapabilitiesCache* capCache )
}


QString QgsServerInterfaceImpl::getEnv(const QString& name ) const
{
return getenv( name.toLocal8Bit() );
}


/** Destructor */
QgsServerInterfaceImpl::~QgsServerInterfaceImpl()
{
@@ -49,6 +49,7 @@ class QgsServerInterfaceImpl : public QgsServerInterface
QgsRequestHandler* requestHandler( ) { return mRequestHandler; }
void registerFilter( QgsServerFilter *filter, int priority = 0 );
QgsServerFiltersMap filters( ) { return mFilters; }
QString getEnv(const QString& name ) const;

private:

@@ -100,7 +100,7 @@ bool QgsServerPlugins::initPlugins(QgsServerInterface *interface)
{
atLeastOneEnabled = TRUE;
mServerPlugins.append( pluginName );
QgsMessageLog::logMessage( QString("Server plugin %1 loaded!").arg( pluginName ), "Server", QgsMessageLog::CRITICAL );
QgsMessageLog::logMessage( QString("Server plugin %1 loaded!").arg( pluginName ), "Server", QgsMessageLog::INFO );
} else {
QgsMessageLog::logMessage( QString("Error loading server plugin %1").arg( pluginName ), "Server", QgsMessageLog::CRITICAL );
}

0 comments on commit c9d6f4d

Please sign in to comment.
You can’t perform that action at this time.