[TCSACR-40][Add] added new API for SyncManager 05/146505/8
authorIckhee Woo <ickhee.woo@samsung.com>
Tue, 29 Aug 2017 06:49:22 +0000 (15:49 +0900)
committerIckhee Woo <ickhee.woo@samsung.com>
Wed, 30 Aug 2017 06:12:24 +0000 (06:12 +0000)
Change-Id: I0253bfecdc429a304f1e32e480d2cdcc339b7fdb
Signed-off-by: Ickhee Woo <ickhee.woo@samsung.com>
13 files changed:
pkg/PlatformFileList.txt
pkg/Tizen.NET.Private.sln
pkg/Tizen.NET.nuspec
src/Tizen.Account.SyncManager/Interop/Interop.Adapter.cs [new file with mode: 0755]
src/Tizen.Account.SyncManager/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Account.SyncManager/Interop/Interop.Manager.cs [new file with mode: 0755]
src/Tizen.Account.SyncManager/Tizen.Account.SyncManager.csproj [new file with mode: 0644]
src/Tizen.Account.SyncManager/Tizen.Account.SyncManager.sln [new file with mode: 0755]
src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/Enumerations.cs [new file with mode: 0755]
src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/ErrorFactory.cs [new file with mode: 0755]
src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/SyncAdapter.cs [new file with mode: 0755]
src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/SyncClient.cs [new file with mode: 0755]
src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/SyncJobData.cs [new file with mode: 0755]

index a5b8c07..d98f125 100644 (file)
@@ -7,6 +7,7 @@ res/maps_marker_sticker_72.png                     #mobile #mobile-emul #tv
 Tizen.Account.AccountManager.dll                   #mobile #mobile-emul #ivi #wearable
 Tizen.Account.FidoClient.dll                       #mobile #mobile-emul #wearable
 Tizen.Account.OAuth2.dll                           #mobile #mobile-emul #ivi #wearable
+Tizen.Account.SyncManager.dll                      #mobile #mobile-emul #wearable
 Tizen.Applications.Alarm.dll                       #common #mobile #mobile-emul #tv #ivi #wearable
 Tizen.Applications.AttachPanel.dll                 #mobile #mobile-emul
 Tizen.Applications.Badge.dll                       #mobile #mobile-emul #ivi
index c4448d0..8a6f048 100644 (file)
@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Account.FidoClient",
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Account.OAuth2", "..\src\Tizen.Account.OAuth2\Tizen.Account.OAuth2.csproj", "{CDBB2633-FE0B-485E-B864-DCA9240E6F7D}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Account.SyncManager", "..\src\Tizen.Account.SyncManager\Tizen.Account.SyncManager.csproj", "{219B1BF6-E17C-42BC-82A3-7B0C81E23AA6}"
+EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications.Alarm", "..\src\Tizen.Applications.Alarm\Tizen.Applications.Alarm.csproj", "{6B8722E8-94A4-4739-B0E3-14F1B158BC81}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications.AttachPanel", "..\src\Tizen.Applications.AttachPanel\Tizen.Applications.AttachPanel.csproj", "{3BACD1BC-613C-4A68-87F2-789B5937FBF6}"
@@ -240,6 +242,18 @@ Global
                {CDBB2633-FE0B-485E-B864-DCA9240E6F7D}.Release|x64.Build.0 = Release|x64
                {CDBB2633-FE0B-485E-B864-DCA9240E6F7D}.Release|x86.ActiveCfg = Release|x86
                {CDBB2633-FE0B-485E-B864-DCA9240E6F7D}.Release|x86.Build.0 = Release|x86
+               {219B1BF6-E17C-42BC-82A3-7B0C81E23AA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {219B1BF6-E17C-42BC-82A3-7B0C81E23AA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {219B1BF6-E17C-42BC-82A3-7B0C81E23AA6}.Debug|x64.ActiveCfg = Debug|x64
+               {219B1BF6-E17C-42BC-82A3-7B0C81E23AA6}.Debug|x64.Build.0 = Debug|x64
+               {219B1BF6-E17C-42BC-82A3-7B0C81E23AA6}.Debug|x86.ActiveCfg = Debug|x86
+               {219B1BF6-E17C-42BC-82A3-7B0C81E23AA6}.Debug|x86.Build.0 = Debug|x86
+               {219B1BF6-E17C-42BC-82A3-7B0C81E23AA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {219B1BF6-E17C-42BC-82A3-7B0C81E23AA6}.Release|Any CPU.Build.0 = Release|Any CPU
+               {219B1BF6-E17C-42BC-82A3-7B0C81E23AA6}.Release|x64.ActiveCfg = Release|x64
+               {219B1BF6-E17C-42BC-82A3-7B0C81E23AA6}.Release|x64.Build.0 = Release|x64
+               {219B1BF6-E17C-42BC-82A3-7B0C81E23AA6}.Release|x86.ActiveCfg = Release|x86
+               {219B1BF6-E17C-42BC-82A3-7B0C81E23AA6}.Release|x86.Build.0 = Release|x86
                {6B8722E8-94A4-4739-B0E3-14F1B158BC81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {6B8722E8-94A4-4739-B0E3-14F1B158BC81}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {6B8722E8-94A4-4739-B0E3-14F1B158BC81}.Debug|x64.ActiveCfg = Debug|x64
index dcd0a80..a34c60d 100644 (file)
@@ -22,6 +22,9 @@
     <file src="bin\Tizen.Account.AccountManager.dll" target="lib\netstandard1.6" />
     <file src="bin\Tizen.Account.AccountManager.pdb" target="lib\netstandard1.6" />
     <file src="bin\Tizen.Account.AccountManager.xml" target="lib\netstandard1.6" />
+    <file src="bin\Tizen.Account.SyncManager.dll" target="lib\netstandard1.6" />
+    <file src="bin\Tizen.Account.SyncManager.pdb" target="lib\netstandard1.6" />
+    <file src="bin\Tizen.Account.SyncManager.xml" target="lib\netstandard1.6" />
     <file src="bin\Tizen.Account.FidoClient.dll" target="lib\netstandard1.6" />
     <file src="bin\Tizen.Account.FidoClient.pdb" target="lib\netstandard1.6" />
     <file src="bin\Tizen.Account.FidoClient.xml" target="lib\netstandard1.6" />
diff --git a/src/Tizen.Account.SyncManager/Interop/Interop.Adapter.cs b/src/Tizen.Account.SyncManager/Interop/Interop.Adapter.cs
new file mode 100755 (executable)
index 0000000..9a05dbc
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright 2016 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Adapter
+    {
+        [DllImport(Libraries.SyncManager, EntryPoint = "sync_adapter_set_callbacks")]
+        internal static extern int SetCallbacks(SyncAdapterStartSyncCallback onStartCb, SyncAdapterCancelSyncCallback onCancelCb);
+
+        [DllImport(Libraries.SyncManager, EntryPoint = "sync_adapter_unset_callbacks")]
+        internal static extern int UnsetCallbacks();
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate bool SyncAdapterStartSyncCallback(IntPtr account, string syncJobName, string syncCapability, IntPtr syncJobUserData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate void SyncAdapterCancelSyncCallback(IntPtr account, string syncJobName, string syncCapability, IntPtr syncJobUserData);
+    }
+}
diff --git a/src/Tizen.Account.SyncManager/Interop/Interop.Libraries.cs b/src/Tizen.Account.SyncManager/Interop/Interop.Libraries.cs
new file mode 100755 (executable)
index 0000000..837e50b
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    /// <summary>
+    /// Wrapper class for maintaining names of dependent native libraries.
+    /// </summary>
+    internal static partial class Libraries
+    {
+        public const string SyncManager = "libcore-sync-client.so.1";
+        public const string Glib = "libglib-2.0.so.0";
+        public const string Libc = "libc.so.6";
+    }
+}
diff --git a/src/Tizen.Account.SyncManager/Interop/Interop.Manager.cs b/src/Tizen.Account.SyncManager/Interop/Interop.Manager.cs
new file mode 100755 (executable)
index 0000000..c269694
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright 2016 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using System;
+using System.Runtime.InteropServices;
+using Tizen.Applications;
+using Tizen.Account.AccountManager;
+
+internal static partial class Interop
+{
+    internal static partial class Manager
+    {
+        [DllImport(Libraries.SyncManager, EntryPoint = "sync_manager_on_demand_sync_job")]
+        internal static extern int RequestOnDemandSyncJob(SafeAccountHandle account, string syncJobName, int syncOption, SafeBundleHandle syncJobUserData, out int syncJobId);
+
+        [DllImport(Libraries.SyncManager, EntryPoint = "sync_manager_add_periodic_sync_job")]
+        internal static extern int AddPeriodicSyncJob(SafeAccountHandle account, string syncJobName, int syncPeriod, int syncOption, SafeBundleHandle syncJobUserData, out int syncJobId);
+
+        [DllImport(Libraries.SyncManager, EntryPoint = "sync_manager_add_data_change_sync_job")]
+        internal static extern int AddDataChangeSyncJob(SafeAccountHandle account, string syncCapability, int syncOption, SafeBundleHandle syncJobUserData, out int syncJobId);
+
+        [DllImport(Libraries.SyncManager, EntryPoint = "sync_manager_remove_sync_job")]
+        internal static extern int RemoveSyncJob(int syncJobId);
+
+        [DllImport(Libraries.SyncManager, EntryPoint = "sync_manager_foreach_sync_job")]
+        internal static extern int ForeachSyncJob(SyncManagerSyncJobCallback syncJobCb, IntPtr userData);
+
+        [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+        internal delegate bool SyncManagerSyncJobCallback(IntPtr account, string syncJobName, string syncCapability, int syncJobId, IntPtr syncJobUserData, IntPtr userData);
+    }
+}
diff --git a/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager.csproj b/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager.csproj
new file mode 100644 (file)
index 0000000..a552e3f
--- /dev/null
@@ -0,0 +1,16 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <Import Project="../../build/common.props" />
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.6</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\Tizen\Tizen.csproj" />
+    <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
+    <ProjectReference Include="..\Tizen.Account.AccountManager\Tizen.Account.AccountManager.csproj" />
+    <ProjectReference Include="..\Tizen.Log\Tizen.Log.csproj" />
+  </ItemGroup>
+
+  <Import Project="../../build/common.targets" />
+</Project>
diff --git a/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager.sln b/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager.sln
new file mode 100755 (executable)
index 0000000..14b65a7
--- /dev/null
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26430.13
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Account.SyncManager", "Tizen.Account.SyncManager.csproj", "{16028D3D-9DA0-466A-9CE4-EE8790F450D6}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Any CPU = Debug|Any CPU
+               Release|Any CPU = Release|Any CPU
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {16028D3D-9DA0-466A-9CE4-EE8790F450D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {16028D3D-9DA0-466A-9CE4-EE8790F450D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {16028D3D-9DA0-466A-9CE4-EE8790F450D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {16028D3D-9DA0-466A-9CE4-EE8790F450D6}.Release|Any CPU.Build.0 = Release|Any CPU
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/Enumerations.cs b/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/Enumerations.cs
new file mode 100755 (executable)
index 0000000..4befba6
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Account.SyncManager
+{
+       /// <summary>
+       /// Enumeration for the Sync option
+       /// </summary>
+    [Flags]
+    public enum SyncOption
+    {
+        /// <summary>
+        /// Sync job will be operated normally
+        /// </summary>
+        None = 0,
+
+        /// <summary>
+        /// Sync job will be operated as soon as possible
+        /// </summary>
+        Expedited = 0X01,
+
+        /// <summary>
+        /// Sync job will not be performed again when it fails
+        /// </summary>
+        NoRetry = 0X02,
+    }
+
+       /// <summary>
+       /// Enumeration for the Sync period
+       /// </summary>
+    public enum SyncPeriod
+    {
+        /// <summary>
+        /// Sync within 30 minutes
+        /// </summary>
+        ThirtyMin = 0,
+
+        /// <summary>
+        /// Sync within 1 hour
+        /// </summary>
+        OneHour,
+
+        /// <summary>
+        /// Sync within 2 hours
+        /// </summary>
+        TwoHours,
+
+        /// <summary>
+        /// Sync within 3 hours
+        /// </summary>
+        ThreeHours,
+
+        /// <summary>
+        /// Sync within 6 hours
+        /// </summary>
+        SixHours,
+
+        /// <summary>
+        /// Sync within 12 hours
+        /// </summary>
+        TwelveHours,
+
+        /// <summary>
+        /// Sync within 1 day
+        /// </summary>
+        OneDay,
+    }
+}
+
diff --git a/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/ErrorFactory.cs b/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/ErrorFactory.cs
new file mode 100755 (executable)
index 0000000..79f1af9
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Account.SyncManager
+{
+    internal enum SyncManagerErrorCode
+    {
+        None = ErrorCode.None,
+        NotSupported = ErrorCode.NotSupported,
+        OutOfMemory = ErrorCode.OutOfMemory,
+        InvalidParameter = ErrorCode.InvalidParameter,
+        InvalidOperation = ErrorCode.InvalidOperation,
+        PermissionDenied = ErrorCode.PermissionDenied,
+        IoError = ErrorCode.IoError,
+        AlreadyInProgress = ErrorCode.AlreadyInProgress,
+        QuotaExceeded = ErrorCode.QuotaExceeded,
+        SystemError = -0x01020000 | 0X01,
+        AdapterNotFound = -0x01020000 | 0X02
+    }
+
+    internal class ErrorFactory
+    {
+        internal static string LogTag = "Tizen.Account.SyncManager";
+
+        internal static Exception GetException(int error)
+        {
+            if ((SyncManagerErrorCode)error == SyncManagerErrorCode.NotSupported)
+            {
+                return new NotSupportedException("Not supported (%http://tizen.org/feature/account.sync)");
+            }
+            else if ((SyncManagerErrorCode)error == SyncManagerErrorCode.OutOfMemory)
+            {
+                return new OutOfMemoryException("Out of memory");
+            }
+            else if ((SyncManagerErrorCode)error == SyncManagerErrorCode.InvalidParameter)
+            {
+                return new ArgumentException("Invalid parameter");
+            }
+            else if ((SyncManagerErrorCode)error == SyncManagerErrorCode.InvalidOperation)
+            {
+                return new InvalidOperationException("Invalid operation");
+            }
+            else if ((SyncManagerErrorCode)error == SyncManagerErrorCode.PermissionDenied)
+            {
+                return new UnauthorizedAccessException("Permission denied (%http://tizen.org/privilege/alarm.set, %http://tizen.org/privilege/calendar.read, %http://tizen.org/privilege/contact.read)");
+            }
+            else if ((SyncManagerErrorCode)error == SyncManagerErrorCode.IoError)
+            {
+                return new Exception("IO error occured");
+            }
+            else if ((SyncManagerErrorCode)error == SyncManagerErrorCode.AlreadyInProgress)
+            {
+                return new InvalidOperationException("Sync is already in progress");
+            }
+            else if ((SyncManagerErrorCode)error == SyncManagerErrorCode.QuotaExceeded)
+            {
+                return new InvalidOperationException("Quota for sync jobs exceeded");
+            }
+            else if ((SyncManagerErrorCode)error == SyncManagerErrorCode.SystemError)
+            {
+                return new Exception("System error occured");
+            }
+            else if ((SyncManagerErrorCode)error == SyncManagerErrorCode.AdapterNotFound)
+            {
+                return new InvalidOperationException("Sync adapter couldn't be found");
+            }
+            else
+            {
+                return new Exception("Unknown error");
+            }
+        }
+    }
+}
+
diff --git a/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/SyncAdapter.cs b/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/SyncAdapter.cs
new file mode 100755 (executable)
index 0000000..8a59593
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.Applications;
+using Tizen.Account.AccountManager;
+
+namespace Tizen.Account.SyncManager
+{
+    /// <summary>
+    /// The class contains the delegates to be called upon scheduling a sync operation
+    /// </summary>
+    public class SyncAdapter
+    {
+        Interop.Adapter.SyncAdapterStartSyncCallback _startSyncCallback;
+        Interop.Adapter.SyncAdapterCancelSyncCallback _cancelSyncCallback;
+
+        /// <summary>
+        /// Callback function for Sync Adapter's start sync request
+        /// </summary>
+        /// <param name="syncParameters"> The sync job parameters corresponding to the sync request. </param>
+        /// <returns> true if sync operation is success, @c false otherwise. </returns>
+        public delegate bool StartSyncCallback(SyncJobData syncParameters);
+
+        /// <summary>
+        /// Callback function for Sync Adapter's cancel sync request.
+        /// </summary>
+        /// <param name="syncParameters"> The sync job parameters corresponding to the sync request. </param>
+        public delegate void CancelSyncCallback(SyncJobData syncParameters);
+
+        /// <summary>
+        /// Sets client (Sync Adapter) callback functions
+        /// </summary>
+        /// <param name="startSyncCb"> A callback function to be called by Sync Manager for performing sync operation. </param>
+        /// <param name="cancelSyncCb"> A callback function to be called by Sync Manager for cancelling sync operation. </param>
+        /// <exception cref="ArgumentNullException"> Thrown when any of the arguments are null. </exception>
+        /// <exception cref="InvalidOperationException"> Thrown when the application calling this API cannot be a sync adapter. </exception>
+        public void SetSyncEventCallbacks(StartSyncCallback startSyncCb, CancelSyncCallback cancelSyncCb)
+        {
+            if (startSyncCb == null || cancelSyncCb == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            _startSyncCallback = (IntPtr accountHandle, string syncJobName, string syncCapability, IntPtr syncJobUserData) =>
+            {
+                Log.Debug(ErrorFactory.LogTag, "Start sync event received");
+
+                AccountManager.Account account = new AccountManager.Account(new SafeAccountHandle(accountHandle, true));
+                Bundle bundle = new Bundle(new SafeBundleHandle(syncJobUserData, true));
+
+                SyncJobData syncJobData = new SyncJobData()
+                {
+                    Account = account,
+                    SyncJobName = syncJobName,
+                    UserData = bundle
+                };
+
+                return startSyncCb(syncJobData);
+            };
+
+            _cancelSyncCallback = (IntPtr accountHandle, string syncJobName, string syncCapability, IntPtr syncJobUserData) =>
+            {
+                Log.Debug(ErrorFactory.LogTag, "cancel sync event received");
+
+                AccountManager.Account account = new AccountManager.Account(new SafeAccountHandle(accountHandle, true));
+                Bundle bundle = new Bundle(new SafeBundleHandle(syncJobUserData, true));
+
+                SyncJobData syncJobData = new SyncJobData()
+                {
+                    Account = account,
+                    SyncJobName = syncJobName,
+                    UserData = bundle
+                };
+
+                cancelSyncCb(syncJobData);
+            };
+
+            int ret = Interop.Adapter.SetCallbacks(_startSyncCallback, _cancelSyncCallback);
+            if (ret != (int)SyncManagerErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to set callbacks");
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Unsets client (Sync Adapter) callback functions
+        /// </summary>
+        /// <exception cref="System.Exception"> Thrown when sync manager internal error occurs. </exception>
+        public void UnsetSyncEventCallbacks()
+        {
+            int ret = Interop.Adapter.UnsetCallbacks();
+            if (ret != (int)SyncManagerErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to unset callbacks");
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+    }
+}
+
diff --git a/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/SyncClient.cs b/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/SyncClient.cs
new file mode 100755 (executable)
index 0000000..4c82b85
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using Tizen.Applications;
+using Tizen.Account.AccountManager;
+
+namespace Tizen.Account.SyncManager
+{
+    /// <summary>
+    /// The SyncClient APIs for managing the sync operations. Applications will call these APIs to schedule their sync operations.
+    /// Sync service maintains sync requests from all the applications and invokes their respective callback methods to perform account synchronization operations.
+    /// </summary>
+    public static class SyncClient
+    {
+        /// <summary>
+        /// The constructor
+        /// </summary>
+        static SyncClient()
+        {
+        }
+
+        /// <summary>
+        /// Requests Sync Manager to perform one time sync operation
+        /// </summary>
+        /// <param name="request"> Sync job information of the sync job request. </param>
+        /// <param name="syncOptions"> sync options determine an way to operate sync job and can be used as ORing. </param>
+        /// <exception cref="ArgumentNullException"> Thrown when any of the arugments are null. </exception>
+        /// <exception cref="InvalidOperationException"> Thrown when the application calling this api doesn't have a sync adapter. </exception>
+        /// <returns> A unique value which can manage sync jobs. The number of sync job id is limited as less than a hundred. </returns>
+        public static int RequestOnDemandSyncJob(SyncJobData request, SyncOption syncOptions)
+        {
+            if (request == null || request.SyncJobName == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            SafeAccountHandle accountHandle = (request.Account != null) ? request.Account.SafeAccountHandle : new SafeAccountHandle();
+            SafeBundleHandle bundleHandle = (request.UserData != null) ? request.UserData.SafeBundleHandle : new SafeBundleHandle();
+
+            int id = 0;
+            int ret = Interop.Manager.RequestOnDemandSyncJob(accountHandle, request.SyncJobName, (int)syncOptions, bundleHandle, out id);
+            if (ret != (int)SyncManagerErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to request on demand sync job");
+                throw ErrorFactory.GetException(ret);
+            }
+            return id;
+        }
+
+        /// <summary>
+        /// Requests Sync Manager to perform periodic sync operations
+        /// </summary>
+        /// <param name="request"> Sync job information of the sync job request. </param>
+        /// <param name="period"> Determines time interval of periodic sync. The periodic sync operation can be triggered in that interval, but it does not guarantee exact time. The minimum value is 30 minutes. </param>
+        /// <param name="syncOptions"> sync options determine an way to operate sync job and can be used as ORing. </param>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined. </exception>
+        /// <exception cref="ArgumentNullException"> Thrown when any of the arguments are null. </exception>
+        /// <exception cref="InvalidOperationException"> Thrown when the application calling this API doesn't have a sync adapter. </exception>
+        /// <returns> A unique value which can manage sync jobs. The number of sync job id is limited as less than a hundred. </returns>
+        public static int AddPeriodicSyncJob(SyncJobData request, SyncPeriod period, SyncOption syncOptions)
+        {
+            if (request == null || request.SyncJobName == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            SafeAccountHandle accountHandle = (request.Account != null) ? request.Account.SafeAccountHandle : new SafeAccountHandle();
+            SafeBundleHandle bundleHandle = (request.UserData != null) ? request.UserData.SafeBundleHandle : new SafeBundleHandle();
+
+            int id = 0;
+            int ret = Interop.Manager.AddPeriodicSyncJob(accountHandle, request.SyncJobName, (int) period, (int)syncOptions, bundleHandle, out id);
+            if (ret != (int)SyncManagerErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to add periodic sync job");
+                throw ErrorFactory.GetException(ret);
+            }
+            return id;
+        }
+
+        /// <summary>
+        /// Requests Sync Manager to perform sync operations whenever corresponding DB changed
+        /// </summary>
+        /// <param name="request"> Sync job information of the sync job request. </param>
+        /// <param name="syncOptions"> sync options determine an way to operate sync job and can be used as ORing. </param>
+        /// <privilege>http://tizen.org/privilege/calendar.read</privilege>
+        /// <privilege>http://tizen.org/privilege/contact.read</privilege>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined. </exception>
+        /// <exception cref="ArgumentNullException"> Thrown when any of the arguments are null. </exception>
+        /// <exception cref="InvalidOperationException"> Thrown when the application calling this API doesn't have a sync adapter. </exception>
+        /// <returns> A unique value which can manage sync jobs. The number of sync job id is limited as less than a hundred. </returns>
+        public static int AddDataChangeSyncJob(SyncJobData request, SyncOption syncOptions)
+        {
+            if (request == null || request.SyncJobName == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            SafeAccountHandle accountHandle = (request.Account != null) ? request.Account.SafeAccountHandle : new SafeAccountHandle();
+            SafeBundleHandle bundleHandle = (request.UserData != null) ? request.UserData.SafeBundleHandle : new SafeBundleHandle();
+
+            int id = 0;
+            int ret = Interop.Manager.AddDataChangeSyncJob(accountHandle, request.SyncJobName, (int)syncOptions, bundleHandle, out id);
+            if (ret != (int)SyncManagerErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to add data change sync job");
+                throw ErrorFactory.GetException(ret);
+            }
+            return id;
+        }
+
+        /// <summary>
+        /// Get all the sync jobs registered with the sync manager
+        /// </summary>
+        /// <returns>
+        /// Returns the list of SyncJobData corresponding to sync requests.
+        /// </returns>
+        public static IEnumerable<KeyValuePair<int, SyncJobData>> GetAllSyncJobs()
+        {
+            IDictionary<int, SyncJobData> syncJobs = new Dictionary<int, SyncJobData>();
+            Interop.Manager.SyncManagerSyncJobCallback cb = (IntPtr accountHandle, string syncJobName, string syncCapability, int syncJobId, IntPtr syncJobUserData, IntPtr userData) =>
+            {
+                AccountManager.Account account = new AccountManager.Account(new SafeAccountHandle(accountHandle, true));
+                Bundle bundle = new Bundle(new SafeBundleHandle(syncJobUserData, true));
+
+                SyncJobData syncJobData = new SyncJobData();
+                syncJobData.Account = account;
+                if (syncJobName != null)
+                    syncJobData.SyncJobName = syncJobName;
+                else
+                    syncJobData.SyncJobName = syncCapability;
+                syncJobData.UserData = bundle;
+
+                syncJobs.Add(syncJobId, syncJobData);
+                return true;
+            };
+
+            int ret = Interop.Manager.ForeachSyncJob(cb, IntPtr.Zero);
+            if (ret != (int)SyncManagerErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to get registered sync job");
+                throw ErrorFactory.GetException(ret);
+            }
+            return syncJobs;
+        }
+
+        /// <summary>
+        /// Requests Sync Manager to remove corresponding sync job job based on id
+        /// </summary>
+        /// <param name="id"> A unique value of each sync job, it can be used to search specific sync job and remove it. </param>
+        /// <exception cref="ArgumentException"> Thrown if the input arugments is invalid. </exception>
+        public static void RemoveSyncJob(int id)
+        {
+            int ret = Interop.Manager.RemoveSyncJob(id);
+            if (ret != (int)SyncManagerErrorCode.None)
+            {
+                Log.Error(ErrorFactory.LogTag, "Failed to remove sync job");
+                throw ErrorFactory.GetException(ret);
+            }
+        }
+    }
+}
+
diff --git a/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/SyncJobData.cs b/src/Tizen.Account.SyncManager/Tizen.Account.SyncManager/SyncJobData.cs
new file mode 100755 (executable)
index 0000000..51c2039
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using Tizen.Applications;
+using Tizen.Account.AccountManager;
+
+namespace Tizen.Account.SyncManager
+{
+    /// <summary>
+    /// Class represents information about a sync job request
+    /// </summary>
+    public class SyncJobData
+    {
+        /// <summary>
+        /// Represents calendar capability
+        /// </summary>
+        /// <remarks>
+        /// If you want to receive notification about calendar database change, assign it to SyncJobName property of SyncJobData object.
+        /// </remarks>
+        public const string CalendarCapability = "http://tizen.org/sync/capability/calendar";
+
+        /// <summary>
+        /// Represents contact capability
+        /// </summary>
+        /// <remarks>
+        /// If you want to receive notification about contact database change, assign it to SyncJobName property of SyncJobData object.
+        /// </remarks>
+        public const string ContactCapability = "http://tizen.org/sync/capability/contact";
+
+        /// <summary>
+        /// Represents image capability
+        /// </summary>
+        /// <remarks>
+        /// If you want to receive notification about image database change, assign it to SyncJobName property of SyncJobData object.
+        /// </remarks>
+        public const string ImageCapability = "http://tizen.org/sync/capability/image";
+
+        /// <summary>
+        /// Represents video capability
+        /// </summary>
+        /// <remarks>
+        /// If you want to receive notification about video database change, assign it to SyncJobName property of SyncJobData object.
+        /// </remarks>
+        public const string VideoCapability = "http://tizen.org/sync/capability/video";
+
+        /// <summary>
+        /// Represents sound capability
+        /// </summary>
+        /// <remarks>
+        /// If you want to receive notification about sound database change, assign it to SyncJobName property of SyncJobData object.
+        /// </remarks>
+        public const string SoundCapability = "http://tizen.org/sync/capability/sound";
+
+        /// <summary>
+        /// Represents music capability
+        /// </summary>
+        /// <remarks>
+        /// If you want to receive notification about music database change, assign it to SyncJobName property of SyncJobData object.
+        /// </remarks>
+        public const string MusicCapability = "http://tizen.org/sync/capability/music";
+
+        /// <summary>
+        /// The account instance on which sync operation was requested or @c null in the case of accountless sync operation
+        /// </summary>
+        public AccountManager.Account Account { get; set; }
+
+        /// <summary>
+        /// User data which contains additional information related registered sync job
+        /// </summary>
+        public Bundle UserData { get; set; }
+
+        /// <summary>
+        /// A string representing a sync job which has been operated or capability setting to operate data change sync job
+        /// </summary>
+        public string SyncJobName { get; set; }
+    }
+}
+