#ifdef MOBILE
const char *capability_calendar = SYNC_SUPPORTS_CAPABILITY_CALENDAR;
-const char *capability_contact = SYNC_SUPPORTS_CAPABILITY_CONTACT;
#endif
+const char *capability_contact = SYNC_SUPPORTS_CAPABILITY_CONTACT;
const char *capability_image = SYNC_SUPPORTS_CAPABILITY_IMAGE;
const char *capability_video = SYNC_SUPPORTS_CAPABILITY_VIDEO;
const char *capability_sound = SYNC_SUPPORTS_CAPABILITY_SOUND;
ret = sync_manager_remove_sync_job(sync_job_id);
assert_eq(ret, SYNC_ERROR_NONE);
+#endif
ret = sync_manager_add_data_change_sync_job(account, capability_contact, SYNC_OPTION_NO_RETRY, user_data, &sync_job_id);
assert_eq(ret, SYNC_ERROR_NONE);
ret = sync_manager_remove_sync_job(sync_job_id);
assert_eq(ret, SYNC_ERROR_NONE);
-#endif
ret = sync_manager_add_data_change_sync_job(account, capability_sound, SYNC_OPTION_NONE, user_data, &sync_job_id);
assert_eq(ret, SYNC_ERROR_NONE);
#ifdef MOBILE
ret = sync_manager_add_data_change_sync_job(account, capability_calendar, -1, user_data, &sync_job_id);
assert_eq(ret, SYNC_ERROR_INVALID_PARAMETER);
+#endif
ret = sync_manager_add_data_change_sync_job(NULL, capability_contact, -1, user_data, &sync_job_id);
assert_eq(ret, SYNC_ERROR_INVALID_PARAMETER);
-#endif
ret = sync_manager_add_data_change_sync_job(account, capability_image, -1, NULL, &sync_job_id);
assert_eq(ret, SYNC_ERROR_INVALID_PARAMETER);
ret = sync_manager_remove_sync_job(sync_job_id);
assert_eq(ret, SYNC_ERROR_NONE);
+#endif
ret = sync_manager_add_data_change_sync_job(account, capability_contact, SYNC_OPTION_NONE, NULL, &sync_job_id);
assert_eq(ret, SYNC_ERROR_NONE);
ret = sync_manager_remove_sync_job(sync_job_id);
assert_eq(ret, SYNC_ERROR_NONE);
-#endif
ret = sync_manager_add_data_change_sync_job(NULL, capability_image, SYNC_OPTION_NONE, NULL, &sync_job_id);
assert_eq(ret, SYNC_ERROR_NONE);
#ifdef MOBILE
ret = sync_manager_add_data_change_sync_job(account, capability_calendar, SYNC_OPTION_EXPEDITED, NULL, NULL);
assert_eq(ret, SYNC_ERROR_INVALID_PARAMETER);
+#endif
ret = sync_manager_add_data_change_sync_job(NULL, capability_contact, (SYNC_OPTION_NO_RETRY | SYNC_OPTION_EXPEDITED), NULL, NULL);
assert_eq(ret, SYNC_ERROR_INVALID_PARAMETER);
-#endif
bundle_free(user_data);
#ifdef MOBILE
ret = sync_manager_add_data_change_sync_job(NULL, capability_calendar, SYNC_OPTION_EXPEDITED, user_data, &sync_job_id);
assert_eq(ret, SYNC_ERROR_SYNC_ADAPTER_NOT_FOUND);
+#endif
ret = sync_manager_add_data_change_sync_job(account, capability_contact, (SYNC_OPTION_NO_RETRY | SYNC_OPTION_EXPEDITED), NULL, &sync_job_id);
assert_eq(ret, SYNC_ERROR_SYNC_ADAPTER_NOT_FOUND);
-#endif
ret = sync_manager_add_data_change_sync_job(NULL, capability_image, SYNC_OPTION_NONE, NULL, &sync_job_id);
assert_eq(ret, SYNC_ERROR_SYNC_ADAPTER_NOT_FOUND);
ret = sync_manager_remove_sync_job(sync_job_id);
assert_eq(ret, SYNC_ERROR_NONE);
+#endif
ret = sync_manager_add_data_change_sync_job(NULL, capability_contact, SYNC_OPTION_NO_RETRY, user_data, &sync_job_id);
assert_eq(ret, SYNC_ERROR_NONE);
ret = sync_manager_remove_sync_job(sync_job_id);
assert_eq(ret, SYNC_ERROR_NONE);
-#endif
ret = sync_manager_add_data_change_sync_job(account, capability_image, SYNC_OPTION_NONE, NULL, &sync_job_id);
assert_eq(ret, SYNC_ERROR_NONE);
/**
* @brief This is contact capability string.
* @since_tizen 2.4
- * @remarks This capability is supported on Mobile profile only. If you want to receive notification about contact DB change, add it through sync_manager_add_data_change_sync_job().
+ * @remarks If you want to receive notification about contact DB change, add it through sync_manager_add_data_change_sync_job().
* @see sync_manager_add_data_change_sync_job()
*/
#define SYNC_SUPPORTS_CAPABILITY_CONTACT "http://tizen.org/sync/capability/contact"
*
* @since_tizen 2.4
*
+ * @remarks Release account with account_destroy() after using it.\n\n
+ * Release sync_job_user_data with bundle_free() after using it.
+ *
* @param[in] account An account handle on which sync operation was requested or @c NULL in the case of accountless sync operation
* @param[in] sync_job_name A string representing a sync job which has been operated or @c NULL in the case of data change sync operation
* @param[in] sync_capability A string representing a sync job which has been operated because of data change or @c NULL in the case of on demand and periodic sync operation
*
* @remarks Data change sync job can be added by using its capability. In the case of adding a sync job with same capability, it will replace previous setting with new one. \n\n
* %http://tizen.org/privilege/calendar.read is needed to add data change sync job for receiving notification with @ref SYNC_SUPPORTS_CAPABILITY_CALENDAR. This capability is supported on Mobile profile only. \n\n
- * %http://tizen.org/privilege/contact.read is needed to add data change sync job for receiving notification with @ref SYNC_SUPPORTS_CAPABILITY_CONTACT. This capability is supported on Mobile profile only.
+ * %http://tizen.org/privilege/contact.read is needed to add data change sync job for receiving notification with @ref SYNC_SUPPORTS_CAPABILITY_CONTACT.
*
* @param[in] account An account handle on which sync operation was requested or @c NULL in the case of accountless sync operation
* @param[in] sync_capability A string representing a sync job which will be operated whenever data change of this capability
SYNC_ERROR_QUOTA_EXCEEDED = TIZEN_ERROR_QUOTA_EXCEEDED, /**< Quota exceeded */
SYNC_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN, /**< Unknown Error */
SYNC_ERROR_SYSTEM = TIZEN_ERROR_SYNC_MANAGER | 0x01, /**< System error */
- SYNC_ERROR_SYNC_ADAPTER_NOT_FOUND = TIZEN_ERROR_SYNC_MANAGER | 0x02 /**< Sync adater is not registered */
+ SYNC_ERROR_SYNC_ADAPTER_NOT_FOUND = TIZEN_ERROR_SYNC_MANAGER | 0x02 /**< Sync adapter is not registered */
} sync_error_e;
* @brief Callback function for Sync Adapter's start sync request.
*
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
- * @remarks This API only can be called at a service application.
+ * @remarks This API only can be called at a service application.\n\n
+ * Release account with account_destroy() after using it.\n\n
+ * Release sync_job_user_data with bundle_free() after using it.
*
* @param[in] account An account handle on which sync operation was requested or @c NULL in the case of accountless sync operation
* @param[in] sync_job_name A string representing a sync job which has been operated or @c NULL in the case of data change sync operation
* @brief Callback function for Sync Adapter's cancel sync request.
*
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
- * @remarks This API only can be called at a service application after calling sync_manager_remove_sync_job().
+ * @remarks This API only can be called at a service application after calling sync_manager_remove_sync_job().\n\n
+ * Release account with account_destroy() after using it.\n\n
+ * Release sync_job_user_data with bundle_free() after using it.
*
* @param[in] account An account handle on which sync operation was requested or @c NULL in the case of accountless sync operation
* @param[in] sync_job_name A string representing a sync job which has been operated or @c NULL in the case of data change sync operation
/**
- * @brief Sets client (Sync Aadapter) callback functions
+ * @brief Sets client (Sync Adapter) callback functions
*
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
* @remarks This API only can be called by a service application. And it can be set by only one service application per a package.
*/
+/**
+ * @brief This is contact capability string.
+ * @since_tizen 3.0
+ * @remarks If you want to receive notification about contact DB change, add it through sync_manager_add_data_change_sync_job().
+ * @see sync_manager_add_data_change_sync_job()
+ */
+#define SYNC_SUPPORTS_CAPABILITY_CONTACT "http://tizen.org/sync/capability/contact"
+
+
/**
* @brief This is image capability string.
* @since_tizen 3.0
*
* @since_tizen 3.0
*
+ * @remarks Release account with account_destroy() after using it.\n\n
+ * Release sync_job_user_data with bundle_free() after using it.
+ *
* @param[in] account An account handle on which sync operation was requested or @c NULL in the case of accountless sync operation
* @param[in] sync_job_name A string representing a sync job which has been operated or @c NULL in the case of data change sync operation
* @param[in] sync_capability A string representing a sync job which has been operated because of data change or @c NULL in the case of on demand and periodic sync operation
* @brief Requests Sync Manager to perform sync operations whenever corresponding DB changed.
*
* @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/contact.read
*
* @remarks Data change sync job can be added by using its capability. In the case of adding a sync job with same capability, it will replace previous setting with new one. \n\n
+ * %http://tizen.org/privilege/contact.read is needed to add data change sync job for receiving notification with @ref SYNC_SUPPORTS_CAPABILITY_CONTACT.
*
* @param[in] account An account handle on which sync operation was requested or @c NULL in the case of accountless sync operation
* @param[in] sync_capability A string representing a sync job which will be operated whenever data change of this capability
Name: sync-service
-Version: 0.1.5
+Version: 0.1.6
Release: 1
License: Apache-2.0
Summary: Sync manager daemon
BuildRequires: pkgconfig(cynara-creds-gdbus)
%if "%{?profile}" == "mobile"
BuildRequires: pkgconfig(calendar-service2)
-BuildRequires: pkgconfig(contacts-service2)
%endif
+BuildRequires: pkgconfig(contacts-service2)
BuildRequires: pkgconfig(capi-content-media-content)
BuildRequires: pkgconfig(libtzplatform-config)
_CONTAINER_ENABLE=OFF
%if "%{?profile}" == "mobile"
-_CALENDAR_CONTACTS_ENABLE=ON
+_CALENDAR_ENABLE=ON
_FEATURE_MOBILE_PROFILE=ON
%else
-_CALENDAR_CONTACTS_ENABLE=OFF
+_CALENDAR_ENABLE=OFF
_FEATURE_MOBILE_PROFILE=OFF
%endif
-DLIBDIR=%{_libdir} \
-DINCLUDEDIR=%{_includedir} \
-D_SEC_FEATURE_CONTAINER_ENABLE:BOOL=${_CONTAINER_ENABLE} \
- -D_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE:BOOL=${_CALENDAR_CONTACTS_ENABLE} \
+ -D_SEC_FEATURE_CALENDAR_ENABLE:BOOL=${_CALENDAR_ENABLE} \
-D_SEC_FEATURE_MOBILE_PROFILE:BOOL=${_FEATURE_MOBILE_PROFILE} \
-DVERSION=%{version}
SET(VERSION_MAJOR 1)
SET(FULLVER "${VERSION_MAJOR}.0")
-IF(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
- ADD_DEFINITIONS("-D_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE=1")
-ENDIF(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
+IF(_SEC_FEATURE_CALENDAR_ENABLE)
+ ADD_DEFINITIONS("-D_SEC_FEATURE_CALENDAR_ENABLE=1")
+ENDIF(_SEC_FEATURE_CALENDAR_ENABLE)
INCLUDE_DIRECTORIES(
{
if (sync_capability != NULL) {
if (
-#if defined(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
+#if defined(_SEC_FEATURE_CALENDAR_ENABLE)
!(strcmp(sync_capability, "http://tizen.org/sync/capability/calendar")) ||
- !(strcmp(sync_capability, "http://tizen.org/sync/capability/contact")) ||
#endif
+ !(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")) ||
!(strcmp(sync_capability, "http://tizen.org/sync/capability/sound")) ||
# ADD_DEFINITIONS("-D_SEC_FEATURE_CONTAINER_ENABLE=1")
#ENDIF(_SEC_FEATURE_CONTAINER_ENABLE)
-IF(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
- ADD_DEFINITIONS("-D_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE=1")
-ENDIF(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
+IF(_SEC_FEATURE_CALENDAR_ENABLE)
+ ADD_DEFINITIONS("-D_SEC_FEATURE_CALENDAR_ENABLE=1")
+ENDIF(_SEC_FEATURE_CALENDAR_ENABLE)
ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE_NAME}\"")
gio-unix-2.0
alarm-service
bundle
+ contacts-service2
cynara-client
cynara-session
cynara-creds-gdbus
SET(PACKAGES ${PACKAGES} vasum)
ENDIF(_SEC_FEATURE_CONTAINER_ENABLE)
-IF(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
- SET(PACKAGES ${PACKAGES} calendar-service2 contacts-service2)
-ENDIF(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
+IF(_SEC_FEATURE_CALENDAR_ENABLE)
+ SET(PACKAGES ${PACKAGES} calendar-service2)
+ENDIF(_SEC_FEATURE_CALENDAR_ENABLE)
pkg_check_modules(PKGS REQUIRED ${PACKAGES})
* @brief This is the implementation file for the DataChangeListener class.
*/
-#if defined(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
+#if defined(_SEC_FEATURE_CALENDAR_ENABLE)
#include <calendar.h>
-#include <contacts.h>
#endif
+#include <contacts.h>
#include <media_content.h>
#include "sync-error.h"
#include "sync_manager.h"
/* LCOV_EXCL_START */
-#if defined(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
+#if defined(_SEC_FEATURE_CALENDAR_ENABLE)
void OnCalendarBookChanged(const char* view_uri, void* user_data) {
LOG_LOGD("On Calendar Book Changed");
DataChangeSyncScheduler* pDCScheduler = (DataChangeSyncScheduler*) (user_data);
pDCScheduler->HandleDataChangeEvent(SYNC_SUPPORTS_CAPABILITY_CALENDAR);
}
+#endif
void OnContactsDataChanged(const char* view_uri, void* user_data) {
DataChangeSyncScheduler* pDCScheduler = (DataChangeSyncScheduler*) (user_data);
pDCScheduler->HandleDataChangeEvent(SYNC_SUPPORTS_CAPABILITY_CONTACT);
}
-#endif
void OnMediaContentDataChanged(media_content_error_e error, int pid, media_content_db_update_item_type_e update_item, media_content_db_update_type_e update_type, media_content_type_e media_type, char *uuid, char *path, char *mime_type, void *user_data) {
/* LCOV_EXCL_STOP */
-#if defined(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
+#if defined(_SEC_FEATURE_CALENDAR_ENABLE)
int
DataChangeSyncScheduler::SubscribeCalendarCallback(void) {
SYNC_LOGE_RET_RES(!calendar_subscription_started, SYNC_ERROR_NONE, "Calendar Callback Already Subscribed");
return SYNC_ERROR_NONE;
}
+#endif
int
return SYNC_ERROR_NONE;
}
-#endif
int
/* LCOV_EXCL_START */
-#if defined(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
+#if defined(_SEC_FEATURE_CALENDAR_ENABLE)
int
DataChangeSyncScheduler::UnSubscribeCalendarCallback(void) {
SYNC_LOGE_RET_RES(calendar_subscription_started, SYNC_ERROR_NONE, "Calendar Callback Already UnSubscribed");
return SYNC_ERROR_NONE;
}
+#endif
int
return SYNC_ERROR_NONE;
}
-#endif
int
DataChangeSyncScheduler::RegisterDataChangeListeners(void) {
int err = SYNC_ERROR_NONE;
-#if defined(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
+#if defined(_SEC_FEATURE_CALENDAR_ENABLE)
err = SubscribeCalendarCallback();
if (err != SYNC_ERROR_NONE) {
/* LCOV_EXCL_START */
return SYNC_ERROR_INVALID_OPERATION;
/* LCOV_EXCL_STOP */
}
+#endif
err = SubscribeContactsCallback();
if (err != SYNC_ERROR_NONE) {
return SYNC_ERROR_INVALID_OPERATION;
/* LCOV_EXCL_STOP */
}
-#endif
err = SubscribeMediaContentCallback();
if (err != SYNC_ERROR_NONE) {
DataChangeSyncScheduler::DeRegisterDataChangeListeners(void) {
int err = VALUE_UNDEFINED;
-#if defined(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
+#if defined(_SEC_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) {
LOG_LOGD("DeRegistration of Contacts DataChangeListener Failed");
return SYNC_ERROR_INVALID_OPERATION;
}
-#endif
err = UnSubscribeMediaContentCallback();
if (err != SYNC_ERROR_NONE) {
* @brief This is the implementation file for the PeriodicSyncScheduler class.
*/
-#if defined(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
+#if defined(_SEC_FEATURE_CALENDAR_ENABLE)
#include <calendar.h>
-#include <contacts.h>
#endif
+#include <contacts.h>
#include <media_content.h>
#include "sync-error.h"
#include "SyncManager_PeriodicSyncScheduler.h"
};
-#if defined(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
-enum DataChangeStatus {
- /** Calendar Book */
- CALENDAR_BOOK_CHANGED = 0,
- /** Calendar Event */
- CALENDAR_EVENT_CHANGED,
- /** Calendar Todo */
- CALENDAR_TODO_CHANGED,
- /** Contacts Modify */
- CONTACTS_DATA_CHANGED,
-};
-#endif
-
-
enum SyncDispatchMessage {
/** Sync Finished*/
SYNC_FINISHED = 0,
#define SYNC_ERROR_PREFIX "org.tizen.sync.Error"
#define PRIV_ALARM_SET "http://tizen.org/privilege/alarm.set"
-#if defined(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
+#if defined(_SEC_FEATURE_CALENDAR_ENABLE)
#define PRIV_CALENDAR_READ "http://tizen.org/privilege/calendar.read"
-#define PRIV_CONTACT_READ "http://tizen.org/privilege/contact.read"
#endif
+#define PRIV_CONTACT_READ "http://tizen.org/privilege/contact.read"
+
#define SYS_DBUS_INTERFACE "org.tizen.system.deviced.PowerOff"
#define SYS_DBUS_MATCH_RULE "type='signal',interface='org.tizen.system.deviced.PowerOff'"
#define SYS_DBUS_PATH "/Org/Tizen/System/DeviceD/PowerOff"
}
-#if defined(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
+#if defined(_SEC_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) {
return _check_privilege(invocation, PRIV_CONTACT_READ);
}
-#endif
gboolean sync_adapter_handle_send_result(TizenSyncAdapter* pObject, GDBusMethodInvocation* pInvocation, const gchar* pCommandLine, gint sync_result, const gchar* sync_job_name);
int ret = SYNC_ERROR_NONE;
-#if defined(_SEC_FEATURE_CALENDAR_CONTACTS_ENABLE)
+#if defined(_SEC_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")) {
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);
+
+ 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 */