/// <summary> /// Updates the account details to the account database. /// </summary> /// <since_tizen> 3 </since_tizen> /// <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> /// <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.SafeAccountHandle, account.AccountId); if (err != AccountError.None) { throw AccountErrorFactory.CreateException(err, "Failed to UpdateAccount"); } }
/// <summary> /// 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> /// <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) { throw AccountErrorFactory.CreateException(AccountError.InvalidParameter, "Failed to DeleteAccount"); } AccountError err = (AccountError)Interop.AccountService.DeleteAccountById(account.AccountId); if (err != AccountError.None) { throw AccountErrorFactory.CreateException(err, "Failed to delete the account by Id: " + account.AccountId); } }
/// <summary> /// 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> /// <privilege>http://tizen.org/privilege/account.read</privilege> /// <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(); 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 ref_account = new Account(handle); return(ref_account); }
/// <summary> /// Checks whether the given appId exists in the account provider DB. /// </summary> /// <since_tizen> 3 </since_tizen> /// <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> /// <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; AccountError res = (AccountError)Interop.AccountProvider.GetAppIdExists(appId); if (res != AccountError.None) { throw AccountErrorFactory.CreateException(res, "Failed to GetLabel for AccountProvider"); } else { isSupported = true; } return(isSupported); }
/// <summary> /// Retrieves the account provider information with the application ID. /// </summary> /// <since_tizen> 3 </since_tizen> /// <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> /// <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; Interop.AccountProvider.Create(out handle); AccountError err = (AccountError)Interop.AccountService.GetAccountProviderByAppId(appId, out handle); if (err != AccountError.None) { throw AccountErrorFactory.CreateException(err, "Failed to GetAccountProviderByAppId"); } AccountProvider provider = new AccountProvider(handle); return(provider); }
/// <summary> /// 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> /// <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> /// <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); if (!supported) { //Get last result and validate error code. AccountError err = (AccountError)ErrorFacts.GetLastResult(); if ((err != AccountError.None) && (err != AccountError.RecordNotFound)) { throw AccountErrorFactory.CreateException(err, "Failed to get IsFeatureSupported"); } } return(supported); }
/// <summary> /// 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> /// <returns>The account ID of the account instance.</returns> /// <privilege>http://tizen.org/privilege/account.read</privilege> /// <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="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) { throw AccountErrorFactory.CreateException(AccountError.InvalidParameter, "Failed to AddAccount"); } int id = -1; AccountError err = (AccountError)Interop.AccountService.AddAccount(account.SafeAccountHandle, out id); if (err != AccountError.None) { throw AccountErrorFactory.CreateException(err, "Failed to AddAccount"); } return(id); }
/// <summary> /// 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> /// <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() { Dictionary <string, string> labels = new Dictionary <string, string>(); Interop.AccountProvider.LabelCallback callback = (string applicationId, string label, string locale, IntPtr userData) => { labels.Add(locale, label); return(true); }; AccountError err = (AccountError)Interop.AccountProvider.GetAccountProviderLabels(Handle, callback, IntPtr.Zero); if (err != AccountError.None) { throw AccountErrorFactory.CreateException(err, "Failed to GetAccountProviderLabels"); } return(labels); }
/// <summary> /// Retrieves all the capability information of the account provider. /// </summary> /// <since_tizen> 3 </since_tizen> /// <privilege>http://tizen.org/privilege/account.read</privilege> /// <feature>http://tizen.org/feature/account</feature> /// <returns> /// The list of capability information. /// </returns> /// <exception cref="InvalidOperationException">In case of any DB error.</exception> /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception> /// <exception cref="NotSupportedException">The required feature is not supported.</exception> public IEnumerable <string> GetAllCapabilities() { List <string> capabilities = new List <string>(); AccountError res; Interop.AccountProvider.AccountProviderFeatureCallback callback = (string appId, string key, IntPtr data) => { capabilities.Add(key); return(true); }; res = (AccountError)Interop.AccountProvider.GetAccountProviderFeatures(Handle, callback, IntPtr.Zero); if (res != AccountError.None) { throw AccountErrorFactory.CreateException(res, "Failed to GetAllCapabilities for AccountProvider"); } return(capabilities); }
/// <summary> /// 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 the capability type and state.</returns> /// <privilege>http://tizen.org/privilege/account.read</privilege> /// <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>(); Interop.Account.AccountCapabilityCallback capabilityCallback = (string type, int capabilityState, IntPtr data) => { capabilities.Add(type, (CapabilityState)capabilityState); return(true); }; AccountError err = (AccountError)Interop.AccountService.QueryAccountCapabilityById(capabilityCallback, accountId, IntPtr.Zero); if (err != AccountError.None) { throw AccountErrorFactory.CreateException(err, "Failed to GetAllCapabilitiesById"); } return(capabilities); }
/// <summary> /// Retrieves capability information with the application ID. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="appId">The application ID.</param> /// <returns> Capability information list for the given appId.</returns> /// <privilege>http://tizen.org/privilege/account.read</privilege> /// <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) { List <string> features = new List <string>(); Interop.AccountProvider.AccountProviderFeatureCallback callback = (string applicationId, string key, IntPtr userData) => { features.Add(key); return(true); }; AccountError err = (AccountError)Interop.AccountProvider.GetAccountProviderFeaturesByAppId(callback, appId, IntPtr.Zero); if (err != AccountError.None) { throw AccountErrorFactory.CreateException(err, "Failed to GetAccountProviderFeaturesByAppId"); } return((IEnumerable <string>)features); }
/// <summary> /// Gets all the capabilities of the account. /// </summary> /// <since_tizen> 3 </since_tizen> /// <returns>List of capabilities as dictionary.</returns> public Dictionary <string, CapabilityState> GetAllCapabilities() { AccountError res = AccountError.None; Dictionary <string, CapabilityState> list = new Dictionary <string, CapabilityState>(); Interop.Account.AccountCapabilityCallback capabilityCallback = (string type, int state, IntPtr data) => { list.Add(type, (CapabilityState)state); return(true); }; res = (AccountError)Interop.Account.GetAllAccountCapabilities(_handle, capabilityCallback, IntPtr.Zero); if (res != AccountError.None) { throw AccountErrorFactory.CreateException(res, "Failed to get account capabilities"); } return(list); }
/// <summary> /// Gets all the custom values. /// </summary> /// <since_tizen> 3 </since_tizen> /// <returns>List of custom key, value pairs as dictionary.</returns> public Dictionary <string, string> GetAllCustomValues() { AccountError res = AccountError.None; Dictionary <string, string> list = new Dictionary <string, string>(); Interop.Account.AccountCustomCallback customCallback = (string key, string value, IntPtr data) => { list.Add(key, value); return(true); }; res = (AccountError)Interop.Account.GetAllAccountCustomValues(_handle, customCallback, IntPtr.Zero); if (res != AccountError.None) { throw AccountErrorFactory.CreateException(res, "Failed to get account capabilities"); } return(list); }
/// <summary> /// Gets the specific label information detail of the account provider. /// </summary> /// <since_tizen> 3 </since_tizen> /// <param name="appId"> /// The application ID to search. /// </param> /// <returns> All the labels information for the given application ID.</returns> /// <privilege>http://tizen.org/privilege/account.read</privilege> /// <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) { AccountErrorFactory.CheckAccountFeature(); Dictionary <string, string> labels = new Dictionary <string, string>(); Interop.AccountProvider.LabelCallback callback = (string applicationId, string label, string locale, IntPtr userData) => { labels.Add(locale, label); return(true); }; AccountError err = (AccountError)Interop.AccountProvider.GetLablesByAppId(callback, appId, IntPtr.Zero); if (err != AccountError.None) { throw AccountErrorFactory.CreateException(err, "Failed to GetLablesByAppId"); } return(labels); }
/// <summary> /// 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> /// <privilege>http://tizen.org/privilege/account.read</privilege> /// <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) { AccountError err = (AccountError)Interop.Account.CreateUnmanagedHandle(out IntPtr handle); if (err != AccountError.None) { Log.Warn(AccountErrorFactory.LogTag, "Failed to create handle"); throw AccountErrorFactory.CreateException(err, "Failed to create unmanaged handle"); } SafeAccountHandle accountHandle = new SafeAccountHandle(handle, false); AccountError res = (AccountError)Interop.AccountService.QueryAccountById(accountId, ref accountHandle); if (res != AccountError.None) { throw AccountErrorFactory.CreateException(res, "Failed to get accounts from the database for account id: " + accountId); } Account ref_account = new Account(accountHandle); return(ref_account); }