From 6b2c7b889430feb0173dda973117746ae5b481e7 Mon Sep 17 00:00:00 2001 From: Ickhee Woo Date: Wed, 7 Dec 2016 19:15:15 +0900 Subject: [PATCH 2/5] move csapi to public Change-Id: Ic7a8e686808a79b2a3d2eab6d659c72c329eb7a5 Signed-off-by: Ickhee Woo --- LICENSE | 202 +++++++ .../Interop/Interop.Account.cs | 151 ++++++ .../Interop/Interop.AccountProvider.cs | 90 ++++ .../Interop/Interop.AccountService.cs | 117 ++++ .../Interop/Interop.Libraries.cs | 31 ++ .../Properties/AssemblyInfo.cs | 35 ++ .../Tizen.Account.AccountManager.Net45.csproj | 66 +++ ...Tizen.Account.AccountManager.Net45.project.json | 11 + .../Tizen.Account.AccountManager.csproj | 115 ++++ .../Tizen.Account.AccountManager.nuspec | 16 + .../Tizen.Account.AccountManager.project.json | 17 + .../Tizen.Account.AccountManager.snk | Bin 0 -> 596 bytes .../Tizen.Account.AccountManager/Account.cs | 595 +++++++++++++++++++++ .../Tizen.Account.AccountManager/AccountEnums.cs | 143 +++++ .../AccountErrorFactory.cs | 184 +++++++ .../AccountProvider.cs | 352 ++++++++++++ .../Tizen.Account.AccountManager/AccountService.cs | 578 ++++++++++++++++++++ .../AccountSucriberEventArgs.cs | 70 +++ packaging/csapi-account-manager.manifest | 5 + packaging/csapi-account-manager.spec | 76 +++ 20 files changed, 2854 insertions(+) create mode 100644 LICENSE create mode 100644 Tizen.Account.AccountManager/Interop/Interop.Account.cs create mode 100644 Tizen.Account.AccountManager/Interop/Interop.AccountProvider.cs create mode 100644 Tizen.Account.AccountManager/Interop/Interop.AccountService.cs create mode 100644 Tizen.Account.AccountManager/Interop/Interop.Libraries.cs create mode 100644 Tizen.Account.AccountManager/Properties/AssemblyInfo.cs create mode 100644 Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.csproj create mode 100644 Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.project.json create mode 100644 Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj create mode 100644 Tizen.Account.AccountManager/Tizen.Account.AccountManager.nuspec create mode 100644 Tizen.Account.AccountManager/Tizen.Account.AccountManager.project.json create mode 100644 Tizen.Account.AccountManager/Tizen.Account.AccountManager.snk create mode 100644 Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs create mode 100644 Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountEnums.cs create mode 100644 Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountErrorFactory.cs create mode 100644 Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountProvider.cs create mode 100644 Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs create mode 100644 Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSucriberEventArgs.cs create mode 100644 packaging/csapi-account-manager.manifest create mode 100755 packaging/csapi-account-manager.spec diff --git a/LICENSE b/LICENSE new file mode 100644 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/Tizen.Account.AccountManager/Interop/Interop.Account.cs b/Tizen.Account.AccountManager/Interop/Interop.Account.cs new file mode 100644 index 0000000..f52da1c --- /dev/null +++ b/Tizen.Account.AccountManager/Interop/Interop.Account.cs @@ -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; +/// +/// Interop for Account class APIs +/// +internal static partial class Interop +{ + /// + /// Interop for Account class APIs + /// + 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/Tizen.Account.AccountManager/Interop/Interop.AccountProvider.cs b/Tizen.Account.AccountManager/Interop/Interop.AccountProvider.cs new file mode 100644 index 0000000..2f82aa1 --- /dev/null +++ b/Tizen.Account.AccountManager/Interop/Interop.AccountProvider.cs @@ -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; + +/// +/// Interop for AccountProvider class APIs +/// +internal static partial class Interop +{ + /// + /// Interop for AccountProvider class APIs + /// + 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/Tizen.Account.AccountManager/Interop/Interop.AccountService.cs b/Tizen.Account.AccountManager/Interop/Interop.AccountService.cs new file mode 100644 index 0000000..9804c1c --- /dev/null +++ b/Tizen.Account.AccountManager/Interop/Interop.AccountService.cs @@ -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; + +/// +/// Interop for Account class APIs +/// +internal static partial class Interop +{ + /// + /// Interop for Account class APIs + /// + 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/Tizen.Account.AccountManager/Interop/Interop.Libraries.cs b/Tizen.Account.AccountManager/Interop/Interop.Libraries.cs new file mode 100644 index 0000000..f18aa0d --- /dev/null +++ b/Tizen.Account.AccountManager/Interop/Interop.Libraries.cs @@ -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. + */ + +/// +/// Interop for Library reference +/// +internal static partial class Interop +{ + /// + /// Interop for Library reference + /// + 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/Tizen.Account.AccountManager/Properties/AssemblyInfo.cs b/Tizen.Account.AccountManager/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..eac89fd --- /dev/null +++ b/Tizen.Account.AccountManager/Properties/AssemblyInfo.cs @@ -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/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.csproj b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.csproj new file mode 100644 index 0000000..659ca68 --- /dev/null +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.csproj @@ -0,0 +1,66 @@ + + + + + Debug + AnyCPU + {67948043-E29E-4E57-B77E-26B206043718} + Library + Properties + Tizen.Account.AccountManager + Tizen.Account.AccountManager + v4.5 + 512 + + + true + full + false + bin\Debug\Net45\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\Net45\ + TRACE + prompt + 4 + + + true + + + Tizen.Account.AccountManager.snk + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.project.json b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.project.json new file mode 100644 index 0000000..5787764 --- /dev/null +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.project.json @@ -0,0 +1,11 @@ +{ + "dependencies": { + "Tizen": "1.0.0" + }, + "frameworks": { + "net45": {} + }, + "runtimes": { + "win": {} + } +} diff --git a/Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj new file mode 100644 index 0000000..6a54d6c --- /dev/null +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj @@ -0,0 +1,115 @@ + + + + 14.0 + Debug + AnyCPU + 8.0.30703 + 2.0 + {2548B842-F053-4FB2-A15B-43D95239759B} + Library + Properties + Tizen.Account.AccountManager + Tizen.Account.AccountManager + 512 + en-US + + + .NETStandard + v1.6 + .NETStandard,Version=v1.6 + .NETStandard,Version=v1.6 + false + true + $(NoWarn);1701 + false + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + + + Tizen.Account.AccountManager.snk + + + + + + + + + + + + + + + + + + + + + + + + + + + <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory) + <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory) + true + + + + $(MSBuildExtensionsPath)\Tizen + $(TizenBuildPath)\bin + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tizen.Account.AccountManager/Tizen.Account.AccountManager.nuspec b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.nuspec new file mode 100644 index 0000000..af9093d --- /dev/null +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.nuspec @@ -0,0 +1,16 @@ + + + + Tizen.Account.AccountManager + $version$ + Tizen Developers + Account Service APIs for Tizen.Account.AccountManager + + + + + + + + + diff --git a/Tizen.Account.AccountManager/Tizen.Account.AccountManager.project.json b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.project.json new file mode 100644 index 0000000..27943bf --- /dev/null +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.project.json @@ -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/Tizen.Account.AccountManager/Tizen.Account.AccountManager.snk b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.snk new file mode 100644 index 0000000000000000000000000000000000000000..24dc9719c9296eef31633107d50ee33d3d6f1de2 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50097-Kw&Z@*)c_xVp06}7-$!$wnwu~AeE~c z)F(tEOd7EbF(^U?b{aPtIlx@;$%;6~hOEz4jHvn!r zd(O_5T!*9T$@t6wLj*vb)q~KZAV&nrEoa#w8DYT9ZKzLk%ThkIc?5}&%+)8QXQr_u zB;q;RXt|xw{2-mk`b)Y82t3q{)k9A&{P$2Y()_xSsmr~Rs*b`n-Q*$^!JMe?os7qR zBvd|H8bsVp_Gt7eod6&Ec)}Dvh{q0bt=Oa*H$YN1ig;#wujJ(uv=&T^>0mQ1pM%N( zg`$>r1{8y%1GT)(trFcFOVc^=028{Sz{VXCY@)x>PjG$LXZ%^P(c#ML?+i^I~O6MtO966(E$Y zb;!f8Vsz^*D57mguWkp3<)QlehSaq*m4RK}o za3<-s5$X9Tkded;%AH4zQAv~uEHLq0iB+u~L5#|v)=Q)Yg)d=FecIqYMXjs%6}%S{ zI*nK8ylM-P-VN%&n^m+Gf#&|vX$PoCOiB&jrsr5Np=;a!$e!7&EKAE9D)^%;lfK~t zA{?PSWo^M1p3lvl@ZR4X_HUbXls~xtC~CQ(Uc;!PuNMQg%in+(-|y`dytNYNmb{pE iSmNtDx}gsqUVNw;6%_2*9~+1DJgUE8d#(7BiJodJcOe@9 literal 0 HcmV?d00001 diff --git a/Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs new file mode 100644 index 0000000..cabe14c --- /dev/null +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs @@ -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 +{ + /// + /// Represents the Account Information. + /// + public class Account : IDisposable + { + private IntPtr _handle = IntPtr.Zero; + internal Account(IntPtr handle) + { + Handle = handle; + } + + ~Account() + { + Dispose(false); + } + /// + /// Creates a new Account instance. + /// + /// Account Instance. + 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); + } + + /// + /// Id of the Account. + /// + /// Account Id shall be created only when account is added to the database. + 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; + } + } + + /// + /// UserName of the Account. + /// + /// User Name of the Account. + 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"); + } + } + } + + /// + /// Display Name of the Account. + /// + /// DisplayName of the Account. + 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"); + } + } + } + + /// + /// Icon path of the Account. + /// + /// Icon path of the Account. + 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"); + } + } + } + + /// + /// Domain name of the Account. + /// + /// Domain name of the Account. + 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"); + } + } + } + + /// + /// Email Id of the Account. + /// + /// Email Id of the Account. + 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"); + } + } + } + + /// + /// Package Name of the Account. + /// + /// Package Name. + 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"); + } + } + } + + /// + /// Access Token of the Account. + /// + /// Access Token. + 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"); + } + } + } + + /// + /// Authentication type of the Account. + /// + /// Authentication type. + 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"); + } + } + } + + /// + /// Secrecy State of the Account. + /// + /// Secrecy State. + 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"); + } + } + } + + /// + /// Sync State of the Account. + /// + /// Sync State. + 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"); + } + } + } + + /// + /// Source of the Account . + /// + /// Account Source. + 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; + } + } + /// + /// Sets the account capability. + /// + /// The Account capability type + /// The Account capability state + /// In case of invalid parameters + 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"); + } + } + /// + /// Gets all the capabilities of an account. + /// + /// The capability type to get the capability value. + /// The capability value (on/off) of the specified CapabilityState . + /// In case of invalid parameters + 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; + } + + /// + /// Gets all the capabilities of an account. + /// + /// List of Cpabailities as Dictionary + public Dictionary GetAllCapabilities() + { + + AccountError res = AccountError.None; + Dictionary list = new Dictionary(); + 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; + } + + /// + /// Sets the Custom Value to the Account. + /// + /// key to be added to the Account. + /// value to be updated for respective key for the Account. + /// In case of invalid parameters + 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); + } + } + + /// + /// Gets the user specific custom text of an account key. + /// + /// The key to retrieve custom text . + /// The text of the given key + /// In case of invalid parameters + /// If there is no given capability type in the account + 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; + } + + /// + /// Gets All the custome values. + /// + /// List of custom key, value pairs as Dictionary. + public Dictionary GetAllCustomValues() + { + AccountError res = AccountError.None; + Dictionary list = new Dictionary(); + + 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; + } + + /// + /// Sets the user text. + /// + /// The index of the user text (must be in range from 0 to 4) + /// The text string to set as the user text + /// In case of invalid parameters + 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); + } + } + + /// + /// Gets the user text. + /// + /// The index of the user text (range: 0 ~ 4) + /// The user text of the given key + /// In case of invalid parameters + /// In case of out of memory + 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; + } + + /// + /// Gets the user int value. + /// + /// The index of the user int (range: 0 ~ 4) + /// The user int of the given key + /// In case of invalid parameters + 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; + } + + /// + /// Sets the user integer value. + /// + /// The index of the user integer (must be in range from 0 to 4) + /// The integer to set as the user integer + /// In case of invalid parameters + 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); + } + } + + /// + /// Overloaded Dispose API for destroying the Account Handle. + /// + 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/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountEnums.cs b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountEnums.cs new file mode 100644 index 0000000..045cac7 --- /dev/null +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountEnums.cs @@ -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 +{ + /// + /// Enumeration for the state of capability + /// + public enum CapabilityState + { + /// + /// Account capability is invalid + /// + InvalidState, + + /// + /// Account capability is disabled + /// + Disabled, + + /// + /// Account capability is enabled + /// + Enabled + } + + /// + /// Enumeration for the state of account secrecy. + /// + public enum AccountSecrecyState + { + /// + /// Account secrecy is invalid + /// + InvalidState, + + /// + /// Account is not visible + /// + Invisible, + + /// + /// Account is visible + /// + Visible + } + + /// + /// Enumeration for the account sync status. + /// + public enum AccountSyncState + { + /// + /// Account sync is invalid + /// + InvalidState, + + /// + /// Account sync not supported + /// + NotSupported, + + /// + /// Account sync supported but all synchronization functionalities are off + /// + Off, + + /// + /// Account sync support and sync status is idle + /// + Idle, + + /// + /// Account sync support and sync status is running + /// + Running + } + + /// + /// Enumeration for the account auth type. + /// + public enum AccountAuthType + { + /// + /// Auth type is invalid + /// + Invalid, + + /// + /// XAuth type + /// + XAuth, + + /// + /// OAuth type + /// + OAuth, + + /// + /// Client-Login type + /// + ClientLogin + } + + /// + /// Account information change notification type + /// + /// + /// When the account database is changed, You can distinguish one event type from the other which are set for subscribing notification. + /// + public enum AccountNotificationType + { + /// + /// The insert notification type. + /// + Insert, + /// + /// The delete notification type. + /// + Delete, + /// + /// The update notification type. + /// + Update, + /// + /// The sync update notification type. + /// + syncUpdate + } +} diff --git a/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountErrorFactory.cs b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountErrorFactory.cs new file mode 100644 index 0000000..13cd203 --- /dev/null +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountErrorFactory.cs @@ -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 +{ + /// + /// Enum to give the type of error occured, if any. + /// + public enum AccountError + { + //TIZEN_ERROR_ACCOUNT = -0x01000000 + /// + /// Successful. + /// + None = Tizen.Internals.Errors.ErrorCode.None, + /// + /// Invalid parameter. + /// + InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, + /// + /// Out of memory. + /// + OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, + /// + /// Same user name exists in your application + /// + Duplcated = -0x01000000 | 0x01, + /// + /// Empty Data + /// + NoData = Tizen.Internals.Errors.ErrorCode.NoData, + /// + /// elated record does not exist + /// + RecordNotFound = -0x01000000 | 0x03, + /// + /// Invalid Operation. + /// + InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation, + /// + /// DB operation failed. + /// + DBFailed = -0x01000000 | 0x04, + /// + /// DB is not connected. + /// + DBNotOpened = -0x01000000 | 0x05, + /// + /// DB query syntax error + /// + QuerySyntaxError = -0x01000000 | 0x06, + /// + /// Iterator has reached the end + /// + IteratorEnd = -0x01000000 | 0x07, + /// + /// Notification failed + /// + NotificationFailed = -0x01000000 | 0x08, + /// + /// Permission denied. + /// + PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, + /// + /// XML parse failed + /// + XMLParseFailed = -0x01000000 | 0x0a, + /// + /// XML File not found + /// + XMLFileNotFound = -0x01000000 | 0x0b, + /// + /// Subscription failed + /// + EventSubscriptionFailed = -0x01000000 | 0x0c, + /// + /// Account provider is not registered + /// + ProviderNotRegistered = -0x01000000 | 0x0d, + /// + /// Multiple accounts are not supported. + /// + MultipleNotAllowed = -0x01000000 | 0x0e, + /// + /// SQLite busy handler expired + /// + 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/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountProvider.cs b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountProvider.cs new file mode 100644 index 0000000..8aa882f --- /dev/null +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountProvider.cs @@ -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 +{ + /// + /// Account Id. + /// + 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; + } + } + /// + /// Account Id. + /// + 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; + } + } + + /// + /// Serviceprovider Id of the account provider. + /// + 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; + } + } + + /// + /// Icon path of an account provider. + /// + 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; + } + } + + /// + /// Small icon path of an account provider. + /// + 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; + } + } + + /// + /// Flag for account provider If supports multiple accounts. + /// + 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; + } + } + + /// + /// Retrieves all the capability information of the account provider. + /// + /// http://tizen.org/privilege/account.read + /// + /// list of capability information. + /// + /// In case of any DB error + /// In case of privilege not defined. + public IEnumerable GetAllCapabilities() + { + List capabilities = new List(); + 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; + } + + /// + /// Gets the specific label information detail of an account provider. + /// + /// + /// 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. + /// + /// The label text given for the locale + /// http://tizen.org/privilege/account.read + /// In case of any DB error or record not found for given locale + /// In case of privilege not defined. + 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; + } + + /// + /// Gets the specific label information detail of an account provider. + /// + /// + /// The application ID to search + /// + /// All the labels information for the given application Id. + /// http://tizen.org/privilege/account.read + /// In case of any DB error or record not found for given appid + /// In case of invalid parameter + /// In case of privilege not defined. + public static Dictionary GetLabelsByAppId(string appId) + { + + Dictionary labels = new Dictionary(); + 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; + } + + /// + /// Gets the label information detail of an account provider. + /// + /// All the labels information for the given account provider. + /// http://tizen.org/privilege/account.read + /// In case of any DB error + /// In case of privilege not defined. + public Dictionary GetLabels() + { + + Dictionary labels = new Dictionary(); + 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; + } + + /// + /// Checks whether the given appId exists in the account provider DB. + /// + /// The application ID to check. + /// returns true If App is supported + /// http://tizen.org/privilege/account.read + /// In case of any DB error or record not found for given appid + /// In case of invalid parameter + /// In case of privilege not defined. + 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; + } + + /// + /// Checks whether the given application ID supports the capability. + /// + /// The application Id + /// The capability information + /// + /// TRUE if the application supports the given capability, + /// otherwise FALSE if the application does not support the given capability + /// + /// http://tizen.org/privilege/account.read + /// In case of any DB error + /// In case of invalid parameter + /// In case of privilege not defined. + 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; + } + + /// + /// Retrieves capability information with application ID. + /// + /// application Id + /// Capability information list for the given appId. + /// http://tizen.org/privilege/account.read + /// In case of any DB error or record not found for given appid + /// In case of invalid parameter + /// In case of privilege not defined. + public static IEnumerable GetFeaturesByAppId(string appId) + { + + List features = new List(); + 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)features; + } + + /// + /// Overloaded Dispose API for destroying the AccountProvider Handle. + /// + 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/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs new file mode 100644 index 0000000..4f3f3ae --- /dev/null +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs @@ -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 +{ + /// + /// 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: + /// + /// Create an account or account provider + /// Update an account or account provider(Only available for the creator) + /// Delete an account or account provider(Only available for the creator) + /// Read an account or account provider with some filter + /// + /// + + public static class AccountService + { + /// + /// This is contact capability string. + /// + public static readonly string ContactCapability = "http://tizen.org/account/capability/contact"; + + /// + /// This is calendar capability string. + /// + public static readonly string CalendarCapability = "http://tizen.org/account/capability/calendar"; + + /// + /// This is email capability string. + /// + public static readonly string EmailCapability = "http://tizen.org/account/capability/email"; + + /// + /// This is photo capability string. + /// + public static readonly string PhotoCapability = "http://tizen.org/account/capability/photo"; + + /// + /// This is video capability string. + /// + public static readonly string VideoCapability = "http://tizen.org/account/capability/video"; + + /// + /// This is music capability string. + /// + public static readonly string MusicCapability = "http://tizen.org/account/capability/music"; + + /// + /// This is document capability string. + /// + public static readonly string DocumentCapability = "http://tizen.org/account/capability/document"; + + /// + /// This is message capability string. + /// + public static readonly string MessageCapability = "http://tizen.org/account/capability/message"; + + /// + /// This is game capability string. + /// + public static readonly string GameCapability = "http://tizen.org/account/capability/game"; + + /// + /// Retrieves all accounts details from the account database. + /// + /// List of Accounts + /// http://tizen.org/privilege/account.read + /// In case of any DB error. + /// In case of privilege not defined. + public static IEnumerable GetAccountsAsync() + { + List accounts = new List(); + List values = new List(); + 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; + } + + /// + /// Retrieve an account with the account ID. + /// + /// The account Id to be searched. + /// Account instance with reference to the given id. + /// http://tizen.org/privilege/account.read + /// In case of any DB error or record not found for given account id + /// In case of invalid parameter + /// In case of privilege not defined. + 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; + } + + /// + /// Retrieves all AccountProviders details from the account database. + /// + /// List of AccountProviders + /// http://tizen.org/privilege/account.read + /// In case of any DB error + /// In case of privilege not defined. + public static IEnumerable GetAccountProviders() + { + List values = new List(); + List providers = new List(); + 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; + } + + /// + /// Retrieves the account provider information with application Id. + /// + /// Application Id. + /// The AccountProvider instance associated with the given application Id. + /// http://tizen.org/privilege/account.read + /// In case of any DB error or record not found for given appid + /// In case of invalid parameter + /// In case of privilege not defined. + 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; + } + + /// + /// Retrieves all the account providers information with feature. + /// + /// The capability value to search for account providers. + /// Retrieves AccountProviders information with the capability name. + /// http://tizen.org/privilege/account.read + /// In case of any DB error or record not found for given feature + /// In case of invalid parameter + /// In case of privilege not defined. + public static IEnumerable GetAccountProvidersByFeature(string feature) + { + List values = new List(); + List providers = new List(); + 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; + } + + /// + /// Inserts into the Database with the new account Infomration. + /// + /// New Account instance to be added. + /// http://tizen.org/privilege/account.read + /// http://tizen.org/privilege/account.write + /// In case of any DB error + /// In case of invalid parameter + /// In case of privilege not defined. + /// In case of OutOfMemory error. + 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; + } + + /// + /// Updates the account details to the account database. + /// + /// account instance to be updated. + /// http://tizen.org/privilege/account.read + /// http://tizen.org/privilege/account.write + /// In case of any DB error + /// In case of invalid parameter + /// In case of privilege not defined. + /// In case of OutOfMemory error. + 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"); + } + } + + /// + /// Deletes the account information from the Database. + /// + /// Account instance to be deleted from the database. + /// http://tizen.org/privilege/account.read + /// http://tizen.org/privilege/account.write + /// In case of any DB error + /// In case of invalid parameter + /// In case of privilege not defined. + 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); + } + } + + /// + /// Deletes an account from the account database by user name. + /// + /// The user name of the account to delete. + /// The package name of the account to delete. + /// http://tizen.org/privilege/account.read + /// http://tizen.org/privilege/account.write + /// In case of any DB error + /// In case of invalid parameter + /// In case of privilege not defined. + 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); + } + } + + /// + /// Deletes an account from the account database by package name. + /// + /// The package name of the account to delete. + /// http://tizen.org/privilege/account.read + /// http://tizen.org/privilege/account.write + /// In case of any DB error + /// In case of invalid parameter + /// In case of privilege not defined. + 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); + } + + } + + /// + /// Retrieves all accounts with the given user name. + /// + /// The user name to search . + /// Accounts list matched with the user name + /// http://tizen.org/privilege/account.read + /// In case of any DB error or record not found for given username + /// In case of invalid parameter + /// In case of privilege not defined. + public static IEnumerable GetAccountsByUserName(string userName) + { + List accounts = new List(); + List values = new List(); + 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; + } + + /// + /// Retrieves all accounts with the given package name. + /// + /// The package name to Search + /// Accounts list matched with the package name + /// http://tizen.org/privilege/account.read + /// In case of any DB error or record not found for given package name + /// In case of invalid parameter + /// In case of privilege not defined. + public static IEnumerable GetAccountsByPackageName(string packageName) + { + List accounts = new List(); + List values = new List(); + 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; + } + + /// + /// Retrieves all accounts with the given cpability type. + /// + /// Capability type + /// Accounts list matched with the capability type + /// http://tizen.org/privilege/account.read + /// In case of any DB error or record not found for given capability type + /// In case of invalid parameter + /// In case of privilege not defined. + public static IEnumerable GetAccountsByCapabilityType(string type) + { + List accounts = new List(); + List values = new List(); + 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; + } + + /// + /// Retrieves all capabilities with the given account + /// + /// account instance + /// Capabilities list as Dictionary of Capability type and State. + /// http://tizen.org/privilege/account.read + /// In case of any DB error or record not found for given account id + /// In case of invalid parameter + /// In case of privilege not defined. + public static Dictionary GetCapabilitiesById(int accountId) + { + Dictionary capabilities = new Dictionary(); + 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; + } + + /// + /// Gets the count of accounts in the account database. + /// + /// The number of accounts in the database + /// http://tizen.org/privilege/account.read + /// In case of any DB error + /// In case of privilege not defined. + 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; + } + + /// + /// Updates the sync status of the given account. + /// + /// Account for which sync status needs to be updated + /// Sync State + /// http://tizen.org/privilege/account.read + /// http://tizen.org/privilege/account.write + /// In case of any DB error + /// In case of invalid parameter + /// In case of privilege not defined. + 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 s_accountUpdated; + /// + /// ContentUpdated event is triggered when the media item info from DB changes. + /// + /// + /// ContentUpdate event is triggered if the MediaInformaion updated/deleted or new Inforamtion is Inserted. + /// + /// + /// A ContentUpdatedEventArgs object that contains information about the update operation. + /// http://tizen.org/privilege/account.read + /// In case of any DB error + /// In case of invalid parameter + /// In case of privilege not defined. + public static event EventHandler 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/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSucriberEventArgs.cs b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSucriberEventArgs.cs new file mode 100644 index 0000000..a9b9215 --- /dev/null +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSucriberEventArgs.cs @@ -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 +{ + /// + /// Event arguments passed when Event is triggered to notify that account is updated/removed from the account database. + /// + 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; + } + + /// + /// The account event type + /// + public AccountNotificationType EventType + { + get; + internal set; + } + + /// + /// The account ID to update + /// + public int AccountId + { + get; + internal set; + } + } +} diff --git a/packaging/csapi-account-manager.manifest b/packaging/csapi-account-manager.manifest new file mode 100644 index 0000000..75b0fa5 --- /dev/null +++ b/packaging/csapi-account-manager.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/csapi-account-manager.spec b/packaging/csapi-account-manager.spec new file mode 100755 index 0000000..5577314 --- /dev/null +++ b/packaging/csapi-account-manager.spec @@ -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 -- 2.7.4 From a3545af06a19e8e519e928bc7bd52cdd45a90b0c Mon Sep 17 00:00:00 2001 From: Younho Park Date: Thu, 15 Dec 2016 09:31:12 +0900 Subject: [PATCH 3/5] added ExcludeArch statement - modified wrong class name Change-Id: I1adb59ddeb26bfd1dc954c3168bef88709dad36c Signed-off-by: Younho Park --- .../Tizen.Account.AccountManager.Net45.csproj | 2 +- Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj | 2 +- .../Tizen.Account.AccountManager/AccountService.cs | 6 +++--- .../{AccountSucriberEventArgs.cs => AccountSubscriberEventArgs.cs} | 4 ++-- packaging/csapi-account-manager.spec | 3 ++- 5 files changed, 9 insertions(+), 8 deletions(-) rename Tizen.Account.AccountManager/Tizen.Account.AccountManager/{AccountSucriberEventArgs.cs => AccountSubscriberEventArgs.cs} (94%) mode change 100755 => 100644 packaging/csapi-account-manager.spec diff --git a/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.csproj b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.csproj index 659ca68..787cfc1 100644 --- a/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.csproj +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.Net45.csproj @@ -50,7 +50,7 @@ - + diff --git a/Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj index 6a54d6c..69e059f 100644 --- a/Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.csproj @@ -63,7 +63,7 @@ - + diff --git a/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs index 4f3f3ae..368bb54 100644 --- a/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs @@ -518,14 +518,14 @@ namespace Tizen.Account.AccountManager private static readonly Interop.AccountService.SubscribeCallback s_accountUpdatedCallback = (string eventType, int accountId, IntPtr userData) => { - AccountSucriberEventArgs eventArgs = new AccountSucriberEventArgs(eventType, accountId); + AccountSubscriberEventArgs eventArgs = new AccountSubscriberEventArgs(eventType, accountId); s_accountUpdated?.Invoke(null, eventArgs); return true; }; private static Interop.AccountService.SafeAccountSubscriberHandle s_subscriberHandle; - private static event EventHandler s_accountUpdated; + private static event EventHandler s_accountUpdated; /// /// ContentUpdated event is triggered when the media item info from DB changes. /// @@ -538,7 +538,7 @@ namespace Tizen.Account.AccountManager /// In case of any DB error /// In case of invalid parameter /// In case of privilege not defined. - public static event EventHandler AccountUpdated + public static event EventHandler AccountUpdated { add { diff --git a/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSucriberEventArgs.cs b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSubscriberEventArgs.cs similarity index 94% rename from Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSucriberEventArgs.cs rename to Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSubscriberEventArgs.cs index a9b9215..84ee0da 100644 --- a/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSucriberEventArgs.cs +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSubscriberEventArgs.cs @@ -21,13 +21,13 @@ namespace Tizen.Account.AccountManager /// /// Event arguments passed when Event is triggered to notify that account is updated/removed from the account database. /// - public class AccountSucriberEventArgs : EventArgs + public class AccountSubscriberEventArgs : 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) + internal AccountSubscriberEventArgs(string eventType, int accountId) { if (eventType.CompareTo(NotiInsert) == 0) { diff --git a/packaging/csapi-account-manager.spec b/packaging/csapi-account-manager.spec old mode 100755 new mode 100644 index 5577314..0c12d25 --- a/packaging/csapi-account-manager.spec +++ b/packaging/csapi-account-manager.spec @@ -8,7 +8,7 @@ Name: csapi-account-manager Summary: Tizen account manager API for C# -Version: 1.0.1 +Version: 1.0.2 Release: 1 Group: Development/Libraries License: Apache-2.0 @@ -17,6 +17,7 @@ Source0: %{name}-%{version}.tar.gz Source1: %{name}.manifest AutoReqProv: no +ExcludeArch: %{ix86} aarch64 BuildRequires: mono-compiler BuildRequires: mono-devel -- 2.7.4 From 24821e19c23a8dcdae01309290b8d947139bc43f Mon Sep 17 00:00:00 2001 From: WonYoung Choi Date: Mon, 19 Dec 2016 18:34:39 +0900 Subject: [PATCH 4/5] Apply dotnet RPM macros Change-Id: I7cafbd8bfc9a3371fed42ee6144017f3c22a5d2a Signed-off-by: WonYoung Choi --- .../Tizen.Account.AccountManager.project.json | 3 -- packaging/csapi-account-manager.spec | 51 ++++------------------ 2 files changed, 9 insertions(+), 45 deletions(-) diff --git a/Tizen.Account.AccountManager/Tizen.Account.AccountManager.project.json b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.project.json index 27943bf..0614e80 100644 --- a/Tizen.Account.AccountManager/Tizen.Account.AccountManager.project.json +++ b/Tizen.Account.AccountManager/Tizen.Account.AccountManager.project.json @@ -8,9 +8,6 @@ "NETStandard.Library": "1.6.0", "Tizen": "1.0.0" }, - "runtimes": { - "win": {} - }, "frameworks": { "netstandard1.6": {} } diff --git a/packaging/csapi-account-manager.spec b/packaging/csapi-account-manager.spec index 0c12d25..efe77f1 100644 --- a/packaging/csapi-account-manager.spec +++ b/packaging/csapi-account-manager.spec @@ -1,11 +1,3 @@ -%{!?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.2 @@ -17,61 +9,36 @@ Source0: %{name}-%{version}.tar.gz Source1: %{name}.manifest AutoReqProv: no -ExcludeArch: %{ix86} aarch64 - -BuildRequires: mono-compiler -BuildRequires: mono-devel +ExcludeArch: aarch64 %ix86 BuildRequires: dotnet-build-tools # NuGet for Dependencies BuildRequires: csapi-tizen-nuget +%define Assemblies Tizen.Account.AccountManager %description -Account Manager C# API for Tizen +%{summary} + +%dotnet_import_sub_packages %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} +%dotnet_build $ASM +%dotnet_pack $ASM/$ASM.nuspec %{version} 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 +%dotnet_install $ASM 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 +%attr(644,root,root) %{dotnet_assembly_files} \ No newline at end of file -- 2.7.4 From ae4140965699898f68ef4fceb08a6f198fe33e28 Mon Sep 17 00:00:00 2001 From: Ickhee Woo Date: Wed, 11 Jan 2017 13:57:44 +0900 Subject: [PATCH 5/5] change ExcludeArch by removing ix86 Change-Id: Ic93f2e9873c4bc506dd26b651744b63e7cb5f256 Signed-off-by: Ickhee Woo --- packaging/csapi-account-manager.spec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packaging/csapi-account-manager.spec b/packaging/csapi-account-manager.spec index efe77f1..377358b 100644 --- a/packaging/csapi-account-manager.spec +++ b/packaging/csapi-account-manager.spec @@ -1,6 +1,6 @@ Name: csapi-account-manager Summary: Tizen account manager API for C# -Version: 1.0.2 +Version: 1.0.3 Release: 1 Group: Development/Libraries License: Apache-2.0 @@ -9,7 +9,7 @@ Source0: %{name}-%{version}.tar.gz Source1: %{name}.manifest AutoReqProv: no -ExcludeArch: aarch64 %ix86 +ExcludeArch: aarch64 BuildRequires: dotnet-build-tools @@ -41,4 +41,4 @@ done %files %manifest %{name}.manifest %license LICENSE -%attr(644,root,root) %{dotnet_assembly_files} \ No newline at end of file +%attr(644,root,root) %{dotnet_assembly_files} -- 2.7.4