- This is for Tizen 4.0.
: Tizen 4.0 Configurability and Build Blocks require
to remove all profile-depending build options in spec files.
(No More profile macros)
- It is recommended to distinguish features/profiles at runtime.
unless it incurs too much overhead, which requires you to
create multiple binaries and subpackages.
Runtime profile determination is activated only for common, mobile, and
unified build. For older (to be obsolete) build projects or
non-mobile GBM build projects, it is always-off.
- patchset2: fixed AEGIS's comments on coding style
Change-Id: I7fed0b9bae2b099ca6f3e5429ca09a882c52cd4e
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
+# To not create auto-provides for extension replacement shared objects
+%global __provides_exclude_from ^.*\\.extension-calendar
+
Name: sync-service
Version: 0.1.18
Release: 1
BuildRequires: pkgconfig(capi-appfw-app-manager)
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(capi-network-connection)
+BuildRequires: pkgconfig(capi-system-info)
BuildRequires: pkgconfig(appcore-efl)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(pkgmgr)
BuildRequires: pkgconfig(cynara-client)
BuildRequires: pkgconfig(cynara-session)
BuildRequires: pkgconfig(cynara-creds-gdbus)
-%if "%{?profile}" == "mobile"
+# If it is mobile, common, or "unified (undefined)"
+%if "%{?profile}" != "wearable" && "%{?profile}" != "tv" && "%{?profile}" != "ivi"
BuildRequires: pkgconfig(calendar-service2)
%endif
BuildRequires: pkgconfig(contacts-service2)
BuildRequires: pkgconfig(capi-content-media-content)
BuildRequires: pkgconfig(libtzplatform-config)
-
%description
sync manager service and sync framework which manages sync of registered applications
-
%package -n libcore-sync-client
Summary: Sync manager client library
Group: Development/Libraries
%build
_FEATURE_CONTAINER_ENABLE=OFF
-%if "%{?profile}" == "mobile"
-_FEATURE_CALENDAR_ENABLE=ON
+# If it is mobile, common, or "unified (undefined)"
+%if "%{?profile}" != "wearable" && "%{?profile}" != "tv" && "%{?profile}" != "ivi"
+# Support runtime feature on/off
+_RUNTIME_PROFILE_TEST=ON
%else
-_FEATURE_CALENDAR_ENABLE=OFF
+# Always off.
+_RUNTIME_PROFILE_TEST=OFF
%endif
cmake \
-DLIBDIR=%{_libdir} \
-DINCLUDEDIR=%{_includedir} \
-D_FEATURE_CONTAINER_ENABLE:BOOL=${_FEATURE_CONTAINER_ENABLE} \
- -D_FEATURE_CALENDAR_ENABLE:BOOL=${_FEATURE_CALENDAR_ENABLE} \
+ -D_RUNTIME_PROFILE_TEST:BOOL=${_RUNTIME_PROFILE_TEST} \
-DVERSION=%{version}
SET(VERSION_MAJOR 1)
SET(FULLVER "${VERSION_MAJOR}.0")
-IF(_FEATURE_CALENDAR_ENABLE)
- ADD_DEFINITIONS("-D_FEATURE_CALENDAR_ENABLE=1")
-ENDIF(_FEATURE_CALENDAR_ENABLE)
+IF(_RUNTIME_PROFILE_TEST)
+ ADD_DEFINITIONS("-D_RUNTIME_PROFILE_TEST=1")
+ENDIF(_RUNTIME_PROFILE_TEST)
INCLUDE_DIRECTORIES(
INCLUDE(FindPkgConfig)
pkg_check_modules(PKGS REQUIRED
capi-appfw-app-manager
+ capi-system-info
dlog
gio-unix-2.0
bundle)
#define SYNC_ADAPTER_DBUS_PATH "/org/tizen/sync/adapter"
#define SYNC_ERROR_PREFIX "org.tizen.sync.Error"
+#ifdef _RUNTIME_PROFILE_TEST
+#include <system_info.h>
+typedef enum {
+ TIZEN_PROFILE_UNKNOWN = 0,
+ TIZEN_PROFILE_MOBILE = 0x1,
+ TIZEN_PROFILE_WEARABLE = 0x2,
+ TIZEN_PROFILE_TV = 0x4,
+ TIZEN_PROFILE_IVI = 0x8,
+ TIZEN_PROFILE_COMMON = 0x10,
+} tizen_profile_t;
+
+static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+
+static inline tizen_profile_t _get_tizen_profile()
+{
+ char *profileName;
+
+ if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+ return profile;
+
+ system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+ switch (*profileName) {
+ case 'm':
+ case 'M':
+ profile = TIZEN_PROFILE_MOBILE;
+ break;
+ case 'w':
+ case 'W':
+ profile = TIZEN_PROFILE_WEARABLE;
+ break;
+ case 't':
+ case 'T':
+ profile = TIZEN_PROFILE_TV;
+ break;
+ case 'i':
+ case 'I':
+ profile = TIZEN_PROFILE_IVI;
+ break;
+ default: /* common or unknown ==> ALL ARE COMMON. */
+ profile = TIZEN_PROFILE_COMMON;
+ }
+ free(profileName);
+
+ return profile;
+}
+#define _FEATURE_CALENDAR_ENABLE (_get_tizen_profile() == TIZEN_PROFILE_MOBILE)
+
+#else /* _RUNTIME_PROFILE_TEST */
+
+#define _FEATURE_CALENDAR_ENABLE (0)
+
+#endif /* _RUNTIME_PROFILE_TEST */
typedef struct sync_manager_s {
TizenSyncManager *ipcObj;
{
if (sync_capability != NULL) {
if (
-#if defined(_FEATURE_CALENDAR_ENABLE)
- !(strcmp(sync_capability, "http://tizen.org/sync/capability/calendar")) ||
-#endif
+ ((_FEATURE_CALENDAR_ENABLE) ? !(strcmp(sync_capability, "http://tizen.org/sync/capability/calendar")) : 0) ||
!(strcmp(sync_capability, "http://tizen.org/sync/capability/contact")) ||
!(strcmp(sync_capability, "http://tizen.org/sync/capability/image")) ||
!(strcmp(sync_capability, "http://tizen.org/sync/capability/video")) ||
# ADD_DEFINITIONS("-D_FEATURE_CONTAINER_ENABLE=1")
#ENDIF(_FEATURE_CONTAINER_ENABLE)
-IF(_FEATURE_CALENDAR_ENABLE)
- ADD_DEFINITIONS("-D_FEATURE_CALENDAR_ENABLE=1")
-ENDIF(_FEATURE_CALENDAR_ENABLE)
+IF(_RUNTIME_PROFILE_TEST)
+ ADD_DEFINITIONS("-D_RUNTIME_PROFILE_TEST=1")
+ENDIF(_RUNTIME_PROFILE_TEST)
ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE_NAME}\"")
capi-network-connection
capi-appfw-application
capi-appfw-app-manager
+ capi-system-info
pkgmgr
pkgmgr-info
dlog
SET(PACKAGES ${PACKAGES} vasum)
ENDIF(_FEATURE_CONTAINER_ENABLE)
-IF(_FEATURE_CALENDAR_ENABLE)
+IF(_RUNTIME_PROFILE_TEST)
SET(PACKAGES ${PACKAGES} calendar-service2)
-ENDIF(_FEATURE_CALENDAR_ENABLE)
+ENDIF(_RUNTIME_PROFILE_TEST)
pkg_check_modules(PKGS REQUIRED ${PACKAGES})
* @brief This is the implementation file for the DataChangeListener class.
*/
-#if defined(_FEATURE_CALENDAR_ENABLE)
+#if defined(_RUNTIME_PROFILE_TEST)
#include <calendar.h>
#endif
/* LCOV_EXCL_START */
-#if defined(_FEATURE_CALENDAR_ENABLE)
+#if defined(_RUNTIME_PROFILE_TEST)
void OnCalendarBookChanged(const char* view_uri, void* user_data) {
LOG_LOGD("On Calendar Book Changed");
/* LCOV_EXCL_STOP */
-#if defined(_FEATURE_CALENDAR_ENABLE)
+#if defined(_RUNTIME_PROFILE_TEST)
int
DataChangeSyncScheduler::SubscribeCalendarCallback(void) {
SYNC_LOGE_RET_RES(!calendar_subscription_started, SYNC_ERROR_NONE, "Calendar Callback Already Subscribed");
/* LCOV_EXCL_START */
-#if defined(_FEATURE_CALENDAR_ENABLE)
+#if defined(_RUNTIME_PROFILE_TEST)
int
DataChangeSyncScheduler::UnSubscribeCalendarCallback(void) {
SYNC_LOGE_RET_RES(calendar_subscription_started, SYNC_ERROR_NONE, "Calendar Callback Already UnSubscribed");
DataChangeSyncScheduler::RegisterDataChangeListeners(void) {
int err = SYNC_ERROR_NONE;
-#if defined(_FEATURE_CALENDAR_ENABLE)
- err = SubscribeCalendarCallback();
- if (err != SYNC_ERROR_NONE) {
- /* LCOV_EXCL_START */
- LOG_LOGD("Registration of Calendar DataChangeListener Failed");
- return SYNC_ERROR_INVALID_OPERATION;
- /* LCOV_EXCL_STOP */
+ if (_FEATURE_CALENDAR_ENABLE) {
+ err = SubscribeCalendarCallback();
+ if (err != SYNC_ERROR_NONE) {
+ /* LCOV_EXCL_START */
+ LOG_LOGD("Registration of Calendar DataChangeListener Failed");
+ return SYNC_ERROR_INVALID_OPERATION;
+ /* LCOV_EXCL_STOP */
+ }
}
-#endif
err = SubscribeContactsCallback();
if (err != SYNC_ERROR_NONE) {
DataChangeSyncScheduler::DeRegisterDataChangeListeners(void) {
int err = VALUE_UNDEFINED;
-#if defined(_FEATURE_CALENDAR_ENABLE)
- err = UnSubscribeCalendarCallback();
- if (err != SYNC_ERROR_NONE) {
- LOG_LOGD("DeRegistration of Calendar DataChangeListener Failed");
- return SYNC_ERROR_INVALID_OPERATION;
+ if (_FEATURE_CALENDAR_ENABLE) {
+ err = UnSubscribeCalendarCallback();
+ if (err != SYNC_ERROR_NONE) {
+ LOG_LOGD("DeRegistration of Calendar DataChangeListener Failed");
+ return SYNC_ERROR_INVALID_OPERATION;
+ }
}
-#endif
err = UnSubscribeContactsCallback();
if (err != SYNC_ERROR_NONE) {
* @brief This is the implementation file for the PeriodicSyncScheduler class.
*/
-#if defined(_FEATURE_CALENDAR_ENABLE)
-#include <calendar.h>
-#endif
-
#include <contacts.h>
#include <media_content.h>
#include "sync-error.h"
*/
#include "SyncManager_SyncDefines.h"
+#include <stdlib.h>
+#include <system_info.h>
/*namespace _SyncManager
bool SyncStatus::syncSomeProgress = false;
*/
//}//_SyncManager
+
+tizen_profile_t _get_tizen_profile()
+{
+ static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+ if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+ return profile;
+
+ char *profileName;
+ system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+ switch (*profileName) {
+ case 'm':
+ case 'M':
+ profile = TIZEN_PROFILE_MOBILE;
+ break;
+ case 'w':
+ case 'W':
+ profile = TIZEN_PROFILE_WEARABLE;
+ break;
+ case 't':
+ case 'T':
+ profile = TIZEN_PROFILE_TV;
+ break;
+ case 'i':
+ case 'I':
+ profile = TIZEN_PROFILE_IVI;
+ break;
+ default: // common or unknown ==> ALL ARE COMMON.
+ profile = TIZEN_PROFILE_COMMON;
+ }
+ free(profileName);
+
+ return profile;
+}
} _SyncManager
*/
+typedef enum {
+ TIZEN_PROFILE_UNKNOWN = 0,
+ TIZEN_PROFILE_MOBILE = 0x1,
+ TIZEN_PROFILE_WEARABLE = 0x2,
+ TIZEN_PROFILE_TV = 0x4,
+ TIZEN_PROFILE_IVI = 0x8,
+ TIZEN_PROFILE_COMMON = 0x10,
+} tizen_profile_t;
+extern tizen_profile_t _get_tizen_profile();
+
+#ifdef _RUNTIME_PROFILE_TEST
+#define _FEATURE_CALENDAR_ENABLE (_get_tizen_profile() == TIZEN_PROFILE_MOBILE)
+#else /* _RUNTIME_PROFILE_TEST */
+#define _FEATURE_CALENDAR_ENABLE (0)
+#endif /* _RUNTIME_PROFILE_TEST */
+
#endif /* SYNC_SERVICE_SYNC_DEFINES_H */
#define SYNC_ERROR_PREFIX "org.tizen.sync.Error"
#define PRIV_ALARM_SET "http://tizen.org/privilege/alarm.set"
-#if defined(_FEATURE_CALENDAR_ENABLE)
#define PRIV_CALENDAR_READ "http://tizen.org/privilege/calendar.read"
-#endif
#define PRIV_CONTACT_READ "http://tizen.org/privilege/contact.read"
}
-#if defined(_FEATURE_CALENDAR_ENABLE)
int _check_privilege_calendar_read(GDBusMethodInvocation *invocation) {
return _check_privilege(invocation, PRIV_CALENDAR_READ);
}
-#endif
int _check_privilege_contact_read(GDBusMethodInvocation *invocation) {
int ret = SYNC_ERROR_NONE;
-#if defined(_FEATURE_CALENDAR_ENABLE)
- const char *capability = (char *)pCapabilityArg;
- if (!strcmp(capability, "http://tizen.org/sync/capability/calendar") ||
- !strcmp(capability, "http://tizen.org/sync/capability/contact")) {
- if (!strcmp(capability, "http://tizen.org/sync/capability/calendar"))
- ret = _check_privilege_calendar_read(pInvocation);
- else
- ret = _check_privilege_contact_read(pInvocation);
-
- if (ret != SYNC_ERROR_NONE) {
- /* LCOV_EXCL_START */
- GError* error = NULL;
+ if (_FEATURE_CALENDAR_ENABLE) {
+ const char *capability = (char *)pCapabilityArg;
+ if (!strcmp(capability, "http://tizen.org/sync/capability/calendar") ||
+ !strcmp(capability, "http://tizen.org/sync/capability/contact")) {
if (!strcmp(capability, "http://tizen.org/sync/capability/calendar"))
- error = g_error_new(_sync_error_quark(), ret, "sync service: calendar.read permission denied");
+ ret = _check_privilege_calendar_read(pInvocation);
else
- error = g_error_new(_sync_error_quark(), ret, "sync service: contact.read permission denied");
+ ret = _check_privilege_contact_read(pInvocation);
- g_dbus_method_invocation_return_gerror(pInvocation, error);
- g_clear_error(&error);
- /* LCOV_EXCL_STOP */
- return true;
+ if (ret != SYNC_ERROR_NONE) {
+ /* LCOV_EXCL_START */
+ GError* error = NULL;
+ if (!strcmp(capability, "http://tizen.org/sync/capability/calendar"))
+ error = g_error_new(_sync_error_quark(), ret, "sync service: calendar.read permission denied");
+ else
+ error = g_error_new(_sync_error_quark(), ret, "sync service: contact.read permission denied");
+
+ g_dbus_method_invocation_return_gerror(pInvocation, error);
+ g_clear_error(&error);
+ /* LCOV_EXCL_STOP */
+ return true;
+ }
}
- }
-#else
- const char *capability = (char *)pCapabilityArg;
- if (!strcmp(capability, "http://tizen.org/sync/capability/contact")) {
- ret = _check_privilege_contact_read(pInvocation);
+ } else {
+ const char *capability = (char *)pCapabilityArg;
+ if (!strcmp(capability, "http://tizen.org/sync/capability/contact")) {
+ ret = _check_privilege_contact_read(pInvocation);
- if (ret != SYNC_ERROR_NONE) {
- /* LCOV_EXCL_START */
- GError* error = NULL;
- error = g_error_new(_sync_error_quark(), ret, "sync service: contact.read permission denied");
+ if (ret != SYNC_ERROR_NONE) {
+ /* LCOV_EXCL_START */
+ GError* error = NULL;
+ error = g_error_new(_sync_error_quark(), ret, "sync service: contact.read permission denied");
- g_dbus_method_invocation_return_gerror(pInvocation, error);
- g_clear_error(&error);
- /* LCOV_EXCL_STOP */
- return true;
+ g_dbus_method_invocation_return_gerror(pInvocation, error);
+ g_clear_error(&error);
+ /* LCOV_EXCL_STOP */
+ return true;
+ }
}
}
-#endif
guint pid = get_caller_pid(pInvocation);
string pkgIdStr;