コード例 #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);
        }
コード例 #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);
        }
コード例 #3
0
ファイル: AccountService.cs プロジェクト: prjung/TizenFX
        /// <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);
        }