Skip to content

Commit

Permalink
Merge pull request #15 from gonicus/carddav-github
Browse files Browse the repository at this point in the history
feat: carddav contact support
  • Loading branch information
cajus authored Feb 12, 2025
2 parents 59ab124 + 61136c7 commit 5672fbd
Show file tree
Hide file tree
Showing 30 changed files with 859 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gonnect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
qt-version: ${{ env.QT_VERSION }}

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=ON -DCMAKE_PREFIX_PATH="${{github.workspace}}/pjproject;${{github.workspace}}/qca/lib/cmake"
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=ON -DBUILD_DEPENDENCIES=ON -DCMAKE_PREFIX_PATH="${{github.workspace}}/pjproject;${{github.workspace}}/qca/lib/cmake"

- name: Build
# Build your program with the given configuration
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

option(BUILD_DEPENDENCIES "Build dependencies" OFF)

if(NOT LINUX)
message(FATAL_ERROR "GOnnect only works for Linux/Flatpack targets")
endif()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Here's a short feature list:

* Call forwarding
* Conference calls with three parties
* LDAP address sources
* LDAP/CardDAV address sources
* Busy state for supported sources
* Configurable identities for outgoing calls
* Configurable busy on active call
Expand Down
30 changes: 30 additions & 0 deletions patches/qtwebdav-cmake-lowercase.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6883604..c410318 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,15 +5,15 @@ find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Network Xml REQUIRED)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
add_library(QtWebDAV SHARED
- QNaturalSort.cpp
- QNaturalSort.h
- QWebDAV.cpp
- QWebDAV.h
- QWebDAV_global.h
- QWebDAVDirParser.cpp
- QWebDAVDirParser.h
- QWebDAVItem.cpp
- QWebDAVItem.h
+ qnaturalsort.cpp
+ qnaturalsort.h
+ qwebdav.cpp
+ qwebdav.h
+ qwebdav_global.h
+ qwebdavdirparser.cpp
+ qwebdavdirparser.h
+ qwebdavitem.cpp
+ qwebdavitem.h
)

target_link_libraries(QtWebDAV PUBLIC

10 changes: 10 additions & 0 deletions patches/vcard-disable-testing.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b8d0506..0f14d34 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,5 +6,3 @@ set(CMAKE_CXX_STANDARD 14)
include_directories(include)

add_subdirectory(src)
-ENABLE_TESTING()
-add_subdirectory(test)
7 changes: 4 additions & 3 deletions resources/flatpak/de.gonicus.gonnect.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@
<keyword>phone</keyword>
</keywords>

<url type="homepage">https://www.gonicus.de</url>
<url type="bugtracker">https://www.gonicus.de</url>
<url type="help">https://www.gonicus.de</url>
<url type="homepage">https://github.com/gonicus/gonnect</url>
<url type="bugtracker">https://github.com/gonicus/gonnect/issues</url>
<url type="help">https://github.com/gonicus/gonnect/wiki</url>
<url type="contact">https://www.gonicus.de</url>

<provides>
<binary>gonnect</binary>
Expand Down
18 changes: 18 additions & 0 deletions resources/flatpak/de.gonicus.gonnect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ modules:
url: "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-2.6.9.tgz"
sha256: 2cb7dc73e9c8340dff0d99357fbaa578abf30cc6619f0521972c555681e6b2ff

- name: qtwebdav
buildsystem: cmake-ninja
sources:
- type: git
url: https://github.com/PikachuHy/QtWebDAV.git
commit: 4739a0f09cd005b9584f740637882be41ec0f062
- type: patch
path: patches/qtwebdav-cmake.patch

- name: vcard
buildsystem: cmake-ninja
sources:
- type: git
url: https://github.com/ivanenko/vCard.git
commit: 733afa9571a728548106c5131c48895bd932e881
- type: patch
path: patches/vcard-cmake.patch

- shared-modules/libusb/libusb.json

- name: hidapi
Expand Down
69 changes: 69 additions & 0 deletions resources/flatpak/patches/qtwebdav-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6883604..7be4550 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,29 +2,50 @@ cmake_minimum_required(VERSION 3.19)
project(QtWebDAV)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Network Xml REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Network Xml REQUIRED)
-set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
-set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
+
add_library(QtWebDAV SHARED
- QNaturalSort.cpp
- QNaturalSort.h
- QWebDAV.cpp
- QWebDAV.h
- QWebDAV_global.h
- QWebDAVDirParser.cpp
- QWebDAVDirParser.h
- QWebDAVItem.cpp
- QWebDAVItem.h
+ qnaturalsort.cpp
+ qnaturalsort.h
+ qwebdav.cpp
+ qwebdav.h
+ qwebdav_global.h
+ qwebdavdirparser.cpp
+ qwebdavdirparser.h
+ qwebdavitem.cpp
+ qwebdavitem.h
)

target_link_libraries(QtWebDAV PUBLIC
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Xml
)
-target_include_directories(QtWebDAV PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(QtWebDAV PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+ $<INSTALL_INTERFACE:include>
+)
target_compile_definitions(QtWebDAV PRIVATE -DQWEBDAV_LIBRARY)
target_compile_definitions(QtWebDAV PRIVATE DEBUG_WEBDAV)
set_target_properties(QtWebDAV PROPERTIES AUTOMOC ON)
+
+file(GLOB_RECURSE QTWEBDAV_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
+set_target_properties(${PROJECT_NAME}
+ PROPERTIES PUBLIC_HEADER "${QTWEBDAV_INCLUDE_FILES}"
+)
+
option(BUILD_EXAMPLE "Build with example")
if (BUILD_EXAMPLE)
add_subdirectory(example)
-endif()
\ No newline at end of file
+endif()
+
+install(TARGETS ${CMAKE_PROJECT_NAME}
+ EXPORT targets
+ LIBRARY
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ PUBLIC_HEADER
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+)
+
+install(EXPORT targets
+ FILE ${CMAKE_PROJECT_NAME}Config.cmake
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
+)
42 changes: 42 additions & 0 deletions resources/flatpak/patches/vcard-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b8d0506..0f14d34 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,5 +6,3 @@ set(CMAKE_CXX_STANDARD 14)
include_directories(include)

add_subdirectory(src)
-ENABLE_TESTING()
-add_subdirectory(test)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f24ebe4..434b9ec 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -8,12 +8,24 @@ utils.cpp )

target_include_directories(${CMAKE_PROJECT_NAME}
PUBLIC
- $<INSTALL_INTERFACE:include>
+ $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)

+file(GLOB_RECURSE VCARD_INCLUDE_FILES "${PROJECT_SOURCE_DIR}/include/*.h")
+set_target_properties(${PROJECT_NAME}
+ PROPERTIES PUBLIC_HEADER "${VCARD_INCLUDE_FILES}"
+)
+
+include(GNUInstallDirs)
install(TARGETS ${CMAKE_PROJECT_NAME}
+ EXPORT targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
\ No newline at end of file
+ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+
+install(EXPORT targets
+ FILE ${CMAKE_PROJECT_NAME}Config.cmake
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
+)
29 changes: 29 additions & 0 deletions resources/templates/sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ maxCalls=4
## default: false
#noVad=false

## Use a software clock to synchronize media streaming. May lead to better latency.
#softwareClock=true

## Clock rate to be applied to the conference bridge. If value is zero, default clock rate will be used (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
## default: 16000
#clockRate=16000
Expand Down Expand Up @@ -463,3 +466,29 @@ port=5061
## (optional)
#sipStatusSubscriptableAttributes="telephoneNumber"

## A CardDAV block defines a CardDAV source for the address book.
## The password for the authentication will be requested in a UI dialog on next start of the app. It will then be saved encrypted for further usage in
## the config file named "keychain". Delete the appropriate part there to enforce a new password request.
## The contacts will be loaded asynchronously on app start. Depending on quantity and server speed, it might take a few minutes until all contacts
## are loaded.
## Example (all fields are mandatory unless specified as optional):

## Each block (= CardDAV source) must have the name "carddav", followed by one or more digits.
# [carddav0]

## The host is the main host address of the remote server, without any port, protocol or path data.
# host=cloud.mycompany.com

## The path relative to the host were to find the resource.
# path=/remote.php/dav/addressbooks/users/john/contacts/

## The user name required for the authentication.
# user=john

## The server port.
## (optional, defaults: 443 is used if useSSL is true, 80 if false)
# port=443

## Whether to use SSL (https) or not (http).
## (optional, default: true)
# useSSL=true
32 changes: 32 additions & 0 deletions sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
## default: false
#noVad=false

## Use a software clock to synchronize media streaming. May lead to better latency.
#softwareClock=true

## Clock rate to be applied to the conference bridge. If value is zero, default clock rate will be used (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
## default: 16000
#clockRate=16000
Expand Down Expand Up @@ -464,3 +467,32 @@
## (optional)
#sipStatusSubscriptableAttributes="telephoneNumber"


## A CardDAV block defines a CardDAV source for the address book.
## The password for the authentication will be requested in a UI dialog on next start of the app. It will then be saved encrypted for further usage in
## the config file named "keychain". Delete the appropriate part there to enforce a new password request.
## The contacts will be loaded asynchronously on app start. Depending on quantity and server speed, it might take a few minutes until all contacts
## are loaded.
## Example (all fields are mandatory unless specified as optional):

## Each block (= CardDAV source) must have the name "carddav", followed by one or more digits.
# [carddav0]

## The host is the main host address of the remote server, without any port, protocol or path data.
# host=cloud.mycompany.com

## The path relative to the host were to find the resource.
# path=/remote.php/dav/addressbooks/users/john/contacts/

## The user name required for the authentication.
# user=john

## The server port.
## (optional, defaults: 443 is used if useSSL is true, 80 if false)
# port=443

## Whether to use SSL (https) or not (http).
## (optional, default: true)
# useSSL=true


38 changes: 36 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Quick QuickControls2 Multimedia Sql Core5Compat)
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Quick QuickControls2 Multimedia Sql Core5Compat Xml)
find_package(Qca-qt6 REQUIRED)

include(FindPkgConfig)
Expand Down Expand Up @@ -86,6 +86,35 @@ set(gonnect_qml_singletons
)
set_source_files_properties(${gonnect_qml_singletons} PROPERTIES QT_QML_SINGLETON_TYPE TRUE)

if(BUILD_DEPENDENCIES)
include(ExternalProject)

ExternalProject_Add(qtwebdav
GIT_REPOSITORY https://github.com/PikachuHy/QtWebDAV.git
CMAKE_ARGS -DCMAKE_PREFIX_PATH=${QT6_INSTALL_PREFIX} -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
PATCH_COMMAND git apply "${PROJECT_SOURCE_DIR}/resources/flatpak/patches/qtwebdav-cmake.patch"
UPDATE_DISCONNECTED TRUE
)
ExternalProject_Get_Property(qtwebdav INSTALL_DIR)
target_include_directories(gonnect SYSTEM PRIVATE ${INSTALL_DIR}/include)
target_link_directories(gonnect PRIVATE ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR})

ExternalProject_Add(vcard
GIT_REPOSITORY https://github.com/ivanenko/vCard.git
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
PATCH_COMMAND git apply "${PROJECT_SOURCE_DIR}/resources/flatpak/patches/vcard-cmake.patch"
UPDATE_DISCONNECTED TRUE
)
ExternalProject_Get_Property(vcard INSTALL_DIR)
target_include_directories(gonnect SYSTEM PRIVATE ${INSTALL_DIR}/include)
target_link_directories(gonnect PRIVATE ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR})

add_dependencies(gonnect vcard qtwebdav)
else()
find_package(QtWebDAV REQUIRED)
find_package(vCard REQUIRED)
endif()


qt_add_qml_module(gonnect
URI base
Expand All @@ -107,7 +136,7 @@ qt_add_qml_module(gonnect
ui/components/controls/SearchDial.qml
ui/components/controls/Switch.qml

ui/components/dialogs/AccountCredentialsDialog.qml
ui/components/dialogs/CredentialsDialog.qml
ui/components/dialogs/BaseDialog.qml
ui/components/dialogs/ConfirmDialog.qml
ui/components/dialogs/InfoDialog.qml
Expand Down Expand Up @@ -245,6 +274,8 @@ qt_add_qml_module(gonnect
contacts/AddressBookManager.h
contacts/AvatarManager.cpp
contacts/AvatarManager.h
contacts/CardDAVAddressBookFeeder.h
contacts/CardDAVAddressBookFeeder.cpp
contacts/Contact.cpp
contacts/Contact.h
contacts/ContactSerializer.cpp
Expand Down Expand Up @@ -345,13 +376,16 @@ target_link_libraries(gonnect
Qt6::Multimedia
Qt6::Sql
Qt6::Core5Compat
Qt6::Xml
${PJSIP_STATIC_LIBRARIES}
PkgConfig::LIBUUID
PkgConfig::LIBUSB1
PkgConfig::LIBHIDAPI
GOnnectVersion
qca-qt6
hid-rp
vCard
QtWebDAV
)

target_include_directories(gonnect
Expand Down
Loading

0 comments on commit 5672fbd

Please sign in to comment.