make contacts and calendar service optional 83/30183/1 tizen_3.0_ivi accepted/tizen/common/20141121.093657 accepted/tizen/ivi/20141201.015707 submit/tizen/20141120.100440 tizen_3.0_ivi_release
authorPatrick Ohly <patrick.ohly@intel.com>
Wed, 12 Nov 2014 12:27:29 +0000 (13:27 +0100)
committerPatrick Ohly <patrick.ohly@intel.com>
Wed, 12 Nov 2014 12:39:15 +0000 (13:39 +0100)
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 <patrick.ohly@intel.com>
bt-share/CMakeLists.txt
bt-share/src/obex-event-handler.c
packaging/bluetooth-share.spec

index 0b3efbe..b124b7f 100644 (file)
@@ -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)
index 97cd205..4a8c30a 100644 (file)
 #include <string.h>
 #include <glib.h>
 #include <vconf-keys.h>
+#ifdef ENABLE_CALENDAR_SERVICE2
 #include <calendar2.h>
+#endif
+#ifdef ENABLE_CONTACTS_SERVICE2
 #include <contacts.h>
+#endif
 #include <vconf.h>
 #include <Ecore_File.h>
 #include <bluetooth-share-api.h>
@@ -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;
index b0022d2..47fd18d 100644 (file)
@@ -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)