Example #1
0
        /// <summary>
        /// Retrieves all the account providers information with feature.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="feature">The capability value to search for account providers.</param>
        /// <returns>Retrieves the AccountProviders information with the capability name.</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 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>();
            List <AccountProvider> providers = new List <AccountProvider>();

            Interop.AccountProvider.AccountProviderCallback providerCallback = (IntPtr handle, IntPtr data) =>
            {
                AccountProvider provider = new AccountProvider(handle);
                values.Add(provider.AppId);
                provider.Dispose();
                return(true);
            };

            AccountError err = (AccountError)Interop.AccountService.GetAccountProviderByFeature(providerCallback, feature, IntPtr.Zero);

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

            foreach (string val in values)
            {
                AccountProvider provider = GetAccountProviderByAppId(val);
                providers.Add(provider);
            }

            return(providers);
        }
Example #2
0
        /// <summary>
        /// Retrieves all the AccountProviders details from the account database.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <returns>List of AccountProviders.</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 <AccountProvider> GetAccountProviders()
        {
            List <string>          values    = new List <string>();
            List <AccountProvider> providers = new List <AccountProvider>();

            Interop.AccountProvider.AccountProviderCallback accountCallback = (IntPtr handle, IntPtr data) =>
            {
                AccountProvider provider = new AccountProvider(handle);
                values.Add(provider.AppId);
                provider.Dispose();
                return(true);
            };

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

            if (res != AccountError.None)
            {
                Log.Warn(AccountErrorFactory.LogTag, "Failed to get account providers from the database");
                throw AccountErrorFactory.CreateException(res, "Failed to get account providers from the database");
            }

            foreach (string val in values)
            {
                AccountProvider provider = GetAccountProviderByAppId(val);
                providers.Add(provider);
            }

            return(providers);
        }
 internal static extern int GetAccountProviderByFeature(Interop.AccountProvider.AccountProviderCallback callback, string key, IntPtr userData);
 internal static extern int GetAllAccountproviders(Interop.AccountProvider.AccountProviderCallback callback, IntPtr userData);