merge with master
[framework/osp/net.git] / inc / FNetNetAccountInfo.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file                FNetNetAccountInfo.h
20  * @brief               This is the header file for the %NetAccountInfo class.
21  *
22  * This header file contains the declarations of the %NetAccountInfo class.
23  */
24 #ifndef _FNET_NET_ACCOUNT_INFO_H_
25 #define _FNET_NET_ACCOUNT_INFO_H_
26
27 #include <FBaseObject.h>
28 #include <FBaseString.h>
29 #include <FBaseResult.h>
30 #include <FBaseErrors.h>
31 #include <FNetNetTypes.h>
32 #include <FNetIpAddress.h>
33 #include <FNetIp4Address.h>
34 #include <FNetNetEndPoint.h>
35
36 namespace Tizen { namespace Net
37 {
38 class _NetAccountInfoImpl;
39
40 /**
41  * @class       NetAccountInfo
42  * @brief       This class provides methods for all the network accounts.
43  *
44  * @since       2.0
45  *
46  * The %NetAccountInfo class provides all the configuration parameters for setting up network connections.
47  * %NetAccountInfo contains the base information required to connect to various bearers and it is designed to be
48  * used in Programmed Data Processor (PDP) context activation. The Wi-Fi accounts are derived from this class
49  * and contain additional information specific to Wi-Fi (such as SSID).
50  *
51  * For more information on the class features, see
52  * <a href="../org.tizen.native.appprogramming/html/guide/net/network_accounts.htm">Network Accounts</a>.
53  */
54 class _OSP_EXPORT_ NetAccountInfo
55         : public Tizen::Base::Object
56 {
57 public:
58         /**
59         * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
60         *
61         * @since        2.0
62         *
63         * @remarks      After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
64         */
65         NetAccountInfo(void);
66
67         /**
68         * This destructor overrides Tizen::Base::Object::~Object().
69         *
70         * @since        2.0
71         */
72         virtual ~NetAccountInfo(void);
73
74         /**
75          * Initializes this instance of %NetAccountInfo with the specified %NetAccountInfo instance. @n
76          * Only the data part is cloned. Attributes such as NetAccountId and the connection status, which are linked with the registry are set to default values.
77          *
78          * @since               2.0
79          *
80          * @return              An error code
81          * @param[in]   netAccountInfo          A %NetAccountInfo instance to initialize the calling instance
82          * @exception   E_SUCCESS                       The method is successful.
83          * @exception   E_INVALID_ARG           The specified @c netAccountInfo is invalid.
84          */
85         result Construct(const NetAccountInfo& netAccountInfo);
86
87         /**
88          * Initializes this instance of %NetAccountInfo.
89          *
90          * @since               2.0
91          *
92          *      @return         An error code
93          *      @exception      E_SUCCESS                       The method is successful.
94          */
95         result Construct(void);
96
97         /**
98          * Gets an account ID.
99          *
100          * @since               2.0
101          *
102          * @return              The account ID
103          * @exception   E_SUCCESS                               The method is successful.
104          * @remarks             The specific error code can be accessed using the GetLastResult() method.
105          */
106         NetAccountId GetAccountId(void) const;
107
108         /**
109          * Gets the name of an account.
110          *
111          * @since               2.0
112          *
113          * @return              The name of the account, @n
114          *                              else a null string if the name is not set or not constructed
115          * @exception   E_SUCCESS                               The method is successful.
116          * @remarks             The specific error code can be accessed using the GetLastResult() method.
117          * @see                 SetAccountName()
118          */
119         Tizen::Base::String GetAccountName(void) const;
120
121         /**
122          * Sets the name of an account. @n
123          * If this method fails, the state of this instance does not change.
124          *
125          * @since               2.0
126          *
127          * @return              An error code
128          * @param[in]   accountName                             The name of an account
129          * @exception   E_SUCCESS                               The method is successful.
130          * @see                 GetAccountName()
131          */
132         result SetAccountName(const Tizen::Base::String& accountName);
133
134         /**
135          * Gets the protocol type.
136          *
137          * @since               2.0
138          *
139          * @return              The type of the protocol
140          * @exception   E_SUCCESS                               The method is successful.
141          * @remarks             The specific error code can be accessed using the GetLastResult() method.
142          * @see                 SetProtocolType()
143          */
144         NetProtocolType GetProtocolType(void) const;
145
146         /**
147          * Sets the protocol type.
148          *
149          * @since               2.0
150          *
151          * @return              An error code
152          * @param[in]   netProtocolType                 The type of the protocol
153          * @exception   E_SUCCESS                               The method is successful.
154          * @remarks             If this method fails, the state of this instance does not change.
155          * @see                 GetProtocolType()
156          */
157         result SetProtocolType(NetProtocolType netProtocolType);
158
159         /**
160          * Gets an Access Point Name.
161          *
162          * @since               2.0
163          *
164          * @return              The Access Point Name, @n
165          *                              else a null string if the name is not set or the instance is not constructed
166          * @exception   E_SUCCESS                               The method is successful.
167          * @remarks             The specific error code can be accessed using the GetLastResult() method.
168          * @see                 SetAccessPointName()
169          */
170         Tizen::Base::String GetAccessPointName(void) const;
171
172         /**
173          * Sets the name of the access point. @n
174          * If this method fails, the state of this instance does not change.
175          *
176          * @since               2.0
177          *
178          * @return              An error code
179          * @param[in]   accessPointName                 The Access Point Name
180          * @exception   E_SUCCESS                               The method is successful.
181          * @see                 GetAccessPointName()
182          */
183         result SetAccessPointName(const Tizen::Base::String& accessPointName);
184
185         /**
186          * Gets the setting for the local address scheme. @n
187          * This scheme can be dynamic or static.
188          *
189          * @since               2.0
190          *
191          * @return              The address scheme
192          * @exception   E_SUCCESS                               The method is successful.
193          * @remarks             The specific error code can be accessed using the GetLastResult() method.
194          * @see                 SetLocalAddress()
195          * @see                 GetLocalAddress()
196          */
197         NetAddressScheme GetLocalAddressScheme(void) const;
198
199         /**
200          * Gets the local address.
201          *
202          * @since                       2.0
203          *
204          * @return                      The local address, @n
205          *                                      else @c null if an error occurs or the dynamic address scheme is being used
206          * @exception           E_SUCCESS                               The method is successful.
207          * @exception           E_INVALID_OPERATION             This operation is not allowed in the dynamic address scheme.
208          * @remarks                     The specific error code can be accessed using the GetLastResult() method.
209          * @see                         SetLocalAddress()
210          */
211         const IpAddress* GetLocalAddress(void) const;
212
213         /**
214          * Enables or disables the use of a static local IP address.
215          *
216          * @since               2.0
217          *
218          * @return              An error code
219          * @param[in]   localAddrScheme                 An indicator specifying whether to use a static local IP address
220          * @param[in]   pLocalAddress                   The local IP address @n
221          *                                                                              If @c localAddrScheme is set to NET_ADDRESS_SCHEME_STATIC, the local IP address assigned is static.
222          *                                                                              If @c localAddrScheme is set to NET_ADDRESS_SCHEME_DYNAMIC or NET_ADDRESS_SCHEME_NONE, this parameter is ignored.
223          * @exception   E_SUCCESS                               The method is successful.
224          * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
225          * @see                 GetLocalAddress()
226          */
227         result SetLocalAddress(NetAddressScheme localAddrScheme, const IpAddress* pLocalAddress);
228
229         /**
230          * Gets the setting for the DNS address scheme.
231          *
232          * @since               2.0
233          *
234          * @return              The address scheme for the DNS
235          * @exception   E_SUCCESS                       The method is successful.
236          * @remarks             The specific error code can be accessed using the GetLastResult() method.
237          * @see                 GetPrimaryDnsAddress()
238          * @see                 GetSecondaryDnsAddress()
239          * @see                 SetDnsAddress()
240          */
241         NetAddressScheme GetDnsAddressScheme(void) const;
242
243         /**
244          * Gets the setting for the primary DNS address.
245          *
246          * @since                       2.0
247          *
248          * @return                      The IpAddress of primary DNS address, @n
249          *                                      else @c null if an error occurs or the dynamic address scheme is being used
250          * @exception           E_SUCCESS                               The method is successful.
251          * @exception           E_INVALID_OPERATION             This operation is not allowed in the dynamic address scheme.
252          * @remarks                     When this instance is got by @ref NetAccountManager::GetNetAccountInfoN,
253          *                                      - this method returns a statically assigned primary DNS address pointer if the DNS address scheme is NET_ADDRESS_SCHEME_STATIC
254          *                                      - this method returns @n null if the DNS address scheme is NET_ADDRESS_SCHEME_DYNAMIC @n
255          *                      The specific error code can be accessed using the GetLastResult() method.
256          * @see                         GetSecondaryDnsAddress()
257          */
258         const IpAddress* GetPrimaryDnsAddress(void) const;
259
260         /**
261          * Gets the setting for the secondary DNS address.
262          *
263          * @since                       2.0
264          *
265          * @return                      The secondary DNS IP address, @n
266          *                                      else @c null if an error occurs or the dynamic address scheme is being used
267          * @exception           E_SUCCESS                               The method is successful.
268          * @exception           E_INVALID_OPERATION             This operation is not allowed in the dynamic address scheme.
269          * @remarks                     The specific error code can be accessed using the GetLastResult() method.
270          * @see                         SetDnsAddress()
271          */
272         const IpAddress* GetSecondaryDnsAddress(void) const;
273
274         /**
275          * Enables or disables the use of a static DNS address with the specified IpAddress objects. @n
276          * If @c dnsAddrScheme is NET_ADDRESS_SCHEME_DYNAMIC, both @c primaryDnsAddress and @c secondaryDnsAddress are ignored. @n
277          * If @c dnsAddrScheme is NET_ADDRESS_SCHEME_STATIC, @c primaryDnsAddress must be a valid IpAddress.
278          * However, @c pSecondaryDnsAddress can be @c null.
279          *
280          * @since               2.0
281          *
282          * @return              An error code
283          * @param[in]   dnsAddrScheme                   An indicator specifying whether or not to use a static DNS address
284          * @param[in]   pPrimaryDnsAddress              The statically assigned primary DNS address if @c dnsAddrScheme is NET_ADDRESS_SCHEME_STATIC
285          * @param[in]   pSecondaryDnsAddress    The statically assigned secondary DNS address if @c dnsAddrScheme is NET_ADDRESS_SCHEME_STATIC
286          * @exception   E_SUCCESS                               The method is successful.
287          * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
288          * @see                 GetPrimaryDnsAddress()
289          * @see                 GetSecondaryDnsAddress()
290          */
291         result SetDnsAddress(NetAddressScheme dnsAddrScheme, const IpAddress* pPrimaryDnsAddress, const IpAddress* pSecondaryDnsAddress);
292
293         /**
294          * Gets the proxy address of the network accounts.
295          *
296          * @since               2.0
297          *
298          * @return              The proxy address, @n
299          *                              else @c null if an error occurs or the address is not set
300          * @exception   E_SUCCESS                               The method is successful.
301          * @exception   E_UNSUPPORTED_FORMAT    The specified address format is not supported.
302          * @remarks             The specific error code can be accessed using the GetLastResult() method.
303          */
304         const NetEndPoint* GetProxyAddress(void) const;
305
306         /**
307          * Sets the proxy address of the network accounts.
308          *
309          * @since               2.0
310          *
311          * @return              An error code
312          * @param[in]   pProxyEndPoint                  A pointer to a NetEndPoint instance containing the IP address and port
313          * @exception   E_SUCCESS                               The method is successful.
314          */
315         result SetProxyAddress(const NetEndPoint* pProxyEndPoint);
316
317         /**
318          * Gets the authentication configuration of network accounts. @n
319          * The user is not provided with read access to the credential information present in the registry if the network account information is extracted from
320          * the registry using @ref NetAccountManager::GetNetAccountInfoN().
321          *
322          * @since               2.0
323          *
324          * @return              An error code
325          * @param[out]  authenticationType      The type of the authentication used
326          * @param[out]  id                                      The ID
327          * @param[out]  password                        The password
328          * @exception   E_SUCCESS                       The method is successful.
329          * @exception   E_ILLEGAL_ACCESS        The user is not provided with read access to the credential information present in the registry, if the network
330          *                                                                      account information is extracted from the registry using NetAccountManager::GetNetAccountInfoN().
331          * @remarks             If this method fails, the state of this instance does not change.
332          * @see                 SetAuthenticationInfo()
333          *
334          */
335         result GetAuthenticationInfo(NetNapAuthType& authenticationType, Tizen::Base::String& id, Tizen::Base::String& password) const;
336
337         /**
338          * Sets the authentication configuration of the network accounts.
339          *
340          * @since               2.0
341          *
342          * @return              An error code
343          * @param[in]   authenticationType      The type of the authentication used
344          * @param[in]   id                                      The ID
345          * @param[in]   password                        The password
346          * @exception   E_SUCCESS                       The method is successful.
347          * @remarks             If this method fails, the state of this instance does not change.
348          * @see                 GetAuthenticationInfo()
349          *
350          */
351         result SetAuthenticationInfo(NetNapAuthType authenticationType, const Tizen::Base::String& id, const Tizen::Base::String& password);
352
353         /**
354          * Gets the operational bearer type of this account.
355          *
356          * @since               2.0
357          *
358          * @return              The operational bearer type
359          * @exception   E_SUCCESS                       The method is successful.
360          * @remarks             The specific error code can be accessed using the GetLastResult() method.
361          */
362         NetBearerType GetBearerType(void) const;
363
364         /**
365          * Gets the current URL of a home page.
366          *
367          * @since                    2.0
368          *
369          * @return                  The current URL of a home page
370          * @see                      SetHomeUrl()
371          */
372         Tizen::Base::String GetHomeUrl(void) const;
373
374         /**
375          * Sets a URL as a home page.
376          *
377          * @since                  2.0
378          *
379          * @param[in]   homeUrl         The URL to set as a home page
380          * @see                    GetHomeUrl()
381          */
382         void SetHomeUrl(const Tizen::Base::String& homeUrl);
383
384         /**
385          * Gets the maximum length of the user name.
386          *
387          * @since               2.0
388          *
389          * @return              The maximum length of the user name
390          */
391         int GetMaximumLengthOfId(void) const;
392
393         /**
394          * Gets the maximum length of the password.
395          *
396          * @since               2.0
397          *
398          * @return              The maximum length of the password
399          */
400         int GetMaximumLengthOfPassword(void) const;
401
402         /**
403          * Gets the maximum length of the account name.
404          *
405          * @since               2.0
406          *
407          * @return              The maximum length of the account name
408          */
409         int GetMaximumLengthOfAccountName(void) const;
410
411         /**
412          * Gets a value that indicates whether the network account is read-only. @n
413          * If it returns @c true, this account is read-only; so any change to this account is not permitted. @n
414          * When it returns @c false, modification is possible.
415          *
416          * @since               2.0
417          *
418          * @return              @c true if this account is read only, @n
419          *                              else @c false
420          * @exception   E_SUCCESS                               The method is successful.
421          * @remarks             The specific error code can be accessed using the GetLastResult() method.
422          */
423         bool IsReadOnly(void) const;
424
425         /**
426          * Compares the specified instance of %NetAccountInfo with the calling instance.
427          *
428          * @since               2.0
429          *
430          * @return              @c true if the values match, @n
431          *                              else @c false
432          * @param[in]   rhs     The other Object to compare
433          * @see                 Object::Equals()
434          */
435         virtual bool Equals(const Tizen::Base::Object& rhs) const;
436
437         /**
438          * Gets the hash value of the current instance.
439          *
440          * @since               2.0
441          *
442          * @return      The hash value of the current instance
443          */
444         virtual int GetHashCode(void) const;
445
446 private:
447         /**
448          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
449          *
450          * @param[in]   rhs                     An instance of %NetAccountInfo
451          */
452         NetAccountInfo(const NetAccountInfo& rhs);
453
454         /**
455          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
456          *
457          * @param[in]   rhs An instance of %NetAccountInfo
458          */
459         NetAccountInfo& operator =(const NetAccountInfo& rhs);
460
461 private:
462         _NetAccountInfoImpl* __pNetAccountInfoImpl;
463
464         friend class _NetAccountInfoImpl;
465 }; // NetAccountInfo
466
467 } } //Tizen::Net
468
469 #endif // _FNET_NET_ACCOUNT_INFO_H_