From 73da086964b8215c46e1e23814e4358e1a9863d5 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Sat, 24 Aug 2013 14:57:55 +0200 Subject: [PATCH] Initial changes to also build on Qt5, doesn't compile yet --- CMakeLists.txt | 9 +- cmake/modules/MacroLogFeature.cmake | 157 ++++++++++++++++++ cmake/modules/MacroOptionalFindPackage.cmake | 47 ++++++ cmake/modules/QtVersionAbstraction.cmake | 107 ++++++++++++ src/CMakeLists.txt | 58 +++---- .../shibboleth/shibbolethaccessmanager.cpp | 1 + src/mirall/folder.cpp | 2 +- src/mirall/mirallconfigfile.cpp | 8 +- src/mirall/owncloudinfo.cpp | 8 +- src/mirall/sslerrordialog.cpp | 6 +- src/mirall/utility.cpp | 26 ++- src/mirall/utility.h | 5 + 12 files changed, 392 insertions(+), 42 deletions(-) create mode 100644 cmake/modules/MacroLogFeature.cmake create mode 100644 cmake/modules/MacroOptionalFindPackage.cmake create mode 100644 cmake/modules/QtVersionAbstraction.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a6df09d0..cd5adccb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_CURRENT_BINARY_D include(GNUInstallDirs) include(DefineInstallationPaths) +include(QtVersionAbstraction) include(GetGitRevisionDescription) get_git_head_revision(GIT_REFSPEC GIT_SHA1) @@ -66,10 +67,10 @@ endif() #### #### find libs -find_package(Qt4 4.7.0 COMPONENTS QtCore QtGui QtXml QtNetwork QtTest QtWebkit REQUIRED ) -if( UNIX AND NOT APPLE ) # Fdo notifications - find_package(Qt4 4.7.0 COMPONENTS QtDBus REQUIRED ) -endif() +#find_package(Qt4 4.7.0 COMPONENTS QtCore QtGui QtXml QtNetwork QtTest QtWebkit REQUIRED ) +#if( UNIX AND NOT APPLE ) # Fdo notifications +# find_package(Qt4 4.7.0 COMPONENTS QtDBus REQUIRED ) +#endif() find_package(Csync REQUIRED) if(UNIX) find_package(INotify REQUIRED) diff --git a/cmake/modules/MacroLogFeature.cmake b/cmake/modules/MacroLogFeature.cmake new file mode 100644 index 000000000..45e27b6df --- /dev/null +++ b/cmake/modules/MacroLogFeature.cmake @@ -0,0 +1,157 @@ +# This file defines the Feature Logging macros. +# +# MACRO_LOG_FEATURE(VAR FEATURE DESCRIPTION URL [REQUIRED [MIN_VERSION [COMMENTS]]]) +# Logs the information so that it can be displayed at the end +# of the configure run +# VAR : TRUE or FALSE, indicating whether the feature is supported +# FEATURE: name of the feature, e.g. "libjpeg" +# DESCRIPTION: description what this feature provides +# URL: home page +# REQUIRED: TRUE or FALSE, indicating whether the featue is required +# MIN_VERSION: minimum version number. empty string if unneeded +# COMMENTS: More info you may want to provide. empty string if unnecessary +# +# MACRO_DISPLAY_FEATURE_LOG() +# Call this to display the collected results. +# Exits CMake with a FATAL error message if a required feature is missing +# +# Example: +# +# INCLUDE(MacroLogFeature) +# +# FIND_PACKAGE(JPEG) +# MACRO_LOG_FEATURE(JPEG_FOUND "libjpeg" "Support JPEG images" "http://www.ijg.org" TRUE "3.2a" "") +# ... +# MACRO_DISPLAY_FEATURE_LOG() + +# Copyright (c) 2006, Alexander Neundorf, +# Copyright (c) 2006, Allen Winter, +# Copyright (c) 2009, Sebastian Trueg, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +IF (NOT _macroLogFeatureAlreadyIncluded) + SET(_file ${CMAKE_BINARY_DIR}/MissingRequirements.txt) + IF (EXISTS ${_file}) + FILE(REMOVE ${_file}) + ENDIF (EXISTS ${_file}) + + SET(_file ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) + IF (EXISTS ${_file}) + FILE(REMOVE ${_file}) + ENDIF (EXISTS ${_file}) + + SET(_file ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) + IF (EXISTS ${_file}) + FILE(REMOVE ${_file}) + ENDIF (EXISTS ${_file}) + + SET(_macroLogFeatureAlreadyIncluded TRUE) + + INCLUDE(FeatureSummary) + +ENDIF (NOT _macroLogFeatureAlreadyIncluded) + + +MACRO(MACRO_LOG_FEATURE _var _package _description _url ) # _required _minvers _comments) + + STRING(TOUPPER "${ARGV4}" _required) + SET(_minvers "${ARGV5}") + SET(_comments "${ARGV6}") + + IF (${_var}) + SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) + ELSE (${_var}) + IF ("${_required}" STREQUAL "TRUE") + SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/MissingRequirements.txt) + ELSE ("${_required}" STREQUAL "TRUE") + SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) + ENDIF ("${_required}" STREQUAL "TRUE") + ENDIF (${_var}) + + SET(_logtext " * ${_package}") + + IF (NOT ${_var}) + IF (${_minvers} MATCHES ".*") + SET(_logtext "${_logtext} (${_minvers} or higher)") + ENDIF (${_minvers} MATCHES ".*") + SET(_logtext "${_logtext} <${_url}>\n ") + ELSE (NOT ${_var}) + SET(_logtext "${_logtext} - ") + ENDIF (NOT ${_var}) + + SET(_logtext "${_logtext}${_description}") + + IF (NOT ${_var}) + IF (${_comments} MATCHES ".*") + SET(_logtext "${_logtext}\n ${_comments}") + ENDIF (${_comments} MATCHES ".*") +# SET(_logtext "${_logtext}\n") #double-space missing features? + ENDIF (NOT ${_var}) + + FILE(APPEND "${_LOGFILENAME}" "${_logtext}\n") + + IF(COMMAND SET_PACKAGE_INFO) # in FeatureSummary.cmake since CMake 2.8.3 + SET_PACKAGE_INFO("${_package}" "\"${_description}\"" "${_url}" "\"${_comments}\"") + ENDIF(COMMAND SET_PACKAGE_INFO) + +ENDMACRO(MACRO_LOG_FEATURE) + + +MACRO(MACRO_DISPLAY_FEATURE_LOG) + IF(COMMAND FEATURE_SUMMARY) # in FeatureSummary.cmake since CMake 2.8.3 + FEATURE_SUMMARY(FILENAME ${CMAKE_CURRENT_BINARY_DIR}/FindPackageLog.txt + WHAT ALL) + ENDIF(COMMAND FEATURE_SUMMARY) + + SET(_missingFile ${CMAKE_BINARY_DIR}/MissingRequirements.txt) + SET(_enabledFile ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) + SET(_disabledFile ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) + + IF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile}) + SET(_printSummary TRUE) + ENDIF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile}) + + IF(_printSummary) + SET(_missingDeps 0) + IF (EXISTS ${_enabledFile}) + FILE(READ ${_enabledFile} _enabled) + FILE(REMOVE ${_enabledFile}) + SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following external packages were located on your system.\n-- This installation will have the extra features provided by these packages.\n-----------------------------------------------------------------------------\n${_enabled}") + ENDIF (EXISTS ${_enabledFile}) + + + IF (EXISTS ${_disabledFile}) + SET(_missingDeps 1) + FILE(READ ${_disabledFile} _disabled) + FILE(REMOVE ${_disabledFile}) + SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following OPTIONAL packages could NOT be located on your system.\n-- Consider installing them to enable more features from this software.\n-----------------------------------------------------------------------------\n${_disabled}") + ENDIF (EXISTS ${_disabledFile}) + + + IF (EXISTS ${_missingFile}) + SET(_missingDeps 1) + FILE(READ ${_missingFile} _requirements) + SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following REQUIRED packages could NOT be located on your system.\n-- You must install these packages before continuing.\n-----------------------------------------------------------------------------\n${_requirements}") + FILE(REMOVE ${_missingFile}) + SET(_haveMissingReq 1) + ENDIF (EXISTS ${_missingFile}) + + + IF (NOT ${_missingDeps}) + SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- Congratulations! All external packages have been found.") + ENDIF (NOT ${_missingDeps}) + + + MESSAGE(${_summary}) + MESSAGE("-----------------------------------------------------------------------------\n") + + + IF(_haveMissingReq) + MESSAGE(FATAL_ERROR "Exiting: Missing Requirements") + ENDIF(_haveMissingReq) + + ENDIF(_printSummary) + +ENDMACRO(MACRO_DISPLAY_FEATURE_LOG) diff --git a/cmake/modules/MacroOptionalFindPackage.cmake b/cmake/modules/MacroOptionalFindPackage.cmake new file mode 100644 index 000000000..a066bc781 --- /dev/null +++ b/cmake/modules/MacroOptionalFindPackage.cmake @@ -0,0 +1,47 @@ +# - MACRO_OPTIONAL_FIND_PACKAGE() combines FIND_PACKAGE() with an OPTION() +# MACRO_OPTIONAL_FIND_PACKAGE( [QUIT] ) +# This macro is a combination of OPTION() and FIND_PACKAGE(), it +# works like FIND_PACKAGE(), but additionally it automatically creates +# an option name WITH_, which can be disabled via the cmake GUI. +# or via -DWITH_=OFF +# The standard _FOUND variables can be used in the same way +# as when using the normal FIND_PACKAGE() + +# Copyright (c) 2006-2010 Alexander Neundorf, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +# This is just a helper macro to set a bunch of variables empty. +# We don't know whether the package uses UPPERCASENAME or CamelCaseName, so we try both: +macro(_MOFP_SET_EMPTY_IF_DEFINED _name _var) + if(DEFINED ${_name}_${_var}) + set(${_name}_${_var} "") + endif(DEFINED ${_name}_${_var}) + + string(TOUPPER ${_name} _nameUpper) + if(DEFINED ${_nameUpper}_${_var}) + set(${_nameUpper}_${_var} "") + endif(DEFINED ${_nameUpper}_${_var}) +endmacro(_MOFP_SET_EMPTY_IF_DEFINED _package _var) + + +macro (MACRO_OPTIONAL_FIND_PACKAGE _name ) + option(WITH_${_name} "Search for ${_name} package" ON) + if (WITH_${_name}) + find_package(${_name} ${ARGN}) + else (WITH_${_name}) + string(TOUPPER ${_name} _nameUpper) + set(${_name}_FOUND FALSE) + set(${_nameUpper}_FOUND FALSE) + + _mofp_set_empty_if_defined(${_name} INCLUDE_DIRS) + _mofp_set_empty_if_defined(${_name} INCLUDE_DIR) + _mofp_set_empty_if_defined(${_name} INCLUDES) + _mofp_set_empty_if_defined(${_name} LIBRARY) + _mofp_set_empty_if_defined(${_name} LIBRARIES) + _mofp_set_empty_if_defined(${_name} LIBS) + _mofp_set_empty_if_defined(${_name} FLAGS) + _mofp_set_empty_if_defined(${_name} DEFINITIONS) + endif (WITH_${_name}) +endmacro (MACRO_OPTIONAL_FIND_PACKAGE) diff --git a/cmake/modules/QtVersionAbstraction.cmake b/cmake/modules/QtVersionAbstraction.cmake new file mode 100644 index 000000000..1c0950ae0 --- /dev/null +++ b/cmake/modules/QtVersionAbstraction.cmake @@ -0,0 +1,107 @@ +include (MacroOptionalFindPackage) +include (MacroLogFeature) + + +option(BUILD_WITH_QT4 "Build with Qt4 no matter if Qt5 was found" ON) + +if( NOT BUILD_WITH_QT4 ) + find_package(Qt5Core QUIET) + if( Qt5Core_DIR ) + find_package(Qt5Widgets QUIET) + find_package(Qt5Quick QUIET) + find_package(Qt5PrintSupport QUIET) + find_package(Qt5WebKit QUIET) + find_package(Qt5Location QUIET) + find_package(Qt5Network QUIET) + find_package(Qt5Sensors QUIET) +# find_package(Qt5WebKitWidgets QUIET) + + message(STATUS "Using Qt 5!") + + include_directories(${Qt5Widgets_INCLUDES}) + add_definitions(${Qt5Widgets_DEFINITIONS}) + set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") + + + # We need this to find the paths to qdbusxml2cpp and co + find_package(Qt5DBus REQUIRED) + + macro(qt_wrap_ui) + qt5_wrap_ui(${ARGN}) + endmacro() + + macro(qt_add_resources) + qt5_add_resources(${ARGN}) + endmacro() + +# find_package(Qt5LinguistTools REQUIRED) + macro(qt_add_translation) +# qt5_add_translation(${ARGN}) + endmacro() + + macro(qt_add_dbus_interface) + qt5_add_dbus_interface(${ARGN}) + endmacro() + + macro(qt_add_dbus_adaptor) + qt5_add_dbus_adaptor(${ARGN}) + endmacro() + + macro(setup_qt) + endmacro() + + set(QT_RCC_EXECUTABLE "${Qt5Core_RCC_EXECUTABLE}") + endif() +endif() +if( NOT Qt5Core_DIR ) + message(STATUS "Could not find Qt5, searching for Qt4 instead...") + + set(NEEDED_QT4_COMPONENTS "QtCore" "QtXml" "QtNetwork" "QtGui" "QtWebkit") + if( BUILD_TESTS ) + list(APPEND NEEDED_QT4_COMPONENTS "QtTest") + endif() + + include(${QT_USE_FILE}) + + macro_optional_find_package(Qt4 4.7.0 COMPONENTS ${NEEDED_QT4_COMPONENTS} ) + macro_log_feature(QT4_FOUND "Qt" "A cross-platform application and UI framework" "http://qt.nokia.com" TRUE "" "If you see this, although libqt4-devel is installed, check whether the \n qtwebkit-devel package and whatever contains QtUiTools is installed too") + + macro(qt5_use_modules) + endmacro() + + macro(qt_wrap_ui) + qt4_wrap_ui(${ARGN}) + endmacro() + + macro(qt_add_resources) + qt4_add_resources(${ARGN}) + endmacro() + + macro(qt_add_translation) + qt4_add_translation(${ARGN}) + endmacro() + + macro(qt_add_dbus_interface) + qt4_add_dbus_interface(${ARGN}) + endmacro() + + macro(qt_add_dbus_adaptor) + qt4_add_dbus_adaptor(${ARGN}) + endmacro() + + macro(setup_qt) + set(QT_DONT_USE_QTGUI TRUE) + set(QT_USE_QTSQL TRUE) + set(QT_USE_QTNETWORK TRUE) + set(QT_USE_QTXML TRUE) + set(QT_USE_QTWEBKIT TRUE) + + include( ${QT_USE_FILE} ) + endmacro() +endif() + +if( Qt5Core_DIR ) + set( HAVE_QT5 TRUE ) +else( Qt5Core_DIR ) + set( HAVE_QT5 FALSE ) +endif( Qt5Core_DIR ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1c15823c4..64c8d92ba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,34 +1,16 @@ -include(${QT_USE_FILE}) - include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) -QT4_ADD_RESOURCES ( MIRALL_RC_SRC ../mirall.qrc) +qt_add_resources(MIRALL_RC_SRC ../mirall.qrc) if ( IS_DIRECTORY ${OEM_THEME_DIR} ) - QT4_ADD_RESOURCES ( MIRALL_RC_SRC ${OEM_THEME_DIR}/theme.qrc) + qt_add_resources(MIRALL_RC_SRC ${OEM_THEME_DIR}/theme.qrc) set(theme_dir ${OEM_THEME_DIR}/theme) else() - QT4_ADD_RESOURCES ( MIRALL_RC_SRC ../theme.qrc) + qt_add_resources(MIRALL_RC_SRC ../theme.qrc) set(theme_dir ${CMAKE_CURRENT_SOURCE_DIR}/../theme) endif() set(synclib_NAME ${APPLICATION_EXECUTABLE}sync) -set(mirall_UI -mirall/folderwizardsourcepage.ui -mirall/folderwizardtargetpage.ui -mirall/sslerrordialog.ui -mirall/settingsdialog.ui -mirall/generalsettings.ui -mirall/networksettings.ui -mirall/accountsettings.ui -mirall/ignorelisteditor.ui -mirall/itemprogressdialog.ui -wizard/owncloudsetupnocredspage.ui -wizard/owncloudhttpcredspage.ui -wizard/owncloudwizardresultpage.ui -wizard/owncloudadvancedsetuppage.ui -) - set(3rdparty_SRC 3rdparty/qtsingleapplication/qtsingleapplication.cpp 3rdparty/qtsingleapplication/qtlocalpeer.cpp @@ -45,7 +27,7 @@ set(3rdparty_HEADER 3rdparty/fancylineedit/fancylineedit.h 3rdparty/QProgressIndicator/QProgressIndicator.h ) -qt4_wrap_cpp(3rdparty_MOC ${3rdparty_HEADER}) +qt_wrap_cpp(3rdparty_MOC ${3rdparty_HEADER}) if(NOT WIN32) list(APPEND 3rdparty_SRC 3rdparty/qtlockedfile/qtlockedfile_unix.cpp) @@ -60,8 +42,6 @@ set(3rdparty_INC ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/fancylineedit ) -qt4_wrap_ui(mirall_UI_SRCS ${mirall_UI}) - set(libsync_SRCS mirall/folderman.cpp mirall/folder.cpp @@ -135,7 +115,7 @@ IF( APPLE ) ENDIF() -qt4_wrap_cpp(syncMoc ${libsync_HEADERS}) +qt_wrap_cpp(syncMoc ${libsync_HEADERS}) list(APPEND libsync_LINK_TARGETS ${QT_LIBRARIES} @@ -149,6 +129,9 @@ if(QTKEYCHAIN_FOUND) endif() add_library(${synclib_NAME} SHARED ${libsync_SRCS} ${syncMoc}) + +qt5_use_modules(${synclib_NAME} Widgets Network Xml Quick WebKitWidgets) + set_target_properties( ${synclib_NAME} PROPERTIES VERSION ${VERSION} SOVERSION ${SOVERSION} @@ -175,6 +158,24 @@ else() install(TARGETS ${synclib_NAME} DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/MacOS) endif() +set(mirall_UI +mirall/folderwizardsourcepage.ui +mirall/folderwizardtargetpage.ui +mirall/sslerrordialog.ui +mirall/settingsdialog.ui +mirall/generalsettings.ui +mirall/networksettings.ui +mirall/accountsettings.ui +mirall/ignorelisteditor.ui +mirall/itemprogressdialog.ui +wizard/owncloudsetupnocredspage.ui +wizard/owncloudhttpcredspage.ui +wizard/owncloudwizardresultpage.ui +wizard/owncloudadvancedsetuppage.ui +) + +qt_wrap_ui(mirall_UI_SRCS ${mirall_UI}) + set(mirall_SRCS mirall/application.cpp mirall/systray.cpp @@ -234,9 +235,9 @@ endif() include_directories(${CSYNC_INCLUDE_DIR}/csync ${CSYNC_INCLUDE_DIR} ${CSYNC_BUILD_PATH}/src) include_directories(${3rdparty_INC}) -qt4_wrap_cpp(mirallMoc ${mirall_HEADERS}) +qt_wrap_cpp(mirallMoc ${mirall_HEADERS}) -qt4_add_translation(mirall_I18N ${TRANSLATIONS}) +qt_add_translation(mirall_I18N ${TRANSLATIONS}) set( final_src ${mirall_HEADERS} @@ -276,7 +277,7 @@ endif(NOT WIN32) # add_executable( ${APPLICATION_EXECUTABLE} main.cpp ${final_src}) add_executable( ${APPLICATION_EXECUTABLE} WIN32 main.cpp ${final_src}) - + qt5_use_modules(${APPLICATION_EXECUTABLE} Widgets Network Xml) else() set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") include(DeployQt4) @@ -286,6 +287,7 @@ else() # we must add MACOSX_BUNDLE only if building a bundle add_executable( ${APPLICATION_EXECUTABLE} WIN32 MACOSX_BUNDLE main.cpp ${final_src}) + qt5_use_modules(${APPLICATION_EXECUTABLE} Widgets Network Xml) #FIXME: hardcoded path if ( EXISTS ${CSYNC_BINARY_DIR}/modules/ocsync_owncloud.so ) diff --git a/src/creds/shibboleth/shibbolethaccessmanager.cpp b/src/creds/shibboleth/shibbolethaccessmanager.cpp index 5e9d1cf16..cbef802c1 100644 --- a/src/creds/shibboleth/shibbolethaccessmanager.cpp +++ b/src/creds/shibboleth/shibbolethaccessmanager.cpp @@ -13,6 +13,7 @@ #include #include +#include #include "creds/shibboleth/shibbolethaccessmanager.h" diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp index 97055c7a0..db354e149 100644 --- a/src/mirall/folder.cpp +++ b/src/mirall/folder.cpp @@ -481,7 +481,7 @@ void Folder::setProxy() if( _csync_ctx ) { /* Store proxy */ QUrl proxyUrl(ownCloudInfo::instance()->webdavUrl()); - QList proxies = QNetworkProxyFactory::proxyForQuery(proxyUrl); + QList proxies = QNetworkProxyFactory::proxyForQuery(QNetworkProxyQuery(proxyUrl)); // We set at least one in Application Q_ASSERT(proxies.count() > 0); QNetworkProxy proxy = proxies.first(); diff --git a/src/mirall/mirallconfigfile.cpp b/src/mirall/mirallconfigfile.cpp index 7fe93735b..b5a7e3be5 100644 --- a/src/mirall/mirallconfigfile.cpp +++ b/src/mirall/mirallconfigfile.cpp @@ -18,10 +18,12 @@ #include "mirall/owncloudinfo.h" #include "mirall/owncloudtheme.h" #include "mirall/theme.h" +#include "mirall/utility.h" + #include "creds/abstractcredentials.h" #include "creds/credentialsfactory.h" -#include -#include + +#include #define DEFAULT_REMOTE_POLL_INTERVAL 30000 // default remote poll time in milliseconds #define DEFAULT_MAX_LOG_LINES 20000 @@ -159,7 +161,7 @@ void MirallConfigFile::restoreGeometry(QWidget *w) QString MirallConfigFile::configPath() const { if( _confDir.isEmpty() ) { - _confDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + _confDir = Utility::dataLocation(); } QString dir = _confDir; diff --git a/src/mirall/owncloudinfo.cpp b/src/mirall/owncloudinfo.cpp index f2376e3d5..3f22c6cdb 100644 --- a/src/mirall/owncloudinfo.cpp +++ b/src/mirall/owncloudinfo.cpp @@ -138,9 +138,13 @@ QNetworkReply* ownCloudInfo::mkdirRequest( const QString& dir ) qDebug() << "OCInfo Making dir " << dir; _authAttempts = 0; QNetworkRequest req; - QUrl url = QUrl(webdavUrl(_connection)); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QUrl url(webdavUrl(_connection)); url.setEncodedPath(url.encodedPath()+QUrl::toPercentEncoding(dir, "/")); - +#else + QUrl url(webdavUrl(_connection)); + url.setPath(url.path(QUrl::FullyEncoded)+QUrl::toPercentEncoding(dir, "/")); +#endif req.setUrl( url ); QNetworkReply *reply = davRequest("MKCOL", req, 0); diff --git a/src/mirall/sslerrordialog.cpp b/src/mirall/sslerrordialog.cpp index b779c691d..40f9dbeb5 100644 --- a/src/mirall/sslerrordialog.cpp +++ b/src/mirall/sslerrordialog.cpp @@ -142,9 +142,9 @@ QString SslErrorDialog::certDiv( QSslCertificate cert ) const msg += QL("
"); QStringList li; - QString org = Qt::escape(cert.subjectInfo( QSslCertificate::Organization)); - QString unit = Qt::escape(cert.subjectInfo( QSslCertificate::OrganizationalUnitName)); - QString country = Qt::escape(cert.subjectInfo( QSslCertificate::CountryName)); + QString org = Utility::escape(cert.subjectInfo( QSslCertificate::Organization)); + QString unit = Utility::escape(cert.subjectInfo( QSslCertificate::OrganizationalUnitName)); + QString country = Utility::escape(cert.subjectInfo( QSslCertificate::CountryName)); if (unit.isEmpty()) unit = tr("<not specified>"); if (org.isEmpty()) org = tr("<not specified>"); if (country.isEmpty()) country = tr("<not specified>"); diff --git a/src/mirall/utility.cpp b/src/mirall/utility.cpp index 32cce92b9..53e5d29ef 100644 --- a/src/mirall/utility.cpp +++ b/src/mirall/utility.cpp @@ -24,6 +24,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#include +#else +#include +#endif + #ifdef Q_OS_UNIX #include #include @@ -51,7 +57,7 @@ QString Utility::formatFingerprint( const QByteArray& fmhash ) hash.append(' '); } - QString fp = QString::fromAscii( hash.trimmed() ); + QString fp = QString::fromLatin1( hash.trimmed() ); fp.replace(QChar(' '), QChar(':')); return fp; @@ -369,4 +375,22 @@ QString Utility::toCSyncScheme(const QString &urlStr) return url.toString(); } +QString Utility::escape(const QString &in) +{ +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + return Qt::escape(in); +#else + return in.toHtmlEscaped(); +#endif +} + +QString Utility::dataLocation() +{ +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + return QDesktopServices::storageLocation(QDesktopServices::DataLocation); +#else + return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); +#endif +} + } // namespace Mirall diff --git a/src/mirall/utility.h b/src/mirall/utility.h index 46022c725..2a33fa182 100644 --- a/src/mirall/utility.h +++ b/src/mirall/utility.h @@ -44,6 +44,11 @@ namespace Utility * @return the formatted string. */ QString compactFormatDouble(double value, int prec, const QString& unit = QString::null); + + // porting methods + QString escape(const QString&); + QString dataLocation(); + } }