Skip to content

Commit 3904722

Browse files
committedMar 15, 2016
[qt5 server] deprecate usage of QFtp and remove from Qt5 builds
1 parent 8fc4056 commit 3904722

File tree

7 files changed

+55
-9
lines changed

7 files changed

+55
-9
lines changed
 

‎ci/travis/linux/qt5/install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ cmake \
3434
-DWITH_QTWEBKIT=OFF \
3535
-DWITH_APIDOC=ON \
3636
-DWITH_ASTYLE=ON \
37+
-DWITH_SERVER=ON \
3738
-DENABLE_QT5=ON \
3839
-DCXX_EXTRA_FLAGS="$CLANG_WARNINGS" \
3940
-DPYTHON_LIBRARY=/usr/lib/libpython3.2mu.so \

‎src/server/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ SET ( qgis_mapserv_SRCS
3131
qgswcsserver.cpp
3232
qgsmapserviceexception.cpp
3333
qgsmslayercache.cpp
34-
qgsftptransaction.cpp
3534
qgsmslayerbuilder.cpp
3635
qgshostedvdsbuilder.cpp
3736
qgsinterpolationlayerbuilder.cpp
@@ -50,21 +49,32 @@ SET ( qgis_mapserv_SRCS
5049
qgssldconfigparser.cpp
5150
qgsconfigparserutils.cpp
5251
qgsserver.cpp
52+
)
53+
IF("${Qt5Network_VERSION}" VERSION_LESS "5.0.0")
54+
SET (qgis_mapserv_SRCS ${qgis_mapserv_SRCS}
55+
qgsftptransaction.cpp
5356
)
57+
ENDIF("${Qt5Network_VERSION}" VERSION_LESS "5.0.0")
58+
5459

5560
# SET (qgis_mapserv_UIS
5661
# none used
5762
# )
5863

5964
SET (qgis_mapserv_MOC_HDRS
60-
qgsftptransaction.h
6165
qgscapabilitiescache.h
6266
qgsconfigcache.h
6367
qgsmslayercache.h
6468
qgsserverlogger.h
6569
qgsserverstreamingdevice.h
6670
)
6771

72+
IF("${Qt5Network_VERSION}" VERSION_LESS "5.0.0")
73+
SET (qgis_mapserv_MOC_HDRS ${qgis_mapserv_MOC_HDRS}
74+
qgsftptransaction.h
75+
)
76+
ENDIF("${Qt5Network_VERSION}" VERSION_LESS "5.0.0")
77+
6878
SET (qgis_mapserv_RCCS
6979
# not used
7080
#qgis_mapserv.qrc

‎src/server/qgsftptransaction.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,22 @@
1717

1818
#include <QFtp>
1919

20-
/** A class for synchronous ftp access (using QFtp in background)*/
20+
/** A class for synchronous ftp access (using QFtp in background)
21+
*
22+
* @deprecated because of QFtp removal in Qt5.
23+
*/
2124
class QgsFtpTransaction: public QObject
2225
{
2326
Q_OBJECT
2427
public:
25-
QgsFtpTransaction();
28+
Q_DECL_DEPRECATED QgsFtpTransaction();
2629
~QgsFtpTransaction();
2730

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

3437
public slots:
3538
void setFinishedFlag( bool error );

‎src/server/qgshttprequesthandler.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
* *
1818
***************************************************************************/
1919

20+
#include "qgis.h"
2021
#include "qgshttprequesthandler.h"
22+
#if QT_VERSION < 0x050000
2123
#include "qgsftptransaction.h"
2224
#include "qgshttptransaction.h"
25+
#endif
2326
#include "qgsmessagelog.h"
2427
#include "qgsmapserviceexception.h"
2528
#include <QBuffer>
@@ -37,7 +40,7 @@ QgsHttpRequestHandler::QgsHttpRequestHandler( const bool captureOutput )
3740
: QgsRequestHandler()
3841
{
3942
mException = nullptr;
40-
mHeadersSent = FALSE;
43+
mHeadersSent = false;
4144
mCaptureOutput = captureOutput;
4245
}
4346

@@ -165,7 +168,7 @@ void QgsHttpRequestHandler::sendHeaders()
165168
}
166169
addToResponseHeader( "\n" );
167170
mHeaders.clear();
168-
mHeadersSent = TRUE;
171+
mHeadersSent = true;
169172
}
170173

171174
void QgsHttpRequestHandler::sendBody()
@@ -574,6 +577,7 @@ void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request,
574577
}
575578
else if ( key.compare( "SLD", Qt::CaseInsensitive ) == 0 )
576579
{
580+
#if QT_VERSION < 0x050000
577581
QByteArray fileContents;
578582
if ( value.startsWith( "http", Qt::CaseInsensitive ) )
579583
{
@@ -585,18 +589,24 @@ void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request,
585589
}
586590
else if ( value.startsWith( "ftp", Qt::CaseInsensitive ) )
587591
{
592+
Q_NOWARN_DEPRECATED_PUSH;
588593
QgsFtpTransaction ftp;
589594
if ( !ftp.get( value, fileContents ) )
590595
{
591596
continue;
592597
}
593598
value = QUrl::fromPercentEncoding( fileContents );
599+
Q_NOWARN_DEPRECATED_POP;
594600
}
595601
else
596602
{
597603
continue; //only http and ftp supported at the moment
598604
}
599605
value = QUrl::fromPercentEncoding( fileContents );
606+
#else
607+
QgsMessageLog::logMessage( "http and ftp methods not supported with Qt5." );
608+
continue;
609+
#endif
600610

601611
}
602612
parameters.insert( key.toUpper(), value );

‎src/server/qgsremotedatasourcebuilder.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
* *
1616
***************************************************************************/
1717

18+
#include "qgis.h"
1819
#include "qgsremotedatasourcebuilder.h"
20+
#if QT_VERSION < 0x050000
1921
#include "qgsftptransaction.h"
2022
#include "qgshttptransaction.h"
23+
#endif
2124
#include "qgslogger.h"
2225
#include "qgsrasterlayer.h"
2326
#include "qgsvectorlayer.h"
@@ -161,6 +164,7 @@ QgsVectorLayer* QgsRemoteDataSourceBuilder::vectorLayerFromRemoteVDS( const QDom
161164

162165
int QgsRemoteDataSourceBuilder::loadData( const QString& url, QByteArray& data ) const
163166
{
167+
#if QT_VERSION < 0x050000
164168
if ( url.startsWith( "http", Qt::CaseInsensitive ) )
165169
{
166170
QgsHttpTransaction http( url );
@@ -172,11 +176,18 @@ int QgsRemoteDataSourceBuilder::loadData( const QString& url, QByteArray& data )
172176
}
173177
else if ( url.startsWith( "ftp", Qt::CaseInsensitive ) )
174178
{
179+
Q_NOWARN_DEPRECATED_PUSH;
175180
QgsFtpTransaction ftp;
176181
if ( ftp.get( url, data ) != 0 )
177182
{
178183
return 1;
179184
}
185+
Q_NOWARN_DEPRECATED_POP;
180186
}
187+
#else
188+
Q_UNUSED( url )
189+
Q_UNUSED( data )
190+
QgsDebugMsg( "http and ftp remote datasources not supported with Qt5" );
191+
#endif
181192
return 0;
182193
}

‎src/server/qgsremoteowsbuilder.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
#include "qgsdatasourceuri.h"
1919
#include "qgsremoteowsbuilder.h"
20+
#if QT_VERSION < 0x050000
2021
#include "qgshttptransaction.h"
22+
#endif
2123
#include "qgslogger.h"
2224
#include "qgsmslayercache.h"
2325
#include "qgsrasterlayer.h"
@@ -239,6 +241,8 @@ QgsRasterLayer* QgsRemoteOWSBuilder::wcsLayerFromUrl( const QString &url,
239241
{
240242
Q_UNUSED( layerName );
241243
Q_UNUSED( allowCaching );
244+
245+
#if QT_VERSION < 0x050000
242246
QgsDebugMsg( "Entering" );
243247

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

341345
QgsDebugMsg( "WCS request is: " + wcsRequest );
342-
343346
//make request and store byte array into temporary file
344347
QgsHttpTransaction httpTransaction( wcsRequest );
345348
QByteArray result;
@@ -355,6 +358,14 @@ QgsRasterLayer* QgsRemoteOWSBuilder::wcsLayerFromUrl( const QString &url,
355358
QgsRasterLayer* rl = new QgsRasterLayer( fileName, layerNameFromUri( fileName ) );
356359
layersToRemove.push_back( rl ); //make sure the layer gets deleted after each request
357360
return rl;
361+
#else
362+
Q_UNUSED( url )
363+
Q_UNUSED( filesToRemove )
364+
Q_UNUSED( layersToRemove )
365+
QgsDebugMsg( "remote http not supported with Qt5" );
366+
return nullptr;
367+
#endif
368+
358369
}
359370

360371
QgsVectorLayer* QgsRemoteOWSBuilder::sosLayer( const QDomElement& remoteOWSElem, const QString& url, const QString& layerName, QList<QgsMapLayer*>& layersToRemove, bool allowCaching ) const

‎src/server/qgsserverprojectparser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ QList<QDomElement> QgsServerProjectParser::publishedComposerElements() const
14031403
QDomElement wmsRestrictedComposersElem = propertiesElem.firstChildElement( "WMSRestrictedComposers" );
14041404
if ( wmsRestrictedComposersElem.isNull() )
14051405
{
1406-
for ( unsigned int i = 0; i < composerNodeList.length(); ++i )
1406+
for ( int i = 0; i < composerNodeList.size(); ++i )
14071407
{
14081408
composerElemList.push_back( composerNodeList.at( i ).toElement() );
14091409
}

0 commit comments

Comments
 (0)
Please sign in to comment.