From a3a462223089c044c993ee3824b1759be1e05a14 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Wed, 12 Nov 2014 13:27:29 +0100 Subject: [PATCH] make contacts and calendar service optional If enabled, incoming vcard and vcalendar items are stored in contact service resp. calendar service. When disabled, such incoming items are silently discarded. This follows the approach already taken for vbookmark items. The enabled/disabled check in CMake only looks at availability of the .pc files. The .spec file then makes the .pc files available only when desired. This is a bit error prone because something might pull them in indirectly. However, that itself would be a bug and thus this simple approach of extending CMake rules was used. Only the mobile profile uses these services. Instead of checking for the profile, a package or system bcond would be better. But that needs to be fixed across multiple packages consistently and thus is not done as part of this commit here. Change-Id: I4eef2ab9cb20b9721becac5ea5989c74c183ab22 Signed-off-by: Patrick Ohly --- bt-share/CMakeLists.txt | 14 +++++++++++--- bt-share/src/obex-event-handler.c | 12 ++++++++++++ packaging/bluetooth-share.spec | 4 ++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/bt-share/CMakeLists.txt b/bt-share/CMakeLists.txt index 0b3efbe..b124b7f 100644 --- a/bt-share/CMakeLists.txt +++ b/bt-share/CMakeLists.txt @@ -19,12 +19,14 @@ INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED glib-2.0 bluetooth-api dbus-glib-1 appcore-common dlog vconf pmapi sysman - notification calendar-service2 contacts-service2 + notification appsvc appcore-efl libprivilege-control capi-content-media-content libtzplatform-config) +pkg_check_modules(CALENDAR_SERVICE2 calendar-service2) +pkg_check_modules(CONTACTS_SERVICE2 contacts-service2) -FOREACH(flag ${pkgs_CFLAGS}) +FOREACH(flag ${pkgs_CFLAGS} ${CALENDAR_SERVICE2_CFLAGS} ${CONTACTS_SERVICE2_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -finstrument-functions") @@ -40,9 +42,15 @@ ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"") ADD_DEFINITIONS("-DTARGET") ADD_DEFINITIONS("-DSLP_DEBUG") +if(CALENDAR_SERVICE2_FOUND) + ADD_DEFINITIONS("-DENABLE_CALENDAR_SERVICE2") +endif(CALENDAR_SERVICE2_FOUND) +if(CONTACTS_SERVICE2_FOUND) + ADD_DEFINITIONS("-DENABLE_CONTACTS_SERVICE2") +endif(CONTACTS_SERVICE2_FOUND) ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/../lib -lbluetooth-share-api) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${CALENDAR_SERVICE2_LDFLAGS} ${CONTACTS_SERVICE2_LDFLAGS} -L${CMAKE_CURRENT_SOURCE_DIR}/../lib -lbluetooth-share-api) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) diff --git a/bt-share/src/obex-event-handler.c b/bt-share/src/obex-event-handler.c index 97cd205..4a8c30a 100644 --- a/bt-share/src/obex-event-handler.c +++ b/bt-share/src/obex-event-handler.c @@ -23,8 +23,12 @@ #include #include #include +#ifdef ENABLE_CALENDAR_SERVICE2 #include +#endif +#ifdef ENABLE_CONTACTS_SERVICE2 #include +#endif #include #include #include @@ -719,6 +723,7 @@ static bt_file_type_t __get_file_type(char *extn) return BT_FILE_OTHER; } +#ifdef ENABLE_CONTACTS_SERVICE2 static bool __bt_vcard_handler(contacts_record_h record, void *user_data) { int ret; @@ -730,7 +735,9 @@ static bool __bt_vcard_handler(contacts_record_h record, void *user_data) return true; } +#endif /* ENABLE_CONTACTS_SERVICE2 */ +#ifdef ENABLE_CALENDAR_SERVICE2 static bool __bt_vcalendar_handler(calendar_record_h record, void *user_data) { int ret; @@ -742,6 +749,7 @@ static bool __bt_vcalendar_handler(calendar_record_h record, void *user_data) return true; } +#endif /* ENABLE_CALENDAR_SERVICE2 */ static gboolean __bt_save_v_object(char *file_path, bt_file_type_t file_type) @@ -752,6 +760,7 @@ static gboolean __bt_save_v_object(char *file_path, DBG("file_path = %s, file_type = %d\n", file_path, file_type); switch (file_type) { +#ifdef ENABLE_CONTACTS_SERVICE2 case BT_FILE_VCARD: ret = contacts_connect2(); if (ret != CONTACTS_ERROR_NONE) { @@ -776,7 +785,9 @@ static gboolean __bt_save_v_object(char *file_path, return FALSE; } break; +#endif /* ENABLE_CONTACTS_SERVICE2 */ +#ifdef ENABLE_CALENDAR_SERVICE2 case BT_FILE_VCAL: ret = calendar_connect(); if (ret != CALENDAR_ERROR_NONE) { @@ -800,6 +811,7 @@ static gboolean __bt_save_v_object(char *file_path, return FALSE; } break; +#endif /* ENABLE_CALENDAR_SERVICE2 */ default: break; diff --git a/packaging/bluetooth-share.spec b/packaging/bluetooth-share.spec index b0022d2..47fd18d 100644 --- a/packaging/bluetooth-share.spec +++ b/packaging/bluetooth-share.spec @@ -19,8 +19,12 @@ BuildRequires: pkgconfig(appcore-efl) BuildRequires: pkgconfig(bluetooth-api) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(dlog) +# Same check as in tizen-extensions-crosswalk. A per-package or global +# bcond would be better, but for now let's follow Crosswalk's approach. +%if "%{profile}" == "mobile" BuildRequires: pkgconfig(calendar-service2) BuildRequires: pkgconfig(contacts-service2) +%endif BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(pmapi) BuildRequires: pkgconfig(sysman) -- 2.7.4