2 // Open Service Platform
3 // Copyright (c) 2012-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 FNet_DnsRequestHandler.h
19 * @brief This is the header file for the _DnsRequestHandler Class.
21 * This header file contains declaration of the _DnsRequestHandler Class.
23 #ifndef _FNET_INTERNAL_DNS_REQUEST_HANDLER_H_
24 #define _FNET_INTERNAL_DNS_REQUEST_HANDLER_H_
26 #include <unique_ptr.h>
27 #include <FBaseDataType.h>
28 #include <FBaseObject.h>
29 #include <FBaseRtThread.h>
30 #include "FNet_DnsEventArg.h"
32 namespace Tizen { namespace Net
36 class _IpHostEntryImpl;
39 class _DnsRequestHandler
40 : public Tizen::Base::Object
41 , public Tizen::Base::Runtime::IRunnable
47 * @param[in] pDnsRequest _DnsRequest
49 _DnsRequestHandler(_DnsRequest* pDnsRequest);
54 ~_DnsRequestHandler();
57 * Two-Phase Constructor
62 * Rnn() - Runnable implementation
67 * Start the Event Handler
68 * @return A result code.
73 * Check the DNS request operation state
75 bool IsRequestStarted();
78 * Fire network stopped event
80 result FireNetworkStoppedEvent();
87 * @param[in] pHostent A pointer to struct hostent
88 * @param[in] dnsId ID of DNS call
89 * @param[in] dnsEvent DNS Event
90 * @return An error code
92 static result DnsCallBack(struct hostent* pHostent, int dnsId, _DnsEvent& dnsEvent);
98 * @param[in] pHostent A pointer to struct hostent
99 * @param[in] ipHostEntryImpl A reference to _IpHostEntryImpl
100 * @return An error code
102 static result SetAddressList(const struct hostent* pHostent, _IpHostEntryImpl& ipHostEntryImpl);
108 * @param[in] pHostent A pointer to struct hostent
109 * @param[in] ipHostEntryImpl A reference to _IpHostEntryImpl
110 * @return An error code
112 static result SetAliasList(const struct hostent* pHostent, _IpHostEntryImpl& ipHostEntryImpl);
119 _DnsRequestHandler(void);
122 * This is the copy constructor for this class. @n
123 * Do @b not use directly.
126 _DnsRequestHandler(const _DnsRequestHandler& rhs);
129 * This is the assignment operator for this class. @n
130 * Do @b not use directly.
133 _DnsRequestHandler& operator =(const _DnsRequestHandler& rhs);
136 std::unique_ptr<_DnsRequest> __pDnsRequest; // Request, Own
137 std::unique_ptr<Tizen::Base::Runtime::Thread> __pThread; // Thread to process request
138 bool __isStarted; // state of dns operation, started.
139 };//_DnsRequestHandler
143 * @brief _DnsRequest contains the event details to be processed by _DnsRequestHandler
148 : public Tizen::Base::Object
153 * @param[in] type Event-type
154 * @param[in] pMsg Message Data
155 * @param[in] event _DnsEvent
157 _DnsRequest(_NetDnsEventType msgType, char* pMsgData, _DnsEvent& event);
165 * Execute() - Process the message
170 * Get the _DnsEvent object
172 _DnsEvent& GetDnsEvent();
182 * This is the copy constructor for this class. @n
183 * Do @b not use directly.
186 _DnsRequest(const _DnsRequest& rhs);
189 * This is the assignment operator for this class. @n
190 * Do @b not use directly.
193 _DnsRequest& operator =(const _DnsRequest& rhs);
197 _NetDnsEventType __msgType; //event type
198 std::unique_ptr<char[]> __pMsgData; // event data, Owned
199 _DnsEvent& __dnsEvent; // Event, has listener reference for callback.
204 #endif // _FNET_INTERNAL_DNS_REQUEST_HANDLER_H_