move csapi to public
authorIckhee Woo <ickhee.woo@samsung.com>
Wed, 7 Dec 2016 10:15:15 +0000 (19:15 +0900)
committerIckhee Woo <ickhee.woo@samsung.com>
Wed, 7 Dec 2016 10:22:28 +0000 (19:22 +0900)
Change-Id: Ic7a8e686808a79b2a3d2eab6d659c72c329eb7a5
Signed-off-by: Ickhee Woo <ickhee.woo@samsung.com>
20 files changed:
LICENSE [new file with mode: 0644]
packaging/csapi-account-manager.manifest [new file with mode: 0644]
packaging/csapi-account-manager.spec [new file with mode: 0755]
src/Tizen.Account.AccountManager/Interop/Interop.Account.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Interop/Interop.AccountProvider.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Interop/Interop.AccountService.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Interop/Interop.Libraries.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Properties/AssemblyInfo.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.csproj [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.project.json [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.nuspec [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.project.json [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.snk [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountEnums.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountErrorFactory.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountProvider.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs [new file with mode: 0644]
src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSucriberEventArgs.cs [new file with mode: 0644]

diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
diff --git a/packaging/csapi-account-manager.manifest b/packaging/csapi-account-manager.manifest
new file mode 100644 (file)
index 0000000..75b0fa5
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+    <request>
+        <domain name="_"/>
+    </request>
+</manifest>
diff --git a/packaging/csapi-account-manager.spec b/packaging/csapi-account-manager.spec
new file mode 100755 (executable)
index 0000000..5577314
--- /dev/null
@@ -0,0 +1,76 @@
+%{!?dotnet_assembly_path: %define dotnet_assembly_path /opt/usr/share/dotnet.tizen/framework}
+
+%if 0%{?tizen_build_devel_mode}
+%define BUILDCONF Debug
+%else
+%define BUILDCONF Release
+%endif
+
+Name:       csapi-account-manager
+Summary:    Tizen account manager API for C#
+Version:    1.0.1
+Release:    1
+Group:      Development/Libraries
+License:    Apache-2.0
+URL:        https://www.tizen.org
+Source0:    %{name}-%{version}.tar.gz
+Source1:    %{name}.manifest
+
+AutoReqProv: no
+
+BuildRequires: mono-compiler
+BuildRequires: mono-devel
+
+BuildRequires: dotnet-build-tools
+
+# NuGet for Dependencies
+BuildRequires: csapi-tizen-nuget
+
+
+%description
+Account Manager C# API for Tizen
+
+%prep
+%setup -q
+cp %{SOURCE1} .
+
+%define Assemblies Tizen.Account.AccountManager
+
+%build
+for ASM in %{Assemblies}; do
+# NuGet Restore
+find $ASM/*.project.json -exec nuget restore {} \;
+# Build
+find $ASM/*.csproj -exec xbuild {} /p:Configuration=%{BUILDCONF} \;
+# NuGet Pack
+nuget pack $ASM/$ASM.nuspec -Version %{version} -Properties Configuration=%{BUILDCONF}
+done
+
+%install
+# Runtime Binary
+mkdir -p %{buildroot}%{dotnet_assembly_path}
+for ASM in %{Assemblies}; do
+%if 0%{?_with_corefx}
+  install -p -m 644 $ASM/bin/%{BUILDCONF}/$ASM.dll %{buildroot}%{dotnet_assembly_path}
+%else
+  install -p -m 644 $ASM/bin/%{BUILDCONF}/Net45/$ASM.dll %{buildroot}%{dotnet_assembly_path}
+%endif
+done
+# NuGet
+mkdir -p %{buildroot}/nuget
+install -p -m 644 *.nupkg %{buildroot}/nuget
+
+%files
+%manifest %{name}.manifest
+%license LICENSE
+%attr(644,root,root) %{dotnet_assembly_path}/*.dll
+
+%package nuget
+Summary:   NuGet package for %{name}
+Group:     Development/Libraries
+
+%description nuget
+NuGet package for %{name}
+
+%files nuget
+/nuget/*.nupkg
diff --git a/src/Tizen.Account.AccountManager/Interop/Interop.Account.cs b/src/Tizen.Account.AccountManager/Interop/Interop.Account.cs
new file mode 100644 (file)
index 0000000..f52da1c
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * 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.Runtime.InteropServices;
+using Tizen.Account.AccountManager;
+/// <summary>
+/// Interop for Account class APIs
+/// </summary>
+internal static partial class Interop
+{
+    /// <summary>
+    /// Interop for Account class APIs
+    /// </summary>
+    internal static partial class Account
+    {
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_create", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Create(out IntPtr handle);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_destroy", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Destroy(IntPtr handle);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_account_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountId(IntPtr data, out int accountId);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_user_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountUserName(IntPtr data, out string userName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_user_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountUserName(IntPtr handle, string userName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_display_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountDisplayName(IntPtr handle, out string displayName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_display_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountDisplayName(IntPtr handle, string displayName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_capability", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountCapability(IntPtr handle, string capabilityType, out int capabilityValue);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_capability", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountCapability(IntPtr handle, string capabilityType, int capabilityValue);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_icon_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountIconPath(IntPtr handle, out string iconPath);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_icon_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountIconPath(IntPtr handle, string iconPath);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_domain_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountDomainName(IntPtr handle, out string domainName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_domain_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountDomainName(IntPtr handle, string domainName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_email_address", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountEmail(IntPtr handle, out string email);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_email_address", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountEmail(IntPtr handle, string email);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_package_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountPackageName(IntPtr handle, out string name);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_package_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountPackageName(IntPtr handle, string name);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_access_token", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountAccessToken(IntPtr handle, out string accessToken);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_access_token", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountAccessToken(IntPtr handle, string accessToken);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_user_text", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountUserText(IntPtr handle, int index, out string userText);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_user_text", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountUserText(IntPtr handle, int index, string userText);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_user_int", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountUserInt(IntPtr handle, int index, out int value);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_user_int", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountUserInt(IntPtr handle, int index, int value);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_auth_type", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountAuthType(IntPtr handle, out int authType);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_auth_type", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountAuthType(IntPtr handle, int authType);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_secret", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountSercet(IntPtr handle, out int secretType);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_secret", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountSecret(IntPtr handle, int secretType);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_sync_support", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountSyncSupport(IntPtr handle, out int syncType);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_sync_support", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountSyncSupport(IntPtr handle, int syncType);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_source", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountSource(IntPtr handle, out string source);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_source", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountSource(IntPtr handle, string source);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_custom", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountCustomValue(IntPtr handle, string key, out string value);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_custom", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SetAccountCustomValue(IntPtr handle, string key, string value);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_update_sync_status_by_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int UpdateAccountSyncStatusById(int accountId, int status);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_capability_all")]
+        internal static extern int GetAllAccountCapabilities(IntPtr handle, AccountCapabilityCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_capability_by_account_id")]
+        internal static extern int QueryAccountCapabilityById(AccountCapabilityCallback callback, int accountId, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_custom_all")]
+        internal static extern int GetAllAccountCustomValues(IntPtr handle, AccountCustomCallback callback, IntPtr userData);
+
+        //Callbacks
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AccountCapabilityCallback(string capabilityType, int capabilityState, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AccountCustomCallback(string key, string value, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AccountCallback(IntPtr data, IntPtr userData);
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Interop/Interop.AccountProvider.cs b/src/Tizen.Account.AccountManager/Interop/Interop.AccountProvider.cs
new file mode 100644 (file)
index 0000000..2f82aa1
--- /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 System.Runtime.InteropServices;
+using Tizen.Account.AccountManager;
+
+/// <summary>
+/// Interop for AccountProvider class APIs
+/// </summary>
+internal static partial class Interop
+{
+    /// <summary>
+    /// Interop for AccountProvider class APIs
+    /// </summary>
+    internal static partial class AccountProvider
+    {
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_create", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Create(out IntPtr handle);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_destroy", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Destroy(IntPtr handle);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_app_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAppId(IntPtr handle, out string appId);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_query_supported_feature", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern bool IsFeatureSupported(string appId, string capabilty);
+
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_service_provider_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetServiceProviderId(IntPtr handle, out string providerId);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_icon_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountProviderIconPath(IntPtr handle, out string iconPath);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_small_icon_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountProviderSmallIconPath(IntPtr handle, out string iconPath);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_multiple_account_support", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetMultipleAccountSupport(IntPtr handle, out int suppport);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_label_by_locale", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetlabelbyLocale(IntPtr handle, string locale, out string label);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_query_app_id_exist", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAppIdExists(string appId);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_foreach_account_type_from_db", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAllAccountProviders(AccountProviderCallback callback, IntPtr data);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_query_provider_feature_by_app_id")]
+        internal static extern int GetAccountProviderFeaturesByAppId(AccountProviderFeatureCallback callback, string appId, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_provider_feature_all")]
+        internal static extern int GetAccountProviderFeatures(IntPtr handle, AccountProviderFeatureCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_get_label")]
+        internal static extern int GetAccountProviderLabels(IntPtr handle, LabelCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_query_label_by_app_id")]
+        internal static extern int GetLablesByAppId(LabelCallback callback, string appId, IntPtr userData);
+
+
+        //Callbacks
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AccountProviderFeatureCallback(string appId, string key, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool AccountProviderCallback(IntPtr handle, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool LabelCallback(string appId, string label, string locale, IntPtr user_data);
+
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Interop/Interop.AccountService.cs b/src/Tizen.Account.AccountManager/Interop/Interop.AccountService.cs
new file mode 100644 (file)
index 0000000..9804c1c
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * 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.Runtime.InteropServices;
+
+/// <summary>
+/// Interop for Account class APIs
+/// </summary>
+internal static partial class Interop
+{
+    /// <summary>
+    /// Interop for Account class APIs
+    /// </summary>
+    internal static partial class AccountService
+    {
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_update_to_db_by_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int UpdateAccountToDBById(IntPtr handle, int id);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_update_to_db_by_user_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int UpdateAccountToDBByUserName(IntPtr handle, string userName, string packageName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_account_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int QueryAccountById(int accountId, out IntPtr handle);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_user_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int QueryAccountByUserName(Interop.Account.AccountCallback callback, string userName, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_package_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int QueryAccountByPackageName(Interop.Account.AccountCallback callback, string packageName, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_capability_by_account_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int QueryAccountCapabilityById(Interop.Account.AccountCapabilityCallback callback, int accoutId, IntPtr data);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_update_sync_status_by_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int UpdateAccountSyncStatusById(int accoutId, int status);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_insert_to_db", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int AddAccount(IntPtr handle, out int accountId);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_delete_from_db_by_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int DeleteAccountById(int accountId);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_delete_from_db_by_user_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int DeleteAccountByUser(string userName, string packageName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_delete_from_db_by_package_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int DeleteAccountByPackage(string packageName);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_total_count_from_db", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAccountCount(out int count);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_foreach_account_from_db")]
+        internal static extern int AccountForeachAccountFromDb(Interop.Account.AccountCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_capability")]
+        internal static extern int GetAccountByCapability(Interop.Account.AccountCallback callback, string capabilityType, int value, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_capability_type")]
+        internal static extern int GetAccountByCapabilityType(Interop.Account.AccountCallback callback, string capabilityType, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_foreach_account_type_from_db")]
+        internal static extern int GetAllAccountproviders(Interop.AccountProvider.AccountProviderCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_query_by_provider_feature")]
+        internal static extern int GetAccountProviderByFeature(Interop.AccountProvider.AccountProviderCallback callback, string key, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_query_by_app_id")]
+        internal static extern int GetAccountProviderByAppId(string appId, out IntPtr handle);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_subscribe_create")]
+        internal static extern int CreateAccountSubscriber(out Interop.AccountService.SafeAccountSubscriberHandle handle);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_subscribe_notification")]
+        internal static extern int RegisterSubscriber(Interop.AccountService.SafeAccountSubscriberHandle handle, Interop.AccountService.SubscribeCallback callback, IntPtr userData);
+
+        [DllImport(Libraries.AccountSvc, EntryPoint = "account_unsubscribe_notification")]
+        internal static extern int UnregisterSubscriber(Interop.AccountService.SafeAccountSubscriberHandle handle);
+
+        //Callbacks
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool SubscribeCallback(string eventType, int accountId, IntPtr userData);
+
+        internal sealed class SafeAccountSubscriberHandle : SafeHandle
+        {
+            public SafeAccountSubscriberHandle()
+                : base(IntPtr.Zero, true)
+            {
+            }
+
+            public override bool IsInvalid
+            {
+                get { return this.handle == IntPtr.Zero; }
+            }
+
+            protected override bool ReleaseHandle()
+            {
+                Account.Destroy(this.handle);
+                this.SetHandle(IntPtr.Zero);
+                return true;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Interop/Interop.Libraries.cs b/src/Tizen.Account.AccountManager/Interop/Interop.Libraries.cs
new file mode 100644 (file)
index 0000000..f18aa0d
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+/// <summary>
+/// Interop for Library reference
+/// </summary>
+internal static partial class Interop
+{
+    /// <summary>
+    /// Interop for Library reference
+    /// </summary>
+    internal static partial class Libraries
+    {
+        public const string AccountSvc = "libaccounts-svc.so.0";
+        public const string Glib = "libglib-2.0.so.0";
+        public const string Libc = "libc.so.6";
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Properties/AssemblyInfo.cs b/src/Tizen.Account.AccountManager/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..eac89fd
--- /dev/null
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tizen.Account.AccountManager")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tizen.Account.AccountManager")]
+[assembly: AssemblyCopyright("Copyright ©  2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("2548b842-f053-4fb2-a15b-43d95239759b")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.csproj b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.csproj
new file mode 100644 (file)
index 0000000..659ca68
--- /dev/null
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{67948043-E29E-4E57-B77E-26B206043718}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Tizen.Account.AccountManager</RootNamespace>
+    <AssemblyName>Tizen.Account.AccountManager</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\Net45\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\Net45\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>true</SignAssembly>
+  </PropertyGroup>
+  <PropertyGroup>
+    <AssemblyOriginatorKeyFile>Tizen.Account.AccountManager.snk</AssemblyOriginatorKeyFile>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="Microsoft.CSharp" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Interop\Interop.Account.cs" />
+    <Compile Include="Interop\Interop.AccountService.cs" />
+    <Compile Include="Interop\Interop.AccountProvider.cs" />
+    <Compile Include="Interop\Interop.Libraries.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Tizen.Account.AccountManager\Account.cs" />
+    <Compile Include="Tizen.Account.AccountManager\AccountEnums.cs" />
+    <Compile Include="Tizen.Account.AccountManager\AccountErrorFactory.cs" />
+    <Compile Include="Tizen.Account.AccountManager\AccountService.cs" />
+    <Compile Include="Tizen.Account.AccountManager\AccountProvider.cs" />
+    <Compile Include="Tizen.Account.AccountManager\AccountSucriberEventArgs.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Tizen.Account.AccountManager.snk" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.project.json b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.project.json
new file mode 100644 (file)
index 0000000..5787764
--- /dev/null
@@ -0,0 +1,11 @@
+{
+  "dependencies": {
+    "Tizen": "1.0.0"
+  },
+  "frameworks": {
+    "net45": {}
+  },
+  "runtimes": {
+    "win": {}
+  }
+}
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj
new file mode 100644 (file)
index 0000000..6a54d6c
--- /dev/null
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{2548B842-F053-4FB2-A15B-43D95239759B}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Tizen.Account.AccountManager</RootNamespace>
+    <AssemblyName>Tizen.Account.AccountManager</AssemblyName>
+    <FileAlignment>512</FileAlignment>
+    <DefaultLanguage>en-US</DefaultLanguage>
+  </PropertyGroup>
+  <PropertyGroup>
+    <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
+    <TargetFrameworkVersion>v1.6</TargetFrameworkVersion>
+    <NuGetTargetMoniker>.NETStandard,Version=v1.6</NuGetTargetMoniker>
+    <TargetFrameworkMoniker>.NETStandard,Version=v1.6</TargetFrameworkMoniker>
+    <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
+    <NoStdLib>true</NoStdLib>
+    <NoWarn>$(NoWarn);1701</NoWarn>
+    <UseVSHostingProcess>false</UseVSHostingProcess>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>true</SignAssembly>
+  </PropertyGroup>
+  <PropertyGroup>
+    <AssemblyOriginatorKeyFile>Tizen.Account.AccountManager.snk</AssemblyOriginatorKeyFile>
+  </PropertyGroup>
+  <ItemGroup>
+    <None Include="Tizen.Account.AccountManager.nuspec" />
+    <None Include="Tizen.Account.AccountManager.project.json" />
+    <None Include="Tizen.Account.AccountManager.snk" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Interop\Interop.Account.cs" />
+    <Compile Include="Interop\Interop.AccountService.cs" />
+    <Compile Include="Interop\Interop.AccountProvider.cs" />
+    <Compile Include="Interop\Interop.Libraries.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Tizen.Account.AccountManager\Account.cs" />
+    <Compile Include="Tizen.Account.AccountManager\AccountEnums.cs" />
+    <Compile Include="Tizen.Account.AccountManager\AccountErrorFactory.cs" />
+    <Compile Include="Tizen.Account.AccountManager\AccountService.cs" />
+    <Compile Include="Tizen.Account.AccountManager\AccountProvider.cs" />
+    <Compile Include="Tizen.Account.AccountManager\AccountSucriberEventArgs.cs" />
+  </ItemGroup>
+  <ItemGroup />
+  <Import Project="$(MSBuildExtensionsPath)\Tizen\Tizen.CSharp.GBS.targets" Condition="Exists('$(MSBuildExtensionsPath)\Tizen\Tizen.CSharp.GBS.targets')" />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+  <PropertyGroup>
+    <!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and
+             https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild
+        -->
+    <!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two
+             properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and
+             to prevent it from outputting a warning (MSB3644).
+        -->
+    <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>
+    <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>
+    <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
+  </PropertyGroup>
+  <!-- Include tasks for Tizen -->
+  <PropertyGroup>
+    <TizenBuildPath>$(MSBuildExtensionsPath)\Tizen</TizenBuildPath>
+    <TizenToolsPath>$(TizenBuildPath)\bin</TizenToolsPath>
+  </PropertyGroup>
+  <UsingTask TaskName="Tizen.Tasks.SignPackage.TizenCleanPackageSource" AssemblyFile="$(TizenToolsPath)\Tizen.Tasks.SignPackage.dll" />
+  <UsingTask TaskName="Tizen.Tasks.SignPackage.TizenPreparePackageManifest" AssemblyFile="$(TizenToolsPath)\Tizen.Tasks.SignPackage.dll" />
+  <UsingTask TaskName="Tizen.Tasks.SignPackage.TizenPreparePackageSource" AssemblyFile="$(TizenToolsPath)\Tizen.Tasks.SignPackage.dll" />
+  <UsingTask TaskName="Tizen.Tasks.SignPackage.TizenSignPackage" AssemblyFile="$(TizenToolsPath)\Tizen.Tasks.SignPackage.dll" />
+  <!-- Task to clean package source -->
+  <Target Name="_TizenCleanPkgSrc">
+    <TizenCleanPackageSource SolutionPath="$(SolutionPath)" ProjectPath="$(MSBuildProjectFullPath)" />
+  </Target>
+  <!-- Task to prepare tizen-manifest.xml file -->
+  <Target Name="_TizenPrepManifest">
+    <TizenPreparePackageManifest SolutionPath="$(SolutionPath)" ProjectPath="$(MSBuildProjectFullPath)" />
+  </Target>
+  <!-- Task to prepare package sources(executable, dlls, resource files) -->
+  <Target Name="_TizenPrepPkgSrc">
+    <TizenPreparePackageSource SolutionPath="$(SolutionPath)" ProjectPath="$(MSBuildProjectFullPath)" AssemblyName="$(AssemblyName)" TargetPath="$(TargetPath)" />
+  </Target>
+  <!-- Task to signing and packaging -->
+  <Target Name="_TizenSignPackge">
+    <TizenSignPackage SolutionPath="$(SolutionPath)" ProjectPath="$(MSBuildProjectFullPath)" SolutionName="$(SolutionName)" AuthorCertificate="$(AuthorCertificate)" AuthorPasswd="$(AuthorPasswd)" DistribCertificate="$(DistribCertificate)" DistribPasswd="$(DistribPasswd)" />
+  </Target>
+</Project>
\ No newline at end of file
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.nuspec b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.nuspec
new file mode 100644 (file)
index 0000000..af9093d
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<package>
+  <metadata>
+    <id>Tizen.Account.AccountManager</id>
+    <version>$version$</version>
+    <authors>Tizen Developers</authors>
+    <description>Account Service APIs for Tizen.Account.AccountManager</description>
+    <dependencies>
+      <dependency id="Tizen" version="1.0.0" />
+    </dependencies>
+  </metadata>
+   <files>
+    <file src="bin/$Configuration$/Tizen.Account.AccountManager.dll" target="lib/netstandard1.3" />
+    <file src="bin/$Configuration$/Net45/Tizen.Account.AccountManager.dll" target="lib/net45" />
+   </files>
+</package>
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.project.json b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.project.json
new file mode 100644 (file)
index 0000000..27943bf
--- /dev/null
@@ -0,0 +1,17 @@
+{
+  "buildOptions": {
+    "debugType": "portable",
+    "platform": "AnyCPU",
+    "preserveCompilationContext": true
+  },
+  "dependencies": {
+    "NETStandard.Library": "1.6.0",
+    "Tizen": "1.0.0"
+  },
+  "runtimes": {
+    "win": {}
+  },
+  "frameworks": {
+    "netstandard1.6": {}
+  }
+}
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.snk b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.snk
new file mode 100644 (file)
index 0000000..24dc971
Binary files /dev/null and b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager.snk differ
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs
new file mode 100644 (file)
index 0000000..cabe14c
--- /dev/null
@@ -0,0 +1,595 @@
+/*
+ * 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;
+
+namespace Tizen.Account.AccountManager
+{
+    /// <summary>
+    /// Represents the Account Information.
+    /// </summary>
+    public class Account : IDisposable
+    {
+        private IntPtr _handle = IntPtr.Zero;
+        internal Account(IntPtr handle)
+        {
+            Handle = handle;
+        }
+
+        ~Account()
+        {
+            Dispose(false);
+        }
+        /// <summary>
+        /// Creates a new Account instance.
+        /// </summary>
+        /// <returns>Account Instance.</returns>
+        public static Account CreateAccount()
+        {
+            IntPtr handle;
+            AccountError err = (AccountError)Interop.Account.Create(out handle);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to create new error.");
+            }
+
+            return new Account(handle);
+        }
+
+        /// <summary>
+        /// Id of the Account.
+        /// </summary>
+        /// <remarks>Account Id shall be created only when account is added to the database.</remarks>
+        public int AccountId
+        {
+            get
+            {
+                int id = 0;
+                AccountError res = (AccountError)Interop.Account.GetAccountId(_handle, out id);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get Id for the Account");
+                }
+
+                return id;
+            }
+        }
+
+        /// <summary>
+        /// UserName of the Account.
+        /// </summary>
+        /// <value>User Name of the Account.</value>
+        public string UserName
+        {
+            get
+            {
+                string name = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountUserName(_handle, out name);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get UserName for the Account");
+                }
+
+                return name;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountUserName(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set UserName for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Display Name of the Account.
+        /// </summary>
+        /// <value>DisplayName of the  Account.</value>
+        public string DisplayName
+        {
+            get
+            {
+                string name = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountDisplayName(_handle, out name);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get DisplayName for the Account");
+                }
+
+                return name;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountDisplayName(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set DisplayName for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Icon path of the Account.
+        /// </summary>
+        /// <value>Icon path of the Account.</value>
+        public string IconPath
+        {
+            get
+            {
+                string path = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountIconPath(_handle, out path);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get IconPath for the Account");
+                }
+
+                return path;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountIconPath(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set IconPath for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Domain name of the Account.
+        /// </summary>
+        /// <value>Domain name of the Account.</value>
+        public string DomainName
+        {
+            get
+            {
+                string name = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountDomainName(_handle, out name);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get DomainName for the Account");
+                }
+
+                return name;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountDomainName(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set DomainName for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Email Id of the Account.
+        /// </summary>
+        /// <value>Email Id of the Account.</value>
+        public string EmailId
+        {
+            get
+            {
+                string email = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountEmail(_handle, out email);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get email for the Account");
+                }
+
+                return email;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountEmail(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set email for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Package Name of the Account.
+        /// </summary>
+        /// <value>Package Name.</value>
+        public string PackageName
+        {
+            get
+            {
+                string name = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountPackageName(_handle, out name);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get PacakageName for the Account");
+                }
+
+                return name;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountPackageName(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set PacakageName for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Access Token of the Account.
+        /// </summary>
+        /// <value>Access Token.</value>
+        public string AccessToken
+        {
+            get
+            {
+                string token = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountAccessToken(_handle, out token);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get token for the Account");
+                }
+
+                return token;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountAccessToken(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set token for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Authentication type of the Account.
+        /// </summary>
+        /// <value>Authentication type.</value>
+        public AccountAuthType AuthType
+        {
+            get
+            {
+                int user;
+                AccountError res = (AccountError)Interop.Account.GetAccountAuthType(_handle, out user);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get AuthType for the Account");
+                }
+
+                return (AccountAuthType)user;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountAuthType(_handle, (int)value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set AuthType for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Secrecy State of the Account.
+        /// </summary>
+        /// <value>Secrecy State.</value>
+        public AccountSecrecyState SecrecyState
+        {
+            get
+            {
+                int state;
+                AccountError res = (AccountError)Interop.Account.GetAccountSercet(_handle, out state);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get User Secret for the Account");
+                }
+
+                return (AccountSecrecyState)state;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountSecret(_handle, (int)value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set User Secret for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Sync State of the Account.
+        /// </summary>
+        /// <value>Sync State.</value>
+        public AccountSyncState SyncState
+        {
+            get
+            {
+                int supported;
+                AccountError res = (AccountError)Interop.Account.GetAccountSyncSupport(_handle, out supported);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get AuthType for the Account");
+                }
+
+                return (AccountSyncState)supported;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountSyncSupport(_handle, (int)value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set AuthType for Account");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Source of the Account .
+        /// </summary>
+        /// <value>Account Source.</value>
+        public string Source
+        {
+            get
+            {
+                string text = "";
+                AccountError res = (AccountError)Interop.Account.GetAccountSource(_handle, out text);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get User Secret for the Account");
+                }
+
+                return text;
+            }
+
+            set
+            {
+                AccountError res = (AccountError)Interop.Account.SetAccountSource(_handle, value);
+                if (res != AccountError.None)
+                {
+                    throw AccountErrorFactory.CreateException(res, "Failed to Set User Secret for Account");
+                }
+            }
+        }
+
+        internal IntPtr Handle
+        {
+            get
+            {
+                return _handle;
+            }
+
+            set
+            {
+                _handle = value;
+            }
+        }
+        /// <summary>
+        /// Sets the account capability.
+        /// </summary>
+        /// <param name="capabilityType"> The Account capability type</param>
+        /// <param name="state">The Account capability state</param>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        public void SetCapability(string capabilityType, CapabilityState state)
+        {
+            AccountError ret = (AccountError)Interop.Account.SetAccountCapability(_handle, capabilityType, (int)state);
+            if (ret != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(ret, "failed to set account capability");
+            }
+        }
+        /// <summary>
+        /// Gets all the capabilities of an account.
+        /// </summary>
+        /// <param name="capabilityType"> The capability type to get the capability value.</param>
+        /// <returns>The capability value (on/off) of the specified CapabilityState .</returns>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        public CapabilityState GetCapability(string capabilityType)
+        {
+            int type;
+            AccountError res = (AccountError)Interop.Account.GetAccountCapability(_handle, capabilityType, out type);
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to GetCapability for Account");
+            }
+
+            return (CapabilityState)type;
+        }
+
+        /// <summary>
+        /// Gets all the capabilities of an account.
+        /// </summary>
+        /// <returns>List of Cpabailities as Dictionary</returns>
+        public Dictionary<string, CapabilityState> GetAllCapabilities()
+        {
+
+            AccountError res = AccountError.None;
+            Dictionary<string, CapabilityState> list = new Dictionary<string, CapabilityState>();
+            Interop.Account.AccountCapabilityCallback capabilityCallback = (string type, int state, IntPtr data) =>
+            {
+                list.Add(type, (CapabilityState)state);
+                return true;
+            };
+
+            res = (AccountError)Interop.Account.GetAllAccountCapabilities(_handle, capabilityCallback, IntPtr.Zero);
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to get account capabilities");
+            }
+
+            return list;
+        }
+
+        /// <summary>
+        /// Sets the Custom Value to the Account.
+        /// </summary>
+        /// <param name="key">key to be added to the Account.</param>
+        /// <param name="value">value to be updated for respective key for the Account.</param>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        public void SetCustomValue(string key, string value)
+        {
+            AccountError err = (AccountError)Interop.Account.SetAccountCustomValue(_handle, key, value);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to set the value for : " + key);
+            }
+        }
+
+        /// <summary>
+        /// Gets the user specific custom text of an account key.
+        /// </summary>
+        /// <param name="key">The key to retrieve custom text .</param>
+        /// <returns>The text of the given key</returns>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        /// <exception cref="InvalidOperationException">If there is no given capability type in the account </exception>
+        public string GetCustomValue(string key)
+        {
+            string result = "";
+            AccountError err = (AccountError)Interop.Account.GetAccountCustomValue(_handle, key, out result);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to get the value for : " + key);
+            }
+
+            return result;
+        }
+
+        /// <summary>
+        /// Gets All the custome values.
+        /// </summary>
+        /// <returns>List of custom key, value pairs as Dictionary.</returns>
+        public Dictionary<string, string> GetAllCustomValues()
+        {
+            AccountError res = AccountError.None;
+            Dictionary<string, string> list = new Dictionary<string, string>();
+
+            Interop.Account.AccountCustomCallback customCallback = (string key, string value, IntPtr data) =>
+            {
+                list.Add(key, value);
+                return true;
+            };
+
+            res = (AccountError)Interop.Account.GetAllAccountCustomValues(_handle, customCallback, IntPtr.Zero);
+
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to get account capabilities");
+            }
+
+            return list;
+        }
+
+        /// <summary>
+        /// Sets the user text.
+        /// </summary>
+        /// <param name="index">The index of the user text (must be in range from 0 to 4) </param>
+        /// <param name="text">The text string to set as the user text</param>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        public void SetUserText(int index, string text)
+        {
+            AccountError err = (AccountError)Interop.Account.SetAccountUserText(_handle, index, text);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to get the value for : " + index);
+            }
+        }
+
+        /// <summary>
+        /// Gets the user text.
+        /// </summary>
+        /// <param name="index">The index of the user text (range: 0 ~ 4)</param>
+        /// <returns>The user text of the given key</returns>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        /// <exception cref="OutOfMemoryException">In case of out of memory</exception>
+        public string GetUserText(int index)
+        {
+            string result = "";
+            AccountError err = (AccountError)Interop.Account.GetAccountUserText(_handle, index, out result);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to get the value for : " + index);
+            }
+
+            return result;
+        }
+
+        /// <summary>
+        /// Gets the user int value.
+        /// </summary>
+        /// <param name="index">The index of the user int (range: 0 ~ 4)</param>
+        /// <returns>The user int of the given key</returns>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        public int GetUserInt(int index)
+        {
+            int result = -1;
+            AccountError err = (AccountError)Interop.Account.GetAccountUserInt(_handle, index, out result);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to get the value for : " + index);
+            }
+
+            return result;
+        }
+
+        /// <summary>
+        /// Sets the user integer value.
+        /// </summary>
+        /// <param name="index">The index of the user integer (must be in range from 0 to 4) </param>
+        /// <param name="value">The integer to set as the user integer</param>
+        /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+        public void SetUserInt(int index, int value)
+        {
+            AccountError err = (AccountError)Interop.Account.SetAccountUserInt(_handle, index, value);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to get the value for : " + index);
+            }
+        }
+
+        /// <summary>
+        /// Overloaded Dispose API for destroying the Account Handle.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (!disposing)
+            {
+                if (_handle != IntPtr.Zero)
+                {
+                    Interop.Account.Destroy(_handle);
+                    _handle = IntPtr.Zero;
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountEnums.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountEnums.cs
new file mode 100644 (file)
index 0000000..045cac7
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * 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.
+ */
+
+namespace Tizen.Account.AccountManager
+{
+    /// <summary>
+    /// Enumeration for the state of capability
+    /// </summary>
+    public enum CapabilityState
+    {
+        /// <summary>
+        /// Account capability is invalid
+        /// </summary>
+        InvalidState,
+
+        /// <summary>
+        /// Account capability is disabled
+        /// </summary>
+        Disabled,
+
+        /// <summary>
+        /// Account capability is enabled
+        /// </summary>
+        Enabled
+    }
+
+    /// <summary>
+    /// Enumeration for the state of account secrecy.
+    /// </summary>
+    public enum AccountSecrecyState
+    {
+        /// <summary>
+        /// Account secrecy is invalid
+        /// </summary>
+        InvalidState,
+
+        /// <summary>
+        /// Account is not visible
+        /// </summary>
+        Invisible,
+
+        /// <summary>
+        /// Account is visible
+        /// </summary>
+        Visible
+    }
+
+    /// <summary>
+    /// Enumeration for the account sync status.
+    /// </summary>
+    public enum AccountSyncState
+    {
+        /// <summary>
+        /// Account sync is invalid
+        /// </summary>
+        InvalidState,
+
+        /// <summary>
+        /// Account sync not supported
+        /// </summary>
+        NotSupported,
+
+        /// <summary>
+        /// Account sync supported but all synchronization functionalities are off
+        /// </summary>
+        Off,
+
+        /// <summary>
+        /// Account sync support and sync status is idle
+        /// </summary>
+        Idle,
+
+        /// <summary>
+        /// Account sync support and sync status is running
+        /// </summary>
+        Running
+    }
+
+    /// <summary>
+    /// Enumeration for the account auth type.
+    /// </summary>
+    public enum AccountAuthType
+    {
+        /// <summary>
+        /// Auth type is invalid
+        /// </summary>
+        Invalid,
+
+        /// <summary>
+        /// XAuth type
+        /// </summary>
+        XAuth,
+
+        /// <summary>
+        /// OAuth type
+        /// </summary>
+        OAuth,
+
+        /// <summary>
+        /// Client-Login type
+        /// </summary>
+        ClientLogin
+    }
+
+    /// <summary>
+    /// Account information change notification type
+    /// </summary>
+    /// <remarks>
+    /// When the account database is changed, You can distinguish one event type from the other which are set for subscribing notification.
+    /// </remarks>
+    public enum AccountNotificationType
+    {
+        /// <summary>
+        /// The insert notification type.
+        /// </summary>
+        Insert,
+        /// <summary>
+        /// The delete notification type.
+        /// </summary>
+        Delete,
+        /// <summary>
+        /// The update notification type.
+        /// </summary>
+        Update,
+        /// <summary>
+        /// The sync update notification type.
+        /// </summary>
+        syncUpdate
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountErrorFactory.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountErrorFactory.cs
new file mode 100644 (file)
index 0000000..13cd203
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * 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;
+
+namespace Tizen.Account.AccountManager
+{
+    /// <summary>
+    /// Enum to give the type of error occured, if any.
+    /// </summary>
+    public enum AccountError
+    {
+        //TIZEN_ERROR_ACCOUNT = -0x01000000
+        /// <summary>
+        /// Successful.
+        /// </summary>
+        None = Tizen.Internals.Errors.ErrorCode.None,
+        /// <summary>
+        /// Invalid parameter.
+        /// </summary>
+        InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+        /// <summary>
+        /// Out of memory.
+        /// </summary>
+        OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+        /// <summary>
+        /// Same user name exists in your application
+        /// </summary>
+        Duplcated = -0x01000000 | 0x01,
+        /// <summary>
+        /// Empty Data
+        /// </summary>
+        NoData = Tizen.Internals.Errors.ErrorCode.NoData,
+        /// <summary>
+        /// elated record does not exist
+        /// </summary>
+        RecordNotFound = -0x01000000 | 0x03,
+        /// <summary>
+        /// Invalid Operation.
+        /// </summary>
+        InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation,
+        /// <summary>
+        /// DB operation failed.
+        /// </summary>
+        DBFailed = -0x01000000 | 0x04,
+        /// <summary>
+        ///  DB is not connected.
+        /// </summary>
+        DBNotOpened = -0x01000000 | 0x05,
+        /// <summary>
+        /// DB query syntax error
+        /// </summary>
+        QuerySyntaxError = -0x01000000 | 0x06,
+        /// <summary>
+        /// Iterator has reached the end
+        /// </summary>
+        IteratorEnd = -0x01000000 | 0x07,
+        /// <summary>
+        /// Notification failed
+        /// </summary>
+        NotificationFailed = -0x01000000 | 0x08,
+        /// <summary>
+        /// Permission denied.
+        /// </summary>
+        PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+        /// <summary>
+        /// XML parse failed
+        /// </summary>
+        XMLParseFailed = -0x01000000 | 0x0a,
+        /// <summary>
+        /// XML File not found
+        /// </summary>
+        XMLFileNotFound = -0x01000000 | 0x0b,
+        /// <summary>
+        /// Subscription failed
+        /// </summary>
+        EventSubscriptionFailed = -0x01000000 | 0x0c,
+        /// <summary>
+        /// Account provider is not registered
+        /// </summary>
+        ProviderNotRegistered = -0x01000000 | 0x0d,
+        /// <summary>
+        /// Multiple accounts are not supported.
+        /// </summary>
+        MultipleNotAllowed = -0x01000000 | 0x0e,
+        /// <summary>
+        /// SQLite busy handler expired
+        /// </summary>
+        DBBusy = -0x01000000 | 0x10
+    };
+
+    internal class AccountErrorFactory
+    {
+        internal const string LogTag = "Tizen.Account.AccountManager";
+
+        internal static Exception CreateException(AccountError err, string msg)
+        {
+            Log.Info(LogTag, "Got Error " + err + " throwing Exception with msg " + msg);
+            Exception exp;
+            switch (err)
+            {
+                case AccountError.InvalidParameter:
+                    {
+                        exp = new ArgumentException(msg + " Invalid Parameters Provided");
+                        break;
+                    }
+
+                case AccountError.OutOfMemory:
+                    {
+                        exp = new OutOfMemoryException(msg + " Out Of Memory");
+                        break;
+                    }
+
+                case AccountError.InvalidOperation:
+                    {
+                        exp = new InvalidOperationException(msg + " Inavlid operation");
+                        break;
+                    }
+
+                case AccountError.NoData:
+                    {
+                        exp = new InvalidOperationException(msg + " Empty Data");
+                        break;
+                    }
+
+                case AccountError.PermissionDenied:
+                    {
+                        exp = new UnauthorizedAccessException(msg + " Permission Denied");
+                        break;
+                    }
+
+                case AccountError.DBFailed:
+                    {
+                        exp = new InvalidOperationException(msg + " DataBase Failed");
+                        break;
+                    }
+
+                case AccountError.DBBusy:
+                    {
+                        exp = new InvalidOperationException(msg + " DataBase Busy");
+                        break;
+                    }
+
+                case AccountError.QuerySyntaxError:
+                    {
+                        exp = new InvalidOperationException(msg + " Network Error");
+                        break;
+                    }
+                case AccountError.XMLFileNotFound:
+                    {
+                        exp = new System.IO.FileNotFoundException(msg + " XML File not found");
+                        break;
+                    }
+                case AccountError.XMLParseFailed:
+                    {
+                        exp = new System.IO.InvalidDataException(msg + " XML parse error");
+                        break;
+                    }
+
+                default:
+                    {
+                        exp = new InvalidOperationException(err + " " + msg);
+                        break;
+                    }
+            }
+
+            return exp;
+        }
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountProvider.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountProvider.cs
new file mode 100644 (file)
index 0000000..8aa882f
--- /dev/null
@@ -0,0 +1,352 @@
+/*
+ * 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.Internals.Errors;
+
+namespace Tizen.Account.AccountManager
+{
+    /// <summary>
+    ///  Account Id.
+    /// </summary>
+    public class AccountProvider : IDisposable
+    {
+        internal IntPtr _handle;
+        internal AccountProvider(IntPtr handle)
+        {
+            Handle = handle;
+        }
+
+        ~AccountProvider()
+        {
+            Dispose(false);
+        }
+
+        internal IntPtr Handle
+        {
+            get
+            {
+                return _handle;
+            }
+
+            set
+            {
+                _handle = value;
+            }
+        }
+        /// <summary>
+        ///  Account Id.
+        /// </summary>
+        public string AppId
+        {
+            get
+            {
+                string id = "";
+                AccountError res = (AccountError)Interop.AccountProvider.GetAppId(Handle, out id);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get AppId for the AccountProvider");
+                }
+
+                return id;
+            }
+        }
+
+        /// <summary>
+        ///  Serviceprovider Id of the account provider.
+        /// </summary>
+        public string ServiceProviderId
+        {
+            get
+            {
+                string id = "";
+                AccountError res = (AccountError)Interop.AccountProvider.GetServiceProviderId(Handle, out id);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get ServiceProviderId for the AccountProvider");
+                }
+
+                return id;
+            }
+        }
+
+        /// <summary>
+        ///  Icon path of an account provider.
+        /// </summary>
+        public string IconPath
+        {
+            get
+            {
+                string path = "";
+                AccountError res = (AccountError)Interop.AccountProvider.GetAccountProviderIconPath(Handle, out path);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get IconPath for the AccountProvider");
+                }
+
+                return path;
+            }
+        }
+
+        /// <summary>
+        ///  Small icon path of an account provider.
+        /// </summary>
+        public string SmallIconPath
+        {
+            get
+            {
+                string path = "";
+                AccountError res = (AccountError)Interop.AccountProvider.GetAccountProviderSmallIconPath(Handle, out path);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get SmallIconPath for the AccountProvider");
+                }
+
+                return path;
+            }
+        }
+
+        /// <summary>
+        ///  Flag for account provider If supports multiple accounts.
+        /// </summary>
+        public bool MultipleAccountSupport
+        {
+            get
+            {
+                int multiple = 0;
+                AccountError res = (AccountError)Interop.AccountProvider.GetMultipleAccountSupport(Handle, out multiple);
+                if (res != AccountError.None)
+                {
+                    Log.Warn(AccountErrorFactory.LogTag, "Failed to get SmallIconPath for the AccountProvider");
+                }
+
+                return (multiple == 0) ? false : true;
+            }
+        }
+
+        /// <summary>
+        /// Retrieves all the capability information of the account provider.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <returns>
+        /// list of capability information.
+        /// </returns>
+        /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public IEnumerable<string> GetAllCapabilities()
+        {
+            List<string> capabilities = new List<string>();
+            AccountError res;
+            Interop.AccountProvider.AccountProviderFeatureCallback callback = (string appId, string key, IntPtr data) =>
+            {
+                capabilities.Add(key);
+                return true;
+            };
+
+            res = (AccountError)Interop.AccountProvider.GetAccountProviderFeatures(Handle, callback, IntPtr.Zero);
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to GetAllCapabilities for AccountProvider");
+            }
+
+            return capabilities;
+        }
+
+        /// <summary>
+        /// Gets the specific label information detail of an account provider.
+        /// </summary>
+        /// <param name="locale">
+        /// The locale is specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code.
+        /// For example, "ko_KR" or "ko-kr" for Korean, "en_US" or "en-us" for American English.
+        /// </param>
+        /// <returns>The label text given for the locale</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given locale</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public string GetLabel(string locale)
+        {
+            string label;
+            AccountError res = (AccountError)Interop.AccountProvider.GetlabelbyLocale(Handle, locale, out label);
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to GetLabel for AccountProvider");
+            }
+
+            return label;
+        }
+
+        /// <summary>
+        /// Gets the specific label information detail of an account provider.
+        /// </summary>
+        /// <param name="appId">
+        /// The application ID to search
+        /// </param>
+        /// <returns> All the labels information for the given application Id.</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given appid</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static Dictionary<string, string> GetLabelsByAppId(string appId)
+        {
+
+            Dictionary<string, string> labels = new Dictionary<string, string>();
+            Interop.AccountProvider.LabelCallback callback = (string applicationId, string label, string locale, IntPtr userData) =>
+            {
+                labels.Add(locale, label);
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountProvider.GetLablesByAppId(callback, appId, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetLablesByAppId");
+            }
+
+            return labels;
+        }
+
+        /// <summary>
+        /// Gets the label information detail of an account provider.
+        /// </summary>
+        /// <returns> All the labels information for the given account provider.</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public Dictionary<string, string> GetLabels()
+        {
+
+            Dictionary<string, string> labels = new Dictionary<string, string>();
+            Interop.AccountProvider.LabelCallback callback = (string applicationId, string label, string locale, IntPtr userData) =>
+            {
+                labels.Add(locale, label);
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountProvider.GetAccountProviderLabels(Handle, callback, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountProviderLabels");
+            }
+
+            return labels;
+        }
+
+        /// <summary>
+        /// Checks whether the given appId exists in the account provider DB.
+        /// </summary>
+        /// <param name="appId">The application ID to check.</param>
+        /// <returns>returns true If App is supported </returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given appid</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public bool IsAppSupported(string appId)
+        {
+            bool isSupported = false;
+            AccountError res = (AccountError)Interop.AccountProvider.GetAppIdExists(appId);
+
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to GetLabel for AccountProvider");
+            }
+            else
+            {
+                isSupported = true;
+            }
+
+            return isSupported;
+        }
+
+        /// <summary>
+        /// Checks whether the given application ID supports the capability.
+        /// </summary>
+        /// <param name="appId">The application Id</param>
+        /// <param name="capability">The capability information</param>
+        /// <returns>
+        /// TRUE if the application supports the given capability,
+        /// otherwise FALSE if the application does not support the given capability
+        /// </returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static bool IsFeatureSupportedByApp(string appId, string capability)
+        {
+            bool supported = Interop.AccountProvider.IsFeatureSupported(appId, capability);
+            if (!supported)
+            {
+                //Get last result and validate error code.
+                AccountError err = (AccountError)ErrorFacts.GetLastResult();
+                if ((err != AccountError.None) && (err != AccountError.RecordNotFound))
+                {
+                    throw AccountErrorFactory.CreateException(err, "Failed to get IsFeatureSupported");
+                }
+            }
+
+            return supported;
+        }
+
+        /// <summary>
+        ///     Retrieves capability information with application ID.
+        /// </summary>
+        /// <param name="appId">application Id</param>
+        /// <returns> Capability information list for the given appId.</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given appid</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static IEnumerable<string> GetFeaturesByAppId(string appId)
+        {
+
+            List<string> features = new List<string>();
+            Interop.AccountProvider.AccountProviderFeatureCallback callback = (string applicationId, string key, IntPtr userData) =>
+            {
+                features.Add(key);
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountProvider.GetAccountProviderFeaturesByAppId(callback, appId, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountProviderFeaturesByAppId");
+            }
+
+            return (IEnumerable<string>)features;
+        }
+
+        /// <summary>
+        /// Overloaded Dispose API for destroying the AccountProvider Handle.
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (!disposing)
+            {
+                if (_handle != IntPtr.Zero)
+                {
+                    Interop.AccountProvider.Destroy(_handle);
+                    _handle = IntPtr.Zero;
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs
new file mode 100644 (file)
index 0000000..4f3f3ae
--- /dev/null
@@ -0,0 +1,578 @@
+/*
+ * 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;
+
+namespace Tizen.Account.AccountManager
+{
+    /// <summary>
+    /// The AccountManager APIs is separated into two major sections:
+    /// 1. Registering an account provider while an application is installed. This information will be used for the Add account screen.
+    /// 2. Adding an account information when an application signs in successfully to share the account information to the Tizen system. This information will be shown in the Tizen settings account menu.
+    ///
+    /// The APIs of both of the sections consist of the following functionality:
+    /// <list>
+    /// <item> Create an account or account provider </item>
+    /// <item> Update an account or account provider(Only available for the creator) </item>
+    /// <item> Delete an account or account provider(Only available for the creator) </item>
+    /// <item> Read an account or account provider with some filter </item>
+    /// </list>
+    /// </summary>
+
+    public static class AccountService
+    {
+        /// <summary>
+        /// This is contact capability string.
+        /// </summary>
+        public static readonly string ContactCapability = "http://tizen.org/account/capability/contact";
+
+        /// <summary>
+        /// This is calendar capability string.
+        /// </summary>
+        public static readonly string CalendarCapability = "http://tizen.org/account/capability/calendar";
+
+        /// <summary>
+        /// This is email capability string.
+        /// </summary>
+        public static readonly string EmailCapability = "http://tizen.org/account/capability/email";
+
+        /// <summary>
+        /// This is photo capability string.
+        /// </summary>
+        public static readonly string PhotoCapability = "http://tizen.org/account/capability/photo";
+
+        /// <summary>
+        /// This is video capability string.
+        /// </summary>
+        public static readonly string VideoCapability = "http://tizen.org/account/capability/video";
+
+        /// <summary>
+        /// This is music capability string.
+        /// </summary>
+        public static readonly string MusicCapability = "http://tizen.org/account/capability/music";
+
+        /// <summary>
+        /// This is document capability string.
+        /// </summary>
+        public static readonly string DocumentCapability = "http://tizen.org/account/capability/document";
+
+        /// <summary>
+        /// This is message capability string.
+        /// </summary>
+        public static readonly string MessageCapability = "http://tizen.org/account/capability/message";
+
+        /// <summary>
+        /// This is game capability string.
+        /// </summary>
+        public static readonly string GameCapability = "http://tizen.org/account/capability/game";
+
+        /// <summary>
+        /// Retrieves all accounts details from the account database.
+        /// </summary>
+        /// <returns>List of Accounts</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error. </exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static IEnumerable<Account> GetAccountsAsync()
+        {
+            List<Account> accounts = new List<Account>();
+            List<int> values = new List<int>();
+            Interop.Account.AccountCallback accountCallback = (IntPtr data, IntPtr userdata) =>
+            {
+                Account account = new Account(data);
+                values.Add(account.AccountId);
+                account.Dispose();
+                return true;
+            };
+
+            AccountError res = (AccountError)Interop.AccountService.AccountForeachAccountFromDb(accountCallback, IntPtr.Zero);
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to AccountForeachAccountFromDb");
+            }
+
+            foreach (int i in values)
+            {
+                Account account = AccountService.GetAccountById(i);
+                accounts.Add(account);
+            }
+
+            return accounts;
+        }
+
+        /// <summary>
+        /// Retrieve an account with the account ID.
+        /// </summary>
+        /// <param name="accountId"> The account Id to be searched.</param>
+        /// <returns>Account instance with reference to the given id.</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given account id</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static Account GetAccountById(int accountId)
+        {
+            Account account = Account.CreateAccount();
+            IntPtr handle = account.Handle;
+            AccountError res = (AccountError)Interop.AccountService.QueryAccountById(accountId, out handle);
+            if (res != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(res, "Failed to get accounts from the database for account id: " + accountId);
+            }
+
+            account.Handle = handle;
+            return account;
+        }
+
+        /// <summary>
+        /// Retrieves all AccountProviders details from the account database.
+        /// </summary>
+        /// <returns>List of AccountProviders</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static IEnumerable<AccountProvider> GetAccountProviders()
+        {
+            List<string> values = new List<string>();
+            List<AccountProvider> providers = new List<AccountProvider>();
+            Interop.AccountProvider.AccountProviderCallback accountCallback = (IntPtr handle, IntPtr data) =>
+            {
+                AccountProvider provider = new AccountProvider(handle);
+                values.Add(provider.AppId);
+                provider.Dispose();
+                return true;
+            };
+
+            AccountError res = (AccountError)Interop.AccountService.GetAllAccountproviders(accountCallback, IntPtr.Zero);
+            if (res != AccountError.None)
+            {
+                Log.Warn(AccountErrorFactory.LogTag, "Failed to get account providers from the database");
+                throw AccountErrorFactory.CreateException(res, "Failed to get account providers from the database");
+            }
+
+            foreach (string val in values)
+            {
+                AccountProvider provider = GetAccountProviderByAppId(val);
+                providers.Add(provider);
+            }
+
+            return providers;
+        }
+
+        /// <summary>
+        /// Retrieves the account provider information with application Id.
+        /// </summary>
+        /// <param name="appId">Application Id.</param>
+        /// <returns>The AccountProvider instance associated with the given application Id.</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given appid</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static AccountProvider GetAccountProviderByAppId(string appId)
+        {
+            IntPtr handle;
+            Interop.AccountProvider.Create(out handle);
+            AccountError err = (AccountError)Interop.AccountService.GetAccountProviderByAppId(appId, out handle);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountProviderByAppId");
+            }
+
+            AccountProvider provider = new AccountProvider(handle);
+            return provider;
+        }
+
+        /// <summary>
+        /// Retrieves all the account providers information with feature.
+        /// </summary>
+        /// <param name="feature">The capability value to search for account providers.</param>
+        /// <returns>Retrieves AccountProviders information with the capability name.</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given feature</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static IEnumerable<AccountProvider> GetAccountProvidersByFeature(string feature)
+        {
+            List<string> values = new List<string>();
+            List<AccountProvider> providers = new List<AccountProvider>();
+            Interop.AccountProvider.AccountProviderCallback providerCallback = (IntPtr handle, IntPtr data) =>
+            {
+                AccountProvider provider = new AccountProvider(handle);
+                values.Add(provider.AppId);
+                provider.Dispose();
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountService.GetAccountProviderByFeature(providerCallback, feature, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountProviderByFeature");
+            }
+
+            foreach (string val in values)
+            {
+                AccountProvider provider = GetAccountProviderByAppId(val);
+                providers.Add(provider);
+            }
+
+            return providers;
+        }
+
+        /// <summary>
+        /// Inserts into the Database with the new account Infomration.
+        /// </summary>
+        /// <param name="account">New Account instance to be added.</param>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <privilege>http://tizen.org/privilege/account.write </privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        /// <exception cref="OutOfMemoryException"> In case of OutOfMemory error.</exception>
+        public static int AddAccount(Account account)
+        {
+            if (account == null)
+            {
+                throw AccountErrorFactory.CreateException(AccountError.InvalidParameter, "Failed to AddAccount");
+            }
+
+            int id = -1;
+            AccountError err = (AccountError)Interop.AccountService.AddAccount(account.Handle, out id);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to AddAccount");
+            }
+
+            return id;
+        }
+
+        /// <summary>
+        /// Updates the account details to the account database.
+        /// </summary>
+        /// <param name="account">account instance to be updated.</param>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <privilege>http://tizen.org/privilege/account.write </privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error </exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        /// <exception cref="OutOfMemoryException"> In case of OutOfMemory error.</exception>
+        public static void UpdateAccount(Account account)
+        {
+            if (account == null)
+            {
+                throw AccountErrorFactory.CreateException(AccountError.InvalidParameter, "Failed to UpdateAccount");
+            }
+
+            AccountError err = (AccountError)Interop.AccountService.UpdateAccountToDBById(account.Handle, account.AccountId);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to UpdateAccount");
+            }
+        }
+
+        /// <summary>
+        /// Deletes the account information from the Database.
+        /// </summary>
+        /// <param name="account">Account instance to be deleted from the database.</param>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <privilege>http://tizen.org/privilege/account.write </privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error </exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static void DeleteAccount(Account account)
+        {
+            if (account == null)
+            {
+                throw AccountErrorFactory.CreateException(AccountError.InvalidParameter, "Failed to DeleteAccount");
+            }
+
+            AccountError err = (AccountError)Interop.AccountService.DeleteAccountById(account.AccountId);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to delete the account by Id: " + account.AccountId);
+            }
+        }
+
+        /// <summary>
+        /// Deletes an account from the account database by user name.
+        /// </summary>
+        /// <param name="userName">The user name of the account to delete.</param>
+        /// <param name="packageName">The package name of the account to delete.</param>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <privilege>http://tizen.org/privilege/account.write </privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static void DeleteAccount(string userName, string packageName)
+        {
+            AccountError err = (AccountError)Interop.AccountService.DeleteAccountByUser(userName, packageName);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to delete the account by userName: " + userName);
+            }
+        }
+
+        /// <summary>
+        /// Deletes an account from the account database by package name.
+        /// </summary>
+        /// <param name="packageName">The package name of the account to delete.</param>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <privilege>http://tizen.org/privilege/account.write </privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static void DeleteAccount(string packageName)
+        {
+            AccountError err = (AccountError)Interop.AccountService.DeleteAccountByPackage(packageName);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to delete the account by package name: " + packageName);
+            }
+
+        }
+
+        /// <summary>
+        /// Retrieves all accounts with the given user name.
+        /// </summary>
+        /// <param name="userName">The user name to search .</param>
+        /// <returns>Accounts list matched with the user name</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given username</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static IEnumerable<Account> GetAccountsByUserName(string userName)
+        {
+            List<Account> accounts = new List<Account>();
+            List<int> values = new List<int>();
+            Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
+            {
+                Account account = new Account(handle);
+                values.Add(account.AccountId);
+                account.Dispose();
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountService.QueryAccountByUserName(accountCallback, userName, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountByUserName");
+            }
+
+            foreach (int i in values)
+            {
+                Account account = AccountService.GetAccountById(i);
+                accounts.Add(account);
+            }
+
+            return accounts;
+        }
+
+        /// <summary>
+        /// Retrieves all accounts with the given package name.
+        /// </summary>
+        /// <param name="packageName"> The package name to Search</param>
+        /// <returns>Accounts list matched with the package name</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given package name</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static IEnumerable<Account> GetAccountsByPackageName(string packageName)
+        {
+            List<Account> accounts = new List<Account>();
+            List<int> values = new List<int>();
+            Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
+            {
+                Account account = new Account(handle);
+                values.Add(account.AccountId);
+                account.Dispose();
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountService.QueryAccountByPackageName(accountCallback, packageName, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountByPackageName");
+            }
+
+            foreach (int i in values)
+            {
+                Account account = AccountService.GetAccountById(i);
+                accounts.Add(account);
+            }
+
+            return accounts;
+        }
+
+        /// <summary>
+        /// Retrieves all accounts with the given cpability type.
+        /// </summary>
+        /// <param name="type"> Capability type</param>
+        /// <returns>Accounts list matched with the capability type</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given capability type</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static IEnumerable<Account> GetAccountsByCapabilityType(string type)
+        {
+            List<Account> accounts = new List<Account>();
+            List<int> values = new List<int>();
+            Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
+            {
+                Account account = new Account(handle);
+                values.Add(account.AccountId);
+                account.Dispose();
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountService.GetAccountByCapabilityType(accountCallback, type, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountByCapabilityType");
+            }
+
+            foreach (int i in values)
+            {
+                Account account = AccountService.GetAccountById(i);
+                accounts.Add(account);
+            }
+
+            return accounts;
+        }
+
+        /// <summary>
+        /// Retrieves all capabilities with the given account
+        /// </summary>
+        /// <param name="accountId">account instance</param>
+        /// <returns>Capabilities list as Dictionary of Capability type and State.</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given account id</exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static Dictionary<string, CapabilityState> GetCapabilitiesById(int accountId)
+        {
+            Dictionary<string, CapabilityState> capabilities = new Dictionary<string, CapabilityState>();
+            Interop.Account.AccountCapabilityCallback capabilityCallback = (string type, int capabilityState, IntPtr data) =>
+            {
+                capabilities.Add(type, (CapabilityState)capabilityState);
+                return true;
+            };
+
+            AccountError err = (AccountError)Interop.AccountService.QueryAccountCapabilityById(capabilityCallback, accountId, IntPtr.Zero);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAllCapabilitiesById");
+            }
+
+            return capabilities;
+        }
+
+        /// <summary>
+        /// Gets the count of accounts in the account database.
+        /// </summary>
+        /// <returns>The number of accounts in the database</returns>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error </exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static int GetAccountsCount()
+        {
+            int count = 0;
+            AccountError err = (AccountError)Interop.AccountService.GetAccountCount(out count);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountCount");
+            }
+
+            return count;
+        }
+
+        /// <summary>
+        /// Updates the sync status of the given account.
+        /// </summary>
+        /// <param name="account"> Account for which sync status needs to be updated</param>
+        /// <param name="status">Sync State</param>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <privilege>http://tizen.org/privilege/account.write</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error </exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static void UpdateSyncStatusById(Account account, AccountSyncState status)
+        {
+            AccountError err = (AccountError)Interop.AccountService.UpdateAccountSyncStatusById(account.AccountId, (int)status);
+            if (err != AccountError.None)
+            {
+                throw AccountErrorFactory.CreateException(err, "Failed to UpdateSyncStatusById");
+            }
+        }
+
+        private static readonly Interop.AccountService.SubscribeCallback s_accountUpdatedCallback = (string eventType, int accountId, IntPtr userData) =>
+        {
+            AccountSucriberEventArgs eventArgs = new AccountSucriberEventArgs(eventType, accountId);
+            s_accountUpdated?.Invoke(null, eventArgs);
+            return true;
+        };
+
+        private static Interop.AccountService.SafeAccountSubscriberHandle s_subscriberHandle;
+
+        private static event EventHandler<AccountSucriberEventArgs> s_accountUpdated;
+        /// <summary>
+        /// ContentUpdated event is triggered when the media item info from DB changes.
+        /// </summary>
+        /// <remarks>
+        /// ContentUpdate event is triggered if the MediaInformaion updated/deleted or new Inforamtion is Inserted.
+        /// </remarks>
+        /// <param name="sender"></param>
+        /// <param name="e">A ContentUpdatedEventArgs object that contains information about the update operation.</param>
+        /// <privilege>http://tizen.org/privilege/account.read</privilege>
+        /// <exception cref="InvalidOperationException">In case of any DB error </exception>
+        /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+        public static event EventHandler<AccountSucriberEventArgs> AccountUpdated
+        {
+            add
+            {
+                if (s_accountUpdated == null)
+                {
+                    if (s_subscriberHandle == null)
+                    {
+                        Interop.AccountService.CreateAccountSubscriber(out s_subscriberHandle);
+                    }
+
+                    AccountError ret = (AccountError)Interop.AccountService.RegisterSubscriber(s_subscriberHandle, s_accountUpdatedCallback, IntPtr.Zero);
+
+                    if (ret != AccountError.None)
+                    {
+                        throw AccountErrorFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+
+                s_accountUpdated += value;
+            }
+
+            remove
+            {
+                s_accountUpdated -= value;
+                if (s_accountUpdated == null)
+                {
+                    AccountError ret = (AccountError)Interop.AccountService.UnregisterSubscriber(s_subscriberHandle);
+                    if (ret != AccountError.None)
+                    {
+                        throw AccountErrorFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+            }
+        }
+
+    }
+}
diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSucriberEventArgs.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSucriberEventArgs.cs
new file mode 100644 (file)
index 0000000..a9b9215
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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.AccountManager
+{
+    /// <summary>
+    /// Event arguments passed when Event is triggered to notify that account is updated/removed from the account database.
+    /// </summary>
+    public class AccountSucriberEventArgs : EventArgs
+    {
+        private const string NotiInsert = "insert";
+        private const string NotiDelete = "delete";
+        private const string NotiUpdate = "update";
+        private const string NotiSyncUpdate = "sync_update";
+        internal AccountSucriberEventArgs(string eventType, int accountId)
+        {
+            if (eventType.CompareTo(NotiInsert) == 0)
+            {
+                EventType = AccountNotificationType.Insert;
+            }
+            else if (eventType.CompareTo(NotiDelete) == 0)
+            {
+                EventType = AccountNotificationType.Delete;
+            }
+            else if (eventType.CompareTo(NotiUpdate) == 0)
+            {
+                EventType = AccountNotificationType.Update;
+            }
+            else if (eventType.CompareTo(NotiSyncUpdate) == 0)
+            {
+                EventType = AccountNotificationType.syncUpdate;
+            }
+
+            AccountId = accountId;
+        }
+
+        /// <summary>
+        /// The account event type
+        /// </summary>
+        public AccountNotificationType EventType
+        {
+            get;
+            internal set;
+        }
+
+        /// <summary>
+        /// The account ID to update
+        /// </summary>
+        public int AccountId
+        {
+            get;
+            internal set;
+        }
+    }
+}