Beispiel #1
0
        /// <summary>
        /// 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>
        /// <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 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(new SafeAccountHandle(handle, true));
                values.Add(account.AccountId);
                account.Dispose();
                return(true);
            };

            AccountError err = (AccountError)Interop.AccountService.GetAccountByCapabilityType(accountCallback, type, IntPtr.Zero);

            if (err != AccountError.None)
            {
                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountByCapabilityType");
            }

            foreach (int i in values)
            {
                Account account = AccountService.GetAccountById(i);
                accounts.Add(account);
            }

            return(accounts);
        }
Beispiel #2
0
        /// <summary>
        /// Retrieves all the accounts details from the account database.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <returns>List of accounts.</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 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(new SafeAccountHandle(data, true));
                values.Add(account.AccountId);
                account.Dispose();
                return(true);
            };

            AccountError res = (AccountError)Interop.AccountService.AccountForeachAccountFromDb(accountCallback, IntPtr.Zero);

            if (res != AccountError.None)
            {
                throw AccountErrorFactory.CreateException(res, "Failed to AccountForeachAccountFromDb");
            }

            foreach (int i in values)
            {
                Account account = AccountService.GetAccountById(i);
                accounts.Add(account);
            }

            return(accounts);
        }
 internal static extern int AccountForeachAccountFromDb(Interop.Account.AccountCallback callback, IntPtr userData);
 internal static extern int GetAccountByCapabilityType(Interop.Account.AccountCallback callback, string capabilityType, IntPtr userData);
 internal static extern int QueryAccountByPackageName(Interop.Account.AccountCallback callback, string packageName, IntPtr userData);