Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[qt5 server] deprecate usage of QFtp and remove from Qt5 builds
  • Loading branch information
m-kuhn committed Mar 15, 2016
1 parent 8fc4056 commit 3904722
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 9 deletions.
1 change: 1 addition & 0 deletions ci/travis/linux/qt5/install.sh
Expand Up @@ -34,6 +34,7 @@ cmake \
-DWITH_QTWEBKIT=OFF \
-DWITH_APIDOC=ON \
-DWITH_ASTYLE=ON \
-DWITH_SERVER=ON \
-DENABLE_QT5=ON \
-DCXX_EXTRA_FLAGS="$CLANG_WARNINGS" \
-DPYTHON_LIBRARY=/usr/lib/libpython3.2mu.so \
Expand Down
14 changes: 12 additions & 2 deletions src/server/CMakeLists.txt
Expand Up @@ -31,7 +31,6 @@ SET ( qgis_mapserv_SRCS
qgswcsserver.cpp
qgsmapserviceexception.cpp
qgsmslayercache.cpp
qgsftptransaction.cpp
qgsmslayerbuilder.cpp
qgshostedvdsbuilder.cpp
qgsinterpolationlayerbuilder.cpp
Expand All @@ -50,21 +49,32 @@ SET ( qgis_mapserv_SRCS
qgssldconfigparser.cpp
qgsconfigparserutils.cpp
qgsserver.cpp
)
IF("${Qt5Network_VERSION}" VERSION_LESS "5.0.0")
SET (qgis_mapserv_SRCS ${qgis_mapserv_SRCS}
qgsftptransaction.cpp
)
ENDIF("${Qt5Network_VERSION}" VERSION_LESS "5.0.0")


# SET (qgis_mapserv_UIS
# none used
# )

SET (qgis_mapserv_MOC_HDRS
qgsftptransaction.h
qgscapabilitiescache.h
qgsconfigcache.h
qgsmslayercache.h
qgsserverlogger.h
qgsserverstreamingdevice.h
)

IF("${Qt5Network_VERSION}" VERSION_LESS "5.0.0")
SET (qgis_mapserv_MOC_HDRS ${qgis_mapserv_MOC_HDRS}
qgsftptransaction.h
)
ENDIF("${Qt5Network_VERSION}" VERSION_LESS "5.0.0")

SET (qgis_mapserv_RCCS
# not used
#qgis_mapserv.qrc
Expand Down
9 changes: 6 additions & 3 deletions src/server/qgsftptransaction.h
Expand Up @@ -17,19 +17,22 @@

#include <QFtp>

/** A class for synchronous ftp access (using QFtp in background)*/
/** A class for synchronous ftp access (using QFtp in background)
*
* @deprecated because of QFtp removal in Qt5.
*/
class QgsFtpTransaction: public QObject
{
Q_OBJECT
public:
QgsFtpTransaction();
Q_DECL_DEPRECATED QgsFtpTransaction();
~QgsFtpTransaction();

/** Transfers the file with the given Url and stores it into ba
@param ftpUrl url of the file to access
@param pointer to buffer to store file contents
@return 0 in case of success*/
int get( const QString& ftpUrl, QByteArray& ba );
Q_DECL_DEPRECATED int get( const QString& ftpUrl, QByteArray& ba );

public slots:
void setFinishedFlag( bool error );
Expand Down
14 changes: 12 additions & 2 deletions src/server/qgshttprequesthandler.cpp
Expand Up @@ -17,9 +17,12 @@
* *
***************************************************************************/

#include "qgis.h"
#include "qgshttprequesthandler.h"
#if QT_VERSION < 0x050000
#include "qgsftptransaction.h"
#include "qgshttptransaction.h"
#endif
#include "qgsmessagelog.h"
#include "qgsmapserviceexception.h"
#include <QBuffer>
Expand All @@ -37,7 +40,7 @@ QgsHttpRequestHandler::QgsHttpRequestHandler( const bool captureOutput )
: QgsRequestHandler()
{
mException = nullptr;
mHeadersSent = FALSE;
mHeadersSent = false;
mCaptureOutput = captureOutput;
}

Expand Down Expand Up @@ -165,7 +168,7 @@ void QgsHttpRequestHandler::sendHeaders()
}
addToResponseHeader( "\n" );
mHeaders.clear();
mHeadersSent = TRUE;
mHeadersSent = true;
}

void QgsHttpRequestHandler::sendBody()
Expand Down Expand Up @@ -574,6 +577,7 @@ void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request,
}
else if ( key.compare( "SLD", Qt::CaseInsensitive ) == 0 )
{
#if QT_VERSION < 0x050000
QByteArray fileContents;
if ( value.startsWith( "http", Qt::CaseInsensitive ) )
{
Expand All @@ -585,18 +589,24 @@ void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request,
}
else if ( value.startsWith( "ftp", Qt::CaseInsensitive ) )
{
Q_NOWARN_DEPRECATED_PUSH;
QgsFtpTransaction ftp;
if ( !ftp.get( value, fileContents ) )
{
continue;
}
value = QUrl::fromPercentEncoding( fileContents );
Q_NOWARN_DEPRECATED_POP;
}
else
{
continue; //only http and ftp supported at the moment
}
value = QUrl::fromPercentEncoding( fileContents );
#else
QgsMessageLog::logMessage( "http and ftp methods not supported with Qt5." );
continue;
#endif

}
parameters.insert( key.toUpper(), value );
Expand Down
11 changes: 11 additions & 0 deletions src/server/qgsremotedatasourcebuilder.cpp
Expand Up @@ -15,9 +15,12 @@
* *
***************************************************************************/

#include "qgis.h"
#include "qgsremotedatasourcebuilder.h"
#if QT_VERSION < 0x050000
#include "qgsftptransaction.h"
#include "qgshttptransaction.h"
#endif
#include "qgslogger.h"
#include "qgsrasterlayer.h"
#include "qgsvectorlayer.h"
Expand Down Expand Up @@ -161,6 +164,7 @@ QgsVectorLayer* QgsRemoteDataSourceBuilder::vectorLayerFromRemoteVDS( const QDom

int QgsRemoteDataSourceBuilder::loadData( const QString& url, QByteArray& data ) const
{
#if QT_VERSION < 0x050000
if ( url.startsWith( "http", Qt::CaseInsensitive ) )
{
QgsHttpTransaction http( url );
Expand All @@ -172,11 +176,18 @@ int QgsRemoteDataSourceBuilder::loadData( const QString& url, QByteArray& data )
}
else if ( url.startsWith( "ftp", Qt::CaseInsensitive ) )
{
Q_NOWARN_DEPRECATED_PUSH;
QgsFtpTransaction ftp;
if ( ftp.get( url, data ) != 0 )
{
return 1;
}
Q_NOWARN_DEPRECATED_POP;
}
#else
Q_UNUSED( url )
Q_UNUSED( data )
QgsDebugMsg( "http and ftp remote datasources not supported with Qt5" );
#endif
return 0;
}
13 changes: 12 additions & 1 deletion src/server/qgsremoteowsbuilder.cpp
Expand Up @@ -17,7 +17,9 @@

#include "qgsdatasourceuri.h"
#include "qgsremoteowsbuilder.h"
#if QT_VERSION < 0x050000
#include "qgshttptransaction.h"
#endif
#include "qgslogger.h"
#include "qgsmslayercache.h"
#include "qgsrasterlayer.h"
Expand Down Expand Up @@ -239,6 +241,8 @@ QgsRasterLayer* QgsRemoteOWSBuilder::wcsLayerFromUrl( const QString &url,
{
Q_UNUSED( layerName );
Q_UNUSED( allowCaching );

#if QT_VERSION < 0x050000
QgsDebugMsg( "Entering" );

//write server url and coverage name to a temporary file
Expand Down Expand Up @@ -339,7 +343,6 @@ QgsRasterLayer* QgsRemoteOWSBuilder::wcsLayerFromUrl( const QString &url,
wcsRequest += "&BBOX=" + bbox;

QgsDebugMsg( "WCS request is: " + wcsRequest );

//make request and store byte array into temporary file
QgsHttpTransaction httpTransaction( wcsRequest );
QByteArray result;
Expand All @@ -355,6 +358,14 @@ QgsRasterLayer* QgsRemoteOWSBuilder::wcsLayerFromUrl( const QString &url,
QgsRasterLayer* rl = new QgsRasterLayer( fileName, layerNameFromUri( fileName ) );
layersToRemove.push_back( rl ); //make sure the layer gets deleted after each request
return rl;
#else
Q_UNUSED( url )
Q_UNUSED( filesToRemove )
Q_UNUSED( layersToRemove )
QgsDebugMsg( "remote http not supported with Qt5" );
return nullptr;
#endif

}

QgsVectorLayer* QgsRemoteOWSBuilder::sosLayer( const QDomElement& remoteOWSElem, const QString& url, const QString& layerName, QList<QgsMapLayer*>& layersToRemove, bool allowCaching ) const
Expand Down
2 changes: 1 addition & 1 deletion src/server/qgsserverprojectparser.cpp
Expand Up @@ -1403,7 +1403,7 @@ QList<QDomElement> QgsServerProjectParser::publishedComposerElements() const
QDomElement wmsRestrictedComposersElem = propertiesElem.firstChildElement( "WMSRestrictedComposers" );
if ( wmsRestrictedComposersElem.isNull() )
{
for ( unsigned int i = 0; i < composerNodeList.length(); ++i )
for ( int i = 0; i < composerNodeList.size(); ++i )
{
composerElemList.push_back( composerNodeList.at( i ).toElement() );
}
Expand Down

0 comments on commit 3904722

Please sign in to comment.