2 // Open Service Platform
3 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FSclAccountManager.h
19 * @brief This is the header file for the %AccountManager class.
21 * This header file contains the declarations of the %AccountManager class.
23 #ifndef _FSCL_ACCOUNT_MANAGER_H_
24 #define _FSCL_ACCOUNT_MANAGER_H_
26 #include <unique_ptr.h>
27 #include <FBaseObject.h>
28 #include <FBaseTypes.h>
29 #include <FSclTypes.h>
31 namespace Tizen { namespace Base
40 namespace Tizen { namespace Social
43 class AccountProvider;
46 * @class AccountManager
47 * @brief This class provides the method for managing accounts.
50 * @final This class is not intended for extension.
52 * The %AccountManager class provides the method for managing accounts.
54 class _OSP_EXPORT_ AccountManager
55 : public Tizen::Base::Object
60 * The user name must be set in the account.
61 * If the account is added successfully, an account ID is newly assigned to it.
62 * The %AddAccount() method can be used only by the application belonging to a package of an application that registers its own account provider.
66 * @privilege %http://tizen.org/privilege/account.write
68 * @return An error code
69 * @param[in,out] account The account to add
70 * @exception E_SUCCESS The method is successful.
71 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
72 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
73 * - The user name is an empty string in the specified @c account. @n
74 * - The account ID is not #INVALID_ACCOUNT_ID. @n
75 * @exception E_INVALID_OPERATION Either of the following conditions has occurred: @n
76 * - The caller application does not belong to a package of an application that registers its own account provider. @n
77 * - The account has already been added with the multiple accounts support set to @c false.
78 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
80 result AddAccount(Account& account);
83 * Removes an account. @n
84 * The %RemoveAccount() method can be used only by an application belonging to a package of an application that registers its own account provider.
88 * @privilege %http://tizen.org/privilege/account.write
90 * @return An error code
91 * @param[in] accountId The account ID
92 * @exception E_SUCCESS The method is successful.
93 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
94 * @exception E_INVALID_ARG The specified @c accountId is invalid.
95 * @exception E_OBJ_NOT_FOUND The specified @c accountId does not exist.
96 * @exception E_INVALID_OPERATION This operation is not allowed if the caller application does not belong to a package of an application that registers its own account provider.
97 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
99 result RemoveAccount(AccountId accountId);
102 * Updates an account. @n
103 * The user name must be set in an account.
104 * The %UpdateAccount() method can be used only by an application belonging to a package of an application that registers its own account provider.
108 * @privilege %http://tizen.org/privilege/account.write
110 * @return An error code
111 * @param[in] account The account to update
112 * @exception E_SUCCESS The method is successful.
113 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
114 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
115 * - The user name is an empty string in the specified @c account. @n
116 * - The account ID is invalid. @n
117 * @exception E_OBJ_NOT_FOUND The specified @c account does not exist.
118 * @exception E_INVALID_OPERATION This operation is not allowed if the caller application does not belong to a package of an application that registers its own account provider.
119 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
121 result UpdateAccount(const Account& account);
124 * Gets the %AccountManager instance.
128 * @return A pointer to the %AccountManager instance, @n
129 * else @c null if it fails
130 * @remarks The specific error code can be accessed using the GetLastResult() method.
132 static AccountManager* GetInstance(void);
136 // This default constructor is intentionally declared as private to implement the Singleton semantic.
140 AccountManager(void);
143 // This destructor is intentionally declared as private to implement the Singleton semantic.
147 virtual ~AccountManager(void);
150 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
154 AccountManager(const AccountManager& rhs);
157 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
161 AccountManager& operator =(const AccountManager& rhs);
164 // Constructs an instance of this class.
168 // @return An error code
169 // @exception E_SUCCESS The method is successful.
170 // @exception E_SYSTEM The method cannot proceed due to a severe system error.
172 result Construct(void);
175 // Initializes an instance of this class.
179 static void InitAccountManager(void);
182 // Destroys an instance of this class.
186 static void DestroyAccountManager(void);
189 static AccountManager* __pInstance;
190 friend struct std::default_delete<AccountManager>;
192 friend class _AccountManagerImpl;
193 class _AccountManagerImpl* __pAccountManagerImpl;
199 #endif //_FSCL_ACCOUNT_MANAGER_H_