X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FTizen.Account.AccountManager%2FTizen.Account.AccountManager%2FAccountService.cs;h=9e5193ca384cc761a5c18f4602b6e398be0c738c;hb=ad3792f2f3c7e60247d1feac55fa898bb68257ee;hp=fc7cbd4a74debd2cf0f74961a88ad71350ec52e8;hpb=588caa1040fe912bbea357bbd3db7959eb661864;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git diff --git a/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs b/src/Tizen.Account.AccountManager/Tizen.Account.AccountManager/AccountService.cs index fc7cbd4..9e5193c 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,19 @@ 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. + /// The account ID of the account instance. /// 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 +279,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 +292,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 +308,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 +316,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 +342,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 +364,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 +386,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 +425,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 +464,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 +503,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 +536,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 +558,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 +591,14 @@ 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 MediaInformation 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