Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add plugin hook support decorator
- Add plugin hook support decorator for use in service modules - Remove handling of plugin hook with request handler (not needed anymore) - Reduce usage of HAVE_SERVER_PYTHON_PLUGINS by using forward opaque declaration.
- Loading branch information
Showing
15 changed files
with
345 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/*************************************************************************** | ||
qgsfilterresponsedecorator.cpp | ||
Define response wrapper for fcgi response | ||
------------------- | ||
begin : 2017-01-03 | ||
copyright : (C) 2017 by David Marteau | ||
email : david dot marteau at 3liz dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsconfig.h" | ||
#include "qgsfilterresponsedecorator.h" | ||
|
||
QgsFilterResponseDecorator::QgsFilterResponseDecorator( QgsServerFiltersMap filters, QgsServerResponse& response ) | ||
: mFilters(filters) | ||
, mResponse(response) | ||
{ | ||
} | ||
|
||
QgsFilterResponseDecorator::~QgsFilterResponseDecorator() | ||
{ | ||
|
||
} | ||
|
||
void QgsFilterResponseDecorator::start() | ||
{ | ||
#ifdef HAVE_SERVER_PYTHON_PLUGINS | ||
QgsServerFiltersMap::const_iterator filtersIterator; | ||
for ( filtersIterator = mFilters.constBegin(); filtersIterator != mFilters.constEnd(); ++filtersIterator ) | ||
{ | ||
filtersIterator.value()->requestReady(); | ||
} | ||
#endif | ||
} | ||
|
||
void QgsFilterResponseDecorator::finish() | ||
{ | ||
|
||
#ifdef HAVE_SERVER_PYTHON_PLUGINS | ||
QgsServerFiltersMap::const_iterator filtersIterator; | ||
for ( filtersIterator = mFilters.constBegin(); filtersIterator != mFilters.constEnd(); ++filtersIterator ) | ||
{ | ||
filtersIterator.value()->responseComplete(); | ||
} | ||
#endif | ||
// Will call 'flush' | ||
mResponse.finish(); | ||
} | ||
|
||
void QgsFilterResponseDecorator::flush() | ||
{ | ||
#ifdef HAVE_SERVER_PYTHON_PLUGINS | ||
QgsServerFiltersMap::const_iterator filtersIterator; | ||
for ( filtersIterator = mFilters.constBegin(); filtersIterator != mFilters.constEnd(); ++filtersIterator ) | ||
{ | ||
filtersIterator.value()->sendResponse(); | ||
} | ||
#endif | ||
mResponse.flush(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/*************************************************************************** | ||
qgsfilterresponsedecorator.h | ||
Define response adapter for handling filter's hooks | ||
------------------- | ||
begin : 2017-01-05 | ||
copyright : (C) 2017 by David Marteau | ||
email : david dot marteau at 3liz dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#ifndef QGSFILTERRESPONSEDECORATOR_H | ||
#define QGSFILTERRESPONSEDECORATOR_H | ||
|
||
#include "qgsserverresponse.h" | ||
#include "qgsserverfilter.h" | ||
|
||
/** | ||
* \ingroup server | ||
* QgsFilterResponseDecorator | ||
* Class defining decorator for calling filter's hooks | ||
*/ | ||
class QgsFilterResponseDecorator: public QgsServerResponse | ||
{ | ||
public: | ||
|
||
QgsFilterResponseDecorator( QgsServerFiltersMap filters, QgsServerResponse& response ); | ||
~QgsFilterResponseDecorator(); | ||
|
||
/** | ||
* Call flter's requestReady() method | ||
*/ | ||
void start(); | ||
|
||
// QgsServerResponse overrides | ||
|
||
void setHeader( const QString& key, const QString& value ) override { mResponse.setHeader(key, value); } | ||
|
||
void clearHeader( const QString& key ) override { mResponse.clearHeader( key ); } | ||
|
||
QString getHeader( const QString& key ) const override { return mResponse.getHeader( key ); } | ||
|
||
QList<QString> headerKeys() const override { return mResponse.headerKeys(); } | ||
|
||
bool headersWritten() const override { return mResponse.headersWritten(); } | ||
|
||
void setReturnCode( int code ) override { mResponse.setReturnCode( code ); } | ||
|
||
void sendError( int code, const QString& message ) override { mResponse.sendError( code, message ); } | ||
|
||
QIODevice* io() override { return mResponse.io(); } | ||
|
||
void finish() override; | ||
|
||
void flush() override; | ||
|
||
void clear() override { mResponse.clear(); } | ||
|
||
|
||
|
||
private: | ||
QgsServerFiltersMap mFilters; | ||
QgsServerResponse& mResponse; | ||
}; | ||
|
||
#endif | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.