This commit is contained in:
Matthias Kuhn 2024-12-10 11:37:45 +01:00
parent d255d21eff
commit 42e044ca4f
3 changed files with 83 additions and 63 deletions

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.10.0)
if(POLICY CMP0048) # in CMake >= 3.0.0
cmake_policy(SET CMP0048 OLD) # keep project() from clearing VERSION variables
cmake_policy(SET CMP0048 NEW)
endif(POLICY CMP0048)
set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
@ -16,9 +16,9 @@ set(CPACK_PACKAGE_VERSION_PATCH ${VER_PATCH})
set(PROJECT_VERSION ${VER_MAJOR}.${VER_MINOR}.${VER_PATCH})
set(API_VERSION ${VER_MAJOR}.${VER_MINOR}.${API_VER_PATCH})
project(o2)
project(o2 VERSION ${PROJECT_VERSION})
option(o2_WITH_QT5 "Use Qt5" ON)
option(o2_WITH_QT6 "Use Qt6" ON)
set(o2_LIB_SUFFIX "" CACHE STRING "Suffix for install 'lib' directory, e.g. 64 for lib64")
@ -27,19 +27,76 @@ if(NOT o2_SHOW_TRACE)
add_definitions(-DQT_NO_DEBUG_OUTPUT=1)
endif()
option(o2_WITH_TESTS "Enable tests" OFF)
option(o2_WITH_TWITTER "Authenticate with Twitter" OFF)
option(o2_WITH_DROPBOX "Authenticate with Dropbox" OFF)
option(o2_WITH_GOOGLE "Authenticate with Google" OFF)
option(o2_WITH_VIMEO "Authenticate with Vimeo" OFF)
option(o2_WITH_FACEBOOK "Authenticate with Facebook" OFF)
option(o2_WITH_UBER "Authenticate with Uber" OFF)
option(o2_WITH_SKYDRIVE "Authenticate with SkyDrive" OFF)
option(o2_WITH_FLICKR "Authenticate with Flickr" OFF)
option(o2_WITH_HUBIC "Authenticate with Hubic" OFF)
option(o2_WITH_SPOTIFY "Authenticate with Spotify" OFF)
option(o2_WITH_SURVEYMONKEY "Authenticate with SurveyMonkey" OFF)
option(o2_WITH_SMUGMUG "Authenticate with SmugMug" OFF)
option(o2_WITH_MSGRAPH "Authenticate with MSGraph" OFF)
option(o2_WITH_KEYCHAIN "keychain store" ON)
option(o2_WITH_OAUTH1 "Include OAuth1 authentication" OFF)
if(o2_WITH_TWITTER OR o2_WITH_DROPBOX OR o2_WITH_FLICKR)
if (o2_WITH_TWITTER)
set(HAVE_TWITTER_SUPPORT 1)
endif()
if (o2_WITH_DROPBOX)
set(HAVE_DROPBOX_SUPPORT 1)
endif()
if (o2_WITH_GOOGLE)
set(HAVE_GOOGLE_SUPPORT 1)
endif()
if (o2_WITH_FACEBOOK)
set(HAVE_FACEBOOK_SUPPORT 1)
endif()
if (o2_WITH_UBER)
set(HAVE_UBER_SUPPORT 1)
endif()
if (o2_WITH_SKYDRIVE)
set(HAVE_SKYDRIVE_SUPPORT 1)
endif()
if (o2_WITH_FLICKR)
set(HAVE_FLICKR_SUPPORT 1)
endif()
if (o2_WITH_HUBIC)
set(HAVE_HUBIC_SUPPORT 1)
endif()
if (o2_WITH_SPOTIFY)
set(HAVE_SPOTIFY_SUPPORT 1)
endif()
if (o2_WITH_SURVEYMONKEY)
set(HAVE_SURVEYMONKEY_SUPPORT 1)
endif()
if (o2_WITH_SMUGMUG)
set(HAVE_SMUGMUG_SUPPORT 1)
endif()
if (o2_WITH_MSGRAPH)
set(HAVE_MSGRAPH_SUPPORT 1)
endif()
if (o2_WITH_KEYCHAIN)
set(HAVE_KEYCHAIN_SUPPORT 1)
endif()
if (o2_WITH_OAUTH1)
set(HAVE_OAUTH1_SUPPORT 1)
endif()
if(o2_WITH_KEYCHAIN)
if(o2_WITH_QT6)
find_package(Qt6Keychain CONFIG REQUIRED)
else()
find_package(Qt5Keychain CONFIG REQUIRED)
endif()
endif(o2_WITH_KEYCHAIN)
if(o2_WITH_TWITTER OR o2_WITH_DROPBOX OR o2_WITH_FLICKR OR o2_WITH_SMUGMUG)
set(o2_WITH_OAUTH1 ON)
endif()
@ -54,3 +111,8 @@ add_subdirectory(src)
if(o2_BUILD_EXAMPLES)
add_subdirectory(examples)
endif(o2_BUILD_EXAMPLES)
if(o2_WITH_TESTS)
enable_testing()
add_subdirectory(tests)
endif()

View File

@ -1,22 +1,14 @@
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.10.0)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
if(o2_WITH_QT5)
if(o2_WITH_QT6)
find_package(Qt6 COMPONENTS Core Network REQUIRED)
else()
find_package(Qt5 COMPONENTS Core Network REQUIRED)
else(o2_WITH_QT5)
set(QT_USE_QTNETWORK true)
set(QT_USE_QTSCRIPT true)
find_package(Qt4 REQUIRED)
endif(o2_WITH_QT5)
#find_package(QJson REQUIRED)
if (NOT o2_WITH_QT5)
include( ${QT_USE_FILE} )
endif(NOT o2_WITH_QT5)
endif()
set( o2_SRCS
o2.cpp
@ -192,37 +184,19 @@ if(o2_WITH_MSGRAPH)
endif(o2_WITH_MSGRAPH)
if(o2_WITH_KEYCHAIN)
if (Qt5Core_DIR)
find_package(Qt5Keychain REQUIRED)
else()
find_package(QtKeychain REQUIRED)
endif()
if(QTKEYCHAIN_FOUND OR QT5KEYCHAIN_FOUND)
MESSAGE("Found QTKeychain")
list(APPEND LINK_TARGETS ${QTKEYCHAIN_LIBRARY})
include_directories(${QTKEYCHAIN_INCLUDE_DIR})
set( o2_SRCS
${o2_SRCS}
o0keychainstore.cpp
)
set( o2_HDRS
${o2_HDRS}
o0keychainstore.h
)
else()
MESSAGE("Qt5Keychain or QtKeychain is required")
endif()
list(APPEND LINK_TARGETS ${QTKEYCHAIN_LIBRARIES})
include_directories(SYSTEM ${QTKEYCHAIN_INCLUDE_DIRS})
set( o2_SRCS
${o2_SRCS}
o0keychainstore.cpp
)
set( o2_HDRS
${o2_HDRS}
o0keychainstore.h
)
endif(o2_WITH_KEYCHAIN)
if(NOT o2_WITH_QT5)
add_definitions(${QT4_DEFINITIONS})
endif(NOT o2_WITH_QT5)
if(BUILD_SHARED_LIBS AND APPLE AND POLICY CMP0042) # in CMake >= 2.8.12
cmake_policy(SET CMP0042 OLD)
set(CMAKE_MACOSX_RPATH OFF) # don't embed @rpath in install name
@ -234,11 +208,7 @@ if(BUILD_SHARED_LIBS)
add_definitions( -DO2_SHARED_LIB )
endif(BUILD_SHARED_LIBS)
if(o2_WITH_QT5)
target_link_libraries( o2 Qt5::Core Qt5::Network ${LINK_TARGETS})
else(o2_WITH_QT5)
target_link_libraries( o2 ${QT_LIBRARIES} ${LINK_TARGETS})
endif(o2_WITH_QT5)
target_link_libraries( o2 Qt::Core Qt::Network ${LINK_TARGETS})
if(BUILD_SHARED_LIBS)
if(APPLE)

View File

@ -10,16 +10,8 @@
#include <QTimer>
#include <QVariantMap>
#include <QUuid>
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
#include <QUrlQuery>
#endif
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
#include <QRegularExpression>
#else
#include <QRegExp>
#endif
#include "o2.h"
#include "o2pollserver.h"
@ -197,12 +189,8 @@ void O2::link() {
if (grantFlow_ == GrantFlowAuthorizationCode || grantFlow_ == GrantFlowImplicit || grantFlow_ == GrantFlowPkce) {
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
const thread_local QRegularExpression rx("([^a-zA-Z0-9]|[-])");
QString uniqueState = QUuid::createUuid().toString().remove(rx);
#else
QString uniqueState = QUuid::createUuid().toString().remove(QRegExp("([^a-zA-Z0-9]|[-])"));
#endif
if (useExternalWebInterceptor_) {
// Save redirect URI, as we have to reuse it when requesting the access token
redirectUri_ = localhostPolicy_.arg(localPort());