Example #1
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);
        }
Example #2
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 #3
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);
        }
Example #4
0
        /// <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)
        {
            AccountErrorFactory.CheckAccountFeature();

            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);
        }
Example #5
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);
        }
Example #6
0
        /// <summary>
        /// Sets the custom value to the account.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="key">Key to be added to the account.</param>
        /// <param name="value">Value to be updated for respective key for the account.</param>
        /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
        public void SetCustomValue(string key, string value)
        {
            AccountError err = (AccountError)Interop.Account.SetAccountCustomValue(_handle, key, value);

            if (err != AccountError.None)
            {
                throw AccountErrorFactory.CreateException(err, "Failed to set the value for : " + key);
            }
        }
Example #7
0
        /// <summary>
        /// Sets the account capability.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="capabilityType"> The account capability type.</param>
        /// <param name="state">The account capability state.</param>
        /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
        public void SetCapability(string capabilityType, CapabilityState state)
        {
            AccountError ret = (AccountError)Interop.Account.SetAccountCapability(_handle, capabilityType, (int)state);

            if (ret != AccountError.None)
            {
                throw AccountErrorFactory.CreateException(ret, "failed to set account capability");
            }
        }
Example #8
0
        /// <summary>
        /// Sets the user integer value.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="index">The index of the user integer (must be in range from 0 to 4).</param>
        /// <param name="value">The integer to set as the user integer.</param>
        /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
        public void SetUserInt(int index, int value)
        {
            AccountError err = (AccountError)Interop.Account.SetAccountUserInt(_handle, index, value);

            if (err != AccountError.None)
            {
                throw AccountErrorFactory.CreateException(err, "Failed to get the value for : " + index);
            }
        }
Example #9
0
        /// <summary>
        /// Deletes the account from the account database by package name.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="packageName">The package name of the account to delete.</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(string packageName)
        {
            AccountError err = (AccountError)Interop.AccountService.DeleteAccountByPackage(packageName);

            if (err != AccountError.None)
            {
                throw AccountErrorFactory.CreateException(err, "Failed to delete the account by package name: " + packageName);
            }
        }
Example #10
0
        /// <summary>
        /// Updates the sync status of the given account.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="account"> Account for which the sync status needs to be updated.</param>
        /// <param name="status">Sync State</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 UpdateSyncStatusById(Account account, AccountSyncState status)
        {
            AccountError err = (AccountError)Interop.AccountService.UpdateAccountSyncStatusById(account.AccountId, (int)status);

            if (err != AccountError.None)
            {
                throw AccountErrorFactory.CreateException(err, "Failed to UpdateSyncStatusById");
            }
        }
Example #11
0
        /// <summary>
        /// Deletes the account from the account database by user name.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="userName">The user name of the account to delete.</param>
        /// <param name="packageName">The package name of the account to delete.</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(string userName, string packageName)
        {
            AccountErrorFactory.CheckAccountFeature();

            AccountError err = (AccountError)Interop.AccountService.DeleteAccountByUser(userName, packageName);

            if (err != AccountError.None)
            {
                throw AccountErrorFactory.CreateException(err, "Failed to delete the account by userName: " + userName);
            }
        }
Example #12
0
        /// <summary>
        /// Gets the user specific custom text of an account key.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="key">The key to retrieve custom text.</param>
        /// <returns>The text of the given key.</returns>
        /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">If there is no given capability type in the account.</exception>
        public string GetCustomValue(string key)
        {
            string       result = "";
            AccountError err    = (AccountError)Interop.Account.GetAccountCustomValue(_handle, key, out result);

            if (err != AccountError.None)
            {
                throw AccountErrorFactory.CreateException(err, "Failed to get the value for : " + key);
            }

            return(result);
        }
Example #13
0
        /// <summary>
        /// Gets all the capabilities of the account.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="capabilityType"> The capability type to get the capability value.</param>
        /// <returns>The capability value (on/off) of the specified CapabilityState.</returns>
        /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
        public CapabilityState GetCapability(string capabilityType)
        {
            int          type;
            AccountError res = (AccountError)Interop.Account.GetAccountCapability(_handle, capabilityType, out type);

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

            return((CapabilityState)type);
        }
Example #14
0
        /// <summary>
        /// Gets the specific label information detail of the account provider.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="locale">
        /// The locale is specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code.
        /// For example, "ko_KR" or "ko-kr" for Korean, "en_US" or "en-us" for American English.
        /// </param>
        /// <returns>The label text given for the locale.</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 locale.</exception>
        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
        public string GetLabel(string locale)
        {
            string       label;
            AccountError res = (AccountError)Interop.AccountProvider.GetlabelbyLocale(Handle, locale, out label);

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

            return(label);
        }
Example #15
0
        /// <summary>
        /// Creates a new account instance.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <returns>Account Instance.</returns>
        public static Account CreateAccount()
        {
            SafeAccountHandle handle;
            AccountError      err = (AccountError)Interop.Account.Create(out handle);

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

            return(new Account(handle));
        }
Example #16
0
        /// <summary>
        /// Gets the count of accounts in the account database.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <returns>The number of accounts in the database.</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 int GetAccountsCount()
        {
            int          count = 0;
            AccountError err   = (AccountError)Interop.AccountService.GetAccountCount(out count);

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

            return(count);
        }
Example #17
0
        /// <summary>
        /// Gets the user integer value.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="index">The index of the user integer (must be in range from 0 to 4).</param>
        /// <returns>The user integer of the given key.</returns>
        /// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
        public int GetUserInt(int index)
        {
            int          result = -1;
            AccountError err    = (AccountError)Interop.Account.GetAccountUserInt(_handle, index, out result);

            if (err != AccountError.None)
            {
                throw AccountErrorFactory.CreateException(err, "Failed to get the value for : " + index);
            }

            return(result);
        }
Example #18
0
        /// <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);
            }
        }
Example #19
0
        /// <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");
            }
        }
Example #20
0
        /// <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);
        }
Example #21
0
        /// <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);
        }
Example #22
0
        /// <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);
        }
Example #23
0
        /// <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);
        }
Example #24
0
        /// <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);
        }
Example #25
0
        /// <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);
        }
Example #26
0
        /// <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);
        }
Example #27
0
        /// <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);
        }
Example #28
0
        /// <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);
        }
Example #29
0
        /// <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);
        }
Example #30
0
        /// <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);
        }