merge with master
[framework/osp/net.git] / inc / FNetDns.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                FNetDns.h
20  * @brief               This is the header file for the %Dns class.
21  *
22  * This header file contains the declarations of the %Dns class.
23  */
24 #ifndef _FNET_DNS_H_
25 #define _FNET_DNS_H_
26
27 #include <FBaseResult.h>
28 #include <FNetIpAddress.h>
29 #include <FNetIpHostEntry.h>
30 #include <FNetNetConnection.h>
31 #include <FNetIDnsEventListener.h>
32
33 namespace Tizen { namespace Net
34 {
35 class _DnsImpl;
36
37 /**
38  * @class       Dns
39  * @brief       This class provides a way to access the resolver of the Domain Name %System.
40  *
41  * @since       2.0
42  *
43  * The %Dns class represents a request for information from a DNS server. A DNS request can be one of two types, represented by the GetHostByAddress()
44  *                      and GetHostByName() methods. The %GetHostByAddress() method represents a request for the DNS information about a host, while the %GetHostByName()
45  *                      method represents a request for the DNS host information for an IP address. Both requests can be made in an asynchronous mode.
46  *
47  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/domain_name_system_access.htm">Domain Name System Access</a>.
48  */
49 class _OSP_EXPORT_ Dns
50         : public Tizen::Base::Object
51 {
52 public:
53         /**
54          * 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.
55          *
56          * @since               2.0
57          *
58          * @remarks             After creating an instance of this class, one of the Construct() methods must be called explicitly to initialize this instance.
59          */
60         Dns(void);
61
62         /**
63          * This destructor overrides Tizen::Base::Object::~Object().
64          *
65          * @since                       2.0
66          */
67         virtual ~Dns(void);
68
69         /**
70          * Initializes this instance of %Dns with the specified parameters.
71          *
72          * @since               2.0
73          *
74          * @return              An error code
75          * @param[in]   netConnection                   A NetConnection on which the DNS request executes
76          * @param[in]   listener                                A reference to IDnsEventListener
77          * @exception   E_SUCCESS                               The method is successful.
78          * @exception   E_INVALID_ARG                   The specified @c netConnection contains an invalid value.
79          * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
80          * @exception   E_SYSTEM                                An internal error has occurred.
81          * @exception   E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation, @n
82          *                                                                              because the caller thread is a worker thread.
83          */
84         result Construct(const NetConnection& netConnection, IDnsEventListener& listener);
85
86         /**
87          * Initializes this instance of %Dns with the specified listener.
88          *
89      * @since           2.0
90          *
91          * @return              An error code
92          * @param[in]   listener                                A reference to IDnsEventListener
93          * @exception   E_SUCCESS                               The method is successful.
94          * @exception   E_INVALID_CONNECTION    The network connection is invalid.
95          * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
96          * @exception   E_SYSTEM                                An internal error has occurred.
97          * @exception   E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation, @n
98          *                                                                              because the caller thread is a worker thread.
99          */
100         result Construct(IDnsEventListener& listener);
101
102 public:
103         /**
104          * Requests a DNS lookup by host name. @n
105          * This method is asynchronous.
106          *
107          * @since               2.0
108          *
109          * @privlevel   public
110          * @privilege   http://tizen.org/privilege/dns
111          *
112          * @return              An error code
113          * @param[in]   hostName                                The DNS name of the host
114          * @exception   E_SUCCESS                               The method is successful.
115          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
116          * @exception   E_INVALID_CONNECTION    The network connection is invalid.
117          * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
118          * @exception   E_NETWORK_UNAVAILABLE   The network is unavailable.
119          * @exception   E_CONNECTION_FAILED             The network connection has failed.
120          * @exception   E_OPERATION_FAILED              Requested but an error is received while waiting for the response.
121          * @exception   E_SYSTEM                                An internal error has occurred.
122          * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
123          *
124          * @remarks             Only one query is processed at a time in this instance.
125          *              Multiple queries may be discarded.
126          */
127         result GetHostByName(const Tizen::Base::String& hostName);
128
129         /**
130          * Requests a DNS lookup by IP address. @n
131          * This method is asynchronous.
132          *
133          * @since               2.0
134          *
135          * @privlevel   public
136          * @privilege   http://tizen.org/privilege/dns
137          *
138          * @return              An error code
139          * @param[in]   ipAddress                               An IP address
140          * @exception   E_SUCCESS                               The method is successful.
141          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
142          * @exception   E_INVALID_CONNECTION    The network connection is invalid.
143          * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
144          * @exception   E_NETWORK_UNAVAILABLE   The network is unavailable.
145          * @exception   E_CONNECTION_FAILED             The network connection has failed.
146          * @exception   E_OPERATION_FAILED              Requested but an error is received while waiting for the response.
147          * @exception   E_SYSTEM                                An internal error has occurred.
148          * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
149          * @remarks             Only one query is processed at a time in this instance.
150          *              Multiple queries may be discarded.
151          */
152         result GetHostByAddress(const IpAddress& ipAddress);
153
154 private:
155         /*
156          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
157          *
158          * @param[in]   rhs                     An instance of %Dns
159          */
160         Dns(const Dns& rhs);
161
162         /*
163          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
164          *
165          * @param[in]   rhs                     An instance of %Dns
166          */
167         Dns& operator =(const Dns& rhs);
168
169 private:
170         _DnsImpl* __pDnsImpl;
171
172         friend class _DnsImpl;
173 }; // Dns
174
175 } } //Tizen::Net
176
177 #endif // _FNET_DNS_H_