using System.Runtime.InteropServices;
using Tizen.Account.AccountManager;
/// <summary>
-/// Interop for Account class APIs
+/// Interop for Account class APIs.
/// </summary>
/// <since_tizen> 3 </since_tizen>
internal static partial class Interop
{
/// <summary>
- /// Interop for Account class APIs
+ /// Interop for Account class APIs.
/// </summary>
/// <since_tizen> 3 </since_tizen>
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)]
using Tizen.Account.AccountManager;
/// <summary>
-/// Interop for AccountProvider class APIs
+/// Interop for AccountProvider class APIs.
/// </summary>
/// <since_tizen> 3 </since_tizen>
internal static partial class Interop
{
/// <summary>
- /// Interop for AccountProvider class APIs
+ /// Interop for AccountProvider class APIs.
/// </summary>
/// <since_tizen> 3 </since_tizen>
internal static partial class AccountProvider
using System;
using System.Runtime.InteropServices;
+using Tizen.Account.AccountManager;
/// <summary>
-/// Interop for Account class APIs
+/// Interop for Account class APIs.
/// </summary>
/// <since_tizen> 3 </since_tizen>
internal static partial class Interop
{
/// <summary>
- /// Interop for Account class APIs
+ /// Interop for Account class APIs.
/// </summary>
/// <since_tizen> 3 </since_tizen>
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);
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);
*/
/// <summary>
-/// Interop for Library reference
+/// Interop for the library reference.
/// </summary>
/// <since_tizen> 3 </since_tizen>
internal static partial class Interop
{
/// <summary>
- /// Interop for Library reference
+ /// Interop for the library reference.
/// </summary>
/// <since_tizen> 3 </since_tizen>
internal static partial class Libraries
namespace Tizen.Account.AccountManager
{
/// <summary>
- /// Represents the Account Information.
+ /// Represents the account information.
/// </summary>
/// <since_tizen> 3 </since_tizen>
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);
}
+
/// <summary>
- /// Creates a new Account instance.
+ /// Creates a new account instance.
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <returns>Account Instance.</returns>
public static Account CreateAccount()
{
- IntPtr handle;
+ SafeAccountHandle handle;
AccountError err = (AccountError)Interop.Account.Create(out handle);
if (err != AccountError.None)
{
/// Id of the Account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <remarks>Account Id shall be created only when account is added to the database.</remarks>
+ /// <remarks>Account ID shall be created only when the account is added to the database.</remarks>
public int AccountId
{
get
}
/// <summary>
- /// UserName of the Account.
+ /// UserName of the account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <value>User Name of the Account.</value>
+ /// <value>User name of the account.</value>
public string UserName
{
get
}
/// <summary>
- /// Display Name of the Account.
+ /// Display name of the account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <value>DisplayName of the Account.</value>
+ /// <value>Display name of the account.</value>
public string DisplayName
{
get
}
/// <summary>
- /// Icon path of the Account.
+ /// Icon path of the account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <value>Icon path of the Account.</value>
+ /// <value>Icon path of the account.</value>
public string IconPath
{
get
}
/// <summary>
- /// Domain name of the Account.
+ /// Domain name of the account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <value>Domain name of the Account.</value>
+ /// <value>Domain name of the account.</value>
public string DomainName
{
get
}
/// <summary>
- /// Email Id of the Account.
+ /// Email ID of the account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <value>Email Id of the Account.</value>
+ /// <value>Email ID of the account.</value>
public string EmailId
{
get
}
/// <summary>
- /// Package Name of the Account.
+ /// Package name of the account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <value>Package Name.</value>
+ /// <value>Package name of the account.</value>
public string PackageName
{
get
}
/// <summary>
- /// Access Token of the Account.
+ /// Access token of the account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <value>Access Token.</value>
+ /// <value>Access token of the account.</value>
public string AccessToken
{
get
}
/// <summary>
- /// Authentication type of the Account.
+ /// Authentication type of the account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <value>Authentication type.</value>
+ /// <value>Authentication type of the account.</value>
public AccountAuthType AuthType
{
get
}
/// <summary>
- /// Secrecy State of the Account.
+ /// Secrecy state of the account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <value>Secrecy State.</value>
+ /// <value>Secrecy state of the account.</value>
public AccountSecrecyState SecrecyState
{
get
}
/// <summary>
- /// Sync State of the Account.
+ /// Sync state of the account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <value>Sync State.</value>
+ /// <value>Sync state of the account.</value>
public AccountSyncState SyncState
{
get
}
/// <summary>
- /// Source of the Account .
+ /// Source of the account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <value>Account Source.</value>
+ /// <value>Account source.</value>
public string Source
{
get
}
}
- internal IntPtr Handle
+ /// <summary>
+ /// Handle of the account.
+ /// </summary>
+ /// <since_tizen> 4 </since_tizen>
+ /// <value>Account handle.</value>
+ public SafeAccountHandle SafeAccountHandle
{
get
{
return _handle;
}
-
- set
- {
- _handle = value;
- }
}
/// <summary>
/// Sets the account capability.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="capabilityType"> The Account capability type</param>
- /// <param name="state">The Account capability state</param>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ /// <param name="capabilityType"> The account capability type.</param>
+ /// <param name="state">The account capability state.</param>
+ /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
public void SetCapability(string capabilityType, CapabilityState state)
{
AccountError ret = (AccountError)Interop.Account.SetAccountCapability(_handle, capabilityType, (int)state);
}
}
/// <summary>
- /// Gets all the capabilities of an account.
+ /// Gets all the capabilities of the account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <param name="capabilityType"> The capability type to get the capability value.</param>
- /// <returns>The capability value (on/off) of the specified CapabilityState .</returns>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ /// <returns>The capability value (on/off) of the specified CapabilityState.</returns>
+ /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
public CapabilityState GetCapability(string capabilityType)
{
int type;
}
/// <summary>
- /// Gets all the capabilities of an account.
+ /// Gets all the capabilities of the account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <returns>List of Cpabailities as Dictionary</returns>
+ /// <returns>List of capabilities as dictionary.</returns>
public Dictionary<string, CapabilityState> GetAllCapabilities()
{
}
/// <summary>
- /// Sets the Custom Value to the Account.
+ /// Sets the custom value to the account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="key">key to be added to the Account.</param>
- /// <param name="value">value to be updated for respective key for the Account.</param>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ /// <param name="key">Key to be added to the account.</param>
+ /// <param name="value">Value to be updated for respective key for the account.</param>
+ /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
public void SetCustomValue(string key, string value)
{
AccountError err = (AccountError)Interop.Account.SetAccountCustomValue(_handle, key, value);
/// Gets the user specific custom text of an account key.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="key">The key to retrieve custom text .</param>
- /// <returns>The text of the given key</returns>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
- /// <exception cref="InvalidOperationException">If there is no given capability type in the account </exception>
+ /// <param name="key">The key to retrieve custom text.</param>
+ /// <returns>The text of the given key.</returns>
+ /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
+ /// <exception cref="InvalidOperationException">If there is no given capability type in the account.</exception>
public string GetCustomValue(string key)
{
string result = "";
}
/// <summary>
- /// Gets All the custome values.
+ /// Gets all the custom values.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <returns>List of custom key, value pairs as Dictionary.</returns>
+ /// <returns>List of custom key, value pairs as dictionary.</returns>
public Dictionary<string, string> GetAllCustomValues()
{
AccountError res = AccountError.None;
/// Sets the user text.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="index">The index of the user text (must be in range from 0 to 4) </param>
- /// <param name="text">The text string to set as the user text</param>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ /// <param name="index">The index of the user text (must be in range from 0 to 4).</param>
+ /// <param name="text">The text string to set as the user text.</param>
+ /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
public void SetUserText(int index, string text)
{
AccountError err = (AccountError)Interop.Account.SetAccountUserText(_handle, index, text);
/// Gets the user text.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="index">The index of the user text (range: 0 ~ 4)</param>
- /// <returns>The user text of the given key</returns>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
- /// <exception cref="OutOfMemoryException">In case of out of memory</exception>
+ /// <param name="index">The index of the user text (must be in range from 0 to 4).</param>
+ /// <returns>The user text of the given key.</returns>
+ /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
+ /// <exception cref="OutOfMemoryException">In case of out of memory.</exception>
public string GetUserText(int index)
{
string result = "";
}
/// <summary>
- /// Gets the user int value.
+ /// Gets the user integer value.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="index">The index of the user int (range: 0 ~ 4)</param>
- /// <returns>The user int of the given key</returns>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ /// <param name="index">The index of the user integer (must be in range from 0 to 4).</param>
+ /// <returns>The user integer of the given key.</returns>
+ /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
public int GetUserInt(int index)
{
int result = -1;
/// Sets the user integer value.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="index">The index of the user integer (must be in range from 0 to 4) </param>
- /// <param name="value">The integer to set as the user integer</param>
- /// <exception cref="ArgumentException">In case of invalid parameters</exception>
+ /// <param name="index">The index of the user integer (must be in range from 0 to 4).</param>
+ /// <param name="value">The integer to set as the user integer.</param>
+ /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
public void SetUserInt(int index, int value)
{
AccountError err = (AccountError)Interop.Account.SetAccountUserInt(_handle, index, value);
}
/// <summary>
- /// Overloaded Dispose API for destroying the Account Handle.
+ /// Overloaded Dispose API for destroying the account handle.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public void Dispose()
{
if (!disposing)
{
- if (_handle != IntPtr.Zero)
- {
- _handle = IntPtr.Zero;
- }
+ //if (_handle != IntPtr.Zero)
+ //{
+ // _handle = IntPtr.Zero;
+ //}
+ //_handle.Dispose();
+ GC.SuppressFinalize(this);
}
}
}
namespace Tizen.Account.AccountManager
{
/// <summary>
- /// Enumeration for the state of capability
+ /// Enumeration for the state of capability.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public enum CapabilityState
{
/// <summary>
- /// Account capability is invalid
+ /// Account capability is invalid.
/// </summary>
/// <since_tizen> 3 </since_tizen>
InvalidState,
/// <summary>
- /// Account capability is disabled
+ /// Account capability is disabled.
/// </summary>
/// <since_tizen> 3 </since_tizen>
Disabled,
/// <summary>
- /// Account capability is enabled
+ /// Account capability is enabled.
/// </summary>
/// <since_tizen> 3 </since_tizen>
Enabled
public enum AccountSecrecyState
{
/// <summary>
- /// Account secrecy is invalid
+ /// Account secrecy is invalid.
/// </summary>
/// <since_tizen> 3 </since_tizen>
InvalidState,
/// <summary>
- /// Account is not visible
+ /// Account is not visible.
/// </summary>
/// <since_tizen> 3 </since_tizen>
Invisible,
/// <summary>
- /// Account is visible
+ /// Account is visible.
/// </summary>
/// <since_tizen> 3 </since_tizen>
Visible
public enum AccountSyncState
{
/// <summary>
- /// Account sync is invalid
+ /// Account sync is invalid.
/// </summary>
/// <since_tizen> 3 </since_tizen>
InvalidState,
/// <summary>
- /// Account sync not supported
+ /// Account sync not supported.
/// </summary>
/// <since_tizen> 3 </since_tizen>
NotSupported,
/// <summary>
- /// Account sync supported but all synchronization functionalities are off
+ /// Account sync supported, but all the synchronization functionalities are off.
/// </summary>
/// <since_tizen> 3 </since_tizen>
Off,
/// <summary>
- /// Account sync support and sync status is idle
+ /// Account sync supported and sync status is idle.
/// </summary>
/// <since_tizen> 3 </since_tizen>
Idle,
/// <summary>
- /// Account sync support and sync status is running
+ /// Acount sync supported and sync status is running.
/// </summary>
/// <since_tizen> 3 </since_tizen>
Running
public enum AccountAuthType
{
/// <summary>
- /// Auth type is invalid
+ /// Auth type is invalid.
/// </summary>
/// <since_tizen> 3 </since_tizen>
Invalid,
/// <summary>
- /// XAuth type
+ /// XAuth type.
/// </summary>
/// <since_tizen> 3 </since_tizen>
XAuth,
/// <summary>
- /// OAuth type
+ /// OAuth type.
/// </summary>
/// <since_tizen> 3 </since_tizen>
OAuth,
/// <summary>
- /// Client-Login type
+ /// ClientLogin type.
/// </summary>
/// <since_tizen> 3 </since_tizen>
ClientLogin
}
/// <summary>
- /// Account information change notification type
+ /// Account information change notification types.
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <remarks>
- /// 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.
/// </remarks>
public enum AccountNotificationType
{
namespace Tizen.Account.AccountManager
{
/// <summary>
- /// Enum to give the type of error occured, if any.
+ /// Enumeration for the types of error occured, if any.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public enum AccountError
/// <since_tizen> 3 </since_tizen>
OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
/// <summary>
- /// Same user name exists in your application
+ /// Same user name exists in your application.
/// </summary>
/// <since_tizen> 3 </since_tizen>
Duplcated = -0x01000000 | 0x01,
/// <summary>
- /// Empty Data
+ /// Empty data.
/// </summary>
/// <since_tizen> 3 </since_tizen>
NoData = Tizen.Internals.Errors.ErrorCode.NoData,
/// <summary>
- /// elated record does not exist
+ /// Elated record does not exist.
/// </summary>
/// <since_tizen> 3 </since_tizen>
RecordNotFound = -0x01000000 | 0x03,
/// <summary>
- /// Invalid Operation.
+ /// Invalid operation.
/// </summary>
/// <since_tizen> 3 </since_tizen>
InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation,
/// <since_tizen> 3 </since_tizen>
DBNotOpened = -0x01000000 | 0x05,
/// <summary>
- /// DB query syntax error
+ /// DB query syntax error.
/// </summary>
/// <since_tizen> 3 </since_tizen>
QuerySyntaxError = -0x01000000 | 0x06,
/// <summary>
- /// Iterator has reached the end
+ /// Iterator has reached the end.
/// </summary>
/// <since_tizen> 3 </since_tizen>
IteratorEnd = -0x01000000 | 0x07,
/// <summary>
- /// Notification failed
+ /// Notification failed.
/// </summary>
/// <since_tizen> 3 </since_tizen>
NotificationFailed = -0x01000000 | 0x08,
/// <since_tizen> 3 </since_tizen>
PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
/// <summary>
- /// XML parse failed
+ /// XML parse failed.
/// </summary>
/// <since_tizen> 3 </since_tizen>
XMLParseFailed = -0x01000000 | 0x0a,
/// <summary>
- /// XML File not found
+ /// XML file not found.
/// </summary>
/// <since_tizen> 3 </since_tizen>
XMLFileNotFound = -0x01000000 | 0x0b,
/// <since_tizen> 3 </since_tizen>
EventSubscriptionFailed = -0x01000000 | 0x0c,
/// <summary>
- /// Account provider is not registered
+ /// Account provider is not registered.
/// </summary>
/// <since_tizen> 3 </since_tizen>
ProviderNotRegistered = -0x01000000 | 0x0d,
/// <since_tizen> 3 </since_tizen>
MultipleNotAllowed = -0x01000000 | 0x0e,
/// <summary>
- /// SQLite busy handler expired
+ /// SQLite busy handler expired.
/// </summary>
/// <since_tizen> 3 </since_tizen>
DBBusy = -0x01000000 | 0x10
namespace Tizen.Account.AccountManager
{
/// <summary>
- /// Account Id.
+ /// The account ID.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public class AccountProvider : IDisposable
}
}
/// <summary>
- /// Account Id.
+ /// The account ID.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public string AppId
}
/// <summary>
- /// Serviceprovider Id of the account provider.
+ /// Serviceprovider ID of the account provider.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public string ServiceProviderId
}
/// <summary>
- /// Icon path of an account provider.
+ /// Icon path of the account provider.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public string IconPath
}
/// <summary>
- /// Small icon path of an account provider.
+ /// Small icon path of the account provider.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public string SmallIconPath
}
/// <summary>
- /// Flag for account provider If supports multiple accounts.
+ /// Flag for the account provider if it supports multiple accounts.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public bool MultipleAccountSupport
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
+ /// <feature>http://tizen.org/feature/account</feature>
/// <returns>
- /// list of capability information.
+ /// The list of capability information.
/// </returns>
- /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+ /// <exception cref="InvalidOperationException">In case of any DB error.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public IEnumerable<string> GetAllCapabilities()
{
List<string> capabilities = new List<string>();
}
/// <summary>
- /// Gets the specific label information detail of an account provider.
+ /// Gets the specific label information detail of the account provider.
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <param name="locale">
/// The locale is specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code.
/// For example, "ko_KR" or "ko-kr" for Korean, "en_US" or "en-us" for American English.
/// </param>
- /// <returns>The label text given for the locale</returns>
+ /// <returns>The label text given for the locale.</returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given locale</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given locale.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public string GetLabel(string locale)
{
string label;
}
/// <summary>
- /// Gets the specific label information detail of an account provider.
+ /// Gets the specific label information detail of the account provider.
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <param name="appId">
- /// The application ID to search
+ /// The application ID to search.
/// </param>
- /// <returns> All the labels information for the given application Id.</returns>
+ /// <returns> All the labels information for the given application ID.</returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given appid</exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given the application ID.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static Dictionary<string, string> GetLabelsByAppId(string appId)
{
}
/// <summary>
- /// Gets the label information detail of an account provider.
+ /// Gets the label information detail of the account provider.
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <returns> All the labels information for the given account provider.</returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public Dictionary<string, string> GetLabels()
{
/// <param name="appId">The application ID to check.</param>
/// <returns>returns true If App is supported </returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given appid</exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error or record not found for the given application ID.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public bool IsAppSupported(string appId)
{
bool isSupported = false;
/// Checks whether the given application ID supports the capability.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="appId">The application Id</param>
- /// <param name="capability">The capability information</param>
+ /// <param name="appId">The application ID.</param>
+ /// <param name="capability">The capability information.</param>
/// <returns>
/// TRUE if the application supports the given capability,
/// otherwise FALSE if the application does not support the given capability
/// </returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error</exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static bool IsFeatureSupportedByApp(string appId, string capability)
{
bool supported = Interop.AccountProvider.IsFeatureSupported(appId, capability);
}
/// <summary>
- /// Retrieves capability information with application ID.
+ /// Retrieves capability information with the application ID.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="appId">application Id</param>
+ /// <param name="appId">The application ID.</param>
/// <returns> Capability information list for the given appId.</returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given appid</exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error or record not found for the given application ID.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static IEnumerable<string> GetFeaturesByAppId(string appId)
{
namespace Tizen.Account.AccountManager
{
/// <summary>
- /// 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:
/// <list>
- /// <item> Create an account or account provider </item>
- /// <item> Update an account or account provider(Only available for the creator) </item>
- /// <item> Delete an account or account provider(Only available for the creator) </item>
- /// <item> Read an account or account provider with some filter </item>
+ /// <item> Create an account or account provider.</item>
+ /// <item> Update an account or account provider (Only available for the creator).</item>
+ /// <item> Delete an account or account provider (Only available for the creator).</item>
+ /// <item> Read an account or account provider with some filter.</item>
/// </list>
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static class AccountService
{
/// <summary>
- /// This is contact capability string.
+ /// This is the contact capability string.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static readonly string ContactCapability = "http://tizen.org/account/capability/contact";
/// <summary>
- /// This is calendar capability string.
+ /// This is the calendar capability string.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static readonly string CalendarCapability = "http://tizen.org/account/capability/calendar";
/// <summary>
- /// This is email capability string.
+ /// This is the email capability string.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static readonly string EmailCapability = "http://tizen.org/account/capability/email";
/// <summary>
- /// This is photo capability string.
+ /// This is the photo capability string.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static readonly string PhotoCapability = "http://tizen.org/account/capability/photo";
/// <summary>
- /// This is video capability string.
+ /// This is the video capability string.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static readonly string VideoCapability = "http://tizen.org/account/capability/video";
/// <summary>
- /// This is music capability string.
+ /// This is the music capability string.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static readonly string MusicCapability = "http://tizen.org/account/capability/music";
/// <summary>
- /// This is document capability string.
+ /// This is the document capability string.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static readonly string DocumentCapability = "http://tizen.org/account/capability/document";
/// <summary>
- /// This is message capability string.
+ /// This is the message capability string.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static readonly string MessageCapability = "http://tizen.org/account/capability/message";
/// <summary>
- /// This is game capability string.
+ /// This is the game capability string.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static readonly string GameCapability = "http://tizen.org/account/capability/game";
/// <summary>
- /// Retrieves all accounts details from the account database.
+ /// Retrieves all the accounts details from the account database.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <returns>List of Accounts</returns>
+ /// <returns>List of accounts.</returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error. </exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static IEnumerable<Account> GetAccountsAsync()
{
List<Account> accounts = new List<Account>();
List<int> values = new List<int>();
Interop.Account.AccountCallback accountCallback = (IntPtr data, IntPtr userdata) =>
{
- Account account = new Account(data);
+ Account account = new Account(new SafeAccountHandle(data, true));
values.Add(account.AccountId);
account.Dispose();
return true;
}
/// <summary>
- /// Retrieve an account with the account ID.
+ /// Retrieves the account with the account ID.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="accountId"> The account Id to be searched.</param>
- /// <returns>Account instance with reference to the given id.</returns>
+ /// <param name="accountId"> The account ID to be searched.</param>
+ /// <returns>Account instance with reference to the given ID.</returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given account id</exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given account ID.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
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;
}
/// <summary>
- /// Retrieves all AccountProviders details from the account database.
+ /// Retrieves all the AccountProviders details from the account database.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <returns>List of AccountProviders</returns>
+ /// <returns>List of AccountProviders.</returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static IEnumerable<AccountProvider> GetAccountProviders()
{
List<string> values = new List<string>();
}
/// <summary>
- /// Retrieves the account provider information with application Id.
+ /// Retrieves the account provider information with the application ID.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="appId">Application Id.</param>
- /// <returns>The AccountProvider instance associated with the given application Id.</returns>
+ /// <param name="appId">The application ID.</param>
+ /// <returns>The AccountProvider instance associated with the given application ID.</returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given appid</exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given appid.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static AccountProvider GetAccountProviderByAppId(string appId)
{
IntPtr handle;
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <param name="feature">The capability value to search for account providers.</param>
- /// <returns>Retrieves AccountProviders information with the capability name.</returns>
+ /// <returns>Retrieves the AccountProviders information with the capability name.</returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given feature</exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given feature.</exception>
+ /// <exception cref="ArgumentException"> In case of invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static IEnumerable<AccountProvider> GetAccountProvidersByFeature(string feature)
{
List<string> values = new List<string>();
}
/// <summary>
- /// Inserts into the Database with the new account Infomration.
+ /// Inserts into the Database with the new account Information.
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <param name="account">New Account instance to be added.</param>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
/// <privilege>http://tizen.org/privilege/account.write </privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error</exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
/// <exception cref="OutOfMemoryException"> In case of OutOfMemory error.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static int AddAccount(Account account)
{
if (account == null)
}
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");
/// Updates the account details to the account database.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="account">account instance to be updated.</param>
+ /// <param name="account">Account instance to be updated.</param>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
/// <privilege>http://tizen.org/privilege/account.write </privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error </exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
/// <exception cref="OutOfMemoryException"> In case of OutOfMemory error.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static void UpdateAccount(Account account)
{
if (account == null)
throw AccountErrorFactory.CreateException(AccountError.InvalidParameter, "Failed to UpdateAccount");
}
- AccountError err = (AccountError)Interop.AccountService.UpdateAccountToDBById(account.Handle, account.AccountId);
+ AccountError err = (AccountError)Interop.AccountService.UpdateAccountToDBById(account.SafeAccountHandle, account.AccountId);
if (err != AccountError.None)
{
throw AccountErrorFactory.CreateException(err, "Failed to UpdateAccount");
}
/// <summary>
- /// Deletes the account information from the Database.
+ /// Deletes the account information from the database.
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <param name="account">Account instance to be deleted from the database.</param>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <privilege>http://tizen.org/privilege/account.write </privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error </exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <privilege>http://tizen.org/privilege/account.write</privilege>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static void DeleteAccount(Account account)
{
if (account == null)
}
/// <summary>
- /// Deletes an account from the account database by user name.
+ /// Deletes the account from the account database by user name.
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <param name="userName">The user name of the account to delete.</param>
/// <param name="packageName">The package name of the account to delete.</param>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <privilege>http://tizen.org/privilege/account.write </privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error</exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <privilege>http://tizen.org/privilege/account.write</privilege>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static void DeleteAccount(string userName, string packageName)
{
AccountError err = (AccountError)Interop.AccountService.DeleteAccountByUser(userName, packageName);
}
/// <summary>
- /// Deletes an account from the account database by package name.
+ /// Deletes the account from the account database by package name.
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <param name="packageName">The package name of the account to delete.</param>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <privilege>http://tizen.org/privilege/account.write </privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error</exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <privilege>http://tizen.org/privilege/account.write</privilege>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static void DeleteAccount(string packageName)
{
AccountError err = (AccountError)Interop.AccountService.DeleteAccountByPackage(packageName);
}
/// <summary>
- /// Retrieves all accounts with the given user name.
+ /// Retrieves all the accounts with the given user name.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="userName">The user name to search .</param>
- /// <returns>Accounts list matched with the user name</returns>
+ /// <param name="userName">The user name to search.</param>
+ /// <returns>Accounts list matched with the user name.</returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given username</exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given username.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static IEnumerable<Account> GetAccountsByUserName(string userName)
{
List<Account> accounts = new List<Account>();
List<int> values = new List<int>();
Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
{
- Account account = new Account(handle);
+ Account account = new Account(new SafeAccountHandle(handle, true));
values.Add(account.AccountId);
account.Dispose();
return true;
}
/// <summary>
- /// Retrieves all accounts with the given package name.
+ /// Retrieves all the accounts with the given package name.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="packageName"> The package name to Search</param>
- /// <returns>Accounts list matched with the package name</returns>
+ /// <param name="packageName"> The package name to search.</param>
+ /// <returns>Accounts list matched with the package name.</returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given package name</exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given package name.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static IEnumerable<Account> GetAccountsByPackageName(string packageName)
{
List<Account> accounts = new List<Account>();
List<int> values = new List<int>();
Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
{
- Account account = new Account(handle);
+ Account account = new Account(new SafeAccountHandle(handle, true));
values.Add(account.AccountId);
account.Dispose();
return true;
}
/// <summary>
- /// Retrieves all accounts with the given cpability type.
+ /// Retrieves all accounts with the given capability type.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="type"> Capability type</param>
- /// <returns>Accounts list matched with the capability type</returns>
+ /// <param name="type"> Capability type.</param>
+ /// <returns>Accounts list matched with the capability type.</returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given capability type</exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error or record not found for the given capability type.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static IEnumerable<Account> GetAccountsByCapabilityType(string type)
{
List<Account> accounts = new List<Account>();
List<int> values = new List<int>();
Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
{
- Account account = new Account(handle);
+ Account account = new Account(new SafeAccountHandle(handle, true));
values.Add(account.AccountId);
account.Dispose();
return true;
}
/// <summary>
- /// Retrieves all capabilities with the given account
+ /// Retrieves all the capabilities with the given account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="accountId">account instance</param>
- /// <returns>Capabilities list as Dictionary of Capability type and State.</returns>
+ /// <param name="accountId">Account instance.</param>
+ /// <returns>Capabilities list as dictionary of the capability type and state.</returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given account id</exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given account ID.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static Dictionary<string, CapabilityState> GetCapabilitiesById(int accountId)
{
Dictionary<string, CapabilityState> capabilities = new Dictionary<string, CapabilityState>();
/// Gets the count of accounts in the account database.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <returns>The number of accounts in the database</returns>
+ /// <returns>The number of accounts in the database.</returns>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error </exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static int GetAccountsCount()
{
int count = 0;
/// Updates the sync status of the given account.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <param name="account"> Account for which sync status needs to be updated</param>
+ /// <param name="account"> Account for which the sync status needs to be updated.</param>
/// <param name="status">Sync State</param>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
/// <privilege>http://tizen.org/privilege/account.write</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error </exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static void UpdateSyncStatusById(Account account, AccountSyncState status)
{
AccountError err = (AccountError)Interop.AccountService.UpdateAccountSyncStatusById(account.AccountId, (int)status);
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <remarks>
- /// 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.
/// </remarks>
/// <param name="sender"></param>
/// <param name="e">A ContentUpdatedEventArgs object that contains information about the update operation.</param>
/// <privilege>http://tizen.org/privilege/account.read</privilege>
- /// <exception cref="InvalidOperationException">In case of any DB error </exception>
- /// <exception cref="ArgumentException"> In case of invalid parameter</exception>
+ /// <feature>http://tizen.org/feature/account</feature>
+ /// <exception cref="InvalidOperationException">In case of any DB error.</exception>
+ /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
/// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
+ /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static event EventHandler<AccountSubscriberEventArgs> AccountUpdated
{
add
namespace Tizen.Account.AccountManager
{
/// <summary>
- /// 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.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public class AccountSubscriberEventArgs : EventArgs
}
/// <summary>
- /// The account event type
+ /// The account event type.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public AccountNotificationType EventType
}
/// <summary>
- /// The account ID to update
+ /// The account ID to update.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public int AccountId
--- /dev/null
+/*
+ * 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
+{
+ /// <summary>
+ /// Represents a wrapper class for a unmanaged Account handle.
+ /// </summary>
+ public sealed class SafeAccountHandle : SafeHandle
+ {
+ /// <summary>
+ /// Initializes a new instance of the SafeAppControlHandle class.
+ /// </summary>
+ public SafeAccountHandle() : base(IntPtr.Zero, true)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the SafeAccountHandle class.
+ /// </summary>
+ /// <param name="existingHandle">An IntPtr object that represents the pre-existing handle to use.</param>
+ /// <param name="ownsHandle">true to reliably release the handle during the finalization phase; false to prevent reliable release.</param>
+ public SafeAccountHandle(IntPtr existingHandle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle)
+ {
+ SetHandle(existingHandle);
+ }
+
+ /// <summary>
+ /// Gets a value that indicates whether the handle is invalid.
+ /// </summary>
+ public override bool IsInvalid
+ {
+ get { return this.handle == IntPtr.Zero; }
+ }
+
+ /// <summary>
+ /// When overridden in a derived class, executes the code required to free the handle.
+ /// </summary>
+ /// <returns>true if the handle is released successfully</returns>
+ protected override bool ReleaseHandle()
+ {
+ this.SetHandle(IntPtr.Zero);
+ return true;
+ }
+ }
+}