Esempio n. 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);
        }
Esempio n. 2
0
    // OnLogInFailed
    void OnLogInFailed(string accountName, AccountError error)
    {
        statusMessage = "Failed to log in to account " + accountName + " - ";

        switch (error)
        {
        case AccountError.InvalidPassword:
            statusMessage += "invalid password";
            break;

        case AccountError.NameNotRegistered:
            statusMessage += "name not registered";
            break;

        case AccountError.AlreadyLoggedIn:
            statusMessage += "account already logged in to";
            break;

        default:
            statusMessage += "unknown error occurred";
            break;
        }

        loginRequestResponses += 1;
    }
Esempio n. 3
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);
        }
        /// <summary>
        /// Permet de se loguer au WebService
        /// </summary>
        /// <param name="p">Dictionnaire contenant votre identifiant</param>
        /// <returns>Valeurs de retour contenant votre mot de passe.
        ///  Il sera nécessaire pour le Logout et l'écriture de vos données</returns>
        public WSR_Result Login(WSR_Params p)
        {
            string     pseudo   = null;
            string     password = null;
            WSR_Result ret      = null;

            ret = VerifParamType(p, "pseudo", out pseudo);
            if (ret != null)
            {
                return(ret);
            }

            AccountError err = Account.Add(pseudo, out password);

            switch (err)
            {
            case AccountError.Ok:
                return(new WSR_Result(password, true));

            case AccountError.KeyNullOrEmpty:
                return(new WSR_Result(CodeRetPseudoObligatoire, String.Format(Properties.Resources.PseudoObligatoire)));

            case AccountError.KeyExist:
                return(new WSR_Result(CodeRetPseudoUtilise, String.Format(Properties.Resources.PseudoUtilise)));

            default:
                return(new WSR_Result(CodeRetErreurInterneService, String.Format(Properties.Resources.ErreurInterneService)));
            }
        }
Esempio n. 5
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);
        }
        /// <summary>
        /// Permet de se loguer au WebService
        /// </summary>
        /// <param name="p">Dictionnaire contenant votre identifiant</param>
        /// <returns>Valeurs de retour contenant votre mot de passe. Il sera nécessaire pour le Logout et l'écriture de vos données</returns>
        public WSR_Result Login(WSR_Params p)
        {
            string     pseudo   = null;
            string     password = null;
            WSR_Result ret      = null;

            ret = VerifParamType(p, "pseudo", out pseudo);
            if (ret != null)
            {
                return(ret);
            }

            AccountError err = Account.Add(pseudo, out password);

            switch (err)
            {
            case AccountError.Ok:
                return(new WSR_Result(password, true));

            case AccountError.KeyNullOrEmpty:
                return(new WSR_Result(CodeRet_PseudoObligatoire, Properties.Resources.PSEUDOOBLIGATOIRE));

            case AccountError.KeyExist:
                return(new WSR_Result(CodeRet_PseudoUtilise, Properties.Resources.PSEUDOUTILISE));

            default:
                return(new WSR_Result(CodeRet_ErreurInterneService, Properties.Resources.ERREURINTERNESERVICE));
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Permet de lire les données associés à un compte utilisateur
        /// </summary>
        /// <param name="p">Dictionnaire contenant l'identifiant, le mot de passe et l'identifiant
        /// du compte à lire</param>
        /// <returns>Valeurs de retour</returns>
        public WSR_Result DownloadData(WSR_Params p)
        {
            string     pseudo         = null;
            string     pwd            = null;
            string     pseudoDownload = null;
            object     data           = null;
            WSR_Result ret            = null;

            ret = VerifParamType(p, "pseudo", out pseudo);
            if (ret == null)
            {
                ret = VerifParamType(p, "pwd", out pwd);
                if (ret == null)
                {
                    ret = VerifParamType(p, "pseudoDowload", out pseudoDownload);
                    if (ret == null)
                    {
                        AccountError err = Account.ReadData(pseudo, pwd, pseudoDownload, out data);
                        switch (err)
                        {
                        case AccountError.Ok:
                            return(new WSR_Result(data, false));

                        case AccountError.KeyNullOrEmpty:
                            return(new WSR_Result(CodeRet_PseudoObligatoire, Properties.Resources.PSEUDOOBLIGATOIRE));

                        case AccountError.PasswordNullOrEmpty:
                            return(new WSR_Result(CodeRet_PasswordObligatoire, Properties.Resources.PASSWORDOBLIGATOIRE));

                        case AccountError.keyDownloadNullOrEmpty:
                            return(new WSR_Result(CodeRet_PseudoDownloadObligatoire, Properties.Resources.PSEUDODOWNLOADOBLIGATOIRE));

                        case AccountError.keyNotFound:
                            return(new WSR_Result(CodeRet_Logout, Properties.Resources.PSEUDONONLOGUE));

                        case AccountError.PasswordWrong:
                            return(new WSR_Result(CodeRet_PasswordIncorrect, Properties.Resources.PASSWORDINCORRECT));

                        case AccountError.keyDownloadNotFound:
                            return(new WSR_Result(CodeRet_PseudoDownloadLogout, String.Format(Properties.Resources.PSEUDODOWNLOADNONLOGUE, pseudoDownload)));

                        default:
                            return(new WSR_Result(CodeRet_ErreurInterneService, Properties.Resources.ERREURINTERNESERVICE));
                        }
                    }
                    else
                    {
                        return(ret);
                    }
                }
                else
                {
                    return(ret);
                }
            }
            else
            {
                return(ret);
            }
        }
Esempio n. 8
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);
        }
Esempio n. 9
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);
        }
        private void e_Finder_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                throw new Exception("Finding account error exception", e.Error);
            }

            List <AccountError> newErrors = e.Result as List <AccountError>;

            // Add the new error to the new list and set the flag
            for (int i = 0; i < newErrors.Count; i++)
            {
                AccountError aError = newErrors[i];
                if (e_doesNotContain(ref e_KnownErrors, ref aError))
                {
                    this.e_KnownErrors.Add(aError);
                    switch (aError.Catagory)
                    {
                    case SpclAccountCat.ACCOUNT:
                        this.setErrorFlag(this.accountRootNode, aError.AccountID, true);
                        break;

                    case SpclAccountCat.EXPENSE:
                        this.setErrorFlag(this.expenseRootNode, aError.AccountID, true);
                        break;

                    case SpclAccountCat.INCOME:
                        this.setErrorFlag(this.incomeRootNode, aError.AccountID, true);
                        break;
                    }
                }
            }

            // Remove the fixed errors. Errors not in the new list.
            for (int i = 0; i < this.e_KnownErrors.Count; i++)
            {
                AccountError aError = this.e_KnownErrors[i];
                if (e_doesNotContain(ref newErrors, ref aError))
                {
                    this.e_KnownErrors.RemoveAt(i);
                    i--;
                    switch (aError.Catagory)
                    {
                    case SpclAccountCat.ACCOUNT:
                        this.setErrorFlag(this.accountRootNode, aError.AccountID, false);
                        break;

                    case SpclAccountCat.EXPENSE:
                        this.setErrorFlag(this.expenseRootNode, aError.AccountID, false);
                        break;

                    case SpclAccountCat.INCOME:
                        this.setErrorFlag(this.incomeRootNode, aError.AccountID, false);
                        break;
                    }
                }
            } // END for loop
        }     // END e_Finder_RunWorkerCompleted()
Esempio n. 11
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);
            }
        }
Esempio n. 12
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");
            }
        }
Esempio n. 13
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);
            }
        }
Esempio n. 14
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");
            }
        }
Esempio n. 15
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);
            }
        }
        /// <summary>
        /// Permet de lire les données associées à un compte utilisateur
        /// </summary>
        /// <param name="p">Dictionnaire contenant votre identifiant, votre mot de passe
        /// et l'identifiant du compte à lire</param>
        /// <returns>Valeurs de retour contenant les données lues</returns>
        public WSR_Result DownloadData(WSR_Params p)
        {
            string     pseudo         = null;
            string     password       = null;
            string     pseudoDownload = null;
            object     data           = null;
            WSR_Result ret            = null;

            ret = VerifParamType(p, "pseudo", out pseudo);
            if (ret != null)
            {
                return(ret);
            }


            ret = VerifParamType(p, "password", out password);
            if (ret != null)
            {
                return(ret);
            }

            ret = VerifParamType(p, "pseudoDownload", out pseudoDownload);
            if (ret != null)
            {
                return(ret);
            }

            AccountError err = Account.ReadData(pseudo, password, pseudoDownload, out data);

            switch (err)
            {
            case AccountError.Ok:
                return(new WSR_Result(data, false));

            case AccountError.KeyNullOrEmpty:
                return(new WSR_Result(CodeRetPseudoObligatoire, String.Format(Properties.Resources.PseudoObligatoire)));

            case AccountError.keyNotFound:
                return(new WSR_Result(CodeRetPseudoNonLogue, String.Format(Properties.Resources.PseudoNonLogue)));

            case AccountError.PasswordNullOrEmpty:
                return(new WSR_Result(CodeRetPasswordObligatoire, String.Format(Properties.Resources.PasswordObligatoire)));

            case AccountError.PasswordWrong:
                return(new WSR_Result(CodeRetPasswordIncorrect, String.Format(Properties.Resources.PasswordIncorrect)));

            case AccountError.keyDownloadNullOrEmpty:
                return(new WSR_Result(CodeRetPseudoDownloadObligatoire, String.Format(Properties.Resources.PseudoDownloadObligatoire)));

            case AccountError.keyDownloadNotFound:
                return(new WSR_Result(CodeRetPseudoDownloadNonLogue, String.Format(Properties.Resources.PseudoDownloadNonLogue)));

            default:
                return(new WSR_Result(CodeRetErreurInterneService, String.Format(Properties.Resources.ErreurInterneService)));
            }
        }
        public WSR_Result UploadData(WSR_Params p)
        {
            string     pseudo   = null;
            string     password = null;
            object     data     = null;
            WSR_Result ret      = null;

            ret = VerifParamType(p, "pseudo", out pseudo);
            if (ret != null)
            {
                return(ret);
            }

            ret = VerifParamType(p, "password", out password);
            if (ret != null)
            {
                return(ret);
            }

            ret = VerifParamExist(p, "data", out data);
            if (ret != null)
            {
                return(ret);
            }

            AccountError err = Account.WriteData(pseudo, password, data);

            switch (err)
            {
            case AccountError.Ok:
                ret = new WSR_Result();
                break;

            case AccountError.KeyNullOrEmpty:
                ret = new WSR_Result(CodeRet_PseudoObligatoire, Properties.Resources.PSEUDOVIDE);
                break;

            case AccountError.PasswordNullOrEmpty:
                ret = new WSR_Result(CodeRet_PasswordObligatoire, Properties.Resources.PWDVIDE);
                break;

            case AccountError.keyNotFound:
                ret = new WSR_Result(CodeRet_ParamKeyInconnu, string.Format(Properties.Resources.PARAMKEYINCONNU, pseudo));
                break;

            case AccountError.PasswordWrong:
                ret = new WSR_Result(CodeRet_PasswordIncorrect, Properties.Resources.PWDWRONG);
                break;

            default:
                ret = new WSR_Result(CodeRet_ErreurInterneService, Properties.Resources.ERREURINTERNE);
                break;
            }
            return(ret);
        }
Esempio n. 18
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);
            }
        }
Esempio n. 19
0
    // OnRegisterFailed
    private void OnRegisterFailed(string accountName, AccountError error)
    {
        statusMessage = "Failed to register account '" + accountName + "': ";

        switch (error)
        {
        case AccountError.NameAlreadyRegistered: statusMessage += "Name already registered."; break;

        default: statusMessage += "Unknown error occurred."; break;
        }
    }
Esempio n. 20
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);
        }
Esempio n. 21
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);
        }
Esempio n. 22
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);
        }
Esempio n. 23
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));
        }
        /// <summary>
        /// Permet de se Déloguer du WebService
        /// </summary>
        /// <param name="p">Dictionnaire contenant votre identifiant et votre mot de passe></param>
        /// <returns>Valeurs de retour</returns>
        public WSR_Result Logout(WSR_Params p)
        {
            string     pseudo   = null;
            string     password = null;
            WSR_Result ret      = null;

            ret = VerifParamType(p, "pseudo", out pseudo);
            if (ret != null)
            {
                return(ret);
            }

            //On verifie que le mot de passe est bien passé en paramètre
            ret = VerifParamType(p, "password", out password);
            if (ret != null)
            {
                return(ret);
            }
            //On efface le compte utilisateur de la liste des utlisateurs connectés et on renvoi un code erreur
            AccountError err = Account.Remove(pseudo, password);

            switch (err)
            {
            case AccountError.Ok:
                ret = new WSR_Result();
                break;

            case AccountError.KeyNullOrEmpty:
                ret = new WSR_Result(CodeRet_PseudoObligatoire, Properties.Resources.PSEUDOVIDE);
                break;

            //Mot de passe vide
            case AccountError.PasswordNullOrEmpty:
                ret = new WSR_Result(CodeRet_PasswordObligatoire, Properties.Resources.PWDVIDE);
                break;

            //Le compte utilisateur n'existe pas
            case AccountError.keyNotFound:
                ret = new WSR_Result(CodeRet_ParamKeyInconnu, string.Format(Properties.Resources.PARAMKEYINCONNU, pseudo));
                break;

            //Mot de passe erroné
            case AccountError.PasswordWrong:
                ret = new WSR_Result(CodeRet_PasswordIncorrect, Properties.Resources.PWDWRONG);
                break;

            default:
                ret = new WSR_Result(CodeRet_ErreurInterneService, Properties.Resources.ERREURINTERNE);
                break;
            }

            return(ret);
        }
Esempio n. 25
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);
        }
Esempio n. 26
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);
        }
        /// <summary>
        /// Permet d'obtenir la liste des utilisateurs logués au WebService
        /// </summary>
        /// <param name="p">Dictionnaire contenant votre identifiant et votre mot de passe</param>
        /// <returns>Valeurs de retour contenant la liste des utilisateurs connectés</returns>
        public WSR_Result GetPseudos(WSR_Params p)
        {
            string        pseudo   = null;
            string        password = null;
            List <string> lstKeys  = null;
            WSR_Result    ret      = null;

            ret = VerifParamType(p, "pseudo", out pseudo);
            if (ret != null)
            {
                return(ret);
            }

            ret = VerifParamType(p, "password", out password);
            if (ret != null)
            {
                return(ret);
            }

            AccountError err = Account.GetKeys(pseudo, password, out lstKeys);

            switch (err)
            {
            case AccountError.Ok:
                //on renvoi la liste des utilisateurs, sérialisée
                ret = new WSR_Result(lstKeys, true);
                break;

            case AccountError.KeyNullOrEmpty:
                ret = new WSR_Result(CodeRet_PseudoObligatoire, Properties.Resources.PSEUDOVIDE);
                break;

            case AccountError.PasswordNullOrEmpty:
                ret = new WSR_Result(CodeRet_PasswordObligatoire, Properties.Resources.PWDVIDE);
                break;

            case AccountError.keyNotFound:
                ret = new WSR_Result(CodeRet_ParamKeyInconnu, string.Format(Properties.Resources.PARAMKEYINCONNU, pseudo));
                break;

            case AccountError.PasswordWrong:
                ret = new WSR_Result(CodeRet_PasswordIncorrect, Properties.Resources.PWDWRONG);
                break;

            default:
                ret = new WSR_Result(CodeRet_ErreurInterneService, Properties.Resources.ERREURINTERNE);
                break;
            }
            return(ret);
        }
Esempio n. 28
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");
            }
        }
Esempio n. 29
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);
            }
        }
Esempio n. 30
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);
        }