From 4c006f8950480bbb1f5c322e786fc64a84720bdc Mon Sep 17 00:00:00 2001 From: Jooseok Song Date: Mon, 28 Aug 2017 18:49:43 +0900 Subject: [PATCH] [TCSACR-81][ADD] Added new property to get account handle Change-Id: Id177d5b51c8e94072914c7f869f3f1cb6fa5fa4c --- .../Interop/Interop.Account.cs | 73 +++---- .../Interop/Interop.AccountProvider.cs | 4 +- .../Interop/Interop.AccountService.cs | 11 +- .../Interop/Interop.Libraries.cs | 4 +- .../Tizen.Account.AccountManager/Account.cs | 148 +++++++------- .../Tizen.Account.AccountManager/AccountEnums.cs | 36 ++-- .../AccountErrorFactory.cs | 24 +-- .../AccountProvider.cs | 70 ++++--- .../Tizen.Account.AccountManager/AccountService.cs | 215 ++++++++++++--------- .../AccountSubscriberEventArgs.cs | 6 +- .../SafeAccountHandle.cs | 63 ++++++ 11 files changed, 386 insertions(+), 268 deletions(-) create mode 100644 src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/SafeAccountHandle.cs diff --git a/src/Tizen.Account.AccountManager/Interop/Interop.Account.cs b/src/Tizen.Account.AccountManager/Interop/Interop.Account.cs index 9789044..90489bc 100644 --- a/src/Tizen.Account.AccountManager/Interop/Interop.Account.cs +++ b/src/Tizen.Account.AccountManager/Interop/Interop.Account.cs @@ -18,127 +18,128 @@ using System; using System.Runtime.InteropServices; using Tizen.Account.AccountManager; /// -/// Interop for Account class APIs +/// Interop for Account class APIs. /// /// 3 internal static partial class Interop { /// - /// Interop for Account class APIs + /// Interop for Account class APIs. /// /// 3 internal static partial class Account { [DllImport(Libraries.AccountSvc, EntryPoint = "account_create", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Create(out IntPtr handle); + internal static extern int Create(out SafeAccountHandle 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); + internal static extern int GetAccountId(SafeAccountHandle 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); + internal static extern int GetAccountUserName(SafeAccountHandle data, out string userName); [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_user_name", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAccountUserName(IntPtr handle, string userName); + internal static extern int SetAccountUserName(SafeAccountHandle handle, string userName); [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_display_name", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAccountDisplayName(IntPtr handle, out string displayName); + internal static extern int GetAccountDisplayName(SafeAccountHandle handle, out string displayName); [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_display_name", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAccountDisplayName(IntPtr handle, string displayName); + internal static extern int SetAccountDisplayName(SafeAccountHandle 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); + internal static extern int GetAccountCapability(SafeAccountHandle 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); + internal static extern int SetAccountCapability(SafeAccountHandle 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); + internal static extern int GetAccountIconPath(SafeAccountHandle handle, out string iconPath); [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_icon_path", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAccountIconPath(IntPtr handle, string iconPath); + internal static extern int SetAccountIconPath(SafeAccountHandle handle, string iconPath); [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_domain_name", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAccountDomainName(IntPtr handle, out string domainName); + internal static extern int GetAccountDomainName(SafeAccountHandle handle, out string domainName); [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_domain_name", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAccountDomainName(IntPtr handle, string domainName); + internal static extern int SetAccountDomainName(SafeAccountHandle handle, string domainName); [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_email_address", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAccountEmail(IntPtr handle, out string email); + internal static extern int GetAccountEmail(SafeAccountHandle handle, out string email); [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_email_address", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAccountEmail(IntPtr handle, string email); + internal static extern int SetAccountEmail(SafeAccountHandle handle, string email); [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_package_name", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAccountPackageName(IntPtr handle, out string name); + internal static extern int GetAccountPackageName(SafeAccountHandle handle, out string name); [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_package_name", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAccountPackageName(IntPtr handle, string name); + internal static extern int SetAccountPackageName(SafeAccountHandle handle, string name); [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_access_token", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAccountAccessToken(IntPtr handle, out string accessToken); + internal static extern int GetAccountAccessToken(SafeAccountHandle handle, out string accessToken); [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_access_token", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAccountAccessToken(IntPtr handle, string accessToken); + internal static extern int SetAccountAccessToken(SafeAccountHandle 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); + internal static extern int GetAccountUserText(SafeAccountHandle 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); + internal static extern int SetAccountUserText(SafeAccountHandle 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); + internal static extern int GetAccountUserInt(SafeAccountHandle 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); + internal static extern int SetAccountUserInt(SafeAccountHandle 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); + internal static extern int GetAccountAuthType(SafeAccountHandle handle, out int authType); [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_auth_type", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAccountAuthType(IntPtr handle, int authType); + internal static extern int SetAccountAuthType(SafeAccountHandle handle, int authType); [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_secret", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAccountSercet(IntPtr handle, out int secretType); + internal static extern int GetAccountSercet(SafeAccountHandle handle, out int secretType); [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_secret", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAccountSecret(IntPtr handle, int secretType); + internal static extern int SetAccountSecret(SafeAccountHandle handle, int secretType); [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_sync_support", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAccountSyncSupport(IntPtr handle, out int syncType); + internal static extern int GetAccountSyncSupport(SafeAccountHandle handle, out int syncType); [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_sync_support", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAccountSyncSupport(IntPtr handle, int syncType); + internal static extern int SetAccountSyncSupport(SafeAccountHandle handle, int syncType); [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_source", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAccountSource(IntPtr handle, out string source); + internal static extern int GetAccountSource(SafeAccountHandle handle, out string source); [DllImport(Libraries.AccountSvc, EntryPoint = "account_set_source", CallingConvention = CallingConvention.Cdecl)] - internal static extern int SetAccountSource(IntPtr handle, string source); + internal static extern int SetAccountSource(SafeAccountHandle 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); + internal static extern int GetAccountCustomValue(SafeAccountHandle 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); + internal static extern int SetAccountCustomValue(SafeAccountHandle 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); + internal static extern int GetAllAccountCapabilities(SafeAccountHandle 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); + internal static extern int GetAllAccountCustomValues(SafeAccountHandle handle, AccountCustomCallback callback, IntPtr userData); //Callbacks [UnmanagedFunctionPointer(CallingConvention.Cdecl)] diff --git a/src/Tizen.Account.AccountManager/Interop/Interop.AccountProvider.cs b/src/Tizen.Account.AccountManager/Interop/Interop.AccountProvider.cs index f201061..02f6314 100644 --- a/src/Tizen.Account.AccountManager/Interop/Interop.AccountProvider.cs +++ b/src/Tizen.Account.AccountManager/Interop/Interop.AccountProvider.cs @@ -19,13 +19,13 @@ using System.Runtime.InteropServices; using Tizen.Account.AccountManager; /// -/// Interop for AccountProvider class APIs +/// Interop for AccountProvider class APIs. /// /// 3 internal static partial class Interop { /// - /// Interop for AccountProvider class APIs + /// Interop for AccountProvider class APIs. /// /// 3 internal static partial class AccountProvider diff --git a/src/Tizen.Account.AccountManager/Interop/Interop.AccountService.cs b/src/Tizen.Account.AccountManager/Interop/Interop.AccountService.cs index 7bb1275..1995ce0 100644 --- a/src/Tizen.Account.AccountManager/Interop/Interop.AccountService.cs +++ b/src/Tizen.Account.AccountManager/Interop/Interop.AccountService.cs @@ -16,27 +16,28 @@ using System; using System.Runtime.InteropServices; +using Tizen.Account.AccountManager; /// -/// Interop for Account class APIs +/// Interop for Account class APIs. /// /// 3 internal static partial class Interop { /// - /// Interop for Account class APIs + /// Interop for Account class APIs. /// /// 3 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); + internal static extern int UpdateAccountToDBById(SafeAccountHandle 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); + internal static extern int QueryAccountById(int accountId, ref SafeAccountHandle 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); @@ -51,7 +52,7 @@ internal static partial class Interop 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); + internal static extern int AddAccount(SafeAccountHandle handle, out int accountId); [DllImport(Libraries.AccountSvc, EntryPoint = "account_delete_from_db_by_id", CallingConvention = CallingConvention.Cdecl)] internal static extern int DeleteAccountById(int accountId); diff --git a/src/Tizen.Account.AccountManager/Interop/Interop.Libraries.cs b/src/Tizen.Account.AccountManager/Interop/Interop.Libraries.cs index f1530bd..dba2781 100644 --- a/src/Tizen.Account.AccountManager/Interop/Interop.Libraries.cs +++ b/src/Tizen.Account.AccountManager/Interop/Interop.Libraries.cs @@ -15,13 +15,13 @@ */ /// -/// Interop for Library reference +/// Interop for the library reference. /// /// 3 internal static partial class Interop { /// - /// Interop for Library reference + /// Interop for the library reference. /// /// 3 internal static partial class Libraries diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs index df10a15..498bb84 100644 --- a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs +++ b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/Account.cs @@ -20,29 +20,31 @@ using System.Collections.Generic; namespace Tizen.Account.AccountManager { /// - /// Represents the Account Information. + /// Represents the account information. /// /// 3 public class Account : IDisposable { - private IntPtr _handle = IntPtr.Zero; - internal Account(IntPtr handle) + private readonly SafeAccountHandle _handle; + + public Account(SafeAccountHandle handle) { - Handle = handle; + _handle = handle; } ~Account() { Dispose(false); } + /// - /// Creates a new Account instance. + /// Creates a new account instance. /// /// 3 /// Account Instance. public static Account CreateAccount() { - IntPtr handle; + SafeAccountHandle handle; AccountError err = (AccountError)Interop.Account.Create(out handle); if (err != AccountError.None) { @@ -56,7 +58,7 @@ namespace Tizen.Account.AccountManager /// Id of the Account. /// /// 3 - /// Account Id shall be created only when account is added to the database. + /// Account ID shall be created only when the account is added to the database. public int AccountId { get @@ -73,10 +75,10 @@ namespace Tizen.Account.AccountManager } /// - /// UserName of the Account. + /// UserName of the account. /// /// 3 - /// User Name of the Account. + /// User name of the account. public string UserName { get @@ -102,10 +104,10 @@ namespace Tizen.Account.AccountManager } /// - /// Display Name of the Account. + /// Display name of the account. /// /// 3 - /// DisplayName of the Account. + /// Display name of the account. public string DisplayName { get @@ -131,10 +133,10 @@ namespace Tizen.Account.AccountManager } /// - /// Icon path of the Account. + /// Icon path of the account. /// /// 3 - /// Icon path of the Account. + /// Icon path of the account. public string IconPath { get @@ -160,10 +162,10 @@ namespace Tizen.Account.AccountManager } /// - /// Domain name of the Account. + /// Domain name of the account. /// /// 3 - /// Domain name of the Account. + /// Domain name of the account. public string DomainName { get @@ -189,10 +191,10 @@ namespace Tizen.Account.AccountManager } /// - /// Email Id of the Account. + /// Email ID of the account. /// /// 3 - /// Email Id of the Account. + /// Email ID of the account. public string EmailId { get @@ -218,10 +220,10 @@ namespace Tizen.Account.AccountManager } /// - /// Package Name of the Account. + /// Package name of the account. /// /// 3 - /// Package Name. + /// Package name of the account. public string PackageName { get @@ -247,10 +249,10 @@ namespace Tizen.Account.AccountManager } /// - /// Access Token of the Account. + /// Access token of the account. /// /// 3 - /// Access Token. + /// Access token of the account. public string AccessToken { get @@ -276,10 +278,10 @@ namespace Tizen.Account.AccountManager } /// - /// Authentication type of the Account. + /// Authentication type of the account. /// /// 3 - /// Authentication type. + /// Authentication type of the account. public AccountAuthType AuthType { get @@ -305,10 +307,10 @@ namespace Tizen.Account.AccountManager } /// - /// Secrecy State of the Account. + /// Secrecy state of the account. /// /// 3 - /// Secrecy State. + /// Secrecy state of the account. public AccountSecrecyState SecrecyState { get @@ -334,10 +336,10 @@ namespace Tizen.Account.AccountManager } /// - /// Sync State of the Account. + /// Sync state of the account. /// /// 3 - /// Sync State. + /// Sync state of the account. public AccountSyncState SyncState { get @@ -363,10 +365,10 @@ namespace Tizen.Account.AccountManager } /// - /// Source of the Account . + /// Source of the account. /// /// 3 - /// Account Source. + /// Account source. public string Source { get @@ -391,25 +393,25 @@ namespace Tizen.Account.AccountManager } } - internal IntPtr Handle + /// + /// Handle of the account. + /// + /// 4 + /// Account handle. + public SafeAccountHandle SafeAccountHandle { get { return _handle; } - - set - { - _handle = value; - } } /// /// Sets the account capability. /// /// 3 - /// The Account capability type - /// The Account capability state - /// In case of invalid parameters + /// The account capability type. + /// The account capability state. + /// In case of an invalid parameter. public void SetCapability(string capabilityType, CapabilityState state) { AccountError ret = (AccountError)Interop.Account.SetAccountCapability(_handle, capabilityType, (int)state); @@ -419,12 +421,12 @@ namespace Tizen.Account.AccountManager } } /// - /// Gets all the capabilities of an account. + /// Gets all the capabilities of the account. /// /// 3 /// The capability type to get the capability value. - /// The capability value (on/off) of the specified CapabilityState . - /// In case of invalid parameters + /// The capability value (on/off) of the specified CapabilityState. + /// In case of an invalid parameter. public CapabilityState GetCapability(string capabilityType) { int type; @@ -438,10 +440,10 @@ namespace Tizen.Account.AccountManager } /// - /// Gets all the capabilities of an account. + /// Gets all the capabilities of the account. /// /// 3 - /// List of Cpabailities as Dictionary + /// List of capabilities as dictionary. public Dictionary GetAllCapabilities() { @@ -463,12 +465,12 @@ namespace Tizen.Account.AccountManager } /// - /// Sets the Custom Value to the Account. + /// Sets the custom value to the account. /// /// 3 - /// key to be added to the Account. - /// value to be updated for respective key for the Account. - /// In case of invalid parameters + /// Key to be added to the account. + /// Value to be updated for respective key for the account. + /// In case of an invalid parameter. public void SetCustomValue(string key, string value) { AccountError err = (AccountError)Interop.Account.SetAccountCustomValue(_handle, key, value); @@ -482,10 +484,10 @@ namespace Tizen.Account.AccountManager /// Gets the user specific custom text of an account key. /// /// 3 - /// 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 + /// The key to retrieve custom text. + /// The text of the given key. + /// In case of an invalid parameter. + /// If there is no given capability type in the account. public string GetCustomValue(string key) { string result = ""; @@ -499,10 +501,10 @@ namespace Tizen.Account.AccountManager } /// - /// Gets All the custome values. + /// Gets all the custom values. /// /// 3 - /// List of custom key, value pairs as Dictionary. + /// List of custom key, value pairs as dictionary. public Dictionary GetAllCustomValues() { AccountError res = AccountError.None; @@ -528,9 +530,9 @@ namespace Tizen.Account.AccountManager /// Sets the user text. /// /// 3 - /// 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 + /// 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 an invalid parameter. public void SetUserText(int index, string text) { AccountError err = (AccountError)Interop.Account.SetAccountUserText(_handle, index, text); @@ -544,10 +546,10 @@ namespace Tizen.Account.AccountManager /// Gets the user text. /// /// 3 - /// 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 + /// The index of the user text (must be in range from 0 to 4). + /// The user text of the given key. + /// In case of an invalid parameter. + /// In case of out of memory. public string GetUserText(int index) { string result = ""; @@ -561,12 +563,12 @@ namespace Tizen.Account.AccountManager } /// - /// Gets the user int value. + /// Gets the user integer value. /// /// 3 - /// The index of the user int (range: 0 ~ 4) - /// The user int of the given key - /// In case of invalid parameters + /// The index of the user integer (must be in range from 0 to 4). + /// The user integer of the given key. + /// In case of an invalid parameter. public int GetUserInt(int index) { int result = -1; @@ -583,9 +585,9 @@ namespace Tizen.Account.AccountManager /// Sets the user integer value. /// /// 3 - /// 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 + /// 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 an invalid parameter. public void SetUserInt(int index, int value) { AccountError err = (AccountError)Interop.Account.SetAccountUserInt(_handle, index, value); @@ -596,7 +598,7 @@ namespace Tizen.Account.AccountManager } /// - /// Overloaded Dispose API for destroying the Account Handle. + /// Overloaded Dispose API for destroying the account handle. /// /// 3 public void Dispose() @@ -609,10 +611,12 @@ namespace Tizen.Account.AccountManager { if (!disposing) { - if (_handle != IntPtr.Zero) - { - _handle = IntPtr.Zero; - } + //if (_handle != IntPtr.Zero) + //{ + // _handle = IntPtr.Zero; + //} + //_handle.Dispose(); + GC.SuppressFinalize(this); } } } diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountEnums.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountEnums.cs index b55a458..68a7a65 100644 --- a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountEnums.cs +++ b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountEnums.cs @@ -17,25 +17,25 @@ namespace Tizen.Account.AccountManager { /// - /// Enumeration for the state of capability + /// Enumeration for the state of capability. /// /// 3 public enum CapabilityState { /// - /// Account capability is invalid + /// Account capability is invalid. /// /// 3 InvalidState, /// - /// Account capability is disabled + /// Account capability is disabled. /// /// 3 Disabled, /// - /// Account capability is enabled + /// Account capability is enabled. /// /// 3 Enabled @@ -47,19 +47,19 @@ namespace Tizen.Account.AccountManager public enum AccountSecrecyState { /// - /// Account secrecy is invalid + /// Account secrecy is invalid. /// /// 3 InvalidState, /// - /// Account is not visible + /// Account is not visible. /// /// 3 Invisible, /// - /// Account is visible + /// Account is visible. /// /// 3 Visible @@ -72,31 +72,31 @@ namespace Tizen.Account.AccountManager public enum AccountSyncState { /// - /// Account sync is invalid + /// Account sync is invalid. /// /// 3 InvalidState, /// - /// Account sync not supported + /// Account sync not supported. /// /// 3 NotSupported, /// - /// Account sync supported but all synchronization functionalities are off + /// Account sync supported, but all the synchronization functionalities are off. /// /// 3 Off, /// - /// Account sync support and sync status is idle + /// Account sync supported and sync status is idle. /// /// 3 Idle, /// - /// Account sync support and sync status is running + /// Acount sync supported and sync status is running. /// /// 3 Running @@ -109,36 +109,36 @@ namespace Tizen.Account.AccountManager public enum AccountAuthType { /// - /// Auth type is invalid + /// Auth type is invalid. /// /// 3 Invalid, /// - /// XAuth type + /// XAuth type. /// /// 3 XAuth, /// - /// OAuth type + /// OAuth type. /// /// 3 OAuth, /// - /// Client-Login type + /// ClientLogin type. /// /// 3 ClientLogin } /// - /// Account information change notification type + /// Account information change notification types. /// /// 3 /// - /// When the account database is changed, You can distinguish one event type from the other which are set for subscribing notification. + /// When the account database is changed, you can distinguish one event type from the other which are set for subscribing notification. /// public enum AccountNotificationType { diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountErrorFactory.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountErrorFactory.cs index 48f9164..51c31dd 100644 --- a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountErrorFactory.cs +++ b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountErrorFactory.cs @@ -20,7 +20,7 @@ using Tizen; namespace Tizen.Account.AccountManager { /// - /// Enum to give the type of error occured, if any. + /// Enumeration for the types of error occured, if any. /// /// 3 public enum AccountError @@ -42,22 +42,22 @@ namespace Tizen.Account.AccountManager /// 3 OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, /// - /// Same user name exists in your application + /// Same user name exists in your application. /// /// 3 Duplcated = -0x01000000 | 0x01, /// - /// Empty Data + /// Empty data. /// /// 3 NoData = Tizen.Internals.Errors.ErrorCode.NoData, /// - /// elated record does not exist + /// Elated record does not exist. /// /// 3 RecordNotFound = -0x01000000 | 0x03, /// - /// Invalid Operation. + /// Invalid operation. /// /// 3 InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation, @@ -72,17 +72,17 @@ namespace Tizen.Account.AccountManager /// 3 DBNotOpened = -0x01000000 | 0x05, /// - /// DB query syntax error + /// DB query syntax error. /// /// 3 QuerySyntaxError = -0x01000000 | 0x06, /// - /// Iterator has reached the end + /// Iterator has reached the end. /// /// 3 IteratorEnd = -0x01000000 | 0x07, /// - /// Notification failed + /// Notification failed. /// /// 3 NotificationFailed = -0x01000000 | 0x08, @@ -92,12 +92,12 @@ namespace Tizen.Account.AccountManager /// 3 PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, /// - /// XML parse failed + /// XML parse failed. /// /// 3 XMLParseFailed = -0x01000000 | 0x0a, /// - /// XML File not found + /// XML file not found. /// /// 3 XMLFileNotFound = -0x01000000 | 0x0b, @@ -107,7 +107,7 @@ namespace Tizen.Account.AccountManager /// 3 EventSubscriptionFailed = -0x01000000 | 0x0c, /// - /// Account provider is not registered + /// Account provider is not registered. /// /// 3 ProviderNotRegistered = -0x01000000 | 0x0d, @@ -117,7 +117,7 @@ namespace Tizen.Account.AccountManager /// 3 MultipleNotAllowed = -0x01000000 | 0x0e, /// - /// SQLite busy handler expired + /// SQLite busy handler expired. /// /// 3 DBBusy = -0x01000000 | 0x10 diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountProvider.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountProvider.cs index 606a286..ce34491 100644 --- a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountProvider.cs +++ b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountProvider.cs @@ -21,7 +21,7 @@ using Tizen.Internals.Errors; namespace Tizen.Account.AccountManager { /// - /// Account Id. + /// The account ID. /// /// 3 public class AccountProvider : IDisposable @@ -50,7 +50,7 @@ namespace Tizen.Account.AccountManager } } /// - /// Account Id. + /// The account ID. /// /// 3 public string AppId @@ -69,7 +69,7 @@ namespace Tizen.Account.AccountManager } /// - /// Serviceprovider Id of the account provider. + /// Serviceprovider ID of the account provider. /// /// 3 public string ServiceProviderId @@ -88,7 +88,7 @@ namespace Tizen.Account.AccountManager } /// - /// Icon path of an account provider. + /// Icon path of the account provider. /// /// 3 public string IconPath @@ -107,7 +107,7 @@ namespace Tizen.Account.AccountManager } /// - /// Small icon path of an account provider. + /// Small icon path of the account provider. /// /// 3 public string SmallIconPath @@ -126,7 +126,7 @@ namespace Tizen.Account.AccountManager } /// - /// Flag for account provider If supports multiple accounts. + /// Flag for the account provider if it supports multiple accounts. /// /// 3 public bool MultipleAccountSupport @@ -149,11 +149,13 @@ namespace Tizen.Account.AccountManager /// /// 3 /// http://tizen.org/privilege/account.read + /// http://tizen.org/feature/account /// - /// list of capability information. + /// The list of capability information. /// - /// In case of any DB error + /// In case of any DB error. /// In case of privilege not defined. + /// The required feature is not supported. public IEnumerable GetAllCapabilities() { List capabilities = new List(); @@ -174,17 +176,19 @@ namespace Tizen.Account.AccountManager } /// - /// Gets the specific label information detail of an account provider. + /// Gets the specific label information detail of the account provider. /// /// 3 /// /// 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 + /// 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 + /// http://tizen.org/feature/account + /// In case of any DB error or record not found for given locale. /// In case of privilege not defined. + /// The required feature is not supported. public string GetLabel(string locale) { string label; @@ -198,17 +202,19 @@ namespace Tizen.Account.AccountManager } /// - /// Gets the specific label information detail of an account provider. + /// Gets the specific label information detail of the account provider. /// /// 3 /// - /// The application ID to search + /// The application ID to search. /// - /// All the labels information for the given application Id. + /// 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 + /// http://tizen.org/feature/account + /// In case of any DB error or record not found for given the application ID. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. public static Dictionary GetLabelsByAppId(string appId) { @@ -229,13 +235,15 @@ namespace Tizen.Account.AccountManager } /// - /// Gets the label information detail of an account provider. + /// Gets the label information detail of the account provider. /// /// 3 /// All the labels information for the given account provider. /// http://tizen.org/privilege/account.read - /// In case of any DB error + /// http://tizen.org/feature/account + /// In case of any DB error. /// In case of privilege not defined. + /// The required feature is not supported. public Dictionary GetLabels() { @@ -262,9 +270,11 @@ namespace Tizen.Account.AccountManager /// 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 + /// http://tizen.org/feature/account + /// In case of any DB error or record not found for the given application ID. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. public bool IsAppSupported(string appId) { bool isSupported = false; @@ -286,16 +296,18 @@ namespace Tizen.Account.AccountManager /// Checks whether the given application ID supports the capability. /// /// 3 - /// The application Id - /// The capability information + /// 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 + /// http://tizen.org/feature/account + /// In case of any DB error. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. public static bool IsFeatureSupportedByApp(string appId, string capability) { bool supported = Interop.AccountProvider.IsFeatureSupported(appId, capability); @@ -313,15 +325,17 @@ namespace Tizen.Account.AccountManager } /// - /// Retrieves capability information with application ID. + /// Retrieves capability information with the application ID. /// /// 3 - /// application Id + /// The 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 + /// http://tizen.org/feature/account + /// In case of any DB error or record not found for the given application ID. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. public static IEnumerable GetFeaturesByAppId(string appId) { diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs index fc7cbd4..d335a8e 100644 --- a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs +++ b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs @@ -20,16 +20,16 @@ using System.Collections.Generic; namespace Tizen.Account.AccountManager { /// - /// The AccountManager APIs is separated into two major sections: + /// The AccountManager APIs are 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 + /// 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. /// /// /// 3 @@ -37,74 +37,76 @@ namespace Tizen.Account.AccountManager public static class AccountService { /// - /// This is contact capability string. + /// This is the contact capability string. /// /// 3 public static readonly string ContactCapability = "http://tizen.org/account/capability/contact"; /// - /// This is calendar capability string. + /// This is the calendar capability string. /// /// 3 public static readonly string CalendarCapability = "http://tizen.org/account/capability/calendar"; /// - /// This is email capability string. + /// This is the email capability string. /// /// 3 public static readonly string EmailCapability = "http://tizen.org/account/capability/email"; /// - /// This is photo capability string. + /// This is the photo capability string. /// /// 3 public static readonly string PhotoCapability = "http://tizen.org/account/capability/photo"; /// - /// This is video capability string. + /// This is the video capability string. /// /// 3 public static readonly string VideoCapability = "http://tizen.org/account/capability/video"; /// - /// This is music capability string. + /// This is the music capability string. /// /// 3 public static readonly string MusicCapability = "http://tizen.org/account/capability/music"; /// - /// This is document capability string. + /// This is the document capability string. /// /// 3 public static readonly string DocumentCapability = "http://tizen.org/account/capability/document"; /// - /// This is message capability string. + /// This is the message capability string. /// /// 3 public static readonly string MessageCapability = "http://tizen.org/account/capability/message"; /// - /// This is game capability string. + /// This is the game capability string. /// /// 3 public static readonly string GameCapability = "http://tizen.org/account/capability/game"; /// - /// Retrieves all accounts details from the account database. + /// Retrieves all the accounts details from the account database. /// /// 3 - /// List of Accounts + /// List of accounts. /// http://tizen.org/privilege/account.read - /// In case of any DB error. + /// http://tizen.org/feature/account + /// In case of any DB error. /// In case of privilege not defined. + /// The required feature is not supported. 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); + Account account = new Account(new SafeAccountHandle(data, true)); values.Add(account.AccountId); account.Dispose(); return true; @@ -126,37 +128,42 @@ namespace Tizen.Account.AccountManager } /// - /// Retrieve an account with the account ID. + /// Retrieves the account with the account ID. /// /// 3 - /// The account Id to be searched. - /// Account instance with reference to the given 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 + /// http://tizen.org/feature/account + /// In case of any DB error or record not found for given account ID. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. public static Account GetAccountById(int accountId) { Account account = Account.CreateAccount(); - IntPtr handle = account.Handle; - AccountError res = (AccountError)Interop.AccountService.QueryAccountById(accountId, out handle); + SafeAccountHandle handle = account.SafeAccountHandle; + + AccountError res = (AccountError)Interop.AccountService.QueryAccountById(accountId, ref 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; + Account ref_account = new Account(handle); + + return ref_account; } /// - /// Retrieves all AccountProviders details from the account database. + /// Retrieves all the AccountProviders details from the account database. /// /// 3 - /// List of AccountProviders + /// List of AccountProviders. /// http://tizen.org/privilege/account.read - /// In case of any DB error + /// http://tizen.org/feature/account + /// In case of any DB error. /// In case of privilege not defined. + /// The required feature is not supported. public static IEnumerable GetAccountProviders() { List values = new List(); @@ -186,15 +193,17 @@ namespace Tizen.Account.AccountManager } /// - /// Retrieves the account provider information with application Id. + /// Retrieves the account provider information with the application ID. /// /// 3 - /// Application Id. - /// The AccountProvider instance associated with the given application Id. + /// The 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 + /// http://tizen.org/feature/account + /// In case of any DB error or record not found for given appid. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. public static AccountProvider GetAccountProviderByAppId(string appId) { IntPtr handle; @@ -214,11 +223,13 @@ namespace Tizen.Account.AccountManager /// /// 3 /// The capability value to search for account providers. - /// Retrieves AccountProviders information with the capability name. + /// Retrieves the 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 + /// http://tizen.org/feature/account + /// In case of any DB error or record not found for given feature. + /// In case of invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. public static IEnumerable GetAccountProvidersByFeature(string feature) { List values = new List(); @@ -247,16 +258,18 @@ namespace Tizen.Account.AccountManager } /// - /// Inserts into the Database with the new account Infomration. + /// Inserts into the Database with the new account Information. /// /// 3 /// 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 + /// http://tizen.org/feature/account + /// In case of any DB error. + /// In case of an invalid parameter. /// In case of privilege not defined. /// In case of OutOfMemory error. + /// The required feature is not supported. public static int AddAccount(Account account) { if (account == null) @@ -265,7 +278,7 @@ namespace Tizen.Account.AccountManager } int id = -1; - AccountError err = (AccountError)Interop.AccountService.AddAccount(account.Handle, out id); + AccountError err = (AccountError)Interop.AccountService.AddAccount(account.SafeAccountHandle, out id); if (err != AccountError.None) { throw AccountErrorFactory.CreateException(err, "Failed to AddAccount"); @@ -278,13 +291,15 @@ namespace Tizen.Account.AccountManager /// Updates the account details to the account database. /// /// 3 - /// account instance to be updated. + /// 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 + /// http://tizen.org/feature/account + /// In case of any DB error. + /// In case of an invalid parameter. /// In case of privilege not defined. /// In case of OutOfMemory error. + /// The required feature is not supported. public static void UpdateAccount(Account account) { if (account == null) @@ -292,7 +307,7 @@ namespace Tizen.Account.AccountManager throw AccountErrorFactory.CreateException(AccountError.InvalidParameter, "Failed to UpdateAccount"); } - AccountError err = (AccountError)Interop.AccountService.UpdateAccountToDBById(account.Handle, account.AccountId); + AccountError err = (AccountError)Interop.AccountService.UpdateAccountToDBById(account.SafeAccountHandle, account.AccountId); if (err != AccountError.None) { throw AccountErrorFactory.CreateException(err, "Failed to UpdateAccount"); @@ -300,15 +315,17 @@ namespace Tizen.Account.AccountManager } /// - /// Deletes the account information from the Database. + /// Deletes the account information from the database. /// /// 3 /// 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 + /// http://tizen.org/privilege/account.write + /// http://tizen.org/feature/account + /// In case of any DB error. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. public static void DeleteAccount(Account account) { if (account == null) @@ -324,16 +341,18 @@ namespace Tizen.Account.AccountManager } /// - /// Deletes an account from the account database by user name. + /// Deletes the account from the account database by user name. /// /// 3 /// 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 + /// http://tizen.org/privilege/account.write + /// http://tizen.org/feature/account + /// In case of any DB error. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. public static void DeleteAccount(string userName, string packageName) { AccountError err = (AccountError)Interop.AccountService.DeleteAccountByUser(userName, packageName); @@ -344,15 +363,17 @@ namespace Tizen.Account.AccountManager } /// - /// Deletes an account from the account database by package name. + /// Deletes the account from the account database by package name. /// /// 3 /// 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 + /// http://tizen.org/privilege/account.write + /// http://tizen.org/feature/account + /// In case of any DB error. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. public static void DeleteAccount(string packageName) { AccountError err = (AccountError)Interop.AccountService.DeleteAccountByPackage(packageName); @@ -364,22 +385,24 @@ namespace Tizen.Account.AccountManager } /// - /// Retrieves all accounts with the given user name. + /// Retrieves all the accounts with the given user name. /// /// 3 - /// The user name to search . - /// Accounts list matched with the 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 + /// http://tizen.org/feature/account + /// In case of any DB error or record not found for given username. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. 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); + Account account = new Account(new SafeAccountHandle(handle, true)); values.Add(account.AccountId); account.Dispose(); return true; @@ -401,22 +424,24 @@ namespace Tizen.Account.AccountManager } /// - /// Retrieves all accounts with the given package name. + /// Retrieves all the accounts with the given package name. /// /// 3 - /// The package name to Search - /// Accounts list matched with the 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 + /// http://tizen.org/feature/account + /// In case of any DB error or record not found for given package name. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. 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); + Account account = new Account(new SafeAccountHandle(handle, true)); values.Add(account.AccountId); account.Dispose(); return true; @@ -438,22 +463,24 @@ namespace Tizen.Account.AccountManager } /// - /// Retrieves all accounts with the given cpability type. + /// Retrieves all accounts with the given capability type. /// /// 3 - /// Capability type - /// Accounts list matched with the capability 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 + /// http://tizen.org/feature/account + /// In case of any DB error or record not found for the given capability type. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. 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); + Account account = new Account(new SafeAccountHandle(handle, true)); values.Add(account.AccountId); account.Dispose(); return true; @@ -475,15 +502,17 @@ namespace Tizen.Account.AccountManager } /// - /// Retrieves all capabilities with the given account + /// Retrieves all the capabilities with the given account. /// /// 3 - /// account instance - /// Capabilities list as Dictionary of Capability type and State. + /// Account instance. + /// Capabilities list as dictionary of the 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 + /// http://tizen.org/feature/account + /// In case of any DB error or record not found for given account ID. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. public static Dictionary GetCapabilitiesById(int accountId) { Dictionary capabilities = new Dictionary(); @@ -506,10 +535,12 @@ namespace Tizen.Account.AccountManager /// Gets the count of accounts in the account database. /// /// 3 - /// The number of accounts in the database + /// The number of accounts in the database. /// http://tizen.org/privilege/account.read - /// In case of any DB error + /// http://tizen.org/feature/account + /// In case of any DB error. /// In case of privilege not defined. + /// The required feature is not supported. public static int GetAccountsCount() { int count = 0; @@ -526,13 +557,15 @@ namespace Tizen.Account.AccountManager /// Updates the sync status of the given account. /// /// 3 - /// Account for which sync status needs to be updated + /// Account for which the 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 + /// http://tizen.org/feature/account + /// In case of any DB error. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. public static void UpdateSyncStatusById(Account account, AccountSyncState status) { AccountError err = (AccountError)Interop.AccountService.UpdateAccountSyncStatusById(account.AccountId, (int)status); @@ -557,14 +590,16 @@ namespace Tizen.Account.AccountManager /// /// 3 /// - /// ContentUpdate event is triggered if the MediaInformaion updated/deleted or new Inforamtion is Inserted. + /// ContentUpdate event is triggered if the MediaInformaion updated/deleted or new information 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 + /// http://tizen.org/feature/account + /// In case of any DB error. + /// In case of an invalid parameter. /// In case of privilege not defined. + /// The required feature is not supported. public static event EventHandler AccountUpdated { add diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSubscriberEventArgs.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSubscriberEventArgs.cs index 153c427..2df2399 100644 --- a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSubscriberEventArgs.cs +++ b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountSubscriberEventArgs.cs @@ -19,7 +19,7 @@ using System; namespace Tizen.Account.AccountManager { /// - /// Event arguments passed when Event is triggered to notify that account is updated/removed from the account database. + /// Event arguments passed when the event is triggered to notify that the account is updated/removed from the account database. /// /// 3 public class AccountSubscriberEventArgs : EventArgs @@ -51,7 +51,7 @@ namespace Tizen.Account.AccountManager } /// - /// The account event type + /// The account event type. /// /// 3 public AccountNotificationType EventType @@ -61,7 +61,7 @@ namespace Tizen.Account.AccountManager } /// - /// The account ID to update + /// The account ID to update. /// /// 3 public int AccountId diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/SafeAccountHandle.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/SafeAccountHandle.cs new file mode 100644 index 0000000..3da224c --- /dev/null +++ b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/SafeAccountHandle.cs @@ -0,0 +1,63 @@ +/* + * 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 System.Runtime.InteropServices; + +namespace Tizen.Account.AccountManager +{ + /// + /// Represents a wrapper class for a unmanaged Account handle. + /// + public sealed class SafeAccountHandle : SafeHandle + { + /// + /// Initializes a new instance of the SafeAppControlHandle class. + /// + public SafeAccountHandle() : base(IntPtr.Zero, true) + { + } + + /// + /// Initializes a new instance of the SafeAccountHandle class. + /// + /// An IntPtr object that represents the pre-existing handle to use. + /// true to reliably release the handle during the finalization phase; false to prevent reliable release. + public SafeAccountHandle(IntPtr existingHandle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) + { + SetHandle(existingHandle); + } + + /// + /// Gets a value that indicates whether the handle is invalid. + /// + public override bool IsInvalid + { + get { return this.handle == IntPtr.Zero; } + } + + /// + /// When overridden in a derived class, executes the code required to free the handle. + /// + /// true if the handle is released successfully + protected override bool ReleaseHandle() + { + this.SetHandle(IntPtr.Zero); + return true; + } + } +} -- 2.7.4