-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
282 additions
and
2 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
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,59 @@ | ||
/*************************************************************************** | ||
qgsserverstreamingdevice.cpp | ||
------------------------------------------------------------------- | ||
Date : 25 May 2015 | ||
Copyright : (C) 2015 by Marco Hugentobler | ||
email : marco.hugentobler at sourcepole 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 "qgsserverstreamingdevice.h" | ||
#include "qgsrequesthandler.h" | ||
|
||
QgsServerStreamingDevice::QgsServerStreamingDevice( const QString& formatName, QgsRequestHandler* rh, QObject* parent ): QIODevice( parent ), mFormatName( formatName ), mRequestHandler( rh ) | ||
{ | ||
} | ||
|
||
QgsServerStreamingDevice::QgsServerStreamingDevice(): QIODevice( 0 ), mRequestHandler( 0 ) | ||
{ | ||
|
||
} | ||
|
||
QgsServerStreamingDevice::~QgsServerStreamingDevice() | ||
{ | ||
} | ||
|
||
bool QgsServerStreamingDevice::open( OpenMode mode ) | ||
{ | ||
if( !mRequestHandler || mode != QIODevice::WriteOnly ) | ||
{ | ||
return false; | ||
} | ||
|
||
mRequestHandler->setHeader( "Content-Type", mFormatName ); | ||
mRequestHandler->sendResponse(); | ||
return QIODevice::open( mode ); | ||
} | ||
|
||
void QgsServerStreamingDevice::close() | ||
{ | ||
QIODevice::close(); | ||
} | ||
|
||
qint64 QgsServerStreamingDevice::writeData( const char * data, qint64 maxSize ) | ||
{ | ||
QByteArray ba( data, maxSize ); | ||
mRequestHandler->setGetFeatureResponse( &ba ); | ||
return maxSize; | ||
} | ||
|
||
qint64 QgsServerStreamingDevice::readData( char * data, qint64 maxSize ) | ||
{ | ||
return -1; //reading not supported | ||
} |
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,44 @@ | ||
/*************************************************************************** | ||
qgsserverstreamingdevice.h | ||
------------------------------------------------------------------- | ||
Date : 25 May 2015 | ||
Copyright : (C) 2015 by Marco Hugentobler | ||
email : marco.hugentobler at sourcepole 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 QGSSERVERSTREAMINGDEVICE_H | ||
#define QGSSERVERSTREAMINGDEVICE_H | ||
|
||
#include <QIODevice> | ||
|
||
class QgsRequestHandler; | ||
|
||
class QgsServerStreamingDevice: public QIODevice | ||
{ | ||
public: | ||
QgsServerStreamingDevice( const QString& formatName, QgsRequestHandler* rh, QObject* parent = 0 ); | ||
~QgsServerStreamingDevice(); | ||
|
||
bool isSequential() const { return false; } | ||
|
||
bool open( OpenMode mode ); | ||
void close(); | ||
|
||
protected: | ||
QString mFormatName; | ||
QgsRequestHandler* mRequestHandler; | ||
|
||
QgsServerStreamingDevice(); //default constructor forbidden | ||
|
||
qint64 writeData( const char * data, qint64 maxSize ); | ||
qint64 readData ( char * data, qint64 maxSize ); | ||
}; | ||
|
||
#endif // QGSSERVERSTREAMINGDEVICE_H |
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