Tizen 2.1 base
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:50:49 +0000 (01:50 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:50:49 +0000 (01:50 +0900)
321 files changed:
CMakeLists.txt [new file with mode: 0755]
LICENSE.APLv2 [new file with mode: 0644]
LICENSE.Flora [new file with mode: 0644]
NOTICE [new file with mode: 0644]
inc/FNet.h [new file with mode: 0644]
inc/FNetDhcpClientInfo.h [new file with mode: 0644]
inc/FNetDns.h [new file with mode: 0755]
inc/FNetHttp.h [new file with mode: 0755]
inc/FNetHttpHttpAuthentication.h [new file with mode: 0755]
inc/FNetHttpHttpCookie.h [new file with mode: 0755]
inc/FNetHttpHttpCookieStorageManager.h [new file with mode: 0755]
inc/FNetHttpHttpCredentials.h [new file with mode: 0755]
inc/FNetHttpHttpHeader.h [new file with mode: 0755]
inc/FNetHttpHttpMessage.h [new file with mode: 0755]
inc/FNetHttpHttpMultipartEntity.h [new file with mode: 0755]
inc/FNetHttpHttpRequest.h [new file with mode: 0755]
inc/FNetHttpHttpResponse.h [new file with mode: 0755]
inc/FNetHttpHttpSession.h [new file with mode: 0755]
inc/FNetHttpHttpStringEntity.h [new file with mode: 0755]
inc/FNetHttpHttpTransaction.h [new file with mode: 0755]
inc/FNetHttpHttpTypes.h [new file with mode: 0755]
inc/FNetHttpHttpUrlEncodedEntity.h [new file with mode: 0755]
inc/FNetHttpHttpXmlDomEntity.h [new file with mode: 0755]
inc/FNetHttpIHttpEntity.h [new file with mode: 0755]
inc/FNetHttpIHttpProgressEventListener.h [new file with mode: 0755]
inc/FNetHttpIHttpTransactionEventListener.h [new file with mode: 0755]
inc/FNetIDnsEventListener.h [new file with mode: 0644]
inc/FNetILocalDhcpServerEventListener.h [new file with mode: 0644]
inc/FNetIManagedNetConnectionEventListener.h [new file with mode: 0644]
inc/FNetINetConnectionEventListener.h [new file with mode: 0644]
inc/FNetIp4Address.h [new file with mode: 0644]
inc/FNetIpAddress.h [new file with mode: 0644]
inc/FNetIpHostEntry.h [new file with mode: 0644]
inc/FNetLocalDhcpServer.h [new file with mode: 0644]
inc/FNetManagedNetConnection.h [new file with mode: 0644]
inc/FNetNetAccountInfo.h [new file with mode: 0644]
inc/FNetNetAccountManager.h [new file with mode: 0755]
inc/FNetNetConnection.h [new file with mode: 0755]
inc/FNetNetConnectionInfo.h [new file with mode: 0644]
inc/FNetNetConnectionManager.h [new file with mode: 0755]
inc/FNetNetEndPoint.h [new file with mode: 0644]
inc/FNetNetStatistics.h [new file with mode: 0755]
inc/FNetNetTypes.h [new file with mode: 0644]
inc/FNetSockISecureSocketEventListener.h [new file with mode: 0644]
inc/FNetSockISocketEventListener.h [new file with mode: 0644]
inc/FNetSockSecureSocket.h [new file with mode: 0755]
inc/FNetSockSocket.h [new file with mode: 0755]
inc/FNetSockSocketIpMulticastRequestOption.h [new file with mode: 0644]
inc/FNetSockSocketLingerOption.h [new file with mode: 0644]
inc/FNetSockSocketTypes.h [new file with mode: 0644]
inc/FNetSockSocketUtility.h [new file with mode: 0755]
inc/FNetSockets.h [new file with mode: 0644]
inc/FNetWifi.h [new file with mode: 0644]
inc/FNetWifiIWifiDirectDeviceListener.h [new file with mode: 0644]
inc/FNetWifiIWifiDirectGroupClientListener.h [new file with mode: 0644]
inc/FNetWifiIWifiDirectGroupOwnerListener.h [new file with mode: 0644]
inc/FNetWifiIWifiManagerEventListener.h [new file with mode: 0644]
inc/FNetWifiIWifiSystemMonitoringEventListener.h [new file with mode: 0644]
inc/FNetWifiWifiBssInfo.h [new file with mode: 0644]
inc/FNetWifiWifiDirectDevice.h [new file with mode: 0755]
inc/FNetWifiWifiDirectDeviceInfo.h [new file with mode: 0644]
inc/FNetWifiWifiDirectDeviceManager.h [new file with mode: 0644]
inc/FNetWifiWifiDirectGroupClient.h [new file with mode: 0755]
inc/FNetWifiWifiDirectGroupInfo.h [new file with mode: 0644]
inc/FNetWifiWifiDirectGroupMember.h [new file with mode: 0644]
inc/FNetWifiWifiDirectGroupOwner.h [new file with mode: 0755]
inc/FNetWifiWifiManager.h [new file with mode: 0755]
inc/FNetWifiWifiNetAccountInfo.h [new file with mode: 0644]
inc/FNetWifiWifiSecurityInfo.h [new file with mode: 0644]
inc/FNetWifiWifiTypes.h [new file with mode: 0644]
osp-net.manifest [new file with mode: 0644]
osp-net.pc.in [new file with mode: 0755]
packaging/osp-net.spec [new file with mode: 0755]
src/CMakeLists.txt [new file with mode: 0755]
src/FNetDhcpClientInfo.cpp [new file with mode: 0644]
src/FNetDns.cpp [new file with mode: 0644]
src/FNetIp4Address.cpp [new file with mode: 0644]
src/FNetIpAddress.cpp [new file with mode: 0644]
src/FNetIpHostEntry.cpp [new file with mode: 0644]
src/FNetLocalDhcpServer.cpp [new file with mode: 0644]
src/FNetManagedNetConnection.cpp [new file with mode: 0644]
src/FNetNetAccountInfo.cpp [new file with mode: 0644]
src/FNetNetAccountManager.cpp [new file with mode: 0644]
src/FNetNetAccountManagerPartner.cpp [new file with mode: 0644]
src/FNetNetConnection.cpp [new file with mode: 0644]
src/FNetNetConnectionInfo.cpp [new file with mode: 0644]
src/FNetNetConnectionManager.cpp [new file with mode: 0644]
src/FNetNetEndPoint.cpp [new file with mode: 0644]
src/FNetNetStatistics.cpp [new file with mode: 0644]
src/FNet_DefaultSystemNetConnection.cpp [new file with mode: 0644]
src/FNet_DefaultSystemNetConnection.h [new file with mode: 0644]
src/FNet_DhcpClientInfoImpl.cpp [new file with mode: 0644]
src/FNet_DhcpClientInfoImpl.h [new file with mode: 0644]
src/FNet_DnsEvent.cpp [new file with mode: 0644]
src/FNet_DnsEvent.h [new file with mode: 0644]
src/FNet_DnsEventArg.cpp [new file with mode: 0644]
src/FNet_DnsEventArg.h [new file with mode: 0644]
src/FNet_DnsImpl.cpp [new file with mode: 0644]
src/FNet_DnsImpl.h [new file with mode: 0644]
src/FNet_DnsManagedNetConnectionEventListener.cpp [new file with mode: 0644]
src/FNet_DnsManagedNetConnectionEventListener.h [new file with mode: 0644]
src/FNet_DnsRequestHandler.cpp [new file with mode: 0644]
src/FNet_DnsRequestHandler.h [new file with mode: 0644]
src/FNet_Ip4AddressImpl.cpp [new file with mode: 0644]
src/FNet_IpHostEntryImpl.cpp [new file with mode: 0644]
src/FNet_IpHostEntryImpl.h [new file with mode: 0644]
src/FNet_LocalDhcpServerEvent.cpp [new file with mode: 0644]
src/FNet_LocalDhcpServerEvent.h [new file with mode: 0644]
src/FNet_LocalDhcpServerEventArg.cpp [new file with mode: 0644]
src/FNet_LocalDhcpServerEventArg.h [new file with mode: 0644]
src/FNet_LocalDhcpServerImpl.cpp [new file with mode: 0644]
src/FNet_LocalDhcpServerImpl.h [new file with mode: 0644]
src/FNet_ManagedNetConnectionImpl.cpp [new file with mode: 0644]
src/FNet_NetAccountDatabase.cpp [new file with mode: 0644]
src/FNet_NetAccountDatabase.h [new file with mode: 0644]
src/FNet_NetAccountInfoImpl.cpp [new file with mode: 0644]
src/FNet_NetAccountInfoImpl.h [new file with mode: 0644]
src/FNet_NetAccountManagerImpl.cpp [new file with mode: 0644]
src/FNet_NetAccountManagerImpl.h [new file with mode: 0644]
src/FNet_NetConnectionEvent.cpp [new file with mode: 0644]
src/FNet_NetConnectionEvent.h [new file with mode: 0644]
src/FNet_NetConnectionEventArg.cpp [new file with mode: 0644]
src/FNet_NetConnectionEventArg.h [new file with mode: 0644]
src/FNet_NetConnectionImpl.cpp [new file with mode: 0644]
src/FNet_NetConnectionInfoImpl.cpp [new file with mode: 0644]
src/FNet_NetConnectionManagerImpl.cpp [new file with mode: 0644]
src/FNet_NetEndPointImpl.cpp [new file with mode: 0644]
src/FNet_NetExporter.cpp [new file with mode: 0644]
src/FNet_NetIpcMessages.cpp [new file with mode: 0644]
src/FNet_NetIpcProxy.cpp [new file with mode: 0644]
src/FNet_NetIpcProxy.h [new file with mode: 0644]
src/FNet_NetStatisticsImpl.cpp [new file with mode: 0644]
src/FNet_NetStatisticsImpl.h [new file with mode: 0644]
src/FNet_NetUtility.cpp [new file with mode: 0644]
src/FNet_NetUtility.h [new file with mode: 0644]
src/FNet_PsSystemNetConnection.cpp [new file with mode: 0644]
src/FNet_PsSystemNetConnection.h [new file with mode: 0644]
src/FNet_SystemNetConnection.cpp [new file with mode: 0644]
src/FNet_SystemNetConnection.h [new file with mode: 0644]
src/FNet_UsbSystemNetConnection.cpp [new file with mode: 0644]
src/FNet_UsbSystemNetConnection.h [new file with mode: 0644]
src/FNet_WifiDirectSystemNetConnection.cpp [new file with mode: 0644]
src/FNet_WifiDirectSystemNetConnection.h [new file with mode: 0644]
src/FNet_WifiSystemNetConnection.cpp [new file with mode: 0644]
src/FNet_WifiSystemNetConnection.h [new file with mode: 0644]
src/http/FNetHttpHttpAuthentication.cpp [new file with mode: 0644]
src/http/FNetHttpHttpCookie.cpp [new file with mode: 0644]
src/http/FNetHttpHttpCookieStorageManager.cpp [new file with mode: 0644]
src/http/FNetHttpHttpCredentials.cpp [new file with mode: 0644]
src/http/FNetHttpHttpHeader.cpp [new file with mode: 0644]
src/http/FNetHttpHttpMessage.cpp [new file with mode: 0644]
src/http/FNetHttpHttpMultipartEntity.cpp [new file with mode: 0644]
src/http/FNetHttpHttpRequest.cpp [new file with mode: 0644]
src/http/FNetHttpHttpResponse.cpp [new file with mode: 0644]
src/http/FNetHttpHttpSession.cpp [new file with mode: 0644]
src/http/FNetHttpHttpStringEntity.cpp [new file with mode: 0644]
src/http/FNetHttpHttpTransaction.cpp [new file with mode: 0644]
src/http/FNetHttpHttpUrlEncodedEntity.cpp [new file with mode: 0644]
src/http/FNetHttpHttpXmlDomEntity.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpAuthenticationImpl.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpCommon.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpCookieImpl.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpCookieStorageManagerImpl.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpCurl.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpCurl.h [new file with mode: 0644]
src/http/FNetHttp_HttpDeleter.h [new file with mode: 0644]
src/http/FNetHttp_HttpFilePart.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpFilePart.h [new file with mode: 0644]
src/http/FNetHttp_HttpHeaderImpl.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpManagedNetConnectionEventListenerImpl.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpManagedNetConnectionEventListenerImpl.h [new file with mode: 0644]
src/http/FNetHttp_HttpMultipartConverter.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpMultipartConverter.h [new file with mode: 0644]
src/http/FNetHttp_HttpMultipartEntityImpl.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpMultipleConnectionInfo.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpMultipleConnectionInfo.h [new file with mode: 0644]
src/http/FNetHttp_HttpNetConnectionEventListenerImpl.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpNetConnectionEventListenerImpl.h [new file with mode: 0644]
src/http/FNetHttp_HttpRequestImpl.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpResponseImpl.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpSessionImpl.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpSocketInfo.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpSocketInfo.h [new file with mode: 0644]
src/http/FNetHttp_HttpStringEntityImpl.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpStringPart.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpStringPart.h [new file with mode: 0644]
src/http/FNetHttp_HttpTransactionEvent.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpTransactionEvent.h [new file with mode: 0644]
src/http/FNetHttp_HttpTransactionEventArg.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpTransactionEventArg.h [new file with mode: 0644]
src/http/FNetHttp_HttpTransactionImpl.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpTransactionUserData.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpTransactionUserData.h [new file with mode: 0644]
src/http/FNetHttp_HttpUrlEncodedEntityImpl.cpp [new file with mode: 0644]
src/http/FNetHttp_HttpXmlDomEntityImpl.cpp [new file with mode: 0644]
src/inc/FNetHttp_HttpAuthenticationImpl.h [new file with mode: 0644]
src/inc/FNetHttp_HttpCommon.h [new file with mode: 0644]
src/inc/FNetHttp_HttpCookieImpl.h [new file with mode: 0644]
src/inc/FNetHttp_HttpCookieStorageManagerImpl.h [new file with mode: 0644]
src/inc/FNetHttp_HttpHeaderImpl.h [new file with mode: 0644]
src/inc/FNetHttp_HttpMultipartEntityImpl.h [new file with mode: 0644]
src/inc/FNetHttp_HttpRequestImpl.h [new file with mode: 0644]
src/inc/FNetHttp_HttpResponseImpl.h [new file with mode: 0644]
src/inc/FNetHttp_HttpSessionImpl.h [new file with mode: 0644]
src/inc/FNetHttp_HttpStringEntityImpl.h [new file with mode: 0644]
src/inc/FNetHttp_HttpTransactionImpl.h [new file with mode: 0644]
src/inc/FNetHttp_HttpUrlEncodedEntityImpl.h [new file with mode: 0644]
src/inc/FNetHttp_HttpXmlDomEntityImpl.h [new file with mode: 0644]
src/inc/FNetSock_IpMulticastRequestOptionImpl.h [new file with mode: 0644]
src/inc/FNetSock_LingerOptionImpl.h [new file with mode: 0644]
src/inc/FNetSock_SecureSocketImpl.h [new file with mode: 0644]
src/inc/FNetSock_SocketImpl.h [new file with mode: 0644]
src/inc/FNetSock_SocketTypes.h [new file with mode: 0644]
src/inc/FNetSock_SocketUtilityImpl.h [new file with mode: 0644]
src/inc/FNetWifi_ConnectivityIpcMessages.h [new file with mode: 0644]
src/inc/FNetWifi_ConnectivityIpcParamTraits.h [new file with mode: 0644]
src/inc/FNetWifi_IWifiDirectListener.h [new file with mode: 0644]
src/inc/FNetWifi_IWifiManagerEventListener.h [new file with mode: 0644]
src/inc/FNetWifi_IWifiProximityEventListener.h [new file with mode: 0644]
src/inc/FNetWifi_WifiBssInfoImpl.h [new file with mode: 0644]
src/inc/FNetWifi_WifiDirectDeviceImpl.h [new file with mode: 0644]
src/inc/FNetWifi_WifiDirectDeviceInfoImpl.h [new file with mode: 0644]
src/inc/FNetWifi_WifiDirectDeviceManagerImpl.h [new file with mode: 0644]
src/inc/FNetWifi_WifiDirectGroupClientImpl.h [new file with mode: 0644]
src/inc/FNetWifi_WifiDirectGroupInfoImpl.h [new file with mode: 0644]
src/inc/FNetWifi_WifiDirectGroupOwnerImpl.h [new file with mode: 0644]
src/inc/FNetWifi_WifiDirectUtility.h [new file with mode: 0644]
src/inc/FNetWifi_WifiManagerImpl.h [new file with mode: 0644]
src/inc/FNetWifi_WifiNetAccountInfoImpl.h [new file with mode: 0644]
src/inc/FNetWifi_WifiProximityManagerImpl.h [new file with mode: 0644]
src/inc/FNetWifi_WifiSecurityInfoImpl.h [new file with mode: 0644]
src/inc/FNetWifi_WifiSystemAdapter.h [new file with mode: 0644]
src/inc/FNetWifi_WifiUtility.h [new file with mode: 0644]
src/inc/FNet_ConnectivityIpcMessages.h [new file with mode: 0644]
src/inc/FNet_ConnectivityIpcParamTraits.h [new file with mode: 0644]
src/inc/FNet_Ip4AddressImpl.h [new file with mode: 0644]
src/inc/FNet_ManagedNetConnectionImpl.h [new file with mode: 0644]
src/inc/FNet_NetConnectionImpl.h [new file with mode: 0644]
src/inc/FNet_NetConnectionInfoImpl.h [new file with mode: 0644]
src/inc/FNet_NetConnectionManagerImpl.h [new file with mode: 0644]
src/inc/FNet_NetEndPointImpl.h [new file with mode: 0644]
src/inc/FNet_NetExporter.h [new file with mode: 0644]
src/inc/FNet_NetTypes.h [new file with mode: 0644]
src/sockets/FNetSockSecureSocket.cpp [new file with mode: 0644]
src/sockets/FNetSockSocket.cpp [new file with mode: 0644]
src/sockets/FNetSockSocketIpMulticastRequestOption.cpp [new file with mode: 0644]
src/sockets/FNetSockSocketLingerOption.cpp [new file with mode: 0644]
src/sockets/FNetSockSocketUtility.cpp [new file with mode: 0644]
src/sockets/FNetSock_IpMulticastRequestOptionImpl.cpp [new file with mode: 0644]
src/sockets/FNetSock_LingerOptionImpl.cpp [new file with mode: 0644]
src/sockets/FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.cpp [new file with mode: 0644]
src/sockets/FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.h [new file with mode: 0644]
src/sockets/FNetSock_SecureSocketEvent.cpp [new file with mode: 0644]
src/sockets/FNetSock_SecureSocketEvent.h [new file with mode: 0644]
src/sockets/FNetSock_SecureSocketEventArg.cpp [new file with mode: 0644]
src/sockets/FNetSock_SecureSocketEventArg.h [new file with mode: 0644]
src/sockets/FNetSock_SecureSocketImpl.cpp [new file with mode: 0644]
src/sockets/FNetSock_SecureSocketManagedNetConnectionEventListenerImpl.cpp [new file with mode: 0644]
src/sockets/FNetSock_SecureSocketManagedNetConnectionEventListenerImpl.h [new file with mode: 0644]
src/sockets/FNetSock_SocketCustomNetConnectionEventListenerImpl.cpp [new file with mode: 0644]
src/sockets/FNetSock_SocketCustomNetConnectionEventListenerImpl.h [new file with mode: 0644]
src/sockets/FNetSock_SocketDeleter.h [new file with mode: 0644]
src/sockets/FNetSock_SocketEvent.cpp [new file with mode: 0644]
src/sockets/FNetSock_SocketEvent.h [new file with mode: 0644]
src/sockets/FNetSock_SocketEventArg.cpp [new file with mode: 0644]
src/sockets/FNetSock_SocketEventArg.h [new file with mode: 0644]
src/sockets/FNetSock_SocketImpl.cpp [new file with mode: 0644]
src/sockets/FNetSock_SocketInternalHelp.cpp [new file with mode: 0644]
src/sockets/FNetSock_SocketInternalHelp.h [new file with mode: 0644]
src/sockets/FNetSock_SocketManagedNetConnectionEventListenerImpl.cpp [new file with mode: 0644]
src/sockets/FNetSock_SocketManagedNetConnectionEventListenerImpl.h [new file with mode: 0644]
src/sockets/FNetSock_SocketUtilityImpl.cpp [new file with mode: 0644]
src/wifi/CMakeLists.txt [new file with mode: 0755]
src/wifi/FNetWifiWifiBssInfo.cpp [new file with mode: 0644]
src/wifi/FNetWifiWifiDirectDevice.cpp [new file with mode: 0644]
src/wifi/FNetWifiWifiDirectDeviceInfo.cpp [new file with mode: 0644]
src/wifi/FNetWifiWifiDirectDeviceManager.cpp [new file with mode: 0644]
src/wifi/FNetWifiWifiDirectGroupClient.cpp [new file with mode: 0644]
src/wifi/FNetWifiWifiDirectGroupInfo.cpp [new file with mode: 0644]
src/wifi/FNetWifiWifiDirectGroupMember.cpp [new file with mode: 0644]
src/wifi/FNetWifiWifiDirectGroupOwner.cpp [new file with mode: 0644]
src/wifi/FNetWifiWifiManager.cpp [new file with mode: 0644]
src/wifi/FNetWifiWifiNetAccountInfo.cpp [new file with mode: 0644]
src/wifi/FNetWifiWifiSecurityInfo.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiBssInfoImpl.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectDeviceEvent.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectDeviceEvent.h [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectDeviceImpl.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectDeviceInfoImpl.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectDeviceManagerImpl.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectEvent.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectEvent.h [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectEventArg.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectEventArg.h [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectGroupClientEvent.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectGroupClientEvent.h [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectGroupClientImpl.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectGroupInfoImpl.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectGroupOwnerEvent.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectGroupOwnerEvent.h [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectGroupOwnerImpl.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectSystemAdapter.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectSystemAdapter.h [new file with mode: 0644]
src/wifi/FNetWifi_WifiDirectUtility.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiIpcMessages.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiIpcProxy.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiIpcProxy.h [new file with mode: 0644]
src/wifi/FNetWifi_WifiManagerEvent.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiManagerEvent.h [new file with mode: 0644]
src/wifi/FNetWifi_WifiManagerEventArg.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiManagerEventArg.h [new file with mode: 0644]
src/wifi/FNetWifi_WifiManagerImpl.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiNetAccountInfoImpl.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiProximityManagerImpl.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiSecurityInfoImpl.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiSystemAdapter.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiSystemMonitoringEvent.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiSystemMonitoringEvent.h [new file with mode: 0644]
src/wifi/FNetWifi_WifiSystemMonitoringEventArg.cpp [new file with mode: 0644]
src/wifi/FNetWifi_WifiSystemMonitoringEventArg.h [new file with mode: 0644]
src/wifi/FNetWifi_WifiUtility.cpp [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..89e0209
--- /dev/null
@@ -0,0 +1,49 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+## OUTPUT PATHS
+SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output/osp)
+
+
+## Disable build rpath 
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+IF(SBS OR OBS)
+ADD_DEFINITIONS("-D_EXCEPT_DEPENDENCY_")
+ENDIF(SBS OR OBS)
+
+IF(SBS)
+ADD_DEFINITIONS("-D_SBS_")
+ENDIF(SBS)
+
+## Set Assembly Compiler
+#SET(CMAKE_ASM_COMPILER "${CMAKE_C_COMPILER}")
+       
+SET(CMAKE_ASM_COMPILER_ARG1 "${CPPFLAGS} -c")
+ENABLE_LANGUAGE(ASM)
+       
+## LIBRARY PATH
+LINK_DIRECTORIES (${LIBRARY_OUTPUT_PATH})
+
+ADD_SUBDIRECTORY(src)
+ADD_SUBDIRECTORY(src/wifi)
+
+# pkgconfig file
+CONFIGURE_FILE(osp-net.pc.in ${CMAKE_SOURCE_DIR}/osp-net.pc @ONLY)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/osp-net.pc DESTINATION lib/pkgconfig)
+
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/ DESTINATION lib/osp
+               FILES_MATCHING PATTERN "*.so*" 
+               PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ                      
+                    GROUP_EXECUTE GROUP_READ
+                    WORLD_EXECUTE WORLD_READ)
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/debug/ DESTINATION lib/osp/debug 
+               FILES_MATCHING PATTERN "*"
+               PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ                                          
+                                       GROUP_EXECUTE GROUP_READ
+                                       WORLD_EXECUTE WORLD_READ)
+
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/inc/ DESTINATION include/osp FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/inc/ DESTINATION include/osp/net FILES_MATCHING PATTERN "*.h")
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100644 (file)
index 0000000..d645695
--- /dev/null
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/LICENSE.Flora b/LICENSE.Flora
new file mode 100644 (file)
index 0000000..9c95663
--- /dev/null
@@ -0,0 +1,206 @@
+Flora License
+
+Version 1.0, May, 2012
+
+http://floralicense.org/license/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction,
+and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by
+the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and
+all other entities that control, are controlled by, or are
+under common control with that entity. For the purposes of
+this definition, "control" means (i) the power, direct or indirect,
+to cause the direction or management of such entity,
+whether by contract or otherwise, or (ii) ownership of fifty percent (50%)
+or more of the outstanding shares, or (iii) beneficial ownership of
+such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity
+exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications,
+including but not limited to software source code, documentation source,
+and configuration files.
+
+"Object" form shall mean any form resulting from mechanical
+transformation or translation of a Source form, including but
+not limited to compiled object code, generated documentation,
+and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form,
+made available under the License, as indicated by a copyright notice
+that is included in or attached to the work (an example is provided
+in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form,
+that is based on (or derived from) the Work and for which the editorial
+revisions, annotations, elaborations, or other modifications represent,
+as a whole, an original work of authorship. For the purposes of this License,
+Derivative Works shall not include works that remain separable from,
+or merely link (or bind by name) to the interfaces of, the Work and
+Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original
+version of the Work and any modifications or additions to that Work or
+Derivative Works thereof, that is intentionally submitted to Licensor
+for inclusion in the Work by the copyright owner or by an individual or
+Legal Entity authorized to submit on behalf of the copyright owner.
+For the purposes of this definition, "submitted" means any form of
+electronic, verbal, or written communication sent to the Licensor or
+its representatives, including but not limited to communication on
+electronic mailing lists, source code control systems, and issue
+tracking systems that are managed by, or on behalf of, the Licensor
+for the purpose of discussing and improving the Work, but excluding
+communication that is conspicuously marked or otherwise designated
+in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity
+on behalf of whom a Contribution has been received by Licensor and
+subsequently incorporated within the Work.
+
+"Tizen Certified Platform" shall mean a software platform that complies
+with the standards set forth in the Compatibility Definition Document
+and passes the Compatibility Test Suite as defined from time to time
+by the Tizen Technical Steering Group and certified by the Tizen
+Association or its designated agent.
+
+2. Grant of Copyright License.  Subject to the terms and conditions of
+this License, each Contributor hereby grants to You a perpetual,
+worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the
+Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License.  Subject to the terms and conditions of
+this License, each Contributor hereby grants to You a perpetual,
+worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+(except as stated in this section) patent license to make, have made,
+use, offer to sell, sell, import, and otherwise transfer the Work
+solely as incorporated into a Tizen Certified Platform, where such
+license applies only to those patent claims licensable by such
+Contributor that are necessarily infringed by their Contribution(s)
+alone or by combination of their Contribution(s) with the Work solely
+as incorporated into a Tizen Certified Platform to which such
+Contribution(s) was submitted. If You institute patent litigation
+against any entity (including a cross-claim or counterclaim
+in a lawsuit) alleging that the Work or a Contribution incorporated
+within the Work constitutes direct or contributory patent infringement,
+then any patent licenses granted to You under this License for that
+Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution.  You may reproduce and distribute copies of the
+Work or Derivative Works thereof pursuant to the copyright license
+above, in any medium, with or without modifications, and in Source or
+Object form, provided that You meet the following conditions:
+
+  1. You must give any other recipients of the Work or Derivative Works
+     a copy of this License; and
+  2. You must cause any modified files to carry prominent notices stating
+     that You changed the files; and
+  3. You must retain, in the Source form of any Derivative Works that
+     You distribute, all copyright, patent, trademark, and attribution
+     notices from the Source form of the Work, excluding those notices
+     that do not pertain to any part of the Derivative Works; and
+  4. If the Work includes a "NOTICE" text file as part of its distribution,
+     then any Derivative Works that You distribute must include a readable
+     copy of the attribution notices contained within such NOTICE file,
+     excluding those notices that do not pertain to any part of
+     the Derivative Works, in at least one of the following places:
+     within a NOTICE text file distributed as part of the Derivative Works;
+     within the Source form or documentation, if provided along with the
+     Derivative Works; or, within a display generated by the Derivative Works,
+     if and wherever such third-party notices normally appear.
+     The contents of the NOTICE file are for informational purposes only
+     and do not modify the License.
+
+You may add Your own attribution notices within Derivative Works
+that You distribute, alongside or as an addendum to the NOTICE text
+from the Work, provided that such additional attribution notices
+cannot be construed as modifying the License. You may add Your own
+copyright statement to Your modifications and may provide additional or
+different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works
+as a whole, provided Your use, reproduction, and distribution of
+the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+any Contribution intentionally submitted for inclusion in the Work
+by You to the Licensor shall be under the terms and conditions of
+this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify
+the terms of any separate license agreement you may have executed
+with Licensor regarding such Contributions.
+
+6. Trademarks.  This License does not grant permission to use the trade
+names, trademarks, service marks, or product names of the Licensor,
+except as required for reasonable and customary use in describing the
+origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+agreed to in writing, Licensor provides the Work (and each
+Contributor provides its Contributions) on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+implied, including, without limitation, any warranties or conditions
+of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+PARTICULAR PURPOSE. You are solely responsible for determining the
+appropriateness of using or redistributing the Work and assume any
+risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+whether in tort (including negligence), contract, or otherwise,
+unless required by applicable law (such as deliberate and grossly
+negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special,
+incidental, or consequential damages of any character arising as a
+result of this License or out of the use or inability to use the
+Work (including but not limited to damages for loss of goodwill,
+work stoppage, computer failure or malfunction, or any and all
+other commercial damages or losses), even if such Contributor
+has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+the Work or Derivative Works thereof, You may choose to offer,
+and charge a fee for, acceptance of support, warranty, indemnity,
+or other liability obligations and/or rights consistent with this
+License. However, in accepting such obligations, You may act only
+on Your own behalf and on Your sole responsibility, not on behalf
+of any other Contributor, and only if You agree to indemnify,
+defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason
+of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Flora License to your work
+
+To apply the Flora License to your work, attach the following
+boilerplate notice, with the fields enclosed by brackets "[]"
+replaced with your own identifying information. (Don't include
+the brackets!) The text should be enclosed in the appropriate
+comment syntax for the file format. We also recommend that a
+file or class name and description of purpose be included on the
+same "printed page" as the copyright notice for easier
+identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Flora License, Version 1.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://floralicense.org/license/
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..7295705
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,9 @@
+Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
+
+Several source codes may have its original copyright owner and/or
+be licensed under other than Apache License, Version 2, say, Flora License, Version 1.
+Please, see copyright and license comments section in the header of each file,
+and the LICENSE.Flora for Flora License terms and conditions.
+
diff --git a/inc/FNet.h b/inc/FNet.h
new file mode 100644 (file)
index 0000000..517d054
--- /dev/null
@@ -0,0 +1,82 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNet.h
+ * @brief              This is the header file for the %Net namespace.
+ *
+ * This header file contains the declarations and descriptions of the %Net namespace.
+ */
+
+#ifndef _FNET_H_
+#define _FNET_H_
+
+#include <FNetNetTypes.h>
+#include <FNetIpAddress.h>
+#include <FNetIp4Address.h>
+#include <FNetNetEndPoint.h>
+#include <FNetNetAccountInfo.h>
+#include <FNetNetAccountManager.h>
+#include <FNetNetConnectionInfo.h>
+#include <FNetINetConnectionEventListener.h>
+#include <FNetNetConnection.h>
+#include <FNetIManagedNetConnectionEventListener.h>
+#include <FNetManagedNetConnection.h>
+#include <FNetNetConnectionManager.h>
+#include <FNetNetStatistics.h>
+#include <FNetIpHostEntry.h>
+#include <FNetIDnsEventListener.h>
+#include <FNetDns.h>
+#include <FNetDhcpClientInfo.h>
+#include <FNetILocalDhcpServerEventListener.h>
+#include <FNetLocalDhcpServer.h>
+
+#include <FNetSockets.h>
+#include <FNetHttp.h>
+#include <FNetWifi.h>
+#ifndef _EXCEPT_DEPENDENCY_
+#include <FNetBluetooth.h>
+#include <FNetNfc.h>
+#endif
+
+namespace Tizen
+{
+/**
+ * @namespace  Tizen::Net
+ * @brief              This namespace contains the classes and interfaces for network account, connection, and addressing utilities.
+ * @since 2.0
+ *
+ * @remarks     @b Header @b %file: @b \#include @b <FNet.h> @n
+ *                             @b Library : @b osp-net @n
+ *
+ * The %Net namespace contains the different classes for the %Net namespace. @n
+ *
+ * This namespace helps to access the data communication capabilities of Tizen. It is responsible for managing connections and
+ *                             accounts, and maintaining IP addresses and connections to the system through %Bluetooth, Hypertext Transfer Protocol (HTTP), Near Field
+ *                             Communication (NFC), %Sockets, and Wi-Fi. It also provides methods for retrieving information about a specific host from the Internet Domain
+ *                             Name %System (DNS).
+ * @n
+ * For more information on the %Net namespace features, see <a href="../org.tizen.native.appprogramming/html/guide/net/net_namespace.htm">Net Guide</a>.
+ *
+ * The following diagram illustrates the relationships between the classes belonging to the %Net namespace.
+ * @image html net_using_the_apis_classdiagram.png
+ *
+ */
+namespace Net
+{
+} } // Tizen::Net
+#endif // _FNET_H_
diff --git a/inc/FNetDhcpClientInfo.h b/inc/FNetDhcpClientInfo.h
new file mode 100644 (file)
index 0000000..1d4423a
--- /dev/null
@@ -0,0 +1,138 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetDhcpClientInfo.h
+ * @brief              This is the header file for the %DhcpClientInfo class.
+ *
+ * This header file contains the declarations of the %DhcpClientInfo class.
+ */
+#ifndef _FNET_DHCP_CLIENT_INFO_H_
+#define _FNET_DHCP_CLIENT_INFO_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FNetIpAddress.h>
+
+namespace Tizen { namespace Net
+{
+class _DhcpClientInfoImpl;
+
+/**
+ * @class      DhcpClientInfo
+ * @brief      This class represents a client information on the local Dynamic Host Configuration Protocol (DHCP) server.
+ *
+ * @since      2.0
+ *
+ * The %DhcpClientInfo class provides functionality for getting information on the local DHCP server.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/local_DHCP_server_access.htm">Local DHCP Server Access</a>.
+ */
+class _OSP_EXPORT_ DhcpClientInfo
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~DhcpClientInfo(void);
+
+public:
+       /**
+        * Gets the name of the DHCP client device.
+        *
+        * @since               2.0
+        *
+        * @return              The name of the DHCP client device, @n
+        *                              else a null string if the name is not set or not constructed
+        */
+       Tizen::Base::String GetName(void) const;
+
+       /**
+        * Gets the IP address of the DHCP client device.
+        *
+        * @since               2.0
+        *
+        * @return              The IpAddress pointer
+        * @remarks             This method returns a dynamically assigned IP address.
+        */
+       const IpAddress* GetIpAddress(void) const;
+
+       /**
+        * Gets the MAC address of the DHCP client device.
+        *
+        * @since               2.0
+        *
+        * @return              The MAC address in the form '00-00-00-00-00-00'
+        * @remarks     In case of the Wi-Fi Direct bearer type, the MAC address is virtual and is used only for the frame packetization.
+        *              This MAC address is different from the MAC address provided by the WifiManager or the WifiDirectDevice class.
+        */
+       Tizen::Base::String GetMacAddress(void) const;
+
+       /**
+        * Compares the specified instance of %DhcpClientInfo with the calling instance.
+        *
+        * @since               2.0
+        *
+        * @return              @c true if the values match, @n
+        *                          else @c false
+        * @param[in]   rhs     The other Object to compare
+        * @see                 Object::Equals()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since               2.0
+        *
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+private:
+       /*
+        * This default constructor is intentionally declared as private so that only the platform can create an instance.
+        */
+       DhcpClientInfo(void);
+
+       /*
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]    rhs    An instance of %DhcpClientInfo
+        */
+       DhcpClientInfo(const DhcpClientInfo& rhs);
+
+       /*
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs             An instance of %DhcpClientInfo
+        */
+       DhcpClientInfo& operator =(const DhcpClientInfo& rhs);
+
+private:
+       _DhcpClientInfoImpl* __pDhcpClientInfoImpl;
+
+       friend class _DhcpClientInfoImpl;
+}; // DhcpClientInfo
+
+} } //Tizen::Net
+
+#endif // _FNET_DHCP_CLIENT_INFO_H_
diff --git a/inc/FNetDns.h b/inc/FNetDns.h
new file mode 100755 (executable)
index 0000000..ab68924
--- /dev/null
@@ -0,0 +1,173 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetDns.h
+ * @brief              This is the header file for the %Dns class.
+ *
+ * This header file contains the declarations of the %Dns class.
+ */
+#ifndef _FNET_DNS_H_
+#define _FNET_DNS_H_
+
+#include <FBaseResult.h>
+#include <FNetIpAddress.h>
+#include <FNetIpHostEntry.h>
+#include <FNetNetConnection.h>
+#include <FNetIDnsEventListener.h>
+
+namespace Tizen { namespace Net
+{
+class _DnsImpl;
+
+/**
+ * @class      Dns
+ * @brief      This class provides a way to access the resolver of the Domain Name %System.
+ *
+ * @since      2.0
+ *
+ * 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()
+ *                     and GetHostByName() methods. The %GetHostByAddress() method represents a request for the DNS information about a host, while the %GetHostByName()
+ *                     method represents a request for the DNS host information for an IP address. Both requests can be made in an asynchronous mode.
+ *
+ * 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>.
+ */
+class _OSP_EXPORT_ Dns
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * 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.
+        *
+        * @since               2.0
+        *
+        * @remarks             After creating an instance of this class, one of the Construct() methods must be called explicitly to initialize this instance.
+        */
+       Dns(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since                       2.0
+        */
+       virtual ~Dns(void);
+
+       /**
+        * Initializes this instance of %Dns with the specified parameters.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   netConnection                   A NetConnection on which the DNS request executes
+        * @param[in]   listener                                A reference to IDnsEventListener
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified @c netConnection contains an invalid value.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                An internal error has occurred.
+        * @exception   E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation, @n
+        *                                                                              because the caller thread is a worker thread.
+        */
+       result Construct(const NetConnection& netConnection, IDnsEventListener& listener);
+
+       /**
+        * Initializes this instance of %Dns with the specified listener.
+        *
+     * @since          2.0
+        *
+        * @return              An error code
+        * @param[in]   listener                                A reference to IDnsEventListener
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_CONNECTION    The network connection is invalid.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                An internal error has occurred.
+        * @exception   E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation, @n
+        *                                                                              because the caller thread is a worker thread.
+        */
+       result Construct(IDnsEventListener& listener);
+
+public:
+       /**
+        * Requests a DNS lookup by host name. @n
+        * This method is asynchronous.
+        *
+        * @since               2.0
+        * @privilege   %http://tizen.org/privilege/dns
+        *
+        * @return              An error code
+        * @param[in]   hostName                                The DNS name of the host
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_INVALID_CONNECTION    The network connection is invalid.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_NETWORK_UNAVAILABLE   The network is unavailable.
+        * @exception   E_CONNECTION_FAILED             The network connection has failed.
+        * @exception   E_OPERATION_FAILED              Requested but an error is received while waiting for the response.
+        * @exception   E_SYSTEM                                An internal error has occurred.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        *
+        * @remarks             Only one query is processed at a time in this instance.
+        *              Multiple queries may be discarded.
+        */
+       result GetHostByName(const Tizen::Base::String& hostName);
+
+       /**
+        * Requests a DNS lookup by IP address. @n
+        * This method is asynchronous.
+        *
+        * @since               2.0
+        * @privilege   %http://tizen.org/privilege/dns
+        *
+        * @return              An error code
+        * @param[in]   ipAddress                               An IP address
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_INVALID_CONNECTION    The network connection is invalid.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_NETWORK_UNAVAILABLE   The network is unavailable.
+        * @exception   E_CONNECTION_FAILED             The network connection has failed.
+        * @exception   E_OPERATION_FAILED              Requested but an error is received while waiting for the response.
+        * @exception   E_SYSTEM                                An internal error has occurred.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @remarks             Only one query is processed at a time in this instance.
+        *              Multiple queries may be discarded.
+        */
+       result GetHostByAddress(const IpAddress& ipAddress);
+
+private:
+       /*
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %Dns
+        */
+       Dns(const Dns& rhs);
+
+       /*
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %Dns
+        */
+       Dns& operator =(const Dns& rhs);
+
+private:
+       _DnsImpl* __pDnsImpl;
+
+       friend class _DnsImpl;
+}; // Dns
+
+} } //Tizen::Net
+
+#endif // _FNET_DNS_H_
diff --git a/inc/FNetHttp.h b/inc/FNetHttp.h
new file mode 100755 (executable)
index 0000000..25dac08
--- /dev/null
@@ -0,0 +1,77 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp.h
+ * @brief              This is the header file for the %Http namespace.
+ *
+ * This header file contains the declarations and descriptions of the %Http namespace.
+ */
+
+#ifndef _FNET_HTTP_H_
+#define _FNET_HTTP_H_
+
+#include "FNetHttpHttpTypes.h"
+#include "FNetHttpHttpHeader.h"
+#include "FNetHttpHttpMessage.h"
+#include "FNetHttpHttpRequest.h"
+#include "FNetHttpHttpResponse.h"
+#include "FNetHttpHttpSession.h"
+#include "FNetHttpHttpCookieStorageManager.h"
+#include "FNetHttpHttpTransaction.h"
+#include "FNetHttpIHttpTransactionEventListener.h"
+#include "FNetHttpHttpAuthentication.h"
+#include "FNetHttpHttpCookie.h"
+#include "FNetHttpHttpCredentials.h"
+#include "FNetHttpIHttpEntity.h"
+#include "FNetHttpHttpMultipartEntity.h"
+#include "FNetHttpHttpStringEntity.h"
+#include "FNetHttpHttpUrlEncodedEntity.h"
+#include "FNetHttpHttpXmlDomEntity.h"
+#include "FNetHttpIHttpProgressEventListener.h"
+
+
+namespace Tizen { namespace Net
+{
+/**
+ * @namespace  Tizen::Net::Http
+ * @brief              This namespace contains the classes and interfaces for the HTTP 1.1 client programming.
+ * @since       2.0
+ *
+ * @remarks     @b Header @b %file: @b \#include @b <FNet.h> @n
+ *                         @b Library : @b osp-net
+ *
+ * The %Http namespace contains the fundamental classes and interfaces for the HTTP 1.1 client programming.
+ *
+ * It provides the implementation of the HTTP data communication protocol. This namespace provides:
+ * - A client interface for the internet applications using the HTTP protocol for communication with the HTTP servers on the Internet.
+ * - A HTTP management module that encapsulates a standard HTTP request-and-response transaction and provides access to the common HTTP headers.
+ * - Support for most HTTP 1.1 features, including pipelining and chunking.
+ *
+ * Using this namespace correctly, makes the application a conditional HTTP 1.1-compliant client, as defined in RFC 2616.
+ *
+ * For more information on the HTTP namespace features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_connectivity.htm">HTTP Guide</a>.
+ *
+ * The following diagram illustrates the relationships between the classes belonging to the %Net namespace.
+ * @image      html    net_http_using_the_apis_classdiagram.png
+ *
+ *
+ */
+namespace Http
+{
+} } } //       Tizen::Net::Http
+#endif // _FNET_HTTP_H_
diff --git a/inc/FNetHttpHttpAuthentication.h b/inc/FNetHttpHttpAuthentication.h
new file mode 100755 (executable)
index 0000000..23b2d54
--- /dev/null
@@ -0,0 +1,168 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpAuthentication.h
+ * @brief              This is the header file for the %HttpAuthentication class.
+ *
+ * This header file contains the declarations of the %HttpAuthentication class.
+ */
+
+#ifndef _FNET_HTTP_HTTP_AUTHENTICATION_H_
+#define _FNET_HTTP_HTTP_AUTHENTICATION_H_
+
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpHttpHeader.h>
+#include <FNetHttpHttpMessage.h>
+#include <FNetHttpHttpCredentials.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpTransaction;
+class _HttpAuthenticationImpl;
+
+/**
+ * @class      HttpAuthentication
+ * @brief      This class encapsulates an HTTP authentication.
+ *
+ * @since      2.0
+ *
+ * The %HttpAuthentication class encapsulates the HTTP authentication activity of the client over the duration of a single transaction.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_connectivity.htm">HTTP Guide</a>.
+ *
+ * The following example demonstrates how to use the %HttpAuthentication class.
+ *
+ * @code
+
+#include <FBase.h>
+#include <FNet.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Net::Http;
+
+void
+MyTransactionEventListener::OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool authRequired)
+{
+       if (authRequired)
+       {
+               HttpAuthentication* pAuth = httpTransaction.OpenAuthenticationInfoN();
+               String basicName("Name");
+               String basicpass("Pass");
+               HttpCredentials* pCredential = new HttpCredentials(basicName, basicpass);
+               String* pRealm = pAuth->GetRealmN();
+               NetHttpAuthScheme scheme = pAuth->GetAuthScheme();
+               if (scheme == NET_HTTP_AUTH_WWW_BASIC || scheme == NET_HTTP_AUTH_PROXY_BASIC)
+               {
+                       HttpTransaction* pNewTransaction =  pAuth->SetCredentials(*pCredential);
+               }
+       }
+}
+
+ * @endcode
+ */
+class _OSP_EXPORT_ HttpAuthentication
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since                       2.0
+        */
+       ~HttpAuthentication(void);
+
+       /**
+        * Gets the realm value received.
+        *
+        * @since                       2.0
+        * @privilege           %http://tizen.org/privilege/http
+        *
+        * @return                      The realm value
+        * @exception           E_SUCCESS                       The method is successful.
+        * @exception           E_OUT_OF_MEMORY     The memory is insufficient.
+        * @exception           E_SYSTEM            A system error has occurred.
+        * @exception           E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::String* GetRealmN(void) const;
+
+       /**
+        * Gets the authentication scheme received.
+        *
+        * @since                       2.0
+        * @privilege           %http://tizen.org/privilege/http
+        *
+        * @return                      The authentication scheme, @n
+        *                                      else @c -1 if an error occurs
+        * @exception           E_SUCCESS                       The method is successful.
+        * @exception           E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception           E_SYSTEM                        A system error has occurred.
+        * @exception           E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       NetHttpAuthScheme GetAuthScheme(void) const;
+
+       /**
+        * Sets the credentials required for setting the "WWW-Authenticate" header in the HttpRequest class.
+        *
+        * @since                       2.0
+        * @privilege           %http://tizen.org/privilege/http
+        *
+        * @return                      The new transaction pointer
+        * @param[in]           credentials                             The credentials
+        * @exception           E_SUCCESS                               The method is successful.
+        * @exception           E_INVALID_STATE                 The method invoked is invalid.
+        * @exception           E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception           E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception           E_SYSTEM                                A system error has occurred.
+        * @exception           E_AUTHENTICATION                The authentication has failed.
+        * @exception           E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @remarks                     This method is used to set the username and password for the given domain and the authentication
+        *                                      scheme on the reception of the IHttpTransactionEventListener::OnTransactionHeaderCompleted() callback.
+        *                                      The specific error code can be accessed using the GetLastResult() method.
+        */
+       HttpTransaction* SetCredentials(HttpCredentials& credentials);
+
+private:
+       /**
+        * This default constructor is intentionally declared as private so that only the platform can create an instance.
+        */
+       HttpAuthentication(void);
+
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs     An instance of %HttpAuthentication
+        */
+       HttpAuthentication(const HttpAuthentication& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]           rhs                             An instance of %HttpAuthentication
+        */
+       HttpAuthentication& operator =(const HttpAuthentication& rhs);
+
+private:
+       _HttpAuthenticationImpl* __pHttpAuthenticationImpl;
+       friend class _HttpAuthenticationImpl;
+
+}; // HttpAuthentication
+
+} } } //Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_AUTHENTICATION_H_
diff --git a/inc/FNetHttpHttpCookie.h b/inc/FNetHttpHttpCookie.h
new file mode 100755 (executable)
index 0000000..a25567f
--- /dev/null
@@ -0,0 +1,252 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpCookie.h
+ * @brief              This is the header file for the %HttpCookie class.
+ *
+ * This header file contains the declarations of the %HttpCookie class.
+ */
+
+#ifndef _FNET_HTTP_HTTP_COOKIE_H_
+#define _FNET_HTTP_HTTP_COOKIE_H_
+
+#include <FBaseUtil.h>
+#include <FBaseColArrayList.h>
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpHttpHeader.h>
+#include <FNetHttpHttpMessage.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpCookieImpl;
+/**
+ * @class      HttpCookie
+ * @brief      This class provides a %Http cookie.
+ *
+ * @since      2.0
+ *
+ * The %HttpCookie class provides a %Http cookie. The %HttpCookie instance encapsulates the cookie received by the server in a particular HttpResponse instance.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_connectivity.htm">HTTP Guide</a>.
+ *
+ * The following example demonstrates how to use the %HttpCookie class.
+ *
+ * @code
+
+#include <FBase.h>
+#include <FNet.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Net::Http;
+using namespace Tizen::Base::Collection;
+
+void
+MyTransactionEventListener::OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool bAuthRequired)
+{
+       IList* pCookieList = null;
+       HttpCookie* pCookie = null;
+       HttpTransaction* pTransaction = const_cast<HttpTransaction*>(&(httpTransaction));
+       HttpResponse* pResponse = pTransaction->GetResponse();
+       HttpHeader* pHeader = pResponse->GetHeader();
+
+       String* pRawHeader = null;
+       pRawHeader = pHeader->GetRawHeaderN();
+
+       pCookieList = pResponse->GetCookies();
+       for (int i = 0; i < pCookieList->GetCount(); i++)
+       {
+               pCookie = static_cast<HttpCookie*>(pCookieList->GetAt(i));
+               String domain = pCookie->GetDomain();
+               String version = pCookie->GetVersion();
+               String path = pCookie->GetPath();
+               String expire = pCookie->GetExpires();
+               String cookieName = pCookie->GetCookieName();
+               String cookieValue = pCookie->GetCookieValue();
+       }
+
+       delete pRawHeader;
+}
+
+ * @endcode
+ */
+class _OSP_EXPORT_ HttpCookie
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+       * Gets the domain name of the cookie.
+       *
+       * @since                2.0
+       *
+       * @return      The domain name of the cookie, @n
+       *                               else an empty string if no domain name is received in the cookie
+       */
+       Tizen::Base::String GetDomain(void) const;
+
+       /**
+       * Gets the path name of the cookie.
+       *
+       * @since                2.0
+       *
+       * @return      The path name of the cookie, @n
+       *                               else an empty string if no path name is received in the cookie
+       */
+       Tizen::Base::String GetPath(void) const;
+
+       /**
+       * Gets the version of the cookie.
+       *
+       * @since                2.0
+       *
+       * @return      The version of the cookie, @n
+       *                               else an empty string if no version is received in the cookie
+       */
+       Tizen::Base::String GetVersion(void) const;
+
+       /**
+       * Gets the expiration date and time of the cookie.
+       *
+       * @since                2.0
+       *
+       * @return      The expiration date and time of the cookie, @n
+       *                               else an empty string if no expiration date and time is received in the cookie
+       */
+       Tizen::Base::String GetExpires(void) const;
+
+       /**
+       * Checks whether the cookie is secured.
+       *
+       * @since                2.0
+       *
+       * @return      @c true if the cookie is secured, @n
+       *                               else @c false
+       */
+       bool IsSecure(void) const;
+
+       /**
+       * Gets the name of the cookie.
+       *
+       * @since                2.0
+       *
+       * @return      The name of the cookie
+       */
+       Tizen::Base::String GetCookieName(void) const;
+
+       /**
+       * Gets the value of the cookie.
+       *
+       * @since                2.0
+       *
+       * @return      The value of the cookie
+       */
+       Tizen::Base::String GetCookieValue(void) const;
+
+       /**
+       * Gets the comment URL of the cookie.
+       *
+       * @since                2.0
+       *
+       * @return      The comment URL of the cookie, @n
+       *                               else an empty string if no comment URL is received in the cookie
+       */
+       Tizen::Base::String GetCommentUrl(void) const;
+
+       /**
+       * Gets the comment on the cookie.
+       *
+       * @since                2.0
+       *
+       * @return               The comment on the cookie, @n
+       *                               else an empty string if no comment is received in the cookie
+       */
+       Tizen::Base::String GetComment(void) const;
+
+       /**
+       * Checks whether the 'HttpOnly' flag is set in the cookie.
+       *
+       * @since                2.0
+       *
+       * @return               @c true if the 'HttpOnly' flag is set, @n
+       *                               else @c false
+       */
+       bool IsHttpOnly(void) const;
+
+       /**
+       * Gets the port list.
+       *
+       * @since                2.0
+       *
+       * @return               The port list, which is a comma separated series of digits, @n
+       *                               else an empty string if no port list is received
+       */
+       Tizen::Base::String GetPorts(void) const;
+
+       /**
+       * Gets the maximum age of the cookie.
+       *
+       * @since                2.0
+       *
+       * @return      The maximum age of the cookie, @n
+       *                               else @c -1 if no maximum age is received in the cookie
+       */
+       int GetMaxAge(void) const;
+
+       /**
+       * Checks whether the 'Discard' flag is set in the cookie.
+       *
+       * @since                2.0
+       *
+       * @return      @c true if the 'Discard' flag is set, @n
+       *                                       else @c false
+       */
+       bool GetDiscard(void) const;
+
+private:
+       /**
+        * This default constructor is intentionally declared as private so that only the platform can create an instance.
+        */
+       HttpCookie(void);
+
+       /**
+        * This destructor is intentionally declared as private so that only the platform can delete an instance.
+        */
+       ~HttpCookie(void);
+
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs             An instance of %HttpCookie
+        */
+       HttpCookie(const HttpCookie& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %HttpCookie
+        */
+       HttpCookie& operator =(const HttpCookie& rhs);
+
+private:
+       friend class _HttpCookieImpl;
+       _HttpCookieImpl* __pHttpCookieImpl;
+
+}; // HttpCookie
+
+} } } //Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_COOKIE_H_
diff --git a/inc/FNetHttpHttpCookieStorageManager.h b/inc/FNetHttpHttpCookieStorageManager.h
new file mode 100755 (executable)
index 0000000..ac33e37
--- /dev/null
@@ -0,0 +1,129 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpCookieStorageManager.h
+ * @brief              This is the header file for the %HttpCookieStorageManager class.
+ *
+ * This header file contains the declarations of the %HttpCookieStorageManager class.
+ */
+
+#ifndef _FNET_HTTP_HTTP_COOKIE_STORAGE_MANAGER_H_
+#define _FNET_HTTP_HTTP_COOKIE_STORAGE_MANAGER_H_
+
+#include <FBaseResult.h>
+#include <FNetHttpHttpTypes.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpSession;
+class _HttpCookieStorageManagerImpl;
+/**
+ * @class      HttpCookieStorageManager
+ * @brief      This class provides a collection of %Http cookies of a particular session.
+ *
+ * @since   2.0
+ *
+ * The %HttpCookieStorageManager class instance encapsulates the cookies received by the client in this particular session.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_connectivity.htm">HTTP Guide</a>.
+ */
+class _OSP_EXPORT_ HttpCookieStorageManager
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * Gets the string to be used in the cookie header of the request corresponding to the requested URL.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   url                                     The request URL
+        * @param[out]  cookies                         The cookie header value @n
+        *                                                          For example, cookie-name1=cookie-value1;cookie-name2=cookie-value2.
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c cookies is an empty string.
+        * @exception   E_INVALID_STATE         The method invoked is invalid.
+        */
+       result GetCookies(const Tizen::Base::String& url, Tizen::Base::String& cookies) const;
+
+       /**
+        * Removes all the cookies corresponding to the requested URL from the cookie storage.
+        *
+        * @since               2.0
+        * @privilege   %http://tizen.org/privilege/http
+        *
+        * @return              An error code
+        * @param[in]   url                                             The requested URL
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified @c url is an empty string.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        */
+       result RemoveCookies(const Tizen::Base::String& url);
+
+       /**
+        * Removes all the cookies from the cookie storage.
+        *
+        * @since               2.0
+        * @privilege   %http://tizen.org/privilege/http
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        */
+       result RemoveAllCookies();
+
+private:
+       /**
+        * This default constructor is intentionally declared as private so that only the platform can create an instance.
+        */
+       HttpCookieStorageManager();
+
+       /**
+        * This default constructor is intentionally declared as private so that only the platform can delete an instance.
+        */
+       ~HttpCookieStorageManager();
+
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs   An instance of %HttpCookieStorageManager
+        */
+       HttpCookieStorageManager(const HttpCookieStorageManager& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs             An instance of %HttpCookieStorageManager
+        */
+       HttpCookieStorageManager& operator =(const HttpCookieStorageManager& rhs);
+
+private:
+       friend class _HttpCookieStorageManagerImpl;
+       _HttpCookieStorageManagerImpl* __pHttpCookieStorageManagerImpl;
+
+}; // HttpCookieStorageManager
+
+} } } //Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_COOKIE_STORAGE_MANAGER_H_
diff --git a/inc/FNetHttpHttpCredentials.h b/inc/FNetHttpHttpCredentials.h
new file mode 100755 (executable)
index 0000000..f00e517
--- /dev/null
@@ -0,0 +1,183 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpCredentials.h
+ * @brief              This is the header file for the %HttpCredentials class.
+ *
+ * This header file contains the declarations of the %HttpCredentials class.
+ */
+
+#ifndef _FNET_HTTP_HTTP_CREDENTIALS_H_
+#define _FNET_HTTP_HTTP_CREDENTIALS_H_
+
+#include <FNetHttpHttpTypes.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+/////////////////////////////////////////////////////////////////////////////
+/**
+ * @class      HttpCredentials
+ * @brief      This class represents the credentials required for authentication.
+ *
+ * @since   2.0
+ *
+ * The %HttpCredentials class represents the credentials required for authentication, that is, the user name and password.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_connectivity.htm">HTTP Guide</a>.
+ */
+//////////////////////////////////////////////////////////////////////////
+class _OSP_EXPORT_ HttpCredentials
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       2.0
+        */
+       HttpCredentials(void);
+
+       /**
+        * Initializes an instance of %HttpCredentials with the specified user name and password.
+        *
+        * @since       2.0
+        *
+        * @param[in]   name                            The user name string
+        * @param[in]   password                        The password string
+        */
+       HttpCredentials(const Tizen::Base::String& name, const Tizen::Base::String& password);
+
+       /**
+       * Copying of objects using this copy constructor is allowed.
+       *
+       * @since        2.0
+       *
+       * @param[in]    rhs     An instance of %HttpCredentials
+       */
+       HttpCredentials(const HttpCredentials& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~HttpCredentials(void);
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs             An instance of %HttpCredentials
+        */
+       HttpCredentials& operator =(const HttpCredentials& rhs);
+
+       /**
+        * Sets the user name for the current instance of %HttpCredentials.
+        *
+        * @since       2.0
+        * @privilege   %http://tizen.org/privilege/http
+        *
+        * @param[in]   name                            The user name string
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified input parameter is invalid.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        */
+       result SetName(const Tizen::Base::String& name);
+
+       /**
+        * Sets the password for the current instance of %HttpCredentials.
+        *
+        * @since       2.0
+        * @privilege   %http://tizen.org/privilege/http
+        *
+        * @param[in]   password                        The password string
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified input parameter is invalid.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        */
+       result SetPassword(const Tizen::Base::String& password);
+
+       /**
+        * Gets the user name of the current instance of %HttpCredentials.
+        *
+        * @since       2.0
+        * @privilege   %http://tizen.org/privilege/http
+        *
+        * @return                      The user name
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::String GetName(void) const;
+
+       /**
+        * Gets the password of the current instance of %HttpCredentials.
+        *
+        * @since       2.0
+        * @privilege   %http://tizen.org/privilege/http
+        *
+        * @return                      The password
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::String GetPassword(void) const;
+
+       /**
+        * Compares the specified instance of %HttpCredentials with the calling instance.
+        *
+        * @since               2.0
+        *
+        * @return              @c true if the values match, @n
+        *                          else @c false
+        * @param[in]   rhs     The other Tizen::Base::Object to compare
+        * @see         Tizen::Base::Object::Equals()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since               2.0
+        *
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+private:
+       Tizen::Base::String __userName;
+       Tizen::Base::String __password;
+
+       friend class HttpCredentialsImpl;
+       class HttpCredentialsImpl* __pHttpCredentialsImpl;
+
+}; // HttpCredentials
+
+} } } //Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_CREDENTIALS_H_
diff --git a/inc/FNetHttpHttpHeader.h b/inc/FNetHttpHttpHeader.h
new file mode 100755 (executable)
index 0000000..2842e03
--- /dev/null
@@ -0,0 +1,213 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpHeader.h
+ * @brief              This is the header file for the %HttpHeader class.
+ *
+ * This header file contains the declarations of the %HttpHeader class.
+ */
+
+#ifndef _FNET_HTTP_HTTP_HEADER_H_
+#define _FNET_HTTP_HTTP_HEADER_H_
+
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseColMultiHashMap.h>
+#include <FBaseColIEnumerator.h>
+#include <FNetHttpHttpTypes.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpHeaderImpl;
+/**
+ * @class      HttpHeader
+ * @brief      This class encapsulates the header fields associated with a message.
+ *
+ * @since      2.0
+ *
+ *  The %HttpHeader class is a collection of header fields associated with an HTTP message. The header fields can be added, read, modified, and
+ *     removed. Also, each field can have multiple values. This class provides easy access to the header.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_connectivity.htm">HTTP Guide</a>.
+ */
+
+class _OSP_EXPORT_ HttpHeader
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since           2.0
+        *
+        * @exception           E_SUCCESS                               The method is successful.
+        * @exception           E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       HttpHeader(void);
+
+       /**
+        * Initializes an instance of %HttpHeader with the values of the specified instance.
+        *
+        * @since       2.0
+        *
+        * @param[in]   pHeader                                 An instance of %HttpHeader
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @remarks             The parameter @c pHeader can be @c null.
+        *                              The specific error code can be accessed using the GetLastResult() method.
+        */
+       HttpHeader(const HttpHeader* pHeader);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~HttpHeader(void);
+
+public:
+       /**
+        * Adds a named field, which is a <@c fieldName, @c fieldValue> pair, to the current instance of %HttpHeader.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   fieldName                               A field name
+        * @param[in]   fieldValue                              A field value
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified @c fieldName is an empty string.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_OBJ_ALREADY_EXIST             The specified @c fieldName already exists. @n
+        *                                                                              The <@c fieldName, @c fieldValue> pair already exists.
+        * @remarks             The field is created on the first instance when this method is used for a particular field name.
+        *                              On subsequent calls, the same field is extended to have several parts, with a new part created to hold the supplied value.
+        *                              If you need to submit a request in the chunked mode, you need to explicitly add the header field named
+        *                              "Transfer-Encoding" with the value @c chunked. Otherwise, the non-chunked mode is used as the default value.
+        * @see                 RemoveField()
+        */
+       result AddField(const Tizen::Base::String& fieldName, const Tizen::Base::String& fieldValue);
+
+       /**
+        * Removes all the fields with the specified field name.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   fieldName                               The field name to remove
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified @c fieldName is an empty string.
+        * @exception   E_OBJ_NOT_FOUND                 The specified @c fieldName is not found in the current instance of %HttpHeader. @n
+        *                                                                              The header field with the specified @c fieldName is not found.
+        * @see                         AddField()
+        */
+       result RemoveField(const Tizen::Base::String& fieldName);
+
+       /**
+        * Removes only the specified <@c fieldName, @c fieldValue> pair from the current instance of %HttpHeader.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   fieldName                               The field name to remove
+        * @param[in]   fieldValue                              The field value to remove with the specified @c fieldName
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified @c fieldName is an empty string.
+        * @exception   E_OBJ_NOT_FOUND                 The specified @c fieldName is not found in the current instance of %HttpHeader. @n
+        *                                              The header field with the specified field name and field value is not found.
+        * @see                         AddField()
+        */
+       result RemoveField(const Tizen::Base::String& fieldName, const Tizen::Base::String& fieldValue);
+
+       /**
+        * Removes all the fields of the current instance of %HttpHeader.
+        *
+        * @since       2.0
+        */
+       void RemoveAll(void);
+
+       /**
+        * Gets a raw header string.
+        *
+        * @since           2.0
+        *
+        * @return                      A raw header string
+        * @exception           E_SUCCESS                               The method is successful.
+        * @exception           E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception           E_INVALID_HEADER                This header object does not contain any header field.
+        * @exception           E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::String* GetRawHeaderN(void) const;
+
+       /**
+        * Gets a list of all the field names in the current instance of %HttpHeader.
+        *
+        * @since           2.0
+        *
+        * @return                      A list that contains all the field names as string values
+        * @exception           E_SUCCESS                               The method is successful.
+        * @exception           E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception           E_INVALID_HEADER                This header object does not contain any header field.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetFieldNamesN(void) const;
+
+       /**
+        * Gets the field values corresponding to the specified field name.
+        *
+        * @since       2.0
+        *
+        * @return              An enumerator containing all the string values of the specified field name
+        * @param[in]   fieldName                               A field name
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified @c fieldName is an empty string.
+        * @exception   E_OBJ_NOT_FOUND                 The specified @c fieldName is not found in the current instance of %HttpHeader. @n
+        *                                                                              The header field with the specified @c fieldName is not found.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IEnumerator* GetFieldValuesN(const Tizen::Base::String& fieldName) const;
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs   An instance of %HttpHeader
+        */
+       HttpHeader(const HttpHeader& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @since       2.0
+        *
+        * @param[in]   rhs                     An instance of %HttpHeader
+        */
+       HttpHeader& operator =(const HttpHeader& rhs);
+
+private:
+       friend class _HttpHeaderImpl;
+       _HttpHeaderImpl* __pHttpHeaderImpl;
+
+}; // HttpHeader
+
+} } } //Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_HEADER_H_
diff --git a/inc/FNetHttpHttpMessage.h b/inc/FNetHttpHttpMessage.h
new file mode 100755 (executable)
index 0000000..ada299a
--- /dev/null
@@ -0,0 +1,177 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpMessage.h
+ * @brief              This is the header file for the %HttpMessage class.
+ *
+ * This header file contains the declarations of the %HttpMessage class.
+ */
+
+#ifndef _FNET_HTTP_HTTP_MESSAGE_H_
+#define _FNET_HTTP_HTTP_MESSAGE_H_
+
+#include <FBaseByteBuffer.h>
+#include <FBaseColQueue.h>
+#include <FNetHttpHttpHeader.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpMessageImpl;
+/**
+ * @class      HttpMessage
+ * @brief      This class is the base class for HttpRequest and HttpResponse.
+ *
+ * @since   2.0
+ *
+ * The %HttpMessage class represents the HTTP messages for the data exchanged between the client and the server, specifically for a request or a
+ * response. Both message types consist of a start line, zero or more header fields, an empty line indicating the end of the header fields, and
+ * possibly a message body.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_connectivity.htm">HTTP Guide</a>.
+ */
+
+class _OSP_EXPORT_ HttpMessage
+       : public Tizen::Base::Object
+{
+
+protected:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.0
+        */
+       HttpMessage(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since 2.0
+        */
+       virtual ~HttpMessage(void);
+
+protected:
+       /**
+        * Writes the message body. @n
+        * This method can be called several times consecutively. All the message bodies are stored in the queue.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   body                                            The message body data
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                           The specified @c body contains an invalid value.
+        * @exception   E_OUT_OF_MEMORY                         The memory is insufficient.
+        * @exception   E_INVALID_SESSION                       The session handle is invalid.
+        * @exception   E_INVALID_TRANSACTION           The transaction handle is invalid.
+        * @exception   E_OUT_OF_RANGE                          The size of the specified body is out of range.
+        * @exception   E_INVALID_STATE                         The current state of the instance prohibits the execution of the specified operation.
+        * @exception   E_UNKNOWN                                       An unknown error has occurred.
+        * @remarks             This method only considers the data between the position and the limit of the Tizen::Base::ByteBuffer as valid.
+        *                              The position and limit has to be set appropriately before invoking this method.
+        * @see                 ReadBodyN()
+        */
+       virtual result WriteBody(const Tizen::Base::ByteBuffer& body) = 0;
+
+protected:
+       /**
+        * Gets the header. @n
+        * This method is used to access the headers associated with a transaction request or response.
+        * The handle is obtained from either the HttpRequest or the HttpResponse objects associated with the transaction. Adding, modifying, or removing a
+        * header field is done using this header handle.
+        *
+        * @since       2.0
+        *
+        * @return              The pointer to HttpHeader that is to modify, @n
+        *                              else @c null if %HttpMessage is not constructed
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_HEADER        The header is @c null.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual HttpHeader* GetHeader(void) const = 0;
+
+       /**
+        * Gets the body of the message associated with HttpRequest or HttpResponse.
+        *
+        * @since       2.0
+        *
+        * @return              The message body
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid. @n
+        *                                                                              Invoke this method before receiving a response body.
+        * @exception   E_EMPTY_BODY                    The requested body is empty.
+        * @exception   E_OUT_OF_RANGE                  The size of the message body is out of range.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_IO                                    The method has failed to read the data.
+        * @exception   E_UNKNOWN                               An unknown error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @remarks             Once this method is invoked, the returned message body is removed from the message body queue.
+        *                              In other words, the message body queue does not hold all the bodies permanently.
+        * @see                 WriteBody()
+        */
+       virtual Tizen::Base::ByteBuffer* ReadBodyN(void) = 0;
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs   An instance of %HttpMessage
+        */
+       HttpMessage(const HttpMessage& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %HttpMessage
+        */
+       HttpMessage& operator =(const HttpMessage& rhs);
+
+protected:
+       //
+       //  This variable is for internal use only. Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // The total length of the message body
+       //
+       // @since       2.0
+       //
+       unsigned int _totalLen;
+
+       //
+       //  This variable is for internal use only. Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // The message queue
+       //
+       // @since       2.0
+       //
+       Tizen::Base::Collection::Queue _bodyQueue;
+
+       //
+       //  This variable is for internal use only. Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // The header of message
+       //
+       // @since       2.0
+       //
+       HttpHeader* _pHeader;
+
+       friend class _HttpMessageImpl;
+       _HttpMessageImpl* _pHttpMessageImpl;
+
+}; // HttpMessage
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_MESSAGE_H_
diff --git a/inc/FNetHttpHttpMultipartEntity.h b/inc/FNetHttpHttpMultipartEntity.h
new file mode 100755 (executable)
index 0000000..4a42fbb
--- /dev/null
@@ -0,0 +1,375 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpMultipartEntity.h
+ * @brief              This is the header file for the %HttpMultipartEntity class.
+ *
+ * This header file contains the declarations of the %HttpMultipartEntity class.
+ */
+
+#ifndef _FNET_HTTP_HTTP_MULTIPART_ENTITY_H_
+#define _FNET_HTTP_HTTP_MULTIPART_ENTITY_H_
+
+#include <FBase.h>
+#include <FText.h>
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpIHttpEntity.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpMultipartEntityImpl;
+
+/**
+ * @if OSPDEPREC
+ * The constant for the default MIME type of the string part.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated  This object is provided only for backward compatibility and will be deleted in the near future.
+ *                             Use HTTP_STRING_PART_DEFAULT_MIME_TYPE instead of this object.
+ * @since      2.0
+ * @endif
+ */
+_OSP_EXPORT_ extern const Tizen::Base::String STRING_PART_DEFAULT_MIME_TYPE;
+
+/**
+ * @if OSPDEPREC
+ * The constant for the default MIME type of the file part.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated  This object is provided only for backward compatibility and will be deleted in the near future.
+  *                            Use HTTP_FILE_PART_DEFAULT_MIME_TYPE instead of this object.
+ * @since      2.0
+ * @endif
+ */
+_OSP_EXPORT_ extern const Tizen::Base::String FILE_PART_DEFAULT_MIME_TYPE;
+
+/**
+ * The constant for the default MIME type of the string part ("text/plain").
+ *
+ * @since      2.0
+ */
+_OSP_EXPORT_ extern const wchar_t HTTP_STRING_PART_DEFAULT_MIME_TYPE[];
+
+/**
+ * The constant for the default MIME type of the file part ("application/octet-stream").
+ *
+ * @since      2.0
+ */
+_OSP_EXPORT_ extern const wchar_t HTTP_FILE_PART_DEFAULT_MIME_TYPE[];
+
+/**
+ * @class      HttpMultipartEntity
+ * @brief      This class represents a multipart/form-data entity as defined in RFC 2388.
+ *
+ * @since 2.0
+ *
+ *  The %HttpMultipartEntity class represents a multipart/form-data entity as defined in RFC 2388.
+ *  The multipart/form-data entity contains a series of parts.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_connectivity.htm">HTTP Guide</a>.
+ *
+ * The following example demonstrates how to use the %HttpMultipartEntity class to upload the content to the server.
+ *
+ * @code
+
+    #include <FBase.h>
+    #include <FNet.h>
+
+    using namespace Tizen::Base;
+    using namespace Tizen::Net::Http;
+
+    void
+    TestHttpMultipartEntity(void)
+    {
+        result r = E_SUCCESS;
+        HttpSession* pSession = null;
+        HttpTransaction* pTransaction = null;
+        HttpRequest* pRequest = null;
+        HttpMultipartEntity* pMultipartEntity = null;
+        String hostAddr(L"http://www.tizen.org");
+
+        // Creates an HTTP session.
+        pSession = new HttpSession();
+        r = pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, hostAddr, null);
+
+        pTransaction = pSession->OpenTransactionN();
+        r = pTransaction->AddHttpTransactionListener(*this);
+        r = pTransaction->SetHttpProgressListener(*this);
+
+        pRequest = pTransaction->GetRequest();
+        pRequest->SetMethod(NET_HTTP_METHOD_POST);
+        r = pRequest->SetUri(L"http://www.tizen.org/test");
+
+        pMultipartEntity = new HttpMultipartEntity();
+        r = pMultipartEntity->Construct();
+
+        r = pMultipartEntity->AddStringPart(L"title", L"Tizen logo");
+        r = pMultipartEntity->AddStringPart(L"date", L"2010-12-25");
+        r = pMultipartEntity->AddFilePart(L"upload", L"/Home/Tizen.jpg", L"Tizen.jpg", L"image/jpeg", L"ISO-8859-1");
+
+        r = pRequest->SetEntity(*pMultipartEntity);
+        r = pTransaction->Submit();
+    }
+
+ * @endcode
+ */
+
+class _OSP_EXPORT_ HttpMultipartEntity
+       : public Tizen::Base::Object
+       , public IHttpEntity
+{
+
+public:
+       /**
+        * 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.
+        *
+        * @since       2.0
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        */
+       HttpMultipartEntity(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since 2.0
+        */
+       virtual ~HttpMultipartEntity(void);
+
+       /**
+        * Initializes this instance of %HttpMultipartEntity.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        */
+       result Construct(void);
+
+       /**
+        * Initializes this instance of %HttpMultipartEntity with the specified parameters.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   boundary                        The boundary of multipart/form-data
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified input parameter is invalid.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        */
+       result Construct(const Tizen::Base::String& boundary);
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs             An instance of %HttpMultipartEntity
+        */
+       HttpMultipartEntity(const HttpMultipartEntity& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %HttpMultipartEntity
+        */
+       HttpMultipartEntity& operator =(const HttpMultipartEntity& rhs);
+
+public:
+       /**
+        * Gets the length of the request content.
+        *
+        * @since       2.0
+        *
+        * @return              The length of the content, @n
+        *                              else @c -1 if the content length is unknown
+        */
+       virtual long long GetContentLength(void) const;
+
+       /**
+        * Gets the type of the request content.
+        *
+        * @since       2.0
+        *
+        * @return              The type of the content
+        */
+       virtual Tizen::Base::String GetContentType(void) const;
+
+       /**
+        * Adds the string part to %HttpMultipartEntity with the default MIME type and character set.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   name                                            The name of the part
+        * @param[in]   text                                            The text of the part @n
+        *                                                                                      The value of @c text is encoded using the default character encoding standard ("ISO-8859-1").
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                           A specified input parameter is invalid.
+        * @exception   E_OUT_OF_MEMORY                         The memory is insufficient.
+        * @exception   E_INVALID_ENCODING_RANGE    The @c text contains code points that are outside the bounds specified by @c encoding.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @remarks             The default MIME type is "text/plain".
+        */
+       result AddStringPart(const Tizen::Base::String& name, const Tizen::Base::String& text);
+
+       /**
+        * Adds the string part to the %HttpMultipartEntity.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   name                                            The name of the part
+        * @param[in]   text                                            The text of the part
+        * @param[in]   mimeType                                        The MIME type of @c text
+        * @param[in]   charset                                         The character set of @c text
+        * @param[in]   encoding                                        An encoding scheme for the specified @c text
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                           A specified input parameter is invalid.
+        * @exception   E_OUT_OF_MEMORY                         The memory is insufficient.
+        * @exception   E_INVALID_ENCODING_RANGE    The @c text contains code points that are outside the bounds specified by @c encoding.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        */
+       result AddStringPart(const Tizen::Base::String& name, const Tizen::Base::String& text, const Tizen::Base::String& mimeType, const Tizen::Base::String& charset, const Tizen::Text::Encoding& encoding);
+
+       /**
+        * Adds the file part to %HttpMultipartEntity with the default MIME type.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+        *                                      For more information, see @ref CompIoPathPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   name                            The name of the part
+        * @param[in]   filePath                        The path of the file to upload
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           A specified input parameter is invalid.
+        * @exception   E_FILE_NOT_FOUND        The specified file cannot be found or accessed.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        * @remarks             The default MIME type is "application/octet-stream".
+        */
+       result AddFilePart(const Tizen::Base::String& name, const Tizen::Base::String& filePath);
+
+       /**
+        * Adds the file part to %HttpMultipartEntity.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since       2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+        *                                      For more information, see @ref CompIoPathPage "here".
+        * @endif
+        *
+        * @return              An error code
+        * @param[in]   name                            The name of the part
+        * @param[in]   filePath                        The path of the file to upload
+        * @param[in]   fileName                        The file name of the part
+        * @param[in]   mimeType                        The MIME type of the content
+        * @param[in]   charset                         The character set of the content
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           A specified input parameter is invalid.
+        * @exception   E_FILE_NOT_FOUND        The specified file cannot be found or accessed.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        */
+       result AddFilePart(const Tizen::Base::String& name, const Tizen::Base::String& filePath, const Tizen::Base::String& fileName, const Tizen::Base::String& mimeType, const Tizen::Base::String& charset);
+
+       /**
+        * Adds the binary part to %HttpMultipartEntity with the default MIME type.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   name                            The name of the part
+        * @param[in]   fileName                        The file name of the part
+        * @param[in]   buffer                          The buffer of file to upload
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           A specified input parameter is invalid.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        * @remarks             The default MIME-type is "application/octet-stream".
+        */
+       result AddFilePartByBuffer(const Tizen::Base::String& name, const Tizen::Base::String& fileName, const Tizen::Base::ByteBuffer& buffer);
+
+       /**
+        * Adds the binary part to %HttpMultipartEntity.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   name                            The name of the part
+        * @param[in]   fileName                        The file name of the part
+        * @param[in]   buffer                          The buffer of the file to upload
+        * @param[in]   mimeType                        The MIME type of the content
+        * @param[in]   charset                         The character set of the content
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           A specified input parameter is invalid.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        */
+       result AddFilePartByBuffer(const Tizen::Base::String& name, const Tizen::Base::String& fileName, const Tizen::Base::ByteBuffer& buffer, const Tizen::Base::String& mimeType, const Tizen::Base::String& charset);
+
+protected:
+       /**
+        * Checks whether the next data exists.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the next data exists, @n
+        *                              else @c false
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual bool HasNextData(void);
+
+       /**
+        * Gets the next data.
+        *
+        * @since       2.0
+        *
+        * @return              The buffer to be read
+        * @param[in]   recommendedSize                 The recommended size of the data to send
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual Tizen::Base::ByteBuffer* GetNextDataN(int recommendedSize);
+
+private:
+       friend class _HttpMultipartEntityImpl;
+       _HttpMultipartEntityImpl* __pHttpMultipartEntityImpl;
+
+}; // HttpMultipartEntity
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_MULTIPART_ENTITY_H_
diff --git a/inc/FNetHttpHttpRequest.h b/inc/FNetHttpHttpRequest.h
new file mode 100755 (executable)
index 0000000..651cfcd
--- /dev/null
@@ -0,0 +1,404 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpRequest.h
+ * @brief              This is the header file for the %HttpRequest class.
+ *
+ * This header file contains the declarations of the %HttpRequest class.
+ */
+
+#ifndef _FNET_HTTP_HTTP_REQUEST_H_
+#define _FNET_HTTP_HTTP_REQUEST_H_
+
+#include <FNetHttpHttpMessage.h>
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpHttpHeader.h>
+#include <FNetHttpIHttpEntity.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpTransaction;
+class _HttpRequestImpl;
+
+/////////////////////////////////////////////////////////////////////////////
+/**
+ * @class      HttpRequest
+ * @brief      This class represents a request message.
+ *
+ * @since   2.0
+ *
+ * The %HttpRequest class represents an HTTP request message that stores a method (for example, HTTP GET), a URI, and the other message headers
+ * and the body supplied by the HttpMessage base class.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_connectivity.htm">HTTP Guide</a>.
+ *
+ * The following example demonstrates how to use the %HttpRequest class.
+ *
+ * @code
+ *
+    #include <FBase.h>
+    #include <FNet.h>
+
+    using namespace Tizen::Base;
+    using namespace Tizen::Net::Http;
+
+    void
+    TestHttpRequest(void)
+    {
+        result r = E_SUCCESS;
+        HttpSession* pSession = null;
+        HttpTransaction* pTransaction = null;
+        String hostAddr(L"http://www.tizen.org");
+
+        pSession = new HttpSession();
+        r = pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, hostAddr, null);
+
+        pTransaction = pSession->OpenTransactionN();
+        r = pTransaction->AddHttpTransactionListener(*this);
+
+        // Get the request instance.
+        HttpRequest* pRequest = pTransaction->GetRequest();
+
+        // Set the method.
+        NetHttpMethod method = NET_HTTP_METHOD_POST;
+        r = pRequest->SetMethod(method);
+
+        // Set the uri.
+        r = pRequest->SetUri(L"http://www.tizen.org/test");
+
+        HttpHeader* pHeader = null;
+        pHeader = pRequest->GetHeader();
+
+        // Add the content-length to header.
+        r = pHeader->AddField(L"Content-Length", L"1024");
+    }
+
+ * @endcode
+ */
+class _OSP_EXPORT_ HttpRequest
+       : public HttpMessage
+{
+
+public:
+       /**
+        * Sets an HTTP method of the request header. @n
+        * The default method is @c NET_HTTP_METHOD_GET.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   method                          An HTTP method
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified input parameter is invalid.
+        * @exception   E_INVALID_STATE         The corresponding transaction is already submitted.
+        * @remarks             The detailed descriptions of the HTTP methods are as follows: @n
+        *                              1) The OPTIONS method represents a request for information about the communication options available on the request/response chain
+        *                              identified by the Request-URI. This method may include a message body to make more detailed queries. To do so, specify the Content-Length
+        *                              (or Transfer-Encoding), and Content-Type header fields. However, if the server does not support this, the server may discard the body. @n
+        *                              2) The GET method retrieves whatever information is identified by the Request-URI. @n
+        *                              3) The HEAD method is identical to GET except that the server must not return a response message body. The GET and HEAD methods do
+        *              not include a message body. @n
+        *                              4) The POST method is used to request that the origin server accepts the entity enclosed in the request as a new subordinate of the
+        *                              resource identified by the Request-URI. @n
+        *                              5) The PUT method requests that the enclosed entity be stored under the supplied Request-URI. @n
+        *                              When you are using the POST or PUT methods, be sure to specify the Content-Length header field, which is the message body length. @n
+        *                              6) The DELETE method requests that the origin server deletes the resource identified by the Request-URI.
+        * @see                 GetMethod()
+        */
+       result SetMethod(NetHttpMethod method);
+
+       /**
+        * Sets a custom method of the request header.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   method                          An HTTP method
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified input parameter is invalid.
+        * @exception   E_INVALID_STATE         The corresponding transaction is already submitted.
+        * @remarks             This method can be used to user-defined methods as well as HTTP 1.1 methods like 'GET, PUT, POST, HEAD etc'.
+        * @see                 GetCustomMethod()
+        */
+       result SetCustomMethod(const Tizen::Base::String& method);
+
+       /**
+        * Sets an HTTP version of the request header.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   version                         An HTTP version
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified input parameter is invalid.
+        * @exception   E_INVALID_STATE         The corresponding transaction is already submitted.
+        * @see                 GetVersion()
+        */
+       result SetVersion(HttpVersion version);
+
+       /**
+        * Sets a URI of the request header.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   uri                                     The raw URI @n
+        *                                                                      The URI must be a valid URI.
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c uri is invalid.
+        * @exception   E_INVALID_STATE         The corresponding transaction is already submitted.
+        * @remarks             The URI must be encoded properly according to RFC 2396 before using this method.
+        *                              The ending slash is a required part of a URL specifying a directory.
+        * @see                 Tizen::Base::Utility::Uri
+        * @see                 GetUri()
+        */
+       result SetUri(const Tizen::Base::String& uri);
+
+       /**
+        * Sets the request message body.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   body                                            The message body data
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception   E_OUT_OF_MEMORY                         The memory is insufficient.
+        * @exception   E_INVALID_SESSION                       The session handle is invalid.
+        * @exception   E_INVALID_TRANSACTION           The transaction handle is invalid.
+        * @exception   E_OUT_OF_RANGE                          The submitted body size is out of range.
+        * @exception   E_INVALID_STATE                         Either of the following conditions has occurred: @n
+        *                                                                                - The corresponding transaction is already submitted. @n
+        *                                                                                - A chunked mode is not enabled.
+        * @exception   E_UNKNOWN                                       An unknown error has occurred.
+        * @remarks             This method can be used in two different situations. @n
+        *                              @li Before submitting the request: @n
+        *                              In this case, this method can be called several times consecutively, and all the bodies are appended together in the message queue until
+        *                              the HttpTransaction::Submit() method is called. Set the message body, when the POST or PUT method is used. @n
+        *                              @li After receiving an ADDCHUNK event: @n
+        *                              In this case, this method must be invoked only once at a time. The recommended chunk size is given in IHttpTransactionEventListener::OnTransactionReadyToWrite().
+        * @see                 SetMethod()
+        * @see                 NetHttpMethod
+        */
+       virtual result WriteBody(const Tizen::Base::ByteBuffer& body);
+
+       /**
+        * Sets the request entity.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   entity                                          An instance of IHttpEntity to send
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception   E_OUT_OF_MEMORY                         The memory is insufficient.
+        * @exception   E_INVALID_SESSION                       The session handle is invalid.
+        * @exception   E_INVALID_TRANSACTION           The transaction handle is invalid.
+        * @exception   E_OUT_OF_RANGE                          The body size is out of range.
+        * @exception   E_INVALID_STATE                         The WriteBody() method is already called.
+        * @remarks             The instance of IHttpEntity is used by the internal platform.
+        *              Do not delete or change the instance of %IHttpEntity before the IHttpTransactionEventListener::OnTransactionCompleted() or IHttpTransactionEventListener::OnTransactionAborted() method is called.
+        */
+       result SetEntity(IHttpEntity& entity);
+
+       /**
+        * Gets the HttpHeader object of the HTTP request.
+        *
+        * @since       2.0
+        *
+        * @return              The header object of the HTTP request, @n
+        *                              else @c null if the header is not set properly
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_HEADER                        The header is @c null.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @remarks             This method is used to access the header associated with a transaction's request. The handle is obtained from the %HttpRequest object
+        *                              associated with the transaction. Adding, modifying, or removing a header field is done using this header handle.
+        */
+       virtual HttpHeader* GetHeader(void) const;
+
+       /**
+        * Sets the string to be sent in the cookie header field of %HttpRequest.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   cookieString                    The cookie string @n
+        *                                                                              For example, Cookie: cookie-name1=cookie-value1;cookie-name2=cookie-value2.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid in this state.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result SetCookie(const Tizen::Base::String& cookieString);
+
+       /**
+        * Gets the cookie header field of %HttpRequest.
+        *
+        * @since       2.0
+        *
+        * @return              The cookie string
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 The cookie is empty.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::String GetCookie(void) const;
+
+       /**
+        * Sets the Accept-Encoding header field of %HttpRequest. @n
+        * This header can be used to specify certain Content-Encoding which are acceptable for the response.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   encoding                                        The accept encoding  @n
+        *                                                                                      Three encodings ("identity", "gzip", "deflate") are supported. @n
+        *                                                                                      If @c encoding is a empty string, an Accept-Encoding header containing all supported encodings will be set.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                           The specified @c encoding is invalid.
+        * @exception   E_INVALID_STATE                         The corresponding transaction is already submitted.
+        * @see                 GetAcceptEncoding()
+        */
+       result SetAcceptEncoding(const Tizen::Base::String& encoding);
+
+protected:
+       /**
+        * 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.
+        *
+        * @since       2.0
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       HttpRequest(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~HttpRequest(void);
+
+       /**
+        * Initializes this instance of %HttpRequest with the specified parameters.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   httpTransaction                         The HTTP transaction
+        * @param[in]   pCommonHeader                           A header object that stores the common header
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                           A specified input parameter is @c null.
+        * @exception   E_INVALID_OPERATION                     The current state of the instance prohibits the execution of the specified operation.
+        * @exception   E_OUT_OF_MEMORY                         The memory is insufficient.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        */
+       result Construct(const HttpTransaction& httpTransaction, const HttpHeader* pCommonHeader);
+
+       /**
+        * Gets an HTTP method of the request header.
+        *
+        * @since               2.0
+        *
+        * @return              HTTP method
+        * @see                 SetMethod()
+        */
+       NetHttpMethod GetMethod(void) const;
+
+       /**
+        * Gets a custom method of the request header.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[out]  method                          The name of custom method
+        * @exception   E_SUCCESS                       The method is successful.
+        * @see                 SetCustomMethod()
+        */
+       result GetCustomMethod(Tizen::Base::String& method) const;
+
+       /**
+        * Gets an HTTP version of the request header.
+        *
+        * @since       2.0
+        *
+        * @return              A version of HTTP
+        * @see                 SetVersion()
+        */
+       HttpVersion GetVersion(void) const;
+
+       /**
+        * Gets a URI of the request header.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[out]  uri                                             The raw URI
+        * @exception   E_SUCCESS                               The method is successful.
+        * @see                 SetUri()
+        */
+       result GetUri(Tizen::Base::String& uri) const;
+
+       /**
+        * Gets the message body associated with an HTTP Request.
+        *
+        * @since       2.0
+        *
+        * @return              The response body object
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_EMPTY_BODY                    The requested body is empty.
+        * @exception   E_OUT_OF_MEMORY                 The ByteBuffer size is smaller than the request body size.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid in this state.
+        * @exception   E_OUT_OF_RANGE                  The @c data size exceeds the maximum range.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @remarks             Be sure to @c Flip() the @c body, which is Tizen::Base::ByteBuffer, before reading any data in the %Tizen::Base::ByteBuffer instance.
+        */
+       virtual Tizen::Base::ByteBuffer* ReadBodyN(void);
+
+       /**
+        * Gets the Accept-Encoding header field of %HttpRequest.
+        *
+        * @since               2.0
+        *
+        * @return              The accept encoding
+        *
+        * @see                 SetAcceptEncoding()
+        */
+       Tizen::Base::String GetAcceptEncoding(void) const;
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs   An instance of %HttpRequest
+        */
+       HttpRequest(const HttpRequest& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                             An instance of %HttpRequest
+        */
+       HttpRequest& operator =(const HttpRequest& rhs);
+
+private:
+       friend class _HttpRequestImpl;
+       _HttpRequestImpl* __pHttpRequestImpl;
+
+}; // HttpRequest
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_REQUEST_H_
diff --git a/inc/FNetHttpHttpResponse.h b/inc/FNetHttpHttpResponse.h
new file mode 100755 (executable)
index 0000000..cdabb9b
--- /dev/null
@@ -0,0 +1,366 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpResponse.h
+ * @brief              This is the header file for the %HttpResponse class.
+ *
+ * This header file contains the declarations of the %HttpResponse class.
+ */
+
+#ifndef _FNET_HTTP_HTTP_RESPONSE_H_
+#define _FNET_HTTP_HTTP_RESPONSE_H_
+
+#include <FBaseColLinkedList.h>
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpHttpHeader.h>
+#include <FNetHttpHttpMessage.h>
+#include <FNetHttpHttpCookie.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpTransaction;
+class _HttpResponseImpl;
+/**
+ * @class      HttpResponse
+ * @brief      This class represents a response message.
+ *
+ * @since   2.0
+ *
+ * The %HttpResponse class represents a response message that stores a status code, the status text, and the server version information, as well as
+ * the message headers and body supplied by the HttpMessage base class.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_connectivity.htm">HTTP Guide</a>.
+ *
+ * The following example demonstrates how to use the %HttpResponse class.
+ *
+ * @code
+
+    #include <FBase.h>
+    #include <FNet.h>
+
+    using namespace Tizen::Base;
+    using namespace Tizen::Net::Http;
+
+    void
+    MyTransactionEventListener::OnTransactionReadyToRead(const Tizen::Net::Http::HttpSession& httpSession,
+                             const Tizen::Net::Http::HttpTransaction& httpTransaction, int availableBodyLen)
+    {
+        HttpResponse* pResponse = httpTransaction.GetResponse();
+
+        if (pResponse->GetHttpStatusCode() == HTTP_STATUS_OK)
+        {
+            ByteBuffer* pBody = null;
+            String statusText = pResponse->GetStatusText();
+            String version = pResponse->GetVersion();
+            pBody = pResponse->ReadBodyN();
+            delete pBody;
+        }
+    }
+
+ * @endcode
+ */
+//////////////////////////////////////////////////////////////////////////
+class _OSP_EXPORT_ HttpResponse
+       : public HttpMessage
+{
+
+public:
+       /**
+        * @if OSPDEPREC
+        * Gets the status code from the response header.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated  This method is deprecated. Instead of using this method, it is recommended to use the GetHttpStatusCode() method that returns the status code as an integer type.
+        * @since       2.0
+        *
+        * @return              The status code, @n
+        *                              else @c -1 if an error occurs
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 Invoke this method before receiving a response header.
+        * @exception   E_INVALID_DATA                  The status code is not defined.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        * @remarks             The @c statusText gives a short textual description of the status code. It is placed after the status code on the first line of the
+        *                              response. The specific error code can be accessed using the GetLastResult() method.
+        * @see                 NetHttpStatusCode
+        * @see                 SetStatusCode()
+        * @endif
+        */
+       NetHttpStatusCode GetStatusCode(void) const;
+
+       /**
+        * Gets the HTTP status code from the response header.
+        *
+        * @since       2.0
+        *
+        * @return              The status code, @n
+        *                              else @c -1 if an error occurs
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_STATE                         Invoke this method before receiving a response header.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        * @remarks             The @c statusText gives a short textual description of the status code. It is placed after the status code on the first line of the
+        *                              response.
+        * @see                 SetHttpStatusCode()
+        */
+       int GetHttpStatusCode(void) const;
+
+       /**
+        * Gets a short textual description of the status code from the response header. @n
+        * This description is placed after the status code on the first line of the response.
+        *
+        * @since       2.0
+        *
+        * @return              The status description, @n
+        *                              else an empty string when the status text is not defined
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_STATE                         Invoke this method before receiving a response header.
+        * @exception   E_INVALID_DATA                          The status text is not defined.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        * @see                 SetStatusText()
+        */
+       Tizen::Base::String GetStatusText(void) const;
+
+       /**
+        * Gets the version of the protocol used by the server from the response header.
+        *
+        * @since       2.0
+        *
+        * @return              The protocol version, @n
+        *                              else an empty string when the version is not defined
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_STATE                         Invoke this method before receiving a response header.
+        * @exception   E_INVALID_DATA                          The version is not defined.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        * @see                 SetVersion()
+        */
+       Tizen::Base::String GetVersion(void) const;
+
+       /**
+        * Gets the HttpHeader object of a response header.
+        *
+        * @since       2.0
+        *
+        * @return              The header object, @n
+        *                              else @c null if the header is not received
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_HEADER                        The header is @c null.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual HttpHeader* GetHeader(void) const;
+
+       /**
+        * Gets the message body of the response.
+        *
+        * @since       2.0
+        *
+        * @return              The response body object
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 Invoke this method before receiving a response body.
+        * @exception   E_EMPTY_BODY                    The requested body is empty.
+        * @exception   E_OUT_OF_RANGE                  The specified @c data size exceeds the maximum range.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_IO                                    The method has failed to read the data.
+        * @exception   E_UNKNOWN                               An unknown error has occurred.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        * @remarks             This method can be invoked several times until there is no more data.
+        */
+       virtual Tizen::Base::ByteBuffer* ReadBodyN(void);
+
+       /**
+        * Gets the list of cookies received in the response.
+        *
+        * @since       2.0
+        *
+        * @return              A list containing HttpCookie instances, @n
+        *                              else @c null if no cookie is received in the response
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid in this state.
+        * @remarks     The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetCookies(void) const;
+
+protected:
+       /**
+        * 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.
+        *
+        * @since       2.0
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize the instance.
+        */
+       HttpResponse(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~HttpResponse(void);
+
+       /**
+        * Initializes this instance of %HttpResponse with the specified parameter.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   httpTransaction                 The HTTP transaction
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_INVALID_ARG                   The specified input parameter is @c null.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        */
+       result Construct(const HttpTransaction& httpTransaction);
+
+protected:
+       /**
+        * @if OSPDEPREC
+        * Sets the status code from the response header.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated This method is deprecated. Instead of using this method, it is recommended to use the SetHttpStatusCode() method that sets
+        * the status code as integer type.
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   statusCode                              The status code
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @remarks             The @c statusCode element is a 3-digit integer result code of the attempt to understand and satisfy the request. The first digit of the
+        *                              @c statusCode defines the class of response. The last two digits do not have any categorization role.
+        * @see                 GetStatusCode()
+        * @endif
+        */
+       result SetStatusCode(NetHttpStatusCode statusCode);
+
+       /**
+        * Sets the status code from the response header.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   statusCode                              The status code
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @remarks             The @c statusCode element is a 3-digit integer result code of the attempt to understand and satisfy the request. The first digit of the
+        *                              @c statusCode defines the class of response. The last two digits do not have any categorization role.
+        * @see                 GetHttpStatusCode()
+        */
+       result SetHttpStatusCode(int statusCode);
+
+       /**
+        * Sets the status text from the response header.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   statusText                              The status description
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is @c null.
+        * @remarks             The @c statusText gives a short textual description of the status code. This description is placed after the status code on the first
+        *                              line of the response.
+        * @see                 GetStatusText()
+        */
+       result SetStatusText(const Tizen::Base::String& statusText);
+
+       /**
+        * Sets the version of the protocol used by the server from the response header.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   httpVersion                             The protocol version
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is @c null.
+        * @see                 GetVersion()
+        */
+       result SetVersion(const Tizen::Base::String& httpVersion);
+
+       /**
+        * Sets the response body.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   body                                    The message body data
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid in this state.
+        * @remarks             This method can be invoked several times until there is no more data to write.
+        */
+       virtual result WriteBody(const Tizen::Base::ByteBuffer& body);
+
+       /**
+        * Reads the data from the data communicated.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   headerLen                               The header length to read
+        * @param[in]   bodyLen                                 The body length to read
+        * @param[out]  rcvHeaderLen                    The received header length
+        * @param[out]  rcvBodyLen                              The received body length
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_IO                                    The method has failed to read the data.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_INVALID_SESSION               The session handle is invalid.
+        * @exception   E_INVALID_TRANSACTION   The transaction handle is invalid.
+        * @exception   E_SYSTEM                                An internal error has occurred.
+        * @exception   E_OUT_OF_RANGE                  The read data exceeds the maximum range.
+        * @exception   E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation. @n
+        *                                                                              The comparer has failed to compare keys.
+        * @exception   E_INVALID_HEADER        An invalid header is received in response.
+        */
+       result Read(int headerLen, int bodyLen, int& rcvHeaderLen, int& rcvBodyLen);
+
+       /**
+        * Saves the cookie received in the response to %HttpResponse.
+        *
+        * @since           2.0
+        *
+        * @return                      An error code
+        * @param[in]           pHeader                                 A response header
+        * @exception           E_SUCCESS                               The method is successful.
+        * @exception           E_INVALID_STATE                 The method invoked is invalid in this state.
+        * @exception           E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @remarks                     Transaction events use this method to set the cookie received in the response.
+        * @see                         GetCookies()
+        */
+       result SetCookie(Tizen::Net::Http::HttpHeader* pHeader);
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs   An instance of %HttpResponse
+        */
+       HttpResponse(const HttpResponse& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                             An instance of %HttpResponse
+        */
+       HttpResponse& operator =(const HttpResponse& rhs);
+
+private:
+       friend class _HttpResponseImpl;
+       _HttpResponseImpl* __pHttpResponseImpl;
+
+}; // HttpResponse
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_RESPONSE_H_
diff --git a/inc/FNetHttpHttpSession.h b/inc/FNetHttpHttpSession.h
new file mode 100755 (executable)
index 0000000..b03922c
--- /dev/null
@@ -0,0 +1,361 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpSession.h
+ * @brief              This is the header file for the %HttpSession class.
+ *
+ * This header file contains the declarations of the %HttpSession class.
+ */
+
+#ifndef _FNET_HTTP_HTTP_SESSION_H_
+#define _FNET_HTTP_HTTP_SESSION_H_
+
+#include <FBaseString.h>
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpHttpTransaction.h>
+#include <FNetHttpHttpHeader.h>
+#include <FNetHttpHttpCookieStorageManager.h>
+#include <FNetHttpHttpAuthentication.h>
+#include <FNetNetConnection.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpSessionImpl;
+/**
+ * @class      HttpSession
+ * @brief      This class represents an HTTP session.
+ *
+ * @since      2.0
+ *
+ * The %HttpSession class represents an HTTP session. The session encapsulates the client's HTTP activity over the duration of the client's execution. It is a set of transactions using the same
+ * connection settings (such as proxy). The client may use several sessions concurrently if desired.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_session.htm">HTTP Session</a>.
+
+ * The following example demonstrates how to use the %HttpSession class.
+ *
+ * @code
+
+    #include <FBase.h>
+    #include <FNet.h>
+
+    using namespace Tizen::Base;
+    using namespace Tizen::Net::Http;
+
+    void
+    TestHttpSession(void)
+    {
+        result r = E_SUCCESS;
+
+        HttpSession* pSession = null;
+        HttpTransaction* pTransaction = null;
+        String* pProxyAddr = null;
+        String hostAddr = L"http://www.tizen.org";
+
+        pSession = new HttpSession();
+
+        // HttpSession construction.
+        r = pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, pProxyAddr ,hostAddr, null);
+
+        // Open a new HttpTransaction.
+        pTransaction = pSession->OpenTransactionN();
+    }
+
+ * @endcode
+ */
+
+class _OSP_EXPORT_ HttpSession
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * 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.
+        *
+        * @since       2.0
+        *
+        * @remarks             After creating an instance of this class, one of the Construct() methods must be called explicitly to initialize the instance.
+        */
+       HttpSession(void);
+
+       /**
+        * Initializes this instance of %HttpSession with the specified parameters. @n
+        * Opens a session using the default @c netConnection.
+        *
+        * @since           2.0
+        *
+        * @return                      An error code
+        * @param[in]           sessionMode                             The session mode to open the session
+        * @param[in]           pProxyAddr                              A proxy address @n
+        *                                                                                      The specified @c pProxyAddr must be a valid URL. If @c pProxyAddr is @c null, %HttpSession uses the system
+        *                                                                                      default proxy address.
+        * @param[in]           hostAddr                                A host address @n
+        *                                                                                      The specified @c hostAddr must be a valid URL. If session mode is NET_HTTP_SESSION_MODE_MULTIPLE_HOST,
+        *                                                                                      @c hostAddr is ignored (In case of multiple host mode, @c hostAddr is set to HttpRequest::SetUri()).
+        * @param[in]           pCommonHeader                   An instance of HttpHeader @n
+        *                                                                                      This is a common header used in all the transactions included in this session.
+        * @param[in]           flag                                    Set to @c true if the cookies must be handled automatically, @n
+        *                                                                                      else @c false if the cookies must be handled manually
+        * @exception           E_SUCCESS                               The method is successful.
+        * @exception           E_INVALID_ARG                   A specified input parameter is invalid.
+        * @exception           E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception           E_INVALID_CONNECTION    The net connection is invalid.
+        * @exception           E_MAX_EXCEEDED                  The number of currently opened sessions has exceeded the maximum limit.
+        * @exception           E_INVALID_PROXY                 The specified proxy address is invalid.
+        * @exception           E_UNKNOWN                               An unknown error has occurred.
+        * @exception           E_SYSTEM                                An internal error has occurred.
+        * @exception           E_INVALID_ADDRESS               The host address is invalid.
+        * @remarks                     In the NORMAL and PIPELINING session modes, all the transactions within this sessions are submitted through the same connection. While
+        *                                      only one transaction is processed at a time in the Normal mode, multiple transactions can be pipelined in the Pipelining mode. In the
+        *                                      normal mode, in order to submit the next transaction, the previous transaction must be complete.
+        */
+       result Construct(NetHttpSessionMode sessionMode, const Tizen::Base::String* pProxyAddr, const Tizen::Base::String& hostAddr, const HttpHeader* pCommonHeader, NetHttpCookieFlag flag = NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL);
+
+       /**
+        * Initializes this instance of %HttpSession with the specified parameters. @n
+        * Opens a session using the specified protocol.
+        *
+        * @since           2.0
+        *
+        * @return                      An error code
+        * @param[in]           netConnection                   A NetConnection instance
+        * @param[in]           sessionMode                             The session mode to open the session
+        * @param[in]           pProxyAddr                              A proxy address @n
+        *                                                                                      The specified @c pProxyAddr must be a valid URL. If @c pProxyAddr is @c null, %HttpSession uses the system
+        *                                                                                      default proxy address.
+        * @param[in]           hostAddr                                A host address @n
+        *                                                                                      The specified @c hostAddr must be a valid URL.
+        * @param[in]           pCommonHeader                   An instance of HttpHeader @n
+        *                                                                                      This is a common header used in all the transactions included in this session.
+        * @param[in]           flag                                    Set to @c true if the cookies must be handled automatically, @n
+        *                                                                                      else @c false if the cookies must be handled manually
+        * @exception           E_SUCCESS                               The method is successful.
+        * @exception           E_INVALID_ARG                   A specified input parameter is invalid.
+        * @exception           E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception           E_INVALID_CONNECTION    The specified @c netConnection is invalid.
+        * @exception           E_MAX_EXCEEDED                  Unable to setup new connection due to too many existing connections.
+        * @exception           E_INVALID_PROXY                 The specified @c pProxyAddr is invalid.
+        * @exception           E_UNKNOWN                               An unknown error has occurred.
+        * @exception           E_SYSTEM                                An internal error has occurred.
+        * @exception           E_INVALID_ADDRESS               The host address is invalid.
+        * @remarks                     In the NORMAL and PIPELINING session mode, all the transactions within this session will be submitted through the same connection.
+        *                                      While only one transaction is processed at a time in the Normal mode, multiple transactions can be pipelined in the Pipelining mode.
+        *                                      In the normal mode, in order to submit the next transaction, the previous transaction must be complete.
+        */
+       result Construct(const NetConnection& netConnection, NetHttpSessionMode sessionMode, const Tizen::Base::String* pProxyAddr, const Tizen::Base::String& hostAddr, const HttpHeader* pCommonHeader, NetHttpCookieFlag flag = NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since 2.0
+        */
+       virtual ~HttpSession(void);
+
+public:
+       /**
+        * Opens a transaction.
+        *
+        * @since       2.0
+        * @privilege   %http://tizen.org/privilege/http
+        *
+        * @return              A pointer to a new HttpTransaction, @n
+        *                              else @c null if an error occurs
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_MAX_EXCEEDED                  The maximum number of transactions has been reached.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @remarks             The corresponding event listener must also be added in the same thread. A single transaction can be opened in a session at a time. After closing an open transaction, another
+        *                              transaction can be opened.
+        */
+       HttpTransaction* OpenTransactionN(void);
+
+       /**
+       * Opens a transaction with authentication information.
+       *
+       * @since        2.0
+       * @privilege    %http://tizen.org/privilege/http
+       *
+       * @return               The pointer to a new HttpTransaction, @n
+       *                               else @c null if an error occurs
+       * @param[in]    auth                    The authentication information
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_MAX_EXCEEDED                  The maximum number of transactions has been reached.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @remarks              The corresponding event listener must also be added in the same thread. A single transaction at a time can be opened in a session. After closing an open transaction, another
+       *                               transaction can be opened.
+       */
+       HttpTransaction* OpenTransactionN(const HttpAuthentication& auth);
+
+       /**
+        * Cancels the specified transaction. @n
+        * This method is followed by the CloseTransaction() method.
+        *
+        * @since       2.0
+        * @privilege   %http://tizen.org/privilege/http
+        *
+        * @return              An error code
+        * @param[in]   httpTransaction             The HttpTransaction to cancel
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_OPERATION_CANCELED            The specified transaction has already been canceled.
+        * @exception   E_INVALID_STATE                         The method invoked is invalid.
+        * @exception   E_INVALID_TRANSACTION           The specified @c httpTransaction is invalid.
+        * @exception   E_UNKNOWN                                       An unknown error has occurred.
+        * @exception   E_OUT_OF_MEMORY                         The memory is insufficient.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @exception   E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+        * @remarks             The canceled transaction is no longer considered active. Also, re-opening the transaction is not allowed.
+        */
+       result CancelTransaction(HttpTransaction& httpTransaction);
+
+       /**
+        * Closes the specified transaction.
+        *
+        * @since       2.0
+        * @privilege   %http://tizen.org/privilege/http
+        *
+        * @return              An error code
+        * @param[in]   httpTransaction                 The HttpTransaction to close
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OBJ_NOT_FOUND                 The specified transaction is not found within the indicated range, or @n
+        *                                                                              The specified transaction is already deleted.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_INVALID_SESSION               The session is invalid.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        */
+       result CloseTransaction(HttpTransaction& httpTransaction);
+
+       /**
+        * Closes all the transactions.
+        *
+        * @since       2.0
+        * @privilege   %http://tizen.org/privilege/http
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OBJ_NOT_FOUND                 The specified transaction is not found within the indicated range, or @n
+        *                                                                              the specified transaction is already deleted.
+        * @exception   E_INVALID_SESSION               The session is invalid.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        */
+       result CloseAllTransactions(void);
+
+       /**
+       * Sets the value to redirect the HTTP request automatically (the value is @c false by default).
+       *
+       * @since                2.0
+       *
+       * @return       An error code
+       * @param[in]    enable                                  Set to @c true to redirect the HTTP request automatically, @n
+       *                                       else @c false
+       * @exception    E_SUCCESS               The method is successful.
+       * @exception    E_INVALID_STATE                 The method invoked is invalid.
+       * @exception    E_SYSTEM                A system error has occurred.
+       */
+       result SetAutoRedirectionEnabled(bool enable);
+
+       /**
+       * Checks whether the HTTP redirection is automatic.
+       *
+       * @since                2.0
+       *
+       * @return       @c true if the HTTP redirection is automatic, @n
+       *                               else @c false
+       * @exception    E_SUCCESS           The method is successful.
+       * @exception    E_SYSTEM            A system error has occurred.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       */
+       bool IsAutoRedirectionEnabled(void) const;
+
+       /**
+        * Gets the number of active transactions in the current instance of %HttpSession.
+        *
+        * @since       2.0
+        * @privilege   %http://tizen.org/privilege/http
+        *
+        * @return      An integer value indicating the number of currently active transactions, @n
+        *                              else @c -1 if an error occurs
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @remarks             The transactions in the state between Submitted and Cancelled (or Closed) are considered to be active transactions.
+        */
+       int GetActiveTransactionCount(void) const;
+
+       /**
+        * Gets the maximum number of transactions, the current instance of %HttpSession can have.
+        *
+        * @since       2.0
+        * @privilege   %http://tizen.org/privilege/http
+        *
+        * @return      An integer value indicating the maximum number of transactions allowed @n
+        *              In NET_HTTP_SESSION_MODE_MULTIPLE_HOST mode, the return value is zero.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @remarks             In NET_HTTP_SESSION_MODE_MULTIPLE_HOST mode, the platform does not limit the number of maximum HttpTransaction that %HttpSession can have. @n
+        */
+       int GetMaxTransactionCount(void) const;
+
+       /**
+        * Gets the pointer to HttpCookieStorageManager.
+        *
+        * @since       2.0
+        *
+        * @return              The pointer to HttpCookieStorageManager, @n
+        *              else @c null if an error occurs
+        */
+       HttpCookieStorageManager* GetCookieStorageManager(void) const;
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs             An instance of %HttpSession
+        */
+       HttpSession(const HttpSession& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of %HttpSession
+        */
+       HttpSession& operator =(const HttpSession& rhs);
+
+private:
+       friend class _HttpSessionImpl;
+       _HttpSessionImpl* __pHttpSessionImpl;
+
+}; // HttpSession
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_SESSION_H_
diff --git a/inc/FNetHttpHttpStringEntity.h b/inc/FNetHttpHttpStringEntity.h
new file mode 100755 (executable)
index 0000000..f11c517
--- /dev/null
@@ -0,0 +1,222 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpStringEntity.h
+ * @brief              This is the header file for the %HttpStringEntity class.
+ *
+ * This header file contains the declarations of the %HttpStringEntity class.
+ */
+
+#ifndef _FNET_HTTP_HTTP_STRING_ENTITY_H_
+#define _FNET_HTTP_HTTP_STRING_ENTITY_H_
+
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpIHttpEntity.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+class ByteBuffer;
+} }
+
+namespace Tizen { namespace Text
+{
+class Encoding;
+} }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpStringEntityImpl;
+
+/**
+ * @class      HttpStringEntity
+ * @brief      This class represents a http body for the text content.
+ *
+ * @since 2.0
+ *
+ * The %HttpStringEntity class represents a http body for the text content.
+ *
+ * The following example demonstrates how to use the %HttpStringEntity class to send the content for text to the server using this class.
+ *
+ * @code
+
+    #include <FBase.h>
+    #include <FNet.h>
+
+    using namespace Tizen::Base;
+    using namespace Tizen::Net::Http;
+
+    void
+    TestHttpStringEntity(void)
+    {
+        result r = E_SUCCESS;
+
+        HttpSession* pSession = null;
+        HttpTransaction* pTransaction = null;
+        HttpRequest* pRequest = null;
+        String hostAddr(L"http://www.tizen.org");
+
+        pSession = new HttpSession();
+        r = pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, hostAddr, null);
+
+        pTransaction = pSession->OpenTransactionN();
+        r = pTransaction->AddHttpTransactionListener(*this);
+
+        pRequest = const_cast<HttpRequest*>(pTransaction->GetRequest());
+        r = pRequest->SetUri(L"http://www.tizen.org/test");
+        r = pRequest->SetMethod(NET_HTTP_METHOD_POST);
+
+        HttpStringEntity* pHttpStringEntity = new HttpStringEntity();
+        pHttpStringEntity->Construct(L"test content body");
+
+        r = pRequest->SetEntity(*pHttpStringEntity);
+
+        // Sends the HttpTransaction.
+        r = pTransaction->Submit();
+    }
+
+ * @endcode
+ */
+
+class _OSP_EXPORT_ HttpStringEntity
+       : public Tizen::Base::Object
+       , public IHttpEntity
+{
+
+public:
+       /**
+        * 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.
+        *
+        * @since       2.0
+        *
+        * @remarks             After creating an instance of this class, the Construct() method
+        *              must be called explicitly to initialize this instance.
+        */
+       HttpStringEntity(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since 2.0
+        */
+       virtual ~HttpStringEntity(void);
+
+       /**
+        * Initializes this instance of %HttpStringEntity with the default content type and character set.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   text                                            The text of the body
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ENCODING_RANGE    The specified @c text contains code points that are outside the bounds of the default encoding standard ("ISO-8859-1").
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @remarks             The default content type is "text/plain" and default charset is "ISO-8859-1".
+        */
+       result Construct(const Tizen::Base::String& text);
+
+       /**
+        * Initializes this instance of %HttpStringEntity with the specified parameters.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   text                                            The text of the body
+        * @param[in]   contentType                                     The content type of @c text
+        * @param[in]   charset                                         The character set of @c text
+        * @param[in]   encoding                                        An encoding scheme for the specified @c text
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                           A specified input parameter is invalid.
+        * @exception   E_INVALID_ENCODING_RANGE    The specified @c text contains code points that are outside the bounds of @c encoding.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        */
+       result Construct(const Tizen::Base::String& text, const Tizen::Base::String& contentType, const Tizen::Base::String& charset, const Tizen::Text::Encoding& encoding);
+
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %HttpStringEntity
+        */
+       HttpStringEntity(const HttpStringEntity& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                             An instance of %HttpStringEntity
+        */
+       HttpStringEntity& operator =(const HttpStringEntity& rhs);
+
+public:
+       /**
+        * Gets the length of the request content.
+        *
+        * @since       2.0
+        *
+        * @return              The length of the content, @n
+        *                              else @c -1 if the content length is unknown
+        */
+       virtual long long GetContentLength(void) const;
+
+       /**
+        * Gets the type of the request content.
+        *
+        * @since       2.0
+        *
+        * @return              The type of the content
+        */
+       virtual Tizen::Base::String GetContentType(void) const;
+
+protected:
+       /**
+        * Checks whether the next data exists.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the next data exists, @n
+        *                              else @c false
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual bool HasNextData(void);
+
+       /**
+        * Gets the next data.
+        *
+        * @since       2.0
+        *
+        * @return              The buffer to be read
+        * @param[in]   recommendedSize                 The recommended size of the data to send
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual Tizen::Base::ByteBuffer* GetNextDataN(int recommendedSize);
+
+private:
+       friend class _HttpStringEntityImpl;
+       _HttpStringEntityImpl* __pHttpStringEntityImpl;
+
+}; // HttpStringEntity
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_STRING_ENTITY_H_
diff --git a/inc/FNetHttpHttpTransaction.h b/inc/FNetHttpHttpTransaction.h
new file mode 100755 (executable)
index 0000000..108d004
--- /dev/null
@@ -0,0 +1,336 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpTransaction.h
+ * @brief              This is the header file for the %HttpTransaction class.
+ *
+ * This header file contains the declarations of the %HttpTransaction class.
+ */
+
+#ifndef _FNET_HTTP_HTTP_TRANSACTION_H_
+#define _FNET_HTTP_HTTP_TRANSACTION_H_
+
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpHttpRequest.h>
+#include <FNetHttpHttpResponse.h>
+#include <FNetHttpHttpAuthentication.h>
+#include <FNetHttpIHttpTransactionEventListener.h>
+#include <FNetHttpIHttpEntity.h>
+#include <FNetHttpIHttpProgressEventListener.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpTransactionImpl;
+/**
+ * @class      HttpTransaction
+ * @brief      This class manages the HTTP transaction that encapsulates a request and a response.
+ *
+ * @since      2.0
+ *
+ * The %HttpTransaction class manages the HTTP transaction that encapsulates a request and a response.
+ * A transaction represents an interaction between the HTTP client and the HTTP origin server.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_transaction.htm">HTTP Transaction</a>.
+ *
+ * The following example demonstrates how to use the %HttpTransaction class.
+ *
+ * @code
+ *
+    #include <FBase.h>
+    #include <FNet.h>
+
+    using namespace Tizen::Base;
+    using namespace Tizen::Net::Http;
+
+    void
+    TestHttpTransaction(void)
+    {
+        result r = E_SUCCESS;
+
+        HttpSession* pSession = null;
+        HttpTransaction* pTransaction = null;
+        String* pProxyAddr = null;
+        String hostAddr(L"http://www.tizen.org");
+
+        pSession = new HttpSession();
+        r = pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, pProxyAddr ,hostAddr, null);
+
+        // Open a new HttpTransaction.
+        pTransaction = pSession->OpenTransactionN();
+
+        r = pTransaction->AddHttpTransactionListener(*this);
+
+        HttpRequest* pRequest = pTransaction->GetRequest();
+        r = pRequest->SetUri(L"http://www.tizen.org");
+        r = pRequest->SetMethod(NET_HTTP_METHOD_GET);
+
+        // Submit the HttpTransaction.
+        r = pTransaction->Submit();
+    }
+
+ * @endcode
+ */
+
+class _OSP_EXPORT_ HttpTransaction
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since   2.0
+        */
+       virtual ~HttpTransaction(void);
+
+public:
+       /**
+        * Submits the HTTP request.
+        *
+        * @since           2.0
+        * @privilege           %http://tizen.org/privilege/http
+        *
+        * @return                      An error code
+        * @exception           E_SUCCESS                       The method is successful.
+        * @exception           E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception           E_INVALID_ARG           A specified input parameter is invalid. @n
+        *                                                                          At least one of Uri, Method, Header, and Body is invalid.
+        * @exception           E_INVALID_HEADER        The header is @c null.
+        * @exception       E_INVALID_STATE             The method invoked is invalid.
+        * @exception           E_OUT_OF_RANGE          The submitted data is out of range.
+        * @exception           E_MAX_EXCEEDED          The number of active transactions has exceeded the maximum limit.
+        * @exception           E_INVALID_PROXY         The proxy server address is invalid.
+        * @exception           E_DNS                           The DNS query has failed.
+        * @exception           E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation.
+        * @exception           E_EMPTY_BODY            The body is empty in a POST method case.
+        * @exception           E_INVALID_SESSION       The session is invalid.
+        * @exception           E_AUTHENTICATION        The authentication has failed.
+        * @exception           E_UNKNOWN                       An unknown error has occurred.
+        * @exception           E_SYSTEM                        A system error has occurred.
+        * @exception           E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @remarks                     The appropriate request header and body must be set using HttpRequest before using this method.
+        *                                      If the session is in a non-pipeline mode, be sure not to submit a transaction before the previous transaction is completed.
+        * @see                         HttpHeader
+        */
+       result Submit(void);
+
+       /**
+        * Gets the authentication information.
+        *
+        * @since       2.0
+        * @privilege   %http://tizen.org/privilege/http
+        *
+        * @return              A pointer to HttpAuthentication
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid.
+        * @exception   E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       HttpAuthentication* OpenAuthenticationInfoN(void);
+
+       /**
+        * Gets a pointer to the HttpRequest related to the transaction. @n
+        * Setting a request header, method, URI, and body can be done by using the @c pHttpRequest pointer.
+        *
+        * @since       2.0
+        *
+        * @return              The HttpRequest object pointer, @n
+        *                              else @c null in case of an invalid condition
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE     The method invoked is invalid.
+        * @exception   E_INVALID_DATA      The request is not valid.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see                 Tizen::Net::Http::HttpRequest
+        */
+       HttpRequest* GetRequest(void) const;
+
+       /**
+        * Gets a pointer to the HttpResponse related to the transaction. @n
+        * Getting a response header and body can be done by using the @c pHttpResponse pointer.
+        *
+        * @since       2.0
+        *
+        * @return              The HttpResponse object pointer, @n
+        *                              else @c null if the response is not received
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         The method invoked is invalid.
+        * @exception   E_INVALID_DATA      The response is not received.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see                 HttpResponse
+        */
+       HttpResponse* GetResponse(void) const;
+
+       /**
+        * Adds the IHttpTransactionEventListener instance. @n
+        * The added listener can listen to events as they are fired.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   listener                        The IHttpTransactionEventListener instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         The method invoked is invalid.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_OBJ_ALREADY_EXIST     The listener is already added.
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation, @n
+        *                                                                      because the caller thread is a worker thread.
+        */
+       result AddHttpTransactionListener(IHttpTransactionEventListener& listener);
+
+       /**
+        * Removes the IHttpTransactionEventListener instance.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   listener                        The IHttpTransactionEventListener instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         The method invoked is invalid.
+        * @exception   E_OBJ_NOT_FOUND         The specified instance is not found within the indicated range, or
+        *                                                                      the listener is already removed.
+        */
+       result RemoveHttpTransactionListener(IHttpTransactionEventListener& listener);
+
+       /**
+        * Sets the IHttpProgressEventListener instance.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   listener                        The IHttpProgressEventListener instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         The method invoked is invalid.
+        */
+       result SetHttpProgressListener(IHttpProgressEventListener& listener);
+
+       /**
+        * Sets a user object to the instance of %HttpTransaction.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   pUserData                       The user data to set
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         The method invoked is invalid.
+        */
+       result SetUserObject(const Tizen::Base::Object* pUserData);
+
+       /**
+        * Gets a user object that is set to the instance of %HttpTransaction.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        */
+       Tizen::Base::Object* GetUserObject(void) const;
+
+       /**
+        * Enables OnTransactionReadyToWrite.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the OnTransactionReadyToWrite listener is active, @n
+        *                              else @c false
+        */
+       bool EnableTransactionReadyToWrite(void);
+
+       /**
+        * Resumes the transaction after the IHttpTransactionEventListener::OnTransactionCertVerificationRequiredN() event is invoked. @n
+        * As described in the IHttpTransactionEventListener section, the above event occurs in case of the uncertified server certificate.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         The current state of the instance prohibits the execution of the specified operation.
+        */
+       result Resume(void);
+
+       /**
+        * Pauses the transaction after the IHttpTransactionEventListener::OnTransactionCertVerificationRequiredN() event is invoked. @n
+        * As described in the IHttpTransactionEventListener section, the above event occurs in case of the uncertified server certificate.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         The current state of the instance prohibits the execution of the specified operation.
+        */
+       result Pause(void);
+
+       /**
+        *      Sets a client certificate to connect the server.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   certificateId           The selected client certificate to set
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified input parameter is invalid.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        * @remarks     Start the AppControl(L"tizen.certificatemanager") for getting the selected client certificate. @n
+        *              For more information, see <a href="../org.tizen.native.appprogramming/html/guide/app/appcontrol_certmgr.htm">here</a>.
+        */
+       result SetClientCertificate(int certificateId);
+
+       /**
+        *      Sets the timeout in seconds that is the timeout for waiting the transaction. @n
+        *      A timeout value of zero means an infinite timeout.
+        *
+        *  @since              2.0
+        *
+        *      @return         An error code
+        *  @param[in]  timeout                                 A timeout for transaction
+        *      @exception      E_SUCCESS                               The method is successful.
+        *  @exception  E_INVALID_ARG                   The specified input parameter is invalid.
+        *  @exception  E_INVALID_STATE                 The transaction is already submitted, or
+        *                                      the transaction is already closed.
+        */
+       result SetTimeout(int timeout);
+
+private:
+       /**
+        * This default constructor is intentionally declared as private so that only the platform can create an instance.
+        */
+       HttpTransaction(void);
+
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %HttpTransaction
+        */
+       HttpTransaction(const HttpTransaction& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                             An instance of %HttpTransaction
+        */
+       HttpTransaction& operator =(const HttpTransaction& rhs);
+
+private:
+       friend class _HttpTransactionImpl;
+       _HttpTransactionImpl* __pHttpTransactionImpl;
+
+}; // HttpTransaction
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_TRANSACTION_H_
diff --git a/inc/FNetHttpHttpTypes.h b/inc/FNetHttpHttpTypes.h
new file mode 100755 (executable)
index 0000000..44e2c90
--- /dev/null
@@ -0,0 +1,424 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpTypes.h
+ * @brief              This is the header file for defining the primitive types for the HTTP operations.
+ *
+ * This header file contains the definition of the primitive types for the HTTP operations.
+ */
+
+#ifndef _FNET_HTTP_HTTP_TYPES_H_
+#define _FNET_HTTP_HTTP_TYPES_H_
+
+#include "FBaseObject.h"
+#include "FBaseColIComparer.h"
+#include "FBaseString.h"
+#include "FBaseErrorDefine.h"
+#include "FBaseColIHashCodeProvider.h"
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+/**
+ * @enum    NetHttpMethod
+ *
+ * Defines the HTTP method types. For the detailed description of each method, refer to HttpRequest::SetMethod().
+ *
+ * @since 2.0
+ */
+enum NetHttpMethod
+{
+       NET_HTTP_METHOD_GET = 0x40,         /**< The HTTP GET Method */
+       NET_HTTP_METHOD_OPTIONS = 0x41,     /**< The HTTP OPTIONS Method */
+       NET_HTTP_METHOD_HEAD = 0x42,        /**< The HTTP HEAD Method */
+       NET_HTTP_METHOD_DELETE = 0x43,      /**< The HTTP DELETE Method */
+       NET_HTTP_METHOD_TRACE = 0x44,       /**< The HTTP TRACE Method */
+       NET_HTTP_METHOD_POST = 0x60,        /**< The HTTP POST Method */
+       NET_HTTP_METHOD_PUT = 0x61,         /**< The HTTP PUT Method */
+       NET_HTTP_METHOD_CONNECT = 0x70,     /**< The HTTP CONNECT Method */
+};
+
+/**
+ * @enum       NetHttpSessionMode
+ *
+ * Defines the HTTP session mode.
+ *
+ * @since 2.0
+ */
+enum NetHttpSessionMode
+{
+       NET_HTTP_SESSION_MODE_NORMAL,           /**< The Normal Mode */
+       NET_HTTP_SESSION_MODE_PIPELINING,       /**< The Pipelining mode */
+       NET_HTTP_SESSION_MODE_MULTIPLE_HOST     /**< The Multiple host mode */
+};
+
+/**
+ * @enum       HttpVersion
+ *
+ * Defines the HTTP version
+ *
+ * @since 2.0
+ */
+enum HttpVersion
+{
+       HTTP_VERSION_1_0,   /**< %Http version 1.0 */
+       HTTP_VERSION_1_1    /**< %Http version 1.1 */
+};
+
+/**
+ * @if OSPDEPREC
+ * @enum    NetHttpStatusCode
+ *
+ * Defines the HTTP status code.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This enum is deprecated. Instead of using this enum, it is recommended to use the HTTP_STATUS_XXX constants.
+ * @since 2.0
+ * @endif
+ */
+enum NetHttpStatusCode
+{
+       NET_HTTP_STATUS_UNDEFINED = 0,                                          /**< @if OSPDEPREC The undefined status @endf */
+       NET_HTTP_STATUS_CONTINUE = 100,                                         /**< @if OSPDEPREC The status code: 100 Continue @endf */
+       NET_HTTP_STATUS_SWITCHING_PROTOCOLS = 101,                              /**< @if OSPDEPREC The status code: 101 Switching Protocols @endf */
+       NET_HTTP_STATUS_OK = 200,                                               /**< @if OSPDEPREC The status code: 200 OK @endf */
+       NET_HTTP_STATUS_CREATED = 201,                                          /**< @if OSPDEPREC The status code: 201 Created @endf */
+       NET_HTTP_STATUS_ACCEPTED = 202,                                         /**< @if OSPDEPREC The status code: 202 Accepted @endf */
+       NET_HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION = 203,                    /**< @if OSPDEPREC The status code: 203 Non-Authoritative Information @endf */
+       NET_HTTP_STATUS_NO_CONTENT = 204,                                       /**< @if OSPDEPREC The status code: 204 No %Content @endf */
+       NET_HTTP_STATUS_RESET_CONTENT = 205,                                    /**< @if OSPDEPREC The status code: 205 Reset %Content @endf */
+       NET_HTTP_STATUS_PARTIAL_CONTENT = 206,                                  /**< @if OSPDEPREC The status code: 206 Partial %Content @endf */
+
+       NET_HTTP_STATUS_MULTIPLE_CHOICE = 300,                                  /**< @if OSPDEPREC The status code: 300 Multiple Choices @endf */
+       NET_HTTP_STATUS_MOVED_PERMANENTLY = 301,                                /**< @if OSPDEPREC The status code: 301 Moved Permanently @endf */
+       NET_HTTP_STATUS_MOVED_TEMPORARILY = 302,                                /**< @if OSPDEPREC The status code: 302 Found @endf */
+       NET_HTTP_STATUS_SEE_OTHER = 303,                                        /**< @if OSPDEPREC The status code: 303 See Other @endf */
+       NET_HTTP_STATUS_NOT_MODIFIED = 304,                                     /**< @if OSPDEPREC The status code: 304 Not Modified @endf */
+       NET_HTTP_STATUS_USE_PROXY = 305,                                        /**< @if OSPDEPREC The status code: 305 Use Proxy @endf */
+
+       NET_HTTP_STATUS_BAD_REQUEST = 400,                                      /**< @if OSPDEPREC The status code: 400 Bad Request @endf */
+       NET_HTTP_STATUS_UNAUTHORIZED = 401,                                     /**< @if OSPDEPREC The status code: 401 Unauthorized @endf */
+       NET_HTTP_STATUS_PAYMENT_REQUIRED = 402,                                 /**< @if OSPDEPREC The status code: 402 Payment Required @endf */
+       NET_HTTP_STATUS_FORBIDDEN = 403,                                        /**< @if OSPDEPREC The status code: 403 Forbidden @endf */
+       NET_HTTP_STATUS_NOT_FOUND = 404,                                        /**< @if OSPDEPREC The status code: 404 Not Found @endf */
+       NET_HTTP_STATUS_METHOD_NOT_ALLOWED = 405,                               /**< @if OSPDEPREC The status code: 405 Method Not Allowed @endf */
+       NET_HTTP_STATUS_NOT_ACCEPTABLE = 406,                                   /**< @if OSPDEPREC The status code: 406 Not Acceptable @endf */
+       NET_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED = 407,                    /**< @if OSPDEPREC The status code: 407 Proxy Authentication Required @endf */
+       NET_HTTP_STATUS_REQUEST_TIME_OUT = 408,                                 /**< @if OSPDEPREC The status code: 408 Request Timeout (not used) @endf */
+       NET_HTTP_STATUS_CONFLICT = 409,                                         /**< @if OSPDEPREC The status code: 409 Conflict @endf */
+       NET_HTTP_STATUS_GONE = 410,                                             /**< @if OSPDEPREC The status code: 410 Gone @endf */
+       NET_HTTP_STATUS_LENGTH_REQUIRED = 411,                                  /**< @if OSPDEPREC The status code: 411 Length Required @endf */
+       NET_HTTP_STATUS_PRECONDITION_FAILED = 412,                              /**< @if OSPDEPREC  The status code: 412 Precondition Failed @endf */
+       NET_HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE = 413,                         /**< @if OSPDEPREC The status code: 413 Request Entity Too Large (not used) @endf */
+       NET_HTTP_STATUS_REQUEST_URI_TOO_LARGE = 414,                            /**< @if OSPDEPREC The status code: 414 Request-URI Too Long (not used) @endf */
+       NET_HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415,                           /**< @if OSPDEPREC The status code: 415 Unsupported %Media Type @endf */
+
+       NET_HTTP_STATUS_INTERNAL_SERVER_ERROR = 500,                            /**< @if OSPDEPREC The status code: 500 Internal Server Error @endf */
+       NET_HTTP_STATUS_NOT_IMPLEMENTED = 501,                                  /**< @if OSPDEPREC The status code: 501 Not Implemented @endf */
+       NET_HTTP_STATUS_BAD_GATEWAY = 502,                                      /**< @if OSPDEPREC The status code: 502 Bad Gateway @endf */
+       NET_HTTP_STATUS_SERVICE_UNAVAILABLE = 503,                              /**< @if OSPDEPREC The status code: 503 Service Unavailable @endf */
+       NET_HTTP_STATUS_GATEWAY_TIME_OUT = 504,                                 /**< @if OSPDEPREC The status code: 504 Gateway Timeout @endf */
+       NET_HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED = 505                        /**< @if OSPDEPREC The status code: 505 HTTP Version Not Supported @endf */
+};
+
+/**
+ * Status Code: 100 Continue
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_CONTINUE = 100;
+/**
+ * Status Code: 101 Switching Protocols
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_SWITCHING_PROTOCOLS = 101;
+
+/**
+ * Status Code: 200 OK
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_OK = 200;
+/**
+ * Status Code: 201 Created
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_CREATED = 201;
+/**
+ * Status Code: 202 Accepted
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_ACCEPTED = 202;
+/**
+ * Status Code: 203 Non-Authoritative Information
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION = 203;
+/**
+ * Status Code: 204 No %Content
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_NO_CONTENT = 204;
+/**
+ * Status Code: 205 Reset %Content
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_RESET_CONTENT = 205;
+/**
+ * Status Code: 206 Partial %Content
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_PARTIAL_CONTENT = 206;
+/**
+ * Status Code: 300 Multiple Choices
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_MULTIPLE_CHOICE = 300;
+/**
+ * Status Code: 301 Moved Permanently
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_MOVED_PERMANENTLY = 301;
+/**
+ * Status Code: 302 Found
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_FOUND = 302;
+/**
+ * Status Code: 303 See Other
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_SEE_OTHER = 303;
+/**
+ * Status Code: 304 Not Modified
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_NOT_MODIFIED = 304;
+/**
+ * Status Code: 305 Use Proxy
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_USE_PROXY = 305;
+/**
+ * Status Code: 306 Switch Proxy
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_SWITCH_PROXY = 306;
+/**
+ * Status Code: 307 Temporary Redirect
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_TEMPORARY_REDIRECT = 307;
+
+/**
+ * Status Code: 400 Bad Request
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_BAD_REQUEST = 400;
+/**
+ * Status Code: 401 Unauthorized
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_UNAUTHORIZED = 401;
+/**
+ * Status Code: 402 Payment Required
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_PAYMENT_REQUIRED = 402;
+/**
+ * Status Code: 403 Forbidden
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_FORBIDDEN = 403;
+/**
+ * Status Code: 404 Not Found
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_NOT_FOUND = 404;
+/**
+ * Status Code: 405 Method Not Allowed
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_METHOD_NOT_ALLOWED = 405;
+/**
+ * Status Code: 406 Not Acceptable
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_NOT_ACCEPTABLE = 406;
+/**
+ * Status Code: 407 Proxy Authentication Required
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED = 407;
+/**
+ * Status Code: 408 Request Timeout
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_REQUEST_TIMEOUT = 408;
+/**
+ * Status Code: 409 Conflict
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_CONFLICT = 409;
+/**
+ * Status Code: 410 Gone
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_GONE = 410;
+/**
+ * Status Code: 411 Length Required
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_LENGTH_REQUIRED = 411;
+/**
+ * Status Code: 412 Precondition Failed
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_PRECONDITION_FAILED = 412;
+/**
+ * Status Code: 413 Request Entity Too Large
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE = 413;
+/**
+ * Status Code: 414 Request-URI Too Long
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_REQUEST_URI_TOO_LONG = 414;
+/**
+ * Status Code: 415 Unsupported %Media Type
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415;
+/**
+ * Status Code: 416 Requested Range Not Satisfiable
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
+/**
+ * Status Code: 417 Expectation Failed
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_EXPECTATION_FAILED = 417;
+
+
+/**
+ * Status Code: 500 Internal Server Error
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_INTERNAL_SERVER_ERROR = 500;
+/**
+ * Status Code: 501 Not Implemented
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_NOT_IMPLEMENTED = 501;
+/**
+ * Status Code: 502 Bad Gateway
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_BAD_GATEWAY = 502;
+/**
+ * Status Code: 503 Service Unavailable
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_SERVICE_UNAVAILABLE = 503;
+/**
+ * Status Code: 504 Gateway Timeout
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_GATEWAY_TIMEOUT = 504;
+/**
+ * Status Code: 505 HTTP Version Not Supported
+ *
+ * @since 2.0
+ */
+static const int HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED = 505;
+
+/**
+ * @enum    NetHttpAuthScheme
+ *
+ * Defines the supported authentication schemes.
+ *
+ * @since 2.0
+ */
+enum NetHttpAuthScheme
+{
+       NET_HTTP_AUTH_NONE = 0,             /**< The no authentication type */
+       NET_HTTP_AUTH_PROXY_BASIC = 1,      /**< The authentication type is Proxy Basic Authentication */
+       NET_HTTP_AUTH_PROXY_MD5 = 2,        /**< The authentication type is Proxy Digest Authentication */
+       NET_HTTP_AUTH_WWW_BASIC = 3,        /**< The authentication Type is HTTP Basic Authentication */
+       NET_HTTP_AUTH_WWW_MD5 = 4,          /**< The authentication type is HTTP Digest Authentication */
+       NET_HTTP_AUTH_PROXY_NTLM = 5,       /**< The authentication type is Proxy NTLM Authentication */
+       NET_HTTP_AUTH_WWW_NTLM = 7,         /**< The authentication type is NTLM Authentication */
+       NET_HTTP_AUTH_WWW_NEGOTIATE = 8     /**< The authentication type is Negotiate Authentication */
+};
+
+/**
+ * @enum    NetHttpCookieFlag
+ *
+ * Defines the HTTP cookie mode.
+ *
+ * @since 2.0
+ */
+enum  NetHttpCookieFlag
+{
+       NET_HTTP_COOKIE_FLAG_NONE,              /**< The mode is not defined */
+       NET_HTTP_COOKIE_FLAG_ALWAYS_AUTOMATIC,  /**< The cookie will be parsed and saved, and also attached to request automatically */
+       NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL      /**< The cookie will be handled by the user action with Tizen::Net::Http::HttpRequest::SetCookie() and Tizen::Net::Http::HttpCookieStorageManager::GetCookies() */
+};
+
+} } } //Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_TYPES_H_
diff --git a/inc/FNetHttpHttpUrlEncodedEntity.h b/inc/FNetHttpHttpUrlEncodedEntity.h
new file mode 100755 (executable)
index 0000000..01ca264
--- /dev/null
@@ -0,0 +1,233 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpUrlEncodedEntity.h
+ * @brief              This is the header file for the %HttpUrlEncodedEntity class.
+ *
+ * This header file contains the declarations of the %HttpUrlEncodedEntity class.
+ */
+
+#ifndef _FNET_HTTP_HTTP_URL_ENCODED_ENTITY_H_
+#define _FNET_HTTP_HTTP_URL_ENCODED_ENTITY_H_
+
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpIHttpEntity.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+class ByteBuffer;
+} }
+
+namespace Tizen { namespace Text
+{
+class Encoding;
+} }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpUrlEncodedEntityImpl;
+
+/**
+ * @class      HttpUrlEncodedEntity
+ * @brief      This class represents a http body for urlencoded pairs (name and value).
+ *
+ * @since 2.0
+ *
+ * The %HttpUrlEncodedEntity class represents a http body for urlencoded pairs (name and value).
+ *
+ * The following example demonstrates how to use the %HttpUrlEncodedEntity class to send the content for urlencoded pairs to the server.
+ *
+ * @code
+
+    #include <FBase.h>
+    #include <FNet.h>
+
+    using namespace Tizen::Base;
+    using namespace Tizen::Net::Http;
+
+    void
+    TestHttpUrlEncodedEntity(void)
+    {
+        result r = E_SUCCESS;
+
+        HttpSession* pSession = null;
+        HttpTransaction* pTransaction = null;
+        HttpRequest* pRequest = null;
+        String hostAddr(L"http://www.tizen.org");
+
+        pSession = new HttpSession();
+        r = pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, hostAddr, null);
+
+        pTransaction = pSession->OpenTransactionN();
+        r = pTransaction->AddHttpTransactionListener(*this);
+
+        pRequest = const_cast<HttpRequest*>(pTransaction->GetRequest());
+        r = pRequest->SetUri(L"http://www.tizen.org/test");
+        r = pRequest->SetMethod(NET_HTTP_METHOD_POST);
+
+        HttpUrlEncodedEntity* pHttpUrlEncodedEntity = new HttpUrlEncodedEntity();
+        r = pHttpUrlEncodedEntity->Construct();
+
+        r = pHttpUrlEncodedEntity->AddParameter(L"name1", L"value1");
+        r = pHttpUrlEncodedEntity->AddParameter(L"name2", L"value2");
+
+        r = pRequest->SetEntity(*pHttpUrlEncodedEntity);
+
+        // Sends the HttpTransaction.
+        r = pTransaction->Submit();
+    }
+
+ * @endcode
+ */
+
+class _OSP_EXPORT_ HttpUrlEncodedEntity
+       : public Tizen::Base::Object
+       , public IHttpEntity
+{
+
+public:
+       /**
+        * 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.
+        *
+        * @since       2.0
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        */
+       HttpUrlEncodedEntity(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since 2.0
+        */
+       virtual ~HttpUrlEncodedEntity(void);
+
+       /**
+        * Initializes this instance of %HttpUrlEncodedEntity.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        * @remarks             The default content type is "application/x-www-form-urlencoded" and default charset is "ISO-8859-1".
+        */
+       result Construct(void);
+
+       /**
+        * Initializes this instance of %HttpUrlEncodedEntity with the specified parameters.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   charset                                         The character set of the entity
+        * @param[in]   encoding                                        An encoding scheme for parameters
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @remarks             The default content type is "application/x-www-form-urlencoded".
+        */
+       result Construct(const Tizen::Base::String& charset, const Tizen::Text::Encoding& encoding);
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %HttpUrlEncodedEntity
+        */
+       HttpUrlEncodedEntity(const HttpUrlEncodedEntity& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                             An instance of %HttpUrlEncodedEntity
+        */
+       HttpUrlEncodedEntity& operator =(const HttpUrlEncodedEntity& rhs);
+
+public:
+       /**
+        * Gets the length of the request content.
+        *
+        * @since       2.0
+        *
+        * @return              The length of the content, @n
+        *                              else @c -1 if the content length is unknown
+        */
+       virtual long long GetContentLength(void) const;
+
+       /**
+        * Gets the type of the request content.
+        *
+        * @since       2.0
+        *
+        * @return              The type of the content
+        */
+       virtual Tizen::Base::String GetContentType(void) const;
+
+       /**
+        * Adds the form data (name and value pairs) to %HttpUrlEncodedEntity.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   name                                            The name of the urlencoded entity
+        * @param[in]   value                                           The value of the urlencoded entity
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ARG                           A specified input parameter is invalid.
+        * @exception   E_INVALID_ENCODING_RANGE    The specified @c name or @c value contains code points that are outside the bounds of the specified @c encoding.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        */
+       result AddParameter(const Tizen::Base::String& name, const Tizen::Base::String& value);
+
+protected:
+       /**
+        * Checks whether the next data exists.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the next data exists, @n
+        *                              else @c false
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual bool HasNextData(void);
+
+       /**
+        * Gets the next data.
+        *
+        * @since       2.0
+        *
+        * @return              The buffer to be read
+        * @param[in]   recommendedSize                 The recommended size of the data to send
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual Tizen::Base::ByteBuffer* GetNextDataN(int recommendedSize);
+
+private:
+       friend class _HttpUrlEncodedEntityImpl;
+       _HttpUrlEncodedEntityImpl* __pHttpUrlEncodedEntityImpl;
+
+}; // HttpUrlEncodedEntity
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_URL_ENCODED_ENTITY_H_
diff --git a/inc/FNetHttpHttpXmlDomEntity.h b/inc/FNetHttpHttpXmlDomEntity.h
new file mode 100755 (executable)
index 0000000..ce257d1
--- /dev/null
@@ -0,0 +1,200 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpXmlDomEntity.h
+ * @brief              This is the header file for the %HttpXmlDomEntity class.
+ *
+ * This header file contains the declarations of the %HttpXmlDomEntity class.
+ */
+
+#ifndef _FNET_HTTP_HTTP_XML_DOM_ENTITY_H_
+#define _FNET_HTTP_HTTP_XML_DOM_ENTITY_H_
+
+#include <libxml/tree.h>
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpIHttpEntity.h>
+
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpXmlDomEntityImpl;
+
+/**
+ * @class      HttpXmlDomEntity
+ * @brief      This class represents a http body for the xml content.
+ *
+ * @since 2.0
+ *
+ * The %HttpXmlDomEntity class represents a http body for the xml content. @n
+ *
+ * The following example demonstrates how to use the %HttpXmlDomEntity class to send the xml content to the server.
+ *
+ * @code
+
+    #include <FBase.h>
+    #include <FNet.h>
+    #include <FXml.h>
+
+    using namespace Tizen::Base;
+    using namespace Tizen::Net::Http;
+
+
+    void
+    TestHttpXmlDomEntity(void)
+    {
+        result r = E_SUCCESS;
+
+        HttpSession* pSession = null;
+        HttpTransaction* pTransaction = null;
+        HttpRequest* pRequest = null;
+        String hostAddr(L"http://www.tizen.org");
+
+        pSession = new HttpSession();
+        r = pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, hostAddr, null);
+
+        pTransaction = pSession->OpenTransactionN();
+        r = pTransaction->AddHttpTransactionListener(*this);
+
+        pRequest = const_cast<HttpRequest*>(pTransaction->GetRequest());
+        r = pRequest->SetUri(L"http://www.tizen.org/test");
+        r = pRequest->SetMethod(NET_HTTP_METHOD_POST);
+
+        xmlDoc* pDocument = MakeDomTree();
+        HttpXmlDomEntity* pHttpXmlDomEntity = new HttpXmlDomEntity();
+        pHttpXmlDomEntity->Construct(*pDocument, L"UTF-8");
+
+        r = pRequest->SetEntity(*pHttpXmlDomEntity);
+
+        // Sends the HttpTransaction.
+        r = pTransaction->Submit();
+    }
+
+ * @endcode
+ */
+
+class _OSP_EXPORT_ HttpXmlDomEntity
+       : public Tizen::Base::Object
+       , public IHttpEntity
+{
+
+public:
+       /**
+        * 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.
+        *
+        * @since       2.0
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        */
+       HttpXmlDomEntity(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since 2.0
+        */
+       virtual ~HttpXmlDomEntity(void);
+
+       /**
+        * Initializes this instance of %HttpXmlDomEntity with the specified parameters.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @param[in]   xmlDocument                                     The DOM instance of the xml content
+        * @param[in]   encodingScheme                          The encoding scheme for the document
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_ENCODING_RANGE    The document contains code points that are outside the bounds specified by @c encodingScheme.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @remarks             The default content type is "text/xml".
+        */
+       result Construct(const xmlDoc& xmlDocument, const Tizen::Base::String& encodingScheme = L"UTF-8");
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %HttpXmlDomEntity
+        */
+       HttpXmlDomEntity(const HttpXmlDomEntity& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                             An instance of %HttpXmlDomEntity
+        */
+       HttpXmlDomEntity& operator =(const HttpXmlDomEntity& rhs);
+
+public:
+       /**
+        * Gets the length of the request content.
+        *
+        * @since       2.0
+        *
+        * @return              The length of the content, @n
+        *                              else @c -1 if the content length is unknown
+        */
+       virtual long long GetContentLength(void) const;
+
+       /**
+        * Gets the type of the request content.
+        *
+        * @since       2.0
+        *
+        * @return              The type of the content
+        */
+       virtual Tizen::Base::String GetContentType(void) const;
+
+protected:
+       /**
+        * Checks whether the next data exists.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the next data exists, @n
+        *                              else @c false
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual bool HasNextData(void);
+
+       /**
+        * Gets the next data.
+        *
+        * @since       2.0
+        *
+        * @return              The buffer to be read
+        * @param[in]   recommendedSize                 The recommended size of the data to send
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual Tizen::Base::ByteBuffer* GetNextDataN(int recommendedSize);
+
+private:
+       friend class _HttpXmlDomEntityImpl;
+       _HttpXmlDomEntityImpl* __pHttpXmlDomEntityImpl;
+
+}; // HttpXmlDomEntity
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_HTTP_XML_DOM_ENTITY_H_
diff --git a/inc/FNetHttpIHttpEntity.h b/inc/FNetHttpIHttpEntity.h
new file mode 100755 (executable)
index 0000000..7c5bee1
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpIHttpEntity.h
+ * @brief              This is the header file for the %IHttpEntity interface.
+ *
+ * This header file contains the declarations of the %IHttpEntity interface.
+ */
+
+#ifndef _FNET_HTTP_IHTTP_ENTITY_H_
+#define _FNET_HTTP_IHTTP_ENTITY_H_
+
+#include <FBaseTypes.h>
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FNetHttpHttpTypes.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpRequestImpl;
+/**
+ * @interface  IHttpEntity
+ * @brief              This interface provides common functions for the HTTP entity.
+ *
+ * @since       2.0
+ *
+ *     The %IHttpEntity interface represents the HTTP entity for the data exchanged between the client and the server.
+ */
+
+
+class _OSP_EXPORT_ IHttpEntity
+{
+
+public:
+       /**
+        * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since       2.0
+        */
+       virtual ~IHttpEntity(void) {}
+
+public:
+       /**
+        * Gets the length of the request content.
+        *
+        * @since       2.0
+        *
+        * @return              The length of the content, @n
+        *                              else @c -1 if the content length is unknown
+        */
+       virtual long long GetContentLength(void) const = 0;
+
+       /**
+        * Gets the type of the request content.
+        *
+        * @since       2.0
+        *
+        * @return              The type of the content
+        */
+       virtual Tizen::Base::String GetContentType(void) const = 0;
+
+protected:
+       /**
+        * Checks whether the next data exists.
+        *
+        * @since       2.0
+        *
+        * @return              @c true if the next data exists, @n
+        *                              else @c false
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual bool HasNextData(void) = 0;
+
+       /**
+        * Gets the next data.
+        *
+        * @since       2.0
+        *
+        * @return              The buffer to be read
+        * @param[in]   recommendedSize                 The recommended size of the data to send
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_INVALID_STATE                 The method invoked is invalid.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       virtual Tizen::Base::ByteBuffer* GetNextDataN(int recommendedSize) = 0;
+
+protected:
+       // Reserved virtual methods for later extension.
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IHttpEntity_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IHttpEntity_Reserved2(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IHttpEntity_Reserved3(void) {}
+
+       friend class _HttpRequestImpl;
+};
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_IHTTP_ENTITY_H_
diff --git a/inc/FNetHttpIHttpProgressEventListener.h b/inc/FNetHttpIHttpProgressEventListener.h
new file mode 100755 (executable)
index 0000000..8bdc683
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpIHttpProgressEventListener.h
+ * @brief              This is the header file for the %IHttpProgressEventListener interface.
+ *
+ * This header file contains the declarations of the %IHttpProgressEventListener interface.
+ */
+
+#ifndef _FNET_HTTP_IHTTP_PROGRESS_EVENT_LISTENER_H_
+#define _FNET_HTTP_IHTTP_PROGRESS_EVENT_LISTENER_H_
+
+#include <FBaseTypes.h>
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpSession;
+class HttpTransaction;
+/**
+ * @interface  IHttpProgressEventListener
+ * @brief              This interface provides the listeners for the HTTP progress events.
+ *
+ * @since       2.0
+ *
+ *  The %IHttpProgressEventListener interface is the listener for the HTTP progress events, when the HTTP message is uploaded or downloaded. In order to use this listener,
+ *     the listener must be set to the HttpTransaction instance using the SetHttpProgressListener() method.
+ */
+
+class _OSP_EXPORT_ IHttpProgressEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+
+public:
+       /**
+       * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+       *
+       * @since 2.0
+       */
+       virtual ~IHttpProgressEventListener(void) {}
+
+public:
+       /**
+        * Called to notify when the content body of the request message is being uploaded.
+        *
+        * @since       2.0
+        *
+        * @param[in]   httpSession                             The session information of the %Http transaction event
+        * @param[in]   httpTransaction                 The transaction information of the %Http transaction event
+        * @param[in]   currentLength                   The current length of the uploaded data (in bytes)
+        * @param[in]   totalLength                             The total length of the data (in bytes) to upload
+        * @remarks             If the content length of the request message is not set, the value of @c totalLength is -1.
+        */
+       virtual void OnHttpUploadInProgress(HttpSession& httpSession, HttpTransaction& httpTransaction, long long currentLength, long long totalLength) = 0;
+
+       /**
+        * Called to notify when the content body of the response message is being downloaded.
+        *
+        * @since       2.0
+        *
+        * @param[in]   httpSession                             The session information of the %Http transaction event
+        * @param[in]   httpTransaction                 The transaction information of the %Http transaction event
+        * @param[in]   currentLength                   The current length of the downloaded data (in bytes)
+        * @param[in]   totalLength                             The total length of the data (in bytes) to download
+        * @remarks             If the content length of the response message is not set, the value of @c totalLength is -1.
+        */
+       virtual void OnHttpDownloadInProgress(HttpSession& httpSession, HttpTransaction& httpTransaction, long long currentLength, long long totalLength) = 0;
+
+protected:
+       // Reserved virtual methods for later extension.
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IHttpProgressEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IHttpProgressEventListener_Reserved2(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IHttpProgressEventListener_Reserved3(void) {}
+};
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_IHTTP_PROGRESS_EVENT_LISTENER_H_
diff --git a/inc/FNetHttpIHttpTransactionEventListener.h b/inc/FNetHttpIHttpTransactionEventListener.h
new file mode 100755 (executable)
index 0000000..721ea84
--- /dev/null
@@ -0,0 +1,179 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpIHttpTransactionEventListener.h
+ * @brief              This is the header file for the %IHttpTransactionEventListener interface.
+ *
+ * This header file contains the declarations of the %IHttpTransactionEventListener interface.
+ */
+
+#ifndef _FNET_HTTP_IHTTP_TRANSACTION_EVENT_LISTENER_H_
+#define _FNET_HTTP_IHTTP_TRANSACTION_EVENT_LISTENER_H_
+
+#include <FBaseTypes.h>
+#include <FBaseString.h>
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpSession;
+class HttpTransaction;
+/**
+ * @interface  IHttpTransactionEventListener
+ * @brief              This interface provides listeners for the HTTP transaction events.
+ *
+ * @since       2.0
+ *
+ * @remarks    If a user-defined class is derived from multiple classes including this interface, a compile error for using an ambiguous base class can occur. @n
+ *          In this case, type casting is required to declare an explicit base class for the user-defined class.
+ *
+ * The %IHttpTransactionEventListener interface provides listeners for the HTTP transaction events. To use this listener, you must add it to the HttpTransaction instance
+ * through the AddListener() method. If an HTTP transaction event is generated, a method of this class is called.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_transaction.htm">HTTP Transaction</a>.
+ */
+
+class _OSP_EXPORT_ IHttpTransactionEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+
+public:
+       /**
+        * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since   2.0
+        */
+       virtual ~IHttpTransactionEventListener(void) {}
+
+public:
+       /**
+        * Called to notify when the content body of the response has been received.
+        *
+        * @since       2.0
+        *
+        * @param[in]   httpSession                                     The session information of the %Http transaction event
+        * @param[in]   httpTransaction                         The transaction information of the %Http transaction event
+        * @param[in]   availableBodyLen                        The length of the available body of the %Http transaction
+        * @see                 HttpResponse::ReadBodyN()
+        */
+       virtual void OnTransactionReadyToRead(HttpSession& httpSession, HttpTransaction& httpTransaction, int availableBodyLen) = 0;
+
+       /**
+        * Called to notify when the process of transaction has been aborted.
+        *
+        * @since       2.0
+        *
+        * @param[in]   httpSession                                     The session information of the %Http transaction event
+        * @param[in]   httpTransaction                         The transaction information of the %Http transaction event
+        * @param[in]   r                                                       The cause of the error
+        * @exception   E_INVALID_ARG                           A specified input parameter is invalid.
+        * @exception   E_OUT_OF_MEMORY                         The memory is insufficient.
+        * @exception   E_IO                                            The method has failed to read the data.
+        * @exception   E_TIMEOUT                                       An attempt to connect to the server has timed out.
+        * @exception   E_NETWORK_UNAVAILABLE           The network is unavailable.
+        * @exception   E_HOST_UNREACHABLE                      The network cannot be reached from this host at this time.
+        * @exception   E_SYSTEM                                        An internal error has occurred.
+        * @exception   E_UNKNOWN                                       An unknown error has occurred.
+        * @exception   E_NOT_RESPONDING                        There is no response.
+        * @exception   E_INVALID_CONTENT                       The content is invalid.
+        * @exception   E_CONNECTION_RESET                      The network connection has been reset.
+        * @exception   E_HTTP_USER                                     The HTTP user is canceled.
+        * @exception   E_NO_CERTIFICATE                        The client certificate is required to connect to the server.
+        * @exception   E_UNSUPPORTED_SERVICE           The service is not allowed.
+        * @exception   E_USER_AGENT_NOT_ALLOWED        The user agent is not allowed.
+        * @exception   E_RESOURCE_UNAVAILABLE          The network resource is unavailable.
+        * @remarks     If the E_NO_CERTIFICATE exception is thrown, start the AppControl(L"tizen.certificatemanager") for getting the selected client certificate. @n
+        *              For more information, see <a href="../org.tizen.native.appprogramming/html/guide/app/appcontrol_certmgr.htm">here</a>.
+        */
+       virtual void OnTransactionAborted(HttpSession& httpSession, HttpTransaction& httpTransaction, result r) = 0;
+
+       /**
+        * Called to add chunks to the request.
+        *
+        * @since       2.0
+        *
+        * @param[in]   httpSession                                     The session information of the %Http transaction event
+        * @param[in]   httpTransaction                         The transaction information of the %Http transaction event
+        * @param[in]   recommendedChunkSize            The length of the chunked %Http transaction
+        * @remarks     To enable this listener, HttpTransaction::EnableTransactionReadyToWrite() must be called.
+        * @see                 HttpRequest::WriteBody()
+        */
+       virtual void OnTransactionReadyToWrite(HttpSession& httpSession, HttpTransaction& httpTransaction, int recommendedChunkSize) = 0;
+
+       /**
+        * Called to notify when the header of response has been received.
+        *
+        * @since       2.0
+        *
+        * @param[in]   httpSession                                     The session information of the %Http transaction event
+        * @param[in]   httpTransaction                         The transaction information of the %Http transaction event
+        * @param[in]   headerLen                                       The length of the %Http transaction's header
+        * @param[in]   bAuthRequired                           Set to @c true if the transaction requires authentication, @n
+        *                                                                                      else @c false
+        * @see                 HttpResponse::GetHeader()
+        */
+       virtual void OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool bAuthRequired) = 0;
+
+       /**
+        * Called to notify when the process of transaction has been completed.
+        *
+        * @since       2.0
+        *
+        * @param[in]   httpSession                                     The session information of the %Http transaction event
+        * @param[in]   httpTransaction                         The transaction information of the %Http transaction event
+        * @see                 HttpResponse::GetHeader()
+     * @see            HttpResponse::ReadBodyN()
+        */
+       virtual void OnTransactionCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction) = 0;
+
+       /**
+        * Called to accept input from the user on whether to resume or pause the transaction in case the certificate is not verified.
+        *
+        * @since           2.0
+        *
+        * @param[in]           httpSession                             The session information of the %Http transaction event
+        * @param[in]           httpTransaction                 The transaction information of the %Http transaction event
+        * @param[in]           pCert                                   The certificate information
+        * @see                         HttpTransaction::Resume()
+     * @see            HttpTransaction::Pause()
+        */
+       virtual void OnTransactionCertVerificationRequiredN(HttpSession& httpSession, HttpTransaction& httpTransaction, Tizen::Base::String* pCert) = 0;
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IHttpTransactionEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IHttpTransactionEventListener_Reserved2(void) {}
+
+};
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_IHTTP_TRANSACTION_EVENT_LISTENER_H_
diff --git a/inc/FNetIDnsEventListener.h b/inc/FNetIDnsEventListener.h
new file mode 100644 (file)
index 0000000..6118d8b
--- /dev/null
@@ -0,0 +1,143 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FNetIDnsEventListener.h
+ * @brief      This is the header file for the %IDnsEventListener interface.
+ *
+ * This header file contains the declarations of the %IDnsEventListener interface.
+ *
+ */
+#ifndef _FNET_IDNS_EVENT_LISTENER_H_
+#define _FNET_IDNS_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Net
+{
+class IpHostEntry;
+/**
+ * @interface  IDnsEventListener
+ * @brief              This interface implements listeners for DNS events.
+ *
+ * @since              2.0
+ *
+ * The %IDnsEventListener interface provides methods for creating notifications about different types of DNS events. These events are only sent
+ * out if a listener is added to the DNS object in the Construct() method. When a DNS event is generated, one of these methods is called. The
+ * methods of this interface may be overridden and used in any application that uses DNS.
+ *
+ * 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>.
+ *
+ * @see        Tizen::Net::IpHostEntry
+ *
+ * The following example demonstrates how to use the %IDnsEventListener interface.
+ *
+ * @code
+ *
+ *     using namespace Tizen::Net;
+ *
+ *     class MyDnsListener
+ *             : public IDnsEventListener
+ *     {
+ *     public:
+ *             void OnDnsResolutionCompletedN(IpHostEntry* ipHostEntry, result r);
+ *     };
+ *
+ *     void
+ *     MyDnsListener::OnDnsResolutionCompletedN(IpHostEntry* ipHostEntry, result r)
+ *     {
+ *             if (ipHostEntry == null)
+ *             {
+ *                     AppLog("error case no.%d \n", r);
+ *             }
+ *             else
+ *             {
+ *                     Tizen::Base::Collection::IList* addressList = ipHostEntry->GetAddressList();
+ *
+ *                     if (addressList != null)
+ *                     {
+ *                             int count = addressList->GetCount();
+ *
+ *                             for (int i = 0; i < count; i++)
+ *                             {
+ *                                     IpAddress* pIpAddress = (IpAddress*)(addressList->GetAt(i));
+ *                                     Tizen::Base::ByteBuffer*_pbb = Tizen::Base::Utility::StringUtil::StringToUtf8N(pIpAddress->ToString());
+ *
+ *                                     AppLog("IpAddress no.%d : %s\n", i, (char*)(_pbb->GetPointer()));
+ *                                     delete _pbb;
+ *                             }
+ *                     }
+ *
+ *                     Tizen::Base::Collection::IList* aliasList = ipHostEntry->GetAliasList();
+ *
+ *                     if (aliasList != null)
+ *                     {
+ *                             int count = aliasList->GetCount();
+ *
+ *                             for (int i = 0; i < count; i++)
+ *                             {
+ *                                     String* alias = (String*)(aliasList->GetAt(i));
+ *                                     Tizen::Base::ByteBuffer*_pbb = Tizen::Base::Utility::StringUtil::StringToUtf8N(*alias);
+ *
+ *                                     AppLog("alias no.%d : %s\n", i, (char*)(_pbb->GetPointer()));
+ *                                     delete _pbb;
+ *                             }
+ *                     }
+ *                     delete ipHostEntry;
+ *             }
+ *     }
+ *
+ * @endcode
+ *
+ */
+class _OSP_EXPORT_ IDnsEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+       /**
+        * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since       2.0
+        */
+       virtual ~IDnsEventListener(void) {}
+
+public:
+       /**
+        * Called to notify the result of the Dns request.
+        *
+        * @since               2.0
+        *
+        * @param[in]   pIpHostEntry                    The information on the dns event
+        * @param[in]   r                                               The cause of the error
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_IN_PROGRESS                   A previous request is in progress.
+        * @exception   E_INVALID_SERVER                The requested server is invalid.
+        * @exception   E_INVALID_DOMAIN                The requested domain of the server is invalid.
+        * @exception   E_NETWORK_UNAVAILABLE   The network is unavailable.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_TIMEOUT                               An attempt to connect to the server has timed out.
+        * @exception   E_NOT_RESPONDING                There is no response.
+        * @exception   E_DNS_NOT_FOUND                 The DNS lookup has failed.
+        * @remarks             Always check the error code before accessing the result.
+        *                              If @c r is not E_SUCCESS, @c ipHostEntry may not exist.
+        */
+       virtual void OnDnsResolutionCompletedN(IpHostEntry* pIpHostEntry, result r) = 0;
+}; // IDnsEventListener
+
+} } // Tizen::Net
+
+#endif // _FNET_IDNS_EVENT_LISTENER_H_
diff --git a/inc/FNetILocalDhcpServerEventListener.h b/inc/FNetILocalDhcpServerEventListener.h
new file mode 100644 (file)
index 0000000..e91d23a
--- /dev/null
@@ -0,0 +1,113 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FNetILocalDhcpServerEventListener.h
+ * @brief      This is the header file for the %ILocalDhcpServerEventListener interface.
+ *
+ * This is the header file for the %ILocalDhcpServerEventListener interface.
+ *
+ */
+#ifndef _FNET_ILOCAL_DHCP_SERVER_EVENT_LISTENER_H_
+#define _FNET_ILOCAL_DHCP_SERVER_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Net
+{
+class LocalDhcpServer;
+class DhcpClientInfo;
+/**
+ * @interface  ILocalDhcpServerEventListener
+ * @brief              This interface defines the listeners for the local DHCP server events.
+ *
+ * @since              2.0
+ *
+ * The %ILocalDhcpServerEventListener interface provides methods for creating notifications about the different kinds of DHCP server events.
+ * These events are only sent out when %ILocalDhcpServerEventListener is added to a LocalDhcpServer instance, by invoking the
+ * SetLocalDhcpServerEventListener() method. When a %LocalDhcpServer event is generated, one of these methods is called. The methods of this
+ * interface may be overridden and used in any application that uses the local DHCP server.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/local_DHCP_server_access.htm">Local DHCP Server Access</a>.
+ *
+ * @see        Tizen::Net::DhcpClientInfo
+ */
+class _OSP_EXPORT_ ILocalDhcpServerEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+       /** This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since 2.0
+        */
+       virtual ~ILocalDhcpServerEventListener(void) {}
+
+public:
+       /**
+        * Called to notify the application that the client network connection on the local DHCP server has been connected.
+        *
+        * @since       2.0
+        *
+        * @param[in]   localDhcpServer         The requested local DHCP server
+        * @param[in]   dhcpClientInfo          The connected client information on the local DHCP server event
+        */
+       virtual void OnDhcpClientConnectedN(LocalDhcpServer& localDhcpServer, DhcpClientInfo& dhcpClientInfo) = 0;
+
+       /**
+        * Called to notify the application that the client network connection on the local DHCP server has been disconnected.
+        *
+        * @since       2.0
+        *
+        * @param[in]   localDhcpServer         The requested local DHCP server
+        * @param[in]   dhcpClientInfo          The disconnected client information on the local DHCP server event
+        */
+       virtual void OnDhcpClientDisconnectedN(LocalDhcpServer& localDhcpServer, DhcpClientInfo& dhcpClientInfo) = 0;
+
+protected:
+       // Reserved virtual methods for later extension.
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void ILocalDhcpServerEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void ILocalDhcpServerEventListener_Reserved2(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void ILocalDhcpServerEventListener_Reserved3(void) {}
+}; // ILocalDhcpServerEventListener
+
+} } // Tizen::Net
+
+#endif // _FNET_ILOCAL_DHCP_SERVER_EVENT_LISTENER_H_
diff --git a/inc/FNetIManagedNetConnectionEventListener.h b/inc/FNetIManagedNetConnectionEventListener.h
new file mode 100644 (file)
index 0000000..ccca860
--- /dev/null
@@ -0,0 +1,146 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FNetIManagedNetConnectionEventListener.h
+ * @brief      This is the header file for the %IManagedNetConnectionEventListener interface.
+ *
+ * This header file contains the declarations of the %IManagedNetConnectionEventListener interface.
+ *
+ */
+#ifndef _FNET_IMANAGED_NET_CONNECTION_EVENT_LISTENER_H_
+#define _FNET_IMANAGED_NET_CONNECTION_EVENT_LISTENER_H_
+
+#include <FBase.h>
+#include <FNetNetTypes.h>
+
+namespace Tizen { namespace Net
+{
+class ManagedNetConnection;
+/**
+ * @interface  IManagedNetConnectionEventListener
+ * @brief              This interface is the listener for network connection events.
+ *
+ * @since              2.0
+ *
+ *  The %IManagedNetConnectionEventListener interface specifies the methods used to create the notifications about the different kinds of network
+ *     connection events. These events are sent only when %IManagedNetConnectionEventListener is added to the ManagedNetConnection instance, and
+ *     this is done by invoking the SetManagedNetConnectionEventListener() method. A method of this interface is called when a network connection
+ *     event is generated.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/managing_network_connections.htm">Managing Network Connections</a>.
+ */
+class _OSP_EXPORT_ IManagedNetConnectionEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+       /** This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since       2.0
+        */
+       virtual ~IManagedNetConnectionEventListener(void) {}
+
+public:
+       /**
+        * Called to notify that the bearer has been changed. @n
+        * An application can send or receive the data through the Socket or HTTP methods and can obtain the information related to the changed bearer.
+        *
+        * @since               2.0
+        *
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       virtual void OnManagedNetConnectionBearerChanged(ManagedNetConnection& managedNetConnection) = 0;
+
+       /**
+        * Called to notify the application that the network connection has been opened and connected. @n
+        * An application can then send or receive the data.
+        *
+        * @since                       2.0
+        *
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       virtual void OnManagedNetConnectionStarted(ManagedNetConnection& managedNetConnection) = 0;
+
+       /**
+        * Called to notify that the network connection has been closed and disconnected.
+        *
+        * @since               2.0
+        *
+        * @param[in]   managedNetConnection                                                            The network connection managed by the system
+        * @param[in]   reason                                                                                          A reason code for the error
+        * @exception   NET_CONNECTION_STOPPED_REASON_RESOURCE_RELEASED         The network connection managed by the system has stopped because network resources have been released.
+        * @exception   NET_CONNECTION_STOPPED_REASON_NETWORK_FAILED            The network has failed.
+        * @exception   NET_CONNECTION_STOPPED_REASON_DEVICE_OFFLINE            The device is in the offline mode.
+        * @exception   NET_CONNECTION_STOPPED_REASON_SERVICE_UNAVAILABLE       The device is out of the coverage area or in the emergency mode.
+        * @exception   NET_CONNECTION_STOPPED_REASON_RESOURCE_UNAVAILABLE      The network resource is unavailable.
+        * @exception   NET_CONNECTION_STOPPED_REASON_SYSTEM                            A system error has occurred.
+        */
+       virtual void OnManagedNetConnectionStopped(ManagedNetConnection& managedNetConnection, NetConnectionStoppedReason reason) = 0;
+
+       /**
+        * Called to notify the application that the connection status has been changed or is in an unstable or suspended state. @n
+        * Thus an application may neither send nor receive data through the Socket or Http until the network connection is resumed.
+        *
+        * @since               2.0
+        *
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       virtual void OnManagedNetConnectionSuspended(ManagedNetConnection& managedNetConnection) = 0;
+
+       /**
+        * Called to notify the application that the network has recovered from a suspended state. @n
+        * Thus an application can send or receive data through the Socket or Http from now on.
+        *
+        * @since               2.0
+        *
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       virtual void OnManagedNetConnectionResumed(ManagedNetConnection& managedNetConnection) = 0;
+
+protected:
+       // Reserved virtual methods for later extension.
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IManagedNetConnectionEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IManagedNetConnectionEventListener_Reserved2(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void IManagedNetConnectionEventListener_Reserved3(void) {}
+}; // IManagedNetConnectionEventListener
+
+} } // Tizen::Net
+#endif // _FNET_IMANAGED_NET_CONNECTION_EVENTLISTENER_H_
diff --git a/inc/FNetINetConnectionEventListener.h b/inc/FNetINetConnectionEventListener.h
new file mode 100644 (file)
index 0000000..d1d2540
--- /dev/null
@@ -0,0 +1,188 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FNetINetConnectionEventListener.h
+ * @brief      This is the header file for the %INetConnectionEventListener interface.
+ *
+ * This header file contains the declarations of the %INetConnectionEventListener interface.
+ *
+ */
+#ifndef _FNET_INET_CONNECTION_EVENT_LISTENER_H_
+#define _FNET_INET_CONNECTION_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Net
+{
+class NetConnection;
+
+/**
+ * @interface  INetConnectionEventListener
+ * @brief              This interface implements the listeners for the network connection events.
+ *
+ * @since              2.0
+ *
+ *  The %INetConnectionEventListener interface specifies the methods for creating the notifications about the different kinds of network
+ *     connection events. These events are only sent when %INetConnectionEventListener is added to a NetConnection instance, by invoking the
+ *     AddNetConnectionListener() method. When a network connection event is generated, a method of this class is called.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/managing_network_connections.htm">Managing Network Connections</a>.
+ *
+ * The following example demonstrates how to use the %INetConnectionEventListener interface.
+ *
+ * @code
+using namespace Tizen::Net;
+using namespace Tizen::Base;
+
+class TestListener
+       : public Object
+       , public virtual INetConnectionEventListener
+{
+public:
+       TestListener() {}
+
+       ~TestListener() {}
+
+       void OnNetConnectionStarted(NetConnection& netConnection, result r)
+       {
+               AppLog("OnStarted\n");
+       }
+
+       void OnNetConnectionStopped(NetConnection& netConnection, result r)
+       {
+               AppLog("OnStopped\n");
+       }
+
+       void OnNetConnectionSuspended(NetConnection& netConnection)
+       {
+               AppLog("OnSuspended\n");
+       }
+
+       void OnNetConnectionResumed(NetConnection& netConnection)
+       {
+               AppLog("OnResumed\n");
+       }
+};
+ * @endcode
+ */
+class _OSP_EXPORT_ INetConnectionEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+       /**
+        * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since       2.0
+        */
+       virtual ~INetConnectionEventListener(void) {}
+
+public:
+       /**
+        * Called to notify the application that the network connection has been opened and connected. @n
+        * An application can send or receive the data.
+        *
+        * @since               2.0
+        *
+        * @param[in]   netConnection                           The network connection
+        * @param[in]   r                                                       An error code
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_TIMEOUT                                       An attempt to connect to the server has timed out.
+        * @exception   E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+        * @exception   E_DEVICE_UNAVAILABLE            The operation has failed due to a missing SIM card.
+        * @exception   E_NETWORK_UNAVAILABLE           The operation has failed because the device is in the offline mode.
+        * @exception   E_SERVICE_UNAVAILABLE           The operation has failed because the device is out of the coverage area or in the emergency mode.
+        * @exception   E_RESOURCE_UNAVAILABLE          The network resource is unavailable.
+        * @exception   E_AUTHENTICATION                        The authentication has failed.
+        * @exception   E_UNSUPPORTED_OPERATION         This operation is not supported.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @exception   E_NETWORK_FAILED                        Requested but an error is received from the network.
+        * @exception   E_INVALID_SIM_STATE                     The network has marked SIM as invalid for the CS and/or PS domain.
+        * @exception   E_FDN_MODE                                      The FDN is enabled and the number is not listed in the FDN list.
+        * @exception   E_DHCP                                          The DHCP operation has failed on WLAN.
+        * @exception   E_LINK                                          A link failure has occurred on WLAN.
+        */
+       virtual void OnNetConnectionStarted(NetConnection& netConnection, result r) = 0;
+
+       /**
+        * Called to notify the application that the network connection has been closed and disconnected.
+        *
+        * @since               2.0
+        *
+        * @param[in]   netConnection                           The network connection
+        * @param[in]   r                                                       An error code
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_NETWORK_UNAVAILABLE           The operation has failed because the device is in the offline mode.
+        * @exception   E_SERVICE_UNAVAILABLE           The operation has failed because the device is out of the coverage area or in the emergency mode.
+        * @exception   E_RESOURCE_UNAVAILABLE          The network resource is unavailable.
+        * @exception   E_UNSUPPORTED_OPERATION         This operation is not supported.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @exception   E_NETWORK_FAILED                        Requested but an error is received from the network.
+        * @exception   E_INVALID_SIM_STATE                     The network has marked SIM as invalid for the CS and/or PS domain.
+        * @exception   E_FDN_MODE                                      The FDN is enabled and the number is not listed in the FDN list.
+        * @exception   E_DHCP                                          The DHCP operation has failed on WLAN.
+        * @exception   E_LINK                                          A link failure has occurred on WLAN.
+        * @remarks             This notification does not imply that the network is stopped permanently and cannot be used.
+        *                              The network can be restarted using NetConnection::Start().
+        *                              The NetConnection::Close() method is used to disconnect the connection
+        *              from the remote server or gateway permanently.
+        */
+       virtual void OnNetConnectionStopped(NetConnection& netConnection, result r) = 0;
+
+       /**
+        * Called to notify the application that the connection status has changed or is in an unstable or suspended state. @n
+        * Thus, an application may neither send nor receive data through Socket or Http until the network connection is resumed.
+        *
+        * @since               2.0
+        *
+        * @param[in]   netConnection           The network connection
+        *
+        */
+       virtual void OnNetConnectionSuspended(NetConnection& netConnection) = 0;
+
+       /**
+        * Called to notify the application that the network has recovered from a suspended state. @n
+        * Thus, an application can send or receive data through Socket or Http from now on.
+        *
+        * @since               2.0
+        *
+        * @param[in]   netConnection           The network connection
+        */
+       virtual void OnNetConnectionResumed(NetConnection& netConnection) = 0;
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+        virtual void INetConnectionEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+        virtual void INetConnectionEventListener_Reserved2(void) {}
+}; // INetConnectionEventListener
+
+} } // Tizen::Net
+#endif // _FNET_INET_CONNECTION_EVENT_LISTENER_H_
diff --git a/inc/FNetIp4Address.h b/inc/FNetIp4Address.h
new file mode 100644 (file)
index 0000000..a2cacd7
--- /dev/null
@@ -0,0 +1,226 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetIp4Address.h
+ * @brief              This is the header file for the %Ip4Address class.
+ *
+ * @since              2.0
+ *
+ * This header file contains the declarations of the %Ip4Address class.
+ */
+#ifndef _FNET_IP4_ADDRESS_H_
+#define _FNET_IP4_ADDRESS_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FNetIpAddress.h>
+#include <FNetSockSocketTypes.h>
+
+namespace Tizen { namespace Net
+{
+class _Ip4AddressImpl;
+/**
+ * @class      Ip4Address
+ * @brief      This class represents an Internet Protocol version 4 (IPv4) address.
+ *
+ * @since      2.0
+ *
+ *  The %Ip4Address class specifies the IPv4 address.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/net_namespace.htm">Net Guide</a>. @n
+ *
+ * The following example demonstrates how to use the %Ip4Address class.
+ *
+ * @code
+ *     using namespace Tizen::Base;
+ *     using namespace Tizen::Net;
+ *
+ *     result
+ *     MyClass::SomeMethod(void)
+ *     {
+ *             result r = E_SUCCESS;
+ *
+ *             Tizen::Base::String ip4String(L"192.168.0.1");
+ *             Ip4Address* pIp4Address = new Ip4Address(ip4String);
+ *
+ *             // Gets the raw IP address.
+ *             int sizeOfIp4Address = 4;
+ *             ByteBuffer bb;
+ *             r = bb.Construct(sizeOfIp4Address);
+ *             r = pIp4Address->GetAddress(bb);
+ *
+ *             // Success
+ *             return (r);
+ *     }
+ * @endcode
+ */
+class _OSP_EXPORT_ Ip4Address
+       : public IpAddress
+{
+public:
+       /**
+        * Initializes this instance of %Ip4Address with the address specified as a string.
+        *
+        * @since               2.0
+        *
+        * @param[in]   ipAddr                  The IP Address as a string @n
+        *                                                              This string represents the IP address in dot-decimal notation (for example, 165.213.173.7)  .
+        * @exception   E_SUCCESS               The instance is created successfully.
+        * @exception   E_INVALID_ARG   The specified @c ipAddr is invalid.
+        * @remarks             The GetLastResult() method is used to check whether the %Ip4Address instance is created successfully.
+        */
+       Ip4Address(const Tizen::Base::String& ipAddr);
+
+       /**
+        * Initializes this instance of %Ip4Address with the address specified as an integer.
+        *
+        * @since               2.0
+        *
+        * @param[in]   ipAddr                  A unsigned @c long number containing the raw IP address @n
+        *                                                              This is a 32-bit unsigned number. It should be in host byte order.
+        * @exception   E_SUCCESS               The instance is created successfully.
+        * @exception   E_INVALID_ARG   The specified @c ipAddr is invalid.
+        * @remarks             The GetLastResult() method is used to check whether the %Ip4Address instance is created successfully.
+        * @see                 IpAddress::NetworkToHostOrder(), IpAddress::HostToNetworkOrder()
+        */
+       Ip4Address(unsigned long ipAddr);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since                       2.0
+        *
+        * @param[in]   rhs                     An instance of %Ip4Address
+        * @remarks             The GetLastResult() method is used to check whether the %Ip4Address instance is created successfully.
+        */
+       Ip4Address(const Ip4Address& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.0
+        */
+       virtual ~Ip4Address(void);
+
+public:
+       /**
+        * Gets the address family to which the %Ip4Address belongs.
+        *
+        * @since               2.0
+        *
+        * @return              NET_AF_IPV4
+        */
+       NetAddressFamily GetNetAddressFamily(void) const;
+
+       /**
+        * Gets the raw IP address.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[out]  ipAddr                  A ByteBuffer object containing the raw IP address
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_OVERFLOW              The length of the remaining bytes of @c ipAddr is less than @c 4.
+        * @remarks             This method returns the raw IP address of the %Ip4Address object. The result is in host byte order. This method writes the raw address
+        *                              in the buffer parameter, starting from the current position. After the operation, the position of the buffer is incremented by the number
+        *                              of bytes successfully written even if the operation fails. The new position cannot be larger than the original limit.
+        */
+       result GetAddress(Tizen::Base::ByteBuffer& ipAddr) const;
+
+       /**
+        * Gets the raw IP address as an integer. @n
+        * The result is in host byte order.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[out]  ipAddr                          An unsigned @c long integer containing the raw IP address
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        * @see                 IpAddress::NetworkToHostOrder(), IpAddress::HostToNetworkOrder()
+        */
+       result GetAddress(unsigned long& ipAddr) const;
+
+       /**
+        * Gets the IP address of the endpoint in textual presentation. @n
+        * An endpoint consists of an IP address and a port.
+        *
+        * @since               2.0
+        *
+        * @return              The %Ip4Address, @n
+        *                              else a null string if the address is not set
+        * @remarks             %Ip4Address is in the standard dot-decimal notation.
+        */
+       Tizen::Base::String ToString(void) const;
+
+       /**
+        * Creates and returns a copy of this instance.
+        *
+        * @since 2.0
+        *
+        * @return              The copy of this instance
+        * @remarks             The GetLastResult() method is used to check whether the %IpAddress instance is copied successfully.
+        */
+       virtual IpAddress* CloneN(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since 2.0
+        *
+        * @return              The reference of this instance
+        * @param[in]   rhs An instance of %Ip4Address
+        */
+       Ip4Address& operator =(const Ip4Address& rhs);
+
+       /**
+        * Compares the specified instance of %Ip4Address with the calling instance.
+        *
+        * @since               2.0
+        *
+        * @return              @c true if the values match, @n
+        *                              else @c false
+        * @param[in]   rhs     The other Object to be compared
+        * @see                 Object::Equals()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since               2.0
+        *
+        * @return      The current instance's hash value
+        */
+       virtual int GetHashCode(void) const;
+
+private:
+       /**
+        * This default constructor is intentionally declared as private so that only the platform can create an instance.
+        */
+       Ip4Address(void);
+
+private:
+       _Ip4AddressImpl* __pIp4AddressImpl;
+
+       friend class _Ip4AddressImpl;
+}; // Ip4Address
+
+} } //Tizen::Net
+
+#endif // _FNET_IP4_ADDRESS_H_
diff --git a/inc/FNetIpAddress.h b/inc/FNetIpAddress.h
new file mode 100644 (file)
index 0000000..76effab
--- /dev/null
@@ -0,0 +1,234 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetIpAddress.h
+ * @brief              This is the header file for the %IpAddress class.
+ *
+ * This header file contains the declarations of the %IpAddress class.
+ */
+#ifndef _FNET_IP_ADDRESS_H_
+#define _FNET_IP_ADDRESS_H_
+
+#include <FBaseObject.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseString.h>
+#include <FBaseResult.h>
+#include <FBaseErrors.h>
+#include <FNetSockSocketTypes.h>
+
+namespace Tizen { namespace Net
+{
+class _IpAddressImpl;
+/**
+ * @class      IpAddress
+ * @brief      This abstract class encapsulates an Internet Protocol (IP) address and the methods to manipulate it.
+ *
+ * @since      2.0
+ *
+ *  The %IpAddress class contains the address of a computer on an IP network. Different computers use different conventions for ordering the bytes
+ *     within multi-byte integer values. Some computers put the most significant byte first (known as big-endian order) and others put the
+ *     least-significant byte first (known as little-endian order). To work with the computers that use different byte ordering, all integer values sent
+ *     over the network are sent in network byte order. This class provides methods to change the order. An endpoint includes an IP address
+ *     and a port.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/net_namespace.htm">Net Guide</a>.
+ */
+class _OSP_EXPORT_ IpAddress
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~IpAddress(void);
+
+       /**
+        * Converts the specified unsigned short address from the host byte order to the network byte order.
+        *
+        * @since               2.0
+        *
+        * @return              The address as an unsigned @c short value, in the network @c byte order
+        * @param[in]   host    The IP address to be converted, expressed in host @c byte order
+        *
+        * @see                 NetworkToHostOrder()
+        */
+       static unsigned short HostToNetworkOrder(unsigned short host);
+
+       /**
+        * Converts the specified unsigned long address from the host byte order to the network byte order.
+        *
+        * @since               2.0
+        *
+        * @return              The address as an unsigned @c long value, in the network @c byte order
+        * @param[in]   host    The IP address to be converted, expressed in host @c byte order
+        *
+        * @see                 NetworkToHostOrder()
+        */
+       static unsigned long HostToNetworkOrder(unsigned long host);
+
+       /**
+        * Converts the specified short integer address from network byte order to host byte order.
+        *
+        * @since               2.0
+        *
+        * @return              The address as an unsigned @c short value, in the host @c byte order
+        * @param[in]   network         The IP address to be converted, expressed in the network @c byte order
+        *
+        * @see                 HostToNetworkOrder()
+        */
+       static unsigned short NetworkToHostOrder(unsigned short network);
+
+       /**
+        * Converts the specified unsigned long address from the network byte order to the host byte order.
+        *
+        * @since               2.0
+        *
+        * @return              The address as an unsigned @c long value, in the host @c byte order
+        * @param[in]   network         The IP address to be converted, expressed in the network @c byte order
+        *
+        * @see                         HostToNetworkOrder()
+       */
+       static unsigned long NetworkToHostOrder(unsigned long network);
+
+       /**
+        * Gets the address family to which the %IpAddress belongs.
+        *
+        * @since               2.0
+        *
+        * @return              The address family
+        */
+       virtual NetAddressFamily GetNetAddressFamily(void) const = 0;
+
+       /**
+        * Gets the raw IP address of the endpoint. @n
+        * An endpoint includes an IP address and a port.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[out]  ipAddr                          A ByteBuffer object for getting the raw IP address
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c ipAddr is invalid.
+        * @exception   E_OVERFLOW                      This operation has caused the memory to overflow.
+        * @remarks             The result @c ipAddr is in the host @c byte order. This method writes the raw address into the buffer parameter, starting from the
+        *                              current position of the buffer. After the operation, the position of the buffer is incremented by the number of bytes successfully written
+        *                              even if the operation fails. The new position cannot be larger than the original limit.
+        */
+       virtual result GetAddress(Tizen::Base::ByteBuffer& ipAddr) const = 0;
+
+       /**
+        * Gets the IP address of the endpoint as a string. @n
+        * An endpoint includes an IP address and a port.
+        *
+        * @since               2.0
+        *
+        * @return              The IP address, @n
+        *                              else a null string if the address is not set
+        */
+       virtual Tizen::Base::String ToString(void) const = 0;
+
+       /**
+        * Creates and returns a copy of this instance.
+        *
+        * @since 2.0
+        *
+        * @return              The copy of this instance
+        * @remarks             The GetLastResult() method is used to check whether the %IpAddress instance is copied successfully.
+        */
+       virtual IpAddress* CloneN(void) const = 0;
+
+protected:
+       /**
+        * This default constructor is intentionally declared as protected because this class cannot be constructed.
+        *
+        * @since       2.0
+        */
+       IpAddress(void);
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since 2.0
+       //
+       virtual void IpAddress_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since 2.0
+       //
+       virtual void IpAddress_Reserved2(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since 2.0
+       //
+       virtual void IpAddress_Reserved3(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since 2.0
+       //
+       virtual void IpAddress_Reserved4(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since 2.0
+       //
+       virtual void IpAddress_Reserved5(void) {}
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of IpAddress
+        */
+       IpAddress(const IpAddress& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                             An instance of %IpAddress
+        */
+       IpAddress& operator =(const IpAddress& rhs);
+
+protected:
+       _IpAddressImpl* _pIpAddressImpl;
+
+       friend class _IpAddressImpl;
+}; // IpAddress
+
+} } //Tizen::Net
+
+#endif // _FNET_IP_ADDRESS_H_
diff --git a/inc/FNetIpHostEntry.h b/inc/FNetIpHostEntry.h
new file mode 100644 (file)
index 0000000..9495329
--- /dev/null
@@ -0,0 +1,165 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetIpHostEntry.h
+ * @brief              This is the header file for the %IpHostEntry class.
+ *
+ * This header file contains the declarations of the %IpHostEntry class.
+ */
+#ifndef _FNET_IP_HOST_ENTRY_H_
+#define _FNET_IP_HOST_ENTRY_H_
+
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseColIList.h>
+#include <FNetSockSocketTypes.h>
+
+namespace Tizen { namespace Net
+{
+class _IpHostEntryImpl;
+
+/**
+ * @class      IpHostEntry
+ * @brief      This class encapsulates the Internet host address information.
+ *
+ * @since      2.0
+ *
+ *  The %IpHostEntry class associates a Domain Name %System (DNS) host name with a list of aliases and matching IP addresses. If the specified host has
+ *  multiple entries in the DNS database, %IpHostEntry contains multiple IP addresses and aliases. The %IpHostEntry class is used as a helper class
+ *     with the Dns class.
+ *
+ * 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>.
+ *
+ * The following example demonstrates how to use the %IpHostEntry class.
+ *
+ * @code
+class MyDnsListener
+    : public IDnsEventListener
+{
+public:
+    void OnDnsResolutionCompletedN(IpHostEntry* ipHostEntry, result r);
+};
+
+
+void
+MyDnsListener::OnDnsResolutionCompletedN(IpHostEntry* ipHostEntry, result r)
+{
+       if (ipHostEntry == null)
+       {
+               AppLog("error case no.%d \n", r);
+       }
+       else
+       {
+               Tizen::Base::Collection::IList* addressList = ipHostEntry->GetAddressList();
+
+               if (addressList != null)
+               {
+                       int count = addressList->GetCount();
+
+                       for (int i = 0; i < count; i++)
+                       {
+                               IpAddress* pIpAddress = (IpAddress*)(addressList->GetAt(i));
+                               Tizen::Base::ByteBuffer*_pbb = Tizen::Base::Utility::StringUtil::StringToUtf8N(pIpAddress->ToString());
+
+                               AppLog("IpAddress no.%d : %s\n", i, (char*)(_pbb->GetPointer()));
+                               delete _pbb;
+                       }
+               }
+
+               Tizen::Base::Collection::IList* aliasList = ipHostEntry->GetAliasList();
+
+               if (aliasList != null)
+               {
+                       int count = aliasList->GetCount();
+
+                       for (int i = 0; i < count; i++)
+                       {
+                               String* alias = (String*)(aliasList->GetAt(i));
+                               Tizen::Base::ByteBuffer*_pbb = Tizen::Base::Utility::StringUtil::StringToUtf8N(*alias);
+
+                               AppLog("alias no.%d : %s\n", i, (char*)(_pbb->GetPointer()));
+                               delete _pbb;
+                       }
+               }
+               delete ipHostEntry;
+       }
+}
+ * @endcode
+ */
+class _OSP_EXPORT_ IpHostEntry
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since                       2.0
+        */
+       virtual ~IpHostEntry(void);
+
+public:
+       /**
+        * Gets the IP address list of a domain name.
+        *
+        * @since               2.0
+        *
+        * @return              An IEnumerator whose element is of the type IpAddress*, @n
+        *                              else @c null if the object is not constructed or addressList is not set
+        */
+       Tizen::Base::Collection::IList* GetAddressList(void) const;
+
+       /**
+        * Gets the alias list of a domain name.
+        *
+        * @since                       2.0
+        *
+        * @return                      An IEnumerator whose element is of the type String*, @n
+        *                                      else @c null if the object is not constructed or aliasList is not set
+        */
+       Tizen::Base::Collection::IList* GetAliasList(void) const;
+
+private:
+       /*
+        * This default constructor is intentionally declared as private so that only the platform can create an instance.
+        */
+       IpHostEntry(void);
+
+       /*
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   value           An instance of %IpHostEntry
+        */
+       IpHostEntry(const IpHostEntry& value);
+
+       /*
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %IpHostEntry
+        */
+       IpHostEntry& operator =(const IpHostEntry& rhs);
+
+private:
+       _IpHostEntryImpl* __pIpHostEntryImpl;
+
+       friend class _IpHostEntryImpl;
+}; // IpHostEntry
+
+} } //Tizen::Net
+
+#endif // _FNET_IP_HOST_ENTRY_H_
diff --git a/inc/FNetLocalDhcpServer.h b/inc/FNetLocalDhcpServer.h
new file mode 100644 (file)
index 0000000..ae67064
--- /dev/null
@@ -0,0 +1,133 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FNetLocalDhcpServer.h
+ * @brief      This is the header file for the %LocalDhcpServer class.
+ *
+ * This header file contains the declarations of the %LocalDhcpServer class.
+ */
+#ifndef _FNET_LOCAL_DHCP_SERVER_H_
+#define _FNET_LOCAL_DHCP_SERVER_H_
+
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseColIList.h>
+
+namespace Tizen { namespace Net
+{
+class NetConnection;
+class ILocalDhcpServerEventListener;
+class _LocalDhcpServerImpl;
+/**
+ * @class      LocalDhcpServer
+ * @brief      This class provides methods for managing the local DHCP server.
+ *
+ * @since      2.0
+ *
+ *  The %LocalDhcpServer class provides methods for managing the local DHCP server. The Wi-Fi Direct or USB NDIS requires the local DHCP server
+ *     for data communication.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/local_DHCP_server_access.htm">Local DHCP Server Access</a>.
+ */
+class _OSP_EXPORT_ LocalDhcpServer
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since   2.0
+        */
+       virtual ~LocalDhcpServer(void);
+
+       /**
+        * Gets a singleton instance of %LocalDhcpServer that it associated with the specified network connection.
+        *
+        * @since       2.0
+        *
+        * @return              An instance of %LocalDhcpServer
+        * @param[in]   netConnection           A run-time session where a local DHCP server used
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified input parameter is invalid.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static LocalDhcpServer* GetInstance(const NetConnection& netConnection);
+
+public:
+       /**
+        * Sets a listener instance for the events about a local DHCP server.
+        *
+        * @since       2.0
+        *
+        * @param[in]   pListener                       An instance of ILocalDhcpServerEventListener @n
+        *                                                                      If it is @c null, it will reset the event listener.
+        * @return              An error code
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         This instance has not been constructed as yet.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation, @n
+        *                                                                      because the caller thread is a worker thread.
+        */
+       result SetLocalDhcpServerEventListener(ILocalDhcpServerEventListener* pListener);
+
+public:
+       /**
+        * Gets a list of all the client information on the local DHCP server.
+        *
+        * @since       2.0
+        *
+        * @return              An IList containing indexes to the DhcpClientInfo on the local DHCP server
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        * @remarks             In case of an error or if there is no active connection for the local DHCP server, @c null is returned.
+        *                              The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetDhcpClientInfoListN(void) const;
+
+private:
+       /**
+        * This default constructor is intentionally declared as private so that only the platform can create an instance.
+        */
+       LocalDhcpServer(void);
+
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs             An instance of %LocalDhcpServer
+        */
+       LocalDhcpServer(const LocalDhcpServer& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %LocalDhcpServer
+        */
+       LocalDhcpServer& operator =(const LocalDhcpServer& rhs);
+
+private:
+       _LocalDhcpServerImpl* __pLocalDhcpServerImpl;
+       friend class _LocalDhcpServerImpl;
+}; // LocalDhcpServer
+
+} } //Tizen::Net
+
+#endif // _FNET_LOCAL_DHCP_SERVER_H_
diff --git a/inc/FNetManagedNetConnection.h b/inc/FNetManagedNetConnection.h
new file mode 100644 (file)
index 0000000..019cd76
--- /dev/null
@@ -0,0 +1,145 @@
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Flora License, Version 1.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//     http://floralicense.org/license/\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an AS IS BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+\r
+/**\r
+ * @file       FNetManagedNetConnection.h \r
+ * @brief      This is the header file for the %ManagedNetConnection class.\r
+ *\r
+ * This header file contains the declarations of the %ManagedNetConnection class.\r
+ */\r
+#ifndef _FNET_MANAGED_NET_CONNECTION_H_\r
+#define _FNET_MANAGED_NET_CONNECTION_H_\r
+\r
+#include <FBase.h>\r
+#include <FNetNetTypes.h>\r
+#include <FNetNetConnectionInfo.h>\r
+#include <FNetIManagedNetConnectionEventListener.h>\r
+\r
+namespace Tizen { namespace Net\r
+{\r
+class _ManagedNetConnectionImpl;\r
+\r
+/**\r
+ * @class      ManagedNetConnection \r
+ * @brief      This class provides methods for the network connection managed by the system.\r
+ *\r
+ * @since      2.0\r
+ *\r
+ *     The %ManagedNetConnection class provides functionalities for accessing the information about the default connection for data communication \r
+ *     managed by the system. Once the connection is established, the applications can use sockets and HTTP interfaces.\r
+ *\r
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/default_network_connection.htm">Default Network Connection</a>.\r
+ */\r
+class _OSP_EXPORT_ ManagedNetConnection\r
+       : public Tizen::Base::Object\r
+{\r
+public:\r
+       /**\r
+        * This destructor overrides Tizen::Base::Object::~Object().\r
+        *\r
+        * @since       2.0\r
+        */\r
+       virtual ~ManagedNetConnection(void);\r
+\r
+public:\r
+       /**\r
+        * Sets a listener object to the current instance of %ManagedNetConnection.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @param[in]   pListener                       An instance of IManagedNetConnectionEventListener @n\r
+        *                                                                      If this is @c null, it will reset the event listener.\r
+        * @return              An error code\r
+        * @exception   E_SUCCESS                       The method is successful.\r
+        * @exception   E_SYSTEM                        An internal error has occurred.\r
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of the specified operation, @n\r
+        *                                                                      because the caller thread is a worker thread.\r
+        */\r
+       result SetManagedNetConnectionEventListener(IManagedNetConnectionEventListener* pListener);\r
+\r
+       /** \r
+        * Gets the network account on which the current instance is based, to establish a connection with a remote server or a gateway.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return              The NetAccountId of the current instance of %ManagedNetConnection, @n\r
+        *                              else @c INVALID_HANDLE if the network connection managed by the system is inactive\r
+        * @exception   E_SUCCESS                               The method is successful.\r
+        * @exception   E_INVALID_STATE                 The network connection is inactive.\r
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.\r
+        */\r
+       NetAccountId GetNetAccountId(void) const;\r
+\r
+       /**\r
+        * Gets the connection state of the current instance of %ManagedNetConnection.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return              An instance of NetConnectionState specifying the state of the network connection, @n\r
+        *                              else @c NET_CONNECTION_STATE_STOPPED if the network connection managed by the system is inactive\r
+        */\r
+       NetConnectionState  GetConnectionState(void) const;\r
+\r
+       /**\r
+        * Gets the information about the current network connection.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return              A pointer to an instance of NetConnectionInfo specifying the information about this network connection\r
+        * @exception   E_SUCCESS                               The method is successful.\r
+        * @exception   E_INVALID_STATE                 The network connection is inactive.\r
+        * @remarks             This method requires a %NetConnectionInfo instance reference.\r
+        *                              %NetConnectionInfo is only available when the network connection managed by the system is active. In other states, this returns null.\r
+        *                              The specific error code can be accessed using the GetLastResult() method.\r
+        * @warning     Do not delete the returned %NetConnectionInfo instance. This instance is directly referencing the internal connectionInfo of \r
+        *                              %ManagedNetConnection.\r
+        */\r
+       const NetConnectionInfo* GetNetConnectionInfo(void) const;\r
+\r
+private:\r
+       /**\r
+        * This default constructor is intentionally declared as private so that only the platform can create an instance.\r
+        *\r
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.\r
+        * @see                 Construct\r
+        */\r
+       ManagedNetConnection(void);\r
+\r
+private:\r
+       /** \r
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.\r
+        *\r
+        * @param[in]   rhs                     An instance of %ManagedNetConnection\r
+        */     \r
+       ManagedNetConnection(const ManagedNetConnection& rhs);\r
+\r
+       /** \r
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.\r
+        *\r
+        * @param[in]   rhs             An instance of %ManagedNetConnection\r
+        */\r
+       ManagedNetConnection& operator =(const ManagedNetConnection& rhs);\r
+\r
+private:\r
+       _ManagedNetConnectionImpl* __pManagedNetConnectionImpl;\r
+\r
+       friend class _ManagedNetConnectionImpl;\r
+}; // ManagedNetConnection\r
+\r
+} } //Tizen::Net\r
+\r
+#endif // _FNET_MANAGED_NET_CONNECTION_H_\r
diff --git a/inc/FNetNetAccountInfo.h b/inc/FNetNetAccountInfo.h
new file mode 100644 (file)
index 0000000..a057fbc
--- /dev/null
@@ -0,0 +1,465 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetNetAccountInfo.h
+ * @brief              This is the header file for the %NetAccountInfo class.
+ *
+ * This header file contains the declarations of the %NetAccountInfo class.
+ */
+#ifndef _FNET_NET_ACCOUNT_INFO_H_
+#define _FNET_NET_ACCOUNT_INFO_H_
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseResult.h>
+#include <FBaseErrors.h>
+#include <FNetNetTypes.h>
+#include <FNetIpAddress.h>
+#include <FNetIp4Address.h>
+#include <FNetNetEndPoint.h>
+
+namespace Tizen { namespace Net
+{
+class _NetAccountInfoImpl;
+
+/**
+ * @class      NetAccountInfo
+ * @brief      This class provides methods for all the network accounts.
+ *
+ * @since      2.0
+ *
+ * The %NetAccountInfo class provides all the configuration parameters for setting up network connections.
+ * %NetAccountInfo contains the base information required to connect to various bearers and it is designed to be
+ * used in Programmed Data Processor (PDP) context activation. The Wi-Fi accounts are derived from this class
+ * and contain additional information specific to Wi-Fi (such as SSID).
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/network_accounts.htm">Network Accounts</a>.
+ */
+class _OSP_EXPORT_ NetAccountInfo
+       : public Tizen::Base::Object
+{
+public:
+       /**
+       * 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.
+       *
+       * @since        2.0
+       *
+       * @remarks      After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+       */
+       NetAccountInfo(void);
+
+       /**
+       * This destructor overrides Tizen::Base::Object::~Object().
+       *
+       * @since        2.0
+       */
+       virtual ~NetAccountInfo(void);
+
+       /**
+        * Initializes this instance of %NetAccountInfo with the specified %NetAccountInfo instance. @n
+        * 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.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   netAccountInfo          A %NetAccountInfo instance to initialize the calling instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c netAccountInfo is invalid.
+        */
+       result Construct(const NetAccountInfo& netAccountInfo);
+
+       /**
+        * Initializes this instance of %NetAccountInfo.
+        *
+        * @since               2.0
+        *
+        *      @return         An error code
+        *      @exception      E_SUCCESS                       The method is successful.
+        */
+       result Construct(void);
+
+       /**
+        * Gets an account ID.
+        *
+        * @since               2.0
+        *
+        * @return              The account ID
+        * @exception   E_SUCCESS                               The method is successful.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       NetAccountId GetAccountId(void) const;
+
+       /**
+        * Gets the name of an account.
+        *
+        * @since               2.0
+        *
+        * @return              The name of the account, @n
+        *                              else a null string if the name is not set or not constructed
+        * @exception   E_SUCCESS                               The method is successful.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see                 SetAccountName()
+        */
+       Tizen::Base::String GetAccountName(void) const;
+
+       /**
+        * Sets the name of an account. @n
+        * If this method fails, the state of this instance does not change.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   accountName                             The name of an account
+        * @exception   E_SUCCESS                               The method is successful.
+        * @see                 GetAccountName()
+        */
+       result SetAccountName(const Tizen::Base::String& accountName);
+
+       /**
+        * Gets the protocol type.
+        *
+        * @since               2.0
+        *
+        * @return              The type of the protocol
+        * @exception   E_SUCCESS                               The method is successful.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see                 SetProtocolType()
+        */
+       NetProtocolType GetProtocolType(void) const;
+
+       /**
+        * Sets the protocol type.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   netProtocolType                 The type of the protocol
+        * @exception   E_SUCCESS                               The method is successful.
+        * @remarks             If this method fails, the state of this instance does not change.
+        * @see                 GetProtocolType()
+        */
+       result SetProtocolType(NetProtocolType netProtocolType);
+
+       /**
+        * Gets an Access Point Name.
+        *
+        * @since               2.0
+        *
+        * @return              The Access Point Name, @n
+        *                              else a null string if the name is not set or the instance is not constructed
+        * @exception   E_SUCCESS                               The method is successful.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see                 SetAccessPointName()
+        */
+       Tizen::Base::String GetAccessPointName(void) const;
+
+       /**
+        * Sets the name of the access point. @n
+        * If this method fails, the state of this instance does not change.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   accessPointName                 The Access Point Name
+        * @exception   E_SUCCESS                               The method is successful.
+        * @see                 GetAccessPointName()
+        */
+       result SetAccessPointName(const Tizen::Base::String& accessPointName);
+
+       /**
+        * Gets the setting for the local address scheme. @n
+        * This scheme can be dynamic or static.
+        *
+        * @since               2.0
+        *
+        * @return              The address scheme
+        * @exception   E_SUCCESS                               The method is successful.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see                 SetLocalAddress(), GetLocalAddress()
+        */
+       NetAddressScheme GetLocalAddressScheme(void) const;
+
+       /**
+        * Gets the local address.
+        *
+        * @since                       2.0
+        *
+        * @return                      The local address, @n
+        *                                      else @c null if an error occurs or the dynamic address scheme is being used
+        * @exception           E_SUCCESS                               The method is successful.
+        * @exception           E_INVALID_OPERATION             This operation is not allowed in the dynamic address scheme.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        * @see                         SetLocalAddress()
+        */
+       const IpAddress* GetLocalAddress(void) const;
+
+       /**
+        * Enables or disables the use of a static local IP address.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   localAddrScheme                 An indicator specifying whether to use a static local IP address
+        * @param[in]   pLocalAddress                   The local IP address @n
+        *                                                                              If @c localAddrScheme is set to NET_ADDRESS_SCHEME_STATIC, the local IP address assigned is static.
+        *                                                                              If @c localAddrScheme is set to NET_ADDRESS_SCHEME_DYNAMIC or NET_ADDRESS_SCHEME_NONE, this parameter is ignored.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
+        * @see                 GetLocalAddress()
+        */
+       result SetLocalAddress(NetAddressScheme localAddrScheme, const IpAddress* pLocalAddress);
+
+       /**
+        * Gets the setting for the DNS address scheme.
+        *
+        * @since               2.0
+        *
+        * @return              The address scheme for the DNS
+        * @exception   E_SUCCESS                       The method is successful.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @see                 GetPrimaryDnsAddress(), GetSecondaryDnsAddress(), SetDnsAddress()
+        */
+       NetAddressScheme GetDnsAddressScheme(void) const;
+
+       /**
+        * Gets the setting for the primary DNS address.
+        *
+        * @since                       2.0
+        *
+        * @return                      The IpAddress of primary DNS address, @n
+        *                                      else @c null if an error occurs or the dynamic address scheme is being used
+        * @exception           E_SUCCESS                               The method is successful.
+        * @exception           E_INVALID_OPERATION             This operation is not allowed in the dynamic address scheme.
+        * @remarks                     When this instance is got by @ref NetAccountManager::GetNetAccountInfoN,
+        *                                      - this method returns a statically assigned primary DNS address pointer if the DNS address scheme is NET_ADDRESS_SCHEME_STATIC
+        *                                      - this method returns @n null if the DNS address scheme is NET_ADDRESS_SCHEME_DYNAMIC @n
+        *                      The specific error code can be accessed using the GetLastResult() method.
+        * @see                         GetSecondaryDnsAddress()
+        */
+       const IpAddress* GetPrimaryDnsAddress(void) const;
+
+       /**
+        * Gets the setting for the secondary DNS address.
+        *
+        * @since                       2.0
+        *
+        * @return                      The secondary DNS IP address, @n
+        *                                      else @c null if an error occurs or the dynamic address scheme is being used
+        * @exception           E_SUCCESS                               The method is successful.
+        * @exception           E_INVALID_OPERATION             This operation is not allowed in the dynamic address scheme.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        * @see                         SetDnsAddress()
+        */
+       const IpAddress* GetSecondaryDnsAddress(void) const;
+
+       /**
+        * Enables or disables the use of a static DNS address with the specified IpAddress objects. @n
+        * If @c dnsAddrScheme is NET_ADDRESS_SCHEME_DYNAMIC, both @c primaryDnsAddress and @c secondaryDnsAddress are ignored. @n
+        * If @c dnsAddrScheme is NET_ADDRESS_SCHEME_STATIC, @c primaryDnsAddress must be a valid IpAddress.
+        * However, @c pSecondaryDnsAddress can be @c null.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   dnsAddrScheme                   An indicator specifying whether or not to use a static DNS address
+        * @param[in]   pPrimaryDnsAddress              The statically assigned primary DNS address if @c dnsAddrScheme is NET_ADDRESS_SCHEME_STATIC
+        * @param[in]   pSecondaryDnsAddress    The statically assigned secondary DNS address if @c dnsAddrScheme is NET_ADDRESS_SCHEME_STATIC
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
+        * @see                 GetPrimaryDnsAddress(), GetSecondaryDnsAddress()
+        */
+       result SetDnsAddress(NetAddressScheme dnsAddrScheme, const IpAddress* pPrimaryDnsAddress, const IpAddress* pSecondaryDnsAddress);
+
+       /**
+        * Gets the proxy address of the network accounts.
+        *
+        * @since               2.0
+        *
+        * @return              The proxy address, @n
+        *                              else @c null if an error occurs or the address is not set
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_UNSUPPORTED_FORMAT    The specified address format is not supported.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       const NetEndPoint* GetProxyAddress(void) const;
+
+       /**
+        * Sets the proxy address of the network accounts.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   pProxyEndPoint                  A pointer to a NetEndPoint instance containing the IP address and port
+        * @exception   E_SUCCESS                               The method is successful.
+        */
+       result SetProxyAddress(const NetEndPoint* pProxyEndPoint);
+
+       /**
+        * Gets the authentication configuration of network accounts. @n
+        * The user is not provided with read access to the credential information present in the registry if the network account information is extracted from
+        * the registry using @ref NetAccountManager::GetNetAccountInfoN().
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[out]  authenticationType      The type of the authentication used
+        * @param[out]  id                                      The ID
+        * @param[out]  password                        The password
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_ILLEGAL_ACCESS        The user is not provided with read access to the credential information present in the registry, if the network
+        *                                                                      account information is extracted from the registry using NetAccountManager::GetNetAccountInfoN().
+        * @remarks             If this method fails, the state of this instance does not change.
+        * @see                 SetAuthenticationInfo()
+        *
+        */
+       result GetAuthenticationInfo(NetNapAuthType& authenticationType, Tizen::Base::String& id, Tizen::Base::String& password) const;
+
+       /**
+        * Sets the authentication configuration of the network accounts.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   authenticationType      The type of the authentication used
+        * @param[in]   id                                      The ID
+        * @param[in]   password                        The password
+        * @exception   E_SUCCESS                       The method is successful.
+        * @remarks             If this method fails, the state of this instance does not change.
+        * @see                 GetAuthenticationInfo()
+        *
+        */
+       result SetAuthenticationInfo(NetNapAuthType authenticationType, const Tizen::Base::String& id, const Tizen::Base::String& password);
+
+       /**
+        * Gets the operational bearer type of this account.
+        *
+        * @since               2.0
+        *
+        * @return              The operational bearer type
+        * @exception   E_SUCCESS                       The method is successful.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       NetBearerType GetBearerType(void) const;
+
+       /**
+        * Gets the current URL of a home page.
+        *
+        * @since                    2.0
+        *
+        * @return                  The current URL of a home page
+        * @see                      SetHomeUrl()
+        */
+       Tizen::Base::String GetHomeUrl(void) const;
+
+       /**
+        * Sets a URL as a home page.
+        *
+        * @since                  2.0
+        *
+        * @param[in]   homeUrl         The URL to set as a home page
+        * @see                    GetHomeUrl()
+        */
+       void SetHomeUrl(const Tizen::Base::String& homeUrl);
+
+       /**
+        * Gets the maximum length of the user name.
+        *
+        * @since               2.0
+        *
+        * @return              The maximum length of the user name
+        */
+       int GetMaximumLengthOfId(void) const;
+
+       /**
+        * Gets the maximum length of the password.
+        *
+        * @since               2.0
+        *
+        * @return              The maximum length of the password
+        */
+       int GetMaximumLengthOfPassword(void) const;
+
+       /**
+        * Gets the maximum length of the account name.
+        *
+        * @since               2.0
+        *
+        * @return              The maximum length of the account name
+        */
+       int GetMaximumLengthOfAccountName(void) const;
+
+       /**
+        * Gets a value that indicates whether the network account is read-only. @n
+        * If it returns @c true, this account is read-only; so any change to this account is not permitted. @n
+        * When it returns @c false, modification is possible.
+        *
+        * @since               2.0
+        *
+        * @return              @c true if this account is read only, @n
+        *                              else @c false
+        * @exception   E_SUCCESS                               The method is successful.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       bool IsReadOnly(void) const;
+
+       /**
+        * Compares the specified instance of %NetAccountInfo with the calling instance.
+        *
+        * @since               2.0
+        *
+        * @return              @c true if the values match, @n
+        *                              else @c false
+        * @param[in]   rhs     The other Object to compare
+        * @see                 Object::Equals()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since               2.0
+        *
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %NetAccountInfo
+        */
+       NetAccountInfo(const NetAccountInfo& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs An instance of %NetAccountInfo
+        */
+       NetAccountInfo& operator =(const NetAccountInfo& rhs);
+
+private:
+       _NetAccountInfoImpl* __pNetAccountInfoImpl;
+
+       friend class _NetAccountInfoImpl;
+}; // NetAccountInfo
+
+} } //Tizen::Net
+
+#endif // _FNET_NET_ACCOUNT_INFO_H_
diff --git a/inc/FNetNetAccountManager.h b/inc/FNetNetAccountManager.h
new file mode 100755 (executable)
index 0000000..b0bdeba
--- /dev/null
@@ -0,0 +1,354 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetNetAccountManager.h
+ * @brief              This is the header file for the %NetAccountManager class.
+ *
+ * This header file contains the declarations of the %NetAccountManager class.
+ */
+#ifndef _FNET_NET_ACCOUNT_MANAGER_H_
+#define _FNET_NET_ACCOUNT_MANAGER_H_
+
+#include <FBaseString.h>
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FBaseColIList.h>
+#include <FBaseColArrayList.h>
+#include <FBaseColArrayListT.h>
+#include <FNetNetTypes.h>
+#include <FNetNetAccountInfo.h>
+
+namespace Tizen { namespace Net
+{
+class _NetAccountManagerImpl;
+
+/**
+ * @class      NetAccountManager
+ * @brief      This class provides methods for creating, deleting, and administering network accounts in the system.
+ *
+ * @since      2.0
+ *
+ * The %NetAccountManager class provides methods for creating, deleting, and administering components that can be used for configuring the
+ * network accounts. These accounts can then be used for connecting to the network.
+ *
+ * For more information on the class features, see
+ * <a href="../org.tizen.native.appprogramming/html/guide/net/network_accounts.htm">Network Accounts</a>.
+ */
+class _OSP_EXPORT_ NetAccountManager
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * 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.
+        *
+        * @since               2.0
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        */
+       NetAccountManager(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.0
+        */
+       virtual ~NetAccountManager(void);
+
+       /**
+        * Initializes this instance of %NetAccountManager.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_SYSTEM                        An internal initialization procedure has failed.
+        */
+       result Construct(void);
+
+public:
+       /**
+        * Creates a new network account.
+        *
+        * @since                       2.0
+        * @privilege           %http://tizen.org/privilege/network.account
+        *
+        * @return                      The @c NetAccountId assigned by the creation of a new network account, @n
+        *                                      else @c INVALID_HANDLE if an error occurs
+        * @param[in,out]       netAccountInfo          A NetAccountInfo instance containing network information to create an account
+        * @exception           E_SUCCESS                       The method is successful.
+        * @exception           E_INVALID_ARG           The specified input parameter is invalid.
+        * @exception           E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception           E_MAX_EXCEEDED          The registry is full. @n Cannot create a new network account.
+        * @exception           E_SYSTEM                        An internal error has occurred.
+        * @exception           E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @remarks                     This method creates a new network account and returns a @c NetAccountId value that can be used in method calls later to operate on the
+        *                                      account. If @c INVALID_HANDLE is returned, the specific error code can be accessed using the GetLastResult() method. A Wi-Fi account
+        *                                      cannot be created using %NetAccountManager.
+        * @see                         GetNetAccountInfoN(), UpdateNetAccount(), DeleteNetAccount()
+        */
+       NetAccountId CreateNetAccount(NetAccountInfo& netAccountInfo);
+
+       /**
+        * Deletes a network account from the registry. @n
+        * If the account is read-only or in service, the deletion fails. The Wi-Fi accounts cannot be deleted by %NetAccountManager.
+        *
+        * @since               2.0
+        * @privilege   %http://tizen.org/privilege/network.account
+        *
+        * @return              An error code
+        * @param[in]   netAccountId            A NetAccountId instance containing valid account information
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ACCOUNT       The specified network account is invalid.
+        * @exception   E_INVALID_OPERATION     This operation is not allowed on this network account instance.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @remarks             If the network account is created by another application, this method fails.
+        *                              This method must use a warning pop-up to notify the user.
+        * @see                 CreateNetAccount(), GetNetAccountInfoN(), UpdateNetAccount()
+        */
+       result DeleteNetAccount(NetAccountId netAccountId);
+
+       /**
+        * Updates an existing network account.
+        *
+        * @since                       2.0
+        * @privilege           %http://tizen.org/privilege/network.account
+        *
+        * @return                      An error code
+        * @param[in]           netAccountInfo          A NetAccountInfo instance containing network information to update an account
+        * @exception           E_SUCCESS                       The method is successful.
+        * @exception           E_INVALID_ARG           The specified input parameter is invalid.
+        * @exception           E_INVALID_ACCOUNT       The input is invalid.
+        * @exception           E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception           E_SYSTEM                        An internal error has occurred.
+        * @exception           E_INVALID_OPERATION     This operation is not allowed on this network account instance.
+        * @exception           E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @remarks                     This method fails if the network account is read-only, in service, or created by another application.
+        *                                      A Wi-Fi account cannot be updated using %NetAccountManager.
+        *                                      Before calling this method, the user must call GetNetAccountInfoN() to get the latest information in the registry
+        *                                      and change the desired fields of that information.
+        *                                      This method must use a warning pop-up to notify the user.
+        * @see                         CreateNetAccount(), GetNetAccountInfoN(), UpdateNetAccount(), DeleteNetAccount()
+        */
+       result UpdateNetAccount(const NetAccountInfo& netAccountInfo);
+
+       /**
+        * @if VISPARTNER-MANUFACTURER
+        * Updates an existing system network account.
+        *
+        * @since                  2.0
+        * @visibility             partner-manufacturer
+        * @privilege              %http://tizen.org/privilege/networkmanager
+        *
+        * @return                 An error code
+        * @param[in]              netAccountInfo             A NetAccountInfo instance containing network information to update an account
+        * @exception              E_SUCCESS                   The method is successful.
+        * @exception              E_INVALID_ARG             The specified input parameter is invalid.
+        * @exception              E_INVALID_ACCOUNT      The input account ID is invalid.
+        * @exception              E_OPERATION_FAILED     This request operation has failed due to an internal error.
+        * @exception              E_PRIVILEGE_DENIED     The application does not have the privilege to call this method.
+        * @see                    GetNetAccountInfoN(), UpdateNetAccount()
+        * @endif
+        */
+       result UpdateSystemNetAccount(const NetAccountInfo& netAccountInfo);
+
+       /**
+        * Gets the information on a network account.
+        *
+        * @since                       2.0
+        *
+        * @return                      A NetAccountInfo instance containing account information
+        * @param[in]           netAccountId            The account ID whose information is required
+        * @exception           E_SUCCESS                       The method is successful.
+        * @exception           E_INVALID_ACCOUNT       The specified network account is invalid.
+        * @exception           E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception           E_SYSTEM                        An internal error has occurred.
+        * @exception           E_INVALID_OPERATION     This operation is not allowed on this network account instance.
+        * @exception           E_INVALID_PROXY         The proxy address is invalid.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        * @remarks                     This method returns:
+        *                                      - the NetAccountInfo instance for a PS account (NET_BEARER_PS) @n
+        *                                      - the WifiNetAccountInfo instance for a WLAN account (NET_BEARER_WIFI) in the %NetAccountInfo type @n
+        *                                      The Wi-Fi account info contains the default %NetAccountInfo and additional Wi-Fi specific information. @n
+        *                                      To determine the type of instance returned, use the GetBearerType() method.
+        *                                      The instance can then be cast down to %WifiNetAccountInfo and used in a NET_BEARER_WIFI case. If the
+        *                                      application gets the last result by E_INVALID_PROXY, it must use a warning pop-up to notify the user.
+        * @see                         CreateNetAccount(), UpdateNetAccount(), DeleteNetAccount()
+        */
+       NetAccountInfo* GetNetAccountInfoN(NetAccountId netAccountId) const;
+
+       /**
+        * Gets a list of all the accounts in the registry.
+        *
+        * @since               2.0
+        *
+        * @return      An IList with NetAccoundIds, which are in the registry
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OBJ_NOT_FOUND         The NetAccountInfo is not found in the registry.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IListT <NetAccountId>* GetNetAccountIdsN(void) const;
+
+       /**
+        * Gets a list of names of all the registered accounts.
+        *
+        * @since               2.0
+        *
+        * @return              An IList containing the indexes to the NetAccountInfos in the registry
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OBJ_NOT_FOUND         The NetAccountInfo is not found in the registry.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        An internal error has occurred (baseband or system).
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::Collection::IList* GetNetAccountNamesN(void) const;
+
+       /**
+        * Gets a network account, which has the specified name.
+        *
+        * @since               2.0
+        *
+        * @return              The NetAccountID with the specified name, @n
+        *                              else @c INVALID_HANDLE in case of an error or if NetAccountInfo is not found
+        * @param[in]   netAccountName          The network account name to search for
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified @c netAccountName is invalid or NetAccountInfo with this name does not exist.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       NetAccountId GetNetAccountId(const Tizen::Base::String& netAccountName) const;
+
+       /**
+        * Gets a network account, which is set for the Tizen application on each bearer.
+        *
+        * @since               2.0
+        *
+        * @return              The network account, @n
+        *                              else INVALID_HANDLE in case of an error or if NetAccountInfo is not found
+        * @param[in]   netBearerType           The network account type of bearer
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_SYSTEM                        An internal error has occurred (baseband).
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        *                              If INVALID_HANDLE is returned but the last result shows success, @n
+        *              show a pop-up that asks the user to select the network profile in the Settings menu.
+        */
+       NetAccountId GetNetAccountId(NetBearerType netBearerType = NET_BEARER_PS) const;
+
+       /**
+        * @if VISPARTNER
+        *
+        * Gets a network account, which is set for the application like email, IM, and so on.
+        *
+        * @since               2.0
+        *
+        * @visibility  partner
+        * @privilege   %http://tizen.org/privilege/customnetaccount
+        *
+        * @return              The @c NetAccountID with the specified name, @n
+        *                              else INVALID_HANDLE is returned in case of an error or if %NetAccountInfo is not found
+        * @param[in]   netProfileName          The network profile name for an application such as email
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The @c netAccountName is invalid or %NetAccountInfo with this name does not exist.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @endif
+        */
+       NetAccountId GetAppNetAccountId(const Tizen::Base::String& netProfileName) const;
+
+       /**
+        * @if VISPARTNER
+        *
+        * Sets the application-wise default account ID to the one specified by the input argument value.
+        *
+        * @since           2.0
+        *
+        * @visibility          partner
+        * @privilege           %http://tizen.org/privilege/customnetaccount
+        *
+        * @return                      An error code
+        * @param[in]           netAccountId            The network account ID
+        * @exception           E_SUCCESS                       The method is successful.
+        * @exception           E_INVALID_ARG           The specified @c netAccountId is invalid.
+        * @exception           E_SYSTEM                        An internal error has occurred.
+        * @exception           E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        *
+        * @endif
+        */
+       result SetNetAccountId(NetAccountId netAccountId);
+
+       /**
+        * @if OSPDEPREC
+        * Gets the preferred network.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated This method is deprecated because it is moved to the NetConnectionManager class.
+        * @since               2.0
+        *
+        * @return              The preferred network, @n
+        *                              else @c NET_WIFI_FIRST in case of an error or if the preferred network is not set
+        * @exception   E_SUCCESS                       The method is successful.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @endif
+        */
+       NetPreferenceType GetNetPreference(void) const;
+
+       /**
+        * @if OSPDEPREC
+        * Sets the preferred network.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated          This method is deprecated because it is moved to the NetConnectionManager class.
+        * @since                       2.0
+        * @privilege           %http://tizen.org/privilege/network.connection
+        *
+        * @return                      An error code
+        * @param[in]           netPreference           The preferred network
+        * @exception           E_SUCCESS                       The method is successful.
+        * @exception           E_INVALID_OPERATION     This operation is not allowed.
+        * @exception           E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @remarks                     This preference is not changed during the application life-cycle.
+        *                                      If this method is not used, the default connection works in the Wi-Fi first mode.
+        * @endif
+        */
+       result SetNetPreference(NetPreferenceType netPreference = NET_WIFI_FIRST);
+
+private:
+       /*
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %NetAccountManager
+        */
+       NetAccountManager(const NetAccountManager& rhs);
+
+       /*
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs An instance of %NetAccountManager
+        */
+       NetAccountManager& operator =(const NetAccountManager& rhs);
+
+private:
+       _NetAccountManagerImpl* __pNetAccountManagerImpl;
+
+       friend class _NetAccountManagerImpl;
+}; // NetAccountManager
+
+} } //Tizen::Net
+#endif // _FNET_NET_ACCOUNT_MANAGER_H_
diff --git a/inc/FNetNetConnection.h b/inc/FNetNetConnection.h
new file mode 100755 (executable)
index 0000000..58532d7
--- /dev/null
@@ -0,0 +1,329 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetNetConnection.h
+ * @brief              This is the header file for the %NetConnection class.
+ *
+ * This header file contains the declarations of the %NetConnection class.
+ */
+#ifndef _FNET_NET_CONNECTION_H_
+#define _FNET_NET_CONNECTION_H_
+
+#include <FBase.h>
+#include <FNetNetTypes.h>
+#include <FNetNetConnectionInfo.h>
+#include <FNetINetConnectionEventListener.h>
+
+namespace Tizen { namespace Net
+{
+class _NetConnectionImpl;
+
+/**
+ * @class      NetConnection
+ * @brief      This class provides methods for all the network connections.
+ *
+ * @since      2.0
+ *
+ * The %NetConnection class provides methods for managing the connections for data communication.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/managing_network_connections.htm">Managing Network Connections</a>.
+ *
+ * The following example demonstrates how to use the %NetConnection class.
+ *
+ * @code
+
+// Start the network connection.
+using namespace Tizen::Net;
+
+void
+Test(void)
+{
+       // Account ID
+       NetAccountId accountId = INVALID_HANDLE;
+       result r = E_SUCCESS;
+
+       // Account manager
+       NetAccountManager netAccountManager;
+       r = netAccountManager.Construct();
+       accountId = netAccountManager.GetNetAccountId();
+
+       // Construct a listener.
+       TestListener* pMyListener = new TestListener();
+
+       // NetConnection instance allocation.
+       NetConnection* pNetConnection = new NetConnection;
+
+       // Construct NetConnection.
+       r = pNetConnection->Construct(accountId);
+
+       // __NetConnectionEvent AddListener.
+       r = pNetConnection->AddNetConnectionListener(pMyListener);
+
+       // NetConnection connect.
+       r = pNetConnection->Start();
+}
+ * @endcode
+ */
+class _OSP_EXPORT_ NetConnection
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * 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.
+        *
+        * @since               2.0
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        */
+       NetConnection(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~NetConnection(void);
+
+       /**
+        * Initializes this instance of %NetConnection with the specified parameter. @n
+        * It automatically binds @c netAccountId with %NetConnection. This method registers an application for receiving the network connection events. @n
+        * A network connection is based on a configured network account for starting the connection. In order to start the network connection, create a new
+        * network account or obtain the information of an existing network account, and call the Start() method.
+        *
+        * @since                       2.0
+        *
+        * @return                      An error code
+        * @param[in]           netAccountId            The index of the network account to which this %NetConnection is bound
+        * @exception           E_SUCCESS                       The method is successful.
+        * @exception           E_MAX_EXCEEDED          Unable to setup a new connection due to too many existing connections.
+        * @exception           E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception           E_INVALID_ARG           The specified input parameter is invalid.
+        * @exception           E_INVALID_ACCOUNT       The specified network account ID is invalid.
+        * @exception           E_SYSTEM                        An internal error has occurred.
+        * @exception           E_INVALID_PROXY         The proxy address is invalid.
+        * @remarks                     If the application gets the last result by E_INVALID_PROXY, it must use a warning pop-up to notify the user.
+        */
+       result Construct(NetAccountId netAccountId);
+
+public:
+       /**
+        * Adds a listener to %NetConnection. @n
+        * The added listener can listen to events when they are fired.
+        *
+        * @since               2.0
+        *
+        * @param[in]   listener                                A reference to INetConnectionEventListener
+        * @return              An error code
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance may be closed.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_OBJ_ALREADY_EXIST             The listener is already added.
+        * @exception   E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation, @n
+        *                                                                              because the caller thread is a worker thread.
+        */
+       result AddNetConnectionListener(INetConnectionEventListener& listener);
+
+       /**
+        * Removes the specified INetConnectionEventListener instance.
+        *
+        * @since               2.0
+        *
+        * @param[in]   listener                                A reference to INetConnectionEventListener
+        * @return              An error code
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance may be closed.
+        * @exception   E_OBJ_NOT_FOUND                 The eventListener is not found.
+        */
+       result RemoveNetConnectionListener(INetConnectionEventListener& listener);
+
+       /**
+        * Starts the network connection.
+        *
+        * @since               2.0
+        * @privilege   %http://tizen.org/privilege/network.connection
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance may be closed.
+        * @exception   E_INVALID_ACCOUNT               The specified network account ID is invalid.
+        * @exception   E_INVALID_CONNECTION    The network connection is invalid.
+        * @exception   E_ILLEGAL_ACCESS                Access is denied to the resources bound to this %NetConnection.
+        * @exception   E_INVALID_CONTEXT               The context information associated with the network connection account is invalid.
+        * @exception   E_SERVICE_LIMITED               A connection is already active. Therefore, cannot setup a co-existing network connection.
+        * @exception   E_SYSTEM                                An internal error has occurred.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @remarks             When the network is available, after calling this method, the OnNetConnectionStarted() method of the registered
+        *                              INetConnectionEventListener instance is called.
+        * @see                 Stop()
+        */
+       result Start(void);
+
+       /**
+        * Stops the network connection.
+        *
+        * @since               2.0
+        * @privilege   %http://tizen.org/privilege/network.connection
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance may be closed.
+        * @exception   E_INVALID_CONNECTION    The network connection is invalid.
+        * @exception   E_ILLEGAL_ACCESS                Access is denied to the resources bound to this %NetConnection.
+        * @exception   E_INVALID_CONTEXT               The context information associated with the network connection account is invalid.
+        * @exception   E_SYSTEM                                An internal error has occurred.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @remarks             This method stops the network connection of an application.  Additionally, it does not ensure immediate disconnection of the network
+        *                              service (for example, 3G data service or Wi-Fi). The network service remains active till all the applications stop using the network
+        *                              connection. Once stopped, the network connection can be restarted using the Start() method.
+        * @see                 Start(), Close()
+        */
+       result Stop(void);
+
+       /**
+        * Closes the network connection. @n
+        * All the resources associated with the network connection are freed. This is a forced operation. The Close() method disconnects the network connection
+        * with a remote server or gateway.
+        *
+        * @since               2.0
+        * @privilege   %http://tizen.org/privilege/network.connection
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance may be closed.
+        * @exception   E_INVALID_CONNECTION    The network connection is invalid.
+        * @exception   E_ILLEGAL_ACCESS                Access is denied to the resources bound to this %NetConnection.
+        * @exception   E_INVALID_CONTEXT               The context information associated with the network connection account is invalid.
+        * @exception   E_SYSTEM                                An internal error has occurred.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @remarks             This method stops the network connection of an application. Additionally, it does not ensure immediate disconnection of the network
+        *                              service (for example, 3G data service or Wi-Fi). The network service remains active till all the applications stop using the network
+        *                              connection.
+        * @see                 Stop()
+        */
+       result Close(void);
+
+       /**
+        * Gets the network account ID of this instance. @n
+        * This ID is used to establish a network connection with a remote server or gateway.
+        *
+        * @since               2.0
+        *
+        * @return              The NetAccountId of this %NetConnection which is bound at Construct(), @n
+        *                              else @c INVALID_HANDLE if %NetConnection is invalid or not constructed
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         This instance may be closed.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       NetAccountId GetNetAccountId(void) const;
+
+       /**
+        * Gets the network connection information.
+        *
+        * @since               2.0
+        *
+        * @return              A NetConnectionInfo instance specifying information on this network connection
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance may be closed.
+        * @exception   E_INVALID_CONNECTION    The network connection is invalid.
+        * @exception   E_ILLEGAL_ACCESS                The access is denied.
+        * @exception   E_INVALID_CONTEXT               The context information associated with the network connection account is invalid.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                                An internal error has occurred.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        * @remarks             This method requires a NetConnectionInfo instance reference. The network connection information is only available when the network
+        *                              connection is "Active". For other states, this method returns @c null.
+        * @warning     Do not delete the returned NetConnectionInfo instance. This instance directly references the internal connection information of
+        *                              %NetConnection.
+        */
+       const NetConnectionInfo* GetNetConnectionInfo(void) const;
+
+       /**
+        * @if OSPDEPREC
+        * Gets the connection information for the specified account.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated This method is deprecated because it is moved to the NetConnectionManager class.
+        * @since       2.0
+        *
+        * @return              A NetConnectionInfo instance specifying information on this network connection, @n
+        *                              else @c null in case of an error or if an active connection is not found
+        * @param[in]   netAccountId            The network account
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ACCOUNT       The specified network account ID is invalid.
+        * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @endif
+        */
+       static NetConnectionInfo* GetNetConnectionInfoN(NetAccountId netAccountId);
+
+       /**
+        * @if OSPDEPREC
+        * Gets a list of all the connection information used by the system.
+        *
+        * @brief <i> [Deprecated] </i>
+        * @deprecated  This method is deprecated because it is moved to the NetConnectionManager class.
+        * @since       2.0
+        *
+        * @return              An IList containing indexes to NetConnectionInfo in the network, @n
+        *                              else @c null in case of an error or if an active connection is not found
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        An internal error has occurred (baseband or system).
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        * @endif
+        */
+       static Tizen::Base::Collection::IList* GetAllNetConnectionInfoN(void);
+
+
+       /**
+        * Gets the state of the network connection.
+        *
+        * @since               2.0
+        *
+        * @return              The state of the network connection
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance may be closed.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       NetConnectionState GetConnectionState(void) const;
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   value                   An instance of %NetConnection
+        */
+       NetConnection(const NetConnection& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                             An instance of %NetConnection
+        */
+       NetConnection& operator =(const NetConnection& rhs);
+
+private:
+       _NetConnectionImpl* __pNetConnectionImpl;
+
+       friend class _NetConnectionImpl;
+}; // NetConnection
+
+} } //Tizen::Net
+
+#endif // _FNET_NET_CONNECTION_H_
diff --git a/inc/FNetNetConnectionInfo.h b/inc/FNetNetConnectionInfo.h
new file mode 100644 (file)
index 0000000..e9f9802
--- /dev/null
@@ -0,0 +1,224 @@
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//     http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+\r
+/**\r
+ * @file               FNetNetConnectionInfo.h \r
+ * @brief              This is the header file for the %NetConnectionInfo class.\r
+ *\r
+ * This header file contains the declarations of the %NetConnectionInfo class.\r
+ */\r
+#ifndef _FNET_NET_CONNECTION_INFO_H_\r
+#define _FNET_NET_CONNECTION_INFO_H_\r
+\r
+#include <FBaseObject.h>\r
+#include <FBaseResult.h>\r
+#include <FNetNetTypes.h>\r
+#include <FNetIpAddress.h>\r
+\r
+namespace Tizen { namespace Net {\r
+class _NetConnectionInfoImpl;\r
+\r
+/**\r
+ * @class      NetConnectionInfo \r
+ * @brief      This class represents a base type for the information related to a network connection.\r
+ *\r
+ * @since      2.0\r
+ *\r
+ *     The %NetConnectionInfo class provides methods to obtain information related to a network connection. %NetConnectionInfo is valid when \r
+ *     NetConnection is not in the "NET_CONNECTION_STATE_STOPPED" state.\r
+ *\r
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/managing_network_connections.htm">Managing Network Connections</a>.\r
+ */\r
+class _OSP_EXPORT_ NetConnectionInfo\r
+       : public Tizen::Base::Object\r
+{\r
+public:\r
+\r
+       /**\r
+        * This is the default constructor for this class.\r
+        *\r
+        * @since       2.0\r
+        *\r
+        * @remarks             The GetLastResult() method is used to check whether the %NetConnectionInfo instance is created successfully.\r
+        */\r
+       NetConnectionInfo(void);\r
+\r
+       /**\r
+        *      This destructor overrides Tizen::Base::Object::~Object().\r
+        *\r
+        * @since       2.0\r
+        */\r
+       virtual ~NetConnectionInfo(void);\r
+\r
+       /** \r
+        * Gets the operating bearer type of a mobile station.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return              The operating bearer type of a specific network connection, @n\r
+        *                              else @c NET_BEARER_NONE if this instance is invalid\r
+        */\r
+        NetBearerType GetBearerType(void) const;\r
+\r
+       /** \r
+        * Gets the operation protocol of a mobile station.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return              The protocol type of a specific network connection, @n\r
+        *                              else @c NET_PROTO_TYPE_NONE     if this instance is invalid\r
+        */\r
+        NetProtocolType GetProtocolType(void) const;\r
+\r
+       /** \r
+        * Gets the Access Point Name.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return              The Access Point Name as a string, @n\r
+        *                              else a null string if the Access Point Name is empty or this instance is invalid\r
+        */\r
+       Tizen::Base::String GetAccessPointName(void) const;\r
+\r
+       /** \r
+        * Gets the local address scheme.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return              The address scheme for the local address, @n\r
+        *                              else @c NET_ADDRESS_SCHEME_NONE if this instance is invalid\r
+        */\r
+       NetAddressScheme GetLocalAddressScheme(void) const;\r
+\r
+       /** \r
+        * Gets the local address information.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return              A pointer to the IpAddress instance representing the local address in the calling instance\r
+        * @remarks             If GetLocalAddressScheme() is NET_ADDRESS_SCHEME_STATIC, this method returns the statically assigned local addresses. @n\r
+        *                              If %GetLocalAddressScheme() is NET_ADDRESS_SCHEME_DYNAMIC, this method returns the dynamically assigned local addresses. @n\r
+        *                              In any case, check whether the IpAddress pointer is @c null or not.\r
+        */\r
+       const IpAddress* GetLocalAddress(void) const;\r
+\r
+       /** \r
+        * Gets the setting for the DNS address scheme.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return              The address scheme for the DNS address, @n\r
+        *                              else @c NET_ADDRESS_SCHEME_NONE if this instance is invalid\r
+        *\r
+        */\r
+       NetAddressScheme GetDnsAddressScheme(void) const;\r
+\r
+       /** \r
+        * Gets the primary DNS address.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return              A pointer to the IpAddress instance representing the primary DNS Address of the network connection\r
+        * @remarks             If GetDnsAddressScheme() is NET_ADDRESS_SCHEME_STATIC, this method returns the statically assigned local addresses. @n\r
+        *                              If %GetDnsAddressScheme() is NET_ADDRESS_SCHEME_DYNAMIC, this method returns the dynamically assigned local addresses. @n\r
+        *                              In any case, check whether the IpAddress pointer is @c null or not, because the DNS address field is not mandatory.\r
+        */\r
+       const IpAddress* GetPrimaryDnsAddress(void) const;\r
+\r
+       /** \r
+        * Gets the secondary DNS address.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return              A pointer to the IpAddress instance representing the secondary DNS Address of the network connection\r
+        * @remarks             If GetDnsAddressScheme() is NET_ADDRESS_SCHEME_STATIC, this method returns the statically assigned local addresses. @n\r
+        *                              If %GetDnsAddressScheme() is NET_ADDRESS_SCHEME_DYNAMIC, this method returns the dynamically assigned local addresses. @n\r
+        *                              In any case, check whether the IpAddress pointer is @c null or not, because the DNS address field is not mandatory.\r
+        */\r
+       const IpAddress* GetSecondaryDnsAddress(void) const;\r
+\r
+       /** \r
+        * Gets the subnet mask address.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return              A pointer to the IpAddress instance representing the subnet mask address of the network connection\r
+        * @remarks     In any case, check whether the %IpAddress pointer is @c null or not, because the subnet mask address field is not mandatory.\r
+        */\r
+       const IpAddress* GetSubnetMaskAddress(void) const;\r
+       \r
+       /** \r
+        * Gets the default gateway address.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return      A pointer to the IpAddress instance representing the default gateway address of the network connection\r
+        * @remarks     In any case, check whether the IpAddress pointer is @c null or not, because the gateway address field is not mandatory.\r
+        */\r
+       const IpAddress* GetDefaultGatewayAddress(void) const;\r
+\r
+       /**\r
+        * Copying of objects using this copy constructor is allowed.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @param[in]   rhs                     An instance of %NetConnectionInfo\r
+        * @remarks             The GetLastResult() method is used to check whether the %NetConnectionInfo instance is created successfully.\r
+        */\r
+       NetConnectionInfo(const NetConnectionInfo& rhs);\r
+\r
+       /**\r
+        * Copying of objects using this copy assignment operator is allowed.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return              The reference of this instance\r
+        * @param[in]   rhs An instance of %NetConnectionInfo\r
+        * @remarks             The GetLastResult() method is used to check whether the %NetConnectionInfo instance is copied successfully.\r
+        */\r
+       NetConnectionInfo& operator =(const NetConnectionInfo& rhs);\r
+\r
+       /**\r
+        * Compares the specified instance of %NetConnectionInfo with the calling instance.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return              @c true if the values match, @n\r
+        *                              else @c false\r
+        * @param[in]   rhs     The other Object to compare\r
+        * @see                 Object::Equals()\r
+        */\r
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;\r
+\r
+       /**\r
+        * Gets the hash value of the current instance.\r
+        *\r
+        * @since               2.0\r
+        *\r
+        * @return      The hash value of the current instance\r
+        */\r
+       virtual int GetHashCode(void) const;\r
+\r
+private: \r
+       _NetConnectionInfoImpl* __pNetConnectionInfoImpl;\r
+\r
+       friend class _NetConnectionInfoImpl;\r
+}; // NetConnectionInfo\r
+\r
+} } //Tizen::Net\r
+\r
+#endif // _FNET_NET_CONNECTION_INFO_H_\r
diff --git a/inc/FNetNetConnectionManager.h b/inc/FNetNetConnectionManager.h
new file mode 100755 (executable)
index 0000000..ea77ea0
--- /dev/null
@@ -0,0 +1,189 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetNetConnectionManager.h
+ * @brief              This is the header file for the %NetConnectionManager class.
+ *
+ * This header file contains the declarations of the %NetConnectionManager class.
+ */
+#ifndef _FNET_NET_CONNECTION_MANAGER_H_
+#define _FNET_NET_CONNECTION_MANAGER_H_
+
+#include <FBase.h>
+#include <FNetNetTypes.h>
+#include <FNetNetConnection.h>
+#include <FNetManagedNetConnection.h>
+
+namespace Tizen { namespace Net
+{
+class _NetConnectionManagerImpl;
+
+/**
+ * @class      NetConnectionManager
+ * @brief      This class provides methods for managing the network connections.
+ *
+ * @since   2.0
+ *
+ *  The %NetConnectionManager class provides methods for creating and retrieving connections for data communication.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/managing_network_connections.htm">Managing Network Connections</a>.
+ */
+class _OSP_EXPORT_ NetConnectionManager
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * 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.
+        *
+        * @since       2.0
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        */
+       NetConnectionManager(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.0
+        */
+       virtual ~NetConnectionManager(void);
+
+       /**
+        * Initializes this instance of %NetConnectionManager.
+        *
+        * @since       2.0
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        */
+       result Construct(void);
+
+public:
+       /**
+        * Creates a new network connection.
+        *
+        * @since       2.0
+        *
+        * @return              A NetConnection instance containing the account information, @n
+        *                              else @c null if an error occurs
+        * @param[in]   netAccountId            The index of the network account to which this %NetConnection is bound
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ACCOUNT       The specified network account ID is invalid.
+        * @exception   E_MAX_EXCEEDED          Unable to setup a new connection due to too many existing connections.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       NetConnection* CreateNetConnectionN(NetAccountId netAccountId);
+
+       /**
+        * Gets an instance of the current connection that is managed by the system.
+        *
+        * @since       2.0
+        *
+        * @return              A ManagedNetConnection instance containing the account information, @n
+        *                              else @c null if an error occurs
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       ManagedNetConnection* GetManagedNetConnectionN(void) const;
+
+       /**
+        * Gets the preferred network.
+        *
+        * @since       2.0
+        *
+        * @return              The preferred network, @n
+        *                              else @c NET_WIFI_FIRST if there is an error or if the preferred network is not set
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       NetPreferenceType GetNetPreference(void) const;
+
+       /**
+        * Sets the preferred network.
+        *
+        * @since       2.0
+        * @privilege   %http://tizen.org/privilege/network.connection
+        *
+        * @return              An error code
+        * @param[in]   netPreference           The preferred network
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_OPERATION     This operation is not allowed.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @remarks             If this method is not used, the default connection works in the Wi-Fi first mode.
+        */
+       result SetNetPreference(NetPreferenceType netPreference);
+
+public:
+       /**
+        * Gets the connection information that is related to a network account.
+        *
+        * @since       2.0
+        *
+        * @return              A NetConnectionInfo instance specifying the information on this network connection, @n
+        *                              else @c null if there is an error or if an active connection is not found
+        * @param[in]   netAccountId            The network account ID
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ACCOUNT       The specified network account ID is invalid.
+        * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static NetConnectionInfo* GetNetConnectionInfoN(NetAccountId netAccountId);
+
+       /**
+        * Gets a list of all the network connections information that is used by the system.
+        *
+        * @since       2.0
+        *
+        * @return              An IList containing indexes to the active %NetConnectionInfo in the network, @n
+        *                              else @c null if there is an error or if there is no active connection in the system
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        An internal error has occurred (baseband or system).
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static Tizen::Base::Collection::IList* GetAllNetConnectionInfoN(void);
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs             An instance of %NetConnectionManager
+        */
+       NetConnectionManager(const NetConnectionManager& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %NetConnectionManager
+        */
+       NetConnectionManager& operator =(const NetConnectionManager& rhs);
+
+private:
+       _NetConnectionManagerImpl* __pNetConnectionManagerImpl;
+
+       friend class _NetConnectionManagerImpl;
+}; // NetConnectionManager
+
+} } //Tizen::Net
+
+#endif // _FNET_NET_CONNECTION_MANAGER_H_
diff --git a/inc/FNetNetEndPoint.h b/inc/FNetNetEndPoint.h
new file mode 100644 (file)
index 0000000..61fdf9b
--- /dev/null
@@ -0,0 +1,178 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetNetEndPoint.h
+ * @brief              This is the header file for the %NetEndPoint class.
+ *
+ * This header file contains the declarations of the %NetEndPoint class.
+ */
+#ifndef _FNET_NET_END_POINT_H_
+#define _FNET_NET_END_POINT_H_
+
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FNetIpAddress.h>
+#include <FNetSockSocketTypes.h>
+
+namespace Tizen { namespace Net
+{
+class _NetEndPointImpl;
+
+/**
+ * @class      NetEndPoint
+ * @brief      This class identifies the network address.
+ *
+ * @since      2.0
+ *
+ * The %NetEndPoint class provides a base class that represents the network address of a resource or service.
+ *
+ */
+class _OSP_EXPORT_ NetEndPoint
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        *      This is the default constructor for this class.
+        *
+        *      @since  2.0
+        */
+       NetEndPoint(void);
+
+       /**
+        * Initializes this instance of %NetEndPoint with the specified address and port number.
+        *
+        * @since       2.0
+        *
+        * @param[in]   ipAddress       The IP address of the target endpoint
+        * @param[in]   port                    The port number
+        * @exception   E_SUCCESS       The instance is initialized successfully.
+        * @exception   E_INVALID_ARG   A specified input parameter is invalid.
+        * @remarks         The GetLastResult() method is used to check whether the %NetEndPoint instance is created successfully.
+        */
+       NetEndPoint(const IpAddress& ipAddress, unsigned short port);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        *
+        * @since                       2.0
+        *
+        * @param[in]   rhs                     An instance of %NetEndPoint
+        * @exception   E_SUCCESS       The instance is initialized successfully.
+        * @exception   E_INVALID_ARG   The specified input parameter is invalid.
+        * @remarks         The GetLastResult() method is used to check whether the %NetEndPoint instance is created successfully.
+        */
+       NetEndPoint(const NetEndPoint& rhs);
+
+       /**
+        *      This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~NetEndPoint(void);
+
+       /**
+        * Gets the address family to which the calling %NetEndPoint instance belongs.
+        *
+        * @since       2.0
+        *
+        * @return              The address family of the calling instance
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        */
+       NetAddressFamily GetNetAddressFamily(void) const;
+
+       /**
+        * Gets the port number of the endpoint.
+        *
+        * @since       2.0
+        *
+        * @return              The port number of the endpoint
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        */
+       unsigned short GetPort(void) const;
+
+       /**
+        * Gets the IP address of the calling instance.
+        *
+        * @since       2.0
+        *
+        * @return              The IP address of the endpoint, @n
+        *                              else @c null if the address information is invalid
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        */
+       IpAddress* GetAddress(void) const;
+
+       /**
+        * Gets the current endpoint.
+        *
+        * @since       2.0
+        *
+        * @return              The current endpoint, @n
+        *                              else @c null string if an error occurs
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        * @remarks             The string output of this method is formatted as follows: IPADDRESS:PORT. @n
+        *                              IPADDRESS is a string representing a number expressed in the Internet Standard "." (dotted) notation (for example, 165.213.173.7). @n
+        *                              PORT is a string representing a port number in host byte order. For example, 165.213.173.7:2000 is a possible string. @n
+        *                              The specific error code can be accessed using the GetLastResult() method.
+        */
+       Tizen::Base::String GetNetEndPoint(void) const;
+
+       /**
+        * Copying of objects using this copy assignment operator is allowed.
+        *
+        * @since               2.0
+        *
+        * @return              The reference of this instance
+        * @param[in]   rhs An instance of %NetEndPoint
+        * @remarks             The GetLastResult() method is used to check whether the %NetEndPoint instance is copied successfully.
+        */
+       NetEndPoint& operator =(const NetEndPoint& rhs);
+
+       /**
+        * Compares the specified instance of %NetEndPoint with the calling instance.
+        *
+        * @since               2.0
+        *
+        * @return              @c true if the values match, @n
+        *                              else @c false
+        * @param[in]   rhs     The other Object to compare
+        * @see                 Object::Equals()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since               2.0
+        *
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+private:
+       _NetEndPointImpl* __pNetEndPointImpl;
+
+       friend class _NetEndPointImpl;
+}; // NetEndPoint
+
+} } //Tizen::Net
+
+#endif // _FNET_NET_END_POINT_H_
diff --git a/inc/FNetNetStatistics.h b/inc/FNetNetStatistics.h
new file mode 100755 (executable)
index 0000000..7942843
--- /dev/null
@@ -0,0 +1,157 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetNetStatistics.h
+ * @brief              This is the header file for the %NetStatistics class.
+ *
+ * This header file contains the declarations of the %NetStatistics class.
+ */
+#ifndef _FNET_NET_STATISTICS_H_
+#define _FNET_NET_STATISTICS_H_
+
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FNetNetTypes.h>
+#include <FNetNetAccountInfo.h>
+
+namespace Tizen { namespace Net
+{
+class _NetStatisticsImpl;
+
+/**
+ * @class      NetStatistics
+ * @brief      This class represents the statistical information on the Packet-Switched (PS) data call.
+ *
+ * @since      2.0
+ *
+ * @remarks    The %NetStatistics class cannot be tested on the emulator.
+ *
+ * The %NetStatistics class provides methods for getting the statistical information on the Packet-Switched (PS) data call.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/network_statistics.htm">Network Statistics</a>.
+ */
+class _OSP_EXPORT_ NetStatistics
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * 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.
+        *
+        * @since               2.0
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        */
+       NetStatistics(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.0
+        */
+       virtual ~NetStatistics(void);
+
+       /**
+        * Initializes this instance of %NetStatistics.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        */
+       result Construct(void);
+
+public:
+       /**
+        * Gets the statistical information. @n
+        * This can consist of details such as the call duration, the sent and received size, and so on.
+        *
+        * @since                       2.0
+        * @privilege           %http://tizen.org/privilege/network.statistics.read
+        *
+        * @return                      The number of bytes sent or received, @n
+        *                                      else @c INVALID_HANDLE if an error occurs
+        * @param[in]           bearerType                      The bearer type of the data call operation @n
+        *                                                                              NET_BEARER_WIFI_DIRECT and NET_BEARER_USB are not supported.
+        * @param[in]           netStatType                     The type of statistical information to get
+        * @exception           E_SUCCESS                       The method is successful.
+        * @exception           E_INVALID_ARG           A specified input parameter is invalid.
+        * @exception           E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @remarks                     The specific error code can be accessed using the GetLastResult() method.
+        */
+       long long GetNetStatisticsInfo(NetBearerType bearerType, NetStatisticsInfoType netStatType) const;
+
+       /**
+        * Resets the specified statistical information on the network according to the operation mode.
+        *
+        * @since               2.0
+        * @privilege   %http://tizen.org/privilege/network.statistics.write
+        *
+        * @return              An error code
+        * @param[in]   bearerType                      The bearer type (OperationMode) whose statistical information is reset @n NET_BEARER_WIFI_DIRECT and NET_BEARER_USB are not supported.
+        * @param[in]   netStatType                     The type of statistical information to reset
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           A specified input parameter is invalid.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @remarks             This method must use warning pop-up for user notification.
+        * @see                 GetNetStatisticsInfo()
+        */
+       result Reset(NetBearerType bearerType, NetStatisticsInfoType netStatType);
+
+       /**
+        * Resets all the specified statistical information on the network according to the operation mode.
+        *
+        * @since               2.0
+        * @privilege   %http://tizen.org/privilege/network.statistics.write
+        *
+        * @return              An error code
+        * @param[in]   bearerType                      The bearer type (OperationMode) whose statistical information would be reset @n NET_BEARER_WIFI_DIRECT and NET_BEARER_USB are not supported.
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG           The specified input parameter is invalid.
+        * @exception   E_SYSTEM                        An internal error has occurred.
+        * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        *
+        * @remarks             This method must use warning pop-up for user notification.
+        * @see                 GetNetStatisticsInfo()
+        */
+       result ResetAll(NetBearerType bearerType);
+
+private:
+       /*
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %NetStatistics
+        */
+       NetStatistics(const NetStatistics& rhs);
+
+       /*
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %NetStatistics
+        */
+       NetStatistics& operator =(const NetStatistics& rhs);
+
+private:
+       _NetStatisticsImpl* __pNetStatisticsImpl;
+
+       friend class _NetStatisticsImpl;
+}; // NetStatistics
+
+} } //Tizen::Net
+#endif // _FNET_NET_STATISTICS_H_
diff --git a/inc/FNetNetTypes.h b/inc/FNetNetTypes.h
new file mode 100644 (file)
index 0000000..337839b
--- /dev/null
@@ -0,0 +1,220 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file                        FNetNetTypes.h
+* @brief               This is the header file for defining the types for the Net namespace.
+*
+* This header file contains the definitions of the various types and enumerators for the NetConnection operations.
+*/
+#ifndef _FNET_NET_TYPES_H_
+#define _FNET_NET_TYPES_H_
+
+#include <FBase.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseErrorDefine.h>
+
+
+namespace Tizen { namespace Net
+{
+
+/**
+ * The network account ID.
+ *
+ * @since 2.0
+ */
+typedef int NetAccountId;
+
+/**
+ * @enum       NetConnectionState
+ *
+ * Defines the state of the network connection.
+ *
+ * @since      2.0
+ */
+enum NetConnectionState
+{
+       NET_CONNECTION_STATE_NONE,          /**< The initial state */
+       NET_CONNECTION_STATE_STARTING,      /**< The network connection is being established */
+       NET_CONNECTION_STATE_STARTED,       /**< The network connection has been established */
+       NET_CONNECTION_STATE_STOPPING,      /**< The network connection is being disconnected */
+       NET_CONNECTION_STATE_STOPPED,       /**< The network connection has been disconnected */
+       NET_CONNECTION_STATE_SUSPENDED,     /**< The network connection has been suspended */
+       NET_CONNECTION_STATE_SUSPEND = 5,   // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
+       NET_CONNECTION_STATE_RESUMED,       /**< The network connection is established, and recovered from SUSPEND state - enable to send/receive packet data */
+       NET_CONNECTION_STATE_AVAILABLE,     // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
+       NET_CONNECTION_STATE_UNAVAILABLE,   // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
+};
+
+/**
+ * @enum    NetConnectionStoppedReason
+ *
+ * Defines the reason for stoppage of the network connection.
+ *
+ * @since 2.0
+ */
+enum NetConnectionStoppedReason
+{
+       NET_CONNECTION_STOPPED_REASON_RESOURCE_RELEASED,    /**< The network connection managed by system stopped because the network resources have been released */
+       NET_CONNECTION_STOPPED_REASON_NETWORK_FAILED,       /**< The network has failed */
+       NET_CONNECTION_STOPPED_REASON_DEVICE_OFFLINE,       /**< The operation has failed because the device is in offline mode */
+       NET_CONNECTION_STOPPED_REASON_SERVICE_UNAVAILABLE,  /**< The device is out of the coverage area or in an emergency mode */
+       NET_CONNECTION_STOPPED_REASON_RESOURCE_UNAVAILABLE, /**< The network resource is unavailable */
+       NET_CONNECTION_STOPPED_REASON_SYSTEM                /**< A system error has occurred */
+};
+
+/**
+ * @enum    NetProtocolType
+ *
+ * Defines the network protocol type.
+ *
+ * @since      2.0
+ */
+enum NetProtocolType
+{
+       NET_PROTO_TYPE_IPV4 = 1,            /**< The IPV4 type */
+       NET_PROTO_TYPE_PPP,                             /**< The PPP type */
+       NET_PROTO_TYPE_IPV6,                            /**< The IPV6 type, currently NOT supported */
+       NET_PROTO_TYPE_NONE = 0         // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. Network Protocol type not set
+};
+
+/**
+ * @enum    NetAddressFamily
+ *
+ * Defines the network address family.
+ *
+ * @since      2.0
+ */
+enum NetAddressFamily
+{
+
+       NET_AF_IPV4 = 1,                /**< The default @n An IPv4 address [RFC791] is represented in decimal format with dots as delimiters. */
+       NET_AF_IPV6,                                    /**< An IPv6 address [RFC2373] is generally represented in hexadecimal numbers with colons as delimiters @n It can also be a combination of hexadecimal and decimal numbers with dots and colons as delimiters. */
+       NET_AF_ALPHANUMERIC,    /**< A generic alphanumeric address (as defined by alphanum in [RFC2396]) */
+       NET_AF_APN,                             /**< A GPRS APN as defined in [GENFORM] */
+       NET_AF_NONE = 0                 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. Network Address Family not set
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * @enum    NetStatisticsInfoType
+ *
+ * Defines the various kinds of data call statistics information.
+ *
+ * @since      2.0
+ */
+enum NetStatisticsInfoType
+{
+       NET_STAT_SENT_SIZE = 2,                                                         /**< The size of the packet sent, since the time the network is last reactivated */
+       NET_STAT_RCVD_SIZE = 3,                                                         /**< The size of the packet received, since the time the network is last reactivated */
+       NET_STAT_TOTAL_SENT_SIZE = 8,                                   /**< The cumulated size of the packet sent since the last reset */
+       NET_STAT_TOTAL_RCVD_SIZE = 9,                                   /**< The cumulated size of the packet received since the last reset */
+       NET_STAT_NONE = 0                                                       // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. Network Statistics Info Type not set
+};
+
+/**
+ * @enum    NetPreferenceType
+ *
+ * Defines the preferred network.
+ *
+ * @since      2.0
+ */
+enum NetPreferenceType
+{
+       NET_WIFI_FIRST,                                 /**< The preference type to follow preferred mode (Wi-Fi first) @n
+                                                                       *       This preference type works like NET_PS_ONLY on the Emulator. */
+       NET_PS_ONLY,                                            /**< The preference type to only operate services for the PS domain */
+       NET_CS_ONLY,                     // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
+       NET_WIFI_ONLY                    /**< The preference type to only operate services for Wi-Fi */
+};
+
+/**
+ * @enum    NetBearerType
+ *
+ * Defines the bearer type.
+ *
+ * @since      2.0
+ */
+enum NetBearerType
+{
+       NET_BEARER_PS = 1,                 /**< The bearer type for the PS domain */
+       NET_BEARER_CS,                                  // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
+       NET_BEARER_WIFI,                        /**< The bearer type for Wi-Fi */
+       NET_BEARER_WIFI_DIRECT,         /**< The bearer type for Wi-Fi Direct @n
+                                                                               *       This bearer type cannot be tested on the Emulator. */
+       NET_BEARER_USB,                         /**< The bearer type for USB NDIS mode @n
+                                                                               *       Can use this bearer type via USB Tethering mode. @n
+                                                                               *       This bearer type cannot be tested on the Emulator. */
+       NET_BEARER_MMS,                         /**< The bearer type for MMS */
+       NET_BEARER_NONE = 0             // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. Network Bearer Type not set
+};
+
+/**
+ * @enum    NetAddressScheme
+ *
+ * Defines the network IP or Domain Name %System (DNS) scheme.
+ *
+ * @since      2.0
+ */
+enum NetAddressScheme
+{
+       NET_ADDRESS_SCHEME_DYNAMIC = 1, /**< The Dynamic IP or DNS Address */
+       NET_ADDRESS_SCHEME_STATIC,      /**< The Static IP or DNS Address */
+       NET_ADDRESS_SCHEME_NONE = 0     // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. Network Address Scheme not set
+};
+
+/**
+ * @enum    NetNapAuthType
+ *
+ * Defines the authentication type of the network.
+ *
+ * @since      2.0
+ *
+ * @remarks  There is no relevant data.
+ */
+enum NetNapAuthType
+{
+       NET_NAPAUTH_PAP = 1,                                            /**< The PAP (Password Authentication Protocol) type */
+       NET_NAPAUTH_CHAP,                                                       /**< The CHAP (Challenge/Handshake Authentication Protocol) type */
+       NET_NAPAUTH_NONE = 0                                    // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. Network NAP Authentication Type not set
+};
+
+/**
+ * @if VISPARTNER-MANUFACTURER
+ *
+ * @enum    NetProxyType
+ *
+ * Defines the proxy type of the network
+ *
+ * @since 2.0
+ *
+ * @visibility  partner-manufacturer
+ *
+ * @endif
+ */
+enum NetProxyType
+{
+    NET_PROXY_TYPE_NONE = 0,  /**< Not use a proxy */
+    NET_PROXY_TYPE_MANUAL     /**< Manual configuration */
+};
+
+
+} } //Tizen::Net
+
+#endif // _FNET_NET_TYPES_H_
diff --git a/inc/FNetSockISecureSocketEventListener.h b/inc/FNetSockISecureSocketEventListener.h
new file mode 100644 (file)
index 0000000..e98af42
--- /dev/null
@@ -0,0 +1,150 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+/**
+* @file                FNetSockISecureSocketEventListener.h
+* @brief       This is the header file for the %ISecureSocketEventListener interface.
+*
+* This header file contains the declarations of the %ISecureSocketEventListener interface.
+*/
+
+#ifndef _FNET_SOCK_ISECURE_SOCKET_EVENT_LISTENER_H_
+#define _FNET_SOCK_ISECURE_SOCKET_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FNetSockSocketTypes.h>
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+class SecureSocket;
+
+/**
+* @interface   ISecureSocketEventListener
+* @brief               This interface contains an event listener for the applications, which issues secure socket requests.
+*
+* @since        2.0
+*
+*                              The %ISecureSocketEventListener interface specifies the methods used for creating the notifications about the different kinds of socket
+*                              events. These events are sent out when using a secure socket in a non-blocking mode. An event listener is added by calling the
+*                              SecureSocket::AddSecureSocketListener() method. One of these methods is called when a socket event is generated.
+*
+* For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/sockets.htm">Sockets Guide</a>.
+*/
+class _OSP_EXPORT_ ISecureSocketEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+
+
+public:
+       /**
+       * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+       *
+       * @since        2.0
+       */
+       virtual ~ISecureSocketEventListener(void) {}
+
+
+public:
+       /**
+       * Called to notify a connecting secure socket that its connection attempt has been completed successfully.
+       *
+       * @since                2.0
+       *
+       * @param[in]    socket          The SecureSocket instance
+       */
+       virtual void OnSecureSocketConnected(SecureSocket& socket) = 0;
+
+       /**
+       * Called to notify the registered secure socket that the peer secure socket has been closed due to normal or forced termination of network. @n
+       * It is also used to notify a connecting secure socket that its connection attempt has resulted in an error.
+       *
+       * @since        2.0
+       *
+       * @param[in]    socket          The SecureSocket instance
+       * @param[in]    reason          The reason of type NetSocketClosedReason for a closed secure socket
+       * @remarks              If the reason is NET_SOCKET_CLOSED_REASON_NO_CERTIFICATE, start the Application control (L"tizen.certificatemanager") for getting the selected client certificate. @n
+       *               For more information, see <a href="../org.tizen.native.appprogramming/html/guide/app/appcontrol_certmgr.htm">here</a>.
+       */
+       virtual void OnSecureSocketClosed(SecureSocket& socket, NetSocketClosedReason reason) = 0;
+
+       /**
+       * Called to notify a secure socket that the data is ready to be retrieved.
+       *
+       * @since        2.0
+       *
+       * @param[in]    socket          The SecureSocket instance
+       * @remarks              This data can be retrieved by calling Receive().
+       */
+       virtual void OnSecureSocketReadyToReceive(SecureSocket& socket) = 0;
+
+
+       /**
+       * Called to notify a secure socket that the data can be sent.
+       *
+       * @since        2.0
+       *
+       * @param[in]    socket          The SecureSocket instance
+       * @remarks              This data can be sent by calling Send().
+       */
+       virtual void OnSecureSocketReadyToSend(SecureSocket& socket) = 0;
+
+       /**
+       * Called to notify a secure socket that the verification of the server's certificate has failed. @n
+       * Either of the following decisions can be taken after the verification fails: @n
+       * - Continue with SSL handshaking without verification.
+       * - Close the secure socket.
+       *
+       * @since        2.0
+       *
+       * @param[in]    socket   The SecureSocket instance
+       */
+       virtual void OnSecureSocketServCertFailed(SecureSocket& socket) = 0;
+
+       /**
+        * Called to notify a secure socket that it has received a new connection from a peer.
+        *
+        * @since        2.0
+        *
+        * @param[in]   socket          The SecureSocket instance
+        */
+       virtual void OnSecureSocketAccept(SecureSocket& socket) {}
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void ISecureSocketEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void ISecureSocketEventListener_Reserved2(void) {}
+
+};
+
+} } } // Tizen::Net::Sockets
+#endif // _FNET_SOCK_ISECURE_SOCKET_EVENT_LISTENER_H_
diff --git a/inc/FNetSockISocketEventListener.h b/inc/FNetSockISocketEventListener.h
new file mode 100644 (file)
index 0000000..5467624
--- /dev/null
@@ -0,0 +1,171 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+/**
+* @file                FNetSockISocketEventListener.h
+* @brief       This is the header file for the %ISocketEventListener interface.
+*
+* This header file contains the declarations of the %ISocketEventListener interface.
+*/
+
+#ifndef _FNET_SOCK_ISOCKET_EVENT_LISTENER_H_
+#define _FNET_SOCK_ISOCKET_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FNetSockSocketTypes.h>
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+class Socket;
+
+/**
+* @interface   ISocketEventListener
+* @brief               This interface contains a listener for the socket events.
+*
+* @since        2.0
+*
+*                              The %ISocketEventListener interface specifies methods used for creating notifications about the different kinds of socket events.
+*                              These events are only sent out when using the socket in a non-blocking mode. A listener is registered by calling the AddSocketListener()
+*                              method. One of these methods is called when a socket event is generated.
+*
+* For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/sockets.htm">Sockets Guide</a>.
+*
+* The following example demonstrates how to use the %ISocketEventListener interface.
+*
+* @code
+using namespace Tizen::Net::Sockets;
+
+class TestListener
+       : public Object
+       , public virtual ISocketEventListener
+{
+public:
+       TestListener() {}
+
+       ~TestListener() {}
+
+       void OnSocketConnected(Socket& socket)
+       {
+               AppLog("OnConnected\n");
+       }
+
+       void OnSocketClosed(Socket& socket, NetSocketClosedReason reason)
+       {
+               AppLog("OnClosed\n");
+       }
+
+       void OnSocketReadyToReceive(Socket& socket)
+       {
+               AppLog("OnReadyToReceive\n");
+       }
+
+       void OnSocketReadyToSend(Socket& socket)
+       {
+               AppLog("OnReadyToSend\n");
+       }
+};
+* @endcode
+*/
+class _OSP_EXPORT_ ISocketEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+
+
+public:
+       /**
+        * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+        *
+        * @since 2.0
+        */
+       virtual ~ISocketEventListener(void) {}
+
+
+public:
+       /**
+       * Called to notify a connecting socket that its connection attempt has been completed successfully.
+       *
+       * @since        2.0
+       *
+       * @param[in]    socket          The Socket instance
+       */
+       virtual void OnSocketConnected(Socket& socket) = 0;
+
+       /**
+       * Called to notify the registered socket that the peer socket has been closed due to normal or forced termination of the network. @n
+       * It is also used to notify a connecting socket that its connection attempt has resulted in an error.
+       *
+       * @since        2.0
+       *
+       * @param[in]    socket          The Socket instance
+       * @param[in]    reason          The reason of type NetSocketClosedReason for a closed socket
+       */
+       virtual void OnSocketClosed(Socket& socket, NetSocketClosedReason reason) = 0;
+
+       /**
+       * Called to notify a socket that the data is ready to be retrieved.
+       *
+       * @since        2.0
+       *
+       * @param[in]    socket          The Socket instance
+       * @remarks              The data can be retrieved by calling Receive() or ReceiveFrom().
+       */
+       virtual void OnSocketReadyToReceive(Socket& socket) = 0;
+
+       /**
+       * Called to notify a socket that the data can be sent.
+       *
+       * @since        2.0
+       *
+       * @param[in]    socket          The Socket instance
+       * @remarks              The data can be sent using Send() or SendTo().
+       */
+       virtual void OnSocketReadyToSend(Socket& socket) = 0;
+
+       /**
+       * Called to notify a socket that it has received a new connection from a peer.
+       *
+       * @since        2.0
+       *
+       * @param[in]    socket          The Socket instance
+       */
+       virtual void OnSocketAccept(Socket& socket) = 0;
+
+protected:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void ISocketEventListener_Reserved1(void) {}
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without prior notice.
+       //
+       // @since       2.0
+       //
+       virtual void ISocketEventListener_Reserved2(void) {}
+
+};
+
+} } } // Tizen::Net::Sockets
+#endif // _FNET_SOCK_ISOCKET_EVENT_LISTENER_H_
diff --git a/inc/FNetSockSecureSocket.h b/inc/FNetSockSecureSocket.h
new file mode 100755 (executable)
index 0000000..b8e566a
--- /dev/null
@@ -0,0 +1,757 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+/**
+ * @file               FNetSockSecureSocket.h
+ * @brief      This is the header file for the %SecureSocket class.
+ *
+ * This header file contains the declarations of the %SecureSocket class. @n
+ * The %SecureSocket class provides secured simple methods for sending and receiving the data over a network.
+ */
+
+#ifndef _FNET_SOCK_SECURE_SOCKET_H_
+#define _FNET_SOCK_SECURE_SOCKET_H_
+
+#include <FBaseObject.h>
+#include <FNetNetEndPoint.h>
+#include <FNetNetConnection.h>
+#include <FNetSockSocketTypes.h>
+#include <FNetSockISecureSocketEventListener.h>
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+class _SecureSocketImpl;
+
+/**
+ * @enum     NetSecureSocketSslVersion
+ *
+ * Defines the secure socket version.
+ *
+ * @since    2.0
+ */
+enum NetSecureSocketSslVersion
+{
+       NET_SOCK_SSL_VERSION_SSLV3 = 0x0300,                    /**< The secure socket version is SSLv3 @n
+                                                                                The value for SSLv3 is 0x0300. */
+       NET_SOCK_SSL_VERSION_TLSV1 = 0x0301,                     /**< The secure socket version is TLSv1 @n
+                                                                                The value for TLSv1 is 0x0301. */
+       NET_SOCK_SSL_VERSION_NONE = 0x0000                     // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. SSL version not set
+};
+
+/**
+ * @enum     NetSecureSocketSslCipherSuiteID
+ *
+ * Defines the CipherSuite ID.
+ *
+ * @since    2.0
+ */
+enum NetSecureSocketSslCipherSuiteID
+{
+       //NET_SOCK_TLS_SSL_RSA_WITH_NULL_MD5 =                  0x0001,         /*< The CipherSuite ID is 0x0001 */
+       //NET_SOCK_TLS_SSL_RSA_WITH_NULL_SHA =                  0x0002,         /*< The CipherSuite ID is 0x0002 */
+       //NET_SOCK_TLS_SSL_RSA_EXPORT_WITH_RC4_40_MD5 =         0x0003,         /**< The CipherSuite ID is 0x0003 */
+       NET_SOCK_TLS_SSL_RSA_WITH_RC4_128_MD5 = 0x0004,                     /**< The CipherSuite ID is 0x0004 */
+       NET_SOCK_TLS_SSL_RSA_WITH_RC4_128_SHA = 0x0005,                     /**< The CipherSuite ID is 0x0005 */
+       //NET_SOCK_TLS_SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5 =     0x0006,         /*< The CipherSuite ID is 0x0006 */
+       //NET_SOCK_TLS_SSL_RSA_WITH_IDEA_CBC_SHA =              0x0007,         /*< The CipherSuite ID is 0x0007 */
+       NET_SOCK_TLS_SSL_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x0008,            /**< The CipherSuite ID is 0x0008 */
+       NET_SOCK_TLS_SSL_RSA_WITH_DES_CBC_SHA = 0x0009,                     /**< The CipherSuite ID is 0x0009 */
+       NET_SOCK_TLS_SSL_RSA_WITH_3DES_EDE_CBC_SHA = 0x000A,                /**< The CipherSuite ID is 0x000A */
+       //NET_SOCK_TLS_SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA =       0x000D,         /*< The CipherSuite ID is 0x000D */
+       //NET_SOCK_TLS_SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA =       0x0010,         /*< The CipherSuite ID is 0x0010 */
+       //NET_SOCK_TLS_SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA =  0x0011,         /*< The CipherSuite ID is 0x0001 */
+       //NET_SOCK_TLS_SSL_DHE_DSS_WITH_DES_CBC_SHA =           0x0012,         /*< The CipherSuite ID is 0x0002 */
+       //NET_SOCK_TLS_SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA =      0x0013,         /*< The CipherSuite ID is 0x0003 */
+       //NET_SOCK_TLS_SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA =  0x0014,         /*< The CipherSuite ID is 0x0004 */
+       //NET_SOCK_TLS_SSL_DHE_RSA_WITH_DES_CBC_SHA =           0x0015,         /*< The CipherSuite ID is 0x0005 */
+       //NET_SOCK_TLS_SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA =      0x0016,         /*< The CipherSuite ID is 0x0006 */
+       //NET_SOCK_TLS_SSL_DH_anon_EXPORT_WITH_RC4_40_MD5 =     0x0017,         /*< The CipherSuite ID is 0x0007 */
+       //NET_SOCK_TLS_SSL_DH_anon_WITH_RC4_128_MD5 =           0x0018,         /*< The CipherSuite ID is 0x0008 */
+       //NET_SOCK_TLS_SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA =  0x0019,         /*< The CipherSuite ID is 0x0009 */
+       //NET_SOCK_TLS_SSL_DH_anon_WITH_DES_CBC_SHA =           0x001A,         /*< The CipherSuite ID is 0x001A */
+       //NET_SOCK_TLS_SSL_DH_anon_WITH_3DES_EDE_CBC_SHA =      0x001B,         /*< The CipherSuite ID is 0x001B */
+       NET_SOCK_TLS_SSL_RSA_WITH_AES_128_CBC_SHA = 0x002F,                 /**< The CipherSuite ID is 0x002F */
+       //NET_SOCK_TLS_SSL_DH_DSS_WITH_AES_128_CBC_SHA =        0x0030,         /*< The CipherSuite ID is 0x0030 */
+       //NET_SOCK_TLS_SSL_DH_RSA_WITH_AES_128_CBC_SHA =        0x0031,         /*< The CipherSuite ID is 0x0031 */
+       //NET_SOCK_TLS_SSL_DHE_DSS_WITH_AES_128_CBC_SHA =       0x0032,         /*< The CipherSuite ID is 0x0032 */
+       //NET_SOCK_TLS_SSL_DHE_RSA_WITH_AES_128_CBC_SHA =       0x0033,         /*< The CipherSuite ID is 0x0033 */
+       //NET_SOCK_TLS_SSL_DH_anon_WITH_AES_128_CBC_SHA =       0x0034,         /*< The CipherSuite ID is 0x0034 */
+       //NET_SOCK_TLS_SSL_RSA_WITH_AES_256_CBC_SHA =           0x0035,         /*< The CipherSuite ID is 0x0035 */
+       //NET_SOCK_TLS_SSL_DH_DSS_WITH_AES_256_CBC_SHA =        0x0036,         /*< The CipherSuite ID is 0x0036 */
+       //NET_SOCK_TLS_SSL_DH_RSA_WITH_AES_256_CBC_SHA =        0x0037,         /*< The CipherSuite ID is 0x0037 */
+       //NET_SOCK_TLS_SSL_DHE_DSS_WITH_AES_256_CBC_SHA =       0x0038,         /*< The CipherSuite ID is 0x0038 */
+       //NET_SOCK_TLS_SSL_DHE_RSA_WITH_AES_256_CBC_SHA =       0x0039,         /*< The CipherSuite ID is 0x0039 */
+       //NET_SOCK_TLS_SSL_DH_anon_WITH_AES_256_CBC_SHA =       0x003A,         /*< The CipherSuite ID is 0x003A */
+
+       // Samsung does not support below cipher suites
+       //TLS_SSL_ECDH_ECDSA_WITH_NULL_SHA_DRAFT09 =              0x0047,
+       //TLS_SSL_ECDH_ECDSA_NULL_SHA =                           0x0047,
+       //TLS_SSL_ECDH_ECDSA_WITH_RC4_128_SHA_DRAFT09 =           0x0048,
+       //TLS_SSL_ECDH_ECDSA_WITH_DES_CBC_SHA_DRAFT09 =           0x0049,
+       //TLS_SSL_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA_DRAFT09 =      0x004A,
+       //TLS_SSL_ECDH_ECDSA_WITH_AES_128_CBC_SHA_DRAFT09 =       0x004B,
+       //TLS_SSL_ECDH_ECDSA_WITH_AES_256_CBC_SHA_DRAFT09 =       0x004C,
+       //TLS_SSL_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA =           0x0063,
+       //TLS_SSL_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA =            0x0065,
+       //TLS_SSL_DHE_DSS_WITH_RC4_128_SHA =                      0x0066,
+       //TLS_SSL_PSK_WITH_RC4_128_SHA =                          0x008A,
+       //TLS_SSL_PSK_WITH_3DES_EDE_CBC_SHA =                     0x008B,
+       //TLS_SSL_PSK_WITH_AES_128_CBC_SHA =                      0x008C,
+       //TLS_SSL_PSK_WITH_AES_256_CBC_SHA =                      0x008D,
+       //TLS_SSL_DHE_PSK_WITH_RC4_128_SHA =                      0x008E,
+       //TLS_SSL_DHE_PSK_WITH_3DES_EDE_CBC_SHA =                 0x008F,
+       //TLS_SSL_DHE_PSK_WITH_AES_128_CBC_SHA =                  0x0090,
+       //TLS_SSL_DHE_PSK_WITH_AES_256_CBC_SHA =                  0x0091,
+       //TLS_SSL_RSA_PSK_WITH_RC4_128_SHA =                      0x0092,
+       //TLS_SSL_RSA_PSK_WITH_3DES_EDE_CBC_SHA =                 0x0093,
+       //TLS_SSL_RSA_PSK_WITH_AES_128_CBC_SHA =                  0x0094,
+       //TLS_SSL_RSA_PSK_WITH_AES_256_CBC_SHA =                  0x0095,
+       //TLS_SSL_ECDH_ECDSA_WITH_NULL_SHA =                      0xC001,
+       //TLS_SSL_ECDH_ECDSA_WITH_RC4_128_SHA =                   0xC002,
+       //TLS_SSL_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA =              0xC003,
+       //TLS_SSL_ECDH_ECDSA_WITH_AES_128_CBC_SHA =               0xC004,
+       //TLS_SSL_ECDH_ECDSA_WITH_AES_256_CBC_SHA =               0xC005,
+       //TLS_SSL_ECDHE_ECDSA_WITH_NULL_SHA          =            0xC006,
+       //TLS_SSL_ECDHE_ECDSA_WITH_RC4_128_SHA       =            0xC007,
+       //TLS_SSL_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA  =            0xC008,
+       //TLS_SSL_ECDHE_ECDSA_WITH_AES_128_CBC_SHA   =            0xC009,
+       //TLS_SSL_ECDHE_ECDSA_WITH_AES_256_CBC_SHA   =            0xC00A,
+       //TLS_SSL_ECDH_anon_WITH_NULL_SHA            =            0xC015,
+       //TLS_SSL_ECDH_anon_WITH_RC4_128_SHA         =            0xC016,
+       //TLS_SSL_ECDH_anon_WITH_3DES_EDE_CBC_SHA    =            0xC017,
+       //TLS_SSL_ECDH_anon_WITH_AES_128_CBC_SHA     =            0xC018,
+       //TLS_SSL_ECDH_anon_WITH_AES_256_CBC_SHA     =            0xC019,
+       //TLS_SSL_ECMQV_ECDSA_WITH_NULL_SHA             =         0xFF4F,
+       //TLS_SSL_ECMQV_ECDSA_WITH_RC4_128_SHA          =         0xFF50,
+       //TLS_SSL_ECMQV_ECDSA_WITH_3DES_EDE_CBC_SHA     =         0xFF52,
+       //TLS_SSL_ECMQV_ECDSA_WITH_AES_128_CBC_SHA      =         0xFF53,
+       //TLS_SSL_ECMQV_ECDSA_WITH_AES_256_CBC_SHA      =         0xFF54,
+
+       NET_SOCK_TLS_SSL_SYSTEM_DEFAULT_CIPHERSUITES = 0xFFFF,               /**< If the user selects this ID, the %SecureSocket instance decides the cipher suite bundle itself @n
+                                                                                         *     For the OAF SSL, the below cipher suites will be included in "ClientHello" message: @n
+                                                                                         *     NET_SOCK_TLS_SSL_RSA_WITH_RC4_128_MD5
+                                                                                         *     NET_SOCK_TLS_SSL_RSA_WITH_RC4_128_SHA
+                                                                                         *     NET_SOCK_TLS_SSL_RSA_EXPORT_WITH_DES40_CBC_SHA
+                                                                                         *     NET_SOCK_TLS_SSL_RSA_WITH_DES_CBC_SHA
+                                                                                         *     NET_SOCK_TLS_SSL_RSA_WITH_3DES_EDE_CBC_SHA
+                                                                                         *     NET_SOCK_TLS_SSL_RSA_WITH_AES_128_CBC_SHA
+                                                                                         */
+       NET_SOCK_TLS_SSL_NULL_WITH_NULL_NULL = 0x0000                      // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. The CipherSuite ID is 0x0000
+};
+
+/**
+ * @class      SecureSocket
+ * @brief      This class provides the Secure %Sockets Layer (SSL) supported socket with security features.
+ *
+ * @since      2.0
+ *
+ * The %SecureSocket class provides the Secure Sockets Layer (SSL) supported socket with security features.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/sockets.htm">Sockets Guide</a>.
+ */
+class _OSP_EXPORT_ SecureSocket
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * 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.
+        *
+        * @since    2.0
+        */
+       SecureSocket(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since    2.0
+        *
+        * @see      Close()
+        */
+       virtual ~SecureSocket(void);
+
+       /**
+        * Initializes this instance of %SecureSocket with the specified parameters. @n
+        * The secure socket is initialized in a non-blocking mode by default.
+        * Use Ioctl() (with NET_SOCKET_FIONBIO) to use a %SecureSocket in the blocking mode.
+        *
+        * @since        2.0
+        * @privilege   %http://tizen.org/privilege/socket
+        *
+        * @return              An error code
+        * @param[in]   netConnection                   A run-time session where a %SecureSocket instance is used
+        * @param[in]   addressFamily                   A ::NetSocketAddressFamily value
+        * @param[in]   socketType                              The secure socket type @n
+        *                                                                              The value should be NET_SOCKET_TYPE_STREAM.
+        * @param[in]   protocol                                The protocol used by this secure socket @n
+        *                                                                              The value should be NET_SOCKET_PROTOCOL_SSL.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_WOULD_BLOCK                   A non-blocking secure socket operation cannot be completed immediately.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_MAX_EXCEEDED                  All sockets are in use.
+        * @exception   E_UNSUPPORTED_OPTION    The specified parameters are not supported.
+        * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
+        * @exception   E_UNSUPPORTED_PROTOCOL  The protocol is not supported.
+        * @exception   E_UNSUPPORTED_TYPE              The secure socket type is not supported.
+        * @exception   E_UNSUPPORTED_FAMILY    The address family is not supported.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @exception   E_INVALID_CONNECTION    The network connection is invalid.
+        * @exception   E_FAILURE                               The method has failed due to an undefined error.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @remarks      The @c netConnection parameter specifies a run-time network connection. @n
+        *                              The @c addressFamily parameter specifies an address family. @n
+        *                              The @c socketType parameter specifies the type of the secure socket. SSL only supports stream-based protocols. @n
+        *                              The @c protocol parameter specifies the protocol used by the secure socket. SSL protocol is defined as NET_SOCKET_PROTOCOL_SSL. @n
+        *                              The first parameter must be a valid run-time network connection. The three parameters are not independent. Some address families
+        *                              restrict the protocols that can be used with them, and often the secure socket type is implicit in the protocol. If the combination
+        *                              of the address family, socket type, and protocol type results in an invalid secure socket, this method returns an error. @n For each
+        *                              secure socket used in the non-blocking mode, an event listener (ISecureSocketEventListener) should be registered and maintained.
+        *                              so that it can receive asynchronous notifications of the secure socket events. AddSecureSocketListener() is used to
+        *                              register an event listener. @n
+        *                              If a secure socket in the blocking mode needs to be used, Ioctl() (with NET_SOCKET_FIONBIO) should be called after initializing the secure socket
+        *                              through this method.
+        * @see                 Ioctl() for understanding the blocking/non-blocking mode
+        */
+       result Construct(const Tizen::Net::NetConnection& netConnection, NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol);
+
+       /**
+        * Initializes this instance of %SecureSocket with the specified parameters. @n
+        * The secure socket is initialized in a non-blocking mode by default.
+        * Use Ioctl() (with NET_SOCKET_FIONBIO) to use a %SecureSocket in the blocking mode.
+        *
+        * @since        2.0
+        * @privilege   %http://tizen.org/privilege/socket
+        *
+        * @return              An error code
+        * @param[in]   addressFamily                   A ::NetSocketAddressFamily value
+        * @param[in]   socketType                              The secure socket type @n
+        *                                                                              The value should be NET_SOCKET_TYPE_STREAM.
+        * @param[in]   protocol                                The protocol used by this secure socket @n
+        *                                                                              The value should be NET_SOCKET_PROTOCOL_SSL.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_WOULD_BLOCK                   A non-blocking secure socket operation cannot be completed immediately.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_MAX_EXCEEDED                  All sockets are in use.
+        * @exception   E_UNSUPPORTED_OPTION    The specified parameters are not supported.
+        * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
+        * @exception   E_UNSUPPORTED_PROTOCOL  The protocol is not supported.
+        * @exception   E_UNSUPPORTED_TYPE              The secure socket type is not supported.
+        * @exception   E_UNSUPPORTED_FAMILY    The address family is not supported.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @exception   E_INVALID_CONNECTION    The network connection is invalid.
+        * @exception   E_FAILURE                               The method has failed due to an undefined error.
+        * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
+        * @remarks             The @c addressFamily parameter specifies an address family. @n
+        *               The @c socketType parameter specifies the type of the secure socket. SSL only supports stream-based protocols. @n
+        *               The @c protocol parameter specifies the protocol used by the secure socket. The SSL protocol is defined as NET_SOCKET_PROTOCOL_SSL. @n
+        *               The three parameters are not independent. Some address families restrict the protocols that can be used with them, and often the
+        *                              secure socket type is implicit in the protocol. If the combination of the address family, socket type, and protocol type results in
+        *               an invalid secure socket, this method returns an error. @n
+        *               For each secure socket used in the non-blocking mode, an event listener
+        *                              (ISecureSocketEventListener) should be registered and maintained, so that it can receive asynchronous notifications of the secure socket
+        *                              events. AddSecureSocketListener() is used to register an event listener. @n
+        *                              If a secure socket in the blocking mode needs to be used, Ioctl() (with NET_SOCKET_FIONBIO) should be called after initializing the secure socket
+        *                              through this method.
+        * @see                 Ioctl() for understanding the blocking/non-blocking mode
+        */
+       result Construct(NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol);
+
+public:
+       /**
+        * Closes the secure socket. @n
+        * All the resources associated with the secure socket are freed.
+        *
+        * @since        2.0
+        * @privilege   %http://tizen.org/privilege/socket
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_STATE                         The secure socket is not in a valid state.
+        * @exception   E_INVALID_SOCKET                        The secure socket is invalid.
+        * @exception   E_NETWORK_UNAVAILABLE           The network is unavailable.
+        * @exception    E_OUT_OF_MEMORY                                The memory is insufficient.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @exception    E_PRIVILEGE_DENIED                     The application does not have the privilege to call this method.
+        * @remarks             If the %SecureSocket class is not initialized through one of the Construct() methods or this method is called more than once,
+        *                              then this method returns E_INVALID_STATE.
+        */
+       result Close(void);
+
+       /**
+        * Establishes a connection to a remote host.
+        *
+        * @if OSPCOMPAT
+        * @brief <i> [Compatibility] </i>
+        * @endif
+        * @since            2.0
+        * @if OSPCOMPAT
+        * @compatibility       This method has compatibility issues with OSP compatible applications. @n
+     *                 For more information, see @ref SecureSocketConnectPage "here".
+     * @endif
+        * @privilege           %http://tizen.org/privilege/socket
+        *
+        * @return                      An error code
+        * @param[in]           remoteEndPoint                          An instance of NetEndPoint representing the remote device
+        * @exception           E_SUCCESS                                       The method is successful.
+        * @exception           E_INVALID_SOCKET                        The secure socket is invalid.
+        * @exception           E_INVALID_STATE                         The secure socket is not in a valid state.
+        * @exception           E_HOST_UNREACHABLE                      The network cannot be reached from this host at this time.
+        * @exception           E_IN_PROGRESS                           A previous request is in progress.
+        * @exception           E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception           E_WOULD_BLOCK                           A non-blocking secure socket operation cannot be completed immediately.
+        * @exception       E_INVALID_CERTIFICATE       The client certificate verification has failed on server.
+        * @exception           E_CERTIFICATE_VERIFICATION_FAILED  The server certificate verification has failed.
+        * @exception           E_CONNECTION_FAILED                     The secure socket is not connected.
+        * @exception           E_TIMEOUT                                       An attempt to connect to the server has timed out.
+        * @exception           E_ALREADY_CONNECTED                     The secure socket is already connected.
+        * @exception           E_UNSUPPORTED_FAMILY            The address family is not supported.
+        * @exception           E_UNSUPPORTED_PROTOCOL          The protocol is not supported.
+        * @exception        E_OUT_OF_MEMORY                            The memory is insufficient.
+        * @exception           E_SYSTEM                                        A system error has occurred.
+        * @exception        E_PRIVILEGE_DENIED                 The application does not have the privilege to call this method.
+        *
+        * @remarks             Starts connection to a remote peer including SSL handshaking.
+        *                              After this method is called, OnSecureSocketConnected() is called. The data is sent to and received from the remote
+        *                              device using Send() and Receive() respectively. If the Bind() method is not called before calling this
+        *                              method, the underlying service provider assigns the local network address and port number.
+        */
+       result Connect(const Tizen::Net::NetEndPoint& remoteEndPoint);
+
+       /**
+        * @page                        SecureSocketConnectPage         Compatibility for Connect()
+        *
+        * @section             SecureSocketConnectPageIssueSection Issues
+        * Implementing this method in OSP compatible applications has the following issues:   @n
+        * -# If the application provides a loopback address in NetEndPoint, it returns E_SYSTEM.
+        *
+        * @section             SecureSocketConnectPageResolutionSection Resolutions
+        *  This issue has been resolved in Tizen.  @n 
+        *  -# If the application provides a loopback address in NetEndPoint, it returns E_SUCCESS instead of E_SYSTEM.
+        */
+
+       /**
+        * Sends the data to a secure socket of the type NET_SOCKET_TYPE_STREAM.
+        *
+        * @since        2.0
+        *
+        * @return              An error code
+        * @param[in]   buffer                                          An instance of ByteBuffer that contains the data to send
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_SOCKET                        The secure socket is invalid.
+        * @exception   E_INVALID_STATE                         The secure socket is not in a valid state.
+        * @exception   E_UNSUPPORTED_OPTION            The specified parameter is not supported.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception   E_WOULD_BLOCK                           A non-blocking secure socket operation cannot be completed immediately.
+        * @exception   E_NETWORK_UNAVAILABLE           The network is unavailable.
+        * @exception   E_CONNECTION_FAILED                     The secure socket is not connected.
+        * @exception   E_TIMEOUT                                       An attempt to connect to the server has timed out.
+        * @exception    E_OUT_OF_MEMORY                                The memory is insufficient.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @remarks             This method sends the data to the remote host specified in the Connect() method.
+        *               This method sends the data in the @c buffer parameter, starting from the current position of the buffer. After the operation,
+        *                              the position of the buffer is incremented by the number of bytes successfully sent. The new position cannot be larger than the
+        *                              original limit. This method can be used only for connection-oriented sockets.
+        *                              In the blocking mode, if space is not available in the send queue, the secure socket blocks until space becomes available.
+       *                               In the non-blocking mode, this method returns the error E_WOULD_BLOCK. This method may
+        *                              complete successfully even if it sends less bytes than the number of bytes present in the buffer. The application
+        *                              should keep track of the number of bytes sent and retry the operation until the application sends the bytes in the
+        *                              buffer. There is no guarantee that the data that is sent appears on the network immediately. To increase network efficiency, the
+        *                              underlying system may delay the transmission until a significant amount of outgoing data is collected. A successful completion of this
+        *                              method means that the underlying system has had room to buffer the data for a network send. If it is important for the
+        *                              application to send every byte to the remote host immediately, use SetSockOpt() (with NET_SOCKET_TCP_NODELAY) of the type
+        *                              ::NetSocketOptName to enable no delay.
+        */
+       result Send(Tizen::Base::ByteBuffer& buffer);
+
+       /**
+        * Sends the data to a secure socket of the type NET_SOCKET_TYPE_STREAM.
+        *
+        * @since        2.0
+        *
+        * @return              An error code
+        * @param[in]   pBuffer                                 The pointer to the buffer containing the data to send
+        * @param[in]   length                                  The length of the data in the buffer
+        * @param[out]  sentLength                              The length of the data sent successfully
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_SOCKET                The secure socket is invalid.
+        * @exception   E_INVALID_STATE                 The secure socket is not in a valid state.
+        * @exception   E_UNSUPPORTED_OPTION    The specified parameters are not supported.
+        * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
+        * @exception   E_WOULD_BLOCK                   A non-blocking secure socket operation cannot be completed immediately.
+        * @exception   E_NETWORK_UNAVAILABLE   The network is unavailable.
+        * @exception   E_CONNECTION_FAILED             The secure socket is not connected.
+        * @exception   E_TIMEOUT                               An attempt to connect to the server has timed out.
+        * @exception    E_OUT_OF_MEMORY                        The memory is insufficient.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @remarks             This method sends the data to the remote host specified in the Connect() method.
+        *               This method sends the data in the buffer of length @c length, starting from the current position of the buffer.
+        *               In the blocking mode, if space is not available in the send queue, the secure socket blocks until space becomes available.
+        *                               In the non-blocking mode, this method returns the error E_WOULD_BLOCK.
+        *               This method may complete successfully even if it sends less bytes than the number of bytes
+        *               in the buffer. The application should keep track of the number of bytes sent
+        *               and retry the operation until the application sends the bytes in the buffer.
+        *               There is no guarantee that the data that is sent appears on the network immediately.
+        *               To increase the network efficiency, the underlying system may delay the transmission until a significant amount
+        *               of outgoing data is collected. A successful completion of this method means that the underlying
+        *               system has had room to buffer the data for a network send.
+        *                              If it is important for the application to send every byte to the remote host immediately,
+        *                              use SetSockOpt() (with NET_SOCKET_TCP_NODELAY) of the type ::NetSocketOptName to enable no delay.
+        */
+       result Send(void* pBuffer, int length, int& sentLength);
+
+       /**
+        * Receives the data from a secure socket of the type NET_SOCKET_TYPE_STREAM.
+        *
+        * @since        2.0
+        *
+        * @return              An error code
+        * @param[out]  buffer                                          An instance of ByteBuffer that is the storage location for the received data
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_SOCKET                        The secure socket is invalid.
+        * @exception   E_INVALID_STATE                         The secure socket is not in a valid state.
+        * @exception   E_UNSUPPORTED_OPTION            The specified parameter is not supported.
+        * @exception   E_INVALID_ARG                           The specified input parameter is invalid.
+        * @exception   E_WOULD_BLOCK                           A non-blocking secure socket operation cannot be completed immediately.
+        * @exception   E_NETWORK_UNAVAILABLE           The network is unavailable.
+        * @exception   E_TIMEOUT                                       An attempt to connect to the server has timed out.
+        * @exception   E_IN_PROGRESS                           A previous request is in progress.
+        * @exception    E_OUT_OF_MEMORY                                The memory is insufficient.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @remarks             This method copies the data into the @c buffer parameter, starting from the current position of the buffer.
+        *               After the operation, the position of the buffer is incremented by the number of bytes successfully received.
+        *               The new position cannot be larger than the original limit. This method can be called from connection-oriented sockets only.
+        *                               If there is no data at the secure socket in the blocking mode,
+        *                               this method blocks until the data arrives. If the secure socket is in the non-blocking mode,
+        *                               the error E_WOULD_BLOCK is returned.
+        *
+        */
+       result Receive(Tizen::Base::ByteBuffer& buffer) const;
+
+       /**
+        * Receives the data from a secure socket of the type NET_SOCKET_TYPE_STREAM.
+        *
+        * @since        2.0
+        *
+        * @return              An error code
+        * @param[out]  pBuffer                                         The pointer to the buffer that is the storage location for the received data
+        * @param[in]   length                                          The length of the data in the buffer
+        * @param[out]  rcvdLength                                      The length of the data that is received successfully
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_SOCKET                        The secure socket is invalid.
+        * @exception   E_INVALID_STATE                         The secure socket is not in a valid state.
+        * @exception   E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+        * @exception   E_INVALID_ARG                           A specified input parameter is invalid.
+        * @exception   E_WOULD_BLOCK                           A non-blocking secure socket operation cannot be completed immediately.
+        * @exception   E_NETWORK_UNAVAILABLE           The network is unavailable.
+        * @exception   E_TIMEOUT                                       An attempt to connect to the server has timed out.
+        * @exception   E_IN_PROGRESS                           A previous request is in progress.
+        * @exception    E_OUT_OF_MEMORY                                The memory is insufficient.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @remarks             This method copies the data into the buffer of length @c length, starting from the current position of the buffer.
+        *                              This method can be called from the connection-oriented sockets only.
+       *                               If there is no data at the secure socket in the blocking mode,
+       *                               this method blocks until the data arrives. If the secure socket is in the non-blocking mode,
+       *                               the error E_WOULD_BLOCK is returned.
+        */
+       result Receive(void* pBuffer, int length, int& rcvdLength) const;
+
+       /**
+       * Binds the secure socket to a local address.
+       *
+       * @since        2.0
+       * @privilege    %http://tizen.org/privilege/socket
+       *
+       * @return               An error code
+       * @param[in]    localEndPoint                           The local NetEndPoint to associate with the secure socket
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_SOCKET                        The secure socket is invalid.
+       * @exception    E_INVALID_STATE                         The secure socket is not in a valid state.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameter is not supported.
+       * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
+       * @exception    E_ALREADY_BOUND                         The address is already in use.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              Use this method if a specific local endpoint should be used.
+       *                               This method can be used on both the connectionless and connection-oriented protocols.
+       *                               For connection-oriented sockets, this method need not be called
+       *                               before using the Connect() method, unless a specific local endpoint needs to be used.
+       *                               This method must be called before the Listen() method.
+       */
+       result Bind(const Tizen::Net::NetEndPoint& localEndPoint);
+
+       /**
+       * Places the secure socket in a listening state.
+       *
+       * @since        2.0
+       * @privilege    %http://tizen.org/privilege/socket
+       *
+       * @return               An error code
+       * @param[in]    backLog                                         The maximum length of the pending connections queue
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_WOULD_BLOCK                           A non-blocking secure socket operation cannot be completed immediately.
+       * @exception    E_INVALID_SOCKET                        The secure socket is invalid.
+       * @exception    E_INVALID_STATE                         The secure socket is not in a valid state.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameter is not supported.
+       * @exception    E_UNSUPPORTED_PROTOCOL          The protocol is not supported.
+       * @exception    E_ALREADY_CONNECTED                     The secure socket is already connected.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              This method causes a connection-oriented socket to listen for
+       *                               the incoming connection attempts. The @c backlog parameter specifies
+       *                               the number of incoming connections that can be queued for acceptance.
+       *                               The Bind() method must be called before calling this method.
+       */
+       result Listen(int backLog);
+
+       /**
+       * Accepts an incoming connection. @n
+       * This method extracts the first connection from the queue of pending connections, and
+       * creates a new secure socket with the same socket type, protocol type, and protocol family
+       * as the listening secure socket.
+       *
+       * @since        2.0
+       * @privilege    %http://tizen.org/privilege/socket
+       *
+       * @return               A new secure socket for a newly created connection with the same socket type, protocol type, and protocol family, @n
+       *                               else @c null if an error occurs
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_WOULD_BLOCK                           A non-blocking secure socket operation cannot be completed immediately.
+       * @exception    E_INVALID_CERTIFICATE           The server certificate verification has failed on client.
+       * @exception    E_CERTIFICATE_VERIFICATION_FAILED  The client certificate verification has failed.
+       * @exception    E_INVALID_SOCKET                        The secure socket is invalid.
+       * @exception    E_INVALID_STATE                         The secure socket is not in a valid state.
+       * @exception    E_UNSUPPORTED_OPTION            This operation is not supported for this socket.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_TIMEOUT                                       An attempt to connect to the server has timed out.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              Before calling this method, the Listen() method must be called first
+       *                               to listen for and queue the incoming connection requests.
+       *                               In the blocking mode, this method blocks until an incoming connection attempt
+       *                               is queued. After accepting a connection, the original socket
+       *                               continues queuing the incoming connection requests until it is closed.
+       *                               Note that if no connection is pending in the queue and the secure socket is in the blocking mode,
+       *                               this method blocks until a new connection arrives. If the secure socket is in the non-blocking mode,
+       *                               the E_WOULD_BLOCK exception is thrown. The specific error code can be accessed using the GetLastResult() method.
+       */
+       SecureSocket* AcceptN(void) const;
+
+       /**
+        * Executes the specified command on the socket.
+        *
+        * @since        2.0
+        * @privilege         %http://tizen.org/privilege/socket
+        *
+        * @return              An error code
+        * @param[in]   cmd                                 The command to execute on the secure socket
+        * @param[in,out] value                                         The value of the IOCTL command
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_SOCKET                        The secure socket is invalid.
+        * @exception   E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+        * @exception   E_INVALID_ARG                           A specified input parameter is invalid.
+        * @exception   E_INVALID_STATE                         The secure socket is not in a valid state.
+        * @exception   E_NETWORK_UNAVAILABLE           The network is unavailable.
+        * @exception   E_OUT_OF_MEMORY                         The memory is insufficient.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @exception   E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+        * @remarks     This method manipulates the underlying device parameters of the secure socket descriptors. @n@n
+        *              The NET_SOCKET_FIONBIO option is used for setting the non-blocking/blocking mode on a secure socket.
+        *              Set the value to zero for enabling the blocking mode, or to a non-zero value for enabling the non-blocking mode.
+        *              When a secure socket is created, by default, it operates in the non-blocking mode and the blocking mode is disabled.
+        *
+        */
+       result Ioctl(NetSocketIoctlCmd cmd, unsigned long& value) const;
+
+       /**
+        * Sets the secure socket to the asynchronous mode by a specified message to the specified event handler when the secure socket events occur.
+        *
+        * @since        2.0
+        *
+        * @return              An error code
+        * @param[in]   socketEventType                 The secure socket events of ::NetSocketEventType @n
+        *                                                                              Multiple events can be combined using the bitwise "|" operator.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_SOCKET                The secure socket is invalid.
+        * @exception   E_INVALID_STATE                 The secure socket is not in a valid state.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        * @exception   E_NETWORK_UNAVAILABLE   The network is unavailable.
+        * @exception   E_TIMEOUT               An attempt to connect to the server has timed out.
+        *
+        * The following example demonstrates how to use the %AsyncSelectByListener() method to set a secure socket to the asynchronous mode.
+        *
+        *      @code
+        *      result res = E_SUCCESS;
+        *
+        *      // Creates the secure socket.
+        *      SecureSocket* pClientSocket = new SecureSocket();
+        *      res = pClientSocket->Construct(NET_SOCKET_AF_IPV4,NET_SOCKET_TYPE_STREAM,NET_SOCKET_PROTOCOL_SSL);
+        *
+        *      // Adds listener.
+        *      MySocketSecureClientListener* pSockClientListener = new MySocketSecureClientListener();
+        *      res = pClientSocket->AddSecureSocketListener(*pSockClientListener);
+        *
+        *      // Selects asynchronous event (non-blocking mode).
+        *      res = pClientSocket->AsyncSelectByListener(NET_SOCKET_EVENT_CONNECT| NET_SOCKET_EVENT_CLOSE);
+        *
+        *      // Creates peer endpoint.
+        *      Ip4Address peerAddr("XXX.XXX.XXX.XXX"); //Secure socket server address.
+        *      unsigned short peerPort = YYY;  // Port
+        *      NetEndPoint* pPeerEndPoint = new NetEndPoint(peerAddr, peerPort);
+        *
+        *      // Connects the secure socket.
+        *      res = pClientSocket->Connect(*pPeerEndPoint);
+        *      @endcode
+        */
+       result AsyncSelectByListener(unsigned long socketEventType);
+
+       /**
+        * Adds a listener to the secure socket. @n
+        * The listener can listen to the events when they are fired.
+        *
+        * @since        2.0
+        *
+        * @return              An error code
+        * @param[in]   listener                                A reference to ISecureSocketEventListener
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+        * @exception   E_INVALID_SOCKET                The secure socket is invalid.
+        * @exception   E_INVALID_STATE                 The associated secure socket is not in a valid state.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        * @exception   E_OBJ_ALREADY_EXIST             The listener is already added.
+        * @exception   E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation, @n
+        *                                                                              because the caller thread is a worker thread.
+        */
+       result AddSecureSocketListener(ISecureSocketEventListener& listener);
+
+       /**
+        * Removes a listener from the secure socket.
+        *
+        * @since        2.0
+        *
+        * @return       An error code
+        * @param[in]   listener                                A reference to ISecureSocketEventListener
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_OBJ_NOT_FOUND                 The specified object is not found within the indicated range.
+        * @exception   E_INVALID_SOCKET                The secure socket is invalid.
+        * @exception   E_INVALID_STATE                 The associated secure socket is not in a valid state.
+        * @exception   E_SYSTEM                                A system error has occurred.
+        */
+       result RemoveSecureSocketListener(ISecureSocketEventListener& listener);
+
+       /**
+        * Gets an option of the secure socket.
+        *
+        * @since        2.0
+        *
+        * @return              An error code
+        * @param[in]   optionLevel                                     A ::NetSocketOptLevel value
+        * @param[in]   optionName                                      A ::NetSocketOptName value
+        * @param[out]  optionValue                                     The integer to receive the option setting
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_SOCKET                        The secure socket is invalid.
+        * @exception   E_INIT_FAILED                           The secure socket is not initialized.
+        * @exception   E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+        * @exception   E_INVALID_ARG                           A specified input parameter is invalid.
+        * @exception   E_INVALID_STATE                         The secure socket is not in a valid state.
+        * @exception   E_NETWORK_UNAVAILABLE           The network is unavailable.
+        * @exception   E_IN_PROGRESS                           A previous request is in progress.
+        * @exception   E_CONNECTION_FAILED                     The secure socket is not connected.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @remarks             The secure socket options determine the behavior of the current secure socket.
+        *                              Upon the successful completion of this method, the integer variable specified
+        *                              by the @c optionValue parameter contains the value of the specified secure socket option.
+        *                              For an option with a bool data type, a non-zero value is returned if the option is enabled. Otherwise,
+        *                              a zero value is returned. For an option with an integer data type, the method returns the appropriate value.
+        *                              The secure socket options are grouped by the level of protocol support.
+        *                              Listed below are the various secure socket options that can be obtained using this overload. These options are
+        *                              grouped by the appropriate NetSocketOptLevel.
+        *                              If any of these options are to be obtained, use the appropriate %NetSocketOptLevel for the @c optionLevel parameter. The option that
+        *                              is chosen, must be specified in the @c optionName parameter. To set the current value of some of the listed options, use the
+        *                              SetSockOpt() method. @n@n
+        *                              The NET_SOCKET_SOL_SOCKET options that can be set using this overloaded method are: @n
+        *                              &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SSLVERSION: Gets the SSL version of the secure socket. @n
+        *                              &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SSLCIPHERSUITEID: Gets the SSL cipher suite ID of the secure socket.
+        * @see          SetSockOpt()
+        */
+       result GetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int& optionValue) const;
+
+       /**
+        * Changes an option of the secure socket.
+        *
+        * @since        2.0
+        *
+        * @return              An error code
+        * @param[in]   optionLevel                                     A ::NetSocketOptLevel value
+        * @param[in]   optionName                                      A ::NetSocketOptName value
+        * @param[in]   optionValue                                     The option value
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_INVALID_SOCKET                        The secure socket is invalid.
+        * @exception   E_INIT_FAILED                           The secure socket is not initialized.
+        * @exception   E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+        * @exception   E_INVALID_ARG                           A specified input parameter is invalid.
+        * @exception   E_INVALID_STATE                         The secure socket is not in a valid state.
+        * @exception   E_NETWORK_UNAVAILABLE           The network is unavailable.
+        * @exception   E_IN_PROGRESS                           A previous request is in progress.
+        * @exception   E_CONNECTION_FAILED                     The secure socket is not connected.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @remarks             This method is used to change the value of the option specified by the @c optionName parameter.
+        *                              The secure socket options determine the behavior of the current secure socket. For an option with a bool data type,
+        *                              specify a non-zero value to enable the option, and a zero value to disable the option.
+        *                              For an option with an integer data type, specify the appropriate value. The secure socket options are grouped
+        *                              by the level of protocol support.
+        *                              Listed below are the various secure socket options that can be set using this overload. These options are
+        *                              grouped by the appropriate NetSocketOptLevel.  If any of these options are to be set, use the appropriate %NetSocketOptLevel for the
+        *                              @c optionLevel parameter. The chosen option must be specified in the @c optionName parameter.
+        *                              To get the current value of some of the options listed, use the GetSockOpt() method. @n@n
+        *                                      &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SSLVERSION: To enable the SSL version of the secure socket. @n
+        *                                      &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SSLCIPHERSUITEID: To set the SSL cipher suite ID of the secure socket. @n
+        *                                      &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SSLCERTVERIFY: To disable server certificate verification on the secure client socket. @n
+        *                                      &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SSLCLIENTCERTVERIFY: To enable client certificate verification on the secure server socket. @n
+        *                                      &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SSLCERTID: To set the SSL certificate ID for the client authentication. Start the Application control (L"tizen.certificatemanager") for getting the selected client certificate. For more information, see <a href="../org.tizen.native.appprogramming/html/guide/app/appcontrol_certmgr.htm">here</a>. @n
+        */
+       result SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int optionValue);
+
+private:
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %SecureSocket
+        */
+       SecureSocket(const SecureSocket& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @return              A reference to this instance
+        * @param[in]   rhs                             An instance of %SecureSocket
+        */
+       SecureSocket& operator =(const SecureSocket& rhs);
+
+private:
+       _SecureSocketImpl* __pSecureSocketImpl;
+
+       friend class _SecureSocketImpl;
+};
+
+} } } // Tizen::Net::Sockets
+#endif // _FNET_SOCK_SECURE_SOCKET_H_
diff --git a/inc/FNetSockSocket.h b/inc/FNetSockSocket.h
new file mode 100755 (executable)
index 0000000..0c04ac9
--- /dev/null
@@ -0,0 +1,983 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+/**
+* @file                FNetSockSocket.h
+* @brief       This is the header file for the %Socket class.
+*
+* This header file contains the declarations of the %Socket class. @n
+* The %Socket class is a base class that provides methods for sending and receiving the data over a network.
+*/
+
+#ifndef _FNET_SOCK_SOCKET_H_
+#define _FNET_SOCK_SOCKET_H_
+
+#include <FBaseObject.h>
+#include <FNetNetEndPoint.h>
+#include <FNetNetConnection.h>
+#include <FNetSockSocketTypes.h>
+#include <FNetSockSocketLingerOption.h>
+#include <FNetSockSocketIpMulticastRequestOption.h>
+#include <FNetSockISocketEventListener.h>
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+class _SocketImpl;
+
+/**
+* @class       Socket
+* @brief       This class is the base class that provides simple methods for sending and receiving the data over a network.
+*
+* @since    2.0
+*
+* The %Socket class is the base class that provides simple methods for sending and receiving the data over a network.
+*
+* For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/sockets.htm">Sockets Guide</a>.
+*/
+class _OSP_EXPORT_ Socket
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+       * 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.
+       *
+       * @since        2.0
+       */
+       Socket(void);
+
+       /**
+       * This destructor overrides Tizen::Base::Object::~Object().
+       *
+       * @since        2.0
+       *
+       * @see          Close()
+       */
+       virtual ~Socket(void);
+
+       /**
+       * Initializes this instance of %Socket with the specified parameters. @n
+       * The socket is initialized in a non-blocking mode by default.
+       * Use Ioctl() (with NET_SOCKET_FIONBIO) to use a %Socket in the blocking mode.
+       *
+       * @since        2.0
+       * @privilege    %http://tizen.org/privilege/socket
+       *
+       * @return               An error code
+       * @param[in]    netConnection                           A run-time session where a %Socket instance is used
+       * @param[in]    addressFamily                           A ::NetSocketAddressFamily value
+       * @param[in]    socketType                                      A ::NetSocketType value
+       * @param[in]    protocol                                        A ::NetSocketProtocol value
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_MAX_EXCEEDED                          All sockets are in use.
+       * @exception    E_UNSUPPORTED_OPTION            This operation is not supported for this socket.
+       * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
+       * @exception    E_UNSUPPORTED_PROTOCOL          The protocol is not supported.
+       * @exception    E_UNSUPPORTED_TYPE                      The socket type is not supported.
+       * @exception    E_UNSUPPORTED_FAMILY            The address family is not supported.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_INVALID_CONNECTION            The network connection is invalid.
+       * @exception    E_FAILURE                                       The method has failed.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks      The @c netConnection parameter specifies a run-time network connection. @n
+       *                               The @c addressFamily parameter specifies an address family. @n
+       *                               The @c socketType parameter specifies the type of the socket. @n
+       *                               The @c protocol parameter specifies the protocol used by the socket. @n
+       *                               The first parameter must be a valid run-time network connection.
+       *                               The three parameters (without @c netConnection) are not independent.
+       *                               Some address families restrict the protocols that can be used with them,
+       *                               and often the socket type is implicit in the protocol.
+       *                               If the combination of the address family, socket type, and protocol type results in
+       *                               an invalid socket, this method returns an error. @n
+       *                               This method is used for a socket of the type NET_SOCKET_PROTOCOL_TCP, NET_SOCKET_PROTOCOL_UDP, or NET_SOCKET_PROTOCOL_SSL. @n
+       *                               If the blocking mode is being used, and a method call is made which does not
+       *                               complete immediately, the application blocks the execution until the requested operation is completed. @n@n
+       *                               If the execution is to be continued even though the requested operation
+       *                               is not complete, the non-blocking mode should be used, which is the default mode in this method. @n
+       *                               For each socket used in the non-blocking mode, an event listener (ISocketEventListener) should be registered
+       *                               and maintained, so that it can receive asynchronous notifications of the socket events. @n
+       *                               To register the listener, AddSocketListener() should be used after calling this method. @n
+       *                               If a socket in the blocking mode needs to be used, Ioctl() (with NET_SOCKET_FIONBIO) should be called after initializing the socket
+       *                               through this method.
+       * @see                  Ioctl() for understanding the blocking/non-blocking mode
+       */
+       result Construct(const NetConnection& netConnection, NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol);
+
+       /**
+       * Initializes this instance of %Socket with the specified parameters. @n
+       * The socket is initialized in a non-blocking mode by default.
+       * Use Ioctl() (with NET_SOCKET_FIONBIO) to use a %Socket in the blocking mode.
+       *
+       * @since        2.0
+       * @privilege    %http://tizen.org/privilege/socket
+       *
+       * @return               An error code
+       * @param[in]    addressFamily                           A ::NetSocketAddressFamily value
+       * @param[in]    socketType                                      A ::NetSocketType value
+       * @param[in]    protocol                                        A ::NetSocketProtocol value
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_MAX_EXCEEDED                          All sockets are in use.
+       * @exception    E_UNSUPPORTED_OPTION            This operation is not supported for this socket.
+       * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
+       * @exception    E_UNSUPPORTED_PROTOCOL          The protocol is not supported.
+       * @exception    E_UNSUPPORTED_TYPE                      The socket type is not supported.
+       * @exception    E_UNSUPPORTED_FAMILY            The address family is not supported.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_INVALID_CONNECTION            The network connection is invalid.
+       * @exception    E_FAILURE                                       The method has failed.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              The @c addressFamily parameter specifies an address family. @n
+       *                               The @c socketType parameter specifies the type of the socket. @n
+       *                               The @c protocol parameter specifies the protocol used by the socket. @n
+       *                               The three parameters are not independent.
+       *                               Some address families restrict the protocols that can be used with them,
+       *                               and often the socket type is implicit in the protocol.
+       *                               If the combination of the address family, socket type, and protocol type results in
+       *                               an invalid socket, this method returns an error. @n
+       *                               This method is used for a socket of the type NET_SOCKET_PROTOCOL_TCP, NET_SOCKET_PROTOCOL_UDP, or NET_SOCKET_PROTOCOL_SSL. @n
+       *                               If the blocking mode is being used, and a method call is made which does not
+       *                               complete immediately, the application blocks the execution
+       *                               until the requested operation is completed. @n@n
+       *                               If the execution is to be continued even though the requested operation
+       *                               is not complete, the non-blocking mode should be used, which is the default mode in this method. @n
+       *                               For each socket used in the non-blocking mode, an event listener (ISocketEventListener) should be registered
+       *                               and maintained, so that it can receive asynchronous notifications of the socket events. @n
+       *                               To register the listener, AddSocketListener() should be used after calling this method. @n
+       *                               If a socket in the blocking mode needs to be used, Ioctl (with NET_SOCKET_FIONBIO) should be called after initializing the socket
+       *                               through this method.
+       * @see                  Ioctl() for understanding the blocking/non-blocking mode
+       */
+       result Construct(NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol);
+
+public:
+       /**
+       * Closes the socket. @n
+       * All the resources associated with the socket are freed.
+       *
+       * @since        2.0
+       * @privilege    %http://tizen.org/privilege/socket
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              If the %Socket class is not initialized through one of the Construct() methods, or this method is called more than once,
+       *                               then this method returns E_INVALID_STATE.
+       */
+       result Close(void);
+
+       /**
+       * Establishes a connection to a remote host for a connection-oriented socket. @n
+       * This socket is of the type NET_SOCKET_TYPE_STREAM.
+       *
+       * @if OSPCOMPAT
+       * @brief <i> [Compatibility] </i>
+       * @endif
+       * @since            2.0
+       * @if OSPCOMPAT
+    * @compatibility   This method has compatibility issues with OSP compatible applications. @n
+    *                  For more information, see @ref SocketConnectPage "here".
+    * @endif
+       * @privilege            %http://tizen.org/privilege/socket
+       *
+       * @return                       An error code
+       * @param[in]            remoteEndPoint                          An instance of NetEndPoint representing the remote device
+       * @exception            E_SUCCESS                                       The method is successful.
+       * @exception            E_INVALID_SOCKET                        The socket is invalid.
+       * @exception            E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception            E_HOST_UNREACHABLE                      The network cannot be reached from this host at this time.
+       * @exception            E_IN_PROGRESS                           A previous request is in progress.
+       * @exception            E_INVALID_ARG                           The specified input parameter is invalid.
+       * @exception            E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
+       * @exception            E_CONNECTION_FAILED                     The socket is not connected.
+       * @exception            E_TIMEOUT                                       An attempt to connect to the server has timed out.
+       * @exception            E_ALREADY_CONNECTED                     The socket is already connected.
+       * @exception            E_UNSUPPORTED_FAMILY            The address family is not supported.
+       * @exception            E_UNSUPPORTED_PROTOCOL          The protocol is not supported.
+       * @exception        E_OUT_OF_MEMORY                             The memory is insufficient.
+       * @exception            E_SYSTEM                                        A system error has occurred.
+       * @exception        E_PRIVILEGE_DENIED                  The application does not have the privilege to call this method.
+       * @remarks                      If the socket is a connectionless socket (that is, of the type NET_SOCKET_TYPE_DATAGRAM), this method fails.
+       *                                       After this method is called, OnSocketConnected() is called. the data can be sent to and received from the remote device using Send() and Receive() respectively.
+       *                                       If a connection-oriented protocol is used and Bind() is not called before calling this method, the underlying service provider
+       *                                       assigns the local network address and port number.
+       */
+       result Connect(const Tizen::Net::NetEndPoint& remoteEndPoint);
+
+       /**
+    * @page                    SocketConnectPage        Compatibility for Connect()
+    *
+    * @section         SocketConnectPageIssueSection Issues
+    * Implementing this method in OSP compatible applications has the following issues:   @n
+    * -# If the application provides a loopback address in NetEndPoint, it returns E_SYSTEM.
+    *
+    * @section         SocketConnectPageResolutionSection Resolutions
+    *  This issue has been resolved in Tizen.  @n 
+    *  -# If the application provides a loopback address in NetEndPoint, it returns E_SUCCESS instead of E_SYSTEM.
+    */
+
+       /**
+       * Sends the data to a socket of the type NET_SOCKET_TYPE_STREAM.
+       *
+       * @since        2.0
+       *
+       * @return               An error code
+       * @param[in]    buffer                                          An instance of ByteBuffer that contains the data to be sent
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameter is not supported.
+       * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
+       * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_CONNECTION_FAILED                     The socket is not connected.
+       * @exception    E_TIMEOUT                                       An attempt to connect to the server has timed out.
+       * @exception  E_OUT_OF_MEMORY                           The memory is insufficient.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @remarks              This method sends the data to the remote host specified in the Connect() or AcceptN() method.
+       *                               This method sends the data in the @c buffer parameter, starting from the current position of the buffer.
+       *                               After the operation, the position of the buffer is incremented by the number of bytes successfully sent.
+       *                               The new position cannot be larger than the original limit.
+       *                               This method can be used only for connection-oriented sockets.
+       *                               In the blocking mode, if space is not available in the send queue, the socket blocks until space becomes available.
+       *                               In the non-blocking mode, this method returns the error E_WOULD_BLOCK.
+       *                               This method may complete successfully even if it sends less than the number of bytes
+       *                               in the buffer. The application should keep track of the number of bytes sent
+       *                               and retry the operation until the application sends the bytes in the buffer.
+       *                               There is no guarantee that the data that is sent appears on the network immediately.
+       *                               To increase network efficiency, the underlying system may delay transmission until a significant amount
+       *                               of outgoing data is collected. The successful completion of this method means that the underlying
+       *                               system has had room to buffer the data for a network send.
+       *                               If it is important for the application to send every byte to the remote host immediately,
+       *                               use SetSockOpt() (with NET_SOCKET_TCP_NODELAY) of the type ::NetSocketOptName to enable no delay.
+       */
+       result Send(Tizen::Base::ByteBuffer& buffer);
+
+       /**
+       * Sends the data to a socket of the type NET_SOCKET_TYPE_STREAM.
+       *
+       * @since        2.0
+       *
+       * @return               An error code
+       * @param[in]    pBuffer                                         The pointer to the buffer containing the data to send
+       * @param[in]    length                                          The length of the data in the buffer
+       * @param[out]   sentLength                                      The length of the data that is sent successfully
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+       * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
+       * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_CONNECTION_FAILED                     The socket is not connected.
+       * @exception    E_TIMEOUT                                       An attempt to connect to the server has timed out.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @remarks              This method sends the data to the remote host specified in the Connect() or AcceptN() method.
+       *                               This method sends the data in the buffer of length @c length, starting from the current position of the buffer.
+       *                               This method can be used only for connection-oriented sockets.
+       *                               In the blocking mode, if space is not available in the send queue, the socket blocks until space becomes available.
+       *                               In the non-blocking mode, this method returns the error E_WOULD_BLOCK.
+       *                               This method may complete successfully even if it sends less than the number of bytes
+       *                               in the buffer. The application should keep track of the number of bytes sent
+       *                               and retry the operation until the application sends the bytes in the buffer.
+       *                               There is no guarantee that the data that is sent appears on the network immediately.
+       *                               To increase the network efficiency, the underlying system may delay the transmission until a significant amount
+       *                               of outgoing data is collected. The successful completion of this method means that the underlying
+       *                               system has had room to buffer the data for a network send.
+       *                               If it is important to send every byte to the remote host immediately,
+       *                               use SetSockOpt() (with NET_SOCKET_TCP_NODELAY) of the type ::NetSocketOptName to enable no delay.
+       */
+       result Send(void* pBuffer, int length, int& sentLength);
+
+       /**
+       * Sends the data to a socket of the type NET_SOCKET_TYPE_DATAGRAM.
+       *
+       * @if OSPCOMPAT
+       * @brief <i> [Compatibility] </i>
+       * @endif
+       * @since            2.0
+       * @if OSPCOMPAT
+       * @compatibility        This method has compatibility issues with OSP compatible applications. @n
+    *                  For more information, see @ref SocketSendToPage1 "here".
+    * @endif
+       *
+       * @return                       An error code
+       * @param[in]            buffer                                          An instance of ByteBuffer containing the data to send
+       * @param[in]            remoteEndPoint                          An instance of NetEndPoint representing the destination for the data
+       * @exception            E_SUCCESS                                       The method is successful.
+       * @exception            E_INVALID_SOCKET                        The socket is invalid.
+       * @exception            E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception            E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+       * @exception            E_INVALID_ARG                           A specified input parameter is invalid.
+       * @exception            E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
+       * @exception            E_HOST_UNREACHABLE                      The network cannot be reached from this host at this time.
+       * @exception            E_OUT_OF_RANGE                          The message length has exceeded the maximum limit of the socket.
+       * @exception        E_OUT_OF_MEMORY                             The memory is insufficient.
+       * @exception            E_SYSTEM                                        A system error has occurred.
+       * @remarks              This method sends the data to the remote host specified by the @c remoteEndPoint parameter.
+       *                               This method sends the data in the @c buffer parameter, starting from the current position of the buffer.
+       *                               After the operation, the position of the buffer is incremented by the number of bytes successfully sent.
+       *                               The new position cannot be larger than the original limit.
+       *                               This method can be used only for connectionless sockets.
+       *                               In the blocking mode, if space is not available in the send queue, the socket blocks
+       *                               until space becomes available. If the socket is in the non-blocking mode,
+       *                               the error E_WOULD_BLOCK is returned.
+       */
+       result SendTo(Tizen::Base::ByteBuffer& buffer, const Tizen::Net::NetEndPoint& remoteEndPoint);
+
+       /**
+    * @page                    SocketSendToPage1        Compatibility for SendTo()
+    *
+    * @section         SocketSendToPage1IssueSection Issues
+    * Implementing this method in OSP compatible applications has the following issues:   @n
+    * -# If the application provides a loopback address in NetEndPoint, it returns E_SYSTEM.
+    *
+    * @section      SocketSendToPage1ResolutionSection Resolutions
+    *  This issue has been resolved in Tizen.  @n 
+    * -# If the application provides a loopback address in NetEndPoint, it returns E_SUCCESS instead E_SYSTEM.
+    */
+
+       /**
+       * Sends the data to a socket of the type NET_SOCKET_TYPE_DATAGRAM.
+       *
+       * @if OSPCOMPAT
+       * @brief <i> [Compatibility] </i>
+       * @endif
+       * @since            2.0
+       * @if OSPCOMPAT
+       * @compatibility        This method has compatibility issues with OSP compatible applications. @n
+    *                  For more information, see @ref SocketSendToPage2 "here".
+    * @endif
+       *
+       * @return                       An error code
+       * @param[in]            pBuffer                                 The pointer to the buffer containing the data to send
+       * @param[in]            length                                  The length of the data in the buffer
+       * @param[in]            remoteEndPoint                  An instance of NetEndPoint representing the destination for the data
+       * @param[out]           sentLength                              The length of the data that is sent successfully
+       * @exception            E_SUCCESS                               The method is successful.
+       * @exception            E_INVALID_SOCKET                The socket is invalid.
+       * @exception            E_INVALID_STATE                 The socket is not in a valid state.
+       * @exception            E_UNSUPPORTED_OPTION    The specified parameters are not supported.
+       * @exception            E_INVALID_ARG                   A specified input parameter is invalid.
+       * @exception            E_WOULD_BLOCK                   A non-blocking socket operation cannot be completed immediately.
+       * @exception            E_HOST_UNREACHABLE              The network cannot be reached from this host at this time.
+       * @exception            E_OUT_OF_RANGE                  The message length has exceeded the maximum limit of the socket.
+       * @exception        E_OUT_OF_MEMORY                     The memory is insufficient.
+       * @exception            E_SYSTEM                                A system error has occurred.
+       * @remarks                      This method sends the data to the remote host specified by the @c remoteEndPoint parameter.
+       *                                       This method sends the data in the buffer. The length of the data is specified by @c length, starting from the current
+       *                                       position of the buffer.
+       *                                       This method can be used only for connectionless sockets.
+       *                                       In the blocking mode, if space is not available in the send queue, the socket blocks
+       *                                       until space becomes available. If the socket is in the non-blocking mode,
+       *                                       the error E_WOULD_BLOCK is returned.
+       */
+       result SendTo(void* pBuffer, int length, const Tizen::Net::NetEndPoint& remoteEndPoint, int& sentLength);
+
+       /**
+    * @page                    SocketSendToPage2        Compatibility for SendTo()
+    *
+    * @section         SocketSendToPage2IssueSection Issues
+    * Implementing this method in OSP compatible applications has the following issues:   @n
+    * -# If the application provides a loopback address in NetEndPoint, it returns E_SYSTEM.
+    *
+    * @section      SocketSendToPage2ResolutionSection Resolutions
+    *  This issue has been resolved in Tizen.  @n 
+    * -# If the application provides a loopback address in NetEndPoint, it returns E_SUCCESS instead of E_SYSTEM.
+    */
+
+       /**
+       * Receives the data from a socket of the type NET_SOCKET_TYPE_STREAM.
+       *
+       * @since        2.0
+       *
+       * @return               An error code
+       * @param[out]   buffer                                          An instance of ByteBuffer that is the storage location for the received data
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameter is not supported.
+       * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
+       * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_TIMEOUT                                       An attempt to connect to the server has timed out.
+       * @exception    E_IN_PROGRESS                           A previous request is in progress.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @remarks              This method copies the data into the @c buffer parameter, starting from the current position of the buffer.
+       *                               After the operation, the position of the buffer is incremented by the number of bytes successfully received.
+       *                               The new position cannot be larger than the original limit.
+       *                               This method can only be called from connection-oriented sockets.
+       *                               If there is no data at the socket in the blocking mode,
+       *                               this method blocks until the data arrives. If the socket is in the non-blocking mode,
+       *                               the error E_WOULD_BLOCK is returned.
+       */
+       result Receive(Tizen::Base::ByteBuffer& buffer) const;
+
+       /**
+       * Receives the data from a socket of the type NET_SOCKET_TYPE_STREAM.
+       *
+       * @since        2.0
+       *
+       * @return               An error code
+       * @param[out]   pBuffer                                         The pointer to the buffer that is the storage location for the received data
+       * @param[in]    length                                          The length of the data in the buffer
+       * @param[out]   rcvdLength                                      The length of the data that is received successfully
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+       * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
+       * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_TIMEOUT                                       An attempt to connect to the server has timed out.
+       * @exception    E_IN_PROGRESS                           A previous request is in progress.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @remarks              This method copies the data into the buffer. The length of the data is specified by @c length, starting from the current
+       *                               position of the buffer.
+       *                               This method can be called only from connection-oriented sockets.
+       *                               If there is no data at the socket in the blocking mode,
+       *                               this method blocks until the data arrives. If the socket is in the non-blocking mode,
+       *                               the error E_WOULD_BLOCK is returned.
+       */
+       result Receive(void* pBuffer, int length, int& rcvdLength) const;
+
+       /**
+       * Receives the data from a socket of the type NET_SOCKET_TYPE_DATAGRAM.
+       *
+       * @if OSPCOMPAT
+       * @brief <i> [Compatibility] </i>
+       * @endif
+       * @since        2.0
+       * @if OSPCOMPAT
+       * @compatibility        This method has compatibility issues with OSP compatible applications. @n
+    *                  For more information, see @ref SocketReceiveFromPage1 "here".
+    * @endif
+       *
+       * @return               An error code
+       * @param[out]   buffer                                          An instance of ByteBuffer that is the storage location for the received data
+       * @param[out]   remoteEndPoint                          The NetEndPoint of the remote server
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+       * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
+       * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
+       * @exception    E_IN_PROGRESS                           A previous request is in progress.
+       * @exception    E_OUT_OF_RANGE                          The message length exceeded the maximum limit.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @remarks              This method copies the data into the specified buffer, starting from the current position of the buffer.
+       *                               After the operation, the position of the buffer is incremented by the number of bytes successfully received.
+       *                               The new position cannot be larger than the original limit.
+       *                               The method returns the remote host endpoint from which the data is sent.
+       *                               This method can only be called from connectionless sockets; that is,
+       *                               this method is used only if connectionless datagrams are to be received
+       *                               from an unknown host or multiple hosts.
+       *                               This method reads the first enqueued datagram received
+       *                               into the local network buffer. If the datagram received is larger
+       *                               than the remaining bytes of the buffer, this method returns the error E_OUT_OF_RANGE.
+       *                               If there is no data at the socket in the blocking mode,
+       *                               this method blocks until the data arrives. If the socket is in the non-blocking mode,
+       *                               the error E_WOULD_BLOCK is returned.
+       */
+       result ReceiveFrom(Tizen::Base::ByteBuffer& buffer, Tizen::Net::NetEndPoint& remoteEndPoint) const;
+
+       /**
+    * @page                    SocketReceiveFromPage1  Compatibility for ReceiveFrom()
+    *
+    * @section         SocketReceiveFromPage1IssueSection Issues
+    * Implementing this method in OSP compatible applications has the following issues:   @n
+    * -# If the application provides a loopback address in NetEndPoint, it returns E_SYSTEM.
+    *
+    * @section         SocketReceiveFromPage1ResolutionSection Resolutions
+    *  This issue has been resolved in Tizen.  @n 
+    * -# If the application provides a loopback address in NetEndPoint, it returns E_SUCCESS instead of E_SYSTEM.
+    */
+
+       /**
+       * Receives the data from a socket of the type NET_SOCKET_TYPE_DATAGRAM.
+       *
+       * @if OSPCOMPAT
+       * @brief <i> [Compatibility] </i>
+       * @endif
+       * @since        2.0
+       * @if OSPCOMPAT
+       * @compatibility        This method has compatibility issues with OSP compatible applications. @n
+    *                  For more information, see @ref SocketReceiveFromPage2 "here".
+    * @endif
+       *
+       * @return               An error code
+       * @param[out]   pBuffer                                         The pointer to the buffer that is the storage location for the received data
+       * @param[in]    length                                          The length of the data in the buffer
+       * @param[out]   remoteEndPoint                          The NetEndPoint of the remote server
+       * @param[out]   rcvdLength                                      The length of the data that is received successfully
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+       * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
+       * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
+       * @exception    E_IN_PROGRESS                           A previous request is in progress.
+       * @exception    E_OUT_OF_RANGE                          The message length exceeded the maximum limit.
+       * @exception  E_OUT_OF_MEMORY                           The memory is insufficient.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @remarks              This method copies the data into the buffer. The length of the data is specified by @c length, starting from the current
+       *                               position of the buffer.
+       *                               The method returns the remote host endpoint from which the data is sent.
+       *                               This method can only be called from connectionless sockets; that is,
+       *                               this method is used only if connectionless datagrams are to be received
+       *                               from an unknown host or multiple hosts.
+       *                               This method reads the first enqueued datagram received
+       *                               into the local network buffer. If the datagram received is larger
+       *                               than the value of @c length parameter, this method will return an error E_OUT_OF_RANGE.
+       *                               If there is no data at the socket in the blocking mode,
+       *                               this method blocks until the data arrives. If the socket is in the non-blocking mode,
+       *                               the error E_WOULD_BLOCK is returned.
+       */
+       result ReceiveFrom(void* pBuffer, int length, Tizen::Net::NetEndPoint& remoteEndPoint, int& rcvdLength) const;
+
+       /**
+    * @page                    SocketReceiveFromPage2  Compatibility for ReceiveFrom()
+    *
+    * @section         SocketReceiveFromPage2IssueSection Issues
+    * Implementing this method in OSP compatible applications has the following issues:   @n
+    * -# If the application provides a loopback address in NetEndPoint, it returns E_SYSTEM.
+    *
+    * @section         SocketReceiveFromPage2ResolutionSection Resolutions
+    *  This issue has been resolved in Tizen.  @n 
+    * -# If the application provides a loopback address in NetEndPoint, it returns E_SUCCESS instead of E_SYSTEM.
+    */
+
+       /**
+       * Binds the socket to a local address.
+       *
+       * @since        2.0
+       * @privilege    %http://tizen.org/privilege/socket
+       *
+       * @return               An error code
+       * @param[in]    localEndPoint                           The local NetEndPoint to associate with the socket
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameter is not supported.
+       * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
+       * @exception    E_ALREADY_BOUND                         The address is already in use.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              Use this method if a specific local endpoint should be used.
+       *                               This method can be used on both the connectionless and connection-oriented protocols.
+       *                               For connection-oriented sockets, this method need not be called
+       *                               before using the Connect() method, unless a specific local endpoint needs to be used.
+       *                               This method must be called before the Listen() method.
+       */
+       result Bind(const Tizen::Net::NetEndPoint& localEndPoint);
+
+       /**
+       * Places the socket in a listening state.
+       *
+       * @since        2.0
+       * @privilege    %http://tizen.org/privilege/socket
+       *
+       * @return               An error code
+       * @param[in]    backLog                                         The maximum length of the pending connections queue
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameter is not supported.
+       * @exception    E_UNSUPPORTED_PROTOCOL          The protocol is not supported.
+       * @exception    E_ALREADY_CONNECTED                     The socket is already connected.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              This method causes a connection-oriented socket to listen for
+       *                               the incoming connection attempts. The @c backlog parameter specifies
+       *                               the number of incoming connections that can be queued for acceptance.
+       *                               The Bind() method must be called before calling this method.
+       */
+       result Listen(int backLog);
+
+       /**
+       * Accepts an incoming connection. @n
+       * This method extracts the first connection from the queue of pending connections, and
+       * creates a new socket with the same socket type, protocol type, and protocol family
+       * as the listening socket.
+       *
+       * @since        2.0
+       * @privilege    %http://tizen.org/privilege/socket
+       *
+       * @return               A new socket for a newly created connection with the same socket type, protocol type, and protocol family, @n
+       *                               else @c null if an error occurs
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_WOULD_BLOCK                           A non-blocking socket operation cannot be completed immediately.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_UNSUPPORTED_OPTION            This operation is not supported for this socket.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_TIMEOUT                                       An attempt to connect to the server has timed out.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              Before calling this method, the Listen() method must be called first
+       *                               to listen for and queue the incoming connection requests.
+       *                               In the blocking mode, this method blocks until an incoming connection attempt
+       *                               is queued. After accepting a connection, the original socket
+       *                               continues queuing the incoming connection requests until it is closed.
+       *                               Note that if no connection is pending in the queue and the socket is in the blocking mode,
+       *                               this method blocks until a new connection arrives. If the socket is in the non-blocking mode,
+       *                               the E_WOULD_BLOCK exception is thrown. The specific error code can be accessed using the GetLastResult() method.
+       */
+       Socket* AcceptN(void) const;
+
+       /**
+       * Executes the specified command on the socket.
+       *
+       * @since        2.0
+       * @privilege    %http://tizen.org/privilege/socket
+       *
+       * @return               An error code
+       * @param[in]    cmd                                 The command to execute on the socket
+       * @param[in,out] value                                          The value of the IOCTL command
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+       * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @exception    E_PRIVILEGE_DENIED                      The application does not have the privilege to call this method.
+       * @remarks              This method manipulates the underlying device parameters of the socket descriptors. @n@n
+       *                               The NET_SOCKET_FIONBIO option is used for setting the non-blocking/blocking mode on a socket.
+       *                               Set the value to zero for enabling the blocking mode, or to a non-zero value for enabling the non-blocking mode.
+       *                               When a socket is created, by default, it operates in the non-blocking mode and the blocking mode is disabled. @n
+       *                               The NET_SOCKET_FIONREAD option is used for getting the number of bytes that are immediately available for reading. @n
+       *                               The NET_SOCKET_FIONWRITE option is used for getting the number of bytes that have not yet been
+       *                       acknowledged by the other side of the connection. This option is not supported in this SDK. @n
+       *                               The NET_SOCKET_SIOCATMARK option is used to determine if all out of band (OOB) data has been read.
+       *                               Currently sockets do not support this option.
+       *
+       */
+       result Ioctl(NetSocketIoctlCmd cmd, unsigned long& value) const;
+
+       /**
+       * Sets the socket to the asynchronous mode by a specified message to the specified event handler when the socket events occur.
+       *
+       * @since        2.0
+       *
+       * @return               An error code
+       * @param[in]    socketEventType                         The socket events of ::NetSocketEventType @n
+       *                                                                                       Multiple events can be combined using the bitwise "|" operator.
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_INVALID_ARG                           The specified input parameter is invalid.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_TIMEOUT                   An attempt to connect to the server has timed out.
+       *
+       */
+       result AsyncSelectByListener(unsigned long socketEventType);
+
+       /**
+       * Adds the specified listener to the socket.
+       *
+       * @since        2.0
+       *
+       * @return               An error code
+       * @param[in]    listener                                A reference to ISocketEventListener
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_INVALID_SOCKET                The socket is invalid.
+       * @exception    E_INVALID_STATE                 The associated socket is not in a valid state.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       * @exception    E_OBJ_ALREADY_EXIST             The listener is already added.
+       * @exception    E_INVALID_OPERATION             The current state of the instance prohibits the execution of the specified operation, @n
+       *                                                                               because the caller thread is a worker thread.
+       */
+       result AddSocketListener(ISocketEventListener& listener);
+
+       /**
+       * Removes the specified listener.
+       *
+       * @since        2.0
+       *
+       * @return       An error code
+       * @param[in]    listener                                A reference to ISocketEventListener
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_OBJ_NOT_FOUND                 The specified object is not found within the indicated range.
+       * @exception    E_INVALID_SOCKET                The socket is invalid.
+       * @exception    E_INVALID_STATE                 The associated socket is not in a valid state.
+       * @exception    E_SYSTEM                                A system error has occurred.
+       */
+       result RemoveSocketListener(ISocketEventListener& listener);
+
+       /**
+       * Gets the peer endpoint for this socket. @n
+       * It returns a NetEndPoint containing the peer IP address and port number.
+       *
+       * @since        2.0
+       *
+       * @return               The peer endpoint for the calling %Socket instance, @n
+       *                               else @c null if the socket is not connected to any peer
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         The socket is not in a valid state.
+       * @exception    E_SYSTEM                        A system error has occurred.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  GetLocalEndPoint()
+       */
+       const NetEndPoint* GetPeerEndPoint(void);
+
+       /**
+       * Gets the local endpoint for this socket. @n
+       * It returns a NetEndPoint containing the local IP address and port number.
+       *
+       * @since        2.0
+       *
+       * @return               The local endpoint for the calling %Socket instance, @n
+       *                               else @c null
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         The socket is not in a valid state.
+       * @exception    E_SYSTEM                        A system error has occurred.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @remarks              This NetEndPoint must be cast to a %NetEndPoint before retrieving any information.
+       */
+       const NetEndPoint* GetLocalEndPoint(void);
+
+       /**
+       * Gets an option of the socket.
+       *
+       * @since        2.0
+       *
+       * @return               An error code
+       * @param[in]    optionLevel                                     A ::NetSocketOptLevel value
+       * @param[in]    optionName                                      A ::NetSocketOptName value
+       * @param[out]   optionValue                                     The integer to receive the option setting
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INIT_FAILED                           The socket is not initialized.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+       * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_IN_PROGRESS                           A previous request is in progress.
+       * @exception    E_CONNECTION_FAILED                     The socket is not connected.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @remarks              The socket options determine the behavior of the current socket.
+       *                               Upon successful completion of this method,
+       *                               @c optionValue parameter contains the value of the specified socket option.
+       *                               For an option with a bool data type, a non-zero value is returned if the option is enabled. Otherwise,
+       *                               a zero value is returned. For an option with an integer data type, the method returns the appropriate value.
+       *                               The socket options are grouped by the level of protocol support.@n@n
+       *                               Listed below are the various socket options that can be obtained using this overload. These options are
+       *                               grouped by the appropriate NetSocketOptLevel.
+       *                               Use the appropriate %NetSocketOptLevel for the @c optionLevel parameter. The option that is chosen,
+       *                               must be specified in the @c optionName parameter. To set the current value of some of
+       *                               the listed options, use the SetSockOpt() method. @n@n
+       *                               The OptionNames are categorized under their specific option levels. @n@n
+       *                               NET_SOCKET_IPPROTO_TCP  @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_TCP_NODELAY: Disables the Nagle algorithm for send coalescing. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_TCP_MAXSEG: Specifies the MSS(Maximum Segment Size) for TCP. @n@n
+       *                               NET_SOCKET_IPPROTO_IP @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_IP_TTL: Time-to-live. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_IP_TOS: Type-of-service and precedence. @n@n
+       *                               NET_SOCKET_SOL_SOCKET @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_ACCEPTCONN: The socket is listening. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_BROADCAST: Permits the sending of broadcast messages. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_DONTROUTE : Do not route. Send the packet directly to the interface addresses. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_ERROR : For getting pending error and clear. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_KEEPALIVE: Uses keep-alive. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_LINGER: Lingers on close if data is present. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_OOBINLINE: Leaves the received Out Of Band data in line. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_RCVBUF: Buffer size for receives. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_RCVTIMEO: Receives a time-out. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_REUSEADDR: Allows the socket to be bound to an address that is already in use. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SNDBUF: Buffer size for sends. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SNDTIMEO: Sends a time-out. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_TYPE: Gets the socket type. @n
+       * @see SetSockOpt()
+       */
+       result GetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int& optionValue) const;
+
+       /**
+       * Gets the socket option status of SO_LINGER.
+       *
+       * @since        2.0
+       *
+       * @return               An error code
+       * @param[in]    optionLevel                                     The socket option level @n
+       *                                                                                       The @c optionLevel is NET_SOCKET_SOL_SOCKET.
+       * @param[in]    optionName                                      The socket configuration option name @n
+       *                                                                                       The @c optionName is NET_SOCKET_SO_LINGER.
+       * @param[out]   optionValue                                     The instance of LingerOption that is to receive the option setting
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_OUT_OF_MEMORY                         The memory is insufficient.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INIT_FAILED                           The socket is not initialized.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+       * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_IN_PROGRESS                           A previous request is in progress.
+       * @exception    E_CONNECTION_FAILED                     The socket is not connected.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @see Tizen::Net::Sockets::LingerOption
+       */
+       result GetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, LingerOption& optionValue) const;
+
+       /**
+       * Changes an option of the socket.
+       *
+       * @since        2.0
+       *
+       * @return               An error code
+       * @param[in]    optionLevel                                     A ::NetSocketOptLevel value
+       * @param[in]    optionName                                      A ::NetSocketOptName value
+       * @param[in]    optionValue                                     The option value
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INIT_FAILED                           The socket is not initialized.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+       * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
+       * @exception    E_INVALID_STATE                         The socket is not in a valid state.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_IN_PROGRESS                           A previous request is in progress.
+       * @exception    E_CONNECTION_FAILED                     The socket is not connected.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       * @remarks              This method is used to change the value of the option specified by the @c optionName parameter.
+       *                               The socket options determine the behavior of the current socket. For an option with a bool data type,
+       *                               specify a non-zero value to enable the option, and a zero value to disable the option.
+       *                               For an option with an integer data type, specify the appropriate value. The socket options are grouped
+       *                               by the level of protocol support. @n@n
+       *                               Listed below are the various socket options that can be set using this overload. These options are
+       *                               grouped by the appropriate NetSocketOptLevel. If any of these options are to be set,
+       *                               use the appropriate %NetSocketOptLevel for the @c optionLevel parameter. The chosen option
+       *                               must be specified in the @c optionName parameter. To get the current value of some of
+       *                               the options listed, use the GetSockOpt() method. @n@n
+       *                               The OptionNames are categorized under their specific option levels. @n@n
+       *                               NET_SOCKET_IPPROTO_TCP @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_TCP_NODELAY: Disables the Nagle algorithm for send coalescing. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_TCP_MAXSEG: Specifies the MSS(Maximum Segment Size) for TCP. @n@n
+       *                               NET_SOCKET_IPPROTO_IP @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_IP_TTL: Time-to-live. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_IP_TOS: Type-of-service and precedence. @n@n
+       *                               NET_SOCKET_SOL_SOCKET @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_BROADCAST : Permits the sending of broadcast messages. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_DONTROUTE : Do not route. Send the packet directly to the interface addresses. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_KEEPALIVE: Uses keep-alive. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_LINGER: Lingers on close if data is present. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_OOBINLINE: Leaves the received Out Of Band data in line. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_RCVBUF: Buffer size for receives. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_RCVTIMEO: Receives a time-out. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_REUSEADDR: Allows the socket to be bound to an address that is already in use. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SNDBUF: Buffer size for sends. @n
+       *                                       &nbsp;&nbsp;&nbsp;NET_SOCKET_SO_SNDTIMEO: Sends a time-out.
+       *
+       *
+       */
+       result SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int optionValue);
+
+       /**
+       * Enables or disables SO_LINGER with the specified linger time in seconds. @n
+       * The maximum timeout value is platform-specific. This setting only affects socket close.
+       *
+       * @since        2.0
+       *
+       * @return               An error code
+       * @param[in]    optionLevel                                     The socket option level @n
+       *                                                                                       The @c optionLevel is NET_SOCKET_SOL_SOCKET.
+       * @param[in]    optionName                                      The socket configuration option name @n
+       *                                                                                       The @c optionName is NET_SOCKET_SO_LINGER.
+       * @param[in]    optionValue                                     An instance of LingerOption that holds the option setting
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INIT_FAILED                           The socket is not initialized.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+       * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
+       * @exception    E_INVALID_STATE                         The socket is in an invalid state.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_IN_PROGRESS                           A previous request is in progress.
+       * @exception    E_CONNECTION_FAILED                     The socket is not connected.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       *
+       */
+       result SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, const LingerOption& optionValue);
+
+       /**
+       * Enables the adding or dropping of a membership for the specified multicast group. @n
+       * Multicast datagram packets are transmitted only to the multicast group members. @n
+       * A socket must join a multicast group before the data is received. @n
+       * Do not call NET_SOCKET_SO_IP_ADD_MEMBERSHIP with the same group more than once on the same network interface.
+       *
+       * @since        2.0
+       *
+       * @return               An error code
+       * @param[in]    optionLevel                                     Set to @c NET_SOCKET_IPPROTO_IP
+       * @param[in]    optionName                                      Set to either @c NET_SOCKET_IP_ADD_MEMBERSHIP or @c NET_SOCKET_IP_DROP_MEMBERSHIP only
+       * @param[in]    optionValue                                     An instance of IpMulticastRequestOption that contains the network interface and group address for multicasting
+       * @exception    E_SUCCESS                                       The method is successful.
+       * @exception    E_INVALID_SOCKET                        The socket is invalid.
+       * @exception    E_INIT_FAILED                           The socket is not initialized.
+       * @exception    E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+       * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
+       * @exception    E_INVALID_STATE                         The socket is in an invalid state.
+       * @exception    E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception    E_IN_PROGRESS                           A previous request is in progress.
+       * @exception    E_CONNECTION_FAILED                     The socket is not connected.
+       * @exception    E_SYSTEM                                        A system error has occurred.
+       *
+       */
+       result SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, const IpMulticastRequestOption& optionValue);
+
+private:
+       /**
+       * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       *
+       * @param[in]    rhs             An instance of %Socket
+       */
+       Socket(const Socket& rhs);
+
+       /**
+       * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       *
+       * @return               A reference to this instance
+       * @param[in]    rhs                     An instance of %Socket
+       */
+       Socket& operator =(const Socket& rhs);
+
+private:
+       _SocketImpl* __pSocketImpl;
+
+       friend class _SocketImpl;
+};
+
+} } }   // Tizen::Net::Sockets
+#endif // _FNET_SOCK_SOCKET_H_
diff --git a/inc/FNetSockSocketIpMulticastRequestOption.h b/inc/FNetSockSocketIpMulticastRequestOption.h
new file mode 100644 (file)
index 0000000..7c54e1c
--- /dev/null
@@ -0,0 +1,260 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+/**
+* @file                FNetSockSocketIpMulticastRequestOption.h
+* @brief       This is the header file for the %IpMulticastRequestOption class.
+*
+* This header file contains the declarations of the %IpMulticastRequestOption class.
+*/
+
+#ifndef _FNET_SOCK_SOCKET_IP_MULTICAST_REQUEST_OPTION_H_
+#define _FNET_SOCK_SOCKET_IP_MULTICAST_REQUEST_OPTION_H_
+
+#include <FBaseObject.h>
+#include <FNetNetEndPoint.h>
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+class _IpMulticastRequestOptionImpl;
+
+/**
+* @class       IpMulticastRequestOption
+* @brief       This class supports the multicasting in sockets for sending and receiving multicast datagram packets.
+*                      For multicasting, a socket must be of type NET_SOCKET_TYPE_DATAGRAM.
+*
+* @since       2.0
+*
+* The %IpMulticastRequestOption class supports the multicasting in sockets for sending and receiving multicast datagram packets.
+*                      For multicasting, a socket must be of type NET_SOCKET_TYPE_DATAGRAM.
+*
+*      For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/sockets.htm">Sockets Guide</a>.
+*
+* @see         Tizen::Net::Sockets::Socket::SetSockOpt(NetSocketOptLevel, NetSocketOptName, const IpMulticastRequestOption&)
+*
+* The following example demonstrates how to use the %IpMulticastRequestOption class with the multicast sender.
+*
+*      @code
+*                              result res = E_SUCCESS;
+*
+*                              // Creates the socket.
+*                              Socket* pSocket = new Socket();
+*                              res = pSocket->Construct(NET_SOCKET_AF_IPV4, NET_SOCKET_TYPE_DATAGRAM, NET_SOCKET_PROTOCOL_UDP);
+*
+*                              // Adds the listener.
+*                              MySocketListener* pSockListener = new MySocketListener();
+*                              res = pSocket->AddSocketListener(*pSockListener);
+*
+*                              // Selects the async event(non-blocking mode).
+*                              res = pSocket->AsyncSelectByListener(NET_SOCKET_EVENT_WRITE);
+*
+*                              // Creates the multicast group end point to send the data.
+*                              Ip4Address multicastAddr("224.1.1.1"); // Multicast group address
+*                              unsigned short multicastPort = XXXX;  // Multicast group port
+*                              NetEndPoint multicastEndPoint(multicastAddr, multicastPort);
+*
+*                              // Creates the data to send.
+*                              const char* pSendData = "Send";
+*                              Tizen::Base::ByteBuffer txBuffer;
+*                              txBuffer.Construct(strlen(pSendData) + 1);
+*                              txBuffer.SetArray((byte*)pSendData, 0, strlen(pSendData));
+*                              txBuffer.Flip();
+*
+*                              // Sends the data to the multicast group
+*                              res = ptSocket->SendTo(txBuffer, multicastEndPoint);
+*      @endcode
+*
+* The following example demonstrates how to use the %IpMulticastRequestOption class with the multicast receiver.
+*
+*      @code
+*                              result res = E_SUCCESS;
+*
+*                              // Creates the socket.
+*                              Socket* pSocket = new Socket();
+*                              res = pSocket->Construct(NET_SOCKET_AF_IPV4, NET_SOCKET_TYPE_DATAGRAM, NET_SOCKET_PROTOCOL_UDP);
+*
+*                              // Adds the listener.
+*                              MySocketListener* pSockListener = new MySocketListener();
+*                              res = pSocket->AddSocketListener(*pSockListener);
+*
+*                              // Selects the async event(non-blocking mode).
+*                              res = pSocket->AsyncSelectByListener(NET_SOCKET_EVENT_READ);
+*
+*                              // Binds the local interface end point to receive the data.
+*                              Ip4Address localAddr(NET_SOCKET_INADDR_ANY); // Any incoming interface
+*                              unsigned short localPort = XXXX;  // Multicast group port
+*                              NetEndPoint localEndPoint(localAddr, localPort);
+*                              res = pSocket->Bind(localEndPoint);
+*
+*                              // Creates the multicast group end point.
+*                              Ip4Address multicastAddr("224.1.1.1"); // Multicast group address
+*                              unsigned short multicastPort = YYYY;  // Any available port, which will not be used for other operations
+*                              NetEndPoint multicastEndPoint(multicastAddr, multicastPort);
+*
+*                              // Creates the local interface end point.
+*                              Ip4Address interfaceAddr(NET_SOCKET_INADDR_ANY); // Local interface address
+*                              unsigned short interfacePort = ZZZZ;  // Any available port, which will not be used for other operations
+*                              NetEndPoint interfaceEndPoint(interfaceAddr, interfacePort);
+*
+*                              // Specifies the IpMulticastRequestOption.
+*                              IpMulticastRequestOption ipMreq(multicastEndPoint, interfaceEndPoint);
+*
+*                              // Joins the multicast group.
+*                              res = pSocket->SetSockOpt(NET_SOCKET_IPPROTO_IP, NET_SOCKET_IP_ADD_MEMBERSHIP, ipMreq);
+*
+*                              // Creates the buffer to receive the data.
+*                              Tizen::Base::ByteBuffer rxBuffer;
+*                              rxBuffer.Construct(MAX_BUFFER_SIZE);
+*
+*                              // Receives the data from the multicast group.
+*                              res = pSocket->ReceiveFrom(rxBuffer, localEndPoint);
+*      @endcode
+*/
+class _OSP_EXPORT_ IpMulticastRequestOption
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * Initializes this instance of %IpMulticastRequestOption with the specified parameters.
+        *
+        * @since               2.0
+        *
+        * @param[in]   multicastAddress                A NetEndPoint instance containing the IP address and port of the multicast group to join
+        * @param[in]   interfaceAddress                A NetEndPoint instance containing the IP address and port of the network interface on which the datagram
+        *                                                                              packets will be received
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   A specified input parameter is invalid.
+        * @exception   E_SYSTEM                                An internal error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       IpMulticastRequestOption(const NetEndPoint& multicastAddress, const NetEndPoint& interfaceAddress);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since               2.0
+        */
+       virtual ~IpMulticastRequestOption(void);
+
+       /**
+       * Copying of objects using this copy constructor is allowed.
+       *
+       * @since                2.0
+       *
+       * @param[in]    rhs                     An instance of %IpMulticastRequestOption
+       */
+       IpMulticastRequestOption(const IpMulticastRequestOption& rhs);
+
+       /**
+       * Copying of objects using this copy assignment operator is allowed.
+       *
+       * @since                2.0
+       *
+       * @return               A reference to this instance
+       * @param[in]    rhs                     An instance of %IpMulticastRequestOption
+       */
+       IpMulticastRequestOption& operator =(const IpMulticastRequestOption& rhs);
+
+public:
+       /**
+        * Sets the multicast group NetEndPoint instance with the specified instance.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   multicastAddress                A NetEndPoint instance containing the IP address and port of the multicast group to join
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result SetMulticastEndPoint(NetEndPoint& multicastAddress);
+
+       /**
+        * Sets the network interface NetEndPoint with the specified instance.
+        *
+        * @since               2.0
+        *
+        * @return              An error code
+        * @param[in]   interfaceAddress                A NetEndPoint instance containing the address and port of the network interface on which the datagram
+        *                                                                              packets will be received
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
+        */
+       result SetInterfaceEndPoint(NetEndPoint& interfaceAddress);
+
+       /**
+       * Gets the NetEndPoint of the multicast group.
+       *
+       * @since                2.0
+       *
+       * @return               The multicast group NetEndPoint, @n
+       *                               else @c null if the multicast group %NetEndPoint is @c null
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 The group end point is in an invalid state.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       */
+       const NetEndPoint* GetMulticastEndPoint(void) const;
+
+       /**
+       * Gets the NetEndPoint of the network interface.
+       *
+       * @since                2.0
+       *
+       * @return               The network interface NetEndPoint, @n
+       *                               else @c null if the network interface %NetEndPoint is @c null
+       * @exception    E_SUCCESS                       The method is successful.
+       * @exception    E_INVALID_STATE         The interface end point is in an invalid state.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       */
+       const NetEndPoint* GetInterfaceEndPoint(void) const;
+
+       /**
+        * Compares the specified instance of %IpMulticastRequestOption with the calling instance.
+        *
+        * @since               2.0
+        * @return              @c true if the values match, @n
+        *                      else @c false
+        * @param[in]   obj     The other Object to be compared
+        * @see                 Object::Equals()
+        */
+       virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since               2.0
+        *
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+private:
+       /**
+       * This default constructor is intentionally declared as private so that only the platform can create an instance.
+       */
+       IpMulticastRequestOption(void);
+
+private:
+       _IpMulticastRequestOptionImpl* __pIpMulticastRequestOptionImpl;
+
+       friend class _IpMulticastRequestOptionImpl;
+};
+
+} } } // Tizen::Net::Sockets
+#endif // _FNET_SOCK_SOCKET_IP_MULTICAST_REQUEST_OPTION_H_
diff --git a/inc/FNetSockSocketLingerOption.h b/inc/FNetSockSocketLingerOption.h
new file mode 100644 (file)
index 0000000..ccad7f3
--- /dev/null
@@ -0,0 +1,200 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+/**
+* @file                FNetSockSocketLingerOption.h
+* @brief       This is the header file for the %LingerOption class.
+*
+* This header file contains the declarations of the %LingerOption class.
+*/
+
+#ifndef _FNET_SOCK_SOCKET_LINGER_OPTION_H_
+#define _FNET_SOCK_SOCKET_LINGER_OPTION_H_
+
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+class _LingerOptionImpl;
+
+/**
+* @class       LingerOption
+* @brief       This class specifies whether a socket remains connected after the Socket::Close() method is called.
+*                      It also specifies the amount of time for which it remains connected, if the data is not sent.
+*
+* @since       2.0
+*
+* The %LingerOption class specifies whether a socket remains connected after the Socket::Close() method is called.
+*                      It also specifies the amount of time for which it remains connected, if the data is not sent.
+*
+*For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/sockets.htm">Sockets Guide</a>.
+*
+* @see         Tizen::Net::Sockets::Socket::SetSockOpt(NetSocketOptLevel, NetSocketOptName, const LingerOption&)
+*
+* The following example demonstrates how to use the %LingerOption class.
+*
+*      @code
+*      using namespace Tizen::Base;
+*      using namespace Tizen::Net::Sockets;
+*
+*      void
+*      MyClass::SomeMethod(void)
+*      {
+*              // Constructs a LingerOption object.
+*              LingerOption socketLinger(true, 10);
+*
+*              // Gets information on a LingerOption object.
+*              if (socketLinger.IsEnabled())
+*              {
+*                      ushort time = socketLinger.GetLingerTime();
+*              }
+*      }
+*      @endcode
+*/
+class _OSP_EXPORT_ LingerOption
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+       * Initializes this instance of %LingerOption class with the specified parameters.
+       *
+       * @since                2.0
+       *
+       * @param[in]    enable          Set to @c true to remain connected after the Socket::Close() method is called, @n
+       *                                                       else @c false
+       * @param[in]    seconds         The number of seconds to remain connected after the Socket::Close() method is called
+       * @remarks      Data may still be available in the outgoing network buffer after the socket is closed.
+       *                               If you want to specify the amount of time the socket attempts to transmit unsent data after being closed,
+       *                               create a %LingerOption with the @c enable parameter set to @c true, and the @c seconds parameter set to the desired
+       *                               amount of time. The @c seconds parameter is used to indicate how long the socket remains connected
+       *                               before getting timed out. If the socket is not required to stay connected for any amount of time after being closed,
+       *                               create a %LingerOption with the enabled parameter set to @c false. In this case, the socket closes immediately
+       *                               and any unsent data is lost. Once created, pass the %LingerOption to the Socket::SetSoLinger() method.
+       *
+       */
+       LingerOption(bool enable, int seconds);
+
+       /**
+       * This destructor overrides Tizen::Base::Object::~Object().
+       *
+       * @since                2.0
+       */
+       virtual ~LingerOption(void);
+
+       /**
+       * Copying of objects using this copy constructor is allowed.
+       *
+       * @since                2.0
+       *
+       * @param[in]    rhs             An instance of %LingerOption
+       */
+       LingerOption(const LingerOption& rhs);
+
+       /**
+       * Copying of objects using this copy assignment operator is allowed.
+       *
+       * @since                2.0
+       *
+       * @return               A reference to this instance
+       * @param[in]    rhs                     An instance of %LingerOption
+       */
+       LingerOption& operator =(const LingerOption& rhs);
+
+       /**
+        * Compares the specified instance of %LingerOption with the calling instance.
+        *
+        * @since               2.0
+        *
+        * @return              @c true if the values match, @n
+        *                      else @c false
+        * @param[in]   obj     The other Object to be compared
+        * @see                 Object::Equals()
+        */
+       virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+       /**
+        * Gets the hash value of the current instance.
+        *
+        * @since               2.0
+        * @return      The hash value of the current instance
+        */
+       virtual int GetHashCode(void) const;
+
+public:
+       /**
+       * Sets a value indicating whether the socket should linger after being closed.
+       *
+       * @since                2.0
+       *
+       * @param[in]    on                      Set to @c true if the socket should linger after Socket::Close() is called, @n
+       *                                                       else @c false
+       */
+       void SetEnabled(bool on);
+
+       /**
+       * Sets the linger time. @n
+       * This is the amount of time to remain connected after calling the Socket::Close() method if data remains to be sent.
+       *
+       * @since                2.0
+       *
+       * @param[in]    seconds         The amount of time, in seconds, to remain connected after calling Socket::Close()
+       * @remarks              Use this method to determine how long a closed socket attempts transferring unsent data before getting timed out. The value can
+       *                               also be set to the desired time-out period in seconds. If the Enabled property is set to @c true, and LingerTime is set to @c 0, the
+       *                               socket attempts to send the data until there is no data left in the outgoing network buffer.
+       * @see                  Socket::SetSockOpt()
+       */
+       void SetLingerTime(int seconds);
+
+       /**
+       * Gets the linger time. @n
+       * This is the amount of time to remain connected after calling the Socket::Close() method if data still remains to be sent.
+       *
+       * @since                2.0
+       *
+       * @return               The amount of time in seconds to remain connected after calling Socket::Close()
+       */
+       int GetLingerTime(void) const;
+
+       /**
+        * Checks whether the linger option is enabled.
+        *
+        * @since               2.0
+        *
+        * @return              @c true if the socket lingers after Socket::Close() is called, @n
+        *                              else @c false
+        */
+       bool IsEnabled(void) const;
+
+private:
+       /**
+       * This default constructor is intentionally declared as private so that only the platform can create an instance.
+       */
+       LingerOption(void);
+
+private:
+       _LingerOptionImpl* __pLingerOptionImpl;
+
+       friend class _LingerOptionImpl;
+};
+
+} } }   // Tizen::Net::Sockets
+
+
+#endif // _FNET_SOCK_SOCKET_LINGER_OPTION_H_
diff --git a/inc/FNetSockSocketTypes.h b/inc/FNetSockSocketTypes.h
new file mode 100644 (file)
index 0000000..b77d11d
--- /dev/null
@@ -0,0 +1,189 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+/**
+* @file                        FNetSockSocketTypes.h
+* @brief               This is the header file for the enumerators of the Socket namespace.
+*
+* This header file contains the definitions of the enumerators for the Socket operations.
+*/
+
+#ifndef _FNET_SOCK_SOCKET_TYPES_H_
+#define _FNET_SOCK_SOCKET_TYPES_H_
+
+#include <FNetNetTypes.h>
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+/**
+ * @enum    NetSocketEventType
+ *
+ * Defines the socket event types.
+ *
+ * @since      2.0
+ */
+enum NetSocketEventType
+{
+       NET_SOCKET_EVENT_WRITE = 0x01,                  /**< The write event */
+       NET_SOCKET_EVENT_READ = 0x02,                   /**< The read event */
+       NET_SOCKET_EVENT_CLOSE = 0x04,                  /**< The close event */
+       NET_SOCKET_EVENT_ACCEPT = 0x08,                 /**< The accept event */
+       NET_SOCKET_EVENT_CONNECT = 0x10,                /**< The connect event */
+       NET_SOCKET_EVENT_SERVCERT_FAIL = 0x20,          /**< The server's certificate failed event @n
+                                                                        Only for %SecureSocket. */
+       NET_SOCKET_EVENT_NONE = 0x00                          // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
+};
+
+/**
+ * @enum    NetSocketAddressFamily
+ *
+ * Defines an address family.
+ *
+ * @since      2.0
+ */
+enum NetSocketAddressFamily
+{
+       //NET_SOCKET_AF_LOCAL = 1,                            /*< The local socket for loopback*/
+       NET_SOCKET_AF_IPV4 = 2,                             /**< An IP version 4 address family */
+       //NET_SOCKET_AF_IPV6,                                           /*< An IP version 6 address family */
+       NET_SOCKET_AF_NONE = 0                             // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
+};
+
+/**
+ * @enum    NetSocketType
+ *
+ * Defines a socket type.
+ *
+ * @since      2.0
+ */
+enum NetSocketType
+{
+       NET_SOCKET_TYPE_STREAM = 1,                         /**< The stream socket */
+       NET_SOCKET_TYPE_DATAGRAM,                        /**< The datagram socket */
+       NET_SOCKET_TYPE_NONE = 0                           // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
+};
+
+/**
+ * @enum    NetSocketProtocol
+ *
+ * Defines a protocol type.
+ *
+ * @since      2.0
+ */
+enum NetSocketProtocol
+{
+       NET_SOCKET_PROTOCOL_TCP = 1,                        /**< The TCP protocol */
+       NET_SOCKET_PROTOCOL_UDP,                        /**< The UDP protocol */
+       NET_SOCKET_PROTOCOL_SSL,                         /**< The SSL protocol */
+       NET_SOCKET_PROTOCOL_NONE = 0                       // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
+};
+
+/**
+ * @enum           NetSocketIoctlCmd
+ *
+ * Defines the commands that control the socket I/O.
+ *
+ * @since      2.0
+ */
+enum NetSocketIoctlCmd
+{
+       NET_SOCKET_FIONBIO = 1,                             /**< The command to set the non-blocking/blocking mode on a socket */
+       NET_SOCKET_FIONREAD,                            /**< The command to determine the amount of data pending in the network input buffer */
+       NET_SOCKET_FIONWRITE,                           /**< The functionality is not supported in this SDK */
+       NET_SOCKET_SIOCATMARK,                           /**< The command to determine whether all out-of-band data is read */
+       NET_SOCKET_IOCTLCMD_NONE = 0                       // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
+};
+
+/**
+ * @enum    NetSocketOptLevel
+ *
+ * Defines the socket option levels. @n
+ * The level decides the context of the option.
+ *
+ * @since      2.0
+ */
+enum NetSocketOptLevel
+{
+       NET_SOCKET_IPPROTO_TCP = 1,                         /**< The socket options apply only to the TCP sockets */
+       NET_SOCKET_IPPROTO_IP,                          /**< The socket options apply only to the IP sockets */
+       NET_SOCKET_SOL_SOCKET,                           /**< The socket options apply to all the sockets */
+       NET_SOCKET_OPTLEVEL_NONE = 0                       // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
+};
+
+/**
+* @enum     NetSocketOptName
+*
+* Defines the socket configuration option names.
+*
+* @since       2.0
+*/
+enum NetSocketOptName
+{
+       NET_SOCKET_TCP_NODELAY = 1,                         /**< The option name is Level: NET_SOCKET_IPPROTO_TCP - Set/Get is possible */
+       NET_SOCKET_TCP_MAXSEG,                          /**< The option name is Level: NET_SOCKET_IPPROTO_TCP - Set/Get is possible */
+       NET_SOCKET_IP_TTL,                              /**< The option name is Level: NET_SOCKET_IPPROTO_IP - Set/Get is possible */
+       NET_SOCKET_IP_TOS,                              /**< The option name is Level: NET_SOCKET_IPPROTO_IP - Set/Get is possible */
+       NET_SOCKET_IP_ADD_MEMBERSHIP,                   /**< The option name is Level: NET_SOCKET_IPPROTO_IP - Only Set is possible */
+       NET_SOCKET_IP_DROP_MEMBERSHIP,                  /**< The option name is Level: NET_SOCKET_IPPROTO_IP - Only Set is possible */
+       NET_SOCKET_SO_ACCEPTCONN,                       /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Only Get is possible */
+       NET_SOCKET_SO_BROADCAST,                        /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
+       NET_SOCKET_SO_DEBUG,                            // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible (Currently, not supported)
+       NET_SOCKET_SO_DONTROUTE,                        /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
+       NET_SOCKET_SO_ERROR,                            /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Only Get is possible */
+       NET_SOCKET_SO_KEEPALIVE,                        /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
+       NET_SOCKET_SO_LINGER,                           /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
+       NET_SOCKET_SO_OOBINLINE,                        /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
+       NET_SOCKET_SO_RCVBUF,                           /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
+       NET_SOCKET_SO_RCVLOWAT,                          // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible (Currently, not supported)
+       NET_SOCKET_SO_RCVTIMEO,                         /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
+       NET_SOCKET_SO_REUSEADDR,                        /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
+       NET_SOCKET_SO_SNDBUF,                           /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
+       NET_SOCKET_SO_SNDLOWAT,                         // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible (Currently, not supported)
+       NET_SOCKET_SO_SNDTIMEO,                         /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
+       NET_SOCKET_SO_TYPE,                             /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Only Get is possible */
+
+       //Secure Socket only
+       NET_SOCKET_SO_SSLVERSION,                       /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
+       NET_SOCKET_SO_SSLCIPHERSUITEID,                 /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
+       NET_SOCKET_SO_SSLCERTVERIFY,                    /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Only Set is possible */
+       NET_SOCKET_SO_SSLCERTID,                         /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Only Set is possible */
+       NET_SOCKET_SO_SSLCLIENTCERTVERIFY,               /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Only Set is possible */
+       NET_SOCKET_OPTNAME_NONE = 0                        // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
+};
+
+/**
+* @enum     NetSocketClosedReason
+*
+* Defines a socket closed reason.
+*
+* @since       2.0
+*/
+enum NetSocketClosedReason
+{
+       NET_SOCKET_CLOSED_REASON_NORMAL = 1,                    /**< A normal closed status by peer */
+       NET_SOCKET_CLOSED_REASON_TIMEOUT,                   /**< The connection attempt failed due to timeout */
+       NET_SOCKET_CLOSED_REASON_NETWORK_UNAVAILABLE,       /**< The network is unavailable */
+       NET_SOCKET_CLOSED_REASON_SYSTEM,                    /**< An internal error has occurred */
+       NET_SOCKET_CLOSED_REASON_NO_CERTIFICATE,            /**< The reason is there is no client's SSL certificate */
+       NET_SOCKET_CLOSED_REASON_BY_USER,                    /**< The connection closed by user */
+       NET_SOCKET_CLOSED_REASON_NONE = 0                      // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
+};
+
+} } } // Tizen::Net::Sockets
+#endif //_FNET_SOCK_SOCKET_TYPES_H_
diff --git a/inc/FNetSockSocketUtility.h b/inc/FNetSockSocketUtility.h
new file mode 100755 (executable)
index 0000000..12208ca
--- /dev/null
@@ -0,0 +1,191 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+/**
+* @file                FNetSockSocketUtility.h
+* @brief       This is the header file for the %SocketUtility class.
+*
+* This header file contains the declarations of the %SocketUtility class. @n
+* This class provides utility methods for socket operations.
+*/
+
+#ifndef _FNET_SOCK_SOCKET_UTILITY_H_
+#define _FNET_SOCK_SOCKET_UTILITY_H_
+
+#include <FBaseCol.h>
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+class _SocketUtilityImpl;
+
+/**
+* @class       SocketUtility
+* @brief       This class provides the utility methods for the Socket class.
+*
+* @since    2.0
+*
+* The %SocketUtility class provides the utility methods for the Socket class.
+*
+* For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/sockets.htm">Sockets Guide</a>.
+*/
+class _OSP_EXPORT_ SocketUtility
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+       * 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.
+       *
+       * @since                2.0
+       */
+       SocketUtility(void);
+
+       /**
+       * This destructor overrides Tizen::Base::Object::~Object().
+       *
+       * @since        2.0
+       */
+       virtual ~SocketUtility(void);
+
+       /**
+       * Initializes this instance of %SocketUtility.
+       *
+       * @since                2.0
+       *
+       * @return               An error code
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_STATE                 This instance is in an invalid state.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_SYSTEM                                Interface creation has failed.
+       */
+       result Construct(void);
+
+       /**
+       * Determines the status of one or more sockets.
+       *
+       * @since                        2.0
+       * @privilege            %http://tizen.org/privilege/socket
+       *
+       * @return                       An error code
+       * @param[in,out]        pCheckRead                                      An IList of Socket instances to check for readability
+       * @param[in,out]        pCheckWrite                                     An IList of Socket instances to check for writability
+       * @param[in,out]        pCheckError                                     An IList of Socket instances to check for errors
+       * @param[in]            microSeconds                            The time to wait for a response, in microseconds
+       * @exception            E_SUCCESS                                       The method is successful.
+       * @exception            E_INVALID_SOCKET                        The socket is invalid.
+       * @exception            E_INVALID_STATE                         The socket is in an invalid state.
+       * @exception            E_UNSUPPORTED_OPTION            The specified parameters are not supported.
+       * @exception            E_INVALID_ARG                           A specified input parameter is invalid.
+       * @exception            E_TIMEOUT                                       The time limit has expired.
+       * @exception            E_NETWORK_UNAVAILABLE           The network is unavailable.
+       * @exception        E_OUT_OF_MEMORY                             The memory is insufficient.
+       * @exception            E_SYSTEM                                        A system error has occurred.
+       * @exception        E_PRIVILEGE_DENIED                  The application does not have the privilege to call this method.
+       * @remarks              This method determines the status of one or more
+       *               Socket instances. There must be at least one socket in an IList
+       *               before this method is used.
+       *               To check sockets for readability and writability use @c pCheckRead and @c pCheckWrite of type
+       *                               %IList respectively by calling this method.
+       *               To detect error conditions, use @c pCheckError.
+       *               After calling this method, the %IList is filled with only those sockets that satisfy the conditions. @n
+       *               All the receive operations succeed without blocking in the following cases: @n
+       *                               -#  If the socket is in a listening state, the readability means that a call to Accept() succeeds without blocking.
+       *                               -#  If the connection on a socket is accepted, the readability means that the data is available for reading. @n
+       *               The readability can also indicate whether the remote socket has shutdown the connection. In this
+       *               case a call to SecureSocket::Receive() or Socket::Receive() returns immediately with @c 0 bytes.
+       *               If a non-blocking call to SecureSocket::Connect() or Socket::Connect() is made, the writability means that the connection is
+       *                               successful and the @c pCheckError parameter identifies the sockets that are not
+       *                               connected successfully. @n
+       *               If a connection has already been established, the writability means that all the send operations
+       *                               have succeeded without blocking.
+       */
+       result Select(Tizen::Base::Collection::IList* pCheckRead, Tizen::Base::Collection::IList* pCheckWrite, Tizen::Base::Collection::IList* pCheckError, int microSeconds);
+
+       /**
+       * Converts the specified unsigned @c short integer from a host @c byte order to a network @c byte order.
+       *
+       * @since                2.0
+       *
+       * @return               An unsigned @c short integer in network @c byte order
+       * @param[in]    hostShort               An unsigned @c short integer in host @c byte order
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  NtoHS()
+       */
+       unsigned short HtoNS(unsigned short hostShort);
+
+       /**
+       * Converts the specified unsigned @c long integer from a host @c byte order to a network @c byte order.
+       *
+       * @since                2.0
+       *
+       * @return               An unsigned @c long integer in network @c byte order
+       * @param[in]    hostLong                An unsigned @c long integer in host @c byte order
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  NtoHL()
+       */
+       unsigned long HtoNL(unsigned long hostLong);
+
+       /**
+       * Converts the specified unsigned @c short integer from a network @c byte order to a host @c byte order.
+       *
+       * @since                2.0
+       *
+       * @return               An unsigned @c short integer in host @c byte order
+       * @param[in]    netShort                An unsigned @c short integer in network @c byte order
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  HtoNS()
+       */
+       unsigned short NtoHS(unsigned short netShort);
+
+       /**
+       * Converts the specified unsigned @c long integer from a network @c byte order to a host @c byte order.
+       *
+       * @since                2.0
+       *
+       * @return               An unsigned @c long integer in host @c byte order
+       * @param[in]    netLong                 An unsigned @c long integer in network @c byte order
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @see                  HtoNL()
+       */
+       unsigned long NtoHL(unsigned long netLong);
+
+private:
+       /**
+       * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+       *
+       * @param[in]    rhs                     An instance of %SocketUtility
+       */
+       SocketUtility(const SocketUtility& rhs);
+
+       /**
+       * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+       *
+       * @return               A reference to this instance
+       * @param[in]    rhs                     An instance of %SocketUtility
+       */
+       SocketUtility& operator =(const SocketUtility& rhs);
+
+private:
+       _SocketUtilityImpl* __pSocketUtilityImpl;
+
+       friend class _SocketUtilityImpl;
+};
+
+} } } // Tizen::Net::Sockets
+#endif // _FNET_SOCK_SOCKET_UTILITY_H_
diff --git a/inc/FNetSockets.h b/inc/FNetSockets.h
new file mode 100644 (file)
index 0000000..4d25b76
--- /dev/null
@@ -0,0 +1,85 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+/**
+* @file                FNetSockets.h
+* @brief       This is the header file for the %Sockets namespace.
+*
+* This header file contains the declarations and descriptions of the %Sockets namespace.
+*/
+
+#ifndef _FNET_SOCKETS_H_
+#define _FNET_SOCKETS_H_
+
+#include <FNetSockSocket.h>
+#include <FNetSockISocketEventListener.h>
+#include <FNetSockSecureSocket.h>
+#include <FNetSockISecureSocketEventListener.h>
+#include <FNetSockSocketIpMulticastRequestOption.h>
+#include <FNetSockSocketLingerOption.h>
+#include <FNetSockSocketUtility.h>
+#include <FNetSockSocketTypes.h>
+
+namespace Tizen { namespace Net
+{
+/**
+* @namespace   Tizen::Net::Sockets
+* @brief               This namespace contains the classes and interfaces for Transmission Control Protocol (TCP) or User Datagram Protocol (UDP) socket
+*                              programming.
+* @since        2.0
+*
+* @remarks      @b Header @b %file: @b \#include @b <FNet.h> @n
+*                              @b Library : @b osp-net @n
+*
+* The %Tizen::Net::Sockets sub-namespace implements the socket data communication protocols by providing a rich set of methods for connecting,
+*                              sending, and receiving data over a network.
+*
+* For more information on the %Sockets namespace features, see <a href="../org.tizen.native.appprogramming/html/guide/net/sockets.htm">Sockets Guide</a>.
+*
+* The following diagram illustrates the relationships between the classes belonging to the %Sockets namespace.
+* @image html net_socket_using_the_apis_classdiagram.png
+*
+* The following example demonstrates how to use a TCP client non-blocking socket.
+*
+*                              @code
+*                              result res = E_SUCCESS;
+*
+*                              // Creates the socket.
+*                              Socket* pClientSocket = new Socket();
+*                              res = pClientSocket->Construct(NET_SOCKET_AF_IPV4, NET_SOCKET_TYPE_STREAM, NET_SOCKET_PROTOCOL_TCP);
+*
+*                              // Adds listener.
+*                              MySocketClientListener* pSockClientListener = new MySocketClientListener();
+*                              res = pClientSocket->AddSocketListener(*pSockClientListener);
+*
+*                              // Selects asynchronous event (non-blocking mode).
+*                              res = pClientSocket->AsyncSelectByListener(NET_SOCKET_EVENT_CONNECT| NET_SOCKET_EVENT_CLOSE);
+*
+*                              // Creates peer endpoint.
+*                              Ip4Address peerAddr("XXX.XXX.XXX.XXX"); // Server socket address.
+*                              unsigned short peerPort = YYY;  // Port
+*                              NetEndPoint* pPeerEndPoint = new NetEndPoint(peerAddr, peerPort);
+*
+*                              // Connects the socket.
+*                              res = pClientSocket->Connect(*pPeerEndPoint);
+*                              @endcode
+*/
+namespace Sockets
+{
+} } } // Tizen::Net::Sockets
+#endif // _FNET_SOCKETS_H_
diff --git a/inc/FNetWifi.h b/inc/FNetWifi.h
new file mode 100644 (file)
index 0000000..46cba03
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. 
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi.h
+ * @brief   This is the header file for the %Wifi namespace.
+ *
+ * This header file contains the declarations and descriptions of the %Wifi namespace.
+ */
+
+#ifndef _FNET_WIFI_H_
+#define _FNET_WIFI_H_
+
+#include <FNetWifiWifiTypes.h>
+#include <FNetWifiWifiManager.h>
+#include <FNetWifiWifiBssInfo.h>
+#include <FNetWifiWifiSecurityInfo.h>
+#include <FNetWifiIWifiManagerEventListener.h>
+#include <FNetWifiIWifiSystemMonitoringEventListener.h>
+#include <FNetWifiWifiNetAccountInfo.h>
+#include <FNetWifiIWifiDirectDeviceListener.h>
+#include <FNetWifiIWifiDirectGroupOwnerListener.h>
+#include <FNetWifiIWifiDirectGroupClientListener.h>
+#include <FNetWifiWifiDirectDevice.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FNetWifiWifiDirectDeviceManager.h>
+#include <FNetWifiWifiDirectGroupClient.h>
+#include <FNetWifiWifiDirectGroupInfo.h>
+#include <FNetWifiWifiDirectGroupMember.h>
+#include <FNetWifiWifiDirectGroupOwner.h>
+
+namespace Tizen { namespace Net
+{
+
+/**
+  * @namespace   Tizen::Net::Wifi
+  * @brief       This namespace contains the classes and interfaces for the Wi-Fi management and Wi-Fi Direct functionalities.
+  * @since       2.0
+  *
+  * @remarks     @b Header @b %file: @b \#include @b <FNet.h> @n
+  *              @b Library : @b osp-wifi @n
+  *
+  * The %Net::Wifi namespace contains the classes and interfaces for Wi-Fi management and Wi-Fi Direct functionalities. It provides a rich set of methods
+  * to manage the Wi-Fi devices and accounts, and to communicate over a Wi-Fi channel. Additionally, the Wi-Fi Direct functionalities are provided to manage
+  * the Wi-Fi Direct device, create a Wi-Fi Direct group, scan Wi-Fi Direct devices, associate to a Wi-Fi Direct group owner, get the WifiDirectGroupOwner or
+  * the WifiDirectGroupClient instance, and allow the listener to get the events related to Wi-Fi Direct device and group.
+  *
+  * This namespace provides the Wi-Fi and Wi-Fi Direct functionalities. The Wi-Fi related operations are provided by classes like WifiManager and WifiSecurityInfo.
+  * The Wi-Fi Direct related operations are provided by classes like WifiDirectDevice.
+  *
+  * For more information on the %Wifi namespace features, see <a href="../org.tizen.native.appprogramming/html/guide/net/wi-fi_connectivity.htm">Wi-Fi Connectivity</a> and <a href="../org.tizen.native.appprogramming/html/guide/net/wi-fi_direct_connectivity.htm">Wi-Fi Direct Connectivity</a>.
+  *
+  * The following diagram illustrates the relationships between the Wi-Fi classes belonging to the %Wifi namespace.
+  * @image html net_wi-fi_using_the_apis_classdiagram.png
+  *
+  * The following diagram illustrates the relationships between the Wi-Fi Direct classes belonging to the %Wifi namespace.
+  * @image html net_wi-fi_direct_using_the_apis_classdiagram.png
+  *
+  */
+namespace Wifi
+{
+
+} } } // Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_H_
diff --git a/inc/FNetWifiIWifiDirectDeviceListener.h b/inc/FNetWifiIWifiDirectDeviceListener.h
new file mode 100644 (file)
index 0000000..cc41e8b
--- /dev/null
@@ -0,0 +1,279 @@
+// 
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. 
+// 
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNetWifiIWifiDirectDeviceListener.h
+ * @brief              This is the header file for the %IWifiDirectDeviceListener interface.
+ *
+ * This header file contains the declarations of the %IWifiDirectDeviceListener interface.
+ */
+#ifndef _FNET_WIFI_IWIFI_DIRECT_DEVICE_LISTENER_H_
+#define _FNET_WIFI_IWIFI_DIRECT_DEVICE_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class WifiDirectGroupInfo;
+class WifiDirectDeviceInfo;
+class WifiDirectGroupMember;
+
+/**
+ * @interface   IWifiDirectDeviceListener
+ * @brief       This interface implements listeners for the WifiDirectDevice events.
+ *
+ * @since       2.0
+ *
+ * The %IWifiDirectDeviceListener interface represents a listener to get the Wi-Fi Direct device status or information.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/wi-fi_direct_connectivity.htm">Wi-Fi Direct Connectivity</a>.
+ */
+
+class _OSP_EXPORT_ IWifiDirectDeviceListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+    /**
+     * This polymorphic destructor should be overridden if required. This way, 
+     * the destructors of the derived classes are called when the destructor of this interface is called.
+     *
+     * @since   2.0
+     */
+    virtual ~IWifiDirectDeviceListener(void) {}
+
+    /**
+     * Called to notify the application that the local Wi-Fi Direct mode is enabled.
+     *
+     * @since 2.0
+     *
+     * @param[in]   localDeviceId       The ID of the Wi-Fi Direct device
+     * @param[in]   r                   An error code
+     * @exception   E_SUCCESS   The activation is successful.
+     * @exception   E_SYSTEM    A system error has occurred.
+     * @see         WifiDirectDevice::Activate()
+     */
+    virtual void OnWifiDirectDeviceActivated(WifiDirectDeviceId localDeviceId, result r) = 0;
+
+    /**
+     * Called to notify the application that the local Wi-Fi Direct mode is disabled.
+     *
+     * @since 2.0
+     *
+     * @param[in]   localDeviceId   An ID for a Wi-Fi Direct device
+     * @param[in]   r               An error code
+     * @exception   E_SUCCESS   The deactivation is successful.
+     * @exception   E_SYSTEM    A system error has occurred.
+     * @see         WifiDirectDevice::Deactivate()
+     */
+    virtual void OnWifiDirectDeviceDeactivated(WifiDirectDeviceId localDeviceId, result r) = 0;
+
+    /**
+     * Called to notify the application when a Wi-Fi Direct connection is established with a remote device.
+     *
+     * @since 2.0
+     *
+     * @param[in]   localDeviceId           An ID for a Wi-Fi Direct device
+     * @param[in]   remoteDeviceInfo        The remote device
+     * @param[in]   r                       An error code
+     *
+     * @exception   E_SUCCESS               The Wi-Fi Direct group has been created successfully.
+     * @exception   E_SYSTEM                A system error has occurred.
+     * @exception   E_OPERATION_CANCELED    The operation has been cancelled explicitly.
+     * @exception   E_AUTHENTICATION        The authentication has failed during the Wi-Fi connection process.
+     * @exception   E_NOT_RESPONDING        The remote device is not responding.
+     * @see       WifiDirectDevice::Connect()
+     * @see       WifiDirectDevice::CancelConnect()
+     */
+    virtual void OnWifiDirectConnected(WifiDirectDeviceId localDeviceId, const WifiDirectDeviceInfo& remoteDeviceInfo, result r) = 0;
+
+    /**
+     * Called to notify the application when the Wi-Fi Direct connection is disconnected with a peer device.
+     *
+     * @since 2.0
+     *
+     * @param[in]   localDeviceId     An ID for a Wi-Fi Direct device
+     * @param[in]   peerMacAddress    The mac address of the peer device
+     * @param[in]   r              An error code
+     * @exception   E_SUCCESS      The method is successful.
+     * @exception   E_SYSTEM       A system error has occurred.
+     * @see         WifiDirectDevice::Disconnect()
+     */
+    virtual void OnWifiDirectDisconnected(WifiDirectDeviceId localDeviceId, const Tizen::Base::String& peerMacAddress, result r) = 0;
+
+    /**
+      * Called to notify the application when an autonomous group is created.
+      *
+      * @since 2.0
+      *
+      * @param[in]   localDeviceId    An ID for a Wi-Fi Direct device
+      * @param[in]   r                An error code
+      * @exception   E_SUCCESS       The method is successful.
+      * @exception   E_SYSTEM        A system error has occurred.
+      * @see         WifiDirectDevice::CreateAutonomousGroup()
+      */
+    virtual void OnWifiDirectAutonomousGroupCreated(WifiDirectDeviceId localDeviceId, result r) = 0;
+
+    /**
+     * Called to notify the application when a local device leaves the group.
+     *
+     * @since 2.0
+     *
+     * @param[in]   localDeviceId  An ID for a Wi-Fi Direct device
+     * @param[in]   r              An error code
+     * @exception   E_SUCCESS      The method is successful.
+     * @exception   E_SYSTEM       A system error has occurred.
+     * @see         WifiDirectDevice::LeaveGroup()
+     */
+    virtual void OnWifiDirectGroupLeft(WifiDirectDeviceId localDeviceId, result r) = 0;
+
+    /**
+     * @if OSPDEPREC
+     * Called to notify the application about the result and related information when a group is created or when a request to create a group is cancelled.
+     * cancellation.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  This method is deprecated because the Wi-Fi direct APIs have been revised to allow the use of APIs with ease irrespective of the role (for example, group owner, group client, and so on). @n
+        *              Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role and so it was necessary to use these APIs. @n
+     *              Instead of using this method, use OnWifiDirectConnected() or OnWifiDirectAutonomousGroupCreated() method.
+     *
+     * @since 2.0
+     *
+     * @param[in]   localDeviceId                   An ID for a Wi-Fi Direct device
+     * @param[in]   wifiDirectGroupInfo             The WifiDirectGroupInfo instance set by the winning group owner after negotiation
+     * @param[in]   wifiDirectGroupOwnerDeviceInfo  The WifiDirectDeviceInfo instance of the group owner
+     * @param[in]   pWifiDirectMember               The WifiDirectGroupMember instance that is casted to the instance of 
+     *                                              WifiDirectGroupOwner or WifiDirectGroupClient as a result of negotiation
+     *                                              after the creation of a group
+     * @param[in]   r                               An error code
+     * @exception   E_SUCCESS                   The Wi-Fi Direct group creation is successful.
+     * @exception   E_SYSTEM                    A system error has occurred.
+     * @exception   E_OPERATION_CANCELED        The operation has been cancelled explicitly.
+     * @exception   E_AUTHENTICATION            The authentication has failed during the Wi-Fi connection process.
+     * @exception   E_DHCP                      The DHCP operation has failed.
+     * @exception   E_NOT_RESPONDING            The target is not responding.
+     * @exception   E_REJECTED                  The connection request has been rejected.
+     * @exception   E_REMOTE_DEVICE_NOT_FOUND   The Wi-Fi Direct device has not been found.
+     * @remarks     If a device becomes a group client, then the WifiDirectGroupInfo::GetGroupOwnerIntent() and WifiDirectGroupInfo::GetMaxNumberOfClients() methods will not contain valid information.
+        * @see         WifiDirectDevice::CreateGroup()
+        * @see                 WifiDirectDevice::CancelGroupCreation()
+        * @endif
+     */
+    virtual void OnWifiDirectGroupCreatedN(WifiDirectDeviceId localDeviceId, const WifiDirectGroupInfo& wifiDirectGroupInfo, const WifiDirectDeviceInfo& wifiDirectGroupOwnerDeviceInfo, WifiDirectGroupMember* pWifiDirectMember, result r) {}
+
+    /**
+     * Called to notify the application when the scan is completed.
+     *
+     * @since 2.0
+     *
+     * @param[in]   localDeviceId                   An ID for a Wi-Fi Direct device
+     * @param[in]   pWifiDirectDeviceInfoList       The WifiDirectDeviceInfo information list representing the
+     *                                              Wi-Fi Direct devices discovered by scan
+     * @param[in]   r                               An error code
+     * @exception   E_SUCCESS                       The scan is successful.
+     * @exception   E_SYSTEM                        A system error has occurred.
+     * @exception   E_OPERATION_CANCELED            The operation has been cancelled explicitly.
+     * @see         WifiDirectDevice::Scan()
+     * @see            WifiDirectDevice::CancelScan()
+     */
+    virtual void OnWifiDirectScanCompletedN(WifiDirectDeviceId localDeviceId, Tizen::Base::Collection::IList* pWifiDirectDeviceInfoList, result r) = 0;
+
+    /**
+     * @if OSPDEPREC
+     * Called to notify the application when the connection to a Wi-Fi Direct group owner is completely established.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  This method is deprecated because the Wi-Fi direct APIs have been revised to allow the use of APIs with ease irrespective of the role (for example, group owner, group client, and so on). @n
+        *              Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role and so it was necessary to use these APIs. @n
+     *              Instead of using this method, use OnWifiDirectConnected() method.
+     *
+     * @since 2.0
+     *
+     * @param[in]    localDeviceId                   An ID for a Wi-Fi Direct device
+     * @param[in]    wifiDirectGroupOwnerDeviceInfo  The WifiDirectDeviceInfo of the connected Wi-Fi Direct group
+     *                                               owner
+     * @param[in]    r                               An error code
+     * @exception    E_SUCCESS                       The association is successful.
+     * @exception    E_SYSTEM                        A system error has occurred.
+     * @exception    E_AUTHENTICATION                The authentication has failed during the Wi-Fi connection process.
+     * @exception    E_DHCP                          The DHCP operation has failed.
+     * @exception    E_NOT_RESPONDING                The target is not responding.
+     * @exception    E_REJECTED                      The connection request has been rejected.
+     * @exception    E_REMOTE_DEVICE_NOT_FOUND       The Wi-Fi Direct device has not been found.
+     * @see          WifiDirectDevice::Associate()
+     * @endif
+     */
+    virtual void OnWifiDirectAssociationCompleted(WifiDirectDeviceId localDeviceId, const WifiDirectDeviceInfo& wifiDirectGroupOwnerDeviceInfo, result r) {}
+
+protected:
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectDeviceListener_Reserved1(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectDeviceListener_Reserved2(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectDeviceListener_Reserved3(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectDeviceListener_Reserved4(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectDeviceListener_Reserved5(void) {}
+}; // IWifiDirectDeviceListener
+
+} } } //Tizen::Net::Wifi
+#endif // _FNET_WIFI_IWIFI_DIRECT_DEVICE_LISTENER_H_
diff --git a/inc/FNetWifiIWifiDirectGroupClientListener.h b/inc/FNetWifiIWifiDirectGroupClientListener.h
new file mode 100644 (file)
index 0000000..0e32abe
--- /dev/null
@@ -0,0 +1,207 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+// 
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNetWifiIWifiDirectGroupClientListener.h
+ * @brief              This is the header file for the %IWifiDirectGroupClientListener interface.
+ *
+ * This header file contains the declarations of the %IWifiDirectGroupClientListener interface.
+ */
+#ifndef _FNET_WIFI_IWIFI_DIRECT_GROUP_CLIENT_LISTENER_H_
+#define _FNET_WIFI_IWIFI_DIRECT_GROUP_CLIENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class WifiDirectDeviceInfo;
+
+/**
+ * @if OSPDEPREC
+ * @interface   IWifiDirectGroupClientListener
+ * @brief       <i> [Deprecated] </i> This interface implements listeners for the WifiDirectGroupClient events.
+ * @deprecated  The %WifiDirectGroupClient class is deprecated, therefore, this interface is also deprecated. @n
+ * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role(for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+ * The Wi-Fi Direct APIs have now been revised to allow the use of APIs with ease irrespective of the role. Now the APIs have been integrated into the IWifiDirectDeviceListener interface. @n
+ *             
+ *              Instead of IWifiDirectGroupClientListener API, use the %IWifiDirectDeviceListener interface.
+ *
+ * @since       2.0
+ *
+ * The %IWifiDirectGroupClientListener interface represents a listener that is used to obtain the Wi-Fi Direct client status or information.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/wi-fi_direct_connectivity.htm">Wi-Fi Direct Connectivity</a>.
+ * @endif
+ */
+
+class _OSP_EXPORT_ IWifiDirectGroupClientListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+    /**
+     * @if OSPDEPREC
+     * This polymorphic destructor should be overridden if required. This way, 
+     * the destructors of the derived classes are called when the destructor of this interface is called.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  The WifiDirectGroupClient class is deprecated, therefore, this destructor is also deprecated. @n
+        * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role(for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * However, now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     *              
+     *
+     * @since   2.0
+     * @endif
+     */
+    virtual ~IWifiDirectGroupClientListener(void) {}
+
+    /**
+     * @if OSPDEPREC
+     * Called to notify the application when the connection to a Wi-Fi Direct group owner is terminated.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  The WifiDirectGroupClient class is deprecated, therefore, this method is also deprecated. @n
+        * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role(for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     *              
+     *              As these APIs have now been integrated into the IWifiDirectDeviceListener interface, use IWifiDirectDeviceListener::OnWifiDirectDisconnected() method instead.
+     *
+     * @since 2.0
+     *
+     * @param[in]   localDeviceId       An ID for a Wi-Fi Direct device
+     * @param[in]   reason              The reason to terminate this association
+     * @param[in]   r                   An error code
+     * @exception   E_SUCCESS           The disassociation is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_NOT_RESPONDING    The target is not responding.
+     * @remarks     When a device is disconnected by itself using WifiDirectGroupClient::Disassociate() method, this event is invoked with Wifi::WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_SELF_INITIATED. @n
+     *              When a device is disconnected by a group owner using WifiDirectGroupOwner::Disconnect() method, due to no range, or due to abrupt connection loss to the group owner, this event is invoked with Wifi::WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_DISCONNECTED.
+        * @see         WifiDirectGroupClient::Disassociate()
+     * @endif
+     */
+    virtual void OnWifiDirectAssociationTerminated(WifiDirectDeviceId localDeviceId, WifiDirectAssociationTerminationReason reason, result r) = 0;
+
+    /**
+     * @if OSPDEPREC
+     * Called to notify the application when the request to acquire the WifiDirectDeviceInfo from a Wi-Fi Direct group owner is received.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  The WifiDirectGroupClient class is deprecated, therefore, this method is also deprecated. @n
+        *  Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role(for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     *             
+     *              So the APIs have been integrated into the WifiDirectDevice class. Hence, use the WifiDirectDevice::GetGroupOwnerInfoN() method instead.
+     *
+     * @since 2.0
+     *
+     * @param[in]   localDeviceId                   An ID for a Wi-Fi Direct device
+     * @param[in]   wifiDirectGroupOwnerDeviceInfo  The WifiDirectDeviceInfo instance of the Wi-Fi Direct group owner
+     * @param[in]   r                               An error code
+     * @exception   E_SUCCESS                       The request for acquiring group owner information is successful.
+     * @exception   E_SYSTEM                        A system error has occurred.
+     * @exception   E_ALREADY_BOUND                 The specified port number is already in use.
+     * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
+     * @exception   E_NOT_RESPONDING                The target is not responding.
+     * @see        WifiDirectGroupClient::RequestGroupOwnerInfo()
+     * @endif
+     */
+    virtual void OnWifiDirectGroupOwnerInfoReceived(WifiDirectDeviceId localDeviceId, const WifiDirectDeviceInfo& wifiDirectGroupOwnerDeviceInfo, result r) = 0;
+
+    /**
+     * @if OSPDEPREC
+     * Called to notify the application that the WifiDirectDeviceInfo list of group members has been received.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  The WifiDirectGroupClient class is deprecated, therefore, this method is also deprecated. @n
+        * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role(for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * This is because the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     *              
+     *
+     * @since 2.0
+     *
+     * @param[in]   localDeviceId               An ID for a Wi-Fi Direct device
+     * @param[in]   pWifiDirectDeviceInfoList   The list of WifiDirectDeviceInfo, @n
+     *                                          else @c null if it fails
+     * @param[in]   r                           An error code
+     * @exception   E_SUCCESS                   The response has been received successfully.
+     * @exception   E_SYSTEM                    A system error has occurred.
+     * @exception   E_ALREADY_BOUND             The specified port number is already in use.
+     * @exception   E_OUT_OF_MEMORY             The memory is insufficient.
+     * @exception   E_NOT_RESPONDING            The group owner is not reachable.
+     * @see         WifiDirectGroupClient::RequestAllGroupMemberInfo()
+     * @endif
+     */
+    virtual void OnWifiDirectAllGroupMemberInfoReceivedN(WifiDirectDeviceId localDeviceId, Tizen::Base::Collection::IList* pWifiDirectDeviceInfoList, result r) = 0;
+
+protected:
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectGroupClientListener_Reserved1(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectGroupClientListener_Reserved2(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectGroupClientListener_Reserved3(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectGroupClientListener_Reserved4(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectGroupClientListener_Reserved5(void) {}
+}; // IWifiDirectGroupClientListener
+
+} } } //Tizen::Net::Wifi
+#endif // _FNET_WIFI_IWIFI_DIRECT_GROUP_CLIENT_LISTENER_H_
diff --git a/inc/FNetWifiIWifiDirectGroupOwnerListener.h b/inc/FNetWifiIWifiDirectGroupOwnerListener.h
new file mode 100644 (file)
index 0000000..11fc510
--- /dev/null
@@ -0,0 +1,234 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNetWifiIWifiDirectGroupOwnerListener.h
+ * @brief              This is the header file for the %IWifiDirectGroupOwnerListener interface.
+ *
+ * This header file contains the declarations of the %IWifiDirectGroupOwnerListener interface.
+ */
+#ifndef _FNET_WIFI_IWIFI_DIRECT_GROUP_OWNER_LISTENER_H_
+#define _FNET_WIFI_IWIFI_DIRECT_GROUP_OWNER_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FNetWifiWifiTypes.h>
+#include <FNetNetConnection.h>
+
+namespace Tizen { namespace Net
+{
+class NetConnection;
+} } // Tizen::Net
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class WifiDirectDeviceInfo;
+
+/**
+ * @if OSPDEPREC
+ * @interface   IWifiDirectGroupOwnerListener
+ * @brief       <i> [Deprecated] </i> This interface implements listeners for the WifiDirectGroupOwner events.
+ * @deprecated  The WifiDirectGroupOwner class is deprecated, therefore, this interface is also deprecated. @n
+ *              Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role(for example, group owner, group client, and so on) and so it was necessary to use these APIs. Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role.  @n
+ *              As the APIs have been integrated into the IWifiDirectDeviceListener interface. Hence, use the IWifiDirectDeviceListener interface instead.
+ *
+ * @since       2.0
+ *
+ * The %IWifiDirectGroupOwnerListener interface represents a listener that is used to obtain the Wi-Fi Direct group owner's status or information.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/wi-fi_direct_connectivity.htm">Wi-Fi Direct Connectivity</a>.
+ * @endif
+ */
+
+class _OSP_EXPORT_ IWifiDirectGroupOwnerListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+    /**
+     * @if OSPDEPREC
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  The WifiDirectGroupOwner class is deprecated, therefore, this destructor is also is deprecated. @n
+        * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role for example, group owner, group client, and so on) and so it was necessary to use these APIs. Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role . @n
+     *              
+     *
+     * @since   2.0
+     * @endif
+     */
+    virtual ~IWifiDirectGroupOwnerListener(void) {}
+
+    /**
+     * @if OSPDEPREC
+     * Called to notify the application that a successful association has occurred with a client.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  The WifiDirectGroupOwner class is deprecated, therefore, this method is also deprecated. @n
+        * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     *              
+     *            As the APIs have been integrated into the IWifiDirectDeviceListener interface, use the IWifiDirectDeviceListener::OnWifiDirectConnected() method instead.
+     *
+     * @since 2.0
+     *
+     * @param[in]    localDeviceId           An ID for a Wi-Fi Direct device
+     * @param[in]    wifiDirectClientInfo    The WifiDirectDeviceInfo instance of an associated node
+     * @endif
+     */
+    virtual void OnWifiDirectClientAssociated(WifiDirectDeviceId localDeviceId, const WifiDirectDeviceInfo& wifiDirectClientInfo) = 0;
+
+    /**
+     * @if OSPDEPREC
+     * Called to notify the application that a disassociation has occurred with a client.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  The WifiDirectGroupOwner class is deprecated, therefore, this method is also deprecated. @n
+        * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     *  
+     *              As the APIs have been integrated into the IWifiDirectDeviceListener interface, use the IWifiDirectDeviceListener::OnWifiDirectDisconnected() method instead.
+     *
+     * @since 2.0
+     *
+     * @param[in]   localDeviceId           An ID for a Wi-Fi Direct device
+     * @param[in]   wifiDirectClientInfo    The WifiDirectDeviceInfo instance of a disassociated node
+     * @param[in]   reason                  The reason of termination of an association
+     * @remarks When a client is disconnected by a group owner using WifiDirectGroupOwner::Disconnect, this event is invoked with Wifi::WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_SELF_INITIATED. @n
+     *          When a client is disconnected by itself using WifiDirectGroupClient::Disassociate(), due to no range, or due to abrupt connection loss to the group owner, this event is invoked with Wifi::WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_DISCONNECTED.
+     * @endif
+     */
+    virtual void OnWifiDirectClientDisassociated(WifiDirectDeviceId localDeviceId, const WifiDirectDeviceInfo& wifiDirectClientInfo, WifiDirectAssociationTerminationReason reason) = 0;
+
+    /**
+     * @if OSPDEPREC
+     * Called to notify the application when the Wi-Fi Direct group is destroyed.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  The WifiDirectGroupOwner class is deprecated, therefore, this method is also deprecated. @n
+     * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     
+     *              As the APIs have been integrated into the IWifiDirectDeviceListener interface, use the IWifiDirectDeviceListener::OnWifiDirectDisconnected() or IWifiDirectDeviceListener::OnWifiDirectGroupLeft() method instead.
+     *
+     * @since 2.0
+     *
+     * @param[in]   localDeviceId       An ID for a Wi-Fi Direct device
+     * @param[in]   r                   An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @see         WifiDirectGroupOwner::DestroyGroup()
+     * @endif
+     */
+    virtual void OnWifiDirectGroupDestroyed(WifiDirectDeviceId localDeviceId, result r) = 0;
+
+    /**
+     * @if OSPDEPREC
+     * Called to notify the application that the group member information service has started.
+     *
+     * @brief   <i> [Deprecated] </i>
+    * @deprecated   The WifiDirectGroupOwner class is deprecated, therefore, this method is also deprecated. @n
+       * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+    
+    *
+    * @since 2.0
+    *
+    * @param[in]    localDeviceId       An ID for a Wi-Fi Direct device
+    * @param[in]    pNetConnection      The network connection that started with the Wi-Fi Direct net account, @n
+    *                                   else @c null if the system fails to start the network connection @n
+    * @param[in]    r                   An error code
+    * @exception    E_SUCCESS           The method is successful.
+    * @exception    E_SYSTEM            A system error has occurred.
+    * @exception    E_OUT_OF_MEMORY     The memory is insufficient.
+    * @exception    E_ALREADY_BOUND     The specified port number is already in use.
+    * @see          WifiDirectGroupOwner::StartGroupMemberInfoService()
+     * @endif
+     */
+    virtual void OnWifiDirectGroupMemberInfoServiceStarted(WifiDirectDeviceId localDeviceId, const Tizen::Net::NetConnection* pNetConnection, result r) = 0;
+
+    /**
+     * @if OSPDEPREC
+    * Called to notify the application that the group member information service has stopped.
+    *
+    * @brief   <i> [Deprecated] </i>
+    * @deprecated  The %WifiDirectGroupOwner class is deprecated, therefore, this method also is deprecated. @n
+       * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+    
+    *
+    * @since 2.0
+    *
+    * @param[in]    localDeviceId       An ID for a Wi-Fi Direct device
+    * @param[in]    r                   An error code
+    * @exception    E_SUCCESS           The method is successful.
+    * @exception    E_SYSTEM            A system error has occurred.
+    * @see          WifiDirectGroupOwner::StopGroupMemberInfoService()
+     * @endif
+     */
+    virtual void OnWifiDirectGroupMemberInfoServiceStopped(WifiDirectDeviceId localDeviceId, result r) = 0;
+
+protected:
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectGroupOwnerListener_Reserved1(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectGroupOwnerListener_Reserved2(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectGroupOwnerListener_Reserved3(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectGroupOwnerListener_Reserved4(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since    2.0
+    //
+    virtual void OnWifiDirectGroupOwnerListener_Reserved5(void) {}
+}; // IWifiDirectGroupOwnerListener
+
+} } } //Tizen::Net::Wifi
+#endif // _FNET_WIFI_IWIFI_DIRECT_GROUP_OWNER_LISTENER_H_
diff --git a/inc/FNetWifiIWifiManagerEventListener.h b/inc/FNetWifiIWifiManagerEventListener.h
new file mode 100644 (file)
index 0000000..15a13be
--- /dev/null
@@ -0,0 +1,150 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNetWifiIWifiManagerEventListener.h
+ * @brief      This is the header file for the %IWifiManagerEventListener interface.
+ *
+ * This header file contains the declarations of the %IWifiManagerEventListener interface.
+ *
+ */
+#ifndef _FNET_WIFI_IWIFI_MANAGER_EVENT_LISTENER_H_
+#define _FNET_WIFI_IWIFI_MANAGER_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseColArrayList.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+/**
+ * @interface   IWifiManagerEventListener
+ * @brief       This interface provides the listeners for WifiManager events.
+ *
+ * @since   2.0
+ *
+ * The %IWifiManagerEventListener interface specifies the methods used for creating notifications about the different kinds of WifiManager events. These events are only sent
+ *  out when using %WifiManager. When a %WifiManager event is generated, a method of this class is called. Thus, if an application provides any functionality related to the %WifiManager events, override and use the methods of this interface.
+ *  This interface specifies the methods used for creating notifications about the different kinds of %WifiManager events.
+ *  
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/wi-fi_connectivity.htm">Wi-Fi Connectivity</a>.
+ */
+class _OSP_EXPORT_ IWifiManagerEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+    /**
+     * This polymorphic destructor should be overridden if required. This way, 
+     * the destructors of the derived classes are called when the destructor of this interface is called.
+     *
+     * @since  2.0
+     */
+    virtual ~IWifiManagerEventListener(void) {}
+
+    /**
+      * Called to notify the application that the local Wi-Fi radio is activated.
+      *
+      * @since       2.0
+         *
+      * @param[in]   r           The error code that occurs during the activation
+      * @exception   E_SUCCESS   The activation is successful.
+      * @exception   E_FAILURE   The method has failed to activate.
+      * @see         WifiManager::Activate()
+      */
+    virtual void OnWifiActivated(result r) = 0;
+
+    /**
+      * Called to notify the application that the local Wi-Fi radio is deactivated.
+      *
+      * @since       2.0
+         *
+      * @param[in]   r           The error code that occurs during the deactivation
+      * @exception   E_SUCCESS   The deactivation is successful.
+      * @exception   E_FAILURE   The method has failed to deactivate.
+      * @see WifiManager::Deactivate()
+      */
+    virtual void OnWifiDeactivated(result r) = 0;
+
+    /**
+      * Called to notify that the connection to an access point (only an infrastructure mode BSS) has been completely established.
+      *
+      * @since       2.0
+         *
+      * @param[in]   ssid                The SSID of the connected BSS
+      * @param[in]   r                   The error code that occurs during the connection
+      * @exception   E_SUCCESS           The connection is successful.
+      * @exception   E_FAILURE           The method has failed to connect.
+      * @exception   E_AUTHENTICATION    The authentication fails when Wi-Fi is connected.
+      * @exception   E_NOT_RESPONDING    The target is not responding when Wi-Fi is connected.
+      * @exception   E_DHCP              The DHCP fails in case of a dynamic IP.
+      * @see         WifiManager::Connect()
+      */
+    virtual void OnWifiConnected(const Tizen::Base::String& ssid, result r) = 0;
+
+    /**
+      * Called to notify that the connection to a BSS has been terminated.
+      *
+      * @since   2.0
+      */
+    virtual void OnWifiDisconnected(void) = 0;
+
+    /**
+      * Called to notify that the Received Signal Strength Indication (RSSI) from BSS has been changed.
+      *
+      * @since       2.0
+         *
+      * @param[in]   rssi    The updated RSSI value (dbm)
+      */
+    virtual void OnWifiRssiChanged(long rssi) = 0;
+
+    /**
+      * Called to notify that the scan to find the access points has been completed.
+      *
+      * @since       2.0
+         *
+      * @param[in]   pWifiBssInfoList    The list of WifiBssInfo information representing the access points discovered by the scan
+      * @param[in]   r                   The error code that occurs during the scan
+      * @exception   E_SUCCESS           The scan is successful.
+      * @exception   E_FAILURE           The scan has failed.
+      * @see         WifiManager::Scan()
+      */
+    virtual void OnWifiScanCompletedN(const Tizen::Base::Collection::IList* pWifiBssInfoList, result r) = 0;
+
+protected:
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since 2.0
+    //
+    virtual void IWifiManagerEventListener_Reserved1(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since 2.0
+    //
+    virtual void IWifiManagerEventListener_Reserved2(void) {}
+}; // IWifiManagerEventListener
+
+} } } // Tizen::Net::Wifi
+#endif // _FNET_WIFI_IWIFI_MANAGER_EVENT_LISTENER_H_
diff --git a/inc/FNetWifiIWifiSystemMonitoringEventListener.h b/inc/FNetWifiIWifiSystemMonitoringEventListener.h
new file mode 100644 (file)
index 0000000..53bceaa
--- /dev/null
@@ -0,0 +1,124 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @if VISPARTNER-MANUFACTURER
+ * @file        FNetWifiIWifiSystemMonitoringEventListener.h
+ * @brief       This is the header file for the %IWifiSyWifiSystemMonitoringntListener interface.
+ * @visibility  partner-manufacturer
+ *
+ * This header file contains the declarations of the %IWifiSystemMonitoringEventListener interface.
+ *
+ * @endif
+ */
+#ifndef _FNET_WIFI_IWIFI_SYSTEM_MONITORING_EVENT_LISTENER_H_
+#define _FNET_WIFI_IWIFI_SYSTEM_MONITORING_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+/**
+ * @if VISPARTNER-MANUFACTURER
+ * @interface   IWifiSystemMonitoringEventListener
+ * @brief       This interface provides the listeners for monitoring the Wi-Fi underlying system.
+ *
+ * @since 2.0
+ * @visibility  partner-manufacturer
+ *
+ * The IWifiSystemMonitoringEventListener interface specifies the methods used for creating notifications about the different
+ * kinds of Wi-Fi system monitoring events. When a Wi-Fi system monitoring event is generated, one of these methods is called.
+ * @endif
+ */
+class _OSP_EXPORT_ IWifiSystemMonitoringEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * This polymorphic destructor should be overridden if required.
+     * This way, the destructors of the derived classes are called when the destructor of this interface is called.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     * @endif
+     */
+    virtual ~IWifiSystemMonitoringEventListener(void) {}
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Called to notify the application that the state of local Wi-Fi connection is changed.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+        *
+     * @param[in]   state               The state of the Wi-Fi current connection
+     * @remark      When the local device is connected with a particular access point,
+     *              IWifiManagerEventListener::OnWifiConnected() as well as this method with @c WIFI_CONN_STATE_CONNECTED
+     *              are called. Therefore, be careful to manipulate only one of those methods. So are the cases of
+     *              IWifiManagerEventListener::OnWifiDisconnected() and this method with @c WIFI_CONN_STATE_NOT_CONNECTED.
+     * @endif
+     */
+    virtual void OnWifiConnectionStateChanged(WifiConnectionState state) = 0;
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Called to notify the application that the scan result of Wi-Fi system on background is updated.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+        *
+     * @remark      Call WifiManager::GetSystemScanResultN() for checking the content of this update.
+        * @endif
+     */
+    virtual void OnWifiSystemScanResultUpdated(void) = 0;
+
+protected:
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related
+    // issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since 2.0
+    //
+    virtual void IWifiSystemMonitoringEventListener_Reserved1(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related
+    // issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since 2.0
+    //
+    virtual void IWifiSystemMonitoringEventListener_Reserved2(void) {}
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related
+    // issues in the application.
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since 2.0
+    //
+    virtual void IWifiSystemMonitoringEventListener_Reserved3(void) {}
+
+}; // IWifiSystemMonitoringEventListener
+
+} } } // Tizen::Net::Wifi
+#endif // _FNET_WIFI_IWIFI_SYSTEM_MONITORING_EVENT_LISTENER_H_
diff --git a/inc/FNetWifiWifiBssInfo.h b/inc/FNetWifiWifiBssInfo.h
new file mode 100644 (file)
index 0000000..ba999d8
--- /dev/null
@@ -0,0 +1,484 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifiWifiBssInfo.h
+ * @brief   This is the header file for the %WifiBssInfo class.
+ *
+ * This header file contains the declarations of the %WifiBssInfo class.
+ */
+#ifndef _FNET_WIFI_WIFI_BSS_INFO_H_
+#define _FNET_WIFI_WIFI_BSS_INFO_H_
+
+#include <FBaseObject.h>
+#include <FNetNetTypes.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Net
+{
+class IpAddress;
+} }
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class WifiSecurityInfo;
+class _WifiBssInfoImpl;
+
+/**
+ * @class   WifiBssInfo
+ * @brief   This class provides methods for managing the BSS information of a Wi-Fi network.
+ *
+ * @since   2.0
+ *
+ * The %WifiBssInfo class provides methods for managing the BSS information of a Wi-Fi network.
+ *
+ * For more information on the class features,
+ * see <a href="../org.tizen.native.appprogramming/html/guide/net/wi-fi_connectivity.htm">Wi-Fi Connectivity</a>.
+ */
+
+class _OSP_EXPORT_ WifiBssInfo
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since   2.0
+        */
+       WifiBssInfo(void);
+
+       /**
+        * Copying of objects using this copy constructor is allowed.
+        * @since   2.0
+        *
+        * @param[in]   value               An instance of %WifiBssInfo
+        */
+       WifiBssInfo(const WifiBssInfo& value);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        * @since       2.0
+        */
+       virtual ~WifiBssInfo(void);
+
+    /**
+     * Gets the SSID of this BSS.
+     *
+     * @since   2.0
+        *
+     * @return  The SSID
+     */
+    Tizen::Base::String GetSsid(void) const;
+
+    /**
+     * Gets the ID of this BSS.
+     *
+     * @since   2.0
+        *
+     * @return      The BSSID expressed as a 6 byte hexadecimal value delimited by dashes, @n
+     *              For example, "00-3D-47-EF-8A-03"
+     */
+    Tizen::Base::String GetBssId(void) const;
+
+    /**
+     * Gets the type of this BSS.
+     *
+     * @since   2.0
+        *
+     * @return      The type of this BSS
+     */
+    WifiBssType GetBssType(void) const;
+
+    /**
+     * Gets the radio channel of this BSS.
+     *
+     * @since   2.0
+        *
+     * @return      The radio channel of this BSS
+     */
+    WifiRadioChannel GetRadioChannel(void) const;
+
+    /**
+     * Gets the security information of this BSS.
+     *
+     * @since   2.0
+        *
+     * @return      The authentication and encryption type of this BSS
+     */
+    const WifiSecurityInfo* GetSecurityInfo(void) const;
+
+    /**
+     * Gets the Received Signal Strength Indication (RSSI) value of the BSS at the time of scanning.
+     *
+     * @since   2.0
+        *
+     * @return      The RSSI value in dBm
+     */
+    long GetRssi(void) const;
+
+    /**
+     * Gets the data rate of this BSS.
+     *
+     * @since       2.0
+        *
+     * @return      The data rate value (Mbps), @n
+     *              else @c -1.0 if the supported data rate is unknown
+     */
+    float GetDataRate(void) const;
+
+    /**
+     * Sets the SSID.
+     *
+     * @since 2.0
+     *
+     * @param[in] ssid The SSID
+     */
+    void SetSsid(const Tizen::Base::String& ssid);
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Checks whether an access point (BSS) is known or not. @n
+        * The access point becomes a known BSS if it has been connected with this device.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      @c true if the access point is known, @n
+     *              else @c false
+     * @see         SetUnknown()
+     * @endif
+     */
+    bool IsKnown(void) const;
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Sets the access point (BSS) unknown.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @see         IsKnown()
+     * @endif
+     */
+    void SetUnknown(void);
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Gets the local IP address scheme.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      The address scheme for the local IP address
+     * @endif
+     */
+    Tizen::Net::NetAddressScheme GetLocalAddressScheme(void) const;
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Sets the local IP address scheme. @n
+        * The %SetLocalAddressScheme() method allows determining whether to use static address or dynamic address.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @param[in]   scheme              The address scheme for the local IP address
+     * @endif
+     */
+    void SetLocalAddressScheme(Tizen::Net::NetAddressScheme scheme);
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Gets the local IP address in the static address scheme.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      The local address configured to this access point, @n
+     *              else @c null if an error occurs or there is no previously set address
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the address scheme for the IP address is @c NET_ADDRESS_SCHEME_DYNAMIC.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     * @see         SetLocalAddress()
+     * @endif
+     */
+    const Tizen::Net::IpAddress* GetLocalAddress(void) const;
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Sets the local IP address in the static address scheme.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      An error code
+     * @param[in]   pAddress            The new address to be assigned
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation.
+     *                                  For example, The address scheme for the IP address is NET_ADDRESS_SCHEME_DYNAMIC.
+     * @remarks     The existing local address is unset when the input argument is @c null.
+     * @see         GetLocalAddress()
+     * @endif
+     */
+    result SetLocalAddress(const Tizen::Net::IpAddress* pAddress);
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Gets the subnet mask address in the static address scheme.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      The subnet mask address configured to this access point, @n
+     *              else @c null if an error occurs or there is no previously set address
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the address scheme for the IP address is @c NET_ADDRESS_SCHEME_DYNAMIC.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     * @see         SetSubnetMaskAddress()
+     * @endif
+     */
+    const Tizen::Net::IpAddress* GetSubnetMaskAddress(void) const;
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Sets the subnet mask address in the static address scheme.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      An error code
+     * @param[in]   pAddress            The new address to assign
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the address scheme for the IP address is @c NET_ADDRESS_SCHEME_DYNAMIC.
+     * @remarks     The existing subnet mask address is unset when the input argument is @c null.
+     * @see         GetSubnetMaskAddress()
+     * @endif
+     */
+    result SetSubnetMaskAddress(const Tizen::Net::IpAddress* pAddress);
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Gets the default gateway address in the static address scheme.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      The default gateway address configured to this access point, @n
+     *              else @c null if an error occurs or there is no previously set address
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the address scheme for the IP address is NET_ADDRESS_SCHEME_DYNAMIC.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     * @see         SetDefaultGatewayAddress()
+     * @endif
+     */
+    const Tizen::Net::IpAddress* GetDefaultGatewayAddress(void) const;
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Sets the default gateway address in the static address scheme.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      An error code
+     * @param[in]   pAddress            The new address to assign
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the address scheme for the IP address is @c NET_ADDRESS_SCHEME_DYNAMIC.
+     * @remarks     The existing gateway address is unset when the input argument is @c null.
+     * @see         GetDefaultGatewayAddress()
+     * @endif
+     */
+    result SetDefaultGatewayAddress(const Tizen::Net::IpAddress* pAddress);
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Gets the primary DNS address in the static address scheme.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      The primary DNS address configured to this access point, @n
+     *              else @c null if an error occurs or there is no previously set address
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the address scheme for the IP address is @c NET_ADDRESS_SCHEME_DYNAMIC.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     * @see         SetPrimaryDnsAddress()
+     * @endif
+     */
+    const Tizen::Net::IpAddress* GetPrimaryDnsAddress(void) const;
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Sets the primary DNS address in the static address scheme.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      An error code
+     * @param[in]   pAddress            The new address to assign
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the address scheme for the IP address is @c NET_ADDRESS_SCHEME_DYNAMIC.
+     * @remarks     The existing primary DNS address is unset when the input argument is @c null.
+     * @see         GetPrimaryDnsAddress()
+     * @endif
+     */
+    result SetPrimaryDnsAddress(const Tizen::Net::IpAddress* pAddress);
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Gets the secondary DNS address in the static address scheme.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      The secondary DNS address configured to this access point, @n
+     *              else @c null if an error occurs or there is no previously set address
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the address scheme for the IP address is NET_ADDRESS_SCHEME_DYNAMIC.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     * @see         SetSecondaryDnsAddress()
+     * @endif
+     */
+    const Tizen::Net::IpAddress* GetSecondaryDnsAddress(void) const;
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Sets the secondary DNS address in the static address scheme.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      An error code
+     * @param[in]   pAddress            The new address to assign
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the address scheme for the IP address is @c NET_ADDRESS_SCHEME_DYNAMIC.
+     * @remarks     The existing secondary DNS address is unset when the input argument is @c null.
+     * @see         GetSecondaryDnsAddress()
+     * @endif
+     */
+    result SetSecondaryDnsAddress(const Tizen::Net::IpAddress* pAddress);
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Gets the proxy type.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      The proxy type
+     * @see         SetProxyType()
+     * @endif
+     */
+    Tizen::Net::NetProxyType GetProxyType(void) const;
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Sets the proxy type.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @param[in]   type                The proxy type
+     * @see         GetProxyType()
+     * @endif
+     */
+    void SetProxyType(Tizen::Net::NetProxyType type);
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Gets the proxy address.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      The proxy address, @n
+     *              else an empty string if an error occurs or there is no previously set address
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the specified input type is @c NET_PROXY_TYPE_NONE.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     * @see         SetProxyAddress()
+     * @endif
+     */
+    Tizen::Base::String GetProxyAddress(void) const;
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Sets the proxy address.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      An error code
+     * @param[in]   address             The proxy address
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation.
+     *                                  For example, The specified input type is NET_PROXY_TYPE_NONE.
+     * @remarks     The existing proxy address is unset when the input argument is an empty string.
+     * @see         GetProxyAddress()
+     * @endif
+     */
+    result SetProxyAddress(const Tizen::Base::String& address);
+
+    /**
+     * Checks whether the specified instance of %WifiBssInfo equals the current instance.
+     *
+     * @since   2.0
+        *
+     * @return       @c true if the specified instance equals the current instance, @n
+     *               else @c false
+     * @param[in]    obj An instance of %WifiBssInfo
+     * @remarks      The method returns @c false if the specified object is not %WifiBssInfo.
+     */
+    virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+    /**
+     * Gets the hash value of the current instance.
+     *
+     * @since   2.0
+     *
+     * @return      The hash value of the current instance
+     */
+    virtual int GetHashCode(void) const;
+
+    /**
+     * Assigns the value of the specified instance to the current instance of %WifiBssInfo.
+     *
+     * @since   2.0
+     *
+     * @return      The reference of this instance
+     * @param[in]   rhs                 An instance of %WifiBssInfo
+     */
+    WifiBssInfo& operator=(const WifiBssInfo& rhs);
+
+private:
+    _WifiBssInfoImpl *__pWifiBssInfoImpl;
+
+friend class _WifiBssInfoImpl;
+}; // WifiBssInfo
+
+} } } //Tizen::Net::Wifi
+#endif // _FNET_WIFI_WIFI_BSS_INFO_H_
diff --git a/inc/FNetWifiWifiDirectDevice.h b/inc/FNetWifiWifiDirectDevice.h
new file mode 100755 (executable)
index 0000000..b8f8915
--- /dev/null
@@ -0,0 +1,678 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNetWifiWifiDirectDevice.h
+ * @brief      This is the header file for the %WifiDirectDevice class.
+ *
+ * This header file contains the declarations of the %WifiDirectDevice class.
+ */
+#ifndef _FNET_WIFI_WIFI_DIRECT_DEVICE_H_
+#define _FNET_WIFI_WIFI_DIRECT_DEVICE_H_
+
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class _WifiDirectDeviceImpl;
+class IWifiDirectDeviceListener;
+class IWifiDirectGroupOwnerListener;
+class IWifiDirectGroupClientListener;
+class WifiDirectGroupInfo;
+class WifiDirectDeviceInfo;
+class WifiDirectGroupMember;
+
+/**
+ * @class   WifiDirectDevice
+ * @brief   This class provides methods for the Wi-Fi Direct device.
+ *
+ * @since   2.0
+ *
+ * The %WifiDirectDevice class provides methods to manage the Wi-Fi Direct device, create a Wi-Fi Direct group,
+ * scan Wi-Fi Direct devices, associate a Wi-Fi Direct group owner, create a WifiDirectGroupMember instance,
+ * and allow the listener to get events related to a Wi-Fi Direct device and group.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/wi-fi_direct_connectivity.htm">Wi-Fi Direct Connectivity</a>.
+ */
+
+class _OSP_EXPORT_ WifiDirectDevice
+       : public Tizen::Base::Object
+{
+public:
+    /**
+     *
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     * @since   2.0
+     */
+    virtual ~WifiDirectDevice(void);
+
+    /**
+     * Adds a listener for Wi-Fi Direct device.
+     *
+     * @since   2.0
+     *
+     * @return      An error code
+     * @param[in]   listener        A reference to the listener instance
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @exception   E_OUT_OF_MEMORY The memory is insufficient.
+     * @exception   E_OBJ_ALREADY_EXIST The listener is already added.
+     */
+    result AddWifiDirectDeviceListener(IWifiDirectDeviceListener& listener);
+
+    /**
+     * @if OSPDEPREC
+     * Adds a listener for the Wi-Fi Direct group owner.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  %WifiDirectGroupOwner class is deprecated, therefore, this method also is deprecated. @n
+        *       Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @param[in]   listener        A reference to the IWifiDirectGroupOwnerListener instance
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @exception   E_OUT_OF_MEMORY The memory is insufficient.
+     * @exception   E_OBJ_ALREADY_EXIST The listener is already added.
+     * @endif
+     */
+    result AddWifiDirectGroupOwnerListener(IWifiDirectGroupOwnerListener& listener);
+
+    /**
+     * @if OSPDEPREC
+     * Adds a listener for the Wi-Fi Direct group client.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  %WifiDirectGroupClient class is deprecated, therefore, this method also is deprecated. @n
+        * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @param[in]   listener        A reference to the IWifiDirectGroupClientListener instance
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @exception   E_OUT_OF_MEMORY The memory is insufficient.
+     * @exception   E_OBJ_ALREADY_EXIST The listener is already added.
+     * @endif
+     */
+    result AddWifiDirectGroupClientListener(IWifiDirectGroupClientListener& listener);
+
+    /**
+     * Removes a listener for the Wi-Fi Direct device.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @param[in]   listener        A reference to the IWifiDirectDeviceListener instance
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @exception   E_OBJ_NOT_FOUND The specified object is not found within the indicated range.
+     */
+    result RemoveWifiDirectDeviceListener(IWifiDirectDeviceListener& listener);
+
+    /**
+     * @if OSPDEPREC
+     * Removes a listener for the Wi-Fi Direct group owner.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  %WifiDirectGroupOwner class is deprecated, therefore, this method also is deprecated. @n
+     *               Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     * @since 2.0
+     *
+     * @return      An error code
+     * @param[in]   listener        A reference to the IWifiDirectGroupOwnerListener instance
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @exception   E_OBJ_NOT_FOUND The specified object is not found within the indicated range.
+     * @endif
+     */
+    result RemoveWifiDirectGroupOwnerListener(IWifiDirectGroupOwnerListener& listener);
+
+    /**
+     * @if OSPDEPREC
+     * Removes a listener for the Wi-Fi Direct group client.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  %WifiDirectGroupClient class is deprecated, therefore, this method also is deprecated. @n
+     * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     *
+        * @since 2.0
+     *
+     * @return      An error code
+     * @param[in]   listener        A reference to the IWifiDirectGroupClientListener instance
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @exception   E_OBJ_NOT_FOUND The specified object is not found within the indicated range.
+     * @endif
+     */
+    result RemoveWifiDirectGroupClientListener(IWifiDirectGroupClientListener& listener);
+
+    /**
+     * Activates the local Wi-Fi device by using the Wi-Fi Direct enabled.
+     *
+     * @since   2.0
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.admin
+     *
+     * @return  An error code
+     * @exception   E_SUCCESS           The activation is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_IN_PROGRESS       The activate process is in progress.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the Wi-Fi Direct device is already activated.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @see IWifiDirectDeviceListener::OnWifiDirectDeviceActivated()
+     */
+    result Activate(void);
+
+    /**
+     * Checks whether the local device is activated.
+     *
+     * @since 2.0
+     *
+     * @return  @c true if the local device is activated, @n
+     *          else @c false
+     * @exception   E_SUCCESS       The hidden mode is set successfully.
+     * @exception   E_SYSTEM        A system error has occurred.
+     */
+    bool IsActivated(void) const;
+
+    /**
+     * Deactivates the local Wi-Fi device.
+     *
+     * @since 2.0
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.admin
+     *
+     * @return  An error code
+     * @exception   E_SUCCESS           The deactivation is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_IN_PROGRESS       The deactivate process is in progress.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the Wi-Fi Direct device is already deactivated.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     *
+     * @see IWifiDirectDeviceListener::OnWifiDirectDeviceDeactivated()
+     */
+    result Deactivate(void);
+
+    /**
+     * Gets the current setting information of a Wi-Fi Direct group.
+     *
+     * @since 2.0
+     *
+     * @return      The Wi-Fi Direct group information if successful, @n
+     *              else @c null
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     */
+    WifiDirectGroupInfo* GetGroupSettingInfoN(void) const;
+
+    /**
+     * Gets the current setting information of a Wi-Fi Direct device.
+     *
+     * @since 2.0
+     *
+     * @return      The Wi-Fi Direct device information if successful, @n
+     *              else @c null
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @exception   E_OUT_OF_MEMORY The memory is insufficient.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     */
+    WifiDirectDeviceInfo* GetLocalDeviceInfoN(void) const;
+
+    /**
+     * Gets the preferred method for the Wi-Fi Protected Setup (WPS) configuration.
+     *
+     * @since 2.0
+     *
+     * @return      The preferred configuration mode for WPS
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     *              @c WIFI_WPS_CONFIG_MODE_NONE will be returned in case of the E_SYSTEM exception.
+     */
+    WifiWpsConfigurationMode GetWpsConfigurationModePreference(void) const;
+
+    /**
+     * Sets the name of a local device.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @param[in]   name                The name for a local device
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_INVALID_ARG       The specified device name is an empty string.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the Wi-Fi Direct device is already activated.
+     * @remarks     This method does not affect the system setting and the device name is only valid during the
+     *              group lifetime. @n
+     *              When an application in the deactivated state calls this method, the peer devices
+     *              detect the device specified in the @c name parameter.
+     *              For example, use this method before using Activate(). @n
+     *              The specified device name is automatically truncated if its size is greater than @c 64 bytes.
+     */
+    result SetLocalDeviceName(const Tizen::Base::String& name);
+
+    /**
+    * Sets the preferred method for the WPS configuration.
+    *
+    * @since 2.0
+    *
+    * @return           An error code
+    * @param[in] mode   The preferred mode for the WPS configuration
+    * @exception E_SUCCESS              The method is successful.
+    * @exception E_SYSTEM               A system error has occurred.
+    * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+    *                                For example, the Wi-Fi Direct device is a group member.
+    * @remarks   The preferred configuration mode of the system is the PIN-DISPLAY method. @n
+    *            This method can change the preferred configuration method for the WPS procedure.
+    *            If the remote device does not support the specified configuration method,
+    *            the common configuration method is selected between the two devices automatically.
+    *            Therefore, this method does not guarantee the use of specified WPS configuration method. @n
+    *            Before calling Connect() method, the user preferred WPS configuration mode should be specified using the SetWpsConfigurationModePreference() method.
+    */
+    result SetWpsConfigurationModePreference(WifiWpsConfigurationMode mode);
+
+    /**
+     * @if OSPDEPREC
+     * Creates a Wi-Fi Direct group by negotiating with the specified Wi-Fi Direct device for the group owner.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  This method is deprecated because the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role (for example, group owner, group client, and so on). @n
+     * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role and so it was necessary to use these APIs.
+     *              Instead of using this API, use Connect() or CreateAutonomousGroup() API.
+     *
+     * @since 2.0
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.admin
+     *
+     * @return      An error code
+     * @param[in]   pWifiDirectGroupInfo        The pointer of a WiFiDirectGroupInfo
+     * @param[in]   pWifiDirectRemoteDeviceInfo The pointer of a WiFiDirectDeviceInfo
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_IN_PROGRESS       A previous request is in progress.
+     * @exception   E_INVALID_ARG       The specified @c pWifiDirectRemoteDeviceInfo contains an invalid argument.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the Wi-Fi Direct group is already created.
+     * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @remarks It is not mandatory for this method to contain values in both the parameters. @n
+     * If @c pWifiDirectGroupInfo is specified and the group is created with the specified group configuration information,
+     * this group configuration information is valid until the group is destroyed.
+     * If @c pWifiDirectGroupInfo is not specified, the Wi-Fi Direct group is created as per the default system configuration settings. @n
+     * If @c pWifiDirectRemoteDeviceInfo is not specified, the Wi-Fi Direct group is created with the
+     * first found device having the same local device name.
+     * Use SetLocalDeviceName() method to set the device name before activation. @n
+     * To obtain a list of Wi-Fi Direct devices which can be candidates for the @c pWifiDirectRemoteDeviceInfo
+     * parameter, use the Scan() method prior using this method.
+     * To connect a specified Wi-Fi Direct group owner directly, the Scan() and Associate() methods can be used. @n
+     * Before this method is called, the event listeners should be added in order to ensure the completion of
+     * group creation and to process the request as a group owner or client. @n
+     * If the autonomous group owner mode is set to @c true in the specified @c pWifiDirectGroupInfo parameter,
+     * @c pWifiDirectRemoteDeviceInfo should be set to @c null and IWifiDirectGroupClientListener would not be required.
+     * @see IWifiDirectDeviceListener::OnWifiDirectGroupCreatedN()
+     * @endif
+     */
+    result CreateGroup(const WifiDirectGroupInfo* pWifiDirectGroupInfo = null, const WifiDirectDeviceInfo* pWifiDirectRemoteDeviceInfo = null);
+
+    /**
+     * @if OSPDEPREC
+     * Cancels Wi-Fi Direct group creation.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  This method is deprecated because the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role (for example, group owner, group client, and so on). @n
+     * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role and so it was necessary to use these APIs. @n
+     *              Instead of using this API, use CancelConnect() API
+     *
+     * @since 2.0
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.admin
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_IN_PROGRESS       A previous request is in progress.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, when there is no group being created.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @see    CreateGroup()
+        * @see IWifiDirectDeviceListener::OnWifiDirectGroupCreatedN()
+        * @endif
+     */
+    result CancelGroupCreation(void);
+
+    /**
+     * Scans Wi-Fi Direct Devices which are in the specified type.
+     *
+     * @since 2.0
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.read
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_IN_PROGRESS       A previous request is in progress.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the Wi-Fi Direct device is deactivated.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @remarks     This operation does not work while the Wi-Fi connection to the AP is in progress or established.
+     * @see         IWifiDirectDeviceListener::OnWifiDirectScanCompletedN()
+     */
+    result Scan(void);
+
+    /**
+     * Cancels the Wi-Fi Direct previous scan operation.
+     *
+     * @since 2.0
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.read
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_IN_PROGRESS       A previous request is in progress.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the scan operation is not in process.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @see         IWifiDirectDeviceListener::OnWifiDirectScanCompletedN()
+     */
+    result CancelScan(void);
+
+    /**
+     * @if OSPDEPREC
+     * Establishes a connection with a specific group owner.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  This method is deprecated because the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role (for example, group owner, group client, and so on). @n
+     * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role and so it was necessary to use these APIs. @n
+     *              Instead of using this API, use Connect() API
+     *
+     * @since 2.0
+     * @privilege    %http://tizen.org/privilege/wifi.wifidirect.admin
+     *
+     * @return       An error code
+     * @param[in]    wifiDirectGroupOwnerDeviceInfo    The WifiDirectDeviceInfo value of a group owner
+     * @exception    E_SUCCESS           The method is successful.
+     * @exception    E_SYSTEM            A system error has occurred.
+     * @exception    E_IN_PROGRESS       A previous request or group creation is in progress.
+     * @exception    E_INVALID_ARG       The specified @c wifiDirectGroupOwnerDeviceInfo contains an invalid argument.
+     * @exception    E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                   For example, the member type of a device is already a group owner or client.
+     * @exception    E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @remarks      If a connection is already established with other device, the previous connection should be disconnected
+     *               before using this method.
+     * @see          IWifiDirectDeviceListener::OnWifiDirectAssociationCompleted()
+     * @endif
+     */
+    result Associate(const WifiDirectDeviceInfo& wifiDirectGroupOwnerDeviceInfo);
+
+    /**
+     * @if OSPDEPREC
+     * Gets the Wi-Fi Direct member instance.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  This method is deprecated because the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role (for example, group owner, group client, and so on). @n
+     * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role and so it was necessary to use these APIs.
+     *
+     * @since 2.0
+     *
+     * @return      The Wi-Fi Direct member instance if successful, @n
+     *              else @c null if the status of device is @c WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the member type of a device is not a group owner or client.
+     * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     * @endif
+     */
+    WifiDirectGroupMember* GetWifiDirectMemberN(void) const;
+
+    /**
+     * Checks whether the local Wi-Fi Direct device is currently discoverable.
+     *
+     * @since 2.0
+     *
+     * @return      @c true if the local Wi-Fi Direct device is currently discoverable, @n
+     *              else @c false
+     * @remarks     At times, even though the Wi-Fi Direct device is activated the device cannot be discovered due to the visibility
+     *                         setting, or if the device is performing some operation, such as Wi-Fi scanning.
+     */
+    bool IsDiscoverable(void) const;
+
+    /**
+     * Connects to the Wi-Fi Direct connection with the specified peer device.
+     *
+     * @since 2.0
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.admin
+     *
+     * @return  An error code
+     * @param[in]   remoteDeviceInfo  The remote peer device to connect.
+     * @exception   E_SUCCESS               The method is successful.
+     * @exception   E_SYSTEM                A system error has occurred.
+     * @exception   E_IN_PROGRESS           The previous request is in progress.
+     * @exception   E_INVALID_ARG           The specified @c remoteDeviceInfo is invalid.
+     * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of this operation. @n
+     *                                      For example, the local device is already connected except in the case of group owner.
+     * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+     *
+     * @remarks   If the local device does not belong to a group owner or client, a group negotiation request is sent to the remote device and the configured group information is used at this time. @n
+     *            If the local device is a group owner, a request to join the group is sent to the remote device.
+     *
+     * @see IWifiDirectDeviceListener::OnWifiDirectConnected()
+     * @see SetGroupSettingInfo()
+     * @see SetWpsConfigurationModePreference()
+     */
+    result Connect(const WifiDirectDeviceInfo& remoteDeviceInfo);
+
+    /**
+     * Cancels the request for Wi-Fi Direct connection.
+     *
+     * @since 2.0
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.admin
+     *
+     * @return  An error code
+     * @exception   E_SUCCESS               The method is successful.
+     * @exception   E_SYSTEM                A system error has occurred.
+     * @exception   E_IN_PROGRESS           The previous request is in progress.
+     * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of this operation. @n
+     *                                      For example, the local device is not connecting.
+     * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+     *
+     * @see IWifiDirectDeviceListener::OnWifiDirectConnected()
+     */
+    result CancelConnect(void);
+
+    /**
+     * Creates a Wi-Fi Direct group as the group owner.
+     *
+     * @since 2.0
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.admin
+     *
+     * @return  An error code
+     * @exception   E_SUCCESS               The method is successful.
+     * @exception   E_SYSTEM                A system error has occurred.
+     * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of this operation. @n
+     *                                 For example, the local device is already deactivated or connected.
+     * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+     *
+     * @see IWifiDirectDeviceListener::OnWifiDirectAutonomousGroupCreated()
+     *
+     */
+    result CreateAutonomousGroup(void);
+
+    /**
+     * Sets the configuration information of a Wi-Fi Direct group.
+     *
+     * @since 2.0
+     *
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.admin
+     *
+     * @return  An error code
+     * @param[in]   groupSettingInfo   The group setting information
+     * @exception   E_SUCCESS               The method is successful.
+     * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of this operation. @n
+     *                                      For example, the local device is already deactivated or connected.
+     * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+     *
+     * @remarks This method should be called before using Connect() to configure the group information.
+     */
+    result SetGroupSettingInfo(const WifiDirectGroupInfo& groupSettingInfo);
+
+    /**
+     * Disconnects the specified peer device.
+     *
+     * @since 2.0
+     *
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.admin
+     *
+     * @return  An error code
+     * @param[in]   peerDeviceInfo      The peer device to disconnect
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_IN_PROGRESS       The previous request is in progress.
+     * @exception   E_INVALID_ARG       The specified @c remoteDeviceInfo is invalid.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the local device is not connected.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     *
+     * @see IWifiDirectDeviceListener::OnWifiDirectDisconnected()
+     */
+    result Disconnect(const WifiDirectDeviceInfo& peerDeviceInfo);
+
+    /**
+     * Leaves the currently participating Wi-Fi Direct group.
+     *
+     * @since 2.0
+     *
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.admin
+     *
+     * @return  An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_IN_PROGRESS       The previous request is in progress.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the local device is not a group owner or client.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     *
+     * @see IWifiDirectDeviceListener::OnWifiDirectGroupLeft()
+     * @remarks If the local device belongs to a group owner, the group will be destroyed and the IWifiDirectDeviceListener::OnWifiDirectDisconnected() event method will not occur for each client connection.
+     */
+    result LeaveGroup(void);
+
+
+    /**
+     * Gets information of the group owner of a Wi-Fi Direct group.
+     *
+     * @since 2.0
+     *
+     * @return    The Wi-Fi Direct group owner information if successful, @n
+     *           else null
+     * @exception E_SUCCESS           The method is successful.
+     * @exception E_SYSTEM            A system error has occurred.
+     * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                For example, the local device is not connected.
+     * @remarks The specific error code can be accessed using the GetLastResult() method
+     */
+    WifiDirectDeviceInfo* GetGroupOwnerInfoN(void) const;
+
+    /**
+     * Gets the list of the Wi-Fi Direct group clients.
+     *
+     * @since 2.0
+     *
+     * @return   A pointer to the list that contains the WifiDirectDeviceInfo instances of the group clients if successful, @n
+     *           else @c null
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, the local device is not a group owner.
+     */
+    Tizen::Base::Collection::IList* GetGroupClientInfoListN(void) const;
+
+    /**
+     * Gets the index of a currently working channel.
+     *
+     * @since 2.0
+     *
+     * @return  The Wi-Fi radio channel
+     *
+     * @remarks If the member type of the local device is not a group owner or client, the channel does not contain valid information.
+     */
+    WifiRadioChannel GetOperatingChannel(void) const;
+
+private:
+    /**
+     *
+     * This default constructor is intentionally declared as private so that only the platform can create an instance.
+     * @remarks     After creating an instance of this class, the Construct() method must be called explicitly
+     *              to initialize this instance.
+     * @see         Construct()
+     */
+    WifiDirectDevice(void);
+
+    /**
+     * This copy constructor is intentionally declared as private to prohibit copying of objects by users.
+     *
+     * @param[in]   value   An instance of %WifiDirectDevice
+     */
+    WifiDirectDevice(const WifiDirectDevice& value);
+
+    /**
+     * Initializes this instance of %WifiDirectDevice.
+     *
+     * @return      An error code
+     * @param[in]   localDeviceId   An ID for a Wi-Fi Direct device
+     *
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @exception   E_OUT_OF_MEMORY The memory is insufficient.
+     * @exception   E_INVALID_ARG   The specified @c localDeviceId is invalid.
+     */
+    result Construct(WifiDirectDeviceId localDeviceId);
+
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to
+     * prohibit copying of objects.
+     *
+     * @param[in]   rhs An instance of %WifiDirectDevice
+     */
+    WifiDirectDevice& operator =(const WifiDirectDevice& rhs);
+
+private:
+    _WifiDirectDeviceImpl* __pWifiDirectDeviceImpl;
+
+    friend class _WifiDirectDeviceImpl;
+}; // WifiDirectDevice
+
+} } } // Tizen::Net::Wifi
+#endif // _FNET_WIFI_WIFI_DIRECT_DEVICE_H_
diff --git a/inc/FNetWifiWifiDirectDeviceInfo.h b/inc/FNetWifiWifiDirectDeviceInfo.h
new file mode 100644 (file)
index 0000000..d56db90
--- /dev/null
@@ -0,0 +1,220 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifiWifiDirectDeviceInfo.h
+ * @brief   This is the header file for the %WifiDirectDeviceInfo class.
+ *
+ * This header file contains the declarations of the %WifiDirectDeviceInfo class.
+ */
+#ifndef _FNET_WIFI_WIFI_DIRECT_DEVICE_INFO_H_
+#define _FNET_WIFI_WIFI_DIRECT_DEVICE_INFO_H_
+
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+template<class type>
+class IListT;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net
+{
+class IpAddress;
+} } // Tizen::Net
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class _WifiDirectDeviceInfoImpl;
+
+/**
+ * @class   WifiDirectDeviceInfo
+ * @brief   This class provides methods for the Wi-Fi Direct device information.
+ *
+ * @since   2.0
+ *
+ * The %WifiDirectDeviceInfo class provides methods for getting information related to a Wi-Fi Direct device.
+ */
+class _OSP_EXPORT_ WifiDirectDeviceInfo
+       : public Tizen::Base::Object
+{
+public:
+    /**
+     * This is the default constructor for this class.
+     *
+     * @since 2.0
+     */
+    WifiDirectDeviceInfo(void);
+
+    /**
+     * Copying of objects using this copy constructor is allowed.
+     *
+     * @since 2.0
+     *
+     * @param[in]   value   An instance of %WifiDirectDeviceInfo
+     */
+    WifiDirectDeviceInfo(const WifiDirectDeviceInfo& value);
+
+    /**
+     * Initializes this instance of %WifiDirectDeviceInfo with the specified device name
+     * and the MAC address.
+     *
+     * @since 2.0
+        *
+     * @param[in]   deviceName  The device name @n
+     *                          The length of @c deviceName must not exceed 64 characters.
+     * @param[in]   macAddr     The MAC address @n
+     *                          The value of @c macAddr must be in the form '00-00-00-00-00-00'.
+     *
+     */
+    WifiDirectDeviceInfo(const Tizen::Base::String& deviceName, const Tizen::Base::String& macAddr);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     * 
+     * @since 2.0
+     */
+    virtual ~WifiDirectDeviceInfo(void);
+
+    /**
+     * Gets the ID of the device.
+     *
+     * @since       2.0
+        *
+     * @return      The ID of the Wi-Fi Direct device
+     * @remarks     This value is only available for local device information query, such as WifiDirectDeviceManager::GetAllDeviceInfoN() or WifiDirectDevice::GetLocalDeviceInfoN(). @n
+     *              When the value is not available, the return value is @c -1.
+     */
+    WifiDirectDeviceId GetDeviceId(void) const;
+
+    /**
+     * Gets the device name.
+     *
+     * @since       2.0
+        *
+     * @return      The device name
+     */
+    Tizen::Base::String GetDeviceName(void) const;
+
+    /**
+     * Gets the MAC address of the device.
+     *
+     * @since       2.0
+        *
+     * @return      The MAC address in the form '00-00-00-00-00-00'
+     * @remarks     This MAC address is different from the MAC address provided by the WifiManager or DhcpClientInfo class.
+     *              Especially, the MAC address which is provided in DhcpClientInfo is a virtual MAC address for data communication during a Wi-Fi Direct group member.
+     */
+    Tizen::Base::String GetMacAddress(void) const;
+
+    /**
+     * Gets the IP address of the device.
+     *
+     * @since       2.0
+        *
+     * @return      An IpAddress pointer to the local address in the calling instance
+     * @remarks     The IP address is provided only using WifiDirectDevice::GetGroupOwnerInfoN(), WifiDirectDevice::GetGroupClientInfoListN(),
+     *              or WifiDirectDevice::GetLocalDeviceInfoN() after becoming a group member.
+     */
+    const Tizen::Net::IpAddress* GetIpAddress(void) const;
+
+    /**
+     * Gets the SSID.
+     *
+     * @since       2.0
+        *
+     * @return      The SSID
+     * @remarks     This method returns an empty string if the member type of a device is not a Wi-Fi Direct group owner or client.
+     */
+    Tizen::Base::String GetSsid(void) const;
+
+    /**
+     * Gets the status of the device.
+     *
+     * @since       2.0
+        *
+     * @return      The status of the Wi-Fi Direct device
+     */
+    WifiDirectDeviceStatus GetDeviceStatus(void) const;
+
+    /**
+     * Gets the member type of the Wi-Fi Direct device.
+     *
+     * @since       2.0
+        *
+     * @return      The member type of the Wi-Fi Direct device
+     */
+    WifiDirectGroupMemberType GetGroupMemberType(void) const;
+
+    /**
+     * Gets the category of the Wi-Fi Direct device type.
+     *
+     * @since       2.0
+        *
+     * @return      The category of the Wi-Fi Direct device type
+     */
+    WifiDirectDeviceTypeCategory GetDeviceTypeCategory(void) const;
+
+    /**
+     * Gets the list of supporting WPS configuration modes.
+     *
+     * @since       2.0
+        *
+     * @return      The list of supporting WPS configuration modes
+     * @remarks     The result of this method is available only using WifiDirectDevice::Scan() or WifiDirectDevice::GetLocalDeviceInfoN().
+     */
+    const Tizen::Base::Collection::IListT <WifiWpsConfigurationMode>* GetSupportedWpsConfigurationModeList(void) const;
+
+    /**
+     * Checks whether the specified instance of %WifiDirectDeviceInfo equals the current instance.
+     *
+     * @since         2.0
+        *
+     * @return        @c true if the specified instance equals the current instance, @n
+     *                   else @c false
+     * @param[in]    obj       An instance of %WifiDirectDeviceInfo
+     * @remarks      This method returns @c false if the specified object is not %WifiDirectDeviceInfo.
+     */
+    virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+    /**
+     * Gets the hash value of the current instance.
+     *
+     * @since       2.0
+     *
+     * @return      The hash value of the current instance
+     */
+    virtual int GetHashCode(void) const;
+
+    /**
+     * Assigns the value of the specified instance to the current instance of %WifiDirectDeviceInfo.
+     *
+     * @since        2.0
+     *
+     * @return       A reference to this instance
+     * @param[in]    rhs     An instance of %WifiDirectDeviceInfo
+     */
+    WifiDirectDeviceInfo& operator =(const WifiDirectDeviceInfo& rhs);
+
+private :
+    _WifiDirectDeviceInfoImpl* __pWifiDirectDeviceInfoImpl;
+
+    friend class _WifiDirectDeviceInfoImpl;
+}; // WifiDirectDeviceInfo
+
+} } } // Tizen::Net::Wifi
+#endif // _FNET_WIFI_WIFI_DIRECT_DEVICE_INFO_H_
diff --git a/inc/FNetWifiWifiDirectDeviceManager.h b/inc/FNetWifiWifiDirectDeviceManager.h
new file mode 100644 (file)
index 0000000..02d9864
--- /dev/null
@@ -0,0 +1,128 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifiWifiDirectDeviceManager.h
+ * @brief   This is the header file for the %WifiDirectDeviceManager class.
+ *
+ * This header file contains the declarations of the %WifiDirectDeviceManager class.
+ */
+#ifndef _FNET_WIFI_WIFI_DIRECT_DEVICE_MANAGER_H_
+#define _FNET_WIFI_WIFI_DIRECT_DEVICE_MANAGER_H_
+
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class _WifiDirectDeviceManagerImpl;
+class WifiDirectDevice;
+class WifiDirectDeviceInfo;
+
+/**
+ * @class  WifiDirectDeviceManager
+ * @brief  This class provides methods for the Wi-Fi Direct device management.
+ *
+ * @since 2.0
+ *
+ * The %WifiDirectDeviceManager class provides methods for creating a WifiDirectDevice instance and
+ * managing the Wi-Fi Direct devices.
+ */
+
+class _OSP_EXPORT_ WifiDirectDeviceManager
+       : public Tizen::Base::Object
+{
+public:
+    /**
+     * This is the default constructor for this class.
+     *
+     * @since 2.0
+     */
+    WifiDirectDeviceManager(void);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     * @since 2.0
+     */
+    virtual ~WifiDirectDeviceManager(void);
+
+    /**
+     * Gets a list of all the devices and also their information provided by the system.
+     *
+     * @since 2.0
+     *
+     * @return      An IList containing WifiDirectDeviceInfo of local devices in the system if successful, @n
+     *              else @c null
+     * @exception   E_SUCCESS               The method is successful.
+     * @exception   E_SYSTEM                An internal error has occurred.
+     * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+     * @exception   E_UNSUPPORTED_OPERATION There is no WifiDirectDeviceInfo available since the device does not support the Wi-Fi Direct feature.
+     * @remarks Currently, a single WifiDirectDeviceInfo instance is returned because the concurrent mode is not supported.
+     *          The specific error code can be accessed using the GetLastResult() method.
+     */
+    static Tizen::Base::Collection::IList* GetAllDeviceInfoN(void);
+
+    /**
+     * Gets an instance of WifiDirectDevice.
+     *
+     * @since 2.0
+     *
+     * @return      An instance of WifiDirectDevice if successful, @n
+     *              else @c null
+     * @param[in]   pLocalDeviceInfo    A pointer of WifiDirectDeviceInfo
+     * @exception   E_SUCCESS               The method is successful.
+     * @exception   E_SYSTEM                An internal error has occurred.
+     * @exception   E_INVALID_ARG           The specified input parameter is invalid.
+     * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+     * @exception   E_UNSUPPORTED_OPERATION The device does not support the Wi-Fi Direct feature.
+     * @remarks If the value of @c pLocalDeviceInfo is @c null, the WifiDirectDevice instance is created for the system default
+     *          device.
+     *          Otherwise, the value of @c pLocalDeviceInfo should be one of the elements obtained from WifiDirectDeviceManager::GetAllDeviceInfoN() to
+     *          create a valid %WifiDirectDevice instance.
+     *          The specific error code can be accessed using the GetLastResult() method.
+     */
+    static WifiDirectDevice* GetWifiDirectDeviceN(const WifiDirectDeviceInfo* pLocalDeviceInfo = null);
+
+private:
+    /**
+    * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+    *
+    * @param[in]   value   An instance of %WifiDirectDeviceManager
+    */
+    WifiDirectDeviceManager(const WifiDirectDeviceManager& value);
+
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit 
+     * copying of objects.
+     *
+     * @param[in]   rhs An instance of %WifiDirectDeviceManager
+     */
+    WifiDirectDeviceManager& operator =(const WifiDirectDeviceManager& rhs);
+
+private:
+    _WifiDirectDeviceManagerImpl* __pWifiDirectDeviceManagerImpl;
+
+    friend class _WifiDirectDeviceManagerImpl;
+}; // WifiDirectDeviceManager
+
+} } } // Tizen::Net::Wifi
+#endif // _FNET_WIFI_WIFI_DIRECT_DEVICE_MANAGER_H_
diff --git a/inc/FNetWifiWifiDirectGroupClient.h b/inc/FNetWifiWifiDirectGroupClient.h
new file mode 100755 (executable)
index 0000000..2746601
--- /dev/null
@@ -0,0 +1,197 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifiWifiDirectGroupClient.h
+ * @brief   This is the header file for the %WifiDirectGroupClient class.
+ *
+ * This header file contains the declarations of the %WifiDirectGroupClient class.
+ */
+#ifndef _FNET_WIFI_WIFI_DIRECT_GROUP_CLIENT_H_
+#define _FNET_WIFI_WIFI_DIRECT_GROUP_CLIENT_H_
+
+#include <FNetWifiWifiDirectGroupMember.h>
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class _WifiDirectGroupClientImpl;
+
+/**
+ * @if OSPDEPREC
+ * @class   WifiDirectGroupClient
+ * @brief   <i> [Deprecated] </i> This class provides methods for the Wi-Fi Direct group client management.
+ * @deprecated   This method is deprecated because the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role (for example, group owner, group client, and so on). @n
+     * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role and so it was necessary to use these APIs.
+ * As the APIs have been integrated into WifiDirectDevice class, use WifiDirectDevice class instead.
+ *
+ * @since   2.0
+ *
+ * The %WifiDirectGroupClient class provides methods to manage the Wi-Fi Direct client.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/wi-fi_direct_connectivity.htm">Wi-Fi Direct Connectivity</a>.
+ * @endif
+ */
+
+class _OSP_EXPORT_ WifiDirectGroupClient
+       : public WifiDirectGroupMember
+{
+public:
+    /**
+     * @if OSPDEPREC
+     * This is the destructor for this class.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  %WifiDirectGroupClient class is deprecated, therefore, this method is also deprecated. @n
+        * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     *
+     * @since 2.0
+     * @endif
+     */
+    virtual ~WifiDirectGroupClient(void);
+
+    /**
+     * @if OSPDEPREC
+     * Closes the connection.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  %WifiDirectGroupClient class is deprecated. Therefore, this method is also deprecated, because previously the Wi-Fi Direct APIs were provided centered on the role(e.g. group owner, group client) @n
+     *              so it was necessary to use APIs in accordance with the strict role; however, it has been revised to allow using APIs with ease without discerning the role. @n
+     *              it is integrated into WifiDirectDevice class. use WifiDirectDevice::Disconnect() API.
+     *
+     * @since 2.0
+     *
+     * @privilege    %http://tizen.org/privilege/wifi.wifidirect.admin
+     *
+     * @return       An error code
+     * @exception    E_SUCCESS               The method is successful.
+     * @exception    E_SYSTEM                A system error has occurred.
+     * @exception    E_IN_PROGRESS           A previous request is in progress.
+     * @exception    E_INVALID_OPERATION     The current state of the instance prohibits the execution of this operation. @n
+     *                                       For example, when the member type of a device is not a Wi-Fi Direct group client.
+     * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+     * @see          IWifiDirectGroupClientListener::OnWifiDirectAssociationTerminated()
+     * @endif
+     */
+    result Disassociate(void);
+
+    /**
+     * @if OSPDEPREC
+     * Requests the WifiDirectDeviceInfo of the Wi-Fi Direct group owner.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  %WifiDirectGroupClient class is deprecated. Therefore, this method is also deprecated, because previously the Wi-Fi Direct APIs were provided centered on the role(e.g. group owner, group client) @n
+     *              so it was necessary to use APIs in accordance with the strict role; however, it has been revised to allow using APIs with ease without discerning the role. @n
+     *              Instead of using this API, WifiDirectDevice::GetGroupOwnerInfoN() API.
+     *
+     * @since 2.0
+     *
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.read, %http://tizen.org/privilege/network.connection and %http://tizen.org/privilege/socket @n
+     *              All the above privileges are required
+     *
+     * @return       An error code
+     * @param[in]    portNumber              A port number to connect to the group member information service
+     * @exception    E_SUCCESS               The method is successful.
+     * @exception    E_SYSTEM                A system error has occurred.
+     * @exception    E_IN_PROGRESS           The previous request for the group owner information is in progress.
+     * @exception    E_INVALID_OPERATION     The current state of the instance prohibits the execution of this operation. @n
+        *                                       For example, when the member type of a device is not a Wi-Fi Direct group client.
+     * @exception    E_OUT_OF_RANGE          The specified port number is less than 1024 or greater than 65535.
+     * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+     * @remarks      The port number used by the group owner must be specified if the group owner changes the port number
+     *               in WifiDirectGroupOwner::StartGroupMemberInfoService().
+     * @see          IWifiDirectGroupClientListener::OnWifiDirectGroupOwnerInfoReceived()
+     * @endif
+     */
+    result RequestGroupOwnerInfo(int portNumber = DEFAULT_PORT);
+
+    /**
+     * @if OSPDEPREC
+     * Requests the WifiDirectDeviceInfo list of the Wi-Fi Direct group members.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  %WifiDirectGroupClient class is deprecated, therefore, this method is also deprecated. @n
+        * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+        *
+     * @since 2.0
+     *
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.read, %http://tizen.org/privilege/network.connection and %http://tizen.org/privilege/socket @n
+     *              All the above privileges are required
+     *
+     * @return       An error code
+     * @param[in]    portNumber              A port number to connect to the group member information service
+     * @exception    E_SUCCESS               The method is successful.
+     * @exception    E_SYSTEM                A system error has occurred.
+     * @exception    E_IN_PROGRESS           The previous request for the group owner information is in progress.
+     * @exception    E_INVALID_OPERATION     The current state of the instance prohibits the execution of this operation. @n
+        *                                       For example, when the member type of a device is not a Wi-Fi Direct group client.
+     * @exception    E_OUT_OF_RANGE          The specified port number is less than 1024 or greater than 65535.
+     * @exception    E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
+        * @remarks      The port number used by the group owner should be specified if the group owner changed the port number in WifiDirectGroupOwner::StartGroupMemberInfoService().
+     * @see          IWifiDirectGroupClientListener::OnWifiDirectAllGroupMemberInfoReceivedN()
+     * @endif
+     */
+    result RequestAllGroupMemberInfo(int portNumber = DEFAULT_PORT);
+
+private:
+    /**
+     * This default constructor is intentionally declared as private so that only the platform can create an instance.
+     *
+     * @remarks     After creating an instance of this class, the Construct() method must be called explicitly
+     *              to initialize this instance.
+     *
+     * @see         Construct()
+     */
+    WifiDirectGroupClient(void);
+
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in]   value   An instance of %WifiDirectGroupClient
+     */
+    WifiDirectGroupClient(const WifiDirectGroupClient& value);
+
+    /**
+     * Initializes this instance of %WifiDirectGroupClient with the specified parameter.
+     *
+     * @return An error code
+     *
+     * @param[in]   wifiDirectGroupClientImpl  A reference to the _WifiDirectGroupClientImpl instance
+     *
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     */
+    result Construct(_WifiDirectGroupClientImpl& wifiDirectGroupClientImpl);
+
+    /**
+    * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit
+    * copying of objects.
+    *
+    * @param[in]   rhs An instance of %WifiDirectGroupClient
+    */
+    WifiDirectGroupClient& operator=(const WifiDirectGroupClient& rhs);
+
+private:
+    static const int DEFAULT_PORT = 3895;
+
+    _WifiDirectGroupClientImpl* __pWifiDirectGroupClientImpl;
+
+    friend class _WifiDirectGroupClientImpl;
+}; // WifiDirectGroupClient
+
+} } } // Tizen::Net::Wifi
+#endif // _FNET_WIFI_WIFI_DIRECT_GROUP_CLIENT_H_
diff --git a/inc/FNetWifiWifiDirectGroupInfo.h b/inc/FNetWifiWifiDirectGroupInfo.h
new file mode 100644 (file)
index 0000000..24ae767
--- /dev/null
@@ -0,0 +1,254 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifiWifiDirectGroupInfo.h
+ * @brief   This is the header file for the %WifiDirectGroupInfo class.
+ *
+ * This header file contains the declarations of the %WifiDirectGroupInfo class.
+ */
+#ifndef _FNET_WIFI_WIFI_DIRECT_GROUP_INFO_H_
+#define _FNET_WIFI_WIFI_DIRECT_GROUP_INFO_H_
+
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class _WifiDirectGroupInfoImpl;
+
+/**
+ * @class   WifiDirectGroupInfo
+ * @brief   This class provides methods for the Wi-Fi Direct group information.
+ *
+ * @since   2.0
+ *
+ * The %WifiDirectGroupInfo class provides methods to get or set the information for a Wi-Fi Direct group.
+ */
+
+class _OSP_EXPORT_ WifiDirectGroupInfo
+       : public Tizen::Base::Object
+{
+public:
+    /**
+     * This is the default constructor for this class.
+     *
+     * @since   2.0
+     */
+    WifiDirectGroupInfo(void);
+
+    /**
+     * Copying of objects using this copy constructor is allowed.
+     *
+     * @since   2.0
+     *
+     * @param[in]   value   An instance of %WifiDirectGroupInfo
+     */
+    WifiDirectGroupInfo(const WifiDirectGroupInfo& value);
+
+    /**
+     * This is the destructor for this class.
+     *
+     * @since   2.0
+     */
+    virtual ~WifiDirectGroupInfo(void);
+
+public:
+    /**
+     * @if OSPDEPREC
+     * Gets the autonomous group owner mode.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  This method is deprecated because this class has been modified and is now composed of information exclusively required to configure a group. @n
+     *              So, a new API has been added. Instead of using this API, use WifiDirectDevice::CreateAutonomousGroup() API.
+
+     *
+     * @since 2.0
+     *
+     * @return  @c true if the autonomous group owner mode is activated, @n
+     *          else @c false
+     * @endif
+     */
+    bool GetAutonomousGroupOwnerMode(void) const;
+
+    /**
+     * Gets the intent of a group owner. It is used during the negotiation phase.
+     *
+     * @since 2.0
+     *
+     * @return  An intent value
+     */
+    int GetGroupOwnerIntent(void) const;
+
+    /**
+     * Gets the maximum number of clients to be associated.
+     *
+     * @since 2.0
+     *
+     * @return  The maximum number of clients to be associated
+     */
+    int GetMaxNumberOfClients(void) const;
+
+    /**
+     * @if OSPDEPREC
+     * @{
+     * Gets the SSID.
+     *
+     * @if OSPCOMPAT
+     * @brief <i> [Deprecated] [Compatibility] </i>
+     * @endif
+     * @deprecated  This method is deprecated because this class has been modified and is now composed of information that is exclusively required to configure a group. @n
+     *              So, new APIs have been added. Instead of using GetSsid() API, use WifiDirectDevice::GetGroupOwnerInfoN() or WifiDirectDevice::GetLocalDeviceInfo() API.
+     *
+     * @since 2.0
+     * @if OSPCOMPAT
+     * @compatibility   This method has compatibility issues with OSP compatible applications. @n
+     *                  For more information, see the issue description for @ref CompWifiDirectGroupInfoGetSsidPage "here".
+     * @endif
+     * @return  The SSID
+     * @}
+     * @endif
+     */
+    Tizen::Base::String GetSsid(void) const;
+
+    /**
+     * @if OSPCOMPAT
+     * @page    CompWifiDirectGroupInfoGetSsidPage Compatibility for GetSsid().
+     * @section CompWifiDirectGroupInfoGetSsidPageIssueSection Issues
+     *          Implementing this method in OSP compatible applications has the following issues: @n
+     *          -# The method returns the SSID which is the same as the device name.
+     *
+     * @section CompWifiDirectGroupInfoGetSsidPageSolutionSection  Resolutions
+     *          This issue has been resolved in Tizen @n
+     *          -# The method returns the SSID which has 'Direct-xy' as its prefix. The 'xy' is two ASCII characters or digits the
+     *          system generates randomly.
+     * @endif
+     */
+
+    /**
+     * @if OSPDEPREC
+     * Gets the BSS ID.
+     *
+     * @brief <i> [Deprecated] </i>
+     * @deprecated  This method is deprecated because this class has been modified and is now composed of information that is exclusively required to configure a group. @n
+     *              So, a new API has been added. Instead of using GetBssId() API, use WifiDirectDevice::GetGroupOwnerInfoN() API.
+     *
+     * @since 2.0
+     *
+     * @return  The BSS ID
+     * @endif
+     */
+    Tizen::Base::String GetBssId(void) const;
+
+    /**
+     * @if OSPDEPREC
+     * Gets the index of a currently working channel.
+     *
+     * @brief <i> [Deprecated] </i>
+     * @deprecated  This method is deprecated because this class has been modified and is now composed of information exclusively required to configure a group. @n
+     *              So this API has been moved to the WifiDirectDevice class.
+     *
+     * @since 2.0
+     *
+     * @return  The Wi-Fi radio channel
+     * @endif
+     */
+    WifiRadioChannel GetOperatingChannel(void) const;
+
+    /**
+     * @if OSPDEPREC
+     * Sets the mode for an autonomous group owner.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  This method is deprecated because this class has been modified and is now composed of information exclusively required to configure a group. @n
+     *              So, a new API has been added. Instead of using SetAutonomousGroupOwnerMode() method, use WifiDirectDevice::CreateAutonomousGroup() API.
+     *
+     * @since 2.0
+     *
+     * @param[in]   mode    Set to @c true if autonomous group owner mode is enabled, @n
+     *                      else @c false
+     * @endif
+     */
+    void SetAutonomousGroupOwnerMode(bool mode);
+
+    /**
+     * Sets the intent of a group owner.
+     *
+     * @since 2.0
+     *
+     * @return       An error code
+     * @param[in]    intent         The intent to become a group owner
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_ARG   Either the specified @c intent is less than @c 0, or exceeds Wifi::MAX_WIFI_DIRECT_GROUP_OWNER_INTENT.
+     * @remarks     A higher intent value means that the intent to become a group owner is higher. 
+     *              If Wifi::MAX_WIFI_DIRECT_GROUP_OWNER_INTENT is selected, it means that a device insists to be a group owner only.
+     *              If two devices participating in a group creation select the intent value as
+     *              Wifi::MAX_WIFI_DIRECT_GROUP_OWNER_INTENT, the group creation fails.
+     */
+    result SetGroupOwnerIntent(int intent);
+
+    /** 
+     * Sets the maximum number of clients to be associated.
+     *
+     * @since 2.0
+     *
+     * @return      An error code
+     * @param[in]   numberOfClient  The maximum number of clients to associate
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_ARG   Either the specified @c numberOfClient is less than @c 0 or exceeds
+     *                              Wifi::MAX_WIFI_DIRECT_CONNECTED_CLIENTS.
+     */
+    result SetMaxNumberOfClients(int numberOfClient);
+
+    /**
+     * Checks whether the specified instance of %WifiDirectGroupInfo equals the current instance.
+     *
+     * @since    2.0
+        *
+     * @return   @c true if the specified instance equals the current instance, @n
+     *           else @c false
+     * @param[in]    obj An instance of %WifiDirectGroupInfo
+     * @remarks  This method returns @c false if the specified object is not %WifiDirectGroupInfo.
+     */
+    virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+    /**
+     * Gets the hash value of the current instance.
+     *
+     * @since    2.0
+     *
+     * @return   The hash value of the current instance
+     */
+    virtual int GetHashCode(void) const;
+
+    /**
+     * Assigns the value of the specified instance to the current instance of %WifiDirectGroupInfo.
+     *
+     * @since   2.0
+     *
+     * @return  A reference to the %WifiDirectGroupInfo instance
+     * @param[in]   rhs     An instance of %WifiDirectGroupInfo
+     */
+    WifiDirectGroupInfo& operator =(const WifiDirectGroupInfo& rhs);
+
+private:
+    _WifiDirectGroupInfoImpl* __pWifiDirectGroupInfoImpl;
+
+    friend class _WifiDirectGroupInfoImpl;
+}; // WifiDirectGroupInfo
+
+} } } // Tizen::Net::Wifi
+#endif // _FNET_WIFI_WIFI_DIRECT_GROUP_INFO_H_
diff --git a/inc/FNetWifiWifiDirectGroupMember.h b/inc/FNetWifiWifiDirectGroupMember.h
new file mode 100644 (file)
index 0000000..a965fe9
--- /dev/null
@@ -0,0 +1,166 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifiWifiDirectGroupMember.h
+ * @brief   This is the header file for the %WifiDirectGroupMember class.
+ *
+ * This header file contains the declarations of the %WifiDirectGroupMember class.
+ */
+#ifndef _FNET_WIFI_WIFI_DIRECT_GROUP_MEMBER_H_
+#define _FNET_WIFI_WIFI_DIRECT_GROUP_MEMBER_H_
+
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class WifiDirectGroupMemberImpl;
+/**
+ * @if OSPDEPREC
+ * @class WifiDirectGroupMember
+ * @brief <i> [Deprecated] </i> This class provides methods for the Wi-Fi Direct group member.
+ * @deprecated   This method is deprecated because the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role (for example, group owner, group client, and so on). @n
+     * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role and so it was necessary to use these APIs.
+ *
+ * @since   2.0
+ *
+ * The %WifiDirectGroupMember class provides methods for the Wi-Fi Direct group member.
+ * @endif
+ */
+
+class _OSP_EXPORT_ WifiDirectGroupMember
+       : public Tizen::Base::Object
+{
+public:
+    /**
+     * @if OSPDEPREC
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated   This method is deprecated because the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role (for example, group owner, group client, and so on). @n
+     * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role and so it was necessary to use these APIs.
+     * @since 2.0
+     * @endif
+     */
+    virtual ~WifiDirectGroupMember(void){}
+
+    /**
+     * @if OSPDEPREC
+     * Gets the type of the Wi-Fi Direct group member.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated   This method is deprecated because the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role (for example, group owner, group client, and so on). @n
+     * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role and so it was necessary to use these APIs.
+     *
+     * @since 2.0
+     *
+     * @return The type of the Wi-Fi Direct group member
+     * @endif
+     */
+    WifiDirectGroupMemberType GetGroupMemberType(void) const;
+
+protected:
+    /**
+     * This is the default constructor for this class.
+     *
+     * @since   2.0
+     */
+    WifiDirectGroupMember(void);
+    /**
+     * This is the copy constructor for the %WifiDirectGroupMember class. @n
+        * Do @b not use directly.
+        *
+        * @since   2.0
+     *
+     * @param[in]   value   An instance of %WifiDirectGroupMember
+     */
+    WifiDirectGroupMember(const WifiDirectGroupMember& value);
+
+    /**
+     * Assigns the value of the specified instance to the current instance of %WifiDirectGroupMember. @n
+        * Do @b not use directly.
+        *
+        * @since   2.0
+     *
+     * @param[in]   rhs     An instance of %WifiDirectGroupMember
+     */
+    WifiDirectGroupMember& operator =(const WifiDirectGroupMember& rhs);
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since       2.0
+    //
+    virtual void WifiDirectGroupMember_Reserved1(void){ }
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since       2.0
+    //
+    virtual void WifiDirectGroupMember_Reserved2(void){ }
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since       2.0
+    //
+    virtual void WifiDirectGroupMember_Reserved3(void){ }
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since       2.0
+    //
+    virtual void WifiDirectGroupMember_Reserved4(void){ }
+
+    //
+    // This method is for internal use only. Using this method can cause behavioral, security-related,
+    // and consistency-related issues in the application.
+    //
+    //
+    // This method is reserved and may change its name at any time without prior notice.
+    //
+    // @since       2.0
+    //
+    virtual void WifiDirectGroupMember_Reserved5(void){ }
+
+protected:
+    WifiDirectGroupMemberType _groupMemberType;
+
+    WifiDirectGroupMemberImpl* _pWifiDirectGroupMemberImpl;
+    friend class WifiDirectGroupMemberImpl;
+}; // WifiDirectGroupMember
+
+} } } // Tizen::Net::Wifi
+#endif // _FNET_WIFI_WIFI_DIRECT_GROUP_MEMBER_H_
diff --git a/inc/FNetWifiWifiDirectGroupOwner.h b/inc/FNetWifiWifiDirectGroupOwner.h
new file mode 100755 (executable)
index 0000000..46ad20d
--- /dev/null
@@ -0,0 +1,246 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifiWifiDirectGroupOwner.h
+ * @brief   This is the header file for the %WifiDirectGroupOwner class.
+ *
+ * This header file contains the declarations of the %WifiDirectGroupOwner class.
+ */
+#ifndef _FNET_WIFI_WIFI_DIRECT_GROUP_OWNER_H_
+#define _FNET_WIFI_WIFI_DIRECT_GROUP_OWNER_H_
+
+#include <FNetWifiWifiDirectGroupMember.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class _WifiDirectGroupOwnerImpl;
+class WifiDirectDeviceInfo;
+
+/**
+ * @if OSPDEPREC
+ * @class   WifiDirectGroupOwner
+ * @brief   <i> [Deprecated] </i> This class provides methods for the Wi-Fi Direct group owner management.
+ * @deprecated   This method is deprecated because the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role (for example, group owner, group client, and so on). @n
+ * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role and so it was necessary to use these APIs. @n
+ * As the APIs have been integrated into the WifiDirectDevice class, use IWifiDirectDevice class instead.
+ *
+ * @since   2.0
+ *
+ * The %WifiDirectGroupOwner class provides methods to manage the Wi-Fi Direct group.
+ * @endif
+ */
+
+class _OSP_EXPORT_ WifiDirectGroupOwner
+    : public WifiDirectGroupMember
+{
+public:
+    /**
+     * @if OSPDEPREC
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  %WifiDirectGroupOwner class is deprecated, therefore, this method is also deprecated. @n
+        * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     *
+     * @since 2.0
+     * @endif
+     */
+    virtual ~WifiDirectGroupOwner(void);
+
+    /**
+     * @if OSPDEPREC
+     * Destroys a Wi-Fi Direct group.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  %WifiDirectGroupOwner class is deprecated, therefore, this method is also deprecated. @n
+* Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     *              As the APIs have been integrated into the WifiDirectDevice class, use WifiDirectDevice::LeaveGroup() API instead.
+     *
+     * @since 2.0
+     *
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.admin
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_IN_PROGRESS       A previous request is in progress.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, when the member type of a device is not a Wi-Fi Direct group owner.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @see         IWifiDirectGroupOwnerListener::OnWifiDirectGroupDestroyed()
+     * @endif
+     */
+    result DestroyGroup(void);
+
+    /**
+     * @if OSPDEPREC
+     * Disconnects a specified Wi-Fi Direct group client.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  %WifiDirectGroupOwner class is deprecated, therefore, this method is also deprecated. @n
+        * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+        *              As the APIs have been integrated into the WifiDirectDevice class, use WifiDirectDevice::Disconnect() API instead.
+     *
+     * @since 2.0
+     *
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.admin
+     *
+     * @return      An error code
+     * @param[in]   wifiDirectRemoteDeviceInfo  The device information of a group client to disconnect
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_IN_PROGRESS       A previous request is in progress.
+     * @exception   E_INVALID_ARG       A specified input parameter is invalid.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+     *                                  For example, when the member type of a device is not a Wi-Fi Direct group owner.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @see         IWifiDirectGroupOwnerListener::OnWifiDirectClientDisassociated()
+     * @endif
+     */
+    result Disconnect(const WifiDirectDeviceInfo& wifiDirectRemoteDeviceInfo);
+
+    /**
+     * @if OSPDEPREC
+     * Gets the list of information of all the members of the Wi-Fi Direct group.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  %WifiDirectGroupOwner class is deprecated ,therefore, this method is also deprecated. @n
+* Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+      *              Instead of GetAllGroupMemberInfoListN() method, use WifiDirectDevice::GetGroupOwnerInfoN() for group owner information and WifiDirectDevice::GetGroupClientInfoListN() for group clients information.
+     *
+     * @since 2.0
+     *
+     * @return      The list of WifiDirectDeviceInfo
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. @n
+        *                                  For example, when the member type of a device is not a Wi-Fi Direct group owner.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
+     * @remarks     The specific error code can be accessed using the GetLastResult() method.
+     * @endif
+     */
+    Tizen::Base::Collection::IList* GetAllGroupMemberInfoListN(void) const;
+
+    /**
+     * @if OSPDEPREC
+     * Starts the group member information service.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  This method is deprecated, therefore, this method is also deprecated. @n
+        * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     *
+     * @since 2.0
+     *
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.read, %http://tizen.org/privilege/network.connection and %http://tizen.org/privilege/socket @n
+     *              All the above privileges are required
+     *
+     * @return      An error code
+     * @param[in]   portNumber          A port number to start group member information service
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_IN_PROGRESS       A previous request is in progress.
+     * @exception   E_OUT_OF_RANGE      The specified port number is less than 1024 or greater than 65535.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
+     *                                  For example, member type of @c wifiDirectDevice is not the group owner or client.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @see       IWifiDirectGroupOwnerListener::OnWifiDirectGroupMemberInfoServiceStarted()
+     * @endif
+     */
+    result StartGroupMemberInfoService(int portNumber = DEFAULT_PORT);
+
+    /**
+     * @if OSPDEPREC
+     * Stops the group member information service.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  %WifiDirectGroupOwner class is deprecated, therefore, this method is also deprecated. @n
+        * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role (for example, group owner, group client, and so on) and so it was necessary to use these APIs. @n
+        * Now the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role. @n
+     *
+     * @since 2.0
+     *
+     * @privilege   %http://tizen.org/privilege/wifi.wifidirect.read, %http://tizen.org/privilege/network.connection and %http://tizen.org/privilege/socket @n
+     *              All the above privileges are required
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_IN_PROGRESS       A previous request is in progress.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @see         IWifiDirectGroupOwnerListener::OnWifiDirectGroupMemberInfoServiceStopped()
+     * @endif
+     */
+    result StopGroupMemberInfoService(void);
+
+private:
+    /**
+     * This default constructor is intentionally declared as private so that only the platform can create an instance.
+     *
+     * @remarks     After creating an instance of this class, the Construct() method must be explicitly called to
+     *              initialize this instance.
+     * @see         Construct()
+     */
+    WifiDirectGroupOwner(void);
+
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in]   value   An instance of %WifiDirectGroupOwner
+     */
+    WifiDirectGroupOwner(const WifiDirectGroupOwner& value);
+
+    /**
+     * Initializes this instance of WifiDirectGroupOwner with the specified listener.
+     *
+     * @return      An error code
+     *
+     * @param[in]   wifiDirectDeviceImpl    A reference to the __WifiDirectDeviceImpl instance
+     *
+     * @exception   E_SUCCESS               The method is successful.
+     * @exception   E_SYSTEM                A system error has occurred.
+     */
+    result Construct(_WifiDirectGroupOwnerImpl& wifiDirectGroupOwnerImpl);
+
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and
+     * declared as private to prohibit copying of objects.
+     *
+     * @param[in]   rhs An instance of %WifiDirectGroupOwner
+     */
+    WifiDirectGroupOwner& operator =(const WifiDirectGroupOwner& rhs);
+
+private:
+    static const int DEFAULT_PORT = 3895;
+
+    _WifiDirectGroupOwnerImpl* __pWifiDirectGroupOwnerImpl;
+
+    friend class _WifiDirectGroupOwnerImpl;
+}; // WifiDirectGroupOwner
+
+} } } // Tizen::Net::Wifi
+#endif // _FNET_WIFI_WIFI_DIRECT_GROUP_OWNER_H_
diff --git a/inc/FNetWifiWifiManager.h b/inc/FNetWifiWifiManager.h
new file mode 100755 (executable)
index 0000000..7736101
--- /dev/null
@@ -0,0 +1,381 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifiWifiManager.h
+ * @brief   This is the header file for the %WifiManager class.
+ *
+ * This header file contains the declarations of the %WifiManager class.
+ */
+#ifndef _FNET_WIFI_WIFI_MANAGER_H_
+#define _FNET_WIFI_WIFI_MANAGER_H_
+
+#include <FBaseTypes.h>
+#include <FBaseResult.h>
+#include <FNetWifiWifiTypes.h>
+#include <FNetWifiIWifiManagerEventListener.h>
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class WifiBssInfo;
+class _WifiManagerImpl;
+class IWifiSystemMonitoringEventListener;
+
+/**
+ * @class   WifiManager
+ * @brief   This class provides methods for the local Wi-Fi device management.
+ *
+ * @since   2.0
+ *
+ *  The %WifiManager class provides methods for creating a %WifiManager instance, and managing the local Wi-Fi devices. It also allows the
+ *      listener to get the events from the local Wi-Fi devices.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/wi-fi_connectivity.htm">Wi-Fi Connectivity</a>.
+ *
+ * The following example demonstrates how to use the %WifiManager class.
+ *
+ * @code
+ *
+ * using namespace Tizen::Net::Wifi;
+ *
+ * result
+ * MyClass::WifiManagerSample(void)
+ * {
+ *     WifiManager wifiMgr;            // Creates an instance of WifiManager
+ *     MyListenerClass wifiListener;   // Creates a listener for WifiManager
+ *     result r;
+ *
+ *     // Initializes wifiMgr using the Construct method
+ *     r = wifiMgr.Construct(wifiListener);
+ *     if (IsFailed(r))
+ *     {
+ *             goto CATCH;
+ *     }
+ *
+ *     // Activates the local Wi-Fi device
+ *     r = wifiMgr.Activate();
+ *     if (IsFailed(r))
+ *     {
+ *             goto CATCH;
+ *     }
+ *
+ *     // Checks the current connection status
+ *     if (!wifiMgr.IsConnected())
+ *     {
+ *             // Deactivates the local Wi-Fi device
+ *             r = wifiMgr.Deactivate();
+ *             if (IsFailed(r))
+ *             {
+ *                     goto CATCH;
+ *             }
+ *     }
+ *
+ *     return r;
+ *
+ * CATCH:
+ *     // Do some exception handling.
+ *     return r;
+ * }
+ *
+ * @endcode
+ *
+ */
+
+class _OSP_EXPORT_ WifiManager
+       : public Tizen::Base::Object
+{
+public:
+    /**
+     * This is the default constructor for this class.
+     *
+     * @since       2.0
+        *
+     * @remarks     After creating an instance of this class, the Construct() method must be called explicitly to initialize the instance.
+     * @see         Construct()
+     */
+    WifiManager(void);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     * @since       2.0
+     */
+    virtual ~WifiManager(void);
+
+    /**
+     * Initializes this instance of %WifiManager with the specified listener.
+     *
+     * @since       2.0
+        *
+     * @return      An error code
+     * @param[in]   listener        A reference to the listener instance
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @exception   E_OUT_OF_MEMORY The memory is insufficient.
+        * @exception   E_UNSUPPORTED_OPERATION This operation is not supported.
+     * @remarks     The @c listener instance must not be deleted before destructing this instance.
+     */
+    result Construct(IWifiManagerEventListener& listener);
+
+    /**
+     * Activates the local Wi-Fi device.
+     *
+     * @since       2.0
+     * @privilege   %http://tizen.org/privilege/wifi.admin
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The activation is successful.
+     * @exception   E_FAILURE           The method has failed to activate.
+     * @exception   E_IN_PROGRESS       The activate process is in progress.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
+     *                                  For example, the Wi-Fi is already activated.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @see IWifiManagerEventListener::OnWifiActivated()
+     */
+    result Activate(void) const;
+
+    /**
+     * Deactivates the local Wi-Fi device.
+     *
+     * @since       2.0
+     * @privilege   %http://tizen.org/privilege/wifi.admin
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The deactivation is successful.
+     * @exception   E_FAILURE           The method has failed to deactivate.
+     * @exception   E_IN_PROGRESS       The deactivate process is in progress.
+     * @exception   E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
+     *                                  For example, the Wi-Fi is already deactivated.
+     * @exception   E_SYSTEM            A system error has occurred.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @see         IWifiManagerEventListener::OnWifiDeactivated()
+     */
+    result Deactivate(void) const;
+
+    /**
+     * Gets the current power status of the local Wi-Fi device.
+     *
+     * @since   2.0
+        *
+     * @return  The current power status of the local Wi-Fi device
+     */
+    WifiPowerStatus GetPowerStatus(void) const;
+
+    /**
+     * Gets the MAC address of the Wi-Fi device.
+     *
+     * @since   2.0
+        *
+     * @return  The MAC address in the form '00-00-00-00-00-00'
+     * @remarks This MAC address is different from the MAC address provided by the WifiDirectDevice class.
+     */
+    Tizen::Base::String GetMacAddress(void) const;
+
+    /**
+     * Checks whether the local device is activated.
+     *
+     * @since   2.0
+        *
+     * @return  @c true if the local device is activated, @n
+     *          else @c false
+     */
+    bool IsActivated(void) const;
+
+    /**
+     * Checks whether the local device is connected with a remote Access Point(AP).
+     *
+     * @since   2.0
+        *
+     * @return  @c true if the local device is connected with a remote Access Point(AP), @n
+     *          else @c false
+     */
+    bool IsConnected(void) const;
+
+    /**
+     * Scans for a nearby BSS with both the infrastructure and independent modes.
+     *
+     * @since       2.0
+     * @privilege   %http://tizen.org/privilege/wifi.read
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_FAILURE           The method has failed.
+     * @exception   E_INVALID_STATE     This instance is in an invalid state.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @remarks     Only active scan (probing for Access Points(APs) and ad hoc stations in the range) is supported.
+     *              This operation does not work while the Wi-Fi Direct scanning or connection is in progress.
+     * @see         IWifiManagerEventListener::OnWifiScanCompletedN()
+     */
+    result Scan(void);
+
+    /**
+     * Connects to a specific access point that is a BSS with an infrastructure mode.
+     *
+     * @since       2.0
+     * @privilege   %http://tizen.org/privilege/wifi.admin
+     *
+     * @return      An error code
+     * @param[in]   targetApInfo        A BSS information representing the target access point
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_FAILURE           The method has failed.
+     * @exception   E_IN_PROGRESS       The previous request is in progress.
+     * @exception   E_INVALID_ARG       The specified input parameter is invalid. @n
+     *                                  For example, the BSS type is an independent mode.
+     * @exception   E_INVALID_STATE     This instance is in an invalid state.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @remarks     If a connection to another access point is already established, it will be disconnected and the new connection
+     *              of this method will be established.
+     * @see IWifiManagerEventListener::OnWifiConnected()
+     */
+    result Connect(const WifiBssInfo& targetApInfo);
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Sets the behavior mode of the Wi-Fi background system about connection and background scanning.
+     *
+     * @since       2.0
+     * @visibility  partner-manufacturer
+     * @privilege   %http://tizen.org/privilege/wifimanager
+     *
+     * @return      An error code
+     * @param[in]   mode                A Wi-Fi background system mode
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @exception   E_OPERATION_FAILED  The operation has failed.
+     * @exception   E_SYSTEM            The method cannot proceed due to a severe system error.
+     * @endif
+     */
+    result SetWifiSystemScanMode(WifiSystemScanMode mode);
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Adds the specified listener for receiving the notification when the state of current Wi-Fi connection is changed
+     * or the result of Wi-Fi background scanning is updated
+     *
+     * @since       2.0
+     * @visibility  partner-manufacturer
+     * @privilege   %http://tizen.org/privilege/wifimanager
+     *
+     * @return      An error code
+     * @param[in]   listener            The listener to add
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_OBJ_ALREADY_EXIST The listener is already added.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @exception   E_SYSTEM            The method cannot proceed due to a severe system error.
+     * @endif
+     */
+    result AddSystemMonitoringEventListener(IWifiSystemMonitoringEventListener& listener);
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Removes the specified IWifiSystemMonitoringEventListener instance for receiving the notification. The removed listener
+     * cannot listen to the events that are fired.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     * @privilege   %http://tizen.org/privilege/wifimanager
+     *
+     * @return      An error code
+     * @param[in]   listener            The listener to remove
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_OBJ_NOT_FOUND     The listener is not found.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @exception   E_SYSTEM            The method cannot proceed due to a severe system error.
+     * @endif
+     */
+    result RemoveSystemMonitoringEventListener(IWifiSystemMonitoringEventListener& listener);
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Gets the state of current Wi-Fi connection.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      The state of the current Wi-Fi connection
+     * @endif
+     */
+    WifiConnectionState GetConnectionState(void) const;
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Gets the information of current Wi-Fi connection target which the local device is connecting or connected with.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      A pointer to the WifiBssInfo instance representing the information of current Wi-Fi connection target
+     *              else @c null if GetConnectionState() is WIFI_CONN_STATE_NOT_CONNECTED
+     * @endif
+     */
+    WifiBssInfo* GetConnectionTargetInfoN(void) const;
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Updates the Wi-Fi BSS information which is saved in the underlying Wi-Fi system.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     * @privilege   %http://tizen.org/privilege/wifimanager
+     *
+     * @return      An error code
+     * @param[in]   bssInfo             A BSS information representing the access point
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
+     * @exception   E_OBJ_NOT_FOUND     The specified input parameter is not found.
+     * @exception   E_OPERATION_FAILED  The operation has failed.
+     * @exception   E_SYSTEM            The method cannot proceed due to a severe system error.
+     * @endif
+     */
+    result UpdateBssInfo(const WifiBssInfo& bssInfo);
+
+    /**
+     * @if VISPARTNER-MANUFACTURER
+     * Gets a list of the latest search results which the underlying Wi-Fi system scan periodically on background.
+     *
+     * @since 2.0
+     * @visibility  partner-manufacturer
+     *
+     * @return      An IList containing WifiBssInfo of existing Wi-Fi connections if successful, @n
+     *              else @c null
+     * @endif
+     */
+    Tizen::Base::Collection::IList* GetSystemScanResultN(void) const;
+
+private:
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in]   value   An instance of %WifiManager
+     */
+    WifiManager(const WifiManager& value);
+
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in]   rhs     An instance of %WifiManager
+     */
+    WifiManager& operator=(const WifiManager& rhs);
+
+private:
+    _WifiManagerImpl* __pWifiManagerImpl;
+
+    friend class _WifiManagerImpl;
+}; // WifiManager
+
+} } } // Tizen::Net::Wifi
+#endif // _FNET_WIFI_WIFI_MANAGER_H_
diff --git a/inc/FNetWifiWifiNetAccountInfo.h b/inc/FNetWifiWifiNetAccountInfo.h
new file mode 100644 (file)
index 0000000..7af229c
--- /dev/null
@@ -0,0 +1,156 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifiWifiNetAccountInfo.h
+ * @brief   This is the header file for the %WifiNetAccountInfo class.
+ *
+ * This header file contains the declarations of the %WifiNetAccountInfo class.
+ */
+#ifndef _FNET_WIFI_WIFI_NET_ACCOUNT_INFO_H_
+#define _FNET_WIFI_WIFI_NET_ACCOUNT_INFO_H_
+
+#include <FBaseObject.h>
+#include <FNetNetAccountInfo.h>
+#include <FNetWifiWifiSecurityInfo.h>
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class _WifiNetAccountInfoImpl;
+class WifiSecurityInfo;
+
+/**
+ * @class   WifiNetAccountInfo
+ * @brief   This class provides the functionality to control the WLAN network accounts.
+ *
+ * @since   2.0
+ *
+ * The %WifiNetAccountInfo class provides the functionality to control the WLAN network accounts and the basic network accounts. This class inherits the
+ * NetAccountInfo class.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/wi-fi_connectivity.htm">Wi-Fi Connectivity</a>.
+ */
+
+class _OSP_EXPORT_ WifiNetAccountInfo
+       : public Tizen::Net::NetAccountInfo
+{
+public:
+    /**
+     * This is the destructor for this class.
+     *
+     *
+     * @since   2.0
+     */
+    virtual ~WifiNetAccountInfo(void);
+
+    /**
+     * Gets the BSSID of this account.
+     *
+     * @since       2.0
+        *
+     * @return      The BSS ID in the form '00-00-00-00-00-00'
+     * @remarks     This operation is not yet supported.
+     */
+    Tizen::Base::String GetBssId(void) const;
+
+    /**
+     * Gets the SSID of this account.
+     *
+     * @since   2.0
+        *
+     * @return  The SSID of this account
+     */
+    Tizen::Base::String GetSsid(void) const;
+
+    /**
+     * Gets the type of BSS of this account.
+     *
+     * @since   2.0
+        *
+     * @return  The type of BSS of this account
+     */
+    WifiBssType GetBssType(void) const;
+
+    /**
+     * Gets the security information of this account.
+     *
+     * @since   2.0
+        *
+     * @return  The authentication and encryption type of this account
+     */
+    const WifiSecurityInfo* GetSecurityInfo(void) const;
+
+    /**
+     * Gets the radio channel of this account. @n
+     * If this value is not set, the default value is WIFI_RADIO_CHANNEL_UNKNOWN.
+     *
+     * @since   2.0
+        *
+     * @return  The radio channel of this account
+     * @remarks This operation is not yet supported.
+     */
+    WifiRadioChannel GetRadioChannel(void) const;
+
+    /**
+     * Checks whether the specified instance of %WifiNetAccountInfo equals the current instance.
+     *
+     * @since    2.0
+        *
+     * @return   @c true if the specified instance equals the current instance, @n
+     *           else @c false
+     * @param[in]    obj An instance of %WifiNetAccountInfo
+     * @remarks  This method returns @c false if the specified object is not %WifiNetAccountInfo.
+     */
+    virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+    /**
+     * Gets the hash value of the current instance.
+     *
+     * @since    2.0
+     *
+     * @return   The hash value of the current instance
+     */
+    virtual int GetHashCode(void) const;
+
+private:
+    /**
+     * This default constructor is intentionally declared as private so that only the platform can create an instance.
+     *
+     */
+    WifiNetAccountInfo(void);
+
+    /**
+     * This copy constructor is intentionally declared as private to prohibit copying of objects by users.
+     *
+     * @param[in]   value   An instance of %WifiNetAccountInfo
+     */
+    WifiNetAccountInfo(const WifiNetAccountInfo& value);
+
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in]   rhs     An instance of %WifiNetAccountInfo        
+     */
+    WifiNetAccountInfo& operator=(const WifiNetAccountInfo& rhs);
+
+private:
+    _WifiNetAccountInfoImpl* __pWifiNetAccountInfoImpl;
+
+    friend class _WifiNetAccountInfoImpl;
+}; // WifiNetAccountInfo
+
+} } } // Tizen::Net::Wifi
+#endif // _FNET_WIFI_WIFI_NET_ACCOUNT_INFO_H_
diff --git a/inc/FNetWifiWifiSecurityInfo.h b/inc/FNetWifiWifiSecurityInfo.h
new file mode 100644 (file)
index 0000000..1de4528
--- /dev/null
@@ -0,0 +1,228 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifiWifiSecurityInfo.h
+ * @brief   This is the header file for the %WifiSecurityInfo class.
+ *
+ * This header file contains the declarations of the %WifiSecurityInfo class.
+ */
+#ifndef _FNET_WIFI_WIFI_SECURITY_INFO_H_
+#define _FNET_WIFI_WIFI_SECURITY_INFO_H_
+
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class _WifiSecurityInfoImpl;
+
+/**
+ * @class   WifiSecurityInfo
+ * @brief   This class provides methods to manage the security information of a Wi-Fi network.
+ *
+ * @since   2.0
+ *
+ * The %WifiSecurityInfo class is used with the WifiNetAccountInfo class to set and get the security information of a Wi-Fi network.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/wi-fi_connectivity.htm">Wi-Fi Connectivity</a>.
+ */
+class _OSP_EXPORT_ WifiSecurityInfo
+       : public Tizen::Base::Object
+{
+public:
+    /**
+     * This is the default constructor for this class.
+     *
+     * @since   2.0
+     */
+    WifiSecurityInfo(void);
+
+    /**
+     * Copying of objects using this copy constructor is allowed.
+     *
+     * @since       2.0
+     *
+     * @param[in]   value   An instance of %WifiSecurityInfo
+     */
+    WifiSecurityInfo(const WifiSecurityInfo& value);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     * @since   2.0
+     */
+    virtual ~WifiSecurityInfo(void);
+
+    /**
+     * Gets the authentication type of this account.
+     *
+     * @since           2.0
+     *
+     * @return          The authentication type of this account
+    */
+    WifiAuthenticationType GetAuthenticationType(void) const;
+
+    /**
+     * Gets the encryption type of this account.
+     *
+     * @since           2.0
+     *
+     * @return          The encryption type
+     * @remarks         If the encryption type is @c WIFI_ENCRYPTION_TKIP_AES_MIXED, either SetNetworkKeyAes() or
+     *                  SetNetworkKeyTkip() can be used to set the key.  
+     */
+    WifiEncryptionType GetEncryptionType(void) const;
+
+    /**
+     * @if OSPDEPREC
+     * Sets the Wired Equivalent Privacy (WEP) key data.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  This method is deprecated because the key value does not need to set for each encryption type.
+     *              Instead of using this method, use SetNetworkKey().
+     *
+     * @since       2.0
+     *
+     * @return      An error code
+     * @param[in]   keyLen          A WifiWepKeyLen enumerator value
+     * @param[in]   keyIndex        The key index of WEP key to set
+     * @param[in]   key             The key data to set
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_ARG   The length of the specified @c key exceeds @c 10 bytes when the
+     * value of @c keyLen is Wifi::WIFI_WEP_KEY_LEN_64BIT,
+     * or the length of the specified @c key exceeds @c 26 bytes when
+     * the value of @c keyLen is Wifi::WIFI_WEP_KEY_LEN_128BIT.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @endif
+     */
+    result SetNetworkKeyWep(WifiWepKeyLen  keyLen, WifiWepKeyIndex keyIndex, const Tizen::Base::String& key);
+
+    /**
+     * @if OSPDEPREC
+     * Sets the Advanced Encryption Standard (AES) key data.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  This method is deprecated because the key value does not need to set for each encryption type.
+     *              Instead of using this method, use SetNetworkKey().
+     *
+     * @since       2.0
+     *
+     * @return      An error code
+     * @param[in]   key             The key data to set
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_ARG   The length of the specified @c key exceeds @c 64 bytes.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @endif
+     */
+    result SetNetworkKeyAes(const Tizen::Base::String& key);
+
+    /**
+     * @if OSPDEPREC
+     * Sets the Temporal Key Integrity Protocol (TKIP) key data.
+     *
+     * @brief   <i> [Deprecated] </i>
+     * @deprecated  This method is deprecated because the key value does not need to set for each encryption type.
+     *              Instead of using this method, use SetNetworkKey().
+     *
+     * @since       2.0
+     *
+     * @return      An error code
+     * @param[in]   key             The key data to set
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_ARG   The length of the specified @c key exceeds @c 64 bytes.
+     * @exception   E_SYSTEM        A system error has occurred.
+     * @endif
+     */
+    result SetNetworkKeyTkip(const Tizen::Base::String& key);
+
+    /**
+     * Sets the Extensible Authentication Protocol (EAP) method information.
+     *
+     * @since       2.0
+     *
+     * @return      An error code
+     * @param[in]   type                        The EAP method type
+     * @param[in]   userId                      The user ID to set @n
+     *                                          Its length must not exceed @c 256 bytes.
+     * @param[in]   password                    The password to set @n
+     *                                          Its length must not exceed @c 256 bytes.
+     * @param[in]   validateServerCertificate   Set to @c true to determine the validation of the server certificate, @n
+     *                                          else @c false
+     * @exception   E_SUCCESS                   The method is successful.
+     * @exception   E_INVALID_ARG               The length of the specified @c userId or @c password exceeds @c 256 bytes.
+     * @exception   E_UNSUPPORTED_TYPE          The input @c type is not supported.
+     * @exception   E_SYSTEM                    A system error has occurred.
+     */
+    result SetEapMethodInfo(WifiEapType type, const Tizen::Base::String& userId, const Tizen::Base::String& password, bool validateServerCertificate = true);
+
+    /**
+     * Sets the network key.
+     *
+     * @since 2.0
+     *
+     * @param[in] key The network key
+     */
+    void SetNetworkKey(const Tizen::Base::String& key);
+
+    /**
+     * Sets the authentication type.
+     *
+     * @since 2.0
+     *
+     * @param[in] authType The authentication type
+     */
+    void SetAuthenticationType(WifiAuthenticationType authType);
+
+    /**
+     * Checks whether the specified instance of %WifiSecurityInfo equals the current instance.
+     *
+     * @since   2.0
+        *
+     * @return   @c true if the specified instance equals the current instance, @n
+     *           else @c false
+     * @param[in]    obj An instance of %WifiSecurityInfo
+     * @remarks  This method returns @c false if the specified object is not %WifiSecurityInfo.
+     */
+    virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+    /**
+     * Gets the hash value of the current instance.
+     *
+     * @since   2.0
+     *
+     * @return   The hash value of the current instance
+     */
+    virtual int GetHashCode(void) const;
+
+    /**
+     * Assigns the value of the specified instance to the current instance of %WifiSecurityInfo.
+     *
+     * @since 2.0
+     *
+     * @return      The reference of this instance
+     * @param[in]   rhs   An instance of %WifiSecurityInfo
+     */
+    WifiSecurityInfo& operator=(const WifiSecurityInfo& rhs);
+
+private:
+    _WifiSecurityInfoImpl* __pWifiSecurityInfoImpl;
+
+    friend class _WifiSecurityInfoImpl;
+}; // WifiSecurityInfo
+
+} } } //Tizen::Net::Wifi
+#endif // _FNET_WIFI_WIFI_SECURITY_INFO_H_
diff --git a/inc/FNetWifiWifiTypes.h b/inc/FNetWifiWifiTypes.h
new file mode 100644 (file)
index 0000000..6cc7921
--- /dev/null
@@ -0,0 +1,372 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifiWifiTypes.h
+ * @brief   This is the header file for the enumerations in the Wifi namespace.
+ *
+ * This header file contains the type declarations of the Wifi namespace.
+ */
+#ifndef _FNET_WIFI_WIFI_TYPES_H_
+#define _FNET_WIFI_WIFI_TYPES_H_
+
+#include <FBaseTypes.h>
+#include <FBaseByteBuffer.h>
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+/**
+ * The Wi-Fi Direct Device ID.
+ *
+ * @since   2.0
+ */
+typedef int WifiDirectDeviceId;
+
+/**
+ * The maximum number of associated clients.
+ *
+ * @since   2.0
+ */
+static const int MAX_WIFI_DIRECT_CONNECTED_CLIENTS = 8;
+
+/**
+ * The maximum number of group owners intent for negotiation.
+ *
+ * @since   2.0
+ */
+static const int MAX_WIFI_DIRECT_GROUP_OWNER_INTENT = 15;
+
+/**
+ * @enum    WifiPowerStatus
+ *
+ * Defines the power status of the local Wi-Fi device.
+ *
+ * @since   2.0
+ * @see     WifiManager::GetPowerStatus()
+ */
+enum WifiPowerStatus
+{
+       WIFI_POWER_STATUS_OFF = 0,      /**<  The local Wi-Fi device is turned off */
+       WIFI_POWER_STATUS_ON,           /**<  The local Wi-Fi device is turned on */
+       WIFI_POWER_STATUS_DEEP_SLEEP,   /**<  The local Wi-Fi device enters deep sleep mode */
+};
+
+/**
+ * @enum    WifiBssType
+ *
+ * Defines the type of Basic Service Set (BSS).
+ *
+ * @since 2.0
+ */
+enum WifiBssType
+{
+       WIFI_BSS_TYPE_INFRASTRUCTURE = 0,   /**< The infrastructure type which usually consists of a single Access Point (AP) @n
+                                                        *   However, in order to provide sufficient coverage, it could be necessary to use two
+                                                        *   or more APs. @n
+                                                        *    Logically, there needs to be an interconnection among APs, and this concept is
+                                                        *   called Distribution %System (DS). @n
+                                                        *   Connecting with multiple APs through DS creates a wireless network of an arbitrary
+                                                        *   size. @n
+                                                        *   This is called Extended Service Set (ESS). Finally, a logical connection point to
+                                                        *   the wired LAN is supported by a concept designated as Portal. */
+       WIFI_BSS_TYPE_INDEPENDENT,          /**<  The simplest Wi-Fi configuration is called as Independent Basic Service Set (IBSS)
+                                            *    or ad hoc @n
+                                                        *    The IBSS is a self-contained network that only supports direct communication
+                                                        *    between Stations (STAs) that belong to the same BSS. @n
+                                                        *    The most common example of this connection is the use of Wi-Fi to establish
+                                                        *    peer-to-peer network connection between two STAs. */
+       WIFI_BSS_TYPE_ANY,                  /**<  The type with no specification */
+       WIFI_BSS_TYPE_MAX = 65535           // This enum value is for internal use only. Using this enum value can cause behavioral,
+                                           // security-related, and consistency-related issues in the application.
+};
+
+/**
+ * @enum    WifiAuthenticationType
+ *
+ * Defines IEEE 802.11 authentication.
+ * IEEE 802.11 authentication operates at the link level between IEEE 802.11 stations (STAs).
+ * IEEE 802.11 does not provide end-to-end (message origin to message destination) or user-to-user authentication.
+ *
+ * @since 2.0
+ */
+enum WifiAuthenticationType
+{
+       WIFI_AUTHENTICATION_OPEN = 0,           /**<  The Open %System Authentication that admits any STA to the DS */
+       WIFI_AUTHENTICATION_SHARED,             /**<  The Shared Key Authentication relies on the WEP to demonstrate knowledge of a
+                                                *    WEP encryption key */
+       WIFI_AUTHENTICATION_WPA,                /**<  The Enterprise Authentication that supports WPA (Wi-Fi Protected Access) */
+       WIFI_AUTHENTICATION_WPA_PSK,            /**<  The Personal Authentication that supports WPA; PSK stands for PreShared Key */
+       WIFI_AUTHENTICATION_WPA2,               /**<  The Enterprise Authentication that supports WPA2 */
+       WIFI_AUTHENTICATION_WPA2_PSK,           /**<  The Personal Authentication that supports WPA2; PSK stands for PreShared Key */
+       WIFI_AUTHENTICATION_WPA_WPA2_MIXED_PSK, /**<  The Personal Authentication that supports both WPA and WPA2; PSK stands for
+                                                *    PreShared Key */
+       WIFI_AUTHENTICATION_MAX = 65535         // This enum value is for internal use only. Using this enum value can cause
+                                               // behavioral, security-related, and consistency-related issues in the application.
+};
+
+/**
+ * @enum    WifiEncryptionType
+ *
+ * Defines the IEEE 802.11 encryption that provides the data confidentiality aspects of a closed wired media.
+ *
+ * @since 2.0
+ */
+enum WifiEncryptionType
+{
+       WIFI_ENCRYPTION_NONE = 0,       /**<  The type with no encryption */
+       WIFI_ENCRYPTION_WEP,            /**<  The Wired Equivalent Privacy @n This is only used for open and shared methods. */
+       WIFI_ENCRYPTION_TKIP,           /**<  The Temporal Key Integrity Protocol */
+       WIFI_ENCRYPTION_AES,            /**<  The Advanced Encryption Standard */
+       WIFI_ENCRYPTION_TKIP_AES_MIXED, /**<  The TKIP and AES are both supported */
+       WIFI_ENCRYPTION_MAX = 65535     // This enum value is for internal use only. Using this enum value can cause behavioral,
+                                       // security-related, and consistency-related issues in the application.
+};
+
+/**
+ * @enum    WifiEapType
+ *
+ * Defines the Extensible Authentication Protocol (EAP) method types that provide a specific authentication mechanism.
+ *
+ * @since 2.0
+ */
+enum WifiEapType
+{
+       WIFI_EAP_NONE = 0,       /**<  The method type where no EAP method is used */
+       WIFI_EAP_SIM,            /**<  The EAP-SIM; EAP for GSM Subscriber Identity */
+       WIFI_EAP_AKA,            /**<  The EAP-AKA; EAP for UMTS Authentication and Key Agreement */
+       WIFI_EAP_TTLS_MSCHAPV2,  /**<  The EAP-TTLS/MSCHAPv2; Tunnel MSCHAPv2 through TTLS(Tunneled Transport Layer Security) */
+       WIFI_EAP_PEAP_MSCHAPV2,  /**<  The PEAPv0/EAP-MSCHAPv2; Tunnel MSCHAPv2 through PEAP(Protected Extensible Authentication
+                                 *    Protocol) */
+       WIFI_EAP_PEAP_GTC,       /**<  The PEAPv1/EAP-GTC; Tunnel GTC through PEAP(Protected Extensible Authentication Protocol) */
+       WIFI_EAP_TLS             /**<  The EAP-TLS, Not supported yet */
+};
+
+/**
+ * @if OSPDEPREC
+ * @enum    WifiWepKeyLen
+ *
+ * Defines the Wired Equivalent Privacy (WEP) key length.
+ *
+ * @brief   <i> [Deprecated] </i>
+ * @deprecated  This enum is deprecated because the SetNetworkKeyWep() method is also deprecated.
+ *
+ * @since 2.0
+ * @endif
+ */
+enum WifiWepKeyLen
+{
+       WIFI_WEP_KEY_LEN_64BIT = 0,     /**< @if OSPDEPREC The WEP key of length 64bits @n
+                                        *   The minimum length of the WEP key is 5 digits (40bits). @endif */
+       WIFI_WEP_KEY_LEN_128BIT,        /**< @if OSPDEPREC The WEP key of length 128bits @n
+                                        *   The minimum length of the WEP key is 13 digits (104bits). @endif */
+       WIFI_WEP_KEY_LEN_MAX = 65535    // This enum value is for internal use only. Using this enum value can cause behavioral,
+                                       // security-related, and consistency-related issues in the application.
+};
+
+/**
+ * @if OSPDEPREC
+ * @enum    WifiWepKeyIndex
+ *
+ * Defines the Wired Equivalent Privacy (WEP) key index.
+ *
+ * @brief   <i> [Deprecated] </i>
+ * @deprecated  This enum is deprecated because the SetNetworkKeyWep() method is also deprecated.
+ *
+ * @since 2.0
+ *
+ * @remarks Only WIFI_WEP_KEY_INDEX_1 is supported now.
+ * @endif
+ */
+enum WifiWepKeyIndex
+{
+       WIFI_WEP_KEY_INDEX_1 = 1,   /**< @if OSPDEPREC The WEP Key Index 1 @endif */
+       WIFI_WEP_KEY_INDEX_2 = 2,   /**< @if OSPDEPREC The WEP Key Index 2 @endif */
+       WIFI_WEP_KEY_INDEX_3 = 3,   /**< @if OSPDEPREC The WEP Key Index 3 @endif */
+       WIFI_WEP_KEY_INDEX_4 = 4,   /**< @if OSPDEPREC The WEP Key Index 4 @endif */
+};
+
+/**
+ * @enum    WifiRadioChannel
+ *
+ * Defines the BSS radio channel.
+ *
+ * @since   2.0
+ */
+enum WifiRadioChannel
+{
+    WIFI_RADIO_CHANNEL_1        = 1,        /**< The Radio Channel 1 */
+    WIFI_RADIO_CHANNEL_2        = 2,        /**< The Radio Channel 2 */
+    WIFI_RADIO_CHANNEL_3        = 4,        /**< The Radio Channel 3 */
+    WIFI_RADIO_CHANNEL_4        = 8,        /**< The Radio Channel 4 */
+    WIFI_RADIO_CHANNEL_5        = 16,       /**< The Radio Channel 5 */
+    WIFI_RADIO_CHANNEL_6        = 32,       /**< The Radio Channel 6 */
+    WIFI_RADIO_CHANNEL_7        = 64,       /**< The Radio Channel 7 */
+    WIFI_RADIO_CHANNEL_8        = 128,      /**< The Radio Channel 8 */
+    WIFI_RADIO_CHANNEL_9        = 256,      /**< The Radio Channel 9 */
+    WIFI_RADIO_CHANNEL_10       = 512,      /**< The Radio Channel 10 */
+    WIFI_RADIO_CHANNEL_11       = 1024,     /**< The Radio Channel 11 */
+    WIFI_RADIO_CHANNEL_12       = 2048,     /**< The Radio Channel 12 */
+    WIFI_RADIO_CHANNEL_13       = 4096,     /**< The Radio Channel 13 */
+    WIFI_RADIO_CHANNEL_14       = 8192,     /**< The Radio Channel 14 */
+    WIFI_RADIO_CHANNEL_UNKNOWN = 0          // This enum value is for internal use only. Using this enum value can cause
+                                            // behavioral, security-related, and consistency-related issues in the application.
+};
+
+/**
+ * @enum    WifiDirectDeviceStatus
+ *
+ * Defines the status of a Wi-Fi Direct device.
+ *
+ * @since   2.0
+ */
+enum WifiDirectDeviceStatus
+{
+       WIFI_DIRECT_DEVICE_DEACTIVATED = 0,     /**< The Wi-Fi interface is deactivated */
+       WIFI_DIRECT_DEVICE_ACTIVATED            /**< The Wi-Fi interface is activated */
+};
+
+/**
+ * @enum    WifiDirectGroupMemberType
+ *
+ * Defines the type of a Wi-Fi Direct device.
+ *
+ * @since   2.0
+ */
+enum WifiDirectGroupMemberType
+{
+       WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE = 0,  /**< The Wi-Fi Direct Group Non-member @n That is, the device does not belong to any
+                                                 * group. */
+       WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER,     /**< The Wi-Fi Direct Group Owner */
+       WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT     /**< The Wi-Fi Direct Group Client */
+};
+
+/**
+ * @enum    WifiDirectDeviceTypeCategory
+ *
+ * Defines the category of the Wi-Fi Direct device type.
+ *
+ * @since   2.0
+ */
+enum WifiDirectDeviceTypeCategory
+{
+       WIFI_DIRECT_DEVICE_TYPE_CATEGORY_COMPUTER = 0,               /**< The PC, Server, %Media Center, UMPC, Notebook, Desktop,
+                                                                     *   MID, Netbook, and so on */
+       WIFI_DIRECT_DEVICE_TYPE_CATEGORY_INPUT_DEVICE,               /**< The Keyboard, Mouse, Joystick, Trackball, Gaming
+                                                                     *   controller, Remote, Touchscreen, Biometric reader, Barcode
+                                                                     *   reader, and so on */
+       WIFI_DIRECT_DEVICE_TYPE_CATEGORY_PRINTER_SCANNER_FAX_COPIER, /**< The Printer, Print Server, Scanner, Fax, Copier,
+                                                                     *   All-in-one, and so on */
+       WIFI_DIRECT_DEVICE_TYPE_CATEGORY_CAMERA,                     /**< The Digital still camera, Video camera, %Web camera,
+                                                                     *   %Security camera, and so on */
+       WIFI_DIRECT_DEVICE_TYPE_CATEGORY_STORAGE,                    /**< The NAS */
+       WIFI_DIRECT_DEVICE_TYPE_CATEGORY_NETWORK_INFRASTRUCTURE,     /**< The AP, Router, Switch, Gateway, and so on */
+       WIFI_DIRECT_DEVICE_TYPE_CATEGORY_DISPLAY,                    /**< The Television, Electronic picture frame, Projector,
+                                                                     *   Monitor, and so on */
+       WIFI_DIRECT_DEVICE_TYPE_CATEGORY_MULTIMEDIA_DEVICE,          /**< The DAR, PVR, MCX, Set-top box, %Media server, %Media
+                                                                     *   adapter, %Media extender, Portable video player, and so
+                                                                     *   on */
+       WIFI_DIRECT_DEVICE_TYPE_CATEGORY_GAMING_DEVICE,              /**< The Xbox, Playstation, Game console, Game console adaptor,
+                                                                     *   Portable gaming device, and so on */
+       WIFI_DIRECT_DEVICE_TYPE_CATEGORY_TELEPHONE,                  /**< The Windows Mobile, Phone, Smartphone, and so on */
+       WIFI_DIRECT_DEVICE_TYPE_CATEGORY_AUDIO_DEVICE,               /**< The Audio tuner, Audio receiver, Speaker, Portable Music
+                                                                     *   Player, Headset, Headphone, Microphone, and so on */
+       WIFI_DIRECT_DEVICE_TYPE_CATEGORY_OTHERS = 255                /**< A device which is not classified into the above types */
+};
+
+/**
+ * @if OSPDEPREC
+ * @enum    WifiDirectAssociationTerminationReason
+ *
+ * Defines the reason for the Wi-Fi Direct group client association's termination.
+ *
+ * @brief   <i> [Deprecated] </i>
+ * @deprecated   This method is deprecated because the Wi-Fi Direct APIs have been revised to allow the use of APIs with ease irrespective of the role (for example, group owner, group client, and so on). @n
+     * Earlier, the Wi-Fi Direct APIs were strictly provided depending on the role and so it was necessary to use these APIs.
+ *
+ * @since   2.0
+ * @endif
+ */
+enum WifiDirectAssociationTerminationReason
+{
+       WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_SELF_INITIATED = 0, /**< @if OSPDEPREC The enumerator that is delivered to a group owner or
+                                                                       *   group client who initiates the disassociation request @endif */
+       WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_DISCONNECTED        /**< @if OSPDEPREC The enumerator that is delivered to a group owner or
+                                                                       *   group client who receives the disassociation request or
+                                                                       *   when a client is disconnected due to out of range or
+                                                                       *   abrupt connection loss to the group owner @endif */
+};
+
+/**
+ * @enum WifiWpsConfigurationMode
+ *
+ * Defines the configuration method for the Wi-Fi Protected Setup (WPS).
+ *
+ * @since     2.0
+ */
+enum WifiWpsConfigurationMode
+{
+       WIFI_WPS_CONFIG_MODE_NONE = 0,          /**< The configuration mode with no method to be provided */
+       WIFI_WPS_CONFIG_MODE_PIN_DISPLAY,       /**< A method to display the PIN code */
+       WIFI_WPS_CONFIG_MODE_PIN_KEYPAD,        /**< A method to provide the keypad to input the PIN */
+       WIFI_WPS_CONFIG_MODE_PBC                /**< A method of Push Button Configuration (PBC) */
+};
+
+/**
+ * @if VISPARTNER-MANUFACTURER
+ * @enum    WifiConnectionState
+ *
+ * Defines the state of the Wi-Fi connection.
+ *
+ * @since 2.0
+ * @visibility  partner-manufacturer
+ * @endif
+ */
+enum WifiConnectionState
+{
+    WIFI_CONN_STATE_NOT_CONNECTED = 0,  /**< The local device is not connected */
+    WIFI_CONN_STATE_ASSOCIATING,        /**< The local device is associating with an AP */
+    WIFI_CONN_STATE_CONFIGURING,        /**< The local device is configuring after association */
+    WIFI_CONN_STATE_CONNECTED           /**< The local device is completely connected after configuration */
+};
+
+/**
+ * @if VISPARTNER-MANUFACTURER
+ * @enum    WifiSystemScanMode
+ *
+ * Defines the mode of the Wi-Fi background system behaviors, mainly about background scanning.
+ *
+ * @since 2.0
+ * @visibility  partner-manufacturer
+ * @endif
+ */
+enum WifiSystemScanMode
+{
+    WIFI_SYSTEM_SCAN_MODE_ACTIVE = 0,   /**< The background scanning is performed with the short and fixed time interval
+                                         *   (10 seconds) during the Wi-Fi connection is not established. The Wi-Fi target picker
+                                         *   popup for connection is not launched when Wi-Fi is turned on. @n
+                                         *   Generally, this mode is for the case that the Wi-Fi setting app is running on
+                                         *   foreground. */
+    WIFI_SYSTEM_SCAN_MODE_PASSIVE       /**< The background scanning is performed with the exponential backoff time interval
+                                         *   (4, 8, ..., and finally 128 seconds) during the Wi-Fi connection is not established.
+                                         *   The Wi-Fi target picker popup for connection is launched when Wi-Fi is turned on. @n
+                                         *   Generally, this mode is for the both cases that the Wi-Fi setting app is running on
+                                         *   background and terminated. */
+};
+
+} } } // Tizen::Net::Wifi
+#endif // _FNET_WIFI_WIFI_TYPES_H_
diff --git a/osp-net.manifest b/osp-net.manifest
new file mode 100644 (file)
index 0000000..ae3e6f7
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
\ No newline at end of file
diff --git a/osp-net.pc.in b/osp-net.pc.in
new file mode 100755 (executable)
index 0000000..c064287
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib/osp
+includedir=/usr/include/osp
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@ 
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
\ No newline at end of file
diff --git a/packaging/osp-net.spec b/packaging/osp-net.spec
new file mode 100755 (executable)
index 0000000..d519559
--- /dev/null
@@ -0,0 +1,110 @@
+%define debug_package %{nil}
+%define __strip /bin/true
+
+Name:       osp-net
+Summary:    The Network library of OSP 
+Version:    1.2.0.0
+Release:    1
+Group:      System/Libraries
+License:    Apache License, Version 2.0 or Flora
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(capi-network-connection)
+BuildRequires:  pkgconfig(capi-network-serial)
+BuildRequires:  pkgconfig(capi-network-tethering)
+BuildRequires:  pkgconfig(capi-network-wifi)
+BuildRequires:  pkgconfig(capi-system-device)
+BuildRequires:  pkgconfig(capi-system-info)
+BuildRequires:  pkgconfig(chromium)
+BuildRequires:  pkgconfig(libcurl)
+BuildRequires:  pkgconfig(libwbxml2)
+BuildRequires:  pkgconfig(osp-appfw)
+BuildRequires:  osp-appfw-internal-devel
+BuildRequires:  pkgconfig(openssl)
+BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(wifi-direct)
+
+
+# runtime requires
+Requires: capi-network-wifi-direct  
+Requires: capi-network-wifi 
+Requires: capi-network-connection  
+Requires: capi-network-serial  
+Requires: capi-network-tethering
+Requires: osp-appfw 
+Requires: chromium
+
+Provides:   libosp-net.so.1 libosp-wifi.so.1 
+
+Requires(post): /sbin/ldconfig  
+Requires(postun): /sbin/ldconfig
+
+%description
+The Network library of OSP
+
+%package devel
+Summary:    The Network library of OSP (Development)
+Group:      TO_BE/FILLED_IN
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+The Network library of OSP (DEV)
+
+%package internal-devel
+Summary:    osp network internel (Internal)
+Group:      TO_BE/FILLED_IN
+Requires:   %{name} = %{version}-%{release}
+
+%description internal-devel
+The Network library of OSP (Internal-DEV)
+
+%package debug
+Summary:    The Network library of OSP (Development)
+Group:      TO_BE/FILLED_IN
+Requires:   %{name} = %{version}-%{release}
+
+%description debug
+The Network library of OSP (DEV)
+
+%prep
+
+%setup -q
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%ifarch %{ix86}
+CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DOBS=1 -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DARCH=x86
+%else
+CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DOBS=1 -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DARCH=arm
+%endif
+
+# Call make instruction with smp support
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp %{_builddir}/%{name}-%{version}/LICENSE.Flora  %{buildroot}/usr/share/license/%{name}
+cat %{_builddir}/%{name}-%{version}/LICENSE.APLv2 >> %{buildroot}/usr/share/license/%{name}
+
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest osp-net.manifest
+/usr/share/license/%{name}
+%{_libdir}/osp/*.so*
+
+%files devel
+%{_includedir}/osp/*.h
+%{_libdir}/pkgconfig/osp-net.pc
+
+%files internal-devel
+%{_includedir}/osp/net/*
+
+%files debug
+%{_libdir}/osp/debug/*.so*
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..4a208c8
--- /dev/null
@@ -0,0 +1,171 @@
+SET (this_target osp-net)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/inc
+       inc
+       /usr/include/chromium
+       /usr/include/curl
+       /usr/include/glib-2.0 
+  /usr/lib/glib-2.0/include
+  /usr/include/libxml2
+  /usr/include/network
+       /usr/include/osp
+       /usr/include/osp/app
+       /usr/include/osp/base
+       /usr/include/osp/io
+       /usr/include/osp/security
+       /usr/include/vconf
+       /usr/include/wifi-direct        
+       )
+
+SET (${this_target}_SOURCE_FILES
+       http/FNetHttp_HttpCommon.cpp
+       http/FNetHttpHttpAuthentication.cpp
+       http/FNetHttp_HttpAuthenticationImpl.cpp
+       http/FNetHttpHttpCookie.cpp
+       http/FNetHttp_HttpCookieImpl.cpp
+       http/FNetHttpHttpCookieStorageManager.cpp
+       http/FNetHttp_HttpCookieStorageManagerImpl.cpp
+       http/FNetHttpHttpCredentials.cpp
+       http/FNetHttpHttpHeader.cpp
+       http/FNetHttp_HttpHeaderImpl.cpp
+       http/FNetHttpHttpMessage.cpp
+       http/FNetHttpHttpRequest.cpp
+       http/FNetHttp_HttpRequestImpl.cpp
+       http/FNetHttpHttpResponse.cpp
+       http/FNetHttp_HttpResponseImpl.cpp
+       http/FNetHttpHttpSession.cpp
+       http/FNetHttp_HttpSessionImpl.cpp
+       http/FNetHttp_HttpMultipleConnectionInfo.cpp
+       http/FNetHttp_HttpTransactionEvent.cpp
+       http/FNetHttp_HttpTransactionEventArg.cpp
+       http/FNetHttpHttpTransaction.cpp
+       http/FNetHttp_HttpTransactionImpl.cpp
+       http/FNetHttp_HttpTransactionUserData.cpp
+       http/FNetHttp_HttpCurl.cpp
+       http/FNetHttp_HttpSocketInfo.cpp
+       http/FNetHttpHttpMultipartEntity.cpp
+       http/FNetHttp_HttpMultipartConverter.cpp
+       http/FNetHttp_HttpMultipartEntityImpl.cpp
+       http/FNetHttp_HttpStringPart.cpp
+       http/FNetHttp_HttpFilePart.cpp
+       http/FNetHttpHttpStringEntity.cpp
+       http/FNetHttp_HttpStringEntityImpl.cpp
+       http/FNetHttpHttpUrlEncodedEntity.cpp
+       http/FNetHttp_HttpUrlEncodedEntityImpl.cpp
+       http/FNetHttpHttpXmlDomEntity.cpp
+       http/FNetHttp_HttpXmlDomEntityImpl.cpp
+       http/FNetHttp_HttpManagedNetConnectionEventListenerImpl.cpp
+       http/FNetHttp_HttpNetConnectionEventListenerImpl.cpp
+       FNetDns.cpp
+       FNet_DnsImpl.cpp
+       FNet_DnsManagedNetConnectionEventListener.cpp
+       FNet_DnsRequestHandler.cpp
+       FNet_DnsEvent.cpp
+       FNet_DnsEventArg.cpp
+       FNetIp4Address.cpp
+       FNet_Ip4AddressImpl.cpp
+       FNetIpAddress.cpp
+       FNetIpHostEntry.cpp
+       FNet_IpHostEntryImpl.cpp
+       FNetManagedNetConnection.cpp
+       FNet_ManagedNetConnectionImpl.cpp
+       FNetNetAccountInfo.cpp
+       FNet_NetAccountInfoImpl.cpp
+       FNetNetAccountManager.cpp
+       FNetNetAccountManagerPartner.cpp
+       FNet_NetAccountManagerImpl.cpp
+       FNetNetConnection.cpp
+       FNet_NetConnectionImpl.cpp
+       FNetNetConnectionInfo.cpp
+       FNet_NetConnectionInfoImpl.cpp
+       FNetNetConnectionManager.cpp
+       FNet_NetConnectionManagerImpl.cpp
+       FNetNetEndPoint.cpp
+       FNet_NetEndPointImpl.cpp
+       FNetNetStatistics.cpp
+       FNet_NetStatisticsImpl.cpp
+       FNet_LocalDhcpServerEvent.cpp
+       FNet_LocalDhcpServerEventArg.cpp
+       FNetLocalDhcpServer.cpp
+       FNet_LocalDhcpServerImpl.cpp
+       FNetDhcpClientInfo.cpp
+       FNet_DhcpClientInfoImpl.cpp
+       FNet_NetAccountDatabase.cpp
+       FNet_NetConnectionEvent.cpp
+       FNet_NetConnectionEventArg.cpp
+       FNet_NetExporter.cpp
+       FNet_NetUtility.cpp
+       FNet_SystemNetConnection.cpp
+       FNet_DefaultSystemNetConnection.cpp
+       FNet_PsSystemNetConnection.cpp
+       FNet_WifiSystemNetConnection.cpp
+       FNet_WifiDirectSystemNetConnection.cpp
+       FNet_UsbSystemNetConnection.cpp
+       FNet_NetIpcProxy.cpp
+       FNet_NetIpcMessages.cpp
+       sockets/FNetSockSocket.cpp
+       sockets/FNetSock_SocketImpl.cpp
+       sockets/FNetSockSecureSocket.cpp
+       sockets/FNetSock_SecureSocketImpl.cpp
+       sockets/FNetSockSocketIpMulticastRequestOption.cpp
+       sockets/FNetSock_IpMulticastRequestOptionImpl.cpp
+       sockets/FNetSockSocketLingerOption.cpp
+       sockets/FNetSock_LingerOptionImpl.cpp
+       sockets/FNetSockSocketUtility.cpp
+       sockets/FNetSock_SocketUtilityImpl.cpp
+       sockets/FNetSock_SocketEvent.cpp
+       sockets/FNetSock_SocketEventArg.cpp
+       sockets/FNetSock_SecureSocketEvent.cpp
+       sockets/FNetSock_SecureSocketEventArg.cpp
+       sockets/FNetSock_SocketInternalHelp.cpp
+       sockets/FNetSock_SocketManagedNetConnectionEventListenerImpl.cpp
+       sockets/FNetSock_SocketCustomNetConnectionEventListenerImpl.cpp
+       sockets/FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.cpp
+       sockets/FNetSock_SecureSocketManagedNetConnectionEventListenerImpl.cpp
+)
+
+## Definitions
+SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -Wall" )
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## Create Library
+ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+## SET LINKER FLAGS
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed")
+
+TARGET_LINK_LIBRARIES(${this_target} "-lchromium" )
+TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw" )
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-network-connection" )
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-network-tethering" )
+TARGET_LINK_LIBRARIES(${this_target} "-lssl" )
+TARGET_LINK_LIBRARIES(${this_target} "-lcurl" )
+TARGET_LINK_LIBRARIES(${this_target} "-lwifi-direct" )
+TARGET_LINK_LIBRARIES(${this_target} "-lglib-2.0" )
+TARGET_LINK_LIBRARIES(${this_target} "-lpthread" )
+TARGET_LINK_LIBRARIES(${this_target} "-ldl" )
+TARGET_LINK_LIBRARIES(${this_target} "-lvconf" )
+TARGET_LINK_LIBRARIES(${this_target} "-lxml2" )
+TARGET_LINK_LIBRARIES(${this_target} "-lcrypto" )
+
+SET_TARGET_PROPERTIES(${this_target} 
+       PROPERTIES 
+       VERSION ${FULLVER}
+       SOVERSION ${MAJORVER}
+       CLEAN_DIRECT_OUTPUT 1
+       )
+
+ADD_CUSTOM_COMMAND(TARGET ${this_target}
+    POST_BUILD
+               COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} 
+               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${MAJORVER}
+               COMMAND ${CMAKE_STRIP} --strip-unneeded ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}
+    COMMENT "strip ${this_target}"
+               )   
diff --git a/src/FNetDhcpClientInfo.cpp b/src/FNetDhcpClientInfo.cpp
new file mode 100644 (file)
index 0000000..4cd18c8
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNetDhcpClientInfo.cpp
+ * @brief              This is the implementation file for the DhcpClientInfo Class.
+ *
+ * This header file contains implementation of the DhcpClientInfo Class.
+ */
+
+#include <FNetDhcpClientInfo.h>
+#include <FBaseSysLog.h>
+#include "FNet_DhcpClientInfoImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net
+{
+
+DhcpClientInfo::DhcpClientInfo(void)
+{
+       __pDhcpClientInfoImpl = new (std::nothrow) _DhcpClientInfoImpl();
+       SysTryReturnVoidResult(NID_NET, __pDhcpClientInfoImpl != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+DhcpClientInfo::DhcpClientInfo(const DhcpClientInfo& rhs)
+{
+       __pDhcpClientInfoImpl = new (std::nothrow) _DhcpClientInfoImpl(rhs);
+       SysTryReturnVoidResult(NID_NET, __pDhcpClientInfoImpl != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+DhcpClientInfo::~DhcpClientInfo(void)
+{
+       delete __pDhcpClientInfoImpl;
+       __pDhcpClientInfoImpl = null;
+}
+
+String
+DhcpClientInfo::GetName(void) const
+{
+       return __pDhcpClientInfoImpl->GetName();
+}
+
+const IpAddress*
+DhcpClientInfo::GetIpAddress(void) const
+{
+       return __pDhcpClientInfoImpl->GetLocalAddress();
+}
+
+String
+DhcpClientInfo::GetMacAddress(void) const
+{
+       return __pDhcpClientInfoImpl->GetMacAddress();
+}
+
+bool
+DhcpClientInfo::Equals(const Object& rhs) const
+{
+       const DhcpClientInfo* pRhs = dynamic_cast<const DhcpClientInfo*>(&rhs);
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       const _DhcpClientInfoImpl* pRhsImpl = _DhcpClientInfoImpl::GetInstance(*pRhs);
+       if (pRhsImpl == null)
+       {
+               return false;
+       }
+
+       return __pDhcpClientInfoImpl->Equals(*pRhsImpl);
+}
+
+int
+DhcpClientInfo::GetHashCode(void) const
+{
+       return __pDhcpClientInfoImpl->GetHashCode();
+}
+
+}} // Tizen::Net
diff --git a/src/FNetDns.cpp b/src/FNetDns.cpp
new file mode 100644 (file)
index 0000000..16137dc
--- /dev/null
@@ -0,0 +1,123 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file                       FNetDns.cpp
+ * @brief              This is the implementation for the Dns class.
+ */
+
+#include <unique_ptr.h>
+#include <FNetDns.h>
+#include <FNetIpAddress.h>
+#include <FNetNetConnection.h>
+#include <FNetIDnsEventListener.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FNet_DnsImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net
+{
+
+Dns::Dns(void)
+       : __pDnsImpl(null)
+{
+}
+
+Dns::~Dns(void)
+{
+       delete __pDnsImpl;
+       __pDnsImpl = null;
+}
+
+result
+Dns::Construct(const NetConnection& netConnection, IDnsEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pDnsImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       unique_ptr<_DnsImpl> pDnsImpl(new (std::nothrow) _DnsImpl());
+       SysTryReturnResult(NID_NET, pDnsImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pDnsImpl->Construct(netConnection, listener);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       __pDnsImpl = pDnsImpl.release();
+
+       return r;
+}
+
+result
+Dns::Construct(IDnsEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pDnsImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       unique_ptr<_DnsImpl> pDnsImpl(new (std::nothrow) _DnsImpl());
+       SysTryReturnResult(NID_NET, pDnsImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pDnsImpl->Construct(listener);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       __pDnsImpl = pDnsImpl.release();
+
+       return r;
+}
+
+result
+Dns::GetHostByName(const String& hostName)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_DNS);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r,
+                       "The application does not have the privilege to call this method.");
+
+       SysAssertf(__pDnsImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pDnsImpl->GetHostByName(hostName);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Dns::GetHostByAddress(const IpAddress& ipAddress)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_DNS);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r,
+                       "The application does not have the privilege to call this method.");
+
+       SysAssertf(__pDnsImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pDnsImpl->GetHostByAddress(ipAddress);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+} }  // Tizen::Net
diff --git a/src/FNetIp4Address.cpp b/src/FNetIp4Address.cpp
new file mode 100644 (file)
index 0000000..0c425bb
--- /dev/null
@@ -0,0 +1,150 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetIp4Address.cpp
+ * @brief              This is the implementation for the %Ip4Address class.
+ */
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseUtilStringUtil.h>
+#include <FNetNetTypes.h>
+#include <FNetIp4Address.h>
+#include <FBaseSysLog.h>
+#include "FNet_Ip4AddressImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Net
+{
+
+Ip4Address::Ip4Address(const String& ipAddr)
+{
+       __pIp4AddressImpl = new (std::nothrow) _Ip4AddressImpl(ipAddr);
+       SysTryReturnVoidResult(NID_NET, __pIp4AddressImpl != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Ip4Address::Ip4Address(unsigned long ipAddr)
+{
+       __pIp4AddressImpl = new (std::nothrow) _Ip4AddressImpl(ipAddr);
+       SysTryReturnVoidResult(NID_NET, __pIp4AddressImpl != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Ip4Address::Ip4Address(const Ip4Address& rhs)
+{
+       __pIp4AddressImpl = new (std::nothrow) _Ip4AddressImpl(*rhs.__pIp4AddressImpl);
+       SysTryReturnVoidResult(NID_NET, __pIp4AddressImpl != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+Ip4Address::~Ip4Address(void)
+{
+       delete __pIp4AddressImpl;
+       __pIp4AddressImpl = null;
+}
+
+NetAddressFamily
+Ip4Address::GetNetAddressFamily(void) const
+{
+       return __pIp4AddressImpl->GetNetAddressFamily();
+}
+
+result
+Ip4Address::GetAddress(ByteBuffer& ipAddr) const
+{
+       result r = E_SUCCESS;
+
+       r = __pIp4AddressImpl->GetAddress(ipAddr);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Ip4Address::GetAddress(unsigned long& ipAddr) const
+{
+       result r = E_SUCCESS;
+
+       r = __pIp4AddressImpl->GetAddress(ipAddr);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+String
+Ip4Address::ToString(void) const
+{
+       return __pIp4AddressImpl->ToString();
+}
+
+Ip4Address&
+Ip4Address::operator =(const Ip4Address& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       _pIpAddressImpl = null; // Not used yet
+
+       *__pIp4AddressImpl = *rhs.__pIp4AddressImpl;
+
+       return *this;
+}
+
+IpAddress*
+Ip4Address::CloneN(void) const
+{
+       Ip4Address* pClone = new (std::nothrow) Ip4Address(*this);
+       SysTryReturn(NID_NET, pClone != null, null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pClone;
+}
+
+bool
+Ip4Address::Equals(const Object& rhs) const
+{
+       const Ip4Address* pRhs = dynamic_cast<const Ip4Address*>(&rhs);
+
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       const _Ip4AddressImpl* pRhsImpl = _Ip4AddressImpl::GetInstance(*pRhs);
+
+       if (pRhsImpl == null)
+       {
+               return false;
+       }
+
+       return __pIp4AddressImpl->Equals(*pRhsImpl);
+}
+
+int
+Ip4Address::GetHashCode(void) const
+{
+       return __pIp4AddressImpl->GetHashCode();
+}
+
+} } // Tizen::Net
diff --git a/src/FNetIpAddress.cpp b/src/FNetIpAddress.cpp
new file mode 100644 (file)
index 0000000..800ea7c
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetIpAddress.cpp
+ * @brief              This is the implementation for the %IpAddress class.
+ */
+
+#include <arpa/inet.h>
+#include <FNetIpAddress.h>
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net
+{
+
+IpAddress::IpAddress(void)
+       : _pIpAddressImpl(null)
+{
+}
+
+IpAddress::~IpAddress(void)
+{
+}
+
+unsigned short
+IpAddress::HostToNetworkOrder(unsigned short host)
+{
+       return htons(host);
+}
+
+unsigned long
+IpAddress::HostToNetworkOrder(unsigned long host)
+{
+       return htonl(host);
+}
+
+unsigned short
+IpAddress::NetworkToHostOrder(unsigned short network)
+{
+       return ntohs(network);
+}
+
+unsigned long
+IpAddress::NetworkToHostOrder(unsigned long network)
+{
+       return ntohl(network);
+}
+
+} } // Tizen::Net
diff --git a/src/FNetIpHostEntry.cpp b/src/FNetIpHostEntry.cpp
new file mode 100644 (file)
index 0000000..c9bd085
--- /dev/null
@@ -0,0 +1,73 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNetIpHostEntry.cpp
+ * @brief              This is the implementation for the IpHostEntry class.
+ */
+
+#include <FBaseColArrayList.h>
+#include <FBaseUtilStringUtil.h>
+#include <FNetNetTypes.h>
+#include <FNetIpHostEntry.h>
+#include <FNetIp4Address.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_IpHostEntryImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Net
+{
+
+IpHostEntry::~IpHostEntry(void)
+{
+       delete __pIpHostEntryImpl;
+       __pIpHostEntryImpl = null;
+}
+
+IList*
+IpHostEntry::GetAddressList(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET, __pIpHostEntryImpl != null, null, E_INVALID_STATE,
+                       "[%s] IpHostEntry instance is in an invalid State", GetErrorMessage(E_INVALID_STATE));
+
+       return __pIpHostEntryImpl->GetAddressList();
+}
+
+
+IList*
+IpHostEntry::GetAliasList(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET, __pIpHostEntryImpl != null, null, E_INVALID_STATE,
+                       "[%s] IpHostEntry instance is in an invalid State", GetErrorMessage(E_INVALID_STATE));
+       return __pIpHostEntryImpl->GetAliasList();
+}
+
+IpHostEntry::IpHostEntry(void)
+{
+       __pIpHostEntryImpl = new (std::nothrow) _IpHostEntryImpl();
+       SysTryReturnVoidResult(NID_NET, __pIpHostEntryImpl != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+} }  // Tizen::Net
diff --git a/src/FNetLocalDhcpServer.cpp b/src/FNetLocalDhcpServer.cpp
new file mode 100644 (file)
index 0000000..8889430
--- /dev/null
@@ -0,0 +1,186 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNetLocalDhcpServer.cpp
+ * @brief              This is the implementation file for the LocalDhcpServer Class.
+ *
+ * This header file contains implementation of the LocalDhcpServer Class.
+ */
+
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseResult.h>
+#include <FBaseColIList.h>
+#include <FNetNetTypes.h>
+#include <FNetNetConnection.h>
+#include <FNetLocalDhcpServer.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_LocalDhcpServerEvent.h"
+#include "FNet_LocalDhcpServerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net
+{
+
+static const int  _MAX_ACTIVE_NETWORK_COUNT = 32;
+
+static ArrayList* gpLocalDhcpServerList = null;
+
+LocalDhcpServer::LocalDhcpServer(void)
+       : __pLocalDhcpServerImpl(null)
+{
+}
+
+LocalDhcpServer::~LocalDhcpServer(void)
+{
+       if (__pLocalDhcpServerImpl != null)
+       {
+               delete __pLocalDhcpServerImpl;
+               __pLocalDhcpServerImpl = null;
+
+               //remove from list also
+               if (gpLocalDhcpServerList != null)
+               {
+                       gpLocalDhcpServerList->Remove(*this);
+               }
+       }
+
+       // when count is zero, cleanup list
+       if ((gpLocalDhcpServerList != null) && (gpLocalDhcpServerList->GetCount() == 0))
+       {
+               gpLocalDhcpServerList->RemoveAll(true);
+               delete gpLocalDhcpServerList;
+               gpLocalDhcpServerList = null;
+       }
+}
+
+LocalDhcpServer*
+LocalDhcpServer::GetInstance(const NetConnection& netConnection)
+{
+       result r = E_SUCCESS;
+       LocalDhcpServer* pLocalDhcpServer = null;
+
+       ClearLastResult();
+
+       // create list,if list is not created
+       if (gpLocalDhcpServerList == null)
+       {
+               gpLocalDhcpServerList = new (std::nothrow) ArrayList();
+               SysTryReturn(NID_NET, gpLocalDhcpServerList != null, null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = gpLocalDhcpServerList->Construct(_MAX_ACTIVE_NETWORK_COUNT);
+               SysTryCatch(NID_NET, r == E_SUCCESS, r = E_OUT_OF_MEMORY , E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       // check if we already have the server created
+       // if yes, search the list and return that, else create a new and add to the list
+       if (gpLocalDhcpServerList->GetCount() == 0)
+       {
+               pLocalDhcpServer = new (std::nothrow) LocalDhcpServer();
+               SysTryCatch(NID_NET, pLocalDhcpServer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = gpLocalDhcpServerList->Add(*pLocalDhcpServer);
+               SysTryCatch(NID_NET, r == E_SUCCESS, r = E_SYSTEM , E_SYSTEM,
+                               "[%s] A system error has been occurred. Failed to add local dhcp server to the list.", GetErrorMessage(E_SYSTEM));
+
+               pLocalDhcpServer->__pLocalDhcpServerImpl = new (std::nothrow) _LocalDhcpServerImpl();
+               SysTryCatch(NID_NET, pLocalDhcpServer->__pLocalDhcpServerImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pLocalDhcpServer->__pLocalDhcpServerImpl->Construct(pLocalDhcpServer, netConnection);
+               SysTryCatch(NID_NET, r == E_SUCCESS, , r, "%s", GetErrorMessage(r));
+
+       }
+       else
+       {
+               // get LocalDhcpServer based on netConnection
+               pLocalDhcpServer = _LocalDhcpServerImpl::GetLocalDhcpServer(gpLocalDhcpServerList, netConnection);
+
+               // if not found, create new
+               if (pLocalDhcpServer == null)
+               {
+                       pLocalDhcpServer = new (std::nothrow) LocalDhcpServer();
+                       SysTryCatch(NID_NET, pLocalDhcpServer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       r = gpLocalDhcpServerList->Add(*pLocalDhcpServer);
+                       SysTryCatch(NID_NET, r == E_SUCCESS, r = E_SYSTEM , E_SYSTEM,
+                                       "[%s] A system error has been occurred. Failed to add local dhcp server to the list.", GetErrorMessage(E_SYSTEM));
+
+                       pLocalDhcpServer->__pLocalDhcpServerImpl = new (std::nothrow) _LocalDhcpServerImpl();
+                       SysTryCatch(NID_NET, pLocalDhcpServer->__pLocalDhcpServerImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       r = pLocalDhcpServer->__pLocalDhcpServerImpl->Construct(pLocalDhcpServer, netConnection);
+                       SysTryCatch(NID_NET, r == E_SUCCESS, , r, "%s", GetErrorMessage(r));
+
+                       SysLog(NID_NET, "New instance added \n");
+               }
+       }
+
+       return pLocalDhcpServer;
+
+CATCH:
+       if (pLocalDhcpServer != null)
+       {
+               gpLocalDhcpServerList->Remove(*pLocalDhcpServer);
+               delete pLocalDhcpServer;
+                pLocalDhcpServer = null;
+       }
+       if ((gpLocalDhcpServerList != null) && (gpLocalDhcpServerList->GetCount() == 0))
+       {
+               gpLocalDhcpServerList->RemoveAll(true);
+               delete gpLocalDhcpServerList;
+               gpLocalDhcpServerList = null;
+       }
+
+       return null;
+}
+
+result
+LocalDhcpServer::SetLocalDhcpServerEventListener(ILocalDhcpServerEventListener* pListener)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET, gpLocalDhcpServerList != null, E_INVALID_STATE,
+                       "This instance has not been constructed or destroyed.");
+
+       r = __pLocalDhcpServerImpl->SetLocalDhcpServerEventListener(pListener);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+IList*
+LocalDhcpServer::GetDhcpClientInfoListN(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET, gpLocalDhcpServerList != null, null, E_INVALID_STATE,
+                          "[%s] LocalDhcpServerList is in an invalid state. This instance has not been constructed or destroyed.",
+                          GetErrorMessage(E_INVALID_STATE));
+
+       return __pLocalDhcpServerImpl->GetDhcpClientInfoListN();
+}
+
+}} // Tizen::Net
diff --git a/src/FNetManagedNetConnection.cpp b/src/FNetManagedNetConnection.cpp
new file mode 100644 (file)
index 0000000..034d125
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetManagedNetConnection.cpp
+ * @brief              This is the implementation for the %ManagedNetConnection class.
+ */
+
+#include <FNetManagedNetConnection.h>
+#include <FNetNetConnectionManager.h>
+#include <FBaseSysLog.h>
+#include "FNet_ManagedNetConnectionImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net
+{
+
+ManagedNetConnection::ManagedNetConnection()
+       : __pManagedNetConnectionImpl(null)
+{
+       __pManagedNetConnectionImpl = new (std::nothrow) _ManagedNetConnectionImpl(this);
+       SysTryReturnVoidResult(NID_NET, __pManagedNetConnectionImpl != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+ManagedNetConnection::~ManagedNetConnection(void)
+{
+       delete __pManagedNetConnectionImpl;
+       __pManagedNetConnectionImpl = null;
+}
+
+result
+ManagedNetConnection::SetManagedNetConnectionEventListener(IManagedNetConnectionEventListener* pListener)
+{
+       result r = E_SUCCESS;
+
+       r = __pManagedNetConnectionImpl->SetManagedNetConnectionEventListener(pListener);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+NetConnectionState
+ManagedNetConnection::GetConnectionState(void) const
+{
+       return __pManagedNetConnectionImpl->GetConnectionState();
+}
+
+NetAccountId
+ManagedNetConnection::GetNetAccountId(void) const
+{
+       return __pManagedNetConnectionImpl->GetNetAccountId();
+}
+
+const NetConnectionInfo*
+ManagedNetConnection::GetNetConnectionInfo(void) const
+{
+       return __pManagedNetConnectionImpl->GetNetConnectionInfo();
+}
+
+} } // Tizen::Net
+
+
diff --git a/src/FNetNetAccountInfo.cpp b/src/FNetNetAccountInfo.cpp
new file mode 100644 (file)
index 0000000..5c325e8
--- /dev/null
@@ -0,0 +1,318 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNetNetAccountInfo.cpp
+ * @brief              This is the implementation for the FNetNetAccountInfo class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FBaseUtilStringUtil.h>
+#include <FNetNetTypes.h>
+#include <FNetNetEndPoint.h>
+#include <FNetNetAccountInfo.h>
+#include <FNetNetAccountManager.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_NetAccountInfoImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Net
+{
+
+NetAccountInfo::NetAccountInfo(void)
+       : __pNetAccountInfoImpl(null)
+{
+}
+
+NetAccountInfo::~NetAccountInfo(void)
+{
+       delete __pNetAccountInfoImpl;
+       __pNetAccountInfoImpl = null;
+}
+
+result
+NetAccountInfo::Construct(const NetAccountInfo& netAccountInfo)
+{
+       result r = E_SUCCESS;
+       const _NetAccountInfoImpl* pOtherNetAccountInfoImpl = _NetAccountInfoImpl::GetInstance(netAccountInfo);
+
+       SysAssertf(__pNetAccountInfoImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       SysTryReturnResult(NID_NET, pOtherNetAccountInfoImpl != null, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. The specified netAccountInfo is invalid.", GetErrorMessage(E_INVALID_ARG));
+
+       unique_ptr<_NetAccountInfoImpl> pNetAccountInfoImpl(new (std::nothrow) _NetAccountInfoImpl());
+       SysTryReturnResult(NID_NET, pNetAccountInfoImpl != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pNetAccountInfoImpl->Construct(*pOtherNetAccountInfoImpl);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       __pNetAccountInfoImpl = pNetAccountInfoImpl.release();
+
+       return r;
+}
+
+result
+NetAccountInfo::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pNetAccountInfoImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       unique_ptr<_NetAccountInfoImpl> pNetAccountInfoImpl(new (std::nothrow) _NetAccountInfoImpl());
+       SysTryReturnResult(NID_NET, pNetAccountInfoImpl != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pNetAccountInfoImpl->Construct();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       __pNetAccountInfoImpl = pNetAccountInfoImpl.release();
+
+       return r;
+}
+
+NetAccountId
+NetAccountInfo::GetAccountId(void)  const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->GetAccountId();
+}
+
+String
+NetAccountInfo::GetAccountName(void) const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->GetAccountName();
+}
+
+result
+NetAccountInfo::SetAccountName(const String& accountName)
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->SetAccountName(accountName);
+}
+
+NetProtocolType
+NetAccountInfo::GetProtocolType(void) const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->GetProtocolType();
+}
+
+result
+NetAccountInfo::SetProtocolType(const NetProtocolType netProtocolType)
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->SetProtocolType(netProtocolType);
+}
+
+String
+NetAccountInfo::GetAccessPointName(void)  const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->GetAccessPointName();
+}
+
+result
+NetAccountInfo::SetAccessPointName(const String& accessPointName)
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->SetAccessPointName(accessPointName);
+}
+
+NetAddressScheme
+NetAccountInfo::GetLocalAddressScheme(void) const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->GetLocalAddressScheme();
+}
+
+const IpAddress*
+NetAccountInfo::GetLocalAddress(void) const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->GetLocalAddress();
+}
+
+result
+NetAccountInfo::SetLocalAddress(NetAddressScheme localAddrScheme, const IpAddress* pLocalAddress)
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->SetLocalAddress(localAddrScheme, pLocalAddress);
+}
+
+const NetEndPoint*
+NetAccountInfo::GetProxyAddress(void) const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->GetProxyAddress();
+}
+
+result
+NetAccountInfo::SetProxyAddress(const NetEndPoint* pProxyEndPoint)
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->SetProxyAddress(pProxyEndPoint);
+}
+
+NetAddressScheme
+NetAccountInfo::GetDnsAddressScheme(void) const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->GetDnsAddressScheme();
+}
+
+const IpAddress*
+NetAccountInfo::GetPrimaryDnsAddress(void) const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->GetPrimaryDnsAddress();
+}
+
+const IpAddress*
+NetAccountInfo::GetSecondaryDnsAddress(void) const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->GetSecondaryDnsAddress();
+}
+
+result
+NetAccountInfo::SetDnsAddress(NetAddressScheme dnsAddressScheme, const IpAddress* pPrimaryDnsAddress,
+                                                         const IpAddress* pSecondaryDnsAddress)
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->SetDnsAddress(dnsAddressScheme, pPrimaryDnsAddress, pSecondaryDnsAddress);
+}
+
+result
+NetAccountInfo::GetAuthenticationInfo(NetNapAuthType& authenticationType, String& id, String& password) const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->GetAuthenticationInfo(authenticationType, id, password);
+}
+
+result
+NetAccountInfo::SetAuthenticationInfo(NetNapAuthType authenticationType, const String& id, const String& password)
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->SetAuthenticationInfo(authenticationType, id, password);
+}
+
+NetBearerType
+NetAccountInfo::GetBearerType(void) const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->GetBearerType();
+}
+
+String
+NetAccountInfo::GetHomeUrl(void) const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->GetHomeUrl();
+}
+
+void
+NetAccountInfo::SetHomeUrl(const String& homeUrl)
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       __pNetAccountInfoImpl->SetHomeUrl(homeUrl);
+}
+
+int
+NetAccountInfo::GetMaximumLengthOfId(void) const
+{
+       return _MAX_AUTH_ID_LENGTH;
+}
+
+int
+NetAccountInfo::GetMaximumLengthOfPassword(void) const
+{
+       return _MAX_AUTH_PASSWORD_LENGTH;
+}
+
+int
+NetAccountInfo::GetMaximumLengthOfAccountName(void) const
+{
+       return _MAX_ACCOUNT_NAME_LENGTH;
+}
+
+bool
+NetAccountInfo::IsReadOnly(void) const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->IsReadOnly();
+}
+
+bool
+NetAccountInfo::Equals(const Object& rhs) const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       const NetAccountInfo* pRhs = dynamic_cast<const NetAccountInfo*>(&rhs);
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       const _NetAccountInfoImpl* pRhsImpl = _NetAccountInfoImpl::GetInstance(*pRhs);
+       if (pRhsImpl == null)
+       {
+               return false;
+       }
+
+       return __pNetAccountInfoImpl->Equals(*pRhsImpl);
+}
+
+int
+NetAccountInfo::GetHashCode(void) const
+{
+       SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetAccountInfoImpl->GetHashCode();
+}
+
+}} // Tizen::Net
diff --git a/src/FNetNetAccountManager.cpp b/src/FNetNetAccountManager.cpp
new file mode 100644 (file)
index 0000000..0d480f1
--- /dev/null
@@ -0,0 +1,229 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file                       FNetNetAccountManager.cpp
+ * @brief              This is the implementation for the %NetAccountManagerclass.
+ */
+
+#include <unique_ptr.h>
+#include <FNetNetAccountManager.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FNet_NetAccountManagerImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net
+{
+
+NetAccountManager::NetAccountManager(void)
+       : __pNetAccountManagerImpl(null)
+{
+}
+
+NetAccountManager::~NetAccountManager(void)
+{
+       delete __pNetAccountManagerImpl;
+       __pNetAccountManagerImpl = null;
+}
+
+result
+NetAccountManager::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pNetAccountManagerImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       unique_ptr<_NetAccountManagerImpl> pNetAccountManagerImpl(new (std::nothrow) _NetAccountManagerImpl());
+       SysTryReturnResult(NID_NET, pNetAccountManagerImpl != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pNetAccountManagerImpl->Construct();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       __pNetAccountManagerImpl = pNetAccountManagerImpl.release();
+
+       return r;
+}
+
+NetAccountId
+NetAccountManager::CreateNetAccount(NetAccountInfo& netAccountInfo)
+{
+       result r = E_SUCCESS;
+       NetAccountId netAccountId = INVALID_HANDLE;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_NETWORK_ACCOUNT);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET, r == E_SUCCESS, INVALID_HANDLE, r,
+                       "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       netAccountId = __pNetAccountManagerImpl->CreateNetAccount(netAccountInfo);
+       r = GetLastResult();
+       SysTryReturn(NID_NET, netAccountId != INVALID_HANDLE, INVALID_HANDLE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return netAccountId;
+}
+
+result
+NetAccountManager::DeleteNetAccount(NetAccountId netAccountId)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_NETWORK_ACCOUNT);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r,
+                       "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pNetAccountManagerImpl->DeleteNetAccount(netAccountId);
+       SysTryReturn(NID_NET, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+NetAccountManager::UpdateNetAccount(const NetAccountInfo& netAccountInfo)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_NETWORK_ACCOUNT);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r,
+                       "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pNetAccountManagerImpl->UpdateNetAccount(netAccountInfo);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+NetAccountInfo*
+NetAccountManager::GetNetAccountInfoN(NetAccountId netAccountId) const
+{
+       result r = E_SUCCESS;
+       NetAccountInfo* pInfo = null;
+
+       SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       pInfo = __pNetAccountManagerImpl->GetNetAccountInfoN(netAccountId);
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pInfo != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pInfo;
+}
+
+IListT<NetAccountId>*
+NetAccountManager::GetNetAccountIdsN(void) const
+{
+       result r = E_SUCCESS;
+       IListT<NetAccountId>* pList = null;
+
+       SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       pList = __pNetAccountManagerImpl->GetNetAccountIdsN();
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pList != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+IList*
+NetAccountManager::GetNetAccountNamesN(void) const
+{
+       result r = E_SUCCESS;
+       IList* pList = null;
+
+       SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       pList = __pNetAccountManagerImpl->GetNetAccountNamesN();
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pList != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+NetAccountId
+NetAccountManager::GetNetAccountId(const String& netAccountName) const
+{
+       result r = E_SUCCESS;
+       NetAccountId netAccountId = INVALID_HANDLE;
+
+       SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       netAccountId = __pNetAccountManagerImpl->GetNetAccountId(netAccountName);
+       r = GetLastResult();
+       SysTryReturn(NID_NET, netAccountId != INVALID_HANDLE, INVALID_HANDLE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return netAccountId;
+}
+
+NetAccountId
+NetAccountManager::GetNetAccountId(NetBearerType netBearerType) const
+{
+       result r = E_SUCCESS;
+       NetAccountId netAccountId = INVALID_HANDLE;
+
+       SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       netAccountId = __pNetAccountManagerImpl->GetNetAccountId(netBearerType);
+       r = GetLastResult();
+       SysTryReturn(NID_NET, netAccountId != INVALID_HANDLE, INVALID_HANDLE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return netAccountId;
+}
+
+NetPreferenceType
+NetAccountManager::GetNetPreference(void) const
+{
+       NetPreferenceType netPreference = NET_WIFI_FIRST;
+
+       SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       netPreference = __pNetAccountManagerImpl->GetNetPreference();
+
+       return netPreference;
+}
+
+result
+NetAccountManager::SetNetPreference(NetPreferenceType netPreference)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_NETWORK_CONNECTION);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r,
+                       "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+
+       SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pNetAccountManagerImpl->SetNetPreference(netPreference);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+}}  // Tizen::Net
diff --git a/src/FNetNetAccountManagerPartner.cpp b/src/FNetNetAccountManagerPartner.cpp
new file mode 100644 (file)
index 0000000..7353429
--- /dev/null
@@ -0,0 +1,120 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FNetNetAccountManagerPartner.cpp
+ * @brief              This is the implementation for the %NetAccountManager class. (only partner visibility)
+ */
+
+#include <net_connection.h>
+#include <FNetNetAccountManager.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FNet_NetTypes.h"
+#include "FNet_NetAccountDatabase.h"
+#include "FNet_NetAccountInfoImpl.h"
+#include "FNet_NetAccountManagerImpl.h"
+#include "FNet_NetConnectionManagerImpl.h"
+#include "FNet_NetIpcProxy.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net
+{
+
+result
+NetAccountManager::UpdateSystemNetAccount(const NetAccountInfo& netAccountInfo)
+{
+       result r = E_SUCCESS;
+       String profileName;
+       NetBearerType bearerType = netAccountInfo.GetBearerType();
+
+       SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturnResult(NID_NET, netAccountInfo.GetAccountId() > 0, E_INVALID_ARG,
+                       "Invalid argument is used. accountId=%d", netAccountInfo.GetAccountId());
+       SysTryReturnResult(NID_NET, !netAccountInfo.GetAccountName().IsEmpty(), E_INVALID_ARG,
+                       "Invalid argument is used. accountName is an empty string.");
+
+       r =  _NetAccountDatabase::GetProfileName(netAccountInfo.GetAccountId(), profileName);
+       SysTryReturnResult(NID_NET, r != E_OUT_OF_MEMORY, r, "Propagating.");
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_INVALID_ARG,
+                       "Invalid argument is used. accountId=%d", netAccountInfo.GetAccountId());
+
+       _NetIpcProxy* pProxy = _NetIpcProxy::GetInstance();
+       SysTryReturnResult(NID_NET, pProxy != null, E_SYSTEM,
+                       "A system error has been occurred. Failed to get an IPC proxy.");
+
+       r = pProxy->UpdateSystemNetAccount(profileName, netAccountInfo, bearerType);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = _NetAccountDatabase::UpdateAccountName(netAccountInfo.GetAccountId(), netAccountInfo.GetAccountName());
+       SysTryReturnResult(NID_NET, r != E_OUT_OF_MEMORY, r, "Propagating.");
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                       "A system error has been occurred. Failed to update account name.");
+
+       return r;
+}
+
+NetAccountId
+NetAccountManager::GetAppNetAccountId(const String& netProfileName) const
+{
+       result r = E_SUCCESS;
+       NetAccountId netAccountId = INVALID_HANDLE;
+
+       SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       _NetIpcProxy* pProxy = _NetIpcProxy::GetInstance();
+       SysTryReturn(NID_NET, pProxy != null, INVALID_HANDLE, E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to get an IPC proxy.", GetErrorMessage(E_SYSTEM));
+
+       r = pProxy->GetAppNetAccountId(netProfileName, netAccountId);
+       SysTryReturn(NID_NET, r == E_SUCCESS, INVALID_HANDLE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return netAccountId;
+}
+
+result
+NetAccountManager::SetNetAccountId(NetAccountId netAccountId)
+{
+       result r = E_SUCCESS;
+       NetAccountId netAccountId2 = INVALID_HANDLE;
+
+       SysAssertf(__pNetAccountManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturnResult(NID_NET, netAccountId > 0, E_INVALID_ARG,
+                       "Invalid argument is used. accountId=%d", netAccountId);
+
+       _NetConnectionManagerImpl* pConnectionManager = _NetConnectionManagerImpl::GetInstance();
+       SysTryReturnResult(NID_NET, pConnectionManager != null, E_SYSTEM,
+                       "A system error has been occurred. Failed to get NetConnectionManager instance.");
+
+       _NetIpcProxy* pProxy = _NetIpcProxy::GetInstance();
+       SysTryReturnResult(NID_NET, pProxy != null, E_SYSTEM,
+                       "A system error has been occurred. Failed to get an IPC proxy.");
+
+       r = pProxy->SetNetAccountId(netAccountId, netAccountId2);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = pConnectionManager->SetManagedNetAccountId(netAccountId2);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+}} // Tizen::Net
diff --git a/src/FNetNetConnection.cpp b/src/FNetNetConnection.cpp
new file mode 100644 (file)
index 0000000..99308f9
--- /dev/null
@@ -0,0 +1,195 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetNetConnection.cpp
+ * @brief              This is the implementation for the %NetConnection class.
+ */
+
+#include <unique_ptr.h>
+#include <FNetNetConnection.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FNet_NetConnectionImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net
+{
+
+NetConnection::NetConnection()
+       : __pNetConnectionImpl(null)
+{
+}
+
+NetConnection::~NetConnection(void)
+{
+       delete __pNetConnectionImpl;
+       __pNetConnectionImpl = null;
+}
+
+result
+NetConnection::Construct(NetAccountId netAccountId)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pNetConnectionImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       unique_ptr<_NetConnectionImpl> pNetConnectionImpl(new (std::nothrow) _NetConnectionImpl());
+       SysTryReturnResult(NID_NET, pNetConnectionImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pNetConnectionImpl->Construct(this, netAccountId);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       __pNetConnectionImpl = pNetConnectionImpl.release();
+
+       return r;
+}
+
+result
+NetConnection::AddNetConnectionListener(INetConnectionEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pNetConnectionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pNetConnectionImpl->AddNetConnectionListener(listener);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+NetConnection::RemoveNetConnectionListener(INetConnectionEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pNetConnectionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pNetConnectionImpl->RemoveNetConnectionListener(listener);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+NetConnection::Start(void)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_NETWORK_CONNECTION);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r,
+                       "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pNetConnectionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pNetConnectionImpl->Start();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+NetConnection::Stop(void)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_NETWORK_CONNECTION);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r,
+                       "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pNetConnectionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pNetConnectionImpl->Stop();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+NetConnection::Close(void)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_NETWORK_CONNECTION);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r,
+                       "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pNetConnectionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pNetConnectionImpl->Close();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+NetConnectionInfo*
+NetConnection::GetNetConnectionInfoN(NetAccountId netAccountId)
+{
+       return _NetConnectionImpl::GetNetConnectionInfoN(netAccountId);
+}
+
+IList*
+NetConnection::GetAllNetConnectionInfoN(void)
+{
+       return _NetConnectionImpl::GetAllNetConnectionInfoN();
+}
+
+NetAccountId
+NetConnection::GetNetAccountId(void) const
+{
+       NetAccountId netAccountId = INVALID_HANDLE;
+
+       SysAssertf(__pNetConnectionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       netAccountId = __pNetConnectionImpl->GetNetAccountId();
+
+       return netAccountId;
+}
+
+const NetConnectionInfo*
+NetConnection::GetNetConnectionInfo(void) const
+{
+       const NetConnectionInfo* pInfo = null;
+
+       SysAssertf(__pNetConnectionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       pInfo = __pNetConnectionImpl->GetNetConnectionInfo();
+
+       return pInfo;
+}
+
+NetConnectionState
+NetConnection::GetConnectionState(void) const
+{
+       NetConnectionState state = NET_CONNECTION_STATE_NONE;
+
+       SysAssertf(__pNetConnectionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       state = __pNetConnectionImpl->GetConnectionState();
+
+       return state;
+}
+
+} } // Tizen::Net
diff --git a/src/FNetNetConnectionInfo.cpp b/src/FNetNetConnectionInfo.cpp
new file mode 100644 (file)
index 0000000..2653968
--- /dev/null
@@ -0,0 +1,156 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FNetNetConnectionInfo.cpp
+ * @brief              This is the implementation for the %NetConnectionInfo class.
+ */
+
+#include <FBaseUtilStringUtil.h>
+#include <FNetNetConnectionInfo.h>
+#include <FNetIp4Address.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetConnectionInfoImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Net
+{
+
+NetConnectionInfo::NetConnectionInfo(void)
+{
+       __pNetConnectionInfoImpl = new (std::nothrow) _NetConnectionInfoImpl();
+       SysTryReturnVoidResult(NID_NET, __pNetConnectionInfoImpl != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+NetConnectionInfo::~NetConnectionInfo(void)
+{
+       delete __pNetConnectionInfoImpl;
+       __pNetConnectionInfoImpl = null;
+}
+
+NetBearerType
+NetConnectionInfo::GetBearerType(void) const
+{
+       return  __pNetConnectionInfoImpl->GetBearerType();
+}
+
+
+NetProtocolType
+NetConnectionInfo::GetProtocolType(void) const
+{
+       return __pNetConnectionInfoImpl->GetProtocolType();
+}
+
+
+String
+NetConnectionInfo::GetAccessPointName(void) const
+{
+       return __pNetConnectionInfoImpl->GetAccessPointName();
+}
+
+NetAddressScheme
+NetConnectionInfo::GetLocalAddressScheme(void) const
+{
+       return __pNetConnectionInfoImpl->GetLocalAddressScheme();
+}
+
+const IpAddress*
+NetConnectionInfo::GetLocalAddress(void) const
+{
+       return __pNetConnectionInfoImpl->GetLocalAddress();
+}
+
+
+NetAddressScheme
+NetConnectionInfo::GetDnsAddressScheme(void) const
+{
+       return __pNetConnectionInfoImpl->GetDnsAddressScheme();
+}
+
+const IpAddress*
+NetConnectionInfo::GetPrimaryDnsAddress(void) const
+{
+       return __pNetConnectionInfoImpl->GetPrimaryDnsAddress();
+}
+
+const IpAddress*
+NetConnectionInfo::GetSecondaryDnsAddress(void) const
+{
+       return __pNetConnectionInfoImpl->GetSecondaryDnsAddress();
+}
+
+const IpAddress*
+NetConnectionInfo::GetSubnetMaskAddress(void) const
+{
+       return __pNetConnectionInfoImpl->GetSubnetMaskAddress();
+}
+
+const IpAddress*
+NetConnectionInfo::GetDefaultGatewayAddress(void) const
+{
+       return __pNetConnectionInfoImpl->GetDefaultGatewayAddress();
+}
+
+NetConnectionInfo::NetConnectionInfo(const NetConnectionInfo& rhs)
+{
+       __pNetConnectionInfoImpl = new (std::nothrow) _NetConnectionInfoImpl(*(rhs.__pNetConnectionInfoImpl));
+       SysTryReturnVoidResult(NID_NET, __pNetConnectionInfoImpl != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
+NetConnectionInfo&
+NetConnectionInfo::operator =(const NetConnectionInfo& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pNetConnectionInfoImpl = *rhs.__pNetConnectionInfoImpl;
+
+       return *this;
+}
+
+
+bool
+NetConnectionInfo::Equals(const Object& rhs) const
+{
+       const NetConnectionInfo* pRhs = dynamic_cast<const NetConnectionInfo*>(&rhs);
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       const _NetConnectionInfoImpl* pRhsImpl = _NetConnectionInfoImpl::GetInstance(*pRhs);
+       if (pRhsImpl == null)
+       {
+               return false;
+       }
+
+       return __pNetConnectionInfoImpl->Equals(*pRhsImpl);
+}
+
+int
+NetConnectionInfo::GetHashCode(void) const
+{
+       return __pNetConnectionInfoImpl->GetHashCode();
+}
+
+} } // Tizen::Net
diff --git a/src/FNetNetConnectionManager.cpp b/src/FNetNetConnectionManager.cpp
new file mode 100644 (file)
index 0000000..e7733d6
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FNetNetConnectionManager.cpp
+ * @brief              This is the implementation for the %NetConnectionManager class.
+ */
+
+#include <FNetNetConnectionInfo.h>
+#include <FNetNetConnectionManager.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FNet_NetConnectionManagerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net
+{
+
+NetConnectionManager::NetConnectionManager(void)
+       : __pNetConnectionManagerImpl(null)
+{
+}
+
+NetConnectionManager::~NetConnectionManager(void)
+{
+}
+
+result
+NetConnectionManager::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pNetConnectionManagerImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       __pNetConnectionManagerImpl = _NetConnectionManagerImpl::GetInstance();
+       SysTryReturnResult(NID_NET, __pNetConnectionManagerImpl != null, E_SYSTEM,
+                       "A system error has been occurred. Failed to initialize the network connection manager instance.");
+
+       return r;
+}
+
+NetConnection*
+NetConnectionManager::CreateNetConnectionN(NetAccountId netAccountId)
+{
+       result r = E_SUCCESS;
+       NetConnection* pConnection = null;
+
+       SysAssertf(__pNetConnectionManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       pConnection = __pNetConnectionManagerImpl->CreateNetConnectionN(netAccountId);
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pConnection != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pConnection;
+}
+
+ManagedNetConnection*
+NetConnectionManager::GetManagedNetConnectionN(void) const
+{
+       result r = E_SUCCESS;
+       ManagedNetConnection* pManagedConnection = null;
+
+       SysAssertf(__pNetConnectionManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       pManagedConnection = __pNetConnectionManagerImpl->GetManagedNetConnectionN();
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pManagedConnection != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pManagedConnection;
+}
+
+NetPreferenceType
+NetConnectionManager::GetNetPreference(void) const
+{
+       SysAssertf(__pNetConnectionManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pNetConnectionManagerImpl->GetNetPreference();
+}
+
+result
+NetConnectionManager::SetNetPreference(NetPreferenceType netPreference)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_NETWORK_CONNECTION);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r,
+                       "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pNetConnectionManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pNetConnectionManagerImpl->SetNetPreference(netPreference);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+NetConnectionInfo*
+NetConnectionManager::GetNetConnectionInfoN(NetAccountId netAccountId)
+{
+       result r = E_SUCCESS;
+       NetConnectionInfo* pConnectionInfo = null;
+
+       pConnectionInfo = _NetConnectionManagerImpl::GetNetConnectionInfoN(netAccountId);
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pConnectionInfo != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pConnectionInfo;
+}
+
+IList*
+NetConnectionManager::GetAllNetConnectionInfoN(void)
+{
+       result r = E_SUCCESS;
+       IList* pList = null;
+
+       pList = _NetConnectionManagerImpl::GetAllNetConnectionInfoN();
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pList != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pList;
+}
+
+} } // Tizen::Net
diff --git a/src/FNetNetEndPoint.cpp b/src/FNetNetEndPoint.cpp
new file mode 100644 (file)
index 0000000..3f8a025
--- /dev/null
@@ -0,0 +1,126 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetNetEndPoint.cpp
+ * @brief              This is the implementation for the %NetEndPoint class.
+ */
+
+#include <FBaseUtilUri.h>
+#include <FBaseShort.h>
+#include <FNetNetEndPoint.h>
+#include <FNetIp4Address.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetEndPointImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net
+{
+
+NetEndPoint::NetEndPoint(void)
+       : __pNetEndPointImpl(null)
+{
+}
+
+NetEndPoint::NetEndPoint(const IpAddress& ipAddress, unsigned short port)
+{
+       __pNetEndPointImpl = new (std::nothrow) _NetEndPointImpl(ipAddress, port);
+       SysTryReturnVoidResult(NID_NET, __pNetEndPointImpl != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturnVoidResult(NID_NET, GetLastResult() == E_SUCCESS, GetLastResult(),
+                       "[%s] IP address is invalid.", GetErrorMessage(GetLastResult()));
+}
+
+NetEndPoint::NetEndPoint(const NetEndPoint& rhs)
+{
+       __pNetEndPointImpl = new (std::nothrow) _NetEndPointImpl(*rhs.__pNetEndPointImpl);
+       SysTryReturnVoidResult(NID_NET, __pNetEndPointImpl != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysTryReturnVoidResult(NID_NET, GetLastResult() == E_SUCCESS, GetLastResult(),
+                       "[%s] The instance is invalid.", GetErrorMessage(GetLastResult()));
+}
+
+NetEndPoint::~NetEndPoint()
+{
+       delete __pNetEndPointImpl;
+       __pNetEndPointImpl = null;
+}
+
+NetAddressFamily
+NetEndPoint::GetNetAddressFamily(void) const
+{
+       return __pNetEndPointImpl->GetNetAddressFamily();
+}
+
+unsigned short
+NetEndPoint::GetPort(void) const
+{
+       return __pNetEndPointImpl->GetPort();
+}
+
+IpAddress*
+NetEndPoint::GetAddress(void) const
+{
+
+       return __pNetEndPointImpl->GetAddress();
+}
+
+String
+NetEndPoint::GetNetEndPoint(void) const
+{
+       return __pNetEndPointImpl->GetNetEndPoint();
+}
+
+NetEndPoint&
+NetEndPoint::operator =(const NetEndPoint& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __pNetEndPointImpl = rhs.__pNetEndPointImpl;
+
+       return *this;
+}
+
+bool
+NetEndPoint::Equals(const Object& rhs) const
+{
+       const NetEndPoint* pRhs = dynamic_cast<const NetEndPoint*>(&rhs);
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       const _NetEndPointImpl* pRhsImpl = _NetEndPointImpl::GetInstance(*pRhs);
+       if (pRhsImpl == null)
+       {
+               return false;
+       }
+
+       return __pNetEndPointImpl->Equals(*pRhsImpl);
+}
+
+int
+NetEndPoint::GetHashCode(void) const
+{
+       return __pNetEndPointImpl->GetHashCode();
+}
+
+} } // Tizen::Net
diff --git a/src/FNetNetStatistics.cpp b/src/FNetNetStatistics.cpp
new file mode 100644 (file)
index 0000000..a9053c2
--- /dev/null
@@ -0,0 +1,123 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file                       FNetNetStatistics.cpp
+ * @brief              This is the implementation for the FNetNetStatistics class.
+ */
+
+#include <unique_ptr.h>
+#include <FNetNetTypes.h>
+#include <FNetNetStatistics.h>
+#include <FNet_NetTypes.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FNet_NetStatisticsImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net
+{
+
+NetStatistics::NetStatistics(void)
+       : __pNetStatisticsImpl(null)
+{
+}
+
+result
+NetStatistics::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pNetStatisticsImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       unique_ptr<_NetStatisticsImpl> pNetStatisticsImpl(new (std::nothrow) _NetStatisticsImpl());
+       SysTryReturnResult(NID_NET, pNetStatisticsImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pNetStatisticsImpl->Construct();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       __pNetStatisticsImpl = pNetStatisticsImpl.release();
+
+       return r;
+}
+
+NetStatistics::~NetStatistics(void)
+{
+       delete __pNetStatisticsImpl;
+       __pNetStatisticsImpl = null;
+}
+
+long long
+NetStatistics::GetNetStatisticsInfo(NetBearerType operationMode, NetStatisticsInfoType netStatType) const
+{
+       result r = E_SUCCESS;
+       long long ret = INVALID_HANDLE;
+
+       ClearLastResult();
+
+       r = _AccessController::CheckUserPrivilege(_PRV_NETWORK_STATISTICS_READ);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET, r == E_SUCCESS, INVALID_HANDLE, r,
+                       "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       SysAssertf(__pNetStatisticsImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       ret = __pNetStatisticsImpl->GetNetStatisticsInfo(operationMode, netStatType);
+       r = GetLastResult();
+       SysTryReturn(NID_NET, r == E_SUCCESS, ret, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return ret;
+}
+
+result
+NetStatistics::Reset(NetBearerType operationMode, NetStatisticsInfoType netStatType)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_NETWORK_STATISTICS_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
+
+       SysAssertf(__pNetStatisticsImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pNetStatisticsImpl->Reset(operationMode, netStatType);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+NetStatistics::ResetAll(NetBearerType operationMode)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_NETWORK_STATISTICS_WRITE);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
+
+       SysAssertf(__pNetStatisticsImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pNetStatisticsImpl->ResetAll(operationMode);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_DefaultSystemNetConnection.cpp b/src/FNet_DefaultSystemNetConnection.cpp
new file mode 100644 (file)
index 0000000..c34e63f
--- /dev/null
@@ -0,0 +1,261 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file                       FNet_DefaultSystemNetConnection.cpp
+ * @brief              This is the implementation file for _DefaultSystemNetConnection class.
+ * @version    3.0
+ *
+ * This file contains the implementation of _DefaultSystemNetConnection class.
+ */
+
+#include <net_connection.h>
+#include <FNetNetConnectionInfo.h>
+#include <FBaseRtMutexGuard.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FNet_NetTypes.h"
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNet_DefaultSystemNetConnection.h"
+#include "FNet_NetConnectionEvent.h"
+#include "FNet_NetConnectionEventArg.h"
+#include "FNet_NetUtility.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net {
+
+void
+ActiveConnectionTypeChangedCallback(connection_type_e type, void* pUserData)
+{
+       _DefaultSystemNetConnection* pConnection = static_cast<_DefaultSystemNetConnection*>(pUserData);
+       bool isBearerChanged = false;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = pConnection->GetConnectionHandle();
+       connection_profile_h profileHandle = null;
+
+       SysLog(NID_NET, "ActiveConnectionTypeChangedCallback() has been called with type : %d", type);
+
+       if (type != CONNECTION_TYPE_DISCONNECTED)
+       {
+               // Connected
+               if ((type == CONNECTION_TYPE_WIFI) && (pConnection->GetBearerType() != NET_BEARER_WIFI))
+               {
+                       isBearerChanged = true;
+               }
+               else if ((type == CONNECTION_TYPE_CELLULAR) && (pConnection->GetBearerType() != NET_BEARER_PS))
+               {
+                       isBearerChanged = true;
+               }
+
+               if (isBearerChanged)
+               {
+                       SysLog(NID_NET, "Invoke stop event, because bearer is changed.");
+                       pConnection->HandleStopEvent(E_NETWORK_FAILED);
+                       pConnection->UpdateConnectionInfo(null);
+               }
+
+               if (pConnection->GetConnectionState() == NET_CONNECTION_STATE_STARTED)
+               {
+                       SysLog(NID_NET, "Ignore the event, because this is already in started state.");
+                       return;
+               }
+
+               ret = connection_get_current_profile(connectionHandle, &profileHandle);
+               SysTryReturnVoidResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                               "[%s] A system error has been occurred. The return value from connection_get_current_profile() is %d", GetErrorMessage(E_SYSTEM), ret);
+
+               pConnection->UpdateConnectionInfo(profileHandle);
+               pConnection->HandleStartEvent();
+
+               connection_profile_destroy(profileHandle);
+       }
+       else
+       {
+               // Not connected
+               pConnection->HandleStopEvent(E_NETWORK_FAILED);
+               pConnection->UpdateConnectionInfo(null);
+       }
+}
+
+_DefaultSystemNetConnection::_DefaultSystemNetConnection(void)
+       : __pConnectionHandle(null)
+{
+}
+
+_DefaultSystemNetConnection::~_DefaultSystemNetConnection(void)
+{
+}
+
+result
+_DefaultSystemNetConnection::Construct(void)
+{
+       result r = E_SUCCESS;
+       unique_ptr<void, _ConnectionDeleter> pConnectionHandle;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = null;
+       connection_type_e type = CONNECTION_TYPE_DISCONNECTED;
+
+       SysAssertf(__pConnectionHandle == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       r = _SystemNetConnection::Initialize(L"DEFAULT");
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       ret = connection_create(&connectionHandle);
+       SysTryCatch(NID_NET, ret == CONNECTION_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_create() is %d", GetErrorMessage(E_SYSTEM), ret);
+       pConnectionHandle.reset(connectionHandle);
+
+       ret = connection_set_type_changed_cb(connectionHandle, ActiveConnectionTypeChangedCallback, this);
+       SysTryCatch(NID_NET, ret == CONNECTION_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_set_type_changed_cb() is %d", GetErrorMessage(E_SYSTEM), ret);
+
+       ret = connection_get_type(connectionHandle, &type);
+       SysTryCatch(NID_NET, ret == CONNECTION_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_get_type() is %d", GetErrorMessage(E_SYSTEM), ret);
+
+       if (type != CONNECTION_TYPE_DISCONNECTED)
+       {
+               // Default connection is ON
+               SysLog(NID_NET, "Default connection is ON. type=%d", type);
+
+               connection_profile_h profileHandle = null;
+
+               ret = connection_get_current_profile(connectionHandle, &profileHandle);
+               if (ret == CONNECTION_ERROR_NONE)
+               {
+                       UpdateConnectionInfo(profileHandle);
+                       connection_profile_destroy(profileHandle);
+
+// ToDo - temporal fix
+#ifdef _OSP_EMUL_
+                       if (_pConnectionInfo->GetProxyAddress().IsEmpty())
+                       {
+                               char* pProxy = null;
+
+                               ret = connection_get_proxy(connectionHandle, CONNECTION_ADDRESS_FAMILY_IPV4, &pProxy);
+                               if ((ret == CONNECTION_ERROR_NONE) && (pProxy != null))
+                               {
+                                       SysLog(NID_NET, "Proxy Address is [%s].", pProxy);
+                                       _pConnectionInfo->SetProxyAddress(String(pProxy));
+                                       free(pProxy);
+                               }
+                       }
+#endif // _OSP_EMUL_
+
+               }
+               else
+               {
+                       SysLog(NID_NET, "The return value from connection_get_current_profile() is %d", ret);
+                       UpdateConnectionInfo(null);
+               }
+       }
+       else
+       {
+               // Default connection is OFF
+               SysLog(NID_NET, "Default connection is OFF.");
+               UpdateConnectionInfo(null);
+       }
+
+       __pConnectionHandle = move(pConnectionHandle);
+
+       return r;
+
+CATCH:
+       _SystemNetConnection::Deinitialize();
+
+       return r;
+}
+
+void
+_DefaultSystemNetConnection::HandleStartEvent(void)
+{
+       _NetConnectionEvent* pEvent = null;
+       _NetConnectionEventArg* pEventArg = null;
+
+       MutexGuard locked(*_pLock);
+
+       unique_ptr<IEnumerator> pEnum(_pEventList->GetEnumeratorN());
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEvent = dynamic_cast<_NetConnectionEvent*>(pEnum->GetCurrent());
+                       if (pEvent != null)
+                       {
+                               // Sends event which doesn't invoke start.
+                               if (pEvent->GetConnectionState() != NET_CONNECTION_STATE_STARTED)
+                               {
+                                       pEvent->SetConnectionState(NET_CONNECTION_STATE_STARTED);
+                                       pEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STARTED, E_SUCCESS);
+                                       if (pEventArg != null)
+                                       {
+                                               pEvent->FireAsync(*pEventArg);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       locked.Unlock();
+}
+
+void
+_DefaultSystemNetConnection::UpdateConnectionInfo(void* pData)
+{
+       connection_profile_h profileHandle = pData;
+       connection_profile_type_e type = CONNECTION_PROFILE_TYPE_WIFI;
+       int ret = CONNECTION_ERROR_NONE;
+
+       MutexGuard locked(*_pLock);
+
+       if (pData != null)
+       {
+               ret = connection_profile_get_type(profileHandle, &type);
+               SysLog(NID_NET, "The return value from connection_profile_get_type() is %d, Type is %d", ret, type);
+               if (type == CONNECTION_PROFILE_TYPE_WIFI)
+               {
+                       _bearerType = NET_BEARER_WIFI;
+               }
+               else
+               {
+                       _bearerType = NET_BEARER_PS;
+               }
+
+               _connectionState = NET_CONNECTION_STATE_STARTED;
+               _pConnectionInfo->Update(pData, true);
+       }
+       else
+       {
+               _bearerType = NET_BEARER_NONE;
+               _connectionState = NET_CONNECTION_STATE_STOPPED;
+               _pConnectionInfo->Clear();
+       }
+
+       locked.Unlock();
+}
+
+void*
+_DefaultSystemNetConnection::GetConnectionHandle(void) const
+{
+       return __pConnectionHandle.get();
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_DefaultSystemNetConnection.h b/src/FNet_DefaultSystemNetConnection.h
new file mode 100644 (file)
index 0000000..ac1cbfa
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNet_DefaultSystemNetConnection.h
+ * @brief      This is the header file for the %_DefaultSystemNetConnection class.
+ *
+ * This header file contains the declarations of the %_DefaultSystemNetConnection class.
+ */
+
+#ifndef _FNET_INTERNAL_DEFAULT_SYSTEM_NET_CONNECTION_H_
+#define _FNET_INTERNAL_DEFAULT_SYSTEM_NET_CONNECTION_H_
+
+#include "FNet_SystemNetConnection.h"
+#include "FNet_NetUtility.h"
+
+namespace Tizen { namespace Net {
+/**
+ * @class      _DefaultSystemNetConnection
+ * @brief      This class provides methods for a system network connection.
+ *
+ * @since 2.1
+ *
+ * This class provides methods for a system network connection.
+ */
+
+class _DefaultSystemNetConnection
+       : public _SystemNetConnection
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        */
+               _DefaultSystemNetConnection(void);
+
+       /**
+        * This is the destructor for this class.
+        */
+       virtual ~_DefaultSystemNetConnection(void);
+
+       /**
+        * Initializes a default instance.
+        *
+        * @since 2.1
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        * @exception   E_OUT_OF_MEMORY         Insufficient memory.
+        * @exception   E_INVALID_ACCOUNT       The specified network account is invalid.
+        * @exception   E_SYSTEM                        An internal error occurred.
+        */
+       result Construct(void);
+
+       virtual void HandleStartEvent(void);
+
+       void UpdateConnectionInfo(void* pData);
+       void* GetConnectionHandle(void) const;
+
+private:
+       /**
+        * This is the copy constructor for this class.
+        *
+        * @param[in]   rhs                     An instance of _DefaultSystemNetConnection
+        */
+       _DefaultSystemNetConnection(const _DefaultSystemNetConnection& rhs);
+
+       /**
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                             An instance of _DefaultSystemNetConnection
+        */
+       _DefaultSystemNetConnection& operator =(const _DefaultSystemNetConnection& rhs);
+
+private:
+       std::unique_ptr<void, _ConnectionDeleter> __pConnectionHandle;
+
+}; // _DefaultSystemNetConnection
+
+} }  // Tizen::Net
+#endif // _FNET_INTERNAL_DEFAULT_SYSTEM_NET_CONNECTION_H_
+
diff --git a/src/FNet_DhcpClientInfoImpl.cpp b/src/FNet_DhcpClientInfoImpl.cpp
new file mode 100644 (file)
index 0000000..d67da57
--- /dev/null
@@ -0,0 +1,166 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_DhcpClientInfoImpl.cpp
+ * @brief              This is the implementation file for the _DhcpClientInfoImpl Class.
+ *
+ * This header file contains implementation of the _DhcpClientInfoImpl Class.
+ */
+
+
+#include <FNetIp4Address.h>
+#include <FNetDhcpClientInfo.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_DhcpClientInfoImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net
+{
+
+_DhcpClientInfoImpl::_DhcpClientInfoImpl(void)
+       : __dhcpClientName(null)
+       , __macAddress(null)
+       , __pLocalAddress(null)
+{
+}
+
+_DhcpClientInfoImpl::_DhcpClientInfoImpl(const DhcpClientInfo& value)
+{
+       const _DhcpClientInfoImpl* pDhcpClientInfoImpl = value.__pDhcpClientInfoImpl;
+
+       unique_ptr<Ip4Address> pLocalAddress(new (std::nothrow) Ip4Address(pDhcpClientInfoImpl->__pLocalAddress->ToString()));
+       SysTryReturnVoidResult(NID_NET, pLocalAddress != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __dhcpClientName = pDhcpClientInfoImpl->__dhcpClientName;
+       __macAddress = pDhcpClientInfoImpl->__macAddress;
+       __pLocalAddress = move(pLocalAddress);
+}
+
+_DhcpClientInfoImpl::~_DhcpClientInfoImpl(void)
+{      
+}
+
+bool
+_DhcpClientInfoImpl::Equals(const Object& obj) const
+{
+       const _DhcpClientInfoImpl* pRhs = dynamic_cast <const _DhcpClientInfoImpl*>(&obj);
+
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       if (__dhcpClientName != pRhs->__dhcpClientName)
+       {
+               return false;
+       }
+
+       if (__macAddress != pRhs->__macAddress)
+       {
+               return false;
+       }
+
+       if (__pLocalAddress != null && pRhs->__pLocalAddress != null)
+       {
+               if (!__pLocalAddress->Equals(*pRhs->__pLocalAddress))
+               {
+                       return false;
+               }
+       }
+       else if (__pLocalAddress != null || pRhs->__pLocalAddress != null)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+int
+_DhcpClientInfoImpl::GetHashCode(void) const
+{
+       int hashCode = _HASH_CODE_INITIAL_VALUE;
+
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __dhcpClientName.GetHashCode();
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __macAddress.GetHashCode();
+
+       if (__pLocalAddress != null)
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __pLocalAddress->GetHashCode();
+       }
+       else
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode;
+       }
+
+       return hashCode;
+}
+
+String
+_DhcpClientInfoImpl::GetName(void) const
+{
+       return __dhcpClientName;
+}
+
+String
+_DhcpClientInfoImpl::GetMacAddress(void) const
+{
+       return __macAddress;
+}
+
+IpAddress*
+_DhcpClientInfoImpl::GetLocalAddress(void) const
+{
+       return __pLocalAddress.get();
+}
+
+DhcpClientInfo*
+_DhcpClientInfoImpl::CreateDhcpClientInfoN(void)
+{
+       DhcpClientInfo* pDhcpClientInfo = new (std::nothrow) DhcpClientInfo();
+       SysTryReturn(NID_NET, pDhcpClientInfo, null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pDhcpClientInfo;
+}
+
+DhcpClientInfo*
+_DhcpClientInfoImpl::CloneDhcpClientInfoN(const DhcpClientInfo& info)
+{
+       DhcpClientInfo* pDhcpClientInfo = new (std::nothrow) DhcpClientInfo(info);
+       SysTryReturn(NID_NET, pDhcpClientInfo, null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pDhcpClientInfo;
+}
+
+_DhcpClientInfoImpl*
+_DhcpClientInfoImpl::GetInstance(DhcpClientInfo& dhcpClientInfo)
+{
+       return dhcpClientInfo.__pDhcpClientInfoImpl;
+}
+
+const _DhcpClientInfoImpl*
+_DhcpClientInfoImpl::GetInstance(const DhcpClientInfo& dhcpClientInfo)
+{
+       return dhcpClientInfo.__pDhcpClientInfoImpl;
+}
+
+}} // Tizen::Net
diff --git a/src/FNet_DhcpClientInfoImpl.h b/src/FNet_DhcpClientInfoImpl.h
new file mode 100644 (file)
index 0000000..515d7f0
--- /dev/null
@@ -0,0 +1,164 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_DhcpClientInfoImpl.h
+ * @brief              This is the header file for the _DhcpClientInfoImpl Class.
+ *
+ */
+
+#ifndef _FNET_INTERNAL_DHCP_CLIENT_INFO_IMPL_H_
+#define _FNET_INTERNAL_DHCP_CLIENT_INFO_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+
+namespace Tizen { namespace Net
+{
+
+class IpAddress;
+class DhcpClientInfo;
+class _LocalDhcpServerImpl;
+class _LocalDhcpServerEvent;
+class _DhcpNetConnectionEventListenerImpl;
+
+/**
+ * @class   _DhcpClientInfoImpl
+ * @brief      This class represents a client information on dhcp server.
+ * @since   2.0
+ *
+ * The DhcpClientInfo class provides functionality for getting information on dhcp server.
+ */
+
+class _DhcpClientInfoImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the constructor for this class.
+        *
+        */
+       _DhcpClientInfoImpl(void);
+
+       /**
+        * This is the constructor for this class.
+        *
+        * @param[in]   value                   An instance of DhcpClientInfo
+        */
+       _DhcpClientInfoImpl(const DhcpClientInfo& value);
+
+       /**
+        * This is the destructor for this class.
+        *
+        */
+       virtual ~_DhcpClientInfoImpl(void);
+
+
+       /**
+        * @see                 DhcpClientInfo::Equals()
+        */
+       bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * @see                 DhcpClientInfo::GetHashCode()
+        */
+       int     GetHashCode(void) const;
+
+public:
+       /**
+        * @see                 DhcpClientInfo::GetName()
+        */
+       Tizen::Base::String GetName(void) const;
+
+       /**
+        * @see                 DhcpClientInfo::GetMacAddress()
+        */
+       Tizen::Base::String GetMacAddress(void) const;
+
+       /**
+        * @see                 DhcpClientInfo::GetLocalAddress()
+        */
+       IpAddress* GetLocalAddress(void) const;
+
+public:
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _DhcpClientInfoImpl
+       * @param[in]   dhcpClientInfo            An instance of DhcpClientInfo
+     */
+       static _DhcpClientInfoImpl* GetInstance(DhcpClientInfo& dhcpClientInfo);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _DhcpClientInfoImpl
+       * @param[in]   dhcpClientInfo     An instance of DhcpClientInfo
+     */
+       static const _DhcpClientInfoImpl* GetInstance(const DhcpClientInfo& dhcpClientInfo);
+
+private:
+       /*
+        * Factory Method to create DhcpClientInfo instance
+        *
+        * @since 2.1
+        * @return                      Instance of DhcpClientInfo
+        */
+       static DhcpClientInfo* CreateDhcpClientInfoN(void);
+
+       /*
+        * Factory Method to Clone DhcpClientInfo instance
+        *
+        * @since 2.1
+        * @return                      Instance of DhcpClientInfo
+        */
+       static DhcpClientInfo* CloneDhcpClientInfoN(const DhcpClientInfo& info);
+
+private:
+       /*
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of __DhcpClientInfoImpl
+        */
+       _DhcpClientInfoImpl(const _DhcpClientInfoImpl& rhs);
+
+       /*
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                             An instance of __DhcpClientInfoImpl
+        */
+       _DhcpClientInfoImpl& operator =(const _DhcpClientInfoImpl& rhs);
+
+private:
+       Tizen::Base::String __dhcpClientName;
+       Tizen::Base::String __macAddress;
+       std::unique_ptr<IpAddress> __pLocalAddress;
+
+       friend class _LocalDhcpServerImpl;
+       friend class _LocalDhcpServerEvent;
+       friend class _DhcpNetConnectionEventListenerImpl;
+       friend class _LocalDhcpServerEventArg;
+}; // _DhcpClientInfoImpl
+
+} } // Tizen::Net
+
+#endif // _FNET_INTERNAL_DHCP_CLIENT_INFO_IMPL_H_
diff --git a/src/FNet_DnsEvent.cpp b/src/FNet_DnsEvent.cpp
new file mode 100644 (file)
index 0000000..dd793f9
--- /dev/null
@@ -0,0 +1,94 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_DnsEvent.cpp
+ * @brief              This is the implementation file for the _DnsEvent Class.
+ *
+ * This file contains the implementation of the _DnsEvent Class.
+ */
+
+#include <FNetNetTypes.h>
+#include <FNetIDnsEventListener.h>
+#include <FNetDns.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_DnsEvent.h"
+#include "FNet_DnsEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net
+{
+
+_DnsEvent::_DnsEvent(void)
+{
+}
+
+_DnsEvent::~_DnsEvent(void)
+{
+}
+
+result
+_DnsEvent::Construct(void)
+{
+       return _Event::Initialize();
+}
+
+void
+_DnsEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+       result r = E_SUCCESS;
+
+       IpHostEntry* pIpHostEntry = null;
+
+       IDnsEventListener* pDnsEventListener = dynamic_cast <IDnsEventListener*>(&listener);
+       SysTryReturnVoidResult(NID_NET, pDnsEventListener != null, E_SYSTEM,
+                       "[%s] A system error has been occurred. Listener argument is invalid.", GetErrorMessage(E_SYSTEM));
+
+       IEventArg* pEventArg = const_cast <IEventArg*>(&arg);
+       _DnsEventArg* pDnsEventArg = dynamic_cast <_DnsEventArg*>(pEventArg);
+       SysTryReturnVoidResult(NID_NET, pDnsEventArg != null, E_SYSTEM,
+                       "[%s] A system error has been occurred. Event argument is invalid type.", GetErrorMessage(E_SYSTEM));
+
+       // check if DNS resolved successfully
+       r = pDnsEventArg->GetError();
+       SysTryCatch(NID_NET, r == E_SUCCESS, r = E_DNS_NOT_FOUND, r,
+                       "[%s] Failed to lookup the DNS.", GetErrorMessage(E_DNS_NOT_FOUND));
+
+       // No error in DNS resolution
+       pIpHostEntry = pDnsEventArg->GetIpHostEntry();
+       SysTryCatch(NID_NET, pIpHostEntry != null, r = E_SYSTEM, r,
+                       "[%s] A system error has been occurred. Event argument is invalid type.", GetErrorMessage(E_SYSTEM));
+
+       pDnsEventListener->OnDnsResolutionCompletedN(pIpHostEntry, r);
+       
+       return;
+
+CATCH:
+       //error scenario callback with null
+       pDnsEventListener->OnDnsResolutionCompletedN(null, r);
+
+       // incase, we have reached here with pIpHostEntry not null, need to free pIpHostEntry
+       // pIpHostEntry can get deleted at the user end, but have to delete if not sent there
+       pIpHostEntry = pDnsEventArg->GetIpHostEntry();
+       delete pIpHostEntry;
+
+       return;
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_DnsEvent.h b/src/FNet_DnsEvent.h
new file mode 100644 (file)
index 0000000..35f6cc4
--- /dev/null
@@ -0,0 +1,99 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNetDns_DnsEvent.h
+ * @brief              This is the header file for the _DnsEvent Class.
+ *
+ * This header file contains declaration of the _DnsEvent Class.
+ * The _DnsEvent class can call a method of a listener (IDnsEventListener object).
+ * So, when a Dns event is occurred, an application can handle it appropriately.
+ */
+#ifndef _FNET_INTERNAL_DNS_EVENT_H_
+#define _FNET_INTERNAL_DNS_EVENT_H_
+
+#include <FBaseDataType.h>
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Net
+{
+
+class Dns;
+/**
+ * @class      _DnsEvent
+ * @brief      This class handles Dns events.
+ *
+ * @since 2.1
+ * When a Dns event occurs, the _DnsEvent object finds a IDnsEventListener object
+ * which is registered for the Dns object and calls an appropriate method of the listener.
+ */
+class _DnsEvent
+       : public Tizen::Base::Runtime::_Event
+{
+
+public:
+       /*
+        * This is the default constructor.
+        *
+        * @remarks             After creating an instance of this class, you must explicitly call the
+        *                              construction method to initialize the instance.
+        * @see                 Construct
+        */
+       _DnsEvent(void);
+
+       /*
+        * This is the class destructor.
+        */
+       virtual ~_DnsEvent(void);
+
+       /*
+        * Construct.
+        */
+       result Construct(void);
+       
+protected:
+       /*
+        * Checks the arg and finds out the type of event. After that this method calls appropriate
+        * listener's method.
+        *
+        * @return              A result code.
+        * @param[in]   listener                        It is a event listener related to this Dns event.
+        * @param[in]   arg                                     It is an argument-like instance of dns event which will be retransmitted to the listener's method as an argument.
+        * @exception   E_SUCCESS                       - The method is successful.
+        * @exception   E_INVALID_ARG           - The argument passed to a method contains an invalid value.@n
+        */
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+
+private:
+       /*
+        * This is the copy constructor.
+        *
+        * @param[in]   rhs     An instance of DnsEvent
+        */
+       _DnsEvent(const _DnsEvent& rhs);
+
+       /*
+        * This is the assignment operator.
+        *
+        * @param[in]   rhs             An instance of Socket
+        */
+       _DnsEvent& operator =(const _DnsEvent& rhs);
+}; // _DnsEvent
+
+} } //Tizen::Net
+
+#endif // _FNET_INTERNAL_DNS_EVENT_H_
diff --git a/src/FNet_DnsEventArg.cpp b/src/FNet_DnsEventArg.cpp
new file mode 100644 (file)
index 0000000..f76bce4
--- /dev/null
@@ -0,0 +1,65 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_DnsEventArg.cpp
+ * @brief              This is the implementation file for the _DnsEventArg Class.
+ *
+ */
+
+#include <FNetNetTypes.h>
+#include <FNetIpHostEntry.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_DnsEventArg.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net
+{
+
+_DnsEventArg::_DnsEventArg(result errorCode, IpHostEntry* pIpHostEntry)
+       : __pIpHostEntry(pIpHostEntry)
+       , __errorCode(errorCode)
+{
+}
+
+_DnsEventArg::~_DnsEventArg(void)
+{
+       //DONOT DELETE pIpHostEntry, since same is passed to user in OnDnsResolutionCompletedN()
+}
+
+IpHostEntry*
+_DnsEventArg::GetIpHostEntry(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET, __errorCode == E_SUCCESS, null, E_OPERATION_FAILED,
+                       "[%s] An error has been occurred in DNS response", GetErrorMessage(E_OPERATION_FAILED));
+
+       SysTryReturn(NID_NET, __pIpHostEntry != null, null, E_INVALID_STATE,
+                       "[%s] IpHostEntry instance must not be null.", GetErrorMessage(E_INVALID_STATE));
+
+       return __pIpHostEntry;
+}
+
+result
+_DnsEventArg::GetError(void) const
+{
+       return (__errorCode);
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_DnsEventArg.h b/src/FNet_DnsEventArg.h
new file mode 100644 (file)
index 0000000..8a2028e
--- /dev/null
@@ -0,0 +1,122 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNetDns_DnsEventArg.h
+ * @brief              This is the header file for the _DnsEventArg Class.
+ *
+ * This header file contains declaration of the _DnsEventArg Class.
+ */
+#ifndef _FNET_INTERNAL_DNS_EVENT_ARG_H_
+#define _FNET_INTERNAL_DNS_EVENT_ARG_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+
+namespace Tizen { namespace Net
+{
+
+//DNS related enum values
+/*
+ * @enum NetDnsEventType
+ * Type for specifying the type of %Dns events
+ * @since 2.1
+ */
+enum _NetDnsEventType
+{
+       NET_DNS_EVENT_NONE = 0,
+       NET_DNS_EVENT_HOSTNAME,     /** < alias info is expected */
+       NET_DNS_EVENT_ADDRESS       /** < Address info is expected */
+};
+
+class IpHostEntry;
+
+/**
+ * @class      _DnsEventArg
+ * @brief      This class is used as an argument of methods of the IDnsEventListener class.
+ *
+ * @since 2.1
+ * This class is used as an argument of IDnsEventListener's methods.
+ * When a %Dns event occurs, the _DnsEvent object finds a IDnsEventListener object
+ * which is registered for the Dns object and calls an appropriate method of the listener.
+ * @see IDnsEventListener for example codes
+ */
+class _DnsEventArg
+       : public Tizen::Base::Object
+       , public Tizen::Base::Runtime::IEventArg
+{
+
+public:
+       /*
+        * This is constructor.
+        */
+       _DnsEventArg(result errorCode, IpHostEntry* pIpHostEntry);
+
+       /*
+        * This is the class destructor.
+        */
+       virtual ~_DnsEventArg(void);
+
+public:
+       /*
+        * Returns the IpHostEntry which contains the result of the Dns request.
+        *
+        * @return              An IpHostEntry object which contains a domain name, an associated IP address list and an associated alias list.
+        *                                              In case of error condition, null is returned.
+        * @remark              You can refer detailed error cause by calling GetLastError()
+        * @exception E_INVALID_STATE                   - dns query succeed, but not valid info found
+        * @exception E_OPERATION_FAILED        - operation failed, so no IpHostEntry info
+        * @exception E_SUCCESS - DNS query successful
+        */
+       IpHostEntry* GetIpHostEntry(void) const;
+
+       /*
+        * Returns the cause of a Dns error.
+        *
+        * @return      See the comment above.
+        */
+       result GetError(void) const;
+
+private:
+       /*
+        * This is constructor.
+        */
+       _DnsEventArg(void);
+
+       /*
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of _DnsEventArg
+        */
+       _DnsEventArg(const _DnsEventArg& rhs);
+
+       /*
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of _DnsEventArg
+        */
+       _DnsEventArg& operator =(const _DnsEventArg& rhs);
+
+private:
+       IpHostEntry* __pIpHostEntry;
+       result __errorCode;
+
+}; // _DnsEventArg
+} } //Tizen::Net
+
+#endif // _FNET_INTERNAL_DNS_EVENT_ARG_H_
diff --git a/src/FNet_DnsImpl.cpp b/src/FNet_DnsImpl.cpp
new file mode 100644 (file)
index 0000000..ecc3630
--- /dev/null
@@ -0,0 +1,282 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_DnsImpl.cpp
+ * @brief              This is the implementation for the  _DnsImpl class.
+ */
+
+#include <FNetNetConnection.h>
+#include <FNetDns.h>
+#include <FNetIDnsEventListener.h>
+#include <FNetManagedNetConnection.h>
+#include <FNetNetConnectionManager.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FNet_NetTypes.h"
+#include "FNet_ManagedNetConnectionImpl.h"
+#include "FNet_NetConnectionManagerImpl.h"
+#include "FNet_DnsImpl.h"
+#include "FNet_DnsEvent.h"
+#include "FNet_DnsManagedNetConnectionEventListener.h"
+#include "FNet_DnsRequestHandler.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Net
+{
+
+_DnsImpl::_DnsImpl(void)
+       : __pNetConnection(null)
+       , __pDnsEvent(null)
+       , __pDnsRequestHandlerList(null)
+       , __pManagedNetConnectionEventListener(null)
+       , __pManagedNetConnection(null)
+{
+}
+
+_DnsImpl::~_DnsImpl(void)
+{
+       if (__pManagedNetConnection != null)
+       {
+               __pManagedNetConnection->SetManagedNetConnectionEventListener(null);
+       }
+}
+
+result
+_DnsImpl::Construct(const NetConnection& netConnection, IDnsEventListener& listener)
+{
+       result r = E_SUCCESS;
+       NetConnectionState netConnectionState = NET_CONNECTION_STATE_NONE;
+
+       SysAssertf(__pDnsEvent == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       netConnectionState = netConnection.GetConnectionState();
+       SysTryReturnResult(NID_NET, (netConnectionState == NET_CONNECTION_STATE_STARTED ||              
+                       netConnectionState == NET_CONNECTION_STATE_RESUMED ||
+                       netConnectionState == NET_CONNECTION_STATE_SUSPENDED),
+                        E_INVALID_CONNECTION, "Network Connection is not established.");
+
+       unique_ptr<_DnsEvent> pDnsEvent(new (std::nothrow) _DnsEvent());
+       SysTryReturnResult(NID_NET, pDnsEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pDnsEvent->Construct();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = pDnsEvent->AddListener(listener, true);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       unique_ptr<ArrayList, _CollectionDeleter> pDnsRequestHandlerList(new (std::nothrow) ArrayList());
+       SysTryReturnResult(NID_NET, pDnsRequestHandlerList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pDnsRequestHandlerList->Construct();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       __pNetConnection = const_cast <NetConnection*>(&netConnection);
+       __pDnsEvent = move(pDnsEvent);
+       __pDnsRequestHandlerList = move(pDnsRequestHandlerList);
+
+       return r;
+}
+
+result
+_DnsImpl::Construct(IDnsEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pDnsEvent == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       unique_ptr<_DnsEvent> pDnsEvent(new (std::nothrow) _DnsEvent());
+       SysTryReturnResult(NID_NET, pDnsEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pDnsEvent->Construct();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = pDnsEvent->AddListener(listener, true);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       unique_ptr<ArrayList, _CollectionDeleter> pDnsRequestHandlerList(new (std::nothrow) ArrayList());
+       SysTryReturnResult(NID_NET, pDnsRequestHandlerList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pDnsRequestHandlerList->Construct();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       //check for default mode
+       if (!_NetConnectionManagerImpl::IsDefaultMode())
+       {
+               SysLog(NID_NET, "DNS uses ManagedNetConnection(Non-default mode)");
+
+               _NetConnectionManagerImpl* pConnectionManagerImpl = _NetConnectionManagerImpl::GetInstance();
+               SysTryReturnResult(NID_NET, pConnectionManagerImpl != null, E_SYSTEM,
+                               "A system error has been occurred. Network framework is not ready.");
+
+               unique_ptr<_DnsManagedNetConnectionEventListener> pManagedNetConnectionEventListener(new (std::nothrow) _DnsManagedNetConnectionEventListener(pDnsRequestHandlerList.get()));
+               SysTryReturnResult(NID_NET, pManagedNetConnectionEventListener != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               unique_ptr<ManagedNetConnection> pManagedNetConnection(pConnectionManagerImpl->GetManagedNetConnectionN());
+               SysTryReturnResult(NID_NET, pManagedNetConnection != null, E_INVALID_CONNECTION, "ManagedNetConnection is not found.");
+
+               _ManagedNetConnectionImpl* pManagedNCImpl= _ManagedNetConnectionImpl::GetInstance(*pManagedNetConnection);
+               SysTryReturnResult(NID_NET, pManagedNCImpl != null, E_INVALID_CONNECTION, "_ManagedNetConnectionImpl is null.");
+
+               r = pManagedNetConnection->SetManagedNetConnectionEventListener(pManagedNetConnectionEventListener.get());
+               SysTryReturnResult(NID_NET, r == E_SUCCESS, E_INVALID_CONNECTION, "Failed to set ManagedNetConnectionEventListener.");
+
+               r = pManagedNCImpl->Start();
+               SysTryReturnResult(NID_NET, r == E_SUCCESS, E_INVALID_CONNECTION, "Failed to start ManagedNetConnection.");
+
+               NetConnectionState connState = pManagedNCImpl->GetConnectionState();
+               if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+               {
+                       SysLog(NID_NET, "ManagedNetConnection is already connected.");
+                       pManagedNetConnectionEventListener->__isConnected = true;
+               }
+
+               __pManagedNetConnectionEventListener = move(pManagedNetConnectionEventListener);
+               __pManagedNetConnection = move(pManagedNetConnection);
+       }
+
+       __pDnsEvent = move(pDnsEvent);
+       __pDnsRequestHandlerList = move(pDnsRequestHandlerList);
+
+       return r;
+}
+
+result
+_DnsImpl::GetHostByName(const String& hostName)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pDnsEvent != null, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturnResult(NID_NET, !hostName.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. hostName is an empty string.");
+
+       ByteBuffer* pByteBuff = null;
+
+       //Check if proper utf8 string, if fails, return
+       pByteBuff = StringUtil::StringToUtf8N(hostName);
+       SysTryReturnResult(NID_NET, GetLastResult() != E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "Propagating.");
+       SysTryReturnResult(NID_NET, pByteBuff != null, E_INVALID_ARG, "Invalid argument is used. hostName=%ls.", hostName.GetPointer());
+       delete pByteBuff;
+
+       unique_ptr<char[]> pHostName(_StringConverter::CopyToCharArrayN(hostName));
+       SysTryReturnResult(NID_NET, pHostName != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       // create a request to be handled asynchronously
+       unique_ptr<_DnsRequest> pDnsRequest(new (std::nothrow) _DnsRequest(NET_DNS_EVENT_HOSTNAME, pHostName.get(), *__pDnsEvent));
+       SysTryReturnResult(NID_NET, pDnsRequest != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       // Ownership is transferred to pDnsRequest
+       pHostName.release();
+
+       // create request handler and pass request to handle
+       unique_ptr<_DnsRequestHandler> pDnsRequestHandler(new (std::nothrow) _DnsRequestHandler(pDnsRequest.get()));
+       SysTryReturnResult(NID_NET, pDnsRequestHandler != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       // Ownership is transferred to pDnsRequestHandler
+       pDnsRequest.release();
+
+       r = pDnsRequestHandler->Construct();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = __pDnsRequestHandlerList->Add(*pDnsRequestHandler);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       // if current network is not Custom NetConnection, or ManagedNetConnection is not already started.
+       if (__pManagedNetConnection != null &&  !__pManagedNetConnectionEventListener->__isConnected)
+       {
+               SysLog(NID_NET, "Waiting for ManagedNetConnection started event");      
+       }
+       else
+       {
+               r = pDnsRequestHandler->Start();
+               SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+       }
+
+       pDnsRequestHandler.release();
+
+       return r;
+}
+
+result
+_DnsImpl::GetHostByAddress(const IpAddress& ipAddress)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pDnsEvent != null, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturnResult(NID_NET, !ipAddress.ToString().IsEmpty(), E_INVALID_ARG,
+                       "Invalid argument is used. IpAddress is empty.");
+
+       SysTryReturnResult(NID_NET, ipAddress.GetNetAddressFamily() == NET_AF_IPV4, E_INVALID_ARG, 
+                       "Invalid argument is used. IPv4 only supported.");
+
+       unique_ptr<char[]> pIpAddr(_StringConverter::CopyToCharArrayN(ipAddress.ToString()));
+       SysTryReturnResult(NID_NET, pIpAddr != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       unique_ptr<_DnsRequest> pDnsRequest(new (std::nothrow) _DnsRequest(NET_DNS_EVENT_ADDRESS, pIpAddr.get(), *__pDnsEvent));
+       SysTryReturnResult(NID_NET, pDnsRequest != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       // Ownership is transferred to pDnsRequest
+       pIpAddr.release();
+
+       // create request handler and pass request to handle
+       unique_ptr<_DnsRequestHandler> pDnsRequestHandler(new (std::nothrow) _DnsRequestHandler(pDnsRequest.get()));
+       SysTryReturnResult(NID_NET, pDnsRequestHandler != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       // Ownership is transferred to pDnsRequestHandler
+       pDnsRequest.release();
+
+       r = pDnsRequestHandler->Construct();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = __pDnsRequestHandlerList->Add(*pDnsRequestHandler);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       // if current network is not Custom NetConnection, or ManagedNetConnection is not already started.
+       if (__pManagedNetConnection != null &&  !__pManagedNetConnectionEventListener->__isConnected)
+       {
+               SysLog(NID_NET, "Waiting for ManagedNetConnection started event");      
+       }
+       else
+       {
+               r = pDnsRequestHandler->Start();
+               SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+       }
+
+       pDnsRequestHandler.release();
+
+       return r;
+}
+
+_DnsImpl*
+_DnsImpl::GetInstance(Dns& dns)
+{
+       return dns.__pDnsImpl;
+}
+
+const _DnsImpl*
+_DnsImpl::GetInstance(const Dns& dns)
+{
+       return dns.__pDnsImpl;
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_DnsImpl.h b/src/FNet_DnsImpl.h
new file mode 100644 (file)
index 0000000..015b69a
--- /dev/null
@@ -0,0 +1,157 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_DnsImpl.h
+ * @brief      This is the header file for the _DnsImpl class.
+ *
+ * This header file contains the declarations of the _DnsImpl Class.
+ */
+
+#ifndef _FNET_INTERNAL_DNS_IMPL_H_
+#define _FNET_INTERNAL_DNS_IMPL_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include "FNet_NetUtility.h"
+
+namespace Tizen { namespace Base
+{
+class String;
+} } // Tizen::Base
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class ArrayList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net
+{
+class Dns;
+class IpAddress;
+class NetConnection;
+class NetConnectionManager;
+class ManagedNetConnection;
+class IDnsEventListener;
+class _DnsEvent;
+class _DnsManagedNetConnectionEventListener;
+
+class _DnsImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks                     After creating an instance of this class, you must explicitly call the
+        *                                              Construct() method to initialize the instance.
+        * @see                         Construct()
+        */
+       _DnsImpl(void);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_DnsImpl(void);
+
+       /**
+        * Initializes this instance of Dns with the specified parameters.
+        *
+        * @see                                 Dns::Construct()
+        * @since 2.1
+        * @return                              An error code
+        *
+        */
+       result Construct(const NetConnection& netConnection, IDnsEventListener& listener);
+
+       /**
+        * Initializes this instance of Dns with the specified listener.
+        *
+        * @see                                 Dns::Construct()
+        * @since 2.1
+        * @return                              An error code
+        */
+       result Construct(IDnsEventListener& listener);
+
+public:
+       /**
+        * Requests a DNS lookup by IP address. This method is asynchronous.
+        *
+        * @see                                 Dns::GetHostByName()
+        * @since 2.1
+        * @return                              An error code
+        */
+       result GetHostByName(const Tizen::Base::String& hostName);
+
+       /**
+        * Requests a DNS lookup by IP address. This method is asynchronous.
+        *
+        * @see                                 Dns::GetHostByAddress()
+        * @since 2.1
+        * @return                              An error code
+        */
+       result GetHostByAddress(const IpAddress& ipAddress);
+
+public:
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _DnsImpl
+     * @param[in]   pDns            An instance of Dns
+     */
+       static _DnsImpl* GetInstance(Dns& dns);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _DnsImpl
+     * @param[in]   pDns     An instance of Dns
+     */
+       static const _DnsImpl* GetInstance(const Dns& dns);
+
+private:
+       /*
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of Dns
+        */
+       _DnsImpl(const _DnsImpl& rhs);
+
+       /*
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs             An instance of Dns
+        */
+       _DnsImpl& operator =(const _DnsImpl& rhs);
+
+private:
+       Tizen::Net::NetConnection* __pNetConnection;
+       std::unique_ptr<_DnsEvent> __pDnsEvent;
+       std::unique_ptr<Tizen::Base::Collection::ArrayList, _CollectionDeleter> __pDnsRequestHandlerList; // List of Runnable to handle requests asynchronously
+       std::unique_ptr<_DnsManagedNetConnectionEventListener> __pManagedNetConnectionEventListener;
+       std::unique_ptr<ManagedNetConnection> __pManagedNetConnection;
+}; // _DnsImpl
+
+} } // Tizen::Net
+
+#endif // _FNET_INTERNAL_DNS_IMPL_H_
diff --git a/src/FNet_DnsManagedNetConnectionEventListener.cpp b/src/FNet_DnsManagedNetConnectionEventListener.cpp
new file mode 100644 (file)
index 0000000..f412b89
--- /dev/null
@@ -0,0 +1,139 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNet_FNet_DnsManagedNetConnectionEventListener.cpp
+ * @brief      This is the implementation file for _DnsManagedNetConnectionEventListener class.
+ * @version    3.0
+ *
+ * This file contains the implementation of _DnsManagedNetConnectionEventListener class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FNetManagedNetConnection.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_DnsRequestHandler.h"
+#include "FNet_DnsManagedNetConnectionEventListener.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net
+{
+
+//DnsManagedNetConnectionEventListener -listener for network connection events.
+
+_DnsManagedNetConnectionEventListener::_DnsManagedNetConnectionEventListener(ArrayList* pDnsRequestHandlerList)
+       :__pDnsRequestHandlerList(pDnsRequestHandlerList)
+       ,__isConnected(false)
+{
+}
+
+_DnsManagedNetConnectionEventListener::~_DnsManagedNetConnectionEventListener(void)
+{
+}
+
+void
+_DnsManagedNetConnectionEventListener::OnManagedNetConnectionBearerChanged(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET, "DnsManagedNetConnectionEventListener received an event, OnManagedNetConnectionBearerChanged.");
+}
+
+void
+_DnsManagedNetConnectionEventListener::OnManagedNetConnectionStarted(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET, "DnsManagedNetConnectionEventListener received an event, OnManagedNetConnectionStarted.");
+       result r = E_SUCCESS;
+
+       __isConnected = true;
+
+       unique_ptr<IEnumerator> pEnumerator(__pDnsRequestHandlerList->GetEnumeratorN());
+       SysTryReturnVoidResult(NID_NET, pEnumerator != null, E_SYSTEM,
+                       "[%s] A system error occurred. Failed to get enumerator from DnsRequestHandlerList.", GetErrorMessage(E_SYSTEM));
+
+       while (pEnumerator->MoveNext() == E_SUCCESS)
+       {
+               _DnsRequestHandler* pDnsRequestHandler = null;
+               pDnsRequestHandler = dynamic_cast<_DnsRequestHandler*>(pEnumerator->GetCurrent());
+               SysTryReturnVoidResult(NID_NET, pDnsRequestHandler != null, E_SYSTEM,
+                               "[%s] A system error occurred. Failed to cast DnsRequestHandler dynamically.", GetErrorMessage(E_SYSTEM));
+               
+               // start processing request
+               if (!pDnsRequestHandler->IsRequestStarted())
+               {
+                       r = pDnsRequestHandler->Start();
+                       SysTryReturnVoidResult(NID_NET, r ==  E_SUCCESS, E_SYSTEM,
+                                       "[%s] A system error occurred. Failed to start DnsRequestHandler.", GetErrorMessage(E_SYSTEM));
+               }
+       }
+}
+
+void
+_DnsManagedNetConnectionEventListener::OnManagedNetConnectionStopped(ManagedNetConnection& managedNetConnection,
+               NetConnectionStoppedReason reason)
+{
+       SysLog(NID_NET, "DnsManagedNetConnectionEventListener received an event, OnManagedNetConnectionStopped.");
+       result r = E_SUCCESS;
+
+       __isConnected = false;
+
+       unique_ptr<IEnumerator> pEnumerator(__pDnsRequestHandlerList->GetEnumeratorN());
+       SysTryReturnVoidResult(NID_NET, pEnumerator != null, E_SYSTEM,
+                       "[%s] A system error occurred. Failed to get enumerator from DnsRequestHandlerList.", GetErrorMessage(E_SYSTEM));
+
+       while (pEnumerator->MoveNext() == E_SUCCESS)
+       {
+               _DnsRequestHandler* pDnsRequestHandler = null;
+               pDnsRequestHandler = dynamic_cast<_DnsRequestHandler*>(pEnumerator->GetCurrent());
+               SysTryCatch(NID_NET, pDnsRequestHandler != null, r = E_SYSTEM, r,
+                               "[%s] A system error occurred. Failed to cast DnsRequestHandler dynamically.", GetErrorMessage(E_SYSTEM));
+       
+               // start processing request
+               if (!pDnsRequestHandler->IsRequestStarted())
+               {
+                       // call event for operation failed
+                       r = pDnsRequestHandler->FireNetworkStoppedEvent();
+                       SysTryCatch(NID_NET, r != E_SUCCESS, r = E_SYSTEM, r,
+                                       "[%s] A system error occurred. Failed to fire NetWorkStoppedEvent.", GetErrorMessage(E_SYSTEM));
+               }                                       
+       }
+
+       // Fall through
+       
+CATCH:
+       // Operation is complete, cleanup list
+       __pDnsRequestHandlerList->RemoveAll(true);
+}
+
+void
+_DnsManagedNetConnectionEventListener::OnManagedNetConnectionSuspended(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET, "DnsManagedNetConnectionEventListener received an event, OnManagedNetConnectionSuspended.");
+}
+
+void
+_DnsManagedNetConnectionEventListener::OnManagedNetConnectionResumed(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET, "DnsManagedNetConnectionEventListener received an event, OnManagedNetConnectionResumed.");
+}
+
+} } // Tizen::Net
+
diff --git a/src/FNet_DnsManagedNetConnectionEventListener.h b/src/FNet_DnsManagedNetConnectionEventListener.h
new file mode 100644 (file)
index 0000000..894978d
--- /dev/null
@@ -0,0 +1,131 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNet_FNet_DnsManagedNetConnectionEventListener.h
+ * @brief      This is the header file for _DnsManagedNetConnectionEventListener class.
+ * @version    3.0
+ *
+ * This header file contains the declarations of _DnsManagedNetConnectionEventListener class.
+ */
+
+#ifndef _FNET_INTERNAL_DNS_MANAGED_NET_CONNECTION_EVENT_LISTENER_H_
+#define _FNET_INTERNAL_DNS_MANAGED_NET_CONNECTION_EVENT_LISTENER_H_
+
+#include <FBaseDataType.h>
+#include <FNetIManagedNetConnectionEventListener.h>
+#include <FNetNetTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class ArrayList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net
+{
+
+class ManagedNetConnection;
+
+/**
+* @class _DnsManagedNetConnectionEventListener
+* @brief This class is the listener for network connection events.
+*/
+
+class _DnsManagedNetConnectionEventListener
+       : public IManagedNetConnectionEventListener
+{
+
+public:
+       _DnsManagedNetConnectionEventListener(Tizen::Base::Collection::ArrayList* pDnsRequestHandlerList);
+
+       virtual ~_DnsManagedNetConnectionEventListener(void);
+
+public:
+       /**
+        * Called to notify that the bearer has been changed. @n
+        * An application can send or receive the data through the Socket or HTTP methods and can obtain the
+        * information related to the changed bearer.
+        *
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       void OnManagedNetConnectionBearerChanged(ManagedNetConnection& managedNetConnection);
+
+       /**
+        * Called to notify the application that the network connection has been opened and connected. @n
+        * An application can then send or receive the data.
+        *
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       void OnManagedNetConnectionStarted(ManagedNetConnection& managedNetConnection);
+
+       /**
+        * Called to notify that the network connection has been closed and disconnected.
+        *
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        * @param[in]   reason                  A reason code for the error
+        *
+        */
+       void OnManagedNetConnectionStopped(ManagedNetConnection& managedNetConnection,
+                                               NetConnectionStoppedReason reason);
+
+       /**
+        * Called to notify the application that the connection status has been changed or is in an unstable or suspended state. @n
+        * Thus an application may neither send nor receive data through the Socket or Http until the network connection is resumed.
+        *
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       void OnManagedNetConnectionSuspended(ManagedNetConnection& managedNetConnection);
+
+       /**
+        * Called to notify the application that the network has recovered from a suspended state. @n
+        * Thus an application can send or receive data through the Socket or Http from now on.
+        *
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       void OnManagedNetConnectionResumed(ManagedNetConnection& managedNetConnection);
+
+private:
+       /**
+        * Default ctor
+        */
+       _DnsManagedNetConnectionEventListener(void);
+
+       /**
+        * This is the copy constructor.
+        *
+        * @param[in]   rhs     An instance of _DnsManagedNetConnectionEventListener
+        * @remarks             The function is declared but not implemented.
+        */
+       _DnsManagedNetConnectionEventListener(const _DnsManagedNetConnectionEventListener& rhs);
+
+       /**
+        * This is the assignment operator.
+        *
+        * @param[in]   rhs             An instance of _DnsManagedNetConnectionEventListener
+        * @remarks             The function is declared but not implemented.
+        */
+       _DnsManagedNetConnectionEventListener& operator =(const _DnsManagedNetConnectionEventListener& rhs);
+
+private:
+       Tizen::Base::Collection::ArrayList* __pDnsRequestHandlerList; // List of Runnable to handle requests asynchronously, not owned
+       bool __isConnected;
+       friend class _DnsImpl;
+}; // _DnsManagedNetConnectionEventListener
+
+} } // Tizen::Net
+
+#endif // _FNET_INTERNAL_DNS_MANAGED_NET_CONNECTION_EVENT_LISTENER_H_
+
diff --git a/src/FNet_DnsRequestHandler.cpp b/src/FNet_DnsRequestHandler.cpp
new file mode 100644 (file)
index 0000000..4bf3268
--- /dev/null
@@ -0,0 +1,324 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_DnsRequestHandler.cpp
+ * @brief              This is the implementation file for the _DnsRequestHandler Class.
+ *
+ */
+
+#include <netdb.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <FNetIp4Address.h>
+#include <FNetIpHostEntry.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_IpHostEntryImpl.h"
+#include "FNet_DnsEvent.h"
+#include "FNet_DnsEventArg.h"
+#include "FNet_DnsRequestHandler.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Net
+{
+
+_DnsRequestHandler::_DnsRequestHandler(_DnsRequest* pDnsRequest)
+       : __pThread(null)
+       , __isStarted(false)
+{
+       __pDnsRequest.reset(pDnsRequest);
+}
+
+result
+_DnsRequestHandler::Construct()
+{
+       result r = E_SUCCESS;
+
+       unique_ptr<Thread> pThread(new (std::nothrow) Thread());
+       SysTryReturnResult(NID_NET, pThread != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pThread->Construct(*this);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                       "A system error has been occurred. Failed to construct a thread.");
+
+       __pThread = move(pThread);
+
+       return r;
+}
+
+_DnsRequestHandler::~_DnsRequestHandler()
+{
+       if (__pThread != null)
+       {
+               __pThread->Join();
+       }
+}
+
+Object*
+_DnsRequestHandler::Run()
+{
+       if (__pDnsRequest.get() != null)
+       {
+               __pDnsRequest->Execute();
+
+               __pDnsRequest.reset(null);
+       }
+
+       return null;
+}
+
+result
+_DnsRequestHandler::Start()
+{
+       result r = E_SUCCESS;
+
+       //start thread
+       SysTryReturnResult(NID_NET, __pThread != null, E_SYSTEM,
+                       "A system error has been occurred. __pThread must not be null.");
+
+       r = __pThread->Start();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                       "A system error has been occurred. Failed to start the thread.");
+
+       __isStarted = true;
+
+       return r;
+}
+
+bool
+_DnsRequestHandler::IsRequestStarted()
+{
+       return __isStarted;
+}
+
+result
+_DnsRequestHandler::FireNetworkStoppedEvent()
+{
+       result r = E_SUCCESS;
+
+       _DnsEventArg* pDnsEventArg = null;
+       
+       _DnsEvent& dnsEvent = __pDnsRequest->GetDnsEvent();     
+
+       // callback app with error E_NETWORK_UNAVAILABLE
+       pDnsEventArg = new (std::nothrow) _DnsEventArg(E_NETWORK_UNAVAILABLE, null);
+       SysTryReturnResult(NID_NET, pDnsEventArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = dnsEvent.FireAsync(*pDnsEventArg);
+
+       return r;
+}
+
+result
+_DnsRequestHandler::DnsCallBack(struct hostent* pHostent, int dnsId, _DnsEvent& dnsEvent)
+{
+       //NOTE: DONOT DELETE pHostent
+
+       result r = E_SUCCESS;
+
+       _DnsEventArg* pDnsEventArg = null;
+       unique_ptr<IpHostEntry> pIpHostEntry;
+       _IpHostEntryImpl* pIpHostEntryImpl = null;
+
+       SysLog(NID_NET, "DnsCallBack() has been called with DNS ID:%d", dnsId);
+
+       // we need to check for null, if null send callback to listener with  E_DNS_NOT_FOUND error
+       if (pHostent != null)
+       {
+               struct in_addr** pInAddrList = null;
+
+               pInAddrList = (struct in_addr**) pHostent->h_addr_list;
+
+               //check we have got IP addresses and host name
+               if (pInAddrList != null && *pInAddrList != null && pHostent->h_name != null)
+               {
+                       // we have resolved the host. now populate the contents
+                       pIpHostEntry.reset(_IpHostEntryImpl::CreateIpHostEntryN());
+                       SysTryReturnResult(NID_NET, pIpHostEntry != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                       pIpHostEntryImpl = _IpHostEntryImpl::GetInstance(*pIpHostEntry);
+                       SysTryReturnResult(NID_NET, pIpHostEntryImpl != null, E_SYSTEM,
+                                       "A system error has been occurred. Failed to get IpHostEntry instance.");
+
+                       // fill address list
+                       r = SetAddressList(pHostent, *pIpHostEntryImpl);
+                       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                                       "A system error has been occurred. Failed to set hostent to address list.");
+
+                       // Fill aliases
+                       r = SetAliasList(pHostent, *pIpHostEntryImpl);
+                       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                                       "A system error has been occurred. Failed to set hostent to alias list.");
+               }
+               else
+               {
+                       r = E_DNS_NOT_FOUND;
+                       SysLogException(NID_NET, r, "[%s] An error has been occurred getting host information.", GetErrorMessage(E_DNS_NOT_FOUND));
+               }
+       }
+       else
+       {
+               r = E_DNS_NOT_FOUND;
+               SysLogException(NID_NET, r, "[%s] An error has been occurred getting host information.", GetErrorMessage(E_DNS_NOT_FOUND));
+       }
+       
+       // call app calback now.
+       //ownership of pIpHostEntry transferred to pDnsEventArg
+       pDnsEventArg = new (std::nothrow) _DnsEventArg(r, pIpHostEntry.get());
+       SysTryReturnResult(NID_NET, pDnsEventArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       pIpHostEntry.release();
+
+       r = dnsEvent.FireAsync(*pDnsEventArg);
+
+       SysLog(NID_NET, "[%s] DnsCallBack() has been done.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+_DnsRequestHandler::SetAddressList(const struct hostent* pHostent, _IpHostEntryImpl& ipHostEntryImpl)
+{
+       result r = E_SUCCESS;
+
+       // fill address list
+       struct in_addr** pInAddrList = null;
+
+       pInAddrList = (struct in_addr**) pHostent->h_addr_list;
+       SysTryReturnResult(NID_NET, pInAddrList != null, E_OPERATION_FAILED, "An error has been occurred in DNS response.");
+
+       unique_ptr<ArrayList, _CollectionDeleter> pAddrList(new (std::nothrow) ArrayList());
+       SysTryReturnResult(NID_NET, pAddrList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pAddrList->Construct();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                       "A system error has been occurred. Failed to construct an address list.");
+
+       for (int addrCount = 0; pInAddrList[addrCount] != null; addrCount++)
+       {
+               SysLog(NID_NET, "Resolved IP Address is %s", inet_ntoa(*pInAddrList[addrCount]));
+
+               unique_ptr<IpAddress> pIpAddress(new (std::nothrow) Ip4Address(ntohl((*pInAddrList[addrCount]).s_addr)));
+               SysTryReturnResult(NID_NET, pIpAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               r = pAddrList->Add(*pIpAddress);
+               SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                               "A system error has been occurred. Failed to add the address to address list.");
+
+               pIpAddress.release();
+       }
+
+       r = ipHostEntryImpl.SetAddressList(*pAddrList);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to set address list.");
+
+       pAddrList.release();
+
+       return r;
+}
+
+result
+_DnsRequestHandler::SetAliasList(const struct hostent* pHostent, _IpHostEntryImpl& ipHostEntryImpl)
+{
+       result r = E_SUCCESS;
+
+       unique_ptr<ArrayList, _CollectionDeleter> pAliasList(new (std::nothrow) ArrayList());
+       SysTryReturnResult(NID_NET, pAliasList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pAliasList->Construct();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                       "A system error has been occurred. Failed to construct an alias list.");
+
+       //Add Hostname to alias list
+       if (pHostent->h_name != null)
+       {
+               SysLog(NID_NET, "Hostname: %s", pHostent->h_name);
+
+               unique_ptr<String> pHostName(new (std::nothrow) String());
+               SysTryReturnResult(NID_NET, pHostName != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               r = StringUtil::Utf8ToString(pHostent->h_name, *pHostName);
+               SysTryReturnResult(NID_NET, r != E_OUT_OF_MEMORY, r, "Propagating.");
+               if (r == E_INVALID_ENCODING_RANGE)
+               {
+                       SysLog(NID_NET, "Failed to convert UTF-8 string into a Unicode string.");
+               }
+               else
+               {
+                       r = pAliasList->Add(*pHostName);
+                       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                                       "A system error has been occurred. Failed to add the hostname to alias list.");
+
+                       pHostName.release();
+               }
+       }
+
+       r = ipHostEntryImpl.SetAliasList(*pAliasList);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                       "A system error has been occurred. Failed to set alias list.");
+
+       pAliasList.release();
+       
+       return r;
+}
+
+// _DnsRequest class implementation
+_DnsRequest::_DnsRequest(_NetDnsEventType msgType, char* pMsgData, _DnsEvent& dnsEvent)
+       : __msgType(msgType)
+       , __dnsEvent(dnsEvent)
+{
+       __pMsgData.reset(pMsgData);
+}
+
+_DnsRequest::~_DnsRequest()
+{
+}
+
+void
+_DnsRequest::Execute()
+{
+       if (__msgType == NET_DNS_EVENT_HOSTNAME)
+       {
+               struct hostent* pHostent = null;
+
+               pHostent = (hostent*) gethostbyname(__pMsgData.get());
+               _DnsRequestHandler::DnsCallBack(pHostent, NET_DNS_EVENT_HOSTNAME, __dnsEvent);
+       }
+       else if (__msgType == NET_DNS_EVENT_ADDRESS)
+       {
+               struct hostent* pHostent = null;
+               struct in_addr ipv4addr;
+
+               inet_pton(AF_INET, __pMsgData.get(), &ipv4addr);
+
+               pHostent = (hostent*) gethostbyaddr(&ipv4addr, sizeof(ipv4addr), AF_INET);
+               _DnsRequestHandler::DnsCallBack(pHostent, NET_DNS_EVENT_ADDRESS, __dnsEvent);
+       }
+
+}
+
+_DnsEvent&
+_DnsRequest::GetDnsEvent()
+{
+       return  __dnsEvent;
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_DnsRequestHandler.h b/src/FNet_DnsRequestHandler.h
new file mode 100644 (file)
index 0000000..e046d9f
--- /dev/null
@@ -0,0 +1,204 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_DnsRequestHandler.h
+ * @brief              This is the header file for the _DnsRequestHandler Class.
+ *
+ * This header file contains declaration of the _DnsRequestHandler Class.
+ */
+#ifndef _FNET_INTERNAL_DNS_REQUEST_HANDLER_H_
+#define _FNET_INTERNAL_DNS_REQUEST_HANDLER_H_
+
+#include <unique_ptr.h>
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseRtThread.h>
+#include "FNet_DnsEventArg.h"
+
+namespace Tizen { namespace Net
+{
+
+class _DnsRequest;
+class _IpHostEntryImpl;
+class _DnsEvent;
+
+class _DnsRequestHandler
+       : public Tizen::Base::Object
+       , public Tizen::Base::Runtime::IRunnable
+{
+
+public:
+       /*
+        * Constructor
+        * @param[in]   pDnsRequest     _DnsRequest
+        */
+       _DnsRequestHandler(_DnsRequest* pDnsRequest);
+
+       /*
+        * Destructor
+        */
+       ~_DnsRequestHandler();
+
+       /*
+        * Two-Phase Constructor
+        */
+       result Construct();
+
+       /*
+        * Rnn() - Runnable implementation
+        */
+       Object* Run();
+
+       /*
+        * Start the Event Handler
+        * @return  A result code.
+        */
+       result Start();
+
+       /*
+        * Check the DNS request operation state
+        */
+       bool IsRequestStarted();
+
+       /*
+        * Fire network stopped  event
+        */
+       result FireNetworkStoppedEvent();
+
+public:
+       /*
+        * DNS Callback
+        *
+        * @since 2.1
+        * @param[in]   pHostent                        A pointer to struct hostent
+        * @param[in]   dnsId                           ID of DNS call
+        * @param[in]   dnsEvent                        DNS Event
+        * @return                                      An error code
+        */
+       static result DnsCallBack(struct hostent* pHostent, int dnsId, _DnsEvent& dnsEvent);
+
+       /*
+        * SetAddressList
+        *
+        * @since 2.1
+        * @param[in]   pHostent                        A pointer to struct hostent
+        * @param[in]   ipHostEntryImpl                 A reference to _IpHostEntryImpl
+        * @return                                      An error code
+        */
+       static result SetAddressList(const struct hostent* pHostent, _IpHostEntryImpl& ipHostEntryImpl);
+
+       /*
+        * SetAliasList
+        *
+        * @since 2.1
+        * @param[in]   pHostent                        A pointer to struct hostent
+        * @param[in]   ipHostEntryImpl                 A reference to _IpHostEntryImpl
+        * @return                                      An error code
+        */
+       static result SetAliasList(const struct hostent* pHostent, _IpHostEntryImpl& ipHostEntryImpl);
+
+private:
+       /*
+        *
+        * Default ctor
+        */     
+       _DnsRequestHandler(void);
+
+       /*
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        */
+       _DnsRequestHandler(const _DnsRequestHandler& rhs);
+
+       /*
+        * This is the assignment operator for this class. @n
+        * Do @b not use directly.
+        *
+        */
+       _DnsRequestHandler& operator =(const _DnsRequestHandler& rhs);
+
+private:
+       std::unique_ptr<_DnsRequest> __pDnsRequest; // Request, Own
+       std::unique_ptr<Tizen::Base::Runtime::Thread> __pThread;      // Thread to process request
+       bool __isStarted; // state of dns operation, started.
+};//_DnsRequestHandler
+
+/**
+* @class _DnsRequest
+* @brief _DnsRequest contains the event details to be processed by _DnsRequestHandler
+* @since 2.1
+*/
+
+class _DnsRequest
+       : public Tizen::Base::Object
+{
+public:
+       /*
+        * Constructor
+        * @param[in]   type            Event-type
+        * @param[in]   pMsg            Message Data
+        * @param[in]   event           _DnsEvent
+        */
+       _DnsRequest(_NetDnsEventType msgType, char* pMsgData, _DnsEvent& event);
+
+       /*
+        * Destructor
+        */
+       ~_DnsRequest();
+
+       /*
+        * Execute() - Process the message
+        */
+       void Execute();
+
+       /*
+        * Get the _DnsEvent object
+        */
+       _DnsEvent& GetDnsEvent();
+
+private:
+       /*
+        *
+        * Default ctor
+        */     
+       _DnsRequest(void);
+
+       /*
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        */
+       _DnsRequest(const _DnsRequest& rhs);
+
+       /*
+        * This is the assignment operator for this class. @n
+        * Do @b not use directly.
+        *
+        */
+       _DnsRequest& operator =(const _DnsRequest& rhs);
+
+//Attributes
+private:
+       _NetDnsEventType __msgType;  //event type
+       std::unique_ptr<char[]> __pMsgData; // event data, Owned
+       _DnsEvent& __dnsEvent;     // Event, has listener reference for callback.
+};//_DnsRequest
+
+} } //Tizen::Net
+
+#endif // _FNET_INTERNAL_DNS_REQUEST_HANDLER_H_
diff --git a/src/FNet_Ip4AddressImpl.cpp b/src/FNet_Ip4AddressImpl.cpp
new file mode 100644 (file)
index 0000000..ddb46cb
--- /dev/null
@@ -0,0 +1,232 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_Ip4AddressImpl.cpp
+ * @brief              This is the implementation for the _Ip4AddressImpl class.
+ */
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <unique_ptr.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseResult.h>
+#include <FBaseUtilStringTokenizer.h>
+#include <FBaseUtilStringUtil.h>
+#include <FNetNetTypes.h>
+#include <FNetIp4Address.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FNet_NetTypes.h"
+#include "FNet_Ip4AddressImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Net::Sockets;
+
+namespace Tizen { namespace Net {
+
+static const int _IP4_ADDRESS_LENGTH = sizeof(unsigned long);
+static const unsigned long _IP4_ADDRESS_NONE = 0xFFFFFFFF;
+static const wchar_t _VALID_IP4_ADDRESS_DELIMITER[] = L".";
+
+_Ip4AddressImpl::_Ip4AddressImpl(void)
+       : __address(_IP4_ADDRESS_NONE)
+       , __addressInTextualFormat()
+       , __isValid(false)
+{
+}
+
+_Ip4AddressImpl::_Ip4AddressImpl(const String& ipAddr)
+       : __address(_IP4_ADDRESS_NONE)
+       , __addressInTextualFormat()
+       , __isValid(false)
+{
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       int ret = 0;
+       struct in_addr in;
+
+       SysTryReturnVoidResult(NID_NET, ipAddr.GetLength() > 0, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. The length of Ip4Address must be longer than 0.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturnVoidResult(NID_NET, ipAddr.GetLength() < _MAX_IPV4_ADDRESS_STRING_LENGTH, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. The length of Ip4Address is longer than the maximum length.", GetErrorMessage(E_INVALID_ARG));
+
+       StringTokenizer tokens(ipAddr, _VALID_IP4_ADDRESS_DELIMITER);
+       SysTryReturnVoidResult(NID_NET, (tokens.GetTokenCount() == 1) || (tokens.GetTokenCount() == 4), E_INVALID_ARG,
+                       "[%s] Invalid argument is used. Ip4Address is in an invalid format. ipAddr=%ls", GetErrorMessage(E_INVALID_ARG), ipAddr.GetPointer());
+
+       while (tokens.HasMoreTokens())
+       {
+               String token;
+               int value = 0;
+
+               tokens.GetNextToken(token);
+
+               r = Integer::Parse(token, value);
+               SysTryReturnVoidResult(NID_NET, r == E_SUCCESS, E_INVALID_ARG,
+                               "[%s] Invalid argument is used. Ip4Address contains a number that cannot be parsed.", GetErrorMessage(E_INVALID_ARG), ipAddr.GetPointer());
+               SysTryReturnVoidResult(NID_NET, (value >= 0) && (value <= 255), E_INVALID_ARG,
+                               "[%s] Invalid argument is used. Each value of Ip4Address must be in the range of 0 to 255.", GetErrorMessage(E_INVALID_ARG));
+       }
+
+       unique_ptr<char[]> pIpAddr(_StringConverter::CopyToCharArrayN(ipAddr));
+       SysTryReturnVoidResult(NID_NET, pIpAddr != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       ret = inet_aton(pIpAddr.get(), &in);
+       SysTryReturnVoidResult(NID_NET, ret != 0, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. Ip4Address=%ls", GetErrorMessage(E_INVALID_ARG), ipAddr.GetPointer());
+
+       __address = ntohl(in.s_addr);
+       __addressInTextualFormat = ipAddr;
+       __isValid = true;
+}
+
+_Ip4AddressImpl::_Ip4AddressImpl(unsigned long ipAddr)
+       : __address(_IP4_ADDRESS_NONE)
+       , __addressInTextualFormat()
+       , __isValid(false)
+{
+       ClearLastResult();
+
+       struct in_addr in;
+       in.s_addr = htonl(ipAddr);
+       char* pIpAddr = inet_ntoa(in);
+
+       SysTryReturnVoidResult(NID_NET, pIpAddr != null, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. Ip4Address must not be null.", GetErrorMessage(E_INVALID_ARG));
+
+       __address = ipAddr;
+       __addressInTextualFormat = String(pIpAddr);
+       __isValid = true;
+}
+
+_Ip4AddressImpl::_Ip4AddressImpl(const _Ip4AddressImpl& value)
+{
+       __address = value.__address;
+       __addressInTextualFormat = value.__addressInTextualFormat;
+       __isValid = value.__isValid;
+}
+
+_Ip4AddressImpl::~_Ip4AddressImpl(void)
+{
+}
+
+NetAddressFamily
+_Ip4AddressImpl::GetNetAddressFamily(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET, __isValid, NET_AF_NONE, E_INVALID_STATE,
+                       "[%s] The Ip4Address is in an invalid state.", GetErrorMessage(E_INVALID_STATE));
+
+       return NET_AF_IPV4;
+}
+
+result
+_Ip4AddressImpl::GetAddress(ByteBuffer& ipAddr) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET, ipAddr.GetRemaining() >= _IP4_ADDRESS_LENGTH, E_OVERFLOW,
+                               "The size of buffer[%d] is smaller than [%d].", ipAddr.GetRemaining(), _IP4_ADDRESS_LENGTH);
+
+       r = ipAddr.SetLong((long)__address);
+
+       return r;
+}
+
+result
+_Ip4AddressImpl::GetAddress(unsigned long& ipAddr) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET, __isValid, E_INVALID_STATE, "The Ip4Address is in an invalid state.");
+
+       ipAddr = __address;
+
+       return r;
+}
+
+String
+_Ip4AddressImpl::ToString(void) const
+{
+       return __addressInTextualFormat;
+}
+
+_Ip4AddressImpl&
+_Ip4AddressImpl::operator =(const _Ip4AddressImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __address = rhs.__address;
+       __addressInTextualFormat = rhs.__addressInTextualFormat;
+       __isValid = rhs.__isValid;
+
+       return *this;
+}
+
+bool
+_Ip4AddressImpl::Equals(const Object& obj) const
+{
+       const _Ip4AddressImpl* pObj = dynamic_cast <const _Ip4AddressImpl*>(&obj);
+
+       if (pObj == null)
+       {
+               return false;
+       }
+
+       if (__address != pObj->__address)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+int
+_Ip4AddressImpl::GetHashCode(void) const
+{
+       return __address;
+}
+
+bool
+_Ip4AddressImpl::IsValid(void) const
+{
+       return __isValid;
+}
+
+_Ip4AddressImpl*
+_Ip4AddressImpl::GetInstance(Ip4Address& ip4Address)
+{
+       return ip4Address.__pIp4AddressImpl;
+}
+
+const _Ip4AddressImpl*
+_Ip4AddressImpl::GetInstance(const Ip4Address& ip4Address)
+{
+       return ip4Address.__pIp4AddressImpl;
+}
+
+}} // Tizen::Net
diff --git a/src/FNet_IpHostEntryImpl.cpp b/src/FNet_IpHostEntryImpl.cpp
new file mode 100644 (file)
index 0000000..a8d5010
--- /dev/null
@@ -0,0 +1,99 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_IpHostEntryImpl.cpp
+ * @brief              This is the implementation for the _IpHostEntryImpl class.
+ */
+
+#include <FBaseColArrayList.h>
+#include <FBaseUtilStringUtil.h>
+#include <FNetNetTypes.h>
+#include <FNetIp4Address.h>
+#include <FNetIpHostEntry.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_IpHostEntryImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Net
+{
+
+_IpHostEntryImpl::_IpHostEntryImpl(void)
+       : __pAddressList(null)
+       , __pAliasList(null)
+{
+}
+
+_IpHostEntryImpl::~_IpHostEntryImpl(void)
+{
+}
+
+IList*
+_IpHostEntryImpl::GetAddressList(void) const
+{
+       return __pAddressList.get();
+}
+
+IList*
+_IpHostEntryImpl::GetAliasList(void) const
+{
+       return __pAliasList.get();
+}
+
+IpHostEntry*
+_IpHostEntryImpl::CreateIpHostEntryN()
+{
+       IpHostEntry* pIpHostEntry = new (std::nothrow) IpHostEntry();
+       SysTryReturn(NID_NET, pIpHostEntry != null, null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pIpHostEntry;
+}
+
+result
+_IpHostEntryImpl::SetAddressList(const IList& addressList)
+{
+       __pAddressList.reset(const_cast <IList*>(&addressList));
+
+       return E_SUCCESS;
+}
+
+result
+_IpHostEntryImpl::SetAliasList(const IList& aliasList)
+{
+       __pAliasList.reset(const_cast <IList*>(&aliasList));
+
+       return E_SUCCESS;
+}
+
+_IpHostEntryImpl*
+_IpHostEntryImpl::GetInstance(IpHostEntry& ipHostEntry)
+{
+       return ipHostEntry.__pIpHostEntryImpl;
+}
+
+const _IpHostEntryImpl*
+_IpHostEntryImpl::GetInstance(const IpHostEntry& ipHostEntry)
+{
+       return ipHostEntry.__pIpHostEntryImpl;
+}
+
+} }  // Tizen::Net
diff --git a/src/FNet_IpHostEntryImpl.h b/src/FNet_IpHostEntryImpl.h
new file mode 100644 (file)
index 0000000..a58588a
--- /dev/null
@@ -0,0 +1,128 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_IpHostEntryImpl.h
+ * @brief              This is the header file for the _IpHostEntryImpl class.
+ */
+
+#ifndef _FNET_INTERNAL_IP_HOST_ENTRY_IMPL_H_
+#define _FNET_INTERNAL_IP_HOST_ENTRY_IMPL_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include "FNet_NetUtility.h"
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net
+{
+
+class _IpHostEntryImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_IpHostEntryImpl(void);
+
+public:
+       /**
+        * @see                 _IpHostEntryImpl::GetAddressList()
+        */
+       Tizen::Base::Collection::IList* GetAddressList(void) const;
+
+       /**
+        * @see                 _IpHostEntryImpl::GetAliasList()
+        */
+       Tizen::Base::Collection::IList* GetAliasList(void) const;
+
+public:
+       /*
+        * Factory Method to create IpHostEntry instance
+        *
+        * @since 2.1
+        * @return                      Instance of IpHostEntry
+        */
+       static IpHostEntry* CreateIpHostEntryN(void);
+
+public:
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _IpHostEntryImpl
+     * @param[in]   ipHostEntry            An instance of IpHostEntry
+     */
+       static _IpHostEntryImpl* GetInstance(IpHostEntry& ipHostEntry);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _IpHostEntryImpl
+     * @param[in]   ipHostEntry     An instance of IpHostEntry
+     */
+       static const _IpHostEntryImpl* GetInstance(const IpHostEntry& ipHostEntry);
+
+private:
+       /*
+        * This is the constructor for this class. @n
+        * Do @b not use directly.
+        *
+        */
+       _IpHostEntryImpl(void);
+
+private:
+       result SetAddressList(const Tizen::Base::Collection::IList& addressList);
+
+       result SetAliasList(const Tizen::Base::Collection::IList& aliasList);
+
+private:
+       /*
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of IpHostEntry
+        */
+       _IpHostEntryImpl(const _IpHostEntryImpl& rhs);
+
+       /*
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                             An instance of IpHostEntry
+        */
+       _IpHostEntryImpl& operator =(const _IpHostEntryImpl& rhs);
+
+private:
+       std::unique_ptr<Tizen::Base::Collection::IList, _CollectionDeleter> __pAddressList;
+       std::unique_ptr<Tizen::Base::Collection::IList, _CollectionDeleter> __pAliasList;
+
+       friend class _DnsRequestHandler;
+       friend class IpHostEntry;
+
+}; // _IpHostEntryImpl
+
+}  }  //Tizen::Net
+
+#endif // _FNET_INTERNAL_IP_HOST_ENTRY_IMPL_H_
diff --git a/src/FNet_LocalDhcpServerEvent.cpp b/src/FNet_LocalDhcpServerEvent.cpp
new file mode 100644 (file)
index 0000000..ef0591b
--- /dev/null
@@ -0,0 +1,174 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_DhcpServerEvent.cpp
+ * @brief              This is the implementation file for the _LocalDhcpServerEvent Class.
+ *
+ * This file contains the implementation of the _LocalDhcpServerEvent Class.
+ */
+
+#include <FNetNetTypes.h>
+#include <FNetDhcpClientInfo.h>
+#include <FNetILocalDhcpServerEventListener.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_LocalDhcpServerImpl.h"
+#include "FNet_LocalDhcpServerEvent.h"
+#include "FNet_LocalDhcpServerEventArg.h"
+#include "FNet_DhcpClientInfoImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net
+{
+
+_LocalDhcpServerEvent::_LocalDhcpServerEvent()
+       : __pLocalDhcpServer(null)
+       , __pLocalDhcpServerEventListener(null)
+{
+}
+
+_LocalDhcpServerEvent::~_LocalDhcpServerEvent(void)
+{      
+}
+
+result
+_LocalDhcpServerEvent::Construct(const LocalDhcpServer& localDhcpServer)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pLocalDhcpServer == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       r =  _Event::Initialize();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                       "A system error has been occurred. Failed to initialize the event.");
+
+       __pLocalDhcpServer = const_cast <LocalDhcpServer*>(&localDhcpServer);
+
+       return r;
+}
+
+result
+_LocalDhcpServerEvent::SetEventListener(ILocalDhcpServerEventListener* pListener)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pLocalDhcpServer != null, "Not yet constructed. Construct() should be called before use.");
+
+       if (__pLocalDhcpServerEventListener == null)
+       {
+               if (pListener != null)
+               {
+                       __pLocalDhcpServerEventListener = pListener;
+                       r = this->AddListener(*pListener, true);
+               }
+               else
+               {
+                       __pLocalDhcpServerEventListener = null;
+               }
+       }
+       else
+       {
+               if (pListener != null)
+               {
+                       this->RemoveListener(*__pLocalDhcpServerEventListener);
+                       __pLocalDhcpServerEventListener = pListener;
+                       r = this->AddListener(*pListener, true);
+               }
+               else
+               {
+                       this->RemoveListener(*__pLocalDhcpServerEventListener);
+                       __pLocalDhcpServerEventListener = null;
+               }
+       }
+
+       return r;
+}
+
+void
+_LocalDhcpServerEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+       result r = E_SUCCESS;
+
+       ILocalDhcpServerEventListener* pLocalDhcpServerEventListener = null;
+       pLocalDhcpServerEventListener = dynamic_cast < ILocalDhcpServerEventListener* >(&listener);
+       SysTryReturnVoidResult(NID_NET, pLocalDhcpServerEventListener != null, E_SYSTEM,
+                       "A system error has been occurred. Listener argument is invalid.");
+
+       IEventArg* pEventArg = const_cast < IEventArg* >(&arg);
+       _LocalDhcpServerEventArg* pLocalDhcpServerEventArg = dynamic_cast < _LocalDhcpServerEventArg* >(pEventArg);
+       SysTryReturnVoidResult(NID_NET, pLocalDhcpServerEventArg != null, E_SYSTEM,
+                       "A system error has been occurred. Event argument is invalid type.");
+
+       // Fire callback
+       DhcpClientInfo* pDhcpClientInfo = pLocalDhcpServerEventArg->GetDhcpClientInfo();
+       SysTryReturnVoidResult(NID_NET, pDhcpClientInfo != null, E_SYSTEM,
+                       "A system error has been occurred. Failed to get dhcp client information.");
+
+       // copy info and send to app.
+       DhcpClientInfo* pCallbackDhcpClientInfo = null;
+       pCallbackDhcpClientInfo = _DhcpClientInfoImpl::CloneDhcpClientInfoN(*pDhcpClientInfo);
+       SysTryReturnVoidResult(NID_NET, pCallbackDhcpClientInfo != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       switch (pLocalDhcpServerEventArg->GetEventType())
+       {
+       case NET_DHCP_SERVER_EVENT_CONNECT:
+               SysLog(NID_NET, "Calling OnNetConnectionSuspended() with Client name:%s, Mac address:%s",
+                   (pCallbackDhcpClientInfo->GetName()).GetPointer(),
+                   (pCallbackDhcpClientInfo->GetMacAddress()).GetPointer());
+
+               pLocalDhcpServerEventListener->OnDhcpClientConnectedN(*GetLocalDhcpServer(),
+                   *pCallbackDhcpClientInfo);
+
+               break;
+
+       case NET_DHCP_SERVER_EVENT_DISCONNECT:
+               SysLog(NID_NET, "Calling OnNetConnectionSuspended() with Client name:%s, Mac address:%s",
+                                       (pCallbackDhcpClientInfo->GetName()).GetPointer(),
+                                       (pCallbackDhcpClientInfo->GetMacAddress()).GetPointer());
+
+               pLocalDhcpServerEventListener->OnDhcpClientDisconnectedN(*GetLocalDhcpServer(),
+                   *pCallbackDhcpClientInfo);
+
+               break;
+
+       default:
+               delete pCallbackDhcpClientInfo;
+
+               r = E_SYSTEM;
+               SysLogException(NID_NET, r, "Event[%d] is invalid.", pLocalDhcpServerEventArg->GetEventType());
+               
+               break;
+       }
+
+       return;
+}
+
+LocalDhcpServer*
+_LocalDhcpServerEvent::GetLocalDhcpServer(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET, __pLocalDhcpServer != null, null, E_INVALID_STATE, "__pLocalDhcpServer is null.");
+
+       return __pLocalDhcpServer;
+}
+
+}} // Tizen::Net
diff --git a/src/FNet_LocalDhcpServerEvent.h b/src/FNet_LocalDhcpServerEvent.h
new file mode 100644 (file)
index 0000000..1d37289
--- /dev/null
@@ -0,0 +1,137 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_LocalDhcpServerEvent.h
+ * @brief              This is the header file for the _LocalDhcpServerEvent class.
+ *
+ * This header file contains declaration of the _LocalDhcpServerEvent class.
+ * The __LocalDhcpServerEvent class can call a method of a listener (ILocalDhcpServerEventListener object).
+ * So, when a dhcp server event occurs, an application can handle it appropriately.
+ */
+
+#ifndef _FNET_INTERNAL_LOCAL_DHCP_SERVER_EVENT_H_
+#define _FNET_INTERNAL_LOCAL_DHCP_SERVER_EVENT_H_
+
+#include <FBaseDataType.h>
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Net
+{
+class LocalDhcpServer;
+class _LocalDhcpServerImpl;
+class ILocalDhcpServerEventListener;
+class DhcpClientInfo;
+
+/**
+ * @class      _LocalDhcpServerEvent
+ * @brief      This class handles dhcp server events.
+ *
+ *
+ * When a dhcp server event occurs, the _LocalDhcpServerEvent class finds a listener and calls
+ * the appropriate method of the listener.
+ *
+ */
+class _LocalDhcpServerEvent
+       : public Tizen::Base::Runtime::_Event
+{
+public:
+       /**
+        * This is the default class constructor.
+        *
+        * @remarks             After creating an instance of this class, you must explicitly call
+        *                              construction methods to initialize the instance.
+        */
+       _LocalDhcpServerEvent(void);
+
+       /**
+        * This is the class destructor.
+        */
+       virtual ~_LocalDhcpServerEvent(void);
+
+       /**
+        * Initializes a new instance of the __LocalDhcpServerEvent class
+        *
+        * @return              The error code
+        * @param[in]   localDhcpServer                 An LocalDhcpServer object whose events are processed
+        * @exception   E_SUCCESS                       - This method is successful.
+        * @exception   E_INVALID_ARG           - The argument passed to a method contains an invalid value.
+        * @exception   E_OUT_OF_MEMORY         - Failed to allocate required/requested memory.
+        * @exception   E_SYSTEM                        - Internal error (System)
+        *
+        */
+       result Construct(const LocalDhcpServer& localDhcpServer);
+
+public:
+       /**
+        * Gets an associated LocalDhcpServer object
+        *
+        * @return              The LocalDhcpServer object 's pointer whose events are processed. If error happens, null is returned.
+        * @exception   E_SUCCESS                       - This method is successful.
+        * @exception   E_INVALID_STATE         - succeed, but not valid info found
+        * @remark              You can refer GetLastResult() for detailed error cause.
+        */
+       LocalDhcpServer* GetLocalDhcpServer(void) const;
+
+       /**
+        * Sets a listener instance for events about a local DHCP server.
+        *
+        * @param[in]   pListener                       An instance of ILocalDhcpServerEventListener if an argument is null, it will reset the event listener.
+        * @return              An error code
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance has not been constructed as yet.
+        * @exception   E_SYSTEM                        An internal error occurred.
+        */
+       result SetEventListener(ILocalDhcpServerEventListener* pListener);
+
+protected:
+       /**
+        * Checks the arg and finds out the type of event. After that this method calls appropriate
+        * pListener's method.
+        *
+        * @return              A result code.
+        * @param[in]   pListener                       It is a event listener related to this Http event.
+        * @param[in]   arg                                     It is an argument-like instance of Http event retransmitted to the listener's method as an argument.
+        * @exception   E_SUCCESS                       - The method is successful.
+        * @exception   E_INVALID_ARG           - The argument passed to a method contains an invalid value.@n
+        */
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+       /*
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of __LocalDhcpServerEvent
+        */
+       _LocalDhcpServerEvent(const _LocalDhcpServerEvent& rhs);
+
+       /*
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                             An instance of __LocalDhcpServerEvent
+        */
+       _LocalDhcpServerEvent& operator =(const _LocalDhcpServerEvent& rhs);
+
+private:
+       LocalDhcpServer* __pLocalDhcpServer;    //for reference
+       ILocalDhcpServerEventListener* __pLocalDhcpServerEventListener;
+       
+       friend class _LocalDhcpServerImpl;
+}; // _LocalDhcpServerEvent
+
+} } // Tizen::Net
+#endif // _FNET_INTERNAL_DHCP_SERVER_EVENT_H_
diff --git a/src/FNet_LocalDhcpServerEventArg.cpp b/src/FNet_LocalDhcpServerEventArg.cpp
new file mode 100644 (file)
index 0000000..32b9109
--- /dev/null
@@ -0,0 +1,68 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_DhcpServerEventArg.cpp
+ * @brief              This is the implementation file for the _LocalDhcpServerEventArg Class.
+ *
+ * This file contains the implementation of the _LocalDhcpServerEventArg Class.
+ */
+
+#include <FNetNetTypes.h>
+#include <FNetDhcpClientInfo.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_DhcpClientInfoImpl.h"
+#include "FNet_LocalDhcpServerEventArg.h"
+
+using namespace std;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net
+{
+
+_LocalDhcpServerEventArg::_LocalDhcpServerEventArg(_NetDhcpServerEventType eventCode, DhcpClientInfo& dhcpClientInfo)
+       : __eventType(eventCode)
+       , __pDhcpClientInfo(null)       
+{
+       unique_ptr<DhcpClientInfo> pDhcpClientInfo(_DhcpClientInfoImpl::CloneDhcpClientInfoN(dhcpClientInfo));
+       SysTryReturnVoidResult(NID_NET, pDhcpClientInfo != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       __pDhcpClientInfo = move(pDhcpClientInfo);
+}
+
+_LocalDhcpServerEventArg::~_LocalDhcpServerEventArg(void)
+{      
+}
+
+_NetDhcpServerEventType
+_LocalDhcpServerEventArg::GetEventType(void) const
+{
+       return (__eventType);
+}
+
+DhcpClientInfo*
+_LocalDhcpServerEventArg::GetDhcpClientInfo(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET, __pDhcpClientInfo != null, null, E_INVALID_STATE,
+                       "[%s] DhcpClientInfo is in an invalid state. __pDhcpClientInfo is null", GetErrorMessage(E_INVALID_STATE));
+
+       return __pDhcpClientInfo.get();
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_LocalDhcpServerEventArg.h b/src/FNet_LocalDhcpServerEventArg.h
new file mode 100644 (file)
index 0000000..de735e8
--- /dev/null
@@ -0,0 +1,125 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_DhcpServernEventArg.h
+ * @brief              This is the header file for the _LocalDhcpServerEventArg class.
+ *
+ * This header file contains declaration of the _LocalDhcpServerEventArg class.
+ */
+#ifndef _FNET_INTERNAL_LOCAL_DHCP_SERVER_EVENT_ARG_H_
+#define _FNET_INTERNAL_LOCAL_DHCP_SERVER_EVENT_ARG_H_
+
+#include <unique_ptr.h>
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+
+namespace Tizen { namespace Net
+{
+class DhcpClientInfo;
+
+/*
+ * @enum NetDhcpServerEventType
+ * Type for specifying the type of DHCP server events
+ */
+enum _NetDhcpServerEventType
+{
+       NET_DHCP_SERVER_EVENT_NONE = 0,
+       NET_DHCP_SERVER_EVENT_CONNECT,      /*< For notifying the connection event */
+       NET_DHCP_SERVER_EVENT_DISCONNECT,   /*< For notifying the disconnect event */
+};
+
+/**
+ * @class      _LocalDhcpServerEventArg
+ * @brief      This class is used as an argument of methods of the ILocalDhcpServerEventListener class.
+ *
+ *
+ * This class is used as an argument of ILocalDhcpServerEventListener's methods.
+ * When a NetConnection event occurs, the _LocalDhcpServerEvent object finds a ILocalDhcpServerEventListener object
+ * which registered for the LocalDhcpServer object and calls an appropriate method of the listener.
+ * @see ILocalDhcpServerEventListener for example codes
+ *
+ */
+class _LocalDhcpServerEventArg
+       : public Tizen::Base::Object
+       , public Tizen::Base::Runtime::IEventArg
+{
+
+public:
+       /**
+        * This is class constructor.
+        *
+        * @param[in] eventType         - what kind of event occurred
+        * @param[in] dhcpClientInfo    - A DhcpClientInfo object
+        */
+       _LocalDhcpServerEventArg(_NetDhcpServerEventType eventType, DhcpClientInfo& dhcpClientInfo);
+
+       /**
+        * This is the class destructor.
+        *
+        */
+       virtual ~_LocalDhcpServerEventArg(void);
+
+public:
+       /**
+        *      Gets the event type.
+        *
+        *      @return See above comment.
+        */
+       _NetDhcpServerEventType GetEventType(void) const;
+
+       /**
+        * Returns the DhcpClientInfo which contains the result of the LocalDhcpServer request.
+        *
+        * @return              An DhcpClientInfo object which contains a device name, an local IP address and mac address.
+        *                              In case of error condition, null is returned.
+        * @exception   E_SUCCESS                       - successful
+        * @exception   E_INVALID_STATE         - succeed, but not valid info found
+        * @exception   E_OPERATION_FAILED      - operation failed, so no DhcpClientInfo
+        * @remark              You can refer detailed error cause by calling GetLastError()
+        */
+       DhcpClientInfo* GetDhcpClientInfo(void) const;
+
+private:
+       /*
+        * This is default constructor
+        *
+        */
+       _LocalDhcpServerEventArg(void);
+
+       /*
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of _LocalDhcpServerEventArg
+        */
+       _LocalDhcpServerEventArg(const _LocalDhcpServerEventArg& rhs);
+
+       /*
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of _DnsEventArg
+        */
+       _LocalDhcpServerEventArg& operator =(const _LocalDhcpServerEventArg& rhs);
+
+private:
+       _NetDhcpServerEventType __eventType;
+       std::unique_ptr<DhcpClientInfo> __pDhcpClientInfo;
+}; // _LocalDhcpServerEventArg
+
+} } // Tizen::Net
+#endif // _FNET_INTERNAL_LOCAL_DHCP_SERVER_EVENT_ARG_H_
diff --git a/src/FNet_LocalDhcpServerImpl.cpp b/src/FNet_LocalDhcpServerImpl.cpp
new file mode 100644 (file)
index 0000000..8e71e7c
--- /dev/null
@@ -0,0 +1,1175 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_LocalDhcpServerImpl.cpp
+ * @brief              This is the implementation file for the __LocalDhcpServerImpl Class.
+ *
+ * This header file contains implementation of the __LocalDhcpServerImpl Class.
+ */
+
+#include <dlfcn.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <string.h>
+
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FNetNetTypes.h>
+#include <FNetIp4Address.h>
+#include <FNetNetConnectionInfo.h>
+#include <FNetNetConnection.h>
+#include <FNetDhcpClientInfo.h>
+#include <FNetLocalDhcpServer.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include <FNetWifiWifiDirectDevice.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include "FNet_NetConnectionImpl.h"
+#include "FNet_LocalDhcpServerImpl.h"
+#include "FNet_DhcpClientInfoImpl.h"
+#include "FNet_LocalDhcpServerEvent.h"
+#include "FNet_LocalDhcpServerEventArg.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Net::Wifi;
+
+namespace Tizen { namespace Net
+{
+
+static const int  _MAX_DHCP_CLIENT_COUNT = 8; //dependent on DHCP server config
+
+static const char _PLATFORM_MAC_ADDRESS_DELIMITER = ':';
+static const char _MAC_ADDRESS_DELIMITER = '-';
+static const char* _WIFI_DIRECT_LIBRARY_NAME = "libosp-wifi.so";
+
+/*
+ * The _DhcpNetConnectionEventListenerImpl class can call listener's method. So, when an NetConnection event occurs,
+ * application can handle it appropriately.
+ */
+class _DhcpNetConnectionEventListenerImpl
+       : public INetConnectionEventListener
+{
+
+public:
+       _DhcpNetConnectionEventListenerImpl(void);
+
+       virtual ~_DhcpNetConnectionEventListenerImpl(void);
+
+public:
+       void SetConstructParams(_LocalDhcpServerEvent* pLocalDhcpServerEvent, tethering_h pUsbTetheringHandle);
+
+public:
+
+       void OnNetConnectionStarted(NetConnection& netConnection, result r);
+
+       void OnNetConnectionStopped(NetConnection& netConnection, result r);
+
+       void OnNetConnectionSuspended(NetConnection& netConnection);
+
+       void OnNetConnectionResumed(NetConnection& netConnection);
+
+private:
+
+       _DhcpNetConnectionEventListenerImpl(const _DhcpNetConnectionEventListenerImpl& value);
+
+       _DhcpNetConnectionEventListenerImpl& operator =(const _DhcpNetConnectionEventListenerImpl& rhs);
+
+private:
+
+       _LocalDhcpServerEvent* __pLocalDhcpServerEvent;// reference, no ownership
+       tethering_h __pUsbTetheringHandle;// no ownership
+
+};
+
+_DhcpNetConnectionEventListenerImpl::_DhcpNetConnectionEventListenerImpl()
+: __pLocalDhcpServerEvent(null)
+, __pUsbTetheringHandle(null)
+{
+
+}
+
+_DhcpNetConnectionEventListenerImpl::~_DhcpNetConnectionEventListenerImpl(void)
+{
+}
+
+void
+_DhcpNetConnectionEventListenerImpl::OnNetConnectionStarted(NetConnection& netConnection, result r)
+{
+       SysLog(NID_NET, "DhcpNetConnectionEventListener received an event, OnNetConnectionStarted.");
+
+       // check, if listener is null
+       if (__pLocalDhcpServerEvent == null)
+       {
+               // log error
+               SysLogException(NID_NET, E_SYSTEM,
+                   "__DhcpNetConnectionEventListenerImpl::OnNetConnectionStarted Invalid state.");
+
+               return;
+       }
+
+       // process connected event
+       _LocalDhcpServerImpl* pLocalDhcpServerImpl = null;
+       pLocalDhcpServerImpl = _LocalDhcpServerImpl::GetInstance(*__pLocalDhcpServerEvent->GetLocalDhcpServer());
+       SysTryReturnVoidResult(NID_NET, pLocalDhcpServerImpl != null, E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to retrieve LocalDhcpServer instance.", GetErrorMessage(E_SYSTEM));
+
+       // set flag
+       pLocalDhcpServerImpl->__isConnectedNetwork = true;
+       // save the list
+       pLocalDhcpServerImpl->SetDhcpConnectedPeerInfoList(pLocalDhcpServerImpl->GetDhcpClientInfoListN(false));
+
+       if (netConnection.GetNetAccountId() == _DEFAULT_USB_ACCOUNT_ID)
+       {
+               SysLog(NID_NET, "OnNetConnectionStarted, Get DHCP Client info for USB");
+
+               ArrayList* pDhcpClientInfoList = null;
+               DhcpClientInfo* pDhcpClientInfo = null;
+               _LocalDhcpServerEventArg* pDhcpServerEventArg = null;
+               _NetDhcpServerEventType eventCode = NET_DHCP_SERVER_EVENT_CONNECT;
+               
+               pDhcpClientInfoList = dynamic_cast<ArrayList*>(pLocalDhcpServerImpl->GetDhcpConnectedPeerInfoList());
+               SysTryReturnVoidResult(NID_NET, pDhcpClientInfoList != null, E_SYSTEM,
+                               "[%s] A system error has been occurred. Failed to retrieve DhcpClientInfoList.", GetErrorMessage(E_SYSTEM));
+               
+               // we know USB case only one entry exists
+               pDhcpClientInfo = dynamic_cast<DhcpClientInfo*>(pDhcpClientInfoList->GetAt(0));
+               SysTryReturnVoidResult(NID_NET, pDhcpClientInfo != null, E_SYSTEM,
+                               "[%s] A system error has been occurred. Failed to retrieve DhcpClientInfo.", GetErrorMessage(E_SYSTEM));
+               
+               pDhcpServerEventArg = new (std::nothrow) _LocalDhcpServerEventArg(eventCode, *pDhcpClientInfo);
+               SysTryReturnVoidResult(NID_NET, pDhcpServerEventArg != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __pLocalDhcpServerEvent->Fire(*pDhcpServerEventArg);
+       }
+       else if (netConnection.GetNetAccountId() == _DEFAULT_WIFI_DIRECT_ACCOUNT_ID)
+       {
+               SysLog(NID_NET, "OnNetConnectionStarted, Get DHCP Client info for WIFI-DIRECT");
+
+               //register for events
+
+               WifiDirectDevice*(*pRegisterListenerFunction)(IWifiDirectDeviceListener* pDeviceListener, IWifiDirectGroupOwnerListener* pOwnerListener,
+                                                       IWifiDirectGroupClientListener* pClientListener) = null;
+
+               pLocalDhcpServerImpl->__pDllHandle = dlopen(_WIFI_DIRECT_LIBRARY_NAME, RTLD_LAZY);
+               SysTryReturnVoidResult(NID_NET, pLocalDhcpServerImpl->__pDllHandle != null, E_SYSTEM,
+                               "[%s] A system error has been occurred. Failed to open wifi library.", GetErrorMessage(E_SYSTEM));
+
+               pRegisterListenerFunction = reinterpret_cast<WifiDirectDevice*(*)(IWifiDirectDeviceListener* pDeviceListener, IWifiDirectGroupOwnerListener* pOwnerListener,
+                                       IWifiDirectGroupClientListener* pClientListener)>( dlsym(pLocalDhcpServerImpl->__pDllHandle,                                                                                            "_WifiDirectDeviceManagerImpl_GetWifiDirectDeviceN"));
+               SysTryReturnVoidResult(NID_NET, pRegisterListenerFunction != null, E_SYSTEM,
+                               "[%s] A system error has been occurred. Failed to get a function pointer.", GetErrorMessage(E_SYSTEM));
+
+               pLocalDhcpServerImpl->__pDevice = pRegisterListenerFunction(null, pLocalDhcpServerImpl, null);
+               SysTryReturnVoidResult(NID_NET, pLocalDhcpServerImpl->__pDevice != null, E_SYSTEM,
+                               "[%s] A system error has been occurred. Failed to get a WifiDirectDevice instance.", GetErrorMessage(E_SYSTEM));
+       }
+       else
+       {
+               // should not reach here.
+               SysAssertf(false, "OnNetConnectionStarted, Bearer not supported for DHCP");
+               return;
+       }
+       
+       return;
+}
+
+void
+_DhcpNetConnectionEventListenerImpl::OnNetConnectionStopped(NetConnection& netConnection, result r)
+{
+       SysLog(NID_NET, "DhcpNetConnectionEventListener received an event, OnNetConnectionStopped.");
+
+       result error = E_SUCCESS;
+       _LocalDhcpServerEventArg* pDhcpServerEventArg = null;
+       _NetDhcpServerEventType eventCode = NET_DHCP_SERVER_EVENT_DISCONNECT;
+       
+       // check
+       if (__pLocalDhcpServerEvent == null)
+       {
+               // log error
+               SysLogException(NID_NET, E_SYSTEM,
+                   "__DhcpNetConnectionEventListenerImpl::OnNetConnectionStopped pDhcpServerEvent is null.");
+
+               return;
+       }
+
+       // process disconnect event
+       ArrayList* pDhcpConnectedPeerInfoList = null;
+       _LocalDhcpServerImpl* pLocalDhcpServerImpl = null;
+
+       pLocalDhcpServerImpl = _LocalDhcpServerImpl::GetInstance(*__pLocalDhcpServerEvent->GetLocalDhcpServer());
+       SysTryReturnVoidResult(NID_NET, pLocalDhcpServerImpl != null, E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to retrieve LocalDhcpServer instance.", GetErrorMessage(E_SYSTEM));
+
+       if (netConnection.GetNetAccountId() == _DEFAULT_USB_ACCOUNT_ID)
+       {
+               SysLog(NID_NET, "OnNetConnectionStopped event received for USB");               
+       }
+       else if (netConnection.GetNetAccountId() == _DEFAULT_WIFI_DIRECT_ACCOUNT_ID)
+       {
+               SysLog(NID_NET, "OnNetConnectionStopped event received for WIFI-DIRECT");
+
+               //un-register for events
+               if (pLocalDhcpServerImpl->__pDllHandle != null)
+               {
+                       if (pLocalDhcpServerImpl->__pDevice != null)
+                       {
+                               void(*pUnRegisterListenerFunction)(WifiDirectDevice* pWifiDirectDevice, IWifiDirectDeviceListener* pDeviceListener,
+                                        IWifiDirectGroupOwnerListener* pOwnerListener, IWifiDirectGroupClientListener* pClientListener) = null;
+
+                               pUnRegisterListenerFunction = reinterpret_cast<void(*)(WifiDirectDevice* pWifiDirectDevice, IWifiDirectDeviceListener* pDeviceListener,  
+                                                       IWifiDirectGroupOwnerListener* pOwnerListener, IWifiDirectGroupClientListener* pClientListener)>(
+                                                       dlsym(pLocalDhcpServerImpl->__pDllHandle, "_WifiDirectDeviceImpl_DeleteWifiDirectDevice"));
+                               if (pUnRegisterListenerFunction != null)
+                               {
+                                       pUnRegisterListenerFunction(pLocalDhcpServerImpl->__pDevice, null, pLocalDhcpServerImpl, null);
+                                       pLocalDhcpServerImpl->__pDevice = null;
+                                       SysLog(NID_NET, "Deleted an instance of WifiDirectDevice.");
+                               }
+                       }
+                       dlclose(pLocalDhcpServerImpl->__pDllHandle);
+                       pLocalDhcpServerImpl->__pDllHandle = null;
+               }       
+       }
+       else
+       {
+               // should not reach here.
+               SysAssertf(false, "OnNetConnectionStopped, Bearer not supported for DHCP");
+
+               return;
+       }
+
+       // notify user about disconnect, call for each peer info
+       pDhcpConnectedPeerInfoList = dynamic_cast<ArrayList*>(pLocalDhcpServerImpl->GetDhcpConnectedPeerInfoList());
+       SysTryReturnVoidResult(NID_NET, pDhcpConnectedPeerInfoList != null, E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to retrieve DhcpConnectedPeerInfoList.", GetErrorMessage(E_SYSTEM));
+
+       unique_ptr<IEnumerator> pListEnumerator(pDhcpConnectedPeerInfoList->GetEnumeratorN());
+
+       SysTryReturnVoidResult(NID_NET, pListEnumerator != null, E_SYSTEM,
+                       "[%s] A system error has been occurred. pListEnumerator is null.", GetErrorMessage(E_SYSTEM));
+
+       // send notify to user about disconnect         
+       while (pListEnumerator->MoveNext() == E_SUCCESS)
+       {
+               DhcpClientInfo* pDhcpClientInfo = null;
+               pDhcpClientInfo = dynamic_cast<DhcpClientInfo*>(pListEnumerator->GetCurrent());
+               
+               if (pDhcpClientInfo != null)
+               {                       
+                       pDhcpServerEventArg = new (std::nothrow) _LocalDhcpServerEventArg(eventCode, *pDhcpClientInfo);
+                       SysTryReturnVoidResult(NID_NET, pDhcpServerEventArg != null, E_OUT_OF_MEMORY,
+                                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       __pLocalDhcpServerEvent->Fire(*pDhcpServerEventArg);
+               }
+       }
+       // Operation is complete, delete the elements
+       pDhcpConnectedPeerInfoList->RemoveAll(true);
+
+       // Remove NetConnectionListener
+       pLocalDhcpServerImpl->__isConnectedNetwork = false;
+
+       error = pLocalDhcpServerImpl->__pNetConnectionClone->RemoveNetConnectionListener(*pLocalDhcpServerImpl->__pNetConnectionListener);
+       SysTryReturnVoidResult(NID_NET, error == E_SUCCESS, E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to remove the NetConnection listener.", GetErrorMessage(E_SYSTEM));
+
+       return;
+}
+
+void
+_DhcpNetConnectionEventListenerImpl::OnNetConnectionSuspended(NetConnection& netConnection)
+{
+       SysLog(NID_NET, "DhcpNetConnectionEventListener received an event, OnNetConnectionSuspended.");
+}
+
+void
+_DhcpNetConnectionEventListenerImpl::OnNetConnectionResumed(NetConnection& netConnection)
+{
+       SysLog(NID_NET, "DhcpNetConnectionEventListener received an event, OnNetConnectionResumed.");
+}
+
+void
+_DhcpNetConnectionEventListenerImpl::SetConstructParams(_LocalDhcpServerEvent* pLocalDhcpServerEvent,
+               tethering_h pUsbTetheringHandle)
+{
+       __pLocalDhcpServerEvent = pLocalDhcpServerEvent;
+       __pUsbTetheringHandle = pUsbTetheringHandle;
+}
+
+
+//LocalDhcpServerImpl Implementation
+
+_LocalDhcpServerImpl::_LocalDhcpServerImpl(void)
+       : __pLocalDhcpServerEvent(null)
+       , __pNetConnection(null)
+       , __pNetConnectionClone(null)
+       , __pNetConnectionListener(null)
+       , __pUsbTetheringHandle(null)
+       , __pDhcpConnectedPeerInfoList(null)
+       , __pDevice(null)
+       , __pDllHandle(null)
+       , __isConstructed(false)
+       , __isConnectedNetwork(false)
+{
+}
+
+_LocalDhcpServerImpl::~_LocalDhcpServerImpl(void)
+{
+       // deallocate memory for handle
+       if (__pUsbTetheringHandle != null)
+       {
+               tethering_destroy(__pUsbTetheringHandle);
+               __pUsbTetheringHandle = null;
+       }
+
+       if (__pDllHandle != null)
+       {
+               if (__pDevice != null)
+               {
+                       void(*pUnRegisterListenerFunction)(WifiDirectDevice* pWifiDirectDevice, IWifiDirectDeviceListener* pDeviceListener, 
+                               IWifiDirectGroupOwnerListener* pOwnerListener,  IWifiDirectGroupClientListener* pClientListener) = null;
+
+                       pUnRegisterListenerFunction = reinterpret_cast<void(*)(WifiDirectDevice* pWifiDirectDevice, IWifiDirectDeviceListener* pDeviceListener,
+                                       IWifiDirectGroupOwnerListener* pOwnerListener, IWifiDirectGroupClientListener* pClientListener)>
+                                       (dlsym(__pDllHandle, "_WifiDirectDeviceImpl_DeleteWifiDirectDevice"));
+                       if (pUnRegisterListenerFunction != null)
+                       {
+                               pUnRegisterListenerFunction(__pDevice, null, this, null);
+                               __pDevice = null;                               
+                       }
+               }
+
+               dlclose(__pDllHandle);
+       }
+}
+
+result
+_LocalDhcpServerImpl::Construct(const LocalDhcpServer* pLocalDhcpServer, const NetConnection& netConnection)
+{
+       result r = E_SUCCESS;
+       _NetConnectionImpl* pNetConnectionImpl = null;
+       NetConnectionState netConnectionState = NET_CONNECTION_STATE_NONE;
+       unique_ptr<_DhcpNetConnectionEventListenerImpl> pNetConnectionListener(null);
+       unique_ptr<NetConnection> pNetConnectionClone(null);
+
+       SysAssertf(__isConstructed == false,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       //check input
+       NetAccountId netAccountId = netConnection.GetNetAccountId();
+       SysTryReturnResult(NID_NET, (netAccountId == _DEFAULT_USB_ACCOUNT_ID || netAccountId == _DEFAULT_WIFI_DIRECT_ACCOUNT_ID),
+                       E_INVALID_ARG, "Invalid argument is used. The bearer type is not supported. bearerType=%d", netAccountId);
+
+       __pNetConnection = const_cast<NetConnection*>(&netConnection);
+
+       //create Event
+       unique_ptr<_LocalDhcpServerEvent> pLocalDhcpServerEvent(new (std::nothrow) _LocalDhcpServerEvent());
+       SysTryReturnResult(NID_NET, pLocalDhcpServerEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pLocalDhcpServerEvent->Construct(*(const_cast < const LocalDhcpServer* >(pLocalDhcpServer)));
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                       "A system error has been occurred. Failed to construct LocalDhcpServerEvent instance.");
+
+       // we have to listen to connection events, so clone NetConnection and set listener
+       pNetConnectionImpl = const_cast<_NetConnectionImpl*>(_NetConnectionImpl::GetInstance(netConnection));
+       SysTryReturnResult(NID_NET, pNetConnectionImpl != null, E_SYSTEM,
+                       "A system error has been occurred. Failed to retrieve NetConnection instance.");
+
+       // Creates new NetConnection for receiving the network event.
+       pNetConnectionClone.reset(pNetConnectionImpl->CopyInstanceN());
+       SysTryReturnResult(NID_NET, pNetConnectionClone != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       //set connection state
+       netConnectionState = __pNetConnection->GetConnectionState();
+
+       if (netConnectionState == NET_CONNECTION_STATE_STARTED ||
+               netConnectionState == NET_CONNECTION_STATE_RESUMED ||
+               netConnectionState == NET_CONNECTION_STATE_SUSPENDED)
+       {
+               __isConnectedNetwork = true;
+       }
+
+       // New CustomNetConnectionEventListener
+       pNetConnectionListener.reset(new (std::nothrow) _DhcpNetConnectionEventListenerImpl());
+       SysTryReturnResult(NID_NET, pNetConnectionListener != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       // Add NetConnectionListener
+       r = pNetConnectionClone->AddNetConnectionListener(*pNetConnectionListener);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to add the NetConnection listener.");
+
+       //check for connection type - USB or Wifi-Direct
+       if (__pNetConnection->GetNetAccountId() == _DEFAULT_USB_ACCOUNT_ID)
+       {
+               // create usb tethering handle
+               int err = TETHERING_ERROR_NONE;         
+
+               err = tethering_create(&__pUsbTetheringHandle);
+               SysLog(NID_NET, "[0x%x] Return value of tethering_create", err);
+       
+               SysTryReturnResult(NID_NET, err == TETHERING_ERROR_NONE, E_SYSTEM,
+                               "A system error has been occurred. Failed to create tethering handle.");
+
+               SysTryReturnResult(NID_NET, __pUsbTetheringHandle !=  null, E_SYSTEM,
+                               "A system error has been occurred. Failed to initialize Usb Tethering Handle.");
+
+               //if already connected  
+               if (__isConnectedNetwork)
+               {                       
+                       //get already connected client information, and store locally
+                       SetDhcpConnectedPeerInfoList(GetDhcpClientInfoListN(false));
+               }
+       }
+       else if (__pNetConnection->GetNetAccountId() == _DEFAULT_WIFI_DIRECT_ACCOUNT_ID)
+       {
+               //if already connected, Register callbacks
+               if (__isConnectedNetwork)
+               {
+                       //register for events
+                       
+                       WifiDirectDevice*(*pRegisterListenerFunction)(IWifiDirectDeviceListener* pDeviceListener,
+                                       IWifiDirectGroupOwnerListener* pOwnerListener, IWifiDirectGroupClientListener* pClientListener) = null;
+
+                       __pDllHandle = dlopen(_WIFI_DIRECT_LIBRARY_NAME, RTLD_LAZY);
+                       SysTryCatch(NID_NET, __pDllHandle != null, r = E_SYSTEM, E_SYSTEM,
+                                       "[%s] A system error has been occurred. Failed to open wifi library.", GetErrorMessage(E_SYSTEM));
+
+                       pRegisterListenerFunction = reinterpret_cast<WifiDirectDevice*(*)(IWifiDirectDeviceListener* pDeviceListener,
+                                       IWifiDirectGroupOwnerListener* pOwnerListener, IWifiDirectGroupClientListener* pClientListener)>
+                                       (dlsym(__pDllHandle, "_WifiDirectDeviceManagerImpl_GetWifiDirectDeviceN"));
+                       SysTryCatch(NID_NET, pRegisterListenerFunction != null, r = E_SYSTEM, E_SYSTEM,
+                                       "[%s] A system error has been occurred. Failed to get a function pointer.", GetErrorMessage(E_SYSTEM));
+
+                       __pDevice = pRegisterListenerFunction(null, this, null);
+                       SysTryCatch(NID_NET, __pDevice != null, r = E_SYSTEM, E_SYSTEM,
+                                       "[%s] A system error has been occurred. Failed to get a WifiDirectDevice instance.", GetErrorMessage(E_SYSTEM));
+
+                       //get already connected client information, and store locally
+                       SetDhcpConnectedPeerInfoList(GetDhcpClientInfoListN(false));
+               }       
+       }
+       else
+       {
+               SysLogException(NID_NET, E_SYSTEM, "Bearer not supported for DHCP");
+               
+               SysTryReturnResult(NID_NET, false, E_SYSTEM, "A system error has been occurred. Bearer not supported for DHCP");
+       }
+
+       __isConstructed = true;
+
+       __pNetConnectionListener = move(pNetConnectionListener);
+       __pLocalDhcpServerEvent = move(pLocalDhcpServerEvent);
+       __pNetConnectionClone = move(pNetConnectionClone);
+
+       return r;
+
+CATCH:
+       if (__pDllHandle != null)
+       {
+               if (__pDevice != null)
+               {
+                       void(*pUnRegisterListenerFunction)(WifiDirectDevice* pWifiDirectDevice, IWifiDirectDeviceListener* pDeviceListener, 
+                               IWifiDirectGroupOwnerListener* pOwnerListener,  IWifiDirectGroupClientListener* pClientListener) = null;
+
+                       pUnRegisterListenerFunction = reinterpret_cast<void(*)(WifiDirectDevice* pWifiDirectDevice, IWifiDirectDeviceListener* pDeviceListener,
+                                       IWifiDirectGroupOwnerListener* pOwnerListener, IWifiDirectGroupClientListener* pClientListener)>
+                                       (dlsym(__pDllHandle, "_WifiDirectDeviceImpl_DeleteWifiDirectDevice"));
+
+                       if (pUnRegisterListenerFunction != null)
+                       {
+                               pUnRegisterListenerFunction(__pDevice, null, this, null);
+                               __pDevice = null;
+                       }
+               }
+
+               dlclose(__pDllHandle);
+       }
+       return r;
+}
+
+LocalDhcpServer*
+_LocalDhcpServerImpl::GetLocalDhcpServer(const IList* pLocalDhcpServerList, const NetConnection& netConnection)
+{
+       LocalDhcpServer* pLocalDhcpServer = null;
+
+       ClearLastResult();
+
+       int count = pLocalDhcpServerList->GetCount();
+
+       for (int index = 0; index < count; index++)
+       {
+               pLocalDhcpServer = (LocalDhcpServer*)(pLocalDhcpServerList->GetAt(index));
+               if (pLocalDhcpServer != null)
+               {
+                       _LocalDhcpServerImpl* pLocalDhcpServerImpl = _LocalDhcpServerImpl::GetInstance(*pLocalDhcpServer);
+
+                       //check if dhcp server is for same connection as the argument netConnection.
+                       // and return the instance
+                       if (pLocalDhcpServerImpl != null && pLocalDhcpServerImpl->__pNetConnection == &netConnection)
+                       {
+                               return pLocalDhcpServer;
+                       }
+               }
+       }
+
+       return null;
+}
+
+result
+_LocalDhcpServerImpl::SetLocalDhcpServerEventListener(ILocalDhcpServerEventListener* pListener)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__isConstructed == true, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pLocalDhcpServerEvent->SetEventListener(pListener);
+
+       if (pListener)
+       {
+               //register for event callbacks
+               __pNetConnectionListener->SetConstructParams(__pLocalDhcpServerEvent.get(), __pUsbTetheringHandle);
+       }
+       else
+       {
+               //unregister for event callback
+               __pNetConnectionListener->SetConstructParams(null, null);
+       }
+
+       return r;
+}
+
+IList*
+_LocalDhcpServerImpl::GetDhcpClientInfoListN(bool all)
+{
+       result r = E_SUCCESS;
+       
+       ClearLastResult();
+       
+       ArrayList* pDhcpClientInfoList = null;
+       DhcpClientInfo* pDhcpClientInfo = null;
+
+       //check netconnection state before proceeding
+       SysTryReturn(NID_NET, __isConnectedNetwork == true, null, E_INVALID_STATE,
+                       "[%s] NET Connection already stopped.", GetErrorMessage(E_INVALID_STATE));
+
+       // create info list
+       pDhcpClientInfoList = new (std::nothrow) ArrayList();
+       SysTryReturn(NID_NET, pDhcpClientInfoList != null, null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pDhcpClientInfoList->Construct(_MAX_DHCP_CLIENT_COUNT);
+       SysTryCatch(NID_NET, r == E_SUCCESS, r = E_SYSTEM, r,
+                       "[%s] A system error has been occurred. Failed to construct DhcpClientInfoList.", GetErrorMessage(E_SYSTEM));
+
+       //check for connection type - USB or Wifi-Direct
+       if (__pNetConnection->GetNetAccountId() == _DEFAULT_USB_ACCOUNT_ID)
+       {
+               SysLog(NID_NET, "Connection type is NET_BEARER_USB.");
+               
+               int err = TETHERING_ERROR_NONE;
+
+               // get USB DHCP client info
+               err = tethering_foreach_connected_clients(__pUsbTetheringHandle, TETHERING_TYPE_USB, OnUsbPeerConnected, pDhcpClientInfoList);
+               SysLog(NID_NET, "The return value from tethering_for_each_connecetd_clients() is 0x%x", err);
+
+               SysTryCatch(NID_NET, err == TETHERING_ERROR_NONE, r = E_SYSTEM, r,
+                   "[%s] A system error has been occurred getting DHCP USB Client info.", GetErrorMessage(E_SYSTEM));
+
+               
+               // if all is true add local server details to list
+               if (all)
+               {                       
+                       pDhcpClientInfo = _DhcpClientInfoImpl::CreateDhcpClientInfoN();
+
+                       SysTryCatch(NID_NET, pDhcpClientInfo != null, r = E_OUT_OF_MEMORY, r,
+                           "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       r = GetLocalDhcpServerInfo(*pDhcpClientInfo);
+                       SysTryCatch(NID_NET, r == E_SUCCESS, , r, "[%s] GetDhcpUsbInterfaceInfo() failed.", GetErrorMessage(r));
+
+                       r = pDhcpClientInfoList->Add(*pDhcpClientInfo);
+                       SysTryCatch(NID_NET, r == E_SUCCESS, r = E_SYSTEM, r,
+                                       "[%s] A system error has been occurred. Failed to add DhcpClientInnfo to the list.", GetErrorMessage(E_SYSTEM));
+               }
+               // trim arrayList to current size
+               pDhcpClientInfoList->Trim();
+
+       }
+       else if (__pNetConnection->GetNetAccountId() == _DEFAULT_WIFI_DIRECT_ACCOUNT_ID)
+       {
+               SysLog(NID_NET, "Connection type is NET_BEARER_WIFI_DIRECT.");
+               int err = WIFI_DIRECT_ERROR_NONE;
+
+               // get WIFI Direct DHCP client info
+               err = wifi_direct_foreach_connected_peers(OnWifiDirectPeerConnected, pDhcpClientInfoList);
+               SysLog(NID_NET, "The return value from wifi_direct_foreach_connected_peers() is 0x%x", err);
+
+               SysTryCatch(NID_NET, err == WIFI_DIRECT_ERROR_NONE, r = E_SYSTEM, r,
+                   "[%s] A system error has been occurred getting DHCP WIfi-Direct Client info.", GetErrorMessage(E_SYSTEM));
+
+               //check if group owner, just for debugging
+               bool isOwner = false;
+               wifi_direct_is_group_owner(&isOwner);
+               if (isOwner)
+               {
+                       SysLog(NID_NET, "The device is group owner of wifi-direct.");
+               }
+               else
+               {
+                       SysLog(NID_NET, "The device is group memeber of wifi-direct");  
+               }
+
+               // if all  is true add local server details to list
+               if (all)
+               {
+                       // add local server details to the list
+                       pDhcpClientInfo = _DhcpClientInfoImpl::CreateDhcpClientInfoN();
+
+                       SysTryCatch(NID_NET, pDhcpClientInfo != null, r = E_OUT_OF_MEMORY, r,
+                           "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       r = GetLocalDhcpServerInfo(*pDhcpClientInfo);
+                       SysTryCatch(NID_NET, r == E_SUCCESS, , r, "[%s] GetLocalDhcpServerInfo() failed.", GetErrorMessage(r));
+
+                       r = pDhcpClientInfoList->Add(*pDhcpClientInfo);
+                       SysTryCatch(NID_NET, r == E_SUCCESS, r = E_SYSTEM, r,
+                                       "[%s] A system error has been occurred. Failed to add DhcpClientInfo to the list.", GetErrorMessage(E_SYSTEM));
+               }
+               // trim arrayList to current size
+               pDhcpClientInfoList->Trim();
+
+       }
+       else
+       {
+               SysLogException(NID_NET, E_SYSTEM, "Bearer not supported for DHCP");
+               
+               r = E_SYSTEM;
+               goto CATCH;
+       }
+
+       return pDhcpClientInfoList;
+
+CATCH:
+       if (pDhcpClientInfo)
+       {
+               delete pDhcpClientInfo;
+               pDhcpClientInfo = null;
+       }
+       if (pDhcpClientInfoList)
+       {
+               pDhcpClientInfoList->RemoveAll(true);
+               delete pDhcpClientInfoList;
+       }
+       return null;
+}
+
+result
+_LocalDhcpServerImpl::ConvertDhcpClientInfo(tethering_client_h clientHandle, DhcpClientInfo& dhcpClientInfo)
+{
+       result r = E_SUCCESS;
+       
+       _DhcpClientInfoImpl* pDhcpClientInfoImpl = null;
+       int err = TETHERING_ERROR_NONE;
+       char *pClientName = null;
+       char *pMacAddress = null;
+       char *pIpAddress = null;
+
+       pDhcpClientInfoImpl = _DhcpClientInfoImpl::GetInstance(dhcpClientInfo);
+       SysTryReturnResult(NID_NET, pDhcpClientInfoImpl != null, E_SYSTEM,
+                       "A system error has been occurred. Failed to get DhcpClientInfo instance.");
+       
+       // set peer name
+       err =  tethering_client_get_name(clientHandle, &pClientName);
+       SysLog(NID_NET, "Error value from tethering_client_get_name() is 0x%x", err);
+       SysLog(NID_NET, "Network interface name is %s", pClientName);
+       
+       SysTryReturnResult(NID_NET, err == TETHERING_ERROR_NONE, E_SYSTEM,
+                       "A system error has been occurred. Failed to get tethering client name.");
+
+       pDhcpClientInfoImpl->__dhcpClientName = String(pClientName);
+       
+       //set mac-address
+       err =  tethering_client_get_mac_address(clientHandle, &pMacAddress);
+       SysLog(NID_NET, "Error value from tethering_client_get_mac_address() is 0x%x", err);
+       SysLog(NID_NET, "Mac address is %s", pMacAddress);
+       
+       SysTryCatch(NID_NET, err == TETHERING_ERROR_NONE, r = E_SYSTEM, r,
+                       "[%s] A system error has been occurred. tethering_client_get_mac_address() returned error.", GetErrorMessage(E_SYSTEM));
+                       
+       pDhcpClientInfoImpl->__macAddress = ConvertMacAddress(pMacAddress);
+       
+       //set ip-address
+       err =  tethering_client_get_ip_address(clientHandle, TETHERING_ADDRESS_FAMILY_IPV4, &pIpAddress);
+       SysLog(NID_NET, "Error value from tethering_client_get_ip_address() is 0x%x", err);
+       SysLog(NID_NET, "Ip address is %s", pIpAddress);
+               
+       SysTryCatch(NID_NET, err == TETHERING_ERROR_NONE, r = E_SYSTEM, r,
+                       "[%s] A system error has been occurred. tethering_client_get_ip_address() returned error.", GetErrorMessage(E_SYSTEM));
+
+       pDhcpClientInfoImpl->__pLocalAddress.reset(new (std::nothrow) Ip4Address(pIpAddress));
+       
+       SysTryCatch(NID_NET, pDhcpClientInfoImpl->__pLocalAddress != null, r = E_OUT_OF_MEMORY, r,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       
+       
+CATCH:         
+       if (pClientName != null)
+       {
+               free(pClientName);
+       }
+       
+       if (pIpAddress != null)
+       {
+               free(pIpAddress);
+       }
+
+       if (pMacAddress != null)
+       {
+               free(pMacAddress);
+       }
+
+       return r;
+}
+
+result
+_LocalDhcpServerImpl::GetLocalDhcpServerInfo(DhcpClientInfo& dhcpClientInfo)
+{
+       result r = E_SUCCESS;
+       
+       _DhcpClientInfoImpl* pDhcpClientInfoImpl = null;
+
+       char *pInterfaceName = null;
+       char *pMacAddress = null;
+       char *pIpAddress = null;
+
+       pDhcpClientInfoImpl = _DhcpClientInfoImpl::GetInstance(dhcpClientInfo);
+       SysTryReturnResult(NID_NET, pDhcpClientInfoImpl != null, E_SYSTEM, "A system error has been occurred. Failed to get DhcpClientInfo instance.");
+       
+       //check for connection type - USB or Wifi-Direct
+       if (__pNetConnection->GetNetAccountId() == _DEFAULT_USB_ACCOUNT_ID)
+       {
+               int err = TETHERING_ERROR_NONE;
+               // set peer name
+               err =  tethering_get_network_interface_name(__pUsbTetheringHandle, TETHERING_TYPE_USB, &pInterfaceName);
+               SysLog(NID_NET, "Error value from tethering_get_name() is 0x%x", err);
+               SysLog(NID_NET, "Network interface name is %s", pInterfaceName);
+       
+               SysTryReturnResult(NID_NET, err == TETHERING_ERROR_NONE, E_SYSTEM,
+                               "A system error has been occurred. tethering_get_name() returned error.");
+       
+               //set mac-address
+               err =  tethering_get_mac_address(__pUsbTetheringHandle, TETHERING_TYPE_USB, &pMacAddress);
+               SysLog(NID_NET, "Error value from tethering_get_mac_address() is 0x%x", err);
+               SysLog(NID_NET, "Mac address is %s", pMacAddress);
+       
+               SysTryCatch(NID_NET, err == TETHERING_ERROR_NONE, r = E_SYSTEM, r,
+                               "[%s] A system error has been occurred. tethering_get_mac_address returned error.", GetErrorMessage(E_SYSTEM));
+                       
+               //set ip-address
+               err =  tethering_get_ip_address(__pUsbTetheringHandle, TETHERING_TYPE_USB, TETHERING_ADDRESS_FAMILY_IPV4, &pIpAddress);
+               SysLog(NID_NET, "Error value from tethering_get_ip_address() is 0x%x", err);
+               SysLog(NID_NET, "Ip address is %s", pIpAddress);
+               
+               SysTryCatch(NID_NET, err == TETHERING_ERROR_NONE, r = E_SYSTEM, r,
+                               "[%s] A system error has been occurred. tethering_get_ip_address() returned error.", GetErrorMessage(E_SYSTEM));
+       }
+       else if (__pNetConnection->GetNetAccountId() == _DEFAULT_WIFI_DIRECT_ACCOUNT_ID)
+       {
+               int err = WIFI_DIRECT_ERROR_NONE;
+               // set interface name
+               err = wifi_direct_get_network_interface_name(&pInterfaceName);
+               SysLog(NID_NET, "Error value from  wifi_direct_get_network_interface_name() is 0x%x", err);
+               SysLog(NID_NET, "Network interface name is %s", pInterfaceName);
+       
+               SysTryReturnResult(NID_NET, err == WIFI_DIRECT_ERROR_NONE, E_SYSTEM,
+                                       "A system error has been occurred. wifi_direct_get_network_interface_name() returned error.");
+       
+               //set mac-address
+               err = wifi_direct_get_mac_address(&pMacAddress);
+               SysLog(NID_NET, "Error value from wifi_direct_get_mac_address() is 0x%x", err);
+               SysLog(NID_NET, "Mac address is %s", pMacAddress);
+       
+               SysTryCatch(NID_NET, err == WIFI_DIRECT_ERROR_NONE, r = E_SYSTEM, r,
+                               "[%s] A system error has been occurred. wifi_direct_get_mac_address() returned error.", GetErrorMessage(E_SUCCESS));
+                       
+               //set ip-address
+               err = wifi_direct_get_ip_address(&pIpAddress);
+               SysLog(NID_NET, "Error value from wifi_direct_get_ip_address() is 0x%x", err);
+               SysLog(NID_NET, "Ip address is %s", pIpAddress);
+               
+               SysTryCatch(NID_NET, err == WIFI_DIRECT_ERROR_NONE, r = E_SYSTEM, r,
+                               "[%s] A system error has been occurred. wifi_direct_get_ip_address() returned error.", GetErrorMessage(E_SYSTEM));
+       }
+       else
+       {
+               SysLogException(NID_NET, r = E_SYSTEM, "Bearer not supported for DHCP");
+               return r;                       
+       }
+
+       pDhcpClientInfoImpl->__dhcpClientName = String(pInterfaceName);
+
+       pDhcpClientInfoImpl->__macAddress = ConvertMacAddress(pMacAddress);
+       
+       pDhcpClientInfoImpl->__pLocalAddress.reset(new (std::nothrow) Ip4Address(pIpAddress));
+
+       SysTryCatch(NID_NET, pDhcpClientInfoImpl->__pLocalAddress != null, r = E_OUT_OF_MEMORY, r,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       
+
+CATCH:         
+       if (pInterfaceName != null)
+       {
+               free(pInterfaceName);
+       }
+       
+       if (pIpAddress != null)
+       {
+               free(pIpAddress);
+       }
+
+       if (pMacAddress != null)
+       {
+               free(pMacAddress);
+       }
+
+       return r;
+}
+
+String
+_LocalDhcpServerImpl::ConvertMacAddress(char* pMacAddress)
+{
+       if (!pMacAddress)
+       {
+               return String("");
+       }
+
+       // format string
+       char* pTempMacAddress = pMacAddress;
+
+       while (*pTempMacAddress != '\0')
+       {
+               if (*pTempMacAddress == _PLATFORM_MAC_ADDRESS_DELIMITER)
+               {
+                       *pTempMacAddress = _MAC_ADDRESS_DELIMITER;
+               }
+               ++pTempMacAddress;
+       }
+
+       return String(pMacAddress);
+}
+
+void
+_LocalDhcpServerImpl::OnWifiDirectClientAssociated(WifiDirectDeviceId localDeviceId, const WifiDirectDeviceInfo& wifiDirectClientInfo)
+{
+       SysLog(NID_NET, "LocalDhcpServer received an event, OnWifiDirectClientAssociated.");
+
+       result r = E_SUCCESS;
+
+       _LocalDhcpServerEventArg* pDhcpServerEventArg = null;
+       _NetDhcpServerEventType eventCode = NET_DHCP_SERVER_EVENT_CONNECT;
+                       
+       String(*pGetMacAddressFunction)(const WifiDirectDeviceInfo& deviceinfo) = null;
+
+       // Get MAC address of the client
+       pGetMacAddressFunction = reinterpret_cast<String(*)(const WifiDirectDeviceInfo& deviceinfo)>(dlsym(__pDllHandle, "_WifiDirectDeviceInfoImpl_GetVirtualMacAddress"));
+       SysTryReturnVoidResult(NID_NET, pGetMacAddressFunction != null, E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to get a function pointer.", GetErrorMessage(E_SYSTEM));
+               
+       String macAddress = pGetMacAddressFunction(wifiDirectClientInfo);
+
+       //check if we have already the info in our local list           
+       
+       if (GetDhcpConnectedPeerInfo(macAddress) == null)
+       {                       
+               // not found, create DhcpClientInfo
+               unique_ptr<DhcpClientInfo> pDhcpClientInfo(_DhcpClientInfoImpl::CreateDhcpClientInfoN());
+               SysTryReturnVoidResult(NID_NET, pDhcpClientInfo != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = ConvertDhcpClientInfo(wifiDirectClientInfo,*pDhcpClientInfo);
+               SysTryReturnVoidResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                               "[%s] A system error has been occurred. Failed to retrieve DhcpClientInfo.", GetErrorMessage(E_SYSTEM));
+
+               //add the info into local list
+               r = AddDhcpConnectedPeerInfo(*pDhcpClientInfo);
+               SysTryReturnVoidResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                               "[%s] A system error has been occurred. Failed to add DhcpConnectedPeerInfo.", GetErrorMessage(E_SYSTEM));
+               
+               // fire event
+               pDhcpServerEventArg = new (std::nothrow) _LocalDhcpServerEventArg(eventCode, *pDhcpClientInfo);
+               SysTryReturnVoidResult(NID_NET, pDhcpServerEventArg != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pDhcpClientInfo.release();
+
+               __pLocalDhcpServerEvent->Fire(*pDhcpServerEventArg);
+       }
+       
+       return;
+}
+
+void
+_LocalDhcpServerImpl::OnWifiDirectClientDisassociated(WifiDirectDeviceId localDeviceId, const WifiDirectDeviceInfo& wifiDirectClientInfo, WifiDirectAssociationTerminationReason reason)
+{
+       SysLog(NID_NET, "LocalDhcpServer received an event, OnWifiDirectClientDisassociated.");
+       
+       _LocalDhcpServerEventArg* pDhcpServerEventArg = null;
+       _NetDhcpServerEventType eventCode = NET_DHCP_SERVER_EVENT_DISCONNECT;   
+       String(*pGetMacAddressFunction)(const WifiDirectDeviceInfo& deviceinfo) = null;
+
+       // Get MAC address of the client
+       pGetMacAddressFunction = reinterpret_cast<String(*)(const WifiDirectDeviceInfo& deviceinfo)>(dlsym(__pDllHandle, "_WifiDirectDeviceInfoImpl_GetVirtualMacAddress"));
+       SysTryReturnVoidResult(NID_NET, pGetMacAddressFunction != null, E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to get a function pointer.", GetErrorMessage(E_SYSTEM));
+
+       String macAddress = pGetMacAddressFunction(wifiDirectClientInfo);
+
+       //check if we have already the info in our local list
+       unique_ptr<DhcpClientInfo> pDhcpClientInfo(GetDhcpConnectedPeerInfo(macAddress, true));
+       SysTryReturnVoidResult(NID_NET, pDhcpClientInfo != null, E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to retrieve DhcpClientInfo.", GetErrorMessage(E_SYSTEM));
+
+       //fire event
+       pDhcpServerEventArg = new (std::nothrow) _LocalDhcpServerEventArg(eventCode, *pDhcpClientInfo);
+       SysTryReturnVoidResult(NID_NET, pDhcpServerEventArg != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pLocalDhcpServerEvent->Fire(*pDhcpServerEventArg);
+}
+
+void
+_LocalDhcpServerImpl::OnWifiDirectGroupDestroyed(WifiDirectDeviceId localDeviceId, result r)
+{
+       SysLog(NID_NET, "LocalDhcpServer received an event, OnWifiDirectGroupDestroyed.");
+}
+
+void
+_LocalDhcpServerImpl::OnWifiDirectGroupMemberInfoServiceStarted(WifiDirectDeviceId localDeviceId, const NetConnection* pNetConnection, result r)
+{
+       SysLog(NID_NET, "LocalDhcpServer received an event, OnWifiDirectGroupMemberInfoServiceStarted.");
+}
+
+void
+_LocalDhcpServerImpl::OnWifiDirectGroupMemberInfoServiceStopped(WifiDirectDeviceId localDeviceId, result r)
+{
+       SysLog(NID_NET, "LocalDhcpServer received an event, OnWifiDirectGroupMemberInfoServiceStopped.");
+}
+
+result
+_LocalDhcpServerImpl::ConvertDhcpClientInfo(const WifiDirectDeviceInfo& wifiDirectdeviceInfo, DhcpClientInfo& dhcpClientInfo)
+{
+       result r = E_SUCCESS;   
+       _DhcpClientInfoImpl* pDhcpClientInfoImpl = null;
+       
+       String(*pGetDeviceNameFunction)(const WifiDirectDeviceInfo& deviceinfo) = null;
+       String(*pGetMacAddressFunction)(const WifiDirectDeviceInfo& deviceinfo) = null;
+       IpAddress*(*pGetIpAddressFunction)(const WifiDirectDeviceInfo& deviceinfo) = null;
+
+       pGetDeviceNameFunction = reinterpret_cast<String(*)(const WifiDirectDeviceInfo& deviceinfo)>
+                       (dlsym(__pDllHandle, "_WifiDirectDeviceInfoImpl_GetDeviceName"));
+       SysTryReturnResult(NID_NET, pGetDeviceNameFunction != null, E_SYSTEM,
+                       "A system error has been occurred. Failed to get a function pointer.");
+       
+       pGetMacAddressFunction = reinterpret_cast<String(*)(const WifiDirectDeviceInfo& deviceinfo)>
+                       (dlsym(__pDllHandle, "_WifiDirectDeviceInfoImpl_GetVirtualMacAddress"));
+       SysTryReturnResult(NID_NET, pGetMacAddressFunction != null, E_SYSTEM,
+                       "A system error has been occurred. Failed to get a function pointer.");
+       
+       pGetIpAddressFunction = reinterpret_cast<IpAddress*(*)(const WifiDirectDeviceInfo& deviceinfo)>
+                       (dlsym(__pDllHandle, "_WifiDirectDeviceInfoImpl_GetIpAddress"));
+       SysTryReturnResult(NID_NET, pGetIpAddressFunction != null, E_SYSTEM,
+                       "A system error has been occurred. Failed to get a function pointer.");
+
+       pDhcpClientInfoImpl = _DhcpClientInfoImpl::GetInstance(dhcpClientInfo);
+       SysTryReturnResult(NID_NET, pDhcpClientInfoImpl != null, E_SYSTEM,
+                       "A system error has been occurred. Failed to get DhcpClientInfo instance.");
+
+       pDhcpClientInfoImpl->__dhcpClientName = pGetDeviceNameFunction(wifiDirectdeviceInfo);
+       pDhcpClientInfoImpl->__macAddress = pGetMacAddressFunction(wifiDirectdeviceInfo);
+
+       const Ip4Address* ipAddress = dynamic_cast<const Ip4Address*>(pGetIpAddressFunction(wifiDirectdeviceInfo));
+       SysTryReturnResult(NID_NET, ipAddress != null, E_SYSTEM, "A system error has been occurred. IP Address is null.");
+       
+       pDhcpClientInfoImpl->__pLocalAddress.reset(new (std::nothrow) Ip4Address(*ipAddress));
+       
+       SysTryReturnResult(NID_NET, pDhcpClientInfoImpl->__pLocalAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       
+       return r;
+}
+
+bool
+_LocalDhcpServerImpl::OnWifiDirectPeerConnected(wifi_direct_connected_peer_info_s* pPeerInfo, void* pUserData)
+{
+       result r = E_SUCCESS;
+
+       ArrayList* pDhcpclientInfoList = static_cast<ArrayList*>(pUserData);
+       
+       //check arguments
+       SysTryReturn(NID_NET, pDhcpclientInfoList != null, false, E_SYSTEM,
+                       "[%s] A system error has been occurred. pDhcpclientInfoList is null.", GetErrorMessage(E_SYSTEM));
+       SysTryReturn(NID_NET, pPeerInfo != null, false, E_SYSTEM,
+                       "[%s] A system error has been occurred. pPeerInfo is null.", GetErrorMessage(E_SYSTEM));
+
+       // create DhcpClientInfo and add to local list
+       unique_ptr<DhcpClientInfo> pDhcpClientInfo(_DhcpClientInfoImpl::CreateDhcpClientInfoN());
+
+       SysTryReturn(NID_NET, pDhcpClientInfo != null, false, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = ConvertDhcpClientInfo(pPeerInfo, *pDhcpClientInfo);
+       SysTryReturn(NID_NET, r == E_SUCCESS, false, r, "[%s] Failed to convert DhcpWifiDirectClientInfo.", GetErrorMessage(r));
+
+       r = pDhcpclientInfoList->Add(*pDhcpClientInfo);
+       SysTryReturn(NID_NET, r == E_SUCCESS, false, r, "[%s] Failed to add DhcpClientInfo to the list.", GetErrorMessage(r));
+
+       pDhcpClientInfo.release();
+
+       return true;
+}
+
+bool
+_LocalDhcpServerImpl::OnUsbPeerConnected(tethering_client_h clientHandle, void* pUserData)
+{
+       result r = E_SUCCESS;
+
+       ArrayList* pDhcpclientInfoList = static_cast<ArrayList*>(pUserData);
+       
+       //check arguments
+       SysTryReturn(NID_NET, pDhcpclientInfoList != null, false, E_SYSTEM,
+                       "[%s] A system error has been occurred. pDhcpclientInfoList is null.", GetErrorMessage(E_SYSTEM));
+       SysTryReturn(NID_NET, clientHandle != null, false, E_SYSTEM,
+                       "[%s] A system error has been occurred. clientHandle is null.", GetErrorMessage(E_SYSTEM));
+
+       // create DhcpClientInfo and add to local list
+       unique_ptr<DhcpClientInfo> pDhcpClientInfo(_DhcpClientInfoImpl::CreateDhcpClientInfoN());
+
+       SysTryReturn(NID_NET, pDhcpClientInfo != null, false, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = _LocalDhcpServerImpl::ConvertDhcpClientInfo(clientHandle, *pDhcpClientInfo);
+       SysTryReturn(NID_NET, r == E_SUCCESS, false, r, "[%s] Failed to convert DhcpClientInfo.", GetErrorMessage(r));
+
+       r = pDhcpclientInfoList->Add(*pDhcpClientInfo);
+       SysTryReturn(NID_NET, r == E_SUCCESS, false, r, "[%s] Failed to add DhcpClientInfo to the list.", GetErrorMessage(r));
+
+       pDhcpClientInfo.release();
+
+       return true;
+}
+
+result
+_LocalDhcpServerImpl::ConvertDhcpClientInfo(const wifi_direct_connected_peer_info_s* pPeerInfo, DhcpClientInfo& dhcpClientInfo)
+{
+       result r = E_SUCCESS;
+
+       _DhcpClientInfoImpl* pDhcpClientInfoImpl = null;
+
+       pDhcpClientInfoImpl = _DhcpClientInfoImpl::GetInstance(dhcpClientInfo);
+       SysTryReturnResult(NID_NET, pDhcpClientInfoImpl != null, E_SYSTEM,
+                       "A system error has been occurred. Failed to get DhcpClientInfo instance.");
+
+       pDhcpClientInfoImpl->__dhcpClientName = String(pPeerInfo->device_name);
+       pDhcpClientInfoImpl->__macAddress = ConvertMacAddress((char*)pPeerInfo->interface_address);
+
+       pDhcpClientInfoImpl->__pLocalAddress.reset(new (std::nothrow) Ip4Address(pPeerInfo->ip_address));       
+       SysTryReturnResult(NID_NET, pDhcpClientInfoImpl->__pLocalAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed");
+       
+       return r;
+}
+
+DhcpClientInfo*
+_LocalDhcpServerImpl::GetDhcpConnectedPeerInfo(const String& macAddress, bool remove)
+{
+       DhcpClientInfo* pDhcpClientInfo = null;
+
+       ClearLastResult();
+
+       SysTryReturn(NID_NET, __pDhcpConnectedPeerInfoList != null, null, E_SYSTEM,
+                       "[%s] A system error has been occurred. Client Info List is null.", GetErrorMessage(E_SYSTEM));
+
+       //search for the given mac-address
+       for (int count = 0; count < __pDhcpConnectedPeerInfoList->GetCount(); count++)
+       {
+               pDhcpClientInfo = dynamic_cast<DhcpClientInfo*>(__pDhcpConnectedPeerInfoList->GetAt(count));
+               if (pDhcpClientInfo != null && pDhcpClientInfo->GetMacAddress() == macAddress)
+               {
+                       if (remove)
+                       {
+                               __pDhcpConnectedPeerInfoList->Remove(*pDhcpClientInfo, false);
+                       }
+                       return pDhcpClientInfo;
+               }
+       }
+       return null;
+}
+
+result
+_LocalDhcpServerImpl::AddDhcpConnectedPeerInfo(const DhcpClientInfo& dhcpClientInfo)
+{
+       result r = E_SUCCESS;
+       
+       // create list for dhcp client info, if not created
+       if (__pDhcpConnectedPeerInfoList == null)
+       {
+               unique_ptr<Tizen::Base::Collection::ArrayList, _CollectionDeleter> pDhcpConnectedPeerInfoList(new (std::nothrow) ArrayList());
+               SysTryReturnResult(NID_NET, pDhcpConnectedPeerInfoList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               r = pDhcpConnectedPeerInfoList->Construct(_MAX_DHCP_CLIENT_COUNT);
+               SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                               "A system error has been occurred. Failed to construct DhcpConnectedPeerInfoList.");
+               __pDhcpConnectedPeerInfoList = std::move(pDhcpConnectedPeerInfoList);
+       }
+
+       r = __pDhcpConnectedPeerInfoList->Add(dhcpClientInfo);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                       "A system error has been occurred. Failed to add DhcpClientInfo to the list.");
+
+       return r;
+}
+
+IList*
+_LocalDhcpServerImpl::GetDhcpConnectedPeerInfoList()
+{      
+       return __pDhcpConnectedPeerInfoList.get();
+}
+
+void
+_LocalDhcpServerImpl::SetDhcpConnectedPeerInfoList(IList* pList)
+{      
+       __pDhcpConnectedPeerInfoList.reset(dynamic_cast<ArrayList*>(pList));
+}
+
+_LocalDhcpServerImpl*
+_LocalDhcpServerImpl::GetInstance(LocalDhcpServer& localDhcpServer)
+{
+       return localDhcpServer.__pLocalDhcpServerImpl;
+}
+
+const _LocalDhcpServerImpl*
+_LocalDhcpServerImpl::GetInstance(const LocalDhcpServer& localDhcpServer)
+{
+       return localDhcpServer.__pLocalDhcpServerImpl;
+}
+
+}} // Tizen::Net
diff --git a/src/FNet_LocalDhcpServerImpl.h b/src/FNet_LocalDhcpServerImpl.h
new file mode 100644 (file)
index 0000000..7033f5a
--- /dev/null
@@ -0,0 +1,234 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_LocalDhcpServerImpl.h
+ * @brief              This is the header file for the LocalDhcpServerImpl class.
+ *
+ * This header file contains declaration of the  LocalDhcpServerImpl class.
+ */
+
+#ifndef _FNET_INTERNAL_LOCAL_DHCP_SERVER_IMPL_H_
+#define _FNET_INTERNAL_LOCAL_DHCP_SERVER_IMPL_H_
+
+#include <tethering.h>
+#include <wifi-direct.h>
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FNetWifiIWifiDirectGroupOwnerListener.h>
+#include "FNet_NetUtility.h"
+
+namespace Tizen { namespace Base
+{
+class String;
+} } // Tizen::Base
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class WifiDirectDevice;
+class WifiDirectDeviceInfo;
+} } } // Tizen::Net::Wifi
+
+namespace Tizen { namespace Net
+{
+class ILocalDhcpServerEventListener;
+class NetConnection;
+class DhcpClientInfo;
+class LocalDhcpServer;
+class _LocalDhcpServerEvent;
+class _DhcpNetConnectionEventListenerImpl;
+
+/**
+ * @class   _LocalDhcpServerImpl
+ * @brief      This class provides methods for managing local DHCP server.
+ * @since   2.0
+ *
+ * The LocalDhcpServer class provides methods for managing local DHCP server.
+ * The Wi-Fi Direct or USB NDIS required DHCP server for data communication.
+ */
+class _LocalDhcpServerImpl
+       : public Tizen::Base::Object
+       , public Tizen::Net::Wifi::IWifiDirectGroupOwnerListener
+{
+
+public:
+       /**
+        * This is the constructor for this class.
+        *
+        */
+       _LocalDhcpServerImpl(void);
+
+       /**
+        * This is the destructor for this class.
+        *
+        */
+       virtual ~_LocalDhcpServerImpl(void);
+
+       /**
+        * @see                 LocalDhcpServer::Construct()
+        */
+       result Construct(const LocalDhcpServer* pLocalDhcpServer, const NetConnection& netConnection);
+
+public:
+       /**
+        * @see                 LocalDhcpServer::GetLocalDhcpServer()
+        */
+       static LocalDhcpServer* GetLocalDhcpServer(const Tizen::Base::Collection::IList* pLocalDhcpServerList,
+                                                                               const NetConnection& netConnection);
+
+       /**
+        * @see                 LocalDhcpServer::SetLocalDhcpServerEventListener()
+        */
+       result SetLocalDhcpServerEventListener(ILocalDhcpServerEventListener* pListener);
+
+       /**
+        * GetDhcpClientInfoListN(), all = true includes local server details, all = false is only connected peers
+        */
+       Tizen::Base::Collection::IList* GetDhcpClientInfoListN(bool all = true);
+
+public:
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _LocalDhcpServerImpl
+       * @param[in]   localDhcpServer            An instance of LocalDhcpServer
+     */
+       static _LocalDhcpServerImpl* GetInstance(LocalDhcpServer& localDhcpServer);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _LocalDhcpServerImpl
+       * @param[in]   localDhcpServer     An instance of LocalDhcpServer
+     */
+       static const _LocalDhcpServerImpl* GetInstance(const LocalDhcpServer& localDhcpServer);
+
+private:
+       
+       virtual void OnWifiDirectClientAssociated(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, const Tizen::Net::Wifi::WifiDirectDeviceInfo& wifiDirectClientInfo);
+       virtual void OnWifiDirectClientDisassociated(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, const Tizen::Net::Wifi::WifiDirectDeviceInfo& wifiDirectClientInfo, Tizen::Net::Wifi::WifiDirectAssociationTerminationReason reason);
+       virtual void OnWifiDirectGroupDestroyed(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, result r);
+       virtual void OnWifiDirectGroupMemberInfoServiceStarted(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, const NetConnection* pNetConnection, result r);
+       virtual void OnWifiDirectGroupMemberInfoServiceStopped(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, result r);
+       
+private:
+       
+       /*
+        * Callback received for wifi-direct connected peer devices
+        *
+        * @return            true to continue next loop, false to exit the loop
+        * @param[in]   pInfo                   The information of connected peer
+        * @param[in]   pUserData               The user data passed on callback registration
+        */
+       static bool OnWifiDirectPeerConnected(wifi_direct_connected_peer_info_s* pPeerInfo, void* pUserData);
+
+       /*
+        * Callback received for USB connected peer devices
+        *
+        * @param[in]   client                  The client of which connection is changed
+        * @param[in]   pUserData               The user data passed on callback registration
+        */
+       static bool OnUsbPeerConnected(tethering_client_h client, void* pUserdata);
+
+       /*
+        * Converts wifi_direct_connected_peer_info_s to DhcpClientInfo
+        */
+       static result ConvertDhcpClientInfo(const wifi_direct_connected_peer_info_s* pPeerInfo, DhcpClientInfo& dhcpClientInfo);
+
+       /*
+        *  Convert MAC address to formatted address
+        */
+       static Tizen::Base::String ConvertMacAddress(char* pMacAddress);
+
+       /*
+        * Gets Local dHCP server info
+        */
+       result GetLocalDhcpServerInfo(DhcpClientInfo& dhcpClientInfo);
+       
+       /*
+        * Get usb connected Client info
+        *
+        */
+       static result ConvertDhcpClientInfo(tethering_client_h clientHandle, DhcpClientInfo& dhcpClientInfo);
+
+       /*
+        * Converts WifiDirectDeviceInfo to DhcpClientInfo
+        *
+        */
+       result  ConvertDhcpClientInfo(const Tizen::Net::Wifi::WifiDirectDeviceInfo& wifiDirectdeviceInfo, DhcpClientInfo& dhcpClientInfo);
+       
+       /*
+        * Get peer info from local list based on mac-address
+        *
+        */
+       DhcpClientInfo* GetDhcpConnectedPeerInfo(const Tizen::Base::String& macAddress, bool remove = false);
+
+       /*
+        * Add connected peer info into local dhcp info list
+        */
+       result AddDhcpConnectedPeerInfo(const DhcpClientInfo& dhcpClientInfo);
+
+       /*
+        * Set connected peer local dhcp info list
+        */     
+       void SetDhcpConnectedPeerInfoList(Tizen::Base::Collection::IList* pList);
+
+       /*
+        * Get connected peer local dhcp info list
+        */
+       Tizen::Base::Collection::IList* GetDhcpConnectedPeerInfoList();
+       
+private:
+       /*
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of _LocalDhcpServerImpl
+        */
+       _LocalDhcpServerImpl(const _LocalDhcpServerImpl& rhs);
+
+       /*
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs             An instance of _LocalDhcpServerImpl
+        */
+       _LocalDhcpServerImpl& operator =(const _LocalDhcpServerImpl& rhs);
+
+private:
+       std::unique_ptr<_LocalDhcpServerEvent> __pLocalDhcpServerEvent;         // event pointer
+       NetConnection* __pNetConnection;                        // refernce, no ownership
+       std::unique_ptr<NetConnection> __pNetConnectionClone;                   // cloned net connection, for events
+       std::unique_ptr<_DhcpNetConnectionEventListenerImpl> __pNetConnectionListener; // Net Conncetion event Listener
+       tethering_h     __pUsbTetheringHandle;             // access point handle
+       std::unique_ptr<Tizen::Base::Collection::ArrayList, _CollectionDeleter> __pDhcpConnectedPeerInfoList;      // list of connected peer info
+       Tizen::Net::Wifi::WifiDirectDevice* __pDevice;
+       void* __pDllHandle;
+       bool __isConstructed;                       // status
+       bool __isConnectedNetwork;
+
+       friend class _DhcpNetConnectionEventListenerImpl;
+}; // _LocalDhcpServerImpl
+
+}} // Tizen::Net
+
+#endif // _FNET_INTERNAL_LOCAL_DHCP_SERVER_IMPL_H_
diff --git a/src/FNet_ManagedNetConnectionImpl.cpp b/src/FNet_ManagedNetConnectionImpl.cpp
new file mode 100644 (file)
index 0000000..a3889d7
--- /dev/null
@@ -0,0 +1,205 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNet_ManagedNetConnectionImpl.cpp
+ * @brief              This is the implementation for the _ManagedNetConnectionImpl class.
+ */
+
+#include <FNetManagedNetConnection.h>
+#include <FBaseSysLog.h>
+#include "FNet_ManagedNetConnectionImpl.h"
+#include "FNet_NetConnectionManagerImpl.h"
+#include "FNet_NetUtility.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net {
+
+_ManagedNetConnectionImpl::_ManagedNetConnectionImpl(const ManagedNetConnection* pConnection)
+       : __isRefAdded(false)
+       , __pConnection(pConnection)
+       , __pListener(null)
+{
+}
+
+_ManagedNetConnectionImpl::~_ManagedNetConnectionImpl(void)
+{
+       result r = E_SUCCESS;
+       _NetConnectionManagerImpl* pManager = _NetConnectionManagerImpl::GetInstance();
+
+       if (__pListener != null)
+       {
+               r = pManager->RemoveManagedNetConnectionEventListener(*__pListener);
+               __pListener = null;
+       }
+
+       if (__isRefAdded)
+       {
+               if (pManager != null)
+               {
+                       pManager->ReleaseManagedNetConnection();
+                       __isRefAdded = false;
+               }
+       }
+
+       __pConnection = null;
+}
+
+result
+_ManagedNetConnectionImpl::SetManagedNetConnectionEventListener(IManagedNetConnectionEventListener* pListener)
+{
+       result r = E_SUCCESS;
+       _NetConnectionManagerImpl* pManager = _NetConnectionManagerImpl::GetInstance();
+
+       if (pManager != null)
+       {
+               if (__pListener != null)
+               {
+                       r = pManager->RemoveManagedNetConnectionEventListener(*__pListener);
+                       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+                       __pListener = null;
+               }
+
+               if (pListener != null)
+               {
+                       r = pManager->AddManagedNetConnectionEventListener(*pListener, __pConnection);
+                       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+                       __pListener = pListener;
+               }
+       }
+
+       return r;
+}
+
+result
+_ManagedNetConnectionImpl::Start(void)
+{
+       result r = E_SUCCESS;
+       _NetConnectionManagerImpl* pManager = _NetConnectionManagerImpl::GetInstance();
+
+       if (!__isRefAdded)
+       {
+               if (pManager != null)
+               {
+                       r = pManager->AddRefManagedNetConnection();
+                       if (r == E_SUCCESS)
+                       {
+                               __isRefAdded = true;
+                       }
+               }
+               else
+               {
+                       SysLogException(NID_NET, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+               }
+       }
+
+       return r;
+}
+
+ManagedNetConnection*
+_ManagedNetConnectionImpl::CreateInstanceN(void)
+{
+       ManagedNetConnection* pConnection = null;
+
+       pConnection = new (std::nothrow) ManagedNetConnection();
+       SysTryReturn(NID_NET, pConnection != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return pConnection;
+}
+
+NetConnectionState
+_ManagedNetConnectionImpl::GetConnectionState(void) const
+{
+       ClearLastResult();
+
+       NetConnectionState state = NET_CONNECTION_STATE_NONE;
+       _NetConnectionManagerImpl* pManager = _NetConnectionManagerImpl::GetInstance();
+
+       if (pManager != null)
+       {
+               state = pManager->GetManagedNetConnectionState();
+       }
+
+       return state;
+}
+
+NetConnectionState
+_ManagedNetConnectionImpl::QueryConnectionState(String& devName) const
+{
+       ClearLastResult();
+
+       NetConnectionState state = NET_CONNECTION_STATE_NONE;
+       _NetConnectionManagerImpl* pManager = _NetConnectionManagerImpl::GetInstance();
+
+       if (pManager != null)
+       {
+               state = pManager->QueryManagedNetConnectionState(devName);
+       }
+
+       return state;
+}
+
+NetAccountId
+_ManagedNetConnectionImpl::GetNetAccountId(void) const
+{
+       ClearLastResult();
+
+       NetAccountId netAccountId = INVALID_HANDLE;
+       _NetConnectionManagerImpl* pManager = _NetConnectionManagerImpl::GetInstance();
+
+       if (pManager != null)
+       {
+               netAccountId = pManager->GetManagedNetAccountId();
+       }
+
+       return netAccountId;
+}
+
+const NetConnectionInfo*
+_ManagedNetConnectionImpl::GetNetConnectionInfo(void) const
+{
+       ClearLastResult();
+
+       const NetConnectionInfo* pInfo = null;
+       _NetConnectionManagerImpl* pManager = _NetConnectionManagerImpl::GetInstance();
+
+       if (pManager != null)
+       {
+               pInfo = pManager->GetManagedNetConnectionInfo();
+       }
+
+       return pInfo;
+}
+
+_ManagedNetConnectionImpl*
+_ManagedNetConnectionImpl::GetInstance(ManagedNetConnection& managedNetConnection)
+{
+       return managedNetConnection.__pManagedNetConnectionImpl;
+}
+
+const _ManagedNetConnectionImpl*
+_ManagedNetConnectionImpl::GetInstance(const ManagedNetConnection& managedNetConnection)
+{
+       return managedNetConnection.__pManagedNetConnectionImpl;
+}
+
+}  } // Tizen::Net
+
diff --git a/src/FNet_NetAccountDatabase.cpp b/src/FNet_NetAccountDatabase.cpp
new file mode 100644 (file)
index 0000000..7a8c6e5
--- /dev/null
@@ -0,0 +1,655 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+* @file                        FNet_NetAccountDatabase.cpp
+* @brief               This is the implementation file for the %_NetAccountDatabase class.
+*
+* This file contains the implementation of the %_NetAccountDatabase class.
+*/
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FBaseColIList.h>
+#include <FBaseColIListT.h>
+#include <FIoDatabase.h>
+#include <FIoDbStatement.h>
+#include <FIoDbEnumerator.h>
+#include <FIoDirectory.h>
+#include <FAppApp.h>
+#include <FBaseSysLog.h>
+#include <FApp_AppInfo.h>
+#include "FNet_NetTypes.h"
+#include "FNet_NetUtility.h"
+#include "FNet_NetAccountDatabase.h"
+
+using namespace std;
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Net {
+
+result
+_NetAccountDatabase::InitializeRepository(void)
+{
+       static const wchar_t _NET_ACCOUNT_DATABASE_CREATE_TABLE_STATEMENT[] =
+                       L"CREATE TABLE IF NOT EXISTS NetAccountTable (accountId INTEGER UNIQUE, accountName TEXT(256) UNIQUE, profileName TEXT(256) UNIQUE, isReadOnly INTEGER)";
+
+       result r = E_SUCCESS;
+       Database accountDb;
+
+       if (!Database::Exists(_NetAccountDatabase::GetDbPath()))
+       {
+               SysLog(NID_NET, "NetAccount database is NOT found, so create it now.");
+       }
+
+       r = accountDb.Construct(_NetAccountDatabase::GetDbPath(), true);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = accountDb.ExecuteSql(String(_NET_ACCOUNT_DATABASE_CREATE_TABLE_STATEMENT), true);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+_NetAccountDatabase::AddAccount(const String& accountName, const String& profileName, _NetAccountOwner owner, NetAccountId& accountId)
+{
+       static const wchar_t _NET_ACCOUNT_DATABASE_GET_MAX_ACCOUNT_ID_STATEMENT[] =
+                       L"SELECT MAX(accountId) FROM NetAccountTable";
+       static const wchar_t _NET_ACCOUNT_DATABASE_ADD_ACCOUNT_STATEMENT[] =
+                       L"INSERT INTO NetAccountTable (accountId, accountName, profileName, isReadOnly) VALUES(?, ?, ?, ?)";
+
+       result r = E_SUCCESS;
+       Database accountDb;
+       unique_ptr<DbStatement> pStmt;
+       unique_ptr<DbEnumerator> pEnum;
+       bool isReadOnly = true;
+       NetAccountId netAccountId = INVALID_HANDLE;
+
+       SysLog(NID_NET, "AddAccount() has been called with accountName:%ls, profileName:%ls, owner:%d",
+                       accountName.GetPointer(), profileName.GetPointer(), owner);
+
+       accountId = INVALID_HANDLE;
+
+       SysTryReturnResult(NID_NET, !accountName.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. accountName is an empty string.");
+       SysTryReturnResult(NID_NET, !profileName.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. profileName is an empty string.");
+
+       r = accountDb.Construct(_NetAccountDatabase::GetDbPath(), false);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       if (owner == _NET_ACCOUNT_OWNER_THIS)
+       {
+               isReadOnly = false;
+       }
+       else
+       {
+               isReadOnly = true;
+       }
+
+       if (owner == _NET_ACCOUNT_OWNER_SYSTEM_INTERNET)
+       {
+               netAccountId = _DEFAULT_PS_ACCOUNT_ID;
+       }
+       else if (owner == _NET_ACCOUNT_OWNER_SYSTEM_MMS)
+       {
+               netAccountId = _DEFAULT_MMS_ACCOUNT_ID;
+       }
+       else
+       {
+               pStmt.reset(accountDb.CreateStatementN(String(_NET_ACCOUNT_DATABASE_GET_MAX_ACCOUNT_ID_STATEMENT)));
+               r = GetLastResult();
+               SysTryReturnResult(NID_NET, pStmt != null, r, "Propagating.");
+
+               pEnum.reset(accountDb.ExecuteStatementN(*pStmt));
+               if (pEnum != null)
+               {
+                       while (pEnum->MoveNext() == E_SUCCESS)
+                       {
+                               pEnum->GetIntAt(0, netAccountId);
+                               break;
+                       }
+               }
+
+               SysTryReturnResult(NID_NET, netAccountId >= 0, E_SYSTEM,
+                               "[%s] A system error has been occurred. Failed to allocate a new accountId.", GetErrorMessage(E_SYSTEM));
+
+               if (netAccountId >= _CUSTOM_ACCOUNT_ID_START)
+               {
+                       netAccountId++;
+               }
+               else
+               {
+                       netAccountId = _CUSTOM_ACCOUNT_ID_START;
+               }
+       }
+
+       pStmt.reset(accountDb.CreateStatementN(String(_NET_ACCOUNT_DATABASE_ADD_ACCOUNT_STATEMENT)));
+       r = GetLastResult();
+       SysTryReturnResult(NID_NET, pStmt != null, r, "Propagating.");
+
+       r = pStmt->BindInt(0, netAccountId);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = pStmt->BindString(1, accountName);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = pStmt->BindString(2, profileName);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = pStmt->BindInt(3, (int)isReadOnly);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pEnum.reset(accountDb.ExecuteStatementN(*pStmt));
+       r = GetLastResult();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       accountId = netAccountId;
+
+       return r;
+}
+
+result
+_NetAccountDatabase::RemoveAccountByAccountId(NetAccountId accountId)
+{
+       static const wchar_t _NET_ACCOUNT_DATABASE_REMOVE_ACCOUNT_BY_ACCOUNT_ID_STATEMENT[] =
+                       L"DELETE FROM NetAccountTable WHERE accountId=?";
+
+       SysLog(NID_NET, "RemoveAccountByAccountId() has been called with accountId:%d", accountId);
+
+       result r = E_SUCCESS;
+       Database accountDb;
+       unique_ptr<DbStatement> pStmt;
+       unique_ptr<DbEnumerator> pEnum;
+
+       SysTryReturnResult(NID_NET, accountId > 0, E_INVALID_ARG, "Invalid argument is used. accountId=%d", accountId);
+
+       r = accountDb.Construct(_NetAccountDatabase::GetDbPath(), false);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pStmt.reset(accountDb.CreateStatementN(String(_NET_ACCOUNT_DATABASE_REMOVE_ACCOUNT_BY_ACCOUNT_ID_STATEMENT)));
+       r = GetLastResult();
+       SysTryReturnResult(NID_NET, pStmt != null, r, "Propagating.");
+
+       r = pStmt->BindInt(0, accountId);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pEnum.reset(accountDb.ExecuteStatementN(*pStmt));
+       r = GetLastResult();
+
+       return r;
+}
+
+result
+_NetAccountDatabase::RemoveAccountByProfileName(const String& profileName)
+{
+       static const wchar_t _NET_ACCOUNT_DATABASE_REMOVE_ACCOUNT_BY_PROFILE_NAME_STATEMENT[] =
+                       L"DELETE FROM NetAccountTable WHERE profileName=?";
+
+       SysLog(NID_NET, "RemoveAccountByProfileName() has been called with profileName:%ls", profileName.GetPointer());
+
+       result r = E_SUCCESS;
+       Database accountDb;
+       unique_ptr<DbStatement> pStmt;
+       unique_ptr<DbEnumerator> pEnum;
+
+       SysTryReturnResult(NID_NET, !profileName.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. profileName is an empty string.");
+
+       r = accountDb.Construct(_NetAccountDatabase::GetDbPath(), false);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pStmt.reset(accountDb.CreateStatementN(String(_NET_ACCOUNT_DATABASE_REMOVE_ACCOUNT_BY_PROFILE_NAME_STATEMENT)));
+       r = GetLastResult();
+       SysTryReturnResult(NID_NET, pStmt != null, r, "Propagating.");
+
+       r = pStmt->BindString(0, profileName);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pEnum.reset(accountDb.ExecuteStatementN(*pStmt));
+       r = GetLastResult();
+
+       return r;
+}
+
+result
+_NetAccountDatabase::UpdateAccountName(NetAccountId accountId, const String& accountName)
+{
+       static const wchar_t _NET_ACCOUNT_DATABASE_UPDATE_ACCOUNT_NAME_STATEMENT[] =
+                       L"UPDATE NetAccountTable SET accountName=? WHERE accountId=?";
+
+       SysLog(NID_NET, "UpdateAccountName() has been called with accountId:%d, accountName:%ls", accountId, accountName.GetPointer());
+
+       result r = E_SUCCESS;
+       Database accountDb;
+       unique_ptr<DbStatement> pStmt;
+       unique_ptr<DbEnumerator> pEnum;
+
+       SysTryReturnResult(NID_NET, accountId > 0, E_INVALID_ARG, "AccountId[%d] is invalid.", accountId);
+       SysTryReturnResult(NID_NET, !accountName.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. accountName is an empty string.");
+
+       r = accountDb.Construct(_NetAccountDatabase::GetDbPath(), false);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pStmt.reset(accountDb.CreateStatementN(String(_NET_ACCOUNT_DATABASE_UPDATE_ACCOUNT_NAME_STATEMENT)));
+       r = GetLastResult();
+       SysTryReturnResult(NID_NET, pStmt != null, r, "Propagating.");
+
+       r = pStmt->BindString(0, accountName);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = pStmt->BindInt(1, accountId);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pEnum.reset(accountDb.ExecuteStatementN(*pStmt));
+       r = GetLastResult();
+
+       return r;
+}
+
+IListT<NetAccountId>*
+_NetAccountDatabase::GetAccountIdsN(void)
+{
+       static const wchar_t _NET_ACCOUNT_DATABASE_GET_ACCOUNT_IDS_STATEMENT[] =
+                       L"SELECT accountId FROM NetAccountTable";
+
+       result r = E_SUCCESS;
+       Database accountDb;
+       unique_ptr<DbStatement> pStmt;
+       unique_ptr<DbEnumerator> pEnum;
+       unique_ptr< ArrayListT<NetAccountId> > pList;
+
+       r = accountDb.Construct(_NetAccountDatabase::GetDbPath(), false);
+       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pStmt.reset(accountDb.CreateStatementN(String(_NET_ACCOUNT_DATABASE_GET_ACCOUNT_IDS_STATEMENT)));
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pStmt != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pList.reset(new (std::nothrow) ArrayListT<NetAccountId>());
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pList != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pList->Construct();
+       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pEnum.reset(accountDb.ExecuteStatementN(*pStmt));
+       r = GetLastResult();
+       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       NetAccountId accountId = INVALID_HANDLE;
+
+                       r = pEnum->GetIntAt(0, accountId);
+                       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       r = pList->Add(accountId);
+                       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+
+       ClearLastResult(); // To suppress E_OUT_OF_RANGE
+
+       return pList.release();
+}
+
+IList*
+_NetAccountDatabase::GetAccountNamesN(void)
+{
+       static const wchar_t _NET_ACCOUNT_DATABASE_GET_ACCOUNT_NAMES_STATEMENT[] =
+                       L"SELECT accountName FROM NetAccountTable";
+
+       result r = E_SUCCESS;
+       Database accountDb;
+       unique_ptr<DbStatement> pStmt;
+       unique_ptr<DbEnumerator> pEnum;
+       unique_ptr<ArrayList, _CollectionDeleter> pList;
+
+       r = accountDb.Construct(_NetAccountDatabase::GetDbPath(), false);
+       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pStmt.reset(accountDb.CreateStatementN(String(_NET_ACCOUNT_DATABASE_GET_ACCOUNT_NAMES_STATEMENT)));
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pStmt != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pList.reset(new (std::nothrow) ArrayList());
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pList != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pList->Construct();
+       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pEnum.reset(accountDb.ExecuteStatementN(*pStmt));
+       r = GetLastResult();
+       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       unique_ptr<String> pAccountName(new (std::nothrow) String());
+                       SysTryReturn(NID_NET, pAccountName != null, null, E_OUT_OF_MEMORY,
+                                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       r = pEnum->GetStringAt(0, *pAccountName);
+                       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       r = pList->Add(*pAccountName);
+                       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       pAccountName.release();
+               }
+       }
+
+       ClearLastResult(); // To suppress E_OUT_OF_RANGE
+
+       return pList.release();
+}
+
+IList*
+_NetAccountDatabase::GetAppProfileNamesN(void)
+{
+       static const wchar_t _NET_ACCOUNT_DATABASE_GET_PROFILE_NAMES_STATEMENT[] =
+                       L"SELECT profileName FROM NetAccountTable WHERE accountId>=?";
+
+       result r = E_SUCCESS;
+       Database accountDb;
+       unique_ptr<DbStatement> pStmt;
+       unique_ptr<DbEnumerator> pEnum;
+       unique_ptr<ArrayList, _CollectionDeleter> pList;
+
+       r = accountDb.Construct(_NetAccountDatabase::GetDbPath(), false);
+       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pStmt.reset(accountDb.CreateStatementN(String(_NET_ACCOUNT_DATABASE_GET_PROFILE_NAMES_STATEMENT)));
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pStmt != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pStmt->BindInt(0, _CUSTOM_ACCOUNT_ID_START);
+       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pList.reset(new (std::nothrow) ArrayList());
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pList != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pList->Construct();
+       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pEnum.reset(accountDb.ExecuteStatementN(*pStmt));
+       r = GetLastResult();
+       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       unique_ptr<String> pProfileName(new (std::nothrow) String());
+                       SysTryReturn(NID_NET, pProfileName != null, null, E_OUT_OF_MEMORY,
+                                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       r = pEnum->GetStringAt(0, *pProfileName);
+                       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       r = pList->Add(*pProfileName);
+                       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       pProfileName.release();
+               }
+       }
+
+       ClearLastResult(); // To suppress E_OUT_OF_RANGE
+
+       return pList.release();
+}
+
+result
+_NetAccountDatabase::GetAccountName(NetAccountId accountId, String& accountName)
+{
+       static const wchar_t _NET_ACCOUNT_DATABASE_GET_ACCOUNT_NAME_STATEMENT[] =
+                       L"SELECT accountName FROM NetAccountTable WHERE accountId=?";
+
+       SysLog(NID_NET, "GetAccountName() has been called with accountId:%d", accountId);
+
+       result r = E_SUCCESS;
+       Database accountDb;
+       unique_ptr<DbStatement> pStmt;
+       unique_ptr<DbEnumerator> pEnum;
+
+       SysTryReturnResult(NID_NET, accountId > 0, E_INVALID_ARG, "Invalid argument is used. accountId=%d", accountId);
+
+       r = accountDb.Construct(_NetAccountDatabase::GetDbPath(), false);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pStmt.reset(accountDb.CreateStatementN(String(_NET_ACCOUNT_DATABASE_GET_ACCOUNT_NAME_STATEMENT)));
+       r = GetLastResult();
+       SysTryReturnResult(NID_NET, pStmt != null, r, "Propagating.");
+
+       r = pStmt->BindInt(0, accountId);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = E_OBJ_NOT_FOUND;
+
+       pEnum.reset(accountDb.ExecuteStatementN(*pStmt));
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEnum->GetStringAt(0, accountName);
+                       r = E_SUCCESS;
+                       break;
+               }
+       }
+
+       return r;
+}
+
+result
+_NetAccountDatabase::GetProfileName(NetAccountId accountId, String& profileName)
+{
+       static const wchar_t _NET_ACCOUNT_DATABASE_GET_PROFILE_NAME_STATEMENT[] =
+                       L"SELECT profileName FROM NetAccountTable WHERE accountId=?";
+
+       SysLog(NID_NET, "GetProfileName() has been called with accountId:%d", accountId);
+
+       result r = E_SUCCESS;
+       Database accountDb;
+       unique_ptr<DbStatement> pStmt;
+       unique_ptr<DbEnumerator> pEnum;
+
+       SysTryReturnResult(NID_NET, accountId > 0, E_INVALID_ARG, "Invalid argument is used. accountId=%d", accountId);
+
+       r = accountDb.Construct(_NetAccountDatabase::GetDbPath(), false);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pStmt.reset(accountDb.CreateStatementN(String(_NET_ACCOUNT_DATABASE_GET_PROFILE_NAME_STATEMENT)));
+       r = GetLastResult();
+       SysTryReturnResult(NID_NET, pStmt != null, r, "Propagating.");
+
+       r = pStmt->BindInt(0, accountId);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = E_OBJ_NOT_FOUND;
+
+       pEnum.reset(accountDb.ExecuteStatementN(*pStmt));
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEnum->GetStringAt(0, profileName);
+                       r = E_SUCCESS;
+                       break;
+               }
+       }
+
+       return r;
+}
+
+result
+_NetAccountDatabase::GetAccountIdByAccountName(const String& accountName, NetAccountId& accountId)
+{
+       static const wchar_t _NET_ACCOUNT_DATABASE_GET_ACCOUNT_ID_BY_ACCOUNT_NAME_STATEMENT[] =
+                       L"SELECT accountId FROM NetAccountTable WHERE accountName=?";
+
+       SysLog(NID_NET, "GetAccountIdByAccountName() has been called with accountName:%ls", accountName.GetPointer());
+
+       result r = E_SUCCESS;
+       Database accountDb;
+       unique_ptr<DbStatement> pStmt;
+       unique_ptr<DbEnumerator> pEnum;
+
+       SysTryReturnResult(NID_NET, !accountName.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. accountName is an empty string.");
+
+       r = accountDb.Construct(_NetAccountDatabase::GetDbPath(), false);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pStmt.reset(accountDb.CreateStatementN(String(_NET_ACCOUNT_DATABASE_GET_ACCOUNT_ID_BY_ACCOUNT_NAME_STATEMENT)));
+       SysTryReturnResult(NID_NET, pStmt != null, r, "Propagating.");
+
+       r = pStmt->BindString(0, accountName);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = E_OBJ_NOT_FOUND;
+
+       pEnum.reset(accountDb.ExecuteStatementN(*pStmt));
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEnum->GetIntAt(0, accountId);
+                       r = E_SUCCESS;
+                       break;
+               }
+       }
+
+       return r;
+}
+
+result
+_NetAccountDatabase::GetAccountIdByProfileName(const String& profileName, NetAccountId& accountId)
+{
+       static const wchar_t _NET_ACCOUNT_DATABASE_GET_ACCOUNT_ID_BY_PROFILE_NAME_STATEMENT[] =
+                       L"SELECT accountId FROM NetAccountTable WHERE profileName=?";
+
+       SysLog(NID_NET, "GetAccountIdByProfileName() has been called with profileName:%ls", profileName.GetPointer());
+
+       result r = E_SUCCESS;
+       Database accountDb;
+       unique_ptr<DbStatement> pStmt;
+       unique_ptr<DbEnumerator> pEnum;
+
+       SysTryReturnResult(NID_NET, !profileName.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. profileName is an empty string.");
+
+       r = accountDb.Construct(_NetAccountDatabase::GetDbPath(), false);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pStmt.reset(accountDb.CreateStatementN(String(_NET_ACCOUNT_DATABASE_GET_ACCOUNT_ID_BY_PROFILE_NAME_STATEMENT)));
+       r = GetLastResult();
+       SysTryReturnResult(NID_NET, pStmt != null, r, "Propagating.");
+
+       r = pStmt->BindString(0, profileName);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = E_OBJ_NOT_FOUND;
+
+       pEnum.reset(accountDb.ExecuteStatementN(*pStmt));
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEnum->GetIntAt(0, accountId);
+                       r = E_SUCCESS;
+                       break;
+               }
+       }
+
+       return r;
+}
+
+bool
+_NetAccountDatabase::IsReadOnly(NetAccountId accountId)
+{
+       static const wchar_t NET_ACCOUNT_DATABASE_GET_IS_READ_ONLY_STATEMENT[] =
+                       L"SELECT isReadOnly FROM NetAccountTable WHERE accountId=?";
+
+       SysLog(NID_NET, "IsReadOnly() has been called with accountId:%d", accountId);
+
+       result r = E_SUCCESS;
+       Database accountDb;
+       unique_ptr<DbStatement> pStmt;
+       unique_ptr<DbEnumerator> pEnum;
+       int isReadOnly = 1;
+
+       SysTryReturn(NID_NET, accountId > 0, true, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. accountId=%d", GetErrorMessage(E_INVALID_ARG), accountId);
+
+       r = accountDb.Construct(_NetAccountDatabase::GetDbPath(), false);
+       SysTryReturn(NID_NET, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pStmt.reset(accountDb.CreateStatementN(String(NET_ACCOUNT_DATABASE_GET_IS_READ_ONLY_STATEMENT)));
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pStmt != null, true, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pStmt->BindInt(0, accountId);
+       SysTryReturn(NID_NET, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = E_OBJ_NOT_FOUND;
+       pEnum.reset(accountDb.ExecuteStatementN(*pStmt));
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEnum->GetIntAt(0, isReadOnly);
+                       r = E_SUCCESS;
+                       break;
+               }
+       }
+       SysTryReturn(NID_NET, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       ClearLastResult();
+
+       return (bool)isReadOnly;
+}
+
+String
+_NetAccountDatabase::GetDbPath(void)
+{
+       static const wchar_t _OLD_DATA_PATH[] = L"/Home/";
+       static const wchar_t _NET_ACCOUNT_DATABASE_FILE_NAME[] = L"netAccount.db";
+
+       String dbPath;
+       _ApiVersion apiVersion = _AppInfo::GetApiVersion();
+
+       if (apiVersion == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               dbPath = String(_OLD_DATA_PATH);
+       }
+       else
+       {
+               dbPath = Tizen::App::App::GetInstance()->GetAppDataPath();
+       }
+
+       dbPath += String(_NET_ACCOUNT_DATABASE_FILE_NAME);
+
+       SysLog(NID_NET, "GetDbPath() has been succeeded with the path:%ls", dbPath.GetPointer());
+
+       return dbPath;
+}
+
+}} // Tizen::Net
diff --git a/src/FNet_NetAccountDatabase.h b/src/FNet_NetAccountDatabase.h
new file mode 100644 (file)
index 0000000..c40a05a
--- /dev/null
@@ -0,0 +1,89 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNet_NetAccountDatabase.h
+ * @brief      This is the header file for the %_NetAccountDatabase class.
+ *
+ * This header file contains the declarations of the %_NetAccountDatabase class.
+ */
+
+#ifndef _FNET_INTERNAL_NET_ACCOUNT_DATABASE_H_
+#define _FNET_INTERNAL_NET_ACCOUNT_DATABASE_H_
+
+#include <FBaseDataType.h>
+#include <FNetNetTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+} } // Tizen::Base
+
+namespace Tizen { namespace Base { namespace Collection
+{
+template<class Type> class IListT;
+class IList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net {
+
+enum _NetAccountOwner
+{
+       _NET_ACCOUNT_OWNER_SYSTEM_INTERNET,
+       _NET_ACCOUNT_OWNER_SYSTEM_MMS,
+       _NET_ACCOUNT_OWNER_SYSTEM,
+       _NET_ACCOUNT_OWNER_OTHER,
+       _NET_ACCOUNT_OWNER_THIS
+};
+
+/**
+ * @class      _NetAccountDatabase
+ * @brief      This class represents a database for the network account.
+ * @since 2.1
+ *
+ * This class represents a database for the network account.
+ */
+class _NetAccountDatabase
+{
+public:
+       static result InitializeRepository(void);
+       static result AddAccount(const Tizen::Base::String& accountName, const Tizen::Base::String& profileName, _NetAccountOwner owner, NetAccountId& accountId);
+       static result RemoveAccountByAccountId(NetAccountId accountId);
+       static result RemoveAccountByProfileName(const Tizen::Base::String& profileName);
+       static result UpdateAccountName(NetAccountId accountId, const Tizen::Base::String& accountName);
+       static Tizen::Base::Collection::IListT<NetAccountId>* GetAccountIdsN(void);
+       static Tizen::Base::Collection::IList* GetAccountNamesN(void);
+       static Tizen::Base::Collection::IList* GetAppProfileNamesN(void);
+       static result GetAccountName(NetAccountId accountId, Tizen::Base::String& accountName);
+       static result GetProfileName(NetAccountId accountId, Tizen::Base::String& profileName);
+       static result GetAccountIdByAccountName(const Tizen::Base::String& accountName, NetAccountId& accountId);
+       static result GetAccountIdByProfileName(const Tizen::Base::String& profileName, NetAccountId& accountId);
+       static bool IsReadOnly(NetAccountId accountId);
+
+private:
+       static Tizen::Base::String GetDbPath(void);
+
+private:
+    _NetAccountDatabase(void);
+       virtual ~_NetAccountDatabase(void);
+
+       _NetAccountDatabase(const _NetAccountDatabase& rhs);
+       _NetAccountDatabase& operator =(const _NetAccountDatabase& rhs);
+}; // _NetAccountDatabase
+
+} } // Tizen::Net
+#endif // _FNET_INTERNAL_NET_ACCOUNT_DATABASE_H_
+
diff --git a/src/FNet_NetAccountInfoImpl.cpp b/src/FNet_NetAccountInfoImpl.cpp
new file mode 100644 (file)
index 0000000..3eca91a
--- /dev/null
@@ -0,0 +1,1017 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_NetAccountInfoImpl.cpp
+ * @brief              This is the implementation for the %_NetAccountInfoImpl class.
+ */
+
+#include <net_connection.h>
+#include <FBaseString.h>
+#include <FNetNetTypes.h>
+#include <FNetNetEndPoint.h>
+#include <FNetNetAccountInfo.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FNet_NetTypes.h"
+#include "FNet_NetAccountInfoImpl.h"
+#include "FNet_NetAccountDatabase.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Net::Wifi;
+
+namespace Tizen { namespace Net {
+
+static const int _MAX_ACCESS_POINT_NAME_LENGTH = 64;
+
+_NetAccountInfoImpl::_NetAccountInfoImpl(void)
+       : __accountId(INVALID_HANDLE)
+       , __accountName()
+       , __accessPointName()
+       , __authType(NET_NAPAUTH_NONE)
+       , __authId()
+       , __authPassword()
+       , __homeUrl()
+       , __bearerType(NET_BEARER_NONE)
+       , __protocolType(NET_PROTO_TYPE_NONE)
+       , __localAddressScheme(NET_ADDRESS_SCHEME_NONE)
+       , __dnsAddressScheme(NET_ADDRESS_SCHEME_NONE)
+       , __pLocalAddress(null)
+       , __pPrimaryDnsAddress(null)
+       , __pSecondaryDnsAddress(null)
+       , __pProxyAddress(null)
+       , __isReadOnly(true)
+{
+}
+
+_NetAccountInfoImpl::~_NetAccountInfoImpl(void)
+{
+}
+
+result
+_NetAccountInfoImpl::Construct(const _NetAccountInfoImpl& netAccountInfo)
+{
+       result r = E_SUCCESS;
+       unique_ptr<IpAddress> pLocalAddress;
+       unique_ptr<IpAddress> pPrimaryDnsAddress;
+       unique_ptr<IpAddress> pSecondaryDnsAddress;
+       unique_ptr<NetEndPoint> pProxyAddress;
+
+       SysAssertf(__bearerType == NET_BEARER_NONE,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       SysTryReturnResult(NID_NET, netAccountInfo.__bearerType != NET_BEARER_NONE, E_INVALID_ARG,
+                       "Invalid argument is used. Network bearer type is invalid.");
+
+       if (netAccountInfo.__pLocalAddress != null)
+       {
+               pLocalAddress.reset(netAccountInfo.__pLocalAddress->CloneN());
+               SysTryReturnResult(NID_NET, pLocalAddress != null, E_OUT_OF_MEMORY,     "Memory allocation failed.");
+       }
+
+       if (netAccountInfo.__pPrimaryDnsAddress != null)
+       {
+               pPrimaryDnsAddress.reset(netAccountInfo.__pPrimaryDnsAddress->CloneN());
+               SysTryReturnResult(NID_NET, pPrimaryDnsAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       if (netAccountInfo.__pSecondaryDnsAddress != null)
+       {
+               pSecondaryDnsAddress.reset(netAccountInfo.__pSecondaryDnsAddress->CloneN());
+               SysTryReturnResult(NID_NET, pSecondaryDnsAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       if (netAccountInfo.__pProxyAddress != null)
+       {
+               pProxyAddress.reset(new (std::nothrow) NetEndPoint(*netAccountInfo.__pProxyAddress));
+               SysTryReturnResult(NID_NET, pProxyAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       __accountId = netAccountInfo.__accountId;
+       __accountName = netAccountInfo.__accountName;
+       __accessPointName = netAccountInfo.__accessPointName;
+       __authType = netAccountInfo.__authType;
+       __authId = netAccountInfo.__authId;
+       __authPassword = netAccountInfo.__authPassword;
+       __homeUrl = netAccountInfo.__homeUrl;
+       __bearerType = netAccountInfo.__bearerType;
+       __protocolType = netAccountInfo.__protocolType;
+       __localAddressScheme = netAccountInfo.__localAddressScheme;
+       __dnsAddressScheme = netAccountInfo.__dnsAddressScheme;
+       __pLocalAddress = move(pLocalAddress);
+       __pPrimaryDnsAddress = move(pPrimaryDnsAddress);
+       __pSecondaryDnsAddress = move(pSecondaryDnsAddress);
+       __pProxyAddress = move(pProxyAddress);
+        __isReadOnly = netAccountInfo.__isReadOnly;
+
+       return r;
+}
+
+result
+_NetAccountInfoImpl::Construct(void)
+{
+       SysAssertf(__bearerType == NET_BEARER_NONE,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       __bearerType = NET_BEARER_PS;
+
+       return E_SUCCESS;
+}
+
+result
+_NetAccountInfoImpl::Construct(NetAccountInfo* pAccountInfo, void* pProfileHandle)
+{
+       result r = E_SUCCESS;
+       NetAccountId accountId = INVALID_HANDLE;
+       String accountName;
+       String accessPointName;
+       NetNapAuthType  authType = NET_NAPAUTH_NONE;
+       String authId;
+       String authPassword;
+       String homeUrl;
+       NetBearerType bearerType;
+       NetProtocolType protocolType;
+       NetAddressScheme localAddressScheme;
+       NetAddressScheme dnsAddressScheme;
+       std::unique_ptr<IpAddress> pLocalAddress;
+       std::unique_ptr<IpAddress> pPrimaryDnsAddress;
+       std::unique_ptr<IpAddress> pSecondaryDnsAddress;
+       std::unique_ptr<NetEndPoint> pProxyAddress;
+       bool isReadOnly = true;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_profile_h profileHandle = static_cast<connection_profile_h>(pProfileHandle);
+
+       SysAssertf(__bearerType == NET_BEARER_NONE,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       SysTryReturnResult(NID_NET, pAccountInfo != null, E_INVALID_ARG, "Invalid argument is used. The account info is null.");
+       SysTryReturnResult(NID_NET, profileHandle != null, E_INVALID_ARG, "Invalid argument is used. The profile handle is null.");
+
+       connection_profile_type_e profileType = CONNECTION_PROFILE_TYPE_CELLULAR;
+       ret = connection_profile_get_type(profileHandle, &profileType);
+       SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                       "A system error has been occurred. The return value from connection_profile_get_type() is %d", ret);
+
+       if (profileType == CONNECTION_PROFILE_TYPE_CELLULAR)
+       {
+               String profileName;
+               char* pProfileName = null;
+               char* pApn = null;
+               connection_cellular_service_type_e serviceType = CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN;
+               connection_cellular_auth_type_e netAuthType = CONNECTION_CELLULAR_AUTH_TYPE_NONE;
+               char* pAuthId = null;
+               char* pAuthPassword = null;
+               char* pHomeUrl = null;
+
+               ret = connection_profile_get_name(profileHandle, &pProfileName);
+               SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                               "A system error has been occurred. The return value from connection_profile_get_name() is %d", ret);
+
+               profileName = String(pProfileName);
+               free(pProfileName);
+
+               r = _NetAccountDatabase::GetAccountIdByProfileName(profileName, accountId);
+               SysTryReturnResult(NID_NET, r != E_OUT_OF_MEMORY, r, "Propagating.");
+               SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                               "A system error has been occurred. Failed to get the account Id from DB.");
+
+               r = _NetAccountDatabase::GetAccountName(accountId, accountName);
+               SysTryReturnResult(NID_NET, r != E_OUT_OF_MEMORY, r, "Propagating.");
+               SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                               "A system error has been occurred. Failed to get the account name from DB.");
+
+               connection_profile_get_cellular_service_type(profileHandle, &serviceType);
+               if ((serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_MMS) || (serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS))
+               {
+                       bearerType = NET_BEARER_MMS;
+                       isReadOnly  = true;
+               }
+               else if ((serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET) || (serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET))
+               {
+                       bearerType = NET_BEARER_PS;
+                       isReadOnly  = true;
+               }
+               else
+               {
+                       bearerType = NET_BEARER_PS;
+                       isReadOnly  = false;
+               }
+
+               ret = connection_profile_get_cellular_apn(profileHandle, &pApn);
+               SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                               "A system error has been occurred. The return value from connection_profile_get_cellular_apn() is %d", ret);
+
+               accessPointName = String(pApn);
+               free(pApn);
+
+               ret = connection_profile_get_cellular_auth_info(profileHandle, &netAuthType, &pAuthId, &pAuthPassword);
+               if (netAuthType == CONNECTION_CELLULAR_AUTH_TYPE_PAP)
+               {
+                       authType = NET_NAPAUTH_PAP;
+               }
+               else if (netAuthType == CONNECTION_CELLULAR_AUTH_TYPE_CHAP)
+               {
+                       authType = NET_NAPAUTH_CHAP;
+               }
+               else
+               {
+                       authType = NET_NAPAUTH_NONE;
+               }
+
+               if (pAuthId != null)
+               {
+                       authId = String(pAuthId);
+                       free(pAuthId);
+               }
+
+               if (pAuthPassword != null)
+               {
+                       authPassword = String(pAuthPassword);
+                       free(pAuthPassword);
+               }
+
+               ret = connection_profile_get_cellular_home_url(profileHandle, &pHomeUrl);
+               if ((ret == CONNECTION_ERROR_NONE) && (pHomeUrl != null))
+               {
+                       homeUrl = String(pHomeUrl);
+                       free(pHomeUrl);
+               }
+       }
+       else if (profileType == CONNECTION_PROFILE_TYPE_WIFI)
+       {
+               accountId = _DEFAULT_WIFI_ACCOUNT_ID;
+               bearerType = NET_BEARER_WIFI;
+       }
+       else
+       {
+               SysLogException(NID_NET, E_INVALID_ARG, "[%s] Invalid argument is used. The profile info is invalid.", GetErrorMessage(E_INVALID_ARG));
+               return E_INVALID_ARG;
+       }
+
+       protocolType = NET_PROTO_TYPE_IPV4;
+
+       connection_ip_config_type_e ipConfigType = CONNECTION_IP_CONFIG_TYPE_NONE;
+       ret = connection_profile_get_ip_config_type(profileHandle, CONNECTION_ADDRESS_FAMILY_IPV4, &ipConfigType);
+       SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                       "A system error has been occurred. The return value from connection_profile_get_ip_config_type() is %d", ret);
+       if ((ipConfigType == CONNECTION_IP_CONFIG_TYPE_STATIC) || (ipConfigType == CONNECTION_IP_CONFIG_TYPE_FIXED))
+       {
+               localAddressScheme = NET_ADDRESS_SCHEME_STATIC;
+               dnsAddressScheme = NET_ADDRESS_SCHEME_STATIC;
+       }
+       else
+       {
+               localAddressScheme = NET_ADDRESS_SCHEME_DYNAMIC;
+               dnsAddressScheme = NET_ADDRESS_SCHEME_DYNAMIC;
+       }
+
+       char* pIpAddr = null;
+       String ipAddr;
+
+       ret = connection_profile_get_ip_address(profileHandle, CONNECTION_ADDRESS_FAMILY_IPV4, &pIpAddr);
+       if ((ret == CONNECTION_ERROR_NONE) && (pIpAddr != null))
+       {
+               ipAddr = String(pIpAddr);
+               pLocalAddress.reset(new (std::nothrow) Ip4Address(ipAddr));
+               free(pIpAddr);
+               pIpAddr = null;
+               SysTryReturnResult(NID_NET, pLocalAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       ret = connection_profile_get_dns_address(profileHandle, 1, CONNECTION_ADDRESS_FAMILY_IPV4, &pIpAddr);
+       if ((ret == CONNECTION_ERROR_NONE) && (pIpAddr != null))
+       {
+               ipAddr = String(pIpAddr);
+               pPrimaryDnsAddress.reset(new (std::nothrow) Ip4Address(ipAddr));
+               free(pIpAddr);
+               pIpAddr = null;
+               SysTryReturnResult(NID_NET, pPrimaryDnsAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       ret = connection_profile_get_dns_address(profileHandle, 2, CONNECTION_ADDRESS_FAMILY_IPV4, &pIpAddr);
+       if ((ret == CONNECTION_ERROR_NONE) && (pIpAddr != null))
+       {
+               ipAddr = String(pIpAddr);
+               pSecondaryDnsAddress.reset(new (std::nothrow) Ip4Address(ipAddr));
+               free(pIpAddr);
+               pIpAddr = null;
+               SysTryReturnResult(NID_NET, pSecondaryDnsAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       char* pProxyAddr = null;
+       String proxyAddr;
+       int delimeterIndex = 0;
+
+       ret = connection_profile_get_proxy_address(profileHandle, CONNECTION_ADDRESS_FAMILY_IPV4, &pProxyAddr);
+       if ((ret == CONNECTION_ERROR_NONE) && (pProxyAddr != null))
+       {
+               proxyAddr = String(pProxyAddr);
+               free(pProxyAddr);
+
+               r = proxyAddr.IndexOf(L":", 0, delimeterIndex);
+               if (r == E_SUCCESS)
+               {
+                       String  proxyIpAddr;
+                       String proxyPort;
+                       int port = 0;
+
+                       r = proxyAddr.SubString(0, delimeterIndex, proxyIpAddr);
+                       r = proxyAddr.SubString(delimeterIndex+1, proxyPort);
+
+                       Ip4Address address(proxyIpAddr);
+                       Integer::Parse(proxyPort, port);
+
+                       pProxyAddress.reset(new (std::nothrow) NetEndPoint(address, port));
+                       SysTryReturnResult(NID_NET, pProxyAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+               }
+       }
+
+       __accountId = accountId;
+       __accountName = accountName;
+       __accessPointName = accessPointName;
+       __authType = authType;
+       __authId = authId;
+       __authPassword = authPassword;
+       __homeUrl = homeUrl;
+       __bearerType = bearerType;
+       __protocolType = protocolType;
+       __localAddressScheme = localAddressScheme;
+       __dnsAddressScheme = dnsAddressScheme;
+       __pLocalAddress = move(pLocalAddress);
+       __pPrimaryDnsAddress = move(pPrimaryDnsAddress);
+       __pSecondaryDnsAddress = move(pSecondaryDnsAddress);
+       __pProxyAddress = move(pProxyAddress);
+       __isReadOnly = isReadOnly;
+
+       pAccountInfo->__pNetAccountInfoImpl = this;
+
+       return E_SUCCESS;
+}
+
+NetAccountId
+_NetAccountInfoImpl::GetAccountId(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       return __accountId;
+}
+
+result
+_NetAccountInfoImpl::SetAccountId(NetAccountId accountId)
+{
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       __accountId = accountId;
+
+       return E_SUCCESS;
+}
+
+String
+_NetAccountInfoImpl::GetAccountName(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       return __accountName;
+}
+
+result
+_NetAccountInfoImpl::SetAccountName(const String& accountName)
+{
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       __accountName = accountName;
+
+       if (__accountName.GetLength() > _MAX_ACCOUNT_NAME_LENGTH)
+       {
+               SysLog(NID_NET, "AccountName's length[%d] is over [%d], so truncate it.",
+                               __accountName.GetLength(), _MAX_ACCOUNT_NAME_LENGTH);
+
+               __accountName.SetLength(_MAX_ACCOUNT_NAME_LENGTH);
+       }
+
+       return E_SUCCESS;
+}
+
+NetProtocolType
+_NetAccountInfoImpl::GetProtocolType(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       return __protocolType;
+}
+
+result
+_NetAccountInfoImpl::SetProtocolType(NetProtocolType netProtocolType)
+{
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       __protocolType = netProtocolType;
+
+       return E_SUCCESS;
+}
+
+String
+_NetAccountInfoImpl::GetAccessPointName(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       return __accessPointName;
+}
+
+result
+_NetAccountInfoImpl::SetAccessPointName(const String& accessPointName)
+{
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       __accessPointName = accessPointName;
+
+       if (__accessPointName.GetLength() > _MAX_ACCESS_POINT_NAME_LENGTH)
+       {
+               SysLog(NID_NET, "AccessPointName's length[%d] is over [%d], so truncate it.",
+                               __accessPointName.GetLength(), _MAX_ACCESS_POINT_NAME_LENGTH);
+
+               __accessPointName.SetLength(_MAX_ACCESS_POINT_NAME_LENGTH);
+       }
+
+       return E_SUCCESS;
+}
+
+NetAddressScheme
+_NetAccountInfoImpl::GetLocalAddressScheme(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       return __localAddressScheme;
+}
+
+const IpAddress*
+_NetAccountInfoImpl::GetLocalAddress(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturn(NID_NET, __localAddressScheme == NET_ADDRESS_SCHEME_STATIC, null, E_INVALID_OPERATION,
+                       "[%s] The operation is not allowed on dynamic address scheme instance.", GetErrorMessage(E_INVALID_OPERATION));
+
+       return __pLocalAddress.get();
+}
+
+result
+_NetAccountInfoImpl::SetLocalAddress(NetAddressScheme localAddrScheme, const IpAddress* pLocalAddress)
+{
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       std::unique_ptr<IpAddress> pTempAddress;
+
+       if (localAddrScheme == NET_ADDRESS_SCHEME_STATIC)
+       {
+               SysLog(NID_NET, "Local address scheme is static.");
+
+               SysTryReturnResult(NID_NET, pLocalAddress != null, E_INVALID_ARG,
+                               "Invalid argument is used. Address scheme is static but local address is null.");
+
+               pTempAddress.reset(pLocalAddress->CloneN());
+               SysTryReturnResult(NID_NET, pTempAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+       else if (localAddrScheme == NET_ADDRESS_SCHEME_DYNAMIC)
+       {
+               SysLog(NID_NET, "Local address scheme is dynamic.");
+       }
+       else
+       {
+               SysLogException(NID_NET, E_INVALID_ARG, "[%s] Invalid argument is used. The address scheme is invalid.", GetErrorMessage(E_INVALID_ARG));
+
+               return E_INVALID_ARG;
+       }
+
+       __localAddressScheme = localAddrScheme;
+       __pLocalAddress.reset(pTempAddress.release());
+
+       return E_SUCCESS;
+}
+
+NetAddressScheme
+_NetAccountInfoImpl::GetDnsAddressScheme(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       return __dnsAddressScheme;
+}
+
+const IpAddress*
+_NetAccountInfoImpl::GetPrimaryDnsAddress(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturn(NID_NET, __dnsAddressScheme == NET_ADDRESS_SCHEME_STATIC, null, E_INVALID_OPERATION,
+                       "[%s] The operation is not allowed on dynamic address scheme instance.", GetErrorMessage(E_INVALID_OPERATION));
+
+       return __pPrimaryDnsAddress.get();
+}
+
+const IpAddress*
+_NetAccountInfoImpl::GetSecondaryDnsAddress(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturn(NID_NET, __dnsAddressScheme == NET_ADDRESS_SCHEME_STATIC, null, E_INVALID_OPERATION,
+                       "[%s] The operation is not allowed on dynamic address scheme instance.", GetErrorMessage(E_INVALID_OPERATION));
+
+       return __pSecondaryDnsAddress.get();
+}
+
+result
+_NetAccountInfoImpl::SetDnsAddress(NetAddressScheme dnsAddressScheme, const IpAddress* pPrimaryDnsAddress,
+                                                                  const IpAddress* pSecondaryDnsAddress)
+{
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       std::unique_ptr<IpAddress> pTempPrimaryDnsAddress;
+       std::unique_ptr<IpAddress> pTempSecondaryDnsAddress;
+
+       if (dnsAddressScheme == NET_ADDRESS_SCHEME_STATIC)
+       {
+               SysLog(NID_NET, "DNS address scheme is static.");
+
+               SysTryReturnResult(NID_NET, pPrimaryDnsAddress != null, E_INVALID_ARG,
+                               "Invalid argument is used. Address scheme is static but primary dns address is null.");
+
+               pTempPrimaryDnsAddress.reset(pPrimaryDnsAddress->CloneN());
+               SysTryReturnResult(NID_NET, pTempPrimaryDnsAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               if (pSecondaryDnsAddress != null)
+               {
+                       pTempSecondaryDnsAddress.reset(pSecondaryDnsAddress->CloneN());
+                       SysTryReturnResult(NID_NET, pTempSecondaryDnsAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+               }
+       }
+       else if (dnsAddressScheme == NET_ADDRESS_SCHEME_DYNAMIC)
+       {
+               SysLog(NID_NET, "DNS address scheme is dynamic.");
+       }
+       else
+       {
+               SysLogException(NID_NET, E_INVALID_ARG, "[%s] Invalid argument is used. The address scheme is invalid.", GetErrorMessage(E_INVALID_ARG));
+
+               return E_INVALID_ARG;
+       }
+
+       __dnsAddressScheme = dnsAddressScheme;
+       __pPrimaryDnsAddress.reset(pTempPrimaryDnsAddress.release());
+       __pSecondaryDnsAddress.reset(pTempSecondaryDnsAddress.release());
+
+       return E_SUCCESS;
+}
+
+const NetEndPoint*
+_NetAccountInfoImpl::GetProxyAddress(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       return __pProxyAddress.get();
+}
+
+result
+_NetAccountInfoImpl::SetProxyAddress(const NetEndPoint* pProxyEndPoint)
+{
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       std::unique_ptr<NetEndPoint> pProxyAddress;
+
+       if (pProxyEndPoint != null)
+       {
+               pProxyAddress.reset(new (std::nothrow) NetEndPoint(*pProxyEndPoint));
+               SysTryReturnResult(NID_NET, pProxyAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       __pProxyAddress.reset(pProxyAddress.release());
+
+       return E_SUCCESS;
+}
+
+result
+_NetAccountInfoImpl::GetAuthenticationInfo(NetNapAuthType& authenticationType, String& id, String& password) const
+{
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       authenticationType = __authType;
+       id = __authId;
+       password = __authPassword;
+
+       return E_SUCCESS;
+}
+
+result
+_NetAccountInfoImpl::SetAuthenticationInfo(NetNapAuthType authenticationType, const String& id, const String& password)
+{
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       __authType = authenticationType;
+       __authId = id;
+       __authPassword = password;
+
+       return E_SUCCESS;
+}
+
+NetBearerType
+_NetAccountInfoImpl::GetBearerType(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       return __bearerType;
+}
+
+result
+_NetAccountInfoImpl::SetBearerType(NetBearerType bearerType)
+{
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       __bearerType = bearerType;
+
+       return E_SUCCESS;
+}
+
+String
+_NetAccountInfoImpl::GetHomeUrl(void) const
+{
+       return __homeUrl;
+}
+
+void
+_NetAccountInfoImpl::SetHomeUrl(const String& homeUrl)
+{
+       __homeUrl = homeUrl;
+}
+
+int
+_NetAccountInfoImpl::GetMaximumLengthOfId(void) const
+{
+       return _MAX_AUTH_ID_LENGTH;
+}
+
+int
+_NetAccountInfoImpl::GetMaximumLengthOfPassword(void) const
+{
+       return _MAX_AUTH_PASSWORD_LENGTH;
+}
+
+int
+_NetAccountInfoImpl::GetMaximumLengthOfAccountName(void) const
+{
+       return _MAX_ACCOUNT_NAME_LENGTH;
+}
+
+bool
+_NetAccountInfoImpl::IsReadOnly(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__bearerType != NET_BEARER_NONE, "Not yet constructed. Construct() should be called before use.");
+
+       return __isReadOnly;
+}
+
+result
+_NetAccountInfoImpl::ConvertToProfileInfo(void* pProfileHandle) const
+{
+       result r = E_SUCCESS;
+       connection_profile_h profileHandle = static_cast<connection_profile_h>(pProfileHandle);
+       int ret = CONNECTION_ERROR_NONE;
+       connection_cellular_auth_type_e authType = CONNECTION_CELLULAR_AUTH_TYPE_NONE;
+       unique_ptr<char[]> pApn;
+       unique_ptr<char[]> pAuthId;
+       unique_ptr<char[]> pAuthPassword;
+       unique_ptr<char[]> pHomeUrl;
+       unique_ptr<char[]> pLocalAddr;
+       unique_ptr<char[]> pPrimaryDnsAddr;
+       unique_ptr<char[]> pSecondaryDnsAddr;
+       unique_ptr<char[]> pProxyAddr;
+       String proxyAddr;
+
+       SysTryReturnResult(NID_NET, pProfileHandle != null, E_INVALID_ARG, "Profile handle is null.");
+       SysTryReturnResult(NID_NET, ((__bearerType == NET_BEARER_PS) || (__bearerType == NET_BEARER_MMS)), E_INVALID_ARG,
+                       "Invalid argument is used. BearerType is NOT PS. bearerType=%d", __bearerType);
+
+       ret = connection_profile_set_cellular_service_type(profileHandle, CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION);
+       SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                       "A system error has been occurred. The return value from connection_profile_set_cellular_service_type() is %d", ret);
+
+       if (!__accessPointName.IsEmpty())
+       {
+               pApn.reset(_StringConverter::CopyToCharArrayN(__accessPointName));
+               SysTryReturnResult(NID_NET, pApn != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               ret = connection_profile_set_cellular_apn(profileHandle, pApn.get());
+               SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                               "A system error has been occurred. The return value from connection_profile_set_cellular_apn() is %d", ret);
+       }
+
+       if (__authType == NET_NAPAUTH_PAP)
+       {
+               authType = CONNECTION_CELLULAR_AUTH_TYPE_PAP;
+       }
+       else if (__authType == NET_NAPAUTH_CHAP)
+       {
+               authType = CONNECTION_CELLULAR_AUTH_TYPE_CHAP;
+       }
+       else
+       {
+               authType = CONNECTION_CELLULAR_AUTH_TYPE_NONE;
+       }
+
+       if (!__authId.IsEmpty())
+       {
+               pAuthId.reset(_StringConverter::CopyToCharArrayN(__authId));
+               SysTryReturnResult(NID_NET, pAuthId != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       if (!__authPassword.IsEmpty())
+       {
+               pAuthPassword.reset(_StringConverter::CopyToCharArrayN(__authPassword));
+               SysTryReturnResult(NID_NET, pAuthPassword != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       if ((pAuthId != null) && (pAuthPassword != null))
+       {
+               ret = connection_profile_set_cellular_auth_info(profileHandle, authType, pAuthId.get(), pAuthPassword.get());
+               SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                               "A system error has been occurred. The return value from connection_profile_set_cellular_auth_info() is %d", ret);
+       }
+
+       if (!__homeUrl.IsEmpty())
+       {
+               pHomeUrl.reset(_StringConverter::CopyToCharArrayN(__homeUrl));
+               SysTryReturnResult(NID_NET, pHomeUrl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               ret = connection_profile_set_cellular_home_url(profileHandle, pHomeUrl.get());
+               SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                               "A system error has been occurred. The return value from connection_profile_set_cellular_home_url() is %d", ret);
+       }
+
+       if (__localAddressScheme == NET_ADDRESS_SCHEME_STATIC)
+       {
+               SysTryReturnResult(NID_NET, __pLocalAddress != null, E_INVALID_ARG, "Invalid argument is used. Local Addr Scheme is static, but local addr is null.");
+
+               ret = connection_profile_set_ip_config_type(profileHandle, CONNECTION_ADDRESS_FAMILY_IPV4, CONNECTION_IP_CONFIG_TYPE_STATIC);
+               SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                               "A system error has been occurred. The return value from connection_profile_set_ip_config_type() is %d", ret);
+
+               pLocalAddr.reset(_StringConverter::CopyToCharArrayN(__pLocalAddress->ToString()));
+               SysTryReturnResult(NID_NET, pLocalAddr != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               ret = connection_profile_set_ip_address(profileHandle, CONNECTION_ADDRESS_FAMILY_IPV4, pLocalAddr.get());
+               SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                               "A system error has been occurred. The return value from connection_profile_set_ip_address() is %d", ret);
+       }
+       else
+       {
+               ret = connection_profile_set_ip_config_type(profileHandle, CONNECTION_ADDRESS_FAMILY_IPV4, CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
+               SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                               "A system error has been occurred. The return value from connection_profile_set_ip_config_type() is %d", ret);
+       }
+
+       if (__pPrimaryDnsAddress != null)
+       {
+               pPrimaryDnsAddr.reset(_StringConverter::CopyToCharArrayN(__pPrimaryDnsAddress->ToString()));
+               SysTryReturnResult(NID_NET, pPrimaryDnsAddr != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               ret = connection_profile_set_dns_address(profileHandle, 1, CONNECTION_ADDRESS_FAMILY_IPV4, pPrimaryDnsAddr.get());
+               SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                               "A system error has been occurred. The return value from connection_profile_set_dns_address() is %d", ret);
+       }
+
+       if (__pSecondaryDnsAddress != null)
+       {
+               pSecondaryDnsAddr.reset(_StringConverter::CopyToCharArrayN(__pSecondaryDnsAddress->ToString()));
+               SysTryReturnResult(NID_NET, pSecondaryDnsAddr != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               ret = connection_profile_set_dns_address(profileHandle, 2, CONNECTION_ADDRESS_FAMILY_IPV4, pSecondaryDnsAddr.get());
+               SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                               "A system error has been occurred. The return value from connection_profile_set_dns_address() is %d", ret);
+       }
+
+       if (__pProxyAddress != null)
+       {
+               proxyAddr = __pProxyAddress->GetNetEndPoint();
+               if (!proxyAddr.IsEmpty())
+               {
+                       ret = connection_profile_set_proxy_type(profileHandle, CONNECTION_PROXY_TYPE_MANUAL);
+                       SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                                       "A system error has been occurred. The return value from connection_profile_set_proxy_type() is %d", ret);
+
+                       pProxyAddr.reset(_StringConverter::CopyToCharArrayN(proxyAddr));
+                       SysTryReturnResult(NID_NET, pProxyAddr != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                       ret = connection_profile_set_proxy_address(profileHandle, CONNECTION_ADDRESS_FAMILY_IPV4, pProxyAddr.get());
+                       SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                                       "A system error has been occurred. The return value from connection_profile_set_proxy_address() is %d", ret);
+               }
+       }
+
+       return r;
+}
+
+bool
+_NetAccountInfoImpl::Equals(const Object& obj) const
+{
+       const _NetAccountInfoImpl* pRhs = dynamic_cast <const _NetAccountInfoImpl*>(&obj);
+
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       if (__accountId != pRhs->__accountId ||
+               __accountName != pRhs->__accountName ||
+               __accessPointName != pRhs->__accessPointName ||
+               __authType != pRhs->__authType ||
+               __authId != pRhs->__authId ||
+               __authPassword != pRhs->__authPassword ||
+               __homeUrl != pRhs->__homeUrl ||
+               __bearerType != pRhs->__bearerType ||
+               __protocolType != pRhs->__protocolType ||
+               __localAddressScheme != pRhs->__localAddressScheme ||
+               __dnsAddressScheme != pRhs->__dnsAddressScheme ||
+               __isReadOnly != pRhs->__isReadOnly )
+       {
+               return false;
+       }
+
+       if (__pLocalAddress != null && pRhs->__pLocalAddress != null)
+       {
+               if (!__pLocalAddress->Equals(*pRhs->__pLocalAddress))
+               {
+                       return false;
+               }
+       }
+       else if (__pLocalAddress != null || pRhs->__pLocalAddress != null)
+       {
+               return false;
+       }
+
+       if (__pPrimaryDnsAddress != null && pRhs->__pPrimaryDnsAddress != null)
+       {
+               if (!__pPrimaryDnsAddress->Equals(*pRhs->__pPrimaryDnsAddress))
+               {
+                       return false;
+               }
+       }
+       else if (__pPrimaryDnsAddress != null || pRhs->__pPrimaryDnsAddress != null)
+       {
+               return false;
+       }
+
+       if (__pSecondaryDnsAddress != null && pRhs->__pSecondaryDnsAddress != null)
+       {
+               if (!__pSecondaryDnsAddress->Equals(*pRhs->__pSecondaryDnsAddress))
+               {
+                       return false;
+               }
+       }
+       else if (__pSecondaryDnsAddress != null || pRhs->__pSecondaryDnsAddress != null)
+       {
+               return false;
+       }
+
+       if (__pProxyAddress != null && pRhs->__pProxyAddress != null)
+       {
+               if (!__pProxyAddress->Equals(*pRhs->__pProxyAddress))
+               {
+                       return false;
+               }
+       }
+       else if (__pProxyAddress != null || pRhs->__pProxyAddress != null)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+int
+_NetAccountInfoImpl::GetHashCode(void) const
+{
+       int hashCode = _HASH_CODE_INITIAL_VALUE;
+
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __accountId;
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __accountName.GetHashCode();
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __accessPointName.GetHashCode();
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __authType;
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __authId.GetHashCode();
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __authPassword.GetHashCode();
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __homeUrl.GetHashCode();
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __bearerType;
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __protocolType;
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __localAddressScheme;
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __dnsAddressScheme;
+
+       if (__pLocalAddress != null)
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __pLocalAddress->GetHashCode();
+       }
+       else
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode;
+       }
+
+       if (__pPrimaryDnsAddress != null)
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __pPrimaryDnsAddress->GetHashCode();
+       }
+       else
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode;
+       }
+
+       if (__pSecondaryDnsAddress != null)
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __pSecondaryDnsAddress->GetHashCode();
+       }
+       else
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode;
+       }
+
+       if (__pProxyAddress != null)
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __pProxyAddress->GetHashCode();
+       }
+       else
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode;
+       }
+
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + (__isReadOnly ? 0 : 1);
+
+       return hashCode;
+}
+
+NetAccountInfo*
+_NetAccountInfoImpl::CreateNetAccountInfoN(void* pProfileHandle)
+{
+       result r = E_SUCCESS;
+
+       std::unique_ptr<NetAccountInfo> pNetAccountInfo(new (std::nothrow) NetAccountInfo());
+       SysTryReturn(NID_NET, pNetAccountInfo != null, null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unique_ptr<_NetAccountInfoImpl> pNetAccountInfoImpl(new (std::nothrow) _NetAccountInfoImpl());
+       SysTryReturn(NID_NET, pNetAccountInfoImpl != null, null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pNetAccountInfoImpl->Construct(pNetAccountInfo.get(), pProfileHandle);
+       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       pNetAccountInfoImpl.release();
+
+       return pNetAccountInfo.release();
+}
+
+_NetAccountInfoImpl*
+_NetAccountInfoImpl::GetInstance(NetAccountInfo& netAccountInfo)
+{
+       return netAccountInfo.__pNetAccountInfoImpl;
+}
+
+const _NetAccountInfoImpl*
+_NetAccountInfoImpl::GetInstance(const NetAccountInfo& netAccountInfo)
+{
+       return netAccountInfo.__pNetAccountInfoImpl;
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_NetAccountInfoImpl.h b/src/FNet_NetAccountInfoImpl.h
new file mode 100644 (file)
index 0000000..28a4af4
--- /dev/null
@@ -0,0 +1,311 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_NetAccountInfoImpl.h
+ * @brief              This is the header file for the _NetAccountInfoImpl class.
+ */
+
+#ifndef _FNET_INTERNAL_NET_ACCOUNT_INFO_IMPL_H_
+#define _FNET_INTERNAL_NET_ACCOUNT_INFO_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FNetNetTypes.h>
+
+namespace Tizen { namespace Net
+{
+class IpAddress;
+class NetEndPoint;
+class NetAccountInfo;
+class _NetAccountManagerImpl;
+
+class _NetAccountInfoImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       _NetAccountInfoImpl(void);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_NetAccountInfoImpl(void);
+
+       /**
+        * @see                 NetAccountInfo::Construct()
+        */
+       result Construct(const _NetAccountInfoImpl& netAccountInfo);
+
+       /**
+        * @see                 NetAccountInfo::Construct()
+        */
+       result Construct(void);
+
+       /**
+        * Initializes this instance of %_NetAccountInfoImpl with the specified profile instance. @n
+        *
+        * @since 2.1
+        * @return              An error code
+        * @param[in]   pAccountInfo                    A %NetAccountInfo instance
+        * @param[in]   pProfileHandle                  A profile handle
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_STATE This instance has already been constructed.
+        * @exception   E_INVALID_ARG           The specified @c pAccountInfo or  @c pProfileInfo is invalid.
+        */
+       result Construct(NetAccountInfo* pAccountInfo, void* pProfileHandle);
+
+public:
+       /**
+        * @see                 NetAccountInfo::GetAccountId()
+        */
+       NetAccountId GetAccountId(void) const;
+
+       /**
+        * @see                 NetAccountInfo::GetAccountName()
+        */
+       Tizen::Base::String GetAccountName(void) const;
+
+       /**
+        * @see                 NetAccountInfo::SetAccountName()
+        */
+       result SetAccountName(const Tizen::Base::String& accountName);
+
+       /**
+        * @see                 NetAccountInfo::GetProtocolType()
+        */
+       NetProtocolType GetProtocolType(void) const;
+
+       /**
+        * @see                 NetAccountInfo::SetProtocolType()
+        */
+       result SetProtocolType(NetProtocolType netProtocolType);
+
+       /**
+        * @see                 NetAccountInfo::GetAccessPointName()
+        */
+       Tizen::Base::String GetAccessPointName(void) const;
+
+       /**
+        * @see                 NetAccountInfo::SetAccessPointName()
+        */
+       result SetAccessPointName(const Tizen::Base::String& accessPointName);
+
+       /**
+        * @see                 NetAccountInfo::GetLocalAddressScheme()
+        */
+       NetAddressScheme GetLocalAddressScheme(void) const;
+
+       /**
+        * @see                 NetAccountInfo::GetLocalAddress()
+        */
+       const IpAddress* GetLocalAddress(void) const;
+
+       /**
+        * @see                 NetAccountInfo::SetLocalAddress()
+        */
+       result SetLocalAddress(NetAddressScheme localAddrScheme, const IpAddress* pLocalAddress);
+
+       /**
+        * @see                 NetAccountInfo::GetDnsAddressScheme()
+        */
+       NetAddressScheme GetDnsAddressScheme(void) const;
+
+       /**
+        * @see                 NetAccountInfo::GetPrimaryDnsAddress()
+        */
+       const IpAddress* GetPrimaryDnsAddress(void) const;
+
+       /**
+        * @see                 NetAccountInfo::GetSecondaryDnsAddress()
+        */
+       const IpAddress* GetSecondaryDnsAddress(void) const;
+
+       /**
+        * @see                 NetAccountInfo::SetDnsAddress()
+        */
+       result SetDnsAddress(NetAddressScheme dnsAddrScheme, const IpAddress* pPrimaryDnsAddress, const IpAddress* pSecondaryDnsAddress);
+
+       /**
+        * @see                 NetAccountInfo::GetProxyAddress()
+        */
+       const NetEndPoint* GetProxyAddress(void) const;
+
+       /**
+        * @see                 NetAccountInfo::SetProxyAddress()
+        */
+       result SetProxyAddress(const NetEndPoint* pProxyEndPoint);
+
+       /**
+        * @see                 NetAccountInfo::GetAuthenticationInfo()
+        */
+       result GetAuthenticationInfo(NetNapAuthType& authenticationType, Tizen::Base::String& id, Tizen::Base::String& password) const;
+
+       /**
+        * @see                 NetAccountInfo::SetAuthenticationInfo()
+        */
+       result SetAuthenticationInfo(NetNapAuthType authenticationType, const Tizen::Base::String& id, const Tizen::Base::String& password);
+
+       /**
+        * @see                 NetAccountInfo::GetBearerType()
+        */
+       NetBearerType GetBearerType(void) const;
+
+       /**
+        * @see                 NetAccountInfo::GetHomeUrl()
+        */
+       Tizen::Base::String GetHomeUrl(void) const;
+
+       /**
+        * @see                 NetAccountInfo::SetHomeUrl()
+        */
+       void SetHomeUrl(const Tizen::Base::String& homeUrl);
+
+       /**
+        * @see                 NetAccountInfo::GetMaximumLengthOfId()
+        */
+       int GetMaximumLengthOfId(void) const;
+
+       /**
+        * @see                 NetAccountInfo::GetMaximumLengthOfPassword()
+        */
+       int GetMaximumLengthOfPassword(void) const;
+
+       /**
+        * @see                 NetAccountInfo::GetMaximumLengthOfAccountName()
+        */
+       int GetMaximumLengthOfAccountName(void) const;
+
+       /**
+        * @see                 NetAccountInfo::IsReadOnly()
+        */
+       bool IsReadOnly(void) const;
+
+       result ConvertToProfileInfo(void* pProfileHandle) const;
+
+       /**
+        * @see                 NetAccountInfo::Equals()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * @see                 NetAccountInfo::GetHashCode()
+        */
+       virtual int GetHashCode(void) const;
+
+public:
+       static NetAccountInfo* CreateNetAccountInfoN(void* pProfileHandle);
+
+public:
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _NetAccountInfoImpl
+     * @param[in]   netAccountInfo            An instance of NetAccountInfo
+     */
+       static _NetAccountInfoImpl* GetInstance(NetAccountInfo& netAccountInfo);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _NetAccountInfoImpl
+     * @param[in]   netAccountInfo     An instance of NetAccountInfo
+     */
+       static const _NetAccountInfoImpl* GetInstance(const NetAccountInfo& netAccountInfo);
+
+private:
+       /**
+        * Sets the bearer type.
+        *
+        * @since 2.1
+        *
+        * @return              An error code
+        * @param[in]   bearerType                      The type of the bearer
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance has not been constructed as yet.
+        * @remarks             If this method fails, the state of this instance does not change.
+        * @see                 GetBearerType()
+        */
+       result SetBearerType(NetBearerType bearerType);
+
+       /**
+        * Sets the account Id.
+        *
+        * @since 2.1
+        *
+        * @return              An error code
+        * @param[in]   accountId                       The account id
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_STATE                 This instance has not been constructed as yet.
+        * @remarks             If this method fails, the state of this instance does not change.
+        * @see                 GetAccountId()
+        */
+       result SetAccountId(NetAccountId accountId);
+
+private:
+       /**
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of _NetAccountInfoImpl
+        */
+       _NetAccountInfoImpl(const _NetAccountInfoImpl& rhs);
+
+       /**
+        * This is the assignment operator for this class. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of _NetAccountInfoImpl
+        */
+       _NetAccountInfoImpl& operator =(const _NetAccountInfoImpl& rhs);
+
+private:
+       NetAccountId __accountId;
+       Tizen::Base::String __accountName;
+       Tizen::Base::String __accessPointName;
+       NetNapAuthType  __authType;
+       Tizen::Base::String __authId;
+       Tizen::Base::String __authPassword;
+       Tizen::Base::String __homeUrl;
+       NetBearerType __bearerType;
+       NetProtocolType __protocolType;
+       NetAddressScheme __localAddressScheme;
+       NetAddressScheme __dnsAddressScheme;
+       std::unique_ptr<IpAddress> __pLocalAddress;
+       std::unique_ptr<IpAddress> __pPrimaryDnsAddress;
+       std::unique_ptr<IpAddress> __pSecondaryDnsAddress;
+       std::unique_ptr<NetEndPoint> __pProxyAddress;
+       bool __isReadOnly;
+
+       friend class _NetAccountManagerImpl;
+}; // _NetAccountInfoImpl
+
+} } //Tizen::Net
+
+#endif // _FNET_INTERNAL_NET_ACCOUNT_INFO_IMPL_H_
diff --git a/src/FNet_NetAccountManagerImpl.cpp b/src/FNet_NetAccountManagerImpl.cpp
new file mode 100644 (file)
index 0000000..8f9e5ba
--- /dev/null
@@ -0,0 +1,826 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNetNetAccountManager.cpp
+ * @brief              This is the implementation for the _NetAccountManagerImpl class.
+ */
+
+#include <dlfcn.h>
+#include <net_connection.h>
+#include <FNetNetAccountInfo.h>
+#include <FNetNetAccountManager.h>
+#include <FNetWifiWifiNetAccountInfo.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FNet_NetTypes.h"
+#include "FNet_NetAccountInfoImpl.h"
+#include "FNet_NetAccountManagerImpl.h"
+#include "FNet_NetConnectionManagerImpl.h"
+#include "FNet_SystemNetConnection.h"
+#include "FNet_NetAccountDatabase.h"
+#include "FNetWifi_WifiNetAccountInfoImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Net::Wifi;
+
+namespace Tizen { namespace Net {
+
+static const char _WIFI_LIBRARY_NAME[] = "libosp-wifi.so";
+
+_NetAccountManagerImpl::_NetAccountManagerImpl(void)
+       : __pConnectionHandle(null)
+{
+}
+
+_NetAccountManagerImpl::~_NetAccountManagerImpl(void)
+{
+}
+
+result
+_NetAccountManagerImpl::Construct(void)
+{
+       result r = E_SUCCESS;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = null;
+
+       SysAssertf(__pConnectionHandle == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       _SystemNetConnection::InitializeNetworkFramework();
+
+       ret = connection_create(&connectionHandle);
+       SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                       "A system error has been occurred. The return value from connection_create() is %d", GetErrorMessage(E_SYSTEM), ret);
+
+       __pConnectionHandle.reset(connectionHandle);
+
+       return r;
+}
+
+NetAccountId
+_NetAccountManagerImpl::CreateNetAccount(NetAccountInfo& netAccountInfo)
+{
+       result r = E_SUCCESS;
+       _NetAccountInfoImpl* pInfoImpl = _NetAccountInfoImpl::GetInstance(netAccountInfo);
+       NetAccountId accountId = INVALID_HANDLE;
+       String profileName;
+       bool isCreated = false;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = __pConnectionHandle.get();
+       connection_profile_h profileHandle = null;
+
+       SysAssertf(__pConnectionHandle != null, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturn(NID_NET, pInfoImpl != null, INVALID_HANDLE, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. Network account info is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_NET, !netAccountInfo.GetAccountName().IsEmpty(),
+                       INVALID_HANDLE, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. accountName is an empty string.", GetErrorMessage(E_INVALID_ARG));
+
+       unique_ptr<IList, _CollectionDeleter> pProfileNamesBefore(_NetAccountManagerImpl::GetAppProfileNamesN());
+       SysTryReturn(NID_NET, pProfileNamesBefore != null, INVALID_HANDLE, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unique_ptr<char[]> pAccountName(_StringConverter::CopyToCharArrayN(netAccountInfo.GetAccountName()));
+       SysTryReturn(NID_NET, pAccountName != null, INVALID_HANDLE, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       ret = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, pAccountName.get(), &profileHandle);
+       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, INVALID_HANDLE,     E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_profile_create() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+
+       unique_ptr<void, _ProfileDeleter> pProfileHandle(profileHandle);
+       r = pInfoImpl->ConvertToProfileInfo(profileHandle);
+       SysTryReturn(NID_NET, r == E_SUCCESS, INVALID_HANDLE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       ret = connection_add_profile(connectionHandle, profileHandle);
+       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, INVALID_HANDLE, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_add_profile() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+
+       unique_ptr<IList, _CollectionDeleter> pProfileNamesAfter(_NetAccountManagerImpl::GetAppProfileNamesN());
+       SysTryReturn(NID_NET, pProfileNamesAfter != null, INVALID_HANDLE, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       unique_ptr<IEnumerator> pEnum(pProfileNamesAfter->GetEnumeratorN());
+       SysTryReturn(NID_NET, pEnum != null, INVALID_HANDLE, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               String* pProfileName = null;
+
+               pProfileName = dynamic_cast<String*>(pEnum->GetCurrent());
+               if ((pProfileName != null) && (!pProfileName->IsEmpty()))
+               {
+                       if (!pProfileNamesBefore->Contains(*pProfileName))
+                       {
+                               SysLog(NID_NET, "ProfileName[%ls] is not found before, so it is a new profile name.", pProfileName->GetPointer());
+                               isCreated = true;
+                               profileName = *pProfileName;
+
+                               break;
+                       }
+               }
+       }
+
+       SysTryReturn(NID_NET, isCreated, INVALID_HANDLE, E_SYSTEM,
+                       "[%s] A system error has been occurred. New account is not found.", GetErrorMessage(E_SYSTEM));
+       SysTryReturn(NID_NET, !profileName.IsEmpty(), INVALID_HANDLE, E_SYSTEM,
+                       "[%s] A system error has been occurred. The profileName of new account is an empty string.", GetErrorMessage(E_SYSTEM));
+
+       r = _NetAccountDatabase::AddAccount(netAccountInfo.GetAccountName(), profileName, _NET_ACCOUNT_OWNER_THIS, accountId);
+       SysTryReturn(NID_NET, r == E_SUCCESS, INVALID_HANDLE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = pInfoImpl->SetAccountId(accountId);
+       SysTryReturn(NID_NET, r == E_SUCCESS, INVALID_HANDLE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       ClearLastResult();
+
+       SysLog( NID_NET, "CreateNetAccount() has been succeeded with accountId:%d, accountName:%ls, profileName:%ls",
+                       netAccountInfo.GetAccountId(), netAccountInfo.GetAccountName().GetPointer(), profileName.GetPointer());
+
+       return accountId;
+}
+
+result
+_NetAccountManagerImpl::DeleteNetAccount(NetAccountId netAccountId)
+{
+       result r = E_SUCCESS;
+       String profileName;
+       bool isReadOnly = true;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = __pConnectionHandle.get();
+
+       SysLog(NID_NET, "DeleteNetAccount() has been called with accountId:%d", netAccountId);
+
+       SysAssertf(__pConnectionHandle != null, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturnResult(NID_NET, netAccountId > 0, E_INVALID_ACCOUNT,
+                       "Invalid network account. accountId=%d", netAccountId);
+
+       isReadOnly = _NetAccountDatabase::IsReadOnly(netAccountId);
+       r = GetLastResult();
+       SysTryReturnResult(NID_NET, r != E_OUT_OF_MEMORY, r, "Propagating.");
+       SysTryReturnResult(NID_NET, !isReadOnly, E_INVALID_OPERATION, "Not allowed on the specified network account.");
+
+       r = _NetAccountDatabase::GetProfileName(netAccountId, profileName);
+       SysTryReturnResult(NID_NET, r != E_OUT_OF_MEMORY, r, "Propagating.");
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_INVALID_ACCOUNT, "Invalid network account. accountId=%d", netAccountId);
+
+       unique_ptr<void, _ProfileDeleter> pProfileHandle(_NetAccountManagerImpl::GetPsProfileHandleN(profileName));
+       SysTryReturnResult(NID_NET, pProfileHandle != null, E_INVALID_ACCOUNT,
+                       "Invalid network account. accountId=%d", netAccountId);
+
+       ret = connection_remove_profile(connectionHandle, pProfileHandle.get());
+       SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                       "A system error has been occurred. The return value from connection_remove_profile() is %d", ret);
+
+       r = _NetAccountDatabase::RemoveAccountByAccountId(netAccountId);
+       SysTryReturnResult(NID_NET, r != E_OUT_OF_MEMORY, r, "Propagating.");
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                       "A system error has been occurred. Failed to remove the account.");
+
+       return r;
+}
+
+result
+_NetAccountManagerImpl::UpdateNetAccount(const NetAccountInfo& netAccountInfo)
+{
+       result r = E_SUCCESS;
+       String profileName;
+       bool isReadOnly = true;
+       const _NetAccountInfoImpl* pInfoImpl = _NetAccountInfoImpl::GetInstance(netAccountInfo);
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = (connection_h) __pConnectionHandle.get();
+
+       SysAssertf(__pConnectionHandle != null, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturnResult(NID_NET, pInfoImpl != null, E_INVALID_ARG,
+                       "Invalid argument is used. Network account info is invalid.");
+       SysTryReturnResult(NID_NET, netAccountInfo.GetAccountId() > 0, E_INVALID_ARG,
+                       "Invalid argument is used. accountId=%d", netAccountInfo.GetAccountId());
+       SysTryReturnResult(NID_NET, !netAccountInfo.GetAccountName().IsEmpty(), E_INVALID_ARG,
+                       "Invalid argument is used. accountName is an empty string.");
+
+       isReadOnly = _NetAccountDatabase::IsReadOnly(netAccountInfo.GetAccountId());
+       r = GetLastResult();
+       SysTryReturnResult(NID_NET, r != E_OUT_OF_MEMORY, r, "Propagating.");
+       SysTryReturnResult(NID_NET, !isReadOnly, E_INVALID_OPERATION,
+                       "Not allowed on the specified network account.");
+
+       r = _NetAccountDatabase::GetProfileName(netAccountInfo.GetAccountId(), profileName);
+       SysTryReturnResult(NID_NET, r != E_OUT_OF_MEMORY, r, "Propagating.");
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_INVALID_ARG,
+                       "Invalid argument is used. accountId=%d.", netAccountInfo.GetAccountId());
+
+       unique_ptr<void, _ProfileDeleter> pProfileHandle(_NetAccountManagerImpl::GetPsProfileHandleN(profileName));
+       SysTryReturnResult(NID_NET, pProfileHandle != null, E_INVALID_ACCOUNT,
+                       "Invalid network account. accountId=%d", netAccountInfo.GetAccountId());
+
+       r = pInfoImpl->ConvertToProfileInfo(pProfileHandle.get());
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       ret = connection_update_profile(connectionHandle, pProfileHandle.get());
+       SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                       "A system error has been occurred. The return value from connection_update_profile() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+
+       r = _NetAccountDatabase::UpdateAccountName(netAccountInfo.GetAccountId(), netAccountInfo.GetAccountName());
+       SysTryReturnResult(NID_NET, r != E_OUT_OF_MEMORY, r, "Propagating.");
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM,
+                       "A system error has been occurred. Failed to update accountName.");
+
+       return r;
+}
+
+NetAccountInfo*
+_NetAccountManagerImpl::GetNetAccountInfoN(NetAccountId netAccountId) const
+{
+       result r = E_SUCCESS;
+       NetAccountInfo* pInfo = null;
+       connection_profile_h profileHandle = null;
+       unique_ptr<void, _ProfileDeleter> pProfileHandle;
+
+       SysAssertf(__pConnectionHandle != null, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturn(NID_NET, netAccountId > 0, null, E_INVALID_ACCOUNT,
+                       "[%s] Invalid network account. accountId=%d.", GetErrorMessage(E_INVALID_ACCOUNT), netAccountId);
+
+       if (netAccountId == _DEFAULT_WIFI_ACCOUNT_ID)
+       {
+               profileHandle = _NetAccountManagerImpl::GetWifiProfileHandleN();
+               SysTryReturn(NID_NET, profileHandle != null, null, E_INVALID_ACCOUNT,
+                               "[%s] WiFi account is NOT found.",GetErrorMessage(E_INVALID_ACCOUNT));
+               pProfileHandle.reset(profileHandle);
+
+               pInfo = _NetAccountManagerImpl::CreateWifiNetAccountInfoN(
+                               profileHandle);
+               r = GetLastResult();
+               SysTryReturn(NID_NET, pInfo != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+       else if (netAccountId == _DEFAULT_WIFI_DIRECT_ACCOUNT_ID)
+       {
+               SysLogException(NID_NET, E_INVALID_ACCOUNT,
+                               "[%s] Wifi direct account information is not found.", GetErrorMessage(E_INVALID_ACCOUNT));
+
+               return null;
+       }
+       else if (netAccountId == _DEFAULT_USB_ACCOUNT_ID)
+       {
+               SysLogException(NID_NET, E_INVALID_ACCOUNT,
+                               "[%s] USB account information is not found.", GetErrorMessage(E_INVALID_ACCOUNT));
+
+               return null;
+       }
+       else
+       {
+               String profileName;
+
+               r = _NetAccountDatabase::GetProfileName(netAccountId, profileName);
+               SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               profileHandle = _NetAccountManagerImpl::GetPsProfileHandleN(profileName);
+               SysTryReturn(NID_NET, profileHandle != null, null, E_INVALID_ACCOUNT,
+                               "[%s] PS account is NOT found.", GetErrorMessage(E_INVALID_ACCOUNT));
+               pProfileHandle.reset(profileHandle);
+
+               pInfo = _NetAccountInfoImpl::CreateNetAccountInfoN(profileHandle);
+               r = GetLastResult();
+               SysTryReturn(NID_NET, pInfo != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       ClearLastResult();
+
+       return pInfo;
+}
+
+IListT<NetAccountId>*
+_NetAccountManagerImpl::GetNetAccountIdsN(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pConnectionHandle != null, "Not yet constructed. Construct() should be called before use.");
+
+       return _NetAccountDatabase::GetAccountIdsN();
+}
+
+IList*
+_NetAccountManagerImpl::GetNetAccountNamesN(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pConnectionHandle != null, "Not yet constructed. Construct() should be called before use.");
+
+       return _NetAccountDatabase::GetAccountNamesN();
+}
+
+NetAccountId
+_NetAccountManagerImpl::GetNetAccountId(const String& netAccountName) const
+{
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       NetAccountId accountId = INVALID_HANDLE;
+
+       SysAssertf(__pConnectionHandle != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = _NetAccountDatabase::GetAccountIdByAccountName(netAccountName, accountId);
+       SysTryReturn(NID_NET, r == E_SUCCESS, INVALID_HANDLE, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. AccountName[%ls] is not found.",
+                       GetErrorMessage(E_INVALID_ARG), netAccountName.GetPointer());
+
+       SysLog(NID_NET, "GetNetAccountId() has been succeeded with accountId:%d", accountId);
+
+       return accountId;
+}
+
+NetAccountId
+_NetAccountManagerImpl::GetNetAccountId(NetBearerType netBearerType) const
+{
+       ClearLastResult();
+
+       NetAccountId accountId = INVALID_HANDLE;
+
+       SysAssertf(__pConnectionHandle != null, "Not yet constructed. Construct() should be called before use.");
+
+       if (netBearerType == NET_BEARER_PS)
+       {
+               accountId = _DEFAULT_PS_ACCOUNT_ID;
+       }
+       else if (netBearerType == NET_BEARER_MMS)
+       {
+               accountId = _DEFAULT_MMS_ACCOUNT_ID;
+       }
+       else if (netBearerType == NET_BEARER_WIFI)
+       {
+               accountId = _DEFAULT_WIFI_ACCOUNT_ID;
+       }
+       else if (netBearerType == NET_BEARER_WIFI_DIRECT)
+       {
+               accountId = _DEFAULT_WIFI_DIRECT_ACCOUNT_ID;
+       }
+       else if (netBearerType == NET_BEARER_USB)
+       {
+               accountId = _DEFAULT_USB_ACCOUNT_ID;
+       }
+       else
+       {
+               SysLogException(NID_NET, E_INVALID_ARG,
+                               "[%s] Invalid argument is used. bearerType=%d", GetErrorMessage(E_INVALID_ARG), netBearerType);
+       }
+
+       return accountId;
+}
+
+NetPreferenceType
+_NetAccountManagerImpl::GetNetPreference(void) const
+{
+       _NetConnectionManagerImpl* pConnectionManager = _NetConnectionManagerImpl::GetInstance();
+
+       SysAssertf(__pConnectionHandle != null, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturn(NID_NET, pConnectionManager != null, NET_WIFI_FIRST, E_SYSTEM,
+                       "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+       return pConnectionManager->GetNetPreference();
+}
+
+result
+_NetAccountManagerImpl::SetNetPreference(NetPreferenceType netPreference)
+{
+       result r = E_SUCCESS;
+
+       _NetConnectionManagerImpl* pConnectionManager = _NetConnectionManagerImpl::GetInstance();
+
+       SysAssertf(__pConnectionHandle != null, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturnResult(NID_NET, pConnectionManager != null, E_SYSTEM, "A system error has been occurred.");
+
+       r = pConnectionManager->SetNetPreference(netPreference);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+_NetAccountManagerImpl*
+_NetAccountManagerImpl::GetInstance(NetAccountManager& netAccountManager)
+{
+       return netAccountManager.__pNetAccountManagerImpl;
+}
+
+const _NetAccountManagerImpl*
+_NetAccountManagerImpl::GetInstance(const NetAccountManager& netAccountManager)
+{
+       return netAccountManager.__pNetAccountManagerImpl;
+}
+
+void*
+_NetAccountManagerImpl::GetPsProfileHandleN(const String& profileName)
+{
+       ClearLastResult();
+
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = null;
+       connection_profile_iterator_h iterator = null;
+       connection_profile_h profileHandle = null;
+       connection_profile_h matchingProfileHandle = null;
+
+       SysLog(NID_NET, "GetPsProfileHandleN() has been called with profileName:%ls", profileName.GetPointer());
+
+       SysTryReturn(NID_NET, !profileName.IsEmpty(), null, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. profileName is an empty string.", GetErrorMessage(E_INVALID_ARG));
+
+       ret = connection_create(&connectionHandle);
+       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_create() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+       unique_ptr<void, _ConnectionDeleter> pConnectionHandle(connectionHandle);
+
+       ret = connection_get_profile_iterator(connectionHandle, CONNECTION_ITERATOR_TYPE_REGISTERED, &iterator);
+       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_get_profile_iterator() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+       unique_ptr<void, _ProfileIteratorDeleter> pIterator(iterator);
+
+       ret = connection_profile_iterator_next(iterator, &profileHandle);
+       while ((ret == CONNECTION_ERROR_NONE) && (profileHandle != null))
+       {
+               char* pTempProfileName = null;
+               String tempProfileName;
+
+               ret = connection_profile_get_name(profileHandle, &pTempProfileName);
+               SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                               "[%s] A system error has been occurred. The return value from connection_profile_get_name() is %d",
+                               GetErrorMessage(E_SYSTEM), ret);
+
+               tempProfileName = String(pTempProfileName);
+               free(pTempProfileName);
+
+               if (profileName.Equals(tempProfileName))
+               {
+                       ret = connection_profile_clone(&matchingProfileHandle, profileHandle);
+                       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                                       "[%s] A system error has been occurred. The return value from connection_profile_clone() is %d",
+                                       GetErrorMessage(E_SYSTEM), ret);
+
+                       break;
+               }
+
+               profileHandle = null;
+               ret = connection_profile_iterator_next(iterator, &profileHandle);
+       }
+
+       SysTryReturn(NID_NET, matchingProfileHandle != null, null, E_INVALID_ACCOUNT,
+                       "[%s] Matching profileName is not found. profileName=%ls", GetErrorMessage(E_INVALID_ACCOUNT), profileName.GetPointer());
+
+       return matchingProfileHandle;
+}
+
+void*
+_NetAccountManagerImpl::GetWifiProfileHandleN(void)
+{
+       ClearLastResult();
+
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = null;
+       connection_profile_iterator_h iterator = null;
+       connection_profile_h profileHandle = null;
+       connection_profile_h matchingProfileHandle = null;
+       connection_profile_type_e profileType = CONNECTION_PROFILE_TYPE_CELLULAR;
+
+       ret = connection_create(&connectionHandle);
+       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_create() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+       unique_ptr<void, _ConnectionDeleter> pConnectionHandle(connectionHandle);
+
+       ret = connection_get_profile_iterator(connectionHandle, CONNECTION_ITERATOR_TYPE_CONNECTED, &iterator);
+       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_get_profile_iterator() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+       unique_ptr<void, _ProfileIteratorDeleter> pIterator(iterator);
+
+       ret = connection_profile_iterator_next(iterator, &profileHandle);
+       while ((ret == CONNECTION_ERROR_NONE) && (profileHandle != null))
+       {
+               ret = connection_profile_get_type(profileHandle, &profileType);
+               SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                               "[%s] A system error has been occurred. The return value from connection_profile_get_type() is %d",
+                               GetErrorMessage(E_SYSTEM), ret);
+
+               if (profileType == CONNECTION_PROFILE_TYPE_WIFI)
+               {
+                       SysLog(NID_NET, "Connected WiFi profile is found.");
+                       ret = connection_profile_clone(&matchingProfileHandle,
+                                       profileHandle);
+                       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                                       "[%s] A system error has been occurred. The return value from connection_profile_clone() is %d",
+                                       GetErrorMessage(E_SYSTEM), ret);
+
+                       break;
+               }
+
+               profileHandle = null;
+               ret = connection_profile_iterator_next(iterator, &profileHandle);
+       }
+
+       SysTryReturn(NID_NET, matchingProfileHandle != null, null, E_INVALID_ACCOUNT,
+                       "[%s] Active Wi-Fi profile is not found.", GetErrorMessage(E_INVALID_ACCOUNT));
+
+       return matchingProfileHandle;
+}
+
+String
+_NetAccountManagerImpl::GetInternetProfileName(void)
+{
+       ClearLastResult();
+
+       String profileName;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = null;
+       connection_profile_iterator_h iterator = null;
+       connection_profile_h profileHandle = null;
+       connection_profile_type_e profileType = CONNECTION_PROFILE_TYPE_WIFI;
+
+       ret = connection_create(&connectionHandle);
+       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_create() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+       unique_ptr<void, _ConnectionDeleter> pConnectionHandle(connectionHandle);
+
+       ret = connection_get_profile_iterator(connectionHandle,
+                       CONNECTION_ITERATOR_TYPE_REGISTERED, &iterator);
+       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_get_profile_iterator() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+       unique_ptr<void, _ProfileIteratorDeleter> pIterator(iterator);
+
+       ret = connection_profile_iterator_next(iterator, &profileHandle);
+       while ((ret == CONNECTION_ERROR_NONE) && (profileHandle != null))
+       {
+               char* pProfileName = null;
+
+               ret = connection_profile_get_type(profileHandle, &profileType);
+               SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+                               "[%s] A system error has been occurred. The return value from connection_profile_get_type() is %d",
+                               GetErrorMessage(E_SYSTEM), ret);
+
+               if (profileType == CONNECTION_PROFILE_TYPE_CELLULAR)
+               {
+                       connection_cellular_service_type_e serviceType = CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN;
+
+                       ret = connection_profile_get_cellular_service_type(profileHandle, &serviceType);
+                       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+                                       "[%s] A system error has been occurred. The return value from connection_profile_get_cellular_service_type() is %d",
+                                       GetErrorMessage(E_SYSTEM), ret);
+
+                       ret = connection_profile_get_name(profileHandle, &pProfileName);
+                       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+                                       "[%s] A system error has been occurred. The return value from connection_profile_get_name() is %d",
+                                       GetErrorMessage(E_SYSTEM), ret);
+
+                       profileName = String(pProfileName);
+                       free(pProfileName);
+
+                       if ((serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET)
+                                       || (serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET))
+                       {
+                               SysLog(NID_NET, "Internet profile is found.");
+                               break;
+                       }
+                       else
+                       {
+                               profileName.Clear();
+                       }
+               }
+               else
+               {
+                       SysLog(NID_NET, "Ignore non-cellular profile.");
+               }
+
+               profileHandle = null;
+               ret = connection_profile_iterator_next(iterator, &profileHandle);
+       }
+
+       SysTryReturn(NID_NET, !profileName.IsEmpty(), profileName, E_INVALID_ACCOUNT,
+                       "[%s] Internet profile is not found.", GetErrorMessage(E_INVALID_ACCOUNT));
+
+       SysLog(NID_NET, "GetInternetProfileName() has been succeeded with profile:%ls", profileName.GetPointer());
+
+       return profileName;
+}
+
+String
+_NetAccountManagerImpl::GetMmsProfileName(void)
+{
+       ClearLastResult();
+
+       String profileName;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = null;
+       connection_profile_iterator_h iterator = null;
+       connection_profile_h profileHandle = null;
+       connection_profile_type_e profileType = CONNECTION_PROFILE_TYPE_WIFI;
+
+       ret = connection_create(&connectionHandle);
+       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_create() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+       unique_ptr<void, _ConnectionDeleter> pConnectionHandle(connectionHandle);
+
+       ret = connection_get_profile_iterator(connectionHandle,
+                       CONNECTION_ITERATOR_TYPE_REGISTERED, &iterator);
+       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_get_profile_iterator() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+       unique_ptr<void, _ProfileIteratorDeleter> pIterator(iterator);
+
+       ret = connection_profile_iterator_next(iterator, &profileHandle);
+       while ((ret == CONNECTION_ERROR_NONE) && (profileHandle != null))
+       {
+               char* pProfileName = null;
+
+               ret = connection_profile_get_type(profileHandle, &profileType);
+               SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+                               "[%s] A system error has been occurred. The return value from connection_profile_get_type() is %d",
+                               GetErrorMessage(E_SYSTEM), ret);
+
+               if (profileType == CONNECTION_PROFILE_TYPE_CELLULAR)
+               {
+                       connection_cellular_service_type_e serviceType = CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN;
+
+                       ret = connection_profile_get_cellular_service_type(profileHandle,
+                                       &serviceType);
+                       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+                                       "[%s] A system error has been occurred. The return value from connection_profile_get_cellular_service_type() is %d",
+                                       GetErrorMessage(E_SYSTEM), ret);
+
+                       ret = connection_profile_get_name(profileHandle, &pProfileName);
+                       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+                                       "[%s] A system error has been occurred. The return value from connection_profile_get_name() is %d",
+                                       GetErrorMessage(E_SYSTEM), ret);
+
+                       profileName = String(pProfileName);
+                       free(pProfileName);
+
+                       if ((serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_MMS)
+                                       || (serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS))
+                       {
+                               SysLog(NID_NET, "MMS profile is found.");
+                               break;
+                       }
+                       else
+                       {
+                               profileName.Clear();
+                       }
+               }
+               else
+               {
+                       SysLog(NID_NET, "Ignore non-cellular profile.");
+               }
+
+               profileHandle = null;
+               ret = connection_profile_iterator_next(iterator, &profileHandle);
+       }
+
+       SysTryReturn(NID_NET, !profileName.IsEmpty(), profileName, E_INVALID_ACCOUNT,
+                       "[%s] MMS profile is not found.", GetErrorMessage(E_INVALID_ACCOUNT));
+
+       SysLog(NID_NET, "GetMmsProfileName() has been succeeded with profile:%ls", profileName.GetPointer());
+
+       return profileName;
+}
+
+IList*
+_NetAccountManagerImpl::GetAppProfileNamesN(void)
+{
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = null;
+       connection_profile_iterator_h iterator = null;
+       connection_profile_h profileHandle = null;
+       connection_profile_type_e profileType = CONNECTION_PROFILE_TYPE_WIFI;
+
+       ret = connection_create(&connectionHandle);
+       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_create() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+       unique_ptr<void, _ConnectionDeleter> pConnectionHandle(connectionHandle);
+
+       unique_ptr<ArrayList, _CollectionDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_NET, pList != null, null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pList->Construct();
+       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       ret = connection_get_profile_iterator(connectionHandle, CONNECTION_ITERATOR_TYPE_REGISTERED, &iterator);
+       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_get_profile_iterator() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+       unique_ptr<void, _ProfileIteratorDeleter> pIterator(iterator);
+
+       ret = connection_profile_iterator_next(iterator, &profileHandle);
+       while ((ret == CONNECTION_ERROR_NONE) && (profileHandle != null))
+       {
+               char* pProfileName = null;
+
+               ret = connection_profile_get_type(profileHandle, &profileType);
+               SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                               "[%s] A system error has been occurred. The return value from connection_profile_get_type() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+
+               if (profileType == CONNECTION_PROFILE_TYPE_CELLULAR)
+               {
+                       connection_cellular_service_type_e serviceType = CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN;
+
+                       ret = connection_profile_get_cellular_service_type(profileHandle, &serviceType);
+                       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                                       "[%s] A system error has been occurred. The return value from connection_profile_get_cellular_service_type() is %d",
+                                       GetErrorMessage(E_SYSTEM), ret);
+
+                       if (serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION)
+                       {
+                               ret = connection_profile_get_name(profileHandle, &pProfileName);
+                               SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                                               "[%s] A system error has been occurred. The return value from connection_profile_get_name() is %d",
+                                               GetErrorMessage(E_SYSTEM), ret);
+
+                               unique_ptr<String> pProfileNameString(new (std::nothrow) String(pProfileName));
+                               free(pProfileName);
+                               SysTryReturn(NID_NET, pProfileNameString != null, null, E_OUT_OF_MEMORY,
+                                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                               r = pList->Add(*pProfileNameString);
+                               SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+                               pProfileNameString.release();
+                       }
+                       else
+                       {
+                               SysLog(NID_NET, "Ignore non-app profile.");
+                       }
+               }
+               else
+               {
+                       SysLog(NID_NET, "Ignore non-cellular profile.");
+               }
+
+               profileHandle = null;
+               ret = connection_profile_iterator_next(iterator, &profileHandle);
+       }
+
+       SysLog(NID_NET, "GetAppProfileNamesN() has been succeeded with profiles count:%d", pList->GetCount());
+
+       return pList.release();
+}
+
+NetAccountInfo*
+_NetAccountManagerImpl::CreateWifiNetAccountInfoN(void* pProfileInfo)
+{
+       void* pHandle = null;
+       NetAccountInfo* pWifiNetAccountInfo = null;
+       WifiNetAccountInfo*(*pFunction)(void* pProfileInfo) = null;
+
+       pHandle = dlopen(_WIFI_LIBRARY_NAME, RTLD_LAZY);
+       SysTryReturn(NID_NET, pHandle != null, null, E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to open wifi library.");
+
+       pFunction = reinterpret_cast<WifiNetAccountInfo*(*)(void* pProfileInfo)>(dlsym(pHandle, "_WifiNetAccountInfoImpl_CreateWifiNetAccountInfoN"));
+       SysTryCatch(NID_NET, pFunction != null, , E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to find a symbol.", GetErrorMessage(E_SYSTEM));
+
+       pWifiNetAccountInfo = pFunction(pProfileInfo);
+       SysTryCatch(NID_NET, pWifiNetAccountInfo != null, , E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to create the instance.", GetErrorMessage(E_SYSTEM));
+
+       dlclose(pHandle);
+
+       return pWifiNetAccountInfo;
+
+CATCH:
+       dlclose(pHandle);
+
+       return null;
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_NetAccountManagerImpl.h b/src/FNet_NetAccountManagerImpl.h
new file mode 100644 (file)
index 0000000..f9fdbbc
--- /dev/null
@@ -0,0 +1,170 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_NetAccountManagerImpl.cpp
+ * @brief              This is the implementation for the %_NetAccountManagerImpl class.
+ */
+
+#ifndef _FNET_INTERNAL_NET_ACCOUNT_MANAGER_IMPL_H_
+#define _FNET_INTERNAL_NET_ACCOUNT_MANAGER_IMPL_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FNetNetTypes.h>
+#include "FNet_NetUtility.h"
+
+namespace Tizen { namespace Base
+{
+class String;
+} } // Tizen::Base
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net
+{
+class NetAccountInfo;
+class NetAccountManager;
+class _PsSystemNetConnection;
+
+class _NetAccountManagerImpl
+       : public Tizen::Base::Object
+{
+public :
+       /**
+        * This is the default constructor for this class.
+        *
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       _NetAccountManagerImpl(void);
+
+       /**
+        * This is the destructor for this class.
+        */
+       ~_NetAccountManagerImpl(void);
+
+       /**
+        * @see                 NetAccountManager::Construct()
+        */
+       result Construct(void);
+
+       /**
+        * @see                 NetAccountManager::CreateNetAccount()
+        */
+       NetAccountId CreateNetAccount(NetAccountInfo& netAccountInfo);
+
+       /**
+        * @see                 NetAccountManager::DeleteNetAccount()
+        */
+       result DeleteNetAccount(NetAccountId netAccountId);
+
+       /**
+        * @see                 NetAccountManager::UpdateNetAccount()
+        */
+       result UpdateNetAccount(const NetAccountInfo& netAccountInfo);
+
+       /**
+        * @see                 NetAccountManager::GetNetAccountId()
+        */
+       NetAccountId GetNetAccountId(const Tizen::Base::String& netAccountName) const;
+
+       /**
+        * @see                 NetAccountManager::GetNetAccountId()
+        */
+       NetAccountId GetNetAccountId(NetBearerType netBearerType) const;
+
+       /**
+        * @see                 NetAccountManager::GetNetAccountInfoN()
+        */
+       NetAccountInfo* GetNetAccountInfoN(NetAccountId netAccountId) const;
+
+       /**
+        * @see                 NetAccountManager::GetNetAccountIdsN()
+        */
+       Tizen::Base::Collection::IListT<NetAccountId>* GetNetAccountIdsN(void) const;
+
+       /**
+        * @see                 NetAccountManager::GetNetAccountNamesN()
+        */
+       Tizen::Base::Collection::IList* GetNetAccountNamesN(void) const;
+
+       /**
+        * @see                 NetAccountManager::GetNetPreference()
+        */
+       NetPreferenceType GetNetPreference(void) const;
+
+       /**
+        * @see                 NetAccountManager::SetNetPreference()
+        */
+       result SetNetPreference(NetPreferenceType netPreference);
+
+public:
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _NetAccountManagerImpl
+     * @param[in]   netAccountManager            An instance of NetAccountManager
+     */
+       static _NetAccountManagerImpl* GetInstance(NetAccountManager& netAccountManager);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _NetAccountManagerImpl
+     * @param[in]   netAccountManager     An instance of NetAccountManager
+     */
+       static const _NetAccountManagerImpl* GetInstance(const NetAccountManager& netAccountManager);
+
+public:
+       static void* GetPsProfileHandleN(const Tizen::Base::String& profileName);
+       static void* GetWifiProfileHandleN(void);
+       static Tizen::Base::String GetInternetProfileName(void);
+       static Tizen::Base::String GetMmsProfileName(void);
+       static Tizen::Base::Collection::IList* GetAppProfileNamesN(void);
+       static NetAccountInfo* CreateWifiNetAccountInfoN(void* pProfileInfo);
+
+private:
+       /**
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of _NetAccountManagerImpl
+        */
+       _NetAccountManagerImpl(const _NetAccountManagerImpl& rhs);
+
+       /**
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of _NetAccountManagerImpl
+        */
+       _NetAccountManagerImpl& operator =(const _NetAccountManagerImpl& rhs);
+
+private:
+       std::unique_ptr<void, _ConnectionDeleter> __pConnectionHandle;
+
+       friend class NetAccountManager;
+
+}; // _NetAccountManagerImpl
+
+}  }  // Tizen::Net
+
+#endif // _FNET_INTERNAL_NET_ACCOUNT_MANAGER_IMPL_H_
diff --git a/src/FNet_NetConnectionEvent.cpp b/src/FNet_NetConnectionEvent.cpp
new file mode 100644 (file)
index 0000000..b8fdd12
--- /dev/null
@@ -0,0 +1,345 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file                       FNet_NetConnectionEvent.cpp
+ * @brief              This is the implementation file for _NetConnectionEvent class.
+ * @version    3.0
+ *
+ * This file contains the implementation of _NetConnectionEvent class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseRtMutexGuard.h>
+#include <FNetNetConnection.h>
+#include <FNetManagedNetConnection.h>
+#include <FNetINetConnectionEventListener.h>
+#include <FNetIManagedNetConnectionEventListener.h>
+#include "FNet_SystemNetConnection.h"
+#include "FNet_NetConnectionEvent.h"
+#include "FNet_NetConnectionEventArg.h"
+#include "FNet_NetUtility.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net {
+
+_NetListenerHashCodeProvider::_NetListenerHashCodeProvider(void)
+{
+}
+
+_NetListenerHashCodeProvider::~_NetListenerHashCodeProvider(void)
+{
+}
+
+int
+_NetListenerHashCodeProvider::GetHashCode(const _NetListenerKey& obj) const
+{
+       return (int)obj;
+}
+
+_NetListenerComparer::_NetListenerComparer(void)
+{
+}
+
+_NetListenerComparer::~_NetListenerComparer(void)
+{
+}
+
+result
+_NetListenerComparer::Compare(const _NetListenerKey& obj1, const _NetListenerKey& obj2, int& cmp) const
+{
+       if (obj1 == obj2)
+       {
+               cmp = 0;
+       }
+       else
+       {
+               cmp = 1;
+       }
+
+       return E_SUCCESS;
+}
+
+_NetConnectionEvent::_NetConnectionEvent(void)
+       : __refCount(1)
+       , __connectionState(NET_CONNECTION_STATE_NONE)
+       , __pSystemConnection(null)
+       , __pListenerMap(null)
+{
+}
+
+_NetConnectionEvent::~_NetConnectionEvent(void)
+{
+       if (__pSystemConnection != null)
+       {
+               __pSystemConnection->RemoveEvent(*this);
+               __pSystemConnection = null;
+       }
+
+       if (__pListenerMap != null)
+       {
+               delete __pListenerMap;
+               __pListenerMap = null;
+       }
+}
+
+result
+_NetConnectionEvent::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       r = _Event::Initialize();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       unique_ptr< HashMapT<_NetListenerKey, Object*> > pListenerMap(new (std::nothrow) HashMapT<_NetListenerKey, Object*>);
+       SysTryReturnResult(NID_NET, pListenerMap != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pListenerMap->Construct(0, 0, __hashCodeProvider, __comparer);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       __pListenerMap = pListenerMap.release();
+
+       return r;
+}
+
+result
+_NetConnectionEvent::AddNetConnectionEventListener(const IEventListener& listener, const Object* pConnection)
+{
+       result r = E_SUCCESS;
+       Mutex* pLock = _NetUtility::GetLock();
+
+       MutexGuard locked(*pLock);
+       SysTryReturnResult(NID_NET, locked.IsLocked(), E_SYSTEM, "A system error has been occurred. Failed to lock mutex.");
+
+       r = __pListenerMap->Add(const_cast<IEventListener*>(&listener), const_cast<Object*>(pConnection));
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = AddListener(listener, true);
+       SysTryCatch(NID_NET, r == E_SUCCESS, __pListenerMap->Remove(const_cast<IEventListener*>(&listener)),
+                       r, "[%s] Propagating.", GetErrorMessage(r));
+
+       locked.Unlock();
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_NetConnectionEvent::RemoveNetConnectionEventListener(const IEventListener& listener)
+{
+       result r = E_SUCCESS;
+       Mutex* pLock = _NetUtility::GetLock();
+
+       MutexGuard locked(*pLock);
+       SysTryReturnResult(NID_NET, locked.IsLocked(), E_SYSTEM, "A system error has been occurred. Failed to lock mutex.");
+
+       r = RemoveListener(listener);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       r = __pListenerMap->Remove(const_cast<IEventListener*>(&listener));
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       locked.Unlock();
+
+       return r;
+}
+
+void
+_NetConnectionEvent::RemoveAllNetConnectionEventListener(const Object* pConnection)
+{
+       result r = E_SUCCESS;
+    IMapEnumeratorT<_NetListenerKey, Object*>* pEnum = __pListenerMap->GetMapEnumeratorN();
+    Object* pValue = null;
+    IEventListener* pListener = null;
+
+       Mutex* pLock = _NetUtility::GetLock();
+       MutexGuard locked(*pLock);
+       SysTryReturnVoidResult(NID_NET, locked.IsLocked(), E_SYSTEM, "A system error has been occurred. Failed to lock mutex.");
+
+    if (pEnum != null)
+    {
+        while (pEnum->MoveNext() == E_SUCCESS)
+        {
+               pEnum->GetKey(pListener);
+               pEnum->GetValue(pValue);
+
+            if (pConnection == pValue)
+            {
+               SysLog(NID_NET, "A connection(0x%x) is deleting, but listener(0x%x) is remaining, so remove the listener.",
+                               pConnection, pListener);
+
+               r = RemoveListener(*pListener);
+               r = __pListenerMap->Remove(pListener);
+            }
+        }
+
+        delete pEnum;
+    }
+
+       locked.Unlock();
+}
+
+void
+_NetConnectionEvent::SetConnectionState(NetConnectionState connectionState)
+{
+       __connectionState = connectionState;
+}
+
+NetConnectionState
+_NetConnectionEvent::GetConnectionState(void) const
+{
+       return __connectionState;
+}
+
+void
+_NetConnectionEvent::SetSystemConnection(_SystemNetConnection* pSystemConnection)
+{
+       __pSystemConnection = pSystemConnection;
+}
+
+int
+_NetConnectionEvent::AddRef(void)
+{
+       __refCount++;
+
+       return __refCount;
+}
+
+int
+_NetConnectionEvent::Release(void)
+{
+       __refCount--;
+
+       if (__refCount == 0)
+       {
+               delete this;
+               return 0;
+       }
+
+       return __refCount;
+}
+
+void
+_NetConnectionEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+       result r = E_SUCCESS;
+       IEventArg* pEventArg = null;
+       _NetConnectionEventArg* pNetConnectionEventArg = null;
+       INetConnectionEventListener* pNetConnectionEventListener = null;
+       IManagedNetConnectionEventListener* pManagedNetConnectionEventListener = null;
+       Object* pConnectionObject = null;
+       NetConnection* pNetConnection = null;
+       ManagedNetConnection* pManagedNetConnection = null;
+
+       pEventArg = const_cast<IEventArg*>(&arg);
+       pNetConnectionEventArg = dynamic_cast<_NetConnectionEventArg*>(pEventArg);
+       SysTryReturnVoidResult(NID_NET, pNetConnectionEventArg != null, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. EventArg is NULL, so ignore the event.", GetErrorMessage(E_INVALID_ARG));
+
+       r = __pListenerMap->GetValue(&listener, pConnectionObject);
+       SysTryReturnVoidResult(NID_NET, r == E_SUCCESS, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. Listener is NOT found, so ignore the event.", GetErrorMessage(E_INVALID_ARG));
+
+       SysLog(NID_NET, "Event Type, %d, returned with the result, %s",
+                       pNetConnectionEventArg->GetType(), GetErrorMessage(pNetConnectionEventArg->GetResult()));
+
+       pNetConnectionEventListener = dynamic_cast<INetConnectionEventListener*>(&listener);
+       pManagedNetConnectionEventListener = dynamic_cast<IManagedNetConnectionEventListener*>(&listener);
+       pNetConnection = dynamic_cast<NetConnection*>(pConnectionObject);
+       pManagedNetConnection = dynamic_cast<ManagedNetConnection*>(pConnectionObject);
+
+       if ((pNetConnectionEventListener != null) && (pNetConnection != null))
+       {
+               switch (pNetConnectionEventArg->GetType())
+               {
+               case _NET_CONNECTION_EVENT_TYPE_STARTED:
+                       SysLog(NID_NET, "Calling OnNetConnectionStarted().");
+                       pNetConnectionEventListener->OnNetConnectionStarted(*pNetConnection, pNetConnectionEventArg->GetResult());
+                       SysLog(NID_NET, "Called OnNetConnectionStarted().");
+                       break;
+               case _NET_CONNECTION_EVENT_TYPE_STOPPED:
+                       SysLog(NID_NET, "Calling OnNetConnectionStopped().");
+                       pNetConnectionEventListener->OnNetConnectionStopped(*pNetConnection, pNetConnectionEventArg->GetResult());
+                       SysLog(NID_NET, "Called OnNetConnectionStopped().");
+                       break;
+               case _NET_CONNECTION_EVENT_TYPE_SUSPENDED:
+                       SysLog(NID_NET, "Calling OnNetConnectionSuspended().");
+                       pNetConnectionEventListener->OnNetConnectionSuspended(*pNetConnection);
+                       SysLog(NID_NET, "Called OnNetConnectionSuspended().");
+                       break;
+               case _NET_CONNECTION_EVENT_TYPE_RESUMED:
+                       SysLog(NID_NET, "Calling OnNetConnectionResumed().");
+                       pNetConnectionEventListener->OnNetConnectionResumed(*pNetConnection);
+                       SysLog(NID_NET, "Called OnNetConnectionResumed().");
+                       break;
+               default:
+                       break;
+               }
+       }
+       else if ((pManagedNetConnectionEventListener != null) && (pManagedNetConnection != null))
+       {
+               switch (pNetConnectionEventArg->GetType())
+               {
+               case _NET_CONNECTION_EVENT_TYPE_STARTED:
+                       if (pNetConnectionEventArg->GetResult() == E_SUCCESS)
+                       {
+                               SysLog(NID_NET, "Calling OnManagedNetConnectionStarted().");
+                               pManagedNetConnectionEventListener->OnManagedNetConnectionStarted(*pManagedNetConnection);
+                               SysLog(NID_NET, "Called OnManagedNetConnectionStarted().");
+                       }
+                       else
+                       {
+                               SysLog(NID_NET, "Calling OnManagedNetConnectionStopped() because of an error, %s",
+                                               GetErrorMessage(pNetConnectionEventArg->GetResult()));
+                               pManagedNetConnectionEventListener->OnManagedNetConnectionStopped(*pManagedNetConnection,
+                                               NET_CONNECTION_STOPPED_REASON_NETWORK_FAILED);  // ToDo - Exception converting
+                               SysLog(NID_NET, "Called OnManagedNetConnectionStopped().");
+                       }
+                       break;
+               case _NET_CONNECTION_EVENT_TYPE_STOPPED:
+                       SysLog(NID_NET, "Calling OnManagedNetConnectionStopped().");
+                       pManagedNetConnectionEventListener->OnManagedNetConnectionStopped(*pManagedNetConnection,
+                                       NET_CONNECTION_STOPPED_REASON_NETWORK_FAILED);  // ToDo - Exception converting
+                       SysLog(NID_NET, "Called OnManagedNetConnectionStopped().");
+                       break;
+               case _NET_CONNECTION_EVENT_TYPE_SUSPENDED:
+                       SysLog(NID_NET, "Calling OnManagedNetConnectionSuspended().");
+                       pManagedNetConnectionEventListener->OnManagedNetConnectionSuspended(*pManagedNetConnection);
+                       SysLog(NID_NET, "Called OnManagedNetConnectionSuspended().");
+                       break;
+               case _NET_CONNECTION_EVENT_TYPE_RESUMED:
+                       SysLog(NID_NET, "Calling OnManagedNetConnectionResumed().");
+                       pManagedNetConnectionEventListener->OnManagedNetConnectionResumed(*pManagedNetConnection);
+                       SysLog(NID_NET, "Called OnManagedNetConnectionResumed().");
+                       break;
+               default:
+                       break;
+               }
+       }
+       else
+       {
+               SysLog(NID_NET, "Connection or event listener is NULL, so ignore the event.");
+       }
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_NetConnectionEvent.h b/src/FNet_NetConnectionEvent.h
new file mode 100644 (file)
index 0000000..be6a26c
--- /dev/null
@@ -0,0 +1,141 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file                       FNet_NetConnectionEvent.h
+ * @brief                      This is the header file for _NetConnectionEvent class.
+ * @version                    3.0
+ *
+ * This header file contains the declarations of _NetConnectionEvent class.
+ * The _NetConnectionEvent class can call listener's method. So, when an event is occurred,
+ * application can handle it appropriately.
+ */
+
+#ifndef _FNET_INTERNAL_NET_CONNECTION_EVENT_H_
+#define _FNET_INTERNAL_NET_CONNECTION_EVENT_H_
+
+#include <FBaseDataType.h>
+#include <FBaseColIHashCodeProviderT.h>
+#include <FBaseColIComparerT.h>
+#include <FNetNetTypes.h>
+#include <FBaseRt_Event.h>
+#include "FNet_NetTypes.h"
+
+namespace Tizen { namespace Base
+{
+class Object;
+} } // Tizen::Base
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventListener;
+class IEventArg;
+} } } // Tizen::Base::Runtime
+
+namespace Tizen { namespace Net
+{
+class _SystemNetConnection;
+
+enum _NetConnectionEventType
+{
+       _NET_CONNECTION_EVENT_TYPE_NONE,
+       _NET_CONNECTION_EVENT_TYPE_STARTED,
+       _NET_CONNECTION_EVENT_TYPE_STOPPED,
+       _NET_CONNECTION_EVENT_TYPE_SUSPENDED,
+       _NET_CONNECTION_EVENT_TYPE_RESUMED
+};
+
+typedef Tizen::Base::Runtime::IEventListener* _NetListenerKey;
+
+class _NetListenerHashCodeProvider
+: public Tizen::Base::Collection::IHashCodeProviderT<_NetListenerKey>
+{
+public:
+       _NetListenerHashCodeProvider(void);
+       ~_NetListenerHashCodeProvider(void);
+
+       virtual int GetHashCode(const _NetListenerKey& obj) const;
+
+private:
+       _NetListenerHashCodeProvider(const _NetListenerHashCodeProvider& rhs);
+       _NetListenerHashCodeProvider& operator =(const _NetListenerHashCodeProvider& rhs);
+}; // _NetListenerHashCodeProvider
+
+class _NetListenerComparer
+: public Tizen::Base::Collection::IComparerT<_NetListenerKey>
+{
+public:
+       _NetListenerComparer(void);
+       ~_NetListenerComparer(void);
+
+       virtual result Compare(const _NetListenerKey& obj1, const _NetListenerKey& obj2, int& cmp) const;
+
+private:
+       _NetListenerComparer(const _NetListenerComparer& rhs);
+       _NetListenerComparer& operator =(const _NetListenerComparer& rhs);
+}; // _NetListenerComparer
+
+class _NetConnectionEvent :
+       public Tizen::Base::Runtime::_Event
+{
+public:
+       _NetConnectionEvent(void);
+       virtual ~_NetConnectionEvent(void);
+
+       virtual result Construct(void);
+
+public:
+       result AddNetConnectionEventListener(const Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Object* pConnection);
+       result RemoveNetConnectionEventListener(const Tizen::Base::Runtime::IEventListener& listener);
+       void RemoveAllNetConnectionEventListener(const Tizen::Base::Object* pConnection);
+
+       void SetConnectionState(NetConnectionState connectionState);
+       NetConnectionState GetConnectionState(void) const;
+
+       void SetSystemConnection(_SystemNetConnection* pConnection);
+
+       int AddRef(void);
+       int Release(void);
+
+protected:
+       virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+       /**
+        * This is the copy constructor.
+        *
+        * @param[in]   rhs             An instance of _NetConnectionEvent
+        */
+       _NetConnectionEvent(const _NetConnectionEvent& rhs);
+
+       /**
+        * This is the assignment operator.
+        *
+        * @param[in]   rhs             An instance of _NetConnectionEvent
+        */
+       _NetConnectionEvent& operator =(const _NetConnectionEvent& rhs);
+
+private:
+       int __refCount;
+       _NetListenerHashCodeProvider __hashCodeProvider;
+       _NetListenerComparer __comparer;
+       NetConnectionState __connectionState;
+       _SystemNetConnection* __pSystemConnection;
+       Tizen::Base::Collection::HashMapT<_NetListenerKey, Tizen::Base::Object*>* __pListenerMap;
+}; // _NetConnectionEvent
+
+} } // Tizen::Net
+#endif // _FNET_INTERNAL_NET_CONNECTION_EVENT_H_
diff --git a/src/FNet_NetConnectionEventArg.cpp b/src/FNet_NetConnectionEventArg.cpp
new file mode 100644 (file)
index 0000000..a164a42
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file                       FNet_NetConnectionEventArg.cpp
+ * @brief              This is the implementation file for _NetConnectionEventArg class.
+ * @version    3.0
+ *
+ * This file contains the implementation of _NetConnectionEventArg class.
+ */
+
+#include <FBaseSysLog.h>
+#include "FNet_NetConnectionEventArg.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net {
+
+_NetConnectionEventArg::_NetConnectionEventArg(_NetConnectionEventType type, result ret)
+       : __type(type)
+       , __ret(ret)
+{
+}
+
+_NetConnectionEventArg::~_NetConnectionEventArg(void)
+{
+}
+
+_NetConnectionEventType
+_NetConnectionEventArg::GetType(void) const
+{
+       return __type;
+}
+
+result
+_NetConnectionEventArg::GetResult(void) const
+{
+       return __ret;
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_NetConnectionEventArg.h b/src/FNet_NetConnectionEventArg.h
new file mode 100644 (file)
index 0000000..0e0a9ab
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file                       FNet_NetConnectionEventArg.h
+ * @brief                      This is the header file for _NetConnectionEventArg class.
+ * @version                    3.0
+ *
+ * This header file contains the declarations of _NetConnectionEventArg class.
+ */
+
+#ifndef _FNET_INTERNAL_NET_CONNECTION_EVENT_ARG_H_
+#define _FNET_INTERNAL_NET_CONNECTION_EVENT_ARG_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+#include "FNet_NetConnectionEvent.h"
+
+namespace Tizen { namespace Net {
+
+class _NetConnectionEventArg
+       : public Tizen::Base::Object
+       , public Tizen::Base::Runtime::IEventArg
+{
+public:
+       _NetConnectionEventArg(_NetConnectionEventType type, result ret);
+       virtual ~_NetConnectionEventArg(void);
+
+       _NetConnectionEventType GetType(void) const;
+       result GetResult(void) const;
+
+private:
+       _NetConnectionEventArg(void);
+
+       _NetConnectionEventArg(const _NetConnectionEventArg& rhs);
+       _NetConnectionEventArg& operator =(const _NetConnectionEventArg& rhs);
+
+private:
+       _NetConnectionEventType __type;
+       result __ret;
+}; // _NetConnectionEventArg
+
+} } // Tizen::Net
+#endif // _FNET_INTERNAL_NET_CONNECTION_EVENT_ARG_H_
+
diff --git a/src/FNet_NetConnectionImpl.cpp b/src/FNet_NetConnectionImpl.cpp
new file mode 100644 (file)
index 0000000..469cae2
--- /dev/null
@@ -0,0 +1,363 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNet_NetConnectionImpl.cpp
+ * @brief              This is the implementation for the _NetConnectionImpl class.
+ */
+
+#include <unique_ptr.h>
+#include <FNetNetTypes.h>
+#include <FNetNetConnectionInfo.h>
+#include <FNetNetConnection.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_NetConnectionImpl.h"
+#include "FNet_NetConnectionManagerImpl.h"
+#include "FNet_SystemNetConnection.h"
+#include "FNet_NetAccountDatabase.h"
+#include "FNet_NetConnectionEvent.h"
+#include "FNet_NetUtility.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net {
+
+_NetConnectionImpl::_NetConnectionImpl()
+       : __pNetConnection(null)
+       , __netAccountId(INVALID_HANDLE)
+       , __isOwner(false)
+       , __isClosed(false)
+       , __pSystemNetConnection(null)
+       , __pEvent(null)
+{
+}
+
+_NetConnectionImpl::~_NetConnectionImpl(void)
+{
+       if (__pEvent != null)
+       {
+               __pEvent->RemoveAllNetConnectionEventListener(__pNetConnection);
+
+               if (__pSystemNetConnection != null)
+               {
+                       if (__isOwner)
+                       {
+                               __pSystemNetConnection->Stop(*__pEvent);
+                       }
+
+                       __pSystemNetConnection = null;
+               }
+
+               __pEvent->Release();
+               __pEvent = null;
+       }
+
+       __pNetConnection = null;
+}
+
+_NetConnectionImpl::_NetConnectionImpl(const _NetConnectionImpl& value)
+{
+       __pNetConnection = null;
+       __netAccountId = value.__netAccountId;
+       __netAccountName = value.__netAccountName;
+       __isOwner = false;
+       __isClosed = value.__isClosed;
+       __pSystemNetConnection = value.__pSystemNetConnection;
+       __pEvent = value.__pEvent;
+       __pEvent->AddRef();
+}
+
+result
+_NetConnectionImpl::Construct(NetConnection* pNetConnection, NetAccountId netAccountId)
+{
+       result r = E_SUCCESS;
+       _SystemNetConnection* pSystemNetConnection = null;
+       String netAccountName;
+
+       SysAssertf(__netAccountId == INVALID_HANDLE,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       _SystemNetConnection::InitializeNetworkFramework();
+
+       unique_ptr<_NetConnectionEvent> pEvent(new (std::nothrow) _NetConnectionEvent());
+       SysTryReturnResult(NID_NET, pEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pEvent->Construct();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+#ifdef _OSP_EMUL_
+       if ((netAccountId == _DEFAULT_WIFI_ACCOUNT_ID) ||
+               (netAccountId == _DEFAULT_WIFI_DIRECT_ACCOUNT_ID) ||
+               (netAccountId == _DEFAULT_USB_ACCOUNT_ID) ||
+               (_NetAccountDatabase::GetAccountName(netAccountId, netAccountName) == E_SUCCESS))
+       {
+               SysLog(NID_NET, "Use default network connection.");
+               pSystemNetConnection = _SystemNetConnection::GetDefaultInstance();
+       }
+       else
+       {
+               pSystemNetConnection = null;
+       }
+       SysTryReturnResult(NID_NET, pSystemNetConnection != null, E_INVALID_ACCOUNT,
+                       "Invalid network account. accountId=%d", netAccountId);
+#else // _OSP_EMUL_
+       if (netAccountId == _DEFAULT_WIFI_ACCOUNT_ID)
+       {
+               // WiFi
+               pSystemNetConnection = _SystemNetConnection::GetWifiInstance();
+       }
+       else if (netAccountId == _DEFAULT_WIFI_DIRECT_ACCOUNT_ID)
+       {
+               // WiFi-Direct
+               pSystemNetConnection = _SystemNetConnection::GetWifiDirectInstance();
+       }
+       else if (netAccountId == _DEFAULT_USB_ACCOUNT_ID)
+       {
+               // USB
+               pSystemNetConnection = _SystemNetConnection::GetUsbInstance();
+       }
+       else
+       {
+               // PS
+               String profileName;
+
+               r = _NetAccountDatabase::GetAccountName(netAccountId, netAccountName);
+               SysTryReturnResult(NID_NET, r == E_SUCCESS, E_INVALID_ACCOUNT,
+                               "Invalid network account. accountId=%d", netAccountId);
+
+               pSystemNetConnection = _SystemNetConnection::GetPsInstance(netAccountId);
+       }
+#endif // _OSP_EMUL_
+       SysTryReturnResult(NID_NET, pSystemNetConnection != null, E_SYSTEM,
+                       "A system error has been occurred. pSystemNetConnection is null.");
+
+       r = pSystemNetConnection->AddEvent(*pEvent);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pEvent->SetSystemConnection(pSystemNetConnection);
+
+       __pNetConnection = pNetConnection;
+       __netAccountId = netAccountId;
+       __netAccountName = netAccountName;
+       __isOwner = true;
+       __isClosed = false;
+       __pSystemNetConnection = pSystemNetConnection;
+       __pEvent = pEvent.release();
+
+       return r;
+}
+
+result
+_NetConnectionImpl::AddNetConnectionListener(INetConnectionEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__netAccountId != INVALID_HANDLE, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturnResult(NID_NET, !__isClosed, E_INVALID_STATE, "The instance was closed.");
+
+       r = __pEvent->AddNetConnectionEventListener(listener, __pNetConnection);
+
+       return r;
+}
+
+result
+_NetConnectionImpl::RemoveNetConnectionListener(INetConnectionEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__netAccountId != INVALID_HANDLE, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturnResult(NID_NET, !__isClosed, E_INVALID_STATE, "The instance was closed.");
+
+       r = __pEvent->RemoveNetConnectionEventListener(listener);
+
+       return r;
+}
+
+result
+_NetConnectionImpl::Start(void)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__netAccountId != INVALID_HANDLE, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturnResult(NID_NET, !__isClosed, E_INVALID_STATE, "The instance was closed.");
+       SysTryReturnResult(NID_NET, __isOwner, E_INVALID_OPERATION, "No right to control the connection.");
+
+       r = __pSystemNetConnection->Start(*__pEvent);
+
+       return r;
+}
+
+result
+_NetConnectionImpl::Stop(void)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__netAccountId != INVALID_HANDLE, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturnResult(NID_NET, !__isClosed, E_INVALID_STATE, "The instance was closed.");
+       SysTryReturnResult(NID_NET, __isOwner, E_INVALID_OPERATION, "No right to control the connection.");
+
+       r = __pSystemNetConnection->Stop(*__pEvent);
+
+       return r;
+}
+
+result
+_NetConnectionImpl::Close(void)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__netAccountId != INVALID_HANDLE, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturnResult(NID_NET, !__isClosed, E_INVALID_STATE, "The instance was closed.");
+       SysTryReturnResult(NID_NET, __isOwner, E_INVALID_OPERATION, "No right to control the connection.");
+
+       __pEvent->RemoveAllNetConnectionEventListener(__pNetConnection);
+
+       if (__pSystemNetConnection != null)
+       {
+               __pSystemNetConnection->Stop(*__pEvent);
+               __pSystemNetConnection = null;
+
+               __pEvent->Release();
+               __pEvent = null;
+       }
+
+       __isClosed = true;
+
+       return r;
+}
+
+NetAccountId
+_NetConnectionImpl::GetNetAccountId(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__netAccountId != INVALID_HANDLE, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturn(NID_NET, !__isClosed, INVALID_HANDLE, E_INVALID_STATE,
+                       "[%s] The instance was closed.", GetErrorMessage(E_INVALID_STATE));
+
+       return __netAccountId;
+}
+
+const NetConnectionInfo*
+_NetConnectionImpl::GetNetConnectionInfo(void)
+{
+       ClearLastResult();
+
+       NetConnectionInfo* pConnectionInfo = null;
+
+       SysAssertf(__netAccountId != INVALID_HANDLE, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturn(NID_NET, !__isClosed, null, E_INVALID_STATE,
+                       "[%s] The instance was closed.", GetErrorMessage(E_INVALID_STATE));
+
+       if (__pEvent->GetConnectionState() == NET_CONNECTION_STATE_STARTED)
+       {
+               __pSystemNetConnection->GetConnectionInfo(__netConnectionInfo);
+               pConnectionInfo = &__netConnectionInfo;
+       }
+
+       return pConnectionInfo;
+}
+
+NetConnectionInfo*
+_NetConnectionImpl::GetNetConnectionInfoN(NetAccountId netAccountId)
+{
+       ClearLastResult();
+
+       return _NetConnectionManagerImpl::GetNetConnectionInfoN(netAccountId);
+}
+
+IList*
+_NetConnectionImpl::GetAllNetConnectionInfoN(void)
+{
+       ClearLastResult();
+
+       return _NetConnectionManagerImpl::GetAllNetConnectionInfoN();
+}
+
+NetConnectionState
+_NetConnectionImpl::GetConnectionState(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__netAccountId != INVALID_HANDLE, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturn(NID_NET, !__isClosed, NET_CONNECTION_STATE_NONE, E_INVALID_STATE,
+                       "[%s] The instance was closed.", GetErrorMessage(E_INVALID_STATE));
+
+       return __pEvent->GetConnectionState();
+}
+
+String
+_NetConnectionImpl::GetProxyAddress(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__netAccountId != INVALID_HANDLE, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturn(NID_NET, !__isClosed, L"", E_INVALID_STATE, "[%s] The instance was closed.", GetErrorMessage(E_INVALID_STATE));
+
+       return __pSystemNetConnection->GetProxyAddress();
+}
+
+NetConnection*
+_NetConnectionImpl::CopyInstanceN(void)
+{
+       ClearLastResult();
+
+       SysAssertf(__netAccountId != INVALID_HANDLE, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturn(NID_NET, !__isClosed, null, E_INVALID_STATE, "[%s] The instance was closed.", GetErrorMessage(E_INVALID_STATE));
+
+       unique_ptr<NetConnection> pConnection(new (std::nothrow) NetConnection());
+       SysTryReturn(NID_NET, pConnection != null, null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       _NetConnectionImpl* pConnectionImpl = new (std::nothrow) _NetConnectionImpl(*this);
+       SysTryReturn(NID_NET, pConnectionImpl != null, null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       pConnectionImpl->__pNetConnection = pConnection.get();
+       pConnection->__pNetConnectionImpl = pConnectionImpl;
+
+       return pConnection.release();
+}
+
+_NetConnectionImpl*
+_NetConnectionImpl::GetInstance(NetConnection& netConnection)
+{
+       return netConnection.__pNetConnectionImpl;
+}
+
+const _NetConnectionImpl*
+_NetConnectionImpl::GetInstance(const NetConnection& netConnection)
+{
+       return netConnection.__pNetConnectionImpl;
+}
+
+} } // Tizen::Net
+
diff --git a/src/FNet_NetConnectionInfoImpl.cpp b/src/FNet_NetConnectionInfoImpl.cpp
new file mode 100644 (file)
index 0000000..2b90c65
--- /dev/null
@@ -0,0 +1,798 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_NetConnectionInfoImpl.cpp
+ * @brief              This is the implementation for the _NetConnectionInfoImpl class.
+ */
+
+#include <net_connection.h>
+#include <FBaseUtilStringUtil.h>
+#include <FNetNetConnectionInfo.h>
+#include <FNetIp4Address.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_NetConnectionInfoImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Net {
+
+_NetConnectionInfoImpl::_NetConnectionInfoImpl(void)
+       : __bearerType(NET_BEARER_NONE)
+       , __protocolType(NET_PROTO_TYPE_NONE)
+       , __localAddressScheme(NET_ADDRESS_SCHEME_NONE)
+       , __dnsAddressScheme(NET_ADDRESS_SCHEME_NONE)
+       , __pLocalAddress(null)
+       , __pSubnetMaskAddress(null)
+       , __pDefaultGatewayAddress(null)
+       , __pPrimaryDnsAddress(null)
+       , __pSecondaryDnsAddress(null)
+{
+}
+
+_NetConnectionInfoImpl::~_NetConnectionInfoImpl(void)
+{
+}
+
+NetBearerType
+_NetConnectionInfoImpl::GetBearerType(void) const
+{
+       return  __bearerType;
+}
+
+NetProtocolType
+_NetConnectionInfoImpl::GetProtocolType(void) const
+{
+       return __protocolType;
+}
+
+String
+_NetConnectionInfoImpl::GetAccessPointName(void) const
+{
+       return __apn;
+}
+
+NetAddressScheme
+_NetConnectionInfoImpl::GetLocalAddressScheme(void) const
+{
+       return __localAddressScheme;
+}
+
+const IpAddress*
+_NetConnectionInfoImpl::GetLocalAddress(void) const
+{
+       return __pLocalAddress.get();
+}
+
+NetAddressScheme
+_NetConnectionInfoImpl::GetDnsAddressScheme(void) const
+{
+       return __dnsAddressScheme;
+}
+
+const IpAddress*
+_NetConnectionInfoImpl::GetPrimaryDnsAddress(void) const
+{
+       return __pPrimaryDnsAddress.get();
+}
+
+const IpAddress*
+_NetConnectionInfoImpl::GetSecondaryDnsAddress(void) const
+{
+       return __pSecondaryDnsAddress.get();
+}
+
+const IpAddress*
+_NetConnectionInfoImpl::GetSubnetMaskAddress(void) const
+{
+       return __pSubnetMaskAddress.get();
+}
+
+const IpAddress*
+_NetConnectionInfoImpl::GetDefaultGatewayAddress(void) const
+{
+       return __pDefaultGatewayAddress.get();
+}
+
+String
+_NetConnectionInfoImpl::GetDeviceName(void) const
+{
+       return __deviceName;
+}
+
+String
+_NetConnectionInfoImpl::GetProxyAddress(void) const
+{
+       return __proxyAddress;
+}
+
+void
+_NetConnectionInfoImpl::CopyFrom(const _NetConnectionInfoImpl* pSource)
+{
+       const Ip4Address* pAddress = null;
+       unique_ptr<IpAddress> pLocalAddress;
+       unique_ptr<IpAddress> pSubnetMaskAddress;
+       unique_ptr<IpAddress> pDefaultGatewayAddress;
+       unique_ptr<IpAddress> pPrimaryDnsAddress;
+       unique_ptr<IpAddress> pSecondaryDnsAddress;
+
+       SysTryReturnVoidResult(NID_NET, pSource != null, E_INVALID_ARG,
+                       "[%s] Invalud argument is used. Source is null.", GetErrorMessage(E_INVALID_ARG));
+
+       pAddress = dynamic_cast<const Ip4Address*>(pSource->GetLocalAddress());
+       if (pAddress != null)
+       {
+               pLocalAddress.reset(new (std::nothrow) Ip4Address(*pAddress));
+               SysTryReturnVoidResult(NID_NET, pLocalAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       pAddress = dynamic_cast<const Ip4Address*>(pSource->GetSubnetMaskAddress());
+       if (pAddress != null)
+       {
+               pSubnetMaskAddress.reset(new (std::nothrow) Ip4Address(*pAddress));
+               SysTryReturnVoidResult(NID_NET, pSubnetMaskAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       pAddress = dynamic_cast<const Ip4Address*>(pSource->GetDefaultGatewayAddress());
+       if (pAddress != null)
+       {
+               pDefaultGatewayAddress.reset(new (std::nothrow) Ip4Address(*pAddress));
+               SysTryReturnVoidResult(NID_NET, pDefaultGatewayAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       pAddress = dynamic_cast<const Ip4Address*>(pSource->GetPrimaryDnsAddress());
+       if (pAddress != null)
+       {
+               pPrimaryDnsAddress.reset(new (std::nothrow) Ip4Address(*pAddress));
+               SysTryReturnVoidResult(NID_NET, pPrimaryDnsAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       pAddress = dynamic_cast<const Ip4Address*>(pSource->GetSecondaryDnsAddress());
+       if (pAddress != null)
+       {
+               pSecondaryDnsAddress.reset(new (std::nothrow) Ip4Address(*pAddress));
+               SysTryReturnVoidResult(NID_NET, pSecondaryDnsAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       __bearerType = pSource->GetBearerType();
+       __protocolType = pSource->GetProtocolType();
+       __apn = pSource->GetAccessPointName();
+       __localAddressScheme = pSource->GetLocalAddressScheme();
+       __dnsAddressScheme = pSource->GetDnsAddressScheme();
+       __proxyAddress = pSource->GetProxyAddress();
+       __deviceName = pSource->GetDeviceName();
+
+       __pLocalAddress.reset(pLocalAddress.release());
+       __pSubnetMaskAddress.reset(pSubnetMaskAddress.release());
+       __pDefaultGatewayAddress.reset(pDefaultGatewayAddress.release());
+       __pPrimaryDnsAddress.reset(pPrimaryDnsAddress.release());
+       __pSecondaryDnsAddress.reset(pSecondaryDnsAddress.release());
+}
+
+void
+_NetConnectionInfoImpl::Clear()
+{
+       __bearerType = NET_BEARER_NONE;
+       __protocolType = NET_PROTO_TYPE_NONE;
+       __apn.Clear();
+       __deviceName.Clear();
+       __proxyAddress.Clear();
+       __localAddressScheme = NET_ADDRESS_SCHEME_NONE;
+       __dnsAddressScheme = NET_ADDRESS_SCHEME_NONE;
+
+       __pLocalAddress.reset(null);
+       __pSubnetMaskAddress.reset(null);
+       __pDefaultGatewayAddress.reset(null);
+       __pPrimaryDnsAddress.reset(null);
+       __pSecondaryDnsAddress.reset(null);
+}
+
+void
+_NetConnectionInfoImpl::SetBearerType(NetBearerType bearerType)
+{
+       __bearerType =  bearerType;
+}
+
+void
+_NetConnectionInfoImpl::SetProtocolType(NetProtocolType protocolType)
+{
+       __protocolType = protocolType;
+}
+
+void
+_NetConnectionInfoImpl::SetAccessPointName(const String& apn)
+{
+       __apn = apn;
+}
+
+void
+_NetConnectionInfoImpl::SetLocalAddressScheme(NetAddressScheme localAddressScheme)
+{
+       __localAddressScheme = localAddressScheme;
+}
+
+void
+_NetConnectionInfoImpl::SetDnsAddressScheme(NetAddressScheme dnsAddressScheme)
+{
+       __dnsAddressScheme = dnsAddressScheme;
+}
+
+void
+_NetConnectionInfoImpl::SetLocalAddress(const String& localAddress)
+{
+       unique_ptr<IpAddress> pLocalAddress(new (std::nothrow) Ip4Address(localAddress));
+       SysTryReturnVoidResult(NID_NET, pLocalAddress != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pLocalAddress.reset(pLocalAddress.release());
+}
+
+void
+_NetConnectionInfoImpl::SetSubnetMaskAddress(const String& subnetMaskAddress)
+{
+       unique_ptr<IpAddress> pSubnetMaskAddress(new (std::nothrow) Ip4Address(subnetMaskAddress));
+       SysTryReturnVoidResult(NID_NET, pSubnetMaskAddress != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pSubnetMaskAddress.reset(pSubnetMaskAddress.release());
+}
+
+void
+_NetConnectionInfoImpl::SetDefaultGatewayAddress(const String& defaultGatewayAddress)
+{
+       unique_ptr<IpAddress> pDefaultGatewayAddress(new (std::nothrow) Ip4Address(defaultGatewayAddress));
+       SysTryReturnVoidResult(NID_NET, pDefaultGatewayAddress != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pDefaultGatewayAddress.reset(pDefaultGatewayAddress.release());
+}
+
+void
+_NetConnectionInfoImpl::SetPrimaryDnsAddress(const String& primaryDnsAddress)
+{
+       unique_ptr<IpAddress> pPrimaryDnsAddress(new (std::nothrow) Ip4Address(primaryDnsAddress));
+       SysTryReturnVoidResult(NID_NET, pPrimaryDnsAddress != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pPrimaryDnsAddress.reset(pPrimaryDnsAddress.release());
+}
+
+void
+_NetConnectionInfoImpl::SetSecondaryDnsAddress(const String& secondaryDnsAddress)
+{
+       unique_ptr<IpAddress> pSecondaryDnsAddress(new (std::nothrow) Ip4Address(secondaryDnsAddress));
+       SysTryReturnVoidResult(NID_NET, pSecondaryDnsAddress != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __pSecondaryDnsAddress.reset(pSecondaryDnsAddress.release());
+}
+
+void
+_NetConnectionInfoImpl::SetProxyAddress(const String& proxyAddress)
+{
+       __proxyAddress = proxyAddress;
+}
+
+void
+_NetConnectionInfoImpl::SetDeviceName(const String& deviceName)
+{
+       __deviceName = deviceName;
+}
+
+void
+_NetConnectionInfoImpl::Update(void* pProfileHandle, bool isDefault)
+{
+       static const wchar_t _IP4_ADDRESS_EMPTY_ADDRESS[] = L":";
+       static const wchar_t _IP4_ADDRESS_DUMMY_ADDRESS[] = L"0.0.0.0";
+
+       NetBearerType bearerType = NET_BEARER_NONE;
+       NetProtocolType protocolType = NET_PROTO_TYPE_NONE;
+       String apn;
+       String deviceName;
+       String proxyAddress;
+       NetAddressScheme localAddressScheme = NET_ADDRESS_SCHEME_NONE;
+       NetAddressScheme dnsAddressScheme = NET_ADDRESS_SCHEME_NONE;
+       unique_ptr<IpAddress> pLocalAddress;
+       unique_ptr<IpAddress> pSubnetMaskAddress;
+       unique_ptr<IpAddress> pDefaultGatewayAddress;
+       unique_ptr<IpAddress> pPrimaryDnsAddress;
+       unique_ptr<IpAddress> pSecondaryDnsAddress;
+
+       int ret = CONNECTION_ERROR_NONE;
+       connection_profile_h profileHandle = static_cast<connection_profile_h>(pProfileHandle);
+       connection_profile_type_e type = CONNECTION_PROFILE_TYPE_WIFI;
+
+       SysLog(NID_NET, "Update() has been called with isDefault:%d", isDefault);
+
+       Clear();
+
+       if (pProfileHandle == null)
+       {
+               return;
+       }
+
+       ret = connection_profile_get_type(profileHandle, &type);
+       SysLog(NID_NET, "The return value from connection_profile_get_type() is %d. Network type is %d", ret, type);
+
+       if (type == CONNECTION_PROFILE_TYPE_WIFI)
+       {
+               SysLog(NID_NET, "Profile type is Wi-Fi.");
+               bearerType = NET_BEARER_WIFI;
+       }
+       else if (type == CONNECTION_PROFILE_TYPE_CELLULAR)
+       {
+               SysLog(NID_NET, "Profile type is Cellular.");
+
+               char* pApn = null;
+               ret = connection_profile_get_cellular_apn(profileHandle, &pApn);
+               if ((ret == CONNECTION_ERROR_NONE) && (pApn != null))
+               {
+                       apn = String(pApn);
+                       free(pApn);
+               }
+
+               bearerType = NET_BEARER_PS;
+       }
+       else
+       {
+               // CONNECTION_PROFILE_TYPE_ETHERNET (For emulator: Treat ethernet as cellular.)
+               SysLog(NID_NET, "Profile type is Ethernet.");
+               bearerType = NET_BEARER_PS;
+       }
+
+       protocolType = NET_PROTO_TYPE_IPV4;
+
+       connection_ip_config_type_e ipConfigType = CONNECTION_IP_CONFIG_TYPE_NONE;
+       ret = connection_profile_get_ip_config_type(profileHandle, CONNECTION_ADDRESS_FAMILY_IPV4, &ipConfigType);
+       SysTryReturnVoidResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_profile_get_ip_config_type() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+
+       if ((ipConfigType == CONNECTION_IP_CONFIG_TYPE_STATIC) || (ipConfigType == CONNECTION_IP_CONFIG_TYPE_FIXED))
+       {
+               localAddressScheme = NET_ADDRESS_SCHEME_STATIC;
+               dnsAddressScheme = NET_ADDRESS_SCHEME_STATIC;
+       }
+       else
+       {
+               localAddressScheme = NET_ADDRESS_SCHEME_DYNAMIC;
+               dnsAddressScheme = NET_ADDRESS_SCHEME_DYNAMIC;
+       }
+
+       char* pIpAddr = null;
+       String ipAddr;
+
+       ret = connection_profile_get_ip_address(profileHandle, CONNECTION_ADDRESS_FAMILY_IPV4, &pIpAddr);
+       if ((ret == CONNECTION_ERROR_NONE) && (pIpAddr != null))
+       {
+               ipAddr = String(pIpAddr);
+               free(pIpAddr);
+               pIpAddr = null;
+               pLocalAddress.reset(new (std::nothrow) Ip4Address(ipAddr));
+               SysTryReturnVoidResult(NID_NET, pLocalAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       ret = connection_profile_get_subnet_mask(profileHandle, CONNECTION_ADDRESS_FAMILY_IPV4, &pIpAddr);
+       if ((ret == CONNECTION_ERROR_NONE) && (pIpAddr != null))
+       {
+               ipAddr = String(pIpAddr);
+               free(pIpAddr);
+               pIpAddr = null;
+               pSubnetMaskAddress.reset(new (std::nothrow) Ip4Address(ipAddr));
+               SysTryReturnVoidResult(NID_NET, pSubnetMaskAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       ret = connection_profile_get_gateway_address(profileHandle, CONNECTION_ADDRESS_FAMILY_IPV4, &pIpAddr);
+       {
+               ipAddr = String(pIpAddr);
+               free(pIpAddr);
+               pIpAddr = null;
+               pDefaultGatewayAddress.reset(new (std::nothrow) Ip4Address(ipAddr));
+               SysTryReturnVoidResult(NID_NET, pDefaultGatewayAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       ret = connection_profile_get_dns_address(profileHandle, 1, CONNECTION_ADDRESS_FAMILY_IPV4, &pIpAddr);
+       if ((ret == CONNECTION_ERROR_NONE) && (pIpAddr != null))
+       {
+               ipAddr = String(pIpAddr);
+               free(pIpAddr);
+               pIpAddr = null;
+               pPrimaryDnsAddress.reset(new (std::nothrow) Ip4Address(ipAddr));
+               SysTryReturnVoidResult(NID_NET, pPrimaryDnsAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       ret = connection_profile_get_dns_address(profileHandle, 2, CONNECTION_ADDRESS_FAMILY_IPV4, &pIpAddr);
+       if ((ret == CONNECTION_ERROR_NONE) && (pIpAddr != null))
+       {
+               ipAddr = String(pIpAddr);
+               free(pIpAddr);
+               pIpAddr = null;
+               pSecondaryDnsAddress.reset(new (std::nothrow) Ip4Address(ipAddr));
+               SysTryReturnVoidResult(NID_NET, pSecondaryDnsAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       char* pProxyAddr = null;
+
+       ret = connection_profile_get_proxy_address(profileHandle, CONNECTION_ADDRESS_FAMILY_IPV4, &pProxyAddr);
+       SysLog(NID_NET, "The return value from connection_profile_get_proxy_address() is [%d], Proxy address is [%s]", ret, pProxyAddr);
+       if ((ret == CONNECTION_ERROR_NONE) && (pProxyAddr != null))
+       {
+               proxyAddress = String(pProxyAddr);
+               proxyAddress.Trim();
+               free(pProxyAddr);
+
+               if (!proxyAddress.IsEmpty())
+               {
+                       if ((proxyAddress.StartsWith(_IP4_ADDRESS_DUMMY_ADDRESS, 0)) || (proxyAddress.StartsWith(_IP4_ADDRESS_EMPTY_ADDRESS, 0)))
+                       {
+                               proxyAddress.Clear();
+                               SysLog(NID_NET, "Proxy address is invalid, so clear it.");
+                       }
+               }
+       }
+
+       if (isDefault)
+       {
+               deviceName.Clear();
+       }
+       else
+       {
+               char* pDeviceName = null;
+
+               ret = connection_profile_get_network_interface_name(profileHandle, &pDeviceName);
+               if ((ret == CONNECTION_ERROR_NONE) && (pDeviceName != null))
+               {
+                       deviceName = String(pDeviceName);
+                       free(pDeviceName);
+               }
+       }
+
+       __bearerType = bearerType;
+       __protocolType = protocolType;
+       __apn = apn;
+       __localAddressScheme = localAddressScheme;
+       __dnsAddressScheme = dnsAddressScheme;
+       __proxyAddress = proxyAddress;
+       __deviceName = deviceName;
+
+       __pLocalAddress.reset(pLocalAddress.release());
+       __pSubnetMaskAddress.reset(pSubnetMaskAddress.release());
+       __pDefaultGatewayAddress.reset(pDefaultGatewayAddress.release());
+       __pPrimaryDnsAddress.reset(pPrimaryDnsAddress.release());
+       __pSecondaryDnsAddress.reset(pSecondaryDnsAddress.release());
+}
+
+NetConnectionInfo*
+_NetConnectionInfoImpl::CreateNetConnectionInfoN(void* pProfileHandle)
+{
+       result r = E_SUCCESS;
+
+       unique_ptr<NetConnectionInfo> pNetConnectionInfo;
+       _NetConnectionInfoImpl* pNetConnectionInfoImpl = null;
+
+       SysTryReturn(NID_NET, pProfileHandle != null, null, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. The profile info is null.", GetErrorMessage(E_INVALID_ARG));
+
+       pNetConnectionInfo.reset(new (std::nothrow) NetConnectionInfo());
+       SysTryReturn(NID_NET, pNetConnectionInfo != null, null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       pNetConnectionInfoImpl = _NetConnectionInfoImpl::GetInstance(*pNetConnectionInfo);
+       SysTryReturn(NID_NET, pNetConnectionInfoImpl != null, null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       pNetConnectionInfoImpl->Update(pProfileHandle);
+       r = GetLastResult();
+       SysTryReturn(NID_NET, pNetConnectionInfoImpl != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pNetConnectionInfo.release();
+}
+
+_NetConnectionInfoImpl::_NetConnectionInfoImpl(const _NetConnectionInfoImpl& value)
+{
+       unique_ptr<IpAddress> pLocalAddress;
+       unique_ptr<IpAddress> pSubnetMaskAddress;
+       unique_ptr<IpAddress> pDefaultGatewayAddress;
+       unique_ptr<IpAddress> pPrimaryDnsAddress;
+       unique_ptr<IpAddress> pSecondaryDnsAddress;
+
+       if (value.__pLocalAddress != null)
+       {
+               pLocalAddress.reset(value.__pLocalAddress->CloneN());
+               SysTryReturnVoidResult(NID_NET, pLocalAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       if (value.__pSubnetMaskAddress != null)
+       {
+               pSubnetMaskAddress.reset(value.__pSubnetMaskAddress->CloneN());
+               SysTryReturnVoidResult(NID_NET, pSubnetMaskAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       if (value.__pDefaultGatewayAddress != null)
+       {
+               pDefaultGatewayAddress.reset(value.__pDefaultGatewayAddress->CloneN());
+               SysTryReturnVoidResult(NID_NET, pDefaultGatewayAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       if (value.__pPrimaryDnsAddress != null)
+       {
+               pPrimaryDnsAddress.reset(value.__pPrimaryDnsAddress->CloneN());
+               SysTryReturnVoidResult(NID_NET, pPrimaryDnsAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       if (value.__pSecondaryDnsAddress != null)
+       {
+               pSecondaryDnsAddress.reset(value.__pSecondaryDnsAddress->CloneN());
+               SysTryReturnVoidResult(NID_NET, pSecondaryDnsAddress != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       __bearerType = value.__bearerType;
+       __protocolType = value.__protocolType;
+       __apn = value.__apn;
+       __deviceName = value.__deviceName;
+       __proxyAddress = value.__proxyAddress;
+       __localAddressScheme = value.__localAddressScheme;
+       __dnsAddressScheme = value.__dnsAddressScheme;
+
+       __pLocalAddress.reset(pLocalAddress.release());
+       __pSubnetMaskAddress.reset(pSubnetMaskAddress.release());
+       __pDefaultGatewayAddress.reset(pDefaultGatewayAddress.release());
+       __pPrimaryDnsAddress.reset(pPrimaryDnsAddress.release());
+       __pSecondaryDnsAddress.reset(pSecondaryDnsAddress.release());
+}
+
+_NetConnectionInfoImpl&
+_NetConnectionInfoImpl::operator =(const _NetConnectionInfoImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       unique_ptr<IpAddress> pLocalAddress;
+       unique_ptr<IpAddress> pSubnetMaskAddress;
+       unique_ptr<IpAddress> pDefaultGatewayAddress;
+       unique_ptr<IpAddress> pPrimaryDnsAddress;
+       unique_ptr<IpAddress> pSecondaryDnsAddress;
+
+       if (rhs.__pLocalAddress != null)
+       {
+               pLocalAddress.reset(rhs.__pLocalAddress->CloneN());
+               SysTryReturn(NID_NET, pLocalAddress != null, *this, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       if (rhs.__pSubnetMaskAddress != null)
+       {
+               pSubnetMaskAddress.reset(rhs.__pSubnetMaskAddress->CloneN());
+               SysTryReturn(NID_NET, pSubnetMaskAddress != null, *this, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       if (rhs.__pDefaultGatewayAddress != null)
+       {
+               pDefaultGatewayAddress.reset(rhs.__pDefaultGatewayAddress->CloneN());
+               SysTryReturn(NID_NET, pDefaultGatewayAddress != null, *this, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       if (rhs.__pPrimaryDnsAddress != null)
+       {
+               pPrimaryDnsAddress.reset(rhs.__pPrimaryDnsAddress->CloneN());
+               SysTryReturn(NID_NET, pPrimaryDnsAddress != null, *this, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       if (rhs.__pSecondaryDnsAddress != null)
+       {
+               pSecondaryDnsAddress.reset(rhs.__pSecondaryDnsAddress->CloneN());
+               SysTryReturn(NID_NET, pSecondaryDnsAddress != null, *this, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+
+       __bearerType = rhs.__bearerType;
+       __protocolType = rhs.__protocolType;
+       __apn = rhs.__apn;
+       __deviceName = rhs.__deviceName;
+       __proxyAddress = rhs.__proxyAddress;
+       __localAddressScheme = rhs.__localAddressScheme;
+       __dnsAddressScheme = rhs.__dnsAddressScheme;
+
+       __pLocalAddress.reset(pLocalAddress.release());
+       __pSubnetMaskAddress.reset(pSubnetMaskAddress.release());
+       __pDefaultGatewayAddress.reset(pDefaultGatewayAddress.release());
+       __pPrimaryDnsAddress.reset(pPrimaryDnsAddress.release());
+       __pSecondaryDnsAddress.reset(pSecondaryDnsAddress.release());
+
+       return *this;
+}
+
+bool
+_NetConnectionInfoImpl::Equals(const Object& obj) const
+{
+       const _NetConnectionInfoImpl* pRhs = dynamic_cast <const _NetConnectionInfoImpl*>(&obj);
+
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       if (__bearerType != pRhs->__bearerType ||
+               __protocolType != pRhs->__protocolType ||
+               __apn != pRhs->__apn ||
+               __deviceName != pRhs->__deviceName ||
+               __proxyAddress != pRhs->__proxyAddress ||
+               __localAddressScheme != pRhs->__localAddressScheme ||
+               __dnsAddressScheme != pRhs->__dnsAddressScheme )
+       {
+               return false;
+       }
+
+       if (__pLocalAddress != null && pRhs->__pLocalAddress != null)
+       {
+               if (!__pLocalAddress->Equals(*pRhs->__pLocalAddress))
+               {
+                       return false;
+               }
+       }
+       else if (__pLocalAddress != null || pRhs->__pLocalAddress != null)
+       {
+               return false;
+       }
+
+       if (__pSubnetMaskAddress != null && pRhs->__pSubnetMaskAddress != null)
+       {
+               if (!__pSubnetMaskAddress->Equals(*pRhs->__pSubnetMaskAddress))
+               {
+                       return false;
+               }
+       }
+       else if (__pSubnetMaskAddress != null || pRhs->__pSubnetMaskAddress != null)
+       {
+               return false;
+       }
+
+       if (__pDefaultGatewayAddress != null && pRhs->__pDefaultGatewayAddress != null)
+       {
+               if (!__pDefaultGatewayAddress->Equals(*pRhs->__pDefaultGatewayAddress))
+               {
+                       return false;
+               }
+       }
+       else if (__pDefaultGatewayAddress != null || pRhs->__pDefaultGatewayAddress != null)
+       {
+               return false;
+       }
+
+       if (__pPrimaryDnsAddress != null && pRhs->__pPrimaryDnsAddress != null)
+       {
+               if (!__pPrimaryDnsAddress->Equals(*pRhs->__pPrimaryDnsAddress))
+               {
+                       return false;
+               }
+       }
+       else if (__pPrimaryDnsAddress != null || pRhs->__pPrimaryDnsAddress != null)
+       {
+               return false;
+       }
+
+       if (__pSecondaryDnsAddress != null && pRhs->__pSecondaryDnsAddress != null)
+       {
+               if ( !__pSecondaryDnsAddress->Equals(*pRhs->__pSecondaryDnsAddress))
+               {
+                       return false;
+               }
+       }
+       else if (__pSecondaryDnsAddress != null || pRhs->__pSecondaryDnsAddress != null)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+int
+_NetConnectionInfoImpl::GetHashCode(void) const
+{
+       int hashCode = _HASH_CODE_INITIAL_VALUE;
+
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __bearerType;
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __protocolType;
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __apn.GetHashCode();
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __deviceName.GetHashCode();
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __proxyAddress.GetHashCode();
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __localAddressScheme;
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __dnsAddressScheme;
+
+       if (__pLocalAddress != null)
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __pLocalAddress->GetHashCode();
+       }
+       else
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode;
+       }
+
+       if (__pSubnetMaskAddress != null)
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __pSubnetMaskAddress->GetHashCode();
+       }
+       else
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode;
+       }
+
+       if (__pDefaultGatewayAddress != null)
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __pDefaultGatewayAddress->GetHashCode();
+       }
+       else
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode;
+       }
+
+       if (__pPrimaryDnsAddress != null)
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __pPrimaryDnsAddress->GetHashCode();
+       }
+       else
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode;
+       }
+
+       if (__pSecondaryDnsAddress != null)
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __pSecondaryDnsAddress->GetHashCode();
+       }
+       else
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode;
+       }
+
+       return hashCode;
+}
+
+_NetConnectionInfoImpl*
+_NetConnectionInfoImpl::GetInstance(NetConnectionInfo& netConnectionInfo)
+{
+       return netConnectionInfo.__pNetConnectionInfoImpl;
+}
+
+const _NetConnectionInfoImpl*
+_NetConnectionInfoImpl::GetInstance(const NetConnectionInfo& netConnectionInfo)
+{
+       return netConnectionInfo.__pNetConnectionInfoImpl;
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_NetConnectionManagerImpl.cpp b/src/FNet_NetConnectionManagerImpl.cpp
new file mode 100644 (file)
index 0000000..92b1066
--- /dev/null
@@ -0,0 +1,717 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNet_NetConnectionManagerImpl.cpp
+ * @brief              This is the implementation for the _NetConnectionManagerImpl class.
+ */
+
+#include <pthread.h>
+#include <net_connection.h>
+#include <unique_ptr.h>
+#include <FNetNetConnection.h>
+#include <FNetIManagedNetConnectionEventListener.h>
+#include <FNetNetConnectionManager.h>
+#include <FBaseRtMutexGuard.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FNet_NetTypes.h"
+#include "FNet_ManagedNetConnectionImpl.h"
+#include "FNet_NetConnectionManagerImpl.h"
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNet_SystemNetConnection.h"
+#include "FNet_NetAccountDatabase.h"
+#include "FNet_NetAccountManagerImpl.h"
+#include "FNet_NetConnectionEvent.h"
+#include "FNet_NetUtility.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net
+{
+
+static const int _NET_CONNECTION_LINGER_TIMER_VALUE = 10000;   // 10sec
+
+_NetConnectionManagerImpl* _NetConnectionManagerImpl::__pInstance = null;
+
+_NetConnectionManagerImpl::_NetConnectionManagerImpl()
+       : __managedNetPreference(NET_WIFI_FIRST)
+       , __managedNetAccountId(_DEFAULT_PS_ACCOUNT_ID)
+       , __managedNetRefCount(0)
+       , __isManagedNetDefaultMode(true)
+       , __pManagedSystemNetConnection(null)
+       , __pManagedNetConnectionEvent(null)
+       , __pManagedNetConnectionTimer(null)
+       , __pDefaultConnection(null)
+       , __pWifiConnection(null)
+       , __pPsConnection(null)
+{
+}
+
+_NetConnectionManagerImpl::~_NetConnectionManagerImpl()
+{
+       if (__pManagedNetConnectionTimer != null)
+       {
+               delete __pManagedNetConnectionTimer;
+               __pManagedNetConnectionTimer = null;
+       }
+
+       if (__pManagedNetConnectionEvent != null)
+       {
+               if (__pManagedSystemNetConnection != null)
+               {
+                       __pManagedSystemNetConnection->Stop(*__pManagedNetConnectionEvent, false);
+                       __pManagedSystemNetConnection = null;
+               }
+
+               __pManagedNetConnectionEvent->Release();
+               __pManagedNetConnectionEvent = null;
+       }
+}
+
+result
+_NetConnectionManagerImpl::Construct()
+{
+       result r = E_SUCCESS;
+       _SystemNetConnection* pDefaultConnection = null;
+       _SystemNetConnection* pWifiConnection = null;
+       _SystemNetConnection* pManagedSystemNetConnection = null;
+
+       _SystemNetConnection::InitializeNetworkFramework();
+
+       unique_ptr<Timer> pManagedNetConnectionTimer(new (std::nothrow) Timer());
+       SysTryReturnResult(NID_NET, pManagedNetConnectionTimer != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pManagedNetConnectionTimer->Construct(*this);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       unique_ptr<_NetConnectionEvent> pManagedNetConnectionEvent(new (std::nothrow) _NetConnectionEvent());
+       SysTryReturnResult(NID_NET, pManagedNetConnectionEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pManagedNetConnectionEvent->Construct();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pDefaultConnection = _SystemNetConnection::GetDefaultInstance();
+       r = GetLastResult();
+       SysTryReturnResult(NID_NET, pDefaultConnection != null, r, "Propagating.");
+
+#ifndef _OSP_EMUL_
+               pWifiConnection = _SystemNetConnection::GetWifiInstance();
+               r = GetLastResult();
+               SysTryReturnResult(NID_NET, pWifiConnection != null, r, "Propagating.");
+#endif // !(_OSP_EMUL_)
+
+       pManagedSystemNetConnection = pDefaultConnection;
+
+       r = pManagedSystemNetConnection->AddEvent(*pManagedNetConnectionEvent);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pManagedNetConnectionEvent->SetSystemConnection(pManagedSystemNetConnection);
+
+       __pManagedSystemNetConnection = pManagedSystemNetConnection;
+       __pManagedNetConnectionEvent = pManagedNetConnectionEvent.release();
+       __pManagedNetConnectionTimer = pManagedNetConnectionTimer.release();
+       __pDefaultConnection = pDefaultConnection;
+       __pWifiConnection = pWifiConnection;
+
+       return r;
+}
+
+void
+_NetConnectionManagerImpl::OnTimerExpired(Timer& timer)
+{
+       if ((__pManagedSystemNetConnection != null) &&(__managedNetRefCount == 0))
+       {
+               __pManagedSystemNetConnection->Stop(*__pManagedNetConnectionEvent);
+       }
+}
+
+NetConnection*
+_NetConnectionManagerImpl::CreateNetConnectionN(NetAccountId netAccountId)
+{
+       SysLog(NID_NET, "CreateNetConnectionN() has been called with accountId:%d", netAccountId);
+
+       result r = E_SUCCESS;
+
+       SysTryReturn(NID_NET, ((netAccountId == _DEFAULT_PS_ACCOUNT_ID) ||
+                                                                       (netAccountId == _DEFAULT_WIFI_ACCOUNT_ID) ||
+                                                                       (netAccountId == _DEFAULT_WIFI_DIRECT_ACCOUNT_ID) ||
+                                                                       (netAccountId == _DEFAULT_USB_ACCOUNT_ID) ||
+                                                                       (netAccountId >= _CUSTOM_ACCOUNT_ID_START)),
+                                                                       null, E_INVALID_ACCOUNT, "[%s] Invalid network account. accountId=%d",
+                                                                       GetErrorMessage(E_INVALID_ACCOUNT), netAccountId);
+
+       unique_ptr<NetConnection> pConnection(new (std::nothrow) NetConnection());
+       SysTryReturn(NID_NET, pConnection != null, null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = pConnection->Construct(netAccountId);
+       SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       ClearLastResult();
+
+       return pConnection.release();
+}
+
+ManagedNetConnection*
+_NetConnectionManagerImpl::GetManagedNetConnectionN(void) const
+{
+       ClearLastResult();
+
+       ManagedNetConnection* pConnection = null;
+
+       pConnection = _ManagedNetConnectionImpl::CreateInstanceN();
+
+       return pConnection;
+}
+
+NetPreferenceType
+_NetConnectionManagerImpl::GetNetPreference(void) const
+{
+       ClearLastResult();
+
+       return __managedNetPreference;
+}
+
+result
+_NetConnectionManagerImpl::SetNetPreference(NetPreferenceType netPreference)
+{
+       result r = E_SUCCESS;
+       String accountName;
+#ifndef _OSP_EMUL_
+       _SystemNetConnection* pNewConnection = null;
+#endif // !_OSP_EMUL_
+
+       SysLog(NID_NET, "SetNetPreference() has been called with preference:%d", netPreference);
+
+       SysTryReturnResult(NID_NET, __managedNetRefCount == 0, E_INVALID_OPERATION, "The managed network connection is used.");
+
+       if (netPreference == NET_PS_ONLY)
+       {
+               _NetAccountDatabase::GetAccountName(__managedNetAccountId, accountName);
+               __pPsConnection = _SystemNetConnection::GetPsInstance(__managedNetAccountId);
+       }
+
+       Mutex* pLock = _NetUtility::GetLock();
+       MutexGuard locked(*pLock);
+
+       __managedNetPreference = netPreference;
+
+       if ((__managedNetPreference == NET_WIFI_FIRST) && (__managedNetAccountId == _DEFAULT_PS_ACCOUNT_ID))
+       {
+               __isManagedNetDefaultMode = true;
+       }
+       else
+       {
+               __isManagedNetDefaultMode = false;
+       }
+
+       __pManagedNetConnectionTimer->Cancel();
+
+#ifndef _OSP_EMUL_
+       if (__isManagedNetDefaultMode)
+       {
+               pNewConnection = __pDefaultConnection;
+       }
+       else if (__managedNetPreference == NET_WIFI_ONLY)
+       {
+               pNewConnection = __pWifiConnection;
+       }
+       else if (__managedNetPreference == NET_PS_ONLY)
+       {
+               pNewConnection = __pPsConnection;
+       }
+       else // NET_WIFI_FIRST
+       {
+               if (__pWifiConnection->GetConnectionState() == NET_CONNECTION_STATE_STARTED)
+               {
+                       pNewConnection = __pWifiConnection;
+               }
+               else
+               {
+                       pNewConnection = __pPsConnection;
+               }
+       }
+
+       if (pNewConnection != __pManagedSystemNetConnection)
+       {
+               SysLog(NID_NET, "ManagedNetConnection should be changed. [0x%x] -> [0x%x]",
+                               __pManagedSystemNetConnection, pNewConnection);
+               if (__pManagedSystemNetConnection != null)
+               {
+                       __pManagedSystemNetConnection->Stop(*__pManagedNetConnectionEvent, false);
+                       __pManagedSystemNetConnection->RemoveEvent(*__pManagedNetConnectionEvent);
+                       __pManagedSystemNetConnection = null;
+                       __pManagedNetConnectionEvent->SetConnectionState(NET_CONNECTION_STATE_NONE);
+                       __pManagedNetConnectionEvent->SetSystemConnection(null);
+               }
+
+               if (pNewConnection != null)
+               {
+                       __pManagedSystemNetConnection = pNewConnection;
+                       __pManagedSystemNetConnection->AddEvent(*__pManagedNetConnectionEvent);
+                       __pManagedNetConnectionEvent->SetSystemConnection(__pManagedSystemNetConnection);
+               }
+       }
+#endif // !_OSP_EMUL_
+
+       locked.Unlock();
+
+       return r;
+}
+
+NetConnectionInfo*
+_NetConnectionManagerImpl::GetNetConnectionInfoN(NetAccountId netAccountId)
+{
+       _NetConnectionManagerImpl* pThis = _NetConnectionManagerImpl::GetInstance();
+
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       NetConnectionInfo* pInfo = null;
+       _SystemNetConnection* pSystemNetConnection = null;
+
+       SysTryReturn(NID_NET, pThis != null, null, E_SYSTEM,
+                       "[%s] A system error has been occurred. System is not ready.", GetErrorMessage(E_SYSTEM));
+
+       if (netAccountId == _DEFAULT_WIFI_ACCOUNT_ID)
+       {
+               pSystemNetConnection = _SystemNetConnection::GetWifiInstance();
+       }
+       else if (netAccountId == _DEFAULT_WIFI_DIRECT_ACCOUNT_ID)
+       {
+               pSystemNetConnection = _SystemNetConnection::GetWifiDirectInstance();
+       }
+       else if (netAccountId == _DEFAULT_USB_ACCOUNT_ID)
+       {
+               pSystemNetConnection = _SystemNetConnection::GetUsbInstance();
+       }
+
+       if (pSystemNetConnection != null)
+       {
+               pInfo = new (std::nothrow) NetConnectionInfo();
+               SysTryReturn(NID_NET, pInfo != null, null,
+                               E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               pSystemNetConnection->GetConnectionInfo(*pInfo);
+       }
+       else
+       {
+               String profileName;
+               connection_profile_h profileHandle = null;
+
+               r = _NetAccountDatabase::GetProfileName(netAccountId, profileName);
+               SysTryReturn(NID_NET, r == E_SUCCESS, null, E_INVALID_ACCOUNT,
+                               "[%s] Invalid network account. accountId:%d", GetErrorMessage(E_INVALID_ACCOUNT), netAccountId);
+
+               profileHandle = (void*)_NetAccountManagerImpl::GetPsProfileHandleN(profileName);
+               SysTryReturn(NID_NET, profileHandle != null, null, E_INVALID_ACCOUNT,
+                               "[%s] Invalid network account. accountId:%d", GetErrorMessage(E_INVALID_ACCOUNT), netAccountId);
+
+               pInfo = _NetConnectionInfoImpl::CreateNetConnectionInfoN(profileHandle);
+               connection_profile_destroy(profileHandle);
+       }
+
+       return pInfo;
+}
+
+IList*
+_NetConnectionManagerImpl::GetAllNetConnectionInfoN(void)
+{
+       _NetConnectionManagerImpl* pThis = _NetConnectionManagerImpl::GetInstance();
+       NetConnectionInfo* pInfo = null;
+
+       ClearLastResult();
+
+       SysTryReturn(NID_NET, pThis != null, null, E_SYSTEM,
+                       "[%s] Asystem error has been occurred. System is not ready.", GetErrorMessage(E_SYSTEM));
+
+       unique_ptr<ArrayList, _CollectionDeleter> pList(new (std::nothrow) ArrayList());
+       SysTryReturn(NID_NET, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+#ifdef _OSP_EMUL_
+       const NetConnectionInfo* pManagedNetConnectionInfo = pThis->GetManagedNetConnectionInfo();
+       pInfo = new (std::nothrow) NetConnectionInfo(*pManagedNetConnectionInfo);
+       if (pInfo != null)
+       {
+               pList->Add(*pInfo);
+       }
+#else // _OSP_EMUL_
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = null;
+       connection_profile_iterator_h iterator = null;
+       connection_profile_h profileHandle = null;
+
+       ret = connection_create(&connectionHandle);
+       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_create() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+       unique_ptr<void, _ConnectionDeleter> pConnectionHandle(connectionHandle);
+
+       ret = connection_get_profile_iterator(connectionHandle, CONNECTION_ITERATOR_TYPE_CONNECTED, &iterator);
+       SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_get_profile_iterator() is %d",
+                       GetErrorMessage(E_SYSTEM), ret);
+       unique_ptr<void, _ProfileIteratorDeleter> pIterator(iterator);
+
+       ret = connection_profile_iterator_next(iterator, &profileHandle);
+       while ((ret == CONNECTION_ERROR_NONE) && (profileHandle != null))
+       {
+               pInfo = _NetConnectionInfoImpl::CreateNetConnectionInfoN(profileHandle);
+               if (pInfo != null)
+               {
+                       pList->Add(*pInfo);
+               }
+
+               profileHandle = null;
+               ret = connection_profile_iterator_next(iterator, &profileHandle);
+       }
+#endif // _OSP_EMUL_
+
+       SysLog(NID_NET, "GetAllNetConnectionInfoN() has been succeeded with result:%s, count:%d",
+                       GetErrorMessage(GetLastResult()), pList->GetCount());
+
+       return pList.release();
+}
+
+bool
+_NetConnectionManagerImpl::IsDefaultMode(void)
+{
+       bool ret = false;
+       _NetConnectionManagerImpl* pThis = _NetConnectionManagerImpl::GetInstance();
+
+       SysLog(NID_NET, "Preference:%d, AccountId:%d", pThis->__managedNetPreference, pThis->__managedNetAccountId);
+
+       ret = pThis->__isManagedNetDefaultMode;
+
+       SysLog(NID_NET, "IsDefaultMode() has done with ret(%d).", ret);
+
+       return ret;
+}
+
+String
+_NetConnectionManagerImpl::GetProxyAddress(void)
+{
+       _NetConnectionManagerImpl* pThis = _NetConnectionManagerImpl::GetInstance();
+       String proxyAddress;
+
+       proxyAddress.Clear();
+
+       if (pThis != null)
+       {
+               if (pThis->__pManagedSystemNetConnection != null)
+               {
+                       proxyAddress = pThis->__pManagedSystemNetConnection->GetProxyAddress();
+               }
+       }
+
+       SysLog(NID_NET, "The current value of ProxyAddress is %ls", proxyAddress.GetPointer());
+
+       return proxyAddress;
+}
+
+_NetConnectionManagerImpl*
+_NetConnectionManagerImpl::GetInstance(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       if (__pInstance == null)
+       {
+               ClearLastResult();
+               pthread_once(&onceBlock, InitSingleton);
+               result r = GetLastResult();
+               if (r != E_SUCCESS)
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+               }
+       }
+
+       return __pInstance;
+}
+
+void
+_NetConnectionManagerImpl::InitSingleton(void)
+{
+    result r = E_SUCCESS;
+    static _NetConnectionManagerImpl instance;
+
+    r = instance.Construct();
+       SysTryReturnVoidResult(NID_NET, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       ClearLastResult();
+       __pInstance = &instance;
+}
+
+result
+_NetConnectionManagerImpl::SetManagedNetAccountId(NetAccountId netAccountId)
+{
+       result r = E_SUCCESS;
+       String accountName;
+
+       SysTryReturnResult(NID_NET, __managedNetRefCount == 0, E_INVALID_OPERATION, "The managed network connection is used.");
+       SysTryReturnResult(NID_NET, ((netAccountId == _DEFAULT_PS_ACCOUNT_ID) ||
+                                                                       (netAccountId >= _CUSTOM_ACCOUNT_ID_START)),
+                                                                       E_INVALID_ARG, "Invalid argument is used. accountId=%d", netAccountId);
+
+       r = _NetAccountDatabase::GetAccountName(netAccountId, accountName);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is used. accountId=%d", netAccountId);
+
+       __pPsConnection = _SystemNetConnection::GetPsInstance(netAccountId);
+       SysTryReturnResult(NID_NET, __pPsConnection != null, E_INVALID_ARG, "Invalid argument is used. accountId=%d", netAccountId);
+
+       Mutex* pLock = _NetUtility::GetLock();
+       MutexGuard locked(*pLock);
+
+       __managedNetAccountId = netAccountId;
+
+       if ((__managedNetPreference == NET_WIFI_FIRST) && (__managedNetAccountId == _DEFAULT_PS_ACCOUNT_ID))
+       {
+               __isManagedNetDefaultMode = true;
+       }
+       else
+       {
+               __isManagedNetDefaultMode = false;
+       }
+
+       locked.Unlock();
+
+       return r;
+}
+
+NetAccountId
+_NetConnectionManagerImpl::GetManagedNetAccountId(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET, __pManagedSystemNetConnection != null, INVALID_HANDLE,
+                       E_INVALID_STATE, "[%s] Managed network connection is inactive.", GetErrorMessage(E_INVALID_STATE));
+
+       SysTryReturn(NID_NET, GetManagedNetConnectionState() == NET_CONNECTION_STATE_STARTED, INVALID_HANDLE,
+                       E_INVALID_STATE, "[%s] Managed network connection is inactive.",GetErrorMessage(E_INVALID_STATE));
+
+       if (__pManagedSystemNetConnection->GetBearerType() == NET_BEARER_WIFI)
+       {
+               return _DEFAULT_WIFI_ACCOUNT_ID;
+       }
+       else
+       {
+               return __managedNetAccountId;
+       }
+}
+
+NetConnectionState
+_NetConnectionManagerImpl::GetManagedNetConnectionState(void) const
+{
+       if ((__isManagedNetDefaultMode) && (__pManagedSystemNetConnection != null))
+       {
+               return __pManagedSystemNetConnection->GetConnectionState();
+       }
+       else
+       {
+               return __pManagedNetConnectionEvent->GetConnectionState();
+       }
+}
+
+NetConnectionState
+_NetConnectionManagerImpl::QueryManagedNetConnectionState(String& devName) const
+{
+       if (__pManagedSystemNetConnection != null)
+       {
+               return __pManagedSystemNetConnection->QueryConnectionState(devName);
+       }
+       else
+       {
+               return __pManagedNetConnectionEvent->GetConnectionState();
+       }
+}
+
+const NetConnectionInfo*
+_NetConnectionManagerImpl::GetManagedNetConnectionInfo(void)
+{
+       _NetConnectionInfoImpl* pInfoImpl = null;
+
+       if ((__pManagedSystemNetConnection != null) &&
+               (GetManagedNetConnectionState() == NET_CONNECTION_STATE_STARTED))
+       {
+               __pManagedSystemNetConnection->GetConnectionInfo(__managedNetConnectionInfo);
+       }
+       else
+       {
+               pInfoImpl = _NetConnectionInfoImpl::GetInstance(__managedNetConnectionInfo);
+               if (pInfoImpl != null)
+               {
+                       pInfoImpl->Clear();
+               }
+       }
+
+       return &__managedNetConnectionInfo;
+}
+
+result
+_NetConnectionManagerImpl::AddManagedNetConnectionEventListener(IManagedNetConnectionEventListener& listener,
+               const ManagedNetConnection* pConnection)
+{
+       result r = E_SUCCESS;
+
+       r = __pManagedNetConnectionEvent->AddNetConnectionEventListener(listener, pConnection);
+
+       SysLog(NID_NET, "AddManagedNetConnectionEventListener() has done with result:%s", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+_NetConnectionManagerImpl::RemoveManagedNetConnectionEventListener(IManagedNetConnectionEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       r = __pManagedNetConnectionEvent->RemoveNetConnectionEventListener(listener);
+
+       SysLog(NID_NET, "RemoveManagedNetConnectionEventListener() has done with result:%s", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+_NetConnectionManagerImpl::AddRefManagedNetConnection(void)
+{
+       result r = E_SUCCESS;
+#ifndef _OSP_EMUL_
+       _SystemNetConnection* pNewConnection = null;
+#endif // !_OSP_EMUL_
+
+       Mutex* pLock = _NetUtility::GetLock();
+       MutexGuard locked(*pLock);
+
+#ifdef _OSP_EMUL_
+       r = __pManagedSystemNetConnection->Start(*__pManagedNetConnectionEvent);
+#else // _OSP_EMUL_
+       if (__managedNetRefCount == 0)
+       {
+               __pManagedNetConnectionTimer->Cancel();
+
+               if (IsDefaultMode())
+               {
+                       pNewConnection = __pDefaultConnection;
+               }
+               else if (__managedNetPreference == NET_WIFI_ONLY)
+               {
+                       pNewConnection = __pWifiConnection;
+               }
+               else if (__managedNetPreference == NET_PS_ONLY)
+               {
+                       pNewConnection = __pPsConnection;
+               }
+               else // NET_WIFI_FIRST
+               {
+                       if (__pWifiConnection->GetConnectionState() == NET_CONNECTION_STATE_STARTED)
+                       {
+                               pNewConnection = __pWifiConnection;
+                       }
+                       else
+                       {
+                               pNewConnection = __pPsConnection;
+                       }
+               }
+       }
+       else
+       {
+               pNewConnection = __pManagedSystemNetConnection;
+       }
+
+       if (pNewConnection != __pManagedSystemNetConnection)
+       {
+               SysLog(NID_NET, "ManagedNetConnection should be changed. [0x%x] -> [0x%x]",
+                               __pManagedSystemNetConnection, pNewConnection);
+               if (__pManagedSystemNetConnection != null)
+               {
+                       __pManagedSystemNetConnection->Stop(*__pManagedNetConnectionEvent, false);
+                       __pManagedSystemNetConnection->RemoveEvent(*__pManagedNetConnectionEvent);
+                       __pManagedSystemNetConnection = null;
+                       __pManagedNetConnectionEvent->SetConnectionState(NET_CONNECTION_STATE_NONE);
+                       __pManagedNetConnectionEvent->SetSystemConnection(null);
+               }
+
+               if (pNewConnection != null)
+               {
+                       __pManagedSystemNetConnection = pNewConnection;
+                       __pManagedSystemNetConnection->AddEvent(*__pManagedNetConnectionEvent);
+                       __pManagedNetConnectionEvent->SetSystemConnection(__pManagedSystemNetConnection);
+               }
+       }
+
+       if (__pManagedSystemNetConnection != null)
+       {
+               SysLog(NID_NET, "Start a ManagedNetConnection.");
+               r = __pManagedSystemNetConnection->Start(*__pManagedNetConnectionEvent);
+       }
+       else
+       {
+               r = E_CONNECTION_FAILED;
+               SysLogException(NID_NET, r, "[%s] Network is unavailable. preference[%d], accountId[%d]",
+                               GetErrorMessage(E_CONNECTION_FAILED), __managedNetPreference, __managedNetAccountId);
+       }
+#endif // !_OSP_EMUL_
+
+       if (r == E_SUCCESS)
+       {
+               __managedNetRefCount++;
+       }
+
+       locked.Unlock();
+
+       SysLog(NID_NET, "AddRefManagedNetConnection() has done with result:%s", GetErrorMessage(r));
+
+       return r;
+}
+
+void
+_NetConnectionManagerImpl::ReleaseManagedNetConnection(void)
+{
+       result r = E_SUCCESS;
+
+       Mutex* pLock = _NetUtility::GetLock();
+       MutexGuard locked(*pLock);
+
+       __managedNetRefCount--;
+
+       if (__managedNetRefCount == 0)
+       {
+               SysLog(NID_NET, "ManagedNetConnection is not used any more, so start a linger timer.");
+               r = __pManagedNetConnectionTimer->Cancel();
+               r = __pManagedNetConnectionTimer->Start(_NET_CONNECTION_LINGER_TIMER_VALUE);
+       }
+
+       locked.Unlock();
+}
+
+_NetConnectionManagerImpl*
+_NetConnectionManagerImpl::GetInstance(NetConnectionManager& netConnectionManager)
+{
+       return netConnectionManager.__pNetConnectionManagerImpl;
+}
+
+const _NetConnectionManagerImpl*
+_NetConnectionManagerImpl::GetInstance(const NetConnectionManager& netConnectionManager)
+{
+       return netConnectionManager.__pNetConnectionManagerImpl;
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_NetEndPointImpl.cpp b/src/FNet_NetEndPointImpl.cpp
new file mode 100644 (file)
index 0000000..599ae2b
--- /dev/null
@@ -0,0 +1,272 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_NetEndPointImpl.cpp
+ * @brief              This is the implementation for the _NetEndPointImpl class.
+ */
+
+#include <FBaseShort.h>
+#include <FNetNetEndPoint.h>
+#include <FNetIp4Address.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_Ip4AddressImpl.h"
+#include "FNet_NetEndPointImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net
+{
+
+static const String _IP_PORT_DELIMITER_STRING = L":";
+static const String _INVALID_NET_END_POINT_STRING = L"";
+
+_NetEndPointImpl::_NetEndPointImpl(void)
+       : __pIpAddress(null)
+       , __port(0)
+{
+}
+
+_NetEndPointImpl::_NetEndPointImpl(const IpAddress& ipAddress, unsigned short port)
+       : __pIpAddress(null)
+       , __port(0)
+{
+       ClearLastResult();
+
+       SysTryReturnVoidResult(NID_NET, ipAddress.GetNetAddressFamily() != NET_AF_NONE,
+                       E_INVALID_ARG, "[%s] Invalid argument is used. IP address is invalid.", GetErrorMessage(E_INVALID_ARG));
+
+       __pIpAddress.reset(ipAddress.CloneN());
+       SysTryReturnVoidResult(NID_NET, __pIpAddress != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __port = port;
+}
+
+_NetEndPointImpl::_NetEndPointImpl(const _NetEndPointImpl& value)
+       : __pIpAddress(null)
+       , __port(0)
+{
+       ClearLastResult();
+
+       SysTryReturnVoidResult(NID_NET, value.__pIpAddress != null, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. The instance is invalid.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturnVoidResult(NID_NET, value.__pIpAddress->GetNetAddressFamily() != NET_AF_NONE, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. The instance is invalid.", GetErrorMessage(E_INVALID_ARG));
+
+       __pIpAddress.reset(value.__pIpAddress->CloneN());
+       SysTryReturnVoidResult(NID_NET, __pIpAddress != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       __port = value.__port;
+}
+
+_NetEndPointImpl::~_NetEndPointImpl()
+{
+       __port = 0;
+}
+
+NetAddressFamily
+_NetEndPointImpl::GetNetAddressFamily(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET, __pIpAddress != null, NET_AF_NONE, E_INVALID_STATE,
+                       "[%s] The object is in invalid state.", GetErrorMessage(E_INVALID_STATE));
+
+       return __pIpAddress->GetNetAddressFamily();
+}
+
+unsigned short
+_NetEndPointImpl::GetPort(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET, __pIpAddress != null, 0, E_INVALID_STATE,
+                       "[%s] The object is in invalid state.", GetErrorMessage(E_INVALID_STATE));
+
+       return __port;
+}
+
+IpAddress*
+_NetEndPointImpl::GetAddress(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET, __pIpAddress != null, null, E_INVALID_STATE,
+                       "[%s] The object is in invalid state.", GetErrorMessage(E_INVALID_STATE));
+
+       return __pIpAddress.get();
+}
+
+String
+_NetEndPointImpl::GetNetEndPoint(void) const
+{
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       String netEndPoint;
+       String ipAddress;
+       String port;
+
+       SysTryCatch(NID_NET, __pIpAddress != null, , E_INVALID_STATE,
+                       "[%s] The object is in invalid state.", GetErrorMessage(E_INVALID_STATE));
+
+// 1. set port to String
+       port = Short::ToString(__port);
+
+// 2. set IpAddress to String
+       ipAddress = __pIpAddress->ToString();
+       SysTryCatch(NID_NET, !ipAddress.IsEmpty(), , E_INVALID_STATE,
+                       "[%s] The object is in invalid state.", GetErrorMessage(E_INVALID_STATE));
+
+// 3. Append IpAddress + port into one
+       netEndPoint.Clear();
+
+       r = netEndPoint.Append(ipAddress);
+       SysTryCatch(NID_NET, r == E_SUCCESS, , E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = netEndPoint.Append(_IP_PORT_DELIMITER_STRING);
+       SysTryCatch(NID_NET, r == E_SUCCESS, , E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = netEndPoint.Append(port);
+       SysTryCatch(NID_NET, r == E_SUCCESS, , E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       return netEndPoint;
+
+CATCH:
+       return _INVALID_NET_END_POINT_STRING;
+}
+
+bool
+_NetEndPointImpl::IsValid(void) const
+{
+       if (__pIpAddress != null)
+       {
+               return true;
+       }
+
+       return false;
+}
+
+result
+_NetEndPointImpl::Update(const IpAddress& ipAddress, unsigned short port)
+{
+       SysTryReturnResult(NID_NET, ipAddress.GetNetAddressFamily() != NET_AF_NONE, E_INVALID_ARG,
+                       "Invalid argument is used. IP address is invalid.");
+
+       std::unique_ptr<IpAddress> pIpAddress(ipAddress.CloneN());
+       SysTryReturnResult(NID_NET, pIpAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       __pIpAddress.reset(pIpAddress.release());
+       __port = port;
+
+       return E_SUCCESS;
+}
+
+_NetEndPointImpl&
+_NetEndPointImpl::operator =(const _NetEndPointImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       if (rhs.__pIpAddress != null)
+       {
+               std::unique_ptr<IpAddress> pIpAddress(rhs.__pIpAddress->CloneN());
+               SysTryReturn(NID_NET, pIpAddress != null, *this, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               __pIpAddress.reset(pIpAddress.release());
+       }
+       else
+       {
+               __pIpAddress.reset(null);
+       }
+
+       __port = rhs.__port;
+
+       return *this;
+}
+
+bool
+_NetEndPointImpl::Equals(const Object& obj) const
+{
+       const _NetEndPointImpl* pObj = dynamic_cast <const _NetEndPointImpl*>(&obj);
+
+       if (pObj == null)
+       {
+               return false;
+       }
+
+       if ((__pIpAddress != null) && (pObj->__pIpAddress != null))
+       {
+               if (__pIpAddress->Equals(*pObj->__pIpAddress) == false)
+               {
+                       return false;
+               }
+       }
+       else if ((__pIpAddress != null) || (pObj->__pIpAddress != null))
+       {
+               return false;
+       }
+
+       if (__port != pObj->__port)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+int
+_NetEndPointImpl::GetHashCode(void) const
+{
+       int hashCode = _HASH_CODE_INITIAL_VALUE;
+
+       if (__pIpAddress != null)
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __pIpAddress->GetHashCode();
+       }
+       else
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode;
+       }
+
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __port;
+
+       return hashCode;
+}
+
+_NetEndPointImpl*
+_NetEndPointImpl::GetInstance(NetEndPoint& netEndPoint)
+{
+       return netEndPoint.__pNetEndPointImpl;
+}
+
+const _NetEndPointImpl*
+_NetEndPointImpl::GetInstance(const NetEndPoint& netEndPoint)
+{
+       return netEndPoint.__pNetEndPointImpl;
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_NetExporter.cpp b/src/FNet_NetExporter.cpp
new file mode 100644 (file)
index 0000000..0f83ef8
--- /dev/null
@@ -0,0 +1,61 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_NetExporter.cpp
+ * @brief              This is the implementation for the %_NetExporter class.
+ */
+
+#include <unique_ptr.h>
+#include <FNetNetAccountInfo.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetAccountInfoImpl.h"
+#include "FNet_NetExporter.h"
+
+using namespace std;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net
+{
+
+_NetExporter::_NetExporter(void)
+{
+}
+
+_NetExporter::~_NetExporter(void)
+{
+}
+
+result
+_NetExporter::InitializeNetAccountInfo(NetAccountInfo* pAccountInfo, void* pProfileInfo)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET, pAccountInfo != null, E_INVALID_ARG, "Invalid argument is used. AccountInfo is null.");
+       SysTryReturnResult(NID_NET, pProfileInfo != null, E_INVALID_ARG, "Invalid argument is used. ProfileInfo is null.");
+
+       unique_ptr<_NetAccountInfoImpl> pNetAccountInfoImpl(new (std::nothrow) _NetAccountInfoImpl());
+       SysTryReturnResult(NID_NET, pNetAccountInfoImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pNetAccountInfoImpl->Construct(pAccountInfo, pProfileInfo);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       pNetAccountInfoImpl.release();
+
+       return r;
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_NetIpcMessages.cpp b/src/FNet_NetIpcMessages.cpp
new file mode 100644 (file)
index 0000000..a2d995f
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNet_NetIpcMessages.cpp
+ * @brief   This is the generator of IPC messages for the Connectivity service daemon.
+ */
+
+#define IPC_MESSAGE_IMPL
+#include "FNet_ConnectivityIpcMessages.h"
+
+// Generate constructors.
+#include <ipc/struct_constructor_macros.h>
+#include "FNet_ConnectivityIpcMessages.h"
+
+// Generate destructors.
+#include <ipc/struct_destructor_macros.h>
+#include "FNet_ConnectivityIpcMessages.h"
+
+// Generate param traits write methods.
+#include <ipc/param_traits_write_macros.h>
+namespace IPC {
+#include "FNet_ConnectivityIpcMessages.h"
+}  // namespace IPC
+
+// Generate param traits read methods.
+#include <ipc/param_traits_read_macros.h>
+namespace IPC {
+#include "FNet_ConnectivityIpcMessages.h"
+}  // namespace IPC
diff --git a/src/FNet_NetIpcProxy.cpp b/src/FNet_NetIpcProxy.cpp
new file mode 100644 (file)
index 0000000..16c14ea
--- /dev/null
@@ -0,0 +1,161 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FTel_NetIpcProxy.cpp
+ * @brief   This is the implementation file for the %_NetIpcProxy class.
+ *
+ * This file contains the implementation of the %_NetIpcProxy class.
+ */
+
+
+#include <pthread.h>
+#include <FBaseSysLog.h>
+#include <FBaseString.h>
+#include <FNetNetTypes.h>
+#include <FIo_IpcClient.h>
+#include <FNet_ConnectivityIpcMessages.h>
+#include "FNet_NetAccountDatabase.h"
+#include "FNet_NetIpcProxy.h"
+#include "FNet_NetAccountInfoImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Net
+{
+
+_NetIpcProxy* _NetIpcProxy::__pInstance = null;
+
+_NetIpcProxy::_NetIpcProxy(void)
+       : __pIpcClient(null)
+{
+}
+
+_NetIpcProxy::~_NetIpcProxy(void)
+{
+}
+
+result
+_NetIpcProxy::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       unique_ptr<_IpcClient> pIpcClient(new (std::nothrow) _IpcClient());
+       SysTryReturnResult(NID_NET, pIpcClient != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pIpcClient->Construct(NET_CONNECTIVITY_IPC_SERVER_NAME, null);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       __pIpcClient = move(pIpcClient);
+
+       return r;
+}
+
+_NetIpcProxy*
+_NetIpcProxy::GetInstance(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       if (__pInstance == null)
+       {
+               ClearLastResult();
+               pthread_once(&onceBlock, InitSingleton);
+               result r = GetLastResult();
+               if (r != E_SUCCESS)
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+               }
+       }
+
+       return __pInstance;
+}
+
+void
+_NetIpcProxy::InitSingleton(void)
+{
+    result r = E_SUCCESS;
+    static _NetIpcProxy instance;
+
+    r = instance.Construct();
+       SysTryReturnVoidResult(NID_NET, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pInstance = &instance;
+}
+
+result
+_NetIpcProxy::UpdateSystemNetAccount(const String& profileName, const NetAccountInfo& netAccountInfo, NetBearerType bearerType)
+{
+       result r = E_SUCCESS;
+       unsigned long ret = 0;
+
+       unique_ptr<IPC::Message> pMessage(new (std::nothrow) ConnectivityNetServiceMsg_updateSystemNetAccount(profileName, netAccountInfo, bearerType, &ret));
+       SysTryReturnResult(NID_NET, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pIpcClient->SendRequest(*pMessage);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+       SysTryReturnResult(NID_NET, ret == E_SUCCESS, ret, "Propagating.");
+
+       return r;
+}
+result
+_NetIpcProxy::GetAppNetAccountId(const String& netProfileName, NetAccountId& netAccountId) const
+{
+       SysLog(NID_NET, "GetAppNetAccountId() has been called with profileName:%ls", netProfileName.GetPointer());
+
+       result r = E_SUCCESS;
+       int accountId = INVALID_HANDLE;
+       unsigned long ret = 0;
+
+       unique_ptr<IPC::Message> pMessage(new (std::nothrow) ConnectivityNetServiceMsg_getAppNetAccountId(netProfileName, &accountId, &ret));
+       SysTryReturnResult(NID_NET, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pIpcClient->SendRequest(*pMessage);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+       SysTryReturnResult(NID_NET, ret == E_SUCCESS, ret, "Propagating.");
+       netAccountId = static_cast<NetAccountId>(accountId);
+
+       SysLog(NID_NET, "GetAppNetAccountId() has done with accountId:%d", netAccountId);
+
+       return r;
+}
+
+result
+_NetIpcProxy::SetNetAccountId(NetAccountId netAccountId, NetAccountId& netAccountId2)
+{
+       SysLog(NID_NET, "SetNetAccountId() has been called with accountId:%d", netAccountId);
+
+       result r = E_SUCCESS;
+       int accountId = INVALID_HANDLE;
+       unsigned long ret = 0;
+
+       unique_ptr<IPC::Message> pMessage(new (std::nothrow) ConnectivityNetServiceMsg_setNetAccountId(netAccountId, &accountId, &ret));
+       SysTryReturnResult(NID_NET, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pIpcClient->SendRequest(*pMessage);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred.");
+       SysTryReturnResult(NID_NET, ret == E_SUCCESS, ret, "Propagating.");
+
+       netAccountId2 = static_cast<NetAccountId>(accountId);
+
+       SysLog(NID_NET, "SetNetAccountId() has done with accountId:%d", netAccountId2);
+
+       return r;
+}
+
+}} // Tizen::Net
diff --git a/src/FNet_NetIpcProxy.h b/src/FNet_NetIpcProxy.h
new file mode 100644 (file)
index 0000000..292120a
--- /dev/null
@@ -0,0 +1,78 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FNet_NetIpcProxy.h
+ * @brief      This is the header file for the %_NetIpcProxy class.
+ *
+ * This header file contains the declarations of the %_NetIpcProxy class.
+ */
+
+#ifndef _FNET_INTERNAL_NET_IPC_PROXY_H_
+#define _FNET_INTERNAL_NET_IPC_PROXY_H_
+
+#include <FBaseObject.h>
+#include "FNet_NetUtility.h"
+
+// Forward declaration
+namespace Tizen { namespace Base
+{
+class String;
+} }
+
+namespace Tizen { namespace Io
+{
+class _IpcClient;
+} }
+
+namespace Tizen { namespace Net
+{
+
+/**
+ * @class   _NetIpcProxy
+ * @brief   This class represents an IPC proxy for %Net service.
+ *
+ * This class represents an IPC proxy for %Net service to communicate with OSP Connectivity daemon.
+ */
+class _NetIpcProxy
+       : public Tizen::Base::Object
+{
+public:
+       static _NetIpcProxy* GetInstance(void);
+
+       result GetAppNetAccountId(const Tizen::Base::String& netProfileName, NetAccountId& netAccountId) const;
+       result SetNetAccountId(NetAccountId netAccountId, NetAccountId& netAccountId2);
+       result UpdateSystemNetAccount(const Tizen::Base::String& profileName, const NetAccountInfo& netAccountInfo, NetBearerType bearerType);
+
+private:
+       _NetIpcProxy(void);
+       virtual ~_NetIpcProxy(void);
+       result Construct(void);
+
+       _NetIpcProxy(const _NetIpcProxy& value);
+       _NetIpcProxy& operator =(const _NetIpcProxy& rhs);
+
+       static void InitSingleton(void);
+
+private:
+       std::unique_ptr<Tizen::Io::_IpcClient> __pIpcClient;
+       static _NetIpcProxy* __pInstance;
+
+}; // _NetIpcProxy
+
+}}
+#endif // _FNET_INTERNAL_NET_IPC_PROXY_H_
diff --git a/src/FNet_NetStatisticsImpl.cpp b/src/FNet_NetStatisticsImpl.cpp
new file mode 100644 (file)
index 0000000..bd595da
--- /dev/null
@@ -0,0 +1,329 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_NetStatisticsImpl.cpp
+ * @brief              This is the implementation for the FNet_NetStatisticsImpl class.
+ */
+
+#include <net_connection.h>
+#include <FNetNetTypes.h>
+#include <FNetNetStatistics.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNet_NetStatisticsImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net
+{
+
+_NetStatisticsImpl::_NetStatisticsImpl(void)
+       : __isConstructed(false)
+{
+}
+
+_NetStatisticsImpl::~_NetStatisticsImpl(void)
+{
+}
+
+result
+_NetStatisticsImpl::Construct()
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(!__isConstructed,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       __isConstructed = true;
+
+       return r;
+}
+
+long long
+_NetStatisticsImpl::GetNetStatisticsInfo(NetBearerType operationMode, NetStatisticsInfoType netStatType) const
+{
+       int err = CONNECTION_ERROR_NONE;
+       long long returnVal = INVALID_HANDLE;
+
+       ClearLastResult();
+
+       SysAssertf(__isConstructed, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturn(NID_NET, (operationMode == NET_BEARER_WIFI || operationMode == NET_BEARER_PS), INVALID_HANDLE, E_INVALID_ARG,
+                       "[%s] Invalid argument is used. operationMode=%d", GetErrorMessage(E_INVALID_ARG), operationMode);
+
+       //get net statistics info based on type
+       switch (netStatType)
+       {
+       //supported cases
+       case NET_STAT_RCVD_SIZE:
+               if (operationMode == NET_BEARER_PS)
+               {
+                       err = connection_get_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &returnVal);
+                       SysLog(NID_NET, "Bearer type: NET_BEARER_PS, Statistics type: NET_STAT_RCVD_SIZE, Value returned: %d", returnVal);
+               }
+               else if (operationMode == NET_BEARER_WIFI)
+               {
+                       err = connection_get_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &returnVal);
+                       SysLog(NID_NET, "Bearer type: NET_BEARER_WIFI, Statistics type: NET_STAT_RCVD_SIZE, Value returned: %d", returnVal);
+               }
+               else
+               {
+                       // should not reach here.
+                       SysLog(NID_NET, "_NetStatisticsImpl::GetNetStatisticsInfo invalid mode: %d", operationMode);
+                       SysTryReturn(NID_NET, false, INVALID_HANDLE, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+               }
+
+               break;
+
+       case NET_STAT_SENT_SIZE:
+               if (operationMode == NET_BEARER_PS)
+               {
+                       err = connection_get_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &returnVal);
+                       SysLog(NID_NET, "Bearer type: NET_BEARER_PS, Statistics type: NET_STAT_SENT_SIZE, Value returned: %d", returnVal);
+               }
+               else if (operationMode == NET_BEARER_WIFI)
+               {
+                       err = connection_get_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &returnVal);
+                       SysLog(NID_NET, "Bearer type: NET_BEARER_WIFI, Statistics type :NET_STAT_SENT_SIZE, Value returned: %d", returnVal);
+               }
+               else
+               {
+                       // should not reach here.
+                       SysLog(NID_NET, "_NetStatisticsImpl::GetNetStatisticsInfo invalid mode: %d", operationMode);
+                       SysTryReturn(NID_NET, false, INVALID_HANDLE, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+               }
+
+               break;
+
+       case NET_STAT_TOTAL_RCVD_SIZE:
+               if (operationMode == NET_BEARER_PS)
+               {
+                       err = connection_get_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &returnVal);
+                       SysLog(NID_NET, "Bearer type: NET_BEARER_PS, Statistics type: NET_STAT_TOTAL_RCVD_SIZE, Value returned: %d", returnVal);
+               }
+               else if (operationMode == NET_BEARER_WIFI)
+               {
+                       err = connection_get_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &returnVal);
+                       SysLog(NID_NET, "Bearer type: NET_BEARER_WIFI, Statistics type: NET_STAT_TOTAL_RCVD_SIZE, Value returned: %d", returnVal);
+               }
+               else
+               {
+                       // should not reach here.
+                       SysLog(NID_NET, "_NetStatisticsImpl::GetNetStatisticsInfo invalid mode: %d", operationMode);
+                       SysTryReturn(NID_NET, false, INVALID_HANDLE, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+               }
+
+               break;
+
+       case NET_STAT_TOTAL_SENT_SIZE:
+               if (operationMode == NET_BEARER_PS)
+               {
+                       err = connection_get_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &returnVal);
+                       SysLog(NID_NET, "Bearer type: NET_BEARER_PS, Statistics type: NET_STAT_TOTAL_SENT_SIZE, Value returned: %d", returnVal);
+               }
+               else if (operationMode == NET_BEARER_WIFI)
+               {
+                       err = connection_get_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &returnVal);
+                       SysLog(NID_NET, "Bearer type: NET_BEARER_WIFI, Statistics type: NET_STAT_TOTAL_SENT_SIZE, Value returned: %d", returnVal);
+               }
+               else
+               {
+                       // should not reach here.
+                       SysLog(NID_NET, "_NetStatisticsImpl::GetNetStatisticsInfo invalid mode: %d", operationMode);
+                       SysTryReturn(NID_NET, false, INVALID_HANDLE, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+               }
+
+               break;
+
+       default:
+               SysTryReturn(NID_NET, false, INVALID_HANDLE, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+
+               break;
+       }
+
+       // make sure u catch error
+       SysLog(NID_NET, "_NetStatisticsImpl::GetNetStatisticsInfo err code: %d", err);
+       SysTryReturn(NID_NET, err == CONNECTION_ERROR_NONE, INVALID_HANDLE, E_SYSTEM,
+                       "[%s] A system error has been occurred. Operation failed .", GetErrorMessage(E_SYSTEM));
+
+       return returnVal;
+}
+
+result
+_NetStatisticsImpl::Reset(NetBearerType operationMode, NetStatisticsInfoType netStatType)
+{
+       int err = CONNECTION_ERROR_NONE;
+
+       SysAssertf(__isConstructed, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturnResult(NID_NET, (operationMode == NET_BEARER_WIFI || operationMode == NET_BEARER_PS),
+                       E_INVALID_ARG, "Invalid argument is used.");
+
+       //Reset net statistics info based on type
+       switch (netStatType)
+       {
+       //supported cases
+       case NET_STAT_RCVD_SIZE:
+               if (operationMode == NET_BEARER_PS)
+               {
+                       err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
+               }
+               else if (operationMode == NET_BEARER_WIFI)
+               {
+                       err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
+               }
+               else
+               {
+                       // should not reach here.
+                       SysLog(NID_NET, "_NetStatisticsImpl::Reset invalid mode: %d", operationMode);
+                       SysTryReturnResult(NID_NET, false, E_INVALID_ARG, "Invalid argument is used.");
+               }
+
+               break;
+
+       case NET_STAT_SENT_SIZE:
+               if (operationMode == NET_BEARER_PS)
+               {
+                       err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
+               }
+               else if (operationMode == NET_BEARER_WIFI)
+               {
+                       err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
+               }
+               else
+               {
+                       // should not reach here.
+                       SysLog(NID_NET, "_NetStatisticsImpl::Reset invalid mode: %d", operationMode);
+                       SysTryReturnResult(NID_NET, false, E_INVALID_ARG, "Invalid argument is used.");
+               }
+
+               break;
+
+       case NET_STAT_TOTAL_RCVD_SIZE:
+               if (operationMode == NET_BEARER_PS)
+               {
+                       err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
+               }
+               else if (operationMode == NET_BEARER_WIFI)
+               {
+                       err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
+               }
+               else
+               {
+                       // should not reach here.
+                       SysLog(NID_NET, "_NetStatisticsImpl::Reset invalid mode: %d", operationMode);
+                       SysTryReturnResult(NID_NET, false, E_INVALID_ARG, "Invalid argument is used.");
+               }
+
+               break;
+
+       case NET_STAT_TOTAL_SENT_SIZE:
+               if (operationMode == NET_BEARER_PS)
+               {
+                       err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
+               }
+               else if (operationMode == NET_BEARER_WIFI)
+               {
+                       err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
+               }
+               else
+               {
+                       // should not reach here.
+                       SysLog(NID_NET, "_NetStatisticsImpl::Reset invalid mode: %d", operationMode);
+                       SysTryReturnResult(NID_NET, false, E_INVALID_ARG, "Invalid argument is used.");
+               }
+
+               break;
+
+       default:
+               SysTryReturnResult(NID_NET, false, E_INVALID_ARG, "Invalid argument is used.");
+
+               break;
+       }
+
+       // make sure u catch error
+       SysLog(NID_NET, "_NetStatisticsImpl::Reset err code: %d", err);
+       SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM,     "A system error has been occurred. Operation failed .");
+
+       return E_SUCCESS;
+}
+
+result
+_NetStatisticsImpl::ResetAll(NetBearerType operationMode)
+{
+       int err = CONNECTION_ERROR_NONE;
+
+       SysAssertf(__isConstructed, "Not yet constructed. Construct() should be called before use.");
+
+       //we support only PS and WIFI
+       if (operationMode == NET_BEARER_PS)
+       {
+               err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
+               SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed .");
+
+               err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
+               SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed .");
+
+               err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
+               SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed .");
+
+               err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
+               SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed .");
+
+       }
+       else if (operationMode == NET_BEARER_WIFI)
+       {
+               err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
+               SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed .");
+
+               err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
+               SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed .");
+
+               err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
+               SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed .");
+
+               err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
+               SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed .");
+       }
+       else
+       {
+               // we dont support other bearer types
+               SysTryReturnResult(NID_NET, false, E_INVALID_ARG, "Invalid argument is used.");
+
+       }
+
+       // make sure u catch error
+       SysLog(NID_NET, "_NetStatisticsImpl::ResetAll err code: %d", err);
+       SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed .");
+
+       return E_SUCCESS;
+}
+
+_NetStatisticsImpl*
+_NetStatisticsImpl::GetInstance(NetStatistics& netStatistics)
+{
+       return netStatistics.__pNetStatisticsImpl;      
+}
+
+const _NetStatisticsImpl*
+_NetStatisticsImpl::GetInstance(const NetStatistics& netStatistics)
+{
+       return netStatistics.__pNetStatisticsImpl;
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_NetStatisticsImpl.h b/src/FNet_NetStatisticsImpl.h
new file mode 100644 (file)
index 0000000..ee844a8
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_NetStatisticsImpl.h
+ * @brief              This is the header file for the _NetStatisticsImpl class.
+ */
+
+#ifndef _FNET_INTERNAL_NET_STATISTICS_IMPL_H_
+#define _FNET_INTERNAL_NET_STATISTICS_IMPL_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FNetNetTypes.h>
+
+namespace Tizen { namespace Net
+{
+class NetStatistics;
+
+class _NetStatisticsImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       _NetStatisticsImpl(void);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_NetStatisticsImpl(void);
+
+       /**
+        * @see                 NetStatistics::Construct()
+        */
+       result Construct(void);
+
+public:
+       /**
+        * @see                 NetStatistics::GetNetStatisticsInfo()
+        */
+       long long GetNetStatisticsInfo(NetBearerType bearerType, NetStatisticsInfoType netStatType) const;
+
+       /**
+        * @see                 NetStatistics::Reset()
+        */
+       result Reset(NetBearerType bearerType, NetStatisticsInfoType netStatType);
+
+       /**
+        * @see                 NetStatistics::ResetAll()
+        */
+       result ResetAll(NetBearerType bearerType);
+
+public:
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _NetStatisticsImpl
+       * @param[in]   netStatistics            An instance of NetStatistics
+     */
+       static _NetStatisticsImpl* GetInstance(NetStatistics& netStatistics);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _NetStatisticsImpl
+       * @param[in]   netStatistics     An instance of NetStatistics
+     */
+       static const _NetStatisticsImpl* GetInstance(const NetStatistics& netStatistics);
+
+private:
+       /*
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of _NetStatisticsImpl
+        */
+       _NetStatisticsImpl(const _NetStatisticsImpl& rhs);
+
+       /*
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of _NetStatisticsImpl
+        */
+       _NetStatisticsImpl& operator =(const _NetStatisticsImpl& rhs);
+
+private:
+       bool __isConstructed;
+       friend class NetStatistics;
+}; // _NetStatisticsImpl
+
+} } // Tizen::Net
+
+#endif // _FNET_INTERNAL_NET_STATISTICS_IMPL_H_
diff --git a/src/FNet_NetUtility.cpp b/src/FNet_NetUtility.cpp
new file mode 100644 (file)
index 0000000..f4b5a2b
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_NetUtility.cpp
+ * @brief              This is the implementation file for %_NetUtility class.
+ *
+ * This file contains the implementation of %_NetUtility class.
+ */
+
+#include <pthread.h>
+#include <FBaseResult.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseRtMutex.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetUtility.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net {
+
+Mutex* _NetUtility::__pLock = null;
+
+_NetUtility::_NetUtility(void)
+{
+}
+
+_NetUtility::~_NetUtility(void)
+{
+}
+
+Mutex*
+_NetUtility::GetLock(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       if (__pLock == null)
+       {
+               ClearLastResult();
+               pthread_once(&onceBlock, InitLock);
+               result r = GetLastResult();
+               if (r != E_SUCCESS)
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+               }
+       }
+
+       return __pLock;
+}
+
+void
+_NetUtility::InitLock(void)
+{
+    result r = E_SUCCESS;
+    static Mutex lock;
+
+    r = lock.Create(L"NetLock");
+       SysTryReturnVoidResult(NID_NET, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pLock = &lock;
+
+}
+
+}} // Tizen::Net
diff --git a/src/FNet_NetUtility.h b/src/FNet_NetUtility.h
new file mode 100644 (file)
index 0000000..8019786
--- /dev/null
@@ -0,0 +1,119 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNet_NetUtility.h
+ * @brief      This is the header file for the %_NetUtility class.
+ *
+ * This header file contains the declarations of the %_NetUtility class.
+ */
+
+#ifndef _FNET_INTERNAL_NET_UTILITY_H_
+#define _FNET_INTERNAL_NET_UTILITY_H_
+
+#include <net_connection.h>
+#include <tethering.h>
+#include <unique_ptr.h>
+#include <FBaseDataType.h>
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class Mutex;
+} } } // Tizen::Base::Runtime
+
+namespace Tizen { namespace Net
+{
+
+struct _CharDeleter
+{
+       void operator()(char* pChar)
+       {
+               free(pChar);
+       }
+};
+
+struct _ConnectionDeleter
+{
+       void operator()(void* pConnection)
+       {
+               connection_destroy(pConnection);
+       }
+};
+
+struct _ProfileDeleter
+{
+       void operator()(void* pProfile)
+       {
+               connection_profile_destroy(pProfile);
+       }
+};
+
+struct _TetheringDeleter
+{
+       void operator()(void* pTethering)
+       {
+               tethering_destroy(pTethering);
+       }
+};
+
+
+struct _ProfileIteratorDeleter
+{
+       void operator()(void* pIterator)
+       {
+               connection_destroy_profile_iterator(pIterator);
+       }
+};
+
+struct _CollectionDeleter
+{
+       template<typename Collection>
+       void operator()(Collection* pCollection)
+       {
+               pCollection->RemoveAll(true);
+               delete pCollection;
+       }
+};
+
+class  _NetUtility
+{
+public:
+       static Tizen::Base::Runtime::Mutex* GetLock(void);
+
+private:
+       /**
+        * This is the default constructor for this class.
+        */
+       _NetUtility(void);
+
+       /**
+        * This is the destructor for this class.
+        */
+       virtual ~_NetUtility(void);
+
+       _NetUtility(const _NetUtility& rhs);
+       _NetUtility& operator =(const _NetUtility& rhs);
+
+       static void InitLock(void);
+
+private:
+       static Tizen::Base::Runtime::Mutex* __pLock;
+
+}; // _NetUtility
+
+} } // Tizen::Net
+#endif // _FNET_INTERNAL_NET_UTILITY_H_
+
diff --git a/src/FNet_PsSystemNetConnection.cpp b/src/FNet_PsSystemNetConnection.cpp
new file mode 100644 (file)
index 0000000..a95da7a
--- /dev/null
@@ -0,0 +1,694 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file                       FNet_PsSystemNetConnection.cpp
+ * @brief              This is the implementation file for _PsSystemNetConnection class.
+ * @version    3.0
+ *
+ * This file contains the implementation of _PsSystemNetConnection class.
+ */
+
+#include <net_connection.h>
+#include <FNetNetConnectionInfo.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FNet_NetTypes.h"
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNet_PsSystemNetConnection.h"
+#include "FNet_NetAccountDatabase.h"
+#include "FNet_NetAccountManagerImpl.h"
+#include "FNet_NetConnectionEvent.h"
+#include "FNet_NetConnectionEventArg.h"
+#include "FNet_NetUtility.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net {
+
+void
+PsOpenCallback(connection_error_e res, void* pUserData)
+{
+       _PsSystemNetConnection* pConnection = static_cast<_PsSystemNetConnection*>(pUserData);
+       NetConnectionState connectionState = pConnection->GetConnectionState();
+       bool isConnected = false;
+       char* pProfileName = null;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_profile_h profileHandle = pConnection->GetProfileHandle();
+       connection_profile_state_e state = CONNECTION_PROFILE_STATE_DISCONNECTED;
+
+       ret = connection_profile_refresh(profileHandle);
+       SysLog(NID_NET, "The return value from connection_profile_refresh() is %d", ret);
+       ret = connection_profile_get_name(profileHandle, &pProfileName);
+       SysLog(NID_NET, "The return value from connection_profile_get_name() is %d", ret);
+       ret = connection_profile_get_state(profileHandle, &state);
+       SysLog(NID_NET, "The return value from connection_profile_get_state() is %d", ret);
+
+       SysLog(NID_NET, "PsOpenCallback() has been called with res:%d, state:%d, name%s", res, state, pProfileName);
+
+       if ((res == CONNECTION_ERROR_NONE) && (state == CONNECTION_PROFILE_STATE_CONNECTED))
+       {
+               SysLog(NID_NET, "Profile[%s] is connected.", pProfileName);
+               isConnected = true;
+       }
+       else
+       {
+               SysLog(NID_NET, "Profile[%s] is disconnected.", pProfileName);
+               isConnected = false;
+       }
+
+       free(pProfileName);
+
+       if (connectionState != NET_CONNECTION_STATE_STARTING)
+       {
+               SysLog(NID_NET, "Ignore open response because it is in state[%d].", connectionState);
+               return;
+       }
+
+       if (isConnected)
+       {
+               pConnection->HandleStartResponse(E_SUCCESS, profileHandle);
+       }
+       else
+       {
+               pConnection->HandleStartResponse(E_NETWORK_FAILED, null);
+       }
+}
+
+void
+PsCloseCallback(connection_error_e res, void* pUserData)
+{
+       _PsSystemNetConnection* pConnection = static_cast<_PsSystemNetConnection*>(pUserData);
+       NetConnectionState connectionState = pConnection->GetConnectionState();
+       bool isConnected = false;
+       char* pProfileName = null;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_profile_h profileHandle = pConnection->GetProfileHandle();
+       connection_profile_state_e state = CONNECTION_PROFILE_STATE_DISCONNECTED;
+
+       ret = connection_profile_refresh(profileHandle);
+       SysLog(NID_NET, "The return value from connection_profile_refresh() is %d", ret);
+       ret = connection_profile_get_name(profileHandle, &pProfileName);
+       SysLog(NID_NET, "The return value from connection_profile_get_name() is %d", ret);
+       ret = connection_profile_get_state(profileHandle, &state);
+       SysLog(NID_NET, "The return value from connection_profile_get_state() is %d", ret);
+
+       SysLog(NID_NET, "PsCloseCallback() has been called with res:%d, state:%d, name:%s", res, state, pProfileName);
+
+       if ((res == CONNECTION_ERROR_NONE) && (state == CONNECTION_PROFILE_STATE_CONNECTED))
+       {
+               SysLog(NID_NET, "Profile[%s] is connected.", pProfileName);
+               isConnected = true;
+       }
+       else
+       {
+               SysLog(NID_NET, "Profile[%s] is disconnected.", pProfileName);
+               isConnected = false;
+       }
+
+       free(pProfileName);
+
+       if (connectionState != NET_CONNECTION_STATE_STOPPING)
+       {
+               SysLog(NID_NET, "Ignore close response because it is in state[%d].", connectionState);
+               return;
+       }
+
+       pConnection->HandleStopResponse();
+}
+
+void
+PsStateChangedCallback(connection_profile_state_e state, void* pUserData)
+{
+       _PsSystemNetConnection* pConnection = static_cast<_PsSystemNetConnection*>(pUserData);
+       NetConnectionState connectionState = pConnection->GetConnectionState();
+       bool isConnected = false;
+       char* pProfileName = null;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_profile_h profileHandle = pConnection->GetProfileHandle();
+
+       ret = connection_profile_refresh(profileHandle);
+       SysLog(NID_NET, "The return value from connection_profile_refresh() is %d", ret);
+       ret = connection_profile_get_name(profileHandle, &pProfileName);
+       SysLog(NID_NET, "The return value from connection_profile_get_name() is %d", ret);
+
+       SysLog(NID_NET, "PsStateChangedCallback() has been called with state:%d, name:%s", state, pProfileName);
+
+       if (state == CONNECTION_PROFILE_STATE_CONNECTED)
+       {
+               SysLog(NID_NET, "Profile[%s] is connected.", pProfileName);
+               isConnected = true;
+       }
+       else
+       {
+               SysLog(NID_NET, "Profile[%s] is disconnected.", pProfileName);
+               isConnected = false;
+       }
+
+       free(pProfileName);
+
+       if ((connectionState == NET_CONNECTION_STATE_STARTING) || (connectionState == NET_CONNECTION_STATE_STOPPING))
+       {
+               SysLog(NID_NET, "Ignore (not requested) event because it is in state[%d].", connectionState);
+               return;
+       }
+
+       if (isConnected)
+       {
+               // Start event
+               SysLog(NID_NET, "Ignore started event.");
+       }
+       else
+       {
+               // Stop event
+               pConnection->HandleStopEvent(E_NETWORK_FAILED);
+       }
+}
+
+_PsSystemNetConnection::_PsSystemNetConnection(void)
+       : __pConnectionHandle(null)
+       , __pProfileHandle(null)
+{
+}
+
+_PsSystemNetConnection::~_PsSystemNetConnection(void)
+{
+}
+
+result
+_PsSystemNetConnection::Construct(const String& profileName)
+{
+       SysLog(NID_NET, "Construct()has been called with profileName:%ls", profileName.GetPointer());
+
+       result r = E_SUCCESS;
+       unique_ptr<void, _ConnectionDeleter> pConnectionHandle;
+       unique_ptr<void, _ProfileDeleter> pProfileHandle;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = null;
+       connection_profile_h profileHandle = null;
+
+       SysAssertf(__pConnectionHandle == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       r = _SystemNetConnection::Initialize(L"PS");
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       ret = connection_create(&connectionHandle);
+       SysTryCatch(NID_NET, ret == CONNECTION_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_create() is %d", GetErrorMessage(E_SYSTEM), ret);
+       pConnectionHandle.reset(connectionHandle);
+
+       profileHandle = _NetAccountManagerImpl::GetPsProfileHandleN(profileName);
+       SysTryCatch(NID_NET, profileHandle != null, r = GetLastResult(), GetLastResult(),
+                       "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       pProfileHandle.reset(profileHandle);
+
+       ret = connection_profile_set_state_changed_cb(profileHandle, PsStateChangedCallback, this);
+       SysTryCatch(NID_NET, ret == CONNECTION_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_profile_set_state_changed_cb() is %d", GetErrorMessage(E_SYSTEM), ret);
+
+       __profileName = profileName;
+       __pConnectionHandle = move(pConnectionHandle);
+       __pProfileHandle = move(pProfileHandle);
+
+       return r;
+
+CATCH:
+       _SystemNetConnection::Deinitialize();
+
+       return r;
+}
+
+result
+_PsSystemNetConnection::Start(_NetConnectionEvent& event)
+{
+       result r = E_SUCCESS;
+       _NetConnectionEventArg* pEventArg = null;
+
+       SysAssertf(__pConnectionHandle != null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       MutexGuard locked(*_pLock);
+
+       if (_connectionState == NET_CONNECTION_STATE_STARTED)
+       {
+               // Already Started
+               SysLog(NID_NET, "PS connection[%ls] is already started.", __profileName.GetPointer());
+
+               if (event.GetConnectionState() != NET_CONNECTION_STATE_STARTED)
+               {
+                       pEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STARTED, E_SUCCESS);
+                       SysTryReturnResult(NID_NET, pEventArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                       event.SetConnectionState(NET_CONNECTION_STATE_STARTED);
+                       event.FireAsync(*pEventArg);
+
+                       _refCount++;
+               }
+       }
+       else if ((_connectionState == NET_CONNECTION_STATE_STARTING) || (_connectionState == NET_CONNECTION_STATE_STOPPING))
+       {
+               // Waiting Response
+               SysLog(NID_NET, "PS connection[%ls] is waiting response.", __profileName.GetPointer());
+
+               if (event.GetConnectionState() != NET_CONNECTION_STATE_STARTING)
+               {
+                       event.SetConnectionState(NET_CONNECTION_STATE_STARTING);
+                       _refCount++;
+               }
+       }
+       else
+       {
+               // None or Stopped
+               SysLog(NID_NET, "PS connection[%ls] is not active, so start now.", __profileName.GetPointer());
+
+               int ret = CONNECTION_ERROR_NONE;
+
+               ret = connection_open_profile(__pConnectionHandle.get(), __pProfileHandle.get(), PsOpenCallback, this);
+               SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                               "A system error has been occurred. The return value from connection_open_profile() is %d", ret);
+
+               _connectionState = NET_CONNECTION_STATE_STARTING;
+               event.SetConnectionState(NET_CONNECTION_STATE_STARTING);
+               _refCount++;
+       }
+
+       locked.Unlock();
+
+       return r;
+}
+
+result
+_PsSystemNetConnection::Stop(_NetConnectionEvent& event, bool waitingEvent)
+{
+       result r = E_SUCCESS;
+       _NetConnectionEventArg* pEventArg = null;
+
+       SysAssertf(__pConnectionHandle != null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       MutexGuard locked(*_pLock);
+
+       if ((event.GetConnectionState() == NET_CONNECTION_STATE_STARTED) ||
+               (event.GetConnectionState() == NET_CONNECTION_STATE_STARTING))
+       {
+               if (_connectionState == NET_CONNECTION_STATE_STARTED)
+               {
+                       // Started
+                       if (_refCount > 1)
+                       {
+                               SysLog(NID_NET, "PS connection[%ls] is used by others[%d].", __profileName.GetPointer(), _refCount-1);
+
+                               if (waitingEvent)
+                               {
+                                       pEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STOPPED, E_SUCCESS);
+                                       SysTryReturnResult(NID_NET, pEventArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                                       event.SetConnectionState(NET_CONNECTION_STATE_STOPPED);
+                                       event.FireAsync(*pEventArg);
+                               }
+
+                               _refCount--;
+                       }
+                       else
+                       {
+                               SysLog(NID_NET, "PS connection[%ls] is not used any longer, so stop it.", __profileName.GetPointer());
+
+                               int ret = CONNECTION_ERROR_NONE;
+
+                               ret = connection_close_profile(__pConnectionHandle.get(), __pProfileHandle.get(), PsCloseCallback, this);
+                               SysTryReturnResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                                               "A system error has been occurred. The return value from connection_close_profile() is %d", ret);
+
+                               _connectionState = NET_CONNECTION_STATE_STOPPING;
+                               _refCount--;
+
+                               event.SetConnectionState(NET_CONNECTION_STATE_STOPPING);
+                       }
+               }
+               else if ((_connectionState == NET_CONNECTION_STATE_STOPPING) ||
+                               (_connectionState == NET_CONNECTION_STATE_STARTING))
+               {
+                       // Waiting Response
+                       _refCount--;
+                       event.SetConnectionState(NET_CONNECTION_STATE_STOPPING);
+               }
+       }
+       else
+       {
+               // None or Stopped
+               SysLog(NID_NET, "PS connection[%ls] is already stopped.", __profileName.GetPointer());
+
+               if (waitingEvent)
+               {
+                       pEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STOPPED, E_SUCCESS);
+                       SysTryReturnResult(NID_NET, pEventArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                       event.SetConnectionState(NET_CONNECTION_STATE_STOPPED);
+                       event.FireAsync(*pEventArg);
+               }
+       }
+
+       locked.Unlock();
+
+       return r;
+}
+
+void
+_PsSystemNetConnection::HandleStartResponse(result error, void* pData)
+{
+       IEnumerator* pEnum = null;
+       _NetConnectionEvent* pEvent = null;
+       _NetConnectionEventArg* pStartEventArg = null;
+       _NetConnectionEventArg* pStopEventArg = null;
+
+       if (_connectionState != NET_CONNECTION_STATE_STARTING)
+       {
+               SysLog(NID_NET, "Ignore _PsSystemNetConnection::HandleStartResponse() because this is NOT in starting state.");
+               return;
+       }
+
+       MutexGuard locked(*_pLock);
+
+       if (error == E_SUCCESS)
+       {
+               _bearerType = NET_BEARER_PS;
+               _connectionState = NET_CONNECTION_STATE_STARTED;
+               _pConnectionInfo->Update(pData);
+       }
+       else
+       {
+               _bearerType = NET_BEARER_NONE;
+               _connectionState = NET_CONNECTION_STATE_STOPPED;
+               _pConnectionInfo->Clear();
+               _refCount = 0;
+       }
+
+       pEnum = _pEventList->GetEnumeratorN();
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEvent = dynamic_cast<_NetConnectionEvent*>(pEnum->GetCurrent());
+                       if (pEvent != null)
+                       {
+                               if (pEvent->GetConnectionState() == NET_CONNECTION_STATE_STARTING)
+                               {
+                                       if (error == E_SUCCESS)
+                                       {
+                                               pEvent->SetConnectionState(NET_CONNECTION_STATE_STARTED);
+                                       }
+                                       else
+                                       {
+                                               pEvent->SetConnectionState(NET_CONNECTION_STATE_STOPPED);
+                                       }
+
+                                       pStartEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STARTED, error);
+                                       if (pStartEventArg != null)
+                                       {
+                                               pEvent->FireAsync(*pStartEventArg);
+                                               SysLog(NID_NET, "Fire Start event on event[0x%x].", pEvent);
+                                       }
+                               }
+                               else if (pEvent->GetConnectionState() == NET_CONNECTION_STATE_STOPPING)
+                               {
+                                       if (error != E_SUCCESS)
+                                       {
+                                               pEvent->SetConnectionState(NET_CONNECTION_STATE_STOPPED);
+                                               pStopEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STOPPED, E_SUCCESS);
+                                               if (pStopEventArg != null)
+                                               {
+                                                               pEvent->FireAsync(*pStopEventArg);
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               delete pEnum;
+       }
+
+       if ((_connectionState == NET_CONNECTION_STATE_STARTED) && (_refCount == 0))
+       {
+               SysLog(NID_NET, "Connection is started, but not used any more, so stop it.");
+
+               int ret = CONNECTION_ERROR_NONE;
+               bool isSuccess = false;
+
+               ret = connection_close_profile(__pConnectionHandle.get(), __pProfileHandle.get(), PsCloseCallback, this);
+               if (ret == CONNECTION_ERROR_NONE)
+               {
+                       _connectionState = NET_CONNECTION_STATE_STOPPING;
+                       isSuccess = true;
+               }
+
+               if (isSuccess == false)
+               {
+                       _connectionState = NET_CONNECTION_STATE_STOPPED;
+
+                       pEnum = _pEventList->GetEnumeratorN();
+                       if (pEnum != null)
+                       {
+                               while (pEnum->MoveNext() == E_SUCCESS)
+                               {
+                                       pEvent = dynamic_cast<_NetConnectionEvent*>(pEnum->GetCurrent());
+                                       if (pEvent != null)
+                                       {
+                                               if (pEvent->GetConnectionState() == NET_CONNECTION_STATE_STOPPING)
+                                               {
+                                                       pEvent->SetConnectionState(NET_CONNECTION_STATE_STOPPED);
+                                                       pStopEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STOPPED, E_SUCCESS);
+                                                       if (pStopEventArg != null)
+                                                       {
+                                                               pEvent->FireAsync(*pStopEventArg);
+                                                       }
+                                               }
+                                       }
+                               }
+
+                               delete pEnum;
+                       }
+               }
+       }
+
+       locked.Unlock();
+}
+
+void
+_PsSystemNetConnection::HandleStopResponse(void)
+{
+       IEnumerator* pEnum = null;
+       _NetConnectionEvent* pEvent = null;
+       _NetConnectionEventArg* pEventArg = null;
+
+       if (_connectionState != NET_CONNECTION_STATE_STOPPING)
+       {
+               SysLog(NID_NET, "Ignore _PsSystemNetConnection::HandleStopResponse() because this is NOT in stopping state.");
+               return;
+       }
+
+       MutexGuard locked(*_pLock);
+
+       _bearerType = NET_BEARER_NONE;
+       _connectionState = NET_CONNECTION_STATE_STOPPED;
+       _pConnectionInfo->Clear();
+
+       pEnum = _pEventList->GetEnumeratorN();
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEvent = dynamic_cast<_NetConnectionEvent*>(pEnum->GetCurrent());
+                       if (pEvent != null)
+                       {
+                               if (pEvent->GetConnectionState() == NET_CONNECTION_STATE_STOPPING)
+                               {
+                                       pEvent->SetConnectionState(NET_CONNECTION_STATE_STOPPED);
+                                       pEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STOPPED, E_SUCCESS);
+                                       if (pEventArg != null)
+                                       {
+                                               pEvent->FireAsync(*pEventArg);
+                                       }
+                               }
+                       }
+               }
+
+               delete pEnum;
+       }
+
+       if (_refCount > 0)
+       {
+               SysLog(NID_NET, "Connection is stopped, but another start request is found, so start the connection.");
+
+               int ret = CONNECTION_ERROR_NONE;
+               bool isSuccess = false;
+
+               ret = connection_open_profile(__pConnectionHandle.get(), __pProfileHandle.get(), PsOpenCallback, this);
+               SysLog(NID_NET, "Invoke connection_open_profile() ret[%d].", ret);
+               if (ret == CONNECTION_ERROR_NONE)
+               {
+                       _connectionState = NET_CONNECTION_STATE_STARTING;
+                       isSuccess = true;
+               }
+
+               if (isSuccess == false)
+               {
+                       _refCount = 0;
+
+                       pEnum = _pEventList->GetEnumeratorN();
+                       if (pEnum != null)
+                       {
+                               while (pEnum->MoveNext() == E_SUCCESS)
+                               {
+                                       pEvent = dynamic_cast<_NetConnectionEvent*>(pEnum->GetCurrent());
+                                       if (pEvent != null)
+                                       {
+                                               if (pEvent->GetConnectionState() == NET_CONNECTION_STATE_STARTING)
+                                               {
+                                                       pEvent->SetConnectionState(NET_CONNECTION_STATE_STOPPED);
+                                                       pEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STARTED, E_NETWORK_FAILED);
+                                                       if (pEventArg != null)
+                                                       {
+                                                               pEvent->FireAsync(*pEventArg);
+                                                       }
+                                               }
+                                       }
+                               }
+
+                               delete pEnum;
+                       }
+               }
+       }
+
+       locked.Unlock();
+}
+
+void
+_PsSystemNetConnection::HandleStartEvent(void)
+{
+       SysLogException(NID_NET, E_INVALID_OPERATION,
+                       "[%s] _PsSystemNetConnection.HandleStartEvent() is NOT allowed.", GetErrorMessage(E_INVALID_OPERATION));
+}
+
+void
+_PsSystemNetConnection::HandleStopEvent(result error)
+{
+       IEnumerator* pEnum = null;
+       _NetConnectionEvent* pEvent = null;
+       _NetConnectionEventArg* pStartEventArg = null;
+       _NetConnectionEventArg* pStopEventArg = null;
+       _NetConnectionEventArg* pStopEventArg2 = null;
+
+       if ((_connectionState == NET_CONNECTION_STATE_NONE) || (_connectionState == NET_CONNECTION_STATE_STOPPED))
+       {
+               SysLog(NID_NET, "Ignore _PsSystemNetConnection::HandleStopEvent() because this is already in stopped state.");
+               return;
+       }
+
+       MutexGuard locked(*_pLock);
+
+       _bearerType = NET_BEARER_NONE;
+       _connectionState = NET_CONNECTION_STATE_STOPPED;
+       _pConnectionInfo->Clear();
+       _refCount = 0;
+
+       pEnum = _pEventList->GetEnumeratorN();
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEvent = dynamic_cast<_NetConnectionEvent*>(pEnum->GetCurrent());
+                       if (pEvent != null)
+                       {
+                               if (pEvent->GetConnectionState() == NET_CONNECTION_STATE_STARTING)
+                               {
+                                       pEvent->SetConnectionState(NET_CONNECTION_STATE_STOPPED);
+                                       pStartEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STARTED, error);
+                                       if (pStartEventArg != null)
+                                       {
+                                               pEvent->FireAsync(*pStartEventArg);
+                                       }
+                               }
+                               else if (pEvent->GetConnectionState() == NET_CONNECTION_STATE_STARTED)
+                               {
+                                       pEvent->SetConnectionState(NET_CONNECTION_STATE_STOPPED);
+                                       pStopEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STOPPED, error);
+                                       if (pStopEventArg != null)
+                                       {
+                                               pEvent->FireAsync(*pStopEventArg);
+                                       }
+                               }
+                               else if (pEvent->GetConnectionState() == NET_CONNECTION_STATE_STOPPING)
+                               {
+                                       pEvent->SetConnectionState(NET_CONNECTION_STATE_STOPPED);
+                                       pStopEventArg2 = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STOPPED, E_SUCCESS);
+                                       if (pStopEventArg2 != null)
+                                       {
+                                               pEvent->FireAsync(*pStopEventArg2);
+                                       }
+                               }
+                       }
+               }
+
+               delete pEnum;
+       }
+
+       locked.Unlock();
+}
+
+NetConnectionState
+_PsSystemNetConnection::QueryConnectionState(String& devName) const
+{
+       NetConnectionState state = _connectionState;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_profile_h profileHandle = _NetAccountManagerImpl::GetPsProfileHandleN(__profileName);
+       connection_profile_state_e profileState = CONNECTION_PROFILE_STATE_DISCONNECTED;
+
+       if (profileHandle != null)
+       {
+               ret = connection_profile_get_state(profileHandle, &profileState);
+               if ((ret == CONNECTION_ERROR_NONE) && (profileState == CONNECTION_PROFILE_STATE_CONNECTED))
+               {
+                       char* pDevName = null;
+
+                       ret = connection_profile_get_network_interface_name(profileHandle, &pDevName);
+                       if ((ret == CONNECTION_ERROR_NONE) && (pDevName != null))
+                       {
+                               devName = String(pDevName);
+                               free(pDevName);
+                       }
+
+                       state = NET_CONNECTION_STATE_STARTED;
+               }
+
+               connection_profile_destroy(profileHandle);
+       }
+
+       SysLog(NID_NET, "QueryConnectionState() has done with state:%d, devName:%ls", state, devName.GetPointer());
+
+       return state;
+}
+
+void*
+_PsSystemNetConnection::GetProfileHandle(void)
+{
+       return __pProfileHandle.get();
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_PsSystemNetConnection.h b/src/FNet_PsSystemNetConnection.h
new file mode 100644 (file)
index 0000000..4db1d79
--- /dev/null
@@ -0,0 +1,129 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNet_PsSystemNetConnection.h
+ * @brief      This is the header file for the %_PsSystemNetConnection class.
+ *
+ * This header file contains the declarations of the %_PsSystemNetConnection class.
+ */
+
+#ifndef _FNET_INTERNAL_PS_SYSTEM_NET_CONNECTION_H_
+#define _FNET_INTERNAL_PS_SYSTEM_NET_CONNECTION_H_
+
+#include "FNet_SystemNetConnection.h"
+#include "FNet_NetUtility.h"
+
+namespace Tizen { namespace Net {
+/**
+ * @class      _PsSystemNetConnection
+ * @brief      This class provides methods for a PS system network connection.
+ *
+ * @since 2.1
+ *
+ * This class provides methods for a system network connection.
+ */
+
+class _PsSystemNetConnection
+       : public _SystemNetConnection
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        */
+               _PsSystemNetConnection(void);
+
+       /**
+        * This is the destructor for this class.
+        */
+       virtual ~_PsSystemNetConnection(void);
+
+       /**
+        * Initializes this instance with the specified account.
+        *
+        * @since 2.1
+        *
+        * @return              An error code
+        * @param[in]   profileName                     The network profile's name
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        * @exception   E_INVALID_ACCOUNT       The specified network profile is invalid.
+        * @exception   E_SYSTEM                        An internal error occurred.
+        */
+       result Construct(const Tizen::Base::String& profileName);
+
+       /**
+        * Starts the network connection.
+        *
+        * @since 2.1
+        *
+        * @return                      An error code
+        * @exception   E_SUCCESS                               The method was successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        * @exception   E_SYSTEM                                        An internal error occurred.
+        * @see                 Stop()
+        */
+       virtual result Start(_NetConnectionEvent& event);
+
+       /**
+        * Stops the network connection.
+        *
+        * @since 2.1
+        *
+        * @return                      An error code
+        * @exception   E_SUCCESS                               The method was successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        * @exception   E_SYSTEM                                        An internal error occurred.
+        * @see                 Start()
+        */
+       virtual result Stop(_NetConnectionEvent& event, bool waitingEvent = true);
+
+       virtual void HandleStartResponse(result error, void* pData);
+       virtual void HandleStopResponse(void);
+       virtual void HandleStartEvent(void);
+       virtual void HandleStopEvent(result error);
+
+       virtual NetConnectionState QueryConnectionState(Tizen::Base::String& devName) const;
+
+       void* GetProfileHandle(void);
+
+private:
+       /**
+        * This is the copy constructor for this class.
+        *
+        * @param[in]   rhs                     An instance of _PsSystemNetConnection
+        */
+       _PsSystemNetConnection(const _PsSystemNetConnection& rhs);
+
+       /**
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                             An instance of _PsSystemNetConnection
+        */
+       _PsSystemNetConnection& operator =(const _PsSystemNetConnection& rhs);
+
+private:
+       Tizen::Base::String __profileName;
+       std::unique_ptr<void, _ConnectionDeleter> __pConnectionHandle;
+       std::unique_ptr<void, _ProfileDeleter> __pProfileHandle;
+
+       friend class _SystemNetConnection;
+
+}; // _PsSystemNetConnection
+
+} }  // Tizen::Net
+#endif // _FNET_INTERNAL_PS_SYSTEM_NET_CONNECTION_H_
+
diff --git a/src/FNet_SystemNetConnection.cpp b/src/FNet_SystemNetConnection.cpp
new file mode 100644 (file)
index 0000000..89d817d
--- /dev/null
@@ -0,0 +1,764 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file                       FNet_SystemNetConnection.cpp
+ * @brief              This is the implementation file for _SystemNetConnection class.
+ * @version    3.0
+ *
+ * This file contains the implementation of _SystemNetConnection class.
+ */
+
+#include <pthread.h>
+#include <net_connection.h>
+#include <FNetNetConnectionInfo.h>
+#include <FBaseRtMutexGuard.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FIo_DirectoryImpl.h>
+#include "FNet_NetTypes.h"
+#include "FNet_SystemNetConnection.h"
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNet_DefaultSystemNetConnection.h"
+#include "FNet_PsSystemNetConnection.h"
+#include "FNet_WifiSystemNetConnection.h"
+#include "FNet_WifiDirectSystemNetConnection.h"
+#include "FNet_UsbSystemNetConnection.h"
+#include "FNet_NetAccountDatabase.h"
+#include "FNet_NetAccountManagerImpl.h"
+#include "FNet_NetConnectionEvent.h"
+#include "FNet_NetConnectionEventArg.h"
+#include "FNet_NetUtility.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Net {
+
+bool _SystemNetConnection::__isInitialized = false;
+HashMap* _SystemNetConnection::__pPsSystemConnectionMap = null;
+_DefaultSystemNetConnection* _SystemNetConnection::__pDefaultConnection = null;
+_WifiSystemNetConnection* _SystemNetConnection::__pWifiConnection = null;
+_WifiDirectSystemNetConnection* _SystemNetConnection::__pWifiDirectConnection = null;
+_UsbSystemNetConnection* _SystemNetConnection::__pUsbConnection = null;
+
+_SystemNetConnection::_SystemNetConnection(void)
+       : _bearerType(NET_BEARER_NONE)
+       , _connectionState(NET_CONNECTION_STATE_NONE)
+       , _pConnectionInfo(null)
+       , _pEventList(null)
+       , _pLock(null)
+       , _refCount(0)
+{
+}
+
+_SystemNetConnection::~_SystemNetConnection(void)
+{
+}
+
+result
+_SystemNetConnection::Initialize(const String& name)
+{
+       result r = E_SUCCESS;
+
+       unique_ptr<_NetConnectionInfoImpl> pConnectionInfo(new (std::nothrow) _NetConnectionInfoImpl());
+       SysTryReturnResult(NID_NET, pConnectionInfo != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       unique_ptr<ArrayList> pEventList(new (std::nothrow) ArrayList());
+       SysTryReturnResult(NID_NET, pEventList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pEventList->Construct();
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       unique_ptr<Mutex> pLock(new (std::nothrow) Mutex());
+       SysTryReturnResult(NID_NET, pLock != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pLock->Create(name);
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+       _name = name;
+       _pConnectionInfo = move(pConnectionInfo);
+       _pEventList = move(pEventList);
+       _pLock = move(pLock);
+
+       return r;
+}
+
+void
+_SystemNetConnection::Deinitialize(void)
+{
+       _bearerType = NET_BEARER_NONE;
+       _connectionState = NET_CONNECTION_STATE_NONE;
+       _name.Clear();
+       _pConnectionInfo.reset(null);
+       _pEventList.reset(null);
+       _pLock.reset(null);
+       _refCount = 0;
+}
+
+result
+_SystemNetConnection::AddEvent(_NetConnectionEvent& event)
+{
+       result r = E_SUCCESS;
+       bool isFound = false;
+
+       SysAssertf(_pEventList != null, "Not yet constructed. Construct() should be called before use.");
+
+       MutexGuard locked(*_pLock);
+
+       isFound = _pEventList->Contains(event);
+       if (!isFound)
+       {
+               r = _pEventList->Add(event);
+       }
+
+       locked.Unlock();
+
+       return r;
+}
+
+result
+_SystemNetConnection::RemoveEvent(_NetConnectionEvent& event)
+{
+       result r = E_SUCCESS;
+       bool isFound = false;
+
+       SysAssertf(_pEventList != null, "Not yet constructed. Construct() should be called before use.");
+
+       MutexGuard locked(*_pLock);
+
+       isFound = _pEventList->Contains(event);
+       if (isFound)
+       {
+               event.SetConnectionState(NET_CONNECTION_STATE_NONE);
+               r = _pEventList->Remove(event, false);
+       }
+
+       locked.Unlock();
+
+       return r;
+}
+
+result
+_SystemNetConnection::Start(_NetConnectionEvent& event)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(_pEventList != null, "Not yet constructed. Construct() should be called before use.");
+
+       MutexGuard locked(*_pLock);
+
+       if (_connectionState == NET_CONNECTION_STATE_STARTED)
+       {
+               SysLog(NID_NET, "[%ls] is already connected.", _name.GetPointer());
+
+               if (event.GetConnectionState() != NET_CONNECTION_STATE_STARTED)
+               {
+                       unique_ptr<_NetConnectionEventArg> pEventArg(new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STARTED, E_SUCCESS));
+                       SysTryReturnResult(NID_NET, pEventArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                       event.SetConnectionState(NET_CONNECTION_STATE_STARTED);
+                       r = event.FireAsync(*pEventArg);
+                       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.", GetErrorMessage(r));
+
+                       _refCount++;
+                       pEventArg.release();
+               }
+       }
+       else
+       {
+               SysLogException(NID_NET, E_INVALID_CONNECTION,
+                               "[%s] %ls is NOT connected.", GetErrorMessage(E_INVALID_CONNECTION), _name.GetPointer());
+               r = E_INVALID_CONNECTION;
+       }
+
+       locked.Unlock();
+
+       return r;
+}
+
+result
+_SystemNetConnection::Stop(_NetConnectionEvent& event, bool waitingEvent)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(_pEventList != null, "Not yet constructed. Construct() should be called before use.");
+
+       MutexGuard locked(*_pLock);
+
+       if ((event.GetConnectionState() != NET_CONNECTION_STATE_STOPPED) &&
+               (event.GetConnectionState() != NET_CONNECTION_STATE_NONE))
+       {
+               if (waitingEvent)
+               {
+                       unique_ptr<_NetConnectionEventArg> pEventArg(new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STOPPED, E_SUCCESS));
+                       SysTryReturnResult(NID_NET, pEventArg != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                       event.SetConnectionState(NET_CONNECTION_STATE_STOPPED);
+                       r = event.FireAsync(*pEventArg);
+                       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
+
+                       pEventArg.release();
+               }
+
+               _refCount--;
+       }
+
+       locked.Unlock();
+
+       return r;
+}
+
+void
+_SystemNetConnection::HandleStartResponse(result error, void* pData)
+{
+       SysLog(NID_NET, "[%ls] Ignore HandleStartResponse(%s,0x%x).", _name.GetPointer(), GetErrorMessage(error), pData);
+}
+
+void
+_SystemNetConnection::HandleStopResponse(void)
+{
+       SysLog(NID_NET, "[%ls] Ignore HandleStopResponse.", _name.GetPointer());
+}
+
+void
+_SystemNetConnection::HandleStartEvent(void)
+{
+       _NetConnectionEvent* pEvent = null;
+       _NetConnectionEventArg* pEventArg = null;
+
+       if (_connectionState == NET_CONNECTION_STATE_STARTED)
+       {
+               SysLog(NID_NET, "[%ls] Ignore HandleStartEvent() because this instance is in started state.", _name.GetPointer());
+               return;
+       }
+
+       SysLog(NID_NET, "[%ls] Notify started event.", _name.GetPointer());
+
+       MutexGuard locked(*_pLock);
+
+       unique_ptr<IEnumerator> pEnum(_pEventList->GetEnumeratorN());
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEvent = dynamic_cast<_NetConnectionEvent*>(pEnum->GetCurrent());
+                       if (pEvent != null)
+                       {
+                               if (pEvent->GetConnectionState() == NET_CONNECTION_STATE_STARTING)
+                               {
+                                       pEvent->SetConnectionState(NET_CONNECTION_STATE_STARTED);
+                                       pEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STARTED, E_SUCCESS);
+                                       if (pEventArg != null)
+                                       {
+                                               pEvent->FireAsync(*pEventArg);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       locked.Unlock();
+}
+
+void
+_SystemNetConnection::HandleStopEvent(result error)
+{
+       _NetConnectionEvent* pEvent = null;
+       _NetConnectionEventArg* pEventArg = null;
+
+       if ((_connectionState == NET_CONNECTION_STATE_NONE) || (_connectionState == NET_CONNECTION_STATE_STOPPED))
+       {
+               SysLog(NID_NET, "[%ls] Ignore HandleStopEvent(%s) because this instance is in stopped state.", _name.GetPointer(), GetErrorMessage(error));
+               return;
+       }
+
+       SysLog(NID_NET, "[%ls] Notify stopped event.", _name.GetPointer());
+
+       MutexGuard locked(*_pLock);
+
+       _refCount = 0;
+
+       unique_ptr<IEnumerator> pEnum(_pEventList->GetEnumeratorN());
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       pEvent = dynamic_cast<_NetConnectionEvent*>(pEnum->GetCurrent());
+                       if (pEvent != null)
+                       {
+                               if ((pEvent->GetConnectionState() != NET_CONNECTION_STATE_NONE) &&
+                                       (pEvent->GetConnectionState() != NET_CONNECTION_STATE_STOPPED))
+                               {
+                                       pEvent->SetConnectionState(NET_CONNECTION_STATE_STOPPED);
+                                       pEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STOPPED, error);
+                                       if (pEventArg != null)
+                                       {
+                                               pEvent->FireAsync(*pEventArg);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       locked.Unlock();
+}
+
+NetConnectionState
+_SystemNetConnection::QueryConnectionState(String& devName) const
+{
+       if (_pConnectionInfo != null)
+       {
+               devName = _pConnectionInfo->GetDeviceName();
+       }
+
+       SysLog(NID_NET, "QueryConnectionState() has done with state:%d, devName:%ls", _connectionState, devName.GetPointer());
+
+       return _connectionState;
+}
+
+NetBearerType
+_SystemNetConnection::GetBearerType(void) const
+{
+       return _bearerType;
+}
+
+NetConnectionState
+_SystemNetConnection::GetConnectionState(void) const
+{
+       return _connectionState;
+}
+
+String
+_SystemNetConnection::GetProxyAddress(void) const
+{
+       String proxyAddress;
+
+       if (_pConnectionInfo != null)
+       {
+               proxyAddress = _pConnectionInfo->GetProxyAddress();
+       }
+
+       SysLog(NID_NET, "GetProxyAddress() has done with proxy:%ls", proxyAddress.GetPointer());
+
+       return proxyAddress;
+}
+
+void
+_SystemNetConnection::GetConnectionInfo(NetConnectionInfo& netConnectionInfo)
+{
+       _NetConnectionInfoImpl* pSource = _pConnectionInfo.get();
+       _NetConnectionInfoImpl* pDestnation = _NetConnectionInfoImpl::GetInstance(netConnectionInfo);
+
+       SysTryReturnVoidResult(NID_NET, ((pSource != null) && (pDestnation != null)), E_INVALID_ARG,
+                       "[%s] Invalid argument is used. The impl instance is null. [0x%x] [0x%x]", GetErrorMessage(E_INVALID_ARG), pSource, pDestnation);
+
+       MutexGuard locked(*_pLock);
+
+       pDestnation->CopyFrom(pSource);
+
+       locked.Unlock();
+}
+
+void
+_SystemNetConnection::InitializeNetworkFramework(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       if (!__isInitialized)
+       {
+               ClearLastResult();
+               pthread_once(&onceBlock, InitializeNetworkFrameworkOnce);
+               result r = GetLastResult();
+               if (r != E_SUCCESS)
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+               }
+       }
+}
+
+void
+_SystemNetConnection::InitializeNetworkFrameworkOnce(void)
+{
+       result r = E_SUCCESS;
+       NetAccountId accountId = INVALID_HANDLE;
+
+       __pPsSystemConnectionMap = new (std::nothrow) HashMap();
+       SysTryReturnVoidResult(NID_NET, __pPsSystemConnectionMap != null, E_OUT_OF_MEMORY,
+                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = __pPsSystemConnectionMap->Construct();
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnVoidResult(NID_NET, r == E_SUCCESS, r,
+                       "[%s] A system error has been occurred. Failed to initialize the HashMap.", GetErrorMessage(r));
+
+       r = _NetAccountDatabase::InitializeRepository();
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnVoidResult(NID_NET, r == E_SUCCESS, r,
+                       "[%s] A system error has been occurred. Failed to initialize the network database.", GetErrorMessage(r));
+
+       String internetProfileName = _NetAccountManagerImpl::GetInternetProfileName();
+       String mmsProfileName = _NetAccountManagerImpl::GetMmsProfileName();
+       String profileName;
+
+       r = _NetAccountDatabase::GetProfileName(_DEFAULT_PS_ACCOUNT_ID, profileName);
+       if (internetProfileName.IsEmpty())
+       {
+               SysLog(NID_NET, "Internet profile is not found.");
+
+               if (!profileName.IsEmpty())
+               {
+                       SysLog(NID_NET, "Remove Internet profile from database.");
+                       r = _NetAccountDatabase::RemoveAccountByAccountId(_DEFAULT_PS_ACCOUNT_ID);
+               }
+       }
+       else
+       {
+               if (internetProfileName != profileName)
+               {
+                       SysLog(NID_NET, "Internet profile is changed. [%ls] -> [%ls]", profileName.GetPointer(), internetProfileName.GetPointer());
+
+                       if (!profileName.IsEmpty())
+                       {
+                               r = _NetAccountDatabase::RemoveAccountByAccountId(_DEFAULT_PS_ACCOUNT_ID);
+                       }
+
+                       r = _NetAccountDatabase::AddAccount(internetProfileName, internetProfileName, _NET_ACCOUNT_OWNER_SYSTEM_INTERNET, accountId);
+               }
+       }
+
+       profileName.Clear();
+
+       r = _NetAccountDatabase::GetProfileName(_DEFAULT_MMS_ACCOUNT_ID, profileName);
+       if (mmsProfileName.IsEmpty())
+       {
+               SysLog(NID_NET, "MMS profile is not found.");
+
+               if (!profileName.IsEmpty())
+               {
+                       SysLog(NID_NET, "Remove MMS profile from database.");
+                       r = _NetAccountDatabase::RemoveAccountByAccountId(_DEFAULT_MMS_ACCOUNT_ID);
+               }
+       }
+       else
+       {
+               if (mmsProfileName != profileName)
+               {
+                       SysLog(NID_NET, "MMS profile is changed. [%ls] -> [%ls]", profileName.GetPointer(), mmsProfileName.GetPointer());
+
+                       if (!profileName.IsEmpty())
+                       {
+                               r = _NetAccountDatabase::RemoveAccountByAccountId(_DEFAULT_MMS_ACCOUNT_ID);
+                       }
+
+                       r = _NetAccountDatabase::AddAccount(mmsProfileName, mmsProfileName, _NET_ACCOUNT_OWNER_SYSTEM_MMS, accountId);
+               }
+       }
+
+       unique_ptr<IList, _CollectionDeleter> pAccountList(_NetAccountDatabase::GetAppProfileNamesN());
+       unique_ptr<IList, _CollectionDeleter> pProfileList(_NetAccountManagerImpl::GetAppProfileNamesN());
+
+       if (pProfileList != null)
+       {
+               if (pProfileList->GetCount() > 0)
+               {
+                       SysLog(NID_NET, "[%d] profiles are found.", pProfileList->GetCount());
+
+                       unique_ptr<IEnumerator> pEnum(pProfileList->GetEnumeratorN());
+                       if (pEnum != null)
+                       {
+                               String* pProfileName = null;
+                               while (pEnum->MoveNext() == E_SUCCESS)
+                               {
+                                       pProfileName = dynamic_cast<String*>(pEnum->GetCurrent());
+                                       if (pProfileName != null)
+                                       {
+                                               if (pAccountList->Contains(*pProfileName))
+                                               {
+                                                       SysLog(NID_NET, "ProfileName[%ls] is already on DB.", pProfileName->GetPointer());
+                                                       pAccountList->Remove(*pProfileName, true);
+                                               }
+                                               else
+                                               {
+                                                       // OSP account
+                                                       SysLog(NID_NET, "ProfileName[%ls] is not found on DB, so add it.", pProfileName->GetPointer());
+                                                       r = _NetAccountDatabase::AddAccount(*pProfileName, *pProfileName, _NET_ACCOUNT_OWNER_OTHER, accountId);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       if (pAccountList != null)
+       {
+               if (pAccountList->GetCount() > 0)
+               {
+                       SysLog(NID_NET, "[%d] zombie accounts are on DB.", pAccountList->GetCount());
+
+                       unique_ptr<IEnumerator> pEnum(pAccountList->GetEnumeratorN());
+                       if (pEnum != null)
+                       {
+                               String* pProfileName = null;
+                               while (pEnum->MoveNext() == E_SUCCESS)
+                               {
+                                       pProfileName = dynamic_cast<String*>(pEnum->GetCurrent());
+                                       if (pProfileName != null)
+                                       {
+                                               r = _NetAccountDatabase::RemoveAccountByProfileName(*pProfileName);
+                                       }
+                               }
+                       }
+               }
+       }
+
+#ifdef _OSP_EMUL_
+       static const wchar_t _DEFAULT_PS_ACCOUNT_NAME_FOR_EMULATOR[] = L"Tizen_Internet_1";
+       static const wchar_t _DEFAULT_MMS_ACCOUNT_NAME_FOR_EMULATOR[] = L"Tizen_Mms_2";
+
+       String defaultAccountName;
+       int defaultAccountId;
+
+       r = _NetAccountDatabase::GetAccountName(_DEFAULT_PS_ACCOUNT_ID, defaultAccountName);
+       if (r != E_SUCCESS)
+       {
+               SysLog(NID_NET, "Default PS account is not found, so add it now.");
+               r = _NetAccountDatabase::AddAccount(String(_DEFAULT_PS_ACCOUNT_NAME_FOR_EMULATOR),
+                               String(_DEFAULT_PS_ACCOUNT_NAME_FOR_EMULATOR), _NET_ACCOUNT_OWNER_SYSTEM_INTERNET, defaultAccountId);
+               r = _NetAccountDatabase::AddAccount(String(_DEFAULT_MMS_ACCOUNT_NAME_FOR_EMULATOR),
+                               String(_DEFAULT_MMS_ACCOUNT_NAME_FOR_EMULATOR), _NET_ACCOUNT_OWNER_SYSTEM_MMS, defaultAccountId);
+       }
+#endif // _OSP_EMUL_
+
+       __isInitialized = true;
+}
+
+_SystemNetConnection*
+_SystemNetConnection::GetPsInstance(NetAccountId netAccountId)
+{
+       result r = E_SUCCESS;
+       _PsSystemNetConnection* pConnection = null;
+       String profileName;
+
+       r = _NetAccountDatabase::GetProfileName(netAccountId, profileName);
+       SysTryReturn(NID_NET, r == E_SUCCESS, null, E_INVALID_ACCOUNT,
+                       "[%s] Invalid network account. accountId=%d", GetErrorMessage(E_INVALID_ACCOUNT), netAccountId);
+
+       Mutex* pLock = _NetUtility::GetLock();
+       MutexGuard locked(*pLock);
+
+       pConnection = dynamic_cast<_PsSystemNetConnection*>(__pPsSystemConnectionMap->GetValue(profileName));
+       if (pConnection == null)
+       {
+               pConnection = new (std::nothrow) _PsSystemNetConnection();
+               SysTryReturn(NID_NET, pConnection != null, null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pConnection->Construct(profileName);
+               if (r != E_SUCCESS)
+               {
+                       SysLogException(NID_NET, r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       delete pConnection;
+                       pConnection = null;
+               }
+               else
+               {
+                       r = __pPsSystemConnectionMap->Add(pConnection->__profileName, *pConnection);
+                       if (r != E_SUCCESS)
+                       {
+                               SysLogException(NID_NET, r, "[%s] Propagating.", GetErrorMessage(r));
+
+                               delete pConnection;
+                               pConnection = null;
+                       }
+               }
+       }
+
+       locked.Unlock();
+
+       return pConnection;
+}
+
+_SystemNetConnection*
+_SystemNetConnection::GetDefaultInstance(void)
+{
+       result r = E_SUCCESS;
+
+       Mutex* pLock = _NetUtility::GetLock();
+       MutexGuard locked(*pLock);
+
+       if (__pDefaultConnection == null)
+       {
+               unique_ptr<_DefaultSystemNetConnection> pDefaultConnection(new (std::nothrow) _DefaultSystemNetConnection());
+               SysTryReturn(NID_NET, pDefaultConnection != null, null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pDefaultConnection->Construct();
+               SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __pDefaultConnection = pDefaultConnection.release();
+       }
+
+       locked.Unlock();
+
+       return __pDefaultConnection;
+}
+
+_SystemNetConnection*
+_SystemNetConnection::GetWifiInstance(void)
+{
+       result r = E_SUCCESS;
+
+       Mutex* pLock = _NetUtility::GetLock();
+       MutexGuard locked(*pLock);
+
+       if (__pWifiConnection == null)
+       {
+               unique_ptr<_WifiSystemNetConnection> pWifiConnection(new (std::nothrow) _WifiSystemNetConnection());
+               SysTryReturn(NID_NET, pWifiConnection != null, null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pWifiConnection->Construct();
+               SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __pWifiConnection = pWifiConnection.release();
+       }
+
+       locked.Unlock();
+
+       return __pWifiConnection;
+}
+
+_SystemNetConnection*
+_SystemNetConnection::GetWifiDirectInstance(void)
+{
+       result r = E_SUCCESS;
+
+       Mutex* pLock = _NetUtility::GetLock();
+       MutexGuard locked(*pLock);
+
+       // ToDo - Should be changed similar with other instance. (After resolving circular dependency.)
+       if (__pWifiDirectConnection == null)
+       {
+               __pWifiDirectConnection = new (std::nothrow) _WifiDirectSystemNetConnection();
+               SysTryReturn(NID_NET, __pWifiDirectConnection != null, null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = __pWifiDirectConnection->Construct();
+               if (r != E_SUCCESS)
+               {
+                       SysLogException(NID_NET, r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       delete __pWifiDirectConnection;
+                       __pWifiDirectConnection = null;
+               }
+       }
+
+       locked.Unlock();
+
+       return __pWifiDirectConnection;
+}
+
+_SystemNetConnection*
+_SystemNetConnection::GetUsbInstance(void)
+{
+       result r = E_SUCCESS;
+
+       Mutex* pLock = _NetUtility::GetLock();
+       MutexGuard locked(*pLock);
+
+       if (__pUsbConnection == null)
+       {
+               unique_ptr<_UsbSystemNetConnection> pUsbConnection(new (std::nothrow) _UsbSystemNetConnection());
+               SysTryReturn(NID_NET, pUsbConnection != null, null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+               r = pUsbConnection->Construct();
+               SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               __pUsbConnection = pUsbConnection.release();
+       }
+
+       locked.Unlock();
+
+       return __pUsbConnection;
+}
+
+#if 0
+result
+_SystemNetConnection::ConvertError(int ret)
+{
+       result r = E_SUCCESS;
+
+       switch (ret)
+       {
+       case NET_ERR_NONE:
+               r = E_SUCCESS;
+               break;
+
+       case NET_ERR_TIME_OUT:
+               r = E_TIMEOUT;
+               break;
+
+       case NET_ERR_NO_SERVICE:
+               r = E_NETWORK_UNAVAILABLE;
+               break;
+
+       case NET_ERR_NO_ACTIVE_CONNECTIONS:
+               r = E_SERVICE_UNAVAILABLE;
+               break;
+
+       case NET_ERR_CONNECTION_LOGIN_FAILED:
+       case NET_ERR_CONNECTION_AUTH_FAILED:
+       case NET_ERR_CONNECTION_INVALID_KEY:
+               r = E_AUTHENTICATION;
+               break;
+
+       case NET_ERR_NOT_SUPPORTED:
+       case NET_ERR_SECURITY_RESTRICTED:
+               r = E_UNSUPPORTED_OPERATION;
+               break;
+
+       case NET_ERR_CONNECTION_OUT_OF_RANGE:
+       case NET_ERR_CONNECTION_PIN_MISSING:
+       case NET_ERR_CONNECTION_CONNECT_FAILED:
+       case NET_ERR_OPERATION_ABORTED:
+       case NET_ERR_ACCESS_DENIED:
+               r = E_NETWORK_FAILED;
+               break;
+
+       case NET_ERR_CONNECTION_DHCP_FAILED:
+               r = E_DHCP;
+               break;
+
+       case NET_ERR_WIFI_DRIVER_FAILURE:
+               r = E_LINK;
+               break;
+
+       default:
+               r = E_SYSTEM;
+               break;
+       }
+
+       return r;
+}
+#endif
+
+} } // Tizen::Net
diff --git a/src/FNet_SystemNetConnection.h b/src/FNet_SystemNetConnection.h
new file mode 100644 (file)
index 0000000..3ca5e57
--- /dev/null
@@ -0,0 +1,191 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNet_SystemNetConnection.h
+ * @brief      This is the header file for the %_SystemNetConnection class.
+ *
+ * This header file contains the declarations of the %_SystemNetConnection class.
+ */
+
+#ifndef _FNET_INTERNAL_SYSTEM_NET_CONNECTION_H_
+#define _FNET_INTERNAL_SYSTEM_NET_CONNECTION_H_
+
+#include <unique_ptr.h>
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FNetNetTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class ArrayList;
+class HashMap;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class Mutex;
+} } } // Tizen::Base::Runtime
+
+namespace Tizen { namespace Net
+{
+class NetConnectionInfo;
+class _NetConnectionEvent;
+class _NetConnectionInfoImpl;
+class _DefaultSystemNetConnection;
+class _WifiSystemNetConnection;
+class _WifiDirectSystemNetConnection;
+class _UsbSystemNetConnection;
+
+/**
+ * @class      _SystemNetConnection
+ * @brief      This class provides methods for a system network connection.
+ *
+ * @since 2.1
+ *
+ * This class provides methods for a system network connection.
+ */
+class _SystemNetConnection
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        *      Adds an event.
+        *
+        * @since 2.1
+        *      @param[in]      event                   A reference to _NetConnectionEvent
+        *      @return                 An error code
+        *      @exception      E_SUCCESS                               The method was successful.
+        *      @exception      E_INVALID_STATE         This instance has not been constructed as yet or it may be closed.
+        */
+       result AddEvent(_NetConnectionEvent& event);
+
+       /**
+        *      Removes an event.
+        *
+        *      @since 2.1
+        *      @param[in]      event                   A reference to _NetConnectionEvent
+        *      @return                 An error code
+        *      @exception      E_SUCCESS                               The method was successful.
+        *      @exception      E_INVALID_STATE         This instance has not been constructed as yet or it may be closed.
+        * @exception   E_OBJ_NOT_FOUND The EventListener was not found.
+        */
+       result RemoveEvent(_NetConnectionEvent& event);
+
+       /**
+        * Starts the network connection.
+        *
+        * @since 2.1
+        *
+        * @return                      An error code
+        * @exception   E_SUCCESS                               The method was successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        * @exception   E_SYSTEM                                        An internal error occurred.
+        * @see                 Stop()
+        */
+       virtual result Start(_NetConnectionEvent& event);
+
+       /**
+        * Stops the network connection.
+        *
+        * @since 2.1
+        *
+        * @return                      An error code
+        * @exception   E_SUCCESS                               The method was successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        * @exception   E_SYSTEM                                        An internal error occurred.
+        * @see                 Start()
+        */
+       virtual result Stop(_NetConnectionEvent& event, bool waitingEvent = true);
+
+       virtual void HandleStartResponse(result error, void* pData);
+       virtual void HandleStopResponse(void);
+       virtual void HandleStartEvent(void);
+       virtual void HandleStopEvent(result error);
+
+       virtual NetConnectionState QueryConnectionState(Tizen::Base::String& devName) const;
+
+       NetBearerType GetBearerType(void) const;
+       NetConnectionState GetConnectionState(void) const;
+       Tizen::Base::String GetProxyAddress(void) const;
+
+       void GetConnectionInfo(NetConnectionInfo& netConnectionInfo);
+
+public:
+       static void InitializeNetworkFramework(void);
+
+       static _SystemNetConnection* GetPsInstance(NetAccountId netAccountId);
+       static _SystemNetConnection* GetDefaultInstance(void);
+       static _SystemNetConnection* GetWifiInstance(void);
+       static _SystemNetConnection* GetWifiDirectInstance(void);
+       static _SystemNetConnection* GetUsbInstance(void);
+
+//     static result ConvertError(int ret);
+
+protected:
+       /**
+        * This is the default constructor for this class.
+        */
+       _SystemNetConnection(void);
+
+       /**
+        * This is the destructor for this class.
+        */
+       virtual ~_SystemNetConnection(void);
+
+       result Initialize(const Tizen::Base::String& name);
+       void Deinitialize(void);
+
+private:
+       static void InitializeNetworkFrameworkOnce(void);
+
+       /**
+        * This is the copy constructor for this class.
+        *
+        * @param[in]   rhs                     An instance of _SystemNetConnection
+        */
+       _SystemNetConnection(const _SystemNetConnection& rhs);
+
+       /**
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                             An instance of _SystemNetConnection
+        */
+       _SystemNetConnection& operator =(const _SystemNetConnection& rhs);
+
+protected:
+       NetBearerType _bearerType;
+       NetConnectionState _connectionState;
+       Tizen::Base::String _name;
+       std::unique_ptr<_NetConnectionInfoImpl> _pConnectionInfo;
+       std::unique_ptr<Tizen::Base::Collection::ArrayList> _pEventList; // Don't use collector deleter because this list doesn't take entries ownership.
+       std::unique_ptr<Tizen::Base::Runtime::Mutex> _pLock;
+       int _refCount;
+
+private:
+       static bool __isInitialized;
+       static Tizen::Base::Collection::HashMap* __pPsSystemConnectionMap;
+       static _DefaultSystemNetConnection* __pDefaultConnection;
+       static _WifiSystemNetConnection* __pWifiConnection;
+       static _WifiDirectSystemNetConnection* __pWifiDirectConnection;
+       static _UsbSystemNetConnection* __pUsbConnection;
+
+}; // _SystemNetConnection
+
+} }  // Tizen::Net
+#endif // _FNET_INTERNAL_SYSTEM_NET_CONNECTION_H_
+
diff --git a/src/FNet_UsbSystemNetConnection.cpp b/src/FNet_UsbSystemNetConnection.cpp
new file mode 100644 (file)
index 0000000..4f7ca29
--- /dev/null
@@ -0,0 +1,198 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file                       FNet_UsbSystemNetConnection.cpp
+ * @brief              This is the implementation file for _UsbSystemNetConnection class.
+ * @version    3.0
+ *
+ * This file contains the implementation of _UsbSystemNetConnection class.
+ */
+
+#include <tethering.h>
+#include <FNetNetConnectionInfo.h>
+#include <FBaseRtMutexGuard.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FNet_NetTypes.h"
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNet_UsbSystemNetConnection.h"
+#include "FNet_NetConnectionEvent.h"
+#include "FNet_NetConnectionEventArg.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net {
+
+void
+TetheringStateChangedCallback(tethering_client_h client, bool opened, void* pUserData)
+{
+       SysLog(NID_NET, "TetheringStateChangedCallback() has been called with opened:%d", opened);
+
+       _UsbSystemNetConnection* pConnection = static_cast<_UsbSystemNetConnection*>(pUserData);
+
+       if (opened)
+       {
+               // USB tethering is ON
+               SysLog(NID_NET, "USB tethering is ON.");
+               pConnection->HandleStartEvent();
+               pConnection->UpdateConnectionInfo(true);
+       }
+       else
+       {
+               // USB tethering is OFF
+               SysLog(NID_NET, "USB tethering is OFF.");
+               pConnection->HandleStopEvent(E_NETWORK_FAILED);
+               pConnection->UpdateConnectionInfo(false);
+       }
+
+       return;
+}
+
+_UsbSystemNetConnection::_UsbSystemNetConnection(void)
+       : __pTetheringHandle(null)
+{
+}
+
+_UsbSystemNetConnection::~_UsbSystemNetConnection(void)
+{
+}
+
+result
+_UsbSystemNetConnection::Construct(void)
+{
+       result r = E_SUCCESS;
+       unique_ptr<void, _TetheringDeleter> pTetheringHandle;
+       int ret = TETHERING_ERROR_NONE;
+       tethering_h tetheringHandle = null;
+       bool usbStatus = false;
+
+       SysAssertf(__pTetheringHandle == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       r = _SystemNetConnection::Initialize(L"USB");
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.", GetErrorMessage(r));
+
+       ret = tethering_create(&tetheringHandle);
+       SysTryCatch(NID_NET, ret == TETHERING_ERROR_NONE && tetheringHandle != null, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from tethering_create() is %d", GetErrorMessage(E_SYSTEM), ret);
+       pTetheringHandle.reset(tetheringHandle);
+
+       ret = tethering_set_connection_state_changed_cb(tetheringHandle, TETHERING_TYPE_USB, TetheringStateChangedCallback, this);
+       SysTryCatch(NID_NET, ret == TETHERING_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from tethering_set_connection_state_changed_cb() is %d", GetErrorMessage(E_SYSTEM), ret);
+
+       __pTetheringHandle = move(pTetheringHandle);
+
+       usbStatus = tethering_is_enabled(tetheringHandle, TETHERING_TYPE_USB);
+       if (usbStatus)
+       {
+               // USB tethering is ON
+               SysLog(NID_NET, "USB tethering is ON.");
+               UpdateConnectionInfo(true);
+       }
+       else
+       {
+               // USB tethering is OFF
+               SysLog(NID_NET, "USB tethering is OFF. Current status of usb is %d", usbStatus);
+               UpdateConnectionInfo(false);
+       }
+
+       return r;
+
+CATCH:
+       _SystemNetConnection::Deinitialize();
+
+       return r;
+}
+
+void
+_UsbSystemNetConnection::UpdateConnectionInfo(bool isStarted)
+{
+       int ret = TETHERING_ERROR_NONE;
+       tethering_h tetheringHandle = __pTetheringHandle.get();
+
+       SysLog(NID_NET, "UpdateConnectionInfo() has been called with status:%d", isStarted);
+
+       SysAssertf(__pTetheringHandle != null,
+                       "Not yet created ! tetheringHandle should be created before use.");
+
+       MutexGuard locked(*_pLock);
+
+       if (isStarted)
+       {
+               char* pIpAddr = null;
+               String ipAddr;
+
+               ret = tethering_get_ip_address(tetheringHandle, TETHERING_TYPE_USB, TETHERING_ADDRESS_FAMILY_IPV4, &pIpAddr);
+               SysLog(NID_NET, "tethering_get_ip_address() ret[%d] addr[%s]", ret, pIpAddr);
+               if ((ret == TETHERING_ERROR_NONE) && (pIpAddr != null))
+               {
+                       ipAddr = String(pIpAddr);
+                       _pConnectionInfo->SetLocalAddress(ipAddr);
+                       free(pIpAddr);
+               }
+
+               ret = tethering_get_subnet_mask(tetheringHandle, TETHERING_TYPE_USB, TETHERING_ADDRESS_FAMILY_IPV4, &pIpAddr);
+               SysLog(NID_NET, "tethering_get_subnet_mask() ret[%d] addr[%s]", ret, pIpAddr);
+               if ((ret == TETHERING_ERROR_NONE) && (pIpAddr != null))
+               {
+                       ipAddr = String(pIpAddr);
+                       _pConnectionInfo->SetSubnetMaskAddress(ipAddr);
+                       free(pIpAddr);
+               }
+
+               ret = tethering_get_gateway_address(tetheringHandle, TETHERING_TYPE_USB, TETHERING_ADDRESS_FAMILY_IPV4, &pIpAddr);
+               SysLog(NID_NET, "tethering_get_gateway_address() ret[%d] addr[%s]", ret, pIpAddr);
+               if ((ret == TETHERING_ERROR_NONE) && (pIpAddr != null))
+               {
+                       ipAddr = String(pIpAddr);
+                       _pConnectionInfo->SetDefaultGatewayAddress(ipAddr);
+                       free(pIpAddr);
+               }
+
+               char* pDevName = null;
+               String devName;
+
+               ret = tethering_get_network_interface_name(tetheringHandle, TETHERING_TYPE_USB, &pDevName);
+               SysLog(NID_NET, "tethering_get_network_interface_name() ret[%d] devName[%s]", ret, pDevName);
+               if ((ret == TETHERING_ERROR_NONE) && (pDevName != null))
+               {
+                       devName = String(pDevName);
+                       _pConnectionInfo->SetDeviceName(devName);
+                       free(pDevName);
+               }
+
+               _bearerType = NET_BEARER_USB;
+               _connectionState = NET_CONNECTION_STATE_STARTED;
+               _pConnectionInfo->SetBearerType(NET_BEARER_USB);
+               _pConnectionInfo->SetProtocolType(NET_PROTO_TYPE_IPV4);
+               _pConnectionInfo->SetLocalAddressScheme(NET_ADDRESS_SCHEME_STATIC);
+       }
+       else
+       {
+               _bearerType = NET_BEARER_NONE;
+               _connectionState = NET_CONNECTION_STATE_STOPPED;
+               _pConnectionInfo->Clear();
+       }
+
+       locked.Unlock();
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_UsbSystemNetConnection.h b/src/FNet_UsbSystemNetConnection.h
new file mode 100644 (file)
index 0000000..bf67030
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNet_UsbSystemNetConnection.h
+ * @brief      This is the header file for the %_UsbSystemNetConnection class.
+ *
+ * This header file contains the declarations of the %_UsbSystemNetConnection class.
+ */
+
+#ifndef _FNET_INTERNAL_USB_SYSTEM_NET_CONNECTION_H_
+#define _FNET_INTERNAL_USB_SYSTEM_NET_CONNECTION_H_
+
+#include "FNet_SystemNetConnection.h"
+#include "FNet_NetUtility.h"
+
+namespace Tizen { namespace Net {
+/**
+ * @class      _UsbSystemNetConnection
+ * @brief      This class provides methods for a USB system network connection.
+ *
+ * @since 2.1
+ *
+ * This class provides methods for a system network connection.
+ */
+
+class _UsbSystemNetConnection
+       : public _SystemNetConnection
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        */
+               _UsbSystemNetConnection(void);
+
+       /**
+        * This is the destructor for this class.
+        */
+       virtual ~_UsbSystemNetConnection(void);
+
+       /**
+        * Initializes this instance with the specified account.
+        *
+        * @since 2.1
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        * @exception   E_INVALID_ACCOUNT       The specified network account is invalid.
+        * @exception   E_SYSTEM                        An internal error occurred.
+        */
+       result Construct(void);
+
+       void UpdateConnectionInfo(bool isStarted);
+
+private:
+       /**
+        * This is the copy constructor for this class.
+        *
+        * @param[in]   rhs                     An instance of _UsbSystemNetConnection
+        */
+       _UsbSystemNetConnection(const _UsbSystemNetConnection& rhs);
+
+       /**
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                             An instance of _UsbSystemNetConnection
+        */
+       _UsbSystemNetConnection& operator =(const _UsbSystemNetConnection& rhs);
+
+private:
+       std::unique_ptr<void, _TetheringDeleter> __pTetheringHandle;
+
+}; // _UsbSystemNetConnection
+
+} }  // Tizen::Net
+#endif // _FNET_INTERNAL_USB_SYSTEM_NET_CONNECTION_H_
+
diff --git a/src/FNet_WifiDirectSystemNetConnection.cpp b/src/FNet_WifiDirectSystemNetConnection.cpp
new file mode 100644 (file)
index 0000000..89f5f2b
--- /dev/null
@@ -0,0 +1,362 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file                       FNet_WifiDirectSystemNetConnection.cpp
+ * @brief              This is the implementation file for _WifiDirectSystemNetConnection class.
+ * @version    3.0
+ *
+ * This file contains the implementation of _WifiDirectSystemNetConnection class.
+ */
+
+#include <dlfcn.h>
+#include <wifi-direct.h>
+#include <FNetIp4Address.h>
+#include <FNetNetConnection.h>
+#include <FNetNetConnectionInfo.h>
+#include <FNetWifiWifiDirectDevice.h>
+#include <FNetWifiWifiDirectGroupMember.h>
+#include <FNetWifiWifiDirectDeviceManager.h>
+#include <FBaseRtMutexGuard.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FNet_NetTypes.h"
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNet_WifiDirectSystemNetConnection.h"
+#include "FNet_NetConnectionEvent.h"
+#include "FNet_NetConnectionEventArg.h"
+#include "FNet_NetUtility.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Net::Wifi;
+
+namespace Tizen { namespace Net {
+
+static const char* _WIFI_DIRECT_LIBRARY_NAME = "libosp-wifi.so";
+
+_WifiDirectSystemNetConnection::_WifiDirectSystemNetConnection(void)
+       : __pDllHandle(null)
+       , __pDevice(null)
+{
+}
+
+_WifiDirectSystemNetConnection::~_WifiDirectSystemNetConnection(void)
+{
+       if (__pDllHandle != null)
+       {
+               if (__pDevice != null)
+               {
+                       void(*pDeleteFunction)(WifiDirectDevice* pWifiDirectDevice, IWifiDirectDeviceListener* pDeviceListener, IWifiDirectGroupOwnerListener* pOwnerListener, IWifiDirectGroupClientListener* pClientListener) = null;
+
+                       pDeleteFunction = reinterpret_cast<void(*)(WifiDirectDevice* pWifiDirectDevice, IWifiDirectDeviceListener* pDeviceListener, IWifiDirectGroupOwnerListener* pOwnerListener, IWifiDirectGroupClientListener* pClientListener)>(dlsym(__pDllHandle, "_WifiDirectDeviceImpl_DeleteWifiDirectDevice"));
+                       if (pDeleteFunction != null)
+                       {
+                               pDeleteFunction(__pDevice, this, this, this);
+                               __pDevice = null;
+                       }
+               }
+
+               dlclose(__pDllHandle);
+       }
+}
+
+result
+_WifiDirectSystemNetConnection::Construct(void)
+{
+       result r = E_SUCCESS;
+       WifiDirectDevice*(*pCreateFunction)(IWifiDirectDeviceListener* pDeviceListener, IWifiDirectGroupOwnerListener* pOwnerListener, IWifiDirectGroupClientListener* pClientListener) = null;
+       bool(*pIsGroupMemberFunction)(void) = null;
+
+       SysAssertf(__pDevice == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       r = _SystemNetConnection::Initialize(L"WIFI-DIRECT");
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.", GetErrorMessage(r));
+
+       __pDllHandle = dlopen(_WIFI_DIRECT_LIBRARY_NAME, RTLD_LAZY);
+       SysTryCatch(NID_NET, __pDllHandle != null, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to open wifi library.", GetErrorMessage(E_SYSTEM));
+
+       pCreateFunction = reinterpret_cast<WifiDirectDevice*(*)(IWifiDirectDeviceListener* pDeviceListener, IWifiDirectGroupOwnerListener* pOwnerListener, IWifiDirectGroupClientListener* pClientListener)>(dlsym(__pDllHandle, "_WifiDirectDeviceManagerImpl_GetWifiDirectDeviceN"));
+       SysTryCatch(NID_NET, pCreateFunction != null, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to get a function pointer.", GetErrorMessage(E_SYSTEM));
+
+       __pDevice = pCreateFunction(this, this, this);
+       SysTryCatch(NID_NET, __pDevice != null, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to get a WifiDirectDevice instance.", GetErrorMessage(E_SYSTEM));
+
+       pIsGroupMemberFunction = reinterpret_cast<bool(*)(void)>(dlsym(__pDllHandle, "_WifiDirectDeviceImpl_IsGroupMember"));
+       SysTryCatch(NID_NET, pIsGroupMemberFunction != null, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. Failed to get a function pointer.", GetErrorMessage(E_SYSTEM));
+
+       if (pIsGroupMemberFunction())
+       {
+               UpdateConnectionInfo(true);
+       }
+       else
+       {
+               UpdateConnectionInfo(false);
+       }
+
+       return r;
+
+CATCH:
+       _SystemNetConnection::Deinitialize();
+
+       if (__pDllHandle != null)
+       {
+               if (__pDevice != null)
+               {
+                       void(*pDeleteFunction)(WifiDirectDevice* pWifiDirectDevice, IWifiDirectDeviceListener* pDeviceListener, IWifiDirectGroupOwnerListener* pOwnerListener, IWifiDirectGroupClientListener* pClientListener) = null;
+
+                       pDeleteFunction = reinterpret_cast<void(*)(WifiDirectDevice* pWifiDirectDevice, IWifiDirectDeviceListener* pDeviceListener, IWifiDirectGroupOwnerListener* pOwnerListener, IWifiDirectGroupClientListener* pClientListener)>(dlsym(__pDllHandle, "_WifiDirectDeviceImpl_DeleteWifiDirectDevice"));
+                       if (pDeleteFunction != null)
+                       {
+                               pDeleteFunction(__pDevice, this, this, this);
+                               __pDevice = null;
+                       }
+               }
+
+               dlclose(__pDllHandle);
+       }
+
+       return r;
+}
+
+void
+_WifiDirectSystemNetConnection::OnWifiDirectDeviceActivated(WifiDirectDeviceId localDeviceId, result r)
+{
+       SysLog(NID_NET, "WifiDirectSystemNetConnection received OnWifiDirectDeviceActivated event with the result %s (Ignore)", GetErrorMessage(r));
+}
+
+void
+_WifiDirectSystemNetConnection::OnWifiDirectDeviceDeactivated(WifiDirectDeviceId localDeviceId, result r)
+{
+       SysLog(NID_NET, "WifiDirectSystemNetConnection received OnWifiDirectDeviceDeactivated event with the result %s", GetErrorMessage(r));
+
+       HandleStopEvent(r);
+       UpdateConnectionInfo(false);
+}
+
+void
+_WifiDirectSystemNetConnection::OnWifiDirectGroupCreatedN(WifiDirectDeviceId localDeviceId,
+               const WifiDirectGroupInfo& wifiDirectGroupInfo, const WifiDirectDeviceInfo& wifiDirectGroupOwnerDeviceInfo,
+               WifiDirectGroupMember* pWifiDirectMember, result r)
+{
+       SysLog(NID_NET, "WifiDirectSystemNetConnection received OnWifiDirectGroupCreatedN event with the result %s", GetErrorMessage(r));
+
+       if (r == E_SUCCESS)
+       {
+               HandleStartEvent();
+               UpdateConnectionInfo(true);
+       }
+       else
+       {
+               HandleStopEvent(r);
+               UpdateConnectionInfo(false);
+       }
+
+       delete pWifiDirectMember;
+}
+
+void
+_WifiDirectSystemNetConnection::OnWifiDirectScanCompletedN(WifiDirectDeviceId localDeviceId, IList* pWifiDirectDeviceInfoList,
+               result r)
+{
+       SysLog(NID_NET, "WifiDirectSystemNetConnection received OnWifiDirectScanCompletedN event with the result %s (Ignore)", GetErrorMessage(r));
+
+       if (pWifiDirectDeviceInfoList != null)
+       {
+               pWifiDirectDeviceInfoList->RemoveAll(true);
+               delete pWifiDirectDeviceInfoList;
+       }
+}
+
+void
+_WifiDirectSystemNetConnection::OnWifiDirectAssociationCompleted(WifiDirectDeviceId localDeviceId,
+               const WifiDirectDeviceInfo& wifiDirectGroupOwnerDeviceInfo, result r)
+{
+       SysLog(NID_NET, "WifiDirectSystemNetConnection received OnWifiDirectAssociationCompleted event with the result %s", GetErrorMessage(r));
+
+       if (r == E_SUCCESS)
+       {
+               HandleStartEvent();
+               UpdateConnectionInfo(true);
+       }
+       else
+       {
+               HandleStopEvent(r);
+               UpdateConnectionInfo(false);
+       }
+}
+
+void
+_WifiDirectSystemNetConnection::OnWifiDirectClientAssociated(WifiDirectDeviceId localDeviceId, const WifiDirectDeviceInfo& wifiDirectClientInfo)
+{
+       SysLog(NID_NET, "WifiDirectSystemNetConnection received OnWifiDirectClientAssociated event (Ignore)");
+}
+
+void
+_WifiDirectSystemNetConnection::OnWifiDirectClientDisassociated(WifiDirectDeviceId localDeviceId, const WifiDirectDeviceInfo& wifiDirectClientInfo, WifiDirectAssociationTerminationReason reason)
+{
+       SysLog(NID_NET, "WifiDirectSystemNetConnection received OnWifiDirectClientDisassociated event (Ignore)");
+}
+
+void
+_WifiDirectSystemNetConnection::OnWifiDirectGroupDestroyed(WifiDirectDeviceId localDeviceId, result r)
+{
+       SysLog(NID_NET, "Enter with Result[%s].", GetErrorMessage(r));
+
+       HandleStopEvent(r);
+       UpdateConnectionInfo(false);
+
+       SysLog(NID_NET, "Exit.");
+}
+
+void
+_WifiDirectSystemNetConnection::OnWifiDirectGroupMemberInfoServiceStarted(WifiDirectDeviceId localDeviceId, const NetConnection* pNetConnection, result r)
+{
+       SysLog(NID_NET, "WifiDirectSystemNetConnection received OnWifiDirectGroupMemberInfoServiceStarted event with the result %s (Ignore)", GetErrorMessage(r));
+}
+
+void
+_WifiDirectSystemNetConnection::OnWifiDirectGroupMemberInfoServiceStopped(WifiDirectDeviceId localDeviceId, result r)
+{
+       SysLog(NID_NET, "WifiDirectSystemNetConnection received OnWifiDirectGroupMemberInfoServiceStopped event with the result %s (Ignore)", GetErrorMessage(r));
+}
+
+void
+_WifiDirectSystemNetConnection::OnWifiDirectAssociationTerminated(WifiDirectDeviceId localDeviceId, WifiDirectAssociationTerminationReason reason, result r)
+{
+       SysLog(NID_NET, "WifiDirectSystemNetConnection received OnWifiDirectAssociationTerminated event with the result %s", GetErrorMessage(r));
+
+       HandleStopEvent(r);
+       UpdateConnectionInfo(false);
+}
+
+void
+_WifiDirectSystemNetConnection::OnWifiDirectGroupOwnerInfoReceived(WifiDirectDeviceId localDeviceId, const WifiDirectDeviceInfo& wifiDirectGroupOwnerDeviceInfo, result r)
+{
+       SysLog(NID_NET, "WifiDirectSystemNetConnection received OnWifiDirectGroupOwnerInfoReceived event with the result %s (Ignore)", GetErrorMessage(r));
+}
+
+void
+_WifiDirectSystemNetConnection::OnWifiDirectAllGroupMemberInfoReceivedN(WifiDirectDeviceId localDeviceId, IList* pWifiDirectDeviceInfoList, result r)
+{
+       SysLog(NID_NET, "WifiDirectSystemNetConnection received OnWifiDirectAllGroupMemberInfoReceivedN event with the result %s (Ignore)", GetErrorMessage(r));
+
+       if (pWifiDirectDeviceInfoList != null)
+       {
+               pWifiDirectDeviceInfoList->RemoveAll(true);
+               delete pWifiDirectDeviceInfoList;
+       }
+}
+
+void
+_WifiDirectSystemNetConnection::UpdateConnectionInfo(bool isStarted)
+{
+       MutexGuard locked(*_pLock);
+
+       if (isStarted)
+       {
+               int ret = WIFI_DIRECT_ERROR_NONE;
+               char* pDeviceName = null;
+               char* pLocalAddress = null;
+               char* pSubnetMaskAddress = null;
+               char* pGatewayAddress = null;
+               String deviceName;
+               String localAddress;
+               String subnetMaskAddress;
+               String gatewayAddress;
+
+               ret = wifi_direct_get_network_interface_name(&pDeviceName);
+               if ((ret == WIFI_DIRECT_ERROR_NONE) && (pDeviceName != null))
+               {
+                       SysLog(NID_NET, "DeviceName is %s", pDeviceName);
+
+                       deviceName = String(pDeviceName);
+                       free(pDeviceName);
+               }
+               else
+               {
+                       SysLog(NID_NET, "Failed result from wifi_direct_get_network_interface_name() is %d", ret);
+
+                       deviceName.Clear();
+               }
+
+               ret = wifi_direct_get_ip_address(&pLocalAddress);
+               if ((ret == WIFI_DIRECT_ERROR_NONE) && (pLocalAddress != null))
+               {
+                       SysLog(NID_NET, "LocalAddress is %s", pLocalAddress);
+
+                       localAddress = String(pLocalAddress);
+                       free(pLocalAddress);
+               }
+               else
+               {
+                       SysLog(NID_NET, "Failed result from wifi_direct_get_ip_address() is %d", ret);
+               }
+
+               ret = wifi_direct_get_subnet_mask(&pSubnetMaskAddress);
+               if ((ret == WIFI_DIRECT_ERROR_NONE) && (pSubnetMaskAddress != null))
+               {
+                       SysLog(NID_NET, "SubnetMaskAddress is %s", pSubnetMaskAddress);
+
+                       subnetMaskAddress = String(pSubnetMaskAddress);
+                       free(pSubnetMaskAddress);
+               }
+               else
+               {
+                       SysLog(NID_NET, "Failed result from wifi_direct_get_subnet_mask() is %d", ret);
+               }
+
+               ret = wifi_direct_get_gateway_address(&pGatewayAddress);
+               if ((ret == WIFI_DIRECT_ERROR_NONE) && (pGatewayAddress != null))
+               {
+                       SysLog(NID_NET, "GatewayAddress is %s", pGatewayAddress);
+
+                       gatewayAddress = String(pGatewayAddress);
+                       free(pGatewayAddress);
+               }
+               else
+               {
+                       SysLog(NID_NET, "Failed result from wifi_direct_get_gateway_address() is %d", ret);
+               }
+
+               _bearerType = NET_BEARER_WIFI_DIRECT;
+               _connectionState = NET_CONNECTION_STATE_STARTED;
+               _pConnectionInfo->SetBearerType(NET_BEARER_WIFI_DIRECT);
+               _pConnectionInfo->SetProtocolType(NET_PROTO_TYPE_IPV4);
+               _pConnectionInfo->SetLocalAddressScheme(NET_ADDRESS_SCHEME_STATIC);
+               _pConnectionInfo->SetLocalAddress(localAddress);
+               _pConnectionInfo->SetSubnetMaskAddress(subnetMaskAddress);
+               _pConnectionInfo->SetDefaultGatewayAddress(gatewayAddress);
+               _pConnectionInfo->SetDeviceName(deviceName);
+       }
+       else
+       {
+               _bearerType = NET_BEARER_NONE;
+               _connectionState = NET_CONNECTION_STATE_STOPPED;
+               _pConnectionInfo->Clear();
+       }
+
+       locked.Unlock();
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_WifiDirectSystemNetConnection.h b/src/FNet_WifiDirectSystemNetConnection.h
new file mode 100644 (file)
index 0000000..932bf88
--- /dev/null
@@ -0,0 +1,124 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNet_WifiDirectSystemNetConnection.h
+ * @brief      This is the header file for the %_WifiDirectSystemNetConnection class.
+ *
+ * This header file contains the declarations of the %_WifiDirectSystemNetConnection class.
+ */
+
+#ifndef _FNET_INTERNAL_WIFI_DIRECT_SYSTEM_NET_CONNECTION_H_
+#define _FNET_INTERNAL_WIFI_DIRECT_SYSTEM_NET_CONNECTION_H_
+
+#include <FNetWifiIWifiDirectDeviceListener.h>
+#include <FNetWifiIWifiDirectGroupOwnerListener.h>
+#include <FNetWifiIWifiDirectGroupClientListener.h>
+#include "FNet_SystemNetConnection.h"
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class WifiDirectDevice;
+} } } // Tizen::Net::Wifi
+
+namespace Tizen { namespace Net {
+class NetConnection;
+
+/**
+ * @class      _WifiDirectSystemNetConnection
+ * @brief      This class provides methods for a WifiDirect system network connection.
+ *
+ * @since 2.1
+ *
+ * This class provides methods for a system network connection.
+ */
+
+class _WifiDirectSystemNetConnection
+       : public _SystemNetConnection
+       , public Tizen::Net::Wifi::IWifiDirectDeviceListener
+       , public Tizen::Net::Wifi::IWifiDirectGroupOwnerListener
+       , public Tizen::Net::Wifi::IWifiDirectGroupClientListener
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        */
+               _WifiDirectSystemNetConnection(void);
+
+       /**
+        * This is the destructor for this class.
+        */
+       virtual ~_WifiDirectSystemNetConnection(void);
+
+       /**
+        * Initializes this instance with the specified account.
+        *
+        * @since 2.1
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        * @exception   E_INVALID_ACCOUNT       The specified network account is invalid.
+        * @exception   E_SYSTEM                        An internal error occurred.
+        */
+       result Construct(void);
+
+       virtual void OnWifiDirectDeviceActivated(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, result r);
+       virtual void OnWifiDirectDeviceDeactivated(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, result r);
+       virtual void OnWifiDirectGroupCreatedN(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, const Tizen::Net::Wifi::WifiDirectGroupInfo& wifiDirectGroupInfo, const Tizen::Net::Wifi::WifiDirectDeviceInfo& wifiDirectGroupOwnerDeviceInfo, Tizen::Net::Wifi::WifiDirectGroupMember* pWifiDirectMember, result r);
+       virtual void OnWifiDirectScanCompletedN(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, Tizen::Base::Collection::IList* pWifiDirectDeviceInfoList, result r);
+       virtual void OnWifiDirectAssociationCompleted(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, const Tizen::Net::Wifi::WifiDirectDeviceInfo& wifiDirectGroupOwnerDeviceInfo, result r);
+
+       virtual void OnWifiDirectConnected(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, const Tizen::Net::Wifi::WifiDirectDeviceInfo& remoteDeviceInfo, result r){}
+       virtual void OnWifiDirectDisconnected(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, const Tizen::Base::String& peerMacAddress, result r){}
+       virtual void OnWifiDirectAutonomousGroupCreated(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, result r){}
+       virtual void OnWifiDirectGroupLeft(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, result r){}
+
+    virtual void OnWifiDirectClientAssociated(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, const Tizen::Net::Wifi::WifiDirectDeviceInfo& wifiDirectClientInfo);
+    virtual void OnWifiDirectClientDisassociated(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, const Tizen::Net::Wifi::WifiDirectDeviceInfo& wifiDirectClientInfo, Tizen::Net::Wifi::WifiDirectAssociationTerminationReason reason);
+    virtual void OnWifiDirectGroupDestroyed(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, result r);
+    virtual void OnWifiDirectGroupMemberInfoServiceStarted(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, const NetConnection* pNetConnection, result r);
+    virtual void OnWifiDirectGroupMemberInfoServiceStopped(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, result r);
+
+    virtual void OnWifiDirectAssociationTerminated(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, Tizen::Net::Wifi::WifiDirectAssociationTerminationReason reason, result r);
+    virtual void OnWifiDirectGroupOwnerInfoReceived(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, const Tizen::Net::Wifi::WifiDirectDeviceInfo& wifiDirectGroupOwnerDeviceInfo, result r);
+    virtual void OnWifiDirectAllGroupMemberInfoReceivedN(Tizen::Net::Wifi::WifiDirectDeviceId localDeviceId, Tizen::Base::Collection::IList* pWifiDirectDeviceInfoList, result r);
+
+       void UpdateConnectionInfo(bool isStarted);
+
+private:
+       /**
+        * This is the copy constructor for this class.
+        *
+        * @param[in]   value                   An instance of _WifiDirectSystemNetConnection
+        */
+       _WifiDirectSystemNetConnection(const _WifiDirectSystemNetConnection& rhs);
+
+       /**
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                             An instance of _WifiDirectSystemNetConnection
+        */
+       _WifiDirectSystemNetConnection& operator =(const _WifiDirectSystemNetConnection& rhs);
+
+private:
+       void* __pDllHandle;
+       Tizen::Net::Wifi::WifiDirectDevice* __pDevice;
+}; // _WifiDirectSystemNetConnection
+
+} }  // Tizen::Net
+#endif // _FNET_INTERNAL_WIFI_DIRECT_SYSTEM_NET_CONNECTION_H_
+
diff --git a/src/FNet_WifiSystemNetConnection.cpp b/src/FNet_WifiSystemNetConnection.cpp
new file mode 100644 (file)
index 0000000..f721d8c
--- /dev/null
@@ -0,0 +1,178 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file                       FNet_WifiSystemNetConnection.cpp
+ * @brief              This is the implementation file for _WifiSystemNetConnection class.
+ * @version    3.0
+ *
+ * This file contains the implementation of _WifiSystemNetConnection class.
+ */
+
+#include <net_connection.h>
+#include <FNetNetConnectionInfo.h>
+#include <FBaseRtMutexGuard.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FNet_NetTypes.h"
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNet_WifiSystemNetConnection.h"
+#include "FNet_NetAccountDatabase.h"
+#include "FNet_NetAccountManagerImpl.h"
+#include "FNet_NetConnectionEvent.h"
+#include "FNet_NetConnectionEventArg.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net {
+
+void
+WifiConnectionTypeChangedCallback(connection_type_e type, void* pUserData)
+{
+       _WifiSystemNetConnection* pConnection = static_cast<_WifiSystemNetConnection*>(pUserData);
+
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = pConnection->GetConnectionHandle();
+       connection_profile_h profileHandle = null;
+       connection_wifi_state_e state = CONNECTION_WIFI_STATE_DEACTIVATED;
+
+       SysLog(NID_NET, "WifiConnectionTypeChangedCallback() has been called with type:%d", type);
+
+       ret = connection_get_wifi_state(connectionHandle, &state);
+       SysTryReturnVoidResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
+                       "[%s] A system error has been called. The return value from connection_get_wifi_state() is %d", ret);
+
+       if (state == CONNECTION_WIFI_STATE_CONNECTED)
+       {
+               profileHandle = _NetAccountManagerImpl::GetWifiProfileHandleN();
+               SysTryReturnVoidResult(NID_NET, profileHandle != null,
+                               E_SYSTEM, "WIFI profileHandle is not found.");
+
+               SysLog(NID_NET, "Wifi is connected.");
+               pConnection->HandleStartEvent();
+               pConnection->UpdateConnectionInfo(profileHandle);
+
+               connection_profile_destroy(profileHandle);
+       }
+       else
+       {
+               SysLog(NID_NET, "Wifi is not connected.");
+               pConnection->HandleStopEvent(E_NETWORK_FAILED);
+               pConnection->UpdateConnectionInfo(null);
+       }
+}
+
+_WifiSystemNetConnection::_WifiSystemNetConnection(void)
+       : __pConnectionHandle(null)
+{
+}
+
+_WifiSystemNetConnection::~_WifiSystemNetConnection(void)
+{
+}
+
+result
+_WifiSystemNetConnection::Construct(void)
+{
+       result r = E_SUCCESS;
+       unique_ptr<void, _ConnectionDeleter> pConnectionHandle;
+       int ret = CONNECTION_ERROR_NONE;
+       connection_h connectionHandle = null;
+       connection_profile_h profileHandle = null;
+       connection_wifi_state_e state = CONNECTION_WIFI_STATE_DEACTIVATED;
+
+       SysAssertf(__pConnectionHandle == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       r = _SystemNetConnection::Initialize(L"WIFI");
+       SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.", GetErrorMessage(r));
+
+       ret = connection_create(&connectionHandle);
+       SysTryCatch(NID_NET, ret == CONNECTION_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_create() is %d", GetErrorMessage(E_SYSTEM), ret);
+       pConnectionHandle.reset(connectionHandle);
+
+       ret = connection_set_type_changed_cb(connectionHandle, WifiConnectionTypeChangedCallback, this);
+       SysTryCatch(NID_NET, ret == CONNECTION_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_set_type_changed_cb() is %d", ret);
+
+       ret = connection_get_wifi_state(connectionHandle, &state);
+       SysTryCatch(NID_NET, ret == CONNECTION_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                       "[%s] A system error has been occurred. The return value from connection_get_wifi_state() is %d", ret);
+
+       if (state == CONNECTION_WIFI_STATE_CONNECTED)
+       {
+               profileHandle = _NetAccountManagerImpl::GetWifiProfileHandleN();
+               if (profileHandle != null)
+               {
+                       SysLog(NID_NET, "Wifi is connected.");
+                       UpdateConnectionInfo(profileHandle);
+                       connection_profile_destroy(profileHandle);
+               }
+               else
+               {
+                       SysLog(NID_NET, "Wifi state is connected, but profileHandle is not found.");
+                       UpdateConnectionInfo(null);
+               }
+       }
+       else
+       {
+               SysLog(NID_NET, "Wifi is not connected.");
+               UpdateConnectionInfo(null);
+       }
+
+       __pConnectionHandle = move(pConnectionHandle);
+
+       return r;
+
+CATCH:
+       _SystemNetConnection::Deinitialize();
+
+       return r;
+}
+
+void
+_WifiSystemNetConnection::UpdateConnectionInfo(void* pData)
+{
+       MutexGuard locked(*_pLock);
+
+       if (pData != null)
+       {
+               _bearerType = NET_BEARER_WIFI;
+               _connectionState = NET_CONNECTION_STATE_STARTED;
+               _pConnectionInfo->Update(pData);
+
+       }
+       else
+       {
+               _bearerType = NET_BEARER_NONE;
+               _connectionState = NET_CONNECTION_STATE_STOPPED;
+               _pConnectionInfo->Clear();
+       }
+
+       locked.Unlock();
+}
+
+void*
+_WifiSystemNetConnection::GetConnectionHandle(void) const
+{
+       return __pConnectionHandle.get();
+}
+
+} } // Tizen::Net
diff --git a/src/FNet_WifiSystemNetConnection.h b/src/FNet_WifiSystemNetConnection.h
new file mode 100644 (file)
index 0000000..7c9e662
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNet_WifiSystemNetConnection.h
+ * @brief      This is the header file for the %_WifiSystemNetConnection class.
+ *
+ * This header file contains the declarations of the %_WifiSystemNetConnection class.
+ */
+
+#ifndef _FNET_INTERNAL_WIFI_SYSTEM_NET_CONNECTION_H_
+#define _FNET_INTERNAL_WIFI_SYSTEM_NET_CONNECTION_H_
+
+#include "FNet_SystemNetConnection.h"
+#include "FNet_NetUtility.h"
+
+namespace Tizen { namespace Net {
+/**
+ * @class      _WifiSystemNetConnection
+ * @brief      This class provides methods for a Wifi system network connection.
+ *
+ * @since 2.1
+ *
+ * This class provides methods for a system network connection.
+ */
+
+class _WifiSystemNetConnection
+       : public _SystemNetConnection
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        */
+               _WifiSystemNetConnection(void);
+
+       /**
+        * This is the destructor for this class.
+        */
+       virtual ~_WifiSystemNetConnection(void);
+
+       /**
+        * Initializes a default instance.
+        *
+        * @since 2.1
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_STATE         This instance is in an invalid state.
+        * @exception   E_INVALID_ACCOUNT       The specified network account is invalid.
+        * @exception   E_SYSTEM                        An internal error occurred.
+        */
+       result Construct(void);
+
+       void UpdateConnectionInfo(void* pData);
+
+       void* GetConnectionHandle(void) const;
+
+private:
+       /**
+        * This is the copy constructor for this class.
+        *
+        * @param[in]   rhs                     An instance of _WifiSystemNetConnection
+        */
+       _WifiSystemNetConnection(const _WifiSystemNetConnection& rhs);
+
+       /**
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                             An instance of _WifiSystemNetConnection
+        */
+       _WifiSystemNetConnection& operator =(const _WifiSystemNetConnection& rhs);
+
+private:
+       std::unique_ptr<void, _ConnectionDeleter> __pConnectionHandle;
+
+}; // _WifiSystemNetConnection
+
+} }  // Tizen::Net
+#endif // _FNET_INTERNAL_WIFI_SYSTEM_NET_CONNECTION_H_
+
diff --git a/src/http/FNetHttpHttpAuthentication.cpp b/src/http/FNetHttpHttpAuthentication.cpp
new file mode 100644 (file)
index 0000000..0d7f735
--- /dev/null
@@ -0,0 +1,107 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpAuthentication.cpp
+ * @brief              This is the implementation file for HttpAuthentication class.
+ *
+ * This file contains the implementation of HttpAuthentication class.
+ */
+
+#include <FBaseString.h>
+#include <FNetHttpHttpAuthentication.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FNetHttp_HttpAuthenticationImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+HttpAuthentication::HttpAuthentication(void)
+{
+       __pHttpAuthenticationImpl = new (std::nothrow) _HttpAuthenticationImpl();
+       SysTryReturnVoidResult(NID_NET_HTTP, __pHttpAuthenticationImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+HttpAuthentication::~HttpAuthentication(void)
+{
+       if (__pHttpAuthenticationImpl != null)
+       {
+               delete __pHttpAuthenticationImpl;
+               __pHttpAuthenticationImpl = null;
+       }
+}
+
+String*
+HttpAuthentication::GetRealmN(void) const
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       String* pRealm = __pHttpAuthenticationImpl->GetRealmN();
+       if (IsFailed(r))
+       {
+               SysLogException(NID_NET_HTTP, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               if (pRealm != null)
+                       delete pRealm;
+
+               return null;
+       }
+
+       return pRealm;
+}
+
+NetHttpAuthScheme
+HttpAuthentication::GetAuthScheme(void) const
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, NET_HTTP_AUTH_NONE, r, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       NetHttpAuthScheme scheme = __pHttpAuthenticationImpl->GetAuthScheme();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, NET_HTTP_AUTH_NONE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return scheme;
+}
+
+HttpTransaction*
+HttpAuthentication::SetCredentials(HttpCredentials& credentials)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       HttpTransaction* pTransaction = __pHttpAuthenticationImpl->SetCredentials(credentials);
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pTransaction;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttpHttpCookie.cpp b/src/http/FNetHttpHttpCookie.cpp
new file mode 100644 (file)
index 0000000..68f08ba
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpCookie.cpp
+ * @brief              This is the implementation file for HttpCookie class.
+ *
+ * This file contains the implementation of HttpCookie class.
+ */
+
+#include <FBaseBuffer.h>
+#include <FBaseString.h>
+#include <FBaseColIList.h>
+#include <FBaseColMultiHashMap.h>
+#include <FNetHttpHttpCookie.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpCookieImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+HttpCookie::HttpCookie()
+{
+       __pHttpCookieImpl = new (std::nothrow) _HttpCookieImpl();
+       SysTryReturnVoidResult(NID_NET_HTTP, __pHttpCookieImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+HttpCookie::~HttpCookie(void)
+{
+       if (__pHttpCookieImpl != null)
+       {
+               delete __pHttpCookieImpl;
+               __pHttpCookieImpl = null;
+       }
+}
+
+bool
+HttpCookie::IsHttpOnly(void) const
+{
+       bool rs = __pHttpCookieImpl->IsHttpOnly();
+       return rs;
+}
+bool
+HttpCookie::GetDiscard(void) const
+{
+       bool rs = __pHttpCookieImpl->GetDiscard();
+       return rs;
+}
+int
+HttpCookie::GetMaxAge(void) const
+{
+       int rs = __pHttpCookieImpl->GetMaxAge();
+       return rs;
+}
+Tizen::Base::String
+HttpCookie::GetDomain(void) const
+{
+       String rs = __pHttpCookieImpl->GetDomain();
+       return rs;
+}
+
+Tizen::Base::String
+HttpCookie::GetPath(void) const
+{
+       String rs = __pHttpCookieImpl->GetPath();
+       return rs;
+}
+
+Tizen::Base::String
+HttpCookie::GetVersion(void) const
+{
+       String rs = __pHttpCookieImpl->GetVersion();
+       return rs;
+}
+
+Tizen::Base::String
+HttpCookie::GetExpires(void) const
+{
+       String rs = __pHttpCookieImpl->GetExpires();
+       return rs;
+}
+
+bool
+HttpCookie::IsSecure(void) const
+{
+       bool rs = __pHttpCookieImpl->IsSecure();
+       return rs;
+}
+
+Tizen::Base::String
+HttpCookie::GetCookieName(void) const
+{
+       String rs = __pHttpCookieImpl->GetCookieName();
+       return rs;
+}
+
+Tizen::Base::String
+HttpCookie::GetPorts(void) const
+{
+       String rs = __pHttpCookieImpl->GetPorts();
+       return rs;
+}
+
+Tizen::Base::String
+HttpCookie::GetCookieValue(void) const
+{
+       String rs = __pHttpCookieImpl->GetCookieValue();
+       return rs;
+}
+
+Tizen::Base::String
+HttpCookie::GetCommentUrl(void) const
+{
+       String rs = __pHttpCookieImpl->GetCommentUrl();
+       return rs;
+}
+
+Tizen::Base::String
+HttpCookie::GetComment(void) const
+{
+       String rs = __pHttpCookieImpl->GetComment();
+       return rs;
+}
+
+} } } //Tizen::Net::Http
diff --git a/src/http/FNetHttpHttpCookieStorageManager.cpp b/src/http/FNetHttpHttpCookieStorageManager.cpp
new file mode 100644 (file)
index 0000000..1b1bcb6
--- /dev/null
@@ -0,0 +1,101 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpCookieStorageManager.cpp
+ * @brief              This is the implementation file for HttpCookieStorageManager class.
+ *
+ * This file contains the implementation of HttpCookieStorageManager class.
+ */
+
+#include <FBaseBuffer.h>
+#include <FBaseString.h>
+#include <FBaseColIList.h>
+#include <FNetHttpHttpSession.h>
+#include <FNetHttpHttpCookieStorageManager.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FNetHttp_HttpCookieStorageManagerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+HttpCookieStorageManager::HttpCookieStorageManager()
+{
+       __pHttpCookieStorageManagerImpl = new (std::nothrow) _HttpCookieStorageManagerImpl();
+       SysTryReturnVoidResult(NID_NET_HTTP, __pHttpCookieStorageManagerImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+HttpCookieStorageManager::~HttpCookieStorageManager()
+{
+       if (__pHttpCookieStorageManagerImpl != null)
+       {
+               delete __pHttpCookieStorageManagerImpl;
+               __pHttpCookieStorageManagerImpl = null;
+       }
+}
+
+result
+HttpCookieStorageManager::GetCookies(const Tizen::Base::String& url, Tizen::Base::String& cookies) const
+{
+       result r = E_SUCCESS;
+
+       SysLog(NID_NET_HTTP, "url : %ls", url.GetPointer());
+
+       r = __pHttpCookieStorageManagerImpl->GetCookies(url, cookies);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpCookieStorageManager::RemoveCookies(const Tizen::Base::String& url)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
+
+       SysLog(NID_NET_HTTP, "url : %ls", url.GetPointer());
+
+       r = __pHttpCookieStorageManagerImpl->RemoveCookies(url);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpCookieStorageManager::RemoveAllCookies()
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
+
+       r = __pHttpCookieStorageManagerImpl->RemoveAllCookies();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttpHttpCredentials.cpp b/src/http/FNetHttpHttpCredentials.cpp
new file mode 100644 (file)
index 0000000..646462c
--- /dev/null
@@ -0,0 +1,163 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpCredentials.cpp
+ * @brief              This is the implementation file for HttpCredentials class.
+ *
+ * This file contains the implementation of HttpCredentials class.
+ */
+
+#include <FBaseBuffer.h>
+#include <FBaseString.h>
+#include <FNetHttpHttpCredentials.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FNet_NetTypes.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+HttpCredentials::HttpCredentials(void)
+       : __pHttpCredentialsImpl(null)
+{
+}
+
+HttpCredentials::HttpCredentials(const String& username, const String& password)
+{
+       __userName = username;
+       __password = password;
+       __pHttpCredentialsImpl = null;
+}
+
+HttpCredentials::HttpCredentials(const HttpCredentials& rhs)
+{
+       __userName = rhs.__userName;
+       __password = rhs.__password;
+       __pHttpCredentialsImpl = null;
+}
+
+HttpCredentials::~HttpCredentials(void)
+{
+}
+
+HttpCredentials&
+HttpCredentials::operator =(const HttpCredentials& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __userName = rhs.__userName;
+       __password = rhs.__password;
+
+       return *this;
+}
+
+String
+HttpCredentials::GetName(void) const
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, L"", r, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       return __userName;
+}
+
+String
+HttpCredentials::GetPassword(void) const
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, L"", r, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       return __password;
+}
+
+result
+HttpCredentials::SetName(const String& userName)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
+
+       SysTryReturnResult(NID_NET_HTTP, userName.GetLength() > 0, E_INVALID_ARG,
+                                "Failed to set user name of the credentials.");
+
+       __userName = userName;
+       return r;
+}
+
+result
+HttpCredentials::SetPassword(const String& password)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
+
+       SysTryReturnResult(NID_NET_HTTP, password.GetLength() > 0, E_INVALID_ARG,
+                                "Failed to set password of the credentials.");
+
+       __password = password;
+       return r;
+}
+
+bool
+HttpCredentials::Equals(const Tizen::Base::Object& rhs) const
+{
+       const HttpCredentials* pRhs = dynamic_cast< const HttpCredentials* >(&rhs);
+
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       if (__userName != pRhs->__userName ||
+               __password != pRhs->__password)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+int
+HttpCredentials::GetHashCode(void) const
+{
+       int hashCode = _HASH_CODE_INITIAL_VALUE;
+
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __userName.GetHashCode();
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __password.GetHashCode();
+
+       return hashCode;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttpHttpHeader.cpp b/src/http/FNetHttpHttpHeader.cpp
new file mode 100644 (file)
index 0000000..a743d98
--- /dev/null
@@ -0,0 +1,167 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpHeader.cpp
+ * @brief              This is the implementation file for HttpHeader class.
+ *
+ * This file contains the implementation of HttpHeader class.
+ */
+
+#include <FBaseBuffer.h>
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpHttpHeader.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpHeaderImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+HttpHeader::HttpHeader(void)
+{
+       ClearLastResult();
+       __pHttpHeaderImpl = new (std::nothrow) _HttpHeaderImpl();
+       SysTryReturnVoidResult(NID_NET_HTTP, __pHttpHeaderImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+HttpHeader::HttpHeader(const HttpHeader* pCommonHeader)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       if (pCommonHeader != null)
+       {
+               __pHttpHeaderImpl = new (std::nothrow) _HttpHeaderImpl(pCommonHeader->__pHttpHeaderImpl);
+       }
+       else
+       {
+               __pHttpHeaderImpl = new (std::nothrow) _HttpHeaderImpl(null);
+       }
+       SysTryReturnVoidResult(NID_NET_HTTP, __pHttpHeaderImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = GetLastResult();
+       if (IsFailed(r))
+       {
+               SysLogException(NID_NET_HTTP, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+}
+
+HttpHeader::~HttpHeader(void)
+{
+       if (__pHttpHeaderImpl != null)
+       {
+               delete __pHttpHeaderImpl;
+               __pHttpHeaderImpl = null;
+       }
+}
+
+result
+HttpHeader::AddField(const String& fieldName, const String& fieldValue)
+{
+       result r = E_SUCCESS;
+
+       SysLog(NID_NET_HTTP, "fieldName : %ls, fieldValue : %ls", fieldName.GetPointer(), fieldValue.GetPointer());
+
+       r = __pHttpHeaderImpl->AddField(fieldName, fieldValue);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpHeader::RemoveField(const String& fieldName)
+{
+       result r = E_SUCCESS;
+
+       SysLog(NID_NET_HTTP, "fieldName : %ls", fieldName.GetPointer());
+
+       r = __pHttpHeaderImpl->RemoveField(fieldName);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpHeader::RemoveField(const String& fieldName, const String& fieldValue)
+{
+       result r = E_SUCCESS;
+
+       SysLog(NID_NET_HTTP, "fieldName : %ls, fieldValue : %ls", fieldName.GetPointer(), fieldValue.GetPointer());
+
+       r = __pHttpHeaderImpl->RemoveField(fieldName, fieldValue);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+void
+HttpHeader::RemoveAll(void)
+{
+       __pHttpHeaderImpl->RemoveAll();
+}
+
+Tizen::Base::String*
+HttpHeader::GetRawHeaderN(void) const
+{
+       result r = E_SUCCESS;
+
+       String* pRawHeaderString = __pHttpHeaderImpl->GetRawHeaderN();
+       r = GetLastResult();
+       if (IsFailed(r))
+       {
+               SysLogException(NID_NET_HTTP, r, "[%s] Failed to get the raw header.", GetErrorMessage(r));
+               delete pRawHeaderString;
+
+               return null;
+       }
+
+       return pRawHeaderString;
+}
+
+IList*
+HttpHeader::GetFieldNamesN() const
+{
+       result r = E_SUCCESS;
+
+       IList* pAllFields = null;
+
+       pAllFields = __pHttpHeaderImpl->GetFieldNamesN();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pAllFields;
+}
+
+IEnumerator*
+HttpHeader::GetFieldValuesN(const String& fieldName) const
+{
+       result r = E_SUCCESS;
+       IEnumerator* pValueEnum = null;
+
+       SysLog(NID_NET_HTTP, "fieldName : %ls", fieldName.GetPointer());
+
+       pValueEnum = __pHttpHeaderImpl->GetFieldValuesN(fieldName);
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, pValueEnum != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pValueEnum;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttpHttpMessage.cpp b/src/http/FNetHttpHttpMessage.cpp
new file mode 100644 (file)
index 0000000..1fb0f41
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpMessage.cpp
+ * @brief              This is the implementation file for HttpMessage class.
+ *
+ * This file contains the implementation of HttpMessage class.
+ */
+
+#include <FNetHttpHttpMessage.h>
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+HttpMessage::~HttpMessage(void)
+{
+       _bodyQueue.RemoveAll(true);
+
+       if (_pHeader != null)
+       {
+               _pHeader->RemoveAll();
+               delete _pHeader;
+               _pHeader = null;
+       }
+}
+
+HttpMessage::HttpMessage(void)
+       : _totalLen(0)
+       , _pHeader(null)
+       , _pHttpMessageImpl(null)
+{
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttpHttpMultipartEntity.cpp b/src/http/FNetHttpHttpMultipartEntity.cpp
new file mode 100644 (file)
index 0000000..4e0e3aa
--- /dev/null
@@ -0,0 +1,238 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpMultipartEntity.cpp
+ * @brief              This is the implementation file for the HttpMultipartEntity class.
+ *
+ * This header file contains the implementation of the HttpMultipartEntity class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FIoFile.h>
+#include <FNetHttpHttpMultipartEntity.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpMultipartEntityImpl.h"
+#include "FNetHttp_HttpCommon.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+using namespace Tizen::Text;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+extern const wchar_t HTTP_STRING_PART_DEFAULT_MIME_TYPE[] = L"text/plain";
+
+extern const wchar_t HTTP_FILE_PART_DEFAULT_MIME_TYPE[] = L"application/octet-stream";
+
+HttpMultipartEntity::HttpMultipartEntity(void)
+       : __pHttpMultipartEntityImpl(null)
+{
+}
+
+HttpMultipartEntity::~HttpMultipartEntity(void)
+{
+       if (__pHttpMultipartEntityImpl != null)
+       {
+               delete __pHttpMultipartEntityImpl;
+               __pHttpMultipartEntityImpl = null;
+       }
+}
+
+result
+HttpMultipartEntity::Construct(void)
+{
+       SysAssertf(__pHttpMultipartEntityImpl == null,
+                          "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+
+       unique_ptr<_HttpMultipartEntityImpl> pHttpMultipartEntityImpl(new (std::nothrow) _HttpMultipartEntityImpl());
+       SysTryReturnResult(NID_NET_HTTP, pHttpMultipartEntityImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pHttpMultipartEntityImpl->Construct();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       __pHttpMultipartEntityImpl = pHttpMultipartEntityImpl.release();
+
+       return r;
+}
+
+result
+HttpMultipartEntity::Construct(const Tizen::Base::String& boundary)
+{
+       SysAssertf(__pHttpMultipartEntityImpl == null,
+                          "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+
+       unique_ptr<_HttpMultipartEntityImpl> pHttpMultipartEntityImpl(new (std::nothrow) _HttpMultipartEntityImpl());
+       SysTryReturnResult(NID_NET_HTTP, pHttpMultipartEntityImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       SysLog(NID_NET_HTTP, "boundary : %ls", boundary.GetPointer());
+
+       r = pHttpMultipartEntityImpl->Construct(boundary);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       __pHttpMultipartEntityImpl = pHttpMultipartEntityImpl.release();
+
+       return r;
+}
+
+long long
+HttpMultipartEntity::GetContentLength(void) const
+{
+       SysAssertf(__pHttpMultipartEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       long long contentLength = 0;
+
+       contentLength = __pHttpMultipartEntityImpl->GetContentLength();
+
+       return contentLength;
+}
+
+Tizen::Base::String
+HttpMultipartEntity::GetContentType(void) const
+{
+       SysAssertf(__pHttpMultipartEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       String contentType = __pHttpMultipartEntityImpl->GetContentType();
+
+       return contentType;
+}
+
+bool
+HttpMultipartEntity::HasNextData(void)
+{
+       SysAssertf(__pHttpMultipartEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+       bool rs = false;
+
+       rs = __pHttpMultipartEntityImpl->HasNextData();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return rs;
+}
+
+Tizen::Base::ByteBuffer*
+HttpMultipartEntity::GetNextDataN(int recommendedSize)
+{
+       SysAssertf(__pHttpMultipartEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+       ByteBuffer* pBuffer = null;
+
+       pBuffer = __pHttpMultipartEntityImpl->GetNextDataN(recommendedSize);
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pBuffer;
+}
+
+result
+HttpMultipartEntity::AddStringPart(const Tizen::Base::String& name, const Tizen::Base::String& text)
+{
+       SysAssertf(__pHttpMultipartEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pHttpMultipartEntityImpl->AddStringPart(name, text);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpMultipartEntity::AddStringPart(const Tizen::Base::String& name, const Tizen::Base::String& text,
+                                                                  const Tizen::Base::String& mimeType, const Tizen::Base::String& charset,
+                                                                  const Tizen::Text::Encoding& encoding)
+{
+       SysAssertf(__pHttpMultipartEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pHttpMultipartEntityImpl->AddStringPart(name, text, mimeType, charset, encoding);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpMultipartEntity::AddFilePart(const Tizen::Base::String& name, const Tizen::Base::String& filePath)
+{
+       SysAssertf(__pHttpMultipartEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pHttpMultipartEntityImpl->AddFilePart(name, filePath);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpMultipartEntity::AddFilePart(const Tizen::Base::String& name, const Tizen::Base::String& filePath,
+                                                                const Tizen::Base::String& fileName, const Tizen::Base::String& mimeType,
+                                                                const Tizen::Base::String& charset)
+{
+       SysAssertf(__pHttpMultipartEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pHttpMultipartEntityImpl->AddFilePart(name, filePath, fileName, mimeType, charset);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpMultipartEntity::AddFilePartByBuffer(const Tizen::Base::String& name, const Tizen::Base::String& fileName,
+                                                                                const Tizen::Base::ByteBuffer& buffer)
+{
+       SysAssertf(__pHttpMultipartEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pHttpMultipartEntityImpl->AddFilePartByBuffer(name, fileName, buffer);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpMultipartEntity::AddFilePartByBuffer(const Tizen::Base::String& name, const Tizen::Base::String& fileName,
+                                                                                const Tizen::Base::ByteBuffer& buffer, const Tizen::Base::String& mimeType,
+                                                                                const Tizen::Base::String& charset)
+{
+       SysAssertf(__pHttpMultipartEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pHttpMultipartEntityImpl->AddFilePartByBuffer(name, fileName, buffer, mimeType, charset);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+} } } // Tizen::Net::HttpMultipartEntity
diff --git a/src/http/FNetHttpHttpRequest.cpp b/src/http/FNetHttpHttpRequest.cpp
new file mode 100644 (file)
index 0000000..e3840ab
--- /dev/null
@@ -0,0 +1,255 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpRequest.cpp
+ * @brief              This is the implementation file for HttpRequest class.
+ *
+ * This file contains the implementation of HttpRequest class.
+ */
+
+#include <FNetHttpHttpRequest.h>
+#include <FNetHttpHttpTransaction.h>
+#include <FNetHttpHttpHeader.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpRequestImpl.h"
+#include "FNetHttp_HttpTransactionImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+HttpRequest::HttpRequest(void)
+{
+       __pHttpRequestImpl = new (std::nothrow) _HttpRequestImpl(this);
+       SysTryReturnVoidResult(NID_NET_HTTP, __pHttpRequestImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+}
+
+
+HttpRequest::~HttpRequest(void)
+{
+       if (__pHttpRequestImpl != null)
+       {
+               delete __pHttpRequestImpl;
+               __pHttpRequestImpl = null;
+       }
+}
+
+result
+HttpRequest::Construct(const HttpTransaction& htttpTransaction, const HttpHeader* pCommonHeader)
+{
+       result r = E_SUCCESS;
+
+       HttpTransaction* pHttpTransaction = const_cast< HttpTransaction* >(&htttpTransaction);
+
+       r = __pHttpRequestImpl->Construct(*_HttpTransactionImpl::GetInstance(*pHttpTransaction), pCommonHeader);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_SYSTEM, "Failed to construct the HttpRequest.");
+
+       return r;
+}
+
+result
+HttpRequest::SetMethod(const NetHttpMethod method)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpRequestImpl->SetMethod(method);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpRequest::SetCustomMethod(const String& method)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpRequestImpl->SetCustomMethod(method);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpRequest::SetVersion(HttpVersion version)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpRequestImpl->SetVersion(version);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpRequest::SetUri(const String& uri)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpRequestImpl->SetUri(uri);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpRequest::WriteBody(const Tizen::Base::ByteBuffer& body)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __pHttpRequestImpl->__pIHttpEntity == null, E_INVALID_STATE, "The entity is already set in HttpRequest.");
+
+       r = __pHttpRequestImpl->WriteBody(body);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpRequest::SetEntity(IHttpEntity& entity)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpRequestImpl->SetEntity(entity);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+HttpHeader*
+HttpRequest::GetHeader(void) const
+{
+       result r = E_SUCCESS;
+
+       HttpHeader* pHeader = null;
+
+       pHeader = __pHttpRequestImpl->GetHeader();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pHeader;
+}
+
+NetHttpMethod
+HttpRequest::GetMethod() const
+{
+       result r = E_SUCCESS;
+
+       NetHttpMethod method;
+
+       method = __pHttpRequestImpl->GetMethod();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, NET_HTTP_METHOD_GET, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return method;
+}
+
+result
+HttpRequest::GetCustomMethod(String& method) const
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpRequestImpl->GetCustomMethod(method);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+HttpVersion
+HttpRequest::GetVersion(void) const
+{
+       result r = E_SUCCESS;
+
+       HttpVersion version = __pHttpRequestImpl->GetVersion();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, version, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return version;
+}
+
+result
+HttpRequest::GetUri(String& uri) const
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpRequestImpl->GetUri(uri);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+Tizen::Base::ByteBuffer*
+HttpRequest::ReadBodyN()
+{
+       result r = E_SUCCESS;
+       ByteBuffer* pBodyBuffer = null;
+
+       pBodyBuffer = __pHttpRequestImpl->ReadBodyN();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pBodyBuffer;
+}
+
+result
+HttpRequest::SetCookie(const Tizen::Base::String& cookieString)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpRequestImpl->SetCookie(cookieString);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+Tizen::Base::String
+HttpRequest::GetCookie(void) const
+{
+       result r = E_SUCCESS;
+       String cookies;
+
+       cookies = __pHttpRequestImpl->GetCookie();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, cookies, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return cookies;
+}
+
+result
+HttpRequest::SetAcceptEncoding(const Tizen::Base::String& encoding)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpRequestImpl->SetAcceptEncoding(encoding);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+Tizen::Base::String
+HttpRequest::GetAcceptEncoding(void) const
+{
+       String encoding;
+
+       encoding = __pHttpRequestImpl->GetAcceptEncoding();
+
+       return encoding;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttpHttpResponse.cpp b/src/http/FNetHttpHttpResponse.cpp
new file mode 100644 (file)
index 0000000..4186f47
--- /dev/null
@@ -0,0 +1,234 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpResponse.cpp
+ * @brief              This is the implementation file for HttpResponse class.
+ *
+ * This file contains the implementation of HttpResponse class.
+ */
+
+#include <FNetHttpHttpHeader.h>
+#include <FNetHttpHttpResponse.h>
+#include <FNetHttpHttpTransaction.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpResponseImpl.h"
+#include "FNetHttp_HttpTransactionImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+HttpResponse::HttpResponse(void)
+{
+       __pHttpResponseImpl = new (std::nothrow) _HttpResponseImpl(this);
+       SysTryReturnVoidResult(NID_NET_HTTP, __pHttpResponseImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+HttpResponse::~HttpResponse(void)
+{
+       if (__pHttpResponseImpl != null)
+       {
+               delete __pHttpResponseImpl;
+               __pHttpResponseImpl = null;
+       }
+}
+
+result
+HttpResponse::Construct(const HttpTransaction& htttpTransaction)
+{
+       result r = E_SUCCESS;
+       HttpTransaction* pHttpTransaction = const_cast< HttpTransaction* >(&htttpTransaction);
+
+       r = __pHttpResponseImpl->Construct(*_HttpTransactionImpl::GetInstance(*pHttpTransaction));
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+NetHttpStatusCode
+HttpResponse::GetStatusCode(void) const
+{
+       result r = E_SUCCESS;
+       NetHttpStatusCode statusCode = NET_HTTP_STATUS_UNDEFINED;
+
+       statusCode = __pHttpResponseImpl->GetStatusCode();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, statusCode, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return statusCode;
+}
+
+int
+HttpResponse::GetHttpStatusCode(void) const
+{
+       result r = E_SUCCESS;
+       int statusCode = -1;
+
+       statusCode = __pHttpResponseImpl->GetHttpStatusCode();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, statusCode, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return statusCode;
+}
+
+String
+HttpResponse::GetStatusText(void) const
+{
+       result r = E_SUCCESS;
+       String statusText = L"";
+
+       statusText = __pHttpResponseImpl->GetStatusText();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, statusText, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return statusText;
+}
+
+String
+HttpResponse::GetVersion(void) const
+{
+       result r = E_SUCCESS;
+       String version = L"";
+
+       version = __pHttpResponseImpl->GetVersion();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, version, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return version;
+}
+
+HttpHeader*
+HttpResponse::GetHeader(void) const
+{
+       result r = E_SUCCESS;
+       HttpHeader* pHeader = null;
+
+       pHeader = __pHttpResponseImpl->GetHeader();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, pHeader, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pHeader;
+}
+
+Tizen::Base::ByteBuffer*
+HttpResponse::ReadBodyN(void)
+{
+       result r = E_SUCCESS;
+       ByteBuffer* pBodyBuffer = null;
+
+       pBodyBuffer = __pHttpResponseImpl->ReadBodyN();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, pBodyBuffer, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pBodyBuffer;
+}
+
+result
+HttpResponse::SetStatusCode(NetHttpStatusCode statusCode)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpResponseImpl->SetStatusCode(statusCode);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpResponse::SetHttpStatusCode(int statusCode)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpResponseImpl->SetHttpStatusCode(statusCode);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return E_SUCCESS;
+}
+
+result
+HttpResponse::SetStatusText(const String& statusText)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpResponseImpl->SetStatusText(statusText);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpResponse::SetVersion(const String& httpVersion)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpResponseImpl->SetVersion(httpVersion);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpResponse::WriteBody(const ByteBuffer& body)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpResponseImpl->WriteBody(body);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+
+result
+HttpResponse::Read(const int headerLen, const int bodyLen, int& rcvHeaderLen, int& rcvBodyLen)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpResponseImpl->Read(headerLen, bodyLen, rcvHeaderLen, rcvBodyLen);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+IList*
+HttpResponse::GetCookies(void) const
+{
+       result r = E_SUCCESS;
+       IList* pCookies = null;
+
+       pCookies = __pHttpResponseImpl->GetCookies();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pCookies;
+}
+
+result
+HttpResponse::SetCookie(HttpHeader* pHeader)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpResponseImpl->SetCookie(pHeader);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttpHttpSession.cpp b/src/http/FNetHttpHttpSession.cpp
new file mode 100644 (file)
index 0000000..bee7daf
--- /dev/null
@@ -0,0 +1,273 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpSession.cpp
+ * @brief              This is the implementation file for HttpSession class.
+ *
+ * This file contains the implementation of HttpSession class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseResult.h>
+#include <FBaseUtilStringUtil.h>
+#include <FNetHttpHttpSession.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FNetHttp_HttpSessionImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+using namespace Tizen::Net;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+HttpSession::HttpSession()
+       : __pHttpSessionImpl(null)
+{
+}
+
+HttpSession::~HttpSession(void)
+{
+       if (__pHttpSessionImpl != null)
+       {
+               delete __pHttpSessionImpl;
+               __pHttpSessionImpl = null;
+       }
+}
+
+result
+HttpSession::Construct(NetHttpSessionMode sessionMode, const String* pProxyAddr, const String& hostAddr,
+                                          const HttpHeader* pCommonHeader,
+                                          NetHttpCookieFlag flag)
+{
+       SysAssertf(__pHttpSessionImpl == null,
+                          "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+
+       unique_ptr<_HttpSessionImpl> pHttpSessionImpl(new (std::nothrow) _HttpSessionImpl(this));
+       SysTryReturnResult(NID_NET_HTTP, pHttpSessionImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pHttpSessionImpl->Construct(sessionMode, pProxyAddr, hostAddr, pCommonHeader, flag);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       __pHttpSessionImpl = pHttpSessionImpl.release();
+
+       return r;
+}
+
+result
+HttpSession::Construct(const Tizen::Net::NetConnection& netConnection, NetHttpSessionMode sessionMode, const String* pProxyAddr,
+                                          const String& hostAddr, const HttpHeader* pCommonHeader,
+                                          NetHttpCookieFlag flag)
+{
+       SysAssertf(__pHttpSessionImpl == null,
+                          "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+
+       unique_ptr<_HttpSessionImpl> pHttpSessionImpl(new (std::nothrow) _HttpSessionImpl(this));
+       SysTryReturnResult(NID_NET_HTTP, pHttpSessionImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pHttpSessionImpl->Construct(netConnection, sessionMode, pProxyAddr, hostAddr, pCommonHeader, flag);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       __pHttpSessionImpl = pHttpSessionImpl.release();
+
+       return r;
+}
+
+HttpCookieStorageManager*
+HttpSession::GetCookieStorageManager(void) const
+{
+       SysAssertf(__pHttpSessionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+       HttpCookieStorageManager* pHttpCookieStorageManager = null;
+
+       pHttpCookieStorageManager = __pHttpSessionImpl->GetCookieStorageManager();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, pHttpCookieStorageManager, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pHttpCookieStorageManager;
+}
+
+result
+HttpSession::SetAutoRedirectionEnabled(bool enable)
+{
+       SysAssertf(__pHttpSessionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pHttpSessionImpl->SetAutoRedirectionEnabled(enable);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+bool
+HttpSession::IsAutoRedirectionEnabled(void) const
+{
+       SysAssertf(__pHttpSessionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       bool rs = false;
+
+       rs = __pHttpSessionImpl->IsAutoRedirectionEnabled();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, rs, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return rs;
+}
+
+HttpTransaction*
+HttpSession::OpenTransactionN()
+{
+       SysAssertf(__pHttpSessionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+       HttpTransaction* pHttpTransaction = null;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       pHttpTransaction = __pHttpSessionImpl->OpenTransactionN();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, pHttpTransaction, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pHttpTransaction;
+}
+
+
+HttpTransaction*
+HttpSession::OpenTransactionN(const HttpAuthentication& auth)
+{
+       SysAssertf(__pHttpSessionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+       HttpTransaction* pHttpTransaction = null;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       pHttpTransaction = __pHttpSessionImpl->OpenTransactionN(auth);
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, pHttpTransaction, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pHttpTransaction;
+}
+
+result
+HttpSession::CloseAllTransactions(void)
+{
+       SysAssertf(__pHttpSessionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       r = __pHttpSessionImpl->CloseAllTransactions();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpSession::CancelTransaction(HttpTransaction& httpTransaction)
+{
+       SysAssertf(__pHttpSessionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
+
+       r = __pHttpSessionImpl->CancelTransaction(httpTransaction);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpSession::CloseTransaction(HttpTransaction& httpTransaction)
+{
+       SysAssertf(__pHttpSessionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
+
+       r = __pHttpSessionImpl->CloseTransaction(httpTransaction);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+int
+HttpSession::GetActiveTransactionCount(void) const
+{
+       SysAssertf(__pHttpSessionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+       int activeTransactionCount = -1;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, -1, r, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       activeTransactionCount = __pHttpSessionImpl->GetActiveTransactionCount();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, activeTransactionCount, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return activeTransactionCount;
+}
+
+int
+HttpSession::GetMaxTransactionCount(void) const
+{
+       SysAssertf(__pHttpSessionImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+       int maxTransactionCount = -1;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, -1, r, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       maxTransactionCount = __pHttpSessionImpl->GetMaxTransactionCount();
+       r = GetLastResult();
+
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, maxTransactionCount, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return maxTransactionCount;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttpHttpStringEntity.cpp b/src/http/FNetHttpHttpStringEntity.cpp
new file mode 100644 (file)
index 0000000..bda8dbf
--- /dev/null
@@ -0,0 +1,159 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpStringEntity.cpp
+ * @brief              This is the implementation file for the HttpStringEntity class.
+ *
+ * This file contains the implementation of the HttpStringEntity class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FTextEncoding.h>
+#include <FNetHttpHttpStringEntity.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpStringEntityImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Text;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+HttpStringEntity::HttpStringEntity(void)
+       : __pHttpStringEntityImpl(null)
+{
+}
+
+HttpStringEntity::~HttpStringEntity(void)
+{
+       if (__pHttpStringEntityImpl != null)
+       {
+               delete __pHttpStringEntityImpl;
+               __pHttpStringEntityImpl = null;
+       }
+}
+
+result
+HttpStringEntity::Construct(const Tizen::Base::String& text)
+{
+       SysAssertf(__pHttpStringEntityImpl == null,
+                          "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+
+       unique_ptr<_HttpStringEntityImpl> pHttpStringEntityImpl(new (std::nothrow) _HttpStringEntityImpl());
+       SysTryReturnResult(NID_NET_HTTP, pHttpStringEntityImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       SysLog(NID_NET_HTTP, "length of text : %d", text.GetLength());
+
+       r = pHttpStringEntityImpl->Construct(text);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       __pHttpStringEntityImpl = pHttpStringEntityImpl.release();
+
+       return r;
+}
+
+result
+HttpStringEntity::Construct(const Tizen::Base::String& text, const Tizen::Base::String& contentType, const Tizen::Base::String& charset,
+                                                       const Tizen::Text::Encoding& encoding)
+{
+       SysAssertf(__pHttpStringEntityImpl == null,
+                          "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+
+       unique_ptr<_HttpStringEntityImpl> pHttpStringEntityImpl(new (std::nothrow) _HttpStringEntityImpl());
+       SysTryReturnResult(NID_NET_HTTP, pHttpStringEntityImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       SysLog(NID_NET_HTTP, "length of text : %d, contentType : %ls, charset : %ls, encodingType : %ls",
+                       text.GetLength(), contentType.GetPointer(), charset.GetPointer(), encoding.GetEncodingType().GetPointer());
+
+       r = pHttpStringEntityImpl->Construct(text, contentType, charset, encoding);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       __pHttpStringEntityImpl = pHttpStringEntityImpl.release();
+
+       return r;
+}
+
+long long
+HttpStringEntity::GetContentLength(void) const
+{
+       SysAssertf(__pHttpStringEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       if (__pHttpStringEntityImpl != null)
+       {
+               return __pHttpStringEntityImpl->GetContentLength();
+       }
+       else
+       {
+               return 0;
+       }
+}
+
+Tizen::Base::String
+HttpStringEntity::GetContentType(void) const
+{
+       SysAssertf(__pHttpStringEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       if (__pHttpStringEntityImpl != null)
+       {
+               return __pHttpStringEntityImpl->GetContentType();
+       }
+       else
+       {
+               return L"";
+       }
+}
+
+bool
+HttpStringEntity::HasNextData(void)
+{
+       SysAssertf(__pHttpStringEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       if (__pHttpStringEntityImpl != null)
+       {
+               return __pHttpStringEntityImpl->HasNextData();
+       }
+       else
+       {
+               return false;
+       }
+}
+
+Tizen::Base::ByteBuffer*
+HttpStringEntity::GetNextDataN(int recommendedSize)
+{
+       SysAssertf(__pHttpStringEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       ByteBuffer* pData = null;
+
+       if (__pHttpStringEntityImpl != null)
+       {
+               pData = __pHttpStringEntityImpl->GetNextDataN(recommendedSize);
+       }
+
+       return pData;
+}
+
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttpHttpTransaction.cpp b/src/http/FNetHttpHttpTransaction.cpp
new file mode 100644 (file)
index 0000000..2a263e8
--- /dev/null
@@ -0,0 +1,228 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpTransaction.cpp
+ * @brief              This is the implementation file for HttpTransaction class.
+ *
+ * This file contains the implementation of HttpTransaction class.
+ */
+
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpHttpTransaction.h>
+#include <FNetHttpHttpRequest.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FNetHttp_HttpTransactionImpl.h"
+#include "FNetHttp_HttpCommon.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+HttpTransaction::HttpTransaction(void)
+{
+       __pHttpTransactionImpl = new (std::nothrow) _HttpTransactionImpl(this);
+       SysTryReturnVoidResult(NID_NET_HTTP, __pHttpTransactionImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+HttpTransaction::~HttpTransaction(void)
+{
+       if (__pHttpTransactionImpl != null)
+       {
+               delete __pHttpTransactionImpl;
+               __pHttpTransactionImpl = null;
+       }
+}
+
+result
+HttpTransaction::Submit(void)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
+
+       r = __pHttpTransactionImpl->Submit();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+       return r;
+}
+
+HttpAuthentication*
+HttpTransaction::OpenAuthenticationInfoN(void)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_HTTP);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       HttpAuthentication* pHttpAuthentication = __pHttpTransactionImpl->OpenAuthenticationInfoN();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pHttpAuthentication;
+}
+
+HttpRequest*
+HttpTransaction::GetRequest() const
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       HttpRequest* pHttpRequest = null;
+
+       pHttpRequest = __pHttpTransactionImpl->GetRequest();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pHttpRequest;
+}
+
+
+HttpResponse*
+HttpTransaction::GetResponse(void) const
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       HttpResponse* pHttpResponse = null;
+
+       pHttpResponse = __pHttpTransactionImpl->GetResponse();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pHttpResponse;
+}
+
+result
+HttpTransaction::AddHttpTransactionListener(IHttpTransactionEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpTransactionImpl->AddHttpTransactionListener(listener);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpTransaction::RemoveHttpTransactionListener(IHttpTransactionEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpTransactionImpl->RemoveHttpTransactionListener(listener);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpTransaction::SetHttpProgressListener(IHttpProgressEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpTransactionImpl->SetHttpProgressListener(listener);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpTransaction::SetUserObject(const Tizen::Base::Object* pUserData)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpTransactionImpl->SetUserObject(pUserData);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+Object*
+HttpTransaction::GetUserObject(void) const
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       Object* pUserObject = null;
+
+       pUserObject = __pHttpTransactionImpl->GetUserObject();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pUserObject;
+}
+
+bool
+HttpTransaction::EnableTransactionReadyToWrite(void)
+{
+       bool rs = false;
+
+       rs = __pHttpTransactionImpl->EnableTransactionReadyToWrite();
+
+       return rs;
+}
+
+result
+HttpTransaction::Resume()
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpTransactionImpl->Resume();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+HttpTransaction::Pause(void)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpTransactionImpl->Pause();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpTransaction::SetClientCertificate(int certificateId)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpTransactionImpl->SetClientCertificate(certificateId);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+HttpTransaction::SetTimeout(int timeout)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpTransactionImpl->SetTimeout(timeout);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttpHttpUrlEncodedEntity.cpp b/src/http/FNetHttpHttpUrlEncodedEntity.cpp
new file mode 100644 (file)
index 0000000..c1a0819
--- /dev/null
@@ -0,0 +1,172 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpUrlEncodedEntity.cpp
+ * @brief              This is the implementation file for the HttpUrlEncodedEntity class.
+ *
+ * This file contains the implementation of the HttpUrlEncodedEntity class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FTextEncoding.h>
+#include <FNetHttpHttpUrlEncodedEntity.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpUrlEncodedEntityImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Text;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+HttpUrlEncodedEntity::HttpUrlEncodedEntity(void)
+       : __pHttpUrlEncodedEntityImpl(null)
+{
+}
+
+HttpUrlEncodedEntity::~HttpUrlEncodedEntity(void)
+{
+       if (__pHttpUrlEncodedEntityImpl != null)
+       {
+               delete __pHttpUrlEncodedEntityImpl;
+               __pHttpUrlEncodedEntityImpl = null;
+       }
+}
+
+result
+HttpUrlEncodedEntity::Construct(void)
+{
+       SysAssertf(__pHttpUrlEncodedEntityImpl == null,
+                          "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+
+       unique_ptr<_HttpUrlEncodedEntityImpl> pHttpUrlEncodedEntityImpl(new (std::nothrow) _HttpUrlEncodedEntityImpl());
+       SysTryReturnResult(NID_NET_HTTP, pHttpUrlEncodedEntityImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pHttpUrlEncodedEntityImpl->Construct();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       __pHttpUrlEncodedEntityImpl = pHttpUrlEncodedEntityImpl.release();
+
+       return r;
+}
+
+result
+HttpUrlEncodedEntity::Construct(const Tizen::Base::String& charset, const Tizen::Text::Encoding& encoding)
+{
+       SysAssertf(__pHttpUrlEncodedEntityImpl == null,
+                          "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+
+       unique_ptr<_HttpUrlEncodedEntityImpl> pHttpUrlEncodedEntityImpl(new (std::nothrow) _HttpUrlEncodedEntityImpl());
+       SysTryReturnResult(NID_NET_HTTP, pHttpUrlEncodedEntityImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       SysLog(NID_NET_HTTP, "charset : %ls, encodingType : %ls", charset.GetPointer(), encoding.GetEncodingType().GetPointer());
+
+       r = pHttpUrlEncodedEntityImpl->Construct(charset, encoding);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       __pHttpUrlEncodedEntityImpl = pHttpUrlEncodedEntityImpl.release();
+
+       return r;
+}
+
+long long
+HttpUrlEncodedEntity::GetContentLength(void) const
+{
+       SysAssertf(__pHttpUrlEncodedEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       if (__pHttpUrlEncodedEntityImpl != null)
+       {
+               return __pHttpUrlEncodedEntityImpl->GetContentLength();
+       }
+       else
+       {
+               return 0;
+       }
+}
+
+Tizen::Base::String
+HttpUrlEncodedEntity::GetContentType(void) const
+{
+       SysAssertf(__pHttpUrlEncodedEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       if (__pHttpUrlEncodedEntityImpl != null)
+       {
+               return __pHttpUrlEncodedEntityImpl->GetContentType();
+       }
+       else
+       {
+               return L"";
+       }
+}
+
+result
+HttpUrlEncodedEntity::AddParameter(const Tizen::Base::String& name, const Tizen::Base::String& value)
+{
+       SysAssertf(__pHttpUrlEncodedEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       SysLog(NID_NET_HTTP, "name : %ls, value : %ls", name.GetPointer(), value.GetPointer());
+
+       r = __pHttpUrlEncodedEntityImpl->AddParameter(name, value);
+       if (IsFailed(r))
+       {
+               SysLogException(NID_NET_HTTP, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       return r;
+}
+
+bool
+HttpUrlEncodedEntity::HasNextData(void)
+{
+       SysAssertf(__pHttpUrlEncodedEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       if (__pHttpUrlEncodedEntityImpl != null)
+       {
+               return __pHttpUrlEncodedEntityImpl->HasNextData();
+       }
+       else
+       {
+               return false;
+       }
+}
+
+Tizen::Base::ByteBuffer*
+HttpUrlEncodedEntity::GetNextDataN(int recommendedSize)
+{
+       SysAssertf(__pHttpUrlEncodedEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       ByteBuffer* pData = null;
+
+       if (__pHttpUrlEncodedEntityImpl != null)
+       {
+               pData = __pHttpUrlEncodedEntityImpl->GetNextDataN(recommendedSize);
+       }
+
+       return pData;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttpHttpXmlDomEntity.cpp b/src/http/FNetHttpHttpXmlDomEntity.cpp
new file mode 100644 (file)
index 0000000..2eb2078
--- /dev/null
@@ -0,0 +1,134 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpXmlDomEntity.cpp
+ * @brief              This is the implementation file for the HttpXmlDomEntity class.
+ *
+ * This file contains the implementation of the HttpXmlDomEntity class.
+ */
+
+#include <unique_ptr.h>
+#include <libxml/tree.h>
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FNetHttpHttpXmlDomEntity.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpXmlDomEntityImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+HttpXmlDomEntity::HttpXmlDomEntity(void)
+       : __pHttpXmlDomEntityImpl(null)
+{
+}
+
+HttpXmlDomEntity::~HttpXmlDomEntity(void)
+{
+       if (__pHttpXmlDomEntityImpl != null)
+       {
+               delete __pHttpXmlDomEntityImpl;
+               __pHttpXmlDomEntityImpl = null;
+       }
+}
+
+result
+HttpXmlDomEntity::Construct(const xmlDoc& xmlDocument, const Tizen::Base::String& encodingScheme)
+{
+       SysAssertf(__pHttpXmlDomEntityImpl == null,
+                          "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+
+       unique_ptr<_HttpXmlDomEntityImpl> pHttpXmlDomEntityImpl(new (std::nothrow) _HttpXmlDomEntityImpl());
+       SysTryReturnResult(NID_NET_HTTP, pHttpXmlDomEntityImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       SysLog(NID_NET_HTTP, "encodingScheme : %ls", encodingScheme.GetPointer());
+
+       r = pHttpXmlDomEntityImpl->Construct(xmlDocument, encodingScheme);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       __pHttpXmlDomEntityImpl = pHttpXmlDomEntityImpl.release();
+
+       return r;
+}
+
+long long
+HttpXmlDomEntity::GetContentLength(void) const
+{
+       SysAssertf(__pHttpXmlDomEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       if (__pHttpXmlDomEntityImpl != null)
+       {
+               return __pHttpXmlDomEntityImpl->GetContentLength();
+       }
+       else
+       {
+               return 0;
+       }
+}
+
+Tizen::Base::String
+HttpXmlDomEntity::GetContentType(void) const
+{
+       SysAssertf(__pHttpXmlDomEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       if (__pHttpXmlDomEntityImpl != null)
+       {
+               return __pHttpXmlDomEntityImpl->GetContentType();
+       }
+       else
+       {
+               return L"";
+       }
+}
+
+bool
+HttpXmlDomEntity::HasNextData(void)
+{
+       SysAssertf(__pHttpXmlDomEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       if (__pHttpXmlDomEntityImpl != null)
+       {
+               return __pHttpXmlDomEntityImpl->HasNextData();
+       }
+       else
+       {
+               return false;
+       }
+}
+
+Tizen::Base::ByteBuffer*
+HttpXmlDomEntity::GetNextDataN(int recommendedSize)
+{
+       SysAssertf(__pHttpXmlDomEntityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       ByteBuffer* pData = null;
+
+       if (__pHttpXmlDomEntityImpl != null)
+       {
+               pData = __pHttpXmlDomEntityImpl->GetNextDataN(recommendedSize);
+       }
+
+       return pData;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpAuthenticationImpl.cpp b/src/http/FNetHttp_HttpAuthenticationImpl.cpp
new file mode 100644 (file)
index 0000000..7e44399
--- /dev/null
@@ -0,0 +1,251 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpAuthenticationImpl.cpp
+ * @brief              This is the implementation file for _HttpAuthenticationImpl class.
+ */
+
+#include <unique_ptr.h>
+#include <FNetHttpHttpTransaction.h>
+#include <FNetHttpHttpCredentials.h>
+#include <FNetHttpHttpAuthentication.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpTransactionImpl.h"
+#include "FNetHttp_HttpCurl.h"
+#include "FNetHttp_HttpAuthenticationImpl.h"
+#include "FNetHttp_HttpSessionImpl.h"
+#include "FNetHttp_HttpHeaderImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpAuthenticationImpl::_HttpAuthenticationImpl(void)
+       : __pHttpTransactionImpl(null)
+       , __authType(NET_HTTP_AUTH_NONE)
+       , __isProxyAuthType(false)
+       , __pHttpCurl(null)
+{
+}
+
+_HttpAuthenticationImpl::~_HttpAuthenticationImpl(void)
+{
+       if (__pHttpCurl != null)
+       {
+               __pHttpCurl->Release();
+       }
+}
+
+String*
+_HttpAuthenticationImpl::GetRealmN(void) const
+{
+       ClearLastResult();
+       String* pRealm = null;
+
+       pRealm = new (std::nothrow) String(__realm);
+       SysTryReturn(NID_NET_HTTP, pRealm != null, null, E_OUT_OF_MEMORY,
+                                "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       return pRealm;
+}
+
+NetHttpAuthScheme
+_HttpAuthenticationImpl::GetAuthScheme(void) const
+{
+       ClearLastResult();
+
+       return __authType;
+}
+
+HttpTransaction*
+_HttpAuthenticationImpl::SetCredentials(HttpCredentials& credentials)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+       HttpTransaction* pTransaction = null;
+
+       SysTryReturn(NID_NET_HTTP, __pHttpTransactionImpl != null && __pHttpTransactionImpl->IsClosed() == false, null, E_INVALID_STATE,
+                                "[E_INVALID_STATE] The HttpTransaction is already closed.");
+
+       SysTryReturn(NID_NET_HTTP, __pHttpTransactionImpl->IsSubmitted(), null, E_INVALID_STATE,
+                                "[E_INVALID_STATE] The HttpTransaction is not submitted yet.");
+
+       SysTryReturn(NID_NET_HTTP, !credentials.GetPassword().IsEmpty() && !credentials.GetName().IsEmpty(), null, E_INVALID_ARG,
+                                "[E_INVALID_ARG] Either user name or password of the credentials is empty.");
+
+       __credentials = credentials;
+
+       pTransaction = Authenticate(credentials);
+       r = GetLastResult();
+       r = TransExceptionsExclusive(r, E_AUTHENTICATION, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r,
+                                "[%s] Failed to set authentication information.", GetErrorMessage(r));
+
+       SysLog(NID_NET_HTTP, "Set the credentials.");
+
+       return pTransaction;
+}
+
+_HttpAuthenticationImpl*
+_HttpAuthenticationImpl::GetInstance(HttpAuthentication& httpAuthentication)
+{
+       return httpAuthentication.__pHttpAuthenticationImpl;
+}
+
+const _HttpAuthenticationImpl*
+_HttpAuthenticationImpl::GetInstance(const HttpAuthentication& httpAuthentication)
+{
+       return httpAuthentication.__pHttpAuthenticationImpl;
+}
+
+HttpTransaction*
+_HttpAuthenticationImpl::Authenticate(HttpCredentials& credentials)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+       _HttpSessionImpl* pHttpSessionImpl = null;
+       _HttpTransactionImpl* pCreatedHttpTransactionImpl = null;
+
+       pHttpSessionImpl = __pHttpTransactionImpl->GetHttpSessioinImpl();
+       SysTryReturn(NID_NET_HTTP, pHttpSessionImpl != null, null, E_INVALID_STATE,
+                                "[E_INVALID_STATE] Failed to get the HttpSession.");
+
+       unique_ptr<HttpTransaction> pCreatedHttpTransaction(pHttpSessionImpl->ReopenTransactionWithAuthN(*__pHttpTransactionImpl->GetHttpTransaction()));
+
+       SysTryReturn(NID_NET_HTTP, pCreatedHttpTransaction != null, null,
+                                E_INVALID_STATE, "[E_INVALID_STATE] Failed to reopen the HttpTransaction with Authentication.");
+
+       pCreatedHttpTransactionImpl = _HttpTransactionImpl::GetInstance(*pCreatedHttpTransaction);
+       pCreatedHttpTransactionImpl->SetHttpAuthenticationImpl(this);
+
+       r = pCreatedHttpTransactionImpl->Submit();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] Failed to submit the HttpTransaction.", GetErrorMessage(r));
+
+       return pCreatedHttpTransaction.release();
+}
+
+HttpCredentials
+_HttpAuthenticationImpl::GetCredentials(void) const
+{
+       return __credentials;
+}
+
+bool
+_HttpAuthenticationImpl::IsProxyAuthenticationType(void) const
+{
+       return __isProxyAuthType;
+}
+
+void
+_HttpAuthenticationImpl::SetHttpCurl(_HttpCurl* pHttpCurl)
+{
+       __pHttpCurl = pHttpCurl;
+}
+
+_HttpCurl*
+_HttpAuthenticationImpl::GetHttpCurl(void) const
+{
+       return __pHttpCurl;
+}
+
+result
+_HttpAuthenticationImpl::Construct(_HttpTransactionImpl& httpTransactionImpl)
+{
+       result r = E_SUCCESS;
+       String realm;
+
+       HttpResponse* pHttpResponse = httpTransactionImpl.GetResponse();
+       SysTryReturnResult(NID_NET_HTTP, pHttpResponse != null,
+                                          E_INVALID_STATE, "The response must not be null.");
+
+       HttpHeader* pHttpHeader = pHttpResponse->GetHeader();
+       SysTryReturnResult(NID_NET_HTTP, pHttpHeader != null,
+                                          E_INVALID_STATE, "The header is empty.");
+
+       _HttpHeaderImpl* pHttpHeaderImpl = _HttpHeaderImpl::GetInstance(*pHttpHeader);
+
+       __authType = httpTransactionImpl.GetHttpAuthType();
+       switch (__authType)
+       {
+       case NET_HTTP_AUTH_PROXY_BASIC:
+       case NET_HTTP_AUTH_PROXY_MD5:
+       case NET_HTTP_AUTH_PROXY_NTLM:
+               r = pHttpHeaderImpl->GetRealm(_HTTP_PROXY_AUTHENTICATE_HEADER_NAME, realm);
+               __isProxyAuthType = true;
+               break;
+
+       case NET_HTTP_AUTH_WWW_BASIC:
+       case NET_HTTP_AUTH_WWW_MD5:
+       case NET_HTTP_AUTH_WWW_NEGOTIATE:
+       case NET_HTTP_AUTH_WWW_NTLM:
+               r = pHttpHeaderImpl->GetRealm(_HTTP_WWW_AUTHENTICATE_HEADER_NAME, realm);
+               __isProxyAuthType = false;
+               break;
+
+       default:
+               break;
+       }
+
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          E_INVALID_STATE, "Failed to found the realm field.");
+
+       __realm = realm;
+       __pHttpTransactionImpl = &httpTransactionImpl;
+
+       __pHttpCurl = httpTransactionImpl.GetHttpCurl();
+       __pHttpCurl->SetAuthenticated();
+       __pHttpCurl->AddRef();
+
+       SysLog(NID_NET_HTTP, "The instance of _HttpCurl is re-used for the authentication.");
+
+       return r;
+}
+
+result
+_HttpAuthenticationImpl::Construct(const _HttpAuthenticationImpl& authenticationImpl, _HttpTransactionImpl& httpTransactionImpl)
+{
+       result r = E_SUCCESS;
+
+       __authType = authenticationImpl.__authType;
+       __isProxyAuthType = authenticationImpl.__isProxyAuthType;
+       __realm = authenticationImpl.__realm;
+       __pHttpTransactionImpl = &httpTransactionImpl;
+       __credentials = authenticationImpl.__credentials;
+
+       __pHttpCurl = authenticationImpl.__pHttpCurl;
+       __pHttpCurl->AddRef();
+
+       return r;
+}
+
+HttpAuthentication*
+_HttpAuthenticationImpl::CreateHttpAuthenticationN(void)
+{
+       return new (std::nothrow) HttpAuthentication();
+}
+
+void
+_HttpAuthenticationImpl::DeleteHttpAuthentication(HttpAuthentication* pHttpAuthentication)
+{
+       delete pHttpAuthentication;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpCommon.cpp b/src/http/FNetHttp_HttpCommon.cpp
new file mode 100644 (file)
index 0000000..99c7901
--- /dev/null
@@ -0,0 +1,782 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpCommon.cpp
+ * @brief              This file implement the common macro or function used by internal module.
+ */
+
+#include <unique_ptr.h>
+#include <pthread.h>
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseUtil.h>
+#include <FBaseRtMutex.h>
+#include <FBaseRtMutexGuard.h>
+#include <FBaseCol.h>
+#include <FAppApp.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FApp_AppInfo.h>
+#include <FIoDirectory.h>
+#include "FNetHttp_HttpCommon.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::App;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+extern const wchar_t _HTTP_USERAGENT_HEADER_NAME[] = L"User-Agent";
+
+extern const wchar_t _HTTP_CONTENT_LENGTH_HEADER_NAME[] = L"Content-Length";
+
+extern const wchar_t _HTTP_CONTENT_TYPE_HEADER_NAME[] = L"Content-Type";
+
+extern const wchar_t _HTTP_TRANSFER_ENCODING_HEADER_NAME[] = L"Transfer-Encoding";
+
+extern const wchar_t _HTTP_EXPECT_HEADER_NAME[] = L"Expect";
+
+extern const wchar_t _HTTP_SET_COOKIE_HEADER_NAME[] = L"Set-Cookie";
+
+extern const wchar_t _HTTP_PROXY_AUTHENTICATE_HEADER_NAME[] = L"Proxy-Authenticate";
+
+extern const wchar_t _HTTP_WWW_AUTHENTICATE_HEADER_NAME[] = L"WWW-Authenticate";
+
+extern const wchar_t _HTTP_CHUNKED_HEADER_VALUE[] = L"chunked";
+
+extern const wchar_t _HTTP_PROTOCOL_SCHEME[] = L"http://";
+
+extern const wchar_t _HTTPS_PROTOCOL_SCHEME[] = L"https://";
+
+extern const wchar_t _HTTP_DEFAULT_BODY_CHARSET[] = L"ISO-8859-1";
+
+extern const wchar_t _MULTI_PART_FORM_DATA_PREFIX[] = L"multipart/form-data; boundary=";
+
+extern const wchar_t _HTTP_STRING_PART_DEFAULT_CHARSET[] = L"ISO-8859-1";
+
+extern const wchar_t _HTTP_FILE_PART_DEFAULT_CHARSET[] = L"";
+
+extern const wchar_t _HTTP_MULTI_PART_BOUNDARY_CHARACTER_SET[] = L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+
+extern const wchar_t _HTTP_SET_COOKIE_DELIMITER[] = L";";
+
+extern const wchar_t _HTTP_SET_COOKIE_FLAG_DELIMITER[] = L"=";
+
+extern const wchar_t _HTTP_COOKIE_COMMENT_NAME[] = L"Comment";
+
+extern const wchar_t _HTTP_COOKIE_COMMENTURL_NAME[] = L"CommentURL";
+
+extern const wchar_t _HTTP_COOKIE_DISCARD_NAME[] = L"Discard";
+
+extern const wchar_t _HTTP_COOKIE_EXPIRES_NAME[] = L"Expires";
+
+extern const wchar_t _HTTP_COOKIE_DOMAIN_NAME[] = L"Domain";
+
+extern const wchar_t _HTTP_COOKIE_MAX_AGE_NAME[] = L"Max-Age";
+
+extern const wchar_t _HTTP_COOKIE_PATH_NAME[] = L"Path";
+
+extern const wchar_t _HTTP_COOKIE_PORT_NAME[] = L"Port";
+
+extern const wchar_t _HTTP_COOKIE_SECURE_NAME[] = L"Secure";
+
+extern const wchar_t _HTTP_COOKIE_VERSION_NAME[] = L"Version";
+
+extern const wchar_t _HTTP_COOKIE_HTTP_ONLY[] = L"HttpOnly";
+
+extern const wchar_t _HTTP_CARRIAGE_RETURN_LINE_FEED[] = L"\r\n";
+
+extern const wchar_t _CURL_COOKIE_HTTP_ONLY_PREFIX[] = L"#HttpOnly_";
+
+extern const wchar_t _HTTP_COOKIE_FILE[] = L"data/cookies.txt";
+
+static const char* NetHttpTransactionEventTypesToString[] =
+{
+       "_HTTP_TRANSACTION_EVENT_TYPE_UNDEFINED", "_HTTP_TRANSACTION_EVENT_TYPE_HEADER_COMPLETED",
+       "_HTTP_TRANSACTION_EVENT_TYPE_READY_TO_READ", "_HTTP_TRANSACTION_EVENT_TYPE_READY_TO_WRITE",
+       "_HTTP_TRANSACTION_EVENT_TYPE_COMPLETD", "_HTTP_TRANSACTION_EVENT_TYPE_ABORTED",
+       "_HTTP_TRANSACTION_EVENT_TYPE_CERT_VERIFICATION_REQUIRED", "_HTTP_TRANSACTION_EVENT_TYPE_UPLOAD_PROGRESS",
+       "_HTTP_TRANSACTION_EVENT_TYPE_DOWNLOAD_PROGRESS"
+};
+
+const char*
+_HttpUtility::ConvertHttpTransactionEventTypeToString(_HttpTransactionEventType index)
+{
+       return NetHttpTransactionEventTypesToString[index];
+}
+
+void
+_HttpUtility::PrintCurlMultiErrorCode(CURLMcode code)
+{
+       const char* pErrorMessage = null;
+       switch (code)
+       {
+               case CURLM_CALL_MULTI_PERFORM:
+                       pErrorMessage = "CURLM_CALL_MULTI_PERFORM";
+                       break;
+               case CURLM_BAD_HANDLE:
+                       pErrorMessage = "CURLM_BAD_HANDLE";
+                       break;
+               case CURLM_BAD_EASY_HANDLE:
+                       pErrorMessage = "CURLM_BAD_EASY_HANDLE";
+                       break;
+               case CURLM_OUT_OF_MEMORY:
+                       pErrorMessage = "CURLM_OUT_OF_MEMORY";
+                       break;
+               case CURLM_INTERNAL_ERROR:
+                       pErrorMessage = "CURLM_INTERNAL_ERROR";
+                       break;
+               case CURLM_BAD_SOCKET:
+                       pErrorMessage = "CURLM_BAD_SOCKET";
+                       break;
+               case CURLM_UNKNOWN_OPTION:
+                       pErrorMessage = "CURLM_UNKNOWN_OPTION";
+                       break;
+               case CURLM_LAST:
+                       pErrorMessage = "CURLM_LAST";
+                       break;
+               default:
+                       pErrorMessage = "CURLM_UNKNOWN_ERROR";
+                       break;
+       }
+
+       SysLog(NID_NET_HTTP, "CURLMcode(%d): %s", code, pErrorMessage);
+}
+
+result
+_HttpUtility::ConvertErrorCode(CURLcode code)
+{
+       result r = E_SUCCESS;
+       switch (code)
+       {
+               case CURLE_OK:
+                       r = E_SUCCESS;
+                       break;
+
+               case CURLE_COULDNT_CONNECT:                 // 7
+                       r = E_HOST_UNREACHABLE;
+                       break;
+
+               case CURLE_READ_ERROR:                      // 26 - couldn't open/read from file
+                       r = E_NOT_RESPONDING;
+                       break;
+
+               case CURLE_OPERATION_TIMEDOUT:              // 28 - the timeout time was reached
+                       r = E_TIMEOUT;
+                       break;
+
+               case CURLE_SSL_CONNECT_ERROR:               // 35 - wrong when connecting with SSL
+                       r = E_CONNECTION_RESET;
+                       break;
+
+               case CURLE_ABORTED_BY_CALLBACK:             // 42 - aborted by callback.
+                       r = E_OPERATION_CANCELED;
+                       break;
+
+               case CURLE_BAD_CONTENT_ENCODING:            // 61 - Unrecognized transfer encoding
+                       r = E_INVALID_CONTENT;
+                       break;
+
+               case CURLE_OUT_OF_MEMORY:                   // 27  Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error instead of a memory allocation error if CURL_DOES_CONVERSIONS is defined
+                       r = E_OUT_OF_MEMORY;
+                       break;
+
+               case CURLE_UNSUPPORTED_PROTOCOL:            // 1
+               case CURLE_URL_MALFORMAT:                   // 3
+               case CURLE_COULDNT_RESOLVE_PROXY:           // 5
+               case CURLE_COULDNT_RESOLVE_HOST:            // 6
+               case CURLE_REMOTE_ACCESS_DENIED:            // 9 a service was denied by the server due to lack of access - when login fails this is not returned.
+               case CURLE_PARTIAL_FILE:                    // 18
+               case CURLE_QUOTE_ERROR:                     // 21 - quote command failure
+               case CURLE_HTTP_RETURNED_ERROR:             // 22
+               case CURLE_WRITE_ERROR:                     // 23
+               case CURLE_UPLOAD_FAILED:                   // 25 - failed upload "command"
+               case CURLE_RANGE_ERROR:                     // 33 - RANGE "command" didn't work
+               case CURLE_HTTP_POST_ERROR:                 // 34
+               case CURLE_BAD_DOWNLOAD_RESUME:             // 36 - couldn't resume download
+               case CURLE_FILE_COULDNT_READ_FILE:          // 37
+               case CURLE_FUNCTION_NOT_FOUND:              // 41
+               case CURLE_BAD_FUNCTION_ARGUMENT:           // 43
+               case CURLE_INTERFACE_FAILED:                // 45 - CURLOPT_INTERFACE failed
+               case CURLE_TOO_MANY_REDIRECTS:              // 47 - catch endless re-direct loops
+               case CURLE_GOT_NOTHING:                     // 52 - when this is a specific error
+               case CURLE_SEND_ERROR:                      // 55 - failed sending network data
+               case CURLE_RECV_ERROR:                      // 56 - failure in receiving network data
+               case CURLE_PEER_FAILED_VERIFICATION:        // 51 - peer's certificate or fingerprint wasn't verified fine
+               case CURLE_SSL_CERTPROBLEM:                 // 58 - problem with the local certificate
+               case CURLE_SSL_CIPHER:                      // 59 - couldn't use specified cipher
+               case CURLE_SSL_CACERT:                      // 60 - problem with the CA cert (path?)
+               case CURLE_SSL_ISSUER_ERROR:                // 83 - Issuer check failed.  (Added in 7.19.0)
+               case CURLE_SSL_CRL_BADFILE:                 // 82 - could not load CRL file, missing or wrong format (Added in 7.19.0)
+               case CURLE_SSL_CACERT_BADFILE:              // 77 - could not load CACERT file, missing or wrong format
+               case CURLE_FILESIZE_EXCEEDED:               // 63 - Maximum file size exceeded
+               case CURLE_SEND_FAIL_REWIND:                // 65 - Sending the data requires a rewind that failed
+               case CURLE_SSL_ENGINE_INITFAILED:           // 66 - failed to initialise ENGINE
+               case CURLE_LOGIN_DENIED:                    // 67 - user, password or similar was not accepted and we failed to login
+               case CURLE_REMOTE_DISK_FULL:                // 70 - out of disk space on server
+               case CURLE_REMOTE_FILE_EXISTS:              // 73 - File already exists
+               case CURLE_CONV_FAILED:                     // 75 - conversion failed
+               case CURLE_CONV_REQD:                       // 76 - caller must register conversion callbacks using curl_easy_setopt options  CURLOPT_CONV_FROM_NETWORK_FUNCTION,  CURLOPT_CONV_TO_NETWORK_FUNCTION, and CURLOPT_CONV_FROM_UTF8_FUNCTION
+               case CURLE_REMOTE_FILE_NOT_FOUND:           // 78 - remote file not found
+               case CURLE_AGAIN:                           // 81 - socket is not ready for send/recv,  wait till it's ready and try again (Added in 7.18.2)
+               case CURLE_CHUNK_FAILED:                    // 88 - chunk callback reported error
+               case CURL_LAST:                             // never use!
+                       r = E_IO;
+                       break;
+
+               case CURLE_SSL_ENGINE_NOTFOUND:             // 53 - SSL crypto engine not found
+               case CURLE_SSL_ENGINE_SETFAILED:            // 54 - can not set SSL crypto engine as default
+               case CURLE_SSL_SHUTDOWN_FAILED:             // 80 - Failed to shut down the SSL connection
+                       r = E_SYSTEM;
+                       break;
+
+               default:
+                       r = E_UNKNOWN;
+                       break;
+       }
+               SysLog(NID_NET_HTTP, "Converter Error Code(CURLE(%d) => OSP result(%lu: %s)", code, r, GetErrorMessage(r));
+               return r;
+}
+
+bool
+_HttpUtility::IsSslError(CURLcode code)
+{
+       bool isSSLError = false;
+       switch (code)
+       {
+               case CURLE_SSL_CONNECT_ERROR:
+               case CURLE_PEER_FAILED_VERIFICATION: // 51 - peer's certificate or fingerprint wasn't verified fine
+               case CURLE_SSL_CERTPROBLEM: // 58 - problem with the local certificate
+               case CURLE_SSL_CIPHER: // 59 - couldn't use specified cipher
+               case CURLE_SSL_CACERT: // 60 - problem with the CA cert (path?)
+               case CURLE_SSL_ISSUER_ERROR: // 83 - Issuer check failed.  (Added in 7.19.0)
+               case CURLE_SSL_CRL_BADFILE: // 82 - could not load CRL file, missing or wrong format (Added in 7.19.0)
+               case CURLE_SSL_CACERT_BADFILE: // 77 - could not load CACERT file, missing or wrong format
+                       isSSLError = true;
+                       break;
+               default:
+                       isSSLError = false;
+                       break;
+       }
+
+       return isSSLError;
+}
+
+result
+_HttpUtility::AddHeaderByteBufferToBuffer(ByteBuffer **ppSrcBuffer, const ByteBuffer & destBuffer)
+{
+       result r = E_SUCCESS;
+
+       r = AddByteBufferToBuffer(ppSrcBuffer, destBuffer, _HTTP_DEFAULT_HEADER_SIZE);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+_HttpUtility::AddHeaderBytesToBuffer(ByteBuffer **ppSrcBuffer, const byte *pDestBytes, int destBytesSize)
+{
+       result r = E_SUCCESS;
+
+       r = AddBytesToBuffer(ppSrcBuffer, pDestBytes, destBytesSize, _HTTP_DEFAULT_HEADER_SIZE);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+_HttpUtility::AddByteBufferToBuffer(ByteBuffer **ppSrcBuffer, const ByteBuffer & destBuffer, int defaultExtendedSize)
+{
+       result r = E_SUCCESS;
+
+       r = AddBytesToBuffer(ppSrcBuffer, destBuffer.GetPointer(), destBuffer.GetRemaining(), defaultExtendedSize);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+_HttpUtility::AddBytesToBuffer(ByteBuffer **ppSrcBuffer, const byte *pDestBytes, int destBytesSize, int defaultExtendedSize)
+{
+       result r = E_SUCCESS;
+       ByteBuffer* pBuffer = null;
+       int srcBufferRemainSize = 0;
+
+       SysTryReturnResult(NID_NET_HTTP, ppSrcBuffer != null && *ppSrcBuffer != null,
+                                  E_SYSTEM, "Input buffer is invalid.");
+
+       //creates the new buffer.
+       srcBufferRemainSize = (*ppSrcBuffer)->GetRemaining();
+       if (srcBufferRemainSize >= destBytesSize)
+       {
+               r = (*ppSrcBuffer)->SetArray(pDestBytes, 0, destBytesSize);
+               SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       }
+       else
+       {
+               (*ppSrcBuffer)->Flip();
+               srcBufferRemainSize = (*ppSrcBuffer)->GetRemaining();
+               int newBufferSize = srcBufferRemainSize + destBytesSize + defaultExtendedSize;
+
+               pBuffer = new (std::nothrow) ByteBuffer();
+               r = pBuffer->Construct(newBufferSize);
+               SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = pBuffer->CopyFrom((** ppSrcBuffer));
+               SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = pBuffer->SetArray(pDestBytes, 0, destBytesSize);
+               SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               SysLog(NID_NET_HTTP, "Creates a new ByteBuffer(%d): ppSrcBuffer(%d), pDestBytes(%d).", newBufferSize,
+                               srcBufferRemainSize, destBytesSize);
+
+               delete *ppSrcBuffer;
+               *ppSrcBuffer = pBuffer;
+       }
+
+       return r;
+
+CATCH:
+
+       delete pBuffer;
+       return r;
+}
+
+bool _HttpUtility::__initialized = false;
+Mutex* _HttpUtility::__pHttpMutex = null;
+IList* _HttpUtility::__pSslCertList = null;
+
+void
+_HttpUtility::DestroyHttp(void)
+{
+       delete __pHttpMutex;
+       delete __pSslCertList;
+       __initialized = false;
+
+       SysLog(NID_NET_HTTP, "Called DestroyHttp.");
+}
+
+void
+_HttpUtility::InitializeHttpOnce(void)
+{
+       result r = E_SUCCESS;
+
+       unique_ptr<Mutex> pMutex(new (std::nothrow)Mutex());
+       SysTryReturnVoidResult(NID_NET_HTTP, pMutex != null, E_OUT_OF_MEMORY,
+                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pMutex->Create();
+       SysTryReturnVoidResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                       "[%s] Propagating.", GetErrorMessage(r));
+
+       SysLog(NID_NET_HTTP, "Created the mutex.");
+
+       unique_ptr<IList> pSslCertList(new (std::nothrow)LinkedList());
+       SysTryReturnVoidResult(NID_NET_HTTP, pSslCertList != null, E_OUT_OF_MEMORY,
+                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       CURLcode code = curl_global_init(CURL_GLOBAL_ALL);
+       SysTryReturnVoidResult(NID_NET_HTTP, code == CURLE_OK, E_SYSTEM, "[E_SYSTEM] Failed to call curl_global_init()");
+
+       SysLog(NID_NET_HTTP, "Called curl_global_init()");
+
+       __pHttpMutex = pMutex.release();
+       __pSslCertList = pSslCertList.release();
+       __initialized = true;
+
+       SysLog(NID_NET_HTTP, "Allocated the LinkedList.");
+
+       //std::atexit(DestroyHttp);
+}
+
+void
+_HttpUtility::InitializeHttp(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       if (!__initialized)
+       {
+               ClearLastResult();
+               SysLog(NID_NET_HTTP, "Initializing HTTP.");
+               pthread_once(&onceBlock, InitializeHttpOnce);
+               result r = GetLastResult();
+               if (IsFailed(r))
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+                       SysLogException(NID_NET_HTTP, r, "[%s] Failed to initialize HTTP.", GetErrorMessage(r));
+                       return;
+               }
+
+               SysLog(NID_NET_HTTP, "Initialized HTTP.");
+       }
+       else
+       {
+               SysLog(NID_NET_HTTP, "HTTP is already initialized.");
+       }
+}
+
+Mutex*
+_HttpUtility::GetHttpMutex(void)
+{
+       SysAssertf(__pHttpMutex != null, "pHttpMutex is null.");
+       return __pHttpMutex;
+}
+
+IList*
+_HttpUtility::GetSslCertList(void)
+{
+       SysAssertf(__pSslCertList != null, "pSSLCertList is null.");
+       return __pSslCertList;
+}
+
+result
+_HttpUtility::AddSslCertInfo(_HttpSslInfo & sslInfo)
+{
+       result r = E_SUCCESS;
+
+       IList* pServerCertList = GetSslCertList();
+       Mutex* pHttpMutex = GetHttpMutex();
+
+       MutexGuard locked(*pHttpMutex);
+       SysTryReturnResult(NID_NET_HTTP, locked.IsLocked(), E_SYSTEM,
+                       "Failed to lock mutex.");
+
+       r = pServerCertList->Add(sslInfo);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                       "Memory allocation failed.");
+
+       return r;
+}
+
+IList*
+_HttpUtility::GetSslCertInfoN(int socketFd)
+{
+       ClearLastResult();
+
+       unique_ptr<IList> pResultList(new (std::nothrow)LinkedList());
+       SysTryReturn(NID_NET_HTTP, pResultList != null, null, E_OUT_OF_MEMORY,
+                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       IList* pServerCertList = GetSslCertList();
+       Mutex* pHttpMutex = GetHttpMutex();
+       _HttpSslInfo* pSSLInfo = null;
+
+       MutexGuard locked(*pHttpMutex);
+       SysTryReturn(NID_NET_HTTP, locked.IsLocked(), null, E_SYSTEM,
+                       "[E_SYSTEM] Failed to lock mutex.");
+
+       unique_ptr<IEnumerator> pEnum(pServerCertList->GetEnumeratorN());
+       SysTryReturn(NID_NET_HTTP, pEnum != null, null, E_OUT_OF_MEMORY,
+                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pSSLInfo = dynamic_cast< _HttpSslInfo* >(pEnum->GetCurrent());
+               SysTryReturn(NID_NET_HTTP, pSSLInfo != null, null, E_OUT_OF_MEMORY,
+                                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               if (pSSLInfo->GetSocketFd() == socketFd)
+               {
+                       SysLog(NID_NET_HTTP, "Found the same server cert.");
+                       pResultList->Add(*pSSLInfo);
+               }
+       }
+
+       return pResultList.release();
+}
+
+result
+_HttpUtility::RemoveSslCertInfo(int socketFd)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+       Mutex* pHttpMutex = GetHttpMutex();
+       _HttpSslInfo* pSSLInfo = null;
+       IList *pServerCertList = GetSslCertList();
+
+       unique_ptr<IList> pResultList(GetSslCertInfoN(socketFd));
+       SysTryReturnResult(NID_NET_HTTP, pResultList != null, E_OUT_OF_MEMORY,
+                       "Memory allocation failed.");
+
+       MutexGuard locked(*pHttpMutex);
+       SysTryReturnResult(NID_NET_HTTP, locked.IsLocked(), E_SYSTEM,
+                       "Failed to lock mutex.");
+
+       unique_ptr<IEnumerator> pEnum(pResultList->GetEnumeratorN());
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pSSLInfo = dynamic_cast< _HttpSslInfo* >(pEnum->GetCurrent());
+               SysTryReturnResult(NID_NET_HTTP, pSSLInfo != null, E_OUT_OF_MEMORY,
+                                       "Memory allocation failed.");
+
+               SysLog(NID_NET_HTTP, "Found the server cert. socketFd(%d), depth(%d)", pSSLInfo->GetSocketFd(), pSSLInfo->GetDepth());
+               pServerCertList->Remove(*pSSLInfo, false);
+       }
+
+       pResultList->RemoveAll(true);
+
+       return r;
+}
+
+bool
+_HttpUtility::HasProtocolScheme(const Tizen::Base::String & host)
+{
+       result r = E_SUCCESS;
+       int indexOfDelimiter = -1;
+
+       //Check if the prefix of hostAddr includes "http://".
+       r = host.IndexOf(_HTTP_PROTOCOL_SCHEME, 0, indexOfDelimiter);
+       if (r == E_OBJ_NOT_FOUND)
+       {
+               //Check if the prefix of hostAddr includes "https://".
+               r = host.IndexOf(_HTTPS_PROTOCOL_SCHEME, 0, indexOfDelimiter);
+               if (r == E_OBJ_NOT_FOUND)
+               {
+                       return false;
+               }
+       }
+
+       return true;
+}
+
+String
+_HttpUtility::GetProtocolScheme(const String & host)
+{
+       result r = E_SUCCESS;
+       String scheme;
+       Uri hostUri;
+
+       r = hostUri.SetUri(host);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, L"", E_INVALID_ARG,
+                        "[E_INVALID_ARG] Failed to set uri");
+       scheme = hostUri.GetScheme();
+       scheme += L"://";
+
+       return scheme;
+}
+
+bool
+_HttpUtility::CompareHost(const Tizen::Base::String & host0, const Tizen::Base::String & host1)
+{
+       result r = E_SUCCESS;
+       Uri hostUri0;
+       Uri hostUri1;
+
+       r = hostUri0.SetUri(host0);
+       r = TransExceptionsExclusive(r, E_INVALID_ARG, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, false, r,
+                        "[%s] Failed to set uri.", GetErrorMessage(r));
+
+       r = hostUri1.SetUri(host1);
+       r = TransExceptionsExclusive(r, E_INVALID_ARG, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, false, r,
+                        "[%s] Failed to set uri", GetErrorMessage(r));
+
+       String scheme0 = hostUri0.GetScheme();
+       String scheme1 = hostUri1.GetScheme();
+
+       if(!scheme0.Equals(scheme1, false))
+       {
+               SetLastResult(E_INVALID_ARG);
+               return false;
+       }
+
+       String hostPart0 = hostUri0.GetHost();
+       String hostPart1 = hostUri1.GetHost();
+
+       if(!hostPart0.Equals(hostPart1, false))
+       {
+               SetLastResult(E_INVALID_ARG);
+               return false;
+       }
+
+       int port0 = hostUri0.GetPort();
+       int port1 = hostUri1.GetPort();
+
+       port0 = (port0 == -1) ? _HTTP_DEFAULT_PORT : port0;
+       port1 = (port1 == -1) ? _HTTP_DEFAULT_PORT : port1;
+
+       if(port0 != port1)
+       {
+               SetLastResult(E_INVALID_ARG);
+               return false;
+       }
+
+       return true;
+}
+
+String
+_HttpUtility::GetCookieFilePath(void)
+{
+       result r = E_SUCCESS;
+
+       String filePath = Tizen::App::App::GetInstance()->GetAppRootPath();
+       r = filePath.Append(_HTTP_COOKIE_FILE);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, L"", r,
+                        "[%s] Propagating.", GetErrorMessage(r));
+
+       SysLog(NID_NET_HTTP, "Cookie Path: %ls", filePath.GetPointer());
+
+       return filePath;
+}
+
+NetHttpAuthScheme
+_HttpUtility::GetHttpAuthScheme(bool isProxyAuth, long  curlAuthScheme)
+{
+       NetHttpAuthScheme authScheme = NET_HTTP_AUTH_NONE;
+       if(isProxyAuth)
+       {
+               switch (curlAuthScheme)
+               {
+                       case _CURL_HTTP_AUTH_NONE:
+                               authScheme = NET_HTTP_AUTH_NONE;
+                               break;
+                       case _CURL_HTTP_AUTH_BASIC:
+                               authScheme = NET_HTTP_AUTH_PROXY_BASIC;
+                               break;
+                       case _CURL_HTTP_AUTH_DIGEST:
+                               authScheme = NET_HTTP_AUTH_PROXY_MD5;
+                               break;
+                       case _CURL_HTTP_AUTH_NTLM:
+                               authScheme = NET_HTTP_AUTH_PROXY_NTLM;
+                               break;
+                       default:
+                               authScheme = NET_HTTP_AUTH_NONE;
+                               break;
+               }
+       }
+       else
+       {
+               switch (curlAuthScheme)
+               {
+                       case _CURL_HTTP_AUTH_NONE:
+                               authScheme = NET_HTTP_AUTH_NONE;
+                               break;
+                       case _CURL_HTTP_AUTH_BASIC:
+                               authScheme = NET_HTTP_AUTH_WWW_BASIC;
+                               break;
+                       case _CURL_HTTP_AUTH_DIGEST:
+                               authScheme = NET_HTTP_AUTH_WWW_MD5;
+                               break;
+                       case _CURL_HTTP_AUTH_NTLM:
+                               authScheme = NET_HTTP_AUTH_WWW_NTLM;
+                               break;
+                       case _CURL_HTTP_AUTH_GSSNEGOTIATE:
+                               authScheme = NET_HTTP_AUTH_WWW_NEGOTIATE;
+                               break;
+                       default:
+                               authScheme = NET_HTTP_AUTH_NONE;
+                               break;
+               }
+       }
+
+       return authScheme;
+}
+
+long
+_HttpUtility::GetHttpCurlAuthScheme(NetHttpAuthScheme httpAuthScheme)
+{
+       long curlScheme = _CURL_HTTP_AUTH_NONE;
+       switch (httpAuthScheme)
+       {
+               case NET_HTTP_AUTH_PROXY_BASIC:
+               case NET_HTTP_AUTH_WWW_BASIC:
+                       curlScheme = _CURL_HTTP_AUTH_BASIC;
+                       break;
+               case NET_HTTP_AUTH_PROXY_MD5:
+               case NET_HTTP_AUTH_WWW_MD5:
+                       curlScheme = _CURL_HTTP_AUTH_DIGEST;
+                       break;
+               case NET_HTTP_AUTH_PROXY_NTLM:
+               case NET_HTTP_AUTH_WWW_NTLM:
+                       curlScheme = _CURL_HTTP_AUTH_NTLM;
+                       break;
+               case NET_HTTP_AUTH_WWW_NEGOTIATE:
+                       curlScheme = _CURL_HTTP_AUTH_GSSNEGOTIATE;
+                       break;
+               default:
+                       curlScheme = _CURL_HTTP_AUTH_NONE;
+                       break;
+       }
+
+       return curlScheme;
+}
+
+static const char* NetHttpAuthSchemeTypesToString[] =
+{
+       "NET_HTTP_AUTH_NONE", "NET_HTTP_AUTH_PROXY_BASIC",
+       "NET_HTTP_AUTH_PROXY_MD5", "NET_HTTP_AUTH_WWW_BASIC",
+       "NET_HTTP_AUTH_WWW_MD5", "NET_HTTP_AUTH_PROXY_NTLM",
+       "", "NET_HTTP_AUTH_WWW_NTLM",
+       "NET_HTTP_AUTH_WWW_NEGOTIATE"
+};
+
+const char*
+_HttpUtility::GetHttpAuthSchemeByString(NetHttpAuthScheme type)
+{
+       return NetHttpAuthSchemeTypesToString[type];
+}
+
+_HttpSslInfo::_HttpSslInfo(int socketFd, int depth, const String & serverCert, const String & errorMessage)
+{
+       __socketFd = socketFd;
+       __depth = depth;
+       __serverCert = serverCert;
+       __errorMessage = errorMessage;
+}
+
+_HttpSslInfo::~_HttpSslInfo()
+{
+}
+
+int
+_HttpSslInfo::GetDepth() const
+{
+       return __depth;
+}
+
+String
+_HttpSslInfo::GetErrorMessage() const
+{
+       return __errorMessage;
+}
+
+String
+_HttpSslInfo::GetServerCert() const
+{
+       return __serverCert;
+}
+
+int
+_HttpSslInfo::GetSocketFd() const
+{
+       return __socketFd;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpCookieImpl.cpp b/src/http/FNetHttp_HttpCookieImpl.cpp
new file mode 100644 (file)
index 0000000..0e87f65
--- /dev/null
@@ -0,0 +1,225 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpCookieImpl.cpp
+ * @brief              This is the implementation file for _HttpCookieImpl class.
+ */
+
+#include <FBaseString.h>
+#include <FNetHttpHttpCookie.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpCookieImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpCookieImpl::_HttpCookieImpl()
+       : __isSecure(false)
+       , __isHttpOnly(false)
+       , __maxAge(-1)
+       , __isDisacrd(false)
+{
+}
+
+_HttpCookieImpl::~_HttpCookieImpl(void)
+{
+}
+
+HttpCookie*
+_HttpCookieImpl::CreateHttpCookieN(void)
+{
+       HttpCookie* pHttpCookie = new (std::nothrow) HttpCookie();
+       SysTryReturn(NID_NET_HTTP, pHttpCookie != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       return pHttpCookie;
+}
+
+void
+_HttpCookieImpl::DeleteHttpCookie(HttpCookie* pCookie)
+{
+       delete pCookie;
+}
+
+bool
+_HttpCookieImpl::IsHttpOnly(void) const
+{
+       return __isHttpOnly;
+}
+bool
+_HttpCookieImpl::GetDiscard(void) const
+{
+
+       return __isDisacrd;
+}
+int
+_HttpCookieImpl::GetMaxAge(void) const
+{
+       return __maxAge;
+}
+Tizen::Base::String
+_HttpCookieImpl::GetDomain(void) const
+{
+       return __domain;
+}
+
+Tizen::Base::String
+_HttpCookieImpl::GetPath(void) const
+{
+       return __path;
+}
+Tizen::Base::String
+_HttpCookieImpl::GetVersion(void) const
+{
+       return __version;
+}
+
+Tizen::Base::String
+_HttpCookieImpl::GetExpires(void) const
+{
+       return __expires;
+}
+
+bool
+_HttpCookieImpl::IsSecure(void) const
+{
+       return __isSecure;
+}
+
+Tizen::Base::String
+_HttpCookieImpl::GetCookieName(void) const
+{
+       return __name;
+}
+
+Tizen::Base::String
+_HttpCookieImpl::GetCookieValue(void) const
+{
+       return __value;
+}
+
+Tizen::Base::String
+_HttpCookieImpl::GetPorts(void) const
+{
+       return __ports;
+}
+
+Tizen::Base::String
+_HttpCookieImpl::GetCommentUrl(void) const
+{
+       return __commentUrl;
+}
+
+Tizen::Base::String
+_HttpCookieImpl::GetComment(void) const
+{
+       return __comment;
+}
+
+_HttpCookieImpl*
+_HttpCookieImpl::GetInstance(HttpCookie& httpCookie)
+{
+       return httpCookie.__pHttpCookieImpl;
+}
+
+const _HttpCookieImpl*
+_HttpCookieImpl::GetInstance(const HttpCookie& httpCookie)
+{
+       return httpCookie.__pHttpCookieImpl;
+}
+
+void
+_HttpCookieImpl::SetDomain(const Tizen::Base::String& domain)
+{
+       __domain = domain;
+}
+
+void
+_HttpCookieImpl::SetPath(const Tizen::Base::String& path)
+{
+       __path = path;
+}
+
+void
+_HttpCookieImpl::SetVersion(const Tizen::Base::String& version)
+{
+       __version = version;
+}
+
+void
+_HttpCookieImpl::SetExpires(const Tizen::Base::String& expires)
+{
+       __expires = expires;
+}
+
+void
+_HttpCookieImpl::SetSecure(bool isSecure)
+{
+       __isSecure = isSecure;
+}
+
+void
+_HttpCookieImpl::SetCookieName(const Tizen::Base::String& name)
+{
+       __name = name;
+}
+
+void
+_HttpCookieImpl::SetCookieValue(const Tizen::Base::String& value)
+{
+       __value = value;
+}
+
+void
+_HttpCookieImpl::SetCommentUrl(const Tizen::Base::String& commentUrl)
+{
+       __commentUrl = commentUrl;
+}
+
+void
+_HttpCookieImpl::SetComment(const Tizen::Base::String& comment)
+{
+       __comment = comment;
+}
+
+void
+_HttpCookieImpl::SetHttpOnly(bool isHttpOnly)
+{
+       __isHttpOnly = isHttpOnly;
+}
+
+void
+_HttpCookieImpl::SetPorts(const Tizen::Base::String& ports)
+{
+       __ports = ports;
+}
+
+void
+_HttpCookieImpl::SetMaxAge(int maxAge)
+{
+       __maxAge = maxAge;
+}
+
+void
+_HttpCookieImpl::SetDiscard(bool isDiscard)
+{
+       __isDisacrd = isDiscard;
+}
+
+} } } //Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpCookieStorageManagerImpl.cpp b/src/http/FNetHttp_HttpCookieStorageManagerImpl.cpp
new file mode 100644 (file)
index 0000000..dad737f
--- /dev/null
@@ -0,0 +1,413 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpCookieStorageManagerImpl.cpp
+ * @brief              This is the implementation file for HttpCookieStorageManagerImpl class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FBaseRtMutex.h>
+#include <FBaseRtMutexGuard.h>
+#include <FBaseUtil.h>
+#include <FBaseColLinkedList.h>
+#include <FBaseColArrayList.h>
+#include <FIoFile.h>
+#include <FNetHttpHttpCookieStorageManager.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpCommon.h"
+#include "FNetHttp_HttpSessionImpl.h"
+#include "FNetHttp_HttpCookieStorageManagerImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Net { namespace Http
+{
+_HttpCookieStorageManagerImpl::_HttpCookieStorageManagerImpl()
+{
+}
+
+_HttpCookieStorageManagerImpl::~_HttpCookieStorageManagerImpl()
+{
+}
+
+HttpCookieStorageManager*
+_HttpCookieStorageManagerImpl::CreateHttpCookieStorageManagerN(void)
+{
+       HttpCookieStorageManager* pHttpCookieStorageManager = new (std::nothrow) HttpCookieStorageManager();
+       SysTryReturn(NID_NET_HTTP, pHttpCookieStorageManager != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       return pHttpCookieStorageManager;
+}
+
+void
+_HttpCookieStorageManagerImpl::DeleteHttpCookieStorageManager(HttpCookieStorageManager* pHttpCookieStorageManager)
+{
+       delete pHttpCookieStorageManager;
+}
+
+result
+_HttpCookieStorageManagerImpl::GetCookies(const Tizen::Base::String& url, Tizen::Base::String& cookies) const
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, !url.IsEmpty(),
+                                          E_INVALID_ARG, "The input argument is empty(%ls).", url.GetPointer());
+
+       Mutex* pHttpMutex = null;
+       Uri uri;
+       String hostName;
+       String domainName;
+       int indexOfPrefix = -1;
+       bool hasProtocolScheme = false;
+
+       hasProtocolScheme = _HttpUtility::HasProtocolScheme(url);
+       if (!hasProtocolScheme)
+       {
+               //Add the prefix as "http://"
+               hostName = _HTTP_PROTOCOL_SCHEME + url;
+       }
+       else
+       {
+               hostName = url;
+       }
+
+       r = uri.SetUri(hostName);
+       r = TransExceptionsExclusive(r, E_INVALID_ARG, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          r, "Failed to check the url(%ls).", url.GetPointer());
+
+       hostName = uri.GetHost();
+       SysLog(NID_NET_HTTP, " The host name of cookie is %ls.", hostName.GetPointer());
+
+       r = hostName.IndexOf(L"www", 0, indexOfPrefix);
+       if (r == E_SUCCESS && indexOfPrefix >= 0)
+       {
+               r = hostName.SubString(String(L"www").GetLength(), domainName);
+       }
+       else
+       {
+               domainName = hostName;
+       }
+
+       SysLog(NID_NET_HTTP, "The domain name of cookie is %ls.", domainName.GetPointer());
+       SysTryReturnResult(NID_NET_HTTP, !domainName.IsEmpty(),
+                                          E_INVALID_ARG, "The input argument is invalid(%ls).", url.GetPointer());
+
+       String filePath = _HttpUtility::GetCookieFilePath();
+       r = GetLastResult();
+       r = TransExceptionsExclusive(r, E_INVALID_STATE, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, !filePath.IsEmpty(),
+                                          r, "The cookie path of system is empty.");
+
+       pHttpMutex = _HttpUtility::GetHttpMutex();
+
+       MutexGuard locked(*pHttpMutex);
+       SysTryReturnResult(NID_NET_HTTP, locked.IsLocked(), E_SYSTEM,
+                       "Failed to lock mutex.");
+
+       if (File::IsFileExist(filePath))
+       {
+               File cookieFile;
+               String cookieLine;
+               r = cookieFile.Construct(filePath, L"r", false);
+               r = TransExceptionsExclusive(r, E_INVALID_STATE, E_OUT_OF_MEMORY);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                       "Failed to construct the cookie path(%ls).", filePath.GetPointer());
+
+               while (cookieFile.Read(cookieLine) == E_SUCCESS)
+               {
+                       if (!cookieLine.StartsWith(_CURL_COOKIE_HTTP_ONLY_PREFIX, false))
+                       {
+                               //Ignore the comment.
+                               if (cookieLine.StartsWith(L"#", false) || cookieLine.Equals(L"\n", false))
+                               {
+                                       continue;
+                               }
+                       }
+
+                       SysLog(NID_NET_HTTP, "The cookie line is %ls.", cookieLine.GetPointer());
+
+                       StringTokenizer headerToken(cookieLine, L"\t");
+                       int index = 0;
+
+                       while (headerToken.HasMoreTokens())
+                       {
+                               String cookieField;
+                               r = headerToken.GetNextToken(cookieField);
+                               cookieField.Trim();
+                               SysLog(NID_NET_HTTP, "The cookie field is %ls.", cookieField.GetPointer());
+                               if (r == E_SUCCESS && !cookieField.IsEmpty())
+                               {
+                                       if (index == _CURL_COOKIE_DOMAIN_NAME_INDEX)
+                                       {
+                                               int indexOf = -1;
+                                               r = cookieField.IndexOf(domainName, 0, indexOf);
+                                               if (r == E_SUCCESS && indexOf >= 0)
+                                               {
+                                                       SysLog(NID_NET_HTTP, "Found the cookie domain(%ls).", cookieField.GetPointer());
+                                               }
+
+                                       }
+                                       else if (index == _CURL_COOKIE_COOKIE_NAME_INDEX)
+                                       {
+                                               if (!cookies.IsEmpty())
+                                               {
+                                                       cookies.Append(L";");
+                                               }
+
+                                               cookies.Append(cookieField);
+                                       }
+                                       else if (index == _CURL_COOKIE_COOKIE_VALUE_INDEX)
+                                       {
+                                               cookies.Append(L"=");
+                                               cookies.Append(cookieField);
+                                       }
+                               }
+                               index++;
+                       }
+               }
+
+       }
+       else
+       {
+               SysLog(NID_NET_HTTP, "The cookie file is not exist.");
+       }
+
+       SysLog(NID_NET_HTTP, "The domain name is %ls, the cookies are %ls.", domainName.GetPointer(), cookies.GetPointer());
+
+       return r;
+}
+
+result
+_HttpCookieStorageManagerImpl::RemoveCookies(const Tizen::Base::String& url)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, !url.IsEmpty(),
+                                          E_INVALID_ARG, "The input argument is empty(%ls).", url.GetPointer());
+
+       Mutex* pHttpMutex = null;
+       LinkedList cookieList;
+       String hostName;
+       String domainName;
+       int indexOfPrefix = -1;
+       bool hasProtocolScheme = false;
+
+       hasProtocolScheme = _HttpUtility::HasProtocolScheme(url);
+       if (!hasProtocolScheme)
+       {
+               //Add the prefix as "http://"
+               hostName = _HTTP_PROTOCOL_SCHEME + url;
+       }
+       else
+       {
+               hostName = url;
+       }
+
+       Uri uri;
+       r = uri.SetUri(hostName);
+       r = TransExceptionsExclusive(r, E_INVALID_ARG, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          r, "Failed to check the url(%ls).", url.GetPointer());
+
+       hostName = uri.GetHost();
+       SysLog(NID_NET_HTTP, "The host name of url is %ls.", hostName.GetPointer());
+
+       r = hostName.IndexOf(L"www", 0, indexOfPrefix);
+       if (r == E_SUCCESS && indexOfPrefix >= 0)
+       {
+               r = hostName.SubString(String(L"www").GetLength(), domainName);
+       }
+       else
+       {
+               domainName = hostName;
+       }
+
+       SysLog(NID_NET_HTTP, " The domain name of url is %ls.", domainName.GetPointer());
+       SysTryReturnResult(NID_NET_HTTP, !domainName.IsEmpty(),
+                                          E_INVALID_ARG, "The input argument is invalid(%ls).", url.GetPointer());
+
+       String filePath = _HttpUtility::GetCookieFilePath();
+       r = GetLastResult();
+       r = TransExceptionsExclusive(r, E_INVALID_STATE, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, !filePath.IsEmpty(),
+                                          r, "The cookie path is empty.");
+
+       pHttpMutex = _HttpUtility::GetHttpMutex();
+
+       MutexGuard locked(*pHttpMutex);
+       SysTryReturnResult(NID_NET_HTTP, locked.IsLocked(), E_SYSTEM,
+                       "Failed to lock mutex.");
+
+       if (File::IsFileExist(filePath))
+       {
+               bool isMatchedCookies = false;
+               String cookieLine;
+               unique_ptr<File> pCookieFile(new (std::nothrow) File());
+               SysTryReturnResult(NID_NET_HTTP, pCookieFile != null, E_OUT_OF_MEMORY,
+                                       "Memory allocation failed.");
+
+               r = pCookieFile->Construct(filePath, L"r", false);
+               r = TransExceptionsExclusive(r, E_INVALID_STATE, E_OUT_OF_MEMORY);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                       "Failed to construct the cookie path(%ls).", filePath.GetPointer());
+
+               while (pCookieFile->Read(cookieLine) == E_SUCCESS)
+               {
+                       if (!cookieLine.StartsWith(_CURL_COOKIE_HTTP_ONLY_PREFIX, false))
+                       {
+                               //Ignore the comment.
+                               if (cookieLine.StartsWith(L"#", 0) || cookieLine.Equals(L"\n", false) == true)
+                               {
+                                       String* pCookieLine = new (std::nothrow) String(cookieLine);
+                                       SysTryReturnResult(NID_NET_HTTP, pCookieLine != null,E_OUT_OF_MEMORY,
+                                                               "Memory allocation failed.");
+
+                                       cookieList.Add(*pCookieLine);
+                                       continue;
+                               }
+                       }
+
+                       SysLog(NID_NET_HTTP, "The cookie line is %ls.", cookieLine.GetPointer());
+                       StringTokenizer headerToken(cookieLine, L"\t");
+                       int index = 0;
+
+                       while (headerToken.HasMoreTokens())
+                       {
+                               String cookieField;
+                               r = headerToken.GetNextToken(cookieField);
+                               cookieField.Trim();
+                               SysLog(NID_NET_HTTP, "The cookie field is %ls.", cookieField.GetPointer());
+                               if (r == E_SUCCESS && cookieField.IsEmpty() == false)
+                               {
+                                       if (index == _CURL_COOKIE_DOMAIN_NAME_INDEX)
+                                       {
+                                               int indexOf = -1;
+                                               r = cookieField.IndexOf(domainName, 0, indexOf);
+                                               if (r == E_SUCCESS && indexOf >= 0)
+                                               {
+                                                       SysLog(NID_NET_HTTP, "Found the cookie domain(%ls) to be removed.", cookieField.GetPointer());
+                                                       isMatchedCookies = true;
+                                                       break;
+                                               }
+                                               else
+                                               {
+                                                       String* pCookieLine = new (std::nothrow) String(cookieLine);
+                                                       SysTryReturnResult(NID_NET_HTTP, pCookieLine != null, E_OUT_OF_MEMORY,
+                                                                               "Memory allocation failed.");
+
+                                                       cookieList.Add(*pCookieLine);
+                                                       SysLog(NID_NET_HTTP, "The cookie domain[%ls] is saved.", cookieField.GetPointer());
+                                                       break;
+                                               }
+                                       }
+                               }
+                               index++;
+                       }
+               }
+
+               if (isMatchedCookies == true)
+               {
+                       int countOfCookie = cookieList.GetCount();
+
+                       pCookieFile.reset(new (std::nothrow) File());
+                       SysTryReturnResult(NID_NET_HTTP, pCookieFile != null, E_OUT_OF_MEMORY,
+                                               "Memory allocation failed.");
+
+                       r = pCookieFile->Construct(filePath, L"w", true);
+                       r = TransExceptionsExclusive(r, E_INVALID_STATE, E_OUT_OF_MEMORY);
+                       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                               "Failed to construct the cookie path(%ls).", filePath.GetPointer());
+
+                       for (int i = 0; i < countOfCookie; i++)
+                       {
+                               String* pCookieLine = dynamic_cast< String* >(cookieList.GetAt(i));
+                               SysLog(NID_NET_HTTP, "[%d] The cookie line is %ls.", i, pCookieLine->GetPointer());
+
+                               r = pCookieFile->Write(*pCookieLine);
+                               r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+                               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,  r,
+                                                       "Failed to write the cookie file.(%ls).", filePath.GetPointer());
+                       }
+
+                       cookieList.RemoveAll(true);
+               }
+               else
+               {
+                       SysLog(NID_NET_HTTP, " Not found the Cookie domain(%ls).", domainName.GetPointer());
+               }
+
+       }
+       else
+       {
+               SysLog(NID_NET_HTTP, "The cookie file is not exist.");
+       }
+
+       SysLog(NID_NET_HTTP, "The Cookie of Domain Name(%ls) is removed.", domainName.GetPointer());
+
+       return r;
+}
+
+result
+_HttpCookieStorageManagerImpl::RemoveAllCookies()
+{
+       result r = E_SUCCESS;
+       Mutex* pHttpMutex = null;
+
+       String filePath = _HttpUtility::GetCookieFilePath();
+       SysTryReturnResult(NID_NET_HTTP, !filePath.IsEmpty(),
+                                          E_INVALID_STATE, "The cookie path is empty.");
+
+       pHttpMutex = _HttpUtility::GetHttpMutex();
+
+       MutexGuard locked(*pHttpMutex);
+       SysTryReturnResult(NID_NET_HTTP, locked.IsLocked(), E_SYSTEM,
+                       "Failed to lock mutex.");
+
+       if (File::IsFileExist(filePath))
+       {
+               r = File::Remove(filePath);
+               r = TransExceptionsExclusive(r, E_INVALID_STATE, E_OUT_OF_MEMORY);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                       "Failed to remove the cookie file[%ls].", filePath.GetPointer());
+
+               SysLog(NID_NET_HTTP, "The cookie file(%ls) was removed.", filePath.GetPointer());
+       }
+
+       return r;
+}
+
+_HttpCookieStorageManagerImpl*
+_HttpCookieStorageManagerImpl::GetInstance(HttpCookieStorageManager& httpCookieStorageManager)
+{
+       return httpCookieStorageManager.__pHttpCookieStorageManagerImpl;
+}
+
+const _HttpCookieStorageManagerImpl*
+_HttpCookieStorageManagerImpl::GetInstance(const HttpCookieStorageManager& httpCookieStorageManager)
+{
+       return httpCookieStorageManager.__pHttpCookieStorageManagerImpl;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpCurl.cpp b/src/http/FNetHttp_HttpCurl.cpp
new file mode 100644 (file)
index 0000000..4f83996
--- /dev/null
@@ -0,0 +1,81 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpCurl.cpp
+ * @brief              This is the implementation file for _HttpCurl class.
+ */
+
+#include <FNetHttpHttpTypes.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpCommon.h"
+#include "FNetHttp_HttpCurl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpCurl::_HttpCurl(CURL* pCurl, bool isAuthenticated)
+{
+       __pCurl = pCurl;
+       __isAuthenticated = isAuthenticated;
+       __refCount = 0;
+       AddRef();
+}
+
+_HttpCurl::~_HttpCurl(void)
+{
+       if (__pCurl != null)
+       {
+               SysLog(NID_NET_HTTP, "__pCurl[%x, IsAuthenticated:%d] is deleted.", __pCurl, __isAuthenticated);
+               curl_easy_cleanup(__pCurl);
+               __pCurl = null;
+       }
+}
+
+void
+_HttpCurl::AddRef(void)
+{
+       __refCount++;
+       SysLog(NID_NET_HTTP, "The reference count of this instance is %d. __pCurl[%x]", __refCount, __pCurl);
+}
+
+void
+_HttpCurl::Release(void)
+{
+       __refCount--;
+       SysLog(NID_NET_HTTP, "The reference count of this instance is %d. __pCurl[%x]", __refCount, __pCurl);
+
+       if (__refCount == 0)
+       {
+               SysLog(NID_NET_HTTP, "The reference count of this instance is 0. So this instance will be deleted.");
+               delete this;
+       }
+}
+
+CURL*
+_HttpCurl::GetCurl(void) const
+{
+       return __pCurl;
+}
+void
+_HttpCurl::SetAuthenticated(void)
+{
+       __isAuthenticated = true;
+}
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpCurl.h b/src/http/FNetHttp_HttpCurl.h
new file mode 100644 (file)
index 0000000..348851c
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpCurl.h
+ * @brief              This is the header file for the %_HttpCurl class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_CURL_H_
+#define _FNET_HTTP_INTERNAL_HTTP_CURL_H_
+
+#include <curl.h>
+#include <FOspConfig.h>
+#include <FNetHttpHttpTypes.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+class _HttpCurl
+       : public Tizen::Base::Object
+{
+
+public:
+       _HttpCurl(CURL* pCurl, bool isAuthenticated);
+
+       virtual ~_HttpCurl(void);
+
+       void AddRef(void);
+
+       void Release(void);
+
+public:
+       CURL* GetCurl(void) const;
+
+       void SetAuthenticated(void);
+
+private:
+       _HttpCurl(const _HttpCurl& rhs);
+
+       _HttpCurl& operator =(const _HttpCurl& rhs);
+
+private:
+       CURL* __pCurl;
+       int __refCount;
+       bool __isAuthenticated;
+
+}; //_HttpCurl
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_CURL_H_
diff --git a/src/http/FNetHttp_HttpDeleter.h b/src/http/FNetHttp_HttpDeleter.h
new file mode 100644 (file)
index 0000000..d393eb9
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpDeleter.h
+ * @brief              This is the header file for defining custom deleter for smart pointer.
+ *
+ * This is the header file for defining custom deleter for smart pointer.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_DELETER_H_
+#define _FNET_HTTP_INTERNAL_HTTP_DELETER_H_
+
+#include <openssl/ssl.h>
+#include <curl.h>
+#include <FNetHttpHttpTypes.h>
+#include <FBaseSysLog.h>
+#include <FSecCert_CertService.h>
+#include <FNetHttpHttpRequest.h>
+#include <FNetHttpHttpResponse.h>
+#include <FNetHttpHttpCookie.h>
+#include <FNetHttpHttpCookieStorageManager.h>
+#include <FNetHttpHttpCookieStorageManager.h>
+#include "FNetHttp_HttpCookieImpl.h"
+#include "FNetHttp_HttpRequestImpl.h"
+#include "FNetHttp_HttpResponseImpl.h"
+#include "FNetHttp_HttpCookieStorageManagerImpl.h"
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+struct _BIoDeleter
+{
+       void operator()(BIO* pBIo)
+       {
+               BIO_free_all(pBIo);
+       }
+};
+
+struct _CertInfoDeleter
+{
+       void operator()(Tizen::Security::Cert::_CertInfo* pCertInfo)
+       {
+               free(pCertInfo);
+       }
+};
+
+struct _HttpCookieDeleter
+{
+       void operator()(HttpCookie* pCookie)
+       {
+               _HttpCookieImpl::DeleteHttpCookie(pCookie);
+       }
+};
+
+struct _HttpRequestDeleter
+{
+       void operator()(HttpRequest* pRequest)
+       {
+               _HttpRequestImpl::DeleteHttpRequest(pRequest);
+       }
+};
+
+struct _HttpResponseDeleter
+{
+       void operator()(HttpResponse* pResponse)
+       {
+               _HttpResponseImpl::DeleteHttpResponse(pResponse);
+       }
+};
+
+struct _HttpCookieStorageManagerDeleter
+{
+       void operator()(HttpCookieStorageManager* pCookieStorageMgr)
+       {
+               _HttpCookieStorageManagerImpl::DeleteHttpCookieStorageManager(pCookieStorageMgr);
+       }
+};
+
+} } } //Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_DELETER_H_
diff --git a/src/http/FNetHttp_HttpFilePart.cpp b/src/http/FNetHttp_HttpFilePart.cpp
new file mode 100644 (file)
index 0000000..8fa667f
--- /dev/null
@@ -0,0 +1,169 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpFilePart.cpp
+ * @brief              This is the implementation file for the _HttpFilePart class.
+ */
+
+#include <FBaseString.h>
+#include <FIoFile.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpFilePart.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpFilePart::_HttpFilePart(void)
+       : __isConstructed(false)
+       , __isDoneFileFormHeader(false)
+       , __pFile(null)
+       , __pBuffer(null)
+{
+}
+
+_HttpFilePart::~_HttpFilePart(void)
+{
+       if (__pFile != null)
+       {
+               delete __pFile;
+               __pFile = null;
+       }
+
+       SysLog(NID_NET_HTTP, "Deleted an instance of _HttpFilePart.");
+}
+
+result
+_HttpFilePart::Construct(const Tizen::Base::String& name, const Tizen::Base::String& filePath, const Tizen::Base::String& fileName,
+                                                const Tizen::Base::String& mimeType,
+                                                const Tizen::Base::String& charset)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_NET_HTTP, !__isConstructed,
+                                          E_INVALID_STATE, "Already constructed.");
+
+       SysTryReturnResult(NID_NET_HTTP, !name.IsEmpty() && !filePath.IsEmpty() && !fileName.IsEmpty() && !mimeType.IsEmpty(),
+                                          E_INVALID_ARG, "The input argument is invalid.");
+
+       __isConstructed = true;
+       __isDoneFileFormHeader = false;
+
+       __name = name;
+       __filePath = filePath;
+       __fileName = fileName;
+       __mimeType = mimeType;
+       __charset = charset;
+
+       return r;
+}
+
+result
+_HttpFilePart::Construct(const Tizen::Base::String& name, const Tizen::Base::ByteBuffer& buffer, const Tizen::Base::String& fileName,
+                                                const Tizen::Base::String& mimeType,
+                                                const Tizen::Base::String& charset)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_NET_HTTP, !__isConstructed,
+                                          E_INVALID_STATE, "Already constructed.");
+
+       SysTryReturnResult(NID_NET_HTTP, !name.IsEmpty() && buffer.GetRemaining() > 0 && !fileName.IsEmpty() && !mimeType.IsEmpty(),
+                                          E_INVALID_ARG, "The input argument is invalid.");
+
+       __isConstructed = true;
+       __isDoneFileFormHeader = false;
+
+       __name = name;
+
+       unique_ptr<Tizen::Base::ByteBuffer> pBuffer(new (std::nothrow) ByteBuffer());
+       SysTryReturnResult(NID_NET_HTTP, pBuffer != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pBuffer->Construct(buffer);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       __fileName = fileName;
+       __mimeType = mimeType;
+       __charset = charset;
+       __pBuffer = move(pBuffer);
+
+       return r;
+}
+
+void
+_HttpFilePart::SetDoneFileFormHeader(bool isDone)
+{
+       __isDoneFileFormHeader = isDone;
+}
+
+bool
+_HttpFilePart::IsDoneFileFormHeader(void) const
+{
+       return __isDoneFileFormHeader;
+}
+
+Tizen::Base::String
+_HttpFilePart::GetName(void) const
+{
+       return __name;
+}
+Tizen::Base::String
+_HttpFilePart::GetFilePath(void) const
+{
+       return __filePath;
+}
+
+void
+_HttpFilePart::SetFile(Tizen::Io::File* pFile)
+{
+       __pFile = pFile;
+}
+
+Tizen::Io::File*
+_HttpFilePart::GetFile(void)
+{
+       return __pFile;
+}
+
+Tizen::Base::ByteBuffer*
+_HttpFilePart::GetByteBuffer(void) const
+{
+       return __pBuffer.get();
+}
+
+Tizen::Base::String
+_HttpFilePart::GetFileName(void) const
+{
+       return __fileName;
+}
+
+Tizen::Base::String
+_HttpFilePart::GetMimeType(void) const
+{
+       return __mimeType;
+}
+
+Tizen::Base::String
+_HttpFilePart::GetCharset(void) const
+{
+       return __charset;
+}
+
+} } } // Tizen::Net::HttpFilePart
diff --git a/src/http/FNetHttp_HttpFilePart.h b/src/http/FNetHttp_HttpFilePart.h
new file mode 100644 (file)
index 0000000..d8f4d62
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpFilePart.h
+ * @brief              This is the header file for the %_HttpFilePart class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_FILE_PART_H_
+#define _FNET_HTTP_INTERNAL_HTTP_FILE_PART_H_
+
+#include <unique_ptr.h>
+#include <FNetHttpHttpTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+} }
+
+namespace Tizen { namespace Io
+{
+class File;
+} }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpMultipartEntityImpl;
+/**
+* @class       _HttpFilePart
+*
+* @since 2.1
+*
+*/
+class _HttpFilePart
+       : public Tizen::Base::Object
+{
+
+public:
+       _HttpFilePart(void);
+
+       virtual ~_HttpFilePart(void);
+
+       result Construct(const Tizen::Base::String& name, const Tizen::Base::String& filePath, const Tizen::Base::String& fileName, const Tizen::Base::String& mimeType, const Tizen::Base::String& charset);
+
+       result Construct(const Tizen::Base::String& name, const Tizen::Base::ByteBuffer& buffer, const Tizen::Base::String& fileName, const Tizen::Base::String& mimeType, const Tizen::Base::String& charset);
+
+       void SetDoneFileFormHeader(bool isDone);
+
+       bool IsDoneFileFormHeader(void) const;
+
+       Tizen::Base::String GetName(void) const;
+
+       Tizen::Base::String GetFilePath(void) const;
+
+       void SetFile(Tizen::Io::File* pFile);
+
+       Tizen::Io::File* GetFile(void);
+
+       Tizen::Base::ByteBuffer* GetByteBuffer(void) const;
+
+       Tizen::Base::String GetFileName(void) const;
+
+       Tizen::Base::String GetMimeType(void) const;
+
+       Tizen::Base::String GetCharset(void) const;
+
+private:
+       _HttpFilePart(const _HttpFilePart& rhs);
+
+       _HttpFilePart& operator =(const _HttpFilePart& rhs);
+
+private:
+       bool __isConstructed;
+       bool __isDoneFileFormHeader;
+       Tizen::Base::String __name;
+       Tizen::Base::String __filePath;
+       Tizen::Io::File* __pFile;
+       std::unique_ptr<Tizen::Base::ByteBuffer> __pBuffer;
+       Tizen::Base::String __fileName;
+       Tizen::Base::String __mimeType;
+       Tizen::Base::String __charset;
+
+}; // _HttpFilePart
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_FILE_PART_H_
diff --git a/src/http/FNetHttp_HttpHeaderImpl.cpp b/src/http/FNetHttp_HttpHeaderImpl.cpp
new file mode 100644 (file)
index 0000000..9cbeca7
--- /dev/null
@@ -0,0 +1,710 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpHeaderImpl.cpp
+ * @brief              This is the implementation file for _HttpHeaderImpl class.
+ */
+
+#include <unique_ptr.h>
+#include <stdlib.h>
+#include <FBaseString.h>
+#include <FBaseColIList.h>
+#include <FBaseColMultiHashMap.h>
+#include <FNetHttpHttpHeader.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FNetHttp_HttpHeaderImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+class _HttpStringComparer
+       : public IComparer
+{
+
+public:
+       result Compare(const Object& obj1, const Object& obj2, int& cmp) const;
+};
+
+result
+_HttpStringComparer::Compare(const Object& obj1, const Object& obj2, int& cmp) const
+{
+       result r = E_SUCCESS;
+
+       const String* pStr1 = dynamic_cast<const String*>(&obj1);
+       SysTryReturnResult(NID_NET_HTTP, pStr1 != null,
+                                          E_INVALID_ARG, "pStr1 must not be null.");
+
+       const String* pStr2 = dynamic_cast<const String*>(&obj2);
+       SysTryReturnResult(NID_NET_HTTP, pStr2 != null,
+                                          E_INVALID_ARG, "pStr2 must not be null.");
+
+       if(pStr1->Equals(*pStr2, false))
+       {
+               cmp = 0;
+       }
+       else
+       {
+               cmp =  (pStr1->CompareTo(*pStr2));
+       }
+
+       return r;
+}
+
+class _HttpMultiHashMapProvider
+       : public Object,
+         public IHashCodeProvider
+{
+public:
+
+       _HttpMultiHashMapProvider() {}
+
+       virtual ~_HttpMultiHashMapProvider() {}
+
+       int GetHashCode(const Object& obj) const;
+
+};
+
+int
+_HttpMultiHashMapProvider::GetHashCode(const Object& obj) const
+{
+       const String* pStr = dynamic_cast<const String*>(&obj);
+       SysTryReturn(NID_NET_HTTP, pStr != null, -1, E_SYSTEM,
+                               "[E_SYSTEM] A system error has occurred.");
+
+       String upperStr(*pStr);
+
+       upperStr.ToUpperCase();
+
+       return upperStr.GetHashCode();
+}
+
+
+_HttpHeaderImpl::_HttpHeaderImpl(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       unique_ptr<_HttpMultiHashMapProvider> pHashProvider(new (std::nothrow) _HttpMultiHashMapProvider());
+       SysTryReturnVoidResult(NID_NET_HTTP, pHashProvider != null, E_OUT_OF_MEMORY,
+                                                  "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       unique_ptr<_HttpStringComparer> pComparer(new (std::nothrow) _HttpStringComparer());
+       SysTryReturnVoidResult(NID_NET_HTTP, pComparer != null, E_OUT_OF_MEMORY,
+                                                  "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       unique_ptr<MultiHashMap> pHeaderMap(new (std::nothrow) MultiHashMap());
+       SysTryReturnVoidResult(NID_NET_HTTP, pHeaderMap != null, E_OUT_OF_MEMORY,
+                                                  "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pHeaderMap->Construct(0, 0, *pHashProvider, *pComparer);
+       SysTryReturnVoidResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                                                  "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+
+       __pHashProvider = pHashProvider.release();
+       __pComparer = pComparer.release();
+       __pHeaderMap = pHeaderMap.release();
+}
+
+_HttpHeaderImpl::_HttpHeaderImpl(const _HttpHeaderImpl* pCommonHeaderImpl)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       unique_ptr<_HttpMultiHashMapProvider> pHashProvider(new (std::nothrow) _HttpMultiHashMapProvider());
+       SysTryReturnVoidResult(NID_NET_HTTP, pHashProvider != null, E_OUT_OF_MEMORY,
+                                                  "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       unique_ptr<_HttpStringComparer> pComparer(new (std::nothrow) _HttpStringComparer());
+       SysTryReturnVoidResult(NID_NET_HTTP, pComparer != null, E_OUT_OF_MEMORY,
+                                                  "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       unique_ptr<MultiHashMap> pHeaderMap(new (std::nothrow) MultiHashMap());
+       SysTryReturnVoidResult(NID_NET_HTTP, pHeaderMap != null, E_OUT_OF_MEMORY,
+                                                  "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pHeaderMap->Construct(0, 0, *pHashProvider, *pComparer);
+       SysTryReturnVoidResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                                                  "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       __pHashProvider = pHashProvider.release();
+       __pComparer = pComparer.release();
+       __pHeaderMap = pHeaderMap.release();
+
+       if (pCommonHeaderImpl != null)
+       {
+               r = SetHeader(*pCommonHeaderImpl);
+               SysTryReturnVoidResult(NID_NET_HTTP, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+}
+
+_HttpHeaderImpl::~_HttpHeaderImpl(void)
+{
+       RemoveAll();
+
+       delete __pHashProvider;
+       __pHashProvider = null;
+
+       delete __pComparer;
+       __pComparer = null;
+
+       delete __pHeaderMap;
+       __pHeaderMap = null;
+}
+
+result
+_HttpHeaderImpl::AddField(const String& fieldName, const String& fieldValue)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_NET_HTTP, fieldName.GetLength() > 0,
+                                          E_INVALID_ARG, "The fieldName is an empty string.");
+
+       bool isEquals = false;
+       unique_ptr<String> pFieldName(new (std::nothrow) String(fieldName));
+       SysTryReturnResult(NID_NET_HTTP, pFieldName != null, E_OUT_OF_MEMORY,
+                                                  "Memory allocation failed.");
+
+       unique_ptr<String> pFieldValue(new (std::nothrow) String(fieldValue));
+       SysTryReturnResult(NID_NET_HTTP, pFieldValue != null, E_OUT_OF_MEMORY,
+                                                  "Memory allocation failed.");
+
+       r = __pHeaderMap->ContainsKey(*pFieldName, isEquals);
+       r = __pHeaderMap->Add(*pFieldName, *pFieldValue);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Failed to add a header field.");
+
+       if (isEquals)
+       {
+               pFieldName.reset(null);
+       } else
+       {
+               pFieldName.release();
+       }
+
+       pFieldValue     .release();
+
+       return r;
+}
+
+
+result
+_HttpHeaderImpl::RemoveField(const String& fieldName)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_NET_HTTP, fieldName.GetLength() > 0,
+                                          E_INVALID_ARG, "The filedName is an empty string.");
+
+       r = __pHeaderMap->Remove(fieldName, true);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                "Failed to remove a header field.");
+
+       return r;
+}
+
+result
+_HttpHeaderImpl::RemoveField(const String& fieldName, const String& fieldValue)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_NET_HTTP, fieldName.GetLength() > 0,
+                                          E_INVALID_ARG, "The filedName is an empty string.");
+
+       r = __pHeaderMap->Remove(fieldName, fieldValue, true);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Failed to remove a header field.");
+
+       return r;
+}
+
+void
+_HttpHeaderImpl::RemoveAll(void)
+{
+       if (__pHeaderMap != null)
+       {
+               __pHeaderMap->RemoveAll(true);
+       }
+}
+
+Tizen::Base::String*
+_HttpHeaderImpl::GetRawHeaderN(void) const
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       String* pName = null;
+       String* pValue = null;
+
+       SysTryReturn(NID_NET_HTTP, __pHeaderMap->GetCount() > 0, null, E_INVALID_HEADER,
+                                "[E_INVALID_HEADER] Header is empty.");
+
+       unique_ptr<String> pRawHeaderString(new (std::nothrow) String(L""));
+       SysTryReturn(NID_NET_HTTP, pRawHeaderString != null, null, E_OUT_OF_MEMORY,
+                                "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       unique_ptr<IList> pNameList(__pHeaderMap->GetKeysN());
+       SysTryReturn(NID_NET_HTTP, pNameList != null, null, E_INVALID_HEADER,
+                               "[E_INVALID_HEADER] Generating a raw header failed. Getting list of all keys in header map is failed.");
+
+       for (int i = 0; i < pNameList->GetCount(); i++)
+       {
+               pName = dynamic_cast< String* >(pNameList->GetAt(i));
+               SysTryReturn(NID_NET_HTTP, pName != null, null, E_OUT_OF_MEMORY,
+                                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               unique_ptr<IEnumerator> pValueEnum(__pHeaderMap->GetValuesN(*pName));
+               SysTryReturn(NID_NET_HTTP, pValueEnum != null, null, E_OUT_OF_MEMORY,
+                                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               while (pValueEnum->MoveNext() == E_SUCCESS)
+               {
+                       pValue = dynamic_cast< String* >(pValueEnum->GetCurrent());
+                       SysTryReturn(NID_NET_HTTP, pValue != null, null, E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       r = pRawHeaderString->Append(*pName);
+                       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       r = pRawHeaderString->Append(L": ");
+                       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       r = pRawHeaderString->Append(*pValue);
+                       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       r = pRawHeaderString->Append(_HTTP_CARRIAGE_RETURN_LINE_FEED);
+                       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               }
+       }
+
+       return pRawHeaderString.release();
+}
+
+IList*
+_HttpHeaderImpl::GetFieldNamesN() const
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+       IList* pFields = null;
+
+       SysTryReturn(NID_NET_HTTP, __pHeaderMap->GetCount() != 0, null, E_INVALID_HEADER,
+                                "[E_INVALID_HEADER] Number of values stored in hash map is zero.");
+
+       pFields = __pHeaderMap->GetKeysN();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r,
+                                "[%s] Propagating.", GetErrorMessage(r));
+
+       return pFields;
+}
+
+
+IEnumerator*
+_HttpHeaderImpl::GetFieldValuesN(const String& fieldName) const
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+       IEnumerator* pValueEnum = null;
+
+       SysTryReturn(NID_NET_HTTP, fieldName.GetLength() > 0, null, E_INVALID_ARG,
+                                "[E_INVALID_ARG] The fieldName is an empty string.");
+
+       pValueEnum = __pHeaderMap->GetValuesN(fieldName);
+       r = GetLastResult();
+       r = TransExceptionsExclusive(r, E_OBJ_NOT_FOUND, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, pValueEnum != null, null, r,
+                                "[%s] Header value not found.", GetErrorMessage(r));
+
+       return pValueEnum;
+}
+
+_HttpHeaderImpl*
+_HttpHeaderImpl::GetInstance(HttpHeader& httpHeader)
+{
+       return httpHeader.__pHttpHeaderImpl;
+}
+
+const _HttpHeaderImpl*
+_HttpHeaderImpl::GetInstance(const HttpHeader& httpHeader)
+{
+       return httpHeader.__pHttpHeaderImpl;
+}
+
+result
+_HttpHeaderImpl::SetHeader(const _HttpHeaderImpl& headerImpl)
+{
+       result r = E_SUCCESS;
+
+       bool isEquals = false;
+       Object* pSrcKey = null;
+       Object* pSrcValue = null;
+       String* pSrcTempKey = null;
+       String* pSrcTempValue = null;
+
+       if (headerImpl.__pHeaderMap->GetCount() == 0)
+       {
+               SysLog(NID_NET_HTTP, "The header is an empty.");
+               r = E_SUCCESS;
+               return r;
+       }
+
+       unique_ptr<IMapEnumerator> pMapEnum(headerImpl.__pHeaderMap->GetMapEnumeratorN());
+       SysTryReturnResult(NID_NET_HTTP, pMapEnum != null, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       while ((pMapEnum->MoveNext() == E_SUCCESS))
+       {
+               pSrcKey = pMapEnum->GetKey();
+               pSrcTempKey = dynamic_cast< String* >(pSrcKey);
+               SysTryReturnResult(NID_NET_HTTP, pSrcTempKey != null, E_SYSTEM,
+                                       "The key of the header is null.");
+
+               unique_ptr<String> pNewKey(new (std::nothrow) String(*pSrcTempKey));
+               SysTryReturnResult(NID_NET_HTTP, pNewKey != null, E_OUT_OF_MEMORY,
+                                       "Memory allocation failed.");
+
+               pSrcValue = pMapEnum->GetValue();
+               pSrcTempValue = dynamic_cast< String* >(pSrcValue);
+               SysTryReturnResult(NID_NET_HTTP, pSrcTempValue != null, E_SYSTEM,
+                                       "The value of the header is null.");
+
+               unique_ptr<String> pNewValue(new (std::nothrow) String(*pSrcTempValue));
+               SysTryReturnResult(NID_NET_HTTP, pNewValue != null, E_OUT_OF_MEMORY,
+                                       "Memory allocation failed.");
+
+               r = __pHeaderMap->ContainsKey(*pNewKey, isEquals);
+               r = __pHeaderMap->Add(*pNewKey, *pNewValue);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS || r == E_OBJ_ALREADY_EXIST, r,
+                                       "Failed to add the pair of key and value to the header map.");
+
+               r = E_SUCCESS;
+
+               if (isEquals)
+               {
+                       pNewKey.reset(null);
+               }
+               else
+               {
+                       pNewKey.release();
+               }
+
+               pNewValue.release();
+       }
+
+       return r;
+}
+
+bool
+_HttpHeaderImpl::CheckChunkedMode(void) const
+{
+       IList* pFieldNames = null;
+       String* pFiledName = null;
+       bool isFoundFieldName = false;
+       String outFieldName;
+
+       if (__pHeaderMap->GetCount() == 0)
+       {
+               return false;
+       }
+
+       pFieldNames = GetFieldNamesN();
+       if (pFieldNames != null)
+       {
+               for (int i = 0; i < pFieldNames->GetCount(); i++)
+               {
+                       pFiledName = dynamic_cast< String* >(pFieldNames->GetAt(i));
+                       SysTryReturn(NID_NET_HTTP, pFiledName != null, false, E_SYSTEM,
+                                               "[E_SYSTEM] A system error has occurred.");
+
+                       if (pFiledName->Equals(_HTTP_TRANSFER_ENCODING_HEADER_NAME, false))
+                       {
+                               isFoundFieldName = true;
+                               break;
+                       }
+               }
+               delete pFieldNames;
+       }
+
+       if (!isFoundFieldName)
+       {
+               return false;
+       }
+       else
+       {
+               IEnumerator* pValueEnum = null;
+               outFieldName = *pFiledName;
+               pValueEnum = __pHeaderMap->GetValuesN(outFieldName);
+
+               if (pValueEnum != null)
+               {
+                       while (pValueEnum->MoveNext() == E_SUCCESS)
+                       {
+                               String* pFiledValue = dynamic_cast< String* >(pValueEnum->GetCurrent());
+                               if (pFiledValue != null)
+                               {
+                                       if (pFiledValue->Equals(_HTTP_CHUNKED_HEADER_VALUE, false))
+                                       {
+                                               delete pValueEnum;
+                                               return true;
+                                       }
+                               }
+                       }
+                       delete pValueEnum;
+               }
+
+               return false;
+       }
+}
+
+bool
+_HttpHeaderImpl::HasHeader(const Tizen::Base::String& fieldName, Tizen::Base::String& outFiledName) const
+{
+       IList* pFieldNames = null;
+       String* pFiledName = null;
+       bool isFoundFieldName = false;
+
+       if (__pHeaderMap->GetCount() == 0)
+       {
+               return false;
+       }
+
+       pFieldNames = GetFieldNamesN();
+       if (pFieldNames != null)
+       {
+               for (int i = 0; i < pFieldNames->GetCount(); i++)
+               {
+                       pFiledName = dynamic_cast< String* >(pFieldNames->GetAt(i));
+                       SysTryReturn(NID_NET_HTTP, pFiledName != null, false, E_SYSTEM,
+                                               "[E_SYSTEM] A system error has occurred.");
+
+                       if (pFiledName->Equals(fieldName, false))
+                       {
+                               isFoundFieldName = true;
+                               outFiledName = *pFiledName;
+                               break;
+                       }
+               }
+               delete pFieldNames;
+       }
+
+       return isFoundFieldName;
+}
+
+bool
+_HttpHeaderImpl::GetHeaderValue(const Tizen::Base::String& fieldName, Tizen::Base::String& outFieldValue) const
+{
+       IList* pFieldNames = null;
+       String* pFiledName = null;
+       bool isFoundFieldName = false;
+       String outFieldName;
+
+       if (__pHeaderMap->GetCount() == 0)
+       {
+               return false;
+       }
+
+       pFieldNames = GetFieldNamesN();
+       if (pFieldNames != null)
+       {
+               for (int i = 0; i < pFieldNames->GetCount(); i++)
+               {
+                       pFiledName = dynamic_cast< String* >(pFieldNames->GetAt(i));
+                       SysTryReturn(NID_NET_HTTP, pFiledName != null, false, E_SYSTEM,
+                                               "[E_SYSTEM] A system error has occurred.");
+
+                       if (pFiledName->Equals(fieldName, false))
+                       {
+                               isFoundFieldName = true;
+                               break;
+                       }
+               }
+               delete pFieldNames;
+       }
+
+       if (!isFoundFieldName)
+       {
+               return false;
+       }
+       else
+       {
+               IEnumerator* pValueEnum = null;
+               outFieldName = *pFiledName;
+               pValueEnum = __pHeaderMap->GetValuesN(outFieldName);
+
+               if (pValueEnum != null)
+               {
+                       while (pValueEnum->MoveNext() == E_SUCCESS)
+                       {
+                               String* pFiledValue = dynamic_cast< String* >(pValueEnum->GetCurrent());
+                               if (pFiledValue != null)
+                               {
+                                       outFieldValue = *pFiledValue;
+                                       delete pValueEnum;
+
+                                       return true;
+                               }
+                       }
+               }
+
+               delete pValueEnum;
+
+               return false;
+       }
+}
+
+struct curl_slist*
+_HttpHeaderImpl::MakeCurlHeaderList()
+{
+       result r = E_SUCCESS;
+
+       const String* pHeaderName = null;
+       const String* pHeaderValue = null;
+
+       String outFiledName;
+       struct curl_slist* pCurlRequestHeaderList = null;
+
+       if (__pHeaderMap->GetCount() <= 0)
+       {
+               SysLog(NID_NET_HTTP, "The request header is empty.");
+               return null;
+       }
+
+       // Get the IList of all Keys
+       unique_ptr<IList> pHeaderNames(__pHeaderMap->GetKeysN());
+       SysTryReturn(NID_NET_HTTP, pHeaderNames != null, null, E_OUT_OF_MEMORY,
+                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       for (int i = 0; i < pHeaderNames->GetCount(); i++)
+       {
+               pHeaderName = dynamic_cast< const String* >(pHeaderNames->GetAt(i));
+               SysTryCatch(NID_NET_HTTP, pHeaderName != null, , E_SYSTEM,
+                                       "[E_SYSTEM] A system error has occurred.");
+
+               if (pHeaderName->Equals(_HTTP_CONTENT_LENGTH_HEADER_NAME, false))
+               {
+                       SysLog(NID_NET_HTTP, "Ignored the Content-Length header.");
+                       continue;
+               }
+
+               unique_ptr<IEnumerator> pHeaderValues(__pHeaderMap->GetValuesN(*pHeaderName));
+               SysTryCatch(NID_NET_HTTP, pHeaderValues != null, , E_OUT_OF_MEMORY,
+                                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               while (pHeaderValues->MoveNext() == E_SUCCESS)
+               {
+                       unique_ptr<String> pRawHeaderString(new (std::nothrow) String());
+                       SysTryCatch(NID_NET_HTTP, pRawHeaderString != null, , E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       r = pRawHeaderString->Append(*pHeaderName);
+                       SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, , E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       r = pRawHeaderString->Append(L":");
+                       SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, , E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       pHeaderValue = dynamic_cast< const String* >(pHeaderValues->GetCurrent());
+                       SysTryCatch(NID_NET_HTTP, pHeaderValue != null, , E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       r = pRawHeaderString->Append(*pHeaderValue);
+                       SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, , E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       unique_ptr<char[]> pLineHeader(_StringConverter::CopyToCharArrayN(*pRawHeaderString));
+                       SysTryCatch(NID_NET_HTTP, pLineHeader != null, , E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       pCurlRequestHeaderList = curl_slist_append(pCurlRequestHeaderList, pLineHeader.get());
+               }
+       }
+
+       if (!HasHeader(_HTTP_EXPECT_HEADER_NAME, outFiledName))
+       {
+               SysLog(NID_NET_HTTP, "Remove the Expect Header.");
+               pCurlRequestHeaderList = curl_slist_append(pCurlRequestHeaderList, "Expect:");
+       }
+
+       if (!HasHeader(_HTTP_CONTENT_TYPE_HEADER_NAME, outFiledName))
+       {
+               SysLog(NID_NET_HTTP, "Remove the Content-Type Header.");
+               pCurlRequestHeaderList = curl_slist_append(pCurlRequestHeaderList, "Content-Type:");
+       }
+
+       return pCurlRequestHeaderList;
+
+CATCH:
+
+       if (pCurlRequestHeaderList != null)
+       {
+               curl_slist_free_all(pCurlRequestHeaderList);
+               pCurlRequestHeaderList = null;
+       }
+
+       return null;
+}
+
+result
+_HttpHeaderImpl::GetRealm(const String& authName, String& outRealm) const
+{
+       result r = E_SUCCESS;
+       String fieldValue;
+
+       r = GetHeaderValue(authName, fieldValue);
+
+       SysLog(NID_NET_HTTP, "The http authentication name is %ls, The header value is %ls.", authName.GetPointer(), fieldValue.GetPointer());
+
+       if (!fieldValue.IsEmpty())
+       {
+               if ((fieldValue.Equals(L"Negotiate", false)) || (fieldValue.Equals(L"NTLM", false)))
+               {
+                       outRealm = L"";
+                       r = E_SUCCESS;
+               }
+               else
+               {
+                       int indexOfDelimiter = -1;
+                       int startIndex = -1;
+                       int endIndex = -1;
+                       r = fieldValue.IndexOf(L"realm", 0, indexOfDelimiter);
+                       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                          E_OBJ_NOT_FOUND, "Failed to found the realm field");
+
+                       r = fieldValue.IndexOf(L"\"", indexOfDelimiter, startIndex);
+                       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                          E_OBJ_NOT_FOUND, "Failed to found the realm field");
+
+                       r = fieldValue.IndexOf(L"\"", startIndex + 1, endIndex);
+                       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                          E_OBJ_NOT_FOUND, "Failed to found the realm field");
+
+                       r = fieldValue.SubString(startIndex + 1, endIndex - startIndex - 1, outRealm);
+                       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                          E_OBJ_NOT_FOUND, "Failed to found the realm field");
+               }
+       }
+
+       return r;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpManagedNetConnectionEventListenerImpl.cpp b/src/http/FNetHttp_HttpManagedNetConnectionEventListenerImpl.cpp
new file mode 100644 (file)
index 0000000..a356f69
--- /dev/null
@@ -0,0 +1,219 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpManagedNetConnectionEventListenerImpl.cpp
+ * @brief              This is the implementation file for the _HttpManagedNetConnectionEventListenerImpl Class.
+ */
+
+#include <FNetManagedNetConnection.h>
+#include <FNetHttpHttpTransaction.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNet_ManagedNetConnectionImpl.h"
+#include "FNetHttp_HttpSessionImpl.h"
+#include "FNetHttp_HttpTransactionImpl.h"
+#include "FNetHttp_HttpCommon.h"
+#include "FNetHttp_HttpManagedNetConnectionEventListenerImpl.h"
+#include "FNetHttp_HttpTransactionEvent.h"
+#include "FNetHttp_HttpTransactionEventArg.h"
+
+using namespace Tizen::Net;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpManagedNetConnectionEventListenerImpl::_HttpManagedNetConnectionEventListenerImpl(_HttpSessionImpl* pHttpSessionImpl)
+       : __isReceivedEvent(false)
+       , __pHttpSessionImpl(pHttpSessionImpl)
+{
+}
+
+_HttpManagedNetConnectionEventListenerImpl::~_HttpManagedNetConnectionEventListenerImpl()
+{
+}
+
+void
+_HttpManagedNetConnectionEventListenerImpl::OnManagedNetConnectionStarted(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET_HTTP, "The network state is started.");
+
+       ProcessPendingTransactions(managedNetConnection);
+
+       SysLog(NID_NET_HTTP, "Called OnManagedNetConnectionStarted()");
+}
+
+void
+_HttpManagedNetConnectionEventListenerImpl::OnManagedNetConnectionStopped(ManagedNetConnection& managedNetConnection, NetConnectionStoppedReason reason)
+{
+       result r = E_SUCCESS;
+       SysLog(NID_NET_HTTP, "The network state is stopped with reason(%d).", reason);
+
+       if (!__isReceivedEvent)
+       {
+               AbortPendingTransactions(managedNetConnection);
+               __pHttpSessionImpl->SetSessionState(false);
+       }
+       else
+       {
+               r = __pHttpSessionImpl->Disconnect();
+               if (IsFailed(r))
+               {
+                       SysLog(NID_NET_HTTP, "Failed to disconnect the HttpSession.");
+               }
+       }
+
+       SysLog(NID_NET_HTTP, "Called OnManagedNetConnectionStopped()");
+}
+
+void
+_HttpManagedNetConnectionEventListenerImpl::OnManagedNetConnectionSuspended(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET_HTTP, "The network state is suspended.");
+}
+
+void
+_HttpManagedNetConnectionEventListenerImpl::OnManagedNetConnectionResumed(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET_HTTP, "The network state is resumed.");
+}
+
+void
+_HttpManagedNetConnectionEventListenerImpl::OnManagedNetConnectionBearerChanged(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET_HTTP, "The network state is changed.");
+}
+
+bool
+_HttpManagedNetConnectionEventListenerImpl::IsEventReceived(void) const
+{
+       return __isReceivedEvent;
+}
+
+void
+_HttpManagedNetConnectionEventListenerImpl::SetReceivedEvent(bool isReceivedEvent)
+{
+       __isReceivedEvent = isReceivedEvent;
+}
+
+void
+_HttpManagedNetConnectionEventListenerImpl::ProcessPendingTransactions(ManagedNetConnection& managedNetConnection)
+{
+       SysAssertf(__pHttpSessionImpl != null, "The __pHttpSessionImpl must not be null.");
+
+       result r = E_SUCCESS;
+
+       if (__isReceivedEvent == false)
+       {
+               _ManagedNetConnectionImpl* pManagedNetConnectionImpl = _ManagedNetConnectionImpl::GetInstance(managedNetConnection);
+               SysAssertf(pManagedNetConnectionImpl != null, "pConnectionInfo must not be null.");
+
+               const NetConnectionInfo* pConnectionInfo = pManagedNetConnectionImpl->GetNetConnectionInfo();
+               SysAssertf(pConnectionInfo != null, "pConnectionInfo must not be null.");
+
+               const _NetConnectionInfoImpl* pConnectionInfoImpl = _NetConnectionInfoImpl::GetInstance(*pConnectionInfo);
+               SysAssertf(pConnectionInfoImpl != null, "pConnectionInfoImpl must not be null.");
+
+               String proxyAddressOfManagedMode = pConnectionInfoImpl->GetProxyAddress();
+               String deviceName = pConnectionInfoImpl->GetDeviceName();
+               SysLog(NID_NET_HTTP, "[Preference Mode] Network is started. the device name is %ls, the system proxy address is %ls.", deviceName.GetPointer(), proxyAddressOfManagedMode.GetPointer());
+
+               if (__pHttpSessionImpl->GetProxyAddress() != null)
+               {
+                       proxyAddressOfManagedMode = *__pHttpSessionImpl->GetProxyAddress();
+                       SysLog(NID_NET_HTTP, "[Preference Mode] Use a specific proxy address[%ls] of application.", proxyAddressOfManagedMode.GetPointer());
+               }
+               else
+               {
+                       String* pPorxyAddress = new (std::nothrow) String(proxyAddressOfManagedMode);
+                       SysTryReturnVoidResult(NID_NET_HTTP, pPorxyAddress != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                       __pHttpSessionImpl->SetProxyAddress(pPorxyAddress);
+               }
+
+               __pHttpSessionImpl->SetDeviceName(deviceName);
+
+               HttpTransaction* pHttpTransaction = null;
+               _HttpTransactionImpl* pHttpTransactionImpl = null;
+               ArrayList* pTransactionList = __pHttpSessionImpl->GetActiveTransactions();
+               SysAssertf(pTransactionList != null, "__pHttpSessionImpl must not be null.");
+
+               int countOfActiveTransactions = pTransactionList->GetCount();
+
+               for (int i = 0; i < countOfActiveTransactions; i++)
+               {
+                       pHttpTransaction = static_cast< HttpTransaction* >(pTransactionList->GetAt(i));
+                       if (pHttpTransaction != null)
+                       {
+                               pHttpTransactionImpl = _HttpTransactionImpl::GetInstance(*pHttpTransaction);
+                               SysAssertf(pHttpTransactionImpl != null, "__pHttpSessionImpl must not be null.");
+
+                               if (pHttpTransactionImpl->IsPendingTransaction())
+                               {
+                                       r = pHttpTransactionImpl->SubmitPendingTransaction(deviceName, proxyAddressOfManagedMode);
+                                       if (IsFailed(r))
+                                       {
+                                               SysLog(NID_NET_HTTP, "Failed to submit the pending HttpTransaction.");
+                                       }
+                               }
+                       }
+               }
+
+               __isReceivedEvent = true;
+       }
+}
+
+void
+_HttpManagedNetConnectionEventListenerImpl::AbortPendingTransactions(ManagedNetConnection& managedNetConnection)
+{
+       SysAssertf(__pHttpSessionImpl != null, "__pHttpSessionImpl must not be null.");
+
+       result r = E_SUCCESS;
+
+       r = managedNetConnection.SetManagedNetConnectionEventListener(null);
+       if (IsFailed(r))
+       {
+               SysLog(NID_NET_HTTP, "Failed to unset the ManagedNetConnectionEventListener.");
+       }
+
+       HttpTransaction* pHttpTransaction = null;
+       _HttpTransactionImpl* pHttpTransactionImpl = null;
+       ArrayList* pTransactionList = __pHttpSessionImpl->GetActiveTransactions();
+       SysAssertf(pTransactionList != null, "__pHttpSessionImpl must not be null.");
+
+       int countOfActiveTransactions = pTransactionList->GetCount();
+
+       for (int i = 0; i < countOfActiveTransactions; i++)
+       {
+               pHttpTransaction = static_cast< HttpTransaction* >(pTransactionList->GetAt(i));
+               if (pHttpTransaction != null)
+               {
+                       pHttpTransactionImpl = _HttpTransactionImpl::GetInstance(*pHttpTransaction);
+                       SysAssertf(pHttpTransactionImpl != null, "__pHttpSessionImpl must not be null.");
+
+                       if (pHttpTransactionImpl->IsPendingTransaction())
+                       {
+                               //Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_ABORTED)  - E_NETWORK_UNAVAILABLE
+                               pHttpTransactionImpl->GetHttpTransactionEvent()->FireTransactionAbortedEvent(E_NETWORK_UNAVAILABLE);
+                       }
+               }
+       }
+       __isReceivedEvent = true;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpManagedNetConnectionEventListenerImpl.h b/src/http/FNetHttp_HttpManagedNetConnectionEventListenerImpl.h
new file mode 100644 (file)
index 0000000..ad5e888
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpManagedNetConnectionEventListenerImpl.h
+ * @brief              This is the header file for the %_HttpManagedNetConnectionEventListenerImpl class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_MANAGED_NET_CONNECTION_EVENT_LISTENER_H_
+#define _FNET_HTTP_INTERNAL_HTTP_MANAGED_NET_CONNECTION_EVENT_LISTENER_H_
+
+#include <FNetIManagedNetConnectionEventListener.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+/**
+* @class       _HttpManagedNetConnectionEventListenerImpl
+* @brief       _HttpManagedNetConnectionEventListenerImpl class implements the IManagedNetConnectionEventListener interface..
+*
+* @since 2.1
+*
+*/
+
+class _HttpManagedNetConnectionEventListenerImpl
+       : public Tizen::Net::IManagedNetConnectionEventListener
+{
+public:
+       _HttpManagedNetConnectionEventListenerImpl(_HttpSessionImpl* pHttpSessionImpl);
+
+       ~_HttpManagedNetConnectionEventListenerImpl(void);
+
+public:
+       void OnManagedNetConnectionStarted(Tizen::Net::ManagedNetConnection& managedNetConnection);
+
+       void OnManagedNetConnectionStopped(Tizen::Net::ManagedNetConnection& managedNetConnection, Tizen::Net::NetConnectionStoppedReason reason);
+
+       void OnManagedNetConnectionSuspended(Tizen::Net::ManagedNetConnection& managedNetConnection);
+
+       void OnManagedNetConnectionResumed(Tizen::Net::ManagedNetConnection& managedNetConnection);
+
+       void OnManagedNetConnectionBearerChanged(Tizen::Net::ManagedNetConnection& managedNetConnection);
+
+public:
+       bool IsEventReceived(void) const;
+
+       void SetReceivedEvent(bool isReceivedEvent);
+
+private:
+       void ProcessPendingTransactions(ManagedNetConnection& managedNetConnection);
+
+       void AbortPendingTransactions(ManagedNetConnection& managedNetConnection);
+
+private:
+       _HttpManagedNetConnectionEventListenerImpl(const _HttpManagedNetConnectionEventListenerImpl& rhs);
+
+       _HttpManagedNetConnectionEventListenerImpl& operator =(const _HttpManagedNetConnectionEventListenerImpl& rhs);
+
+private:
+       bool __isReceivedEvent;
+       class _HttpSessionImpl* __pHttpSessionImpl;
+
+}; // _HttpManagedNetConnectionEventListenerImpl
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_MANAGED_NET_CONNECTION_EVENT_LISTENER_H_
diff --git a/src/http/FNetHttp_HttpMultipartConverter.cpp b/src/http/FNetHttp_HttpMultipartConverter.cpp
new file mode 100644 (file)
index 0000000..da35c49
--- /dev/null
@@ -0,0 +1,691 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpMultipartConverter.cpp
+ * @brief              This is the implementation file for the _HttpMultipartConverter class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FIoFile.h>
+#include <FTextEncoding.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpCommon.h"
+#include "FNetHttp_HttpMultipartEntityImpl.h"
+#include "FNetHttp_HttpMultipartConverter.h"
+#include "FNetHttp_HttpStringPart.h"
+#include "FNetHttp_HttpFilePart.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+using namespace Tizen::Text;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpMultipartConverter::_HttpMultipartConverter(void)
+       : __isConstructed(false)
+       , __pEntity(null)
+{
+}
+
+_HttpMultipartConverter::~_HttpMultipartConverter(void)
+{
+       __isConstructed = false;
+}
+
+result
+_HttpMultipartConverter::Construct(_HttpMultipartEntityImpl* pMultipartEntityImpl)
+{
+       SysTryReturnResult(NID_NET_HTTP, !__isConstructed,
+                                          E_INVALID_STATE, "Already constructed.");
+
+       result r = E_SUCCESS;
+
+       __isConstructed = true;
+
+       __pEntity = pMultipartEntityImpl;
+
+       __startBoundary = L"--" + __pEntity->GetBoundary();
+       __endBoundary = __startBoundary + L"--";
+
+       SysLog(NID_NET_HTTP, "The _HttpMultipartConverter instance was constructed.");
+
+       return r;
+}
+
+Tizen::Base::ByteBuffer*
+_HttpMultipartConverter::GenerateFormOfStringPartsN(bool isCheckedLength)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       ByteBuffer* pBuffer = null;
+       ByteBuffer* pTempBuffer = null;
+
+       SysTryReturn(NID_NET_HTTP, __isConstructed, null, E_INVALID_STATE,
+                                "[E_INVALID_STATE] Not constructed yet.");
+
+       SysTryReturn(NID_NET_HTTP, GetCountOfStringParts() > 0, null, E_INVALID_STATE,
+                                "[E_INVALID_STATE] StringParts is empty.");
+
+       SysLog(NID_NET_HTTP, "[StringParts] The value of isCheckedLegth is %s.", isCheckedLength ? "true" : "false");
+
+       unique_ptr<IEnumerator> pStringEnum(__pEntity->GetStringPartList()->GetEnumeratorN());
+       SysTryReturn(NID_NET_HTTP, pStringEnum != null, null, E_SYSTEM,
+                                "[E_SYSTEM] Failed to GetEnumeratorN().");
+
+       while (pStringEnum->MoveNext() == E_SUCCESS)
+       {
+               String formPart;
+               _HttpStringPart* pStringPart = null;
+
+               pStringPart = dynamic_cast< _HttpStringPart* >(pStringEnum->GetCurrent());
+               SysTryCatch(NID_NET_HTTP, pStringPart != null, , E_SYSTEM,
+                                       "[E_SYSTEM] A system error has occurred.");
+
+               SysLog(NID_NET_HTTP, "[StringPart] The name is %ls, the mimeType is %ls, the charset is %ls.",
+                          pStringPart->GetName().GetPointer(), pStringPart->GetMimeType().GetPointer(),
+                          pStringPart->GetCharset().GetPointer());
+
+               formPart.Append(__startBoundary);
+               formPart.Append(_HTTP_CARRIAGE_RETURN_LINE_FEED);
+
+               formPart.Append(L"Content-Disposition: form-data; name=\"");
+               formPart.Append(pStringPart->GetName());
+               formPart.Append(L"\"");
+
+               formPart.Append(_HTTP_CARRIAGE_RETURN_LINE_FEED);
+               formPart.Append(L"Content-Type: ");
+               formPart.Append(pStringPart->GetMimeType());
+               if (!pStringPart->GetCharset().IsEmpty())
+               {
+                       formPart.Append(L"; charset=");
+                       formPart.Append(pStringPart->GetCharset());
+               }
+
+               SysLog(NID_NET_HTTP, "[StringParts] The header is \n%ls.", formPart.GetPointer());
+
+               formPart.Append(_HTTP_CARRIAGE_RETURN_LINE_FEED);
+               formPart.Append(_HTTP_CARRIAGE_RETURN_LINE_FEED);
+
+               //Generates the byte buffer from formPart.
+               pTempBuffer = ConvertByteBufferN(formPart, _HTTP_DEFAULT_BODY_CHARSET);
+               r = GetLastResult();
+               r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+               SysTryCatch(NID_NET_HTTP, pTempBuffer != null, , r,
+                                       "[%s] Failed to convert the byte buffer from string.", GetErrorMessage(r));
+
+               if (pBuffer == null)
+               {
+                       pBuffer = new (std::nothrow) ByteBuffer();
+                       SysTryCatch(NID_NET_HTTP, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       r = pBuffer->Construct(pTempBuffer->GetRemaining());
+                       SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+                       r = pBuffer->CopyFrom(*pTempBuffer);
+                       SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+               else
+               {
+                       r = _HttpUtility::AddHeaderByteBufferToBuffer(&pBuffer, *pTempBuffer);
+                       SysTryCatch(NID_NET_HTTP, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               }
+
+               delete pTempBuffer;
+               pTempBuffer = null;
+
+               //Generates the byte buffer from value using the specific charset.
+               if (pStringPart->GetValue()->GetRemaining() > 0)
+               {
+                       SysLog(NID_NET_HTTP, "[StringParts] The length of value is %d.", pStringPart->GetValue()->GetRemaining());
+                       r = _HttpUtility::AddHeaderByteBufferToBuffer(&pBuffer, *pStringPart->GetValue());
+                       SysTryCatch(NID_NET_HTTP, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               }
+
+               pTempBuffer = ConvertByteBufferN(_HTTP_CARRIAGE_RETURN_LINE_FEED, _HTTP_DEFAULT_BODY_CHARSET);
+               r = GetLastResult();
+               r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+               SysTryCatch(NID_NET_HTTP, pTempBuffer != null, , r,
+                                       "[%s] Failed to convert the byte buffer from string.", GetErrorMessage(r));
+
+               r = _HttpUtility::AddHeaderByteBufferToBuffer(&pBuffer, *pTempBuffer);
+               SysTryCatch(NID_NET_HTTP, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               delete pTempBuffer;
+               pTempBuffer = null;
+       }
+
+       //Marked the already generated string parts.
+       if (!isCheckedLength)
+       {
+               __pEntity->GetStringPartList()->RemoveAll(true);
+       }
+
+       if (GetCountOfFileParts() == 0)
+       {
+               pTempBuffer = GetLastBoundaryN();
+               r = GetLastResult();
+               r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+               SysTryCatch(NID_NET_HTTP, pTempBuffer != null, , r,
+                                       "[%s] GetLastBoundaryN() must not be null.", GetErrorMessage(r));
+
+               r = _HttpUtility::AddHeaderByteBufferToBuffer(&pBuffer, *pTempBuffer);
+               SysTryCatch(NID_NET_HTTP, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               delete pTempBuffer;
+               pTempBuffer = null;
+       }
+
+       pBuffer->Flip();
+
+       SysLog(NID_NET_HTTP, "[StringParts] The form of StringParts was generated.");
+
+       return pBuffer;
+
+CATCH:
+
+       if (pBuffer != null)
+       {
+               delete pBuffer;
+       }
+
+       if (pTempBuffer != null)
+       {
+               delete pTempBuffer;
+       }
+
+       return null;
+}
+
+int
+_HttpMultipartConverter::GetCountOfStringParts(void) const
+{
+       if (!__isConstructed)
+       {
+               return 0;
+       }
+
+       return __pEntity->GetStringPartList()->GetCount();
+}
+
+
+long long
+_HttpMultipartConverter::GetLengthOfStringParts(void)
+{
+       long long contentLength = 0;
+       ByteBuffer* pBuffer = null;
+
+       if (!__isConstructed)
+       {
+               return 0;
+       }
+
+       if (GetCountOfStringParts() == 0)
+       {
+               return contentLength;
+       }
+
+       pBuffer = GenerateFormOfStringPartsN(true);
+       SysTryReturn(NID_NET_HTTP, GetLastResult() != E_OUT_OF_MEMORY, _HTTP_INVALID_CONTENT_LENGTH, E_OUT_OF_MEMORY,
+                                "[E_OUT_OF_MEMORY] Propagating.");
+
+       if (pBuffer != null)
+       {
+               contentLength = pBuffer->GetRemaining();
+               delete pBuffer;
+       }
+       else
+       {
+               contentLength = _HTTP_INVALID_CONTENT_LENGTH;
+       }
+
+       SysLog(NID_NET_HTTP, "[StringParts] The Content-Length is %lld.", contentLength);
+
+       return contentLength;
+}
+
+long long
+_HttpMultipartConverter::GetLengthOfFileParts(void)
+{
+       result r = E_SUCCESS;
+       long long contentLength = 0;
+       int count = 0;
+
+       if (!__isConstructed)
+       {
+               return 0;
+       }
+
+       if (GetCountOfFileParts() == 0)
+       {
+               return contentLength;
+       }
+
+       unique_ptr<IEnumerator> pFileEnum(__pEntity->GetFilePartList()->GetEnumeratorN());
+       SysTryReturn(NID_NET_HTTP, pFileEnum != null, _HTTP_INVALID_CONTENT_LENGTH, E_OUT_OF_MEMORY,
+                                "[E_OUT_OF_MEMORY] Propagating.");
+
+       while (pFileEnum->MoveNext() == E_SUCCESS)
+       {
+               String formPart;
+               _HttpFilePart* pFilePart = null;
+               FileAttributes fileAttributes;
+
+               pFilePart = dynamic_cast< _HttpFilePart* >(pFileEnum->GetCurrent());
+               SysTryReturn(NID_NET_HTTP, pFilePart != null, _HTTP_INVALID_CONTENT_LENGTH, E_SYSTEM,
+                                       "[E_SYSTEM] A system error has occurred.");
+
+               SysLog(NID_NET_HTTP, "Converts the FilePart into the ByteBuffer(Header Part)");
+
+               formPart.Append(__startBoundary);
+               formPart.Append(_HTTP_CARRIAGE_RETURN_LINE_FEED);
+               formPart.Append(L"Content-Disposition: form-data; name=\"");
+               formPart.Append(pFilePart->GetName());
+               formPart.Append(L"\"; filename=\"");
+               formPart.Append(pFilePart->GetFileName());
+               formPart.Append(L"\"");
+               formPart.Append(_HTTP_CARRIAGE_RETURN_LINE_FEED);
+               formPart.Append(L"Content-Type: ");
+               formPart.Append(pFilePart->GetMimeType());
+               if (!pFilePart->GetCharset().IsEmpty())
+               {
+                       formPart.Append(L"; charset=");
+                       formPart.Append(pFilePart->GetCharset());
+               }
+
+               formPart.Append(_HTTP_CARRIAGE_RETURN_LINE_FEED);
+               formPart.Append(_HTTP_CARRIAGE_RETURN_LINE_FEED);
+
+               SysLog(NID_NET_HTTP, "[File Part] The header is \n%ls", formPart.GetPointer());
+
+               unique_ptr<ByteBuffer> pBuffer(ConvertByteBufferN(formPart, _HTTP_DEFAULT_BODY_CHARSET));
+               r = GetLastResult();
+               r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+               SysTryReturn(NID_NET_HTTP, pBuffer != null, _HTTP_INVALID_CONTENT_LENGTH, r,
+                                       "[%s] Failed to convert the byte buffer from string.", GetErrorMessage(r));
+
+               contentLength += pBuffer->GetRemaining();
+               SysLog(NID_NET_HTTP, "[File Part] The length of header is %d.", pBuffer->GetRemaining());
+
+               if (pFilePart->GetFilePath().IsEmpty())
+               {
+                       contentLength += pFilePart->GetByteBuffer()->GetRemaining();
+                       SysLog(NID_NET_HTTP, "[File Part] The length of file name(%ls) is %d.", pFilePart->GetFileName().GetPointer(), pFilePart->GetByteBuffer()->GetRemaining());
+               }
+               else
+               {
+                       //add the file size.
+                       r = File::GetAttributes(pFilePart->GetFilePath(), fileAttributes);
+                       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, _HTTP_INVALID_CONTENT_LENGTH, E_SYSTEM,
+                                               "[E_SYSTEM] Failed to GetAttributes(%ls).", pFilePart->GetFilePath().GetPointer());
+
+                       contentLength += fileAttributes.GetFileSize();
+                       SysLog(NID_NET_HTTP, "[File Part] The size of File(%ls) is %lld.", pFilePart->GetFilePath().GetPointer(), fileAttributes.GetFileSize());
+               }
+
+               count++;
+
+               pBuffer.reset(ConvertByteBufferN(_HTTP_CARRIAGE_RETURN_LINE_FEED, _HTTP_DEFAULT_BODY_CHARSET));
+               r = GetLastResult();
+               r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+               SysTryReturn(NID_NET_HTTP, pBuffer != null, _HTTP_INVALID_CONTENT_LENGTH, r,
+                                       "[%s] Failed to convert the byte buffer from string.", GetErrorMessage(r));
+
+               contentLength += pBuffer->GetRemaining();
+
+               //add the last boundary. or "\r\n"
+               if (count == GetCountOfFileParts())
+               {
+                       pBuffer.reset(GetLastBoundaryN());
+                       r = GetLastResult();
+                       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+                       SysTryReturn(NID_NET_HTTP, pBuffer != null, _HTTP_INVALID_CONTENT_LENGTH, r,
+                                               "[%s] GetLastBoundaryN() must not be null.", GetErrorMessage(r));
+
+                       contentLength += pBuffer->GetRemaining();
+                       break;
+               }
+       }
+
+       SysLog(NID_NET_HTTP, "[FileParts] The value of Content-Length is %lld.", contentLength);
+
+       return contentLength;
+}
+
+Tizen::Base::ByteBuffer*
+_HttpMultipartConverter::GenerateNextFormOfFilePartsN(int recommendedSize)
+{
+       result r = E_SUCCESS;
+
+       _HttpFilePart* pFilePart = null;
+       ByteBuffer* pBuffer = null;
+       ByteBuffer* pTempBuffer = null;
+
+       SysTryReturn(NID_NET_HTTP, __isConstructed, null, E_INVALID_STATE,
+                                "[E_INVALID_STATE] Not constructed yet.");
+
+       SysTryReturn(NID_NET_HTTP, GetCountOfFileParts() > 0, null, E_INVALID_STATE,
+                                "[E_INVALID_STATE] FilePartList is empty.");
+
+       pFilePart = dynamic_cast< _HttpFilePart* >(__pEntity->GetFilePartList()->GetAt(0));
+       SysTryReturn(NID_NET_HTTP, pFilePart != null, null, E_INVALID_STATE,
+                                "[E_INVALID_STATE] pFilePart is null.");
+
+       //checks if the FilePart is already converted the byte buffer?
+       if (!pFilePart->IsDoneFileFormHeader())
+       {
+               //generates the byte buffer(Header Part) from the FilePart.
+               SysLog(NID_NET_HTTP, "[FileParts] Converting the FilePart into the ByteBuffer(Header)");
+               String formPart;
+
+               formPart.Append(__startBoundary);
+               formPart.Append(_HTTP_CARRIAGE_RETURN_LINE_FEED);
+               formPart.Append(L"Content-Disposition: form-data; name=\"");
+               formPart.Append(pFilePart->GetName());
+               formPart.Append(L"\"; filename=\"");
+               formPart.Append(pFilePart->GetFileName());
+               formPart.Append(L"\"");
+               formPart.Append(_HTTP_CARRIAGE_RETURN_LINE_FEED);
+               formPart.Append(L"Content-Type: ");
+               formPart.Append(pFilePart->GetMimeType());
+               if (!pFilePart->GetCharset().IsEmpty())
+               {
+                       formPart.Append(L"; charset=");
+                       formPart.Append(pFilePart->GetCharset());
+               }
+
+               formPart.Append(_HTTP_CARRIAGE_RETURN_LINE_FEED);
+               formPart.Append(_HTTP_CARRIAGE_RETURN_LINE_FEED);
+
+               SysLog(NID_NET_HTTP, "[FileParts] The header is \n%ls", formPart.GetPointer());
+
+               pTempBuffer = ConvertByteBufferN(formPart, _HTTP_DEFAULT_BODY_CHARSET);
+               r = GetLastResult();
+               r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+               SysTryCatch(NID_NET_HTTP, pTempBuffer != null, , r,
+                                       "[%s] Failed to convert the byte buffer from string.", GetErrorMessage(r));
+
+               pBuffer = new (std::nothrow) ByteBuffer();
+               SysTryCatch(NID_NET_HTTP, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = pBuffer->Construct(pTempBuffer->GetRemaining());
+               SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               r = pBuffer->CopyFrom(*pTempBuffer);
+               SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pFilePart->SetDoneFileFormHeader(true);
+
+               delete pTempBuffer;
+               pTempBuffer = null;
+       }
+       else
+       {
+               bool isLastFile = false;
+
+               //Process File or File ByteBuffer..
+               pBuffer = new (std::nothrow) ByteBuffer();
+               SysTryCatch(NID_NET_HTTP, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = pBuffer->Construct(recommendedSize);
+               SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+               //File Byte Buffer
+               if (pFilePart->GetFilePath().IsEmpty())
+               {
+                       SysLog(NID_NET_HTTP, "[FileParts] The file name is %ls.", pFilePart->GetFileName().GetPointer());
+                       ByteBuffer* pFileBuffer = pFilePart->GetByteBuffer();
+
+                       //check if the ByteBuffer is empty
+                       if (pFileBuffer->GetRemaining() == 0)
+                       {
+                               SysLog(NID_NET_HTTP, "[FileParts] The remaining buffer is zero.");
+                               isLastFile = true;
+                       }
+                       else
+                       {
+                               r = pBuffer->ReadFrom(*pFileBuffer);
+                               SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,
+                                                       "[E_SYSTEM] Failed to copy from the buffer(%ls).", pFilePart->GetFileName().GetPointer());
+                       }
+
+               }
+               else    //File
+               {
+                       File* pFile = null;
+                       //generates the byte buffer(Binary Part) from the FilePart.
+                       SysLog(NID_NET_HTTP, "[FileParts] The file is %ls.", pFilePart->GetFilePath().GetPointer());
+
+                       //Handle the file
+                       if (pFilePart->GetFile() == null)
+                       {
+                               SysLog(NID_NET_HTTP, "[FileParts] The file(%ls) was opened.", pFilePart->GetFilePath().GetPointer());
+                               pFile = new (std::nothrow) File();
+                               SysTryCatch(NID_NET_HTTP, pFile != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                                       "[E_OUT_OF_MEMORY] Memory allocation failed. (%ls).", pFilePart->GetFilePath().GetPointer());
+
+                               pFilePart->SetFile(pFile);
+                               r = pFile->Construct(pFilePart->GetFilePath(), L"r");
+                               if (IsFailed(r))
+                               {
+                                       r = E_IO;
+                                       SysLogException(NID_NET_HTTP, r, "[E_IO] Failed to open the file(%ls).", pFilePart->GetFilePath().GetPointer());
+
+                                       delete pFile;
+                                       pFilePart->SetFile(null);
+
+                                       goto CATCH;
+                               }
+                       }
+                       else
+                       {
+                               pFile = pFilePart->GetFile();
+                       }
+
+                       r = pFile->Read(*pBuffer);
+                       if (r == E_END_OF_FILE)
+                       {
+                               isLastFile = true;
+
+                       }
+                       else if (IsFailed(r))
+                       {
+                               r = E_SYSTEM;
+                               SysLogException(NID_NET_HTTP, r, "[E_SYSTEM] Failed to read the file.");
+
+                               delete pFile;
+                               pFilePart->SetFile(null);
+
+                               goto CATCH;
+                       }
+               }
+
+               if (isLastFile)
+               {
+                       SysLog(NID_NET_HTTP, "[FileParts] End of the file or byte buffer(%ls)", pFilePart->GetFileName().GetPointer());
+
+                       //Removes the FilePart in FilePartList.
+                       __pEntity->GetFilePartList()->Remove(*pFilePart, true);
+
+                       pTempBuffer = ConvertByteBufferN(_HTTP_CARRIAGE_RETURN_LINE_FEED, _HTTP_DEFAULT_BODY_CHARSET);
+                       r = GetLastResult();
+                       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+                       SysTryCatch(NID_NET_HTTP, pTempBuffer != null, , r,
+                                               "[%s] Failed to convert the byte buffer from string.", GetErrorMessage(r));
+
+                       r = _HttpUtility::AddByteBufferToBuffer(&pBuffer, *pTempBuffer, 0);
+                       SysTryCatch(NID_NET_HTTP, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       delete pTempBuffer;
+                       pTempBuffer = null;
+
+                       //Add the last boundary
+                       if (GetCountOfFileParts() == 0)
+                       {
+                               //add the last boundary
+                               pTempBuffer = GetLastBoundaryN();
+                               SysTryCatch(NID_NET_HTTP, pTempBuffer != null, r = E_SYSTEM, E_SYSTEM,
+                                                       "[E_SYSTEM] GetLastBoundaryN() is null.");
+
+                               r = _HttpUtility::AddByteBufferToBuffer(&pBuffer, *pTempBuffer, 0);
+                               SysTryCatch(NID_NET_HTTP, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                               delete pTempBuffer;
+                               pTempBuffer = null;
+
+                       }
+               }
+       }
+
+       pBuffer->Flip();
+
+       SysLog(NID_NET_HTTP, "[FileParts] The form of FileParts was generated.");
+
+       return pBuffer;
+
+CATCH:
+
+       if (pBuffer != null)
+       {
+               delete pBuffer;
+       }
+
+       if (pTempBuffer != null)
+       {
+               delete pTempBuffer;
+       }
+
+       SetLastResult(r);
+       return null;
+
+}
+
+int
+_HttpMultipartConverter::GetCountOfFileParts(void) const
+{
+       if (!__isConstructed)
+       {
+               return 0;
+       }
+
+       return __pEntity->GetFilePartList()->GetCount();
+}
+
+bool
+_HttpMultipartConverter::HasNextForm(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET_HTTP, GetCountOfStringParts() > 0 || GetCountOfFileParts() > 0, false, E_INVALID_STATE,
+                                "[E_INVALID_STATE] The next form is empty.");
+
+       return true;
+}
+
+Tizen::Base::ByteBuffer*
+_HttpMultipartConverter::GetNextFormN(int recommendedSize)
+{
+       result r = E_SUCCESS;
+       ByteBuffer* pBuffer = null;
+
+       SysLog(NID_NET_HTTP, "The recommendedSize is %d.", recommendedSize);
+
+       if (GetCountOfStringParts() > 0)
+       {
+               pBuffer = GenerateFormOfStringPartsN(false);
+               r = GetLastResult();
+               SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r,
+                                        "[%s] Failed to generate the StringParts.", GetErrorMessage(r));
+       }
+       else if (GetCountOfFileParts() > 0)
+       {
+               pBuffer = GenerateNextFormOfFilePartsN(recommendedSize);
+               r = GetLastResult();
+               SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r,
+                                        "[%s] Failed to generate the FileParts.", GetErrorMessage(r));
+
+       }
+       else
+       {
+               SysTryReturn(NID_NET_HTTP, false, null, E_SYSTEM,
+                                        "[E_SYSTEM] The next form is empty");
+       }
+
+       return pBuffer;
+}
+
+Tizen::Base::ByteBuffer*
+_HttpMultipartConverter::ConvertByteBufferN(const Tizen::Base::String& str, const Tizen::Base::String& charset)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+       ByteBuffer* pBuffer = null;
+
+       Encoding* pEnc = Encoding::GetEncodingN(charset);
+       SysTryReturn(NID_NET_HTTP, pEnc != null, null, E_SYSTEM, "[E_SYSTEM] pEnc must not be null.");
+
+       pBuffer = pEnc->GetBytesN(str);
+       r = GetLastResult();
+       delete pEnc;
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS && pBuffer != null, null, r,
+                                "[%s] Failed to encode the str.", GetErrorMessage(r));
+
+       //remove the terminated character of the str.
+       r = pBuffer->SetLimit(pBuffer->GetRemaining() - 1);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, E_SYSTEM,
+                                "[E_SYSTEM] Failed to set the limit in bytebuffer.");
+
+       return pBuffer;
+}
+
+Tizen::Base::ByteBuffer*
+_HttpMultipartConverter::GetLastBoundaryN(void)
+{
+       result r = E_SUCCESS;
+       ByteBuffer* pBuffer = null;
+
+       String lastBoundary;
+       lastBoundary.Append(__endBoundary);
+       lastBoundary.Append(_HTTP_CARRIAGE_RETURN_LINE_FEED);
+
+       //add the last boundary
+       pBuffer = ConvertByteBufferN(lastBoundary, _HTTP_DEFAULT_BODY_CHARSET);
+       r = GetLastResult();
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, pBuffer != null, null, r,
+                                "[%s] Failed to convert the byte buffer from String.", GetErrorMessage(r));
+
+       SysLog(NID_NET_HTTP, "The last boundary is %ls.", lastBoundary.GetPointer());
+
+       return pBuffer;
+}
+
+} } } // Tizen::Net::HttpMultipartConverter
diff --git a/src/http/FNetHttp_HttpMultipartConverter.h b/src/http/FNetHttp_HttpMultipartConverter.h
new file mode 100644 (file)
index 0000000..83c2fc6
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpMultipartConverter.h
+ * @brief              This is the header file for the %_HttpMultipartConverter class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_MULTIPART_CONVERTER_H_
+#define _FNET_HTTP_INTERNAL_HTTP_MULTIPART_CONVERTER_H_
+
+namespace Tizen { namespace Base
+{
+class String;
+} }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpMultipartEntityImpl;
+/**
+* @class       _HttpMultipartConverter
+* @brief       _HttpMultipartConverter class converts the HttpMultipartEntity class into ByteBuffer.
+*
+* @since 2.1
+*
+*/
+class _HttpMultipartConverter
+       : public Tizen::Base::Object
+{
+
+public:
+       _HttpMultipartConverter(void);
+
+       virtual ~_HttpMultipartConverter(void);
+
+       result Construct(_HttpMultipartEntityImpl* pMultipartEntityImpl);
+
+       Tizen::Base::ByteBuffer* GenerateFormOfStringPartsN(bool isCheckedLength);
+
+       int GetCountOfStringParts(void) const;
+
+       long long GetLengthOfStringParts(void);
+
+       Tizen::Base::ByteBuffer* GenerateNextFormOfFilePartsN(int recommendedSize);
+
+       int GetCountOfFileParts(void) const;
+
+       long long GetLengthOfFileParts(void);
+
+       bool HasNextForm(void) const;
+
+       Tizen::Base::ByteBuffer* GetNextFormN(int recommendedSize);
+
+       Tizen::Base::ByteBuffer* GetLastBoundaryN(void);
+
+       static Tizen::Base::ByteBuffer* ConvertByteBufferN(const Tizen::Base::String& str, const Tizen::Base::String& charset);
+
+private:
+       _HttpMultipartConverter(const _HttpMultipartConverter& rhs);
+
+       _HttpMultipartConverter& operator =(const _HttpMultipartConverter& rhs);
+
+private:
+       bool __isConstructed;
+       _HttpMultipartEntityImpl* __pEntity;
+       Tizen::Base::String __startBoundary;
+       Tizen::Base::String __endBoundary;
+
+}; // _HttpMultipartConverter
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_MULTI_PART_CONVERTER_H_
diff --git a/src/http/FNetHttp_HttpMultipartEntityImpl.cpp b/src/http/FNetHttp_HttpMultipartEntityImpl.cpp
new file mode 100644 (file)
index 0000000..6aaff47
--- /dev/null
@@ -0,0 +1,441 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpMultipartEntityImpl.cpp
+ * @brief              This is the implementation file for the _HttpMultipartEntityImpl class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FTextEncoding.h>
+#include <FIoFile.h>
+#include <FNetHttpHttpMultipartEntity.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpMultipartEntityImpl.h"
+#include "FNetHttp_HttpCommon.h"
+#include "FNetHttp_HttpMultipartConverter.h"
+#include "FNetHttp_HttpStringPart.h"
+#include "FNetHttp_HttpFilePart.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+using namespace Tizen::Text;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpMultipartEntityImpl::_HttpMultipartEntityImpl(void)
+{
+       __pStringPartList = null;
+       __pFilePartList = null;
+       __pHttpMultipartConverter = new (std::nothrow) _HttpMultipartConverter();
+       SysTryReturnVoidResult(NID_NET_HTTP, __pHttpMultipartConverter != null, E_OUT_OF_MEMORY,
+                                                  "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+_HttpMultipartEntityImpl::~_HttpMultipartEntityImpl(void)
+{
+       if (__pStringPartList != null)
+       {
+               __pStringPartList->RemoveAll(true);
+               delete __pStringPartList;
+               __pStringPartList = null;
+       }
+
+       if (__pFilePartList != null)
+       {
+               __pFilePartList->RemoveAll(true);
+               delete __pFilePartList;
+               __pFilePartList = null;
+       }
+
+       if (__pHttpMultipartConverter != null)
+       {
+               delete __pHttpMultipartConverter;
+               __pHttpMultipartConverter = null;
+       }
+
+       SysLog(NID_NET_HTTP, "The _HttpMultipartEntityImpl instance was deleted.");
+}
+
+result
+_HttpMultipartEntityImpl::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       unique_ptr<LinkedList> pStringPartList(new (std::nothrow) LinkedList());
+       SysTryReturnResult(NID_NET_HTTP, pStringPartList != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       unique_ptr<LinkedList> pFilePartList(new (std::nothrow) LinkedList());
+       SysTryReturnResult(NID_NET_HTTP, pFilePartList != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       __boundary = GenerateBoundary();
+
+       r = __pHttpMultipartConverter->Construct(this);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          E_SYSTEM, "Failed to construct the HttpMultipartEntity.");
+
+
+       __pStringPartList = pStringPartList.release();
+       __pFilePartList = pFilePartList.release();
+
+       return r;
+}
+
+result
+_HttpMultipartEntityImpl::Construct(const Tizen::Base::String& boundary)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, !boundary.IsEmpty(),
+                                          E_INVALID_ARG, "The boundary is empty");
+
+       unique_ptr<LinkedList> pStringPartList(new (std::nothrow) LinkedList());
+       SysTryReturnResult(NID_NET_HTTP, pStringPartList != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       unique_ptr<LinkedList> pFilePartList(new (std::nothrow) LinkedList());
+       SysTryReturnResult(NID_NET_HTTP, pFilePartList != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       __boundary = boundary;
+
+       r = __pHttpMultipartConverter->Construct(this);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          E_SYSTEM, "Failed to construct the HttpMultipartEntity.");
+
+       __pStringPartList = pStringPartList.release();
+       __pFilePartList = pFilePartList.release();
+
+       return r;
+}
+
+long long
+_HttpMultipartEntityImpl::GetContentLength(void) const
+{
+       long long contentLength = 0;
+
+       contentLength = __pHttpMultipartConverter->GetLengthOfStringParts() + __pHttpMultipartConverter->GetLengthOfFileParts();
+
+       return contentLength;
+}
+
+Tizen::Base::String
+_HttpMultipartEntityImpl::GetContentType(void) const
+{
+       String contentType(_MULTI_PART_FORM_DATA_PREFIX);
+       contentType += __boundary;
+
+       return contentType;
+}
+
+bool
+_HttpMultipartEntityImpl::HasNextData(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       bool rs = false;
+
+       rs = __pHttpMultipartConverter->HasNextForm();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, false, r,
+                                "[%s] Propagating.", GetErrorMessage(r));
+
+       return rs;
+}
+
+Tizen::Base::ByteBuffer*
+_HttpMultipartEntityImpl::GetNextDataN(int recommendedSize)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       ByteBuffer* pBuffer = null;
+
+       pBuffer = __pHttpMultipartConverter->GetNextFormN(recommendedSize);
+       r = GetLastResult();
+       if (pBuffer == null && IsFailed(r))
+       {
+               SysLogException(NID_NET_HTTP, r, "[%s] Propagating.", GetErrorMessage(r));
+               return null;
+       }
+
+       return pBuffer;
+}
+
+result
+_HttpMultipartEntityImpl::AddStringPart(const Tizen::Base::String& name, const Tizen::Base::String& text)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       Encoding* pEnc = null;
+
+       SysTryReturnResult(NID_NET_HTTP, !name.IsEmpty(),
+                                          E_INVALID_ARG, "The name is empty.");
+
+       pEnc = Encoding::GetEncodingN(_HTTP_STRING_PART_DEFAULT_CHARSET);
+       r = GetLastResult();
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, pEnc != null,
+                                          r, "Failed to get the instance of Encoding.");
+
+       r = AddStringPart(name, text, HTTP_STRING_PART_DEFAULT_MIME_TYPE, _HTTP_STRING_PART_DEFAULT_CHARSET, *pEnc);
+       delete pEnc;
+
+       return r;
+}
+
+result
+_HttpMultipartEntityImpl::AddStringPart(const Tizen::Base::String& name, const Tizen::Base::String& text,
+                                                                               const Tizen::Base::String& mimeType, const Tizen::Base::String& charset,
+                                                                               const Tizen::Text::Encoding& encoding)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       unique_ptr<ByteBuffer> pTextBuffer;
+
+       SysTryReturnResult(NID_NET_HTTP, !name.IsEmpty(),
+                                          E_INVALID_ARG, "The name is empty.");
+
+       SysTryReturnResult(NID_NET_HTTP, !mimeType.IsEmpty(),
+                                          E_INVALID_ARG, "The mimeType is empty.");
+
+       SysTryReturnResult(NID_NET_HTTP, !charset.IsEmpty(),
+                                          E_INVALID_ARG, "The charset is empty.");
+
+       unique_ptr<_HttpStringPart> pStringPart(new (std::nothrow) _HttpStringPart());
+       SysTryReturnResult(NID_NET_HTTP, pStringPart != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       if (text.IsEmpty())
+       {
+               SysLog(NID_NET_HTTP, "The text is empty.");
+
+               pTextBuffer.reset(new (std::nothrow) ByteBuffer());
+               SysTryReturnResult(NID_NET_HTTP, pTextBuffer != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               r = pTextBuffer->Construct(0);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+       else
+       {
+               pTextBuffer.reset(_HttpMultipartConverter::ConvertByteBufferN(text, charset));
+               r = GetLastResult();
+               SysTryReturnResult(NID_NET_HTTP, pTextBuffer != null, r, "Failed to encode the text.");
+       }
+
+       r = pStringPart->Construct(name, *pTextBuffer, mimeType, charset);
+       r = TransExceptionsExclusive(r, E_INVALID_ARG, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                               "Propagating.");
+
+       pTextBuffer.release();
+
+       r = __pStringPartList->Add(*pStringPart);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       pStringPart.release();
+
+       return r;
+}
+
+result
+_HttpMultipartEntityImpl::AddFilePart(const Tizen::Base::String& name, const Tizen::Base::String& filePath)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       bool rs = false;
+       String fileName;
+
+       SysTryReturnResult(NID_NET_HTTP, !name.IsEmpty(),
+                                          E_INVALID_ARG, "The name is empty.");
+
+       SysTryReturnResult(NID_NET_HTTP, !filePath.IsEmpty(),
+                                          E_INVALID_ARG, "The filePath is empty.");
+
+       //Check if the filePath is valid
+       rs = File::IsFileExist(filePath);
+       SysTryReturnResult(NID_NET_HTTP, rs,
+                                          E_FILE_NOT_FOUND, "Failed to found the file.(%ls)", filePath.GetPointer());
+
+       fileName = File::GetFileName(filePath);
+       r = AddFilePart(name, filePath, fileName, HTTP_FILE_PART_DEFAULT_MIME_TYPE, _HTTP_FILE_PART_DEFAULT_CHARSET);
+
+       return r;
+}
+
+result
+_HttpMultipartEntityImpl::AddFilePart(const Tizen::Base::String& name, const Tizen::Base::String& filePath,
+                                                                         const Tizen::Base::String& fileName, const Tizen::Base::String& mimeType,
+                                                                         const Tizen::Base::String& charset)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       bool rs = false;
+
+       SysTryReturnResult(NID_NET_HTTP, !name.IsEmpty(),
+                                          E_INVALID_ARG, "The name is empty.");
+
+       SysTryReturnResult(NID_NET_HTTP, !filePath.IsEmpty(),
+                                          E_INVALID_ARG, "The filePath is empty.");
+
+       SysTryReturnResult(NID_NET_HTTP, !fileName.IsEmpty(),
+                                          E_INVALID_ARG, "The fileName is empty.");
+
+       SysTryReturnResult(NID_NET_HTTP, !mimeType.IsEmpty(),
+                                          E_INVALID_ARG, "The mimeType is empty.");
+
+       //Check if the filePath is valid
+       rs = File::IsFileExist(filePath);
+       SysTryReturnResult(NID_NET_HTTP, rs,
+                                          E_FILE_NOT_FOUND, "Failed to found the file(%ls).", filePath.GetPointer());
+
+       unique_ptr<_HttpFilePart> pFilePart(new (std::nothrow) _HttpFilePart());
+       SysTryReturnResult(NID_NET_HTTP, pFilePart != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pFilePart->Construct(name, filePath, fileName, mimeType, charset);
+       r = TransExceptionsExclusive(r, E_INVALID_ARG, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                               "Propagating.");
+
+       r = __pFilePartList->Add(*pFilePart);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       pFilePart.release();
+
+       return r;
+}
+
+result
+_HttpMultipartEntityImpl::AddFilePartByBuffer(const Tizen::Base::String& name, const Tizen::Base::String& fileName,
+                                                                                         const Tizen::Base::ByteBuffer& buffer)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, !name.IsEmpty(),
+                                          E_INVALID_ARG, "The name is empty.");
+
+       SysTryReturnResult(NID_NET_HTTP, !fileName.IsEmpty(),
+                                          E_INVALID_ARG, "The fileName is empty.");
+
+       SysTryReturnResult(NID_NET_HTTP, buffer.GetRemaining() > 0,
+                                          E_INVALID_ARG, "The buffer is empty.");
+
+       r = AddFilePartByBuffer(name, fileName, buffer, HTTP_FILE_PART_DEFAULT_MIME_TYPE, _HTTP_FILE_PART_DEFAULT_CHARSET);
+
+       return r;
+}
+
+
+result
+_HttpMultipartEntityImpl::AddFilePartByBuffer(const Tizen::Base::String& name, const Tizen::Base::String& fileName,
+                                                                                         const Tizen::Base::ByteBuffer& buffer, const Tizen::Base::String& mimeType,
+                                                                                         const Tizen::Base::String& charset)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, !name.IsEmpty(),
+                                          E_INVALID_ARG, "The name is empty.");
+
+       SysTryReturnResult(NID_NET_HTTP, buffer.GetRemaining() > 0,
+                                          E_INVALID_ARG, "The buffer is empty.");
+
+       SysTryReturnResult(NID_NET_HTTP, !fileName.IsEmpty(),
+                                          E_INVALID_ARG, "The fileName is empty.");
+
+       SysTryReturnResult(NID_NET_HTTP, !mimeType.IsEmpty(),
+                                          E_INVALID_ARG, "The mimeType is empty.");
+
+       unique_ptr<_HttpFilePart> pFilePart(new (std::nothrow) _HttpFilePart());
+       SysTryReturnResult(NID_NET_HTTP, pFilePart != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pFilePart->Construct(name, buffer, fileName, mimeType, charset);
+       r = TransExceptionsExclusive(r, E_INVALID_ARG, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                               "Propagating.");
+
+       r = __pFilePartList->Add(*pFilePart);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       pFilePart.release();
+
+       return r;
+}
+
+_HttpMultipartEntityImpl*
+_HttpMultipartEntityImpl::GetInstance(HttpMultipartEntity& httpMultipartEntity)
+{
+       return httpMultipartEntity.__pHttpMultipartEntityImpl;
+}
+
+const _HttpMultipartEntityImpl*
+_HttpMultipartEntityImpl::GetInstance(const HttpMultipartEntity& httpMultipartEntity)
+{
+       return httpMultipartEntity.__pHttpMultipartEntityImpl;
+}
+
+Tizen::Base::Collection::IList*
+_HttpMultipartEntityImpl::GetStringPartList(void) const
+{
+       return __pStringPartList;
+}
+
+Tizen::Base::Collection::IList*
+_HttpMultipartEntityImpl::GetFilePartList(void) const
+{
+       return __pFilePartList;
+}
+
+Tizen::Base::String
+_HttpMultipartEntityImpl::GetBoundary(void) const
+{
+       return __boundary;
+}
+
+Tizen::Base::String
+_HttpMultipartEntityImpl::GenerateBoundary(void) const
+{
+       String text;
+
+       for (int i = 0; i < _HTTP_MULTIPART_BOUNDARY_LENGTH; i++)
+       {
+               int num = (((double) Math::Rand()) / Math::RAND_VALUE_MAX) * _HTTP_MULTI_PART_BOUNDARY_CHARACTER_SET_LENGTH;
+               text.Append(_HTTP_MULTI_PART_BOUNDARY_CHARACTER_SET[num]);
+       }
+
+       return text;
+}
+
+} } } // Tizen::Net::_HttpMultipartEntityImpl
diff --git a/src/http/FNetHttp_HttpMultipleConnectionInfo.cpp b/src/http/FNetHttp_HttpMultipleConnectionInfo.cpp
new file mode 100644 (file)
index 0000000..5d656aa
--- /dev/null
@@ -0,0 +1,510 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpMultipleConnectionInfo.cpp
+ * @brief              This is the implementation file for _HttpMultipleConnectionInfo class.
+ */
+
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FBaseCol.h>
+#include <FBase_StringConverter.h>
+#include <FBaseRt_EventDispatcher.h>
+#include "FNetHttp_HttpCommon.h"
+#include "FNetHttp_HttpMultipleConnectionInfo.h"
+#include "FNetHttp_HttpTransactionImpl.h"
+#include "FNetHttp_HttpTransactionUserData.h"
+#include "FNetHttp_HttpCurl.h"
+#include "FNetHttp_HttpSocketInfo.h"
+#include "FNetHttp_HttpRequestImpl.h"
+#include "FNetHttp_HttpResponseImpl.h"
+#include "FNetHttp_HttpHeaderImpl.h"
+#include "FNetHttp_HttpTransactionEventArg.h"
+#include "FNetHttp_HttpTransactionEvent.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpMultipleConnectionInfo::_HttpMultipleConnectionInfo()
+       : __refCount(0)
+       , __sessionId(-1)
+       , __pCurlM(null)
+       , __pGMainContext(null)
+       , __remainsConnection(-1)
+       , __isAlreadyClosedSession(false)
+       , __pTimerSource(null)
+       , __cookieFlag(NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL)
+{
+}
+
+_HttpMultipleConnectionInfo::~_HttpMultipleConnectionInfo(void)
+{
+       if (__pTimerSource != null)
+       {
+               int timerId = g_source_get_id(__pTimerSource);
+               g_source_set_callback(__pTimerSource, null, null, null);
+               SysLog(NID_NET_HTTP, "Deleted g_source_destroy(%d)", timerId);
+               g_source_destroy(__pTimerSource);
+               g_source_unref(__pTimerSource);
+               __pTimerSource = null;
+               SysLog(NID_NET_HTTP, "Cancelled the TimerSource[%d] of HttpSession[%d].", timerId, __sessionId);
+       }
+
+       if (__pCurlM != null)
+       {
+               SysLog(NID_NET_HTTP, "Deleted the __pCurlM(%x).", __pCurlM);
+               curl_multi_cleanup(__pCurlM);
+               __pCurlM = null;
+       }
+       __pGMainContext = null;
+
+       SysLog(NID_NET_HTTP, "Deleted the HttpMultipleConnectionInfo of HttpSession[%d]", __sessionId);
+}
+
+result
+_HttpMultipleConnectionInfo::Construct(CURLM* pCurlM, int sessionId, NetHttpCookieFlag cookieFlag)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_NET_HTTP, pCurlM != null,
+                                          E_INVALID_ARG, "pCurlM is null.");
+
+       _EventDispatcher* pEventDispatcher = _EventDispatcher::GetCurrentEventDispatcher();
+       SysTryReturnResult(NID_NET_HTTP, pEventDispatcher != null,
+                                          E_SYSTEM, "GetCurrentEventDispatcher() is null.");
+
+       __pCurlM = pCurlM;
+       SysLog(NID_NET_HTTP, "Created the __pCurlM(%x).", __pCurlM);
+       __pGMainContext = pEventDispatcher->GetGMainContext();
+       __sessionId = sessionId;
+       __cookieFlag = cookieFlag;
+
+       AddRef();
+
+       return r;
+}
+
+void
+_HttpMultipleConnectionInfo::AddRef(void)
+{
+       __refCount++;
+       SysLog(NID_NET_HTTP, "The reference count is %d. HttpSession[%d]", __refCount, __sessionId);
+}
+
+void
+_HttpMultipleConnectionInfo::Release(void)
+{
+       __refCount--;
+       SysLog(NID_NET_HTTP, "The reference count is %d. HttpSession[%d]", __refCount, __sessionId);
+
+       if (__refCount == 0)
+       {
+               SysLog(NID_NET_HTTP, "The reference count is 0. HttpSession[%d]", __sessionId);
+               delete this;
+       }
+}
+
+result
+_HttpMultipleConnectionInfo::SetTimerEvent(int timeout_ms)
+{
+       result r = E_SUCCESS;
+
+       int timerId = -1;
+
+       if (__pTimerSource != null)
+       {
+               timerId = g_source_get_id(__pTimerSource);
+               g_source_set_callback(__pTimerSource, null, null, null);
+               SysLog(NID_NET_HTTP, "Deleted g_source_destroy(%d)", timerId);
+               g_source_destroy(__pTimerSource);
+               g_source_unref(__pTimerSource);
+               __pTimerSource = null;
+               SysLog(NID_NET_HTTP, "Cancelled the TimerSource[%d] of HttpSession[%d].", timerId, __sessionId);
+       }
+
+       if (timeout_ms >= 0)
+       {
+               __pTimerSource = g_timeout_source_new(timeout_ms);
+               g_source_set_callback(__pTimerSource, _HttpMultipleConnectionInfo::OnCurlTimerExpiredEvent, this, null);
+               g_source_attach(__pTimerSource, __pGMainContext);
+
+               timerId = g_source_get_id(__pTimerSource);
+               SysLog(NID_NET_HTTP, "Created the TimerSource[%d] of HttpSession[%d], timeout[%d].", timerId, __sessionId, timeout_ms);
+       }
+       else
+       {
+               SysLog(NID_NET_HTTP, "The value of timeout_ms is less than 0.");
+       }
+
+       return r;
+}
+
+int
+_HttpMultipleConnectionInfo::OnCurlMultiSocketUpdated(CURL* pCurl, curl_socket_t socketFd, int curlAction, void* pUserData,
+                                                                                                         void* pCurlMAssigned)
+{
+       static const char* pCurlSocketActionMessages[] = { "NONE", "IN", "OUT", "INOUT", "REMOVE" };
+       SysLog(NID_NET_HTTP, "Updated Socket(%d), Action(%s).", socketFd, pCurlSocketActionMessages[curlAction]);
+
+       _HttpMultipleConnectionInfo* pHttpMultipleConnectionInfo = static_cast< _HttpMultipleConnectionInfo* >(pUserData);
+       _HttpSocketInfo* pHttpSocketInfo = static_cast< _HttpSocketInfo* >(pCurlMAssigned);
+
+       if (curlAction == CURL_POLL_REMOVE)
+       {
+               SysLog(NID_NET_HTTP, "Removed the Socket(%d).", socketFd);
+               delete pHttpSocketInfo;
+       }
+       else
+       {
+               if (pHttpSocketInfo == null)
+               {
+                       SysLog(NID_NET_HTTP, "Adding the Socket(%d).", socketFd);
+                       pHttpSocketInfo = new (std::nothrow) _HttpSocketInfo();
+                       pHttpSocketInfo->SetSocketEvent(pHttpMultipleConnectionInfo, socketFd, curlAction, false);
+               }
+               else
+               {
+                       SysLog(NID_NET_HTTP, "Changing the Socket(%d). Action %s => %s", socketFd,
+                                  pCurlSocketActionMessages[pHttpSocketInfo->GetSocketAction()], pCurlSocketActionMessages[curlAction]);
+                       pHttpSocketInfo->SetSocketEvent(pHttpMultipleConnectionInfo, socketFd, curlAction, true);
+               }
+       }
+
+       return 0;
+}
+
+int
+_HttpMultipleConnectionInfo::OnCurlMultiTimerChanged(CURLM* pCurlM, long timeout_ms, void* pUserData)
+{
+       result r = E_SUCCESS;
+       SysLog(NID_NET_HTTP, "The timer(%d) of curlM was changed.", timeout_ms);
+
+       _HttpMultipleConnectionInfo* pHttpMultipleConnectionInfo = static_cast< _HttpMultipleConnectionInfo* >(pUserData);
+
+       r = pHttpMultipleConnectionInfo->SetTimerEvent(timeout_ms);
+       if (IsFailed(r))
+       {
+               SysLog(NID_NET_HTTP, "Failed to Set the timer.");
+       }
+
+       return 0;
+}
+
+gboolean
+_HttpMultipleConnectionInfo::OnCurlTimerExpiredEvent(gpointer pUserData)
+{
+       CURLMcode rc;
+       int timerId = -1;
+
+       _HttpMultipleConnectionInfo* pHttpMultipleConnectionInfo = static_cast< _HttpMultipleConnectionInfo* >(pUserData);
+
+       if (pHttpMultipleConnectionInfo->__pTimerSource != null)
+       {
+               timerId = g_source_get_id(pHttpMultipleConnectionInfo->__pTimerSource);
+               g_source_set_callback(pHttpMultipleConnectionInfo->__pTimerSource, null, null, null);
+               SysLog(NID_NET_HTTP, "Deleted g_source_destroy(%d).", timerId);
+               g_source_destroy(pHttpMultipleConnectionInfo->__pTimerSource);
+               g_source_unref(pHttpMultipleConnectionInfo->__pTimerSource);
+               pHttpMultipleConnectionInfo->__pTimerSource = null;
+               SysLog(NID_NET_HTTP, "Expired the TimerSource[%d] of HttpSession[%d].", timerId,
+                          pHttpMultipleConnectionInfo->__sessionId);
+       }
+
+       rc = curl_multi_socket_action(pHttpMultipleConnectionInfo->__pCurlM, CURL_SOCKET_TIMEOUT, 0,
+                                                                &(pHttpMultipleConnectionInfo->__remainsConnection));
+       if (rc == CURLM_OK)
+       {
+               SysLog(NID_NET_HTTP, "CURLM_OK - Called curl_multi_socket_action(), HttpSession[%d]",
+                          pHttpMultipleConnectionInfo->__sessionId);
+       }
+       else
+       {
+               _HttpUtility::PrintCurlMultiErrorCode(rc);
+       }
+
+
+       pHttpMultipleConnectionInfo->CheckCurlMultiStatus();
+
+       return false;
+}
+
+void
+_HttpMultipleConnectionInfo::CheckCurlMultiStatus(void)
+{
+       result r = E_SUCCESS;
+       CURLMsg* pMessage = null;
+       int messageCount = 0;
+       CURL* pCurl = null;
+       char* pUrl = null;
+       CURLcode curlCode = CURLE_OK;
+       _HttpTransactionImpl* pHttpTransactionImpl = null;
+       _HttpTransactionUserData* pHttpTransactionUserData = null;
+
+       SysLog(NID_NET_HTTP, "The remains of connection is %d.", __remainsConnection);
+       pMessage = curl_multi_info_read(__pCurlM, &messageCount);
+       while (pMessage != null)
+       {
+               SysLog(NID_NET_HTTP, "The count of message left is %d.", messageCount);
+               if (pMessage->msg == CURLMSG_DONE)
+               {
+                       pCurl = pMessage->easy_handle;
+                       curlCode = pMessage->data.result;
+                       curl_easy_getinfo(pCurl, CURLINFO_PRIVATE, &pHttpTransactionUserData);
+                       curl_easy_getinfo(pCurl, CURLINFO_EFFECTIVE_URL, &pUrl);
+
+                       if (pHttpTransactionUserData != null)
+                       {
+                               _HttpCurl* pHttpCurl = null;
+                               SysLog(NID_NET_HTTP, "Completed - HttpSession[%d], HttpTransaction[%d],  %s: result(%d) - %s", __sessionId, pHttpTransactionUserData->GetTransactionId(), pUrl, curlCode, pHttpTransactionUserData->GetErrorMessage());
+
+                               if (pHttpTransactionUserData->IsClosedTransaction() == true)
+                               {
+                                       SysLog(NID_NET_HTTP, "The HttpTransaction[%d] is already closed.",
+                                                  pHttpTransactionUserData->GetTransactionId());
+                               }
+                               else
+                               {
+                                       pHttpTransactionImpl = pHttpTransactionUserData->GetHttpTransactionImpl();
+                                       SysAssertf(pHttpTransactionImpl != null, "The pHttpTransactionImpl must not be null.");
+
+                                       _HttpTransactionEvent* pHttpTransactionEvent = pHttpTransactionImpl->GetHttpTransactionEvent();
+                                       SysAssertf(pHttpTransactionEvent != null, "The pHttpTransactionEvent must not be null.");
+
+                                       if (__isAlreadyClosedSession == true)
+                                       {
+                                               //Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_ABORTED)
+                                               pHttpTransactionEvent->FireTransactionAbortedEvent(E_NETWORK_UNAVAILABLE);
+                                               goto FINISH;
+                                       }
+
+                                       //Check if the curlCode is CURLE_OK
+                                       if (curlCode == CURLE_OK)
+                                       {
+                                               int readBodySize = 0;
+
+                                               if (!pHttpTransactionImpl->IsHeaderEventFired())
+                                               {
+                                                       _HttpResponseImpl* pHttpResponseImpl = pHttpTransactionImpl->GetHttpResponseImpl();
+                                                       pCurl = pHttpTransactionImpl->GetHttpCurl()->GetCurl();
+
+                                                       SysLog(NID_NET_HTTP, "The header event will be fired in CheckCurlMStatus()");
+
+                                                       r = pHttpResponseImpl->AddRawHeader(null, 0, true);
+                                                       if (IsFailed(r))
+                                                       {
+                                                               r = E_SYSTEM;
+                                                               SysLogException(NID_NET_HTTP, r, "[%s] Propagated.", GetErrorMessage(r));
+                                                       }
+
+                                                       long httpAuth = _CURL_HTTP_AUTH_NONE;
+                                                       long proxyAuth = _CURL_HTTP_AUTH_NONE;
+                                                       curl_easy_getinfo(pCurl, CURLINFO_HTTPAUTH_AVAIL, &httpAuth);
+                                                       curl_easy_getinfo(pCurl, CURLINFO_PROXYAUTH_AVAIL, &proxyAuth);
+
+                                                       //Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_HEADER_COMPLETED)
+                                                       pHttpTransactionEvent->FireTransactionHeaderCompletedEvent(pHttpResponseImpl->GetHeaderLength(), proxyAuth, httpAuth);
+
+                                                       if (pHttpTransactionUserData->IsClosedTransaction() == true)
+                                                       {
+                                                               SysLog(NID_NET_HTTP, "The HttpTransaction is already closed.");
+                                                               goto FINISH;
+                                                       }
+                                               }
+
+                                               _HttpResponseImpl* pHttpResponseImpl = pHttpTransactionImpl->GetHttpResponseImpl();
+                                               SysTryReturnVoidResult(NID_NET_HTTP, pHttpResponseImpl != null, E_SYSTEM,
+                                                                                          "[E_SYSTEM] An internal error has occurred.");
+
+                                               r = pHttpResponseImpl->AddLastBody(readBodySize);
+
+                                               if (readBodySize != 0)
+                                               {
+                                                       pHttpResponseImpl->SetCurrentBodyLength(readBodySize);
+
+                                                       //Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_READY_TO_READ)
+                                                       pHttpTransactionEvent->FireTransactionReadyToReadEvent(readBodySize);
+
+                                                       if (pHttpTransactionUserData->IsClosedTransaction() == true)
+                                                       {
+                                                               SysLog(NID_NET_HTTP, "The HttpTransaction[%d] is already closed.", pHttpTransactionUserData->GetTransactionId());
+                                                               goto FINISH;
+                                                       }
+
+                                                       if (pHttpTransactionImpl->GetHttpProgressEventListener() != null)
+                                                       {
+                                                               //Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_DOWNLOAD_PROGRESS)
+                                                               pHttpTransactionEvent->FireHttpDownloadInProgressEvent(pHttpResponseImpl->GetCurrentBodyLength(), pHttpResponseImpl->GetTotalBodyLength());
+
+                                                               if (pHttpTransactionUserData->IsClosedTransaction() == true)
+                                                               {
+                                                                       SysLog(NID_NET_HTTP, "The HttpTransaction[%d] is already closed.", pHttpTransactionUserData->GetTransactionId());
+                                                                       goto FINISH;
+                                                               }
+                                                       }
+                                               }
+
+                                               //Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_COMPLETD)
+                                               pHttpTransactionEvent->FireTransactionCompletedEvent();
+                                       }
+                                       else
+                                       {
+                                               SysLog(NID_NET_HTTP, "Exceptional Case");
+
+                                               //Convert the error code from CURLCode
+                                               r = _HttpUtility::ConvertErrorCode(curlCode);
+                                               if (r != E_OPERATION_CANCELED)
+                                               {
+                                                       if (_HttpUtility::IsSslError(curlCode))
+                                                       {
+                                                               IList* pSslList = _HttpUtility::GetSslCertInfoN(pHttpTransactionUserData->GetSocketFd());
+                                                               if (pSslList == null || pSslList->GetCount() == 0)
+                                                               {
+                                                                       if (curlCode == CURLE_SSL_CACERT || curlCode == CURLE_SSL_ISSUER_ERROR || curlCode == CURLE_SSL_CRL_BADFILE || curlCode == CURLE_SSL_CACERT_BADFILE)
+                                                                       {
+                                                                               pHttpTransactionEvent->FireTransactionAbortedEvent(E_SYSTEM);
+                                                                       } else
+                                                                       {
+                                                                               //Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_ABORTED) - E_NO_CERTIFICATE
+                                                                               pHttpTransactionEvent->FireTransactionAbortedEvent(E_NO_CERTIFICATE);
+                                                                       }
+                                                               }
+                                                               else
+                                                               {
+                                                                       IEnumerator* pEnum = null;
+                                                                       _HttpSslInfo* pSSLInfo = null;
+
+                                                                       pEnum = pSslList->GetEnumeratorN();
+                                                                       while (pEnum->MoveNext() == E_SUCCESS)
+                                                                       {
+                                                                               _HttpSslInfo* pTempSSLInfo = dynamic_cast< _HttpSslInfo* >(pEnum->GetCurrent());
+                                                                               SysAssertf(pTempSSLInfo != null, "The pTempSSLInfo must hot be null.");
+
+                                                                               if (pSSLInfo == null || pTempSSLInfo->GetDepth() < pSSLInfo->GetDepth())
+                                                                               {
+                                                                                       pSSLInfo = pTempSSLInfo;
+                                                                                       SysLog(NID_NET_HTTP, "The value of _HttpSslInfo is depth(%d), Subject(%ls).", pSSLInfo->GetDepth(), pSSLInfo->GetServerCert().GetPointer());
+                                                                               }
+                                                                       }
+                                                                       delete pEnum;
+
+                                                                       SysLog(NID_NET_HTTP, "SERVER CERT FAIL(Reason: %ls)", pSSLInfo->GetErrorMessage().GetPointer());
+                                                                       String* pServerCert = new (std::nothrow) String(pSSLInfo->GetServerCert());
+
+                                                                       r = _HttpUtility::RemoveSslCertInfo(pHttpTransactionUserData->GetSocketFd());
+                                                                       if (IsFailed(r))
+                                                                       {
+                                                                               SysLogException(NID_NET_HTTP, E_SYSTEM, "[E_SYSTEM] Failed to remove the server cert.");
+                                                                       }
+
+                                                                       //Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_CERT_VERIFICATION_REQUIRED)
+                                                                       pHttpTransactionEvent->FireTransactionCertVerificationRequiredNEvent(pServerCert);
+
+                                                                       if (pHttpTransactionUserData->IsClosedTransaction() == false && pHttpTransactionImpl->IsAlreadyResumed() == false)
+                                                                       {
+                                                                               SysLog(NID_NET_HTTP, "The HttpTransaction[%d] action(resume or pause) does not set.", pHttpTransactionUserData->GetTransactionId());
+
+                                                                               //Start the timer. (30s)
+                                                                               pHttpTransactionImpl->SetTimer();
+                                                                               SysLog(NID_NET_HTTP, "The timer will be expired if the user does not call the API for resume or pause the transaction.");
+                                                                       }
+                                                               }
+
+                                                               delete pSslList;
+                                                       }
+                                                       else
+                                                       {
+                                                               //Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_ABORTED)
+                                                               pHttpTransactionEvent->FireTransactionAbortedEvent(r);
+                                                       }
+                                               }
+                                               else
+                                               {
+                                                       SysLog(NID_NET_HTTP, "Ignored to fire the event(_HTTP_TRANSACTION_EVENT_TYPE_ABORTED), the result is E_OPERATION_CANCELED.");
+                                               }
+                                       }
+                               }
+
+FINISH:
+                               curl_multi_remove_handle(__pCurlM, pCurl);
+
+                               if (__cookieFlag == NET_HTTP_COOKIE_FLAG_ALWAYS_AUTOMATIC)
+                               {
+                                       curl_easy_setopt(pCurl, CURLOPT_COOKIELIST, "FLUSH");
+                                       SysLog(NID_NET_HTTP, "Flush the cookie data to the file.");
+                               }
+
+                               pHttpCurl = pHttpTransactionUserData->GetHttpCurl();
+                               pHttpCurl->Release();
+
+                               pHttpTransactionUserData->Release();
+
+                               if (__refCount == 1)
+                               {
+                                       this->Release();
+                                       SysLog(NID_NET_HTTP, "The _HttpMultipleConnectionInfo instance was deleted.");
+                                       return;
+                               }
+                               else
+                               {
+                                       this->Release();
+                               }
+                       }
+                       else
+                       {
+                               SysAssertf(false, "The pHttpTransactionUserData must not be null.");
+                       }
+               }
+               //Next while-loop
+               pMessage = curl_multi_info_read(__pCurlM, &messageCount);
+       }
+}
+
+void
+_HttpMultipleConnectionInfo::SetRemainsConnection(int remainsConnection)
+{
+       __remainsConnection = remainsConnection;
+}
+
+int
+_HttpMultipleConnectionInfo::GetRemainsConnection(void) const
+{
+       return __remainsConnection;
+}
+
+void
+_HttpMultipleConnectionInfo::Close(void)
+{
+       __isAlreadyClosedSession = true;
+}
+
+CURLM*
+_HttpMultipleConnectionInfo::GetCurlM(void) const
+{
+       return __pCurlM;
+}
+
+GMainContext*
+_HttpMultipleConnectionInfo::GetGMainContext(void) const
+{
+       return __pGMainContext;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpMultipleConnectionInfo.h b/src/http/FNetHttp_HttpMultipleConnectionInfo.h
new file mode 100644 (file)
index 0000000..880a97b
--- /dev/null
@@ -0,0 +1,96 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpMultipleConnectionInfo.h
+ * @brief              This is the header file for the %_HttpMultipleConnectionInfo class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_MULTIPLE_CONNECTION_INFO_H_
+#define _FNET_HTTP_INTERNAL_HTTP_MULTIPLE_CONNECTION_INFO_H_
+
+#include <curl.h>
+#include <glib.h>
+#include <FOspConfig.h>
+#include <FNetHttpHttpTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+} }
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+class _HttpMultipleConnectionInfo
+       : public Tizen::Base::Object
+{
+
+public:
+       _HttpMultipleConnectionInfo(void);
+
+       virtual ~_HttpMultipleConnectionInfo(void);
+
+       result Construct(CURLM* pCurlM, int sessionId, NetHttpCookieFlag cookieFlag);
+
+       void AddRef(void);
+
+       void Release(void);
+
+public:
+       CURLM* GetCurlM(void) const;
+
+       GMainContext* GetGMainContext(void) const;
+
+       void SetRemainsConnection(int remainsConnection);
+
+       int GetRemainsConnection(void) const;
+
+       void Close(void);
+
+       // Check for completed transfers, and remove their easy handles
+       void CheckCurlMultiStatus(void);
+
+       //Set Timer Event and Run
+       result SetTimerEvent(int ms);
+
+       //by event
+       static gboolean OnCurlTimerExpiredEvent(gpointer data);
+
+       //by callback
+       static int OnCurlMultiSocketUpdated(CURL* e, curl_socket_t s, int what, void* cbp, void* sockp);
+       static int OnCurlMultiTimerChanged(CURLM* multi, long timeout_ms, void* userp);
+
+private:
+       _HttpMultipleConnectionInfo(const _HttpMultipleConnectionInfo& rhs);
+
+       _HttpMultipleConnectionInfo& operator =(const _HttpMultipleConnectionInfo& rhs);
+
+private:
+       int __refCount;
+       int __sessionId;
+       CURLM* __pCurlM;
+       GMainContext* __pGMainContext;
+       int __remainsConnection;
+       bool __isAlreadyClosedSession;
+       GSource* __pTimerSource;
+       NetHttpCookieFlag __cookieFlag;
+
+}; // _HttpMultipleConnectionInfo
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_MULTIPLE_CONNECTION_INFO_H_
diff --git a/src/http/FNetHttp_HttpNetConnectionEventListenerImpl.cpp b/src/http/FNetHttp_HttpNetConnectionEventListenerImpl.cpp
new file mode 100644 (file)
index 0000000..e083ef5
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpNetConnectionEventListenerImpl.cpp
+ * @brief              This is the implementation file for _HttpNetConnectionEventListenerImpl class.
+ */
+
+#include <FBaseString.h>
+#include <FNetNetConnection.h>
+#include <FNetNetConnectionInfo.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNetHttp_HttpSessionImpl.h"
+#include "FNetHttp_HttpNetConnectionEventListenerImpl.h"
+
+using namespace Tizen::Net;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpNetConnectionEventListenerImpl::_HttpNetConnectionEventListenerImpl(_HttpSessionImpl* pHttpSessionImpl)
+{
+       __pHttpSessionImpl = pHttpSessionImpl;
+}
+
+_HttpNetConnectionEventListenerImpl::~_HttpNetConnectionEventListenerImpl(void)
+{
+       __pHttpSessionImpl = null;
+}
+
+void
+_HttpNetConnectionEventListenerImpl::OnNetConnectionStarted(NetConnection& netConnection, result r)
+{
+       SysLog(NID_NET_HTTP, "The network state is started with result(%s).", GetErrorMessage(r));
+}
+
+void
+_HttpNetConnectionEventListenerImpl::OnNetConnectionStopped(NetConnection& netConnection, result r)
+{
+       result res = E_SUCCESS;
+       SysLog(NID_NET_HTTP, "The network state is stopped with result(%s).", GetErrorMessage(r));
+
+       res = __pHttpSessionImpl->Disconnect();
+       if (IsFailed(res))
+       {
+               SysLog(NID_NET_HTTP, "Failed to disconnect the HttpSession.");
+       }
+
+       res = netConnection.RemoveNetConnectionListener(*this);
+       if (IsFailed(res))
+       {
+               SysLog(NID_NET_HTTP, "Failed to remove the NetConnectionListener.");
+       }
+
+       SysLog(NID_NET_HTTP, "Called OnNetConnectionStopped()");
+}
+
+void
+_HttpNetConnectionEventListenerImpl::OnNetConnectionSuspended(NetConnection& netConnection)
+{
+       SysLog(NID_NET_HTTP, "The network state is suspended.");
+}
+
+void
+_HttpNetConnectionEventListenerImpl::OnNetConnectionResumed(NetConnection& netConnection)
+{
+       SysLog(NID_NET_HTTP, "The network state is resumed.");
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpNetConnectionEventListenerImpl.h b/src/http/FNetHttp_HttpNetConnectionEventListenerImpl.h
new file mode 100644 (file)
index 0000000..d489d02
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpNetConnectionEventListenerImpl.h
+ * @brief              This is the header file for %_HttpNetConnectionEventListenerImpl class.
+ *
+ * This header file contains the declarations of _HttpNetConnectionEventListenerImpl class.
+ * The _HttpNetConnectionEventListenerImpl class can call listener's method. So, when an event is occurred,
+ * application can handle it appropriately.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_NET_CONNECTION_EVENT_LISTENER_H_
+#define _FNET_HTTP_INTERNAL_HTTP_NET_CONNECTION_EVENT_LISTENER_H_
+
+#include <FNetINetConnectionEventListener.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpSessionImpl;
+/**
+* @class       _HttpNetConnectionEventListenerImpl
+* @brief       _HttpNetConnectionEventListenerImpl class implements the INetConnectionEventListener interface.
+*
+* @since 2.1
+*
+*/
+
+class _HttpNetConnectionEventListenerImpl
+       : public Tizen::Net::INetConnectionEventListener
+{
+
+public:
+       _HttpNetConnectionEventListenerImpl(_HttpSessionImpl* pHttpSessionImpl);
+
+       virtual ~_HttpNetConnectionEventListenerImpl(void);
+
+       void OnNetConnectionStarted(NetConnection& netConnection, result r);
+
+       void OnNetConnectionStopped(NetConnection& netConnection, result r);
+
+       void OnNetConnectionSuspended(NetConnection& netConnection);
+
+       void OnNetConnectionResumed(NetConnection& netConnection);
+
+private:
+       _HttpNetConnectionEventListenerImpl(const _HttpNetConnectionEventListenerImpl& rhs);
+
+       _HttpNetConnectionEventListenerImpl& operator =(const _HttpNetConnectionEventListenerImpl& rhs);
+
+private:
+       _HttpSessionImpl* __pHttpSessionImpl;
+
+}; // _HttpNetConnectionEventListenerImpl
+
+} } } // Tizen::Net::Http
+
+#endif // _FNET_HTTP_INTERNAL_HTTP_NET_CONNECTION_EVENT_LISTENER_H_
diff --git a/src/http/FNetHttp_HttpRequestImpl.cpp b/src/http/FNetHttp_HttpRequestImpl.cpp
new file mode 100644 (file)
index 0000000..8af311c
--- /dev/null
@@ -0,0 +1,707 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpRequestImpl.cpp
+ * @brief              This is the implementation file for _HttpRequestImpl class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FNetNetTypes.h>
+#include <FNetHttpHttpHeader.h>
+#include <FNetHttpHttpRequest.h>
+#include <FBaseColIEnumerator.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpCommon.h"
+#include "FNetHttp_HttpRequestImpl.h"
+#include "FNetHttp_HttpSessionImpl.h"
+#include "FNetHttp_HttpTransactionImpl.h"
+#include "FNetHttp_HttpHeaderImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpRequestImpl::_HttpRequestImpl(HttpRequest* pRequest)
+       : __method(NET_HTTP_METHOD_GET)
+       , __httpVersion(HTTP_VERSION_1_1)
+       , __cookieFlag(NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL)
+       , __recommendedSize(0)
+       , __isFirstChunk(false)
+       , __isLastChunk(false)
+       , __isReceivedTransactionReadyToWriteEvent(false)
+       , __pIHttpEntity(null)
+       , __pSendingBuffer(null)
+       , __pHttpTransactionImpl(null)
+       , __pHttpRequest(pRequest)
+{
+}
+
+_HttpRequestImpl::~_HttpRequestImpl(void)
+{
+       __pIHttpEntity = null;
+       __pSendingBuffer = null;
+       __pHttpTransactionImpl = null;
+       __pHttpRequest = null;
+}
+
+result
+_HttpRequestImpl::Construct(const _HttpTransactionImpl& httpTransactionImpl, const HttpHeader* pCommonHeader)
+{
+       result r = E_SUCCESS;
+
+       __pHttpTransactionImpl = const_cast< _HttpTransactionImpl* >(&httpTransactionImpl);
+
+       unique_ptr<HttpHeader> pHeader(new (std::nothrow) HttpHeader(pCommonHeader));
+       r = GetLastResult();
+       SysTryReturnResult(NID_NET_HTTP, pHeader != null, r,
+                                "Propagating.");
+
+       // Queue construction
+       r = __pHttpRequest->_bodyQueue.Construct();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                                          "Memory allocation failed.");
+
+       _HttpSessionImpl* pHttpSessionImpl = httpTransactionImpl.GetHttpSessioinImpl();
+       SysTryReturnResult(NID_NET_HTTP, pHttpSessionImpl != null,
+                                          E_SYSTEM, "HttpSession must not be null.");
+
+       __cookieFlag = pHttpSessionImpl->GetHttpCookieFlag();
+       __pHttpRequest->_pHeader = pHeader.release();
+
+       // Total Length of the body initialization
+       __pHttpRequest->_totalLen = 0;
+
+       return r;
+}
+
+HttpRequest*
+_HttpRequestImpl::CreateHttpRequestN(void)
+{
+       return new (std::nothrow) HttpRequest();
+}
+
+void
+_HttpRequestImpl::DeleteHttpRequest(HttpRequest* pHttpRequest)
+{
+       delete pHttpRequest;
+}
+
+bool
+_HttpRequestImpl::IsEmptyBody(void) const
+{
+       int countOfCurrentBuffer = __pHttpRequest->_bodyQueue.GetCount();
+       if (countOfCurrentBuffer == 0)
+       {
+               return true;
+       }
+       else
+       {
+               return false;
+       }
+}
+
+unsigned int
+_HttpRequestImpl::GetTotalBodyLength(void) const
+{
+       return __pHttpRequest->_totalLen;
+}
+
+void
+_HttpRequestImpl::SetRecommendedSize(int recommendedSize)
+{
+       __recommendedSize = recommendedSize;
+}
+
+void
+_HttpRequestImpl::SetReceivedTransactionReadyToWriteEvent(bool isReceviedEvent)
+{
+       __isReceivedTransactionReadyToWriteEvent = isReceviedEvent;
+}
+
+void
+_HttpRequestImpl::SetFirstChunkBody(bool isFirstChunk)
+{
+       __isFirstChunk = isFirstChunk;
+}
+
+bool
+_HttpRequestImpl::IsFirstChunkBody(void) const
+{
+       return __isFirstChunk;
+}
+
+bool
+_HttpRequestImpl::IsLastChunkBody(void) const
+{
+       return __isLastChunk;
+}
+
+bool
+_HttpRequestImpl::HasCookie(void) const
+{
+       bool rs = !(__cookieValue.IsEmpty());
+
+       return rs;
+}
+
+void
+_HttpRequestImpl::SetSendingBuffer(ByteBuffer* pBuffer)
+{
+       __pSendingBuffer = pBuffer;
+}
+
+ByteBuffer*
+_HttpRequestImpl::GetSendingBuffer(void) const
+{
+       return __pSendingBuffer;
+}
+
+Tizen::Base::String
+_HttpRequestImpl::GetMethodName(void) const
+{
+       return __methodName;
+}
+
+result
+_HttpRequestImpl::SetMethod(const NetHttpMethod method)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __pHttpTransactionImpl->IsSubmitted() == false,
+                                          E_INVALID_STATE, "HttpRequest is already submitted.");
+
+       SysTryReturnResult(NID_NET_HTTP,
+                                          ((method >= NET_HTTP_METHOD_GET) &&
+                                               (method <= NET_HTTP_METHOD_TRACE)) || method == NET_HTTP_METHOD_POST || method == NET_HTTP_METHOD_PUT || method == NET_HTTP_METHOD_CONNECT,
+                                          E_INVALID_ARG, "The method is invalid.");
+
+       switch (method)
+       {
+       case NET_HTTP_METHOD_GET:
+               __methodName = L"GET";
+               break;
+
+       case NET_HTTP_METHOD_OPTIONS:
+               __methodName = L"OPTIONS";
+               break;
+
+       case NET_HTTP_METHOD_HEAD:
+               __methodName = L"HEAD";
+               break;
+
+       case NET_HTTP_METHOD_DELETE:
+               __methodName = L"DELETE";
+               break;
+
+       case NET_HTTP_METHOD_TRACE:
+               __methodName = L"TRACE";
+               break;
+
+       case NET_HTTP_METHOD_POST:
+               __methodName = L"POST";
+               break;
+
+       case NET_HTTP_METHOD_PUT:
+               __methodName = L"PUT";
+               break;
+
+       case NET_HTTP_METHOD_CONNECT:
+               __methodName = L"CONNECT";
+               break;
+       }
+
+       __method = method;
+
+       SysLog(NID_NET_HTTP, "The method is %ls.", __methodName.GetPointer());
+
+       return r;
+}
+
+result
+_HttpRequestImpl::SetCustomMethod(const String& method)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __pHttpTransactionImpl->IsSubmitted() == false,
+                                          E_INVALID_STATE, "HttpRequest is already submitted.");
+
+       SysTryReturnResult(NID_NET_HTTP, method.IsEmpty() == false,
+                                          E_INVALID_ARG, "The method is empty.");
+
+       __customMethodName = method;
+       __methodName = method;
+
+       SysLog(NID_NET_HTTP, "The custom method is %ls.", method.GetPointer());
+
+       return r;
+}
+
+result
+_HttpRequestImpl::SetVersion(HttpVersion version)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __pHttpTransactionImpl->IsSubmitted() == false,
+                                          E_INVALID_STATE, "HttpRequest is already submitted.");
+
+       SysTryReturnResult(NID_NET_HTTP, version == HTTP_VERSION_1_0 || version == HTTP_VERSION_1_1,
+                                          E_INVALID_ARG, "The version is invalid.");
+
+       __httpVersion = version;
+
+       SysLog(NID_NET_HTTP, "The http version is %s.", version == HTTP_VERSION_1_0 ? "HTTP_VERSION_1_0": "HTTP_VERSION_1_1");
+
+       return r;
+}
+
+result
+_HttpRequestImpl::SetUri(const String& uri)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __pHttpTransactionImpl->IsSubmitted() == false,
+                                          E_INVALID_STATE, "HttpRequest is already submitted.");
+
+       SysTryReturnResult(NID_NET_HTTP, uri.GetLength() > 0,
+                                          E_INVALID_ARG, "The uri is empty");
+
+       __uri = uri;
+
+       SysLog(NID_NET_HTTP, "The uri is %ls.", uri.GetPointer());
+
+       return r;
+}
+
+result
+_HttpRequestImpl::WriteBody(const Tizen::Base::ByteBuffer& body)
+{
+       result r = E_SUCCESS;
+
+       unique_ptr<ByteBuffer> pBodyBuffer;
+       int srcBodySize = body.GetRemaining();
+
+       SysTryReturnResult(NID_NET_HTTP, srcBodySize >= 0,
+                                          E_INVALID_ARG, "The remaining of the buffer MUST be greater than or equal to 0.");
+
+       //Before submitting.
+       if (__pHttpTransactionImpl->IsSubmitted() == false)
+       {
+               pBodyBuffer.reset(new (std::nothrow) ByteBuffer());
+               SysTryReturnResult(NID_NET_HTTP, pBodyBuffer != null, E_OUT_OF_MEMORY,
+                                                          "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = pBodyBuffer->Construct(body);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                       "Failed to construct the ByteBuffer.");
+
+               r = __pHttpRequest->_bodyQueue.Enqueue(*pBodyBuffer);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                       "Failed to enqueue the ByteBuffer to the queue.");
+
+               __pHttpRequest->_totalLen += srcBodySize;
+               __isFirstChunk = true;
+
+               SysLog(NID_NET_HTTP, "Enqueue the body(%d) to queue. Total(%ld)", srcBodySize, __pHttpRequest->_totalLen);
+
+               //After submitting in OnTransactionReadyToWrite().
+       }
+       else if (__pHttpTransactionImpl->IsSubmitted() == true && __pHttpTransactionImpl->IsTransactionReadyToWriteEanbled() == true)
+       {
+               SysTryReturnResult(NID_NET_HTTP, __method == NET_HTTP_METHOD_POST || __method == NET_HTTP_METHOD_PUT, E_INVALID_STATE,
+                                       "Failed to construct the ByteBuffer.");
+
+               SysTryReturnResult(NID_NET_HTTP, __isReceivedTransactionReadyToWriteEvent == true, E_INVALID_STATE,
+                                       "OnTransactionReadyToWrite event not received yet.");
+
+               SysTryReturnResult(NID_NET_HTTP, __recommendedSize >= srcBodySize, E_OUT_OF_RANGE,
+                                       "The buffer size(%d) MUST be smaller than the recommended size(%d).", srcBodySize, __recommendedSize);
+
+               pBodyBuffer.reset(new (std::nothrow) ByteBuffer());
+               SysTryReturnResult(NID_NET_HTTP, pBodyBuffer != null, E_OUT_OF_MEMORY,
+                                                          "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = pBodyBuffer->Construct(body);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                       "Failed to construct the ByteBuffer.");
+
+               r = __pHttpRequest->_bodyQueue.Enqueue(*pBodyBuffer);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                       "Failed to enqueue the ByteBuffer to the queue.");
+
+               __pHttpRequest->_totalLen += srcBodySize;
+               __isFirstChunk = false;
+
+               SysLog(NID_NET_HTTP, "Enqueue the body(%d) to queue.(OnTransactionReadyToWrite). Total(%ld)", srcBodySize, __pHttpRequest->_totalLen);
+       }
+
+       pBodyBuffer.release();
+
+       return r;
+}
+
+result
+_HttpRequestImpl::SetEntity(IHttpEntity& entity)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __pHttpTransactionImpl->IsSubmitted() == false,
+                                          E_INVALID_STATE, "HttpTransaction is already submitted.");
+
+       SysTryReturnResult(NID_NET_HTTP, __pHttpRequest->_totalLen == 0,
+                                          E_INVALID_STATE, "The body(buffer) is already set to the HttpRequest.");
+
+       String keyName;
+       String contentLength(L"0");
+       unique_ptr<ByteBuffer> pByteBuffer;
+       long long length = 0;
+       _HttpHeaderImpl* pHeaderImpl = null;
+
+       __pIHttpEntity = &entity;
+
+       pHeaderImpl = _HttpHeaderImpl::GetInstance(*__pHttpRequest->_pHeader);
+
+       //ToDo test.. chunked mode for entity.
+       __pHttpTransactionImpl->EnableTransactionReadyToWrite();
+
+       if (pHeaderImpl->HasHeader(_HTTP_CONTENT_TYPE_HEADER_NAME, keyName))
+       {
+               pHeaderImpl->RemoveField(keyName);
+               SysLog(NID_NET_HTTP, "The Content-Type header was removed.");
+       }
+
+       if (pHeaderImpl->HasHeader(_HTTP_CONTENT_LENGTH_HEADER_NAME, keyName))
+       {
+               pHeaderImpl->RemoveField(keyName);
+               SysLog(NID_NET_HTTP, "The Content-Length header was removed.");
+       }
+
+       r = pHeaderImpl->AddField(_HTTP_CONTENT_TYPE_HEADER_NAME, entity.GetContentType());
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       length = entity.GetContentLength();
+       SysTryReturnResult(NID_NET_HTTP, length != _HTTP_INVALID_CONTENT_LENGTH, E_INVALID_ARG,
+                               "The content-length of entity is invalid.");
+
+       contentLength = LongLong::ToString(length);
+
+       r = pHeaderImpl->AddField(_HTTP_CONTENT_LENGTH_HEADER_NAME, contentLength);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       SysLog(NID_NET_HTTP, "The Content-Type is %ls.", entity.GetContentType().GetPointer());
+       SysLog(NID_NET_HTTP, "The Content-Length is %ls.", contentLength.GetPointer());
+
+       if (entity.HasNextData())
+       {
+               //generates the form data from IHttpEntity.
+               pByteBuffer.reset(entity.GetNextDataN(length));
+               r = GetLastResult();
+               SysTryReturnResult(NID_NET_HTTP, pByteBuffer != null, r,
+                                       "Failed to generate form data from the IHttpEntity.");
+
+               r = WriteBody(*pByteBuffer);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                       "Failed to write the byte buffer.");
+       }
+
+       SysLog(NID_NET_HTTP, "Completed to set the entity.");
+
+       return r;
+}
+
+HttpHeader*
+_HttpRequestImpl::GetHeader(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET_HTTP, __pHttpRequest->_pHeader != null, null, E_INVALID_HEADER,
+                                "[E_INVALID_HEADER] HttpHeader must not be null.");
+
+       return __pHttpRequest->_pHeader;
+}
+
+NetHttpMethod
+_HttpRequestImpl::GetMethod() const
+{
+       ClearLastResult();
+
+       return __method;
+}
+
+result
+_HttpRequestImpl::GetCustomMethod(String& method) const
+{
+       result r = E_SUCCESS;
+
+       method = __customMethodName;
+
+       return r;
+}
+
+HttpVersion
+_HttpRequestImpl::GetVersion(void) const
+{
+       ClearLastResult();
+
+       return __httpVersion;
+}
+
+result
+_HttpRequestImpl::GetUri(String& uri) const
+{
+       result r = E_SUCCESS;
+
+       uri = __uri;
+
+       return r;
+}
+
+Tizen::Base::ByteBuffer*
+_HttpRequestImpl::ReadBodyN()
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       unique_ptr<ByteBuffer> pResultBuffer;
+       ByteBuffer* pByteBuffer = null;
+       int resultBufferLen = 0;
+       int countOfCurrentBuffer = 0;
+
+       countOfCurrentBuffer = __pHttpRequest->_bodyQueue.GetCount();
+       if (countOfCurrentBuffer <= 0)
+       {
+               r = E_EMPTY_BODY;
+               SetLastResult(r);
+               SysLog(NID_NET_HTTP, "No more data to read.");
+               return null;
+       }
+
+       pResultBuffer.reset(new (std::nothrow) ByteBuffer());
+       SysTryReturn(NID_NET_HTTP, pResultBuffer != null, null, E_OUT_OF_MEMORY,
+                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pResultBuffer->Construct(__pHttpRequest->_totalLen);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, E_OUT_OF_MEMORY,
+                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       for (int i = 0; i < countOfCurrentBuffer; i++)
+       {
+               int bufferSize = 0;
+
+               pByteBuffer = dynamic_cast< ByteBuffer* >(__pHttpRequest->_bodyQueue.Dequeue());
+               SysTryReturn(NID_NET_HTTP, pByteBuffer != null, null, E_EMPTY_BODY,
+                                       "[E_EMPTY_BODY] The buffer of the body is empty.");
+
+               bufferSize = pByteBuffer->GetRemaining();
+
+               r = pResultBuffer->CopyFrom(*pByteBuffer);
+               SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, E_OUT_OF_RANGE,
+                                       "[E_OUT_OF_RANGE] Failed to copy the buffer to new buffer.");
+
+               delete pByteBuffer;
+
+               if (bufferSize == 0)
+               {
+                       SysLog(NID_NET_HTTP, "Write the last chunk(Empty Body).");
+                       __isLastChunk = true;
+                       break;
+               }
+       }
+
+       pResultBuffer->Flip();
+       resultBufferLen = pResultBuffer->GetRemaining();
+       __pHttpRequest->_totalLen = __pHttpRequest->_totalLen - resultBufferLen;
+
+       SysLog(NID_NET_HTTP, "Read the body(%d), Remained Body(%d).", resultBufferLen, __pHttpRequest->_totalLen);
+
+       return pResultBuffer.release();
+}
+
+Tizen::Base::ByteBuffer*
+_HttpRequestImpl::ReadAllBodyN(void) const
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       unique_ptr<ByteBuffer> pResultBuffer;
+       ByteBuffer* pByteBuffer = null;
+       int resultBufferLen = 0;
+
+       unique_ptr<IEnumerator> pEnum;
+       int countOfCurrentBuffer = 0;
+
+       countOfCurrentBuffer = __pHttpRequest->_bodyQueue.GetCount();
+       if (countOfCurrentBuffer <= 0)
+       {
+               r = E_EMPTY_BODY;
+               SetLastResult(r);
+               SysLog(NID_NET_HTTP, "No more data to read.");
+               return null;
+       }
+
+       pEnum.reset(__pHttpRequest->_bodyQueue.GetEnumeratorN());
+       SysTryReturn(NID_NET_HTTP, pEnum != null, null, E_OUT_OF_MEMORY,
+                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       pResultBuffer.reset(new (std::nothrow) ByteBuffer());
+       SysTryReturn(NID_NET_HTTP, pResultBuffer != null, null, E_OUT_OF_MEMORY,
+                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pResultBuffer->Construct(__pHttpRequest->_totalLen);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, E_OUT_OF_MEMORY,
+                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               int bufferSize = 0;
+
+               pByteBuffer = dynamic_cast< ByteBuffer* >(pEnum->GetCurrent());
+               SysTryReturn(NID_NET_HTTP, pByteBuffer != null, null, E_EMPTY_BODY,
+                                       "[E_EMPTY_BODY] The buffer of the body is empty.");
+
+               bufferSize = pByteBuffer->GetRemaining();
+
+               r = pResultBuffer->CopyFrom(*pByteBuffer);
+               SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, E_OUT_OF_RANGE,
+                                       "[E_OUT_OF_RANGE] Failed to copy the buffer to new buffer.");
+
+               pByteBuffer->Flip();
+       }
+
+       pResultBuffer->Flip();
+       resultBufferLen = pResultBuffer->GetRemaining();
+
+       SysLog(NID_NET_HTTP, "Read the body(%d).", resultBufferLen);
+
+       return pResultBuffer.release();
+}
+
+IHttpEntity*
+_HttpRequestImpl::GetEntity(void) const
+{
+       return __pIHttpEntity;
+}
+
+bool
+_HttpRequestImpl::HasNextData(void)
+{
+       bool rs = false;
+       rs = __pIHttpEntity->HasNextData();
+
+       return rs;
+}
+
+ByteBuffer*
+_HttpRequestImpl::GetNextDataN(int recommendedSize)
+{
+       ByteBuffer* pBuffer = null;
+       pBuffer = __pIHttpEntity->GetNextDataN(recommendedSize);
+
+       return pBuffer;
+}
+
+result
+_HttpRequestImpl::SetCookie(const Tizen::Base::String& cookieString)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, cookieString.IsEmpty() == false,
+                                          E_INVALID_ARG, "The input argument is empty.");
+
+       SysTryReturnResult(NID_NET_HTTP, __cookieFlag == NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL,
+                                          E_INVALID_STATE, "The cookieFlag of HttpSession is invalid.");
+
+       SysTryReturnResult(NID_NET_HTTP, __pHttpTransactionImpl->IsSubmitted() == false,
+                                          E_INVALID_STATE, "HttpTransaction is already submitted.");
+
+       String lowerString;
+       String subCookieString;
+
+       r = cookieString.ToLower(lowerString);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          E_INVALID_ARG, "The input argument is invalid.");
+
+       SysTryReturnResult(NID_NET_HTTP, lowerString.StartsWith(L"cookie:", 0),
+                                          E_INVALID_ARG, "Cookie string doesn't start with Cookie:");
+
+       r = cookieString.SubString(_COOKIE_PREFIX_LENGTH, subCookieString);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          E_INVALID_ARG, "Failed to get the sub cookie string.");
+
+       subCookieString.Trim();
+
+       __cookieValue = subCookieString;
+
+       SysLog(NID_NET_HTTP, "The cookie string is %ls.", cookieString.GetPointer());
+
+       return r;
+}
+
+String
+_HttpRequestImpl::GetCookie(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET_HTTP, __cookieValue.IsEmpty() == false, L"", E_INVALID_STATE,
+                                "[E_INVALID_STATE] Cookies is empty.");
+
+       SysTryReturn(NID_NET_HTTP, __cookieFlag == NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL, L"", E_INVALID_STATE,
+                                "[E_INVALID_STATE] The cookieFlag of HttpSession is invalid.");
+
+       return __cookieValue;
+}
+
+result
+_HttpRequestImpl::SetAcceptEncoding(const Tizen::Base::String& encoding)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __pHttpTransactionImpl->IsSubmitted() == false, E_INVALID_STATE, "HttpRequest is already submitted.");
+       SysTryReturnResult(NID_NET_HTTP, encoding.IsEmpty() == false, E_INVALID_ARG, "The input argument is empty.");
+
+       __encoding = encoding;
+
+       return r;
+}
+
+Tizen::Base::String
+_HttpRequestImpl::GetAcceptEncoding(void) const
+{
+       return __encoding;
+}
+
+_HttpRequestImpl*
+_HttpRequestImpl::GetInstance(HttpRequest& httpRequest)
+{
+       return httpRequest.__pHttpRequestImpl;
+}
+
+const _HttpRequestImpl*
+_HttpRequestImpl::GetInstance(const HttpRequest& httpRequest)
+{
+       return httpRequest.__pHttpRequestImpl;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpResponseImpl.cpp b/src/http/FNetHttp_HttpResponseImpl.cpp
new file mode 100644 (file)
index 0000000..e5667a8
--- /dev/null
@@ -0,0 +1,925 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpResponseImpl.cpp
+ * @brief              This is the implementation file for _HttpResponseImpl class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FTextAsciiEncoding.h>
+#include <FTextLatin1Encoding.h>
+#include <FBaseUtilStringTokenizer.h>
+#include <FBaseInteger.h>
+#include <FNetHttpHttpHeader.h>
+#include <FNetHttpHttpCookie.h>
+#include <FNetHttpHttpResponse.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FNetHttp_HttpCommon.h"
+#include "FNetHttp_HttpDeleter.h"
+#include "FNetHttp_HttpResponseImpl.h"
+#include "FNetHttp_HttpTransactionImpl.h"
+#include "FNetHttp_HttpHeaderImpl.h"
+#include "FNetHttp_HttpCookieImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Text;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpResponseImpl::_HttpResponseImpl(HttpResponse* pResponse)
+       : __isReceivedHeader(false)
+       , __isReceivedBody(false)
+       , __statusCode(0)
+       , __statusCodeType(NET_HTTP_STATUS_UNDEFINED)
+       , __readHeaderLength(-1)
+       , __pReadHeaderBuffer(null)
+       , __readBodyLength(0)
+       , __totalBodyLength(0)
+       , __isCurrentReceivedBody(false)
+       , __pReadBodyBuffuer(null)
+       , __pCookieList(null)
+       , __pHttpTransactionImpl(null)
+       , __pHttpResponse(pResponse)
+{
+}
+
+_HttpResponseImpl::~_HttpResponseImpl(void)
+{
+       if (__pReadHeaderBuffer != null)
+       {
+               delete __pReadHeaderBuffer;
+               __pReadHeaderBuffer = null;
+       }
+
+       if (__pReadBodyBuffuer != null)
+       {
+               delete __pReadBodyBuffuer;
+               __pReadBodyBuffuer = null;
+       }
+
+       if (__pCookieList != null)
+       {
+               __pCookieList->RemoveAll(true);
+               delete __pCookieList;
+               __pCookieList = null;
+       }
+
+       __pHttpTransactionImpl = null;
+       __pHttpResponse = null;
+}
+
+result
+_HttpResponseImpl::Construct(const _HttpTransactionImpl& httpTransactinImpl)
+{
+       result r = E_SUCCESS;
+
+       __pHttpTransactionImpl = const_cast< _HttpTransactionImpl* >(&httpTransactinImpl);
+
+       unique_ptr<HttpHeader> pHeader(new (std::nothrow) HttpHeader());
+       SysTryReturnResult(NID_NET_HTTP, pHeader, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       r = __pHttpResponse->_bodyQueue.Construct();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                                          "Memory allocation failed.");
+
+       unique_ptr<ByteBuffer> pReadHeaderBuffer(new (std::nothrow) ByteBuffer());
+       SysTryReturnResult(NID_NET_HTTP, pReadHeaderBuffer, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       r = pReadHeaderBuffer->Construct(_HTTP_DEFAULT_HEADER_SIZE);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       unique_ptr<ByteBuffer> pReadBodyBuffuer(new (std::nothrow) ByteBuffer());
+       SysTryReturnResult(NID_NET_HTTP, pReadBodyBuffuer, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       r = pReadBodyBuffuer->Construct(_MAX_HTTP_BODY_SIZE);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+
+       __pHttpResponse->_pHeader = pHeader.release();
+       __pReadHeaderBuffer = pReadHeaderBuffer.release();
+       __pReadBodyBuffuer = pReadBodyBuffuer.release();
+
+       SysLog(NID_NET_HTTP, "The _HttpResponseImpl instance was constructed.");
+
+       return r;
+}
+
+HttpResponse*
+_HttpResponseImpl::CreateHttpResponseN(void)
+{
+       HttpResponse* pHttpResponse = new (std::nothrow) HttpResponse();
+       SysTryReturn(NID_NET_HTTP, pHttpResponse, null, E_OUT_OF_MEMORY,
+                                "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       return pHttpResponse;
+}
+
+void
+_HttpResponseImpl::DeleteHttpResponse(HttpResponse* pHttpResponse)
+{
+       delete pHttpResponse;
+}
+
+NetHttpStatusCode
+_HttpResponseImpl::GetStatusCode(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET_HTTP, __isReceivedHeader, NET_HTTP_STATUS_UNDEFINED, E_INVALID_STATE,
+                                "[E_INVALID_STATE] HttpHeader is not received yet.");
+
+       SysTryReturn(NID_NET_HTTP, __statusCodeType != NET_HTTP_STATUS_UNDEFINED, NET_HTTP_STATUS_UNDEFINED, E_INVALID_DATA,
+                                "[E_INVALID_DATA] Status code is undefined.");
+
+       SysLog(NID_NET_HTTP, "The status code is %d.", static_cast< int >(__statusCodeType));
+
+       return __statusCodeType;
+}
+
+int
+_HttpResponseImpl::GetHttpStatusCode(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET_HTTP, __isReceivedHeader, INVALID_HANDLE, E_INVALID_STATE,
+                                "[E_INVALID_STATE] HttpHeader is not received yet.");
+
+       SysLog(NID_NET_HTTP, "The status code is %d.", __statusCode);
+
+       return __statusCode;
+}
+
+String
+_HttpResponseImpl::GetStatusText(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET_HTTP, __isReceivedHeader, L"", E_INVALID_STATE,
+                                "[E_INVALID_STATE] HttpHeader is not received yet.");
+
+       return __statusText;
+}
+
+String
+_HttpResponseImpl::GetVersion(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET_HTTP, __isReceivedHeader, L"", E_INVALID_STATE,
+                                "[E_INVALID_STATE] HttpHeader is not received yet.");
+
+       return __version;
+}
+
+
+HttpHeader*
+_HttpResponseImpl::GetHeader(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET_HTTP, __pHttpResponse->_pHeader != null, null, E_INVALID_HEADER,
+                                "[E_INVALID_HEADER] HttpHeader is null.");
+
+       return __pHttpResponse->_pHeader;
+}
+
+
+Tizen::Base::ByteBuffer*
+_HttpResponseImpl::ReadBodyN(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       unique_ptr<ByteBuffer> pResultBuffer;
+       ByteBuffer* pByteBuffer = null;
+       int resultBufferLen = 0;
+       int countOfCurrentBuffer = 0;
+
+       SysTryReturn(NID_NET_HTTP, __isReceivedBody == true, null, E_INVALID_STATE,
+                                "[E_INVALID_STATE]  Body is not received yet.");
+
+       SysTryReturn(NID_NET_HTTP, __pHttpResponse->_totalLen > 0, null, E_EMPTY_BODY,
+                                "[E_EMPTY_BODY]  No more data to read.");
+
+       countOfCurrentBuffer = __pHttpResponse->_bodyQueue.GetCount();
+       SysTryReturn(NID_NET_HTTP, countOfCurrentBuffer > 0, null, E_EMPTY_BODY,
+                                "[E_EMPTY_BODY] No more data to read.");
+
+       pResultBuffer.reset(new (std::nothrow) ByteBuffer());
+       SysTryReturn(NID_NET_HTTP, pResultBuffer, null, E_OUT_OF_MEMORY,
+                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pResultBuffer->Construct(__pHttpResponse->_totalLen);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, E_OUT_OF_MEMORY,
+                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       for (int i = 0; i < countOfCurrentBuffer; i++)
+       {
+               pByteBuffer = static_cast< ByteBuffer* >(__pHttpResponse->_bodyQueue.Dequeue());
+               SysTryReturn(NID_NET_HTTP, pByteBuffer != null, null, E_EMPTY_BODY,
+                                       "[E_EMPTY_BODY] The buffer of the body is empty.");
+
+               r = pResultBuffer->CopyFrom(*pByteBuffer);
+               SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, E_OUT_OF_RANGE,
+                                       "[E_OUT_OF_RANGE] Failed to copy the buffer to new buffer.");
+
+               delete pByteBuffer;
+       }
+
+       pResultBuffer->Flip();
+       resultBufferLen = pResultBuffer->GetRemaining();
+       __pHttpResponse->_totalLen = __pHttpResponse->_totalLen - resultBufferLen;
+
+       SysLog(NID_NET_HTTP, "Read the body(%d).", resultBufferLen);
+
+       return pResultBuffer.release();
+}
+
+result
+_HttpResponseImpl::SetStatusCode(NetHttpStatusCode statusCode)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, (statusCode >= NET_HTTP_STATUS_CONTINUE) &&
+                                          (statusCode <= NET_HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED),
+                                          E_INVALID_ARG, "StatusCode argument is invalid.");
+
+       __statusCodeType = statusCode;
+       SysLog(NID_NET_HTTP, "Set status code(%d).", statusCode);
+
+       return r;
+}
+
+result
+_HttpResponseImpl::SetHttpStatusCode(int statusCode)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, statusCode >= NET_HTTP_STATUS_CONTINUE,
+                                          E_INVALID_ARG, "The input argument is invalid.");
+
+       __statusCode = statusCode;
+       SysLog(NID_NET_HTTP, "Set status code(%d).", statusCode);
+
+       return r;
+}
+
+result
+_HttpResponseImpl::SetStatusText(const String& statusText)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, statusText.GetLength() > 0,
+                                          E_INVALID_ARG, "The input argument is empty.");
+
+       __statusText = statusText;
+
+       return r;
+}
+
+
+result
+_HttpResponseImpl::SetVersion(const String& httpVersion)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, httpVersion.GetLength() > 0,
+                                          E_INVALID_ARG, "The input argument is empty.");
+
+       __version = httpVersion;
+
+       return r;
+}
+
+
+result
+_HttpResponseImpl::WriteBody(const ByteBuffer& body)
+{
+       result r = E_SUCCESS;
+
+       r = __pHttpResponse->_bodyQueue.Enqueue(body);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          E_INVALID_ARG, "Failed to enqueue the body to the buffer");
+
+       return r;
+}
+
+result
+_HttpResponseImpl::Read(const int headerLen, const int bodyLen, int& rcvHeaderLen, int& rcvBodyLen)
+{
+       result r = E_SUCCESS;
+
+       //Read the Header from the HttpResponse
+       if (headerLen > 0 && bodyLen == 0)
+       {
+               r = ParseHeader(rcvHeaderLen);
+               r = TransExceptionsExclusive(r, E_INVALID_HEADER, E_OUT_OF_MEMORY);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                  r, "Propagating.");
+
+               HttpHeader* pHeader = GetHeader();
+               SysTryReturnResult(NID_NET_HTTP, pHeader != null,
+                                                  E_INVALID_HEADER, "The header is an empty.");
+
+               r = SetCookie(pHeader);
+               SysTryReturnResult(NID_NET_HTTP, r != E_OUT_OF_MEMORY,
+                                                  E_OUT_OF_MEMORY, "Propagating.");
+               if (IsFailed(r))
+               {
+                       SysLog(NID_NET_HTTP, "Failed to SetCookie()");
+               }
+
+               //Read the Body from the HttpResponse
+       }
+       else if (headerLen == 0 && bodyLen > 0)
+       {
+               rcvBodyLen = bodyLen;
+       }
+
+       return r;
+}
+
+Tizen::Base::Collection::IList*
+_HttpResponseImpl::GetCookies(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET_HTTP, __pCookieList != null && __pCookieList->GetCount() > 0, null, E_INVALID_STATE,
+                                "[E_INVALID_STATE] Cookie list is empty.");
+
+       return __pCookieList;
+}
+
+_HttpResponseImpl*
+_HttpResponseImpl::GetInstance(HttpResponse& httpResponse)
+{
+       return httpResponse.__pHttpResponseImpl;
+}
+
+const _HttpResponseImpl*
+_HttpResponseImpl::GetInstance(const HttpResponse& httpResponse)
+{
+       return httpResponse.__pHttpResponseImpl;
+}
+
+result
+_HttpResponseImpl::SetCookie(HttpHeader* pHeader)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, pHeader != null,
+                                          E_INVALID_STATE, "The header is null.");
+
+       IEnumerator* pValueEnum = null;
+       unique_ptr<HttpCookie, _HttpCookieDeleter> pCookie;
+       String cookieFieldName;
+       bool isFoundCookieHeader = false;
+
+       _HttpHeaderImpl* pHeaderImpl = _HttpHeaderImpl::GetInstance(*pHeader);
+       SysTryReturnResult(NID_NET_HTTP, pHeaderImpl != null,
+                                          E_INVALID_STATE, "The header must not be null.");
+
+       __pCookieList = new (std::nothrow) LinkedList();
+       SysTryReturnResult(NID_NET_HTTP, __pCookieList != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       isFoundCookieHeader = pHeaderImpl->HasHeader(_HTTP_SET_COOKIE_HEADER_NAME, cookieFieldName);
+       if (isFoundCookieHeader)
+       {
+               pValueEnum = pHeaderImpl->GetFieldValuesN(cookieFieldName);
+       }
+
+       if (pValueEnum != null)
+       {
+               while (pValueEnum->MoveNext() == E_SUCCESS)
+               {
+                       String* pCookieLine = static_cast< String* >(pValueEnum->GetCurrent());
+                       if (pCookieLine != null && pCookieLine->IsEmpty() == false)
+                       {
+                               pCookie.reset(_HttpCookieImpl::CreateHttpCookieN());
+                               SysTryReturnResult(NID_NET_HTTP, pCookie != null,
+                                                                  E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                               _HttpCookieImpl* pCookieImpl = _HttpCookieImpl::GetInstance(*pCookie);
+                               SysTryReturnResult(NID_NET_HTTP, pCookieImpl != null, E_OUT_OF_MEMORY,
+                                                       "Memory allocation failed.");
+
+                               //Parse the cookie.
+                               SysLog(NID_NET_HTTP, "The cookie line is %ls.", pCookieLine->GetPointer());
+                               StringTokenizer headerToken(*pCookieLine, _HTTP_SET_COOKIE_DELIMITER);
+
+                               while (headerToken.HasMoreTokens())
+                               {
+                                       String cookieField;
+                                       String cookieFlagName;
+                                       String cookieFlagValue;
+
+                                       int index = 0;
+                                       r = headerToken.GetNextToken(cookieField);
+                                       if (r == E_SUCCESS && cookieField.IsEmpty() == false)
+                                       {
+                                               r = cookieField.IndexOf(_HTTP_SET_COOKIE_FLAG_DELIMITER, 0, index);
+                                               if (r == E_SUCCESS && index >= 0)
+                                               {
+                                                       r = cookieField.SubString(0, index, cookieFlagName);
+                                                       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_INVALID_STATE,
+                                                                               "The cookie is invalid.");
+
+                                                       r = cookieField.SubString(index + 1, cookieFlagValue);
+
+                                               }
+                                               else    //only cookieFlag
+                                               {
+                                                       cookieFlagName = cookieField;
+                                               }
+
+                                               cookieFlagName.Trim();
+
+                                               SysLog(NID_NET_HTTP, "The name of cookie flag is %ls, the value of cookie flag is %ls.",
+                                                          cookieFlagName.GetPointer(), cookieFlagValue.GetPointer());
+
+                                               if (cookieFlagName.Equals(_HTTP_COOKIE_COMMENT_NAME, false))
+                                               {
+                                                       pCookieImpl->SetComment(cookieFlagValue);
+                                                       SysLog(NID_NET_HTTP, "Set %ls as value(%ls).",
+                                                                  _HTTP_COOKIE_COMMENT_NAME, cookieFlagValue.GetPointer());
+
+                                               }
+                                               else if (cookieFlagName.Equals(_HTTP_COOKIE_COMMENTURL_NAME, false))
+                                               {
+                                                       pCookieImpl->SetCommentUrl(cookieFlagValue);
+                                                       SysLog(NID_NET_HTTP, "Set %ls as value(%ls).",
+                                                                  _HTTP_COOKIE_COMMENTURL_NAME, cookieFlagValue.GetPointer());
+
+                                               }
+                                               else if (cookieFlagName.Equals(_HTTP_COOKIE_DISCARD_NAME, false))
+                                               {
+                                                       if (cookieFlagValue.IsEmpty() == false && cookieFlagValue.Equals(L"TRUE", false))
+                                                               pCookieImpl->SetDiscard(true);
+
+                                                       SysLog(NID_NET_HTTP, "Set %ls as value(%ls).",
+                                                                  _HTTP_COOKIE_DISCARD_NAME, cookieFlagValue.GetPointer());
+
+                                               }
+                                               else if (cookieFlagName.Equals(_HTTP_COOKIE_DOMAIN_NAME, false))
+                                               {
+                                                       pCookieImpl->SetDomain(cookieFlagValue);
+                                                       SysLog(NID_NET_HTTP, "Set %ls as value(%ls).",
+                                                                  _HTTP_COOKIE_DOMAIN_NAME, cookieFlagValue.GetPointer());
+
+                                               }
+                                               else if (cookieFlagName.Equals(_HTTP_COOKIE_MAX_AGE_NAME, false))
+                                               {
+                                                       if (cookieFlagValue.IsEmpty() == false)
+                                                       {
+                                                               int rs = -1;
+                                                               r = Integer::Parse(cookieFlagValue, rs);
+                                                               pCookieImpl->SetMaxAge(rs);
+                                                               SysLog(NID_NET_HTTP, "Set %ls as value(%d).", _HTTP_COOKIE_MAX_AGE_NAME, rs);
+                                                       }
+
+                                               }
+                                               else if (cookieFlagName.Equals(_HTTP_COOKIE_PATH_NAME, false))
+                                               {
+                                                       pCookieImpl->SetPath(cookieFlagValue);
+                                                       SysLog(NID_NET_HTTP, "Set %ls as value(%ls).",
+                                                                  _HTTP_COOKIE_PATH_NAME, cookieFlagValue.GetPointer());
+
+                                               }
+                                               else if (cookieFlagName.Equals(_HTTP_COOKIE_PORT_NAME, false))
+                                               {
+                                                       pCookieImpl->SetPorts(cookieFlagValue);
+                                                       SysLog(NID_NET_HTTP, "Set %ls as value(%ls).",
+                                                                  _HTTP_COOKIE_PORT_NAME, cookieFlagValue.GetPointer());
+
+                                               }
+                                               else if (cookieFlagName.Equals(_HTTP_COOKIE_SECURE_NAME, false))
+                                               {
+                                                       if (cookieFlagValue.IsEmpty() == false && cookieFlagValue.Equals(L"TRUE", false))
+                                                               pCookieImpl->SetSecure(true);
+
+                                                       SysLog(NID_NET_HTTP, "Set %ls as value(%ls).",
+                                                                  _HTTP_COOKIE_SECURE_NAME, cookieFlagValue.GetPointer());
+
+                                               }
+                                               else if (cookieFlagName.Equals(_HTTP_COOKIE_VERSION_NAME, false))
+                                               {
+                                                       pCookieImpl->SetVersion(cookieFlagValue);
+                                                       SysLog(NID_NET_HTTP, "Set %ls as value(%ls).",
+                                                                  _HTTP_COOKIE_VERSION_NAME, cookieFlagValue.GetPointer());
+
+                                               }
+                                               else if (cookieFlagName.Equals(_HTTP_COOKIE_EXPIRES_NAME, false))
+                                               {
+                                                       pCookieImpl->SetExpires(cookieFlagValue);
+                                                       SysLog(NID_NET_HTTP, "Set %ls as value(%ls).",
+                                                                  _HTTP_COOKIE_EXPIRES_NAME, cookieFlagValue.GetPointer());
+
+                                               }
+                                               else if (cookieFlagName.Equals(_HTTP_COOKIE_HTTP_ONLY, false))
+                                               {
+                                                       pCookieImpl->SetHttpOnly(true);
+                                                       SysLog(NID_NET_HTTP, "Set %ls as value(true).", _HTTP_COOKIE_HTTP_ONLY);
+
+                                               }
+                                               else
+                                               {
+                                                       if (pCookieImpl->GetCookieName().IsEmpty() == true)
+                                                       {
+                                                               pCookieImpl->SetCookieName(cookieFlagName);
+                                                               pCookieImpl->SetCookieValue(cookieFlagValue);
+                                                               SysLog(NID_NET_HTTP, "Set Cookie - Name: %ls, Value: %ls",
+                                                                          cookieFlagName.GetPointer(), cookieFlagValue.GetPointer());
+                                                       }
+                                                       else
+                                                       {
+                                                               SysLog(NID_NET_HTTP, "Invalid Cookie format. Cookie name already exist.: %ls, Value: %ls",
+                                                                          cookieFlagName.GetPointer(), cookieFlagValue.GetPointer());
+                                                       }
+                                               }
+                                       }
+
+                               } //end while(headerToken.HasMoreTokens())
+
+                               r = __pCookieList->Add(*pCookie);
+                               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                                                       "Memory allocation failed.");
+
+                               pCookie.release();
+
+                       } //end if(pCookie != null)
+               }
+
+               delete pValueEnum;
+
+       }
+       else
+       {
+               SysLog(NID_NET_HTTP, "The cookie was not exist in HttpHeader.");
+       }
+
+       return r;
+}
+
+int
+_HttpResponseImpl::GetHeaderLength(void) const
+{
+       return __readHeaderLength;
+}
+
+result
+_HttpResponseImpl::ParseHeader(int& recevHeaderLen)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __pReadHeaderBuffer != null,
+                                          E_INVALID_HEADER, "The header of the response is empty.");
+
+       String rawHeaders;
+       String tempRawHeaders;
+       Latin1Encoding latin1Encoding;
+       String delim = L" ";
+       int numerOfHeaders = 0;
+       int indexOfLastHttpStatusLine = -1;
+
+       HttpHeader* pHeader = GetHeader();
+       SysTryReturnResult(NID_NET_HTTP, pHeader != null,
+                                          E_INVALID_HEADER, "The header is empty.");
+
+       _HttpHeaderImpl* pHeaderImpl = _HttpHeaderImpl::GetInstance(*pHeader);
+       SysTryReturnResult(NID_NET_HTTP, pHeaderImpl != null,
+                                          E_INVALID_HEADER, "The header is empty.");
+
+       //Encoding the header String.
+       r = latin1Encoding.GetString(*__pReadHeaderBuffer, tempRawHeaders);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          E_INVALID_HEADER, "Failed to encode the header.");
+
+       //Get the last http status lines.
+       r = tempRawHeaders.LastIndexOf(L"\r\n\r\nHTTP/", tempRawHeaders.GetLength() - 1, indexOfLastHttpStatusLine);
+
+       //Check if tempRawHeaders is included multiple headers.
+       if (r == E_SUCCESS)
+       {
+               SysLog(NID_NET_HTTP, "Received multiple headers.");
+               r = tempRawHeaders.SubString(indexOfLastHttpStatusLine + String("\r\n\r\n").GetLength(), rawHeaders);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                  E_INVALID_HEADER, "The header is invalid.");
+       } else
+       {
+               rawHeaders = tempRawHeaders;
+       }
+
+       recevHeaderLen = rawHeaders.GetLength() + 1;  //add the null terminated character.
+
+       StringTokenizer headerToken(rawHeaders, _HTTP_CARRIAGE_RETURN_LINE_FEED);
+
+       while (headerToken.HasMoreTokens())
+       {
+               String headerLine;
+               String headerName;
+               String headerValue;
+               int index = 0;
+
+               r = headerToken.GetNextToken(headerLine);
+               if (headerLine.IsEmpty())
+               {
+                       SysLog(NID_NET_HTTP, "The headerLine is empty.");
+                       continue;
+               }
+               numerOfHeaders++;
+
+               SysLog(NID_NET_HTTP, "The header line is %ls.", headerLine.GetPointer());
+
+               //First Line, Status Code Status Value (ex> HTTP/1.1 200 OK)
+               if (numerOfHeaders == 1)
+               {
+                       headerLine.Trim();
+
+                       char version[3];
+                       version[0] = '\0';
+                       int statusCode = -1;
+                       char statusText[headerLine.GetLength()];
+                       statusText[0] = '\0';
+
+                       char* pHeaderLine = _StringConverter::CopyToCharArrayN(headerLine);
+                       SysTryReturnResult(NID_NET_HTTP, pHeaderLine != null,
+                                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                       //Parse HTTP First line.
+                       sscanf(pHeaderLine, "HTTP/%s %d %s", version, &statusCode, statusText);
+                       delete[] pHeaderLine;
+
+                       SysLog(NID_NET_HTTP, "Version: %s, StatusCode: %d, StatusText: %s", version, statusCode, statusText);
+
+                       __version = version;
+                       __statusCode = statusCode;
+                       __statusCodeType = static_cast< NetHttpStatusCode >(statusCode);
+                       __statusText = statusText;
+
+                       SysTryReturnResult(NID_NET_HTTP, !__version.IsEmpty() && statusCode != -1 && !__statusText.IsEmpty(),
+                                                          E_INVALID_HEADER, "The header is invalid.");
+
+                       continue;
+               }
+
+               r = headerLine.IndexOf(L":", 0, index);
+               if (r != E_SUCCESS || index == -1)
+               {
+                       SysLog(NID_NET_HTTP, "The delimiter(:) is empty.");
+                       continue;
+               }
+
+               //Header Name
+               r = headerLine.SubString(0, index, headerName);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                  E_INVALID_HEADER, "The header name is invalid.");
+
+               //if value is empty.
+               if (index + 1 == headerLine.GetLength())
+               {
+                       SysLog(NID_NET_HTTP, "The header value is empty.");
+                       headerValue.Clear();
+               }
+               else
+               {
+                       //Header Value
+                       r = headerLine.SubString(index + 1, headerValue);
+                       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                          E_INVALID_HEADER, "The header value is invalid.");
+
+                       headerValue.Trim();
+               }
+
+               SysLog(NID_NET_HTTP, "The name is %ls, the value is %ls.", headerName.GetPointer(), headerValue.GetPointer());
+               r = pHeaderImpl->AddField(headerName, headerValue);
+               if (IsFailed(r))
+               {
+                       if (r == E_OBJ_ALREADY_EXIST)
+                       {
+                               SysLog(NID_NET_HTTP, "The header name(%ls) is already exist.", headerName.GetPointer());
+                               r = E_SUCCESS;
+                       }
+                       else
+                       {
+                               SysLogException(NID_NET_HTTP, r, "[%s] Failed to add the header.", GetErrorMessage(r));
+                       }
+               }
+       }
+
+       SysLog(NID_NET_HTTP, "Completed to parse the header of the response.");
+       return r;
+}
+
+result
+_HttpResponseImpl::AddRawHeader(const byte* pHeaderLine, int headerLineSize, bool isTerminatedHeader)
+{
+       result r = E_SUCCESS;
+
+       if (headerLineSize > 0)
+       {
+               r = _HttpUtility::AddHeaderBytesToBuffer(&__pReadHeaderBuffer, pHeaderLine, headerLineSize);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                  E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       if (isTerminatedHeader)
+       {
+               byte nullTerminated = 0;
+               r = _HttpUtility::AddHeaderBytesToBuffer(&__pReadHeaderBuffer, &nullTerminated, 1);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                  E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               __isReceivedHeader = true;
+               __pReadHeaderBuffer->Flip();
+               __readHeaderLength = __pReadHeaderBuffer->GetRemaining();
+               SysLog(NID_NET_HTTP, "Completed to receive the header of the response.");
+       }
+
+       return r;
+}
+
+result
+_HttpResponseImpl::AddRawBody(const byte* pBody, int bodySize, bool& isFullBuffer, int& readBodySize)
+{
+       result r = E_SUCCESS;
+
+       unique_ptr<ByteBuffer> pFullBodyBuffer;
+
+       int bufferRemainSize = __pReadBodyBuffuer->GetRemaining();
+
+       __isReceivedBody = true;
+
+       //Keep the data into the ByteBuffer.
+       if (bufferRemainSize >= bodySize)
+       {
+               r = __pReadBodyBuffuer->SetArray(pBody, 0, bodySize);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                  E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               isFullBuffer = false;
+               return r;
+       }
+
+       //The new ByteBuffer is created when the Buffer is full.
+       __pReadBodyBuffuer->Flip();
+       isFullBuffer = true;
+       readBodySize = __pReadBodyBuffuer->GetRemaining();
+
+       pFullBodyBuffer.reset(new (std::nothrow) ByteBuffer());
+       SysTryReturnResult(NID_NET_HTTP, pFullBodyBuffer != null, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       r = pFullBodyBuffer->Construct(readBodySize);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       r = pFullBodyBuffer->CopyFrom(*__pReadBodyBuffuer);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       pFullBodyBuffer->Flip();
+
+       r = WriteBody(*pFullBodyBuffer);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                               "Failed to enqueue the body to the buffer");
+
+       pFullBodyBuffer.release();
+
+       __pHttpResponse->_totalLen += readBodySize;
+       SysLog(NID_NET_HTTP, "Current received body length: %d", __pHttpResponse->_totalLen);
+
+       //Reset the ByteBuffer.
+       __pReadBodyBuffuer->Clear();
+
+       bufferRemainSize = __pReadBodyBuffuer->GetRemaining();
+       SysAssert(bufferRemainSize >= bodySize)
+
+       r = __pReadBodyBuffuer->SetArray(pBody, 0, bodySize);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_SYSTEM,
+                               "Failed to set the body to the buffer");
+
+       SysLog(NID_NET_HTTP, "Completed to add the body of the response to queue.");
+
+       return r;
+}
+
+result
+_HttpResponseImpl::AddLastBody(int& readBodySize)
+{
+       result r = E_SUCCESS;
+       unique_ptr<ByteBuffer> pFullBodyBuffer;
+       __pReadBodyBuffuer->Flip();
+
+       readBodySize = __pReadBodyBuffuer->GetRemaining();
+
+       if (readBodySize > 0)
+       {
+               pFullBodyBuffer.reset(new (std::nothrow) ByteBuffer());
+               SysTryReturnResult(NID_NET_HTTP, pFullBodyBuffer, E_OUT_OF_MEMORY,
+                                       "Memory allocation failed.");
+
+               r = pFullBodyBuffer->Construct(readBodySize);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                                       "Memory allocation failed.");
+
+               r = pFullBodyBuffer->CopyFrom(*__pReadBodyBuffuer);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                                       "Memory allocation failed.");
+
+               pFullBodyBuffer->Flip();
+
+               r = WriteBody(*pFullBodyBuffer);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                       "Failed to enqueue the body to the buffer");
+
+               pFullBodyBuffer.release();
+
+               __pHttpResponse->_totalLen += readBodySize;
+               SysLog(NID_NET_HTTP, "Current received body length is %d.", __pHttpResponse->_totalLen);
+
+               SysLog(NID_NET_HTTP, "Completed to add the last body of the response to queue.");
+       }
+       else
+       {
+               SysLog(NID_NET_HTTP, "The header is only exist(Empty Body).");
+       }
+
+       return r;
+}
+
+void
+_HttpResponseImpl::SetCurrentBodyLength(int readBodyLength)
+{
+       __readBodyLength += readBodyLength;
+}
+
+int
+_HttpResponseImpl::GetCurrentBodyLength(void) const
+{
+       return __readBodyLength;
+}
+void
+_HttpResponseImpl::SetTotalBodyLength(int totalBodyLength)
+{
+       __totalBodyLength = totalBodyLength;
+}
+
+int
+_HttpResponseImpl::GetTotalBodyLength(void) const
+{
+       return __totalBodyLength;
+}
+
+void
+_HttpResponseImpl::SetReceivedBody(bool flag)
+{
+       __isCurrentReceivedBody = flag;
+}
+
+bool
+_HttpResponseImpl::IsHeaderReceived(void) const
+{
+       return __isReceivedHeader;
+}
+
+bool
+_HttpResponseImpl::IsBodyReceived(void) const
+{
+       return __isReceivedBody;
+}
+
+bool
+_HttpResponseImpl::IsCurrentBodyReceived(void) const
+{
+       return __isCurrentReceivedBody;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpSessionImpl.cpp b/src/http/FNetHttp_HttpSessionImpl.cpp
new file mode 100644 (file)
index 0000000..072e7c8
--- /dev/null
@@ -0,0 +1,1335 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpSessionImpl.cpp
+ * @brief              This is the implementation file for _HttpSessionImpl class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FBaseUtilStringUtil.h>
+#include <FIoFile.h>
+#include <FNetNetConnection.h>
+#include <FNetManagedNetConnection.h>
+#include <FNetNetConnectionManager.h>
+#include <FNetHttpHttpSession.h>
+#include <FNetHttpHttpAuthentication.h>
+#include <FBaseSysLog.h>
+#include <FBaseRtMutex.h>
+#include <FBaseRtMutexGuard.h>
+#include <FBase_StringConverter.h>
+#include <FBaseRt_EventDispatcher.h>
+#include "FNet_ManagedNetConnectionImpl.h"
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNet_NetConnectionImpl.h"
+#include "FNet_NetConnectionManagerImpl.h"
+#include "FNetHttp_HttpCommon.h"
+#include "FNetHttp_HttpDeleter.h"
+#include "FNetHttp_HttpSessionImpl.h"
+#include "FNetHttp_HttpMultipleConnectionInfo.h"
+#include "FNetHttp_HttpTransactionImpl.h"
+#include "FNetHttp_HttpCurl.h"
+#include "FNetHttp_HttpRequestImpl.h"
+#include "FNetHttp_HttpResponseImpl.h"
+#include "FNetHttp_HttpHeaderImpl.h"
+#include "FNetHttp_HttpAuthenticationImpl.h"
+#include "FNetHttp_HttpCookieStorageManagerImpl.h"
+#include "FNetHttp_HttpTransactionEventArg.h"
+#include "FNetHttp_HttpTransactionEvent.h"
+#include "FNetHttp_HttpNetConnectionEventListenerImpl.h"
+#include "FNetHttp_HttpManagedNetConnectionEventListenerImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+using namespace Tizen::Net;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+int _HttpSessionImpl::__generatedSessionId = -1;
+int _HttpSessionImpl::__countOfSessions = 0;
+
+_HttpSessionImpl::_HttpSessionImpl(HttpSession* pHttpSession)
+       : __sessionId(-1)
+       , __pHttpSession(pHttpSession)
+       , __isConstructed(false)
+       , __sessionMode(NET_HTTP_SESSION_MODE_NORMAL)
+       , __pProxyAddress(null)
+       , __pCommonHeader(null)
+       , __cookieFlag(NET_HTTP_COOKIE_FLAG_NONE)
+       , __countOfTransaction(0)
+       , __isSecure(false)
+       , __isValid(false)
+       , __isClosed(false)
+       , __isAutoRedirectionEnabled(false)
+       , __isAlreadyResumed(false)
+       , __pHttpMultipleConnectionInfo(null)
+       , __pCookieStorageMgr(null)
+       , __pNetConnection(null)
+       , __pNetConnectionListener(null)
+       , __pManagedNetConnection(null)
+       , __pManagedNetConnectionListener(null)
+{
+}
+
+_HttpSessionImpl::~_HttpSessionImpl(void)
+{
+       SysLog(NID_NET_HTTP, "The HttpSession[%d] instance will be deleted.", __sessionId);
+
+       Dispose();
+
+       if (__pProxyAddress != null)
+       {
+               delete __pProxyAddress;
+               __pProxyAddress = null;
+       }
+
+       if (__pCommonHeader != null)
+       {
+               _HttpHeaderImpl::GetInstance(*__pCommonHeader)->RemoveAll();
+               delete __pCommonHeader;
+               __pCommonHeader = null;
+       }
+
+       if (__pHttpMultipleConnectionInfo != null)
+       {
+               __pHttpMultipleConnectionInfo->Release();
+       }
+
+       if (__pCookieStorageMgr != null)
+       {
+               _HttpCookieStorageManagerImpl::DeleteHttpCookieStorageManager(__pCookieStorageMgr);
+               __pCookieStorageMgr = null;
+       }
+
+       if (__pNetConnection != null)
+       {
+               delete __pNetConnection;
+               __pNetConnection = null;
+       }
+
+       if (__pNetConnectionListener != null)
+       {
+               delete __pNetConnectionListener;
+               __pNetConnectionListener = null;
+       }
+
+       if (__pManagedNetConnection != null)
+       {
+               delete __pManagedNetConnection;
+               __pManagedNetConnection = null;
+       }
+
+       if (__pManagedNetConnectionListener != null)
+       {
+               delete __pManagedNetConnectionListener;
+               __pManagedNetConnectionListener = null;
+       }
+
+       __isConstructed = false;
+       __sessionMode = NET_HTTP_SESSION_MODE_NORMAL;
+
+       __countOfTransaction = 0;
+       __isSecure = false;
+       __isValid = false;
+       __isClosed = false;
+
+       SysLog(NID_NET_HTTP, "The HttpSession[%d] instance was deleted.", __sessionId);
+
+       __sessionId = -1;
+}
+
+String
+_HttpSessionImpl_GetSessionModeAsString(NetHttpSessionMode sessionMode)
+{
+       switch (sessionMode)
+       {
+       case NET_HTTP_SESSION_MODE_NORMAL:
+               return String(L"NET_HTTP_SESSION_MODE_NORMAL");
+
+       case NET_HTTP_SESSION_MODE_PIPELINING:
+               return String(L"NET_HTTP_SESSION_MODE_PIPELINING");
+
+       case NET_HTTP_SESSION_MODE_MULTIPLE_HOST:
+               return String(L"NET_HTTP_SESSION_MODE_MULTIPLE_HOST");
+
+       default:
+               return String(L"Invalid SessionMode");
+       }
+}
+
+String
+_HttpSessionImpl_GetCookieFlagAsString(NetHttpCookieFlag flag)
+{
+       switch (flag)
+       {
+       case NET_HTTP_COOKIE_FLAG_NONE:
+               return String(L"NET_HTTP_COOKIE_FLAG_NONE");
+
+       case NET_HTTP_COOKIE_FLAG_ALWAYS_AUTOMATIC:
+               return String(L"NET_HTTP_COOKIE_FLAG_ALWAYS_AUTOMATIC");
+
+       case NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL:
+               return String(L"NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL");
+
+       default:
+               return String(L"Invalid CookieFlag");
+       }
+}
+
+result
+_HttpSessionImpl::Construct(NetHttpSessionMode sessionMode, const String* pProxyAddr, const String& hostAddr,
+                                                       const HttpHeader* pCommonHeader,
+                                                       NetHttpCookieFlag flag)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __isConstructed == false,
+                                          E_INVALID_STATE, "Already constructed.");
+
+       SysTryReturnResult(NID_NET_HTTP, sessionMode == NET_HTTP_SESSION_MODE_NORMAL || sessionMode == NET_HTTP_SESSION_MODE_PIPELINING || sessionMode == NET_HTTP_SESSION_MODE_MULTIPLE_HOST,
+                                          E_INVALID_ARG, "Invalid SessionMode.");
+
+       if (sessionMode != NET_HTTP_SESSION_MODE_MULTIPLE_HOST)
+       {
+               SysTryReturnResult(NID_NET_HTTP, hostAddr.GetLength() > 0,
+                                                  E_INVALID_ARG, "Invalid hostAddr.");
+
+       }
+       SysTryReturnResult(NID_NET_HTTP, NET_HTTP_COOKIE_FLAG_NONE == flag || NET_HTTP_COOKIE_FLAG_ALWAYS_AUTOMATIC == flag || NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL == flag,
+                                          E_INVALID_ARG, "Invalid cookie flag.");
+
+       SysLog(NID_NET_HTTP, "There are currently opened sessions[%d] in the Application.", __countOfSessions);
+
+       _HttpUtility::InitializeHttp();
+
+       Mutex* pHttpMutex = _HttpUtility::GetHttpMutex();
+
+       MutexGuard locked(*pHttpMutex);
+       SysTryReturnResult(NID_NET_HTTP, locked.IsLocked(), E_SYSTEM,
+                       "Failed to lock mutex.");
+
+       SysTryReturnResult(NID_NET_HTTP, __countOfSessions < _MAX_HTTP_SESSIONS_PER_APPID_PER_PROTOCOL, E_MAX_EXCEEDED,
+                       "The number of currently opened sessions have exceeded the maximum limit(%d).", _MAX_HTTP_SESSIONS_PER_APPID_PER_PROTOCOL);
+
+       r = locked.Unlock();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_SYSTEM,
+                       "Failed to unlock mutex.");
+
+       SysLog(NID_NET_HTTP, "[ManagedNetConnection] NetHttpSessionMode : %ls, Host Address : %ls, NetHttpCookieFlag : %ls",
+                  _HttpSessionImpl_GetSessionModeAsString(sessionMode).GetPointer(), hostAddr.GetPointer(), _HttpSessionImpl_GetCookieFlagAsString(flag).GetPointer());
+
+       _ManagedNetConnectionImpl* pManagedNetConnectionImpl = null;
+       NetConnectionState connState = NET_CONNECTION_STATE_NONE;
+       String tempAddress;
+       String proxyAddressOfManagedMode;
+       bool hasProtocolScheme = false;
+       Uri* pHostUri = null;
+       Uri* pProxyUri = null;
+       CURLM* pCurlM = null;
+       __sessionMode = sessionMode;
+       unique_ptr<_HttpManagedNetConnectionEventListenerImpl> pManagedNetConnectionListener;
+       unique_ptr<ManagedNetConnection> pManagedNetConnection;
+       unique_ptr<String> pProxyAddress;
+       unique_ptr<HttpHeader> pHeader;
+       unique_ptr<_HttpMultipleConnectionInfo> pHttpMultipleConnectionInfo;
+       unique_ptr<HttpCookieStorageManager, _HttpCookieStorageManagerDeleter> pCookieStorageMgr;
+
+       NetConnectionManager netConnectionManager;
+
+       r = netConnectionManager.Construct();
+       r = TransExceptionsExclusive(r, E_INVALID_CONNECTION, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          r, "Failed to construct the connection manager.");
+
+       pManagedNetConnection.reset(netConnectionManager.GetManagedNetConnectionN());
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          E_INVALID_CONNECTION, "Failed to get the managed network connection.");
+
+       pManagedNetConnectionImpl = _ManagedNetConnectionImpl::GetInstance(*pManagedNetConnection);
+       SysTryReturnResult(NID_NET_HTTP, pManagedNetConnectionImpl != null,
+                                          E_INVALID_CONNECTION, "Failed to get the managed network connection.");
+
+       pManagedNetConnectionListener.reset(new (std::nothrow) _HttpManagedNetConnectionEventListenerImpl(this));
+       SysTryReturnResult(NID_NET_HTTP, pManagedNetConnectionListener != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pManagedNetConnection->SetManagedNetConnectionEventListener(pManagedNetConnectionListener.get());
+       r = TransExceptionsExclusive(r, E_INVALID_CONNECTION, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          r, "Failed to set the listener of managed network.");
+
+       if (_NetConnectionManagerImpl::IsDefaultMode() != true)
+       {
+               SysLog(NID_NET_HTTP, "[Preference Mode] Current network is specific network preference Mode.");
+
+               r = pManagedNetConnectionImpl->Start();
+               r = TransExceptionsExclusive(r, E_INVALID_CONNECTION, E_OUT_OF_MEMORY);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Failed to start the managed network connection.");
+
+               connState = pManagedNetConnectionImpl->GetConnectionState();
+               if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+               {
+                       pManagedNetConnectionListener->SetReceivedEvent(true);
+
+                       const NetConnectionInfo* pConnectionInfo = pManagedNetConnectionImpl->GetNetConnectionInfo();
+                       SysTryReturnResult(NID_NET_HTTP, pConnectionInfo != null,
+                                                          E_INVALID_CONNECTION, "Failed to get NetConnectionInfo.");
+
+                       const _NetConnectionInfoImpl* pConnectionInfoImpl = _NetConnectionInfoImpl::GetInstance(*pConnectionInfo);
+                       SysTryReturnResult(NID_NET_HTTP, pConnectionInfoImpl != null,
+                                                          E_INVALID_CONNECTION, "Failed to get NetConnectionInfo.");
+
+                       proxyAddressOfManagedMode = pConnectionInfoImpl->GetProxyAddress();
+                       __deviceName = pConnectionInfoImpl->GetDeviceName();
+                       SysLog(NID_NET_HTTP, "[Preference Mode] Network is already started. The device name is %ls, the system proxy address is %ls.", __deviceName.GetPointer(), proxyAddressOfManagedMode.GetPointer());
+               }
+       }
+       else
+       {
+               pManagedNetConnectionListener->SetReceivedEvent(true);
+               proxyAddressOfManagedMode = _NetConnectionManagerImpl::GetProxyAddress();
+               SysLog(NID_NET_HTTP, "[Default Mode] The current network is managed network preference Mode. The system proxy address is %ls.", proxyAddressOfManagedMode.GetPointer());
+       }
+
+       if (pProxyAddr != null)
+       {
+               SysLog(NID_NET_HTTP, "The proxy address is %ls.", pProxyAddr->GetPointer());
+
+               pProxyAddress.reset(new (std::nothrow) String(*pProxyAddr));
+               SysTryReturnResult(NID_NET_HTTP, pProxyAddress != null, E_OUT_OF_MEMORY,
+                                       "Memory allocation failed.");
+       }
+       else
+       {
+               if (_NetConnectionManagerImpl::IsDefaultMode() == true || pManagedNetConnectionListener->IsEventReceived() == true)
+               {
+                       SysLog(NID_NET_HTTP, "The proxy url is %ls.", proxyAddressOfManagedMode.GetPointer());
+
+                       pProxyAddress.reset(new (std::nothrow) String(proxyAddressOfManagedMode));
+                       SysTryReturnResult(NID_NET_HTTP, pProxyAddress != null, E_OUT_OF_MEMORY,
+                                               "Memory allocation failed.");
+
+               }
+               else
+               {
+                       SysLog(NID_NET_HTTP, "[Preference Mode] The system proxy address will be gotten after the managed connection is started.");
+               }
+       }
+
+       pProxyAddress->Trim();
+       pProxyAddress->ToLower(tempAddress);
+
+       if (tempAddress.IsEmpty() == false)
+       {
+               hasProtocolScheme = _HttpUtility::HasProtocolScheme(tempAddress);
+               if (!hasProtocolScheme)
+               {
+                       (*pProxyAddress) = _HTTP_PROTOCOL_SCHEME + (*pProxyAddress);
+               }
+
+               pProxyUri = new (std::nothrow) Uri();
+               SysTryReturnResult(NID_NET_HTTP, pProxyUri != null, E_OUT_OF_MEMORY,
+                                       "Memory allocation failed.");
+
+               r = pProxyUri->SetUri(*pProxyAddress);
+               delete pProxyUri;
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_INVALID_PROXY,
+                                       "The proxy address is invalid.");
+       }
+
+       if (sessionMode != NET_HTTP_SESSION_MODE_MULTIPLE_HOST)
+       {
+               __hostAddress = hostAddr;
+               __hostAddress.Trim();
+               __hostAddress.ToLower(tempAddress);
+
+               hasProtocolScheme = _HttpUtility::HasProtocolScheme(tempAddress);
+               if (!hasProtocolScheme)
+               {
+                       //Add the prefix as "http://"
+                       __hostAddress = _HTTP_PROTOCOL_SCHEME + __hostAddress;
+               }
+
+               SysLog(NID_NET_HTTP, "The host address is %ls.", __hostAddress.GetPointer());
+
+               pHostUri = new (std::nothrow) Uri();
+               SysTryReturnResult(NID_NET_HTTP, pHostUri != null, E_OUT_OF_MEMORY,
+                                       "Memory allocation failed.");
+
+               r = pHostUri->SetUri(__hostAddress);
+               delete pHostUri;
+               r = TransExceptionsExclusive(r, E_INVALID_ARG, E_OUT_OF_MEMORY);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "The host address is invalid.");
+       }
+
+       if (pCommonHeader != null)
+       {
+               String* pRawHeaderString = pCommonHeader->GetRawHeaderN();
+               SysLog(NID_NET_HTTP, "The common header is %ls.", pRawHeaderString->GetPointer());
+               delete pRawHeaderString;
+
+               pHeader.reset(new (std::nothrow) HttpHeader(pCommonHeader));
+               r = GetLastResult();
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+       }
+       else
+       {
+               SysLog(NID_NET_HTTP, "The common header is null.");
+       }
+
+       __cookieFlag = flag;
+
+       pHttpMultipleConnectionInfo.reset(new (std::nothrow) _HttpMultipleConnectionInfo());
+       SysTryReturnResult(NID_NET_HTTP, pHttpMultipleConnectionInfo != null, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       pCurlM = curl_multi_init();
+       __sessionId = _HttpSessionImpl::GenerateSessionId();
+
+       //If sessionId is 0, delete the cookie_{appid}.txt file.
+       InitializeSession();
+
+       r = pHttpMultipleConnectionInfo->Construct(pCurlM, __sessionId, __cookieFlag);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       curl_multi_setopt(pCurlM, CURLMOPT_SOCKETFUNCTION, _HttpMultipleConnectionInfo::OnCurlMultiSocketUpdated);
+       curl_multi_setopt(pCurlM, CURLMOPT_SOCKETDATA, pHttpMultipleConnectionInfo.get());
+       curl_multi_setopt(pCurlM, CURLMOPT_TIMERFUNCTION, _HttpMultipleConnectionInfo::OnCurlMultiTimerChanged);
+       curl_multi_setopt(pCurlM, CURLMOPT_TIMERDATA, pHttpMultipleConnectionInfo.get());
+
+       if (__sessionMode == NET_HTTP_SESSION_MODE_PIPELINING)
+       {
+               curl_multi_setopt(pCurlM, CURLMOPT_PIPELINING, 1L);
+               SysLog(NID_NET_HTTP, "The pipelining mode was enabled. HttpSession[%d]", __sessionId);
+       }
+
+       pCookieStorageMgr.reset(_HttpCookieStorageManagerImpl::CreateHttpCookieStorageManagerN());
+       SysTryReturnResult(NID_NET_HTTP, pCookieStorageMgr != null, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       r = __activeTransactions.Construct();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       r = locked.Lock();
+       SysTryReturnResult(NID_NET_HTTP, locked.IsLocked(), E_SYSTEM,
+                       "Failed to lock mutex.");
+
+       __countOfSessions++;
+
+       r = locked.Unlock();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_SYSTEM,
+                       "Failed to unlock mutex.");
+
+       __isConstructed = true;
+       __isValid = true;
+
+       __pManagedNetConnection = pManagedNetConnection.release();
+       __pManagedNetConnectionListener = pManagedNetConnectionListener.release();
+       __pProxyAddress = pProxyAddress.release();
+       __pCommonHeader = pHeader.release();
+       __pHttpMultipleConnectionInfo = pHttpMultipleConnectionInfo.release();
+       __pCookieStorageMgr = pCookieStorageMgr.release();
+
+       SysLog(NID_NET_HTTP, "The HttpSession[%d] instance was created.", __sessionId);
+
+       return r;
+}
+
+result
+_HttpSessionImpl::Construct(const NetConnection& netConnection, NetHttpSessionMode sessionMode,
+                                                       const String* pProxyAddr, const String& hostAddr, const HttpHeader* pCommonHeader,
+                                                       NetHttpCookieFlag flag)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __isConstructed == false,
+                                          E_INVALID_STATE, "Already constructed.");
+
+       SysTryReturnResult(NID_NET_HTTP, sessionMode == NET_HTTP_SESSION_MODE_NORMAL || sessionMode == NET_HTTP_SESSION_MODE_PIPELINING || sessionMode == NET_HTTP_SESSION_MODE_MULTIPLE_HOST,
+                                          E_INVALID_ARG, "Invalid SessionMode.");
+
+       if (sessionMode != NET_HTTP_SESSION_MODE_MULTIPLE_HOST)
+       {
+               SysTryReturnResult(NID_NET_HTTP, hostAddr.GetLength() > 0,
+                                                  E_INVALID_ARG, "Invalid hostAddr.");
+
+       }
+       SysTryReturnResult(NID_NET_HTTP, NET_HTTP_COOKIE_FLAG_NONE == flag || NET_HTTP_COOKIE_FLAG_ALWAYS_AUTOMATIC == flag || NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL == flag,
+                                          E_INVALID_ARG, "Invalid cookie flag.");
+
+       _HttpUtility::InitializeHttp();
+
+       // Check the network state
+       NetConnectionState connState = netConnection.GetConnectionState();
+       if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+       {
+               SysLog(NID_NET_HTTP, "The custom network is available.");
+       }
+       else
+       {
+               r = E_INVALID_CONNECTION;
+               SysLogException(NID_NET_HTTP, r, "[E_INVALID_CONNECTION] Custom Network is not available.");
+               return r;
+       }
+
+       const NetConnectionInfo* pConnectionInfo = null;
+       const _NetConnectionInfoImpl* pConnectionInfoImpl = null;
+       _NetConnectionImpl* pNetConnectionImpl = const_cast< _NetConnectionImpl* >(_NetConnectionImpl::GetInstance(netConnection));
+       SysTryReturnResult(NID_NET_HTTP, pNetConnectionImpl != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       SysLog(NID_NET_HTTP, "There are currently opened sessions[%d] in the Application.", __countOfSessions);
+
+       Mutex* pHttpMutex = _HttpUtility::GetHttpMutex();
+
+       MutexGuard locked(*pHttpMutex);
+       SysTryReturnResult(NID_NET_HTTP, locked.IsLocked(), E_SYSTEM,
+                       "Failed to lock mutex.");
+
+       SysTryReturnResult(NID_NET_HTTP, __countOfSessions < _MAX_HTTP_SESSIONS_PER_APPID_PER_PROTOCOL, E_MAX_EXCEEDED,
+                       "The number of currently opened sessions have exceeded the maximum limit(%d)", _MAX_HTTP_SESSIONS_PER_APPID_PER_PROTOCOL);
+
+       r = locked.Unlock();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_SYSTEM,
+                       "Failed to unlock mutex.");
+
+       SysLog(NID_NET_HTTP, "[ManagedNetConnection] NetHttpSessionMode: %ls, Host Address: %ls, NetHttpCookieFlag: %ls",
+                  _HttpSessionImpl_GetSessionModeAsString(
+                          sessionMode).GetPointer(), hostAddr.GetPointer(), _HttpSessionImpl_GetCookieFlagAsString(flag).GetPointer());
+
+       String tempAddress;
+       bool hasProtocolScheme = false;
+       Uri* pHostUri = null;
+       Uri* pProxyUri = null;
+       CURLM* pCurlM = null;
+       __sessionMode = sessionMode;
+       unique_ptr<_HttpNetConnectionEventListenerImpl> pNetConnectionListener;
+       unique_ptr<NetConnection> pNetConnection;
+       unique_ptr<String> pProxyAddress;
+       unique_ptr<HttpHeader> pHeader;
+       unique_ptr<_HttpMultipleConnectionInfo> pHttpMultipleConnectionInfo;
+       unique_ptr<HttpCookieStorageManager, _HttpCookieStorageManagerDeleter> pCookieStorageMgr;
+
+       if (pProxyAddr != null)
+       {
+               SysLog(NID_NET_HTTP, "The proxy address %ls.", pProxyAddr->GetPointer());
+
+               pProxyAddress.reset(new (std::nothrow) String(*pProxyAddr));
+               SysTryReturnResult(NID_NET_HTTP, pProxyAddress != null, E_OUT_OF_MEMORY,
+                                       "Memory allocation failed.");
+       }
+       else
+       {
+               String defaultProxyUrl = pNetConnectionImpl->GetProxyAddress();
+               SysLog(NID_NET_HTTP, "The system proxy is %ls.", defaultProxyUrl.GetPointer());
+
+               pProxyAddress.reset(new (std::nothrow) String(defaultProxyUrl));
+               SysTryReturnResult(NID_NET_HTTP, pProxyAddress != null, E_OUT_OF_MEMORY,
+                                       "Memory allocation failed.");
+       }
+
+       pProxyAddress->Trim();
+       pProxyAddress->ToLower(tempAddress);
+
+       if (tempAddress.IsEmpty() == false)
+       {
+               hasProtocolScheme = _HttpUtility::HasProtocolScheme(tempAddress);
+               if (!hasProtocolScheme)
+               {
+                       (*pProxyAddress) = _HTTP_PROTOCOL_SCHEME + (*pProxyAddress);
+               }
+
+               pProxyUri = new (std::nothrow) Uri();
+               SysTryReturnResult(NID_NET_HTTP, pProxyUri != null, E_OUT_OF_MEMORY,
+                                       "Memory allocation failed.");
+
+               r = pProxyUri->SetUri(*pProxyAddress);
+               delete pProxyUri;
+               r = TransExceptionsExclusive(r, E_INVALID_PROXY, E_OUT_OF_MEMORY);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                       "The proxy address is invalid.");
+       }
+
+       if (sessionMode != NET_HTTP_SESSION_MODE_MULTIPLE_HOST)
+       {
+               __hostAddress = hostAddr;
+               __hostAddress.Trim();
+               __hostAddress.ToLower(tempAddress);
+
+               hasProtocolScheme = _HttpUtility::HasProtocolScheme(tempAddress);
+               if (!hasProtocolScheme)
+               {
+                       //Add the prefix as "http://"
+                       __hostAddress = _HTTP_PROTOCOL_SCHEME + __hostAddress;
+               }
+
+               SysLog(NID_NET_HTTP, "The host address is %ls.", __hostAddress.GetPointer());
+
+               pHostUri = new (std::nothrow) Uri();
+               SysTryReturnResult(NID_NET_HTTP, pHostUri != null, E_OUT_OF_MEMORY,
+                                       "Memory allocation failed.");
+
+               r = pHostUri->SetUri(__hostAddress);
+               delete pHostUri;
+               r = TransExceptionsExclusive(r, E_INVALID_ARG, E_OUT_OF_MEMORY);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                       "The host address is invalid.");
+       }
+
+       if (pCommonHeader != null)
+       {
+               String* pRawHeaderString = pCommonHeader->GetRawHeaderN();
+               if (pRawHeaderString != null)
+               {
+                       SysLog(NID_NET_HTTP, "The common header is %ls.", pRawHeaderString->GetPointer());
+                       delete pRawHeaderString;
+               }
+
+               pHeader.reset(new (std::nothrow) HttpHeader(pCommonHeader));
+               r = GetLastResult();
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+       }
+       else
+       {
+               SysLog(NID_NET_HTTP, "The common header is null.");
+       }
+
+       __cookieFlag = flag;
+
+       pHttpMultipleConnectionInfo.reset(new (std::nothrow) _HttpMultipleConnectionInfo());
+       SysTryReturnResult(NID_NET_HTTP, pHttpMultipleConnectionInfo != null, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       pCurlM = curl_multi_init();
+
+       __sessionId = _HttpSessionImpl::GenerateSessionId();
+
+       //If sessionId is 0, delete the cookies}.txt file.
+       InitializeSession();
+
+       r = pHttpMultipleConnectionInfo->Construct(pCurlM, __sessionId, __cookieFlag);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       curl_multi_setopt(pCurlM, CURLMOPT_SOCKETFUNCTION, _HttpMultipleConnectionInfo::OnCurlMultiSocketUpdated);
+       curl_multi_setopt(pCurlM, CURLMOPT_SOCKETDATA, pHttpMultipleConnectionInfo.get());
+       curl_multi_setopt(pCurlM, CURLMOPT_TIMERFUNCTION, _HttpMultipleConnectionInfo::OnCurlMultiTimerChanged);
+       curl_multi_setopt(pCurlM, CURLMOPT_TIMERDATA, pHttpMultipleConnectionInfo.get());
+
+       if (__sessionMode == NET_HTTP_SESSION_MODE_PIPELINING)
+       {
+               curl_multi_setopt(pCurlM, CURLMOPT_PIPELINING, 1L);
+               SysLog(NID_NET_HTTP, "Enable the pipelining mode, HttpSession[%d]", __sessionId);
+       }
+
+       pCookieStorageMgr.reset(_HttpCookieStorageManagerImpl::CreateHttpCookieStorageManagerN());
+       SysTryReturnResult(NID_NET_HTTP, pCookieStorageMgr != null, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       // Set the device name (setsockopt)
+       pConnectionInfo = netConnection.GetNetConnectionInfo();
+       pConnectionInfoImpl = _NetConnectionInfoImpl::GetInstance(*pConnectionInfo);
+
+       __deviceName = pConnectionInfoImpl->GetDeviceName();
+       if (__deviceName.IsEmpty())
+       {
+               SysLog(NID_NET_HTTP, "[Emulator] The device name is an empty string.");
+       }
+       else
+       {
+               SysLog(NID_NET_HTTP, "[Target] The device name is %ls.", __deviceName.GetPointer());
+       }
+
+       // Creates new NetConnection for receiving the network event.
+       pNetConnection.reset(pNetConnectionImpl->CopyInstanceN());
+       SysTryReturnResult(NID_NET_HTTP, pNetConnection != null, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       // New CustomNetConnectionEventListener
+       pNetConnectionListener.reset(new (std::nothrow) _HttpNetConnectionEventListenerImpl(this));
+       SysTryReturnResult(NID_NET_HTTP, pNetConnectionListener != null, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       // Add NetConnectionListener
+       r = pNetConnection->AddNetConnectionListener(*pNetConnectionListener);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                               "Failed to add the NetConnection listener.");
+
+       r = __activeTransactions.Construct();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_OUT_OF_MEMORY,
+                               "Memory allocation failed.");
+
+       r = locked.Lock();
+       SysTryReturnResult(NID_NET_HTTP, locked.IsLocked(), E_SYSTEM,
+                       "Failed to lock mutex.");
+
+       __countOfSessions++;
+
+       r = locked.Unlock();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_SYSTEM,
+                       "Failed to unlock mutex.");
+
+       __isConstructed = true;
+       __isValid = true;
+
+       __pNetConnection = pNetConnection.release();
+       __pNetConnectionListener = pNetConnectionListener.release();
+       __pProxyAddress = pProxyAddress.release();
+       __pCommonHeader = pHeader.release();
+       __pHttpMultipleConnectionInfo = pHttpMultipleConnectionInfo.release();
+       __pCookieStorageMgr = pCookieStorageMgr.release();
+
+       SysLog(NID_NET_HTTP, "The HttpSession[%d] instance was created.", __sessionId);
+
+       return r;
+}
+
+HttpCookieStorageManager*
+_HttpSessionImpl::GetCookieStorageManager(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(!__isClosed, "The HttpSession[%d] has been closed.", __sessionId);
+       SysAssertf(__pCookieStorageMgr != null, "The pCookieStorageMgr must not be null.");
+
+       return __pCookieStorageMgr;
+}
+
+_HttpSessionImpl*
+_HttpSessionImpl::GetInstance(HttpSession& httpSession)
+{
+       return httpSession.__pHttpSessionImpl;
+}
+
+const _HttpSessionImpl*
+_HttpSessionImpl::GetInstance(const HttpSession& httpSession)
+{
+       return httpSession.__pHttpSessionImpl;
+}
+
+NetHttpSessionMode
+_HttpSessionImpl::GetSessionMode(void) const
+{
+       return __sessionMode;
+}
+
+String
+_HttpSessionImpl::GetHostAddress(void) const
+{
+       return __hostAddress;
+}
+
+String*
+_HttpSessionImpl::GetProxyAddress(void) const
+{
+       return __pProxyAddress;
+}
+
+void
+_HttpSessionImpl::SetProxyAddress(String* pProxyAddress)
+{
+       __pProxyAddress = pProxyAddress;
+}
+
+String
+_HttpSessionImpl::GetDeviceName(void) const
+{
+       return __deviceName;
+}
+
+void
+_HttpSessionImpl::SetDeviceName(const String& deviceName)
+{
+       __deviceName = deviceName;
+}
+
+NetHttpCookieFlag
+_HttpSessionImpl::GetHttpCookieFlag(void) const
+{
+       return __cookieFlag;
+}
+
+result
+_HttpSessionImpl::SetAutoRedirectionEnabled(bool enable)
+{
+       SysAssertf(!__isClosed, "The HttpSession[%d] has been closed.", __sessionId);
+
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __countOfTransaction == 0,
+                                          E_INVALID_STATE, "The HttpTransaction is already opened. This function should be called before opening a HttpTransaction.");
+
+       if (__isAutoRedirectionEnabled == enable)
+       {
+               SysLog(NID_NET_HTTP, "The auto redirection value is not changed[%s].", enable ? "true" : "false");
+               return r;
+
+       }
+       else
+       {
+               __isAutoRedirectionEnabled = enable;
+       }
+
+       SysLog(NID_NET_HTTP, "The auto redirection is set the value[%s].", enable ? "true" : "false");
+
+       return r;
+}
+
+bool
+_HttpSessionImpl::IsAutoRedirectionEnabled(void) const
+{
+       SysAssertf(!__isClosed, "The HttpSession[%d] has been closed.", __sessionId);
+
+       ClearLastResult();
+
+       return __isAutoRedirectionEnabled;
+}
+
+result
+_HttpSessionImpl::CloseAllTransactions(void)
+{
+       SysAssertf(!__isClosed, "The HttpSession[%d] has been closed.", __sessionId);
+
+       result r = E_SUCCESS;
+
+       HttpTransaction* pHttpTransaction = null;
+       _HttpTransactionImpl* pHttpTransactionImpl = null;
+       int countOfActiveTransactions = 0;
+
+       countOfActiveTransactions = __activeTransactions.GetCount();
+       for (int i = 0; i < countOfActiveTransactions; i++)
+       {
+               pHttpTransaction = static_cast< HttpTransaction* >(__activeTransactions.GetAt(i));
+               if (pHttpTransaction != null)
+               {
+                       pHttpTransactionImpl = _HttpTransactionImpl::GetInstance(*pHttpTransaction);
+                       if (pHttpTransactionImpl->IsClosed() == false)
+                       {
+                               r = CloseTransaction(*pHttpTransaction);
+                               if (IsFailed(r))
+                               {
+                                       SysLogException(NID_NET_HTTP, r, "[%s] Failed to close the HttpTransaction[%d].",
+                                                                       pHttpTransactionImpl->GetTransactionId(), GetErrorMessage(r));
+                               }
+                       }
+               }
+       }
+       __activeTransactions.RemoveAll(false);
+
+       return r;
+}
+
+result
+_HttpSessionImpl::Disconnect(void)
+{
+       SysAssertf(!__isClosed, "The HttpSession[%d] has been closed.", __sessionId);
+
+       result r = E_SUCCESS;
+
+       __isValid = false;
+       __pHttpMultipleConnectionInfo->Close();
+
+       HttpTransaction* pHttpTransaction = null;
+       _HttpTransactionImpl* pHttpTransactionImpl = null;
+       int countOfActiveTransactions = 0;
+
+       countOfActiveTransactions = __activeTransactions.GetCount();
+       for (int i = 0; i < countOfActiveTransactions; i++)
+       {
+               pHttpTransaction = static_cast< HttpTransaction* >(__activeTransactions.GetAt(i));
+               if (pHttpTransaction != null)
+               {
+                       pHttpTransactionImpl = _HttpTransactionImpl::GetInstance(*pHttpTransaction);
+                       r = pHttpTransactionImpl->Abort();
+                       if (IsFailed(r))
+                       {
+                               SysLog(NID_NET_HTTP, "Failed to abort the HttpTransaction.");
+                       }
+               }
+       }
+
+       SysLog(NID_NET_HTTP, "The HttpSession[%d] is disconnected.", __sessionId);
+       return r;
+}
+
+bool
+_HttpSessionImpl::IsSessionValid(void) const
+{
+       return __isValid;
+}
+
+void
+_HttpSessionImpl::SetSessionState(bool isValid)
+{
+       __isValid = true;
+}
+
+bool
+_HttpSessionImpl::IsConnectionStarted(void) const
+{
+       if (__pManagedNetConnection == null)
+               return true;
+
+       if (__pManagedNetConnectionListener != null)
+       {
+               return __pManagedNetConnectionListener->IsEventReceived();
+       }
+
+       return false;
+}
+
+void
+_HttpSessionImpl::IgnoreSslVerification(void)
+{
+       __isAlreadyResumed = true;
+}
+
+result
+_HttpSessionImpl::Close(void)
+{
+       SysAssertf(!__isClosed, "The HttpSession[%d] has been closed.", __sessionId);
+
+       result r = E_SUCCESS;
+
+       Mutex* pHttpMutex = _HttpUtility::GetHttpMutex();
+
+       MutexGuard locked(*pHttpMutex);
+       SysTryReturnResult(NID_NET_HTTP, locked.IsLocked(), E_SYSTEM,
+                       "Failed to lock mutex.");
+
+       __countOfSessions--;
+
+       r = locked.Unlock();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_SYSTEM,
+                       "Failed to unlock mutex.");
+
+       SysLog(NID_NET_HTTP, "There are currently opened sessions[%d] in the Application.", __countOfSessions);
+
+       CloseAllTransactions();
+
+       SysLog(NID_NET_HTTP, "The HttpSession[%d] is closed.", __sessionId);
+       __isClosed = true;
+
+       return r;
+}
+
+HttpTransaction*
+_HttpSessionImpl::OpenTransactionN()
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       HttpTransaction* pHttpTransaction = null;
+
+       pHttpTransaction = OpenTransactionWithCurlN(null);
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       SysLog(NID_NET_HTTP, "The HttpTransaction was opened.");
+
+       return pHttpTransaction;
+}
+
+HttpTransaction*
+_HttpSessionImpl::OpenTransactionN(const HttpAuthentication& auth)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       HttpTransaction* pHttpTransaction = null;
+       _HttpTransactionImpl* pHttpTransactionImpl = null;
+       const _HttpAuthenticationImpl* pHttpAuthenticationImpl = null;
+       _HttpCurl* pHttpAuthenticationRef = null;
+       CURL* pCurl = null;
+
+       pHttpAuthenticationImpl = _HttpAuthenticationImpl::GetInstance(auth);
+       pHttpAuthenticationRef = pHttpAuthenticationImpl->GetHttpCurl();
+       pCurl = pHttpAuthenticationRef->GetCurl();
+       SysTryReturn(NID_NET_HTTP, pCurl != null, null, E_INVALID_STATE,
+                                "[E_INVALID_STATE] The curl instance must not be null.");
+
+       pHttpTransaction = OpenTransactionWithCurlN(pCurl);
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS && pHttpTransaction != null, null, r,
+                                "[%s] Propagating.", GetErrorMessage(r));
+
+       pHttpTransactionImpl = _HttpTransactionImpl::GetInstance(*pHttpTransaction);
+       SysTryReturn(NID_NET_HTTP, pHttpTransactionImpl != null, null, E_SYSTEM,
+                                "[E_SYSTEM] An internal error has occurred.");
+
+       pHttpTransactionImpl->SetHttpAuthenticationImpl(pHttpAuthenticationImpl);
+
+       SysLog(NID_NET_HTTP, "The HttpTransactio was opened with HttpAuthentication.");
+
+       return pHttpTransaction;
+}
+
+HttpTransaction*
+_HttpSessionImpl::OpenTransactionWithCurlN(CURL* pCurl)
+{
+       SysAssertf(!__isClosed, "The HttpSession[%d] has been closed.", __sessionId);
+
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       unique_ptr<HttpTransaction> pHttpTransaction;
+       _HttpTransactionImpl* pHttpTransactionImpl = null;
+
+       if (__sessionMode != NET_HTTP_SESSION_MODE_MULTIPLE_HOST)
+       {
+               SysTryReturn(NID_NET_HTTP, __countOfTransaction < GetMaxTransactionCount(), null, E_MAX_EXCEEDED,
+                                        "[E_MAX_EXCEEDED] Number(%d) of HttpTransaction exceeds max HttpTransaction count(%d).", __countOfTransaction, GetMaxTransactionCount());
+       }
+
+       pHttpTransaction.reset(_HttpTransactionImpl::CreateHttpTransactionN());
+       SysTryReturn(NID_NET_HTTP, pHttpTransaction != null, null, E_OUT_OF_MEMORY,
+                                "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       pHttpTransactionImpl = _HttpTransactionImpl::GetInstance(*pHttpTransaction);
+
+       r = pHttpTransactionImpl->Construct(*this, __pCommonHeader, pCurl);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r,
+                               "[%s] Failed to construct the HttpTransaction.", GetErrorMessage(r));
+
+       if (__isAlreadyResumed == true)
+       {
+               pHttpTransactionImpl->IgnoreSslVerification();
+               SysLog(NID_NET_HTTP, "Ignore SSL verification.");
+       }
+
+       r = __activeTransactions.Add(*pHttpTransaction);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, E_OUT_OF_MEMORY,
+                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       __countOfTransaction++;
+
+       SysLog(NID_NET_HTTP, "The HttpTransaction[%d] was opened. The count of active transactions is %d.", pHttpTransactionImpl->GetTransactionId(), __countOfTransaction);
+       return pHttpTransaction.release();
+}
+
+result
+_HttpSessionImpl::CancelTransaction(HttpTransaction& httpTransaction)
+{
+       SysAssertf(!__isClosed, "The HttpSession[%d] has been closed.", __sessionId);
+
+       result r = E_SUCCESS;
+       _HttpTransactionImpl* pHttpTransactionImpl = _HttpTransactionImpl::GetInstance(httpTransaction);
+
+       SysTryReturnResult(NID_NET_HTTP, pHttpTransactionImpl->IsSubmitted() == true && pHttpTransactionImpl->IsClosed() == false,
+                                          E_INVALID_STATE, "Either the HttpTransaction[%d] has not been submitted yet, or it has been closed.",
+                                          pHttpTransactionImpl->GetTransactionId());
+
+       SysTryReturnResult(NID_NET_HTTP, pHttpTransactionImpl->IsCanceled() == false,
+                                          E_OPERATION_CANCELED, "The HttpTransaction[%d] is already cancelled.", pHttpTransactionImpl->GetTransactionId());
+
+       r = CloseTransaction(httpTransaction);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                "Failed to cancel the HttpTransaction[%d].", pHttpTransactionImpl->GetTransactionId());
+
+       pHttpTransactionImpl = _HttpTransactionImpl::GetInstance(httpTransaction);
+       pHttpTransactionImpl->SetTransactionCanceled(true);
+
+       SysLog(NID_NET_HTTP, "The HttpTransaction[%d] was cancelled.", pHttpTransactionImpl->GetTransactionId());
+
+       return r;
+}
+
+
+result
+_HttpSessionImpl::CloseTransaction(HttpTransaction& httpTransaction)
+{
+       SysAssertf(!__isClosed, "The HttpSession[%d] has been closed.", __sessionId);
+
+       result r = E_SUCCESS;
+
+       _HttpTransactionImpl* pHttpTransactionImpl = null;
+
+       pHttpTransactionImpl = _HttpTransactionImpl::GetInstance(httpTransaction);
+
+       if (pHttpTransactionImpl->IsClosed() == true)
+       {
+               SysLog(NID_NET_HTTP, "The HttpTransaction[%d] is already closed. HttpSession[%d]",
+                          pHttpTransactionImpl->GetTransactionId(), __sessionId);
+       }
+       else
+       {
+               r = __activeTransactions.Remove(httpTransaction, false);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                  E_INVALID_TRANSACTION, "Failed to remove HttpTransaction.");
+
+               r = pHttpTransactionImpl->Close();
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                        "Failed to close HttpTransaction.");
+
+               __countOfTransaction--;
+
+               SysLog(NID_NET_HTTP, "The HttpTransaction[%d] is now closed. HttpSession[%d]",
+                          pHttpTransactionImpl->GetTransactionId(), __sessionId);
+       }
+
+       return r;
+
+}
+
+int
+_HttpSessionImpl::GetActiveTransactionCount(void) const
+{
+       SysAssertf(!__isClosed, "The HttpSession[%d] has been closed.", __sessionId);
+
+       ClearLastResult();
+
+       return __countOfTransaction;
+}
+
+int
+_HttpSessionImpl::GetMaxTransactionCount(void) const
+{
+       SysAssertf(!__isClosed, "The HttpSession[%d] has been closed.", __sessionId);
+
+       ClearLastResult();
+
+       if (__sessionMode == NET_HTTP_SESSION_MODE_NORMAL)
+       {
+               return _MAX_HTTP_TRANSACTIONS_PER_SESSION_NORMAL;
+       }
+       else if (__sessionMode == NET_HTTP_SESSION_MODE_PIPELINING)
+       {
+               return _MAX_HTTP_TRANSACTIONS_PER_SESSION_PIPE;
+       }
+       else if (__sessionMode == NET_HTTP_SESSION_MODE_MULTIPLE_HOST)
+       {
+               return _MAX_HTTP_TRANSACTIONS_PER_SESSION_MULTIPLE_HOST;
+       }
+       else
+       {
+               return -1;
+       }
+}
+
+HttpSession*
+_HttpSessionImpl::GetHttpSession(void) const
+{
+       return __pHttpSession;
+}
+
+_HttpMultipleConnectionInfo*
+_HttpSessionImpl::GetHttpMultipleConnectionInfo(void) const
+{
+       return __pHttpMultipleConnectionInfo;
+}
+
+result
+_HttpSessionImpl::Dispose(void)
+{
+       SysAssertf(!__isClosed, "The HttpSession[%d] has been closed.", __sessionId);
+
+       result r = E_SUCCESS;
+       if (!__isConstructed)
+       {
+               SysLog(NID_NET_HTTP, "The HttpSession[%d] is not constructed yet.", __sessionId);
+               return r;
+       }
+
+       r = Close();
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                "Failed to close the HttpSession[%d].", __sessionId);
+
+       return r;
+}
+
+HttpTransaction*
+_HttpSessionImpl::ReopenTransactionWithAuthN(HttpTransaction& httpTransaction)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       unique_ptr<HttpTransaction> pCreatedTransaction;
+       _HttpTransactionImpl* pCreatedTransactionImpl = null;
+       _HttpRequestImpl* pCreatedHttpRequestImpl = null;
+
+       _HttpTransactionImpl* pHttpTransactionImpl = null;
+       HttpRequest* pHttpRequest = null;
+       _HttpRequestImpl* pHttpRequestImpl = null;
+       _HttpAuthenticationImpl* pAuthenticationImpl = null;
+
+       ByteBuffer bodyBuffer;
+       ByteBuffer* pRequestBuffer = null;
+       String uri;
+       NetHttpMethod method;
+       ArrayListT< IHttpTransactionEventListener* > listenerList;
+       Object* pUserData = null;
+
+       pHttpTransactionImpl = _HttpTransactionImpl::GetInstance(httpTransaction);
+       SysTryReturn(NID_NET_HTTP, pHttpTransactionImpl != null, null, E_SYSTEM,
+                                "[E_SYSTEM] An internal error has occurred.");
+
+       pHttpRequest = pHttpTransactionImpl->GetRequest();
+       SysTryReturn(NID_NET_HTTP, pHttpRequest != null, null, E_SYSTEM,
+                                "[E_SYSTEM] An internal error has occurred.");
+
+       pHttpRequestImpl = _HttpRequestImpl::GetInstance(*pHttpRequest);
+       SysTryReturn(NID_NET_HTTP, pHttpRequestImpl != null, null, E_SYSTEM,
+                                "[E_SYSTEM] An internal error has occurred.");
+
+       method = pHttpRequestImpl->GetMethod();
+
+       r = pHttpRequestImpl->GetUri(uri);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r,
+                                "[%s] Failed to get the uri.", GetErrorMessage(r));
+
+       r = listenerList.Construct(*(pHttpTransactionImpl->GetEventListenerList()));
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, E_OUT_OF_MEMORY,
+                                "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       pAuthenticationImpl = pHttpTransactionImpl->GetHttpAuthenticationImpl();
+       SysTryReturn(NID_NET_HTTP, pAuthenticationImpl != null, null, E_INVALID_STATE,
+                                "[E_INVALID_STATE] The HttpAuthentication is null.");
+
+       pUserData = httpTransaction.GetUserObject();
+
+       r = CloseTransaction(httpTransaction);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r,
+                               "[%s] Propagating.", GetErrorMessage(r));
+
+       pCreatedTransaction.reset(OpenTransactionN());
+       r = GetLastResult();
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r,
+                               "[%s] Failed to open the HttpTransaction.", GetErrorMessage(r));
+
+       pCreatedTransactionImpl = _HttpTransactionImpl::GetInstance(*pCreatedTransaction);
+
+       r = pCreatedTransactionImpl->SetUserObject(pUserData);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r,
+                               "[%s] Failed to set the user object.", GetErrorMessage(r));
+
+       pCreatedHttpRequestImpl = _HttpRequestImpl::GetInstance(*pCreatedTransactionImpl->GetRequest());
+
+       r = pCreatedHttpRequestImpl->SetMethod(method);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r,
+                               "[%s] Failed to set the method.", GetErrorMessage(r));
+
+       r = pCreatedHttpRequestImpl->SetUri(uri);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r,
+                               "[%s] Failed to set the URI.", GetErrorMessage(r));
+
+       pRequestBuffer = pHttpTransactionImpl->GetRequestBuffer();
+       if (pRequestBuffer != null)
+       {
+               //Clear the flag of _HttpRequestImpl
+               pHttpRequestImpl->SetReceivedTransactionReadyToWriteEvent(false);
+
+               r = pCreatedHttpRequestImpl->WriteBody(*pRequestBuffer);
+               SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r, "[%s] Failed to write the body.", GetErrorMessage(r));
+
+               SysLog(NID_NET_HTTP, "The __pRequestBuffer is added to the Body.");
+       }
+
+       for (int i = 0; i < listenerList.GetCount(); i++)
+       {
+               IHttpTransactionEventListener* pListener = null;
+               r = listenerList.GetAt(i, pListener);
+               SysTryReturn(NID_NET_HTTP, r == E_SUCCESS && pListener != null, null, E_SYSTEM,
+                                       "[E_SYSTEM] A system error has occurred.");
+
+               r = pCreatedTransactionImpl->AddHttpTransactionListener(*pListener);
+               SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r,
+                                       "[%s] Failed to add the HttpTransactionEventListener.", GetErrorMessage(r));
+       }
+
+       SysLog(NID_NET_HTTP, "The HttpTransaction[%d] was re-opened.", pCreatedTransactionImpl->GetTransactionId());
+
+       return pCreatedTransaction.release();
+}
+
+ArrayList*
+_HttpSessionImpl::GetActiveTransactions(void)
+{
+       return &__activeTransactions;
+}
+
+int
+_HttpSessionImpl::GenerateSessionId(void)
+{
+       int sessionId = 0;
+       Mutex* pHttpMutex = null;
+
+       pHttpMutex = _HttpUtility::GetHttpMutex();
+
+       MutexGuard locked(*pHttpMutex);
+       SysTryReturn(NID_NET_HTTP, locked.IsLocked(), _HTTP_INVALID_ID, E_SYSTEM,
+                       "[E_SYSTEM] Failed to lock mutex.");
+
+       if (__generatedSessionId >= Integer::VALUE_MAX)
+       {
+               __generatedSessionId = 0;
+       }
+       else
+       {
+               __generatedSessionId++;
+       }
+
+       sessionId = __generatedSessionId;
+
+       return sessionId;
+}
+
+int
+_HttpSessionImpl::GetSessionId(void) const
+{
+       return __sessionId;
+}
+
+result
+_HttpSessionImpl::InitializeSession(void)
+{
+       result r = E_SUCCESS;
+       Mutex* pHttpMutex = null;
+
+       pHttpMutex = _HttpUtility::GetHttpMutex();
+
+       MutexGuard locked(*pHttpMutex);
+       SysTryReturnResult(NID_NET_HTTP, locked.IsLocked(), E_SYSTEM,
+                       "Failed to lock mutex.");
+
+       if (__generatedSessionId == 0)
+       {
+               String filePath = _HttpUtility::GetCookieFilePath();
+               r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+               SysTryReturnResult(NID_NET_HTTP, filePath.IsEmpty() == false, r,
+                                       "Failed to get the cookie path of system.");
+
+               if (File::IsFileExist(filePath))
+               {
+                       r = File::Remove(filePath);
+                       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, E_SYSTEM,
+                                               "Failed to remove the cookie file[%ls].", filePath.GetPointer());
+
+                       SysLog(NID_NET_HTTP, "The cookie file[%ls] was removed.", filePath.GetPointer());
+               }
+       }
+
+       return r;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpSocketInfo.cpp b/src/http/FNetHttp_HttpSocketInfo.cpp
new file mode 100644 (file)
index 0000000..a643f26
--- /dev/null
@@ -0,0 +1,124 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpSocketInfo.cpp
+ * @brief              This is the implementation file for _HttpSocketInfo class.
+ */
+
+#include <FNetHttpHttpTypes.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpCommon.h"
+#include "FNetHttp_HttpTransactionImpl.h"
+#include "FNetHttp_HttpSocketInfo.h"
+#include "FNetHttp_HttpMultipleConnectionInfo.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpSocketInfo::_HttpSocketInfo(void)
+       : __pCurl(null)
+       , __pSocketChannel(null)
+       , __pSocketSource(null)
+       , __socketAction(0)
+{
+}
+
+_HttpSocketInfo::~_HttpSocketInfo(void)
+{
+       if (__pSocketSource != null)
+       {
+               g_source_set_callback(__pSocketSource, null, null, null);
+               SysLog(NID_NET_HTTP, "Deleted g_source_destroy(%d)", g_source_get_id(__pSocketSource));
+               g_source_destroy(__pSocketSource);
+               g_source_unref(__pSocketSource);
+               __pSocketSource = null;
+       }
+
+       if (__pSocketChannel != null)
+       {
+               g_io_channel_unref(__pSocketChannel);
+               __pSocketChannel = null;
+       }
+
+       SysLog(NID_NET_HTTP, "The _HttpSocketInfo instance was deleted.");
+}
+
+int
+_HttpSocketInfo::GetSocketAction(void) const
+{
+       return __socketAction;
+}
+
+result
+_HttpSocketInfo::SetSocketEvent(_HttpMultipleConnectionInfo* pHttpMultipleConnectionInfo, curl_socket_t socketFd, int socketAction, bool isCreated)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, pHttpMultipleConnectionInfo != null,
+                                          E_INVALID_STATE, "The _HttpMultipleConnectionInfo is already deleted.");
+
+       GIOCondition condition = static_cast< GIOCondition >((socketAction &  CURL_POLL_IN ? G_IO_IN : 0) | (socketAction & CURL_POLL_OUT ? G_IO_OUT : 0));
+
+       if (isCreated == false)
+       {
+               CURLMcode rc;
+               __pSocketChannel = g_io_channel_unix_new(socketFd);
+               SysLog(NID_NET_HTTP, "The SocketChannel was created.");
+
+               CURLM* pCurlM = pHttpMultipleConnectionInfo->GetCurlM();
+               SysTryReturnResult(NID_NET_HTTP, pCurlM != null,
+                                                  E_SYSTEM, "The pCurlM must not be null.");
+
+               rc = curl_multi_assign(pCurlM, socketFd, this);
+               if (rc == CURLM_OK)
+               {
+                       SysLog(NID_NET_HTTP, "CURLM_OK: Called curl_multi_assign()");
+               }
+               else
+               {
+                       _HttpUtility::PrintCurlMultiErrorCode(rc);
+               }
+       }
+
+       if (__pSocketSource != null)
+       {
+               g_source_set_callback(__pSocketSource, null, null, null);
+               SysLog(NID_NET_HTTP, "Deleted g_source_destroy(%d)", g_source_get_id(__pSocketSource));
+               g_source_destroy(__pSocketSource);
+               g_source_unref(__pSocketSource);
+               __pSocketSource = null;
+               SysLog(NID_NET_HTTP, "Unref the SocketSource.");
+       }
+
+       __socketAction = socketAction;
+       __pSocketSource = g_io_create_watch(__pSocketChannel, condition);
+       g_source_set_callback(__pSocketSource, (GSourceFunc) _HttpTransactionImpl::OnSocketReceivedEvent, pHttpMultipleConnectionInfo, null);
+
+       GMainContext* pGMainContext = pHttpMultipleConnectionInfo->GetGMainContext();
+       SysTryReturnResult(NID_NET_HTTP, pGMainContext != null,
+                                          E_SYSTEM, "The pGMainContext must not be null.");
+
+       g_source_attach(__pSocketSource, pGMainContext);
+       SysLog(NID_NET_HTTP, "Created the SocketSource for receiving the event. [SocktFd(%d), Condition(%d)]", socketFd, condition);
+
+       return r;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpSocketInfo.h b/src/http/FNetHttp_HttpSocketInfo.h
new file mode 100644 (file)
index 0000000..a2a1d5a
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpSocketInfo.h
+ * @brief              This is the header file for the %_HttpSocketInfo class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_SOCKET_INFO_H_
+#define _FNET_HTTP_INTERNAL_HTTP_SOCKET_INFO_H_
+
+#include <glib.h>
+#include <sys/socket.h>
+#include <curl.h>
+#include <FOspConfig.h>
+#include <FNetHttpHttpTypes.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpMultipleConnectionInfo;
+
+class _HttpSocketInfo
+       : public Tizen::Base::Object
+{
+
+public:
+       _HttpSocketInfo(void);
+
+       virtual ~_HttpSocketInfo(void);
+
+public:
+       int GetSocketAction(void) const;
+
+       result SetSocketEvent(_HttpMultipleConnectionInfo* pHttpMultipleConnectionInfo, curl_socket_t socketFd, int socketAction, bool isCreated);
+
+private:
+       _HttpSocketInfo(const _HttpSocketInfo& rhs);
+
+       _HttpSocketInfo& operator =(const _HttpSocketInfo& rhs);
+
+private:
+       CURL* __pCurl;
+       GIOChannel* __pSocketChannel;
+       GSource* __pSocketSource;
+       int __socketAction;
+
+}; // _HttpSocketInfo
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_SOCKET_INFO_H_
diff --git a/src/http/FNetHttp_HttpStringEntityImpl.cpp b/src/http/FNetHttp_HttpStringEntityImpl.cpp
new file mode 100644 (file)
index 0000000..f39f5d5
--- /dev/null
@@ -0,0 +1,203 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpStringEntityImpl.cpp
+ * @brief              This is the implementation file for the _HttpStringEntityImpl class.
+ */
+
+#include <FTextEncoding.h>
+#include <FTextLatin1Encoding.h>
+#include <FNetHttpHttpStringEntity.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpStringEntityImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Text;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+static const wchar_t HTTP_STRING_ENTITY_DEFAULT_CONTENT_TYPE[] = L"text/plain";
+static const wchar_t HTTP_STRING_ENTITY_DEFAULT_CHARSET[] = L"";
+
+_HttpStringEntityImpl::_HttpStringEntityImpl(void)
+       : __contentLength(-1)
+       , __pBuffer(null)
+{
+}
+
+_HttpStringEntityImpl::~_HttpStringEntityImpl(void)
+{
+       if (__pBuffer != null)
+       {
+               delete __pBuffer;
+               __pBuffer = null;
+       }
+}
+
+result
+_HttpStringEntityImpl::Construct(const Tizen::Base::String& text)
+{
+       result r = E_SUCCESS;
+
+       String defaultContentType(HTTP_STRING_ENTITY_DEFAULT_CONTENT_TYPE);
+       String defaultCharset(HTTP_STRING_ENTITY_DEFAULT_CHARSET);
+       Latin1Encoding defaultEncoding;
+
+       r = Construct(text, defaultContentType, defaultCharset, defaultEncoding);
+
+       return r;
+}
+
+result
+_HttpStringEntityImpl::Construct(const Tizen::Base::String& text, const Tizen::Base::String& contentType,
+                                                                const Tizen::Base::String& charset,
+                                                                const Tizen::Text::Encoding& encoding)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, contentType.IsEmpty() == false,
+                                          E_INVALID_ARG, "Content-Type must not be empty.");
+
+       __contentType = contentType;
+       if (!charset.IsEmpty())
+       {
+               __contentType.Append(L"; charset=");
+               __contentType.Append(charset);
+       }
+
+       if (!text.IsEmpty())
+       {
+               __pBuffer = encoding.GetBytesN(text);
+               if (__pBuffer)
+               {
+                       r = __pBuffer->SetLimit(__pBuffer->GetRemaining() - 1);     // Remove null termination character.
+                       __contentLength = __pBuffer->GetRemaining();
+               }
+               else
+               {
+                       r = GetLastResult();
+                       SysLogException(NID_NET_HTTP, r, "[%s] Failed to process text encoding.", GetErrorMessage(r));
+               }
+       }
+       else
+       {
+               __pBuffer = null;
+               __contentLength = 0;
+       }
+
+       return r;
+}
+
+long long
+_HttpStringEntityImpl::GetContentLength(void) const
+{
+       return __contentLength;
+}
+
+Tizen::Base::String
+_HttpStringEntityImpl::GetContentType(void) const
+{
+       return __contentType;
+}
+
+_HttpStringEntityImpl*
+_HttpStringEntityImpl::GetInstance(HttpStringEntity& httpStringEntity)
+{
+       return httpStringEntity.__pHttpStringEntityImpl;
+}
+
+const _HttpStringEntityImpl*
+_HttpStringEntityImpl::GetInstance(const HttpStringEntity& httpStringEntity)
+{
+       return httpStringEntity.__pHttpStringEntityImpl;
+}
+
+bool
+_HttpStringEntityImpl::HasNextData(void)
+{
+       ClearLastResult();
+       bool ret = false;
+
+       if (__pBuffer && __pBuffer->GetRemaining())
+       {
+               ret = true;
+       }
+       else
+       {
+               ret = false;
+       }
+
+       return ret;
+}
+
+Tizen::Base::ByteBuffer*
+_HttpStringEntityImpl::GetNextDataN(int recommendedSize)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+       int size = 0;
+       ByteBuffer* pData = null;
+
+       if (0 >= recommendedSize)
+       {
+               return null;
+       }
+
+       if (0 >= __pBuffer->GetRemaining())
+       {
+               return null;
+       }
+
+       if (__pBuffer->GetRemaining() <= recommendedSize)
+       {
+               size = __pBuffer->GetRemaining();
+       }
+       else
+       {
+               size = recommendedSize;
+       }
+
+       pData = new (std::nothrow) ByteBuffer();
+       SysTryReturn(NID_NET_HTTP, pData != null, null, E_OUT_OF_MEMORY,
+                                "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pData->Construct(size);
+       if (IsFailed(r))
+       {
+               SysLogException(NID_NET_HTTP, r, "[%s] Failed to initialize a ByteBuffer.", GetErrorMessage(r));
+
+               delete pData;
+               return null;
+       }
+
+       r = pData->ReadFrom(*__pBuffer);
+       if (IsFailed(r))
+       {
+               SysLogException(NID_NET_HTTP, r, "[%s] Failed to copy data.", GetErrorMessage(r));
+
+               delete pData;
+               return null;
+       }
+
+       pData->Flip();
+
+       return pData;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpStringPart.cpp b/src/http/FNetHttp_HttpStringPart.cpp
new file mode 100644 (file)
index 0000000..49609d8
--- /dev/null
@@ -0,0 +1,121 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpStringPart.cpp
+ * @brief              This is the implementation file for the _HttpStringPart class.
+ */
+
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpStringPart.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpStringPart::_HttpStringPart(void)
+       : __isConstructed(false)
+       , __pValue(null)
+{
+}
+
+_HttpStringPart::~_HttpStringPart(void)
+{
+       if (__pValue != null)
+       {
+               delete __pValue;
+               __pValue = null;
+       }
+}
+
+result
+_HttpStringPart::Construct(const Tizen::Base::String& name, const Tizen::Base::ByteBuffer& buffer, const Tizen::Base::String& mimeType,
+                                                  const Tizen::Base::String& charset)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_NET_HTTP, __isConstructed == false,
+                                          E_INVALID_STATE, "Already constructed.");
+
+       SysTryReturnResult(NID_NET_HTTP, name.IsEmpty() == false || mimeType.IsEmpty() == false,
+                                          E_INVALID_ARG, "The input argument is invalid.");
+
+       __isConstructed = true;
+       __name = name;
+
+       __pValue = new (std::nothrow) ByteBuffer();
+       SysTryReturnResult(NID_NET_HTTP, __pValue != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pValue->Construct(buffer);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       __mimeType = mimeType;
+       __charset = charset;
+
+       return r;
+}
+
+result
+_HttpStringPart::Construct(const _HttpStringPart& part)
+{
+       result r = E_SUCCESS;
+       SysTryReturnResult(NID_NET_HTTP, __isConstructed == false,
+                                          E_INVALID_STATE, "Already constructed.");
+
+       __isConstructed = true;
+       __name = part.__name;
+
+       __pValue = new (std::nothrow) ByteBuffer();
+       SysTryReturnResult(NID_NET_HTTP, __pValue != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pValue->Construct(*part.__pValue);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       __mimeType = part.__mimeType;
+       __charset = part.__charset;
+
+       return r;
+}
+
+Tizen::Base::String
+_HttpStringPart::GetName(void) const
+{
+       return __name;
+}
+Tizen::Base::ByteBuffer*
+_HttpStringPart::GetValue(void) const
+{
+       return __pValue;
+}
+Tizen::Base::String
+_HttpStringPart::GetMimeType(void) const
+{
+       return __mimeType;
+}
+Tizen::Base::String
+_HttpStringPart::GetCharset(void) const
+{
+       return __charset;
+}
+
+} } } // Tizen::Net::HttpStringPart
diff --git a/src/http/FNetHttp_HttpStringPart.h b/src/http/FNetHttp_HttpStringPart.h
new file mode 100644 (file)
index 0000000..e11f6fe
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpStringPart.h
+ * @brief              This is the header file for the %_HttpStringPart class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_STRING_PART_H_
+#define _FNET_HTTP_INTERNAL_HTTP_STRING_PART_H_
+
+#include <FNetHttpHttpTypes.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+class String;
+} }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpMultipartEntityImpl;
+/**
+ * @class      _HttpStringPart
+ * @brief      This class represents a string body for multipart/form-data entity.
+ *
+ * @since 2.1
+ *
+ */
+
+class _HttpStringPart
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+       * This is the default constructor for this class.
+       */
+       _HttpStringPart(void);
+
+       /**
+       * This is the destructor for this class.
+       */
+       virtual ~_HttpStringPart(void);
+
+       result Construct(const Tizen::Base::String& name, const Tizen::Base::ByteBuffer& buffer, const Tizen::Base::String& mimeType, const Tizen::Base::String& charset);
+
+       result Construct(const _HttpStringPart& part);
+
+       Tizen::Base::String GetName(void) const;
+
+       Tizen::Base::ByteBuffer* GetValue(void) const;
+
+       Tizen::Base::String GetMimeType(void) const;
+
+       Tizen::Base::String GetCharset(void) const;
+
+private:
+       _HttpStringPart(const _HttpStringPart& rhs);
+
+       _HttpStringPart& operator =(const _HttpStringPart& rhs);
+
+private:
+       bool __isConstructed;
+       Tizen::Base::String __name;
+       Tizen::Base::ByteBuffer* __pValue;
+       Tizen::Base::String __mimeType;
+       Tizen::Base::String __charset;
+
+}; // _HttpStringPart
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_STRING_PART_H_
diff --git a/src/http/FNetHttp_HttpTransactionEvent.cpp b/src/http/FNetHttp_HttpTransactionEvent.cpp
new file mode 100644 (file)
index 0000000..55f993d
--- /dev/null
@@ -0,0 +1,528 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpTransactionEvent.cpp
+ * @brief              This is the implementation file for _HttpTransactionEvent class.
+ */
+
+#include <FNetHttpIHttpTransactionEventListener.h>
+#include <FNetHttpHttpRequest.h>
+#include <FNetHttpHttpResponse.h>
+#include <FBaseSysLog.h>
+#include <FBaseRtIEventArg.h>
+#include "FNetHttp_HttpSessionImpl.h"
+#include "FNetHttp_HttpTransactionImpl.h"
+#include "FNetHttp_HttpTransactionUserData.h"
+#include "FNetHttp_HttpRequestImpl.h"
+#include "FNetHttp_HttpResponseImpl.h"
+#include "FNetHttp_HttpTransactionEvent.h"
+#include "FNetHttp_HttpTransactionEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpTransactionEvent::_HttpTransactionEvent(void)
+       : __pHttpSessionImpl(null)
+       , __pHttpTransactionImpl(null)
+       , __pHttpProgressListener(null)
+       , __transactionId(-1)
+{
+}
+
+_HttpTransactionEvent::~_HttpTransactionEvent(void)
+{
+       __pHttpSessionImpl = null;
+       __pHttpTransactionImpl = null;
+}
+
+result
+_HttpTransactionEvent::Construct(_HttpSessionImpl* pHttpSessionImpl, _HttpTransactionImpl* pHttpTransactionImpl)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, pHttpSessionImpl != null,
+                                          E_SYSTEM, "pHttpSessionImpl must not be null.");
+
+       SysTryReturnResult(NID_NET_HTTP, pHttpTransactionImpl != null,
+                                          E_SYSTEM, "pHttpTransactionImpl must not be null.");
+
+       __pHttpSessionImpl = pHttpSessionImpl;
+       __pHttpTransactionImpl = pHttpTransactionImpl;
+       __transactionId = pHttpTransactionImpl->GetTransactionId();
+
+       r = _Event::Initialize();
+
+       return r;
+}
+
+result
+_HttpTransactionEvent::SetHttpProgressListener(const IHttpProgressEventListener* pListener)
+{
+       result r = E_SUCCESS;
+
+       __pHttpProgressListener = const_cast< IHttpProgressEventListener* >(pListener);
+
+       return r;
+}
+
+result
+_HttpTransactionEvent::FireTransactionReadyToReadEvent(int readBodyLength, bool async)
+{
+       result r = E_SUCCESS;
+
+       SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_READY_TO_READ), readBodyLength(%d), async(%d)", readBodyLength, async);
+
+       _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_READY_TO_READ);
+       SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       pEventArg->SetReadBodyLength(readBodyLength);
+
+       if (async)
+       {
+               FireAsync(*pEventArg);
+       }
+       else
+       {
+               Fire(*pEventArg);
+       }
+
+       return r;
+}
+
+result
+_HttpTransactionEvent::FireTransactionReadyToWriteEvent(int recommenedLength, bool async)
+{
+       result r = E_SUCCESS;
+
+       SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_READY_TO_WRITE), recommenedLength(%d), async(%d)", recommenedLength, async);
+
+       _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_READY_TO_WRITE);
+       SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       pEventArg->SetRecommendedSize(recommenedLength);
+
+       if (async)
+       {
+               FireAsync(*pEventArg);
+       }
+       else
+       {
+               Fire(*pEventArg);
+       }
+
+       return r;
+}
+
+result
+_HttpTransactionEvent::FireTransactionHeaderCompletedEvent(int headerLength, long proxyAuth, long httpAuth, bool async)
+{
+       result r = E_SUCCESS;
+
+       SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_HEADER_COMPLETED) HtpAuth(%ld), ProxyAuth(%ld), async(%d)", httpAuth, proxyAuth, async);
+
+       _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_HEADER_COMPLETED);
+       SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       pEventArg->SetReadHeaderLength(headerLength);
+
+       if (proxyAuth != _CURL_HTTP_AUTH_NONE)
+               pEventArg->SetProxyAuth(true);
+
+       pEventArg->SetAuthType(httpAuth);
+
+       if (async)
+       {
+               FireAsync(*pEventArg);
+       }
+       else
+       {
+               Fire(*pEventArg);
+       }
+
+       return r;
+}
+
+result
+_HttpTransactionEvent::FireTransactionCertVerificationRequiredNEvent(String* pServerCert, bool async)
+{
+       result r = E_SUCCESS;
+
+       SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_CERT_VERIFICATION_REQUIRED), async(%d)", async);
+
+       _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_CERT_VERIFICATION_REQUIRED);
+       SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       pEventArg->SetServerCert(pServerCert);
+
+       if (async)
+       {
+               FireAsync(*pEventArg);
+       }
+       else
+       {
+               Fire(*pEventArg);
+       }
+
+       return r;
+}
+
+result
+_HttpTransactionEvent::FireTransactionCompletedEvent(bool async)
+{
+       result r = E_SUCCESS;
+
+       SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_COMPLETD), async(%d)", async);
+
+       _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_COMPLETD);
+       SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       if (async)
+       {
+               FireAsync(*pEventArg);
+       }
+       else
+       {
+               Fire(*pEventArg);
+       }
+
+       return r;
+}
+
+result
+_HttpTransactionEvent::FireTransactionAbortedEvent(result error, bool async)
+{
+       result r = E_SUCCESS;
+
+       SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_ABORTED), error(%s), async(%d)", GetErrorMessage(error), async);
+
+       _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_ABORTED);
+       SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       pEventArg->SetError(error);
+
+       if (async)
+       {
+               FireAsync(*pEventArg);
+       }
+       else
+       {
+               Fire(*pEventArg);
+       }
+
+       return r;
+}
+
+result
+_HttpTransactionEvent::FireHttpUploadInProgressEvent(int currentLength, int totalLength, bool async)
+{
+       result r = E_SUCCESS;
+
+       SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_UPLOAD_PROGRESS), async(%d)", async);
+
+       _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_UPLOAD_PROGRESS);
+       SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       pEventArg->SetUploadProgress(currentLength, totalLength);
+
+       if (async)
+       {
+               FireAsync(*pEventArg);
+       }
+       else
+       {
+               Fire(*pEventArg);
+       }
+
+       return r;
+}
+
+result
+_HttpTransactionEvent::FireHttpDownloadInProgressEvent(int currentLength, int totalLength, bool async)
+{
+       result r = E_SUCCESS;
+
+       SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_DOWNLOAD_PROGRESS), async(%d)", async);
+
+       _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_DOWNLOAD_PROGRESS);
+       SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       pEventArg->SetDownloadProgress(currentLength, totalLength);
+
+       if (async)
+       {
+               FireAsync(*pEventArg);
+       }
+       else
+       {
+               Fire(*pEventArg);
+       }
+
+       return r;
+}
+
+void
+_HttpTransactionEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
+{
+       result r = E_SUCCESS;
+
+       HttpSession* pHttpSessoin = null;
+       HttpTransaction* pHttpTransaction = null;
+       _HttpTransactionUserData* pHttpTransactionUserData = null;
+
+       _HttpRequestImpl* pHttpRequestImpl = null;
+       IHttpEntity* pIHttpEntity = null;
+       _HttpResponseImpl* pHttpResponseImpl = null;
+       IHttpTransactionEventListener* pHttpTransactionEventListener = null;
+       IEventArg* pEventArg = null;
+       _HttpTransactionEventArg* pHttpTransactionEventArg = null;
+
+       bool isAuthRequired = false;
+       int readHeaderLength = 0;
+       long httpAuth = 0;
+       bool isProxyAuth = false;
+       int readBodyLength = 0;
+       int recommendedSize = 0;
+
+       long long currentUploadProgress = 0;
+       long long totalUploadProgress = 0;
+       long long currentDownloadProgress = 0;
+       long long totalDownloadProgress = 0;
+
+       int transactionId = -1;
+       _HttpTransactionEventType eventType = _HTTP_TRANSACTION_EVENT_TYPE_UNDEFINED;
+
+       SysLog(NID_NET_HTTP, "calling FireImpl.");
+
+       pEventArg = const_cast< IEventArg* >(&arg);
+       pHttpTransactionEventListener = dynamic_cast< IHttpTransactionEventListener* >(&listener);
+       SysTryReturnVoidResult(NID_NET_HTTP, pHttpTransactionEventListener != null, E_SYSTEM,
+                                                  "[E_SYSTEM] The event listener must not be null.");
+
+       pHttpTransactionEventArg = dynamic_cast< _HttpTransactionEventArg* >(pEventArg);
+       SysTryReturnVoidResult(NID_NET_HTTP, pHttpTransactionEventArg != null, E_SYSTEM,
+                                                  "[E_SYSTEM] The event argument must not be null.");
+
+       transactionId = pHttpTransactionEventArg->GetTransactionId();
+       eventType = pHttpTransactionEventArg->GetEventType();
+
+       pHttpSessoin = __pHttpSessionImpl->GetHttpSession();
+       pHttpTransaction = __pHttpTransactionImpl->GetHttpTransaction();
+
+       pHttpTransactionUserData = __pHttpTransactionImpl->GetHttpTransactionUserData();
+
+       SysLog(NID_NET_HTTP, "The event type is %s. HttpTransaction[%d]", _HttpUtility::ConvertHttpTransactionEventTypeToString(eventType), transactionId);
+
+       switch (eventType)
+       {
+       case _HTTP_TRANSACTION_EVENT_TYPE_UNDEFINED:
+
+               r = E_SYSTEM;
+               SysLogException(NID_NET_HTTP, r, "[E_SYSTEM] The NET_HTTP_TRANSACTION_EVENT_UNDEFINED must not be set.");
+
+               break;
+
+       case _HTTP_TRANSACTION_EVENT_TYPE_HEADER_COMPLETED:
+
+               pHttpResponseImpl = _HttpResponseImpl::GetInstance(*__pHttpTransactionImpl->GetResponse());
+               r = pHttpResponseImpl->Read(pHttpTransactionEventArg->GetReadHeaderLength(), 0, readHeaderLength, readBodyLength);
+               SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, r = E_INVALID_CONTENT, E_INVALID_CONTENT,
+                                       "[E_INVALID_CONTENT] The header format is invalid.");
+
+               SysLog(NID_NET_HTTP, "The value of GetReadHeaderLength() is %d, the readHeaderLength is %d.",
+                          pHttpTransactionEventArg->GetReadHeaderLength(), readHeaderLength);
+
+               //if Http Status Code is 401 or 407
+               if (pHttpResponseImpl->GetHttpStatusCode() == NET_HTTP_STATUS_UNAUTHORIZED || pHttpResponseImpl->GetHttpStatusCode() ==
+                       NET_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED)
+               {
+                       httpAuth = pHttpTransactionEventArg->GetAuthType();
+                       isProxyAuth = pHttpTransactionEventArg->IsProxyAuth();
+
+                       NetHttpAuthScheme authScheme = _HttpUtility::GetHttpAuthScheme(isProxyAuth, httpAuth);
+                       __pHttpTransactionImpl->SetHttpAuthType(authScheme);
+
+                       isAuthRequired = true;
+                       SysLog(NID_NET_HTTP, "The authScheme is %s.", _HttpUtility::GetHttpAuthSchemeByString(authScheme));
+               }
+
+               SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionHeaderCompleted(HeaderLength: %d, AuthRequired: %d, HttpTransaction[%d])",
+                          readHeaderLength, isAuthRequired, transactionId);
+               pHttpTransactionEventListener->OnTransactionHeaderCompleted(*pHttpSessoin, *pHttpTransaction, readHeaderLength, isAuthRequired);
+               SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionHeaderCompleted");
+
+               readHeaderLength = 0;
+               readBodyLength = 0;
+
+               break;
+
+       case _HTTP_TRANSACTION_EVENT_TYPE_READY_TO_READ:
+
+               pHttpResponseImpl = _HttpResponseImpl::GetInstance(*__pHttpTransactionImpl->GetResponse());
+               r = pHttpResponseImpl->Read(0, pHttpTransactionEventArg->GetReadBodyLength(), readHeaderLength, readBodyLength);
+               SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, r = E_INVALID_CONTENT, E_INVALID_CONTENT,
+                                       "[E_INVALID_CONTENT] The header format is invalid.");
+
+               SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionReadyToRead(availableBodyLen: %d, HttpTransaction[%d])",
+                          readBodyLength, transactionId);
+               pHttpTransactionEventListener->OnTransactionReadyToRead(*pHttpSessoin, *pHttpTransaction, readBodyLength);
+               SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionReadyToRead ");
+               readHeaderLength = 0;
+               readBodyLength = 0;
+
+               break;
+
+       case _HTTP_TRANSACTION_EVENT_TYPE_READY_TO_WRITE:
+
+               pHttpRequestImpl = _HttpRequestImpl::GetInstance(*__pHttpTransactionImpl->GetRequest());
+               pIHttpEntity = pHttpRequestImpl->GetEntity();
+               recommendedSize = pHttpTransactionEventArg->GetRecommendedSize();
+
+               if (pIHttpEntity != null)
+               {
+                       SysLog(NID_NET_HTTP, "####### Calling callback : [IHttpEntity] OnTransactionReadyToWrite(recommendedSize: %d, HttpTransaction[%d])",
+                                  recommendedSize, transactionId);
+
+                       if (pHttpRequestImpl->HasNextData())
+                       {
+                               ByteBuffer* pBuffer = pHttpRequestImpl->GetNextDataN(recommendedSize);
+                               r = GetLastResult();
+                               r = TransExceptionsExclusive(r, E_IO, E_OUT_OF_MEMORY);
+                               SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, , r,
+                                                       "[%s] Failed to get the next data.", GetErrorMessage(r));
+
+                               r = pHttpRequestImpl->WriteBody(*pBuffer);
+                               delete pBuffer;
+                               r = TransExceptionsExclusive(r, E_IO, E_OUT_OF_MEMORY);
+                               SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, , r,
+                                                       "[%s] Failed to write the next data.", GetErrorMessage(r));
+                       }
+                       else
+                       {
+                               ByteBuffer lastChunk;
+                               r = lastChunk.Construct(0);
+                               SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                                       "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                               r = pHttpRequestImpl->WriteBody(lastChunk);
+                               r = TransExceptionsExclusive(r, E_IO, E_OUT_OF_MEMORY);
+                               SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, , r,
+                                                       "[%s] Failed to write the last chunk.", GetErrorMessage(r));
+                       }
+
+               }
+               else
+               {
+                       SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionReadyToWrite(recommendedSize: %d, HttpTransaction[%d])",
+                                  recommendedSize, transactionId);
+                       pHttpTransactionEventListener->OnTransactionReadyToWrite(*pHttpSessoin, *pHttpTransaction, recommendedSize);
+                       SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionReadyToWrite");
+               }
+
+               break;
+
+       case _HTTP_TRANSACTION_EVENT_TYPE_COMPLETD:
+
+               SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionCompleted(HttpTransaction[%d])", transactionId);
+               pHttpTransactionEventListener->OnTransactionCompleted(*pHttpSessoin, *pHttpTransaction);
+               SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionCompleted");
+
+               pHttpTransactionUserData->CloseTransaction();
+               readHeaderLength = 0;
+               readBodyLength = 0;
+
+               break;
+
+       case _HTTP_TRANSACTION_EVENT_TYPE_ABORTED:
+
+               SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionAborted(HttpTransaction(%s)[%d])", GetErrorMessage(pHttpTransactionEventArg->GetError()), transactionId);
+               pHttpTransactionEventListener->OnTransactionAborted(*pHttpSessoin, *pHttpTransaction, pHttpTransactionEventArg->GetError());
+               SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionAborted");
+
+               pHttpTransactionUserData->CloseTransaction();
+
+               break;
+
+       case _HTTP_TRANSACTION_EVENT_TYPE_CERT_VERIFICATION_REQUIRED:
+
+               SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionCertVerificationRequiredN(HttpTransaction[%d])", transactionId);
+               __pHttpTransactionImpl->SetCertRequiredEventFired(true);
+               pHttpTransactionEventListener->OnTransactionCertVerificationRequiredN(*pHttpSessoin, *pHttpTransaction, pHttpTransactionEventArg->GetServerCert());
+               SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionCertVerificationRequiredN");
+
+               break;
+
+       case _HTTP_TRANSACTION_EVENT_TYPE_UPLOAD_PROGRESS:
+
+               currentUploadProgress = pHttpTransactionEventArg->GetCurrentUploadProgress();
+               totalUploadProgress = pHttpTransactionEventArg->GetTotalUploadProgress();
+
+               SysLog(NID_NET_HTTP, "####### Calling callback : OnHttpUploadInProgress(%lld/%lld, HttpTransaction[%d])",
+                          currentUploadProgress, totalUploadProgress, transactionId);
+               __pHttpProgressListener->OnHttpUploadInProgress(*pHttpSessoin, *pHttpTransaction, currentUploadProgress, totalUploadProgress);
+               SysLog(NID_NET_HTTP, "####### Called callback : OnHttpUploadInProgress");
+
+               break;
+
+       case _HTTP_TRANSACTION_EVENT_TYPE_DOWNLOAD_PROGRESS:
+
+               currentDownloadProgress = pHttpTransactionEventArg->GetCurrentDownloadProgress();
+               totalDownloadProgress = pHttpTransactionEventArg->GetTotalDownloadProgress();
+
+               SysLog(NID_NET_HTTP, "####### Calling callback : OnHttpDownloadInProgress(%lld/%lld, HttpTransaction[%d])",
+                          currentDownloadProgress, totalDownloadProgress, transactionId);
+               __pHttpProgressListener->OnHttpDownloadInProgress(*pHttpSessoin, *pHttpTransaction, currentDownloadProgress, totalDownloadProgress);
+               SysLog(NID_NET_HTTP, "####### Called callback : OnHttpDownloadInProgress");
+
+               break;
+
+       default:
+               r = E_SYSTEM;
+               SysLogException(NID_NET_HTTP, r, "[E_SYSTEM] The eventType is invalid.");
+               SysAssertf(false, "[E_SYSTEM] The eventType is invalid.");
+
+               break;
+
+       }
+
+       SysLog(NID_NET_HTTP, "Called FireImpl.");
+
+       return;
+
+CATCH:
+
+       SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionAborted(HttpTransaction[%d])", transactionId);
+       pHttpTransactionEventListener->OnTransactionAborted(*pHttpSessoin, *pHttpTransaction, r);
+       SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionAborted");
+
+       pHttpTransactionUserData->CloseTransaction();
+
+       return;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpTransactionEvent.h b/src/http/FNetHttp_HttpTransactionEvent.h
new file mode 100644 (file)
index 0000000..a958819
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpTransactionEvent.h
+ * @brief              This is the header file for %_HttpTransactionEvent class.
+ *
+ * This header file contains the declarations of _HttpTransactionEvent class.
+ * The _HttpTransactionEvent class can call listener's method. So, when an event is occurred,
+ * application can handle it appropriately.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_TRANSACTION_EVENT_H_
+#define _FNET_HTTP_INTERNAL_HTTP_TRANSACTION_EVENT_H_
+
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpIHttpProgressEventListener.h>
+#include <FBaseRt_Event.h>
+#include "FNetHttp_HttpCommon.h"
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpSessionImpl;
+class _HttpTransactionImpl;
+/**
+ * @class      _HttpTransactionEvent
+ * @brief      This class handles an Http Transaction event. It is inherited from Event class.
+ *
+ * @since 2.1
+ *
+ * When an Http Transaction event is occurred, the __HttpTransactionEvent class finds listener and calls
+ * the appropriate listener's method. @n
+ */
+
+class _HttpTransactionEvent
+       : public Tizen::Base::Runtime::_Event
+{
+
+public:
+       _HttpTransactionEvent(void);
+
+       ~_HttpTransactionEvent(void);
+
+       result Construct(_HttpSessionImpl* pHttpSessionImpl, _HttpTransactionImpl* pHttpTransactionImpl);
+
+       result SetHttpProgressListener(const IHttpProgressEventListener* pListener);
+
+       result FireTransactionReadyToReadEvent(int readBodyLength, bool async = false);
+
+       result FireTransactionReadyToWriteEvent(int recommenedLength, bool async = false);
+
+       result FireTransactionHeaderCompletedEvent(int headerLength, long proxyAuth, long httpAuth, bool async = false);
+
+       result FireTransactionCertVerificationRequiredNEvent(Tizen::Base::String* pServerCert, bool async = false);
+
+       result FireTransactionCompletedEvent(bool async = false);
+
+       result FireTransactionAbortedEvent(result error, bool async = false);
+
+       result FireHttpUploadInProgressEvent(int currentLength, int totalLength, bool async = false);
+
+       result FireHttpDownloadInProgressEvent(int currentLength, int totalLength, bool async = false);
+
+protected:
+       virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+       _HttpTransactionEvent(const _HttpTransactionEvent& rhs);
+
+       _HttpTransactionEvent& operator =(const _HttpTransactionEvent& rhs);
+
+private:
+       _HttpSessionImpl* __pHttpSessionImpl;
+       _HttpTransactionImpl* __pHttpTransactionImpl;
+       IHttpProgressEventListener* __pHttpProgressListener;
+       int __transactionId;
+
+}; // _HttpTransactionEvent
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_TRANSACTION_EVENT_H_
diff --git a/src/http/FNetHttp_HttpTransactionEventArg.cpp b/src/http/FNetHttp_HttpTransactionEventArg.cpp
new file mode 100644 (file)
index 0000000..26b6ae3
--- /dev/null
@@ -0,0 +1,192 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpTransactionEventArg.cpp
+ * @brief              This is the implementation file for _HttpTransactionEventArg class.
+ */
+
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpTransactionImpl.h"
+#include "FNetHttp_HttpTransactionEvent.h"
+#include "FNetHttp_HttpTransactionEventArg.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpTransactionEventArg::_HttpTransactionEventArg(int transactionId, _HttpTransactionEventType eventType)
+       : __transactionId(transactionId)
+       , __eventType(eventType)
+       , __result(E_SUCCESS)
+       , __readHeaderLength(0)
+       , __httpAuth(0)
+       , __isProxyAuth(false)
+       , __readBodyLength(0)
+       , __recommendedSize(0)
+       , __uploadCurrentProgress(0)
+       , __uploadTotalProgress(0)
+       , __downloadCurrentProgress(0)
+       , __downloadTotalProgress(0)
+       , __pServerCert(null)
+{
+}
+
+_HttpTransactionEventArg::~_HttpTransactionEventArg(void)
+{
+       __transactionId = -1;
+       __eventType = _HTTP_TRANSACTION_EVENT_TYPE_UNDEFINED;
+       __result = E_SUCCESS;
+       __readHeaderLength = 0;
+       __readBodyLength = 0;
+}
+
+int
+_HttpTransactionEventArg::GetTransactionId() const
+{
+       return __transactionId;
+}
+
+_HttpTransactionEventType
+_HttpTransactionEventArg::GetEventType()
+{
+
+       return __eventType;
+}
+
+void
+_HttpTransactionEventArg::SetError(result error)
+{
+       __result = error;
+}
+
+result
+_HttpTransactionEventArg::GetError() const
+{
+       return __result;
+}
+
+void
+_HttpTransactionEventArg::SetReadHeaderLength(int readHeaderLength)
+{
+       __readHeaderLength = readHeaderLength;
+}
+
+int
+_HttpTransactionEventArg::GetReadHeaderLength(void) const
+{
+       return __readHeaderLength;
+}
+
+void
+_HttpTransactionEventArg::SetAuthType(long httpAuth)
+{
+       __httpAuth = httpAuth;
+}
+long
+_HttpTransactionEventArg::GetAuthType(void) const
+{
+       return __httpAuth;
+}
+
+void
+_HttpTransactionEventArg::SetProxyAuth(bool isProxyAuth)
+{
+       __isProxyAuth = isProxyAuth;
+}
+
+bool
+_HttpTransactionEventArg::IsProxyAuth(void) const
+{
+       return __isProxyAuth;
+}
+
+void
+_HttpTransactionEventArg::SetReadBodyLength(int readBodyLength)
+{
+       __readBodyLength = readBodyLength;
+}
+int
+_HttpTransactionEventArg::GetReadBodyLength(void) const
+{
+       return __readBodyLength;
+}
+
+void
+_HttpTransactionEventArg::SetRecommendedSize(int recommendedSize)
+{
+       __recommendedSize = recommendedSize;
+}
+
+int
+_HttpTransactionEventArg::GetRecommendedSize(void) const
+{
+       return __recommendedSize;
+}
+
+void
+_HttpTransactionEventArg::SetUploadProgress(long long currentSize, long long totalSize)
+{
+       __uploadCurrentProgress = currentSize;
+       __uploadTotalProgress = totalSize;
+}
+
+long long
+_HttpTransactionEventArg::GetCurrentUploadProgress(void) const
+{
+       return __uploadCurrentProgress;
+}
+
+long long
+_HttpTransactionEventArg::GetTotalUploadProgress(void) const
+{
+       return __uploadTotalProgress;
+}
+
+void
+_HttpTransactionEventArg::SetDownloadProgress(long long currentSize, long long totalSize)
+{
+       __downloadCurrentProgress = currentSize;
+       __downloadTotalProgress = totalSize;
+}
+
+long long
+_HttpTransactionEventArg::GetCurrentDownloadProgress(void) const
+{
+       return __downloadCurrentProgress;
+}
+
+long long
+_HttpTransactionEventArg::GetTotalDownloadProgress(void) const
+{
+       return __downloadTotalProgress;
+}
+
+void
+_HttpTransactionEventArg::SetServerCert(String* pServerCert)
+{
+       __pServerCert = pServerCert;
+}
+
+String*
+_HttpTransactionEventArg::GetServerCert(void) const
+{
+       return __pServerCert;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpTransactionEventArg.h b/src/http/FNetHttp_HttpTransactionEventArg.h
new file mode 100644 (file)
index 0000000..ee733a1
--- /dev/null
@@ -0,0 +1,122 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpTransactionEventArg.h
+ * @brief              This is the header file for %_HttpTransactionEventArg class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_TRANSACTION_EVENT_ARG_H_
+#define _FNET_HTTP_INTERNAL_HTTP_TRANSACTION_EVENT_ARG_H_
+
+#include <FBaseRtIEventArg.h>
+#include "FNetHttp_HttpCommon.h"
+
+namespace Tizen { namespace Base
+{
+class String;
+} }
+
+namespace Tizen { namespace Net { namespace Http
+{
+/**
+ * @class      _HttpTransactionEventArg FNetHttp_HttpTransactionEventArg.h "OspdOaf/FNet/H/FNetHttp_HttpTransactionEventArg.h"
+ * @brief      This class is used as an argument on firing a Transaction Event.
+ *
+ * @since 2.1
+ *
+ * _HttpTransactionEventArg::FireImpl() receives an argument of this type, when any %Http Transaction event is generated.
+ */
+
+class _HttpTransactionEventArg
+       : public Tizen::Base::Object
+       , public Tizen::Base::Runtime::IEventArg
+{
+
+public:
+       _HttpTransactionEventArg(int transactionId, _HttpTransactionEventType eventType);
+
+       ~_HttpTransactionEventArg(void);
+
+       int GetTransactionId(void) const;
+
+       _HttpTransactionEventType GetEventType(void);
+
+       void SetError(result error);
+
+       result GetError(void) const;
+
+       void SetReadHeaderLength(int readHeaderLength);
+
+       int GetReadHeaderLength(void) const;
+
+       void SetAuthType(long httpAuth);
+
+       long GetAuthType(void) const;
+
+       void SetProxyAuth(bool isProxyAuth);
+
+       bool IsProxyAuth(void) const;
+
+       void SetReadBodyLength(int readBodyLength);
+
+       int GetReadBodyLength(void) const;
+
+       void SetRecommendedSize(int recommendedSize);
+
+       int GetRecommendedSize(void) const;
+
+       void SetUploadProgress(long long currentSize, long long totalSize);
+
+       long long GetCurrentUploadProgress(void) const;
+
+       long long GetTotalUploadProgress(void) const;
+
+       void SetDownloadProgress(long long currentSize, long long totalSize);
+
+       long long GetCurrentDownloadProgress(void) const;
+
+       long long GetTotalDownloadProgress(void) const;
+
+       void SetServerCert(Tizen::Base::String* pServerCert);
+
+       Tizen::Base::String* GetServerCert(void) const;
+
+private:
+       _HttpTransactionEventArg(const _HttpTransactionEventArg& rhs);
+
+       _HttpTransactionEventArg& operator =(const _HttpTransactionEventArg& rhs);
+
+private:
+       int __transactionId;
+       _HttpTransactionEventType __eventType;
+       result __result;
+       int __readHeaderLength;
+       long __httpAuth;
+       bool __isProxyAuth;
+       int __readBodyLength;
+       int __recommendedSize;
+       long long __uploadCurrentProgress;
+       long long __uploadTotalProgress;
+       long long __downloadCurrentProgress;
+       long long __downloadTotalProgress;
+       Tizen::Base::String* __pServerCert;
+
+}; // _HttpTransactionEventArg
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_TRANSACTION_EVENT_ARG_H_
diff --git a/src/http/FNetHttp_HttpTransactionImpl.cpp b/src/http/FNetHttp_HttpTransactionImpl.cpp
new file mode 100644 (file)
index 0000000..6e1bf75
--- /dev/null
@@ -0,0 +1,1874 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpTransactionImpl.cpp
+ * @brief              This is the implementation file for _HttpTransactionImpl class.
+ */
+
+#include <unique_ptr.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <vconf.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseUtilStringUtil.h>
+#include <FIoDirectory.h>
+#include <FAppApp.h>
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpHttpRequest.h>
+#include <FNetHttpHttpResponse.h>
+#include <FNetHttpHttpHeader.h>
+#include <FNetHttpHttpSession.h>
+#include <FNetHttpHttpAuthentication.h>
+#include <FNetHttpIHttpTransactionEventListener.h>
+#include <FNetHttpIHttpEntity.h>
+#include <FNetHttpIHttpProgressEventListener.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FBaseRt_EventDispatcher.h>
+#include <FSecCert_CertService.h>
+#include <FSecCert_CertServiceProxy.h>
+#include "FNet_ManagedNetConnectionImpl.h"
+#include "FNetHttp_HttpCommon.h"
+#include "FNetHttp_HttpMultipleConnectionInfo.h"
+#include "FNetHttp_HttpTransactionImpl.h"
+#include "FNetHttp_HttpTransactionUserData.h"
+#include "FNetHttp_HttpCurl.h"
+#include "FNetHttp_HttpDeleter.h"
+#include "FNetHttp_HttpSocketInfo.h"
+#include "FNetHttp_HttpHeaderImpl.h"
+#include "FNetHttp_HttpSessionImpl.h"
+#include "FNetHttp_HttpRequestImpl.h"
+#include "FNetHttp_HttpResponseImpl.h"
+#include "FNetHttp_HttpAuthenticationImpl.h"
+#include "FNetHttp_HttpTransactionEvent.h"
+#include "FNetHttp_HttpTransactionEventArg.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Security::Cert;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+int _HttpTransactionImpl::__generatedTransactionId = -1;
+
+_HttpTransactionImpl::_HttpTransactionImpl(HttpTransaction* pHttpTransaction)
+       : __transactionId(-1)
+       , __sessionId(-1)
+       , __pHttpSessionImpl(null)
+       , __pHttpMultipleConnectionInfo(null)
+       , __pHttpTransaction(pHttpTransaction)
+       , __pHttpRequest(null)
+       , __pHttpResponse(null)
+       , __pHttpTransactionEvent(null)
+       , __authType(NET_HTTP_AUTH_NONE)
+       , __pHttpAuthenticationImpl(null)
+       , __pRequestBuffer(null)
+       , __pUserData(null)
+       , __isClosed(false)
+       , __isCanceled(false)
+       , __isSubmitted(false)
+       , __isPendingTransaction(false)
+       , __enableTransactionReadyToWrite(false)
+       , __isHeaderEventFired(false)
+       , __uploadCurrentProgress(0)
+       , __donwloadCurrentProgress(0)
+       , __timeout(0)
+       , __certificateId(-1)
+       , __isAlreadyResumed(false)
+       , __isAlreadyPaused(false)
+       , __isCertRequiredEventFired(false)
+       , __pHttpProgressListener(null)
+       , __pHttpTransactionUserData(null)
+       , __pHttpCurl(null)
+       , __pTimerSource(null)
+{
+}
+
+_HttpTransactionImpl::~_HttpTransactionImpl(void)
+{
+       SysLog(NID_NET_HTTP, "The _HttpTransactionImpl instance will be deleted.");
+
+       Dispose();
+
+       if (__pHttpRequest != null)
+       {
+               _HttpRequestImpl::DeleteHttpRequest(__pHttpRequest);
+               __pHttpRequest = null;
+       }
+
+       if (__pHttpResponse != null)
+       {
+               _HttpResponseImpl::DeleteHttpResponse(__pHttpResponse);
+               __pHttpResponse = null;
+       }
+
+       if (__pHttpTransactionUserData != null)
+       {
+               __pHttpTransactionUserData->__pHttpTransactionImpl = null;
+               __pHttpTransactionUserData->Release();
+       }
+
+       if (__pHttpAuthenticationImpl != null)
+       {
+               delete __pHttpAuthenticationImpl;
+               __pHttpAuthenticationImpl = null;
+       }
+
+       if (__pHttpCurl != null)
+       {
+               __pHttpCurl->Release();
+       }
+
+       __transactionListenerList.RemoveAll();
+
+       if (__pHttpTransactionEvent != null)
+       {
+               delete __pHttpTransactionEvent;
+               __pHttpTransactionEvent = null;
+       }
+
+       if (__pRequestBuffer != null)
+       {
+               delete __pRequestBuffer;
+               __pRequestBuffer = null;
+       }
+
+       if (__pTimerSource != null)
+       {
+               int timerId = g_source_get_id(__pTimerSource);
+               g_source_set_callback(__pTimerSource, null, null, null);
+               SysLog(NID_NET_HTTP, "Deleted g_source_destroy(%d)", timerId);
+               g_source_destroy(__pTimerSource);
+               g_source_unref(__pTimerSource);
+               __pTimerSource = null;
+               SysLog(NID_NET_HTTP, "Cancelled the TimerSource[%d] of HttpTransaction[%d].", timerId, __transactionId);
+       }
+
+       __pHttpMultipleConnectionInfo = null;
+
+       SysLog(NID_NET_HTTP, "The _HttpTransactionImpl instance was deleted.");
+}
+
+result
+_HttpTransactionImpl::Construct(_HttpSessionImpl& httpSessionImpl, HttpHeader* pCommonHeader, CURL* pCurl)
+{
+       result r = E_SUCCESS;
+
+       bool isCreatedCurl = false;
+       unique_ptr<HttpRequest, _HttpRequestDeleter> pHttpRequest;
+       unique_ptr<HttpResponse, _HttpResponseDeleter> pHttpResponse;
+       unique_ptr<_HttpTransactionEvent> pHttpTransactionEvent;
+       unique_ptr<_HttpTransactionUserData> pHttpTransactionUserData;
+
+       SysTryReturnResult(NID_NET_HTTP, __isClosed == false,
+                                          E_INVALID_STATE, "Already closed.");
+
+       __pHttpSessionImpl = &httpSessionImpl;
+       __pHttpMultipleConnectionInfo = __pHttpSessionImpl->GetHttpMultipleConnectionInfo();
+       SysTryReturnResult(NID_NET_HTTP, __pHttpMultipleConnectionInfo != null,
+                                          E_SYSTEM, "__pHttpMultipleConnectionInfo is null.");
+
+       __sessionId = __pHttpSessionImpl->GetSessionId();
+
+       pHttpRequest.reset(_HttpRequestImpl::CreateHttpRequestN());
+       SysTryReturnResult(NID_NET_HTTP, pHttpRequest != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = _HttpRequestImpl::GetInstance(*pHttpRequest)->Construct(*this, pCommonHeader);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       pHttpResponse.reset(_HttpResponseImpl::CreateHttpResponseN());
+       SysTryReturnResult(NID_NET_HTTP, pHttpResponse != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = _HttpResponseImpl::GetInstance(*pHttpResponse)->Construct(*this);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       if (pCurl == null)
+       {
+               pCurl = curl_easy_init();
+               SysTryReturnResult(NID_NET_HTTP, pCurl != null, E_SYSTEM, "Failed to call curl_easy_init(), the pCurl must not be null.");
+               SysLog(NID_NET_HTTP, "Created an instance of CURL. [%x]", pCurl);
+               isCreatedCurl = true;
+       }
+       else
+       {
+               SysLog(NID_NET_HTTP, "Reused the pCurl[%x]", pCurl);
+       }
+
+       __pHttpCurl = new (std::nothrow) _HttpCurl(pCurl, false);
+       if (__pHttpCurl == null)
+       {
+               if (isCreatedCurl)
+               {
+                       curl_easy_cleanup(pCurl);
+               }
+               r = E_OUT_OF_MEMORY;
+               SysLogException(NID_NET_HTTP, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               goto CATCH;
+       }
+
+       __transactionId = GenerateTransactionId();
+       __transactionListenerList.Construct();
+
+       pHttpTransactionEvent.reset(new (std::nothrow) _HttpTransactionEvent());
+       SysTryCatch(NID_NET_HTTP, pHttpTransactionEvent != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       pHttpTransactionEvent->Construct(__pHttpSessionImpl, this);
+
+       pHttpTransactionUserData.reset(new (std::nothrow) _HttpTransactionUserData(this, __pHttpCurl));
+       SysTryCatch(NID_NET_HTTP, pHttpTransactionUserData != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       __pHttpRequest = pHttpRequest.release();
+       __pHttpResponse = pHttpResponse.release();
+       __pHttpTransactionEvent = pHttpTransactionEvent.release();
+       __pHttpTransactionUserData = pHttpTransactionUserData.release();
+
+       SysLog(NID_NET_HTTP, "The HttpTransaction[%d] was constructed.", __transactionId);
+
+       return r;
+
+CATCH:
+
+       if (__pHttpCurl != null)
+       {
+               __pHttpCurl->Release();
+               __pHttpCurl = null;
+       }
+
+       return r;
+}
+
+HttpTransaction*
+_HttpTransactionImpl::CreateHttpTransactionN(void)
+{
+       return new (std::nothrow) HttpTransaction();
+}
+
+void
+_HttpTransactionImpl::DeleteHttpTransaction(HttpTransaction* pHttpTransaction)
+{
+       delete pHttpTransaction;
+}
+
+result
+_HttpTransactionImpl::Dispose()
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __isClosed == false,
+                                          E_INVALID_STATE, "HttpTransaction[%d] is already closed.", __transactionId);
+
+       r = __pHttpSessionImpl->CloseTransaction(*__pHttpTransaction);
+
+       return r;
+}
+
+result
+_HttpTransactionImpl::Close(void)
+{
+       result r = E_SUCCESS;
+
+       IEnumeratorT< IHttpTransactionEventListener* >* pEnum = null;
+       IHttpTransactionEventListener* pHttpTransactionEventListener = null;
+       int sockFd = 0;
+
+       pEnum = __transactionListenerList.GetEnumeratorN();
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               r = pEnum->GetCurrent(pHttpTransactionEventListener);
+
+               if (pHttpTransactionEventListener != null)
+                       __pHttpTransactionEvent->RemoveListener(*pHttpTransactionEventListener);
+       }
+       delete pEnum;
+
+       if (__pHttpTransactionUserData->GetSocketFd() >= 0)
+       {
+               sockFd = __pHttpTransactionUserData->GetSocketFd();
+               SysLog(NID_NET_HTTP, "The socket(%d) was closed.", sockFd);
+       }
+
+       __isClosed = true;
+
+       __pHttpTransactionUserData->__isAlreadyClosedTransaction = true;
+
+       __pHttpTransactionUserData->__isAbortedTransaction = true;
+
+       SysLog(NID_NET_HTTP, "The HttpTransaction[%d] was closed.", __transactionId);
+
+       ClearLastResult();
+
+       return E_SUCCESS;
+}
+
+result
+_HttpTransactionImpl::Abort(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __isClosed == false,
+                                          E_INVALID_STATE, "HttpTransaction[%d] is already closed.", __transactionId);
+
+       if (__pHttpTransactionUserData->GetSocketFd() >= 0)
+       {
+               int sockFd = __pHttpTransactionUserData->GetSocketFd();
+               SysLog(NID_NET_HTTP, "SocketFd(%d) will be closed. HttpTransaction[%d]", sockFd, __transactionId);
+               close(sockFd);
+               SysLog(NID_NET_HTTP, "Socket was closed. HttpTransaction[%d]");
+
+       }
+       __pHttpTransactionUserData->__isAbortedTransaction = true;
+
+       return r;
+}
+
+String
+_HttpTransactionImpl::GetDefaultUserAgent(void)
+{
+       ClearLastResult();
+
+       SysLog(NID_NET_HTTP, "Set the Default User-Agent.");
+
+       char* pUserAgent = vconf_get_str(VCONFKEY_BROWSER_USER_AGENT);
+       SysAssertf(pUserAgent != null, "Failed to get default user agent(VCONFKEY_BROWSER_USER_AGENT)");
+
+       String userAgent(pUserAgent);
+       SysLog(NID_NET_HTTP, "Default User-Agent is %ls.", userAgent.GetPointer());
+       free(pUserAgent);
+
+       return userAgent;
+}
+
+result
+_HttpTransactionImpl::Submit(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __isClosed == false,
+                                          E_INVALID_STATE, "HttpTransaction[%d] is already closed.", __transactionId);
+
+       SysTryReturnResult(NID_NET_HTTP, __isSubmitted == false,
+                                          E_INVALID_STATE, "HttpTransaction[%d] is already submitted.", __transactionId);
+
+       SysTryReturnResult(NID_NET_HTTP, __pHttpSessionImpl->IsSessionValid(),
+                                          E_INVALID_SESSION, "The HttpSession is invalid. Construct a new HttpSession.");
+
+       CURL* pCurl = null;
+       CURLMcode rc;
+       char* pUrl = null;
+       char* pMethodName = null;
+       struct curl_slist* pRequestHeaderList = null;
+
+       HttpVersion httpVersion;
+       String hostAddress;
+       String url;
+       bool hasProtocolScheme = false;
+       bool compareHost = false;
+       String methodName;
+       String contentLength;
+       HttpHeader* pHeader = null;
+       _HttpHeaderImpl* pHeaderImpl = null;
+       _HttpRequestImpl* pRequestImpl = null;
+
+       ByteBuffer* pBodyBuffer = null;
+       int bodySize = 0;
+       long long contentLen = -1;
+       NetHttpAuthScheme authScheme = NET_HTTP_AUTH_NONE;
+       String outFiledName;
+       String encoding;
+
+       bool isEnableOnHttpBodyReadyToWrite = false;
+
+       SysLog(NID_NET_HTTP, "The HttpTransaction[%d] will be submitted. HttpSessionId[%d]", __transactionId, __sessionId);
+
+       pRequestImpl = _HttpRequestImpl::GetInstance(*__pHttpRequest);
+       pHeader = pRequestImpl->GetHeader();
+       SysTryReturnResult(NID_NET_HTTP, pHeader != null,
+                                          E_SYSTEM, "The header must not be null.");
+
+       pHeaderImpl = _HttpHeaderImpl::GetInstance(*pHeader);
+       SysTryReturnResult(NID_NET_HTTP, pHeaderImpl != null,
+                                          E_SYSTEM, "The header must not be null.");
+
+       pCurl = __pHttpCurl->GetCurl();
+       SysTryReturnResult(NID_NET_HTTP, pCurl != null,
+                                          E_SYSTEM, "The Curl must not be null.");
+
+       //Set the http version.
+       httpVersion = pRequestImpl->GetVersion();
+       if (httpVersion == HTTP_VERSION_1_0)
+       {
+               curl_easy_setopt(pCurl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
+       }
+       else
+       {
+               curl_easy_setopt(pCurl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
+       }
+
+       //Check if the host of url equals the host address of HttpSession.
+       r = pRequestImpl->GetUri(url);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS && url.IsEmpty() == false,
+                                          E_INVALID_ARG, "Failed to get the uri.");
+
+       SysLog(NID_NET_HTTP, "The request uri is %ls.", url.GetPointer());
+
+       hostAddress = __pHttpSessionImpl->GetHostAddress();
+
+       hasProtocolScheme = _HttpUtility::HasProtocolScheme(url);
+       if (!hasProtocolScheme)
+       {
+               if (__pHttpSessionImpl->GetSessionMode() == NET_HTTP_SESSION_MODE_MULTIPLE_HOST)
+               {
+                       url = _HTTP_PROTOCOL_SCHEME + url;
+               }
+               else
+               {
+                       //Add the scheme of host address.
+                       String scheme = _HttpUtility::GetProtocolScheme(hostAddress);
+                       scheme.Trim();
+                       url = scheme + url;
+                       SysLog(NID_NET_HTTP, "Added the scheme to url(%ls).", url.GetPointer());
+               }
+
+               SysLog(NID_NET_HTTP, "Added the scheme to url(%ls).", url.GetPointer());
+       }
+
+       //Compare the host of HttpSessoin with the host of uri.
+       if (__pHttpSessionImpl->GetSessionMode() != NET_HTTP_SESSION_MODE_MULTIPLE_HOST)
+       {
+               compareHost = _HttpUtility::CompareHost(hostAddress, url);
+               r = GetLastResult();
+               r = TransExceptionsExclusive(r, E_INVALID_ARG, E_OUT_OF_MEMORY);
+               SysTryReturnResult(NID_NET_HTTP, compareHost,
+                                                  r, "The host address(%ls) of HttpSession is different with url(%ls).", hostAddress.GetPointer(), url.GetPointer());
+       }
+
+       pUrl = _StringConverter::CopyToCharArrayN(url);
+       SysTryReturnResult(NID_NET_HTTP, pUrl != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       //Set the url.
+       curl_easy_setopt(pCurl, CURLOPT_URL, pUrl);
+       delete[] pUrl;
+
+       //Set the network interface.
+       if (!__pHttpSessionImpl->GetDeviceName().IsEmpty())
+       {
+               char* pDeviceName = _StringConverter::CopyToCharArrayN(__pHttpSessionImpl->GetDeviceName());
+               SysTryReturnResult(NID_NET_HTTP, pDeviceName != null,
+                                                  E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               SysLog(NID_NET_HTTP, "[Target] The device name is %s.", pDeviceName);
+               curl_easy_setopt(pCurl, CURLOPT_INTERFACE, pDeviceName);
+               delete[] pDeviceName;
+       }
+
+       //Set the proxy address.
+       if (__pHttpSessionImpl->GetProxyAddress() != null)
+       {
+               char* pProxyAddress = _StringConverter::CopyToCharArrayN(*__pHttpSessionImpl->GetProxyAddress());
+               SysTryReturnResult(NID_NET_HTTP, pProxyAddress != null,
+                                                  E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               curl_easy_setopt(pCurl, CURLOPT_PROXY, pProxyAddress);
+               delete[] pProxyAddress;
+       }
+
+       //Set the method.
+       methodName = pRequestImpl->GetMethodName();
+       SysTryReturnResult(NID_NET_HTTP, !methodName.IsEmpty(), E_INVALID_ARG, "Method name is empty.");
+
+       pMethodName = _StringConverter::CopyToCharArrayN(methodName);
+       curl_easy_setopt(pCurl, CURLOPT_CUSTOMREQUEST, pMethodName);
+       delete[] pMethodName;
+
+       //Set the user-agent.
+       if (!pHeaderImpl->HasHeader(_HTTP_USERAGENT_HEADER_NAME, outFiledName))
+       {
+               SysLog(NID_NET_HTTP, "Set the default user agent.");
+               String userAgent = GetDefaultUserAgent();
+               SysTryReturnResult(NID_NET_HTTP, userAgent.IsEmpty() == false, E_SYSTEM, "Default User-Agent is empty.");
+
+               r = pHeaderImpl->AddField(_HTTP_USERAGENT_HEADER_NAME, userAgent);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                  r, "Propagating.");
+       }
+
+       //Set the headers.
+       pRequestHeaderList = pHeaderImpl->MakeCurlHeaderList();
+       if (pRequestHeaderList != null)
+       {
+               curl_easy_setopt(pCurl, CURLOPT_HTTPHEADER, pRequestHeaderList);
+               __pHttpTransactionUserData->__pCurlRequestHeaderList = pRequestHeaderList;
+       }
+
+       //Set the cookie.
+       if (__pHttpSessionImpl->GetHttpCookieFlag() == NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL)
+       {
+               if (pRequestImpl->HasCookie())
+               {
+                       String cookies = pRequestImpl->GetCookie();
+                       SysLog(NID_NET_HTTP, "Set the Cookies(%ls).", cookies.GetPointer());
+                       char* pCookies = _StringConverter::CopyToCharArrayN(cookies);
+                       SysTryReturnResult(NID_NET_HTTP, pCookies != null,
+                                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                       curl_easy_setopt(pCurl, CURLOPT_COOKIE, pCookies);
+                       delete[] pCookies;
+               }
+
+       }
+       else if (__pHttpSessionImpl->GetHttpCookieFlag() == NET_HTTP_COOKIE_FLAG_ALWAYS_AUTOMATIC)
+       {
+               String filePath = _HttpUtility::GetCookieFilePath();
+               r = GetLastResult();
+               r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+               SysTryReturnResult(NID_NET_HTTP, !filePath.IsEmpty(), r, "Failed to get cookie path of system.");
+
+               char* pFilePath = _StringConverter::CopyToCharArrayN(filePath);
+               SysTryReturnResult(NID_NET_HTTP, pFilePath != null,
+                                                  E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               curl_easy_setopt(pCurl, CURLOPT_COOKIEFILE, pFilePath);
+               curl_easy_setopt(pCurl, CURLOPT_COOKIEJAR, pFilePath);
+
+               delete[] pFilePath;
+
+               SysLog(NID_NET_HTTP, "Set the Cookies automatically.");
+       }
+
+       encoding = pRequestImpl->GetAcceptEncoding();
+
+       if (!encoding.IsEmpty())
+       {
+               char* pEncodingType = _StringConverter::CopyToCharArrayN(encoding);
+               SysTryReturnResult(NID_NET_HTTP, pEncodingType != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               curl_easy_setopt(pCurl, CURLOPT_ENCODING, pEncodingType);
+               delete[] pEncodingType;
+       }
+
+       if (pHeaderImpl->GetHeaderValue(_HTTP_CONTENT_LENGTH_HEADER_NAME, contentLength))
+       {
+               r = LongLong::Parse(contentLength, contentLen);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                  E_INVALID_ARG, "Failed to parse the content-length.");
+               //Set Content-Length
+               if (contentLen >= 0)
+               {
+                       curl_easy_setopt(pCurl, CURLOPT_POSTFIELDSIZE_LARGE, static_cast< curl_off_t >(contentLen));
+                       SysLog(NID_NET_HTTP, "Set the Content-Length(%lld).", contentLen);
+               }
+
+               SysLog(NID_NET_HTTP, "The Content-Length is %lld.", contentLen);
+       }
+       else
+       {
+               SysLog(NID_NET_HTTP, "The Content-Length is not set.");
+       }
+
+       bodySize = pRequestImpl->GetTotalBodyLength();
+
+       if (__enableTransactionReadyToWrite)
+       {
+               if (contentLen >= 0 && contentLen <= bodySize)
+               {
+                       SysLog(NID_NET_HTTP, "Content-Length(%lld) is equals or less than the bodySize(%u).", contentLen, bodySize);
+                       isEnableOnHttpBodyReadyToWrite = false;
+               }
+               else
+               {
+                       isEnableOnHttpBodyReadyToWrite = true;
+               }
+               SysLog(NID_NET_HTTP, "The isEnableOnHttpBodyReadyToWrite is %d.", isEnableOnHttpBodyReadyToWrite);
+       }
+
+       //Set the content and content size.
+       if (!isEnableOnHttpBodyReadyToWrite)
+       {
+               if (!pRequestImpl->IsEmptyBody())
+               {
+                       if (__pRequestBuffer != null)
+                       {
+                               delete __pRequestBuffer;
+                       }
+
+                       __pRequestBuffer = pRequestImpl->ReadAllBodyN();
+
+                       pBodyBuffer = pRequestImpl->ReadBodyN();
+                       if (pBodyBuffer != null)
+                       {
+                               int bodySize = pBodyBuffer->GetRemaining();
+                               const byte* pBodyBytes = pBodyBuffer->GetPointer();
+
+                               curl_easy_setopt(pCurl, CURLOPT_COPYPOSTFIELDS, pBodyBytes);
+                               delete pBodyBuffer;
+
+                               SysLog(NID_NET_HTTP, "The Body Size is %d.", bodySize);
+                       }
+               }
+       }
+
+       //The connection timeout is 30s. (default)
+       curl_easy_setopt(pCurl, CURLOPT_CONNECTTIMEOUT, _HTTP_DEFAULT_CONNECTION_TIMEOUT);
+
+       //Set the transaction timeout. The timeout includes connection timeout.
+       if (__timeout > 0)
+       {
+               curl_easy_setopt(pCurl, CURLOPT_TIMEOUT, __timeout);
+       }
+       else if (__timeout == 0)
+       {
+               curl_easy_setopt(pCurl, CURLOPT_LOW_SPEED_LIMIT, 1L);
+               curl_easy_setopt(pCurl, CURLOPT_LOW_SPEED_TIME, 30L);
+       }
+
+       //Set default CA path.
+       String caPath = _CertService::GetCertificateCrtFilePath();
+       SysLog(NID_NET_HTTP, "The CA Path is %ls.", caPath.GetPointer());
+
+       char* pCaPath = _StringConverter::CopyToCharArrayN(caPath);
+       SysTryReturnResult(NID_NET_HTTP, pCaPath != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       curl_easy_setopt(pCurl, CURLOPT_CAINFO, pCaPath);
+       curl_easy_setopt(pCurl, CURLOPT_CAPATH, null);
+       delete[] pCaPath;
+
+       curl_easy_setopt(pCurl, CURLOPT_SSL_VERIFYPEER, 0);
+       curl_easy_setopt(pCurl, CURLOPT_SSL_VERIFYHOST, 2);
+
+       if (__certificateId >= 0)
+       {
+               SysLog(NID_NET_HTTP, "Set the client certificate(%d)", __certificateId);
+       }
+
+       //Set Redirection
+       if (__pHttpSessionImpl->IsAutoRedirectionEnabled())
+       {
+               curl_easy_setopt(pCurl, CURLOPT_FOLLOWLOCATION, 1L);
+               curl_easy_setopt(pCurl, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
+               SysLog(NID_NET_HTTP, "Enabled Auto-Redirection");
+       }
+       else
+       {
+               curl_easy_setopt(pCurl, CURLOPT_FOLLOWLOCATION, 0L);
+               SysLog(NID_NET_HTTP, "Disabled Auto-Redirection");
+       }
+
+       if (__pHttpAuthenticationImpl != null)
+       {
+               if (__pHttpAuthenticationImpl->IsProxyAuthenticationType())
+               {
+                       String userPwd;
+                       char* pUserPwd = null;
+
+                       userPwd.Append(__pHttpAuthenticationImpl->GetCredentials().GetName());
+                       userPwd.Append(L":");
+                       userPwd.Append(__pHttpAuthenticationImpl->GetCredentials().GetPassword());
+
+                       pUserPwd = _StringConverter::CopyToCharArrayN(userPwd);
+                       if (pUserPwd != null)
+                       {
+                               authScheme = __pHttpAuthenticationImpl->GetAuthScheme();
+                               SysLog(NID_NET_HTTP, "Set the ProxyAuthentication(%s), userPwd",
+                                               _HttpUtility::GetHttpAuthSchemeByString(authScheme));
+
+                               curl_easy_setopt(pCurl, CURLOPT_PROXYAUTH, _HttpUtility::GetHttpCurlAuthScheme(authScheme));
+                               curl_easy_setopt(pCurl, CURLOPT_PROXYUSERPWD, pUserPwd);
+
+                               delete[] pUserPwd;
+                       }
+               }
+               else
+               {
+                       String userPwd;
+                       char* pUserPwd = null;
+
+                       userPwd.Append(__pHttpAuthenticationImpl->GetCredentials().GetName());
+                       userPwd.Append(L":");
+                       userPwd.Append(__pHttpAuthenticationImpl->GetCredentials().GetPassword());
+
+                       pUserPwd = _StringConverter::CopyToCharArrayN(userPwd);
+                       if (pUserPwd != null)
+                       {
+                               authScheme = __pHttpAuthenticationImpl->GetAuthScheme();
+                               SysLog(NID_NET_HTTP, "Set the HttpAuthentication(%s), userPwd", _HttpUtility::GetHttpAuthSchemeByString(authScheme));
+
+                               curl_easy_setopt(pCurl, CURLOPT_HTTPAUTH, _HttpUtility::GetHttpCurlAuthScheme(authScheme));
+                               curl_easy_setopt(pCurl, CURLOPT_USERPWD, pUserPwd);
+
+                               delete[] pUserPwd;
+                       }
+               }
+       }
+
+       //the Call back for the Response Header.
+       curl_easy_setopt(pCurl, CURLOPT_HEADERFUNCTION, _HttpTransactionImpl::OnHttpHeaderReceived);
+       curl_easy_setopt(pCurl, CURLOPT_HEADERDATA, __pHttpTransactionUserData);
+
+       //the Call back for the Response Body.
+       curl_easy_setopt(pCurl, CURLOPT_WRITEFUNCTION, _HttpTransactionImpl::OnHttpBodyReceived);
+       curl_easy_setopt(pCurl, CURLOPT_WRITEDATA, __pHttpTransactionUserData);
+
+       //the Call back for uploading the Body.
+       if (isEnableOnHttpBodyReadyToWrite)
+       {
+               curl_easy_setopt(pCurl, CURLOPT_POST, 1L); //For receiving the OnHttpBodyReadyToWrite
+
+               //curl_easy_setopt(pCurl, CURLOPT_UPLOAD, 1L);
+               curl_easy_setopt(pCurl, CURLOPT_READFUNCTION, _HttpTransactionImpl::OnHttpBodyReadyToWrite);
+               curl_easy_setopt(pCurl, CURLOPT_READDATA, __pHttpTransactionUserData);
+       }
+
+       curl_easy_setopt(pCurl, CURLOPT_NOPROGRESS, false);
+       curl_easy_setopt(pCurl, CURLOPT_PROGRESSFUNCTION, _HttpTransactionImpl::OnHttpProgress);
+       curl_easy_setopt(pCurl, CURLOPT_PROGRESSDATA, __pHttpTransactionUserData);
+
+       curl_easy_setopt(pCurl, CURLOPT_SSL_CTX_FUNCTION, _HttpTransactionImpl::OnHttpSslHandshake);
+       curl_easy_setopt(pCurl, CURLOPT_SSL_CTX_DATA, __pHttpTransactionUserData);
+
+       curl_easy_setopt(pCurl, CURLOPT_VERBOSE, 1L);
+       curl_easy_setopt(pCurl, CURLOPT_DEBUGFUNCTION, _HttpTransactionImpl::OnHttpDebugReceived);
+       curl_easy_setopt(pCurl, CURLOPT_ERRORBUFFER, __pHttpTransactionUserData->__error);
+
+       curl_easy_setopt(pCurl, CURLOPT_OPENSOCKETDATA, &__pHttpTransactionUserData->__socketFd);
+       curl_easy_setopt(pCurl, CURLOPT_OPENSOCKETFUNCTION, _HttpTransactionImpl::OnSocketOpened);
+
+       curl_easy_setopt(pCurl, CURLOPT_PRIVATE, __pHttpTransactionUserData); //curl_getinfo(PRIVATE)
+
+       //if current network is Custom NetConnection, Default Mode of ManagedNetConnection or Preference Mode of ManagedNetConnection is already started.
+       if (__pHttpSessionImpl->IsConnectionStarted())
+       {
+               CURLM* pCurlM = __pHttpMultipleConnectionInfo->GetCurlM();
+               SysTryReturnResult(NID_NET_HTTP, pCurlM != null,
+                                                  E_SYSTEM, "The pCurlM must not be null. HttpTransaction[%d]", __transactionId);
+
+               //Adds the Curl handle to CurlM
+               rc = curl_multi_add_handle(pCurlM, pCurl);
+               if (rc == CURLM_OK)
+               {
+                       SysLog(NID_NET_HTTP, "CURLM_OK: Called curl_multi_add_handle(). HttpTransaction[%d]", __transactionId);
+               }
+               else
+               {
+                       _HttpUtility::PrintCurlMultiErrorCode(rc);
+                       SysTryReturnResult(NID_NET_HTTP, false,
+                                                          E_SYSTEM, "Failed to curl_multi_add_handle(). HttpTransaction[%d]", __transactionId);
+               }
+               __pHttpCurl->AddRef();
+
+               __pHttpTransactionUserData->AddRef();
+
+               __pHttpSessionImpl->GetHttpMultipleConnectionInfo()->AddRef();
+
+               SysLog(NID_NET_HTTP, "Submitted the HttpTransaction[%d] successfully.", __transactionId);
+
+       }
+       else
+       {
+               __isPendingTransaction = true;
+               SysLog(NID_NET_HTTP, "[Preference Mode] The HttpTransaction is pending. The HttpTransaction[%d] will be submitted after the managed connection is started.", __transactionId);
+       }
+
+       __isSubmitted = true;
+
+       ClearLastResult();
+
+       return r;
+}
+
+result
+_HttpTransactionImpl::SubmitPendingTransaction(const String& deviceName, const String& proxyAddress)
+{
+       result r = E_SUCCESS;
+       CURLMcode rc;
+       CURLM* pCurlM = null;
+
+       CURL* pCurl = __pHttpCurl->GetCurl();
+       SysTryReturnResult(NID_NET_HTTP, pCurl != null,
+                                          E_SYSTEM, "The Curl must not be null.");
+
+       if (!deviceName.IsEmpty())
+       {
+               char* pDeviceName = _StringConverter::CopyToCharArrayN(deviceName);
+               SysTryReturnResult(NID_NET_HTTP, pDeviceName != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               SysLog(NID_NET_HTTP, "[Target] The device name is %s.", pDeviceName);
+               curl_easy_setopt(pCurl, CURLOPT_INTERFACE, pDeviceName);
+               delete[] pDeviceName;
+       }
+
+       if (__pHttpSessionImpl->GetProxyAddress() != null)
+       {
+               char* pProxyAddress = _StringConverter::CopyToCharArrayN(*__pHttpSessionImpl->GetProxyAddress());
+               SysTryReturnResult(NID_NET_HTTP, pProxyAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               curl_easy_setopt(pCurl, CURLOPT_PROXY, pProxyAddress);
+               delete[] pProxyAddress;
+       }
+
+       pCurlM = __pHttpMultipleConnectionInfo->GetCurlM();
+       SysTryReturnResult(NID_NET_HTTP, pCurlM != null,
+                                          E_SYSTEM, "The pCurlM must not be null. HttpTransaction[%d]", __transactionId);
+
+       //Adds the Curl handle to CurlM
+       rc = curl_multi_add_handle(pCurlM, pCurl);
+       if (rc == CURLM_OK)
+       {
+               SysLog(NID_NET_HTTP, "CURLM_OK: Called curl_multi_add_handle(). HttpTransaction[%d]", __transactionId);
+       }
+       else
+       {
+               _HttpUtility::PrintCurlMultiErrorCode(rc);
+               SysTryReturnResult(NID_NET_HTTP, false,
+                                                  E_SYSTEM, "Failed to curl_multi_add_handle(). HttpTransaction[%d]", __transactionId);
+       }
+       __pHttpCurl->AddRef();
+
+       __pHttpTransactionUserData->AddRef();
+
+       __pHttpSessionImpl->GetHttpMultipleConnectionInfo()->AddRef();
+
+       SysLog(NID_NET_HTTP, "Submitted the pending HttpTransaction[%d] successfully.", __transactionId);
+
+       ClearLastResult();
+
+       return r;
+}
+
+HttpRequest*
+_HttpTransactionImpl::GetRequest() const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET_HTTP, __isClosed == false, null, E_INVALID_STATE,
+                                "[E_INVALID_STATE] HttpTransaction(%d) is already closed.", __transactionId);
+
+       SysTryReturn(NID_NET_HTTP, __pHttpRequest != null, null, E_INVALID_DATA,
+                                "[E_INVALID_DATA] HttpRequest must not be null.", __transactionId);
+
+       return __pHttpRequest;
+}
+
+HttpResponse*
+_HttpTransactionImpl::GetResponse(void) const
+{
+       ClearLastResult();
+
+       _HttpResponseImpl* pHttpResponseImpl = _HttpResponseImpl::GetInstance(*__pHttpResponse);
+
+       SysTryReturn(NID_NET_HTTP, !__isClosed, null, E_INVALID_STATE,
+                                "[E_INVALID_STATE] HttpTransaction[%d] is already closed.", __transactionId);
+
+       SysTryReturn(NID_NET_HTTP, pHttpResponseImpl->IsHeaderReceived() || pHttpResponseImpl->IsBodyReceived(), null, E_INVALID_DATA,
+                                "[E_INVALID_DATA] Header or Body of the HttpResponse are not received yet.");
+
+       return __pHttpResponse;
+}
+
+result
+_HttpTransactionImpl::AddHttpTransactionListener(IHttpTransactionEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __isClosed == false,
+                                          E_INVALID_STATE, "HttpTransaction[%d] is already closed.", __transactionId);
+
+       r = __pHttpTransactionEvent->AddListener(listener, true);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, r, r, "[%s] Failed to add the listener.", GetErrorMessage(r));
+
+       IHttpTransactionEventListener* pListener = const_cast< IHttpTransactionEventListener* >(&listener);
+       SysTryReturnResult(NID_NET_HTTP, pListener != null,
+                                          E_SYSTEM, "A system error has occurred.");
+
+       r = __transactionListenerList.Add(pListener);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Failed to add the listener.");
+
+       SysLog(NID_NET_HTTP, "Added the listener(HttpTransaction[%d]).", __transactionId);
+
+       return r;
+}
+
+result
+_HttpTransactionImpl::RemoveHttpTransactionListener(IHttpTransactionEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __isClosed == false,
+                                          E_INVALID_STATE, "HttpTransaction[%d] is already closed.", __transactionId);
+
+       r = __pHttpTransactionEvent->RemoveListener(listener);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Failed to add the listener.");
+
+       IHttpTransactionEventListener* pListener = const_cast< IHttpTransactionEventListener* >(&listener);
+       r = __transactionListenerList.Remove(pListener);
+       if (IsFailed(r))
+       {
+               SysLog(NID_NET_HTTP, "Failed to remove the listener(HttpTransaction[%d]).", __transactionId);
+       }
+
+       SysLog(NID_NET_HTTP, "Removed the listener(HttpTransaction[%d]).", __transactionId);
+
+       return r;
+}
+
+result
+_HttpTransactionImpl::SetHttpProgressListener(IHttpProgressEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __isClosed == false,
+                                          E_INVALID_STATE, "HttpTransaction(%d) is already closed.", __transactionId);
+
+       __pHttpProgressListener = &listener;
+       __pHttpTransactionEvent->SetHttpProgressListener(__pHttpProgressListener);
+
+       return r;
+}
+
+result
+_HttpTransactionImpl::SetUserObject(const Tizen::Base::Object* pUserData)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __isClosed == false,
+                                          E_INVALID_STATE, "HttpTransaction[%d] is already closed.", __transactionId);
+
+       __pUserData = pUserData;
+
+       return r;
+}
+
+Tizen::Base::Object*
+_HttpTransactionImpl::GetUserObject(void) const
+{
+       return const_cast< Object* >(__pUserData);
+}
+
+bool
+_HttpTransactionImpl::EnableTransactionReadyToWrite(void)
+{
+       if (__isSubmitted)
+       {
+               SysLog(NID_NET_HTTP, "Should be called before the HttpTransaction is submitted.");
+               return false;
+       }
+       __enableTransactionReadyToWrite = true;
+
+       SysLog(NID_NET_HTTP, "Enable OnTransactionReadyToWrite().");
+
+       return true;
+}
+
+result
+_HttpTransactionImpl::Resume()
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __isClosed == false,
+                                          E_INVALID_STATE, "HttpTransaction[%d] is already closed.", __transactionId);
+
+       SysTryReturnResult(NID_NET_HTTP, __isCertRequiredEventFired == true,
+                                          E_INVALID_STATE, "Should be called after the OnTransactionCertVerificationRequiredN() is invoked.");
+
+       SysTryReturnResult(NID_NET_HTTP, __isAlreadyResumed == false,
+                                          E_INVALID_STATE, "The HttpTransaction[%d] is already resumed.", __transactionId);
+
+       SysLog(NID_NET_HTTP, "Calling Resume() to ignore server certificate verification.");
+
+       //Rollback the HttpTransaction.
+
+       if (__pHttpCurl != null)
+       {
+               __pHttpCurl->Release();
+       }
+
+       CURL* pCurl = curl_easy_init();
+       SysTryReturnResult(NID_NET_HTTP, pCurl != null,
+                                          E_INVALID_STATE, "Failed to call curl_easy_init(), easy is null");
+       SysLog(NID_NET_HTTP, "Created an instance of CURL. [%x]", pCurl);
+
+       __pHttpCurl = new (std::nothrow) _HttpCurl(pCurl, false);
+       SysTryReturnResult(NID_NET_HTTP, __pHttpCurl != null,
+                                          E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       if (__pHttpTransactionUserData != null)
+       {
+               __pHttpTransactionUserData->Release();
+       }
+
+       __pHttpTransactionUserData = new (std::nothrow) _HttpTransactionUserData(this, __pHttpCurl);
+       SysTryReturnResult(NID_NET_HTTP, __pHttpTransactionUserData != null,
+                                               E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+
+       __isSubmitted = false;
+       __transactionId = GenerateTransactionId();
+
+       if (__pRequestBuffer != null)
+       {
+               _HttpRequestImpl* pHttpRequestImpl = _HttpRequestImpl::GetInstance(*__pHttpRequest);
+               SysTryReturnResult(NID_NET_HTTP, pHttpRequestImpl != null,
+                                                  E_INVALID_STATE, "The current state of the instance prohibits the execution of the specified operation.");
+
+               //Clear the flag of _HttpRequestImpl
+               pHttpRequestImpl->SetReceivedTransactionReadyToWriteEvent(false);
+
+               r = pHttpRequestImpl->WriteBody(*__pRequestBuffer);
+               r = TransExceptionsExclusive(r, E_INVALID_STATE, E_OUT_OF_MEMORY);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                  r, "The current state of the instance prohibits the execution of the specified operation.");
+
+               SysLog(NID_NET_HTTP, "__pRequestBuffer is added the Body.");
+       }
+       __pHttpSessionImpl->IgnoreSslVerification();
+       __isAlreadyResumed = true;
+
+       r = Submit();
+       r = TransExceptionsExclusive(r, E_INVALID_STATE, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                          r, "Failed to submit the transaction.");
+
+       SysLog(NID_NET_HTTP, "Called Resume() to ignore server certificate verification.");
+
+       return r;
+}
+result
+_HttpTransactionImpl::Pause(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __isClosed == false,
+                                          E_INVALID_STATE, "HttpTransaction[%d] is already closed.", __transactionId);
+
+       SysTryReturnResult(NID_NET_HTTP, __isCertRequiredEventFired == true,
+                                          E_INVALID_STATE, "Should be called after the OnTransactionCertVerificationRequiredN() is invoked.");
+
+       SysTryReturnResult(NID_NET_HTTP, __isAlreadyPaused == false,
+                                          E_INVALID_STATE, "The HttpTransaction[%d] is already paused.", __transactionId);
+
+       SysLog(NID_NET_HTTP, "Calling Pause().");
+
+       __isAlreadyPaused = true;
+
+       //Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_ABORTED) - E_HTTP_USER
+       __pHttpTransactionEvent->FireTransactionAbortedEvent(E_HTTP_USER, true);
+
+       SysLog(NID_NET_HTTP, "Called Pause().");
+
+       return r;
+}
+
+result
+_HttpTransactionImpl::SetTimeout(int timeout)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, timeout >= 0,
+                                          E_INVALID_ARG, "The specified input parameter is invalid.");
+
+       SysTryReturnResult(NID_NET_HTTP, __isClosed == false,
+                                          E_INVALID_STATE, "HttpTransaction[%d] is already closed.", __transactionId);
+
+       SysTryReturnResult(NID_NET_HTTP, __isSubmitted == false,
+                                          E_INVALID_STATE, "HttpTransaction[%d] is already submitted.", __transactionId);
+
+       __timeout = timeout;
+
+       SysLog(NID_NET_HTTP, "Set the timeout[%d].", timeout);
+
+       return r;
+}
+
+result
+_HttpTransactionImpl::SetClientCertificate(int certificateId)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_HTTP, __isClosed == false,
+                                          E_INVALID_STATE, "HttpTransaction[%d] is already closed.", __transactionId);
+
+       SysTryReturnResult(NID_NET_HTTP, certificateId >= 0,
+                                          E_INVALID_ARG, "The certificateId is invalid.");
+
+       __certificateId = certificateId;
+
+       SysLog(NID_NET_HTTP, "Selected Client Certificate ID[%d].", certificateId);
+
+       return r;
+}
+
+_HttpTransactionImpl*
+_HttpTransactionImpl::GetInstance(HttpTransaction& httpTransaction)
+{
+       return httpTransaction.__pHttpTransactionImpl;
+}
+
+const _HttpTransactionImpl*
+_HttpTransactionImpl::GetInstance(const HttpTransaction& httpTransaction)
+{
+       return httpTransaction.__pHttpTransactionImpl;
+}
+
+_HttpSessionImpl*
+_HttpTransactionImpl::GetHttpSessioinImpl(void) const
+{
+       return __pHttpSessionImpl;
+}
+
+HttpTransaction*
+_HttpTransactionImpl::GetHttpTransaction(void) const
+{
+       return __pHttpTransaction;
+}
+
+_HttpTransactionEvent*
+_HttpTransactionImpl::GetHttpTransactionEvent(void) const
+{
+       return __pHttpTransactionEvent;
+}
+
+bool
+_HttpTransactionImpl::IsTransactionReadyToWriteEanbled(void) const
+{
+       return __enableTransactionReadyToWrite;
+}
+
+HttpAuthentication*
+_HttpTransactionImpl::OpenAuthenticationInfoN(void)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+       _HttpAuthenticationImpl* pHttpAuthenticationImpl = null;
+       unique_ptr<HttpAuthentication> pHttpAuthentication(_HttpAuthenticationImpl::CreateHttpAuthenticationN());
+       SysTryReturn(NID_NET_HTTP, pHttpAuthentication != null, null, E_OUT_OF_MEMORY,
+                                "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       pHttpAuthenticationImpl = _HttpAuthenticationImpl::GetInstance(*pHttpAuthentication);
+
+       r = pHttpAuthenticationImpl->Construct(*this);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, null, r,
+                               "[%s] Failed to construct HttpAuthentication.", GetErrorMessage(r));
+
+       SetHttpAuthenticationImpl(pHttpAuthenticationImpl);
+
+       SysLog(NID_NET_HTTP, "The HttpAuthentication instance is created.");
+
+       return pHttpAuthentication.release();
+}
+
+int
+_HttpTransactionImpl::GenerateTransactionId(void)
+{
+       int transactionId = 0;
+       Mutex* pHttpMutex = null;
+
+       pHttpMutex = _HttpUtility::GetHttpMutex();
+
+       MutexGuard locked(*pHttpMutex);
+       SysTryReturn(NID_NET_HTTP, locked.IsLocked(), _HTTP_INVALID_ID, E_SYSTEM,
+                       "[E_SYSTEM] Failed to lock mutex.");
+
+       if (__generatedTransactionId >= Integer::VALUE_MAX)
+       {
+               __generatedTransactionId = 0;
+       }
+       else
+       {
+               __generatedTransactionId++;
+       }
+
+       transactionId = __generatedTransactionId;
+
+       return transactionId;
+}
+
+int
+_HttpTransactionImpl::GetTransactionId(void) const
+{
+       return __transactionId;
+}
+
+void
+_HttpTransactionImpl::SetHttpAuthType(NetHttpAuthScheme authType)
+{
+       __authType = authType;
+}
+
+NetHttpAuthScheme
+_HttpTransactionImpl::GetHttpAuthType(void) const
+{
+       return __authType;
+}
+
+void
+_HttpTransactionImpl::SetHttpAuthenticationImpl(const _HttpAuthenticationImpl* pAuthenticationImpl)
+{
+       result r = E_SUCCESS;
+
+       if (__pHttpAuthenticationImpl != null)
+       {
+               delete __pHttpAuthenticationImpl;
+       }
+
+       __pHttpAuthenticationImpl = new (std::nothrow) _HttpAuthenticationImpl();
+       SysTryReturnVoidResult(NID_NET_HTTP, __pHttpAuthenticationImpl != null, E_OUT_OF_MEMORY,
+                               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = __pHttpAuthenticationImpl->Construct(*pAuthenticationImpl, *this);
+       SysTryReturnVoidResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                               "[%s] Propagating.", GetErrorMessage(r));
+}
+
+_HttpAuthenticationImpl*
+_HttpTransactionImpl::GetHttpAuthenticationImpl(void) const
+{
+       return __pHttpAuthenticationImpl;
+}
+
+ByteBuffer*
+_HttpTransactionImpl::GetRequestBuffer(void)
+{
+       return __pRequestBuffer;
+}
+
+ArrayListT< IHttpTransactionEventListener* >*
+_HttpTransactionImpl::GetEventListenerList(void)
+{
+       return &__transactionListenerList;
+}
+
+_HttpTransactionUserData*
+_HttpTransactionImpl::GetHttpTransactionUserData(void) const
+{
+       return __pHttpTransactionUserData;
+}
+
+bool
+_HttpTransactionImpl::IsClosed(void) const
+{
+       return __isClosed;
+}
+
+bool
+_HttpTransactionImpl::IsCanceled(void) const
+{
+       return __isCanceled;
+}
+
+void
+_HttpTransactionImpl::SetTransactionCanceled(bool isCanceled)
+{
+       __isCanceled = isCanceled;
+}
+
+bool
+_HttpTransactionImpl::IsSubmitted(void) const
+{
+       return __isSubmitted;
+}
+
+bool
+_HttpTransactionImpl::IsPendingTransaction(void) const
+{
+       return __isPendingTransaction;
+}
+
+bool
+_HttpTransactionImpl::IsHeaderEventFired(void) const
+{
+       return __isHeaderEventFired;
+}
+
+void
+_HttpTransactionImpl::SetCertRequiredEventFired(bool isFired)
+{
+       __isCertRequiredEventFired = isFired;
+}
+
+bool
+_HttpTransactionImpl::IsAlreadyResumed(void) const
+{
+       if (__isAlreadyResumed || __isAlreadyPaused)
+       {
+               return true;
+       }
+       else
+       {
+               return false;
+       }
+}
+
+void
+_HttpTransactionImpl::IgnoreSslVerification(void)
+{
+       __isAlreadyResumed = true;
+}
+
+void
+_HttpTransactionImpl::SetTimer(void)
+{
+       int timerId = -1;
+       GMainContext* pGMainContext = __pHttpMultipleConnectionInfo->GetGMainContext();
+       SysTryReturnVoidResult(NID_NET_HTTP, pGMainContext != null, E_SYSTEM,
+                                                  "[E_SYSTEM] The pGMainContext must not be null.");
+
+       __pTimerSource = g_timeout_source_new(_HTTP_DEFAULT_CONNECTION_TIMEOUT * 1000);
+       g_source_set_callback(__pTimerSource, _HttpTransactionImpl::OnHttpTransactionTimerExpiredEvent, this, null);
+       g_source_attach(__pTimerSource, pGMainContext);
+
+       timerId = g_source_get_id(__pTimerSource);
+       SysLog(NID_NET_HTTP, "Created the TimerSource[%d] of HttpTransaction[%d], timeout[%d].", timerId, __transactionId, _HTTP_DEFAULT_CONNECTION_TIMEOUT * 1000);
+}
+
+_HttpCurl*
+_HttpTransactionImpl::GetHttpCurl(void) const
+{
+       return __pHttpCurl;
+}
+
+const IHttpProgressEventListener*
+_HttpTransactionImpl::GetHttpProgressEventListener(void) const
+{
+       return __pHttpProgressListener;
+}
+
+_HttpResponseImpl*
+_HttpTransactionImpl::GetHttpResponseImpl(void) const
+{
+       return _HttpResponseImpl::GetInstance(*__pHttpResponse);
+}
+
+gboolean
+_HttpTransactionImpl::OnSocketReceivedEvent(GIOChannel* pSource, GIOCondition condition, gpointer pUserData)
+{
+       if (condition == G_IO_IN)
+       {
+               SysLog(NID_NET_HTTP, "====> [Event] Received the socket event(G_IO_IN).");
+       }
+       else if (condition == G_IO_OUT)
+       {
+               SysLog(NID_NET_HTTP, "====> [Event] Received the socket event(G_IO_OUT).");
+       }
+       else
+       {
+               SysLog(NID_NET_HTTP, "====> [Event] Received the socket event(%d).", condition);
+       }
+
+       _HttpMultipleConnectionInfo* pHttpMultipleConnectionInfo = static_cast< _HttpMultipleConnectionInfo* >(pUserData);
+       int remainsConnection = -1;
+
+       CURLMcode rc;
+       int fd = g_io_channel_unix_get_fd(pSource);
+       //CURL_CSELECT_IN : 1, CURL_CSELECT_OUT: 2
+       int action = (condition & G_IO_IN ? CURL_CSELECT_IN : 0) | (condition & G_IO_OUT ? CURL_CSELECT_OUT : 0);
+
+       CURLM* pCurlM = pHttpMultipleConnectionInfo->GetCurlM();
+       SysTryReturn(NID_NET_HTTP, pCurlM != null, false, E_SYSTEM, "[E_SYSTEM] The pCurlM must not be null.");
+       rc = curl_multi_socket_action(pCurlM, fd, action, &remainsConnection);
+
+       pHttpMultipleConnectionInfo->SetRemainsConnection(remainsConnection);
+       if (rc == CURLM_OK)
+       {
+               SysLog(NID_NET_HTTP, "CURLM_OK: Called curl_multi_socket_action(%d)", action);
+       }
+       else
+       {
+               _HttpUtility::PrintCurlMultiErrorCode(rc);
+       }
+
+       pHttpMultipleConnectionInfo->CheckCurlMultiStatus();
+
+       if (remainsConnection > 0)
+       {
+               return true;
+       }
+       else
+       {
+               return false;
+       }
+}
+
+curl_socket_t
+_HttpTransactionImpl::OnSocketOpened(int* pSocketFd, curlsocktype purpose, struct curl_sockaddr* addr)
+{
+       int socketFd = socket(addr->family, addr->socktype, addr->protocol);
+       SysLog(NID_NET_HTTP, "SOCKET FD (%d)", socketFd);
+
+       *pSocketFd = socketFd;
+
+       return socketFd;
+}
+
+size_t
+_HttpTransactionImpl::OnHttpProgress(void* pUserData, double totalDownloadSize, double currentDownloadedSize,
+                                                                        double totalUploadSize,
+                                                                        double currentUploadedSize)
+{
+       _HttpTransactionUserData* pHttpTransactionUserData = static_cast< _HttpTransactionUserData* >(pUserData);
+       _HttpTransactionImpl* pHttpTransactionImpl = pHttpTransactionUserData->GetHttpTransactionImpl();
+
+       if (pHttpTransactionUserData->IsAbortedTransaction())
+       {
+               SysLog(NID_NET_HTTP, "The HttpTransaction is already closed.");
+               return _HTTP_NETWORK_ERROR;
+       }
+
+       if (pHttpTransactionImpl->__pHttpProgressListener != null)
+       {
+               long long donwloadTotalProgress = static_cast< long long >(totalDownloadSize);
+               long long donwloadCurrentProgress = static_cast< long long >(currentDownloadedSize);
+
+               long long uploadTotalProgress = static_cast< long long >(totalUploadSize);
+               long long uploadCurrentProgress = static_cast< long long >(currentUploadedSize);
+
+               SysLog(NID_NET_HTTP, "===> Progress  UP(%lld/%lld) DOWN(%lld/%lld)", uploadCurrentProgress, uploadTotalProgress,
+                          donwloadCurrentProgress,
+                          donwloadTotalProgress);
+
+               if (donwloadCurrentProgress != pHttpTransactionImpl->__donwloadCurrentProgress)
+               {
+                       _HttpResponseImpl* pHttpResponseImpl = _HttpResponseImpl::GetInstance(*pHttpTransactionImpl->__pHttpResponse);
+
+                       if (pHttpResponseImpl->IsCurrentBodyReceived())
+                       {
+                               //Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_DOWNLOAD_PROGRESS)
+                               pHttpTransactionImpl->__pHttpTransactionEvent->FireHttpDownloadInProgressEvent(pHttpResponseImpl->GetCurrentBodyLength(), donwloadTotalProgress);
+
+                               pHttpResponseImpl->SetReceivedBody(false);
+                               pHttpResponseImpl->SetTotalBodyLength(donwloadTotalProgress);
+                       }
+
+                       pHttpTransactionImpl->__donwloadCurrentProgress = donwloadCurrentProgress;
+
+               }
+               else if (uploadCurrentProgress != pHttpTransactionImpl->__uploadCurrentProgress)
+               {
+                       //Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_UPLOAD_PROGRESS)
+                       pHttpTransactionImpl->__pHttpTransactionEvent->FireHttpUploadInProgressEvent(uploadCurrentProgress, uploadTotalProgress);
+                       pHttpTransactionImpl->__uploadCurrentProgress = uploadCurrentProgress;
+               }
+       }
+
+       return 0;
+}
+
+size_t
+_HttpTransactionImpl::OnHttpHeaderReceived(void* pHeaderMsg, size_t size, size_t nmemb, void* pUserData)
+{
+       result r = E_SUCCESS;
+       int bytesSize = size * nmemb;
+
+       //SysLog(NID_NET_HTTP, "===> Received the header(Bytes: %d).", bytesSize);
+
+       if (pHeaderMsg == null || bytesSize <= 0)
+       {
+               SysLog(NID_NET_HTTP, "Invalid header was received.");
+               return bytesSize;
+       }
+
+       byte* pBytes = static_cast< byte* >(pHeaderMsg);
+       _HttpTransactionUserData* pHttpTransactionUserData = static_cast< _HttpTransactionUserData* >(pUserData);
+       _HttpTransactionImpl* pHttpTransactionImpl = pHttpTransactionUserData->GetHttpTransactionImpl();
+       _HttpResponseImpl* pHttpResponseImpl = null;
+
+       String headerLine((char*) pBytes);
+
+       if (pHttpTransactionUserData->IsAbortedTransaction())
+       {
+               SysLog(NID_NET_HTTP, "The HttpTransaction is already closed.");
+               return bytesSize;
+       }
+
+       pHttpResponseImpl = _HttpResponseImpl::GetInstance(*pHttpTransactionImpl->__pHttpResponse);
+       r = pHttpResponseImpl->AddRawHeader(pBytes, bytesSize, false);
+       if (IsFailed(r))
+       {
+               SysLogException(NID_NET_HTTP, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       return bytesSize;
+}
+
+//Call back Function for curl.
+size_t
+_HttpTransactionImpl::OnHttpBodyReceived(void* pBodyMsg, size_t size, size_t nmemb, void* pUserData)
+{
+       result r = E_SUCCESS;
+       int bytesSize = size * nmemb;
+
+       SysLog(NID_NET_HTTP, "===> Received the body(Bytes: %d).", bytesSize);
+
+       if (pBodyMsg == null || bytesSize <= 0)
+       {
+               SysLog(NID_NET_HTTP, "Invalid body was received.");
+               return bytesSize;
+       }
+
+       byte* pBytes = (byte*) pBodyMsg;
+       _HttpTransactionUserData* pHttpTransactionUserData = static_cast< _HttpTransactionUserData* >(pUserData);
+       _HttpTransactionImpl* pHttpTransactionImpl = pHttpTransactionUserData->GetHttpTransactionImpl();
+       _HttpResponseImpl* pHttpResponseImpl = null;
+       CURL* pCurl = null;
+       bool isFullBuffer = false;
+       int readBodySize = -1;
+
+       if (pHttpTransactionUserData->IsAbortedTransaction())
+       {
+               SysLog(NID_NET_HTTP, "The HttpTransaction was aborted.");
+               return bytesSize;
+       }
+
+       pHttpResponseImpl = _HttpResponseImpl::GetInstance(*pHttpTransactionImpl->__pHttpResponse);
+       pCurl = pHttpTransactionImpl->__pHttpCurl->GetCurl();
+
+       if (!pHttpTransactionImpl->__isHeaderEventFired)
+       {
+               SysLog(NID_NET_HTTP, "The header event will be fired in OnHttpBodyReceived()");
+
+               r = pHttpResponseImpl->AddRawHeader(null, 0, true);
+               if (IsFailed(r))
+               {
+                       SysLogException(NID_NET_HTTP, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+
+               long httpAuth = _CURL_HTTP_AUTH_NONE;
+               long proxyAuth = _CURL_HTTP_AUTH_NONE;
+               curl_easy_getinfo(pCurl, CURLINFO_HTTPAUTH_AVAIL, &httpAuth);
+               curl_easy_getinfo(pCurl, CURLINFO_PROXYAUTH_AVAIL, &proxyAuth);
+
+               //Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_HEADER_COMPLETED)
+               pHttpTransactionImpl->__pHttpTransactionEvent->FireTransactionHeaderCompletedEvent(pHttpResponseImpl->GetHeaderLength(), proxyAuth, httpAuth);
+
+               pHttpTransactionImpl->__isHeaderEventFired = true;
+
+               if (pHttpTransactionUserData->IsAbortedTransaction())
+               {
+                       SysLog(NID_NET_HTTP, "The HttpTransaction was aborted.");
+                       return bytesSize;
+               }
+       }
+
+       r = pHttpResponseImpl->AddRawBody(pBytes, bytesSize, isFullBuffer, readBodySize);
+       if (IsFailed(r))
+       {
+               SysLogException(NID_NET_HTTP, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
+       //Check if the Buffer is full.
+       if (isFullBuffer && readBodySize > 0)
+       {
+               //Fire the event(NET_HTTP_TRANSACTION_EVENT_READY_TO_READ)
+               pHttpTransactionImpl->__pHttpTransactionEvent->FireTransactionReadyToReadEvent(readBodySize);
+
+               pHttpResponseImpl->SetCurrentBodyLength(readBodySize);
+               pHttpResponseImpl->SetReceivedBody(true);
+       }
+
+       return bytesSize;
+}
+
+size_t
+_HttpTransactionImpl::OnHttpDebugReceived(CURL* pCurl, curl_infotype type, char* pChar, size_t size, void* pUserData)
+{
+       char logBuffer[_HTTP_DEFAULT_HEADER_SIZE];
+       int logSize = 0;
+
+       if (_HTTP_DEFAULT_HEADER_SIZE > static_cast< int >(size))
+       {
+               logSize = size;
+       }
+       else
+       {
+               logSize = _HTTP_DEFAULT_HEADER_SIZE - 1;
+       }
+
+       if (type == CURLINFO_TEXT)
+       {
+               strncpy(logBuffer, pChar, logSize);
+               logBuffer[logSize] = '\0';
+               SysLog(NID_NET_HTTP, "[DEBUG] %s", logBuffer);
+       }
+       else if (type == CURLINFO_HEADER_IN || type == CURLINFO_HEADER_OUT)
+       {
+               //Ignore the body message.
+               if (size >= 2 && pChar[0] == 0x0D && pChar[1] == 0x0A)
+               {
+                       return 0;
+               }
+               else
+               {
+                       strncpy(logBuffer, pChar, logSize);
+                       logBuffer[logSize] = '\0';
+                       SysLog(NID_NET_HTTP, "[DEBUG] %s", logBuffer);
+               }
+       }
+
+       return 0;
+}
+
+size_t
+_HttpTransactionImpl::OnHttpBodyReadyToWrite(void* pBodyMsg, size_t size, size_t nmemb, void* pUserData)
+{
+       result r = E_SUCCESS;
+       int recommendedSize = size * nmemb;
+
+       SysLog(NID_NET_HTTP, "===> Called(%d).", recommendedSize);
+
+       _HttpTransactionUserData* pHttpTransactionUserData = static_cast< _HttpTransactionUserData* >(pUserData);
+       _HttpTransactionImpl* pHttpTransactionImpl = pHttpTransactionUserData->GetHttpTransactionImpl();
+       _HttpRequestImpl* pHttpRequestImpl = null;
+       ByteBuffer* pBodyBuffer = null;
+       int bufferSize = 0;
+
+       if (pHttpTransactionUserData->IsAbortedTransaction())
+       {
+               SysLog(NID_NET_HTTP, "The HttpTransaction was aborted.");
+               return CURL_READFUNC_ABORT;
+       }
+
+       pHttpRequestImpl = _HttpRequestImpl::GetInstance(*pHttpTransactionImpl->__pHttpRequest);
+       pHttpRequestImpl->SetRecommendedSize(recommendedSize);
+       if (pHttpRequestImpl->IsFirstChunkBody())
+       {
+               SysLog(NID_NET_HTTP,
+                          "First chunk Body. Ignore to fire the event(OnTransactionReadyToWriteEvent) to send the first chunk");
+       }
+       else
+       {
+               pHttpRequestImpl->SetReceivedTransactionReadyToWriteEvent(true);
+               //Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_READY_TO_WRITE)
+               pHttpTransactionImpl->__pHttpTransactionEvent->FireTransactionReadyToWriteEvent(recommendedSize);
+       }
+
+       pBodyBuffer = pHttpRequestImpl->GetSendingBuffer();
+       if (pBodyBuffer == null)
+       {
+               if (pHttpRequestImpl->IsLastChunkBody()) //Last chunk (ByteBuffer is an empty(0))
+               {
+                       SysLog(NID_NET_HTTP, "Sent the last chunk.");
+                       return 0;
+               }
+               //Read the body from the Queue.
+               pBodyBuffer = pHttpRequestImpl->ReadBodyN();
+               SysTryReturn(NID_NET_HTTP, pBodyBuffer != null, CURL_READFUNC_ABORT, E_IO,
+                                        "[E_IO] Failed to read the body. pBodyBuffer is null[CURL_READFUNC_ABORT].");
+       }
+
+       bufferSize = pBodyBuffer->GetRemaining();
+       if (bufferSize > recommendedSize)
+       {
+               r = pBodyBuffer->GetArray(static_cast< byte* >(pBodyMsg), 0, recommendedSize);
+               SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, CURL_READFUNC_ABORT, E_IO,
+                                        "[E_IO] Failed to read the body[CURL_READFUNC_ABORT].");
+
+               pHttpRequestImpl->SetSendingBuffer(pBodyBuffer);
+               SysLog(NID_NET_HTTP, "[bufferSize(%d) > recommendedSize(%d)] Sent the chunk(size: %d).", bufferSize, recommendedSize,
+                          recommendedSize);
+               return recommendedSize;
+
+       }
+       else
+       {
+               r = pBodyBuffer->GetArray(static_cast< byte* >(pBodyMsg), 0, bufferSize);
+               SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, CURL_READFUNC_ABORT, E_IO,
+                                        "[E_IO] Failed to read the body[CURL_READFUNC_ABORT].");
+               pHttpRequestImpl->SetSendingBuffer(null);
+               delete pBodyBuffer;
+
+               if (pHttpRequestImpl->IsFirstChunkBody())
+               {
+                       pHttpRequestImpl->SetFirstChunkBody(false);
+                       SysLog(NID_NET_HTTP, "Ended the first chunk body.");
+               }
+
+               SysLog(NID_NET_HTTP, "[bufferSize(%d) <= recommendedSize(%d)] Sent the chunk(size: %d).", bufferSize, recommendedSize,
+                          bufferSize);
+               return bufferSize;
+       }
+
+       SysLogException(NID_NET_HTTP, E_IO, "[E_IO] CURL_READFUNC_ABORT.");
+
+       return CURL_READFUNC_ABORT;
+}
+
+CURLcode
+_HttpTransactionImpl::OnHttpSslHandshake(CURL* pCurl, SSL_CTX* pSslctx, void* pUserData)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+       CURLcode curlCode = CURLE_OK;
+
+       _HttpTransactionUserData* pHttpTransactionUserData = static_cast< _HttpTransactionUserData* >(pUserData);
+       _HttpTransactionImpl* pHttpTransactionImpl = pHttpTransactionUserData->GetHttpTransactionImpl();
+
+       if (pHttpTransactionImpl->__isAlreadyResumed)
+       {
+               SysLog(NID_NET_HTTP, "Resume the HttpTransaction. Ignore to verify the server cert.");
+       }
+       else
+       {
+               SSL_CTX_set_verify_depth(pSslctx, _HTTP_CERT_VERIFICATION_DEPTH_LIMIT);
+               SSL_CTX_set_verify(pSslctx, SSL_VERIFY_PEER, _HttpTransactionImpl::OnHttpSslVerify);
+       }
+
+       if (pHttpTransactionImpl->__certificateId >= 0)
+       {
+               X509* pClientCert = null;
+               EVP_PKEY* pClientKey = null;
+
+               _CertServiceProxy* pCertProxy = null;
+               pCertProxy = _CertServiceProxy::GetInstance();
+               SysTryReturn(NID_NET_HTTP, pCertProxy != null, CURLE_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               unique_ptr<_CertInfo, _CertInfoDeleter> pClientCertInfo(pCertProxy->GetUserCertificateByCertIdN(pHttpTransactionImpl->__certificateId, _CERT_ENC_TYPE_PEM));
+               r = GetLastResult();
+               r = TransExceptionsExclusive(r, E_NO_CERTIFICATE, E_OUT_OF_MEMORY);
+               SysTryReturn(NID_NET_HTTP, r == E_SUCCESS && pClientCertInfo != null, CURLE_SSL_CERTPROBLEM, r, "[%s] Certificate(%d) is not found.", GetErrorMessage(r), pHttpTransactionImpl->__certificateId);
+
+               BIO* pNewBIoCert = BIO_new(BIO_s_mem());
+               unique_ptr<BIO, _BIoDeleter> pBIoCert(pNewBIoCert);
+               SysTryReturn(NID_NET_HTTP, pBIoCert != null, CURLE_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               BIO_write(pNewBIoCert, (const void*)pClientCertInfo->certificate, pClientCertInfo->certLength);
+               pClientCert = PEM_read_bio_X509(pNewBIoCert, null, 0, null);
+               SysTryReturn(NID_NET_HTTP, pClientCert != null, CURLE_SSL_CERTPROBLEM, E_NO_CERTIFICATE, "[E_NO_CERTIFICATE] Failed to read Certificate(%d).", pHttpTransactionImpl->__transactionId);
+
+               char tempSubjectName[_HTTP_CERT_SUBJECT_SIZE];
+               X509_NAME_oneline(X509_get_subject_name(pClientCert), tempSubjectName, _HTTP_CERT_SUBJECT_SIZE);
+               String clientCertString = String(tempSubjectName);
+
+               SysLog(NID_NET_HTTP, "The subject of certificate is %ls.", clientCertString.GetPointer());
+
+               SysTryReturn(NID_NET_HTTP, SSL_CTX_use_certificate(pSslctx, pClientCert), CURLE_SSL_CERTPROBLEM, E_NO_CERTIFICATE, "[E_NO_CERTIFICATE] Failed to use Certificate(%d).", pHttpTransactionImpl->__transactionId);
+
+               BIO* pNewBIoKey = BIO_new(BIO_s_mem());
+               unique_ptr<BIO, _BIoDeleter> pBIoKey(pNewBIoKey);
+               SysTryReturn(NID_NET_HTTP, pBIoKey != null, CURLE_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               BIO_write(pNewBIoKey, (const void*)pClientCertInfo->privatekey, pClientCertInfo->privateKeyLen);
+               pClientKey = PEM_read_bio_PrivateKey(pNewBIoKey, null, 0, null);
+               SysTryReturn(NID_NET_HTTP, pClientKey != null, CURLE_SSL_CERTPROBLEM, E_NO_CERTIFICATE, "[E_NO_CERTIFICATE] Failed to read Private Key(%d).", pHttpTransactionImpl->__transactionId);
+
+               SysTryReturn(NID_NET_HTTP, SSL_CTX_use_PrivateKey(pSslctx, pClientKey), CURLE_SSL_CERTPROBLEM, E_NO_CERTIFICATE, "[E_NO_CERTIFICATE] Failed to use Private Key(%d).", pHttpTransactionImpl->__transactionId);
+               SysTryReturn(NID_NET_HTTP, SSL_CTX_check_private_key(pSslctx), CURLE_SSL_CERTPROBLEM, E_NO_CERTIFICATE, "[E_NO_CERTIFICATE] Failed to check Private Key(%d).", pHttpTransactionImpl->__transactionId);
+
+       }
+
+       return curlCode;
+}
+
+int
+_HttpTransactionImpl::OnHttpSslVerify(int preverify_ok, X509_STORE_CTX* pX509ctx)
+{
+       result r = E_SUCCESS;
+       int socketFd = -1;
+       unique_ptr<_HttpSslInfo> pSSLInfo;
+       int sslIndex = SSL_get_ex_data_X509_STORE_CTX_idx();
+       SSL* pSsl = (SSL*) X509_STORE_CTX_get_ex_data(pX509ctx, sslIndex);
+
+       SysTryReturn(NID_NET_HTTP, pSsl != null, 0, E_SYSTEM, "[E_SYSTEM] The ssl must not be null.");
+
+       socketFd = SSL_get_fd(pSsl);
+       SysLog(NID_NET_HTTP, "The ssl socket is %d.", socketFd);
+
+       X509* pServerCert = null;
+       int depth = X509_STORE_CTX_get_error_depth(pX509ctx);
+       int error = X509_STORE_CTX_get_error(pX509ctx);
+
+       if (error != X509_V_OK)
+       {
+               STACK_OF(X509)* pServerCertChain = null;
+               String serverCertString;
+               pServerCertChain = X509_STORE_CTX_get1_chain(pX509ctx);
+               if (pServerCertChain != null)
+               {
+                       int numberOfCerts = pServerCertChain->stack.num;
+                       for (int i = numberOfCerts; i > 0; i--)
+                       {
+                               pServerCert = sk_X509_pop(pServerCertChain);
+                               if (pServerCert != null)
+                               {
+                                       char tempSubjectName[_HTTP_CERT_SUBJECT_SIZE];
+                                       X509_NAME_oneline(X509_get_subject_name(pServerCert), tempSubjectName, _HTTP_CERT_SUBJECT_SIZE);
+                                       serverCertString = String(tempSubjectName);
+
+                                       SysLog(NID_NET_HTTP, "The subject of certificate is %ls[depth: %d].", serverCertString.GetPointer(), i -1);
+                                       depth = i -1;
+                                       X509_free(pServerCert);
+
+                               }
+                       }
+                       sk_X509_free(pServerCertChain);
+               }
+
+               const char* pErrorMsg = X509_verify_cert_error_string(error);
+               SysLog(NID_NET_HTTP, "Failed to verify the cert. depth(%d) - error(%s)", depth, pErrorMsg);
+               SysLog(NID_NET_HTTP, "The subject of last certificate is %ls.", serverCertString.GetPointer());
+
+               pSSLInfo.reset(new (std::nothrow) _HttpSslInfo(socketFd, depth, serverCertString, pErrorMsg));
+               SysTryReturn(NID_NET_HTTP, pSSLInfo != null, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = _HttpUtility::AddSslCertInfo(*pSSLInfo);
+               SysTryReturn(NID_NET_HTTP, r == E_SUCCESS, 0, r, "[%s] Memory allocation failed.", GetErrorMessage(r));
+
+               pSSLInfo.release();
+
+               return 0;
+
+       }
+       else
+       {
+               return 1;
+       }
+}
+
+gboolean
+_HttpTransactionImpl::OnHttpTransactionTimerExpiredEvent(gpointer pUserData)
+{
+       int timerId = -1;
+       _HttpTransactionImpl* pHttpTransactionImpl = static_cast< _HttpTransactionImpl* >(pUserData);
+
+       if (pHttpTransactionImpl->__pTimerSource != null)
+       {
+               timerId = g_source_get_id(pHttpTransactionImpl->__pTimerSource);
+               g_source_set_callback(pHttpTransactionImpl->__pTimerSource, null, null, null);
+               pHttpTransactionImpl->__pTimerSource = null;
+               SysLog(NID_NET_HTTP, "Deleted g_source_destroy(%d)", timerId);
+
+               if (!pHttpTransactionImpl->IsClosed())
+               {
+                       //Fire the event(NET_HTTP_TRANSACTION_EVENT_ABORTED) - E_TIMEOUT
+                       pHttpTransactionImpl->__pHttpTransactionEvent->FireTransactionAbortedEvent(E_TIMEOUT, true);
+               }
+       }
+
+       return false;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpTransactionUserData.cpp b/src/http/FNetHttp_HttpTransactionUserData.cpp
new file mode 100644 (file)
index 0000000..4ca929a
--- /dev/null
@@ -0,0 +1,133 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpTransactionUserData.cpp
+ * @brief              This is the implementation file for _HttpTransactionUserData class.
+ */
+
+#include <FNetHttpHttpTypes.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpCommon.h"
+#include "FNetHttp_HttpTransactionImpl.h"
+#include "FNetHttp_HttpTransactionUserData.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+_HttpTransactionUserData::_HttpTransactionUserData(_HttpTransactionImpl* pHttpTransactionImpl, _HttpCurl* pHttpCurl)
+{
+       __pHttpTransactionImpl = pHttpTransactionImpl;
+       __transactionId = pHttpTransactionImpl->GetTransactionId();
+       __isAlreadyClosedTransaction = false;
+       __isAbortedTransaction = false;
+       __refCount = 0;
+       __pHttpCurl = pHttpCurl;
+       __pCurlRequestHeaderList = null;
+       __socketFd = -1;
+       __pServerCert = null;
+       __isServerCertError = false;
+       __error[0] = '\0';
+
+       AddRef();
+}
+
+_HttpTransactionUserData::~_HttpTransactionUserData(void)
+{
+       __pHttpTransactionImpl = null;
+
+       if (__pCurlRequestHeaderList != null)
+       {
+               curl_slist_free_all(__pCurlRequestHeaderList);
+               __pCurlRequestHeaderList = null;
+       }
+
+       SysLog(NID_NET_HTTP, "_HttpTransactionUserData of HttpTransaction[%d] was deleted", __transactionId);
+}
+
+void
+_HttpTransactionUserData::AddRef(void)
+{
+       __refCount++;
+       SysLog(NID_NET_HTTP, "The reference count of this instance is %d. HttpTransaction[%d]", __refCount, __transactionId);
+}
+
+void
+_HttpTransactionUserData::Release(void)
+{
+       __refCount--;
+
+       SysLog(NID_NET_HTTP, "The reference count of this instance is %d. HttpTransaction[%d]", __refCount, __transactionId);
+
+       if (__refCount == 0)
+       {
+               SysLog(NID_NET_HTTP, "The reference count of this instance is 0. So this instance will be deleted.");
+               delete this;
+       }
+}
+
+void
+_HttpTransactionUserData::CloseTransaction(void)
+{
+       __isAlreadyClosedTransaction = true;
+}
+
+bool
+_HttpTransactionUserData::IsClosedTransaction(void) const
+{
+       return __isAlreadyClosedTransaction;
+}
+
+bool
+_HttpTransactionUserData::IsAbortedTransaction(void) const
+{
+       return __isAbortedTransaction;
+}
+
+_HttpTransactionImpl*
+_HttpTransactionUserData::GetHttpTransactionImpl(void) const
+{
+       return __pHttpTransactionImpl;
+}
+
+int
+_HttpTransactionUserData::GetTransactionId(void) const
+{
+       return __transactionId;
+}
+
+int
+_HttpTransactionUserData::GetSocketFd(void) const
+{
+       return __socketFd;
+}
+
+_HttpCurl*
+_HttpTransactionUserData::GetHttpCurl(void) const
+{
+       return __pHttpCurl;
+}
+
+const char*
+_HttpTransactionUserData::GetErrorMessage(void) const
+{
+       return __error;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpTransactionUserData.h b/src/http/FNetHttp_HttpTransactionUserData.h
new file mode 100644 (file)
index 0000000..19e4504
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpTransactionUserData.h
+ * @brief              This is the header file for the %_HttpTransactionUserData class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_TRANSACTION_USER_DATA_H_
+#define _FNET_HTTP_INTERNAL_HTTP_TRANSACTION_USER_DATA_H_
+
+#include <sys/socket.h>
+#include <curl.h>
+#include <glib.h>
+#include <FBaseColArrayListT.h>
+#include <FOspConfig.h>
+#include <FNetHttpHttpTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+} }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpTransactionImpl;
+class _HttpCurl;
+
+class _HttpTransactionUserData
+       : public Tizen::Base::Object
+{
+
+public:
+       _HttpTransactionUserData(_HttpTransactionImpl* __pHttpTransactionImpl, _HttpCurl* pHttpCurl);
+
+       virtual ~_HttpTransactionUserData(void);
+
+       void AddRef(void);
+
+       void Release(void);
+
+public:
+       void CloseTransaction(void);
+
+       bool IsClosedTransaction(void) const;
+
+       bool IsAbortedTransaction(void) const;
+
+       _HttpTransactionImpl* GetHttpTransactionImpl(void) const;
+
+       int GetTransactionId(void) const;
+
+       int GetSocketFd(void) const;
+
+       _HttpCurl* GetHttpCurl(void) const;
+
+       const char* GetErrorMessage(void) const;
+
+private:
+       _HttpTransactionUserData(const _HttpTransactionUserData& rhs);
+
+       _HttpTransactionUserData& operator =(const _HttpTransactionUserData& rhs);
+
+private:
+       _HttpTransactionImpl* __pHttpTransactionImpl;
+       bool __isAlreadyClosedTransaction;
+       bool __isAbortedTransaction;
+       int __transactionId;
+       int __refCount;
+       _HttpCurl* __pHttpCurl;
+       struct curl_slist* __pCurlRequestHeaderList;
+       int __socketFd;
+       Tizen::Base::String* __pServerCert;
+       bool __isServerCertError;
+       Tizen::Base::String __certErrorMessage;
+       char __error[CURL_ERROR_SIZE];
+
+       friend class _HttpTransactionImpl;
+
+}; //_HttpTransactionUserData
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_TRANSACTION_USER_DATA_H_
diff --git a/src/http/FNetHttp_HttpUrlEncodedEntityImpl.cpp b/src/http/FNetHttp_HttpUrlEncodedEntityImpl.cpp
new file mode 100644 (file)
index 0000000..bdc99d0
--- /dev/null
@@ -0,0 +1,262 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpUrlEncodedEntityImpl.cpp
+ * @brief              This is the implementation file for the _HttpUrlEncodedEntityImpl class.
+ */
+
+#include <FBaseString.h>
+#include <FBaseByteBuffer.h>
+#include <FBaseUtil.h>
+#include <FTextLatin1Encoding.h>
+#include <FNetHttpHttpUrlEncodedEntity.h>
+#include <FBaseSysLog.h>
+#include "FNetHttp_HttpUrlEncodedEntityImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Text;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+static const wchar_t HTTP_URL_ENCODED_ENTITY_DEFAULT_CONTENT_TYPE[] = L"application/x-www-form-urlencoded";
+static const wchar_t HTTP_URL_ENCODED_ENTITY_DEFAULT_CHARSET[] = L"ISO-8859-1";
+
+_HttpUrlEncodedEntityImpl::_HttpUrlEncodedEntityImpl(void)
+       : __pEncoding(null)
+       , __contentLength(-1)
+       , __pBuffer(null)
+{
+}
+
+_HttpUrlEncodedEntityImpl::~_HttpUrlEncodedEntityImpl(void)
+{
+       if (__pBuffer != null)
+       {
+               delete __pBuffer;
+               __pBuffer = null;
+       }
+
+       if (__pEncoding != null)
+       {
+               delete __pEncoding;
+               __pEncoding = null;
+       }
+}
+
+result
+_HttpUrlEncodedEntityImpl::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       r = Construct(HTTP_URL_ENCODED_ENTITY_DEFAULT_CHARSET, __defaultEncoding);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Propagating.");
+
+       SysLog(NID_NET_HTTP, "The _HttpUrlEncodedEntityImpl instance was constructed.");
+
+       return r;
+}
+
+result
+_HttpUrlEncodedEntityImpl::Construct(const String& charset, const Encoding& encoding)
+{
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       String encodingType;
+
+       encodingType = encoding.GetEncodingType();
+       __pEncoding = Encoding::GetEncodingN(encodingType);
+       r = GetLastResult();
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, __pEncoding != null, r, "Failed to copy an encoding instance.");
+
+       __contentType = HTTP_URL_ENCODED_ENTITY_DEFAULT_CONTENT_TYPE;
+       __charset = charset;
+
+       if (!charset.IsEmpty())
+       {
+               __contentType.Append(L"; charset=");
+               __contentType.Append(charset);
+       }
+
+       __pBuffer = null;
+
+       SysLog(NID_NET_HTTP, "The _HttpUrlEncodedEntityImpl instance was constructed.");
+
+       return r;
+}
+
+long long
+_HttpUrlEncodedEntityImpl::GetContentLength(void) const
+{
+       return __contentLength;
+}
+
+Tizen::Base::String
+_HttpUrlEncodedEntityImpl::GetContentType(void) const
+{
+       return __contentType;
+}
+
+bool
+_HttpUrlEncodedEntityImpl::HasNextData(void)
+{
+       ClearLastResult();
+       bool ret = false;
+
+       if (__pBuffer && __pBuffer->GetRemaining())
+       {
+               ret = true;
+       }
+       else
+       {
+               ret = false;
+       }
+
+       return ret;
+}
+
+Tizen::Base::ByteBuffer*
+_HttpUrlEncodedEntityImpl::GetNextDataN(int recommendedSize)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+       int size = 0;
+       ByteBuffer* pData = null;
+
+       if (recommendedSize <= 0)
+       {
+               return null;
+       }
+
+       if (__pBuffer->GetRemaining() <= 0)
+       {
+               return null;
+       }
+
+       if (__pBuffer->GetRemaining() <= recommendedSize)
+       {
+               size = __pBuffer->GetRemaining();
+       }
+       else
+       {
+               size = recommendedSize;
+       }
+
+       pData = new (std::nothrow) ByteBuffer();
+       SysTryReturn(NID_NET_HTTP, pData != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pData->Construct(size);
+       if (IsFailed(r))
+       {
+               SysLogException(NID_NET_HTTP, r, "[%s] Failed to initialize a ByteBuffer.", GetErrorMessage(r));
+
+               delete pData;
+               return null;
+       }
+
+       r = pData->ReadFrom(*__pBuffer);
+       if (IsFailed(r))
+       {
+               SysLogException(NID_NET_HTTP, r, "[%s] Failed to copy data.", GetErrorMessage(r));
+
+               delete pData;
+               return null;
+       }
+
+       pData->Flip();
+
+       return pData;
+}
+
+result
+_HttpUrlEncodedEntityImpl::AddParameter(const String& name, const String& value)
+{
+       result r = E_SUCCESS;
+       String encodedName;
+       String encodedValue;
+       String addedString;
+       ByteBuffer* pAddedBuffer = null;
+
+       SysTryReturnResult(NID_NET_HTTP, name.IsEmpty() == false, E_INVALID_ARG, "Name should not be empty.");
+
+       r = UrlEncoder::Encode(name, __charset, encodedName);
+       SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Failed to encode a name.");
+
+       if (value.IsEmpty() == false)
+       {
+               r = UrlEncoder::Encode(value, __charset, encodedValue);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r, "Failed to encode a value.");
+       }
+
+       if (__pBuffer != null)
+       {
+               // Previous parameter is found... add '&'
+               addedString.Append(L"&");
+       }
+       addedString.Append(encodedName);
+       addedString.Append(L"=");
+       addedString.Append(encodedValue);
+
+       pAddedBuffer = __pEncoding->GetBytesN(addedString);
+       SysTryReturnResult(NID_NET_HTTP, pAddedBuffer != null, GetLastResult(),
+                                "Failed to encode the added parameter.");
+
+       r = pAddedBuffer->SetLimit(pAddedBuffer->GetRemaining() - 1);   // Remove null termination character.
+
+       if (__pBuffer == null)
+       {
+               __pBuffer = pAddedBuffer;
+               SysLog(NID_NET_HTTP, "__pBuffer.Length(%d).", __pBuffer->GetRemaining());
+       }
+       else
+       {
+               ByteBuffer* pFinalBuffer = null;
+               pFinalBuffer = new (std::nothrow) ByteBuffer();
+               r = pFinalBuffer->Construct(__pBuffer->GetRemaining() + pAddedBuffer->GetRemaining());
+               r = pFinalBuffer->SetArray(__pBuffer->GetPointer(), 0, __pBuffer->GetRemaining());
+               r = pFinalBuffer->SetArray(pAddedBuffer->GetPointer(), 0, pAddedBuffer->GetRemaining());
+
+               delete __pBuffer;
+               delete pAddedBuffer;
+               __pBuffer = pFinalBuffer;
+       }
+
+       __pBuffer->SetPosition(0);
+       __contentLength = __pBuffer->GetRemaining();
+
+       SysLog(NID_NET_HTTP, "The __contentLength is %d.", __contentLength);
+
+       return r;
+}
+
+_HttpUrlEncodedEntityImpl*
+_HttpUrlEncodedEntityImpl::GetInstance(HttpUrlEncodedEntity& httpUrlEncodedEntity)
+{
+       return httpUrlEncodedEntity.__pHttpUrlEncodedEntityImpl;
+}
+
+const _HttpUrlEncodedEntityImpl*
+_HttpUrlEncodedEntityImpl::GetInstance(const HttpUrlEncodedEntity& httpUrlEncodedEntity)
+{
+       return httpUrlEncodedEntity.__pHttpUrlEncodedEntityImpl;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/http/FNetHttp_HttpXmlDomEntityImpl.cpp b/src/http/FNetHttp_HttpXmlDomEntityImpl.cpp
new file mode 100644 (file)
index 0000000..14d2f5e
--- /dev/null
@@ -0,0 +1,191 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttpHttpXmlDomEntity.cpp
+ * @brief              This is the implementation file for the _HttpXmlDomEntityImpl class.
+ */
+
+#include <libxml/tree.h>
+
+#include <FBaseString.h>
+#include <FNetHttpHttpXmlDomEntity.h>
+#include "FNetHttp_HttpXmlDomEntityImpl.h"
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FBaseUtil.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Net { namespace Http
+{
+
+static const wchar_t HTTP_XML_DOM_ENTITY_DEFAULT_CONTENT_TYPE[] = L"text/xml";
+
+_HttpXmlDomEntityImpl::_HttpXmlDomEntityImpl(void)
+       : __contentLength(-1)
+       , __pBuffer(null)
+{
+}
+
+_HttpXmlDomEntityImpl::~_HttpXmlDomEntityImpl(void)
+{
+       if (__pBuffer != null)
+       {
+               delete __pBuffer;
+               __pBuffer = null;
+       }
+}
+
+result
+_HttpXmlDomEntityImpl::Construct(const xmlDoc& xmlDocument, const Tizen::Base::String& encodingScheme)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+       char* pEncoding = null;
+       xmlDoc* pDocument = null;
+       xmlChar* pXmlBuffer = null;
+       int bufferSize = 0;
+
+       pEncoding = _StringConverter::CopyToCharArrayN(encodingScheme);
+       r = GetLastResult();
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_HTTP, pEncoding != null, r, "CopyToCharArrayN() failed.");
+
+       pDocument = const_cast< xmlDoc* >(&xmlDocument);
+       xmlDocDumpFormatMemoryEnc(pDocument, &pXmlBuffer, &bufferSize, pEncoding, 1);
+       delete[] pEncoding;
+
+       if (bufferSize)
+       {
+               __pBuffer = new (std::nothrow) ByteBuffer();
+               SysTryReturnResult(NID_NET_HTTP, __pBuffer != null,
+                                                  E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               r = __pBuffer->Construct(bufferSize);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS,
+                                                  E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               r = __pBuffer->SetArray((byte*) pXmlBuffer, 0, bufferSize);
+               SysTryReturnResult(NID_NET_HTTP, r == E_SUCCESS, r,
+                                        "Propagating.");
+
+               __pBuffer->SetPosition(0);
+
+               __contentLength = __pBuffer->GetRemaining();
+
+               xmlFree(pXmlBuffer);
+       }
+       else
+       {
+               SysLogException(NID_NET_HTTP, E_INVALID_ENCODING_RANGE,
+                                               "[E_INVALID_ENCODING_RANGE] Failed to encode the xml document.");
+
+               r = E_INVALID_ENCODING_RANGE;
+               __pBuffer = null;
+       }
+
+       return r;
+}
+
+long long
+_HttpXmlDomEntityImpl::GetContentLength(void) const
+{
+       return __contentLength;
+}
+
+Tizen::Base::String
+_HttpXmlDomEntityImpl::GetContentType(void) const
+{
+       String contentType(HTTP_XML_DOM_ENTITY_DEFAULT_CONTENT_TYPE);
+
+       return contentType;
+}
+
+_HttpXmlDomEntityImpl*
+_HttpXmlDomEntityImpl::GetInstance(HttpXmlDomEntity& httpXmlDomEntity)
+{
+       return httpXmlDomEntity.__pHttpXmlDomEntityImpl;
+}
+
+const _HttpXmlDomEntityImpl*
+_HttpXmlDomEntityImpl::GetInstance(const HttpXmlDomEntity& httpXmlDomEntity)
+{
+       return httpXmlDomEntity.__pHttpXmlDomEntityImpl;
+}
+
+bool
+_HttpXmlDomEntityImpl::HasNextData(void)
+{
+       ClearLastResult();
+       bool ret = false;
+
+       if (__pBuffer && __pBuffer->GetRemaining())
+               ret = true;
+       else
+               ret = false;
+
+       return ret;
+}
+
+Tizen::Base::ByteBuffer*
+_HttpXmlDomEntityImpl::GetNextDataN(int recommendedSize)
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+       int size = 0;
+       ByteBuffer* pData = null;
+
+       if (0 >= recommendedSize)
+               return null;
+
+       if (0 >= __pBuffer->GetRemaining())
+               return null;
+
+       if (__pBuffer->GetRemaining() <= recommendedSize)
+               size = __pBuffer->GetRemaining();
+       else
+               size = recommendedSize;
+
+       pData = new (std::nothrow) ByteBuffer();
+       SysTryReturn(NID_NET_HTTP, pData != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pData->Construct(size);
+       if (IsFailed(r))
+       {
+               SysLogException(NID_NET_HTTP, r, "[%s] Failed to initialize a ByteBuffer.", GetErrorMessage(r));
+
+               delete pData;
+               return null;
+       }
+
+       r = pData->ReadFrom(*__pBuffer);
+       if (IsFailed(r))
+       {
+               SysLogException(NID_NET_HTTP, r, "[%s] Failed to copy data.", GetErrorMessage(r));
+
+               delete pData;
+               return null;
+       }
+
+       pData->Flip();
+
+       return pData;
+}
+
+} } } // Tizen::Net::Http
diff --git a/src/inc/FNetHttp_HttpAuthenticationImpl.h b/src/inc/FNetHttp_HttpAuthenticationImpl.h
new file mode 100644 (file)
index 0000000..ac4b5fe
--- /dev/null
@@ -0,0 +1,131 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpAuthenticationImpl.h
+ * @brief              This is the header file for the %_HttpAuthenticationImpl class.
+ *
+ * This header file contains the declarations of the %_HttpAuthenticationImpl class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_AUTHENTICATION_IMPL_H_
+#define _FNET_HTTP_INTERNAL_HTTP_AUTHENTICATION_IMPL_H_
+
+#include <FOspConfig.h>
+#include <FNetHttpHttpTypes.h>
+#include "FNetHttp_HttpCommon.h"
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpTransaction;
+class HttpCredentials;
+class _HttpTransactionImpl;
+class _HttpCurl;
+/**
+ * @class      _HttpAuthenticationImpl
+ * @brief      This class encapsulates an %HTTP authentication.
+ *
+ * @since 2.1
+  */
+
+class _OSP_EXPORT_ _HttpAuthenticationImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       ~_HttpAuthenticationImpl(void);
+
+       /**
+        * @see                 HttpAuthentication::GetRealmN()
+        */
+       Tizen::Base::String* GetRealmN(void) const;
+
+       /**
+        * @see                 HttpAuthentication::GetAuthScheme()
+        */
+       NetHttpAuthScheme GetAuthScheme(void) const;
+
+       /**
+        * @see                 HttpAuthentication::SetCredentials()
+        */
+       HttpTransaction* SetCredentials(HttpCredentials& credentials);
+
+public:
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpAuthenticationImpl
+        * @param[in]   pHttpAuthentication            An instance of HttpAuthentication
+        */
+       static _HttpAuthenticationImpl* GetInstance(HttpAuthentication& hHttpAuthentication);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpAuthenticationImpl
+        * @param[in]   pHttpAuthentication            An instance of HttpAuthentication
+        */
+       static const _HttpAuthenticationImpl* GetInstance(const HttpAuthentication& httpAuthentication);
+
+public:
+       HttpTransaction* Authenticate(HttpCredentials& credentials);
+
+       HttpCredentials GetCredentials(void) const;
+
+       bool IsProxyAuthenticationType(void) const;
+
+       void SetHttpCurl(_HttpCurl* pHttpCurl);
+
+       _HttpCurl* GetHttpCurl(void) const;
+
+public:
+       _HttpAuthenticationImpl(void);
+
+       result Construct(_HttpTransactionImpl& httpTransactionImpl);
+
+       result Construct(const _HttpAuthenticationImpl& authenticationImpl, _HttpTransactionImpl& httpTransactionImpl);
+
+       static HttpAuthentication* CreateHttpAuthenticationN(void);
+
+       static void DeleteHttpAuthentication(HttpAuthentication* pHttpAuthentication);
+
+private:
+       _HttpAuthenticationImpl(const _HttpAuthenticationImpl& rhs);
+
+       _HttpAuthenticationImpl& operator =(const _HttpAuthenticationImpl& rhs);
+
+private:
+       _HttpTransactionImpl* __pHttpTransactionImpl;
+       NetHttpAuthScheme __authType;
+       bool __isProxyAuthType;
+       Tizen::Base::String __realm;
+       HttpCredentials __credentials;
+       _HttpCurl* __pHttpCurl;
+
+       friend class HttpAuthentication;
+
+}; // _HttpAuthenticationImpl
+
+} } } //Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_AUTHENTICATION_IMPL_H_
diff --git a/src/inc/FNetHttp_HttpCommon.h b/src/inc/FNetHttp_HttpCommon.h
new file mode 100644 (file)
index 0000000..15c1c54
--- /dev/null
@@ -0,0 +1,571 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpCommon.h
+ * @brief              This is the header file for defining common types and utility functions for %HTTP operations.
+ *
+ * This header file contains the definition of common types and utility functions for %HTTP operations.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_COMMON_H_
+#define _FNET_HTTP_INTERNAL_HTTP_COMMON_H_
+
+#include <curl.h>
+#include <FNetHttpHttpTypes.h>
+#include <FBaseSysLog.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+class String;
+} }
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } }
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class Mutex;
+} } }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class _HttpSslInfo;
+
+/**
+ * The User-Agent header name
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_USERAGENT_HEADER_NAME[];
+
+/**
+ * The Content-Length header name
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_CONTENT_LENGTH_HEADER_NAME[];
+
+/**
+ * The Content-Type header name
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_CONTENT_TYPE_HEADER_NAME[];
+
+/**
+ * The Transfer-Encoding header name
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_TRANSFER_ENCODING_HEADER_NAME[];
+
+/**
+ * The Expect header name
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_EXPECT_HEADER_NAME[];
+
+/**
+ * The Set-Cookie name
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_SET_COOKIE_HEADER_NAME[];
+
+/**
+ * The Proxy-Authenticate name
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_PROXY_AUTHENTICATE_HEADER_NAME[];
+
+/**
+ * The WWW-Authenticate
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_WWW_AUTHENTICATE_HEADER_NAME[];
+
+/**
+ * The chunked header value
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_CHUNKED_HEADER_VALUE[];
+
+/**
+ * The protocol scheme of http://
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_PROTOCOL_SCHEME[];
+
+/**
+ * The protocol scheme of https://
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTPS_PROTOCOL_SCHEME[];
+
+/**
+ * The default charset of body part.
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_DEFAULT_BODY_CHARSET[];
+
+/**
+ * The prefix of multipart/form-data.
+ */
+_OSP_EXPORT_ extern const wchar_t _MULTI_PART_FORM_DATA_PREFIX[];
+
+/**
+ * The default charset of string part.
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_STRING_PART_DEFAULT_CHARSET[];
+
+/**
+ * The default charset of file part.
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_FILE_PART_DEFAULT_CHARSET[];
+
+/**
+ * The character set of boundary
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_MULTI_PART_BOUNDARY_CHARACTER_SET[];
+
+/**
+ * The length of character set of boundary
+ */
+static const int _HTTP_MULTI_PART_BOUNDARY_CHARACTER_SET_LENGTH = 62;
+
+/**
+ * The delimiter of cookie value
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_SET_COOKIE_DELIMITER[];
+
+/**
+ * The delimiter of cookie flag
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_SET_COOKIE_FLAG_DELIMITER[];
+
+/**
+ * The Comment flag name of Cookie
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_COOKIE_COMMENT_NAME[];
+
+/**
+ * The CommentURL flag name of Cookie
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_COOKIE_COMMENTURL_NAME[];
+
+/**
+ * The Discard flag name of Cookie
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_COOKIE_DISCARD_NAME[];
+
+/**
+ * The Expires flag name of Cookie
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_COOKIE_EXPIRES_NAME[];
+
+/**
+ * The Domain flag name of Cookie
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_COOKIE_DOMAIN_NAME[];
+
+/**
+ * The Max-Age flag name of Cookie
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_COOKIE_MAX_AGE_NAME[];
+
+/**
+ * The Path flag name of Cookie
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_COOKIE_PATH_NAME[];
+
+/**
+ * The Port flag name of Cookie
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_COOKIE_PORT_NAME[];
+
+/**
+ * The Secure flag name of Cookie
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_COOKIE_SECURE_NAME[];
+
+/**
+ * The Version flag name of Cookie
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_COOKIE_VERSION_NAME[];
+
+/**
+ * The HttpOnly flag name of Cookie
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_COOKIE_HTTP_ONLY[];
+
+/**
+ * The carriage return and line feed characters
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_CARRIAGE_RETURN_LINE_FEED[];
+
+/**
+ * The #HttpOnly_ prefix of curl
+ */
+_OSP_EXPORT_ extern const wchar_t _CURL_COOKIE_HTTP_ONLY_PREFIX[];
+
+/**
+ * The path of cookie file ({application-home dir}/data/cookies.txt)
+ */
+_OSP_EXPORT_ extern const wchar_t _HTTP_COOKIE_FILE[];
+
+static const int _CURL_COOKIE_DOMAIN_NAME_INDEX = 0;
+
+static const int _CURL_COOKIE_COOKIE_NAME_INDEX = 5;
+
+static const int _CURL_COOKIE_COOKIE_VALUE_INDEX = 6;
+
+static const int _COOKIE_PREFIX_LENGTH = 7;
+
+static const long long _HTTP_INVALID_CONTENT_LENGTH = -1;
+
+static const int _HTTP_INVALID_ID = -1;
+
+/**
+ * The maximum number of transactions allowed (NET_HTTP_SESSION_MODE_NORMAL mode)
+ */
+static const int _MAX_HTTP_TRANSACTIONS_PER_SESSION_NORMAL = 1;
+
+/**
+ * The maximum number of transactions allowed (NET_HTTP_SESSION_MODE_PIPELINING mode)
+ */
+static const int _MAX_HTTP_TRANSACTIONS_PER_SESSION_PIPE = 5;
+
+/**
+ * The maximum number of transactions allowed (NET_HTTP_SESSION_MODE_PIPELINING mode), '0' means that the platform does not limit the number of maximum HttpTransaction that that HttpSession can have.
+ */
+static const int _MAX_HTTP_TRANSACTIONS_PER_SESSION_MULTIPLE_HOST = 0;
+
+/**
+ * The maximum number of session that application can have.
+ */
+static const int _MAX_HTTP_SESSIONS_PER_APPID_PER_PROTOCOL = 10;
+
+/**
+ * The length of multi-part boundary
+ */
+static const int _HTTP_MULTIPART_BOUNDARY_LENGTH = 40;
+
+/**
+ * The default connection timeout
+ */
+static const int _HTTP_DEFAULT_CONNECTION_TIMEOUT = 30;
+
+/**
+ * The http default port
+ */
+static const int _HTTP_DEFAULT_PORT = 80;
+
+/**
+ * The event type of transaction
+ */
+enum _HttpTransactionEventType
+{
+       _HTTP_TRANSACTION_EVENT_TYPE_UNDEFINED = 0,
+       _HTTP_TRANSACTION_EVENT_TYPE_HEADER_COMPLETED,
+       _HTTP_TRANSACTION_EVENT_TYPE_READY_TO_READ,
+       _HTTP_TRANSACTION_EVENT_TYPE_READY_TO_WRITE,
+       _HTTP_TRANSACTION_EVENT_TYPE_COMPLETD,
+       _HTTP_TRANSACTION_EVENT_TYPE_ABORTED,
+       _HTTP_TRANSACTION_EVENT_TYPE_CERT_VERIFICATION_REQUIRED,
+       _HTTP_TRANSACTION_EVENT_TYPE_UPLOAD_PROGRESS,
+       _HTTP_TRANSACTION_EVENT_TYPE_DOWNLOAD_PROGRESS
+};
+
+/**
+ * The maximum size of header
+ */
+static const int _HTTP_DEFAULT_HEADER_SIZE = 1024;
+
+/**
+ * The maximum limit of depth for certificate verification.
+ */
+static const int _HTTP_CERT_VERIFICATION_DEPTH_LIMIT = 9;
+
+/**
+ * The maximum size of certificate subject.
+ */
+static const int _HTTP_CERT_SUBJECT_SIZE = 256;
+
+/**
+ * The maximum size of body to read.
+ */
+static const int _MAX_HTTP_BODY_SIZE = CURL_MAX_WRITE_SIZE;
+
+/**
+ * The length of multi-part boundary
+ */
+static const int _HTTP_NETWORK_ERROR = -1;
+
+static const long _CURL_HTTP_AUTH_NONE = 0;                 //none
+static const long _CURL_HTTP_AUTH_BASIC = 1;                    // The constant for basic authentication
+static const long _CURL_HTTP_AUTH_DIGEST = 2;               // The constant for digest authentication
+static const long _CURL_HTTP_AUTH_GSSNEGOTIATE = 4;         // The constant for gss-negotiate authentication
+static const long _CURL_HTTP_AUTH_NTLM = 8;                  // The constant for ntlm authentication
+static const long _CURL_HTTP_AUTH_DIGEST_IE = 16;            //Not Support
+
+class _HttpUtility
+{
+
+public:
+       /**
+        * Checks whether the host address contains the protocol scheme such as "http://" or "https://".
+        *
+        * @return              @c true if the host address contains the protocol scheme, @n
+        *                              else @c false
+        * @param[in]   host    The host address
+        */
+       static bool HasProtocolScheme(const Tizen::Base::String& host);
+
+       /**
+        * Gets the protocol scheme.
+        *
+        * @return              The protocol scheme.
+        * @param[in]   host                            The host address
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG       Invalid argument.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static Tizen::Base::String GetProtocolScheme(const Tizen::Base::String& host);
+
+       /**
+        * Compares the values of the two hosts.
+        *
+        * @return              @c true if the host part of @c host0 equal to the @c host1, @n
+        *                              else @c false
+        * @param[in]   host0                           The host address
+        * @param[in]   host1                           The host address
+        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_INVALID_ARG       Invalid argument.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static bool CompareHost(const Tizen::Base::String& host0, const Tizen::Base::String& host1);
+
+       /**
+        * Gets the cookie file path.
+        *
+        * @return              The cookie file path.
+        */
+       static Tizen::Base::String GetCookieFilePath(void);
+
+       /**
+        * Converts NetHttpTransactionEventType to string name.
+        *
+        * @return              The string of NetHttpTransactionEventType
+        * @param[in]   index                           The index of NetHttpTransactionEventType
+        */
+       static const char* ConvertHttpTransactionEventTypeToString(_HttpTransactionEventType index);
+
+       /**
+        * Adds a buffer to the header buffer.
+        *
+        * @return              An error code
+        * @param[in]   ppSrcBuffer                     The source buffer, it can be replaced with new buffer.
+        * @param[in]   destBuffer                      The destination buffer to be added
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        */
+       static result AddHeaderByteBufferToBuffer(Tizen::Base::ByteBuffer** ppSrcBuffer, const Tizen::Base::ByteBuffer& destBuffer);
+
+       /**
+        * Adds a bytes to the header buffer.
+        *
+        * @return              An error code
+        * @param[in]   ppSrcBuffer                     The source buffer, it can be replaced with new buffer.
+        * @param[in]   pDestBytes                      The destination bytes
+        * @param[in]   destBytesSize           The size of destination bytes
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        */
+       static result AddHeaderBytesToBuffer(Tizen::Base::ByteBuffer** ppSrcBuffer, const byte* pDestBytes, int destBytesSize);
+
+       /**
+        * Adds a destination buffer to the source buffer.
+        *
+        * @return              An error code
+        * @param[in]   ppSrcBuffer                     The source buffer, it can be replaced with new buffer.
+        * @param[in]   destBuffer                      The destination buffer to be added
+        * @param[in]   defaultExtendedSize     The extended size of buffer.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        */
+       static result AddByteBufferToBuffer(Tizen::Base::ByteBuffer** ppSrcBuffer, const Tizen::Base::ByteBuffer& destBuffer, int defaultExtendedSize);
+
+       /**
+        * Adds a bytes to the buffer.
+        *
+        * @return              An error code
+        * @param[in]   ppSrcBuffer                     The source buffer, it can be replaced with new buffer.
+        * @param[in]   pDestBytes                      The destination bytes
+        * @param[in]   destBytesSize           The size of destination bytes
+        * @param[in]   defaultExtendedSize     The extended size of buffer.
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        */
+       static result AddBytesToBuffer(Tizen::Base::ByteBuffer** ppSrcBuffer, const byte* pDestBytes, int destBytesSize, int defaultExtendedSize);
+
+       /**
+        * Prints a curl error code.
+        *
+        * @param[in]   code                    The error code of CURLMcode
+        */
+       static void PrintCurlMultiErrorCode(CURLMcode code);
+
+       /**
+        * Destroy system variables for HTTP.
+        */
+       static void DestroyHttp(void);
+
+       /**
+        * Once block for thread-safe singleton.
+        */
+       static void     InitializeHttpOnce(void);
+
+       /**
+        * Initialize system variables for HTTP.
+        */
+       static void InitializeHttp(void);
+
+       /**
+        * Get the system mutex.
+        */
+       static Tizen::Base::Runtime::Mutex* GetHttpMutex(void);
+
+       /**
+        * Converts the auth scheme of curl to the auth scheme of osp.
+        *
+        * @return              The auth scheme of osp
+        * @param[in]   isProxyAuth                     @c true if the @c curlAuthScheme is proxy auth, @n
+        *                                                                      else @c false
+        * @param[in]   curlAuthScheme          The auth scheme of curl
+        */
+       static NetHttpAuthScheme GetHttpAuthScheme(bool isProxyAuth, long curlAuthScheme);
+
+       /**
+        * Gets the name of auth scheme.
+        *
+        * @return              The name of auth scheme
+        * @param[in]   httpAuthScheme          The auth scheme of osp
+        */
+       static const char* GetHttpAuthSchemeByString(NetHttpAuthScheme httpAuthScheme);
+
+       /**
+        * Converts the auth scheme of osp to the auth scheme of curl.
+        *
+        * @return              The auth scheme of curl
+        * @param[in]   httpAuthScheme          The auth scheme of osp
+        */
+       static long GetHttpCurlAuthScheme(NetHttpAuthScheme httpAuthScheme);
+
+       /**
+        * Converts a curl error code to an osp error.
+        *
+        * @return              An error code
+        * @param[in]   code                    The error code of CURLcode
+        */
+       static result ConvertErrorCode(CURLcode code);
+
+       /**
+        * Checks whether the error code is a ssl error.
+        *
+        * @return              @c true if he error code is a ssl error, @n
+        *                              else @c false
+        * @param[in]   code                    The error code of CURLcode
+        */
+       static bool IsSslError(CURLcode code);
+
+       /**
+        * Gets certificate list.
+        *
+        * @return              The certificate list <_HttpSslInfo>
+        */
+       static Tizen::Base::Collection::IList* GetSslCertList(void);
+
+       /**
+        * Adds a _HttpSslInfo
+        *
+        * @return              An error code
+        * @param[in]   sslInfo                         The instance of _HttpSslInfo
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        */
+       static result AddSslCertInfo(_HttpSslInfo& sslInfo);
+
+       /**
+        * Gets a list of _HttpSslInfo searched by socket fd.
+        *
+        * @return              The instance of _HttpSslInfo
+        * @param[in]   socketFd                        The socket fd
+        * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
+        * @exception   E_SYSTEM                        A system error has occurred.
+        * @remarks             The specific error code can be accessed using the GetLastResult() method.
+        */
+       static Tizen::Base::Collection::IList* GetSslCertInfoN(int socketFd);
+
+       /**
+        * Removes a _HttpSslInfo
+        *
+        * @return              An error code
+        * @param[in]   socketFd                        The socket fd
+        * @exception   E_SYSTEM                        A system error has occurred.
+        */
+       static result RemoveSslCertInfo(int socketFd);
+
+private:
+       /**
+        * This is the default constructor for this class.
+        */
+       _HttpUtility(void);
+
+       /**
+        * This is the destructor for this class.
+        */
+       virtual ~_HttpUtility(void);
+
+private:
+       _HttpUtility(const _HttpUtility& rhs);
+       _HttpUtility& operator =(const _HttpUtility& rhs);
+
+private:
+
+       // system variables for system. (singleton)
+       static bool __initialized;
+       static Tizen::Base::Runtime::Mutex* __pHttpMutex;
+       static Tizen::Base::Collection::IList* __pSslCertList;
+
+
+}; // _HttpUtility
+
+/**
+ * @class      _HttpSslInfo
+ * @brief      This class represents a SSL Information.
+ *
+ */
+class _HttpSslInfo
+       : public Tizen::Base::Object
+{
+
+public:
+       _HttpSslInfo(int socketFd, int depth, const Tizen::Base::String& serverCert, const Tizen::Base::String& errorMessage);
+       virtual ~_HttpSslInfo(void);
+
+    int GetSocketFd(void) const;
+    int GetDepth(void) const;
+    Tizen::Base::String GetErrorMessage(void) const;
+    Tizen::Base::String GetServerCert(void) const;
+
+private:
+       int __socketFd;
+       int __depth;
+       Tizen::Base::String __serverCert;
+       Tizen::Base::String __errorMessage;
+
+}; //_HttpSslInfo
+
+} } } //Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_COMMON_H_
diff --git a/src/inc/FNetHttp_HttpCookieImpl.h b/src/inc/FNetHttp_HttpCookieImpl.h
new file mode 100644 (file)
index 0000000..67dddb8
--- /dev/null
@@ -0,0 +1,195 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpCookieImpl.h
+ * @brief              This is the header file for the %_HttpCookieImpl class.
+ *
+ * This header file contains the declarations of the %_HttpCookieImpl class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_COOKIE_IMPL_H_
+#define _FNET_HTTP_INTERNAL_HTTP_COOKIE_IMPL_H_
+
+#include <FOspConfig.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+} }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpCookie;
+/**
+ * @class      _HttpCookieImpl
+ * @brief      This class provides a Http cookie.
+ *
+ * @since 2.1
+  */
+
+class _OSP_EXPORT_ _HttpCookieImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * @see                 HttpCookie::GetDomain()
+        */
+       Tizen::Base::String GetDomain(void) const;
+
+       /**
+        * @see                 HttpCookie::GetPath()
+        */
+       Tizen::Base::String GetPath(void) const;
+
+       /**
+        * @see                 HttpCookie::GetVersion()
+        */
+       Tizen::Base::String GetVersion(void) const;
+
+       /**
+        * @see                 HttpCookie::GetExpires()
+        */
+       Tizen::Base::String GetExpires(void) const;
+
+       /**
+        * @see                 HttpCookie::IsSecure()
+        */
+       bool IsSecure(void) const;
+
+       /**
+        * @see                 HttpCookie::GetCookieName()
+        */
+       Tizen::Base::String GetCookieName(void) const;
+
+       /**
+        * @see                 HttpCookie::GetCookieValue()
+        */
+       Tizen::Base::String GetCookieValue(void) const;
+
+       /**
+        * @see                 HttpCookie::GetCommentUrl()
+        */
+       Tizen::Base::String GetCommentUrl(void) const;
+
+       /**
+        * @see                 HttpCookie::GetComment()
+        */
+       Tizen::Base::String GetComment(void) const;
+
+       /**
+        * @see                 HttpCookie::IsHttpOnly()
+        */
+       bool IsHttpOnly(void) const;
+
+       /**
+        * @see                 HttpCookie::GetPorts()
+        */
+       Tizen::Base::String GetPorts(void) const;
+
+       /**
+        * @see                 HttpCookie::GetMaxAge()
+        */
+       int GetMaxAge(void) const;
+
+       /**
+        * @see                 HttpCookie::GetDiscard()
+        */
+       bool GetDiscard(void) const;
+
+public:
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpCookieImpl
+        * @param[in]   pHttpCookie            An instance of HttpCookie
+        */
+       static _HttpCookieImpl* GetInstance(HttpCookie& httpCookie);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpCookieImpl
+        * @param[in]   pHttpCookie            An instance of HttpCookie
+        */
+       static const _HttpCookieImpl* GetInstance(const HttpCookie& httpCookie);
+
+public:
+       void SetDomain(const Tizen::Base::String& domain);
+
+       void SetPath(const Tizen::Base::String& path);
+
+       void SetVersion(const Tizen::Base::String& version);
+
+       void SetExpires(const Tizen::Base::String& expires);
+
+       void SetSecure(bool isSecure);
+
+       void SetCookieName(const Tizen::Base::String& name);
+
+       void SetCookieValue(const Tizen::Base::String& value);
+
+       void SetCommentUrl(const Tizen::Base::String& commentUrl);
+
+       void SetComment(const Tizen::Base::String& comment);
+
+       void SetHttpOnly(bool isHttpOnly);
+
+       void SetPorts(const Tizen::Base::String& ports);
+
+       void SetMaxAge(int maxAge);
+
+       void SetDiscard(bool isDiscard);
+
+public:
+       _HttpCookieImpl(void);
+
+       ~_HttpCookieImpl(void);
+
+       static HttpCookie* CreateHttpCookieN(void);
+
+       static void DeleteHttpCookie(HttpCookie* pCookie);
+
+private:
+       _HttpCookieImpl(const _HttpCookieImpl& rhs);
+
+       _HttpCookieImpl& operator =(const _HttpCookieImpl& rhs);
+
+private:
+       Tizen::Base::String __domain;
+       Tizen::Base::String __path;
+       Tizen::Base::String __version;
+       Tizen::Base::String __expires;
+       bool __isSecure;
+       Tizen::Base::String __name;
+       Tizen::Base::String __value;
+       Tizen::Base::String __commentUrl;
+       Tizen::Base::String __comment;
+       bool __isHttpOnly;
+       Tizen::Base::String __ports;
+       int __maxAge;
+       bool __isDisacrd;
+
+       friend class HttpCookie;
+
+}; // _HttpCookieImpl
+
+} } } //Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_COOKIE_IMPL_H_
diff --git a/src/inc/FNetHttp_HttpCookieStorageManagerImpl.h b/src/inc/FNetHttp_HttpCookieStorageManagerImpl.h
new file mode 100644 (file)
index 0000000..1188c73
--- /dev/null
@@ -0,0 +1,99 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpCookieStorageManagerImpl.h
+ * @brief              This is the header file for the %_HttpCookieStorageManagerImpl class.
+ *
+ * This header file contains the declarations of the %_HttpCookieStorageManagerImpl class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_COOKIE_STORAGE_MANAGER_IMPL_H_
+#define _FNET_HTTP_INTERNAL_HTTP_COOKIE_STORAGE_MANAGER_IMPL_H_
+
+#include <FOspConfig.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpCookieStorageManager;
+class _HttpSessionImpl;
+/**
+ * @class      _HttpCookieStorageManagerImpl
+ * @brief      This class provides a collection of %Http cookies of a particular session.
+ *
+ * @since 2.1
+ */
+
+class _OSP_EXPORT_ _HttpCookieStorageManagerImpl
+{
+
+public:
+       /**
+        * @see                 HttpCookieStorageManager::GetCookies()
+        */
+       result GetCookies(const Tizen::Base::String& url, Tizen::Base::String& cookies) const;
+
+       /**
+        * @see                 HttpCookieStorageManager::RemoveCookies()
+        */
+       result RemoveCookies(const Tizen::Base::String& url);
+
+       /**
+        * @see                 HttpCookieStorageManager::RemoveAllCookies()
+        */
+       result RemoveAllCookies();
+
+public:
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpCookieStorageManagerImpl
+        * @param[in]   pHttpCookieStorageManager            An instance of HttpCookieStorageManager
+        */
+       static _HttpCookieStorageManagerImpl* GetInstance(HttpCookieStorageManager& httpCookieStorageManager);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpCookieStorageManagerImpl
+        * @param[in]   pHttpCookieStorageManager            An instance of HttpCookieStorageManager
+        */
+       static const _HttpCookieStorageManagerImpl* GetInstance(const HttpCookieStorageManager& httpCookieStorageManager);
+
+public:
+       _HttpCookieStorageManagerImpl();
+
+       ~_HttpCookieStorageManagerImpl();
+
+       static HttpCookieStorageManager* CreateHttpCookieStorageManagerN(void);
+
+       static void DeleteHttpCookieStorageManager(HttpCookieStorageManager* pHttpCookieStorageManager);
+
+private:
+       _HttpCookieStorageManagerImpl(const _HttpCookieStorageManagerImpl& rhs);
+
+       _HttpCookieStorageManagerImpl& operator =(const _HttpCookieStorageManagerImpl& rhs);
+
+private:
+       friend class HttpCookieStorageManager;
+
+}; // _HttpCookieStorageManagerImpl
+
+} } } //Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_COOKIE_STORAGE_MANAGER_IMPL_H_
diff --git a/src/inc/FNetHttp_HttpHeaderImpl.h b/src/inc/FNetHttp_HttpHeaderImpl.h
new file mode 100644 (file)
index 0000000..2cdd08c
--- /dev/null
@@ -0,0 +1,163 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpHeaderImpl.h
+ * @brief              This is the header file for the %_HttpHeaderImpl class.
+ *
+ * This header file contains the declarations of the %_HttpHeaderImpl class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_HEADER_IMPL_H_
+#define _FNET_HTTP_INTERNAL_HTTP_HEADER_IMPL_H_
+
+#include <curl.h>
+#include <FOspConfig.h>
+#include <FNetHttpHttpTypes.h>
+#include "FNetHttp_HttpCommon.h"
+
+namespace Tizen { namespace Base
+{
+class String;
+} }
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class MultiHashMap;
+class IEnumerator;
+} } }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpHeader;
+class _HttpStringComparer;
+class _HttpMultiHashMapProvider;
+/**
+ * @class      _HttpHeaderImpl
+ * @brief      This class encapsulates the header fields associated with a message.
+ *
+ * @since 2.1
+ */
+
+class _OSP_EXPORT_ _HttpHeaderImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        */
+       _HttpHeaderImpl(void);
+
+       /**
+        * This is the copy constructor for the %_HttpHeaderImpl class. @n
+        * This initializes an instance of %_HttpHeaderImpl with the values of the specified instance.
+        *
+        * @since 2.1
+        */
+       _HttpHeaderImpl(const _HttpHeaderImpl* pHeaderImpl);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_HttpHeaderImpl(void);
+
+       /**
+        * @see                 HttpHeader::AddField()
+        */
+       result AddField(const Tizen::Base::String& fieldName, const Tizen::Base::String& fieldValue);
+
+       /**
+        * @see                 HttpHeader::RemoveField()
+        */
+       result RemoveField(const Tizen::Base::String& fieldName);
+
+       /**
+        * @see                 HttpHeader::RemoveField()
+        */
+       result RemoveField(const Tizen::Base::String& fieldName, const Tizen::Base::String& fieldValue);
+
+       /**
+        * @see                 HttpHeader::RemoveAll()
+        */
+       void RemoveAll(void);
+
+       /**
+        * @see                 HttpHeader::GetRawHeaderN()
+        */
+       Tizen::Base::String* GetRawHeaderN(void) const;
+
+       /**
+        * @see                 HttpHeader::GetFieldNamesN()
+        */
+       Tizen::Base::Collection::IList* GetFieldNamesN(void) const;
+
+       /**
+        * @see                 HttpHeader::GetFieldValuesN()
+        */
+       Tizen::Base::Collection::IEnumerator* GetFieldValuesN(const Tizen::Base::String& fieldName) const;
+
+public:
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpHeaderImpl
+        * @param[in]   pHttpHeader            An instance of HttpHeader
+        */
+       static _HttpHeaderImpl* GetInstance(HttpHeader& httpHeader);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpHeaderImpl
+        * @param[in]   pHttpHeader            An instance of HttpHeader
+        */
+       static const _HttpHeaderImpl* GetInstance(const HttpHeader& httpHeader);
+
+public:
+       bool CheckChunkedMode(void) const;
+
+       bool HasHeader(const Tizen::Base::String& fieldName, Tizen::Base::String& outFiledName) const;
+
+       bool GetHeaderValue(const Tizen::Base::String& fieldName, Tizen::Base::String& outFieldValue) const;
+
+       struct curl_slist* MakeCurlHeaderList(void);
+
+       result GetRealm(const Tizen::Base::String& authName, Tizen::Base::String& outRealm) const;
+
+       result SetHeader(const _HttpHeaderImpl& headerImpl);
+
+private:
+       _HttpHeaderImpl(const _HttpHeaderImpl& rhs);
+
+       _HttpHeaderImpl& operator =(const _HttpHeaderImpl& rhs);
+
+private:
+       Tizen::Base::Collection::MultiHashMap* __pHeaderMap;
+       _HttpStringComparer* __pComparer;
+       _HttpMultiHashMapProvider* __pHashProvider;
+
+}; // _HttpHeaderImpl
+
+} } } //Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_HEADER_IMPL_H_
diff --git a/src/inc/FNetHttp_HttpMultipartEntityImpl.h b/src/inc/FNetHttp_HttpMultipartEntityImpl.h
new file mode 100644 (file)
index 0000000..6197511
--- /dev/null
@@ -0,0 +1,182 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpMultipartEntityImpl.h
+ * @brief              This is the header file for the %_HttpMultipartEntityImpl class.
+ *
+ * This header file contains the declarations of the %_HttpMultipartEntityImpl class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_MULTIPART_ENTITY_IMPL_H_
+#define _FNET_HTTP_INTERNAL_HTTP_MULTIPART_ENTITY_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FOspConfig.h>
+#include <FNetHttpHttpTypes.h>
+#include <FNetHttpIHttpEntity.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+} }
+
+namespace Tizen { namespace Text
+{
+class Encoding;
+} }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpMultipartEntity;
+/**
+ * @class      _HttpMultipartEntityImpl
+ * @brief      This class represents a multipart/form-data entity as defined in RFC 2388.
+ *
+ * @since 2.1
+ */
+
+class _OSP_EXPORT_ _HttpMultipartEntityImpl
+       : public Tizen::Base::Object
+       , public IHttpEntity
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       _HttpMultipartEntityImpl(void);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_HttpMultipartEntityImpl(void);
+
+       /**
+        * @see                 HttpMultipartEntity::Construct()
+        */
+       result Construct(void);
+
+       /**
+        * @see                 HttpMultipartEntity::Construct()
+        */
+       result Construct(const Tizen::Base::String& boundary);
+
+       /**
+        * @see                 HttpMultipartEntity::GetContentLength()
+        */
+       virtual long long GetContentLength(void) const;
+
+       /**
+        * @see                 HttpMultipartEntity::GetContentType()
+        */
+       virtual Tizen::Base::String GetContentType(void) const;
+
+       /**
+        * @see                 HttpMultipartEntity::AddStringPart()
+        */
+       result AddStringPart(const Tizen::Base::String& name, const Tizen::Base::String& text);
+
+       /**
+        * @see                 HttpMultipartEntity::AddStringPart()
+        */
+       result AddStringPart(const Tizen::Base::String& name, const Tizen::Base::String& text, const Tizen::Base::String& mimeType, const Tizen::Base::String& charset, const Tizen::Text::Encoding& encoding);
+
+       /**
+        * @see                 HttpMultipartEntity::AddFilePart()
+        */
+       result AddFilePart(const Tizen::Base::String& name, const Tizen::Base::String& filePath);
+
+       /**
+        * @see                 HttpMultipartEntity::AddFilePart()
+        */
+       result AddFilePart(const Tizen::Base::String& name, const Tizen::Base::String& filePath, const Tizen::Base::String& fileName, const Tizen::Base::String& mimeType, const Tizen::Base::String& charset);
+
+       /**
+        * @see                 HttpMultipartEntity::AddFilePartByBuffer()
+        */
+       result AddFilePartByBuffer(const Tizen::Base::String& name, const Tizen::Base::String& fileName, const Tizen::Base::ByteBuffer& buffer);
+
+       /**
+        * @see                 HttpMultipartEntity::AddFilePartByBuffer()
+        */
+       result AddFilePartByBuffer(const Tizen::Base::String& name, const Tizen::Base::String& fileName, const Tizen::Base::ByteBuffer& buffer, const Tizen::Base::String& mimeType, const Tizen::Base::String& charset);
+
+public:
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpMultipartEntityImpl
+        * @param[in]   pHttpMultipartEntity            An instance of HttpMultipartEntity
+        */
+       static _HttpMultipartEntityImpl* GetInstance(HttpMultipartEntity& httpMultipartEntity);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpMultipartEntityImpl
+        * @param[in]   pHttpMultipartEntity            An instance of HttpMultipartEntity
+        */
+       static const _HttpMultipartEntityImpl* GetInstance(const HttpMultipartEntity& httpMultipartEntity);
+
+public:
+       Tizen::Base::Collection::IList* GetStringPartList(void) const;
+
+       Tizen::Base::Collection::IList* GetFilePartList(void) const;
+
+       Tizen::Base::String GetBoundary(void) const;
+
+
+protected:
+       /**
+        * @see                 HttpMultipartEntity::HasNextData()
+        */
+       virtual bool HasNextData(void);
+
+       /**
+        * @see                 HttpMultipartEntity::GetNextDataN()
+        */
+       virtual Tizen::Base::ByteBuffer* GetNextDataN(int recommendedSize);
+
+private:
+       _HttpMultipartEntityImpl(const _HttpMultipartEntityImpl& rhs);
+
+       _HttpMultipartEntityImpl& operator =(const _HttpMultipartEntityImpl& rhs);
+
+       Tizen::Base::String GenerateBoundary(void) const;
+
+private:
+       Tizen::Base::String __boundary;
+       Tizen::Base::Collection::IList* __pStringPartList;
+       Tizen::Base::Collection::IList* __pFilePartList;
+
+       class _HttpMultipartConverter* __pHttpMultipartConverter;
+
+       friend class HttpMultipartEntity;
+
+}; // _HttpMultipartEntityImpl
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_MULTIPART_ENTITY_IMPL_H_
diff --git a/src/inc/FNetHttp_HttpRequestImpl.h b/src/inc/FNetHttp_HttpRequestImpl.h
new file mode 100644 (file)
index 0000000..bbad4e7
--- /dev/null
@@ -0,0 +1,232 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpRequestImpl.h
+ * @brief              This is the header file for the %_HttpRequestImpl class.
+ *
+ * This header file contains the declarations of the %_HttpRequestImpl class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_REQUEST_IMPL_H_
+#define _FNET_HTTP_INTERNAL_HTTP_REQUEST_IMPL_H_
+
+#include <FOspConfig.h>
+#include <FNetHttpHttpTypes.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+class String;
+} }
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class IHttpEntity;
+class HttpHeader;
+class HttpRequest;
+class HttpTransaction;
+class _HttpTransactionImpl;
+/**
+ * @class      _HttpRequestImpl
+ * @brief      This class represents a request message.
+ *
+ * @since 2.1
+ */
+
+class _OSP_EXPORT_ _HttpRequestImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * @see                 HttpRequest::Setmethod()
+        */
+       result SetMethod(NetHttpMethod method);
+
+       /**
+        * @see                 HttpRequest::SetCustomMethod()
+        */
+       result SetCustomMethod(const Tizen::Base::String& method);
+
+       /**
+        * @see                 HttpRequest::SetVersion()
+        */
+       result SetVersion(HttpVersion version);
+
+       /**
+        * @see                 HttpRequest::SetUri()
+        */
+       result SetUri(const Tizen::Base::String& uri);
+
+       /**
+        * @see                 HttpRequest::WriteBody()
+        */
+       virtual result WriteBody(const Tizen::Base::ByteBuffer& body);
+
+       /**
+        * @see                 HttpRequest::SetEntity()
+        */
+       result SetEntity(IHttpEntity& entity);
+
+       /**
+        * @see                 HttpRequest::GetHeader()
+        */
+       virtual HttpHeader* GetHeader(void) const;
+
+       /**
+        * @see                 HttpRequest::SetCookie()
+        */
+       result SetCookie(const Tizen::Base::String& cookieString);
+
+       /**
+        * @see                 HttpRequest::GetCookie()
+        */
+       Tizen::Base::String GetCookie(void) const;
+
+       /**
+        * @see                 HttpRequest::GetMethod()
+        */
+       NetHttpMethod GetMethod(void) const;
+
+       /**
+        * @see                 GetCustomMethod()
+        */
+       result GetCustomMethod(Tizen::Base::String& method) const;
+
+       /**
+        * @see                 GetVersion()
+        */
+       HttpVersion GetVersion(void) const;
+
+       /**
+        * @see                 HttpRequest::GetUri()
+        */
+       result GetUri(Tizen::Base::String& uri) const;
+
+       /**
+        * @see                 HttpRequest::ReadBodyN()
+        */
+       virtual Tizen::Base::ByteBuffer* ReadBodyN(void);
+
+       /**
+        * @see                 HttpRequest::SetAcceptEncoding()
+        */
+       result SetAcceptEncoding(const Tizen::Base::String& encoding);
+
+       /**
+        * @see                 HttpRequest::GetAcceptEncoding()
+        */
+       Tizen::Base::String GetAcceptEncoding(void) const;
+
+public:
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpRequestImpl
+        * @param[in]   pHttpRequest            An instance of HttpRequest
+        */
+       static _HttpRequestImpl* GetInstance(HttpRequest& httpRequest);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpRequestImpl
+        * @param[in]   pHttpRequest            An instance of HttpRequest
+        */
+       static const _HttpRequestImpl* GetInstance(const HttpRequest& httpRequest);
+
+public:
+       _HttpRequestImpl(HttpRequest* pRequest);
+
+       virtual ~_HttpRequestImpl(void);
+
+       result Construct(const _HttpTransactionImpl& httpTransactionImpl, const HttpHeader* pCommonHeader);
+
+public:
+       static HttpRequest* CreateHttpRequestN(void);
+
+       static void DeleteHttpRequest(HttpRequest* pHttpRequest);
+
+       bool IsEmptyBody(void) const;
+
+       unsigned int GetTotalBodyLength(void) const;
+
+       void SetRecommendedSize(int recommendedSize);
+
+       void SetReceivedTransactionReadyToWriteEvent(bool isReceviedEvent);
+
+       void SetFirstChunkBody(bool isFirstChunk);
+
+       bool IsFirstChunkBody(void) const;
+
+       bool IsLastChunkBody(void) const;
+
+       bool HasCookie(void) const;
+
+       void SetSendingBuffer(Tizen::Base::ByteBuffer* pBuffer);
+
+       Tizen::Base::ByteBuffer* GetSendingBuffer(void) const;
+
+       Tizen::Base::String GetMethodName(void) const;
+
+       Tizen::Base::ByteBuffer* ReadAllBodyN(void) const;
+
+       IHttpEntity* GetEntity(void) const;
+
+       bool HasNextData(void);
+
+       Tizen::Base::ByteBuffer* GetNextDataN(int recommendedSize);
+
+private:
+       _HttpRequestImpl(void);
+
+       _HttpRequestImpl(const _HttpRequestImpl& rhs);
+
+       _HttpRequestImpl& operator =(const _HttpRequestImpl& rhs);
+
+private:
+       NetHttpMethod __method;
+       Tizen::Base::String __customMethodName;
+       Tizen::Base::String __methodName;
+       HttpVersion __httpVersion;
+       Tizen::Base::String __uri;
+       Tizen::Base::String __cookieValue;
+       NetHttpCookieFlag __cookieFlag;
+       Tizen::Base::String __encoding;
+       int __recommendedSize;
+       bool __isFirstChunk;
+       bool __isLastChunk;
+       bool __isReceivedTransactionReadyToWriteEvent;
+       IHttpEntity* __pIHttpEntity;
+       Tizen::Base::ByteBuffer* __pSendingBuffer;
+       _HttpTransactionImpl* __pHttpTransactionImpl;
+       HttpRequest* __pHttpRequest; //To access member variables of the HttpRequest(HttpMessage).
+
+       friend class HttpRequest;
+
+}; // _HttpRequestImpl
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_REQUEST_IMPL_H_
diff --git a/src/inc/FNetHttp_HttpResponseImpl.h b/src/inc/FNetHttp_HttpResponseImpl.h
new file mode 100644 (file)
index 0000000..db5b1fb
--- /dev/null
@@ -0,0 +1,217 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpResponseImpl.h
+ * @brief              This is the header file for the %_HttpResponseImpl class.
+ *
+ * This header file contains the declarations of the %_HttpResponseImpl class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_RESPONSE_IMPL_H_
+#define _FNET_HTTP_INTERNAL_HTTP_RESPONSE_IMPL_H_
+
+#include <FOspConfig.h>
+#include <FNetHttpHttpTypes.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+class String;
+} }
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpHeader;
+class HttpResponse;
+class _HttpTransactionImpl;
+/**
+ * @class      _HttpResponseImpl
+ * @brief      This class represents a response message.
+ *
+ * @since 2.1
+ */
+
+class _OSP_EXPORT_ _HttpResponseImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * @see                 HttpResponse::GetStatusCode()
+        */
+       NetHttpStatusCode GetStatusCode(void) const;
+
+       /**
+        * @see                 HttpResponse::GetHttpStatusCode()
+        */
+       int GetHttpStatusCode(void) const;
+
+       /**
+        * @see                 HttpResponse::GetStatusText()
+        */
+       Tizen::Base::String GetStatusText(void) const;
+
+       /**
+        * @see                 HttpResponse::GetVersion()
+        */
+       Tizen::Base::String GetVersion(void) const;
+
+       /**
+        * @see                 HttpResponse::GetHeader()
+        */
+       virtual HttpHeader* GetHeader(void) const;
+
+       /**
+        * @see                 HttpResponse::ReadBodyN()
+        */
+       virtual Tizen::Base::ByteBuffer* ReadBodyN(void);
+
+       /**
+        * @see                 HttpResponse::GetCookies()
+        */
+       Tizen::Base::Collection::IList* GetCookies(void) const;
+
+       /**
+        * @see                 HttpResponse::SetStatusCode()
+        */
+       result SetStatusCode(NetHttpStatusCode statusCode);
+
+       /**
+        * @see                 HttpResponse::SetHttpStatusCode()
+        */
+       result SetHttpStatusCode(int statusCode);
+
+       /**
+        * @see                 HttpResponse::SetStatusText()
+        */
+       result SetStatusText(const Tizen::Base::String& statusText);
+
+       /**
+        * @see                 HttpResponse::SetVersion()
+        */
+       result SetVersion(const Tizen::Base::String& httpVersion);
+
+       /**
+        * @see                 HttpResponse::WriteBody()
+        */
+       virtual result WriteBody(const Tizen::Base::ByteBuffer& body);
+
+       /**
+        * @see                 HttpResponse::Read()
+        */
+       result Read(int headerLen, int bodyLen, int& rcvHeaderLen, int& rcvBodyLen);
+
+       /**
+        * @see                 HttpResponse::SetCookie()
+        */
+       result SetCookie(Tizen::Net::Http::HttpHeader* pHeader);
+
+public:
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpResponseImpl
+        * @param[in]   pHttpResponse            An instance of HttpResponse
+        */
+       static _HttpResponseImpl* GetInstance(HttpResponse& httpResponse);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpResponseImpl
+        * @param[in]   pHttpResponse            An instance of HttpResponse
+        */
+       static const _HttpResponseImpl* GetInstance(const HttpResponse& httpResponse);
+
+public:
+       _HttpResponseImpl(HttpResponse* pResponse);
+
+       virtual ~_HttpResponseImpl(void);
+
+       result Construct(const _HttpTransactionImpl& httpTransactinImpl);
+
+public:
+       static HttpResponse* CreateHttpResponseN(void);
+
+       static void DeleteHttpResponse(HttpResponse* pHttpResponse);
+
+       int GetHeaderLength(void) const;
+
+       result ParseHeader(int& recevHeaderLen);
+
+       Tizen::Base::Collection::IList* GetCookiesListN(void);
+
+       result AddRawHeader(const byte* pHeaderLine, int headerLineSize, bool isTerminatedHeader);
+
+       result AddRawBody(const byte* pBody, int bodySize, bool& isFullBuffer, int& readBodySize);
+
+       result AddLastBody(int& readBodySize);
+
+       void SetCurrentBodyLength(int readBodyLength);
+
+       int GetCurrentBodyLength(void) const;
+
+       void SetTotalBodyLength(int totalBodyLength);
+
+       int GetTotalBodyLength(void) const;
+
+       void SetReceivedBody(bool flag);
+
+       bool IsHeaderReceived(void) const;
+
+       bool IsBodyReceived(void) const;
+
+       bool IsCurrentBodyReceived(void) const;
+
+private:
+       _HttpResponseImpl(void);
+
+       _HttpResponseImpl(const _HttpResponseImpl& rhs);
+
+       _HttpResponseImpl& operator =(const _HttpResponseImpl& rhs);
+
+private:
+       bool __isReceivedHeader;
+       bool __isReceivedBody;
+       int __statusCode;
+       NetHttpStatusCode __statusCodeType;
+       Tizen::Base::String __statusText;
+       Tizen::Base::String __version;
+       int __readHeaderLength;
+       Tizen::Base::ByteBuffer* __pReadHeaderBuffer;
+       int __readBodyLength;
+       int __totalBodyLength;
+       bool __isCurrentReceivedBody;
+       Tizen::Base::ByteBuffer* __pReadBodyBuffuer;
+       Tizen::Base::Collection::IList* __pCookieList;
+       _HttpTransactionImpl* __pHttpTransactionImpl;
+       HttpResponse* __pHttpResponse;
+
+       friend class HttpResponse;
+
+}; // _HttpResponseImpl
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_RESPONSE_IMPL_H_
diff --git a/src/inc/FNetHttp_HttpSessionImpl.h b/src/inc/FNetHttp_HttpSessionImpl.h
new file mode 100644 (file)
index 0000000..ffef26b
--- /dev/null
@@ -0,0 +1,245 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpSessionImpl.h
+ * @brief              This is the header file for the %_HttpSessionImpl class.
+ *
+ * This header file contains the declarations of the %_HttpSessionImpl class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_SESSION_IMPL_H_
+#define _FNET_HTTP_INTERNAL_HTTP_SESSION_IMPL_H_
+
+#include <curl.h>
+#include <glib.h>
+#include <FOspConfig.h>
+#include <FNetHttpHttpTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+} }
+
+namespace Tizen { namespace Net
+{
+class ManagedNetConnection;
+class NetConnection;
+class _NetConnectionImpl;
+} }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpSession;
+class HttpTransaction;
+class HttpHeader;
+class HttpAuthentication;
+class HttpCookieStorageManager;
+class _HttpNetConnectionEventListenerImpl;
+class _HttpManagedNetConnectionEventListenerImpl;
+class _HttpHeaderImpl;
+class _HttpMultipleConnectionInfo;
+/**
+ * @class      _HttpSessionImpl
+ * @brief      This class represents an HTTP session.
+ *
+ * @since 2.1
+ */
+
+class _OSP_EXPORT_ _HttpSessionImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, one of the Construct() methods must be called explicitly to initialize the instance.
+        * @see                 Construct()
+        */
+       _HttpSessionImpl(HttpSession* pHttpSession);
+
+       /**
+        * @see                 HttpSession::Construct()
+        */
+       result Construct(NetHttpSessionMode sessionMode, const Tizen::Base::String* pProxyAddr, const Tizen::Base::String& hostAddr, const HttpHeader* pCommonHeader, NetHttpCookieFlag flag = NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL);
+
+       /**
+        * @see                 HttpSession::Construct()
+        */
+       result Construct(const NetConnection& netConnection, NetHttpSessionMode sessionMode, const Tizen::Base::String* pProxyAddr, const Tizen::Base::String& hostAddr, const HttpHeader* pCommonHeader, NetHttpCookieFlag flag = NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_HttpSessionImpl(void);
+
+       /**
+        * @see                 HttpSession::OpenTransactionN()
+        */
+       HttpTransaction* OpenTransactionN(void);
+
+       /**
+       * @see                          HttpSession::OpenTransactionN()
+       */
+       HttpTransaction* OpenTransactionN(const HttpAuthentication& auth);
+
+       /**
+        * @see                 HttpSession::CancelTransaction()
+        */
+       result CancelTransaction(HttpTransaction& httpTransaction);
+
+       /**
+       * @see                          HttpSession::CloseTransaction()
+       */
+       result CloseTransaction(HttpTransaction& httpTransaction);
+
+       /**
+       * @see                          HttpSession::CloseAllTransactions()
+       */
+       result CloseAllTransactions(void);
+
+       /**
+       * @see                          HttpSession::SetAutoRedirectionEnabled()
+       */
+       result SetAutoRedirectionEnabled(bool enable);
+
+       /**
+       * @see                          HttpSession::IsAutoRedirectionEnabled()
+       */
+       bool IsAutoRedirectionEnabled(void) const;
+
+       /**
+       * @see                  HttpSession::GetActiveTransactionCount()
+       */
+       int GetActiveTransactionCount(void) const;
+
+       /**
+       * @see                  HttpSession::GetMaxTransactionCount()
+       */
+       int GetMaxTransactionCount(void) const;
+
+       /**
+       * @see                  HttpSession::GetCookieStorageManager()
+       */
+       HttpCookieStorageManager* GetCookieStorageManager(void) const;
+
+public:
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpSessionImpl
+        * @param[in]   pHttpSession            An instance of HttpSession
+        */
+       static _HttpSessionImpl* GetInstance(HttpSession& httpSession);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpSessionImpl
+        * @param[in]   pHttpSession            An instance of HttpSession
+        */
+       static const _HttpSessionImpl* GetInstance(const HttpSession& httpSession);
+
+public:
+       NetHttpSessionMode GetSessionMode(void) const;
+
+       Tizen::Base::String GetHostAddress(void) const;
+
+       Tizen::Base::String* GetProxyAddress(void) const;
+
+       void SetProxyAddress(Tizen::Base::String* pProxyAddress);
+
+       Tizen::Base::String GetDeviceName(void) const;
+
+       void SetDeviceName(const Tizen::Base::String& deviceName);
+
+       bool IsSessionValid(void) const;
+
+       void SetSessionState(bool isValid);
+
+       NetHttpCookieFlag GetHttpCookieFlag(void) const;
+
+       HttpSession* GetHttpSession(void) const;
+
+       _HttpMultipleConnectionInfo* GetHttpMultipleConnectionInfo(void) const;
+
+       Tizen::Base::Collection::ArrayList* GetActiveTransactions(void);
+
+       bool IsConnectionStarted(void) const;
+
+       HttpTransaction* OpenTransactionWithCurlN(CURL* pCurl);
+
+       HttpTransaction* ReopenTransactionWithAuthN(HttpTransaction& httpTransaction);
+
+       result Disconnect(void); // HttpSession is disconnected when network problem is occurred.
+
+       void IgnoreSslVerification(void);
+
+       result Dispose(void);
+
+       result Close(void);
+
+       static int GenerateSessionId(void);
+
+       int GetSessionId(void) const;
+
+       static result InitializeSession(void);
+
+public:
+       _HttpSessionImpl(const _HttpSessionImpl& rhs);
+
+       _HttpSessionImpl& operator =(const _HttpSessionImpl& rhs);
+
+private:
+       static int __generatedSessionId;
+       int __sessionId;
+       static int __countOfSessions;   //The number of opened sessions in the application.
+
+       HttpSession* __pHttpSession;
+       bool __isConstructed;
+       NetHttpSessionMode __sessionMode;
+       Tizen::Base::String* __pProxyAddress;
+       Tizen::Base::String __hostAddress;
+       HttpHeader* __pCommonHeader;
+       NetHttpCookieFlag __cookieFlag;
+       Tizen::Base::Collection::ArrayList __activeTransactions;
+       int __countOfTransaction;
+       bool __isSecure;
+       bool __isValid;
+       bool __isClosed;
+       bool __isAutoRedirectionEnabled;
+       bool __isAlreadyResumed;
+       class _HttpMultipleConnectionInfo* __pHttpMultipleConnectionInfo;
+       HttpCookieStorageManager* __pCookieStorageMgr;
+       Tizen::Net::NetConnection* __pNetConnection;
+       _HttpNetConnectionEventListenerImpl* __pNetConnectionListener;
+       Tizen::Net::ManagedNetConnection* __pManagedNetConnection;
+       _HttpManagedNetConnectionEventListenerImpl* __pManagedNetConnectionListener;
+       Tizen::Base::String __deviceName;
+
+       friend class HttpSession;
+
+}; // _HttpSessionImpl
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_SESSION_IMPL_H_
diff --git a/src/inc/FNetHttp_HttpStringEntityImpl.h b/src/inc/FNetHttp_HttpStringEntityImpl.h
new file mode 100644 (file)
index 0000000..e222f92
--- /dev/null
@@ -0,0 +1,133 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpStringEntityImpl.h
+ * @brief              This is the header file for the %_HttpStringEntityImpl class.
+ *
+ * This header file contains the declarations of the %_HttpStringEntityImpl class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_STRING_ENTITY_IMPL_H_
+#define _FNET_HTTP_INTERNAL_HTTP_STRING_ENTITY_IMPL_H_
+
+#include <FOspConfig.h>
+#include <FNetHttpIHttpEntity.h>
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpStringEntity;
+/**
+ * @class      _HttpStringEntityImpl
+ * @brief      This class represents an implementation of %HttpStringEntity class.
+ *
+ * @since 2.1
+ *
+ * This class represents an implementation of %HttpStringEntity class.
+ *
+ * @see                HttpStringEntity
+ */
+
+class _OSP_EXPORT_ _HttpStringEntityImpl
+       : public Tizen::Base::Object
+       , public IHttpEntity
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, you must explicitly call the
+        *                              Construct() method to initialize the instance.
+        * @see                 Construct()
+        */
+       _HttpStringEntityImpl(void);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_HttpStringEntityImpl(void);
+
+       /**
+        * @see                 HttpStringEntity::Construct()
+        */
+       result Construct(const Tizen::Base::String& text);
+
+       /**
+        * @see                 HttpStringEntity::Construct()
+        */
+       result Construct(const Tizen::Base::String& text, const Tizen::Base::String& contentType, const Tizen::Base::String& charset, const Tizen::Text::Encoding& encoding);
+
+       /**
+        * @see                 HttpStringEntity::GetContentLength()
+        */
+       virtual long long GetContentLength(void) const;
+
+       /**
+        * @see                 HttpStringEntity::GetContentType()
+        */
+       virtual Tizen::Base::String GetContentType(void) const;
+
+public:
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpStringEntityImpl
+        * @param[in]   pHttpStringEntity            An instance of HttpStringEntity
+        */
+       static _HttpStringEntityImpl* GetInstance(HttpStringEntity& httpStringEntity);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpStringEntityImpl
+        * @param[in]   pHttpStringEntity            An instance of HttpStringEntity
+        */
+       static const _HttpStringEntityImpl* GetInstance(const HttpStringEntity& httpStringEntity);
+
+protected:
+       /**
+        * @see                 HttpStringEntity::HasNextData()
+        */
+       virtual bool HasNextData(void);
+
+       /**
+        * @see                 HttpStringEntity::GetNextDataN()
+        */
+       virtual Tizen::Base::ByteBuffer* GetNextDataN(int recommendedSize);
+
+private:
+       _HttpStringEntityImpl(const _HttpStringEntityImpl& rhs);
+
+       _HttpStringEntityImpl& operator =(const _HttpStringEntityImpl& rhs);
+
+private:
+       long long __contentLength;
+       Tizen::Base::String __contentType;
+       Tizen::Base::ByteBuffer* __pBuffer;
+
+       friend class HttpStringEntity;
+
+}; // _HttpStringEntityImpl
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_STRING_ENTITY_IMPL_H_
diff --git a/src/inc/FNetHttp_HttpTransactionImpl.h b/src/inc/FNetHttp_HttpTransactionImpl.h
new file mode 100644 (file)
index 0000000..f14efe9
--- /dev/null
@@ -0,0 +1,314 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpTransactionImpl.h
+ * @brief              This is the header file for the %_HttpTransactionImpl class.
+ *
+ * This header file contains the declarations of the %_HttpTransactionImpl class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_TRANSACTION_IMPL_H_
+#define _FNET_HTTP_INTERNAL_HTTP_TRANSACTION_IMPL_H_
+
+#include <sys/socket.h>
+#include <curl.h>
+#include <openssl/ssl.h>
+#include <glib.h>
+#include <FBaseColArrayListT.h>
+#include <FOspConfig.h>
+#include <FNetHttpHttpTypes.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+class String;
+} }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpHeader;
+class HttpRequest;
+class HttpResponse;
+class HttpTransaction;
+class HttpAuthentication;
+class IHttpTransactionEventListener;
+class IHttpProgressEventListener;
+class IHttpEntity;
+class _HttpSessionImpl;
+class _HttpResponseImpl;
+class _HttpAuthenticationImpl;
+class _HttpTransactionEvent;
+class _HttpMultipleConnectionInfo;
+class _HttpTransactionUserData;
+class _HttpCurl;
+/**
+ * @class      _HttpTransactionImpl
+ * @brief
+ *
+ * @since 2.1
+ */
+
+class _OSP_EXPORT_ _HttpTransactionImpl
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the destructor for this class.
+        *
+        * @since   1.0
+        */
+       virtual ~_HttpTransactionImpl(void);
+
+       /**
+        * @see                         HttpTransaction::Submit()
+        */
+       result Submit(void);
+
+       /**
+        * @see                         HttpTransaction::OpenAuthenticationInfoN()
+        */
+       HttpAuthentication* OpenAuthenticationInfoN(void);
+
+       /**
+        * @see                 HttpTransaction::GetRequest()
+        */
+       HttpRequest* GetRequest(void) const;
+
+       /**
+        * @see                 HttpTransaction::HttpResponse()
+        */
+       HttpResponse* GetResponse(void) const;
+
+       /**
+        * @see                 HttpTransaction::AddHttpTransactionListener()
+        */
+       result AddHttpTransactionListener(IHttpTransactionEventListener& listener);
+
+       /**
+        * @see                 HttpTransaction::RemoveHttpTransactionListener()
+        */
+       result RemoveHttpTransactionListener(IHttpTransactionEventListener& listener);
+
+       /**
+        * @see                 HttpTransaction::SetHttpProgressListener()
+        */
+       result SetHttpProgressListener(IHttpProgressEventListener& listener);
+
+       /**
+        * @see                 HttpTransaction::SetUserObject()
+        */
+       result SetUserObject(const Tizen::Base::Object* pUserData);
+
+       /**
+        * @see                 HttpTransaction::GetUserObject()
+        */
+       Tizen::Base::Object* GetUserObject(void) const;
+
+       /**
+        * @see                 HttpTransaction::EnableTransactionReadyToWrite()
+        */
+       bool EnableTransactionReadyToWrite(void);
+
+       /**
+        * @see                 HttpTransaction::Resume()
+        */
+       result Resume(void);
+
+       /**
+        * @see                 HttpTransaction::Pause()
+        */
+       result Pause(void);
+
+       /**
+        * @see                 HttpTransaction::SetClientCertificate()
+        */
+       result SetClientCertificate(int certificateId);
+
+       /**
+        *      Set the timeout in seconds that is the timeout for waiting the transaction.
+        *      A timeout value of zero means an infinite timeout.
+        *
+        *  @since 2.1
+        *       @return                An error code
+        *  @param[in]  timeout                                         A timeout for transaction
+        *       @exception     E_SUCCESS                               The method is successful.
+        *  @exception  E_INVALID_ARG           The specified input parameter is invalid.
+        *  @exception  E_INVALID_STATE         The transaction is already submitted. @n
+        *                                                      The transaction is already closed.
+        */
+       result SetTimeout(int timeout);
+
+public:
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpTransactionImpl
+        * @param[in]   pHttpTransaction            An instance of HttpTransaction
+        */
+       static _HttpTransactionImpl* GetInstance(HttpTransaction& httpTransaction);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpTransactionImpl
+        * @param[in]   pHttpTransaction            An instance of HttpTransaction
+        */
+       static const _HttpTransactionImpl* GetInstance(const HttpTransaction& httpTransaction);
+
+public:
+       _HttpSessionImpl* GetHttpSessioinImpl(void) const;
+
+       HttpTransaction* GetHttpTransaction(void) const;
+
+       _HttpTransactionEvent* GetHttpTransactionEvent(void) const;
+
+       NetHttpAuthScheme GetHttpAuthType(void) const;
+
+       void SetHttpAuthType(NetHttpAuthScheme authType);
+
+       _HttpAuthenticationImpl* GetHttpAuthenticationImpl(void) const;
+
+       void SetHttpAuthenticationImpl(const _HttpAuthenticationImpl* pAuthenticationImpl);
+
+       Tizen::Base::ByteBuffer* GetRequestBuffer(void);
+
+       Tizen::Base::Collection::ArrayListT< IHttpTransactionEventListener* >* GetEventListenerList(void);
+
+       _HttpTransactionUserData* GetHttpTransactionUserData(void) const;
+
+       _HttpCurl* GetHttpCurl(void) const;
+
+       static Tizen::Base::String GetDefaultUserAgent(void);
+
+       const IHttpProgressEventListener* GetHttpProgressEventListener(void) const;
+
+       _HttpResponseImpl* GetHttpResponseImpl(void) const;
+
+       bool IsTransactionReadyToWriteEanbled(void) const;
+
+       bool IsClosed(void) const;
+
+       bool IsCanceled(void) const;
+
+       void SetTransactionCanceled(bool isCanceled);
+
+       bool IsSubmitted(void) const;
+
+       bool IsPendingTransaction(void) const;
+
+       bool IsHeaderEventFired(void) const;
+
+       void SetCertRequiredEventFired(bool isFired);
+
+       bool IsAlreadyResumed(void) const;
+
+       result SubmitPendingTransaction(const Tizen::Base::String& deviceName, const Tizen::Base::String& proxyAddress);
+
+       void IgnoreSslVerification(void);
+
+       void SetTimer(void);
+
+       result Dispose(void);
+
+       result Close(void);
+
+       result Abort(void);
+
+       static int GenerateTransactionId(void);
+
+       int GetTransactionId(void) const;
+
+public:
+       _HttpTransactionImpl(HttpTransaction* pHttpTransaction);
+
+       static HttpTransaction* CreateHttpTransactionN(void);
+
+       static void DeleteHttpTransaction(HttpTransaction* pHttpTransaction);
+
+       result Construct(_HttpSessionImpl& httpSessionImpl, HttpHeader* pCommonHeader, CURL* pCurl);
+
+public:
+       //by event
+       static gboolean OnSocketReceivedEvent(GIOChannel* pSource, GIOCondition condition, gpointer pUserData);
+
+       static gboolean OnHttpTransactionTimerExpiredEvent(gpointer data);
+
+       //by callback
+       static curl_socket_t OnSocketOpened(int* data, curlsocktype purpose, struct curl_sockaddr* addr);
+
+       static size_t OnHttpHeaderReceived(void* pHeaderMsg, size_t size, size_t nmemb, void* pUserData);
+
+       static size_t OnHttpBodyReceived(void* pBodyMsg, size_t size, size_t nmemb, void* pUserData);
+
+       static size_t OnHttpProgress(void* pUserData, double totalDownloadSize, double currentDownloadedSize, double totalUploadSize, double currentUploadedSize);
+
+       static size_t OnHttpDebugReceived(CURL* pCurl, curl_infotype type, char* pChar, size_t size, void* pUserData);
+
+       static size_t OnHttpBodyReadyToWrite(void* pBodyMsg, size_t size, size_t nmemb, void* pUserData);
+
+       static CURLcode OnHttpSslHandshake(CURL* pCurl, SSL_CTX* pSslctx, void* pUserData);
+
+       static int OnHttpSslVerify(int preverify_ok, X509_STORE_CTX* pX509ctx);
+
+private:
+       _HttpTransactionImpl(const _HttpTransactionImpl& rhs);
+
+       _HttpTransactionImpl& operator =(const _HttpTransactionImpl& rhs);
+
+private:
+       static int __generatedTransactionId;
+       int __transactionId;
+       int __sessionId;
+       _HttpSessionImpl* __pHttpSessionImpl;
+       _HttpMultipleConnectionInfo* __pHttpMultipleConnectionInfo;
+       HttpTransaction* __pHttpTransaction;
+       HttpRequest* __pHttpRequest;
+       HttpResponse* __pHttpResponse;
+       _HttpTransactionEvent* __pHttpTransactionEvent;
+       NetHttpAuthScheme __authType;
+       _HttpAuthenticationImpl* __pHttpAuthenticationImpl;
+       Tizen::Base::ByteBuffer* __pRequestBuffer;
+       const Tizen::Base::Object* __pUserData;
+       bool __isClosed;
+       bool __isCanceled;
+       bool __isSubmitted;
+       bool __isPendingTransaction;
+       bool __enableTransactionReadyToWrite;
+       bool __isHeaderEventFired;
+       long long __uploadCurrentProgress;
+       long long __donwloadCurrentProgress;
+       int __timeout;
+       int __certificateId;
+       bool __isAlreadyResumed;
+       bool __isAlreadyPaused;
+       bool __isCertRequiredEventFired;
+       Tizen::Base::Collection::ArrayListT< IHttpTransactionEventListener* > __transactionListenerList;
+       const IHttpProgressEventListener* __pHttpProgressListener;
+       _HttpTransactionUserData* __pHttpTransactionUserData;
+       _HttpCurl* __pHttpCurl;
+       GSource* __pTimerSource;
+
+       friend class HttpTransaction;
+
+}; //_HttpTransactionImpl
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_TRANSACTION_IMPL_H_
diff --git a/src/inc/FNetHttp_HttpUrlEncodedEntityImpl.h b/src/inc/FNetHttp_HttpUrlEncodedEntityImpl.h
new file mode 100644 (file)
index 0000000..d642d44
--- /dev/null
@@ -0,0 +1,156 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpUrlEncodedEntityImpl.h
+ * @brief              This is the header file for the %_HttpUrlEncodedEntityImpl class.
+ *
+ * This header file contains the declarations of the %_HttpUrlEncodedEntityImpl class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_URL_ENCODED_ENTITY_IMPL_H_
+#define _FNET_HTTP_INTERNAL_HTTP_URL_ENCODED_ENTITY_IMPL_H_
+
+#include <FTextLatin1Encoding.h>
+#include <FOspConfig.h>
+#include <FNetHttpIHttpEntity.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+class String;
+} }
+
+namespace Tizen { namespace Text
+{
+class Latin1Encoding;
+} }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpHttpUrlEncodedEntity;
+/**
+ * @class      _HttpUrlEncodedEntityImpl
+ * @brief      This class represents an implementation of %HttpUrlEncodedEntity class.
+ *
+ * @since 2.1
+ *
+ * This class represents an implementation of %HttpUrlEncodedEntity class.
+ *
+ * @see                HttpUrlEncodedEntity
+ */
+
+class _OSP_EXPORT_ _HttpUrlEncodedEntityImpl
+       : public Tizen::Base::Object
+       , public IHttpEntity
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, you must explicitly call the
+        *                              Construct() method to initialize the instance.
+        * @see                 Construct()
+        */
+       _HttpUrlEncodedEntityImpl(void);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_HttpUrlEncodedEntityImpl(void);
+
+       /**
+        * @see                 HttpUrlEncodedEntity::Construct()
+        */
+       result Construct(void);
+
+       /**
+        * @see                 HttpUrlEncodedEntity::Construct()
+        */
+       result Construct(const Tizen::Base::String& charset, const Tizen::Text::Encoding& encoding);
+
+       /**
+        * @see                 HttpUrlEncodedEntity::GetContentLength()
+        */
+       virtual long long GetContentLength(void) const;
+
+       /**
+        * @see                 HttpUrlEncodedEntity::GetContentType()
+        */
+       virtual Tizen::Base::String GetContentType(void) const;
+
+       /**
+        * @see                 HttpUrlEncodedEntity::AddParameter()
+        */
+       result AddParameter(const Tizen::Base::String& name, const Tizen::Base::String& value);
+
+public:
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpUrlEncodedEntityImpl
+        * @param[in]   pHttpUrlEncodedEntity            An instance of HttpUrlEncodedEntity
+        */
+       static _HttpUrlEncodedEntityImpl* GetInstance(HttpUrlEncodedEntity& httpUrlEncodedEntity);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpUrlEncodedEntityImpl
+        * @param[in]   pHttpUrlEncodedEntity            An instance of HttpUrlEncodedEntity
+        */
+       static const _HttpUrlEncodedEntityImpl* GetInstance(const HttpUrlEncodedEntity& httpUrlEncodedEntity);
+
+protected:
+       /**
+        * @see                 HttpUrlEncodedEntity::HasNextData()
+        */
+       virtual bool HasNextData(void);
+
+       /**
+        * @see                 HttpUrlEncodedEntity::GetNextDataN()
+        */
+       virtual Tizen::Base::ByteBuffer* GetNextDataN(int recommendedSize);
+
+private:
+       _HttpUrlEncodedEntityImpl(const _HttpUrlEncodedEntityImpl& rhs);
+
+       _HttpUrlEncodedEntityImpl& operator =(const _HttpUrlEncodedEntityImpl& rhs);
+
+private:
+       result Encode(void) const;
+
+private:
+       Tizen::Text::Latin1Encoding __defaultEncoding;
+       Tizen::Base::String __contentType;
+       Tizen::Base::String __charset;
+       Tizen::Text::Encoding* __pEncoding;
+       long long __contentLength;
+       Tizen::Base::ByteBuffer* __pBuffer;
+
+       friend class HttpUrlEncodedEntity;
+
+}; // HttpHttpUrlEncodedEntity
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_URL_ENCODED_ENTITY_IMPL_H_
diff --git a/src/inc/FNetHttp_HttpXmlDomEntityImpl.h b/src/inc/FNetHttp_HttpXmlDomEntityImpl.h
new file mode 100644 (file)
index 0000000..9c2817b
--- /dev/null
@@ -0,0 +1,145 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetHttp_HttpXmlDomEntityImpl.h
+ * @brief              This is the header file for the %_HttpXmlDomEntityImpl class.
+ *
+ * This header file contains the declarations of the %_HttpXmlDomEntityImpl class.
+ */
+
+#ifndef _FNET_HTTP_INTERNAL_HTTP_XML_DOM_ENTITY_IMPL_H_
+#define _FNET_HTTP_INTERNAL_HTTP_XML_DOM_ENTITY_IMPL_H_
+
+#include <libxml/tree.h>
+
+#include <FOspConfig.h>
+#include <FNetHttpIHttpEntity.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+class String;
+} }
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpXmlDomEntity;
+/**
+ * @class      _HttpXmlDomEntityImpl
+ * @brief      This class represents an implementation of %HttpXmlDomEntity class.
+ *
+ * @since 2.1
+ *
+ * This class represents an implementation of %HttpXmlDomEntity class.
+ *
+ * @see                HttpXmlDomEntity
+ */
+
+class _OSP_EXPORT_ _HttpXmlDomEntityImpl
+       : public Tizen::Base::Object
+       , public IHttpEntity
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, you must explicitly call the
+        *                              Construct() method to initialize the instance.
+        * @see                 Construct()
+        */
+       _HttpXmlDomEntityImpl(void);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_HttpXmlDomEntityImpl(void);
+
+       /**
+        * @see                 HttpXmlDomEntity::Construct()
+        */
+       result Construct(const xmlDoc& xmlDocument, const Tizen::Base::String& encodingScheme = L"UTF-8");
+
+       /**
+        * @see                 HttpXmlDomEntity::GetContentLength()
+        */
+       virtual long long GetContentLength(void) const;
+
+       /**
+        * @see                 HttpXmlDomEntity::GetContentType()
+        */
+       virtual Tizen::Base::String GetContentType(void) const;
+
+public:
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpXmlDomEntityImpl
+        * @param[in]   pHttpXmlDomEntity            An instance of HttpXmlDomEntity
+        */
+       static _HttpXmlDomEntityImpl* GetInstance(HttpXmlDomEntity& httpXmlDomEntity);
+
+       /**
+        * Gets the Impl instance.
+        *
+        * @since 2.1
+        * @return                      The pointer to _HttpXmlDomEntityImpl
+        * @param[in]   pHttpXmlDomEntity            An instance of HttpXmlDomEntity
+        */
+       static const _HttpXmlDomEntityImpl* GetInstance(const HttpXmlDomEntity& httpXmlDomEntity);
+
+protected:
+       /**
+        * @see                 HttpXmlDomEntity::HasNextData()
+        */
+       virtual bool HasNextData(void);
+
+       /**
+        * @see                 HttpXmlDomEntity::GetNextDataN()
+        */
+       virtual Tizen::Base::ByteBuffer* GetNextDataN(int recommendedSize);
+
+private:
+       /**
+        * This is the copy constructor for this class.
+        *
+        * @param[in]   value                   An instance of _HttpXmlDomEntityImpl
+        */
+       _HttpXmlDomEntityImpl(const _HttpXmlDomEntityImpl& value);
+
+       /**
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                             An instance of _HttpXmlDomEntityImpl
+        */
+       _HttpXmlDomEntityImpl& operator =(const _HttpXmlDomEntityImpl& rhs);
+
+private:
+       long long __contentLength;
+       Tizen::Base::ByteBuffer* __pBuffer;
+
+       friend class HttpXmlDomEntity;
+
+}; // _HttpXmlDomEntityImpl
+
+} } } // Tizen::Net::Http
+#endif // _FNET_HTTP_INTERNAL_HTTP_XML_DOM_ENTITY_IMPL_H_
diff --git a/src/inc/FNetSock_IpMulticastRequestOptionImpl.h b/src/inc/FNetSock_IpMulticastRequestOptionImpl.h
new file mode 100644 (file)
index 0000000..af01a10
--- /dev/null
@@ -0,0 +1,140 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_IpMulticastRequestOptionImpl.h
+ * @brief              This is the header file for the _IpMulticastRequestOptionImpl class.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_IP_MULTICAST_REQUEST_OPTION_IMPL_H_
+#define _FNET_SOCK_INTERNAL_IP_MULTICAST_REQUEST_OPTION_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseObject.h>
+#include <FOspConfig.h>
+#include <FNetSockSocketIpMulticastRequestOption.h>
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+class Socket;
+class _IpMulticastRequestOptionImpl;
+
+class _OSP_EXPORT_ _IpMulticastRequestOptionImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * @see                 IpMulticastRequestOption::IpMulticastRequestOption()
+        */
+       _IpMulticastRequestOptionImpl(const NetEndPoint& multicastAddress, const NetEndPoint& interfaceAddress);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_IpMulticastRequestOptionImpl(void);
+
+       /**
+        * This is the copy constructor for the %_IpMulticastRequestOptionImpl class. @n
+        * This initializes an instance of %_IpMulticastRequestOptionImpl with the values of the specified instance.
+        *
+        * @since 2.1
+        */
+       _IpMulticastRequestOptionImpl(const _IpMulticastRequestOptionImpl& rhs);
+
+       /**
+        * This is the assignment operator.
+        * Do @b not use directly.
+        *
+        * @since 2.1
+        * @param[in]   rhs                     An instance of %_IpMulticastRequestOptionImpl
+        */
+       _IpMulticastRequestOptionImpl& operator =(const _IpMulticastRequestOptionImpl& rhs);
+
+       /**
+        * @see                 IpMulticastRequestOption::Equals()
+        */
+       virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+       /**
+        * @see                 IpMulticastRequestOption::GetHashCode()
+        */
+       virtual int GetHashCode(void) const;
+
+public:
+       /**
+        * @see                 IpMulticastRequestOption::SetMulticastEndPoint()
+        */
+       result SetMulticastEndPoint(NetEndPoint& multicastAddress);
+
+       /**
+        * @see                 IpMulticastRequestOption::SetInterfaceEndPoint()
+        */
+       result SetInterfaceEndPoint(NetEndPoint& interfaceAddress);
+
+       /**
+        * @see                 IpMulticastRequestOption::SetInterfaceEndPoint()
+        */
+       const NetEndPoint* GetMulticastEndPoint(void) const;
+
+       /**
+        * @see                 IpMulticastRequestOption::SetInterfaceEndPoint()
+        */
+       const NetEndPoint* GetInterfaceEndPoint(void) const;
+
+public:
+       /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _IpMulticastRequestOptionImpl
+     * @param[in]   ipMulticastRequestOption            An instance of IpMulticastRequestOption
+     */
+       static _IpMulticastRequestOptionImpl* GetInstance(IpMulticastRequestOption& ipMulticastRequestOption);
+
+       /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _IpMulticastRequestOptionImpl
+     * @param[in]   ipMulticastRequestOption     An instance of IpMulticastRequestOption
+     */
+       static const _IpMulticastRequestOptionImpl* GetInstance(const IpMulticastRequestOption& ipMulticastRequestOption);
+
+private:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       _IpMulticastRequestOptionImpl(void);
+
+private:
+       std::unique_ptr<NetEndPoint> __pMulticastAddr;
+       std::unique_ptr<NetEndPoint> __pInterfaceAddr;
+
+       friend class _SocketImpl;
+       friend class _NetEndPointImpl;
+       friend class IpMulticastRequestOption;
+
+}; // _IpMulticastRequestOptionImpl
+
+} } } // Tizen::Net::Sockets
+#endif // _FNET_SOCK_INTERNAL_IP_MULTICAST_REQUEST_OPTION_IMPL_H_
diff --git a/src/inc/FNetSock_LingerOptionImpl.h b/src/inc/FNetSock_LingerOptionImpl.h
new file mode 100644 (file)
index 0000000..68f971f
--- /dev/null
@@ -0,0 +1,141 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_LingerOptionImpl.h
+ * @brief              This is the header file for the _LingerOptionImpl class.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_LINGER_OPTION_IMPL_H_
+#define _FNET_SOCK_INTERNAL_LINGER_OPTION_IMPL_H_
+
+
+#include <FBaseObject.h>
+#include <FOspConfig.h>
+#include <FNetSockSocketLingerOption.h>
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+class Socket;
+class _LingerOptionImpl;
+
+class _OSP_EXPORT_ _LingerOptionImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * @see                 LingerOption::LingerOption()
+        */
+       _LingerOptionImpl(bool enable, int seconds);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_LingerOptionImpl(void);
+
+       /**
+        * This is the copy constructor for the %_LingerOptionImpl class. @n
+        * This initializes an instance of %_LingerOptionImpl with the values of the specified instance.
+        *
+        * @since 2.1
+        */
+       _LingerOptionImpl(const _LingerOptionImpl& rhs);
+
+       /**
+        * This is the assignment operator.
+        * Do @b not use directly.
+        *
+        * @since 2.1
+        * @param[in]   rhs                     An instance of %_LingerOptionImpl
+        */
+       _LingerOptionImpl& operator =(const _LingerOptionImpl& rhs);
+
+       /**
+        * @see                 LingerOption::Equals()
+        */
+       virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+       /**
+        * @see                 LingerOption::GetHashCode()
+        */
+       virtual int GetHashCode(void) const;
+
+public:
+       /**
+        * @see                 LingerOption::SetEnabled()
+        */
+       void SetEnabled(bool on);
+
+       /**
+        * @see                 LingerOption::SetLingerTime()
+        */
+       void SetLingerTime(int seconds);
+
+       /**
+        * @see                 LingerOption::GetLingerTime()
+        */
+       int GetLingerTime(void) const;
+
+       /**
+        * @see                 LingerOption::IsEnabled()
+        */
+       bool IsEnabled(void) const;
+
+public:
+       /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _LingerOptionImpl
+     * @param[in]   lingerOption            An instance of LingerOption
+     */
+       static _LingerOptionImpl* GetInstance(LingerOption& lingerOption);
+
+       /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _LingerOptionImpl
+     * @param[in]   lingerOption     An instance of LingerOption
+     */
+       static const _LingerOptionImpl* GetInstance(const LingerOption& lingerOption);
+
+private:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       _LingerOptionImpl(void);
+
+private:
+       bool __enabled;
+       int __lingerTime;
+
+
+       friend class _SocketImpl;
+       friend class Socket;
+       friend class LingerOption;
+
+}; // _LingerOptionImpl
+
+} } }   // Tizen::Net::Sockets
+#endif // _FNET_SOCK_INTERNAL_LINGER_OPTION_IMPL_H_
diff --git a/src/inc/FNetSock_SecureSocketImpl.h b/src/inc/FNetSock_SecureSocketImpl.h
new file mode 100644 (file)
index 0000000..fe0d3b7
--- /dev/null
@@ -0,0 +1,362 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SecureSocketImpl.h
+ * @brief              This is the header file for the _SecureSocketImpl class.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_SECURE_SOCKET_IMPL_H_
+#define _FNET_SOCK_INTERNAL_SECURE_SOCKET_IMPL_H_
+
+#include <glib.h>
+#include <openssl/ssl.h>
+#include <pthread.h>
+#include <FBaseObject.h>
+#include <FBaseColArrayListT.h>
+#include <FBaseRtThread.h>
+#include <FOspConfig.h>
+#include <FNetSockSecureSocket.h>
+#include <FNetSockSocketTypes.h>
+#include "FNetSock_SocketTypes.h"
+
+namespace Tizen { namespace Net
+{
+class NetEndPoint;
+class Ip4Address;
+class NetConnection;
+class NetConnectionManager;
+class ManagedNetConnection;
+} } // Tizen::Net
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+class SecureSocket;
+class _SecureSocketEvent;
+class ISecureSocketEventListener;
+class _GlibSecureSocketInfo;
+class _SecureSocketManagedNetConnectionEventListener;
+class _SecureSocketCustomNetConnectionEventListener;
+
+class _OSP_EXPORT_ _SecureSocketImpl
+       : public Tizen::Base::Object
+       , public Tizen::Base::Runtime::IRunnable
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       _SecureSocketImpl(SecureSocket* pSocket);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_SecureSocketImpl(void);
+
+       /**
+        * @see                 SecureSocket::Construct()
+        */
+       result Construct(const Tizen::Net::NetConnection& netConnection, NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol);
+
+       /**
+        * @see                 SecureSocket::Construct()
+        */
+       result Construct(NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol);
+
+public:
+       /**
+        * @see                 SecureSocket::Close()
+        */
+       result Close(void);
+
+       /**
+        * @see                 SecureSocket::Connect()
+        */
+       result Connect(const Tizen::Net::NetEndPoint& remoteEndPoint);
+
+       /**
+        * @see                 SecureSocket::Send()
+        */
+       result Send(Tizen::Base::ByteBuffer& buffer);
+
+       /**
+        * @see                 SecureSocket::Send()
+        */
+       result Send(void* pBuffer, int length, int& sentLength);
+
+       /**
+        * @see                 SecureSocket::Receive()
+        */
+       result Receive(Tizen::Base::ByteBuffer& buffer);
+
+       /**
+        * @see                 SecureSocket::Receive()
+        */
+       result Receive(void* pBuffer, int length, int& rcvdLength);
+
+       /**
+        * @see                 SecureSocket::Bind()
+        */
+       result Bind(const Tizen::Net::NetEndPoint& localEndPoint);
+
+       /**
+        * @see                 SecureSocket::Listen()
+        */
+       result Listen(int backLog);
+
+       /**
+        * @see                 SecureSocket::AcceptN()
+        */
+       SecureSocket* AcceptN(void);
+
+       /**
+        * @see                 SecureSocket::Ioctl()
+        */
+       result Ioctl(NetSocketIoctlCmd cmd, unsigned long& value);
+
+       /**
+        * @see                 SecureSocket::AsyncSelectByListener()
+        */
+       result AsyncSelectByListener(unsigned long socketEventType);
+
+       /**
+        * @see                 SecureSocket::AddSecureSocketListener()
+        */
+       result AddSecureSocketListener(ISecureSocketEventListener& listener);
+
+       /**
+        * @see                 SecureSocket::RemoveSecureSocketListener()
+        */
+       result RemoveSecureSocketListener(ISecureSocketEventListener& listener);
+
+       /**
+        * @see                 SecureSocket::GetSockOpt()
+        */
+       result GetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int& optionValue) const;
+
+       /**
+        * @see                 SecureSocket::SetSockOpt()
+        */
+       result SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int optionValue);
+
+       /**
+        * @see                 SecureSocket::GetSocketFd()
+        */
+       int GetSecureSocketFd(void);
+
+// Internal Operation
+public:
+       SecureSocket* GetSecureSocket(void) const;
+
+       virtual Tizen::Base::Object* Run(void);
+
+public:
+       /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _SecureSocketImpl
+     * @param[in]   secureSocket            An instance of SecureSocket
+     */
+       static _SecureSocketImpl* GetInstance(SecureSocket& secureSocket);
+
+       /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _SecureSocketImpl
+     * @param[in]   secureSocket     An instance of SecureSocket
+     */
+       static const _SecureSocketImpl* GetInstance(const SecureSocket& secureSocket);
+
+private:
+       /**
+        * @see                 SecureSocket::Construct()
+        */
+       result Construct(void);
+
+       /**
+        * Frees the resource allocated by this SecureSocket instance.
+        *
+        * @return              An error code
+        * @exception   E_SUCCESS                               The method was successful.
+        * @exception   E_FAILURE                               Failed due to undefined error.
+        * @remarks             The implementer of the derived class of Resource class must override
+        *                              this method and provide specific resource deallocation routine.
+        */
+       result Dispose(void);
+
+private:
+       /**
+        * This is the copy constructor for this class.
+        *
+        * @param[in]   rhs                     An instance of _SecureSocketImpl
+        */
+       _SecureSocketImpl(const _SecureSocketImpl& rhs);
+
+       /**
+        * This is the assignment operator. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                             An instance of _SecureSocketImpl
+        */
+       _SecureSocketImpl& operator =(const _SecureSocketImpl& rhs);
+
+// glib
+private:
+       //by event
+       static gboolean OnGioEventCallback(GIOChannel* pSource, GIOCondition condition, gpointer pUserData);
+
+       void SetTimer(void);
+
+       static gboolean OnTimerExpiredEvent(gpointer data);
+
+// ssl
+private:
+       //static int OnPasswdCallback(char* pBuf, int size, int rwflag, void* pUserData);
+
+       static int OnVerifyPeerCallback(int preverify_ok, X509_STORE_CTX* pX509Ctx);
+
+       static int OnVerifyClientCallback(int preverify_ok, X509_STORE_CTX* pX509Ctx);
+
+       static int OnClientCertCallback(SSL* pSsl, X509** ppX509, EVP_PKEY** ppKey);
+
+       static RSA* OnTmpRsaCallback(SSL* pSsl, int isexport, int keylength);
+
+       result SslConnect(int& sslError);
+
+       result SslAccept(SSL* pSsl, int& sslError);
+
+       result ConvertSslError(int sslError);
+
+private:
+       HSocket __socketFd;
+       bool __isConstructed;
+       bool __isClosed;
+       bool __isLoopback;
+       bool __isAsync;
+       bool __isReadFired;
+       bool __isConnectFired;
+       bool __isAcceptFired;
+       bool __isServer;
+       bool __isWriteFired;
+       bool __isCloseFired;
+       bool __isConnectFailed;
+       bool __isAcceptFailed;
+       bool __isCertVerifyFailed;
+       bool __isClientNoCert;
+       bool __isPeerNoCert;
+       bool __isClientVerify;
+       bool __isSslConnected;
+       bool __isSslAccepted;
+       bool __isRunFinished;
+       bool __isNonblock;
+       bool __isLoadVerify;
+       int __sslVerify;
+       unsigned long __socketEventType;
+
+       // for creation sockets
+       NetSocketAddressFamily __protocolFamily;
+       NetSocketType __socketType;
+       NetSocketProtocol __protocol;
+       NetSecureSocketSslVersion __sslVersion;
+       NetSecureSocketSslCipherSuiteID __sslCipherSuiteId;
+
+       Tizen::Net::NetConnectionManager* __pNetConnectionManager;
+       Tizen::Net::ManagedNetConnection* __pManagedNetConnection;
+       _SecureSocketManagedNetConnectionEventListener* __pManagedNetConnectionEventListener;
+       Tizen::Net::NetConnection* __pCustomNetConnection;
+       _SecureSocketCustomNetConnectionEventListener* __pCustomNetConnectionEventListener;
+
+       Tizen::Base::Collection::ArrayListT<ISecureSocketEventListener*> __secureSocketEventListenerList;
+
+       _SecureSocketEvent* __pSecureSocketEvent;
+
+       SecureSocket* __pSecureSocket;
+       Tizen::Base::Runtime::Thread* __pThread;
+
+       SSL* __pSsl;
+       SSL_METHOD* __pSslMethod;
+       SSL_CTX* __pSslCtx;
+
+       GMainContext* __pGMainContext;
+       _GlibSecureSocketInfo* __pGlibSocketInfo;
+
+       GSource* __pTimerSource;
+
+       static pthread_mutex_t __mapMutex;
+
+       Tizen::Base::Integer* __pSslKey;
+       int __sslDepth;
+
+       friend class SecureSocket;
+       friend class _SecureSocketEvent;
+       friend class _GlibSecureSocketInfo;
+       friend class _SecureSocketCustomNetConnectionEventListener;
+       friend class _SecureSocketManagedNetConnectionEventListener;
+
+}; // _SecureSocketImpl
+
+typedef struct SecureUserData
+{
+       _SecureSocketImpl* pSecureSocketImpl;
+       GSource* pGSource;
+} _SecureUserData;
+
+class _GlibSecureSocketInfo
+       : public Tizen::Base::Object
+{
+
+public:
+       _GlibSecureSocketInfo(void);
+       virtual ~_GlibSecureSocketInfo(void);
+
+public:
+       //Set Socket Event and Run
+       result SetSocketEvent(_SecureSocketImpl* pSecureSocketImpl, HSocket socketFd);
+
+private:
+       /**
+        * This is the copy constructor for this class.
+        *
+        * @param[in]   value                   An instance of _GlibSecureSocketInfo
+        */
+       _GlibSecureSocketInfo(const _GlibSecureSocketInfo& value);
+
+       /**
+        * This is the assignment operator. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                             An instance of _GlibSecureSocketInfo
+       */
+       _GlibSecureSocketInfo& operator =(const _GlibSecureSocketInfo& rhs);
+
+private:
+       GIOChannel* __pSocketChannel;
+       GSource* __pSocketSource;
+       HSocket __socketFd;
+       _SecureUserData* __pUserData;
+}; // _GlibSecureSocketInfo
+
+} } } // Tizen::Net::Sockets
+#endif // _FNET_SOCK_INTERNAL_SECURE_SOCKET_IMPL_H_
diff --git a/src/inc/FNetSock_SocketImpl.h b/src/inc/FNetSock_SocketImpl.h
new file mode 100644 (file)
index 0000000..19d290f
--- /dev/null
@@ -0,0 +1,360 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketImpl.h
+ * @brief              This is the header file for the _SocketImpl class.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_SOCKET_IMPL_H_
+#define _FNET_SOCK_INTERNAL_SOCKET_IMPL_H_
+
+#include <glib.h>
+#include <FBaseObject.h>
+#include <FBaseColArrayListT.h>
+#include <FOspConfig.h>
+#include <FNetSockSocketTypes.h>
+#include "FNetSock_SocketTypes.h"
+
+namespace Tizen { namespace Net
+{
+class NetEndPoint;
+class Ip4Address;
+class NetConnection;
+class NetConnectionManager;
+class ManagedNetConnection;
+} } // Tizen::Net
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+class Socket;
+class _SocketEvent;
+class LingerOption;
+class IpMulticastRequestOption;
+class ISocketEventListener;
+class _GlibSocketInfo;
+class _SocketManagedNetConnectionEventListener;
+class _SocketCustomNetConnectionEventListener;
+
+class _OSP_EXPORT_ _SocketImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       _SocketImpl(Socket* pSocket);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_SocketImpl(void);
+
+       /**
+        * @see                 Socket::Construct()
+        */
+       result Construct(const NetConnection& netConnection, NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol);
+
+       /**
+        * @see                 Socket::Construct()
+        */
+       result Construct(NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol);
+
+public:
+       /**
+        * @see                 Socket::Close()
+        */
+       result Close(void);
+
+       /**
+        * @see                 Socket::Connect()
+        */
+       result Connect(const Tizen::Net::NetEndPoint& remoteEndPoint);
+
+       /**
+        * @see                 Socket::Send()
+        */
+       result Send(Tizen::Base::ByteBuffer& buffer);
+
+       /**
+        * @see                 Socket::Send()
+        */
+       result Send(void* pBuffer, int length, int& sentLength);
+
+       /**
+        * @see                 Socket::SendTo()
+        */
+       result SendTo(Tizen::Base::ByteBuffer& buffer, const Tizen::Net::NetEndPoint& remoteEndPoint);
+
+       /**
+        * @see                 Socket::SendTo()
+        */
+       result SendTo(void* pBuffer, int length, const Tizen::Net::NetEndPoint& remoteEndPoint, int& sentLength);
+
+       /**
+        * @see                 Socket::Receive() // const delete
+        */
+       result Receive(Tizen::Base::ByteBuffer& buffer);
+
+       /**
+        * @see                 Socket::Receive() // const delete
+        */
+       result Receive(void* pBuffer, int length, int& rcvdLength);
+
+       /**
+        * @see                 Socket::ReceiveFrom() // const delete
+        */
+       result ReceiveFrom(Tizen::Base::ByteBuffer& buffer, Tizen::Net::NetEndPoint& remoteEndPoint);
+
+       /**
+        * @see                 Socket::ReceiveFrom() // const delete
+        */
+       result ReceiveFrom(void* pBuffer, int length, Tizen::Net::NetEndPoint& remoteEndPoint, int& rcvdLength);
+
+       /**
+        * @see                 Socket::Bind()
+        */
+       result Bind(const Tizen::Net::NetEndPoint& localEndPoint);
+
+       /**
+        * @see                 Socket::Listen()
+        */
+       result Listen(int backLog);
+
+       /**
+        * @see                 Socket::AcceptN()
+        */
+       Socket* AcceptN(void);
+
+       /**
+        * @see                 Socket::Ioctl()
+        */
+       result Ioctl(NetSocketIoctlCmd cmd, unsigned long& value);
+
+       /**
+        * @see                 Socket::AsyncSelectByListener()
+        */
+       result AsyncSelectByListener(unsigned long socketEventType);
+
+       /**
+        * @see                 Socket::AddSocketListener()
+        */
+       result AddSocketListener(ISocketEventListener& listener);
+
+       /**
+        * @see                 Socket::RemoveSocketListener()
+        */
+       result RemoveSocketListener(ISocketEventListener& listener);
+
+       /**
+        * @see                 Socket::GetPeerEndPoint()
+        */
+       const NetEndPoint* GetPeerEndPoint(void);
+
+       /**
+        * @see                 Socket::GetLocalEndPoint()
+        */
+       const NetEndPoint* GetLocalEndPoint(void);
+
+       /**
+        * @see                 Socket::GetSockOpt()
+        */
+       result GetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int& optionValue) const;
+
+       /**
+        * @see                 Socket::GetSockOpt()
+        */
+       result GetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, LingerOption& optionValue) const;
+
+       /**
+        * @see                 Socket::SetSockOpt()
+        */
+       result SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int optionValue);
+
+       /**
+        * @see                 Socket::SetSockOpt()
+        */
+       result SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, const LingerOption& optionValue);
+
+       /**
+        * @see                 Socket::SetSockOpt()
+        */
+       result SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, const IpMulticastRequestOption& optionValue);
+
+       /**
+        * @see                 Socket::GetSocketFd()
+        */
+       int GetSocketFd(void);
+
+// Internal Operation
+public:
+       Socket* GetSocket(void) const;
+
+public:
+       /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _SocketImpl
+     * @param[in]   socket            An instance of Socket
+     */
+       static _SocketImpl* GetInstance(Socket& socket);
+
+       /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _SocketImpl
+     * @param[in]   socket     An instance of Socket
+     */
+       static const _SocketImpl* GetInstance(const Socket& socket);
+
+private:
+       /**
+        * Frees the resource allocated by this Socket instance.
+        *
+        * @return                      An error code
+        * @exception   E_SUCCESS                                                       The method was successful.
+        * @exception   E_FAILURE                                                       The method failed.
+        * @remarks         The implementer of the derived class of Resource class must override
+        *                              this method and provide specific resource deallocation routine.
+        */
+       result Dispose(void);
+
+private:
+       /**
+        * This is the copy constructor for this class.
+        *
+        * @param[in]   rhs                     An instance of _SocketImpl
+        */
+       _SocketImpl(const _SocketImpl& rhs);
+
+       /**
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                             An instance of _SocketImpl
+        */
+       _SocketImpl& operator =(const _SocketImpl& rhs);
+
+// glib
+private:
+       //by event
+       static gboolean OnGioEventCallback(GIOChannel* pSource, GIOCondition condition, gpointer pUserData);
+
+       static gboolean OnTimerCallback(gpointer pUserData);
+
+private:
+       HSocket __socketFd;
+
+       bool __isConstructed;
+       bool __isClosed;
+       bool __isLoopback;
+
+       bool __isUdp;
+       bool __isAsync;
+       bool __isNonblock;
+       bool __isServer;
+
+       bool __isAcceptFired;
+       bool __isReadFired;
+       bool __isErrorReadFired;
+       bool __isConnectFired;
+       bool __isWriteFired;
+       bool __isCloseFired;
+       unsigned long __socketEventType;
+
+       bool __isTimeout;
+
+       // for creation sockets
+       NetSocketAddressFamily __protocolFamily;
+       NetSocketType __socketType;
+       NetSocketProtocol __protocol;
+
+       Tizen::Net::NetConnectionManager* __pNetConnectionManager;
+       Tizen::Net::ManagedNetConnection* __pManagedNetConnection;
+       _SocketManagedNetConnectionEventListener* __pManagedNetConnectionEventListener;
+       Tizen::Net::NetConnection* __pCustomNetConnection;
+       _SocketCustomNetConnectionEventListener* __pCustomNetConnectionEventListener;
+
+       Tizen::Base::Collection::ArrayListT<ISocketEventListener*> __socketEventListenerList;
+
+       Socket* __pSocket;
+
+       _SocketEvent* __pSocketEvent;
+       NetEndPoint* __pLocal;
+       NetEndPoint* __pPeer;
+
+       LingerOption* __pLingerOption;
+       IpMulticastRequestOption* __pMulticastOption;
+
+       GMainContext* __pGMainContext;
+       _GlibSocketInfo* __pGlibSocketInfo;
+
+       friend class Socket;
+       friend class _GlibSocketInfo;
+       friend class _SocketEvent;
+       friend class _SocketCustomNetConnectionEventListener;
+       friend class _SocketManagedNetConnectionEventListener;
+
+}; // _SocketImpl
+
+typedef struct UserData
+{
+       _SocketImpl* pSocketImpl;
+       GSource* pGSource;
+} _UserData;
+
+class _GlibSocketInfo
+       : public Tizen::Base::Object
+{
+public:
+       _GlibSocketInfo(void);
+       virtual ~_GlibSocketInfo(void);
+
+public:
+       //Set Socket Event and Run
+       result SetSocketEvent(_SocketImpl* pSocketImpl, HSocket socketFd);
+
+// Lifecycle
+private:
+       /**
+        * This is the copy constructor.
+        */
+       _GlibSocketInfo(const _GlibSocketInfo& value);
+
+private:
+       /**
+        * This is the assignment operator.
+        */
+       _GlibSocketInfo& operator =(const _GlibSocketInfo& rhs);
+
+private:
+       GIOChannel* __pSocketChannel;
+       GSource* __pSocketSource;
+       HSocket __socketFd;
+       _UserData* __pUserData;
+
+}; // _GlibSocketInfo
+
+} } }   // Tizen::Net::Sockets
+#endif // _FNET_SOCK_INTERNAL_SOCKET_IMPL_H_
diff --git a/src/inc/FNetSock_SocketTypes.h b/src/inc/FNetSock_SocketTypes.h
new file mode 100644 (file)
index 0000000..3f31ed9
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketTypes.h
+ * @brief              This is the header file for the Internal socket types.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_SOCKET_TYPES_H_
+#define _FNET_SOCK_INTERNAL_SOCKET_TYPES_H_
+
+
+#include <FBaseDataType.h>
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+typedef Handle HSocket;             // Socket handle
+
+static const int SOCKET_INADDR_ANY = 0;
+
+} } }   // Tizen::Net::Sockets
+#endif // _FNET_SOCK_INTERNAL_SOCKET_TYPES_H_
diff --git a/src/inc/FNetSock_SocketUtilityImpl.h b/src/inc/FNetSock_SocketUtilityImpl.h
new file mode 100644 (file)
index 0000000..af21a09
--- /dev/null
@@ -0,0 +1,126 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketUtility.h
+ * @brief              This is the header file for the _SocketUtilityImpl class.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_SOCKET_UTILITY_IMPL_H_
+#define _FNET_SOCK_INTERNAL_SOCKET_UTILITY_IMPL_H_
+
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+class _OSP_EXPORT_ _SocketUtilityImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       _SocketUtilityImpl(void);
+
+       /**
+        * @see                 SocketUtility::Construct()
+        */
+       result Construct(void);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_SocketUtilityImpl(void);
+
+public:
+       /**
+        * @see                 SocketUtility::Select()
+        */
+       result Select(Tizen::Base::Collection::IList* pCheckRead, Tizen::Base::Collection::IList* pCheckWrite, Tizen::Base::Collection::IList* pCheckError, int microSeconds);
+
+       /**
+        * @see                 SocketUtility::HtoNS()
+        */
+       unsigned short HtoNS(unsigned short hostShort);
+
+       /**
+        * @see                 SocketUtility::HtoNL()
+        */
+       unsigned long HtoNL(unsigned long hostLong);
+
+       /**
+        * @see                 SocketUtility::NtoHS()
+        */
+       unsigned short NtoHS(unsigned short netShort);
+
+       /**
+        * @see                 SocketUtility::NtoHL()
+        */
+       unsigned long NtoHL(unsigned long netLong);
+
+       // For internal use
+       result IListToSocketFdSet(const Tizen::Base::Collection::IList& iList, fd_set* pSet, int& nfds);
+
+       result SocketFdSetToIList(const fd_set* pSet, Tizen::Base::Collection::IList& iList);
+
+public:
+       /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _SocketUtilityImpl
+     * @param[in]   socketUtility            An instance of SocketUtility
+     */
+       static _SocketUtilityImpl* GetInstance(SocketUtility& socketUtility);
+
+       /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _SocketUtilityImpl
+     * @param[in]   socketUtility     An instance of SocketUtility
+     */
+       static const _SocketUtilityImpl* GetInstance(const SocketUtility& socketUtility);
+
+private:
+       _SocketUtilityImpl(const _SocketUtilityImpl& rhs);
+
+       _SocketUtilityImpl& operator =(const _SocketUtilityImpl& rhs);
+
+private:
+       bool __isConstructed;
+
+       friend class SocketUtility;
+
+}; // _SocketUtilityImpl
+
+} } }   // Tizen::Net::Sockets
+#endif // _FNET_SOCK_INTERNAL_SOCKET_UTILITY_IMPL_H_
diff --git a/src/inc/FNetWifi_ConnectivityIpcMessages.h b/src/inc/FNetWifi_ConnectivityIpcMessages.h
new file mode 100644 (file)
index 0000000..19f7cc4
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNetWifi_ConnectivityIpcMessages.h
+ * @brief      This is the header file for the Connectivity service daemon's IPC messages.
+ *
+ * This header file contains the declarations of the IPC messages for the Connectivity service daemon.
+ */
+
+#include <ipc/ipc_message_macros.h>
+#include <FIo_IpcCommonParamTraits.h>
+#include <FIo_IpcMessageStart.h>
+#include "FNetWifi_ConnectivityIpcParamTraits.h"
+
+#ifndef WIFI_CONNECTIVITY_IPC_SERVER_NAME
+#define WIFI_CONNECTIVITY_IPC_SERVER_NAME "osp.net.wifi.ipcserver.connectivity"
+#endif
+
+#define IPC_MESSAGE_START ConnectivityWifiServiceMsgStart
+
+// Client -> Server (sync)
+IPC_SYNC_MESSAGE_CONTROL1_1(ConnectivityWifiServiceMsg_setSystemScanMode, int /* mode */, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL0_1(ConnectivityWifiServiceMsg_checkSystemSettingPrivilege, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL1_1(ConnectivityWifiServiceMsg_updateWifiBssInfo, Tizen::Net::Wifi::WifiBssInfo /* BSS info */, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL0_1(ConnectivityWifiServiceMsg_initializeWifiDirect, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL0_2(ConnectivityWifiServiceMsg_getWifiDirectLocalDeviceName, Tizen::Base::String /* local name */, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL1_1(ConnectivityWifiServiceMsg_setWifiDirectLocalDeviceName, Tizen::Base::String /* local name */, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL1_1(ConnectivityWifiServiceMsg_registerBssId, Tizen::Base::String /* BSS ID */, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL1_1(ConnectivityWifiServiceMsg_unregisterBssId, Tizen::Base::String /* BSS ID */, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL0_1(ConnectivityWifiServiceMsg_activateProximityCheck, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL0_1(ConnectivityWifiServiceMsg_deactivateProximityCheck, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL0_2(ConnectivityWifiServiceMsg_isProximityCheckActivated, bool /* Proximity service status */, unsigned long /* result */)
+
+// Server -> Client (async)
+IPC_MESSAGE_CONTROL0(ConnectivityWifiServiceMsg_onProximityCheckActivated);
+IPC_MESSAGE_CONTROL0(ConnectivityWifiServiceMsg_onProximityCheckDeactivated);
+IPC_MESSAGE_CONTROL1(ConnectivityWifiServiceMsg_onWifiBssDetected, Tizen::Net::Wifi::WifiBssInfo /* BSS info */);
+IPC_MESSAGE_CONTROL1(ConnectivityWifiServiceMsg_onWifiBssLost, Tizen::Base::String /* BSS ID */);
diff --git a/src/inc/FNetWifi_ConnectivityIpcParamTraits.h b/src/inc/FNetWifi_ConnectivityIpcParamTraits.h
new file mode 100644 (file)
index 0000000..956853b
--- /dev/null
@@ -0,0 +1,335 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNetWifi_ConnectivityIpcMessages.h
+ * @brief      This is the header file for the Connectivity service daemon's IPC messages.
+ *
+ * This header file contains the declarations of the IPC messages for the Connectivity service daemon.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_CONNECTIVITY_IPC_PARAM_TRAITS_H_
+#define _FNET_WIFI_INTERNAL_CONNECTIVITY_IPC_PARAM_TRAITS_H_
+
+#include <base/tuple.h>
+#include <ipc/ipc_param_traits.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FNetWifiWifiTypes.h>
+#include <FNetWifiWifiBssInfo.h>
+#include <FNetWifiWifiSecurityInfo.h>
+#include <FNetIp4Address.h>
+#include <FNetNetTypes.h>
+#include "FNetWifi_WifiBssInfoImpl.h"
+#include "FNetWifi_WifiSecurityInfoImpl.h"
+#include "FIo_IpcCommonDataTypes.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Net;
+using namespace Tizen::Net::Wifi;
+
+namespace IPC
+{
+template <>
+struct ParamTraits<Tizen::Net::Wifi::WifiBssInfo>
+{
+       typedef WifiBssInfo param_type;
+
+       static void Write(Message* m, const param_type& p)
+       {
+               const IpAddress* pAddress = null;
+               const WifiSecurityInfo* pSecurityInfo = null;
+               NetAddressScheme ipScheme = NET_ADDRESS_SCHEME_DYNAMIC;
+               NetProxyType proxyType = NET_PROXY_TYPE_NONE;
+
+               // 1. BSS ID
+               WriteParam(m, p.GetBssId());
+
+               // 2. SSID
+               WriteParam(m, p.GetSsid());
+
+               // 3. Radio Channel
+               m->WriteInt(p.GetRadioChannel());
+
+               // 4. BSS Type
+               m->WriteInt(p.GetBssType());
+
+               // 5. Security Info
+               pSecurityInfo = p.GetSecurityInfo();
+               if (pSecurityInfo != null)
+               {
+                       m->WriteInt(pSecurityInfo->GetAuthenticationType());
+                       m->WriteInt(pSecurityInfo->GetEncryptionType());
+               }
+
+               // 6. RSSI
+               m->WriteLong(p.GetRssi());
+
+               // 7. Data Rate
+               float dataRate = p.GetDataRate();
+               m->WriteBytes(&dataRate, sizeof(dataRate));
+
+               // 8. Known
+               m->WriteBool(p.IsKnown());
+
+               // 9. Local address scheme
+               ipScheme = p.GetLocalAddressScheme();
+               m->WriteInt(ipScheme);
+
+               if (ipScheme == NET_ADDRESS_SCHEME_STATIC)
+               {
+                       // 10. IP address
+                       pAddress = p.GetLocalAddress();
+                       if (pAddress != null)
+                       {
+                               WriteParam(m, pAddress->ToString());
+                       }
+                       else
+                       {
+                               WriteParam(m, String(L""));
+                       }
+
+                       // 11. Subnet mask address
+                       pAddress = p.GetSubnetMaskAddress();
+                       if (pAddress != null)
+                       {
+                               WriteParam(m, pAddress->ToString());
+                       }
+                       else
+                       {
+                               WriteParam(m, String(L""));
+                       }
+
+                       // 12. Default gateway address
+                       pAddress = p.GetDefaultGatewayAddress();
+                       if (pAddress != null)
+                       {
+                               WriteParam(m, pAddress->ToString());
+                       }
+                       else
+                       {
+                               WriteParam(m, String(L""));
+                       }
+
+                       // 13. Primary DNS address
+                       pAddress = p.GetPrimaryDnsAddress();
+                       if (pAddress != null)
+                       {
+                               WriteParam(m, pAddress->ToString());
+                       }
+                       else
+                       {
+                               WriteParam(m, String(L""));
+                       }
+
+                       // 14. Secondary DNS address
+                       pAddress = p.GetSecondaryDnsAddress();
+                       if (pAddress != null)
+                       {
+                               WriteParam(m, pAddress->ToString());
+                       }
+                       else
+                       {
+                               WriteParam(m, String(L""));
+                       }
+               }
+
+               // 15. Proxy type
+               proxyType = p.GetProxyType();
+               m->WriteInt(proxyType);
+
+               if (proxyType == NET_PROXY_TYPE_MANUAL)
+               {
+                       // 16. Proxy address
+                       WriteParam(m, p.GetProxyAddress());
+               }
+       }
+
+       static bool Read(const Message* m, void** iter, param_type* r)
+       {
+               _WifiBssInfoImpl* pInfoImpl = null;
+               WifiSecurityInfo securityInfo;
+               _WifiSecurityInfoImpl* pSecurityInfoImpl = null;
+               String bssId;
+               String Ssid;
+               String addressStr;
+               bool isKnown = false;
+               int ipScheme = 0;
+               int proxyType = 0;
+               int radioChannel = 0;
+               int bssType = 0;
+               int authenticationType = 0;
+               int encryptionType = 0;
+               long rssi = 0;
+               float* pDataRate = null;
+
+               pInfoImpl = _WifiBssInfoImpl::GetInstance(*r);
+               pSecurityInfoImpl = _WifiSecurityInfoImpl::GetInstance(securityInfo);
+
+               // 1. BSS ID
+               if (!ReadParam(m, iter, &bssId))
+               {
+                       return false;
+               }
+               pInfoImpl->SetBssId(bssId);
+
+               // 2. SSID
+               if (!ReadParam(m, iter, &Ssid))
+               {
+                       return false;
+               }
+               pInfoImpl->SetSsid(Ssid);
+
+               // 3. Radio Channel
+               m->ReadInt(iter, &radioChannel);
+               pInfoImpl->SetRadioChannel((WifiRadioChannel)radioChannel);
+
+               // 4. BSS Type
+               m->ReadInt(iter, &bssType);
+               pInfoImpl->SetBssType((WifiBssType)bssType);
+
+               // 5. Security Info
+               m->ReadInt(iter, &authenticationType);
+               pSecurityInfoImpl->SetAuthenticationType((WifiAuthenticationType)authenticationType);
+
+               m->ReadInt(iter, &encryptionType);
+               pSecurityInfoImpl->SetEncryptionType((WifiEncryptionType)encryptionType);
+
+               // 6. RSSI
+               m->ReadLong(iter, &rssi);
+               pInfoImpl->SetRssi(rssi);
+
+               // 7. Date Rate
+               const char* pTempDataRate = null;
+               m->ReadBytes(iter, &pTempDataRate, sizeof(*pDataRate));
+               pDataRate = (float*)(pTempDataRate);
+               pInfoImpl->SetDataRate(*pDataRate);
+
+               // 8. Known
+               m->ReadBool(iter, &isKnown);
+               pInfoImpl->SetKnown(isKnown);
+
+               // 9. Local address scheme
+               m->ReadInt(iter, &ipScheme);
+               pInfoImpl->SetLocalAddressScheme((NetAddressScheme)ipScheme);
+
+               if (ipScheme == NET_ADDRESS_SCHEME_STATIC)
+               {
+                       // 10. IP address
+                       if (!ReadParam(m, iter, &addressStr))
+                       {
+                               return false;
+                       }
+
+                       if (addressStr.GetLength() > 0)
+                       {
+                               Tizen::Net::Ip4Address ipAddress(addressStr); // on the assumption that the address family is IP 4.
+                               pInfoImpl->SetLocalAddress(&ipAddress);
+                       }
+                       else
+                       {
+                               pInfoImpl->SetLocalAddress(null);
+                       }
+
+                       // 11. Subnet mask address
+                       if (!ReadParam(m, iter, &addressStr))
+                       {
+                               return false;
+                       }
+
+                       if (addressStr.GetLength() > 0)
+                       {
+                               Tizen::Net::Ip4Address maskAddress(addressStr); // on the assumption that the address family is IP 4.
+                               pInfoImpl->SetSubnetMaskAddress(&maskAddress);
+                       }
+                       else
+                       {
+                               pInfoImpl->SetSubnetMaskAddress(null);
+                       }
+
+                       // 12. Default gateway address
+                       if (!ReadParam(m, iter, &addressStr))
+                       {
+                               return false;
+                       }
+
+                       if (addressStr.GetLength() > 0)
+                       {
+                               Tizen::Net::Ip4Address gwAddress(addressStr); // on the assumption that the address family is IP 4.
+                               pInfoImpl->SetDefaultGatewayAddress(&gwAddress);
+                       }
+                       else
+                       {
+                               pInfoImpl->SetDefaultGatewayAddress(null);
+                       }
+
+                       // 13. Primary DNS address
+                       if (!ReadParam(m, iter, &addressStr))
+                       {
+                               return false;
+                       }
+
+                       if (addressStr.GetLength() > 0)
+                       {
+                               Tizen::Net::Ip4Address priDnsAddress(addressStr); // on the assumption that the address family is IP 4.
+                               pInfoImpl->SetPrimaryDnsAddress(&priDnsAddress);
+                       }
+                       else
+                       {
+                               pInfoImpl->SetPrimaryDnsAddress(null);
+                       }
+
+                       // 14. Secondary DNS address
+                       if (!ReadParam(m, iter, &addressStr))
+                       {
+                               return false;
+                       }
+
+                       if (addressStr.GetLength() > 0)
+                       {
+                               Tizen::Net::Ip4Address secDnsAddress(addressStr); // on the assumption that the address family is IP 4.
+                               pInfoImpl->SetSecondaryDnsAddress(&secDnsAddress);
+                       }
+                       else
+                       {
+                               pInfoImpl->SetSecondaryDnsAddress(null);
+                       }
+               }
+
+               // 15. Proxy type
+               m->ReadInt(iter, &proxyType);
+               pInfoImpl->SetProxyType((NetProxyType)proxyType);
+
+               if (proxyType == NET_PROXY_TYPE_MANUAL)
+               {
+                       // 16. Proxy address
+                       if (!ReadParam(m, iter, &addressStr))
+                       {
+                               return false;
+                       }
+                       pInfoImpl->SetProxyAddress(addressStr);
+               }
+
+               return true;
+       }
+
+    static void Log(const param_type& p, std::string* l)
+       {
+       }
+};
+}
+
+#endif // _FNET_WIFI_INTERNAL_CONNECTIVITY_IPC_PARAM_TRAITS_H_
diff --git a/src/inc/FNetWifi_IWifiDirectListener.h b/src/inc/FNetWifi_IWifiDirectListener.h
new file mode 100644 (file)
index 0000000..d40bbff
--- /dev/null
@@ -0,0 +1,137 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetWifiIWifiDirectDeviceListener.h
+ * @brief              This is the header file for the %IWifiDirectDeviceListener interface.
+ *
+ * This header file contains the declarations of the %IWifiDirectDeviceListener interface.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_IWIFI_DIRECT_LISTENER_H_
+#define _FNET_WIFI_INTERNAL_IWIFI_DIRECT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FNetWifiWifiTypes.h>
+#include <FOspConfig.h>
+
+namespace Tizen { namespace Net {      namespace Wifi
+{
+class _WifiDirectEventArg;
+
+/**
+ * @interface   _IWifiDirectDeviceListener
+ * @brief       This interface implements listeners for the _WifiDirectDeviceImpl events.
+ * @since 2.1
+ *
+ *  This interface represents a listener to get the Wi-Fi Direct device status or information.
+ */
+
+class _OSP_EXPORT_ _IWifiDirectListener
+    : public Tizen::Base::Runtime::IEventListener
+{
+public:
+    /**
+     * This polymorphic destructor should be overridden if required. This way, 
+     * the destructors of the derived classes are called when the destructor of this interface is called.
+     *
+     * @since 2.1
+     */
+    virtual ~_IWifiDirectListener(void) {}
+
+    /**
+     * @see IWifiDirectDeviceListener::OnWifiDirectDeviceActivated()
+     */
+    virtual void OnWifiDirectDeviceActivated(const _WifiDirectEventArg& arg, result r) = 0;
+
+    /**
+     * @see IWifiDirectDeviceListener::OnWifiDirectDeviceDeactivated()
+     */   
+    virtual void OnWifiDirectDeviceDeactivated(const _WifiDirectEventArg& arg, result r) = 0;
+    
+    /**
+     * @see IWifiDirectDeviceListener::OnWifiDirectGroupCreatedN()
+     */
+    virtual void OnWifiDirectGroupCreatedN(const _WifiDirectEventArg& arg, WifiDirectGroupMemberType wifiDirectMemberType, result r) = 0;
+
+    /**
+     * @see IWifiDirectDeviceListener::OnWifiDirectScanCompletedN()
+     */
+    virtual void OnWifiDirectScanCompletedN(const _WifiDirectEventArg& arg, result r) = 0;
+
+    /**
+     * @see IWifiDirectDeviceListener::OnWifiDirectAssociationCompleted()
+     */
+    virtual void OnWifiDirectAssociationCompleted(const _WifiDirectEventArg& arg, result r) = 0;
+
+
+    /**
+     * @see IWifiDirectGroupOwnerListener::OnWifiDirectClientAssociated()
+     */  
+    virtual void OnWifiDirectClientAssociated(const _WifiDirectEventArg& arg) = 0;
+
+    /**
+     * @see IWifiDirectGroupOwnerListener::OnWifiDirectClientDisassociated()
+     */   
+    virtual void OnWifiDirectClientDisassociated(const _WifiDirectEventArg& arg, WifiDirectAssociationTerminationReason reason) = 0;
+    
+    /**
+     * @see IWifiDirectGroupOwnerListener::OnWifiDirectGroupDestroyed()
+     */
+    virtual void OnWifiDirectGroupDestroyed(const _WifiDirectEventArg& arg, result r) = 0;
+
+    /**
+     * @see IWifiDirectGroupClientListener::OnWifiDirectAssociationTerminated()
+     */
+    virtual void OnWifiDirectAssociationTerminated(const _WifiDirectEventArg& arg, result r) = 0;
+
+    /**
+     * @see IWifiDirectGroupClientListener::OnWifiDirectGroupOwnerInfoReceived()
+     */
+    virtual void OnWifiDirectGroupOwnerInfoReceived(const _WifiDirectEventArg& arg, result r) = 0;
+
+    /**
+     * @see IWifiDirectGroupClientListener::OnWifiDirectAllGroupMemberInfoReceivedN()
+     */
+    virtual void OnWifiDirectAllGroupMemberInfoReceivedN(const _WifiDirectEventArg& arg, result r) = 0;
+
+    /**
+     * @see IWifiDirectGroupOwnerListener::OnWifiDirectConnected()
+     */
+    virtual void OnWifiDirectConnected(const _WifiDirectEventArg& arg, result r) = 0;
+
+    /**
+     * @see IWifiDirectGroupClientListener::OnWifiDirectDisconnected()
+     */
+    virtual void OnWifiDirectDisconnected(const _WifiDirectEventArg& arg, result r) = 0;
+
+    /**
+     * @see IWifiDirectGroupClientListener::OnWifiDirectGroupLeft()
+     */
+    virtual void OnWifiDirectGroupLeft(const _WifiDirectEventArg& arg, result r) = 0;
+
+    /**
+     * @see IWifiDirectGroupClientListener::OnWifiDirectAutonomousGroupCreated()
+     */
+    virtual void OnWifiDirectAutonomousGroupCreated(const _WifiDirectEventArg& arg, result r) = 0;
+
+};
+
+} } } //Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_IWIFI_DIRECT_LISTENER_H_
+
diff --git a/src/inc/FNetWifi_IWifiManagerEventListener.h b/src/inc/FNetWifi_IWifiManagerEventListener.h
new file mode 100644 (file)
index 0000000..faa59b4
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_IWifiManagerEventListener.h
+ * @brief   This is the header file for the _IWifiManagerEventListener interface.
+ *
+ * This is the header file for the internal interface of wifi events.
+ *
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_IWIFI_MANAGER_EVENT_LISTENER_H_
+#define _FNET_WIFI_INTERNAL_IWIFI_MANAGER_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FOspConfig.h>
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+/**
+ * @interface   _IWifiManagerEventListener
+ * @brief       This interface implements listeners for WifiManager internal events.
+ * @since       1.0
+ */
+
+class _OSP_EXPORT_ _IWifiManagerEventListener:
+    public Tizen::Base::Runtime::IEventListener
+{
+
+public:
+   /**
+     * This polymorphic destructor should be overridden if required. This way, 
+     * the destructors of the derived classes are called when the destructor of this interface is called.
+     *
+     */
+    virtual ~_IWifiManagerEventListener(void) {}
+
+    /**
+     * @see IWifiManagerEventListener::OnWifiActivated()
+     */
+    virtual void OnWifiActivated(result r) = 0;
+
+    /**
+     * @see IWifiManagerEventListener::OnWifiDeactivated()
+     */
+    virtual void OnWifiDeactivated(result r) = 0;
+
+    /**
+     * @see IWifiManagerEventListener::OnWifiConnected()
+     */
+    virtual void OnWifiConnected(const Tizen::Base::String& ssid, result r) = 0;
+
+    /**
+     * @see IWifiManagerEventListener::OnWifiDisconnected()
+     */
+    virtual void OnWifiDisconnected(void) = 0;
+
+    /**
+     * @see IWifiManagerEventListener::OnWifiRssiChanged()
+     */
+    virtual void OnWifiRssiChanged(long rssi) = 0;
+
+    /**
+     * @see IWifiManagerEventListener::OnWifiScanCompletedN()
+     */
+    virtual void OnWifiScanCompletedN(Tizen::Base::Collection::IList* pWifiBssInfoList, result r) = 0;
+
+    /**
+     * @see IWifiSystemMonitoringEventListener::OnWifiConnectionStateChanged()
+     */
+    virtual void OnWifiConnectionStateChanged(WifiConnectionState state) = 0;
+
+    /**
+     * @see IWifiSystemMonitoringEventListener::OnWifiSystemScanResultUpdated()
+     */
+    virtual void OnWifiSystemScanResultUpdated(void) = 0;
+
+}; // _IWifiManagerEventListener
+
+} } } // Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_IWIFI_MANAGER_EVENT_LISTENER_H_
diff --git a/src/inc/FNetWifi_IWifiProximityEventListener.h b/src/inc/FNetWifi_IWifiProximityEventListener.h
new file mode 100644 (file)
index 0000000..cde097a
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_IProximityEventListener.h
+ * @brief   This is the header file for the _IProximityEventListener interface.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_IWIFI_PROXIMITY_EVENT_LISTENER_H_
+#define _FNET_WIFI_INTERNAL_IWIFI_PROXIMITY_EVENT_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FOspConfig.h>
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class WifiBssInfo;
+
+/**
+ * @interface   _IWifiManagerEventListener
+ * @brief       This interface implements listeners for WifiProximityManager internal events.
+ */
+
+class _OSP_EXPORT_ _IWifiProximityEventListener:
+    public Tizen::Base::Runtime::IEventListener
+{
+
+public:
+   /**
+     * This polymorphic destructor should be overridden if required. This way, 
+     * the destructors of the derived classes are called when the destructor of this interface is called.
+     *
+     */
+    virtual ~_IWifiProximityEventListener(void) {}
+
+    /**
+      * Called to notify the application that detected the registered MAC address for the proximity service.
+         *
+      * @param[in]   wifiBssInfo       The BSS info of detected AP
+      *
+      * @see         Tizen::Net::Wifi::_WifiProximityManagerImpl::AddProximityEventListener()
+      */
+    virtual void OnWifiBssDetectedN(Tizen::Net::Wifi::WifiBssInfo* pWifiBssInfo) = 0;
+
+    /**
+      * Called to notify the application that lost the registered MAC address for the proximity service.
+         *
+      * @param[in]   bssId     The MAC address of lost AP
+      *
+      * @see         Tizen::Net::Wifi::_WifiProximityManagerImpl::RemoveProximityEventListener()
+      */
+    virtual void OnWifiBssLost(const Tizen::Base::String& bssId) = 0;
+
+    /**
+      * Called to notify the application that the proximity service is activated.
+      *
+      * @see         Tizen::Net::Wifi::_WifiProximityManagerImpl::ActivateProximityCheck()
+      */
+    virtual void OnWifiProximityCheckActivated() = 0;
+
+    /**
+      * Called to notify the application that the proximity service is deactivated.
+      *
+      * @see         Tizen::Net::Wifi::_WifiProximityManagerImpl::DeactivateProximityCheck()
+      */
+    virtual void OnWifiProximityCheckDeactivated() = 0;
+
+}; // _IWifiProximityEventListener
+
+} } } // Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_IWIFI_PROXIMITY_EVENT_LISTENER_H_
diff --git a/src/inc/FNetWifi_WifiBssInfoImpl.h b/src/inc/FNetWifi_WifiBssInfoImpl.h
new file mode 100644 (file)
index 0000000..f37ab77
--- /dev/null
@@ -0,0 +1,333 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiBssInfoImpl.h
+ * @brief   This is the header file for the %_WifiBssInfoImpl class.
+ *
+ * This header file contains the declarations of the %_WifiBssInfoImpl class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_BSS_INFO_IMPL_H_
+#define _FNET_WIFI_INTERNAL_WIFI_BSS_INFO_IMPL_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+#include <FNetWifiWifiSecurityInfo.h>
+
+namespace Tizen { namespace Net {
+class IpAddress;
+} }
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+class WifiBssInfo;
+
+/**
+ * @class   _WifiBssInfoImpl
+ * @brief   This class provides the methods for managing the BSS information of a Wi-Fi network.
+ *
+ * This class provides the methods for managing the BSS information of a Wi-Fi network.
+ */
+class _OSP_EXPORT_ _WifiBssInfoImpl
+    : public Tizen::Base::Object
+{
+public:
+    /**
+     * This is the default constructor for this class.
+     *
+     * @since   1.0
+     */
+    _WifiBssInfoImpl(void);
+
+    /**
+     * This is the copy constructor for the _WifiBssInfoImpl class.
+     *
+     * @param[in]   value   An instance of %_WifiBssInfoImpl
+     */
+    _WifiBssInfoImpl(const _WifiBssInfoImpl& value);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     */
+    virtual ~_WifiBssInfoImpl(void);
+
+    /**
+     * @see WifiBssInfo::GetSsid()
+     */
+    Tizen::Base::String GetSsid(void) const;
+
+    /**
+     * @see WifiBssInfo::GetBssId()
+     */
+    Tizen::Base::String GetBssId(void) const;
+
+    /**
+     * @see WifiBssInfo::GetBssType()
+     */
+    WifiBssType GetBssType(void) const;
+
+    /**
+     * @see WifiBssInfo::GetRadioChannel()
+     */
+    WifiRadioChannel GetRadioChannel(void) const;
+
+    /**
+     * @see WifiBssInfo::GetSecurityInfo()
+     */
+    const WifiSecurityInfo* GetSecurityInfo(void) const;
+
+    /**
+     * @see WifiBssInfo::GetRssi()
+     */
+    long GetRssi(void) const;
+
+    /**
+     * @see WifiBssInfo::GetDataRate()
+     */
+    float GetDataRate(void) const;
+
+    /**
+     * Gets the Access Point handler
+     * @return  The pointer to wifi ap handler
+     */
+    void* GetBssHandle(void) const;
+
+    /**
+     * Allocates Instance of %WifiBssInfo.
+     *
+     * @since 2.1
+     * @return  WifiBssInfo
+     *
+     */
+    static WifiBssInfo* CreateWifiBssInfoN(void);
+
+    /**
+     * Sets the SSID of this BSS.
+     *
+     * @param[in]   ssid    The SSID
+     */
+    void SetSsid(const Tizen::Base::String& ssid);
+
+    /**
+     * Sets the ID of this BSS.
+     *
+     * @param[in]   bssId   The BSSID in the form '00-00-00-00-00-00'
+     */
+    void SetBssId(const Tizen::Base::String& bssid);
+
+    /**
+     * Sets the type of this BSS.
+     *
+     * @param[in]   bssType     The type of this BSS
+     */
+    void SetBssType(WifiBssType bssType);
+
+    /**
+     * Sets the radio channel of this BSS.
+     *
+     * @param[in]   channel     The radio channel of this BSS
+     */
+    void SetRadioChannel(WifiRadioChannel channel);
+
+    /**
+     * Sets the security information of this BSS.
+     *
+     * @param[in]   secuInfo    The authentication and encryption type of this BSS
+     */
+    void SetSecurityInfo(const WifiSecurityInfo& securityInfo);
+
+    /**
+     * Sets the Received Signal Strength Indication (RSSI) value of BSS at scanning time
+     *
+     * @param[in]   rssi    The RSSI value (dB)
+     */
+    void SetRssi(long rssi);
+
+    /**
+     * Sets the data rate of this BSS.
+     *
+     * @param[in]   dataRate    The data rate value (Mbps)
+     * @remarks     If the supported data rate is unknown, default value is @c -1.0.
+     */
+    void SetDataRate(float dataRate);
+
+    /**
+     * Sets the halder for wifi ap.
+     *
+     * @param[in]   apHandler    Handle to acces point
+     */
+    void SetBssHandle(void* apHandler);
+
+    /**
+     * @see WifiBssInfo::IsKnown()
+     */
+    bool IsKnown(void) const;
+
+    /**
+     * Sets the access point (BSS) is known or not.
+     *
+     * @param[in]   isKnown    @c true if the access point is known, @n
+     *                         else @c false
+     * @see WifiBssInfo::SetUnknown()
+     */
+    void SetKnown(bool isKnown);
+
+    /**
+     * @see WifiBssInfo::GetLocalAddressScheme()
+     */
+    Tizen::Net::NetAddressScheme GetLocalAddressScheme(void) const;
+
+    /**
+     * @see WifiBssInfo::SetLocalAddressScheme()
+     */
+    void SetLocalAddressScheme(Tizen::Net::NetAddressScheme scheme);
+
+    /**
+     * @see WifiBssInfo::GetLocalAddress()
+     */
+    const Tizen::Net::IpAddress* GetLocalAddress(void) const;
+
+    /**
+     * @see WifiBssInfo::SetLocalAddress()
+     */
+    result SetLocalAddress(const Tizen::Net::IpAddress* pAddress);
+
+    /**
+     * @see WifiBssInfo::GetSubnetMaskAddress()
+     */
+    const Tizen::Net::IpAddress* GetSubnetMaskAddress(void) const;
+
+    /**
+     * @see WifiBssInfo::SetSubnetMaskAddress()
+     */
+    result SetSubnetMaskAddress(const Tizen::Net::IpAddress* pAddress);
+
+    /**
+     * @see WifiBssInfo::GetDefaultGatewayAddress()
+     */
+    const Tizen::Net::IpAddress* GetDefaultGatewayAddress(void) const;
+
+    /**
+     * @see WifiBssInfo::SetDefaultGatewayAddress()
+     */
+    result SetDefaultGatewayAddress(const Tizen::Net::IpAddress* pAddress);
+
+    /**
+     * @see WifiBssInfo::GetPrimaryDnsAddress()
+     */
+    const Tizen::Net::IpAddress* GetPrimaryDnsAddress(void) const;
+
+    /**
+     * @see WifiBssInfo::SetPrimaryDnsAddress()
+     */
+    result SetPrimaryDnsAddress(const Tizen::Net::IpAddress* pAddress);
+
+    /**
+     * @see WifiBssInfo::GetSecondaryDnsAddress()
+     */
+    const Tizen::Net::IpAddress* GetSecondaryDnsAddress(void) const;
+
+    /**
+     * @see WifiBssInfo::SetSecondaryDnsAddress()
+     */
+    result SetSecondaryDnsAddress(const Tizen::Net::IpAddress* pAddress);
+
+    /**
+     * @see WifiBssInfo::GetProxyType()
+     */
+    Tizen::Net::NetProxyType GetProxyType(void) const;
+
+    /**
+     * @see WifiBssInfo::SetProxyType()
+     */
+    void SetProxyType(Tizen::Net::NetProxyType type);
+
+    /**
+     * @see WifiBssInfo::GetProxyAddress()
+     */
+    Tizen::Base::String GetProxyAddress(void) const;
+
+    /**
+     * @see WifiBssInfo::SetProxyAddress()
+     */
+    result SetProxyAddress(const Tizen::Base::String& address);
+
+    /**
+     * @see WifiBssInfo::Equals()
+     */
+    virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+    /**
+     * Gets the hash value of the current instance.
+     *
+     * @return   The hash value of the current instance
+     */
+    virtual int GetHashCode(void) const;
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @return  The pointer to %_WifiBssInfoImpl
+     * @param[in]   wifiBssInfo   An instance of %WifiBssInfo
+     */
+    static _WifiBssInfoImpl* GetInstance(WifiBssInfo& wifiBssInfo);
+    
+    /**
+     * Gets the Impl instance.
+     *
+     * @return  The pointer to %_WifiBssInfoImpl
+     * @param[in]   wifiBssInfo   An instance of %WifiBssInfo
+     */
+    static const _WifiBssInfoImpl* GetInstance(const WifiBssInfo& wifiBssInfo);
+
+    /**
+     * Copying of objects using this copy assignment operator is allowed.
+     *
+     * @return      The reference of this instance
+     * @param[in]   rhs   A reference to the %_WifiBssInfoImpl instance to be copied
+     */
+    _WifiBssInfoImpl& operator=(const _WifiBssInfoImpl& rhs);
+
+private:
+    Tizen::Base::String __ssid;
+    Tizen::Base::String __bssid;
+    WifiBssType __bssType;
+    WifiRadioChannel __channel;
+    WifiSecurityInfo __securityInfo;
+    long __rssi;
+    float __dataRate;
+    bool __isKnown;
+    Tizen::Net::NetAddressScheme __scheme;
+    Tizen::Net::IpAddress* __pLocalAddress;
+    Tizen::Net::IpAddress* __pMaskAddress;
+    Tizen::Net::IpAddress* __pGatewayAddress;
+    Tizen::Net::IpAddress* __pPriDnsAddress;
+    Tizen::Net::IpAddress* __pSecDnsAddress;
+    Tizen::Net::NetProxyType __proxyType;
+    Tizen::Base::String __proxyAddress;
+    void* __pApHandler;
+
+}; // _WifiBssInfoImpl
+
+} } } //Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_BSS_INFO_IMPL_H_
+
diff --git a/src/inc/FNetWifi_WifiDirectDeviceImpl.h b/src/inc/FNetWifi_WifiDirectDeviceImpl.h
new file mode 100644 (file)
index 0000000..ec46e29
--- /dev/null
@@ -0,0 +1,485 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectDeviceImpl.h
+ * @brief   This is the header file for the _WifiDirectDeviceImpl class.
+ * @version 2.0
+ *
+ * This header file contains declarations of the _WifiDirectDeviceImpl class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_DIRECT_DEVICE_IMPL_H_
+#define _FNET_WIFI_INTERNAL_WIFI_DIRECT_DEVICE_IMPL_H_
+
+// Includes
+#include <unique_ptr.h>
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+#include "FNetWifi_WifiDirectGroupOwnerImpl.h"
+#include "FNetWifi_WifiDirectGroupClientImpl.h"
+#include "FNetWifi_IWifiDirectListener.h"
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class IWifiDirectDeviceListener;
+class IWifiDirectGroupOwnerListener;
+class IWifiDirectGroupClientListener;
+class WifiDirectDevice;
+class WifiDirectDeviceInfo;
+class WifiDirectGroupInfo;
+class _WifiDirectSystemAdapter;
+class _WifiDirectDeviceEvent;
+class _WifiDirectGroupOwnerEvent;
+class _WifiDirectGroupClientEvent;
+class _WifiDirectEventArg;
+
+enum _WifiDirectDeviceState
+{
+   WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATED,
+   WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATING,
+   WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATING,
+   WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED,
+   WIFI_DIRECT_DEVICE_INTERNAL_CONNECTING,
+   WIFI_DIRECT_DEVICE_INTERNAL_CONNECT_CANCELLING,
+   WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER,
+   WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT,
+   WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING,
+   WIFI_DIRECT_DEVICE_INTERNAL_LEAVING,
+   WIFI_DIRECT_DEVICE_INTERNAL_GROUP_CREATING
+};
+
+
+enum _WifiDirectScanState
+{
+   WIFI_DIRECT_SCAN_INTERNAL_IDLE,
+   WIFI_DIRECT_SCAN_INTERNAL_SCANNING,
+   WIFI_DIRECT_SCAN_INTERNAL_CANCELLING
+};
+
+/**
+ * @class      _WifiDirectDeviceImpl
+ * @brief   This class provides methods for the Wi-Fi Direct management.
+ * @since      2.0
+ *
+ * WifiDirectDeviceImpl class provides the functionality for creating a WifiDirectDevice instance, and
+ * managing Wi-Fi Direct group. It also allows the listener to get events from Wi-Fi Direct group.
+ */
+
+class _OSP_EXPORT_ _WifiDirectDeviceImpl
+    : public Tizen::Base::Object
+    , public _IWifiDirectListener
+{
+public:
+
+    /**
+     * @see WifiDirectDevice::Construct()
+     */
+    result Construct(WifiDirectDeviceId localDeviceId, bool enableIpInfoService = true);
+
+    /**
+     * @see WifiDirectDevice::AddWifiDirectDeviceListener()
+     */
+       result AddWifiDirectDeviceListener(IWifiDirectDeviceListener &listener);
+
+    /**
+     * @see WifiDirectDevice::AddWifiDirectGroupOwnerListener()
+     */
+       result AddWifiDirectGroupOwnerListener(IWifiDirectGroupOwnerListener &listener);
+
+    /**
+     * @see WifiDirectDevice::AddWifiDirectGroupClientListener()
+     */
+       result AddWifiDirectGroupClientListener(IWifiDirectGroupClientListener &listener);
+
+    /**
+     * @see WifiDirectDevice::RemoveWifiDirectDeviceListener()
+     */
+       result RemoveWifiDirectDeviceListener(IWifiDirectDeviceListener &listener);
+
+    /**
+     * @see WifiDirectDevice::RemoveWifiDirectGroupOwnerListener()
+     */
+       result RemoveWifiDirectGroupOwnerListener(IWifiDirectGroupOwnerListener &listener);
+
+    /**
+     * @see WifiDirectDevice::RemoveWifiDirectGroupClientListener()
+     */
+       result RemoveWifiDirectGroupClientListener(IWifiDirectGroupClientListener &listener);
+
+    /**
+     * @see WifiDirectDevice::Activate()
+     */
+       result Activate(void);
+
+    /**
+     * @see WifiDirectDevice::Deactivate()
+     */
+       result Deactivate(void);
+
+    /**
+     * @see WifiDirectDevice::IsActivated()
+     */
+    bool IsActivated(void) const;
+
+    /**
+     * @see WifiDirectDevice::GetGroupSettingInfoN()
+     */
+       WifiDirectGroupInfo* GetGroupSettingInfoN(void) const;
+
+    /**
+     * @see WifiDirectDevice::GetLocalDeviceInfoN()
+     */
+       WifiDirectDeviceInfo* GetLocalDeviceInfoN(void) const;
+
+    /**
+     * @see WifiDirectDevice::GetWpsConfigurationModePreference()
+     */
+       WifiWpsConfigurationMode GetWpsConfigurationModePreference(void) const;
+
+    /**
+     * @see WifiDirectDevice::SetLocalDeviceName()
+     */
+       result SetLocalDeviceName(const Tizen::Base::String &name);
+
+    /**
+     * @see WifiDirectDevice::SetWpsConfigurationModePreference()
+     */
+       result SetWpsConfigurationModePreference(WifiWpsConfigurationMode mode);
+
+    /**
+     * @see WifiDirectDevice::CreateGroup()
+     */
+       result CreateGroup(const WifiDirectGroupInfo *pWifiDirectGroupInfo = null, const WifiDirectDeviceInfo *pWifiDirectRemoteDeviceInfo = null);
+
+    /**
+     * @see WifiDirectDevice::CancelGroupCreation()
+     */
+       result CancelGroupCreation(void);
+
+    /**
+     * @see WifiDirectDevice::Scan()
+     */
+       result Scan(void);
+
+    /**
+     * @see WifiDirectDevice::CancelScan()
+     */
+       result CancelScan(void);
+
+    /**
+     * @see WifiDirectDevice::Associate()
+     */
+       result Associate(const WifiDirectDeviceInfo &wifiDirectGroupOwnerDeviceInfo);
+
+    /**
+     * @see WifiDirectDevice::GetWifiDirectMemberN()
+     */
+       WifiDirectGroupMember* GetWifiDirectMemberN(void);
+
+    /**
+     * @see WifiDirectDevice::IsDiscoverable()
+     */
+       bool IsDiscoverable(void) const;
+
+       /**
+     * @see WifiDirectDevice::Connect()
+     */
+       result Connect(const WifiDirectDeviceInfo& peerDeviceInfo);
+
+       /**
+     * @see WifiDirectDevice::CancelConnect()
+     */
+       result CancelConnect(void);
+
+    /**
+     * @see WifiDirectDevice::CreateAutonomousGroup()
+     */
+       result CreateAutonomousGroup(void);
+
+    /**
+     * @see WifiDirectDevice::SetGroupSettingInfo()
+     */
+       result SetGroupSettingInfo(const WifiDirectGroupInfo& groupConfigurationInfo);
+
+    /**
+     * @see WifiDirectDevice::Disconnect()
+     */
+       result Disconnect(const WifiDirectDeviceInfo& remoteDeviceInfo);
+
+    /**
+     * @see WifiDirectDevice::LeaveGroup()
+     */
+       result LeaveGroup(void);
+
+    /**
+     * @see WifiDirectDevice::GetGroupOwnerInfo()
+     */
+       WifiDirectDeviceInfo* GetGroupOwnerInfoN(void) const;
+
+    /**
+     * @see WifiDirectDevice::GetGroupClientInfoListN()
+     */
+       Tizen::Base::Collection::IList* GetGroupClientInfoListN(void) const;
+
+       /**
+     * @see WifiDirectDevice::GetOperatingChannel()
+     */
+       WifiRadioChannel GetOperatingChannel(void) const;
+
+    /**
+     * Returns string representation of current status.
+     *
+     * @return      current status of wifi direct
+     */
+
+       const char* GetStringOfCurrentState(void) const;
+
+    /**
+     * Returns String representation of Current Status of Scan.
+     *
+     * @return      current scan status of wifi direct
+     */
+       const char* GetStringOfScanState(void) const;
+
+    /**
+     * Adds reference count.
+     *
+     * @return      current reference count
+     */
+       int AddRef(void);
+
+    /**
+     * Removes reference count.
+     *
+     * @return      current reference count
+     */
+       int Release(void);
+
+    /**
+     * returns current status of wifi direct
+     *
+     * @return      Wifi Direct Device Status
+     */
+    _WifiDirectDeviceState GetWifiDirectDeviceCurrentState(void) const;
+
+    /**
+     * Sets current status of wifi direct
+     *
+     * @param[in]    currentState Wifi Direct Device Status
+     */
+       void SetWifiDirectDeviceCurrentState(_WifiDirectDeviceState currentState);
+
+    /**
+     * Returns wifi direct group owner event object
+     *
+     * @return      Wifi Direct Group Owner event object
+     */
+       _WifiDirectGroupOwnerEvent* GetWifiDirectGroupOwnerEvent() const;
+
+    /**
+     * Returns wifi direct group client event object
+     *
+     * @return      Wifi Direct Group Client event object
+     */
+       _WifiDirectGroupClientEvent* GetWifiDirectGroupClientEvent() const;
+
+    /**
+     * Returns all device information
+     *
+     * @return      List of Device Information
+     */
+    static Tizen::Base::Collection::IList* GetAllDeviceInfoN(void);
+
+    /**
+     * Gets WifiDirectDeviceInstance, 
+     *   incase pDeviceInfo = null gets information of Default Device
+     *
+     * @return      Wifi Direct Device instance
+     * @param[in]   pDeviceInfo A pointer to WifiDirectDeviceInfo
+     */
+    static WifiDirectDevice* GetWifiDirectDeviceInstanceN(const WifiDirectDeviceInfo* pDeviceInfo = null);
+
+
+    /**
+     * Gets WifiDirectDeviceInstance
+     *
+     * @return      Wifi Direct Device instance
+     */
+    static WifiDirectDevice* GetWifiDirectDeviceInstanceWithoutIpServiceN(void);
+
+    /**
+     * Creates _WifiDirectDeviceImpl class instance 
+     *
+     * @return      The pointer to _WifiDirectDeviceImpl
+     */
+    static _WifiDirectDeviceImpl* CreateWifiDirectDeviceImplInstanceN(void);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @return  The pointer to %_WifiDirectDeviceImpl
+     * @param[in]   wifiDirectDevice   An instance of %WifiDirectDevice
+     */
+    static _WifiDirectDeviceImpl* GetInstance(WifiDirectDevice& wifiDirectDevice);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @return  The pointer to %_WifiDirectDeviceImpl
+     * @param[in]   wifiDirectDevice   An instance of %WifiDirectDevice
+     */
+    static const _WifiDirectDeviceImpl* GetInstance(const WifiDirectDevice& wifiDirectDevice);
+
+private:
+
+    /**
+     * This default constructor is intentionally declared as private so that only the platform can create an instance.
+     *
+     */
+    _WifiDirectDeviceImpl(void);
+
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in] rhs _WifiDirectDeviceImpl
+     */
+    _WifiDirectDeviceImpl(const _WifiDirectDeviceImpl& rhs);
+
+    /**
+     * 
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     */
+    virtual ~_WifiDirectDeviceImpl(void);
+
+    /**
+     * @see IWifiDirectDeviceListener::OnWifiDirectDeviceActivated()
+     */
+       void OnWifiDirectDeviceActivated(const _WifiDirectEventArg& arg, result r);
+
+    /**
+     * @see IWifiDirectDeviceListener::OnWifiDirectDeviceDeactivated()
+     */
+       void OnWifiDirectDeviceDeactivated(const _WifiDirectEventArg& arg, result r);
+
+    /**
+     * @see IWifiDirectDeviceListener::OnWifiDirectGroupCreatedN()
+     */
+       void OnWifiDirectGroupCreatedN(const _WifiDirectEventArg& arg, WifiDirectGroupMemberType wifiDirectMemberType, result r);
+
+    /**
+     * @see IWifiDirectDeviceListener::OnWifiDirectScanCompletedN()
+     */
+       void OnWifiDirectScanCompletedN(const _WifiDirectEventArg& arg, result r);
+
+    /**
+     * @see IWifiDirectDeviceListener::OnWifiDirectAssociationCompleted()
+     */
+       void OnWifiDirectAssociationCompleted(const _WifiDirectEventArg& arg, result r);
+
+    /**
+     * @see IWifiDirectDeviceListener::OnWifiDirectConnected()
+     */
+    void OnWifiDirectConnected(const _WifiDirectEventArg& arg, result r);
+
+    /**
+     * @see IWifiDirectDeviceListener::OnWifiDirectDisconnected()
+     */
+
+    void OnWifiDirectDisconnected(const _WifiDirectEventArg& arg, result r);
+
+    /**
+     * @see IWifiDirectDeviceListener::OnWifiDirectGroupLeft()
+     */
+    void OnWifiDirectGroupLeft(const _WifiDirectEventArg& arg, result r);
+
+    /**
+     * @see IWifiDirectDeviceListener::OnWifiDirectAutonomousGroupCreated()
+     */
+    void OnWifiDirectAutonomousGroupCreated(const _WifiDirectEventArg& arg, result r);
+
+
+    /**
+     * @see IWifiDirectGroupOwnerListener::OnWifiDirectAssociationCompleted()
+     */
+       void OnWifiDirectClientAssociated(const _WifiDirectEventArg& arg);
+
+    /**
+     * @see IWifiDirectGroupOwnerListener::OnWifiDirectClientDisassociated()
+     */
+       void OnWifiDirectClientDisassociated(const _WifiDirectEventArg& arg, WifiDirectAssociationTerminationReason reason);
+
+    /**
+     * @see IWifiDirectGroupOwnerListener::OnWifiDirectGroupDestroyed()
+     */
+       void OnWifiDirectGroupDestroyed(const _WifiDirectEventArg& arg, result r);
+
+    /**
+     * @see IWifiDirectGroupClientListener::OnWifiDirectAssociationTerminated()
+     */
+
+       void OnWifiDirectAssociationTerminated(const _WifiDirectEventArg& arg, result r);
+
+    /**
+     * @see IWifiDirectGroupClientListener::OnWifiDirectGroupOwnerInfoReceived()
+     */
+       void OnWifiDirectGroupOwnerInfoReceived(const _WifiDirectEventArg& arg, result r);
+
+    /**
+     * @see IWifiDirectGroupClientListener::OnWifiDirectAllGroupMemberInfoReceivedN()
+     */
+       void OnWifiDirectAllGroupMemberInfoReceivedN(const _WifiDirectEventArg& arg, result r);
+
+    /**
+     *
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in] rhs An instance of %_WifiDirectDeviceImpl
+     */
+       _WifiDirectDeviceImpl& operator =(const _WifiDirectDeviceImpl& rhs);
+
+private:
+    WifiDirectDeviceId  __localDeviceId;
+
+    std::unique_ptr<_WifiDirectDeviceEvent> __pWifiDirectDeviceEvent;
+    std::unique_ptr<_WifiDirectGroupOwnerEvent> __pWifiDirectGroupOwnerEvent;
+    std::unique_ptr<_WifiDirectGroupClientEvent> __pWifiDirectGroupClientEvent;
+
+    _WifiDirectGroupOwnerImpl __groupOwnerImpl;
+    _WifiDirectGroupClientImpl __groupClientImpl;
+
+       _WifiDirectDeviceState __deviceState;
+       _WifiDirectScanState __scanState;
+
+    _WifiDirectSystemAdapter* __pWifiDirectSystemAdapter;
+
+       int __refCount;
+    Tizen::Base::Runtime::Mutex __stateMutex;
+    friend class std::default_delete<_WifiDirectDeviceImpl>;
+}; // _WifiDirectDeviceImpl
+} } } // Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_DIRECT_DEVICE_IMPL_H_
+
+
diff --git a/src/inc/FNetWifi_WifiDirectDeviceInfoImpl.h b/src/inc/FNetWifi_WifiDirectDeviceInfoImpl.h
new file mode 100644 (file)
index 0000000..68ca3e6
--- /dev/null
@@ -0,0 +1,331 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file  FNetWifi_WifiDirectDeviceInfoImpl.h
+ * @brief This is the header file for the _WifiDirectDeviceInfoImpl class.
+ *
+ * This header file contains the declarations of the _WifiDirectDeviceInfoImpl Class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_DIRECT_DEVICE_INFO_IMPL_H_
+#define _FNET_WIFI_INTERNAL_WIFI_DIRECT_DEVICE_INFO_IMPL_H_
+
+// Includes
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FNetIpAddress.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+template <class type>
+class IListT;
+}}}
+
+namespace Tizen {      namespace Net
+{
+class IpAddress;
+
+namespace Wifi
+{
+class WifiDirectDeviceInfo;
+
+/**
+ * @class   _WifiDirectDeviceInfoImpl
+ * @brief   This class provides methods for the Wi-Fi Direct device information.
+ * @since   2.0
+ *
+ * This class provides methods for getting information related to a Wi-Fi Direct device.
+ */
+
+class _OSP_EXPORT_ _WifiDirectDeviceInfoImpl
+    : public Tizen::Base::Object
+{
+
+public:
+
+    /**
+     * This is the default constructor for this class.
+     *
+     * @since 2.0
+     */
+    _WifiDirectDeviceInfoImpl(void);
+
+    /**
+     * This is the copy constructor for this class.
+     *
+     * @since 2.0
+     *
+     * @param[in]   rhs   An instance of %WifiDirectDeviceInfo
+     */
+    _WifiDirectDeviceInfoImpl(const _WifiDirectDeviceInfoImpl& rhs);
+
+    /**
+     * Initializes this instance of WifiDirectDeviceInfo with the specified device name
+     * and the MAC address.
+     *
+     * @since 2.0
+     * @param[in]   deviceName  The device name @n
+     *                          The length of @c deviceName should not exceed 64 characters
+     * @param[in]   macAddr     The MAC address @n
+     *                          The value of @c macAddr should be in the form '00-00-00-00-00-00'
+     *
+     */
+    _WifiDirectDeviceInfoImpl(const Tizen::Base::String& deviceName, const Tizen::Base::String& macAddr);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     * @since 2.0
+     */
+    virtual ~_WifiDirectDeviceInfoImpl(void);
+
+    /**
+     * @see WifiDirectDeviceInfo::GetDeviceId()
+     */
+    WifiDirectDeviceId GetDeviceId(void) const;
+
+    /**
+     * @see WifiDirectDeviceInfo::GetDeviceName()
+     */
+    Tizen::Base::String GetDeviceName(void) const;
+
+    /**
+     * @see WifiDirectDeviceInfo::GetMacAddress()
+     */
+    Tizen::Base::String GetMacAddress(void) const ;
+
+    /**
+     * @see WifiDirectDeviceInfo::GetIpAddress()
+     */
+    const Tizen::Net::IpAddress *GetIpAddress(void) const;
+
+    /**
+     * @see WifiDirectDeviceInfo::GetSsid()
+     */
+    Tizen::Base::String GetSsid(void) const;
+    
+    /**
+     * @see WifiDirectDeviceInfo::GetDeviceStatus()
+     */
+    WifiDirectDeviceStatus GetDeviceStatus(void) const;
+
+    /**
+     * @see WifiDirectDeviceInfo::GetGroupMemberType()
+     */
+    WifiDirectGroupMemberType GetGroupMemberType(void) const;
+
+    /**
+     * @see WifiDirectDeviceInfo::GetDeviceTypeCategory()
+     */
+    WifiDirectDeviceTypeCategory GetDeviceTypeCategory(void) const;
+
+    /**
+     * @see WifiDirectDeviceInfo::GetSupportedWpsConfigurationModeList()
+     */
+    const Tizen::Base::Collection::IListT<WifiWpsConfigurationMode>* GetSupportedWpsConfigurationModeList(void) const;
+
+    /**
+     * @see WifiDirectDeviceInfo::GetVirtualMacAddress()
+     */
+    Tizen::Base::String GetVirtualMacAddress(void) const;
+
+    /**
+     * Sets the ID of the device.
+     *
+     * @param[in]    localDeviceId       Device ID
+     */
+    void SetDeviceId(const WifiDirectDeviceId localDeviceId);
+
+    /**
+     * Sets the device name.
+     *
+     * @return       An error code
+     * @param[in]    deviceName          String of Device Name
+     * @exception    E_SUCCESS           The method was successful.
+     * @exception    E_INVALID_ARG       A specified input parameter is invalid.
+     *
+     */
+    result SetDeviceName(const Tizen::Base::String& deviceName);
+
+    /**
+     * Sets the mac address.
+     *
+     * @return       An error code
+     * @param[in]    macAddress          String of MacAddress in format "00-00-00-00-00-00"
+     * @exception    E_SUCCESS           The method was successful.
+     * @exception    E_INVALID_ARG       A specified input parameter is invalid.
+     *
+     */
+    result SetMacAddress(const Tizen::Base::String& macAddress);
+
+    /**
+     * Sets the virtual mac address.
+     *
+     * @return       An error code
+     * @param[in]    macAddress          String of MacAddress in format "00-00-00-00-00-00"
+     * @exception    E_SUCCESS           The method was successful.
+     * @exception    E_INVALID_ARG       A specified input parameter is invalid.
+     *
+     */
+    result SetVirtualMacAddress(const Tizen::Base::String& macAddress);
+
+    /**
+     * Sets the ip address.
+     *
+     * @return       An error code
+     * @param[in]    ipAddress           String of ipaddress
+     * @exception    E_SUCCESS           The method was successful.
+     * @exception    E_OUT_OF_MEMORY     Memory Allocation failure or invalid input.
+     *
+     */
+    result SetIpAddress(const Tizen::Base::String& ipAddress);
+
+    /**
+     * Sets the SSID (Service Set Identifier).
+     *
+     * @return       An error code
+     * @param[in]    ssid                String of SSID
+     * @exception    E_SUCCESS           The method was successful.
+     * @exception    E_INVALID_ARG       A specified input parameter is invalid.
+     *
+     */
+    result SetSsid(const Tizen::Base::String& ssid);
+
+    /**
+     * Sets the device status.
+     *
+     * @param[in]    deviceStatus        Device status
+     *
+     */
+    void SetDeviceStatus(const WifiDirectDeviceStatus& deviceStatus);
+
+    /**
+     * Sets the group member type.
+     *
+     * @param[in]    groupMemberType     Group Member Type
+     *
+     */
+    void SetGroupMemberType(const WifiDirectGroupMemberType& groupMemberType);
+
+    /**
+     * Sets the device type category.
+     *
+     * @param[in]    deviceTypeCategory  Device Type Category
+     *
+     */
+    void SetDeviceTypeCategory(const WifiDirectDeviceTypeCategory& deviceTypeCategory);
+
+    /**
+     * Sets the wps mode.
+     *
+     * @param[in]    wpsConfigurationModeList    List of supported WPS Mode.
+     *
+     */
+    void SetSupportedWpsConfigurationMode( const Tizen::Base::Collection::IListT<WifiWpsConfigurationMode>& wpsConfigurationModeList );
+
+    /**
+     * Sets the disconnected flag.
+     *
+     * @param[in]    value               Flag value
+     *
+     */
+    void SetDisconnect(bool value);
+
+    /**
+     * Gets the disconnected flag value.
+     *     
+     */
+    bool IsDisconnecting(void);
+
+    /**
+     * @see WifiDirectDeviceInfo::Equals()
+     */
+    virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+    /**
+     * @see WifiDirectDeviceInfo::GetHashCode()
+     */
+    virtual int GetHashCode(void) const;
+
+    /**
+     * Sets the ssid for wifiDirectDeviceInfo object.
+     *
+     * @param[in]    wifiDirectDeviceInfo Wifi Direct Device Info object
+     * @param[in]    ssid            String of ssid
+     *
+     */
+    static void SetSsidOfWifiDirectDeviceInfo(WifiDirectDeviceInfo& wifiDirectDeviceInfo, const Tizen::Base::String& ssid);
+
+    /**
+     * Creates WifiDirectDeviceInfo object from impl object
+     *
+     * @param[in]    wifiDirectDeviceInfoImpl Wifi Direct Device Info Impl Object
+     *
+     */
+    static WifiDirectDeviceInfo* GetWifiDirectDeviceInfoInstanceN(_WifiDirectDeviceInfoImpl& wifiDirectDeviceInfoImpl);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return  The pointer to %_WifiDirectDeviceInfoImpl
+     * @param[in]   wifiDirectDeviceInfo   An instance of %wifiDirectDeviceInfo
+     */
+    static _WifiDirectDeviceInfoImpl* GetInstance(WifiDirectDeviceInfo& wifiDirectDeviceInfo);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return  The pointer to %_WifiDirectDeviceInfoImpl
+     * @param[in]   wifiDirectDeviceInfo   An instance of %wifiDirectDeviceInfo
+     */
+    static const _WifiDirectDeviceInfoImpl* GetInstance(const WifiDirectDeviceInfo& wifiDirectDeviceInfo);
+    
+    /**
+     * @see WifiDirectDeviceInfo::operator=()
+     */
+    _WifiDirectDeviceInfoImpl& operator =(const _WifiDirectDeviceInfoImpl& rhs);
+
+    /**
+     * Prints the device information (Only for debugging purpose)
+     *
+     * @param[in]    wifiDirectDeviceInfo Device information
+     *
+     */
+    static void PrintDeviceInfo( const _WifiDirectDeviceInfoImpl& wifiDirectDeviceInfo);
+
+private:
+    WifiDirectDeviceId __localDeviceId;
+    Tizen::Base::String __deviceName;
+    Tizen::Base::String __macAddress;
+    Tizen::Base::String __virtualMacAddress;
+    Tizen::Base::String __ssid;
+    Tizen::Net::IpAddress* __pIpAddress;
+    WifiDirectDeviceStatus __deviceStatus;
+    WifiDirectGroupMemberType __groupMemberType;
+    WifiDirectDeviceTypeCategory __deviceTypeCategory;
+    Tizen::Base::Collection::ArrayListT<WifiWpsConfigurationMode> __wpsConfigurationModeList;
+    bool __isDisconnecting;
+}; // _WifiDirectDeviceInfoImpl
+
+} } }// Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_DIRECT_DEVICE_INFO_IMPL_H_
+
+
diff --git a/src/inc/FNetWifi_WifiDirectDeviceManagerImpl.h b/src/inc/FNetWifi_WifiDirectDeviceManagerImpl.h
new file mode 100644 (file)
index 0000000..111ec3e
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectDeviceManagerImpl.h
+ * @brief   This is the header file for the %_WifiDirectDeviceManagerImpl class.
+ *
+ * This header file contains the declarations of the %_WifiDirectDeviceManagerImpl class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_DIRECT_DEVICE_MANAGER_IMPL_H_
+#define _FNET_WIFI_INTERNAL_WIFI_DIRECT_DEVICE_MANAGER_IMPL_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Tizen {      namespace Net { namespace Wifi
+{
+class WifiDirectDeviceManager;
+class WifiDirectDevice;
+class WifiDirectDeviceInfo;
+
+/**
+ * @class  _WifiDirectDeviceManagerImpl
+ * @brief  This class provides methods for the Wi-Fi Direct Device management.
+ * @since 2.0
+ *
+ * _WifiDirectDeviceManagerImpl class provides the functionality for creating a _WifiDirectDeviceManagerImpl instance, and
+ * managing Wi-Fi Direct group. It also allows the listener to get events from Wi-Fi Direct group.
+ */
+
+class _OSP_EXPORT_ _WifiDirectDeviceManagerImpl
+    : public Tizen::Base::Object
+{
+public:
+
+    /**
+     * This is the default constructor for this class.
+     *
+     * @since 2.0
+     */
+    _WifiDirectDeviceManagerImpl(void);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     * @since 2.0
+     */
+    virtual ~_WifiDirectDeviceManagerImpl(void);
+
+    /**
+     * @see WifiDirectDeviceManager::GetAllDeviceInfoN()
+     */
+    static Tizen::Base::Collection::IList* GetAllDeviceInfoN(void);
+
+    /**
+     * @see WifiDirectDeviceManager::GetWifiDirectDeviceN()
+     */
+    static WifiDirectDevice* GetWifiDirectDeviceN(const WifiDirectDeviceInfo* pLocalDeviceInfo = null);
+
+    /**
+     * Gets the Impl instance.
+     *
+     *
+     * @since 2.1
+     * @return  The pointer to %_WifiDirectDeviceManagerImpl
+     * @param[in]   wifiDirectDeviceManager   An instance of %WifiDirectDeviceManager
+     */
+    static _WifiDirectDeviceManagerImpl* GetInstance(WifiDirectDeviceManager& wifiDirectDeviceManager);
+
+    /**
+     * Gets the Impl instance.
+     *
+     *
+     * @since 2.1
+     * @return  The pointer to %_WifiDirectDeviceManagerImpl
+     * @param[in]   wifiDirectDeviceManager   An instance of %WifiDirectDeviceManager
+     */
+    static const _WifiDirectDeviceManagerImpl* GetInstance(const WifiDirectDeviceManager& wifiDirectDeviceManager);
+
+private:
+    /**
+     * @see WifiDirectDeviceManager::WifiDirectDeviceManager()
+     */
+    _WifiDirectDeviceManagerImpl(const _WifiDirectDeviceManagerImpl& value);
+
+    /**
+     * @see WifiDirectDeviceManager::operator =()
+     */
+    _WifiDirectDeviceManagerImpl& operator =(const _WifiDirectDeviceManagerImpl& rhs);
+}; // _WifiDirectDeviceManagerImpl
+
+} } }// Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_DIRECT_DEVICE_MANAGER_IMPL_H_
+
diff --git a/src/inc/FNetWifi_WifiDirectGroupClientImpl.h b/src/inc/FNetWifi_WifiDirectGroupClientImpl.h
new file mode 100644 (file)
index 0000000..834c09f
--- /dev/null
@@ -0,0 +1,394 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectGroupClientImpl.h
+ * @brief   This is the header file for the WifiDirectClientImpl class.
+ *
+ * This header file contains declaration of the  WifiDirectClientImpl class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_CLIENT_IMPL_H_
+#define _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_CLIENT_IMPL_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+#include <FNetINetConnectionEventListener.h>
+#include <FNetSockISocketEventListener.h>
+#include <FNetWifi_WifiDirectUtility.h>
+
+namespace Tizen {      namespace Net
+{
+class NetConnection;
+class IpAddress;
+class Ip4Address;
+
+namespace Wifi
+{
+class WifiDirectDeviceInfo;
+class WifiDirectGroupClient;
+class _WifiDirectDeviceImpl;
+class _WifiDirectSystemAdapter;
+
+enum _WifiDirectMemberInfoRequestStateType
+{
+    WIFI_DIRECT_DEVICE_INFO_REQUEST_READY,
+    WIFI_DIRECT_OWNER_INFO_REQUEST,
+    WIFI_DIRECT_MEMBER_INFO_REQUEST,
+    WIFI_DIRECT_OWNER_INFO_REQUEST_SENT,
+    WIFI_DIRECT_MEMBER_INFO_REQUEST_SENT
+};
+
+/**
+ * @class      _WifiDirectGroupClientImpl
+ * @brief   This class provides methods for the Wi-Fi Direct group client management.
+ * @since      2.0
+ *
+ * WifiDirectClient class provides the functionality for creating a WifiDirectClient instance, and
+ * a managing Wi-Fi Direct client. It also allows the listener to get events from Wi-Fi Direct client.
+ */
+
+class _OSP_EXPORT_ _WifiDirectGroupClientImpl
+    : public Tizen::Base::Object
+    , virtual public Tizen::Net::INetConnectionEventListener
+    , virtual public Tizen::Net::Sockets::ISocketEventListener
+    , virtual public Tizen::Base::Runtime::ITimerEventListener
+{
+public:
+    
+    /**
+     * 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.
+     *
+     */
+    _WifiDirectGroupClientImpl(void);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     */
+    virtual ~_WifiDirectGroupClientImpl(void);
+
+    /**
+     * @see WifiDirectGroupClient::Construct()
+     */
+    result Construct(WifiDirectDeviceId localDeviceId, _WifiDirectDeviceImpl& wifiDirectDeviceImpl, bool enableIpInfoService = true);
+
+    /**
+     * @see WifiDirectGroupClient::Disassociate()
+     */
+    result Disassociate(void);
+
+    /**
+     * @see WifiDirectGroupClient::RequestGroupOwnerInfo()
+     */
+    result RequestGroupOwnerInfo(int portNumber);
+
+    /**
+     * @see WifiDirectGroupClient::RequestAllGroupMemberInfo()
+     */
+    result RequestAllGroupMemberInfo(int portNumber);
+
+    /**
+     * Clean Sockets, closes socket and releases memory for that.
+     *
+     */
+    void CleanUpServerSocket(void);
+
+    /**
+     * Adds reference count for object
+     *
+     * @return   current reference count
+     */
+    int AddRef(void);
+
+    /**
+     * Decreases reference count for object
+     *
+     * @return   current reference count
+     */
+    int Release(void);
+
+    /**
+     * Creates WifiDirectGroupClient instance from _WifiDirectGroupClientImpl
+     *
+     * @return   WifiDirectGroupClient instance
+     * @param[in]   groupClientImpl to An instance of %_WifiDirectGroupClientImpl
+     */
+    static WifiDirectGroupClient* GetWifiDirectGroupClientInstanceN( _WifiDirectGroupClientImpl &groupClientImpl );
+
+    /**
+     * Create Net Connection for Info Service
+     *
+     * @return       An error code
+     *
+     * @exception    E_SUCCESS               The method was successful.
+     * @exception    E_SYSTEM                A system error occurred.
+     * @exception    E_OUT_OF_MEMORY         Failed to Allocated required memory
+     *
+     */
+    result CreateNetConnection(void);
+
+    /**
+     * Sends request for Group Member Info
+     *
+     * @return       An error code
+     *
+     * @param[in]    messageType             It can be info or request for all member of owner info
+     * @exception    E_SUCCESS               The method was successful.
+     * @exception    E_SYSTEM                A system error occurred.
+     * @exception    E_OUT_OF_MEMORY         Failed to Allocated required memory
+     *
+     */
+    result SendRequestGroupMemberInfoMessage(_WIFIDIRECT_MESSAGE_TYPE messageType);
+
+    /**
+     * Starts socket server
+     *
+     * @return       An error code
+     *
+     * @exception    E_SUCCESS               The method was successful.
+     * @exception    E_ALREADY_BOUND         Socket Already Bound
+     * @exception    E_SYSTEM                A system error occurred.
+     * @exception    E_OUT_OF_MEMORY         Failed to Allocated required memory
+     *
+     */
+    result StartSocketServer(void);
+
+    /**
+     * Parse message from given buffer
+     *
+     * @return       List of Parsed data
+     *
+     * @param[in]   messageType  Type of Message
+     * @param[in]   message      data to be parsed
+     *
+     */
+    Tizen::Base::Collection::IList* ParsingMessageN(_WIFIDIRECT_MESSAGE_TYPE messageType, const Tizen::Base::String& message);
+
+    /**
+     * Generates wifi direct device info
+     *
+     * @return       WifiDirectDeviceInfo
+     *     
+     * @param[in]   message       data to be parsed
+     * @param[in]   currentIndex  Current index in data stream
+     *
+     */
+    WifiDirectDeviceInfo* GenerateWifiDirectDeviceInfoN(const Tizen::Base::String& message, int& currentIndex);
+
+    /**
+     * Provides device name
+     *
+     * @return       String
+     *     
+     * @param[in]   currentIndex  Current index in data stream
+     * @param[in]   message       data to be parsed
+     *
+     */
+    Tizen::Base::String Message2String(int& currentIndex, const Tizen::Base::String& message );
+
+    /**
+     * Provides device name with length
+     *
+     * @return       String
+     *     
+     * @param[in]   currentIndex  Current index in data stream
+     * @param[in]   message       data to be parsed
+     *
+     */
+    Tizen::Base::String MessageWithLength2String(int& currentIndex, const Tizen::Base::String& message );
+
+    /**
+     * Starts retry timer
+     *
+     * @return       An error code
+     *
+     * @exception    E_SUCCESS               The method was successful.
+     * @exception    E_SYSTEM                A system error occurred.
+     * @exception    E_OUT_OF_MEMORY         Failed to Allocated required memory
+     * @exception    E_INVALID_ARG           The specified input parameter is invalid.
+     * @exception    E_INVALID_STATE         The state of the timer is not valid.
+     *
+     */
+    result StartTimer(void);
+
+    /**
+     * Stops retry timer
+     *
+     * @return       An error code
+     *
+     * @exception    E_SUCCESS               The method was successful.
+     * @exception    E_SYSTEM                A system error occurred.
+     * @exception    E_INVALID_STATE         The state of the timer is not valid.
+     *
+     */
+    result StopTimer(void);
+
+    /**
+     * Returns retry count
+     *
+     * @return       Retry Count
+     *
+     */
+    int GetRetryCount(void);
+
+    /**
+     * Increases retry count by one
+     *
+     */
+    void UpdateRetryCount(void);
+
+    /**
+     * Sets retry count to zero
+     *
+     */
+    void ResetRetryCount(void);
+
+    /**
+     * Request info service process
+     *
+     * @return       An error code
+     *
+     * @param[in]    requestType             Type of Request
+     * @param[in]    portNumber              Port Number of service
+     * @exception    E_SUCCESS               The method was successful.
+     * @exception    E_SYSTEM                A system error occurred.
+     * @exception    E_OUT_OF_MEMORY         Failed to Allocated required memory
+     * @exception    E_OUT_OF_RANGE          Port Number out of rangec
+     * @exception    E_INVALID_OPERATION     Invalid Device state
+     * @exception    E_IN_PROGRESS           Info Request in progress
+     *
+     */
+    result RequestInfoProcess(_WifiDirectMemberInfoRequestStateType requestType, int portNumber);
+
+    /**
+     * Get char string of current status
+     *
+     * @return       char*
+     *
+     */
+    const char* GetStringOfCurrentState(void) const;
+
+    /**
+     * Gets the impl instance.
+     *
+     * @since 2.1
+     * @return  The pointer to %_WifiDirectGroupClientImpl
+     * @param[in]   wifiDirectGroupClient   An instance of %WifiDirectGroupClient
+     */
+    static _WifiDirectGroupClientImpl* GetInstance(WifiDirectGroupClient& wifiDirectGroupClient);
+
+    /**
+     * Gets the impl instance.
+     *
+     * @since 2.1
+     * @return  The pointer to %_WifiDirectGroupClientImpl
+     * @param[in]   wifiDirectGroupClient   An instance of %WifiDirectGroupClient
+     */
+    static const _WifiDirectGroupClientImpl* GetInstance(const WifiDirectGroupClient& wifiDirectGroupClient);
+
+private:
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @since 2.1
+     *
+     * @param[in] rhs _WifiDirectGroupClientImpl
+     */
+    _WifiDirectGroupClientImpl(const _WifiDirectGroupClientImpl& value);
+
+    /**
+     * @see Tizen::Net::INetConnectionEventListener::OnNetConnectionStarted()
+     */
+    void OnNetConnectionStarted(Tizen::Net::NetConnection& netConnection, result r);
+
+    /**
+     * @see Tizen::Net::INetConnectionEventListener::OnNetConnectionStopped()
+     */
+    void OnNetConnectionStopped(Tizen::Net::NetConnection& netConnection, result r);
+
+
+    /**
+     * @see Tizen::Net::INetConnectionEventListener::OnNetConnectionSuspended()
+     */
+    void OnNetConnectionSuspended(Tizen::Net::NetConnection& netConnection) {}
+
+    /**
+     * @see Tizen::Net::INetConnectionEventListener::OnNetConnectionResumed()
+     */
+    void OnNetConnectionResumed(Tizen::Net::NetConnection& netConnection) {}
+
+    /**
+     * @see Tizen::Net::Sockets::ISocketEventListener::OnSocketConnected()
+     */
+    void OnSocketConnected(Tizen::Net::Sockets::Socket& socket) {}
+
+    /**
+     * @see Tizen::Net::Sockets::ISocketEventListener::OnSocketClosed()
+     */
+    void OnSocketClosed(Tizen::Net::Sockets::Socket& socket, Tizen::Net::Sockets::NetSocketClosedReason reason){}
+
+    /**
+     * @see Tizen::Net::Sockets::ISocketEventListener::OnSocketReadyToReceive()
+     */
+    void OnSocketReadyToReceive(Tizen::Net::Sockets::Socket& socket);
+
+    /**
+     * @see Tizen::Net::Sockets::ISocketEventListener::OnSocketReadyToSend()
+     */
+    void OnSocketReadyToSend(Tizen::Net::Sockets::Socket& socket){}
+
+    /**
+     * @see Tizen::Net::Sockets::ISocketEventListener::OnSocketAccept()
+     */
+    void OnSocketAccept(Tizen::Net::Sockets::Socket& socket){}
+    
+    /**
+     * @see Tizen::Base::Runtime::ITimerEventListener::OnTimerExpired()
+     */
+    void OnTimerExpired(Tizen::Base::Runtime::Timer &timer);
+
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in] rhs An instance of %_WifiDirectGroupClientImpl
+     */
+    _WifiDirectGroupClientImpl& operator =(const _WifiDirectGroupClientImpl& rhs);
+
+private:
+    static const int DEFAULT_PORT = 3895;
+    WifiDirectDeviceId __localDeviceId;
+    _WifiDirectDeviceImpl* __pWifiDirectDeviceImpl;
+    _WifiDirectSystemAdapter* __pWifiDirectSystemAdapter;
+
+    Tizen::Net::NetConnection* __pNetConnection;
+    Tizen::Net::Sockets::Socket* __pClientSocket;
+    const Tizen::Net::IpAddress* __pLocalIpAddress;
+    int __portNumber;
+    int __refCount;
+
+    _WifiDirectMemberInfoRequestStateType __currentState;
+    Tizen::Base::Runtime::Timer __retryTimer;
+    Tizen::Base::Runtime::Mutex        __stateMutex;
+    int __retryCount;
+}; // _WifiDirectGroupClientImpl
+} } } // Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_CLIENT_IMPL_H_
+
diff --git a/src/inc/FNetWifi_WifiDirectGroupInfoImpl.h b/src/inc/FNetWifi_WifiDirectGroupInfoImpl.h
new file mode 100644 (file)
index 0000000..960daf9
--- /dev/null
@@ -0,0 +1,220 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file  FNetWifi_WifiDirectGroupInfoImpl.h
+ * @brief This is the header file for the _WifiDirectGroupInfoImpl class.
+ *
+ * This header file contains the declarations of the _WifiDirectGroupInfoImpl Class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_INFO_IMPL_H_
+#define _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_INFO_IMPL_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen {      namespace Net { namespace Wifi
+{
+class WifiDirectGroupInfo;
+
+/**
+ * @class      _WifiDirectGroupInfoImpl
+ * @brief   This class provides methods for the Wi-Fi Direct group.
+ * @since      2.0
+ *
+ * WifiDirectGroupInfo class provides the functionality for getting or setting information on a Wi-Fi Direct group.
+ */
+
+class _OSP_EXPORT_ _WifiDirectGroupInfoImpl
+    : public Tizen::Base::Object
+{
+public:
+
+    /**
+     * This is the default constructor for this class.
+     *
+     * @since   2.0
+     */
+    _WifiDirectGroupInfoImpl(void);
+
+    /**
+     * Copying of objects using this copy constructor is allowed.
+     *
+     * @since   2.0
+     *
+     * @param[in]   value   An instance of %_WifiDirectGroupInfoImpl
+     */
+    _WifiDirectGroupInfoImpl(const _WifiDirectGroupInfoImpl& value);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     * @since   2.0
+     */
+    virtual ~_WifiDirectGroupInfoImpl(void);
+
+    /**
+     * @see WifiDirectGroupInfo::GetAutonomousGroupOwnerMode()
+     */
+    bool GetAutonomousGroupOwnerMode(void) const;
+
+    /**
+     * @see WifiDirectGroupInfo::GetHiddenMode()
+     */
+    bool GetHiddenMode(void) const;
+
+    /**
+     * @see WifiDirectGroupInfo::GetGroupOwnerIntent()
+     */
+    int GetGroupOwnerIntent(void) const;
+
+    /**
+     * @see WifiDirectGroupInfo::GetMaxNumberOfClients()
+     */
+    int GetMaxNumberOfClients(void) const;
+
+    /**
+     * @see WifiDirectGroupInfo::GetSsid()
+     */
+    Tizen::Base::String GetSsid(void) const;
+
+    /**
+     * @see WifiDirectGroupInfo::GetBssId()
+     */
+    Tizen::Base::String GetBssId(void) const;
+
+    /**
+     * @see WifiDirectGroupInfo::GetOperatingChannel()
+     */
+    WifiRadioChannel GetOperatingChannel(void) const;
+
+    /**
+     * @see WifiDirectGroupInfo::SetAutonomousGroupOwnerMode()
+     */
+    void SetAutonomousGroupOwnerMode(bool mode);
+
+    /**
+     * @see WifiDirectGroupInfo::SetHiddenMode()
+     */
+    void SetHiddenMode(bool mode);
+
+    /**
+     * @see WifiDirectGroupInfo::SetGroupOwnerIntent()
+     */
+    result SetGroupOwnerIntent(int intent);
+    
+    /**
+     * @see WifiDirectGroupInfo::SetMaxNumberOfClients()
+     */
+    result SetMaxNumberOfClients(int numberOfClient);
+
+    /**
+     * @see WifiDirectGroupInfo::SetSsid()
+     */
+    result SetSsid(const Tizen::Base::String &ssid);
+
+    /**
+     * @see WifiDirectGroupInfo::Equals()
+     */
+    virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+    /**
+     * @see WifiDirectGroupInfo::GetHashCode()
+     */
+    virtual int GetHashCode(void) const;
+
+    /**
+     * Sets the BSSID .
+     *
+     * @return       An error code
+     * @param[in]    bssid                String of BSSID
+     *
+     */
+    void SetBssId(const Tizen::Base::String &bssId);
+
+    /**
+     * Sets the operating channel.
+     *
+     * @return       An error code
+     * @param[in]    radioChannel        Radio Channel 
+     *
+     */
+    void SetOperatingChannel(const WifiRadioChannel &radioChannel);
+
+    /**
+     * Sets the bssid of group info object .
+     *
+     * @return       An error code
+     * @param[in]    wifiDirectGroupInfo  Group Info object
+     * @param[in]    bssid                String of BSSID
+     *
+     */
+    static void SetBssIdOfWifiDirectGroupInfo( WifiDirectGroupInfo& wifiDirectGroupInfo, const Tizen::Base::String &bssId );
+
+    /**
+     * Create wifi direct group info object using _WifiDirectGroupInfoImpl object.
+     *
+     * @return       An error code
+     * @param[in]    wifiDirectGroupInfoImpl  An instance of %_WifiDirectGroupInfoImpl
+     *
+     */
+    static WifiDirectGroupInfo* CreateWifiDirectGroupInfoInstanceN(_WifiDirectGroupInfoImpl &wifiDirectGroupInfoImpl);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return  The pointer to %_WifiDirectGroupInfoImpl
+     * @param[in]   wifiDirectGroupInfo   An instance of %WifiDirectGroupInfo
+     */
+    static _WifiDirectGroupInfoImpl* GetInstance(WifiDirectGroupInfo& wifiDirectGroupInfo);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return  The pointer to %_WifiDirectGroupInfoImpl
+     * @param[in]   wifiDirectGroupInfo   An instance of %WifiDirectGroupInfo
+     */
+    static const _WifiDirectGroupInfoImpl* GetInstance(const WifiDirectGroupInfo& wifiDirectGroupInfo);
+
+    /**
+     * This is the assignment operator.
+     *
+     * Copying of objects using this copy assignment operator is allowed.
+     *
+     * @param[in] rhs An instance of %_WifiDirectGroupInfoImpl
+     */
+    _WifiDirectGroupInfoImpl& operator =(const _WifiDirectGroupInfoImpl& rhs);
+
+private:
+    bool __isAutoGroupOwnerMode;
+    bool __isHiddenMode;
+    int __groupOwnerIntent;
+    int __maxNumberOfClient;
+    Tizen::Base::String __ssid;
+    Tizen::Base::String __bssId;
+    WifiRadioChannel __radioChannel;
+};
+}}}// Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_INFO_IMPL_H_
+
+
diff --git a/src/inc/FNetWifi_WifiDirectGroupOwnerImpl.h b/src/inc/FNetWifi_WifiDirectGroupOwnerImpl.h
new file mode 100644 (file)
index 0000000..489b331
--- /dev/null
@@ -0,0 +1,305 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectGroupOwnerImpl.h
+ * @brief      This is the header file for the _WifiDirectGroupOwnerImpl class.
+ *
+ * This header file contains declaration of the _WifiDirectGroupOwnerImpl class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_OWNER_IMPL_H_
+#define _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_OWNER_IMPL_H_
+
+// Includes
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+#include <FNetSockISocketEventListener.h>
+#include <FNetINetConnectionEventListener.h>
+#include "FNetWifi_WifiDirectUtility.h"
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Tizen {      namespace Net
+{
+class DhcpClientInfo;
+class LocalDhcpServer;
+class NetConnection;
+class IpAddress;
+class Ip4Address;
+class NetEndPoint;
+}}
+namespace Tizen { namespace Net { namespace Wifi
+{
+class _WifiDirectSystemAdapter;
+class _WifiDirectDeviceImpl;
+class WifiDirectDeviceInfo;
+class WifiDirectGroupOwner;
+
+
+enum _WifiDirectMemberInfoServiceStateType
+{
+    WIFI_DIRECT_MEMBER_INFO_SERVICE_IDLE,
+    WIFI_DIRECT_MEMBER_INFO_SERVICE_STARTING,
+    WIFI_DIRECT_MEMBER_INFO_SERVICE_STARTED,
+    WIFI_DIRECT_MEMBER_INFO_SERVICE_STOPPING
+};
+
+/**
+ * @class      _WifiDirectGroupOwnerImpl
+ * @brief   This class provides methods for the Wi-Fi Direct group owner management.
+ * @since      2.0
+ *
+ * _WifiDirectGroupOwnerImpl class provides the functionality for creating a _WifiDirectGroupOwnerImpl instance, and
+ * managing Wi-Fi Direct group. It also allows the listener to get events from Wi-Fi Direct group.
+ */
+
+class _OSP_EXPORT_ _WifiDirectGroupOwnerImpl
+    : public Tizen::Base::Object
+    , public Tizen::Net::INetConnectionEventListener
+    , public Tizen::Net::Sockets::ISocketEventListener
+{
+public:
+    /**
+     * This is the default constructor for this class.
+     *
+     */
+    _WifiDirectGroupOwnerImpl(void);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     */
+    virtual ~_WifiDirectGroupOwnerImpl(void);
+
+    /**
+     * @see WifiDirectGroupOwner::Construct()
+     */
+    result Construct(WifiDirectDeviceId localDeviceId, _WifiDirectDeviceImpl& wifiDirectDeviceImpl, bool enableIpInfoService = true);
+
+    /**
+     * @see WifiDirectGroupOwner::DestroyGroup()
+     */
+    result DestroyGroup(void);
+
+    /**
+     * @see WifiDirectGroupOwner::Disconnect()
+     */
+    result Disconnect(const WifiDirectDeviceInfo& wifiDirectRemoteDeviceInfo);
+
+    /**
+     * @see WifiDirectGroupOwner::StartGroupMemberInfoService()
+     */
+    result StartGroupMemberInfoService(const int portNumber);
+
+    /**
+     * @see WifiDirectGroupOwner::StopGroupMemberInfoService()
+     */
+    result StopGroupMemberInfoService(void);
+
+    /**
+     * @see WifiDirectGroupOwner::GetAllGroupMemberInfoListN()
+     */
+    Tizen::Base::Collection::IList* GetAllGroupMemberInfoListN(void);
+
+    /**
+     * Clean Sockets, closes socket and releases memory for that.
+     *
+     */
+    void CleanUpServerSocket(void);
+
+    /**
+     * Adds reference count for object
+     *
+     * @return   current reference count
+     */
+    int AddRef(void);
+
+    /**
+     * Decreases reference count for object
+     *
+     * @return   current reference count
+     */
+    int Release(void);
+
+    /**
+     * Reset Disconnected flag
+     */
+    void ResetDisconnect();
+
+    /**
+     * Creates WifiDirectGroupOwner instance from _WifiDirectGroupOwnerImpl
+     *
+     * @return   WifiDirectGroupOwner instance
+     * @param[in]   groupOwnerImpl An instance of %_WifiDirectGroupOwnerImpl
+     */
+    static WifiDirectGroupOwner* GetWifiDirectGroupOwnerInstanceN(_WifiDirectGroupOwnerImpl &groupOwnerImpl);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return  The pointer to %_WifiDirectGroupOwnerImpl
+     * @param[in]   wifiDirectGroupOwner   An instance of %WifiDirectGroupOwner
+     */
+    static _WifiDirectGroupOwnerImpl* GetInstance(WifiDirectGroupOwner& wifiDirectGroupOwner);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return  The pointer to %_WifiDirectGroupOwnerImpl
+     * @param[in]   wifiDirectGroupOwner   An instance of %WifiDirectGroupOwner
+     */
+    static const _WifiDirectGroupOwnerImpl* GetInstance(const WifiDirectGroupOwner& wifiDirectGroupOwner);
+
+private:
+
+    /**
+     * Create net connection for info service
+     *
+     * @return       An error code
+     *
+     * @exception    E_SUCCESS               The method was successful.
+     * @exception    E_SYSTEM                A system error occurred.
+     * @exception    E_OUT_OF_MEMORY         Failed to Allocated required memory
+     *
+     */
+    result CreateNetConnectionForService(void);
+
+    /**
+     * Starts socket server
+     *
+     * @return       An error code
+     *
+     * @exception    E_SUCCESS               The method was successful.
+     * @exception    E_ALREADY_BOUND         Socket Already Bound
+     * @exception    E_SYSTEM                A system error occurred.
+     * @exception    E_OUT_OF_MEMORY         Failed to Allocated required memory
+     *
+     */
+    result StartGroupMemberSocketServer(void);
+
+    /**
+     * Sends request for group member Info
+     *
+     * @param[in]    recvEndPoint            Sender's information
+     * @param[in]    messageType             It can be info or request for all member of owner info
+     */
+    void SendResponseGroupMemberInfoMessage(const Tizen::Net::NetEndPoint& recvEndPoint, _WIFIDIRECT_MESSAGE_TYPE messageType);
+
+    /**
+     * Create message string from device info
+     *
+     * @return       String of message
+     *
+     * @param[in]   wifiDirectDeviceInfo Device Info
+     *
+     */
+    Tizen::Base::String MakeMessageFormat(WifiDirectDeviceInfo& wifiDirectDeviceInfo);
+
+    /**
+     * @see Tizen::Net::Sockets::ISocketEventListener::OnSocketConnected()
+     */
+    void OnSocketConnected(Tizen::Net::Sockets::Socket& socket) {}
+
+    /**
+     * @see Tizen::Net::Sockets::ISocketEventListener::OnSocketClosed()
+     */
+    void OnSocketClosed(Tizen::Net::Sockets::Socket& socket, Tizen::Net::Sockets::NetSocketClosedReason reason){}
+
+    /**
+     * @see Tizen::Net::Sockets::ISocketEventListener::OnSocketReadyToReceive()
+     */
+    void OnSocketReadyToReceive(Tizen::Net::Sockets::Socket& socket);
+
+    /**
+     * @see Tizen::Net::Sockets::ISocketEventListener::OnSocketReadyToSend()
+     */
+    void OnSocketReadyToSend(Tizen::Net::Sockets::Socket& socket){}
+
+    /**
+     * @see Tizen::Net::Sockets::ISocketEventListener::OnSocketAccept()
+     */
+    void OnSocketAccept(Tizen::Net::Sockets::Socket& socket){}
+
+    /**
+     * @see Tizen::Net::INetConnectionEventListener::OnNetConnectionStarted()
+     */
+    void OnNetConnectionStarted(Tizen::Net::NetConnection& netConnection, result r);
+
+    /**
+     * @see Tizen::Net::INetConnectionEventListener::OnNetConnectionStopped()
+     */
+    void OnNetConnectionStopped(Tizen::Net::NetConnection& netConnection, result r);
+
+    /**
+     * @see Tizen::Net::INetConnectionEventListener::OnNetConnectionSuspended()
+     */
+    void OnNetConnectionSuspended(Tizen::Net::NetConnection& netConnection) {}
+
+    /**
+     * @see Tizen::Net::INetConnectionEventListener::OnNetConnectionResumed()
+     */
+    void OnNetConnectionResumed(Tizen::Net::NetConnection& netConnection) {}
+
+    /**
+     * Get char string of current status
+     *
+     * @return       string of current status
+     *
+     */
+    const char* GetStringOfCurrentState(void) const;
+
+private:
+
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in] rhs %_WifiDirectGroupOwnerImpl
+     */
+    _WifiDirectGroupOwnerImpl(const _WifiDirectGroupOwnerImpl& rhs);
+    
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in] rhs An instance of %_WifiDirectGroupOwnerImpl
+     */
+    _WifiDirectGroupOwnerImpl& operator =(const _WifiDirectGroupOwnerImpl& rhs);
+
+private:
+    static const int DEFAULT_PORT = 3895;
+    WifiDirectDeviceId __localDeviceId;
+    _WifiDirectDeviceImpl* __pWifiDirectDeviceImpl;
+    _WifiDirectSystemAdapter* __pWifiDirectSystemAdapter;
+
+    Tizen::Net::NetConnection* __pNetConnection;
+    Tizen::Net::Sockets::Socket* __pServerSocket;
+    const Tizen::Net::IpAddress* __pLocalIpAddress;
+    int __portNumber;
+    _WifiDirectMemberInfoServiceStateType __currentState;
+    bool __isDisconnect;
+
+}; // _WifiDirectGroupOwnerImpl
+} } }// Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_OWNER_IMPL_H_
+
diff --git a/src/inc/FNetWifi_WifiDirectUtility.h b/src/inc/FNetWifi_WifiDirectUtility.h
new file mode 100644 (file)
index 0000000..3b23840
--- /dev/null
@@ -0,0 +1,188 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifi_WifiDirectUtility.h
+ * @brief   This is the header file for the _WifiDirectUtility class.
+ *
+ * This header file contains declarations of the _WifiDirectUtility class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_DIRECT_UTILITY_H_
+#define _FNET_WIFI_INTERNAL_WIFI_DIRECT_UTILITY_H_
+
+#include <wifi-direct.h>
+#include <FBaseString.h>
+#include <FBaseInteger.h>
+#include <FNetWifiWifiTypes.h>
+
+
+namespace Tizen{ namespace Base
+{
+class String;
+
+namespace Collection
+{
+template <class type>
+class IListT;
+}}
+
+namespace Net { namespace Wifi
+{
+
+class WifiDirectGroupInfo;
+class WifiDirectDeviceInfo;
+
+    enum _WIFIDIRECT_MESSAGE_TYPE
+    {
+        UNKNOWN = 0,
+        REQUEST_OWNER_INFO,
+        REQUEST_ALL_MEMBER_INFO,
+        RESPONSE_OWNER_INFO,
+        RESPONSE_ALL_MEMBER_INFO
+    };
+
+static const Tizen::Base::String BROADCAST_ADDR   = L"255.255.255.255";
+static const int MIN_PORT_NUMBER = 1024;
+static const int MAX_PORT_NUMBER = 65535;
+static const int MESSAGE_TYPE_LENGTH = 1;
+static const int MAC_ADDRESS_LENGTH = 6;
+static const int MAX_MAC_ADDRESS_LENGTH = 17;
+static const int MAX_DEVICE_NAME_LENGTH = 64;
+static const WifiDirectDeviceId DEFAULT_DEVICE_ID = 0;
+
+class _WifiDirectUtility
+{
+
+public:
+
+    /**
+     * It parses message string and return Info Service Message Type
+     *
+     * @return  _WIFIDIRECT_MESSAGE_TYPE    info message type
+     * @param[in]   message                 string of service message type
+     */
+    static _WIFIDIRECT_MESSAGE_TYPE GetMessageType(Tizen::Base::String message);
+
+    /**
+     * Check mac address format for valid characters or not.
+     * @return      @c true if it contains valid characters, @n
+     *              else @c false
+     * @param[in]   pMacAddress     pointer to mac address
+     */
+
+    static bool CheckMacFormat(wchar_t *pMacAddress);
+
+    /**
+     * Checks mac address is  valid or not.
+     * @return      @c true if mac address is valid, @n
+     *              else @c false
+     * @param[in]   macAddress      String of mac address
+     */
+    static bool CheckMacAddress(Tizen::Base::String macAddress);
+
+    /**
+     * Converts erro code to tizen error code
+     * @return      error code
+     * @param[in]   err         error code
+     */
+    static result ConvertErrorCode(int err);
+
+    /**
+     * Converts WIFI radio channel
+     * @return      WifiRadioChannel
+     * @param[in]   channel         channel
+     */
+    static WifiRadioChannel ConvertChannel(int channel);
+
+    /**
+     * Converts mac address char buffer to string.
+     * @return      macAddress
+     * @param[in]   macAddress      mac address
+     * @remark      it converts string to macaddress also converts mac address format from 00:00:00:00:00:00 to 00-00-00-00-00-00
+     */
+    static Tizen::Base::String ConvertMacCharToString(const char macAddress[]);
+
+    /**
+     * Converts string address char to char buffer.
+     * @return      macAddress
+     * @param[in]   macAddress      mac address
+     * @remark      it converts string to macaddress also converts mac address format from 00-00-00-00-00-00 to 00:00:00:00:00:00
+     */
+    static char* ConvertMacStringToCharN(const Tizen::Base::String macAddress);
+
+    /**
+     * Converts Primary Device Category.
+     * @return      WifiDirectDeviceTypeCategory
+     * @param[in]   primaryDevType
+     */
+    static WifiDirectDeviceTypeCategory ConvertDeviceTypeCategory(wifi_direct_primary_device_type_e primaryDevType);
+
+    /**
+     * Converts Supported WPS Configuration.
+     * @return      WifiWpsConfigurationMode
+     * @param[in]   wpsType
+     */
+    static WifiWpsConfigurationMode ConvertSupportedWpsMode(wifi_direct_wps_type_e wpsType);
+
+    /**
+     * Converts PeerInfo to Device Info.
+     * @return      WifiDirectDeviceInfo    pointer to Device Info
+     * @param[in]   memberType              Member Type
+     * @param[in]   peerInfo                peer information
+     */
+    static WifiDirectDeviceInfo* ConvertPeerInfoToDeviceInfoN(WifiDirectGroupMemberType memberType,
+        const wifi_direct_connected_peer_info_s& peerInfo);
+
+    /**
+     * Converts Discovery Entry to Device Info.
+     * @return      WifiDirectDeviceInfo    pointer to Device Info
+     * @param[in]   peerInfo                peer information
+     */
+    static WifiDirectDeviceInfo* ConvertDiscoveryEntry2DeviceInfoN(const wifi_direct_discovered_peer_info_s& peerInfo);
+
+private:
+    /**
+     * This default constructor is intentionally declared as private because this class cannot be constructed.
+     *
+     */
+    _WifiDirectUtility(void);
+
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     * @param[in] rhs An instance of %_WifiDirectUtility
+     * 
+     * @since 2.1
+     */
+    _WifiDirectUtility(const _WifiDirectUtility& rhs);
+
+    /**
+     * This destructor is intentionally declared as private because this class cannot be constructed. 
+     *
+     */
+    virtual ~_WifiDirectUtility(void);
+    
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in] rhs An instance of %_WifiDirectUtility
+     */
+    _WifiDirectUtility& operator =(const _WifiDirectUtility& rhs);
+
+}; // _WifiDirectUtility
+
+} } } //Tizen::Net::Wifi
+#endif // _FNET_WIFI_INTERNAL_WIFI_DIRECT_UTILITY_H_
diff --git a/src/inc/FNetWifi_WifiManagerImpl.h b/src/inc/FNetWifi_WifiManagerImpl.h
new file mode 100644 (file)
index 0000000..935ea1e
--- /dev/null
@@ -0,0 +1,265 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file        FNetWifi_WifiManagerImpl.h
+ * @brief       This is the header file for the _WifiManagerImpl Class.
+ * @version     3.0
+ *
+ * This header file contains declaration of the _WifiManagerImpl Class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_MANAGER_IMPL_H_
+#define _FNET_WIFI_INTERNAL_WIFI_MANAGER_IMPL_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+#include "FNetWifi_IWifiManagerEventListener.h"
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+class WifiBssInfo;
+class WifiManager;
+class IWifiManagerEventListener;
+class IWifiSystemMonitoringEventListener;
+class _WifiSystemAdapter;
+class _WifiSystemMonitoringEvent;
+
+/**
+ * @class   _WifiManagerImpl
+ * @brief   This class provides methods for the local Wi-Fi device management.
+ * @since   1.0
+ *
+ * _WifiManagerImpl class provides the functionality for creating a _WifiManagerImpl instance, and
+ * managing local Wifi devices. It also allows the listener to get events from local Wifi devices.
+ */
+class _OSP_EXPORT_ _WifiManagerImpl :
+       public Tizen::Base::Object,
+       public _IWifiManagerEventListener
+{
+
+public:
+    /**
+     * This is the default constructor for this class.
+     *
+     * @remarks     After creating an instance of this class, you must explicitly call
+     *              the construction method to initialize the instance.
+     * @see Construct()
+     */
+    _WifiManagerImpl(void);
+
+    /**
+     *  This is the copy constructor for this class. Do @b not use directly.
+     *
+     * @param[in]   value   An instance of %_WifiManagerImpl
+     */
+    _WifiManagerImpl(const _WifiManagerImpl& value);
+
+    /**
+     *This destructor overrides Tizen::Base::Object::~Object().
+     */
+    virtual ~_WifiManagerImpl(void);
+
+    /**
+     * @see WifiManager::Construct()
+     */
+     result Construct(IWifiManagerEventListener& listener);
+
+    /**
+     * @see WifiManager::Activate()
+     */
+    result Activate(void);
+
+    /**
+     * @see WifiManager::Deactivate()
+     */
+    result Deactivate(void);
+
+    /**
+     * @see WifiManager::GetPowerStatus()
+     */
+    WifiPowerStatus GetPowerStatus(void) const;
+
+    /**
+     * @see WifiManager::GetMacAddress()
+     */
+    Tizen::Base::String GetMacAddress(void) const;
+
+    /**
+     * @see WifiManager::IsActivated()
+     */
+    bool IsActivated(void) const;
+
+    /**
+     * @see WifiManager::IsConnected()
+     */
+    bool IsConnected(void) const;
+
+    /**
+     * @see WifiManager::Scan()
+     */
+    result Scan(void);
+
+    /**
+     * @see WifiManager::Connect()
+     */
+    result Connect(const WifiBssInfo& targetApInfo);
+
+    /**
+     * @see WifiManager::SetWifiSystemScanMode()
+     */
+    result SetWifiSystemScanMode(WifiSystemScanMode mode);
+
+    /**
+     * @see WifiManager::AddSystemMonitoringEventListener()
+     */
+    result AddSystemMonitoringEventListener(IWifiSystemMonitoringEventListener& listener);
+
+    /**
+     * @see WifiManager::RemoveSystemMonitoringEventListener()
+     */
+    result RemoveSystemMonitoringEventListener(IWifiSystemMonitoringEventListener& listener);
+
+    /**
+     * @see WifiManager::GetConnectionState()
+     */
+    WifiConnectionState GetConnectionState(void) const;
+
+    /**
+     * @see WifiManager::GetConnectionTargetInfoN()
+     */
+    WifiBssInfo* GetConnectionTargetInfoN(void) const;
+
+    /**
+     * @see WifiManager::UpdateBssInfo()
+     */
+    result UpdateBssInfo(const WifiBssInfo& bssInfo);
+
+    /**
+     * @see WifiManager::GetSystemScanResultN()
+     */
+    Tizen::Base::Collection::IList* GetSystemScanResultN(void) const;
+
+    /**
+     * @see IWifiManagerEventListener::OnWifiActivated()
+     */
+    virtual void OnWifiActivated(result r);
+
+    /**
+     * @see IWifiManagerEventListener::OnWifiDeactivated()
+     */
+    virtual void OnWifiDeactivated(result r);
+
+    /**
+     * @see IWifiManagerEventListener::OnWifiConnected()
+     */
+    virtual void OnWifiConnected(const Tizen::Base::String& ssid, result r);
+
+    /**
+     * @see IWifiManagerEventListener::OnWifiDisconnected()
+     */
+    virtual void OnWifiDisconnected(void);
+
+    /**
+     * @see IWifiManagerEventListener::OnWifiRssiChanged()
+     */
+    virtual void OnWifiRssiChanged(long rssi);
+
+    /**
+     * @see IWifiManagerEventListener::OnWifiScanCompletedN()
+     */
+    virtual void OnWifiScanCompletedN(Tizen::Base::Collection::IList* pWifiBssInfoList, result r);
+
+    /**
+     * @see IWifiSystemMonitoringEventListener::OnWOnWifiConnectionStateChanged()
+     */
+    virtual void OnWifiConnectionStateChanged(WifiConnectionState state);
+
+    /**
+     * @see IWifiSystemMonitoringEventListener::OnWifiSystemScanResultUpdated()
+     */
+    virtual void OnWifiSystemScanResultUpdated(void);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @return  The pointer to %_WifiManagerImpl
+     * @param[in]   wifiManager   An instance of %WifiManager
+     */
+    static _WifiManagerImpl* GetInstance(WifiManager& wifiManager);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @return  The pointer to %_WifiManagerImpl
+     * @param[in]   wifiManager   An instance of %WifiManager
+     */
+    static const _WifiManagerImpl* GetInstance(const WifiManager& wifiManager);
+    
+    /**
+     * @see WifiManager::operator=()
+     */
+    _WifiManagerImpl& operator=(const _WifiManagerImpl& rhs);
+
+private:
+    enum _WifiManagerState
+    {
+           WIFI_MANAGER_DEACTIVATED,
+           WIFI_MANAGER_ACTIVATING,
+           WIFI_MANAGER_DEACTIVATING,
+           WIFI_MANAGER_ACTIVATED,
+           WIFI_MANAGER_CONNECTING,
+           WIFI_MANAGER_CONNECTED
+    };
+    enum _WifiScanState
+    {
+           WIFI_SCAN_IDLE,
+           WIFI_SCAN_SCANNING,
+           WIFI_SCAN_CANCELLING
+    };
+
+    /**
+     * Return character string of current wifi status
+     */
+    const char* GetStringOfCurrentState(void) const;
+
+    /**
+     * Return character string of current scan status
+     */
+    const char* GetStringOfCurrentScanState(void) const;
+
+    /**
+     * Return character string of current connection state
+     */
+    const char* GetStringOfConnectionState(WifiConnectionState state) const;
+
+private:
+    _WifiSystemAdapter* __pWifiSystemAdapter;
+       _WifiSystemMonitoringEvent* __pMonitoringEvt;
+    IWifiManagerEventListener* __pManagerEvtListener;
+    WifiBssInfo* __pTargetApInfo;
+    Tizen::Base::Runtime::Mutex __stateMutex;
+    _WifiManagerState __currentState;
+    _WifiScanState __currentScanState;
+    bool __wasConnected;
+
+}; // _WifiManagerImpl
+
+} } } // Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_MANAGER_IMPL_H_
diff --git a/src/inc/FNetWifi_WifiNetAccountInfoImpl.h b/src/inc/FNetWifi_WifiNetAccountInfoImpl.h
new file mode 100644 (file)
index 0000000..8529838
--- /dev/null
@@ -0,0 +1,187 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifi_WifiNetAccountInfoImpl.h
+ * @brief   This is the header file for the %_WifiNetAccountInfoImpl class.
+ *
+ * This header file contains the declarations of the %_WifiNetAccountInfoImpl class.
+ */
+
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_NET_ACCOUNT_INFO_IMPL_H_
+#define _FNET_WIFI_INTERNAL_WIFI_NET_ACCOUNT_INFO_IMPL_H_
+
+#include <FBaseObject.h>
+#include <FOspConfig.h>
+#include <FNetWifiWifiTypes.h>
+#include <FNetWifiWifiSecurityInfo.h>
+
+namespace Tizen { namespace Net
+{
+
+class NetAccountInfo;
+
+} }
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class WifiNetAccountInfo;
+
+/**
+ * @file        FNetWifi_WifiManagerImpl.h
+ * @brief       This is the header file for the _WifiNetAccountInfoImpl Class.
+ * @version     3.0
+ *
+ * This header file contains declaration of the _WifiNetAccountInfoImpl Class.
+ */
+class _OSP_EXPORT_ _WifiNetAccountInfoImpl
+       : public Tizen::Base::Object
+{
+public:
+    /**
+     * This is the default constructor for this class.
+     *
+     * @since 2.1
+     */
+    _WifiNetAccountInfoImpl(void);
+
+    /**
+     * Copying of objects using this copy constructor is allowed.
+     *
+     * @since 2.1
+     */
+    _WifiNetAccountInfoImpl(const _WifiNetAccountInfoImpl &rhs);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     * @since 2.1
+     */
+    virtual ~_WifiNetAccountInfoImpl(void);
+
+    /**
+     * @see WifiNetAccountInfo::GetBssId()
+     */
+    Tizen::Base::String GetBssId(void) const;
+
+    /**
+     * @see WifiNetAccountInfo::GetSsid()
+     */
+    Tizen::Base::String GetSsid(void) const;
+
+    /**
+     * @see WifiNetAccountInfo::GetBssType()
+     */
+    WifiBssType GetBssType(void) const;
+
+    /**
+     * @see WifiNetAccountInfo::GetSecurityInfo()
+     */
+    const WifiSecurityInfo* GetSecurityInfo(void) const;
+
+    /**
+     * @see WifiNetAccountInfo::GetRadioChannel()
+     */
+    WifiRadioChannel GetRadioChannel(void) const;
+
+    /**
+     * Sets the BSSID of this account.
+     *
+     * @param[in]   bssId   The BSSID to be set
+     * @remarks     The BSSID is not yet supported.
+     */
+    void SetBssId(Tizen::Base::String& bssid);
+
+    /**
+     * Sets the SSID of this account.
+     *
+     * @param[in]   ssid    The SSID to be set
+     */
+    void SetSsid(Tizen::Base::String& ssid);
+
+    /**
+     * Sets the type of BSS of this account.
+     *
+     * @param[in]   bssType     The BSS type to be set
+     */
+    void SetBssType(WifiBssType bssType);
+
+    /**
+     * Sets the security information of this account.
+     *
+     * @param[in]   secuInfo    The WifiSecurityInfo to be set
+     */
+    void SetSecurityInfo(const WifiSecurityInfo& securityInfo);
+
+    /**
+     * Sets the radio channel of this account.
+     *
+     * @param[in]   channel     The channel value to be set
+     * @remarks     Channel control is not yet supported.
+     */
+    void SetRadioChannel(WifiRadioChannel channel);
+
+    /**
+     * @see WifiNetAccountInfo::Equals()
+     */
+    virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+    /**
+     * @see WifiNetAccountInfo::GetHashCode()
+     */
+    virtual int GetHashCode(void) const;
+
+
+    /**
+     * Allocates Instance of WifiNetAccountInfo.
+     *
+     * @since 2.1
+     * @return  WifiNetAccountInfo
+     *
+     */
+    static WifiNetAccountInfo* CreateWifiNetAccountInfoN(void* pProfileInfo);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return  The pointer to %_WifiNetAccountInfoImpl
+     * @param[in]   wifiNetAccountInfo   An instance of %WifiNetAccountInfo
+     */
+    static _WifiNetAccountInfoImpl* GetInstance(WifiNetAccountInfo& wifiNetAccountInfo);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return  The pointer to %_WifiNetAccountInfoImpl
+     * @param[in]   wifiNetAccountInfo   An instance of %WifiNetAccountInfo
+     */
+    static const _WifiNetAccountInfoImpl* GetInstance(const WifiNetAccountInfo& wifiNetAccountInfo);
+
+private:
+    WifiBssType             __bssType;
+    Tizen::Base::String       __ssid;
+    WifiSecurityInfo        __securityInfo;
+    Tizen::Base::String       __bssid;
+    WifiRadioChannel        __channel;
+
+}; // _WifiNetAccountInfoImpl
+
+} } } // Tizen::Net::Wifi
+#endif // _FNET_WIFI_INTERNAL_WIFI_NET_ACCOUNT_INFO_IMPL_H_
+
diff --git a/src/inc/FNetWifi_WifiProximityManagerImpl.h b/src/inc/FNetWifi_WifiProximityManagerImpl.h
new file mode 100644 (file)
index 0000000..0817204
--- /dev/null
@@ -0,0 +1,190 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file        FNetWifi_WifiProximityManagerImpl.h
+ * @brief       This is the header file for the _WifiProximityManagerImpl Class.
+ * @version     3.0
+ *
+ * This header file contains declaration of the _WifiProximityManagerImpl Class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_PROXIMITY_MANAGER_IMPL_H_
+#define _FNET_WIFI_INTERNAL_WIFI_PROXIMITY_MANAGER_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+
+namespace Collection
+{
+template<class KeyType, class ValueType> class HashMapT;
+template<class KeyType, class ValueType> class MultiHashMapT;
+}
+} }
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+class _IWifiProximityEventListener;
+class _WifiIpcProxy;
+
+/**
+ * @class   _WifiProximityManagerImpl
+ * @brief   This class provides methods for the proximity service.
+ *
+ */
+class _OSP_EXPORT_ _WifiProximityManagerImpl :
+       public Tizen::Base::Object
+{
+
+public:
+       /**
+        * Adds the MAC address and listener that listens to the proximity events.
+        *
+        * @return  An error code
+        * @param[in]   listener            The listener for the proximity events @n
+        *              bssId               The MAC address for the proximity events @n
+        *
+        * @exception   E_SUCCESS           The method is successful.
+        * @exception   E_OBJ_ALREADY_EXIST The specified listener or MAC address already exists.
+        * @exception   E_SYSTEM            A system error has occurred.
+        *
+        */
+    result AddProximityEventListener(_IWifiProximityEventListener& listener, const Tizen::Base::String& bssId);
+
+       /**
+        * Removes the MAC address and listener that listens to the proximity events.
+        *
+        * @return  An error code
+        * @param[in]   listener            The listener for the proximity events @n
+        *              bssId               The MAC address for the proximity events @n
+        *
+        * @exception   E_SUCCESS           The method is successful.
+        * @exception   E_OBJ_NOT_FOUND         The specified listener or MAC address is not found.
+        * @exception   E_SYSTEM            A system error has occurred.
+        *
+        */
+    result RemoveProximityEventListener(_IWifiProximityEventListener& listener, const Tizen::Base::String& bssId);
+
+       /**
+        * Activates the proximity service.
+        *
+        * @return  An error code
+        *
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of this operation.
+        * @exception   E_SYSTEM                A system error has occurred.
+        *
+        */
+    result ActivateProximityCheck(void);
+
+       /**
+        * Deactivates the proximity service.
+        *
+        * @return  An error code
+        *
+        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_INVALID_OPERATION     The current state of the instance prohibits the execution of this operation.
+        * @exception   E_SYSTEM                A system error has occurred.
+        *
+        */
+    result DeactivateProximityCheck(void);
+
+       /**
+        * Checks whether the proximity service is activated.
+        *
+     * @return  @c true if the proximity service is activated, @n
+     *          else @c false
+        *
+        */
+    bool IsProximityCheckActivated(void);
+
+    /**
+     * Get the singleton insatnce of _WifiProximityManagerImpl.
+     *
+     * @return      The pointer to _WifiProximityManagerImpl
+     */
+    static _WifiProximityManagerImpl* GetInstance(void);
+
+    void OnWifiBssDetected(const WifiBssInfo& wifiBssInfo);
+    void OnWifiBssLost(const Tizen::Base::String& bssId);
+    void OnWifiProximityCheckActivated();
+    void OnWifiProximityCheckDeactivated();
+
+private:
+    /**
+     * This default constructor is intentionally declared as private to implement the Singleton semantic.
+     *
+     * @remarks     After creating an instance of this class, you must explicitly call
+     *              the construction method to initialize the instance.
+     * @see Construct()
+     */
+       _WifiProximityManagerImpl(void);
+
+    /**
+     * This destructor is intentionally declared as private to implement the Singleton semantic.
+     *
+     */
+    virtual ~_WifiProximityManagerImpl(void);
+
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in]   rhs                 An instance of %_WifiProximityManagerImpl
+     */
+    _WifiProximityManagerImpl(const _WifiProximityManagerImpl& value);
+
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of
+     * objects.
+     *
+     * @param[in] rhs An instance of %_WifiProximityManagerImpl
+     */
+    _WifiProximityManagerImpl& operator =(const _WifiProximityManagerImpl& rhs);
+
+    /**
+     * Initializes the _WifiProximityManagerImpl instance.
+     */
+    result Construct(void);
+
+    /**
+     * Initializes the _WifiProximityManagerImpl singletone instance.
+     */
+    static void InitSingleton(void);
+
+    /**
+     * Destorys instance of singleton class.
+     */
+    static void DestroySingleton(void);
+
+private:
+    Tizen::Base::Collection::HashMapT<_IWifiProximityEventListener*, bool>* __pListenerStateMap;
+    Tizen::Base::Collection::MultiHashMapT<Tizen::Base::String, _IWifiProximityEventListener*>* __pBssListenerMap;
+    _WifiIpcProxy* __pWifiServiceProxy;
+     static _WifiProximityManagerImpl* __pWifiProximityManagerImpl;
+
+friend class std::default_delete<_WifiProximityManagerImpl>;
+
+}; // _WifiProximityManagerImpl
+
+} } } // Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_PROXIMITY_MANAGER_IMPL_H_
diff --git a/src/inc/FNetWifi_WifiSecurityInfoImpl.h b/src/inc/FNetWifi_WifiSecurityInfoImpl.h
new file mode 100644 (file)
index 0000000..a1865f5
--- /dev/null
@@ -0,0 +1,245 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifi_WifiSecurityInfoImpl.h
+ * @brief   This is the header file for the _WifiSecurityInfoImpl class.
+ * @version 1.0
+ *
+ * This header file contains declarations of the _WifiSecurityInfoImpl class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_SECURITY_INFO_IMPL_H_
+#define _FNET_WIFI_INTERNAL_WIFI_SECURITY_INFO_IMPL_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+#include "FNetWifi_WifiUtility.h"
+
+namespace Tizen { namespace Net {  namespace Wifi
+{
+class WifiSecurityInfo;
+/**
+ * @class   _WifiSecurityInfoImpl
+ * @brief   This class provides extended methods to manage the additional security information of a Wi-Fi network.
+ * @since   1.2
+ *
+ * This class is used with the WifiSecurityInfo class to set and get the additional security information of a Wi-Fi network.
+ */
+
+class _OSP_EXPORT_ _WifiSecurityInfoImpl :
+    public Tizen::Base::Object
+{
+
+public:
+
+    /**
+     * This is the default constructor for this class.
+     */
+    _WifiSecurityInfoImpl(void);
+
+    /**
+     * Copying of objects using this copy constructor is allowed.
+     *
+     */
+    _WifiSecurityInfoImpl(const _WifiSecurityInfoImpl& value);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     */
+    ~_WifiSecurityInfoImpl(void);
+
+    /**
+     * @see WifiSecurityInfo::GetAuthenticationType()
+     */
+    WifiAuthenticationType GetAuthenticationType(void) const;
+
+    /**
+     * @see WifiSecurityInfo::GetEncryptionType()
+     */
+    WifiEncryptionType GetEncryptionType(void) const;
+
+    /**
+     * @see WifiSecurityInfo::SetNetworkKeyWep()
+     */
+    result SetNetworkKeyWep(WifiWepKeyLen  keyLen, WifiWepKeyIndex keyIndex, const Tizen::Base::String& key);
+
+    /**
+     * @see WifiSecurityInfo::SetNetworkKeyAes()
+     */
+    result SetNetworkKeyAes(const Tizen::Base::String& key);
+
+    /**
+     * @see WifiSecurityInfo::SetNetworkKeyTkip()
+     */
+    result SetNetworkKeyTkip(const Tizen::Base::String& key);
+
+    /**
+     * Get the Wired Equivalent Privacy (WEP) key data.
+     *
+     * @return     unsigned char*
+     */
+    const unsigned char* GetNetworkKeyWep(void) const;
+
+    /**
+     * Gets the Advanced Encryption Standard (AES) key data.
+     *
+     * @return      unsigned char*
+     */
+    const unsigned char* GetNetworkKeyAes(void) const;
+
+    /**
+     * Gets the Temporal Key Integrity Protocol (TKIP) key data.
+     *
+     * @return      unsigned char*
+     */
+    const unsigned char* GetNetworkKeyTkip(void) const;
+
+    /**
+     * @see WifiSecurityInfo::SetEapMethodInfo()
+     */
+    result SetEapMethodInfo(WifiEapType type, const Tizen::Base::String& userId, const Tizen::Base::String& password, bool validateServerCertificate = true);
+
+    /**
+     * Gets the type of EAP.
+     *
+     * @return      The EAP type
+     */
+    WifiEapType GetEapType(void) const;
+
+    /**
+     * Gets the user ID of EAP.
+     *
+     * @return      user ID
+     */
+    const char* GetEapUserId(void) const;
+
+    /**
+     * Gets the password of EAP
+     *
+     * @return      password
+     */
+    const char* GetEapPassword(void) const;
+
+    /**
+     * @see WifiSecurityInfo::SetNetworkKey()
+     */
+    void SetNetworkKey(const Tizen::Base::String& key);
+
+    /**
+     * @see WifiSecurityInfo::SetAuthenticationType()
+     */
+    void SetAuthenticationType(WifiAuthenticationType type);
+
+    /**
+     * Gets the network key
+     *
+     * @return  The network key
+     */
+    Tizen::Base::String GetNetworkKey(void) const;
+
+    /**
+     * Sets the encryption type of this account.
+     *
+     * @param[in]   encryptionType  The encryption type
+     */
+    void SetEncryptionType(WifiEncryptionType encryptionType);
+
+    /**
+     * @see WifiSecurityInfo::Equals()
+     */
+    virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+    /**
+     * @see WifiSecurityInfo::GetHashCode()
+     */
+    virtual int GetHashCode(void) const;
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return  The pointer to %_WifiSecurityInfoImpl
+     * @param[in]   wifiSecurityInfo   An instance of %WifiSecurityInfo
+     */
+    static _WifiSecurityInfoImpl* GetInstance(WifiSecurityInfo& wifiSecurityInfo);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return  The pointer to %_WifiSecurityInfoImpl
+     * @param[in]   wifiSecurityInfo   An instance of %WifiSecurityInfo
+     */
+    static const _WifiSecurityInfoImpl* GetInstance(const WifiSecurityInfo& wifiSecurityInfo);
+
+    /**
+     * @see WifiSecurityInfo::GetHashCode()
+     */
+    _WifiSecurityInfoImpl& operator=(const _WifiSecurityInfoImpl& rhs);
+
+private:
+    /**
+     * @brief   Defines IEEE 802.11 security key with the WEP encryption.
+     */
+    struct WifiNetworkKeyWep
+    {
+        WifiWepKeyLen   keyLen;                             //< WEP Key length(64 or 128 bits).
+        int             keyIndex;                           //< WEP Key index(must be 1, 2, 3, or 4).
+        unsigned char key[WIFI_WEP_128BIT_KEY_LENGTH + 1];  //< WEP key value.
+    };
+
+    /**
+     * @brief   Defines IEEE 802.11 security key with the AES encryption.
+     */
+    struct WifiNetworkKeyAes
+    {
+        unsigned char key[WIFI_AES_KEY_LENGTH + 1];  //< The AES key value.
+    };
+
+    /**
+     * @brief   Defines the type definition of IEEE 802.11 security key with the TKIP encryption.
+     */
+    struct WifiNetworkKeyTkip
+    {
+        unsigned char key[WIFI_TKIP_KEY_LENGTH + 1]; //< The TKIP key value
+    };
+
+    /**
+     * @brief   Defines Information of EAP method.
+     */
+    struct WifiEapMethodInfo
+    {
+        WifiEapType eapType;                    //< EAP method type.
+        char userId[WIFI_EAP_KEY_LENGTH + 1];   //< EAP userId.
+        char password[WIFI_EAP_KEY_LENGTH + 1]; //< EAP password.
+        bool validateCertificate;            //< The option to validate server certificate.
+    };
+    WifiAuthenticationType __authenticationType;
+    WifiEncryptionType __encryptionType;
+    WifiNetworkKeyWep __wepKey;
+    WifiNetworkKeyAes __aesKey;
+    WifiNetworkKeyTkip __tkipKey;
+    WifiEapMethodInfo __eapInfo;
+    Tizen::Base::String __networkKey;
+
+}; // _WifiSecurityInfoImpl
+
+} } } //Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_SECURITY_INFO_IMPL_H_
diff --git a/src/inc/FNetWifi_WifiSystemAdapter.h b/src/inc/FNetWifi_WifiSystemAdapter.h
new file mode 100644 (file)
index 0000000..00501d5
--- /dev/null
@@ -0,0 +1,307 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifi_WifiSystemAdapter.h
+ * @brief   This is the header file for the _WifiSystemAdapter class.
+ * @version 2.1
+ *
+ * This header file contains declarations of the _WifiSystemAdapter class.
+ */
+#ifndef _FNET_WIFI_INTERNAL_WIFI_SYSTEM_ADAPTER_H_
+#define _FNET_WIFI_INTERNAL_WIFI_SYSTEM_ADAPTER_H_
+
+#include <unique_ptr.h>
+#include <wifi.h>
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+class WifiBssInfo;
+class _WifiManagerImpl;
+class _WifiManagerEvent;
+
+class _OSP_EXPORT_ _WifiSystemAdapter :
+       public Tizen::Base::Object
+{
+
+public:
+    /**
+     * Register an instance of _IWifiManagerEventListener interface.
+     *
+     * @return      An error code
+     * @param[in]   listener            The instance of _IWifiManagerEventListener to be registered
+     * @param[in]   isHighPriority      Set to @c true to register with the high priority, @n
+     *                                  else @c false
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
+     */
+       result RegisterManagerEventListener(_IWifiManagerEventListener& listener);
+
+    /**
+     * Unregister an instance of _IBluetoothManagerEventListener interface.
+     *
+     * @return      An error code
+     * @param[in]   listener            The instance of _IWifiManagerEventListener to be unregistered
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_OBJ_NOT_FOUND     The input instance is not registered.
+     */
+    result UnregisterManagerEventListener(const _IWifiManagerEventListener& listener);
+
+    /**
+     * Activates the local Wifi device.
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The activation was successful.
+     * @exception   E_FAILURE           Failed to activate.
+     * @exception   E_SYSTEM            A system error occurred.
+     */
+    result Activate(void);
+
+    /**
+     * Deactivates the local Wifi device.
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The deactivation was successful.
+     * @exception   E_FAILURE           Failed to deactivate.
+     * @exception   E_SYSTEM            A system error occurred.
+     */
+    result Deactivate(void);
+
+    /**
+     * Gets the MAC address of the Wifi device.
+     * @return      The MAC address in the form '00-00-00-00-00-00'
+     */
+    Tizen::Base::String GetMacAddress(void) const;
+
+    /**
+     * Checks whether the local device is activated.
+     * @return      @c true, if the local device is activated @n
+     *              @c false, otherwise
+     */
+    bool IsActivated(void) const;
+
+    /**
+     * Checks whether the local device is connected with a remote STA.
+     * @return      @c true, if the local device is connected with a remote STA @n
+     *              @c false, otherwise
+     */
+    bool IsConnected(void) const;
+
+    /**
+     * Requests a scan for nearby BSS with both infrastructure and independent mode.
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method was successful.
+     * @exception   E_FAILURE           The method failed.
+     * @remarks     Only active scan - i.e. probing for APs in the range - is supported.
+     * @see         IWifiManagerEventListener::OnWifiScanCompleted()
+     */
+    result Scan(void);
+
+    /**
+     * Establishes a connection to a specific access point - only BSS with infrastructure mode.
+     *
+     * @return      An error code
+     * @param[in]   targetApInfo        A BSS information that represents target access point.
+     * @exception   E_SUCCESS           The method was successful.
+     * @exception   E_FAILURE           The method failed.
+     * @exception   E_INVALID_ARG       A specified input parameter is invalid. E.g. BSS type is independent mode.
+     * @remarks     If a connection to other access point is already established, it will be disconnected and the new connection
+     *              of this method will be established.
+     * @see         IWifiManagerEventListener::OnWifiConnected()
+     */
+    result Connect(const WifiBssInfo& targetApInfo);
+
+    /**
+     * Gets the state of current Wi-Fi connection.
+     *
+     * @return      The state of the current Wi-Fi connection
+     */
+    WifiConnectionState GetConnectionState(void) const;
+
+    /**
+     * Gets the information of current Wi-Fi connection target which the local device is connecting or connected with.
+     *
+     * @return      A pointer to the WifiBssInfo instance representing the information of current Wi-Fi connection target
+     *              else @c null if GetConnectionState() is WIFI_CONNECTION_STATE_NOT_CONNECTED
+     */
+    WifiBssInfo* GetConnectionTargetInfoN(void) const;
+
+    /**
+     * Gets a list of the latest search results which the underlying Wi-Fi system scan periodically on background.
+     *
+     * @return      An IList containing WifiBssInfo of existing Wi-Fi connections if successful, @n
+     *              else @c null
+     */
+    Tizen::Base::Collection::IList* GetSystemScanResultN(void) const;
+
+    /**
+     * Called when the device state is changed.
+     *
+     * @param[in]   state               Device status
+     * @param[in]   pUserData           The user data passed from the callback registration function
+     */
+    static void OnWifiDeviceStateChanged(wifi_device_state_e state, void* pUserData);
+
+    /**
+     * Called when the connection state is changed.
+     *
+     * @param[in]   state               Connection status
+     * @param[in]   apHanlder           Access point handler
+     * @param[in]   pUserData           The user data passed from the callback registration function
+     */
+    static void OnWifiConnectionStateChanged(wifi_connection_state_e state, wifi_ap_h ap, void* pUserData);
+    
+    /**
+     * Called when each access point is found.
+     *
+     * @param[in]   pApHandler          Access point
+     * @param[in]   pUserData           The user data passed from the callback registration function
+     */
+    static bool OnWifiEachAccessPointFound(wifi_ap_h pApHandle, void* pUserData);
+
+    /**
+     * Called when each access point is checked.
+     *
+     * @param[in]   pApHandle           Access point
+     * @param[in]   pUserData           The user data passed from the callback registration function
+     */
+    static bool OnWifiEachAccessPointChecked(wifi_ap_h pApHandle, void* pUserData);
+
+    /**
+     * Called when Wifi is activated.
+     *
+     * @param[in]   errorCode           Error code
+     * @param[in]   pUserData           The user data passed from the callback registration function
+     */
+    static void OnWifiActivated(wifi_error_e errorCode, void* pUserData);
+
+    /**
+     * Called when Wifi is dectivated.
+     *
+     * @param[in]   errorCode           Error code
+     * @param[in]   pUserData           The user data passed from the callback registration function
+     */
+    static void OnWifiDeactivated(wifi_error_e errorCode, void* pUserData);
+
+    /**
+     * Called when the local device is connected with Wifi access point.
+     *
+     * @param[in]   errorCode           Error code
+     * @param[in]   pUserData           The user data passed from the callback registration function
+     */
+    static void OnWifiConnected(wifi_error_e errorCode, void* pUserData);
+
+    /**
+     * Called when the scan process is completed.
+     *
+     * @param[in]   errorCode           Error code
+     * @param[in]   pUserData           The user data passed from the callback registration function
+     */
+    static void OnWifiScanCompleted(wifi_error_e errorCode, void* pUserData);
+    
+    /**
+     * Called when the rssi value is changed.
+     *
+     * @param[in]   rssiLevel           Rssi level
+     * @param[in]   pUserData           The user data passed from the callback registration function
+     */
+    static void OnWifiRssiLevelChanged(wifi_rssi_level_e rssiLevel, void* pUserData);
+
+    /**
+     * Called when the background scan result is updated.
+     *
+     * @param[in]   errorCode           Error code
+     * @param[in]   pUserData           The user data passed from the callback registration function
+     */
+    static void OnWifiBackgroundScanResultUpdated(wifi_error_e errorCode, void* pUserData);
+
+    /**
+     * Get the singleton insatnce of _WifiSystemAdapter.
+     *
+     * @return      The pointer to _WifiSystemAdapter
+     */
+    static _WifiSystemAdapter* GetInstance(void);
+
+private:
+    /**
+     * This default constructor is intentionally declared as private to implement the Singleton semantic.
+     *
+     * @remarks     After creating an instance of this class, you must explicitly call
+     *              the construction method to initialize the instance.
+     * @see Construct()
+     */
+    _WifiSystemAdapter(void);
+
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in]   rhs                 An instance of %_WifiSystemAdapter
+     */
+    _WifiSystemAdapter(const _WifiSystemAdapter& rhs);
+
+    /**
+     * This destructor is intentionally declared as private to implement the Singleton semantic.
+     *
+     */
+    virtual ~_WifiSystemAdapter(void);
+
+    /**
+     * Initializes the _WifiSystemAdapter instance and adds the listener instance.
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The initialization was successful.
+     * @exception   E_SYSTEM            A system error occurred.
+     */
+    result Construct();
+
+    /**
+     * Initializes the _WifiSystemAdapter singletone instance.
+     *
+     * @exception   E_SUCCESS           The initialization was successful.
+     * @exception   E_SYSTEM            A system error occurred.
+     * @exception   E_OUT_OF_MEMORY     The memory is insufficient.     
+     */
+    static void InitSingleton(void);
+
+    /**
+     * Destorys instance of singleton class.
+     *
+     */
+    static void DestroySingleton(void);
+    
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in] rhs An instance of %_WifiSystemAdapter
+     */
+    _WifiSystemAdapter& operator=(const _WifiSystemAdapter& rhs);
+
+private:
+    std::unique_ptr<_WifiManagerEvent> __pWifiManagerEvent;
+    WifiBssInfo* __pBssInfo;
+
+friend class std::default_delete<_WifiSystemAdapter>;
+
+}; // _WifiSystemAdapter
+
+} } } // Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_SYSTEM_ADAPTER_H_
diff --git a/src/inc/FNetWifi_WifiUtility.h b/src/inc/FNetWifi_WifiUtility.h
new file mode 100644 (file)
index 0000000..89fe67c
--- /dev/null
@@ -0,0 +1,244 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiUtility.h
+ * @brief   This is the header file for the %_WifiUtility class.
+ *
+ * This header file contains the declarations of the %_WifiUtility class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_UTILITY_H_
+#define _FNET_WIFI_INTERNAL_WIFI_UTILITY_H_
+
+#include <FOspConfig.h>
+#include <wifi.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Base
+{
+
+class String;
+
+} } // Tizen::Base
+
+
+namespace Tizen { namespace Net
+{
+class IpAddress;
+} } // Tizen::Net
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class WifiBssInfo;
+
+struct _CharDeleter
+{
+    void operator()(char* pChar)
+    {
+        free(pChar);
+    }
+};
+
+/**
+ * The length of a security key value with Wired Equivalent Privacy (WEP-64Bit)
+ */
+static const int WIFI_WEP_64BIT_KEY_LENGTH = 10;
+
+/**
+ * The length of a security key value with Wired Equivalent Privacy (WEP-128Bit)
+ */
+static const int WIFI_WEP_128BIT_KEY_LENGTH = 26;
+
+/**
+ * The length of a security key value with Advanced Encryption Standard (AES)
+ */
+static const int WIFI_AES_KEY_LENGTH = 64;
+/**
+ * The length of a security key value with Temporal Key Integrity Protocol (TKIP)
+ */
+static const int WIFI_TKIP_KEY_LENGTH = WIFI_AES_KEY_LENGTH;
+/**
+ * The length of the user and password values of Extensible Authentication Protocol method (EAP)
+ */
+static const int WIFI_EAP_KEY_LENGTH = 256;
+
+class _OSP_EXPORT_ _WifiUtility
+{
+public:
+    /**
+     * Converts  net_err_t to result
+     *
+     * @return       An error code
+     * @param[in]   error                error code
+     */
+    static result ConvertErrorCode(int error);
+
+    /**
+     * Converts wlan_security_mode_type_t to WifiAuthentication Type
+     *
+     * @return       WifiAuthenticationType
+     * @param[in]   securityMode         Security Mode
+     * @param[in]   encType              Encryption Type
+     */
+    static WifiAuthenticationType ConvertAuthType(wifi_security_type_e securityMode, wifi_encryption_type_e encType);
+    
+     /**
+     * Converts WifiAuthenticationType to wifi_security_type_e
+     *
+     * @return       wifi_security_type_e
+     * @param[in]   authMode         Authentication Mode
+     */
+
+    static wifi_security_type_e ConvertSecurityType(WifiAuthenticationType authMode);
+    /**
+     * Converts frequency to RadioChannel.
+     *
+     * @return       WifiRadioChannel
+     * @param[in]    frequency           radio frequency value
+     */
+    static WifiRadioChannel ConvertRadioChannel(int frequency);
+
+    /**
+     * Converts Rssi value from level
+     *
+     * @return       long
+     * @param[in]    val                 rssi value
+     */
+    static long ConvertLeveltoRssiValue(wifi_rssi_level_e val);
+
+    /**
+     * Converts Rssi value from percentage
+     *
+     * @return       long
+     * @param[in]    val                 Rssi percentage value
+     */
+    static long ConvertPercentagetoRssiValue(char val);
+
+
+    /**
+     * Converts Encryption Type
+     *
+     * @return       WifiEncryptionType
+     * @param[in]    encType             Encryption Type
+     */
+    static WifiEncryptionType ConvertEncryptionType(wifi_encryption_type_e encType);
+
+    /**
+     * Converts Encryption Type
+     *
+     * @return       wifi_encryption_type_e
+     * @param[in]    encryptionMode       Encryption Type
+     */
+    static wifi_encryption_type_e ConvertEncryptionType(WifiEncryptionType encryptionMode);
+
+    /**
+     * Converts EAP Type
+     *
+     * @return       WifiEapType
+     * @param[in]    eapType             EAP Type
+     * @param[in]    eapAuthType         EAP authentication type
+     */
+    static WifiEapType ConvertEapType(wifi_eap_type_e eapType, wifi_eap_auth_type_e eapAuthType);
+
+    /**
+     * Converts EAP Type
+     *
+     * @return       wlan_eap_type_t
+     * @param[in]    eapType             EAP Type
+     */
+    static wifi_eap_type_e ConvertEapType(WifiEapType eapType);
+
+    /**
+     * Converts EAP Authentication Type
+     *
+     * @return       wlan_eap_auth_type_t
+     * @param[in]    eapType         EAP authentication type
+     */
+    static wifi_eap_auth_type_e ConvertEapAuthType(WifiEapType eapype);
+
+    /**
+     * Converts Mac Address
+     *
+     * @return       String
+     * @param[in]    macAddress          mac address
+     */
+    static Tizen::Base::String ConvertMacAddress(char macAddress[]);
+
+    /**
+     * Converts profile info to bssinfo
+     *
+     * @return       WifiBssInfo        bss information
+     * @param[in]    apHandler          Access Point Handler
+     */
+    static WifiBssInfo* CreateWifiBssInfoInstanceN(wifi_ap_h& apHandler);
+
+    /**
+     * Releases memory for wifi aphandler and sets it to null
+     *
+     * @param[in]    apHandler          Access Point Handler
+     */
+    static void WifiApClone(void** pDest, void* pSrc);
+
+    /**
+     * Clones access point handler
+     *
+     * @param[in]    apHandler          Access Point Handler
+     */
+    static void WifiApDestory(void** pApHandler);
+
+    /**
+     * Checks whether the values of the two %IpAddress objects are equal.
+     */
+    static bool CheckAddressEquality(Tizen::Net::IpAddress* pFirstAddress, Tizen::Net::IpAddress* pSecondAddress);
+
+private:
+       /**
+        * This default constructor is intentionally declared as private because this class cannot be constructed.
+        *
+        */
+    _WifiUtility(void);
+
+       /**
+        * This destructor is intentionally declared as private because this class cannot be constructed. 
+        *
+        */
+       virtual ~_WifiUtility(void);
+
+private:
+
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @since 2.1
+     *
+     * @param[in] rhs   An instance of %_WifiUtility
+     */
+       _WifiUtility(const _WifiUtility& rhs);
+
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in] rhs An instance of %_WifiUtility
+     */
+       _WifiUtility& operator =(const _WifiUtility& rhs);
+
+}; // _WifiUtility
+
+} } }  // Tizen::Net::Wifi
+#endif // _FNET_WIFI_INTERNAL_WIFI_UTILITY_H_
+
diff --git a/src/inc/FNet_ConnectivityIpcMessages.h b/src/inc/FNet_ConnectivityIpcMessages.h
new file mode 100644 (file)
index 0000000..9db66d4
--- /dev/null
@@ -0,0 +1,40 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNet_ConnectivityIpcMessages.h
+ * @brief      This is the header file for the Connectivity service daemon's IPC messages.
+ *
+ * This header file contains the declarations of the IPC messages for the Connectivity service daemon.
+ */
+
+#include <ipc/ipc_message_macros.h>
+#include <FIo_IpcCommonParamTraits.h>
+#include <FIo_IpcMessageStart.h>
+#include "FNet_ConnectivityIpcParamTraits.h"
+
+
+#ifndef NET_CONNECTIVITY_IPC_SERVER_NAME
+#define NET_CONNECTIVITY_IPC_SERVER_NAME "osp.net.ipcserver.connectivity"
+#endif
+
+#define IPC_MESSAGE_START ConnectivityNetServiceMsgStart
+
+// Client -> Server (sync)
+IPC_SYNC_MESSAGE_CONTROL1_2(ConnectivityNetServiceMsg_getAppNetAccountId, Tizen::Base::String /* ProfileName */, int /* NetAccountId */, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL1_2(ConnectivityNetServiceMsg_setNetAccountId, int /* NetAccountId*/, int /* NetAccountId */, unsigned long /* result */)
+IPC_SYNC_MESSAGE_CONTROL3_1(ConnectivityNetServiceMsg_updateSystemNetAccount, Tizen::Base::String /* ProfileName */, Tizen::Net::NetAccountInfo /* NetAccountInfo */, int /* NetBearerType*/, unsigned long /* result */)
+
diff --git a/src/inc/FNet_ConnectivityIpcParamTraits.h b/src/inc/FNet_ConnectivityIpcParamTraits.h
new file mode 100644 (file)
index 0000000..f786d49
--- /dev/null
@@ -0,0 +1,403 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file       FNet_ConnectivityIpcMessages.h
+ * @brief      This is the header file for the Connectivity service daemon's IPC messages.
+ *
+ * This header file contains the declarations of the IPC messages for the Connectivity service daemon.
+ */
+
+#ifndef _FNET_INTERNAL_CONNECTIVITY_IPC_PARAM_TRAITS_H_
+#define _FNET_INTERNAL_CONNECTIVITY_IPC_PARAM_TRAITS_H_
+
+#include <unique_ptr.h>
+#include <base/tuple.h>
+#include <ipc/ipc_param_traits.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FNetNetAccountInfo.h>
+#include <FNetIpAddress.h>
+#include <FNetIp4Address.h>
+#include <FNetNetTypes.h>
+#include <FNetNetEndPoint.h>
+#include "FIo_IpcCommonDataTypes.h"
+
+using namespace std;
+using namespace Tizen::Net;
+using namespace Tizen::Net::Wifi;
+
+namespace IPC
+{
+template <>
+struct ParamTraits<Tizen::Net::NetAccountInfo>
+{
+       typedef Tizen::Net::NetAccountInfo param_type;
+
+       static void Write(Message* m, const param_type& p)
+       {
+               bool isNull = false;
+               Tizen::Net::NetNapAuthType authType;
+               Tizen::Base::String authId;
+               Tizen::Base::String authPassword;
+
+               Tizen::Net::NetAddressScheme localAddressScheme;
+               Tizen::Net::NetAddressScheme dnsAddressScheme;
+               Tizen::Net::NetEndPoint* pNetEndPoint;
+
+               SysLog(NID_NET, "Writting... APN : %ls", p.GetAccessPointName().GetPointer());
+               WriteParam(m, p.GetAccessPointName());
+               SysLog(NID_NET, "Writting... Account Id : %d", p.GetAccountId());
+               m->WriteInt(p.GetAccountId());
+               SysLog(NID_NET, "Writting... Account Name : %ls", p.GetAccountName().GetPointer());
+               WriteParam(m, p.GetAccountName());
+
+               // AuthenticationInfo
+               p.GetAuthenticationInfo(authType, authId, authPassword);
+               SysLog(NID_NET, "Writting... Auth Info (Type, Id, Pw) : (%d, %ls, %ls)", authType, authId.GetPointer(), authPassword.GetPointer());
+
+               m->WriteInt(authType);
+               WriteParam(m, authId);
+               WriteParam(m, authPassword);
+
+               SysLog(NID_NET, "Writting... HomeUrl : %ls", p.GetHomeUrl().GetPointer());
+               WriteParam(m, p.GetHomeUrl());
+               SysLog(NID_NET, "Writting... Bearer : %d", p.GetBearerType());
+               m->WriteInt(p.GetBearerType());
+
+               SysLog(NID_NET, "Writting... Local Address Scheme : %d", p.GetLocalAddressScheme());
+               // LocalAddressScheme
+               localAddressScheme = p.GetLocalAddressScheme();
+               m->WriteInt(localAddressScheme);
+
+               // LocalAddress
+               if (localAddressScheme == NET_ADDRESS_SCHEME_STATIC)
+               {
+                       if (p.GetLocalAddress() != null)
+                       {
+                               isNull = false;
+                               m->WriteBool(isNull);
+
+                               SysLog(NID_NET, "Writting... NetAddressFamily : %d", p.GetLocalAddress()->GetNetAddressFamily());
+                               m->WriteInt(p.GetLocalAddress()->GetNetAddressFamily());
+                               SysLog(NID_NET, "Writting... Local Address : %ls", p.GetLocalAddress()->ToString().GetPointer());
+                               WriteParam(m, p.GetLocalAddress()->ToString());
+                       }
+                       else
+                       {
+                               isNull = true;
+                               m->WriteBool(isNull);
+                       }
+               }
+
+               SysLog(NID_NET, "Writting... DNS Address Scheme : %d", p.GetDnsAddressScheme());
+               // DnsAddressScheme
+               dnsAddressScheme = p.GetDnsAddressScheme();
+               m->WriteInt(dnsAddressScheme);
+
+               SysLog(NID_NET, "Writting... DNS Address");
+               if (dnsAddressScheme == NET_ADDRESS_SCHEME_STATIC)
+               {
+                       if (p.GetPrimaryDnsAddress() != null)
+                       {
+                               isNull = false;
+                               m->WriteBool(isNull);
+
+                               // PrimaryDnsAddress
+                               m->WriteInt(p.GetPrimaryDnsAddress()->GetNetAddressFamily());
+                               WriteParam(m, p.GetPrimaryDnsAddress()->ToString());
+                               SysLog(NID_NET, "Primary Dns Net Address Family : %d", p.GetPrimaryDnsAddress()->GetNetAddressFamily());
+
+                               if (p.GetSecondaryDnsAddress() != null)
+                               {
+                                       isNull = false;
+                                       m->WriteBool(isNull);
+
+                                       // SecondaryDnsAddress
+                                       m->WriteInt(p.GetSecondaryDnsAddress()->GetNetAddressFamily());
+                                       WriteParam(m, p.GetSecondaryDnsAddress()->ToString());
+                               }
+                               else
+                               {
+                                       isNull = true;
+                                       m->WriteBool(isNull);
+                               }
+                       }
+                       else
+                       {
+                               isNull = true;
+                               m->WriteBool(isNull);
+                       }
+               }
+
+               SysLog(NID_NET, "Protocol Type : %d",p.GetProtocolType());
+               m->WriteInt(p.GetProtocolType());
+
+               // NetEndPoint
+               SysLog(NID_NET, "NetEndPoint");
+               pNetEndPoint = const_cast<NetEndPoint*>(p.GetProxyAddress());
+
+               if (pNetEndPoint != null)
+               {
+                       isNull = false;
+                       m->WriteBool(isNull);
+
+                       SysLog(NID_NET, "Proxy Address Family : %d ", pNetEndPoint->GetNetAddressFamily());
+                       m->WriteInt(pNetEndPoint->GetNetAddressFamily());
+
+                       SysLog(NID_NET, "Proxy Address : %ls", pNetEndPoint->GetAddress()->ToString().GetPointer());
+                       WriteParam(m, pNetEndPoint->GetAddress()->ToString());
+                       SysLog(NID_NET, "Proxy Port : %d", static_cast <int>(pNetEndPoint->GetPort()));
+                       m->WriteInt(static_cast <int>(pNetEndPoint->GetPort()));
+               }
+               else
+               {
+                       isNull = true;
+                       m->WriteBool(isNull);
+               }
+       }
+
+       static bool Read(const Message* m, void** iter, param_type* r)
+       {
+               Tizen::Base::String accessPointName;
+               int accountId;
+               Tizen::Base::String accountName;
+               int authType;
+               Tizen::Base::String authId;
+               Tizen::Base::String authPassword;
+               Tizen::Base::String homeUrl;
+               int bearerType;
+               int localAddressScheme;
+               int localAddressFamily;
+               Tizen::Base::String localAddress;
+               int dnsAddressScheme;
+               int primaryDnsAddressFamily;
+               Tizen::Base::String primaryDnsAddress;
+               int secondaryDnsAddressFamily;
+               Tizen::Base::String secondaryDnsAddress;
+               int protocolType;
+               int proxyAddressFamily;
+               Tizen::Base::String proxyAddress;
+               int port;
+               bool isNull;
+
+               unique_ptr<Ip4Address> pPrimaryDnsIp4Address(null);
+               unique_ptr<Ip4Address> pSecondaryDnsIp4Address(null);
+               unique_ptr<Ip4Address> pLocalIp4Address(null);
+               unique_ptr<Ip4Address> pProxyIp4Address(null);
+
+               r->Construct();
+
+               // APN
+               if (!ReadParam(m, iter, &accessPointName))
+               {
+                       return false;
+               }
+               SysLog(NID_NET, "AccessPointName : %ls", accessPointName.GetPointer());
+               r->SetAccessPointName(accessPointName);
+
+               // Account Id (No Setter)
+               m->ReadInt(iter, &accountId);
+               SysLog(NID_NET, "AccountId : %d", accountId);
+
+               // Account Name
+               if (!ReadParam(m, iter, &accountName))
+               {
+                       return false;
+               }
+               SysLog(NID_NET, "AccountName : %ls", accountName.GetPointer());
+               r->SetAccountName(accountName);
+
+               // Authentication Info
+               m->ReadInt(iter, &authType);
+               SysLog(NID_NET, "AuthType : %d", authType);
+               if (!ReadParam(m, iter, &authId))
+               {
+                       return false;
+               }
+               SysLog(NID_NET, "authId : %ls", authId.GetPointer());
+               if (!ReadParam(m, iter, &authPassword))
+               {
+                       return false;
+               }
+               SysLog(NID_NET, "authPassword : %ls", authPassword.GetPointer());
+               r->SetAuthenticationInfo((Tizen::Net::NetNapAuthType)authType, authId, authPassword);
+
+               // Home URL
+               if (!ReadParam(m, iter, &homeUrl))
+               {
+                       return false;
+               }
+               SysLog(NID_NET, "homeUrl : %ls", homeUrl.GetPointer());
+               r->SetHomeUrl(homeUrl);
+
+               // Bearer Type (No Setter)
+               m->ReadInt(iter, &bearerType);
+               SysLog(NID_NET, "bearerType : %d", bearerType);
+
+               // Local Address
+               m->ReadInt(iter, &localAddressScheme);
+               if (localAddressScheme == 1)
+               {
+                       SysLog(NID_NET, "Local Address Scheme : Dynamic");
+                       r->SetLocalAddress(NET_ADDRESS_SCHEME_DYNAMIC, null);
+               }
+               else if (localAddressScheme == 2)
+               {
+                       m->ReadBool(iter, &isNull);
+                       if (!isNull)
+                       {
+                               SysLog(NID_NET, "Local Address Scheme : Static");
+                               m->ReadInt(iter, &localAddressFamily);
+                               if (!ReadParam(m, iter, &localAddress))
+                               {
+                                       return false;
+                               }
+                               SysLog(NID_NET, "Local Address : %ls", localAddress.GetPointer());
+
+                               // Setting Part
+                               SysLog(NID_NET, "Set Local Address statically");
+                               if (localAddressFamily == NET_AF_IPV4)
+                               {
+                                       // NET_AF_IPV4
+                                       pLocalIp4Address.reset(new (std::nothrow) Ip4Address(localAddress));
+                               }
+                               else
+                               {
+                                       // Not supported yet.
+                                       return false;
+                               }
+                               r->SetLocalAddress(NET_ADDRESS_SCHEME_STATIC, pLocalIp4Address.get());
+                       }
+                       else
+                       {
+                               // Local Address is null
+                       }
+               }
+               else
+               {
+                       SysLog(NID_NET, "Local Address Scheme : None");
+               }
+
+               // DnsAddressScheme
+               m->ReadInt(iter, &dnsAddressScheme);
+               if (dnsAddressScheme == 1)
+               {
+                       SysLog(NID_NET, "DNS Address Scheme : Dynamic");
+                       r->SetDnsAddress(NET_ADDRESS_SCHEME_DYNAMIC, null, null);
+               }
+               else if (dnsAddressScheme == 2)
+               {
+                       SysLog(NID_NET, "Dns Address Scheme : Static");
+
+                       m->ReadBool(iter, &isNull);
+                       if (!isNull)
+                       {
+                               // PrimaryDnsAddress
+                               m->ReadInt(iter, &primaryDnsAddressFamily);
+                               if (!ReadParam(m, iter, &primaryDnsAddress))
+                               {
+                                       return false;
+                               }
+                               SysLog(NID_NET, "primaryDnsAddress : %ls", primaryDnsAddress.GetPointer());
+                               if (primaryDnsAddressFamily == NET_AF_IPV4)
+                               {
+                                       pPrimaryDnsIp4Address.reset(new (std::nothrow) Ip4Address(primaryDnsAddress));
+                               }
+                               else
+                               {
+                                       // IPv6 is NOT supported yet
+                               }
+
+                               m->ReadBool(iter, &isNull);
+                               if (!isNull)
+                               {
+                                       // SecondaryDnsAddress
+                                       m->ReadInt(iter, &secondaryDnsAddressFamily);
+                                       if (!ReadParam(m, iter, &secondaryDnsAddress))
+                                       {
+                                               return false;
+                                       }
+                                       SysLog(NID_NET, "secondaryDnsAddress : %ls", secondaryDnsAddress.GetPointer());
+                                       if (secondaryDnsAddressFamily == NET_AF_IPV4)
+                                       {
+                                               pSecondaryDnsIp4Address.reset(new (std::nothrow) Ip4Address(secondaryDnsAddress));
+                                       }
+                                       else
+                                       {
+                                               // IPv6 is NOT supported yet
+                                       }
+                               }
+                               else
+                               {
+                                       // Secondary DNS is null
+                               }
+                               r->SetDnsAddress(NET_ADDRESS_SCHEME_STATIC, pPrimaryDnsIp4Address.get(), pSecondaryDnsIp4Address.get());
+                       }
+                       else
+                       {
+                               // Primary DNS is null
+                       }
+               }
+               else
+               {
+                       SysLog(NID_NET, "Dns Address Scheme : None");
+               }
+
+               m->ReadInt(iter, &protocolType);
+               SysLog(NID_NET, "protocolType : %d", protocolType);
+
+               // NetEndPoint
+               m->ReadBool(iter, &isNull);
+               if (isNull)
+               {
+                       // NetEndPoint is null
+               }
+               else
+               {
+                       m->ReadInt(iter, &proxyAddressFamily);
+                       if (!ReadParam(m, iter, &proxyAddress))
+                       {
+                               return false;
+                       }
+                       m->ReadInt(iter, &port);
+
+                       // Set ProxyAddress
+                       if ((NetAddressFamily)proxyAddressFamily == NET_AF_IPV4)
+                       {
+                               pProxyIp4Address.reset(new (std::nothrow) Ip4Address(proxyAddress));
+                       }
+                       else
+                       {
+                               // Not supported yet.
+                               return false;
+                       }
+                       unique_ptr<NetEndPoint> pProxyEndPoint(new (std::nothrow) NetEndPoint(*pProxyIp4Address, port));
+
+                       SysLog(NID_NET, "SetProxyAddress() from Recieved NetAccountInfo");
+                       r->SetProxyAddress(pProxyEndPoint.get());
+               }
+
+               return true;
+       }
+
+    static void Log(const param_type& p, std::string* l)
+       {
+       }
+};
+}
+
+#endif // _FNET_INTERNAL_CONNECTIVITY_IPC_PARAM_TRAITS_H_
diff --git a/src/inc/FNet_Ip4AddressImpl.h b/src/inc/FNet_Ip4AddressImpl.h
new file mode 100644 (file)
index 0000000..c940189
--- /dev/null
@@ -0,0 +1,159 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               _FNetIp4AddressImpl.h
+ * @brief              This is the header file for the _Ip4AddressImpl class.
+ */
+
+#ifndef _FNET_INTERNAL_IP4_ADDRESS_IMPL_H_
+#define _FNET_INTERNAL_IP4_ADDRESS_IMPL_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+} } // Tizen::Base
+
+
+namespace Tizen { namespace Net
+{
+class Ip4Address;
+
+class _Ip4AddressImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       _Ip4AddressImpl(const Tizen::Base::String& ipAddr);
+
+       /**
+        * This is the constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       _Ip4AddressImpl(unsigned long ipAddr);
+
+       /**
+        * This is the copy constructor for the %_Ip4AddressImpl class.
+        *
+        * @since 2.1
+        * @param[in]   rhs                     An instance of the %_Ip4AddressImpl class
+        */
+       _Ip4AddressImpl(const _Ip4AddressImpl& rhs);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_Ip4AddressImpl(void);
+
+public:
+       /**
+        * @see                 Ip4Address::GetNetAddressFamily()
+        */
+       NetAddressFamily GetNetAddressFamily(void) const;
+
+       /**
+        * @see                 Ip4Address::GetAddress()
+        */
+       result GetAddress(Tizen::Base::ByteBuffer& ipAddr) const;
+
+       /**
+        * @see                 Ip4Address::GetAddress()
+        */
+       result GetAddress(unsigned long& ipAddr) const;
+
+       /**
+        * @see                 Ip4Address::ToString()
+        */
+       Tizen::Base::String ToString(void) const;
+
+       /**
+        * @see                 Ip4Address::operator =()
+        */
+       _Ip4AddressImpl& operator =(const _Ip4AddressImpl& ip4AddressImpl);
+
+       /**
+        * @see                 Ip4Address::Equals()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * @see                 Ip4Address::GetHashCode()
+        */
+       virtual int GetHashCode(void) const;
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // This query interface returns current status of Ip4Address instance
+       // whether valid IP Address is allocated
+       //
+       // @since                       1.0
+       // @return                      @c true if the IP Address is valid, @n
+       //                                      else @c false
+       //
+       bool IsValid(void) const;
+
+public:
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _Ip4AddressImpl
+     * @param[in]   ip4Address            An instance of Ip4Address
+     */
+       static _Ip4AddressImpl* GetInstance(Ip4Address& ip4Address);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _Ip4AddressImpl
+     * @param[in]   ip4Address     An instance of Ip4Address
+     */
+       static const _Ip4AddressImpl* GetInstance(const Ip4Address& ip4Address);
+
+private:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        */
+       _Ip4AddressImpl(void);
+
+private:
+       unsigned long __address; // IPv4 address in host byte order
+       Tizen::Base::String __addressInTextualFormat;
+       bool __isValid;
+}; // _Ip4AddressImpl
+
+} } // Tizen::Net
+
+#endif // _FNET_INTERNAL_IP4_ADDRESS_IMPL_H_
diff --git a/src/inc/FNet_ManagedNetConnectionImpl.h b/src/inc/FNet_ManagedNetConnectionImpl.h
new file mode 100644 (file)
index 0000000..806da78
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNet_ManagedNetConnectionImpl.h
+ * @brief              This is the header file for the _ManagedNetConnectionImpl class.
+ */
+
+#ifndef _FNET_INTERNAL_MANAGED_NET_CONNECTION_IMPL_H_
+#define _FNET_INTERNAL_MANAGED_NET_CONNECTION_IMPL_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FNetNetTypes.h>
+
+namespace Tizen { namespace Net
+{
+class IManagedNetConnectionEventListener;
+class NetConnectionInfo;
+class ManagedNetConnection;
+class _NetConnectionManagerImpl;
+
+class _ManagedNetConnectionImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       virtual ~_ManagedNetConnectionImpl(void);
+
+public:
+
+       /**
+        * @see                 ManagedNetConnection::SetManagedNetConnectionEventListener()
+        */
+       result SetManagedNetConnectionEventListener(IManagedNetConnectionEventListener* pListener);
+
+       /**
+        * @see                 ManagedNetConnection::GetNetAccountId()
+        */
+       NetAccountId GetNetAccountId(void) const;
+
+       /**
+        * @see                 ManagedNetConnection::GetConnectionState()
+        */
+       NetConnectionState  GetConnectionState(void) const;
+
+       // For blocking socket - Query connection state via IPC
+       NetConnectionState  QueryConnectionState(Tizen::Base::String& devName) const;
+
+       /**
+        * @see                 ManagedNetConnection::GetNetConnectionInfo()
+        */
+       const NetConnectionInfo* GetNetConnectionInfo(void) const;
+
+       /**
+        * Starts
+        *
+        * @since 2.1
+        * @return              An error code
+        *
+        * @exception   E_SUCCESS               The method wa successful.
+        */
+       result Start(void);
+
+public:
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _ManagedNetConnectionImpl
+     * @param[in]   managedNetConnection            An instance of ManagedNetConnection
+     */
+       static _ManagedNetConnectionImpl* GetInstance(ManagedNetConnection& managedNetConnection);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _ManagedNetConnectionImpl
+     * @param[in]   managedNetConnection     An instance of ManagedNetConnection
+     */
+       static const _ManagedNetConnectionImpl* GetInstance(const ManagedNetConnection& managedNetConnection);
+
+private:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        */
+       _ManagedNetConnectionImpl(const ManagedNetConnection* pConnection);
+
+private:
+       static ManagedNetConnection* CreateInstanceN(void);
+
+private:
+       /**
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of _ManagedNetConnectionImpl
+        */
+       _ManagedNetConnectionImpl(const _ManagedNetConnectionImpl& rhs);
+
+       /**
+        * This is the assignment operator.
+        *
+        * @param[in]   rhs             An instance of the Socket
+        */
+       _ManagedNetConnectionImpl& operator =(const _ManagedNetConnectionImpl& rhs);
+
+private:
+       bool __isRefAdded;
+       const ManagedNetConnection* __pConnection;
+       IManagedNetConnectionEventListener* __pListener;
+
+       friend class ManagedNetConnection;
+       friend class _NetConnectionManagerImpl;
+}; // _ManagedNetConnectionImpl
+
+} }  //Tizen::Net
+
+#endif // _FNET_INTERNAL_MANAGED_NET_CONNECTION_IMPL_H_
diff --git a/src/inc/FNet_NetConnectionImpl.h b/src/inc/FNet_NetConnectionImpl.h
new file mode 100644 (file)
index 0000000..4f468d1
--- /dev/null
@@ -0,0 +1,177 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNet_NetConnectionImpl.h
+ * @brief              This is the header file for the _NetConnectionImpl class.
+ */
+
+#ifndef _FNET_INTERNAL_NET_CONNECTION_IMPL_H_
+#define _FNET_INTERNAL_NET_CONNECTION_IMPL_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FNetNetTypes.h>
+
+namespace Tizen { namespace Net
+{
+class NetConnection;
+class NetConnectionInfo;
+class INetConnectionEventListener;
+class _NetConnectionEvent;
+class _SystemNetConnection;
+
+class _NetConnectionImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        * @remarks             After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+               _NetConnectionImpl(void);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_NetConnectionImpl(void);
+
+       /**
+        * @see                 NetConnection::Construct()
+        */
+       result Construct(NetConnection* pNetConnection, NetAccountId netAccountId);
+
+public:
+       /**
+        * @see                 NetConnection::Construct()
+        */
+       result AddNetConnectionListener(INetConnectionEventListener& listener);
+
+       /**
+        * @see                 NetConnection::Construct()
+        */
+       result RemoveNetConnectionListener(INetConnectionEventListener& listener);
+
+       /**
+        * @see                 NetConnection::Construct()
+        */
+       result Start(void);
+
+       /**
+        * @see                 NetConnection::Construct()
+        */
+       result Stop(void);
+
+       /**
+        * @see                 NetConnection::Construct()
+        */
+       result Close(void);
+
+       /**
+        * @see                 NetConnection::GetNetAccountId()
+        */
+       NetAccountId GetNetAccountId(void) const;
+
+       /**
+        * @see                 NetConnection::GetNetConnectionInfo()
+        */
+       const NetConnectionInfo* GetNetConnectionInfo(void);
+
+       /**
+        * @see                 NetConnection::GetNetConnectionInfoN()
+        */
+       static NetConnectionInfo* GetNetConnectionInfoN(NetAccountId netAccountId);
+
+       /**
+        * @see                 NetConnection::GetAllNetConnectionInfoN()
+        */
+       static Tizen::Base::Collection::IList* GetAllNetConnectionInfoN(void);
+
+       /**
+        * @see                 NetConnection::GetConnectionState()
+        */
+       NetConnectionState  GetConnectionState(void) const;
+
+       Tizen::Base::String GetProxyAddress(void) const;
+
+       /**
+        * Copies an instance.
+        *
+        *@since 2.1
+        */
+       NetConnection* CopyInstanceN(void);
+
+public:
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _NetConnectionImpl
+     * @param[in]   netConnection            An instance of NetConnection
+     */
+       static _NetConnectionImpl* GetInstance(NetConnection& netConnection);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _NetConnectionImpl
+     * @param[in]   netConnection     An instance of NetConnection
+     */
+       static const _NetConnectionImpl* GetInstance(const NetConnection& netConnection);
+
+private:
+       void UpdateNetConnectionInfo(NetConnectionState state);
+
+private:
+       /**
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of _NetConnectionImpl
+        */
+       _NetConnectionImpl(const _NetConnectionImpl& rhs);
+
+       /**
+        * This is the assignment operator. Do @b not use directly.
+        *
+        * @param[in]   rhs                     An instance of _NetConnectionImpl
+        */
+       _NetConnectionImpl& operator =(const _NetConnectionImpl& rhs);
+
+private:
+       NetConnection* __pNetConnection;
+       NetAccountId __netAccountId;
+       Tizen::Base::String __netAccountName;
+       bool __isOwner;
+       bool __isClosed;
+       NetConnectionInfo __netConnectionInfo;
+       _SystemNetConnection* __pSystemNetConnection;
+       _NetConnectionEvent* __pEvent;
+
+       friend class _NetConnectionEvent;
+}; // _NetConnectionImpl
+
+} } // Tizen::Net
+
+#endif // _FNET_INTERNAL_NET_CONNECTION_IMPL_H_
diff --git a/src/inc/FNet_NetConnectionInfoImpl.h b/src/inc/FNet_NetConnectionInfoImpl.h
new file mode 100644 (file)
index 0000000..5829a49
--- /dev/null
@@ -0,0 +1,225 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_NetConnectionInfoImpl.cpp
+ * @brief              This is the implementation for the _NetConnectionInfoImpl class.
+ */
+
+#ifndef _FNET_INTERNAL_NET_CONNECTION_INFO_IMPL_H_
+#define _FNET_INTERNAL_NET_CONNECTION_INFO_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FNetNetTypes.h>
+
+namespace Tizen { namespace Net {
+class IpAddress;
+class Ip4Address;
+class NetConnectionInfo;
+class _NetConnectionManagerImpl;
+class _SystemNetConnection;
+class _DefaultSystemNetConnection;
+class _PsSystemNetConnection;
+class _UsbSystemNetConnection;
+class _WifiSystemNetConnection;
+class _WifiDirectSystemNetConnection;
+
+class _NetConnectionInfoImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        */
+               _NetConnectionInfoImpl(void);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_NetConnectionInfoImpl(void);
+
+       /**
+        * @see                 NetConnectionInfo::GetBearerType()
+        */
+        NetBearerType GetBearerType(void) const ;
+
+       /**
+        * @see                 NetConnectionInfo::GetProtocolType()
+        */
+        NetProtocolType GetProtocolType(void) const ;
+
+       /**
+        * @see                 NetConnectionInfo::GetAccessPointName()
+        */
+       Tizen::Base::String GetAccessPointName(void) const;
+
+       /**
+        * @see                 NetConnectionInfo::GetLocalAddressScheme()
+        */
+       NetAddressScheme GetLocalAddressScheme(void) const;
+
+       /**
+        * @see                 NetConnectionInfo::GetLocalAddress()
+        */
+       const IpAddress*  GetLocalAddress(void) const;
+
+       /**
+        * @see                 NetConnectionInfo::GetDnsAddressScheme()
+        */
+       NetAddressScheme  GetDnsAddressScheme(void) const;
+
+       /**
+        * @see                 NetConnectionInfo::GetPrimaryDnsAddress()
+        */
+       const IpAddress* GetPrimaryDnsAddress(void) const;
+
+       /**
+        * @see                 NetConnectionInfo::GetSecondaryDnsAddress()
+        */
+       const IpAddress* GetSecondaryDnsAddress(void) const;
+
+       /**
+        * @see                 NetConnectionInfo::GetSubnetMaskAddress()
+        */
+       const IpAddress* GetSubnetMaskAddress(void) const;
+
+       /**
+        * @see                 NetConnectionInfo::GetDefaultGatewayAddress()
+        */
+       const IpAddress* GetDefaultGatewayAddress(void) const;
+
+       /**
+        * @since 2.1
+        * @return              A device name.
+        */
+       Tizen::Base::String GetDeviceName(void) const;
+
+       /**
+        * @since 2.1
+        * @return              A proxy address.
+        */
+       Tizen::Base::String GetProxyAddress(void) const;
+
+       void Update(void* pProfileHandle, bool isDefault = false);
+
+public:
+       static NetConnectionInfo* CreateNetConnectionInfoN(void* pProfileHandle);
+
+public:
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _NetConnectionInfoImpl
+     * @param[in]   netConnectionInfo            An instance of NetConnectionInfo
+     */
+       static _NetConnectionInfoImpl* GetInstance(NetConnectionInfo& netConnectionInfo);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _NetConnectionInfoImpl
+     * @param[in]   netConnectionInfo     An instance of NetConnectionInfo
+     */
+       static const _NetConnectionInfoImpl* GetInstance(const NetConnectionInfo& netConnectionInfo);
+
+public:
+       /**
+        * @see                 NetConnectionInfo::NetConnectionInfo()
+        */
+       _NetConnectionInfoImpl(const _NetConnectionInfoImpl& rhs);
+
+       /**
+        * @see                 NetConnectionInfo::operator =()
+        */
+       _NetConnectionInfoImpl& operator =(const _NetConnectionInfoImpl& rhs);
+
+       /**
+        * @see                 NetConnectionInfo::Equals()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * @see                 NetConnectionInfo::GetHashCode()
+        */
+       virtual int GetHashCode(void) const;
+
+private:
+       void CopyFrom(const _NetConnectionInfoImpl* pSource);
+
+       void Clear(void);
+
+       void SetBearerType(NetBearerType bearerType);
+
+       void SetProtocolType(NetProtocolType protocolType);
+
+       void SetAccessPointName(const Tizen::Base::String& apn);
+
+       void SetLocalAddressScheme(NetAddressScheme localAddressScheme);
+
+       void SetDnsAddressScheme(NetAddressScheme dnsAddressScheme);
+
+       void SetLocalAddress(const Tizen::Base::String& localAddress);
+
+       void SetSubnetMaskAddress(const Tizen::Base::String& localAddress);
+
+       void SetDefaultGatewayAddress(const Tizen::Base::String& localAddress);
+
+       void SetPrimaryDnsAddress(const Tizen::Base::String& primaryDnsAddress);
+
+       void SetSecondaryDnsAddress(const Tizen::Base::String& secondaryDnsAddress);
+
+       void SetProxyAddress(const Tizen::Base::String& proxyAddress);
+
+       void SetDeviceName(const Tizen::Base::String& deviceName);
+
+private:
+       NetBearerType __bearerType;
+       NetProtocolType __protocolType;
+
+       Tizen::Base::String __apn;
+       Tizen::Base::String __deviceName;
+       Tizen::Base::String __proxyAddress;
+
+       NetAddressScheme __localAddressScheme;
+       NetAddressScheme __dnsAddressScheme;
+
+       std::unique_ptr<IpAddress> __pLocalAddress;
+       std::unique_ptr<IpAddress> __pSubnetMaskAddress;
+       std::unique_ptr<IpAddress> __pDefaultGatewayAddress;
+       std::unique_ptr<IpAddress> __pPrimaryDnsAddress;
+       std::unique_ptr<IpAddress> __pSecondaryDnsAddress;
+
+       friend class _NetConnectionManagerImpl;
+       friend class _SystemNetConnection;
+       friend class _DefaultSystemNetConnection;
+       friend class _PsSystemNetConnection;
+       friend class _UsbSystemNetConnection;
+       friend class _WifiSystemNetConnection;
+       friend class _WifiDirectSystemNetConnection;
+}; // _NetConnectionInfoImpl
+
+} } //Tizen::Net
+
+#endif // _FNET_INTERNAL_NET_CONNECTION_INFO_IMPL_H_
diff --git a/src/inc/FNet_NetConnectionManagerImpl.h b/src/inc/FNet_NetConnectionManagerImpl.h
new file mode 100644 (file)
index 0000000..d799444
--- /dev/null
@@ -0,0 +1,218 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNet_NetConnectionManagerImpl.h
+ * @brief              This is the header file for the _NetConnectionManagerImpl class.
+ */
+
+#ifndef _FNET_INTERNAL_NET_CONNECTION_MANAGER_IMPL_H_
+#define _FNET_INTERNAL_NET_CONNECTION_MANAGER_IMPL_H_
+
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FBaseRtITimerEventListener.h>
+#include <FNetNetTypes.h>
+#include <FNetNetConnectionInfo.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+} } // Tizen::Base
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class Timer;
+} } } // Tizen::Base::Runtime
+
+namespace Tizen { namespace Net {
+class NetConnection;
+class NetConnectionInfo;
+class NetConnectionManager;
+class ManagedNetConnection;
+class IManagedNetConnectionEventListener;
+class _NetAccountManagerImpl;
+class _ManagedNetConnectionImpl;
+class _SystemNetConnection;
+class _NetConnectionEvent;
+
+class _NetConnectionManagerImpl
+       : public Tizen::Base::Object
+       , virtual public Tizen::Base::Runtime::ITimerEventListener
+{
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @remarks             After creating an instance of this class, the
+        *                                              Construct() method must be called explicitly to initialize this instance.
+        * @see                 Construct()
+        */
+       _NetConnectionManagerImpl(void);
+
+       /**
+        *      This is the destructor for this class.
+        *      This method closes the NetConnectionManagerImpl instance and also releases the resources associated with it.
+        */
+       virtual ~_NetConnectionManagerImpl(void);
+
+       /**
+        * @see                         NetConnectionManager::Construct()
+        */
+       result Construct(void);
+
+public:
+       void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
+
+public:
+       /**
+        * @see                 NetConnectionManager::CreateNetConnectionN()
+        */
+       NetConnection* CreateNetConnectionN(NetAccountId netAccountId);
+
+       /**
+        * @see                 NetConnectionManager::GetManagedNetConnectionN()
+        */
+       ManagedNetConnection* GetManagedNetConnectionN(void) const;
+
+       /**
+        * @see                 NetConnectionManager::GetNetPreference()
+        */
+       NetPreferenceType GetNetPreference(void) const;
+
+       /**
+        * @see                 NetConnectionManager::SetNetPreference()
+        */
+       result SetNetPreference(NetPreferenceType netPreference);
+
+       /**
+        * @see                 NetConnectionManager::GetNetConnectionInfoN()
+        */
+       static NetConnectionInfo* GetNetConnectionInfoN(NetAccountId netAccountId) ;
+
+       /**
+        * @see                 NetConnectionManager::GetAllNetConnectionInfoN()
+        */
+       static Tizen::Base::Collection::IList* GetAllNetConnectionInfoN(void) ;
+
+       /**
+        * Checks whether current mode is Default Mode
+        *
+        * @since 2.1
+        * @return              Current mode.
+        */
+       static bool IsDefaultMode(void);
+
+       static Tizen::Base::String GetProxyAddress(void);
+
+       static _NetConnectionManagerImpl* GetInstance(void);
+
+public:
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _NetConnectionManagerImpl
+     * @param[in]   netConnectionManager            An instance of NetConnectionManager
+     */
+       static _NetConnectionManagerImpl* GetInstance(NetConnectionManager& netConnectionManager);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _NetConnectionManagerImpl
+     * @param[in]   netConnectionManager     An instance of NetConnectionManager
+     */
+       static const _NetConnectionManagerImpl* GetInstance(const NetConnectionManager& netConnectionManager);
+
+private:
+       /**
+        * Sets the application-wise default account ID to the one specified by the input argument value.
+        *
+        * @since 2.1
+        * @return              An error code
+        * @param[in]   accountId                       The network account
+        * @exception   E_SUCCESS                       The method was successful.
+        * @exception   E_INVALID_ARG           The specified @c netAccountId is invalid.
+        * @exception   E_SYSTEM                        An internal error occurred.
+        */
+       result SetManagedNetAccountId(NetAccountId netAccountId);
+
+       NetAccountId GetManagedNetAccountId(void) const;
+
+       NetConnectionState GetManagedNetConnectionState(void) const;
+
+       // For blocking socket - Query connection state via IPC
+       NetConnectionState QueryManagedNetConnectionState(Tizen::Base::String& devName) const;
+
+       const NetConnectionInfo* GetManagedNetConnectionInfo(void);
+
+       result AddManagedNetConnectionEventListener(IManagedNetConnectionEventListener& listener, const ManagedNetConnection* pConnection);
+
+       result RemoveManagedNetConnectionEventListener(IManagedNetConnectionEventListener& listener);
+
+       result AddRefManagedNetConnection(void);
+
+       void ReleaseManagedNetConnection(void);
+
+       static void InitSingleton(void);
+
+private:
+       /**
+        * This is the copy constructor for this class. @n
+        * Do @b not use directly.
+        *
+        */
+       _NetConnectionManagerImpl(const _NetConnectionManagerImpl& rhs);
+
+       /**
+        * This is the assignment operator for this class. @n
+        * Do @b not use directly.
+        *
+        */
+       _NetConnectionManagerImpl& operator= (const _NetConnectionManagerImpl& rhs);
+
+private:
+       NetPreferenceType __managedNetPreference;
+       NetAccountId __managedNetAccountId;
+       NetConnectionInfo       __managedNetConnectionInfo;
+       int __managedNetRefCount;
+       bool __isManagedNetDefaultMode;
+       _SystemNetConnection* __pManagedSystemNetConnection;
+       _NetConnectionEvent* __pManagedNetConnectionEvent;
+       Tizen::Base::Runtime::Timer* __pManagedNetConnectionTimer;
+       _SystemNetConnection* __pDefaultConnection;
+       _SystemNetConnection* __pWifiConnection;
+       _SystemNetConnection* __pPsConnection;
+
+       static _NetConnectionManagerImpl* __pInstance;
+
+       friend class NetConnectionManager;
+       friend class NetAccountManager;
+       friend class _NetAccountManagerImpl;
+       friend class _ManagedNetConnectionImpl;
+}; // _NetConnectionManagerImpl
+
+} } //Tizen::Net
+
+#endif // _FNET_INTERNAL_NET_CONNECTION_MANAGER_IMPL_H_
diff --git a/src/inc/FNet_NetEndPointImpl.h b/src/inc/FNet_NetEndPointImpl.h
new file mode 100644 (file)
index 0000000..2e51495
--- /dev/null
@@ -0,0 +1,160 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_NetEndPointImpl.h
+ * @brief              This is the header file for the _NetEndPointImpl class.
+ */
+
+#ifndef _FNET_INTERNAL_NET_END_POINT_IMPL_H_
+#define _FNET_INTERNAL_NET_END_POINT_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseDataType.h>
+#include <FBaseObject.h>
+#include <FNetNetTypes.h>
+
+namespace Tizen { namespace Base
+{
+class String;
+} } // Tizen::Base
+
+namespace Tizen { namespace Net
+{
+class IpAddress;
+class NetEndPoint;
+
+class _NetEndPointImpl
+       : public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the constructor for this class.
+        *
+        * @since 2.1
+        */
+       _NetEndPointImpl(const IpAddress& ipAddress, unsigned short port);
+
+       /**
+        * This is the copy constructor for the %_NetEndPointImpl class.
+        *
+        * @since 2.1
+        * @param[in]   rhs                     An instance of the %_NetEndPointImpl class
+        */
+       _NetEndPointImpl(const _NetEndPointImpl& rhs);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since 2.1
+        */
+       virtual ~_NetEndPointImpl(void);
+
+public:
+       /**
+        * @see                 NetEndPoint::GetNetAddressFamily()
+        */
+       NetAddressFamily GetNetAddressFamily(void) const;
+
+       /**
+        * @see                 NetEndPoint::GetPort()
+        */
+       unsigned short GetPort(void) const;
+
+       /**
+        * @see                 NetEndPoint::GetAddress()
+        */
+       IpAddress* GetAddress(void) const;
+
+       /**
+        * @see                 NetEndPoint::GetNetEndPoint()
+        */
+       Tizen::Base::String GetNetEndPoint(void) const;
+
+public:
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // Checks the current status of NetEndPoint - whether IpAddress and port info is valid or not.
+       //
+       // @since 2.1
+       // @return              @c true if valid IpAddress and valid port number is inserted and the construction is complete @n
+       //                              @c false, otherwise
+       //
+       bool IsValid(void) const;
+
+       //
+       // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // Changes IpAddress and port of Constructed NetEndPoint
+       //
+       // @return              An error code
+       // @remark              @c true is returned only if valid IpAddress & valid port number is inserted & construction
+       //                              is complete.
+       //
+       result Update(const IpAddress& ipAddress, unsigned short port);
+
+       /**
+        * @see                 NetEndPoint::operator =()
+        */
+       _NetEndPointImpl& operator =(const _NetEndPointImpl& rhs);
+
+       /**
+        * @see                 NetEndPoint::Equals()
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * @see                 NetEndPoint::GetHashCode()
+        */
+       virtual int GetHashCode(void) const;
+
+public:
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to _NetEndPointImpl
+     * @param[in]   netEndPoint            An instance of NetEndPoint
+     */
+       static _NetEndPointImpl* GetInstance(NetEndPoint& netEndPoint);
+
+    /**
+     * Gets the Impl instance.
+     *
+     * @since 2.1
+     * @return              The pointer to  _NetEndPointImpl
+     * @param[in]   netEndPoint     An instance of NetEndPoint
+     */
+       static const _NetEndPointImpl* GetInstance(const NetEndPoint& netEndPoint);
+
+private:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since 2.1
+        */
+       _NetEndPointImpl(void);
+
+private:
+       std::unique_ptr<IpAddress> __pIpAddress;
+       unsigned short __port;
+
+}; // _NetEndPointImpl
+
+} } // Tizen::Net
+
+#endif //  _FNET_INTERNAL_NET_END_POINT_IMPL_H_
diff --git a/src/inc/FNet_NetExporter.h b/src/inc/FNet_NetExporter.h
new file mode 100644 (file)
index 0000000..fcc27c4
--- /dev/null
@@ -0,0 +1,65 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_NetExporter.h
+ * @brief              This is the header file for the %_NetExporter class.
+ */
+
+#ifndef _FNET_INTERNAL_NET_EXPORTER_H_
+#define _FNET_INTERNAL_NET_EXPORTER_H_
+
+#include <FBaseDataType.h>
+#include <FOspConfig.h>
+
+namespace Tizen { namespace Net
+{
+class NetAccountInfo;
+
+class _OSP_EXPORT_ _NetExporter
+{
+public:
+       static result InitializeNetAccountInfo(NetAccountInfo* pAccountInfo, void* pProfileInfo);
+
+private:
+       /**
+        * This default constructor is intentionally declared as private because this class is not constructible.
+        */
+       _NetExporter(void);
+
+       /**
+        * This destructor is intentionally declared as private because this class is not constructible.
+        */
+       virtual ~_NetExporter(void);
+
+       /**
+        * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs             An instance of %_NetExporter
+        */
+       _NetExporter(const _NetExporter& rhs);
+
+       /**
+        * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+        *
+        * @param[in]   rhs                     An instance of %_NetExporter
+        */
+       _NetExporter& operator =(const _NetExporter& rhs);
+}; // _NetExporter
+
+} } // Tizen::Net
+
+#endif //  _FNET_INTERNAL_NET_EXPORTER_H_
diff --git a/src/inc/FNet_NetTypes.h b/src/inc/FNet_NetTypes.h
new file mode 100644 (file)
index 0000000..73c2d78
--- /dev/null
@@ -0,0 +1,50 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FNet_NetTypes.h
+ * @brief              This is the header file for defining types for the Tizen::Net namespace.
+ */
+
+#ifndef _FNET_INTERNAL_NET_TYPES_H_
+#define _FNET_INTERNAL_NET_TYPES_H_
+
+#include <FBaseString.h>
+
+namespace Tizen { namespace Net
+{
+
+typedef unsigned long IPV4Addr;
+
+static const int _MAX_IPV4_ADDRESS_STRING_LENGTH = 16; // The IPv4 address string length
+static const int _MAX_AUTH_ID_LENGTH = 44; // The user ID length
+static const int _MAX_AUTH_PASSWORD_LENGTH = 44; // The password length
+static const int _MAX_ACCOUNT_NAME_LENGTH = 40; // The network information(Access Point set) length
+static const int MAX_MAC_ADDRESS_LENGTH = 6; // Definition for WLAN 48-bit MAC address
+
+static const int  _DEFAULT_PS_ACCOUNT_ID = 1;
+static const int  _DEFAULT_MMS_ACCOUNT_ID = 2;
+static const int  _DEFAULT_WIFI_ACCOUNT_ID = 11;
+static const int  _DEFAULT_WIFI_DIRECT_ACCOUNT_ID = 12;
+static const int  _DEFAULT_USB_ACCOUNT_ID = 21;
+static const int  _CUSTOM_ACCOUNT_ID_START = 101;
+
+static const int _HASH_CODE_INITIAL_VALUE = 17;
+static const int _HASH_CODE_COEFFICIENT_VALUE = 37;
+
+} } // Tizen::Net
+
+#endif // _FNET_INTERNAL_NET_TYPES_H_
diff --git a/src/sockets/FNetSockSecureSocket.cpp b/src/sockets/FNetSockSecureSocket.cpp
new file mode 100644 (file)
index 0000000..c97853e
--- /dev/null
@@ -0,0 +1,317 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSockSecureSocket.cpp
+ * @brief              This is the implementation for the SecureSocket class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FNetNetTypes.h>
+#include <FNetSockSecureSocket.h>
+#include <FSec_AccessController.h>
+#include "FNetSock_SecureSocketImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Net;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+SecureSocket::SecureSocket(void)
+       : __pSecureSocketImpl(null)
+{
+}
+
+SecureSocket::~SecureSocket(void)
+{
+       delete __pSecureSocketImpl;
+       __pSecureSocketImpl = null;
+}
+
+result
+SecureSocket::Construct(const NetConnection& netConnection, NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
+                                       "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       SysAssertf(__pSecureSocketImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       unique_ptr<_SecureSocketImpl> pSecureSocketImpl(new (std::nothrow) _SecureSocketImpl(this));
+       SysTryReturn(NID_NET_SOCK, pSecureSocketImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+
+       r = pSecureSocketImpl->Construct(netConnection, addressFamily, socketType, protocol);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pSecureSocketImpl = pSecureSocketImpl.release();
+
+       return r;
+}
+
+result
+SecureSocket::Construct(NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
+                                       "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       SysAssertf(__pSecureSocketImpl == null,
+                       "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       unique_ptr<_SecureSocketImpl> pSecureSocketImpl(new (std::nothrow) _SecureSocketImpl(this));
+       SysTryReturn(NID_NET_SOCK, pSecureSocketImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+
+       r = pSecureSocketImpl->Construct(addressFamily, socketType, protocol);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       __pSecureSocketImpl = pSecureSocketImpl.release();
+
+       return r;
+}
+
+result
+SecureSocket::Close(void)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
+                                       "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pSecureSocketImpl->Close();
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+SecureSocket::Connect(const NetEndPoint& remoteEP)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
+                                       "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pSecureSocketImpl->Connect(remoteEP);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+SecureSocket::Send(ByteBuffer& buffer)
+{
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSecureSocketImpl->Send(buffer);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+SecureSocket::Send(void* pBuffer, int length, int& sentLength)
+{
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSecureSocketImpl->Send(pBuffer, length, sentLength);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+SecureSocket::Receive(ByteBuffer& buffer) const
+{
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSecureSocketImpl->Receive(buffer);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+SecureSocket::Receive(void* pBuffer, int length, int& rcvdLength) const
+{
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSecureSocketImpl->Receive(pBuffer, length, rcvdLength);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+SecureSocket::Bind(const NetEndPoint& localEP)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
+                                       "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pSecureSocketImpl->Bind(localEP);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+SecureSocket::Listen(int backLog)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
+                                       "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pSecureSocketImpl->Listen(backLog);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+SecureSocket*
+SecureSocket::AcceptN(void) const
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+       SecureSocket* pNewSocket = null;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, null, E_PRIVILEGE_DENIED,
+                                       "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       pNewSocket = __pSecureSocketImpl->AcceptN();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, pNewSocket, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pNewSocket;
+}
+
+result
+SecureSocket::Ioctl(NetSocketIoctlCmd cmd, unsigned long& pArg) const
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
+                                       "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pSecureSocketImpl->Ioctl(cmd, pArg);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+SecureSocket::AsyncSelectByListener(unsigned long socketEventType)
+{
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSecureSocketImpl->AsyncSelectByListener(socketEventType);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+SecureSocket::AddSecureSocketListener(ISecureSocketEventListener& listener)
+{
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSecureSocketImpl->AddSecureSocketListener(listener);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+SecureSocket::RemoveSecureSocketListener(ISecureSocketEventListener& listener)
+{
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSecureSocketImpl->RemoveSecureSocketListener(listener);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+SecureSocket::GetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int& optionValue) const
+{
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSecureSocketImpl->GetSockOpt(optionLevel, optionName, optionValue);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
+SecureSocket::SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int optionValue)
+{
+       SysAssertf(__pSecureSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSecureSocketImpl->SetSockOpt(optionLevel, optionName, optionValue);
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSockSocket.cpp b/src/sockets/FNetSockSocket.cpp
new file mode 100644 (file)
index 0000000..0c1c14c
--- /dev/null
@@ -0,0 +1,442 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSockSocket.cpp
+ * @brief              This is the implementation for the Socket class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FNetNetTypes.h>
+#include <FNetSockSocket.h>
+#include <FSec_AccessController.h>
+#include "FNetSock_SocketImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Net;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+Socket::Socket(void)
+       : __pSocketImpl(null)
+{
+}
+
+Socket::~Socket(void)
+{
+       delete __pSocketImpl;
+       __pSocketImpl = null;
+}
+
+result
+Socket::Construct(const NetConnection& netConnection, NetSocketAddressFamily addressFamily, NetSocketType socketType,
+                                 NetSocketProtocol protocol)
+{
+    SysAssertf(__pSocketImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+    result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
+
+       unique_ptr<_SocketImpl> pSocketImpl(new (std::nothrow) _SocketImpl(this));
+       SysTryReturnResult(NID_NET_SOCK, pSocketImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pSocketImpl->Construct(netConnection, addressFamily, socketType, protocol);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       __pSocketImpl = pSocketImpl.release();
+
+       return r;
+}
+
+result
+Socket::Construct(NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol)
+{
+    SysAssertf(__pSocketImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
+
+       unique_ptr<_SocketImpl> pSocketImpl(new (std::nothrow) _SocketImpl(this));
+       SysTryReturnResult(NID_NET_SOCK, pSocketImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pSocketImpl->Construct(addressFamily, socketType, protocol);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       __pSocketImpl = pSocketImpl.release();
+
+       return r;
+}
+
+result
+Socket::Close(void)
+{
+    SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+       r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       r = __pSocketImpl->Close();
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::Connect(const NetEndPoint& remoteEP)
+{
+    SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+    result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+    r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       r = __pSocketImpl->Connect(remoteEP);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::Send(ByteBuffer& buffer)
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->Send(buffer);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::Send(void* pBuffer, int length, int& sentLength)
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->Send(pBuffer, length, sentLength);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::SendTo(ByteBuffer& buffer, const NetEndPoint& remoteEP)
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->SendTo(buffer, remoteEP);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::SendTo(void* pBuffer, int length, const NetEndPoint& remoteEP, int& sentLength)
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->SendTo(pBuffer, length, remoteEP, sentLength);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::Receive(ByteBuffer& buffer) const
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->Receive(buffer);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::Receive(void* pBuffer, int length, int& rcvdLength) const
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->Receive(pBuffer, length, rcvdLength);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::ReceiveFrom(ByteBuffer& buffer, NetEndPoint& remoteEP) const
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->ReceiveFrom(buffer, remoteEP);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::ReceiveFrom(void* pBuffer, int length, NetEndPoint& remoteEP, int& rcvdLength) const
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->ReceiveFrom(pBuffer, length, remoteEP, rcvdLength);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::Bind(const NetEndPoint& localEP)
+{
+    SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+    r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       r = __pSocketImpl->Bind(localEP);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::Listen(int backLog)
+{
+    SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+    r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       r = __pSocketImpl->Listen(backLog);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+Socket*
+Socket::AcceptN(void) const
+{
+    SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       Socket* pNewSocket = null;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+    r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+    SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
+
+       pNewSocket = __pSocketImpl->AcceptN();
+       r = GetLastResult();
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, pNewSocket, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pNewSocket;
+}
+
+result
+Socket::Ioctl(NetSocketIoctlCmd cmd, unsigned long& pArg) const
+{
+    SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+    r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       r = __pSocketImpl->Ioctl(cmd, pArg);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::AsyncSelectByListener(unsigned long socketEventType)
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->AsyncSelectByListener(socketEventType);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::AddSocketListener(ISocketEventListener& listener)
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->AddSocketListener(listener);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::RemoveSocketListener(ISocketEventListener& listener)
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->RemoveSocketListener(listener);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+const NetEndPoint*
+Socket::GetPeerEndPoint(void)
+{
+    SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       NetEndPoint* pRemoteEP = null;
+
+       pRemoteEP = const_cast <NetEndPoint*>(__pSocketImpl->GetPeerEndPoint());
+       r = GetLastResult();
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, pRemoteEP, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pRemoteEP;
+}
+
+const NetEndPoint*
+Socket::GetLocalEndPoint(void)
+{
+    SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       NetEndPoint* pLocalEP = null;
+
+       pLocalEP = const_cast <NetEndPoint*>(__pSocketImpl->GetLocalEndPoint());
+       r = GetLastResult();
+       SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, pLocalEP, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pLocalEP;
+}
+
+result
+Socket::GetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int& pOptVal) const
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->GetSockOpt(optionLevel, optionName, pOptVal);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::GetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, LingerOption& optionValue) const
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->GetSockOpt(optionLevel, optionName, optionValue);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int pOptVal)
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->SetSockOpt(optionLevel, optionName, pOptVal);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, const LingerOption& optionValue)
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->SetSockOpt(optionLevel, optionName, optionValue);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+Socket::SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, const IpMulticastRequestOption& optionValue)
+{
+       SysAssertf(__pSocketImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketImpl->SetSockOpt(optionLevel, optionName, optionValue);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSockSocketIpMulticastRequestOption.cpp b/src/sockets/FNetSockSocketIpMulticastRequestOption.cpp
new file mode 100644 (file)
index 0000000..96d967d
--- /dev/null
@@ -0,0 +1,130 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSockSocketIpMulticastRequestOption.cpp
+ * @brief              This is the implementation for the IpMulticastRequestOption class.
+ */
+
+#include <FNetNetTypes.h>
+#include <FNetSockSocketIpMulticastRequestOption.h>
+#include <FBaseSysLog.h>
+#include "FNetSock_IpMulticastRequestOptionImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Net;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+IpMulticastRequestOption::IpMulticastRequestOption(const NetEndPoint& multicastAddress, const NetEndPoint& interfaceAddress)
+{
+       __pIpMulticastRequestOptionImpl = new (std::nothrow) _IpMulticastRequestOptionImpl(multicastAddress, interfaceAddress);
+       SysTryReturnVoidResult(NID_NET_SOCK, __pIpMulticastRequestOptionImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+IpMulticastRequestOption::~IpMulticastRequestOption(void)
+{
+               delete __pIpMulticastRequestOptionImpl;
+               __pIpMulticastRequestOptionImpl = null;
+}
+
+IpMulticastRequestOption::IpMulticastRequestOption(const IpMulticastRequestOption& rhs)
+{
+       __pIpMulticastRequestOptionImpl = new (std::nothrow) _IpMulticastRequestOptionImpl(*(rhs.__pIpMulticastRequestOptionImpl));
+       SysTryReturnVoidResult(NID_NET_SOCK, __pIpMulticastRequestOptionImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+IpMulticastRequestOption&
+IpMulticastRequestOption::operator =(const IpMulticastRequestOption& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pIpMulticastRequestOptionImpl = *rhs.__pIpMulticastRequestOptionImpl;
+
+       return *this;
+}
+
+result
+IpMulticastRequestOption::SetMulticastEndPoint(NetEndPoint& multicastAddress)
+{
+       result r = E_SUCCESS;
+
+       r = __pIpMulticastRequestOptionImpl->SetMulticastEndPoint(multicastAddress);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r,"Propagating.");
+
+       return r;
+}
+
+result
+IpMulticastRequestOption::SetInterfaceEndPoint(NetEndPoint& interfaceAddress)
+{
+       result r = E_SUCCESS;
+
+       r = __pIpMulticastRequestOptionImpl->SetInterfaceEndPoint(interfaceAddress);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r,"Propagating.");
+
+       return r;
+}
+
+const NetEndPoint*
+IpMulticastRequestOption::GetMulticastEndPoint(void) const
+{
+       return __pIpMulticastRequestOptionImpl->GetMulticastEndPoint();
+}
+
+const NetEndPoint*
+IpMulticastRequestOption::GetInterfaceEndPoint(void) const
+{
+       return __pIpMulticastRequestOptionImpl->GetInterfaceEndPoint();
+}
+
+bool
+IpMulticastRequestOption::Equals(const Object& obj) const
+{
+       const IpMulticastRequestOption* pRhs = dynamic_cast<const IpMulticastRequestOption*>(&obj);
+
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       const _IpMulticastRequestOptionImpl* pRhsImpl = _IpMulticastRequestOptionImpl::GetInstance(*pRhs);
+       if (pRhsImpl == null)
+       {
+               return false;
+       }
+
+       return __pIpMulticastRequestOptionImpl->Equals(*pRhsImpl);
+}
+
+int
+IpMulticastRequestOption::GetHashCode(void) const
+{
+       return __pIpMulticastRequestOptionImpl->GetHashCode();
+}
+
+IpMulticastRequestOption::IpMulticastRequestOption(void)
+{
+       __pIpMulticastRequestOptionImpl = new (std::nothrow) _IpMulticastRequestOptionImpl();
+       SysTryReturnVoidResult(NID_NET_SOCK, __pIpMulticastRequestOptionImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSockSocketLingerOption.cpp b/src/sockets/FNetSockSocketLingerOption.cpp
new file mode 100644 (file)
index 0000000..1f09205
--- /dev/null
@@ -0,0 +1,119 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSockSocketLingerOption.cpp
+ * @brief              This is the implementation for the LingerOption class.
+ */
+
+#include <FNetNetTypes.h>
+#include <FNetSockSocketLingerOption.h>
+#include <FBaseSysLog.h>
+#include "FNetSock_LingerOptionImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+LingerOption::LingerOption(bool enable, int seconds)
+{
+       __pLingerOptionImpl = new (std::nothrow) _LingerOptionImpl(enable, seconds);
+       SysTryReturnVoidResult(NID_NET_SOCK, __pLingerOptionImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+LingerOption::~LingerOption(void)
+{
+               delete __pLingerOptionImpl;
+               __pLingerOptionImpl = null;
+}
+
+LingerOption::LingerOption(const LingerOption& rhs)
+{
+       __pLingerOptionImpl = new (std::nothrow) _LingerOptionImpl(*(rhs.__pLingerOptionImpl));
+       SysTryReturnVoidResult(NID_NET_SOCK, __pLingerOptionImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+LingerOption&
+LingerOption::operator =(const LingerOption& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       *__pLingerOptionImpl = *rhs.__pLingerOptionImpl;
+
+       return *this;
+}
+
+bool
+LingerOption::Equals(const Object& obj) const
+{
+       const LingerOption* pRhs = dynamic_cast<const LingerOption*>(&obj);
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       const _LingerOptionImpl* pRhsImpl = _LingerOptionImpl::GetInstance(*pRhs);
+       if (pRhsImpl == null)
+       {
+               return false;
+       }
+
+       return __pLingerOptionImpl->Equals(*pRhsImpl);
+}
+
+int
+LingerOption::GetHashCode(void) const
+{
+       return __pLingerOptionImpl->GetHashCode();
+}
+
+void
+LingerOption::SetEnabled(bool on)
+{
+       __pLingerOptionImpl->__enabled = on;
+}
+
+void
+LingerOption::SetLingerTime(int seconds)
+{
+       __pLingerOptionImpl->__lingerTime = seconds;
+}
+
+int
+LingerOption::GetLingerTime(void) const
+{
+       return __pLingerOptionImpl->__lingerTime;
+}
+
+bool
+LingerOption::IsEnabled(void) const
+{
+       return __pLingerOptionImpl->__enabled;
+}
+
+LingerOption::LingerOption(void)
+{
+       __pLingerOptionImpl = new (std::nothrow) _LingerOptionImpl();
+       SysTryReturnVoidResult(NID_NET_SOCK, __pLingerOptionImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSockSocketUtility.cpp b/src/sockets/FNetSockSocketUtility.cpp
new file mode 100644 (file)
index 0000000..ea47197
--- /dev/null
@@ -0,0 +1,124 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSockSocketUtility.cpp
+ * @brief              This is the implementation for the SocketUtility class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FNetSockSocket.h>
+#include <FNetSockSecureSocket.h>
+#include <FNetSockSocketUtility.h>
+#include <FSec_AccessController.h>
+#include "FNetSock_SocketUtilityImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+SocketUtility::SocketUtility(void)
+       : __pSocketUtilityImpl(null)
+{
+}
+
+SocketUtility::~SocketUtility(void)
+{
+       delete __pSocketUtilityImpl;
+       __pSocketUtilityImpl = null;
+}
+
+result
+SocketUtility::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pSocketUtilityImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       unique_ptr<_SocketUtilityImpl> pSocketUtilityImpl(new (std::nothrow) _SocketUtilityImpl());
+       SysTryReturnResult(NID_NET_SOCK, pSocketUtilityImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pSocketUtilityImpl->Construct();
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       __pSocketUtilityImpl = pSocketUtilityImpl.release();
+
+       return r;
+}
+
+result
+SocketUtility::Select(IList* checkRead, IList* checkWrite, IList* checkError, int microSeconds)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_SOCKET);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       SysAssertf(__pSocketUtilityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pSocketUtilityImpl->Select(checkRead, checkWrite, checkError, microSeconds);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+unsigned short
+SocketUtility::HtoNS(unsigned short hostShort)
+{
+       ClearLastResult();
+
+       SysAssertf(__pSocketUtilityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pSocketUtilityImpl->HtoNS(hostShort);
+}
+
+unsigned long
+SocketUtility::HtoNL(unsigned long hostLong)
+{
+       ClearLastResult();
+
+       SysAssertf(__pSocketUtilityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pSocketUtilityImpl->HtoNL(hostLong);
+}
+
+unsigned short
+SocketUtility::NtoHS(unsigned short netShort)
+{
+       ClearLastResult();
+
+       SysAssertf(__pSocketUtilityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pSocketUtilityImpl->HtoNS(netShort);
+}
+
+unsigned long
+SocketUtility::NtoHL(unsigned long netLong)
+{
+       ClearLastResult();
+
+       SysAssertf(__pSocketUtilityImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pSocketUtilityImpl->NtoHL(netLong);
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSock_IpMulticastRequestOptionImpl.cpp b/src/sockets/FNetSock_IpMulticastRequestOptionImpl.cpp
new file mode 100644 (file)
index 0000000..b8f38d3
--- /dev/null
@@ -0,0 +1,259 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_IpMulticastRequestOptionImpl.cpp
+ * @brief              This is the implementation for the _IpMulticastRequestOptionImpl class.
+ */
+
+#include <FNetNetTypes.h>
+#include <FNetSockSocketIpMulticastRequestOption.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetEndPointImpl.h"
+#include "FNet_NetTypes.h"
+#include "FNetSock_IpMulticastRequestOptionImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+_IpMulticastRequestOptionImpl::_IpMulticastRequestOptionImpl(const NetEndPoint& multicastAddress, const NetEndPoint& interfaceAddress)
+{
+       ClearLastResult();
+
+       SysTryReturnVoidResult(NID_NET_SOCK, multicastAddress.GetAddress() != null, E_INVALID_ARG, "[E_INVALID_ARG] MulticastAddress is invalid.");
+       SysTryReturnVoidResult(NID_NET_SOCK, interfaceAddress.GetAddress() != null, E_INVALID_ARG, "[E_INVALID_ARG] InterfaceAddress is invalid.");
+
+       unique_ptr<NetEndPoint> pMulticastAddr(new (std::nothrow) NetEndPoint(multicastAddress));
+       SysTryReturnVoidResult(NID_NET, pMulticastAddr != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       unique_ptr<NetEndPoint> pInterfaceAddr(new (std::nothrow) NetEndPoint(interfaceAddress));
+       SysTryReturnVoidResult(NID_NET, pInterfaceAddr != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       __pMulticastAddr = move(pMulticastAddr);
+       __pInterfaceAddr = move(pInterfaceAddr);
+}
+
+_IpMulticastRequestOptionImpl::~_IpMulticastRequestOptionImpl(void)
+{
+}
+
+_IpMulticastRequestOptionImpl::_IpMulticastRequestOptionImpl(const _IpMulticastRequestOptionImpl& rhs)
+{
+       unique_ptr<NetEndPoint> pMulticastAddr;
+       unique_ptr<NetEndPoint> pInterfaceAddr;
+
+       if (rhs.__pMulticastAddr != null)
+       {
+               pMulticastAddr.reset(new (std::nothrow) NetEndPoint(*(rhs.__pMulticastAddr)));
+               SysTryReturnVoidResult(NID_NET_SOCK, pMulticastAddr != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       }
+
+       if (rhs.__pInterfaceAddr != null)
+       {
+               pInterfaceAddr.reset(new (std::nothrow) NetEndPoint(*(rhs.__pInterfaceAddr)));
+               SysTryReturnVoidResult(NID_NET_SOCK, pInterfaceAddr != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       }
+
+       __pMulticastAddr = move(pMulticastAddr);
+       __pInterfaceAddr = move(pInterfaceAddr);
+
+}
+
+_IpMulticastRequestOptionImpl&
+_IpMulticastRequestOptionImpl::operator =(const _IpMulticastRequestOptionImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       unique_ptr<NetEndPoint> pMulticastAddr;
+       unique_ptr<NetEndPoint> pInterfaceAddr;
+
+       if (rhs.__pMulticastAddr != null)
+       {
+               pMulticastAddr.reset(new (std::nothrow) NetEndPoint(*(rhs.__pMulticastAddr)));
+               SysTryReturn(NID_NET_SOCK, pMulticastAddr != null, *this, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       }
+
+       if (rhs.__pInterfaceAddr != null)
+       {
+               pInterfaceAddr.reset(new (std::nothrow) NetEndPoint(*(rhs.__pInterfaceAddr)));
+               SysTryReturn(NID_NET_SOCK, pInterfaceAddr != null, *this, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       }
+
+       __pMulticastAddr = move(pMulticastAddr);
+       __pInterfaceAddr = move(pInterfaceAddr);
+
+       return *this;
+}
+
+bool
+_IpMulticastRequestOptionImpl::Equals(const Tizen::Base::Object& obj) const
+{
+       const _IpMulticastRequestOptionImpl* pRhs = dynamic_cast <const _IpMulticastRequestOptionImpl*>(&obj);
+
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       if (__pMulticastAddr != null && pRhs->__pMulticastAddr != null)
+       {
+               if (!__pMulticastAddr->Equals(*pRhs->__pMulticastAddr))
+               {
+                       return false;
+               }
+       }
+       else if (__pMulticastAddr != null || pRhs->__pMulticastAddr != null)
+       {
+               return false;
+       }
+
+       if (__pInterfaceAddr != null && pRhs->__pInterfaceAddr != null)
+       {
+               if (!__pInterfaceAddr->Equals(*pRhs->__pInterfaceAddr))
+               {
+                       return false;
+               }
+       }
+       else if (__pInterfaceAddr != null || pRhs->__pInterfaceAddr != null)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+int
+_IpMulticastRequestOptionImpl::GetHashCode(void) const
+{
+       int hashCode = _HASH_CODE_INITIAL_VALUE;
+
+       if (__pMulticastAddr != null)
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __pMulticastAddr->GetHashCode();
+       }
+       else
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode;
+       }
+
+       if (__pInterfaceAddr != null)
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + __pInterfaceAddr->GetHashCode();
+       }
+       else
+       {
+               hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode;
+       }
+
+       return hashCode;
+}
+
+result
+_IpMulticastRequestOptionImpl::SetMulticastEndPoint(NetEndPoint& multicastAddress)
+{
+       SysTryReturnResult(NID_NET_SOCK, multicastAddress.GetAddress() != null, E_INVALID_ARG, "The null IpAddress of input NetEndPoint.");
+
+       result r = E_SUCCESS;
+       _NetEndPointImpl* pMulticastAddrImpl = null;
+
+       if (__pMulticastAddr == null)
+       {
+               unique_ptr<NetEndPoint> pMulticastAddr(new (std::nothrow) NetEndPoint(multicastAddress));
+               SysTryReturnResult(NID_NET_SOCK, pMulticastAddr != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               __pMulticastAddr = move(pMulticastAddr);
+       }
+       else
+       {
+               pMulticastAddrImpl = _NetEndPointImpl::GetInstance(*__pMulticastAddr);
+               r = pMulticastAddrImpl->Update(*(multicastAddress.GetAddress()), multicastAddress.GetPort());
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+       }
+
+       return r;
+}
+
+result
+_IpMulticastRequestOptionImpl::SetInterfaceEndPoint(NetEndPoint& interfaceAddress)
+{
+    SysTryReturnResult(NID_NET_SOCK, interfaceAddress.GetAddress() != null, E_INVALID_ARG, "The null IpAddress of input NetEndPoint.");
+
+       result r = E_SUCCESS;
+       _NetEndPointImpl* pInterfaceAddrImpl = null;
+
+       if (__pInterfaceAddr == null)
+       {
+               unique_ptr<NetEndPoint> pInterfaceAddr(new (std::nothrow) NetEndPoint(interfaceAddress));
+               SysTryReturnResult(NID_NET_SOCK, pInterfaceAddr != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               __pInterfaceAddr = move(pInterfaceAddr);
+       }
+       else
+       {
+               pInterfaceAddrImpl = _NetEndPointImpl::GetInstance(*__pInterfaceAddr);
+               r = pInterfaceAddrImpl->Update(*(interfaceAddress.GetAddress()), interfaceAddress.GetPort());
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+       }
+
+       return r;
+}
+
+const NetEndPoint*
+_IpMulticastRequestOptionImpl::GetMulticastEndPoint(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET_SOCK, __pMulticastAddr != null, null, E_INVALID_STATE, "[E_INVALID_STATE] Not a valid state.");
+
+       return __pMulticastAddr.get();
+}
+
+const NetEndPoint*
+_IpMulticastRequestOptionImpl::GetInterfaceEndPoint(void) const
+{
+       ClearLastResult();
+
+       SysTryReturn(NID_NET_SOCK, __pInterfaceAddr != null, null, E_INVALID_STATE, "[E_INVALID_STATE] Not a valid state.");
+
+       return __pInterfaceAddr.get();
+}
+
+_IpMulticastRequestOptionImpl*
+_IpMulticastRequestOptionImpl::GetInstance(IpMulticastRequestOption& ipMulticastRequestOption)
+{
+       return ipMulticastRequestOption.__pIpMulticastRequestOptionImpl;
+}
+
+const _IpMulticastRequestOptionImpl*
+_IpMulticastRequestOptionImpl::GetInstance(const IpMulticastRequestOption& ipMulticastRequestOption)
+{
+       return ipMulticastRequestOption.__pIpMulticastRequestOptionImpl;
+}
+
+_IpMulticastRequestOptionImpl::_IpMulticastRequestOptionImpl(void)
+       : __pMulticastAddr(null)
+       , __pInterfaceAddr(null)
+{
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSock_LingerOptionImpl.cpp b/src/sockets/FNetSock_LingerOptionImpl.cpp
new file mode 100644 (file)
index 0000000..d52ab1a
--- /dev/null
@@ -0,0 +1,135 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_LingerOptionImpl.cpp
+ * @brief              This is the implementation for the _LingerOptionImpl class.
+ */
+
+#include <FNetNetTypes.h>
+#include <FNetSockSocketLingerOption.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetTypes.h"
+#include "FNetSock_LingerOptionImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+_LingerOptionImpl::_LingerOptionImpl(bool enable, int seconds)
+       : __enabled(enable)
+       , __lingerTime(seconds)
+{
+}
+
+_LingerOptionImpl::_LingerOptionImpl(void)
+       : __enabled(false)
+       , __lingerTime(0)
+{
+}
+
+_LingerOptionImpl::~_LingerOptionImpl(void)
+{
+}
+
+_LingerOptionImpl::_LingerOptionImpl(const _LingerOptionImpl& rhs)
+{
+       __enabled = rhs.__enabled;
+       __lingerTime = rhs.__lingerTime;
+}
+
+_LingerOptionImpl&
+_LingerOptionImpl::operator =(const _LingerOptionImpl& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       __enabled = rhs.__enabled;
+       __lingerTime = rhs.__lingerTime;
+
+       return *this;
+}
+
+bool
+_LingerOptionImpl::Equals(const Tizen::Base::Object& obj) const
+{
+       const _LingerOptionImpl* pRhs = dynamic_cast <const _LingerOptionImpl*>(&obj);
+
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       if (__enabled != pRhs->__enabled ||
+               __lingerTime != pRhs->__lingerTime)
+       {
+               return false;
+       }
+
+       return true;
+}
+
+int
+_LingerOptionImpl::GetHashCode(void) const
+{
+       int hashCode = _HASH_CODE_INITIAL_VALUE;
+
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + ( __enabled ? 0 : 1);
+       hashCode = _HASH_CODE_COEFFICIENT_VALUE * hashCode + (__lingerTime);
+
+       return hashCode;
+}
+
+void
+_LingerOptionImpl::SetEnabled(bool on)
+{
+       __enabled = on;
+}
+
+void
+_LingerOptionImpl::SetLingerTime(int seconds)
+{
+       __lingerTime = seconds;
+}
+
+int
+_LingerOptionImpl::GetLingerTime(void) const
+{
+       return __lingerTime;
+}
+
+bool
+_LingerOptionImpl::IsEnabled(void) const
+{
+       return __enabled;
+}
+
+_LingerOptionImpl*
+_LingerOptionImpl::GetInstance(LingerOption& lingerOption)
+{
+       return lingerOption.__pLingerOptionImpl;
+}
+
+const _LingerOptionImpl*
+_LingerOptionImpl::GetInstance(const LingerOption& lingerOption)
+{
+       return lingerOption.__pLingerOptionImpl;
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.cpp b/src/sockets/FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.cpp
new file mode 100644 (file)
index 0000000..453d754
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.cpp
+ * @brief              This is the implementation file for _SecureSocketCustomNetConnectionEventListener class.
+ * @version     2.1
+ *
+ * This file contains the implementation of _SecureSocketCustomNetConnectionEventListener class.
+ */
+
+#include <unistd.h>
+#include <FNetNetConnectionInfo.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNetSock_SecureSocketEventArg.h"
+#include "FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.h"
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+_SecureSocketCustomNetConnectionEventListener::_SecureSocketCustomNetConnectionEventListener(void)
+       : __isStopped(false)
+       , __pNetConnectionInfo(null)
+       , __socketFd(INVALID_HANDLE)
+       , __pSecureSocketImpl(null)
+       , __pSecureSocketEvent(null)
+{
+}
+
+_SecureSocketCustomNetConnectionEventListener::~_SecureSocketCustomNetConnectionEventListener(void)
+{
+       __pSecureSocketEvent = null;
+       __pSecureSocketImpl = null;
+       __socketFd = INVALID_HANDLE;
+       __pNetConnectionInfo = null;
+       __isStopped = false;
+}
+
+void
+_SecureSocketCustomNetConnectionEventListener::OnNetConnectionStarted(NetConnection& netConnection, result r)
+{
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionStarted - Enter");
+
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionStarted - End");
+}
+
+void
+_SecureSocketCustomNetConnectionEventListener::OnNetConnectionStopped(NetConnection& netConnection, result r)
+{
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionStopped - Enter");
+
+       __isStopped = true;
+
+       int sockFd = INVALID_HANDLE;
+
+       _SecureSocketEventArg* pSecureSocketEventArg = null;
+
+       pSecureSocketEventArg = new (std::nothrow) _SecureSocketEventArg(__pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+       pSecureSocketEventArg->SetError(E_NETWORK_UNAVAILABLE);
+       __pSecureSocketEvent->Fire(*pSecureSocketEventArg);
+
+       if (__pSecureSocketImpl->__pGlibSocketInfo != null)
+       {
+               delete __pSecureSocketImpl->__pGlibSocketInfo;
+               __pSecureSocketImpl->__pGlibSocketInfo = null;
+       }
+
+       if (__pSecureSocketImpl->__socketFd > INVALID_HANDLE)
+       {
+               sockFd =__pSecureSocketImpl->__socketFd;
+               close(__pSecureSocketImpl->__socketFd);
+               __pSecureSocketImpl->__socketFd = INVALID_HANDLE;
+               SysLog(NID_NET_SOCK, "### SocketFd(%d) was closed..", sockFd);
+       }
+
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionStopped - End");
+}
+
+void
+_SecureSocketCustomNetConnectionEventListener::OnNetConnectionSuspended(NetConnection& netConnection)
+{
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionSuspended - Enter");
+
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionSuspended - End");
+}
+
+void
+_SecureSocketCustomNetConnectionEventListener::OnNetConnectionResumed(NetConnection& netConnection)
+{
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionResumed - Enter");
+
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionResumed - End");
+}
+
+void
+_SecureSocketCustomNetConnectionEventListener::SetConstructParams(_SecureSocketEvent* pSecureSocketEventSet, HSocket socketFdSet, _SecureSocketImpl* pSecureSocketImplSet)
+{
+       __pSecureSocketEvent = pSecureSocketEventSet;
+       __socketFd = socketFdSet;
+       __pSecureSocketImpl = pSecureSocketImplSet;
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.h b/src/sockets/FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.h
new file mode 100644 (file)
index 0000000..7332921
--- /dev/null
@@ -0,0 +1,185 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.h
+ * @brief              This is the header file for _SocketCustomNetConnectionListener class.
+ * @version            2.1
+ *
+ * This header file contains the declarations of _SocketCustomNetConnectionListener class.
+ * The _SocketCustomNetConnectionListener class can call listener's method. So, when an event is occurred,
+ * application can handle it appropriately.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_SECURE_SOCKET_CUSTOM_NET_CONNECTION_EVENT_LISTENER_H_
+#define _FNET_SOCK_INTERNAL_SECURE_SOCKET_CUSTOM_NET_CONNECTION_EVENT_LISTENER_H_
+
+
+#include <netinet/in.h>
+#include <FNetINetConnectionEventListener.h>
+#include "FNet_NetTypes.h"
+#include "FNetSock_SecureSocketEvent.h"
+
+namespace Tizen { namespace Net
+{
+
+class NetConnection;
+class NetConnectionInfo;
+} } // Tizen::Net
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+class _SecureSocketImpl;
+/**
+ * @class      _SecureSocketCustomNetConnectionEventListener FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.h "OspdOaf/FNet/H/FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.h"
+ * @brief      This class is the listener for network connection events.
+ *
+ * @since   2.1
+ *
+ * The _SecureSocketCustomNetConnectionEventListener class specifies the methods used for notifying different kinds
+ * of network connection events. These events are only sent out when NetConnectionEventListener is added to the NetConnection instance,
+ * and this is done by invoking the AddNetConnectionListener() method.
+ * When a network connection event is generated, a method of this interface is called.
+ * Thus, if an application does any job related to network connection events, override and use methods of this interface.
+ */
+
+class _SecureSocketCustomNetConnectionEventListener
+       : public Tizen::Net::INetConnectionEventListener
+       , virtual public Tizen::Base::Runtime::IEventListener
+{
+
+
+public:
+       _SecureSocketCustomNetConnectionEventListener(void);
+
+       virtual ~_SecureSocketCustomNetConnectionEventListener(void);
+
+
+public:
+       /**
+        * Called to notify the application that the network connection has been opened and connected. @n
+        * An application can send or receive the data.
+        *
+        * @since               1.0
+        * @param[in]   netConnection                           The network connection
+        * @param[in]   r                                                       An error code
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_TIMEOUT                                       An attempt to connect to the server has timed out.
+        * @exception   E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+        * @exception   E_DEVICE_UNAVAILABLE            The operation has failed due to a missing SIM card.
+        * @exception   E_NETWORK_UNAVAILABLE           The operation has failed because the device is in the offline mode.
+        * @exception   E_SERVICE_UNAVAILABLE           The operation has failed because the device is out of the coverage area or in an emergency mode.
+        * @exception   E_RESOURCE_UNAVAILABLE          The network resource is unavailable.
+        * @exception   E_AUTHENTICATION                        Authentication has failed.
+        * @exception   E_UNSUPPORTED_OPERATION         This operation is not supported.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @exception   E_NETWORK_FAILED                        Requested but an error is received from the network.
+        * @exception   E_INVALID_SIM_STATE                     The network has marked SIM as invalid for the CS and/or PS domain.
+        * @exception   E_FDN_MODE                                      The FDN is enabled and the number is not listed in the FDN list.
+        * @exception   E_DHCP                                          The DHCP operation has failed on WLAN.
+        * @exception   E_LINK                                          A link failure has occurred on WLAN.
+        */
+       void OnNetConnectionStarted(NetConnection& netConnection, result r);
+
+
+       /**
+        * Called to notify the application that the network connection has been closed and disconnected.
+        *
+        * @since               1.0
+        * @param[in]   netConnection                           The network connection
+        * @param[in]   r                                                       An error code
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_NETWORK_UNAVAILABLE           The operation has failed because the device is in the offline mode.
+        * @exception   E_SERVICE_UNAVAILABLE           The operation has failed because the device is out of the coverage area or in an emergency mode.
+        * @exception   E_RESOURCE_UNAVAILABLE          The network resource is unavailable.
+        * @exception   E_UNSUPPORTED_OPERATION         This operation is not supported.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @exception   E_NETWORK_FAILED                        Requested but an error is received from the network.
+        * @exception   E_INVALID_SIM_STATE                     The network has marked SIM as invalid for the CS and/or PS domain.
+        * @exception   E_FDN_MODE                                      The FDN is enabled and the number is not listed in the FDN list.
+        * @exception   E_DHCP                                          The DHCP operation has failed on WLAN.
+        * @exception   E_LINK                                          A link failure has occurred on WLAN.
+        * @remarks             This notification does not imply that the network is stopped permanently and cannot be used.
+        *                              The network can be restarted using NetConnection::Start().
+        *                              The NetConnection::Close() method is used to disconnect the connection
+        *              from the remote server or gateway permanently.
+        * @see                 Tizen::Net::NetConnection::Start(), Tizen::Net::NetConnection::Close()
+        *
+        */
+       void OnNetConnectionStopped(NetConnection& netConnection, result r);
+
+
+       /**
+        * Called to notify the application that the connection status has changed or is in an unstable or suspended state. @n
+        * Thus, an application may neither send nor receive data through Socket or Http until the network connection is resumed.
+        *
+        * @since               1.0
+        * @param[in]   netConnection           The network connection
+        *
+        */
+       void OnNetConnectionSuspended(NetConnection& netConnection);
+
+
+       /**
+        * Called to notify the application that the network has recovered from a suspended state. @n
+        * Thus, an application can send or receive data through Socket or Http from now on.
+        *
+        * @since               1.0
+        * @param[in]   netConnection           The network connection
+        */
+       void OnNetConnectionResumed(NetConnection& netConnection);
+
+
+       // Set Params
+       void SetConstructParams(_SecureSocketEvent* pSecureSocketEventSet, HSocket socketFdSet, _SecureSocketImpl* pSecureSocketImplSet);
+
+
+private:
+       /**
+        * This is the copy constructor.
+        *
+        * @param[in]   value   An instance of _SocketCustomNetConnectionEventListener
+        * @remarks             The function is declared but not implemented.
+        */
+       _SecureSocketCustomNetConnectionEventListener(const _SecureSocketCustomNetConnectionEventListener& value);
+
+
+private:
+       /**
+        * This is the assignment operator.
+        *
+        * @param[in]   rhs             An instance of _SocketCustomNetConnectionEventListener
+        * @remarks             The function is declared but not implemented.
+        */
+       _SecureSocketCustomNetConnectionEventListener& operator =(const _SecureSocketCustomNetConnectionEventListener& rhs);
+
+
+private:
+       bool __isStopped;
+
+       const NetConnectionInfo* __pNetConnectionInfo;
+       HSocket __socketFd;
+
+       _SecureSocketImpl* __pSecureSocketImpl;
+
+       _SecureSocketEvent* __pSecureSocketEvent;
+
+}; // _SecureSocketCustomNetConnectionEventListener
+
+} } } // Tizen::Net::Sockets
+
+#endif // _FNET_SOCK_INTERNAL_SECURE_SOCKET_CUSTOM_NET_CONNECTION_EVENT_LISTENER_H_
diff --git a/src/sockets/FNetSock_SecureSocketEvent.cpp b/src/sockets/FNetSock_SecureSocketEvent.cpp
new file mode 100644 (file)
index 0000000..984f006
--- /dev/null
@@ -0,0 +1,211 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SecureSocketEvent.cpp
+ * @brief              This is the implementation file for _SecureSocketEvent class.
+ * @version     2.1
+ *
+ * This file contains the implementation of _SecureSocketEvent class.
+ */
+
+#include <FNetSockISecureSocketEventListener.h>
+#include <FNetSockSocketTypes.h>
+#include <FBaseRtIEventArg.h>
+#include <FBaseSysLog.h>
+#include "FNetSock_SocketInternalHelp.h"
+#include "FNetSock_SecureSocketEventArg.h"
+#include "FNetSock_SecureSocketEvent.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+_SecureSocketEvent::_SecureSocketEvent(void)
+       : __pSecureSocketImpl(null)
+{
+}
+
+_SecureSocketEvent::~_SecureSocketEvent(void)
+{
+       __pSecureSocketImpl = null;
+}
+
+result
+_SecureSocketEvent::Construct(_SecureSocketImpl* pSecureSocketImpl)
+{
+       result r = E_SUCCESS;
+
+       r = _Event::Initialize();
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       SysTryReturnResult(NID_NET_SOCK, pSecureSocketImpl != null, E_SYSTEM, "pSecureSocketImpl is null.");
+
+       __pSecureSocketImpl = pSecureSocketImpl;
+
+       return r;
+}
+
+_SecureSocketImpl*
+_SecureSocketEvent::GetSocket(void)
+{
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_NET_SOCK, __pSecureSocketImpl != null, r = E_INVALID_SOCKET, E_INVALID_SOCKET, "[E_INVALID_SOCKET] SecureSocketImpl instance is null.");
+
+       return __pSecureSocketImpl;
+
+CATCH:
+       SetLastResult(r);
+       return null;
+}
+
+void
+_SecureSocketEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+       result r = E_SUCCESS;
+
+       SecureSocket* pSecureSocket = null;
+
+       ISecureSocketEventListener* pSocketEventListener = null;
+       IEventArg* pEventArg = null;
+       _SecureSocketEventArg* pSocketEventArg = null;
+
+       int socketFd = INVALID_HANDLE;
+       NetSocketEventType eventType = NET_SOCKET_EVENT_NONE;
+       NetSocketClosedReason closedReason = NET_SOCKET_CLOSED_REASON_NONE;
+       result errorCode = E_SUCCESS;
+
+       SysLog(NID_NET_SOCK, "Enter.");
+
+       pEventArg = const_cast <IEventArg*>(&arg);
+       pSocketEventListener = dynamic_cast <ISecureSocketEventListener*>(&listener);
+       pSocketEventArg = dynamic_cast <_SecureSocketEventArg*>(pEventArg);
+
+       SysTryReturnVoidResult(NID_NET_SOCK, pSocketEventListener != null, E_SYSTEM, "[E_SYSTEM] The socket event listener is null");
+       SysTryReturnVoidResult(NID_NET_SOCK, pSocketEventArg != null, E_SYSTEM, "[E_SYSTEM] The socket event argument is null");
+
+       socketFd = __pSecureSocketImpl->GetSecureSocketFd();
+       eventType = pSocketEventArg->GetEventType();
+       errorCode = pSocketEventArg->GetError();
+
+       pSecureSocket = __pSecureSocketImpl->GetSecureSocket();
+
+       SysLog(NID_NET_SOCK, "SocketFd(%d), EventType(%s)", socketFd, ConvertEventTypeToString(eventType));
+
+       switch (eventType)
+       {
+       case NET_SOCKET_EVENT_NONE:
+
+               r = E_SYSTEM;
+               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] #########NET_SOCKET_EVENT_NONE##########");
+               break;
+
+       case NET_SOCKET_EVENT_WRITE:
+
+               SysLog(NID_NET_SOCK, "######################################################################");
+               SysLog(NID_NET_SOCK, "####### Calling callback : OnSecureSocketReadyToSend(SocketFd: %d)", socketFd);
+               SysLog(NID_NET_SOCK, "######################################################################");
+
+               __pSecureSocketImpl->__isWriteFired = true;
+
+               pSocketEventListener->OnSecureSocketReadyToSend(*pSecureSocket);
+
+               SysLog(NID_NET_SOCK, "####### Called callback : OnSecureSocketReadyToSend");
+               break;
+
+       case NET_SOCKET_EVENT_READ:
+
+               SysLog(NID_NET_SOCK, "######################################################################");
+               SysLog(NID_NET_SOCK, "####### Calling callback : OnSecureSocketReadyToReceive(SocketFd: %d)", socketFd);
+               SysLog(NID_NET_SOCK, "######################################################################");
+
+               __pSecureSocketImpl->__isReadFired = true;
+
+               pSocketEventListener->OnSecureSocketReadyToReceive(*pSecureSocket);
+
+               SysLog(NID_NET_SOCK, "####### Called callback : OnSecureSocketReadyToReceive");
+               break;
+
+       case NET_SOCKET_EVENT_CLOSE:
+
+               SysLog(NID_NET_SOCK, "######################################################################");
+               SysLog(NID_NET_SOCK, "####### Calling callback : OnSecureSocketClosed(SocketFd: %d, NetSocketClosedReason: %s)",
+                                       socketFd, GetErrorMessage(errorCode));
+               SysLog(NID_NET_SOCK, "######################################################################");
+
+               __pSecureSocketImpl->__isCloseFired = true;
+
+               closedReason = ConvertClosedReason(errorCode);
+               pSocketEventListener->OnSecureSocketClosed(*pSecureSocket, closedReason);
+
+               SysLog(NID_NET_SOCK, "####### Called callback : OnSecureSocketClosed");
+               break;
+
+       case NET_SOCKET_EVENT_CONNECT:
+
+               SysLog(NID_NET_SOCK, "######################################################################");
+               SysLog(NID_NET_SOCK, "####### Calling callback : OnSecureSocketConnected");
+               SysLog(NID_NET_SOCK, "######################################################################");
+
+               __pSecureSocketImpl->__isConnectFired = true;
+
+               pSocketEventListener->OnSecureSocketConnected(*pSecureSocket);
+
+               SysLog(NID_NET_SOCK, "####### Called callback : OnSecureSocketConnected");
+               break;
+
+       case NET_SOCKET_EVENT_SERVCERT_FAIL:
+
+               SysLog(NID_NET_SOCK, "######################################################################");
+               SysLog(NID_NET_SOCK, "####### Calling callback : OnSecureSocketServCertFailed");
+               SysLog(NID_NET_SOCK, "######################################################################");
+
+               __pSecureSocketImpl->__isCertVerifyFailed = true;
+
+               pSocketEventListener->OnSecureSocketServCertFailed(*pSecureSocket);
+
+               SysLog(NID_NET_SOCK, "####### Called callback : OnSecureSocketServCertFailed");
+               break;
+
+       case NET_SOCKET_EVENT_ACCEPT:
+
+               SysLog(NID_NET_SOCK, "######################################################################");
+               SysLog(NID_NET_SOCK, "####### Calling callback : OnSecureSocketAccept(SocketFd: %d)", socketFd);
+               SysLog(NID_NET_SOCK, "######################################################################");
+
+               __pSecureSocketImpl->__isAcceptFired = true;
+
+               pSocketEventListener->OnSecureSocketAccept(*pSecureSocket);
+
+               SysLog(NID_NET_SOCK, "####### Called callback : OnSecureSocketAccept");
+               break;
+       default:
+               r = E_SYSTEM;
+               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] The eventType is invalid.");
+               break;
+       }
+
+       SysLog(NID_NET_SOCK, "Exit.");
+
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSock_SecureSocketEvent.h b/src/sockets/FNetSock_SecureSocketEvent.h
new file mode 100644 (file)
index 0000000..d469166
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SecureSocketEvent.h
+ * @brief              This is the header file for _SecureSocketEvent class.
+ * @version            2.1
+ *
+ * This header file contains the declarations of _SecureSocketEvent class.
+ * The _SecureSocketEvent class can call listener's method. So, when an event is occurred,
+ * application can handle it appropriately.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_SECURE_SOCKET_EVENT_H_
+#define _FNET_SOCK_INTERNAL_SECURE_SOCKET_EVENT_H_
+
+
+#include <FBaseRtIEventListener.h>
+#include <FNetSockSocketTypes.h>
+#include <FBaseRt_Event.h>
+#include <FBaseRtIEventArg.h>
+#include "FNetSock_SecureSocketImpl.h"
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+class _SecureSocketImpl;
+
+/**
+ * @class      _SecureSocketEvent FNetSock_SecureSocketEvent.h "OspdOaf/FNet/H/FNetSock_SecureSocketEvent.h"
+ * @brief      This class handles an SecureSocket event. It is inherited from Event class.
+ *
+ * @since   2.1
+ *
+ * When an SecureSocket event is occurred, the _SecureSocketEvent class finds listener and calls
+ * the appropriate listener's method. @n
+ */
+
+class _SecureSocketEvent
+       : public Tizen::Base::Runtime::_Event
+{
+
+
+public:
+       _SecureSocketEvent(void);
+
+       virtual ~_SecureSocketEvent(void);
+
+       result Construct(_SecureSocketImpl* pSecureSocketImpl);
+
+       _SecureSocketImpl* GetSocket(void);
+
+
+protected:
+       virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+
+private:
+       /**
+        * This is the copy constructor.
+        *
+        * @param[in]   value   An instance of Socket
+        * @remarks             The function is declared but not implemented.
+        */
+       _SecureSocketEvent(const _SecureSocketEvent& value);
+
+
+private:
+       /**
+        * This is the assignment operator.
+        *
+        * @param[in]   rhs             An instance of Socket
+        * @remarks             The function is declared but not implemented.
+        */
+       _SecureSocketEvent& operator =(const _SecureSocketEvent& rhs);
+
+
+private:
+       _SecureSocketImpl* __pSecureSocketImpl;
+
+}; // _SecureSocketEvent
+
+} } } // Tizen::Net::Sockets
+#endif // _FNET_SOCK_INTERNAL_SECURE_SOCKET_EVENT_H_
diff --git a/src/sockets/FNetSock_SecureSocketEventArg.cpp b/src/sockets/FNetSock_SecureSocketEventArg.cpp
new file mode 100644 (file)
index 0000000..7d4f169
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SecureSocketEventArg.cpp
+ * @brief              This is the implementation file for _SecureSocketEventArg class.
+ * @version     2.1
+ *
+ * This file contains the implementation of _SecureSocketEventArg class.
+ */
+
+#include <FNetSockSocketTypes.h>
+#include <FBaseSysLog.h>
+#include "FNetSock_SecureSocketImpl.h"
+#include "FNetSock_SecureSocketEventArg.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+_SecureSocketEventArg::_SecureSocketEventArg(int socketFd, NetSocketEventType socketEvent)
+       : __socketFd(socketFd)
+       , __socketEvent(socketEvent)
+       , __errorCode(E_SUCCESS)
+{
+}
+
+_SecureSocketEventArg::~_SecureSocketEventArg(void)
+{
+       __socketFd = INVALID_HANDLE;
+       __socketEvent = NET_SOCKET_EVENT_NONE;
+       __errorCode = E_SUCCESS;
+}
+
+int
+_SecureSocketEventArg::GetSocketFd(void)
+{
+       return __socketFd;
+}
+
+NetSocketEventType
+_SecureSocketEventArg::GetEventType(void)
+{
+       return __socketEvent;
+}
+
+void
+_SecureSocketEventArg::SetError(result error)
+{
+       __errorCode = error;
+}
+
+result
+_SecureSocketEventArg::GetError(void)
+{
+       return __errorCode;
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSock_SecureSocketEventArg.h b/src/sockets/FNetSock_SecureSocketEventArg.h
new file mode 100644 (file)
index 0000000..8e72d87
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SecureSocketEventArg.h
+ * @brief              This is the header file for _SecureSocketEventArg class.
+ * @version            2.1
+ *
+ * This header file contains the declarations of _SecureSocketEventArg class.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_SECURE_SOCKET_EVENT_ARG_H_
+#define _FNET_SOCK_INTERNAL_SECURE_SOCKET_EVENT_ARG_H_
+
+
+#include <FBaseResult.h>
+#include <FNetNetTypes.h>
+#include <FNetSockSocketTypes.h>
+#include <FBaseRtIEventArg.h>
+#include "FNetSock_SecureSocketEvent.h"
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+/**
+ * @class      _SecureSocketEventArg FNetSock_SecureSocketEventArg.h "OspdOaf/FNet/H/FNetSock_SecureSocketEventArg.h"
+ * @brief      This class is used as an argument on firing a SecureSocket Event.
+ *
+ * @since   2.1
+ *
+ * _SecureSocketEventArg::FireImpl() receives an argument of this type, when any %SecureSocket event is generated.
+ */
+
+class _SecureSocketEventArg
+       : public Tizen::Base::Object
+       , public Tizen::Base::Runtime::IEventArg
+{
+
+
+public:
+       _SecureSocketEventArg(int socketFd, NetSocketEventType socketEvent);
+
+       virtual ~_SecureSocketEventArg(void);
+
+       int GetSocketFd(void);
+       NetSocketEventType GetEventType(void);
+
+       void SetError(result error);
+       result GetError(void);
+
+
+private:
+       int __socketFd;
+       NetSocketEventType __socketEvent;
+       result __errorCode;
+
+}; // _SecureSocketEventArg
+
+} } } // Tizen::Net::Sockets
+#endif // _FNET_SOCK_INTERNAL_SECURE_SOCKET_EVENT_ARG_H_
diff --git a/src/sockets/FNetSock_SecureSocketImpl.cpp b/src/sockets/FNetSock_SecureSocketImpl.cpp
new file mode 100644 (file)
index 0000000..7fe111c
--- /dev/null
@@ -0,0 +1,3470 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SecureSocketImpl.cpp
+ * @brief              This is the implementation for the _SecureSocketImpl class.
+ */
+
+#include <unique_ptr.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <errno.h>
+#include <sys/poll.h>
+#include <openssl/pkcs12.h>
+#include <openssl/crypto.h>
+#include <openssl/pem.h>
+#include <openssl/err.h>
+#include <openssl/x509.h>
+#include <openssl/bio.h>
+#include <FAppApp.h>
+#include <FNetNetTypes.h>
+#include <FNetIp4Address.h>
+#include <FNetNetConnectionManager.h>
+#include <FNetSockSecureSocket.h>
+#include <FBaseSysLog.h>
+#include <FSecCert_CertService.h>
+#include <FSecCert_CertServiceProxy.h>
+#include <FBase_StringConverter.h>
+#include <FBaseRt_EventDispatcher.h>
+#include <FApp_AppInfo.h>
+#include "FNet_NetEndPointImpl.h"
+#include "FNet_Ip4AddressImpl.h"
+#include "FNet_NetConnectionManagerImpl.h"
+#include "FNet_ManagedNetConnectionImpl.h"
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNet_NetConnectionImpl.h"
+#include "FNetSock_SecureSocketEvent.h"
+#include "FNetSock_SecureSocketEventArg.h"
+#include "FNetSock_SocketInternalHelp.h"
+#include "FNetSock_SecureSocketManagedNetConnectionEventListenerImpl.h"
+#include "FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.h"
+#include "FNetSock_SecureSocketImpl.h"
+#include "FNetSock_SocketDeleter.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Security::Cert;
+using namespace Tizen::App;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+static const long _SECURE_SOCKET_CONNECTION_TIMEOUT = 30;
+static const long _THREAD_SLEEP_TIMER = 2000; // 2000 milliseconds = 2 second (sleep time)
+static const long _MAX_COUNT_THREAD_SLEEP_TIMER = 15; // 2000 * 15 = 30000 milliseconds = 30 seconds (max sleep time)
+static const long _RSA_512_KEY = 512; // RSA Key length 512
+static const long _RSA_1024_KEY = 1024; // RSA Key length 1024
+static const long _SSL_VERIFY_DEPTH = 9; // certificate verification depth 9
+
+pthread_mutex_t _SecureSocketImpl::__mapMutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+
+bool _Singleton::__initialized = false;
+HashMap* _Singleton::__pSslMap = null;
+
+_SecureSocketImpl::_SecureSocketImpl(SecureSocket* pSocket)
+       : __socketFd(INVALID_HANDLE)
+       , __isConstructed(false)
+       , __isClosed(false)
+       , __isLoopback(false)
+       , __isAsync(false)
+       , __isReadFired(false)
+       , __isConnectFired(false)
+       , __isAcceptFired(false)
+       , __isServer(false)
+       , __isWriteFired(false)
+       , __isCloseFired(false)
+       , __isConnectFailed(false)
+       , __isAcceptFailed(false)
+       , __isCertVerifyFailed(false)
+       , __isClientNoCert(false)
+       , __isPeerNoCert(false)
+       , __isClientVerify(false)
+       , __isSslConnected(false)
+       , __isSslAccepted(false)
+       , __isRunFinished(false)
+       , __isNonblock(false)
+       , __isLoadVerify(false)
+       , __sslVerify(SECURE_SOCKET_VERIFY_NONE)
+       , __socketEventType(NET_SOCKET_EVENT_NONE)
+       , __protocolFamily(NET_SOCKET_AF_NONE)
+       , __socketType(NET_SOCKET_TYPE_NONE)
+       , __protocol(NET_SOCKET_PROTOCOL_NONE)
+       , __sslVersion(NET_SOCK_SSL_VERSION_NONE)
+       , __sslCipherSuiteId(NET_SOCK_TLS_SSL_NULL_WITH_NULL_NULL)
+       , __pNetConnectionManager(null)
+       , __pManagedNetConnection(null)
+       , __pManagedNetConnectionEventListener(null)
+       , __pCustomNetConnection(null)
+       , __pCustomNetConnectionEventListener(null)
+       , __pSecureSocketEvent(null)
+       , __pSecureSocket(pSocket)
+       , __pThread(null)
+       , __pSsl(null)
+       , __pSslMethod(null)
+       , __pSslCtx(null)
+       , __pGMainContext(null)
+       , __pGlibSocketInfo(null)
+       , __pTimerSource(null)
+       , __pSslKey(null)
+       , __sslDepth(0)
+{
+}
+
+_SecureSocketImpl::~_SecureSocketImpl(void)
+{
+       Dispose();
+
+       if (__pThread != null)
+       {
+               __pThread->Join();
+               delete __pThread;
+               __pThread = null;
+       }
+
+       delete __pGlibSocketInfo;
+       __pGlibSocketInfo = null;
+
+       ERR_free_strings();
+       ERR_clear_error();
+
+       pthread_mutex_lock(&__mapMutex);
+       if ((_Singleton::GetInitialized() == true) && (__pSslKey))
+       {
+           _Singleton::GetSslMap()->Remove(*__pSslKey, true);
+       }
+       pthread_mutex_unlock(&__mapMutex);
+
+       if (__pSsl != null)
+       {
+               SSL_shutdown(__pSsl);
+
+               SSL_free(__pSsl);
+               __pSsl = null;
+       }
+
+       if (__pSslCtx != null)
+       {
+               SSL_CTX_free(__pSslCtx);
+               __pSslCtx = null;
+       }
+
+       __pGMainContext = null;
+
+       __secureSocketEventListenerList.RemoveAll();
+
+       delete __pSecureSocketEvent;
+       __pSecureSocketEvent = null;
+
+       delete __pCustomNetConnection;
+       __pCustomNetConnection = null;
+
+       delete __pCustomNetConnectionEventListener;
+       __pCustomNetConnectionEventListener = null;
+
+       delete __pManagedNetConnection;
+       __pManagedNetConnection = null;
+
+       delete __pManagedNetConnectionEventListener;
+       __pManagedNetConnectionEventListener = null;
+
+       delete __pNetConnectionManager;
+       __pNetConnectionManager = null;
+
+       if (__pTimerSource != null)
+       {
+               int timerId = g_source_get_id(__pTimerSource);
+               g_source_set_callback(__pTimerSource, null, null, null);
+               SysLog(NID_NET_SOCK, "### deleted g_source_destroy(%d)", timerId);
+               g_source_destroy(__pTimerSource);
+               g_source_unref(__pTimerSource);
+               __pTimerSource = null;
+               SysLog(NID_NET_SOCK, "Canceled the TimerSource[%d].", timerId);
+       }
+
+       __protocol = NET_SOCKET_PROTOCOL_NONE;
+       __socketType = NET_SOCKET_TYPE_NONE;
+       __protocolFamily = NET_SOCKET_AF_NONE;
+       __socketEventType = NET_SOCKET_EVENT_NONE;
+       __isCloseFired = false;
+       __isWriteFired = false;
+       __isReadFired = false;
+       __isConnectFired = false;
+       __isAcceptFired = false;
+       __isServer = false;
+       __isCertVerifyFailed = false;
+       __isConnectFailed = false;
+       __isAcceptFailed = false;
+       __isClientNoCert = false;
+       __isPeerNoCert = false;
+       __isClientVerify = false;
+       __isSslConnected = false;
+       __isSslAccepted = false;
+       __isRunFinished = false;
+       __isNonblock = false;
+       __isLoadVerify = false;
+       __sslVerify = SECURE_SOCKET_VERIFY_NONE;
+        __sslVersion = NET_SOCK_SSL_VERSION_NONE;
+       __sslCipherSuiteId = NET_SOCK_TLS_SSL_NULL_WITH_NULL_NULL;
+       __isAsync = false;
+       __isClosed = false;
+       __isLoopback = false;
+       __isConstructed = false;
+       __socketFd = INVALID_HANDLE;
+}
+
+result
+_SecureSocketImpl::Construct(const Tizen::Net::NetConnection& netConnection, NetSocketAddressFamily addressFamily,
+                                                        NetSocketType socketType, NetSocketProtocol protocol)
+{
+       SysTryReturnResult(NID_NET_SOCK, addressFamily == NET_SOCKET_AF_IPV4, E_UNSUPPORTED_FAMILY,     "The AddressFamily is unsupported.");
+       SysTryReturnResult(NID_NET_SOCK, socketType == NET_SOCKET_TYPE_STREAM, E_UNSUPPORTED_TYPE, "The SocketType is unsupported.");
+       SysTryReturnResult(NID_NET_SOCK, protocol == NET_SOCKET_PROTOCOL_SSL, E_UNSUPPORTED_PROTOCOL, "The Protocol is unsupported.");
+
+       SysLog(NID_NET_SOCK, "Socket uses CustomNetConnection.");
+
+       _Singleton::InitializeSecureSocket();
+
+       // Add netConection null check validation
+       NetConnection* pNetConnection = const_cast <NetConnection*>(&netConnection);
+       SysTryReturnResult(NID_NET_SOCK, pNetConnection, E_INVALID_ARG, "NetConnection is invalid.");
+
+       result r = E_SUCCESS;
+       int af = 0;
+       int type = 0;
+       int sockFd = INVALID_HANDLE;
+       int flags = 0;
+       int err = 0;
+
+       _NetConnectionImpl* pCustomNCImpl = null;
+       NetConnectionState connState = NET_CONNECTION_STATE_NONE;
+
+       String deviceName;
+       char* pDeviceName = null;
+       const NetConnectionInfo* pNetConnectionInfo = null;
+       const _NetConnectionInfoImpl* pNCInfoImpl = null;
+
+       unique_ptr<_SecureSocketEvent> pSecureSocketEvent;
+       unique_ptr<_SecureSocketCustomNetConnectionEventListener> pCustomNetConnectionEventListener;
+       unique_ptr<NetConnection> pCustomNetConnection;
+
+       // Set proper inparam
+       if (addressFamily == NET_SOCKET_AF_IPV4)
+       {
+               af = AF_INET;
+               __protocolFamily = addressFamily;
+       }
+
+       if (socketType == NET_SOCKET_TYPE_STREAM)
+       {
+           SysTryReturnResult(NID_NET_SOCK, protocol == NET_SOCKET_PROTOCOL_SSL, E_INVALID_ARG, "Invalid SocketType - Mismatch.");
+        type = SOCK_STREAM;
+        __socketType = socketType;
+        __protocol = NET_SOCKET_PROTOCOL_SSL;
+       }
+
+       // Custom Network Check
+       connState = pNetConnection->GetConnectionState();
+
+       if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+       {
+               SysLog(NID_NET_SOCK, "Custom Network is available.");
+       }
+       else
+       {
+               r = E_INVALID_CONNECTION;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_CONNECTION] Custom Network is not available.");
+               return r;
+       }
+
+       __socketFd = socket(af, type, 0);
+
+       if (__socketFd < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to construct the socket.", GetErrorMessage((r)));
+               goto CATCH;
+       }
+
+       flags = fcntl(__socketFd, F_GETFL);
+       flags |= O_NONBLOCK;
+
+       if (fcntl(__socketFd, F_SETFL, flags) < 0)
+       {
+               __isNonblock = false;
+               r = E_SYSTEM;
+               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to construct(ioctl) the socket.");
+               goto CATCH;
+       }
+       else
+       {
+               __isNonblock = true;
+
+               __secureSocketEventListenerList.Construct();
+
+               pSecureSocketEvent.reset(new (std::nothrow) _SecureSocketEvent());
+               SysTryReturnResult(NID_NET_SOCK, pSecureSocketEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               r = pSecureSocketEvent->Construct(this);
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Socket Event Construct is Failed.");
+
+               SSL_load_error_strings();
+               ERR_load_BIO_strings();
+               OpenSSL_add_all_algorithms();
+               CRYPTO_malloc_init();
+               SSLeay_add_all_algorithms();
+               ERR_load_crypto_strings();
+
+               __pSslMethod = (SSL_METHOD*) SSLv3_method();
+               __sslVersion = NET_SOCK_SSL_VERSION_SSLV3;
+
+               __pSslCtx = SSL_CTX_new(__pSslMethod);
+               SysTryCatch(NID_NET_SOCK, __pSslCtx != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the SSL Context.");
+       }
+
+       // Set the device name (setsockopt)
+       pNetConnectionInfo = pNetConnection->GetNetConnectionInfo();
+       SysTryCatch(NID_NET_SOCK, pNetConnectionInfo != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get the ConnectionInfo Object.");
+
+       pNCInfoImpl = _NetConnectionInfoImpl::GetInstance(*pNetConnectionInfo);
+       SysTryCatch(NID_NET_SOCK, pNCInfoImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get the ConnectionInfoImpl Object.");
+
+       deviceName = pNCInfoImpl->GetDeviceName();
+
+       if (deviceName.IsEmpty())
+       {
+               SysLog(NID_NET_SOCK, "DeviceName is empty string. - Emulator Case");
+       }
+       else
+       {
+               SysLog(NID_NET_SOCK, "DeviceName is not empty string.[Device Name : %ls] - Target Case", deviceName.GetPointer());
+
+               pDeviceName = _StringConverter::CopyToCharArrayN(deviceName);
+               SysTryCatch(NID_NET_SOCK, pDeviceName != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               err = setsockopt(__socketFd, SOL_SOCKET, SO_BINDTODEVICE, pDeviceName, strlen(pDeviceName) + 1);
+               delete[] pDeviceName;
+               if (err < 0)
+               {
+                       r = ConvertErrorToResult(errno);
+                       SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_INVALID_CONNECTION, E_INVALID_CONNECTION,
+                               "[E_INVALID_CONNECTION] Failed to bind(setsockopt) Device Name.");
+               }
+       }
+
+       // Copy New CustomNetConnection
+       pCustomNCImpl = _NetConnectionImpl::GetInstance(*pNetConnection);
+
+       pCustomNetConnection.reset(pCustomNCImpl->CopyInstanceN());
+       SysTryCatch(NID_NET_SOCK, pCustomNetConnection != null, r = E_INVALID_CONNECTION, E_INVALID_CONNECTION,
+               "[E_INVALID_CONNECTION] CustomNetConnection is null. Failed to copy the InstanceN.");
+
+       // New CustomNetConnectionEventListener
+       pCustomNetConnectionEventListener.reset(new (std::nothrow) _SecureSocketCustomNetConnectionEventListener());
+       SysTryCatch(NID_NET_SOCK, pCustomNetConnectionEventListener != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       // AddNetConnectionListener
+       r = pCustomNetConnection->AddNetConnectionListener(*pCustomNetConnectionEventListener);
+       r = TransExceptionsExclusive(r, E_INVALID_CONNECTION, E_OUT_OF_MEMORY);
+       SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Failed to add the NetConnectionListener.", GetErrorMessage(r));
+
+       // Set the __socketFd
+       pCustomNetConnectionEventListener->SetConstructParams(pSecureSocketEvent.get(), __socketFd, this);
+
+       __pCustomNetConnection = pCustomNetConnection.release();
+       __pCustomNetConnectionEventListener = pCustomNetConnectionEventListener.release();
+       __pSecureSocketEvent = pSecureSocketEvent.release();
+
+       __isConstructed = true;
+
+       SysLog(NID_NET_SOCK, "Created the Secure Socket by non-blocking mode(default) [Fd: %d]", __socketFd);
+
+       return r;
+
+CATCH:
+       if (__socketFd > INVALID_HANDLE)
+       {
+               sockFd = __socketFd;
+               close(__socketFd);
+               SysLog(NID_NET_SOCK, "### SocketFd is closed. [Fd : %d]", sockFd);
+       }
+
+       if (__pSslCtx)
+       {
+               SSL_CTX_free(__pSslCtx);
+               __pSslCtx = null;
+       }
+       return r;
+}
+
+result
+_SecureSocketImpl::Construct(NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol)
+{
+       SysTryReturnResult(NID_NET_SOCK, addressFamily == NET_SOCKET_AF_IPV4, E_UNSUPPORTED_FAMILY,
+                                       "The AddressFamily is unsupported.");
+       SysTryReturnResult(NID_NET_SOCK, socketType == NET_SOCKET_TYPE_STREAM, E_UNSUPPORTED_TYPE,
+                                       "The SocketType is unsupported.");
+       SysTryReturnResult(NID_NET_SOCK, protocol == NET_SOCKET_PROTOCOL_SSL, E_UNSUPPORTED_PROTOCOL,
+                                       "The Protocol is unsupported.");
+
+       SysLog(NID_NET_SOCK, "Socket uses DefaultNetConnection.");
+
+       _Singleton::InitializeSecureSocket();
+
+       result r = E_SUCCESS;
+       int af = 0;
+       int type = 0;
+       int flags = 0;
+       int sockFd = INVALID_HANDLE;
+
+       _ManagedNetConnectionImpl* pManagedNCImpl = null;
+       NetConnectionState connState = NET_CONNECTION_STATE_NONE;
+       _SocketMethodFlag flag = FLAG_NONE;
+
+       unique_ptr<_SecureSocketEvent> pSecureSocketEvent;
+       unique_ptr<_SecureSocketManagedNetConnectionEventListener> pManagedNetConnectionEventListener;
+       unique_ptr<ManagedNetConnection> pManagedNetConnection;
+       unique_ptr<NetConnectionManager> pNetConnectionManager;
+
+       // Set proper inparam
+       if (addressFamily == NET_SOCKET_AF_IPV4)
+       {
+               af = AF_INET;
+               __protocolFamily = addressFamily;
+       }
+
+       if (socketType == NET_SOCKET_TYPE_STREAM)
+       {
+           SysTryReturnResult(NID_NET_SOCK, protocol == NET_SOCKET_PROTOCOL_SSL, E_INVALID_ARG, "Invalid SocketType - Mismatch.");
+
+               type = SOCK_STREAM;
+               __socketType = socketType;
+               __protocol = NET_SOCKET_PROTOCOL_SSL;
+       }
+
+       __socketFd = socket(af, type, 0);
+
+       if (__socketFd < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to construct the socket.", GetErrorMessage((r)));
+       }
+       else
+       {
+               flags = fcntl(__socketFd, F_GETFL);
+               flags |= O_NONBLOCK;
+
+               if (fcntl(__socketFd, F_SETFL, flags) < 0)
+               {
+                       __isNonblock = false;
+                       r = E_SYSTEM;
+                       SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to construct(ioctl) the socket.");
+                       close(__socketFd);
+                       return r;
+               }
+               else
+               {
+                       __isNonblock = true;
+
+                       __secureSocketEventListenerList.Construct();
+
+                       pSecureSocketEvent.reset(new (std::nothrow) _SecureSocketEvent());
+                       SysTryReturn(NID_NET_SOCK, pSecureSocketEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       r = pSecureSocketEvent->Construct(this);
+                       SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to construct the SecureSocketEvent.", GetErrorMessage(r));
+
+                       SSL_load_error_strings();
+                       ERR_load_BIO_strings();
+                       OpenSSL_add_all_algorithms();
+                       CRYPTO_malloc_init();
+                       SSLeay_add_all_algorithms();
+                       ERR_load_crypto_strings();
+
+                       __pSslMethod = (SSL_METHOD*) SSLv3_method();
+                       __sslVersion = NET_SOCK_SSL_VERSION_SSLV3;
+
+                       __pSslCtx = SSL_CTX_new(__pSslMethod);
+                       SysTryCatch(NID_NET_SOCK, __pSslCtx != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the SSL Context.");
+               }
+       }
+
+       if (_NetConnectionManagerImpl::IsDefaultMode() != true)
+       {
+               SysLog(NID_NET_SOCK, "Socket uses ManagedNetConnection");
+
+               pNetConnectionManager.reset(new (std::nothrow) NetConnectionManager());
+               SysTryCatch(NID_NET_SOCK, pNetConnectionManager != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = pNetConnectionManager->Construct();
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_INVALID_CONNECTION, r, "[%s] Failed to construct the ManagedNetConnection.", GetErrorMessage(r));
+
+               pManagedNetConnection.reset(pNetConnectionManager->GetManagedNetConnectionN());
+               SysTryCatch(NID_NET_SOCK, pManagedNetConnection != null, r = E_INVALID_CONNECTION, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] ManagedNetConnection is null. Failed to the GetManagedNetConnectionN.");
+
+               pManagedNCImpl = _ManagedNetConnectionImpl::GetInstance(*pManagedNetConnection);
+               SysTryCatch(NID_NET_SOCK, pManagedNCImpl != null, r = E_INVALID_CONNECTION, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] ManagedNetConnectionImpl is null. Failed to the GetManagedNetConnectionN.");
+
+               // New ManagedNetConnectionEventListener
+               pManagedNetConnectionEventListener.reset(new (std::nothrow) _SecureSocketManagedNetConnectionEventListener());
+               SysTryCatch(NID_NET_SOCK, pManagedNetConnectionEventListener != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               // SetManagedNetConnectionEventListener
+               r = pManagedNetConnection->SetManagedNetConnectionEventListener(pManagedNetConnectionEventListener.get());
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_INVALID_CONNECTION, r, "[%s] Failed to the SetManagedNetConnectionEventListener.", GetErrorMessage(r));
+
+               // Set the __socketFd
+               flag = FLAG_CONSTRUCT;
+               pManagedNetConnectionEventListener->SetConstructParams(pSecureSocketEvent.get(), __socketFd, flag, this);
+
+               // Start ManagedNetConnectionImpl
+               r = pManagedNCImpl->Start();
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_INVALID_CONNECTION, r, "[%s] Failed to start the ManagedNetConnection.", GetErrorMessage(r));
+
+               connState = pManagedNCImpl->GetConnectionState();
+               if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+               {
+                       pManagedNetConnectionEventListener->SetStartedFlag(true);
+               }
+       }
+
+       __pNetConnectionManager = pNetConnectionManager.release();
+       __pManagedNetConnection = pManagedNetConnection.release();
+       __pManagedNetConnectionEventListener = pManagedNetConnectionEventListener.release();
+       __pSecureSocketEvent = pSecureSocketEvent.release();
+
+       __isConstructed = true;
+
+       SysLog(NID_NET_SOCK, "Created the Secure Socket by non-blocking mode(default) [Fd: %d]", __socketFd);
+
+       return r;
+
+CATCH:
+       if (__socketFd > INVALID_HANDLE)
+       {
+               sockFd = __socketFd;
+               close(__socketFd);
+               SysLog(NID_NET_SOCK, "### SocketFd is closed. [Fd : %d]", sockFd);
+       }
+
+       if (__pSslCtx)
+       {
+               SSL_CTX_free(__pSslCtx);
+               __pSslCtx = null;
+       }
+       return r;
+}
+
+result
+_SecureSocketImpl::Connect(const Tizen::Net::NetEndPoint& remoteEP)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+       SysTryReturnResult(NID_NET_SOCK, __pSslCtx != null, E_INVALID_ARG, "The SSL Context object is null.");
+
+       result r = E_SUCCESS;
+
+       int err = 0;
+       int sslError = 0;
+       int sslIndex = 0;
+
+       NetAddressFamily af;
+       unsigned long ipAddr = 0;
+       unsigned short port = 0;
+       Ip4Address* pIp4Addr = null;
+       const _NetEndPointImpl* pRemoteEPImpl = null;
+
+       struct sockaddr_in remoteAddr;
+
+       String remoteAddrString;
+
+       NetConnectionState connState = NET_CONNECTION_STATE_NONE;
+       _SocketMethodFlag flag = FLAG_NONE;
+
+       String deviceName;
+       char* pDeviceName = null;
+       const _ManagedNetConnectionImpl* pMNCConnImpl = null;
+       long milliseconds = _THREAD_SLEEP_TIMER; // 2000 milliseconds (sleep time)
+       int tryCount = 0;
+       bool isConnectionStarted = false;
+
+       char* pCaPath = null;
+       String caPath;
+
+       pRemoteEPImpl = _NetEndPointImpl::GetInstance(remoteEP);
+
+       if (pRemoteEPImpl->IsValid() == true)
+       {
+               pIp4Addr = static_cast <Ip4Address*>(pRemoteEPImpl->GetAddress());
+               remoteAddrString = pIp4Addr->ToString();
+       }
+       else
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] NetEndPoint is invalid.");
+               return r;
+       }
+
+       _ApiVersion apiVersion = _AppInfo::GetApiVersion();
+
+       if (apiVersion == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (__isLoopback == false)
+               {
+                       if (remoteAddrString == LOOPBACK_ADDRESS)
+                       {
+                               r = E_SYSTEM;
+                               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to assign the requested address.");
+                               return r;
+                       }
+               }
+               else
+               {
+                       if (remoteAddrString != LOOPBACK_ADDRESS)
+                       {
+                               r = E_SYSTEM;
+                               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to assign the requested address.");
+                               return r;
+                       }
+               }
+       }
+
+       af = pRemoteEPImpl->GetNetAddressFamily();
+       SysTryReturnResult(NID_NET_SOCK, af == NET_AF_IPV4, E_INVALID_ARG, "Address family is invalid.");
+
+       r = pIp4Addr->GetAddress(ipAddr);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_INVALID_ARG, "Address is invalid.");
+
+       port = pRemoteEPImpl->GetPort();
+
+       memset(&remoteAddr, 0, sizeof(remoteAddr));
+       remoteAddr.sin_family = AF_INET;
+       remoteAddr.sin_addr.s_addr = htonl(ipAddr);
+       remoteAddr.sin_port = htons(port);
+
+       if (__pManagedNetConnection != null)
+       {
+               SysLog(NID_NET_SOCK, "This socket uses ManagedNetConnection internally. [Fd : %d]", __socketFd);
+
+               if (__isNonblock == false)
+               {
+                       SysLog(NID_NET_SOCK, "This socket is blocking mode.");
+
+                       pMNCConnImpl = _ManagedNetConnectionImpl::GetInstance(*__pManagedNetConnection);
+
+                       while (1)
+                       {
+                               connState = pMNCConnImpl->QueryConnectionState(deviceName);
+
+                               switch (connState)
+                               {
+                               case NET_CONNECTION_STATE_STARTED:
+
+                               case NET_CONNECTION_STATE_RESUMED:
+
+                               case NET_CONNECTION_STATE_SUSPENDED:
+                                       SysLog(NID_NET_SOCK, "Network is available.");
+
+                                       if (deviceName.IsEmpty())
+                                       {
+                                               SysLog(NID_NET_SOCK, "DeviceName is empty string. - Emulator Case");
+                                       }
+                                       else
+                                       {
+                                               SysLog(NID_NET_SOCK, "DeviceName is not empty string.[Device Name : %ls] - Target Case", deviceName.GetPointer());
+
+                                               pDeviceName = _StringConverter::CopyToCharArrayN(deviceName);
+                                               SysTryCatch(NID_NET_SOCK, pDeviceName != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                                               err = setsockopt(__socketFd, SOL_SOCKET, SO_BINDTODEVICE, pDeviceName, strlen(pDeviceName) + 1);
+                                               delete[] pDeviceName;
+                                               if (err < 0)
+                                               {
+                                                       ConvertErrorToResult(errno);
+
+                                                       SysLogException(NID_NET_SOCK, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] Failed to bind the device name.");
+                                               }
+                                       }
+
+                                       err = connect(__socketFd, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr));
+                                       break;
+
+                               case NET_CONNECTION_STATE_STARTING:
+
+                               case NET_CONNECTION_STATE_NONE:
+
+                               case NET_CONNECTION_STATE_STOPPING:
+
+                               case NET_CONNECTION_STATE_STOPPED:
+                                       SysLog(NID_NET_SOCK, "Network is not available.");
+                                       break;
+
+                               default:
+                                       SysLog(NID_NET_SOCK, "Should not come here.");
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+                               {
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STOPPED)
+                               {
+                                       r = E_INVALID_CONNECTION;
+                                       SysLogException(NID_NET_SOCK, r, "[E_INVALID_CONNECTION] Network is stopped.");
+                                       break;
+                               }
+
+                               tryCount++;
+
+                               if (tryCount > _MAX_COUNT_THREAD_SLEEP_TIMER) // 2000 milliseconds * 15 count = 30 seconds timeout
+                               {
+                                       r = E_TIMEOUT;
+                                       SysLogException(NID_NET_SOCK, r, "[E_TIMEOUT] Network timeout happened. Try Again");
+                                       tryCount = 0;
+                                       break;
+                               }
+
+                               Thread::Sleep(milliseconds);
+                       }
+               }
+               else
+               {
+                       isConnectionStarted = __pManagedNetConnectionEventListener->GetStartedFlag();
+
+                       if (isConnectionStarted)
+                       {
+                               err = connect(__socketFd, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr));
+                       }
+                       else
+                       {
+                               r = E_WOULD_BLOCK;
+                               flag = FLAG_CONNECT;
+                               __pManagedNetConnectionEventListener->SetConnectParams(__socketFd, remoteAddr, flag, this);
+
+                               return r;
+                       }
+               }
+       }
+       else
+       {
+               err = connect(__socketFd, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr));
+       }
+
+       if (err < 0)
+       {
+               r = ConvertErrorToResult(errno);
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to connect the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isConnectFired = true;
+                       }
+                       goto CATCH;
+               }
+       }
+
+       // Set default CA path.
+       caPath = _CertService::GetCertificateCrtFilePath();
+       SysLog(NID_NET_SOCK, "CA Path(%ls)", caPath.GetPointer());
+
+       pCaPath = _StringConverter::CopyToCharArrayN(caPath);
+       SysTryReturnResult(NID_NET_SOCK, pCaPath != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+       sslError = SSL_CTX_load_verify_locations(__pSslCtx, pCaPath, null);
+       SysTryCatch(NID_NET_SOCK, sslError >= 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to verify the trusted CA list.");
+
+       sslError = SSL_CTX_set_default_verify_paths(__pSslCtx);
+       SysTryCatch(NID_NET_SOCK, sslError >= 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to set the default verify paths.");
+
+       delete[] pCaPath;
+    pCaPath = null;
+
+       __pSsl = SSL_new(__pSslCtx);
+       SysTryCatch(NID_NET_SOCK, __pSsl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the SSL Object.");
+
+       SSL_set_fd(__pSsl, __socketFd);
+
+       SSL_set_options(__pSsl, SSL_OP_ALL);
+
+       if (__isAsync == true || __isNonblock == true)
+       {
+               SSL_CTX_set_client_cert_cb(__pSslCtx, (int (*)(SSL*, X509**, EVP_PKEY**)) _SecureSocketImpl::OnClientCertCallback);
+
+               SSL_set_mode(__pSsl, SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
+
+               sslIndex = SSL_get_ex_new_index(0, (char*) "_SecureSocketImpl index", null, null, null);
+               SysLog(NID_NET_SOCK, "SSL index(%d).", sslIndex);
+
+               SSL_set_ex_data(__pSsl, sslIndex, this);
+
+               __pSslKey = new Integer((int) __pSsl);
+               pthread_mutex_lock(&__mapMutex);
+               _Singleton::GetSslMap()->Add(*(__pSslKey), *(new Integer((int) sslIndex)));
+               pthread_mutex_unlock(&__mapMutex);
+               SysLog(NID_NET_SOCK, "__pSslKey : %d ", __pSslKey);
+               // SysLog(NID_NET_SOCK, " : %d ", _Singleton::GetSslMap()->GetCount());
+
+               SSL_set_verify(__pSsl, SSL_VERIFY_PEER, (int (*)(int, X509_STORE_CTX*)) _SecureSocketImpl::OnVerifyPeerCallback);
+               // verify certification depth is set to _SSL_VERIFY_DEPTH.
+               // Allows level 0: peer certificates.
+               //        level 1: CA certificates.
+               //        level 2: higher level CA certificates.
+               //                and so on.
+               __sslDepth = _SSL_VERIFY_DEPTH;
+               SSL_set_verify_depth(__pSsl, __sslDepth);
+
+               // Create thread
+               __pThread = new (std::nothrow) Thread();
+               SysTryCatch(NID_NET_SOCK, __pThread != null, r = E_OUT_OF_MEMORY, r, "Memory allocation failed.");
+
+               r = __pThread->Construct(*this);
+               SysTryCatch(NID_NET_SOCK, r != E_OUT_OF_MEMORY, , r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Failed to construct the thread.", GetErrorMessage(r));
+
+               // Start thread
+               r = __pThread->Start();
+        SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Failed to start the thread.", GetErrorMessage(r));
+
+               r = E_WOULD_BLOCK;
+               SysLogException(NID_NET_SOCK, r, "[E_WOULD_BLOCK] Returned EWOULDBLOCK to connect the socket.");
+
+               __isConnectFired = false;
+       }
+       else
+       {
+               if (__sslVerify == SECURE_SOCKET_VERIFY_NONE)
+               {
+                       SSL_set_verify(__pSsl, SSL_VERIFY_PEER, null);
+               }
+
+               r = SslConnect(sslError);
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Failed to connect the socket.", GetErrorMessage(r));
+       }
+
+       return r;
+
+CATCH:
+       if (__pThread)
+       {
+               delete __pThread;
+               __pThread = null;
+       }
+
+    if (pCaPath != null)
+    {
+        delete[] pCaPath;
+        pCaPath = null;
+    }
+
+       return r;
+}
+
+result
+_SecureSocketImpl::Send(ByteBuffer& buffer)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+       result res = E_SUCCESS;
+
+       int sentLength = 0;
+       int sslError = 0;
+
+       unsigned int offset = buffer.GetPosition();
+       unsigned int length = buffer.GetRemaining();
+
+       SysTryReturnResult(NID_NET_SOCK, length > 0, E_INVALID_ARG, "Address is invalid.");
+       SysTryReturnResult(NID_NET_SOCK, __pSsl != null, E_CONNECTION_FAILED, "The Secure Socket is not connected.");
+
+       sentLength = SSL_write(__pSsl, (char*) (buffer.GetPointer() + offset), length);
+
+       if (sentLength <= 0)
+       {
+               sslError = SSL_get_error(__pSsl, sentLength);
+
+               // Error code mapping
+               switch (sslError)
+               {
+               case SSL_ERROR_SSL: // Error occurred in SSL library or protocol error.
+                       r = E_SYSTEM;
+                       break;
+
+               case SSL_ERROR_SYSCALL: // I/o Error Occurred.
+                       r = E_SYSTEM;
+                       break;
+
+               case SSL_ERROR_ZERO_RETURN: // TLS/SSL connection has been closed.
+                       r = E_CONNECTION_FAILED;
+                       break;
+
+               case SSL_ERROR_WANT_READ:  // Operation is not completed.
+               case SSL_ERROR_WANT_WRITE:
+                       r = E_WOULD_BLOCK;
+                       break;
+
+               default:
+                       r = E_SYSTEM;
+                       break;
+               }
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to send the socket.", GetErrorMessage(r));
+
+                       if (__isAsync == true)
+                       {
+                               __isWriteFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to send the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isWriteFired = false;
+                               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+                               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Memory allocation failed.", GetErrorMessage(r));
+                               SysTryCatch(NID_NET_SOCK, r != E_SUCCESS, r = E_WOULD_BLOCK, E_WOULD_BLOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Actually send byte : %d byte", sentLength);
+
+       if (__isAsync == true)
+       {
+               __isWriteFired = false;
+               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Memory allocation failed.", GetErrorMessage(r));
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+       }
+
+       r = buffer.SetPosition(offset + sentLength);
+    SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM , E_SYSTEM, "[E_SYSTEM] Failed to Set the position.");
+
+       return r;
+
+CATCH:
+       res = buffer.SetPosition(offset);
+    SysTryReturnResult(NID_NET_SOCK, res == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to Set the position.");
+
+       return r;
+}
+
+result
+_SecureSocketImpl::Send(void* pBuffer, int length, int& sentLength)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       int sslError = 0;
+
+       if (!pBuffer || length <= 0)
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] The buffer is null or the length is invalid.");
+               return r;
+       }
+
+       SysTryReturnResult(NID_NET_SOCK, __pSsl != null, E_CONNECTION_FAILED, "The Secure Socket is not connected.");
+
+       sentLength = SSL_write(__pSsl, static_cast <char*>(pBuffer), length);
+
+       if (sentLength <= 0)
+       {
+               sslError = SSL_get_error(__pSsl, sentLength);
+
+               // error code mapping
+               switch (sslError)
+               {
+               case SSL_ERROR_SSL: // Error occurred in SSL library or protocol error.
+                       r = E_SYSTEM;
+                       break;
+
+               case SSL_ERROR_SYSCALL: // I/o Error Occurred.
+                       r = E_SYSTEM;
+                       break;
+
+               case SSL_ERROR_ZERO_RETURN: // TLS/SSL connection has been closed.
+                       r = E_CONNECTION_FAILED;
+                       break;
+
+               case SSL_ERROR_WANT_READ: // Operation is not completed.
+               case SSL_ERROR_WANT_WRITE:
+                       r = E_WOULD_BLOCK;
+                       break;
+
+               default:
+                       r = E_SYSTEM;
+                       break;
+               }
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to send the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isWriteFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to send the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isWriteFired = false;
+                               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+                               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Memory allocation failed.");
+                               SysTryReturnResult(NID_NET_SOCK, r != E_SUCCESS, E_WOULD_BLOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Actually send byte : %d byte", sentLength);
+
+       if (__isAsync == true)
+       {
+               __isWriteFired = false;
+               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Memory allocation failed.");
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_SecureSocketImpl::Receive(ByteBuffer& buffer)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+       result res = E_SUCCESS;
+
+       int rcvdLength = 0;
+       int sslError = 0;
+
+       unsigned int offset = buffer.GetPosition();
+       unsigned int length = buffer.GetRemaining();
+
+       SysTryReturnResult(NID_NET_SOCK, length > 0, E_INVALID_ARG, "Address is invalid.");
+       SysTryReturnResult(NID_NET_SOCK, __pSsl != null, E_CONNECTION_FAILED, "The Secure Socket is not connected.");
+
+       rcvdLength = SSL_read(__pSsl, (char*) (buffer.GetPointer() + offset), length);
+
+       if (rcvdLength < 0)
+       {
+               sslError = SSL_get_error(__pSsl, rcvdLength);
+
+               // Error code mapping
+               switch (sslError)
+               {
+               case SSL_ERROR_SSL: // Error occurred in SSL library or protocol error.
+                       r = E_SYSTEM;
+                       break;
+
+               case SSL_ERROR_SYSCALL: // I/o Error Occurred.
+                       r = E_SYSTEM;
+                       break;
+
+               case SSL_ERROR_ZERO_RETURN: // TLS/SSL connection has been closed.
+                       r = E_CONNECTION_FAILED;
+                       break;
+
+               case SSL_ERROR_WANT_READ: // Operation is not completed.
+               case SSL_ERROR_WANT_WRITE:
+                       r = E_WOULD_BLOCK;
+                       break;
+
+               default:
+                       r = E_SYSTEM;
+                       break;
+               }
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to receive the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isReadFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to receive the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isReadFired = false;
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Actually receive byte : %d byte", rcvdLength);
+
+       if (__isAsync == true)
+       {
+               __isReadFired = false;
+       }
+
+       r = buffer.SetPosition(offset + rcvdLength);
+       SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to Set the position.");
+
+       return r;
+
+CATCH:
+       res = buffer.SetPosition(offset);
+       SysTryReturnResult(NID_NET_SOCK, res == E_SUCCESS, E_SYSTEM, "Failed to Set the position.");
+
+       return r;
+}
+
+result
+_SecureSocketImpl::Receive(void* pBuffer, int length, int& rcvdLength)
+{
+SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       int sslError = 0;
+
+       if (!pBuffer || length <= 0)
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] The buffer is null or the length is invalid.");
+               return r;
+       }
+
+       SysTryReturnResult(NID_NET_SOCK, __pSsl != null, E_CONNECTION_FAILED, "The Secure Socket is not connected.");
+
+       rcvdLength = SSL_read(__pSsl, static_cast <char*>(pBuffer), length);
+
+       if (rcvdLength < 0)
+       {
+               sslError = SSL_get_error(__pSsl, rcvdLength);
+
+               // Error code mapping
+               switch (sslError)
+               {
+               case SSL_ERROR_SSL: // Error occurred in SSL library or protocol error.
+                       r = E_SYSTEM;
+                       break;
+
+               case SSL_ERROR_SYSCALL: // I/O Error occurred.
+                       r = E_SYSTEM;
+                       break;
+
+               case SSL_ERROR_ZERO_RETURN: // TLS/SSL connection has been closed.
+                       r = E_CONNECTION_FAILED;
+                       break;
+
+               case SSL_ERROR_WANT_READ: // Operation is not completed.
+               case SSL_ERROR_WANT_WRITE:
+                       r = E_WOULD_BLOCK;
+                       break;
+
+               default:
+                       r = E_SYSTEM;
+                       break;
+               }
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to receive the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isReadFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to receive the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isReadFired = false;
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Actually receive byte : %d byte", rcvdLength);
+
+       if (__isAsync == true)
+       {
+               __isReadFired = false;
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_SecureSocketImpl::Ioctl(NetSocketIoctlCmd cmd, unsigned long& pArg)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+       SysTryReturnResult(NID_NET_SOCK, (cmd == NET_SOCKET_FIONBIO), E_INVALID_ARG, "IoctlCmd is invalid.");
+
+       result r = E_SUCCESS;
+       int err = 0;
+       int flag = 0;
+
+       if (cmd == NET_SOCKET_FIONBIO && pArg != 0)
+       {
+               // command = FIONBIO;
+               flag = fcntl(__socketFd, F_GETFL);
+               err = fcntl(__socketFd, F_SETFL, flag | O_NONBLOCK);
+               SysLog(NID_NET_SOCK, "Changed the Socket by non-blocking mode. [Fd: %d]", __socketFd);
+               __isNonblock = true;
+       }
+       else if (cmd == NET_SOCKET_FIONBIO && pArg == 0)
+       {
+               // command = FIONBIO;
+               flag = fcntl(__socketFd, F_GETFL);
+               err = fcntl(__socketFd, F_SETFL, flag & ~O_NONBLOCK);
+               SysLog(NID_NET_SOCK, "Changed the Socket by blocking mode. [Fd: %d]", __socketFd);
+               __isNonblock = false;
+       }
+
+       if (err < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to Ioctl the socket.", GetErrorMessage(r));
+       }
+
+       return r;
+}
+
+result
+_SecureSocketImpl::Bind(const NetEndPoint& localEP)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       NetAddressFamily af;
+       unsigned long ipAddr = 0;
+       unsigned short port = 0;
+       Ip4Address* pIp4Addr = null;
+       const _NetEndPointImpl* pLocalEPImpl = null;
+
+       struct sockaddr_in localAddr;
+
+       pLocalEPImpl = _NetEndPointImpl::GetInstance(localEP);
+
+       af = pLocalEPImpl->GetNetAddressFamily();
+       SysTryReturnResult(NID_NET_SOCK, af == NET_AF_IPV4, E_INVALID_ARG, "Address family is invalid.");
+
+       pIp4Addr = static_cast <Ip4Address*>(pLocalEPImpl->GetAddress());
+       r = pIp4Addr->GetAddress(ipAddr);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_INVALID_ARG, "Address is invalid.");
+
+       port = pLocalEPImpl->GetPort();
+
+       memset(&localAddr, 0, sizeof(localAddr));
+       localAddr.sin_family = AF_INET;
+       localAddr.sin_addr.s_addr = htonl(ipAddr);
+       localAddr.sin_port = htons(port);
+
+       if (bind(__socketFd, (struct sockaddr*) &localAddr, sizeof(localAddr)) < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to bind the socket.");
+       }
+
+       SysLog(NID_NET_SOCK, "bind the socket. [Fd : %d]", __socketFd);
+
+       return r;
+}
+
+result
+_SecureSocketImpl::Listen(int backLog)
+{
+SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+       int err = 0;
+
+       _SocketMethodFlag flag = FLAG_NONE;
+       NetConnectionState connState = NET_CONNECTION_STATE_NONE;
+
+       String deviceName;
+       char* pDeviceName = null;
+       const _ManagedNetConnectionImpl* pMNCConnImpl = null;
+       long milliseconds = _THREAD_SLEEP_TIMER; // 2000 milliseconds (sleep time)
+       int tryCount = 0;
+
+       bool isConnectionStarted = false;
+
+       if (__pManagedNetConnection != null)
+       {
+               SysLog(NID_NET_SOCK, "This socket uses ManagedNetConnection internally. [Fd : %d]", __socketFd);
+
+               if (__isNonblock == false)
+               {
+                       SysLog(NID_NET_SOCK, "This socket is blocking mode.");
+
+                       pMNCConnImpl = _ManagedNetConnectionImpl::GetInstance(*__pManagedNetConnection);
+
+                       // Blocking mode
+                       while (1)
+                       {
+                               connState = pMNCConnImpl->QueryConnectionState(deviceName);
+
+                               switch (connState)
+                               {
+                               case NET_CONNECTION_STATE_STARTED:
+
+                               case NET_CONNECTION_STATE_RESUMED:
+
+                               case NET_CONNECTION_STATE_SUSPENDED:
+                                       SysLog(NID_NET_SOCK, "Network is available.");
+
+                                       if (deviceName.IsEmpty())
+                                       {
+                                               SysLog(NID_NET_SOCK, "DeviceName is empty string. - Emulator Case");
+                                       }
+                                       else
+                                       {
+                                               SysLog(NID_NET_SOCK, "DeviceName is not empty string. [Device Name : %ls] - Target Case", deviceName.GetPointer());
+
+                                               pDeviceName = _StringConverter::CopyToCharArrayN(deviceName);
+                                               SysTryCatch(NID_NET_SOCK, pDeviceName != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                                               err = setsockopt(__socketFd, SOL_SOCKET, SO_BINDTODEVICE, pDeviceName, strlen(pDeviceName) + 1);
+                                               delete[] pDeviceName;
+                                               if (err < 0)
+                                               {
+                                                       ConvertErrorToResult(errno);
+                                                       SysLogException(NID_NET_SOCK, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] Device Name binding is Failed.");
+                                               }
+                                       }
+
+                                       err = listen(__socketFd, backLog);
+                                       break;
+
+                               case NET_CONNECTION_STATE_STARTING:
+
+                               case NET_CONNECTION_STATE_NONE:
+
+                               case NET_CONNECTION_STATE_STOPPING:
+
+                               case NET_CONNECTION_STATE_STOPPED:
+                                       SysLog(NID_NET_SOCK, "Network is not available.");
+                                       break;
+
+                               default:
+                                       SysLog(NID_NET_SOCK, "Should not come here.");
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+                               {
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STOPPED)
+                               {
+                                       r = E_INVALID_CONNECTION;
+                                       SysLogException(NID_NET_SOCK, r, "[E_INVALID_CONNECTION] Network is stopped.");
+                                       break;
+                               }
+
+                               tryCount++;
+
+                               if (tryCount > _MAX_COUNT_THREAD_SLEEP_TIMER) // 2000 milliseconds * 15 count = 30 seconds timeout
+                               {
+                                       r = E_TIMEOUT;
+                                       SysLogException(NID_NET_SOCK, r, "[E_TIMEOUT] Network is timeout. Try Again");
+                                       tryCount = 0;
+                                       break;
+                               }
+
+                               Thread::Sleep(milliseconds);
+                       }
+               }
+               else
+               {
+                       SysLog(NID_NET_SOCK, "This socket is non-blocking mode.");
+
+                       isConnectionStarted = __pManagedNetConnectionEventListener->GetStartedFlag();
+
+                       if (isConnectionStarted)
+                       {
+                               err = listen(__socketFd, backLog);
+                       }
+                       else
+                       {
+                               r = E_WOULD_BLOCK;
+                               flag = FLAG_LISTEN;
+                               __pManagedNetConnectionEventListener->SetListenParams(__socketFd, backLog, flag);
+                       }
+               }
+       }
+       else
+       {
+               err = listen(__socketFd, backLog);
+       }
+
+       if (err < 0)
+       {
+               r = ConvertErrorToResult(errno);
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to listen the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isAcceptFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to listen the socket.", GetErrorMessage(r));
+                       __isServer = true;
+                       if (__isAsync == true)
+                       {
+                               __isAcceptFired = false;
+                               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+                               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Memory allocation failed.");
+                               SysTryReturnResult(NID_NET_SOCK, r != E_SUCCESS, E_WOULD_BLOCK, "SocketFd : [%d], Set the socketEvent to attach all condition.", __socketFd);
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Socket is listening. [Fd : %d, backLog : %d]", __socketFd, backLog);
+
+       __isServer = true;
+
+       if (__isAsync == true)
+       {
+               __isAcceptFired = false;
+               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Memory allocation failed.");
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach All condition.", __socketFd);
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+SecureSocket*
+_SecureSocketImpl::AcceptN(void)
+{
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       SecureSocket* pClientSocket = null;
+       _SecureSocketImpl* pClientSocketImpl = null;
+       int sslError = 0;
+       int sslIndex = 0;
+       int clientFd = INVALID_HANDLE;
+       unsigned int clientSize = 0;
+       struct sockaddr_in clientAddr;
+       char* pCaPath = null;
+
+       SysTryReturn(NID_NET_SOCK, __isClosed == false, null, E_INVALID_STATE, "[E_INVALID_STATE] Socket is already closed.");
+
+       pthread_mutex_lock(&__mapMutex);
+
+       clientSize = sizeof(clientAddr);
+
+       clientFd = accept(__socketFd, (struct sockaddr*) &clientAddr, &clientSize);
+
+       if (clientFd < 0)
+       {
+               r = ConvertErrorToResult(errno);
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to accept the socket.", GetErrorMessage(r));
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to accept the socket.", GetErrorMessage(r));
+                       goto CATCH;
+               }
+       }
+
+       if (__isAsync == true)
+       {
+               __isAcceptFired = false;
+               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Memory allocation failed.", GetErrorMessage(r));
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach All condition.", __socketFd);
+       }
+
+       // Implementation - new Socket
+       pClientSocket = new (std::nothrow) SecureSocket();
+       SysTryCatch(NID_NET_SOCK, pClientSocket != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Secure Socket Memory allocation failed.");
+
+       pClientSocketImpl = new (std::nothrow) _SecureSocketImpl(pClientSocket);
+       SysTryCatch(NID_NET_SOCK, pClientSocketImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       // Set new Socket Event
+       pClientSocketImpl->__pSecureSocketEvent = new (std::nothrow) _SecureSocketEvent();
+       SysTryCatch(NID_NET_SOCK, pClientSocketImpl->__pSecureSocketEvent != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pClientSocketImpl->__pSecureSocketEvent->Construct(pClientSocketImpl);
+       SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to construct the Secure Socket event.");
+
+       if (__isLoadVerify == false)
+       {
+               // Set default CA path.
+               String caPath = _CertService::GetCertificateCrtFilePath();
+               SysLog(NID_NET_SOCK, "CA Path(%ls)", caPath.GetPointer());
+
+               pCaPath = _StringConverter::CopyToCharArrayN(caPath);
+               SysTryCatch(NID_NET_SOCK, pCaPath != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               sslError = SSL_CTX_load_verify_locations(__pSslCtx, pCaPath, null);
+               SysTryCatch(NID_NET_SOCK, sslError >= 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to verify the trusted CA list.");
+
+               sslError = SSL_CTX_set_default_verify_paths(__pSslCtx);
+               SysTryCatch(NID_NET_SOCK, sslError >= 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to set the default verify paths.");
+
+               __isLoadVerify = true;
+
+               delete[] pCaPath;
+               pCaPath = null;
+       }
+
+       pClientSocketImpl->__pSsl = SSL_new(__pSslCtx);
+       SysTryCatch(NID_NET_SOCK, pClientSocketImpl->__pSsl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the SSL Object.");
+
+       SSL_set_fd(pClientSocketImpl->__pSsl, clientFd);
+
+       SSL_set_options(pClientSocketImpl->__pSsl, SSL_OP_ALL);
+
+       SSL_set_tmp_rsa_callback(pClientSocketImpl->__pSsl, OnTmpRsaCallback);
+
+       //if (__sslVerify == SECURE_SOCKET_VERIFY_NONE)
+       //{
+       //      SSL_set_verify(pClientSocketImpl->__pSsl, SSL_VERIFY_PEER, null);
+       //}
+
+       if (__isAsync == true || __isNonblock == true)
+       {
+               // verify certification depth is set to _SSL_VERIFY_DEPTH.
+               // Allows level 0: peer certificates.
+               //        level 1: CA certificates.
+               //        level 2: higher level CA certificates.
+               //        and so on.
+               __sslDepth = _SSL_VERIFY_DEPTH;
+               SSL_set_verify_depth(pClientSocketImpl->__pSsl, __sslDepth);
+
+               SSL_set_mode(pClientSocketImpl->__pSsl, SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
+
+               if ((_Singleton::GetInitialized() == true) && (__pSslKey))
+               {
+                   _Singleton::GetSslMap()->Remove(*__pSslKey, true);
+               }
+
+               sslIndex = SSL_get_ex_new_index(0, (char*) "_SecureSocketImpl index", null, null, null);
+               SysLog(NID_NET_SOCK, "SSL index(%d).", sslIndex);
+
+               SSL_set_ex_data(pClientSocketImpl->__pSsl, sslIndex, this);
+
+               __pSslKey = new Integer((int) pClientSocketImpl->__pSsl);
+
+               _Singleton::GetSslMap()->Add(*(__pSslKey), *(new Integer((int) sslIndex)));
+
+ssl_accept:
+               r = SslAccept(pClientSocketImpl->__pSsl, sslError);
+               if ((sslError == SSL_ERROR_WANT_READ) || (sslError == SSL_ERROR_WANT_WRITE))
+               {
+                       goto ssl_accept;
+               }
+               else if ((r != E_WOULD_BLOCK) && (r != E_SUCCESS))
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to accept the socket.", GetErrorMessage(r));
+                       goto CATCH;
+               }
+       }
+       else
+       {
+               r = SslAccept(pClientSocketImpl->__pSsl, sslError);
+               if (r != E_SUCCESS)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to accept the socket.", GetErrorMessage(r));
+                       goto CATCH;
+               }
+       }
+
+       // New socket creation complete!
+       pClientSocketImpl->__socketFd = clientFd;
+       pClientSocketImpl->__isClosed = false;
+       pClientSocketImpl->__isNonblock = this->__isNonblock;
+       pClientSocketImpl->__socketEventType = this->__socketEventType;
+       pClientSocketImpl->__isServer = false;
+       pClientSocketImpl->__isConnectFired = true;
+       pClientSocketImpl->__protocolFamily = this->__protocolFamily;
+       pClientSocketImpl->__socketType = this->__socketType;
+       pClientSocketImpl->__protocol = this->__protocol;
+       pClientSocketImpl->__pGMainContext = this->__pGMainContext;
+       pClientSocketImpl->__isConstructed = true;
+       //pClientSocketImpl->__pSsl = this->__pSsl;
+       pClientSocketImpl->__isSslConnected = true;
+       pClientSocketImpl->__isRunFinished = true;
+
+       pClientSocket->__pSecureSocketImpl = pClientSocketImpl;
+
+       SysLog(NID_NET_SOCK, "New Secure Socket(Child Socket) is created by Server Secure Socket. [ServerFd : %d] [ChildFd : %d]", pClientSocket->__pSecureSocketImpl->__socketFd, __socketFd);
+
+       if (__isAsync == true)
+       {
+               pClientSocketImpl->__pGlibSocketInfo = new (std::nothrow) _GlibSecureSocketInfo();
+               SysTryCatch(NID_NET_SOCK, __pGlibSocketInfo, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = pClientSocketImpl->__pGlibSocketInfo->SetSocketEvent(pClientSocketImpl, clientFd);
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Memory allocation failed.", GetErrorMessage(r));
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach All condition to ClientFd.", clientFd);
+       }
+
+       pthread_mutex_unlock(&__mapMutex);
+
+       return pClientSocket;
+
+CATCH:
+       pthread_mutex_unlock(&__mapMutex);
+
+       if (pClientSocket != null)
+       {
+               delete pClientSocket;
+               pClientSocket = null;
+       }
+
+       if (pCaPath != null)
+       {
+           delete[] pCaPath;
+           pCaPath = null;
+       }
+
+       SetLastResult(r);
+       return null;
+}
+
+result
+_SecureSocketImpl::Close(void)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       int sockFd = __socketFd;
+       IEnumeratorT<ISecureSocketEventListener*>* pEnum = null;
+       ISecureSocketEventListener* pSecureSocketEventListener = null;
+
+       pEnum = __secureSocketEventListenerList.GetEnumeratorN();
+
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       r = pEnum->GetCurrent(pSecureSocketEventListener);
+
+                       if (pSecureSocketEventListener != null)
+                       {
+                               r = __pSecureSocketEvent->RemoveListener(*pSecureSocketEventListener);
+                               r = __secureSocketEventListenerList.Remove(const_cast<ISecureSocketEventListener*>(pSecureSocketEventListener));
+                       }
+               }
+               delete pEnum;
+       }
+
+       if (__pGlibSocketInfo != null)
+       {
+               delete __pGlibSocketInfo;
+               __pGlibSocketInfo = null;
+       }
+
+       if (__socketFd > INVALID_HANDLE)
+       {
+               if (close(__socketFd) < 0)
+               {
+                       r = ConvertErrorToResult(errno);
+                       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to close the socket.");
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Socket is closed. [Fd : %d]", sockFd);
+
+       __socketFd = INVALID_HANDLE;
+       __isClosed = true;
+
+       return r;
+}
+
+result
+_SecureSocketImpl::GetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int& optionValue) const
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+       int err = 0;
+
+       int optLevel = 0;
+       int optName = 0;
+       unsigned int optLen = 0;
+
+       struct timeval timeout;
+
+       char* pVersion = null;
+       char* pCipher = null;
+
+       switch (optionLevel)
+       {
+       case NET_SOCKET_IPPROTO_TCP:
+               optLevel = IPPROTO_TCP;
+
+               if (((optionName == NET_SOCKET_SO_SSLVERSION) || (optionName == NET_SOCKET_SO_SSLCIPHERSUITEID) ||
+                               (optionName == NET_SOCKET_SO_SSLCERTVERIFY) || (optionName == NET_SOCKET_SO_SSLCLIENTCERTVERIFY) || (optionName == NET_SOCKET_SO_SSLCERTID)))
+               {
+                       r = E_INVALID_ARG;
+                       SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] Invalid argument is used.");
+                       return r;
+               }
+               break;
+
+       case NET_SOCKET_IPPROTO_IP:
+               optLevel = IPPROTO_IP;
+
+               if (((optionName == NET_SOCKET_SO_SSLVERSION) || (optionName == NET_SOCKET_SO_SSLCIPHERSUITEID) ||
+                               (optionName == NET_SOCKET_SO_SSLCERTVERIFY) || (optionName == NET_SOCKET_SO_SSLCLIENTCERTVERIFY) || (optionName == NET_SOCKET_SO_SSLCERTID)))
+               {
+                       r = E_INVALID_ARG;
+                       SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] Invalid argument is used.");
+                       return r;
+               }
+               break;
+
+       case NET_SOCKET_SOL_SOCKET:
+               optLevel = SOL_SOCKET;
+               break;
+
+       default:
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] Invalid argument is used.");
+               return r;
+       }
+
+       switch (optionName)
+       {
+       case NET_SOCKET_SO_SSLVERSION:
+
+               if (__pSsl == null)
+               {
+                       optionValue = __sslVersion;
+                       return r;
+               }
+
+               pVersion = (char*) SSL_get_version(__pSsl);
+               SysTryReturn(NID_NET_SOCK, pVersion != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get the option value.");
+
+               if (strcmp(pVersion, "SSLv3") == 0)
+               {
+                       optionValue = NET_SOCK_SSL_VERSION_SSLV3;
+               }
+               else if (strcmp(pVersion, "TLSv1") == 0)
+               {
+                       optionValue = NET_SOCK_SSL_VERSION_TLSV1;
+               }
+               else
+               {
+                       r = E_SYSTEM;
+                       SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to get the option value.");
+                       return r;
+               }
+
+               return r;
+
+       case NET_SOCKET_SO_SSLCIPHERSUITEID:
+
+               if (__pSsl == null)
+               {
+                       optionValue = __sslCipherSuiteId;
+                       return r;
+               }
+
+               pCipher = (char*) SSL_get_cipher(__pSsl);
+               SysTryReturn(NID_NET_SOCK, pCipher != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get the option value.");
+
+               if (strcmp(pCipher, "RC4-MD5") == 0)
+               {
+                       optionValue = NET_SOCK_TLS_SSL_RSA_WITH_RC4_128_MD5;
+               }
+               else if (strcmp(pCipher, "RC4-SHA") == 0)
+               {
+                       optionValue = NET_SOCK_TLS_SSL_RSA_WITH_RC4_128_SHA;
+               }
+               else if (strcmp(pCipher, "DES-CBC-SHA") == 0)
+               {
+                       optionValue = NET_SOCK_TLS_SSL_RSA_WITH_DES_CBC_SHA;
+               }
+               else if (strcmp(pCipher, "DES-CBC3-SHA") == 0)
+               {
+                       optionValue = NET_SOCK_TLS_SSL_RSA_WITH_3DES_EDE_CBC_SHA;
+               }
+               else if (strcmp(pCipher, "AES128-SHA") == 0)
+               {
+                       optionValue = NET_SOCK_TLS_SSL_RSA_WITH_AES_128_CBC_SHA;
+               }
+               else if (strcmp(pCipher, "EXP-DES-CBC-SHA") == 0)
+               {
+                       optionValue = NET_SOCK_TLS_SSL_RSA_EXPORT_WITH_DES40_CBC_SHA;
+               }
+               else
+               {
+                       r = E_SYSTEM;
+                       SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to get the option value.");
+                       return r;
+               }
+
+               return r;
+
+       case NET_SOCKET_TCP_NODELAY:
+               optName = TCP_NODELAY;
+               break;
+
+       case NET_SOCKET_TCP_MAXSEG:
+               optName = TCP_MAXSEG;
+               break;
+
+       case NET_SOCKET_IP_TTL:
+               optName = IP_TTL;
+               break;
+
+       case NET_SOCKET_IP_TOS:
+               optName = IP_TOS;
+               break;
+
+       case NET_SOCKET_SO_KEEPALIVE:
+               optName = SO_KEEPALIVE;
+               break;
+
+       case NET_SOCKET_SO_OOBINLINE:
+               optName = SO_OOBINLINE;
+               break;
+
+       case NET_SOCKET_SO_RCVBUF:
+               optName = SO_RCVBUF;
+               break;
+
+       case NET_SOCKET_SO_RCVTIMEO:
+               optName = SO_RCVTIMEO;
+               break;
+
+       case NET_SOCKET_SO_REUSEADDR:
+               optName = SO_REUSEADDR;
+               break;
+
+       case NET_SOCKET_SO_SNDBUF:
+               optName = SO_SNDBUF;
+               break;
+
+       case NET_SOCKET_SO_SNDTIMEO:
+               optName = SO_SNDTIMEO;
+               break;
+
+       case NET_SOCKET_SO_TYPE:
+               optName = SO_TYPE;
+               break;
+
+       default:
+               r = E_UNSUPPORTED_OPTION;
+               SysLogException(NID_NET_SOCK, r, "[E_UNSUPPORTED_OPTION] %d is unsupported", optionName);
+               return r;
+       }
+
+       if (optName == SO_RCVTIMEO || optName == SO_SNDTIMEO)
+       {
+               optLen = sizeof(timeout);
+               err = getsockopt(__socketFd, optLevel, optName, &timeout, &optLen);
+               optionValue = (timeout.tv_sec * 1000) + (timeout.tv_usec / 1000);
+       }
+       else
+       {
+               optLen = sizeof(optionValue);
+               err = getsockopt(__socketFd, optLevel, optName, (int*) &optionValue, &optLen);
+       }
+
+       if (err < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to get the option value.", GetErrorMessage(r));
+       }
+
+       return r;
+}
+
+result
+_SecureSocketImpl::SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int optionValue)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+       SysTryReturnResult(NID_NET_SOCK, __pSslCtx != null, E_INVALID_ARG, "The SSL context is null.");
+
+       result r = E_SUCCESS;
+       int err = 0;
+
+       int optLevel = NET_SOCKET_OPTLEVEL_NONE;
+       int optName = NET_SOCKET_OPTNAME_NONE;
+       unsigned int optLen = 0;
+
+       struct timeval timeout;
+
+       char* pCipher = null;
+
+       switch (optionLevel)
+       {
+       case NET_SOCKET_IPPROTO_TCP:
+               optLevel = IPPROTO_TCP;
+
+               if (((optionName == NET_SOCKET_SO_SSLVERSION) || (optionName == NET_SOCKET_SO_SSLCIPHERSUITEID) ||
+                               (optionName == NET_SOCKET_SO_SSLCERTVERIFY) || (optionName == NET_SOCKET_SO_SSLCLIENTCERTVERIFY) || (optionName == NET_SOCKET_SO_SSLCERTID)))
+               {
+                       r = E_INVALID_ARG;
+                       SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] Invalid argument is used.");
+                       return r;
+               }
+               break;
+
+       case NET_SOCKET_IPPROTO_IP:
+               optLevel = IPPROTO_IP;
+
+               if (((optionName == NET_SOCKET_SO_SSLVERSION) || (optionName == NET_SOCKET_SO_SSLCIPHERSUITEID) ||
+                               (optionName == NET_SOCKET_SO_SSLCERTVERIFY) || (optionName == NET_SOCKET_SO_SSLCLIENTCERTVERIFY) || (optionName == NET_SOCKET_SO_SSLCERTID)))
+               {
+                       r = E_INVALID_ARG;
+            SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] Invalid argument is used.");
+                       return r;
+               }
+               break;
+
+       case NET_SOCKET_SOL_SOCKET:
+               optLevel = SOL_SOCKET;
+               break;
+
+       default:
+               r = E_INVALID_ARG;
+        SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] Invalid argument is used.");
+               return r;
+       }
+
+       switch (optionName)
+       {
+       case NET_SOCKET_SO_SSLVERSION:
+
+               SSL_CTX_free(__pSslCtx);
+               __pSslCtx = null;
+
+               SSL_load_error_strings();
+               ERR_load_BIO_strings();
+               OpenSSL_add_all_algorithms();
+               CRYPTO_malloc_init();
+               SSLeay_add_all_algorithms();
+               ERR_load_crypto_strings();
+
+               if (optionValue == NET_SOCK_SSL_VERSION_SSLV3)
+               {
+                       __pSslMethod = (SSL_METHOD*) SSLv3_method();
+                       __sslVersion = NET_SOCK_SSL_VERSION_SSLV3;
+               }
+               else if (optionValue == NET_SOCK_SSL_VERSION_TLSV1)
+               {
+                       __pSslMethod = (SSL_METHOD*) TLSv1_method();
+                       __sslVersion = NET_SOCK_SSL_VERSION_TLSV1;
+               }
+
+               __pSslCtx = SSL_CTX_new(__pSslMethod);
+               SysTryCatch(NID_NET_SOCK, __pSslCtx != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the SSL Context.");
+
+               return r;
+
+       case NET_SOCKET_SO_SSLCIPHERSUITEID:
+               if (optionValue == NET_SOCK_TLS_SSL_RSA_WITH_RC4_128_MD5)
+               {
+                       pCipher = (char*) "RC4-MD5";
+                       __sslCipherSuiteId = NET_SOCK_TLS_SSL_RSA_WITH_RC4_128_MD5;
+               }
+               else if (optionValue == NET_SOCK_TLS_SSL_RSA_WITH_RC4_128_SHA)
+               {
+                       pCipher = (char*) "RC4-SHA";
+                       __sslCipherSuiteId = NET_SOCK_TLS_SSL_RSA_WITH_RC4_128_SHA;
+               }
+               else if (optionValue == NET_SOCK_TLS_SSL_RSA_WITH_DES_CBC_SHA)
+               {
+                       pCipher = (char*) "DES-CBC-SHA";
+                       __sslCipherSuiteId = NET_SOCK_TLS_SSL_RSA_WITH_DES_CBC_SHA;
+               }
+               else if (optionValue == NET_SOCK_TLS_SSL_RSA_WITH_3DES_EDE_CBC_SHA)
+               {
+                       pCipher = (char*) "DES-CBC3-SHA";
+                       __sslCipherSuiteId = NET_SOCK_TLS_SSL_RSA_WITH_3DES_EDE_CBC_SHA;
+               }
+               else if (optionValue == NET_SOCK_TLS_SSL_RSA_WITH_AES_128_CBC_SHA)
+               {
+                       pCipher = (char*) "AES128-SHA";
+                       __sslCipherSuiteId = NET_SOCK_TLS_SSL_RSA_WITH_AES_128_CBC_SHA;
+               }
+               else if (optionValue == NET_SOCK_TLS_SSL_RSA_EXPORT_WITH_DES40_CBC_SHA)
+               {
+                       pCipher = (char*) "EXP-DES-CBC-SHA";
+                       __sslCipherSuiteId = NET_SOCK_TLS_SSL_RSA_EXPORT_WITH_DES40_CBC_SHA;
+               }
+               else if (optionValue == NET_SOCK_TLS_SSL_SYSTEM_DEFAULT_CIPHERSUITES)
+               {
+                       pCipher = (char*) "RC4-MD5:RC4-SHA:DES-CBC-SHA:DES-CBC3-SHA:AES128-SHA:EXP-DES-CBC-SHA";
+                       __sslCipherSuiteId = NET_SOCK_TLS_SSL_SYSTEM_DEFAULT_CIPHERSUITES;
+               }
+
+               if (SSL_CTX_set_cipher_list(__pSslCtx, pCipher) <= 0)
+               {
+                       __sslCipherSuiteId = NET_SOCK_TLS_SSL_NULL_WITH_NULL_NULL;
+                       SysLog(NID_NET_SOCK, "Failed to the Setting Cipher.");
+                       r = E_SYSTEM;
+               }
+
+               return r;
+
+       case NET_SOCKET_SO_SSLCLIENTCERTVERIFY:
+
+               if (__isAsync == true || __isNonblock == true)
+               {
+                       SSL_CTX_set_verify(__pSslCtx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT | SSL_VERIFY_CLIENT_ONCE,
+                                       (int (*)(int, X509_STORE_CTX*)) _SecureSocketImpl::OnVerifyClientCallback);
+               }
+               else
+               {
+                       SSL_CTX_set_verify(__pSslCtx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT | SSL_VERIFY_CLIENT_ONCE, null);
+               }
+
+               __sslVerify = SECURE_SOCKET_VERIFY_ENABLE;
+
+               return r;
+       case NET_SOCKET_SO_SSLCERTVERIFY:
+
+               if (__isAsync == true || __isNonblock == true)
+               {
+                       if (optionValue > 0)   // Enable SSL Verification
+                       {
+                               __sslVerify = SECURE_SOCKET_VERIFY_ENABLE;
+                       }
+                       else if (optionValue == 0) // Disable SSL Verification
+                       {
+                               __sslVerify = SECURE_SOCKET_VERIFY_DISABLE;
+                       }
+               }
+               else
+               {
+                       if (optionValue > 0) // Enable SSL Verification
+                       {
+                               __sslVerify = SECURE_SOCKET_VERIFY_ENABLE;
+                               SSL_CTX_set_verify(__pSslCtx, SSL_VERIFY_PEER, null);
+                       }
+                       else if (optionValue == 0) // Disable SSL Verification
+                       {
+                               __sslVerify = SECURE_SOCKET_VERIFY_DISABLE;
+                               SSL_CTX_set_verify(__pSslCtx, SSL_VERIFY_NONE, null);
+                       }
+               }
+               return r;
+
+       case NET_SOCKET_SO_SSLCERTID:
+       {
+               X509* pCert = null;
+               EVP_PKEY* pKey = null;
+
+               _CertServiceProxy* pCertProxy = null;
+               pCertProxy = _CertServiceProxy::GetInstance();
+               SysTryReturnResult(NID_NET_SOCK, pCertProxy != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               unique_ptr<_CertInfo, _CertInfoDeleter> pCertInfo(pCertProxy->GetUserCertificateByCertIdN(optionValue, _CERT_ENC_TYPE_PEM));
+               r = GetLastResult();
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS && pCertInfo != null, E_SYSTEM, "Certificate(%d) is not found.", optionValue);
+
+               BIO* pNewBIoCert = BIO_new(BIO_s_mem());
+               unique_ptr<BIO, _BIoDeleter> pBIoCert(pNewBIoCert);
+               SysTryReturnResult(NID_NET_SOCK, pBIoCert != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               BIO_write(pNewBIoCert, (const void*)pCertInfo->certificate, pCertInfo->certLength);
+               pCert = PEM_read_bio_X509(pNewBIoCert, null, 0, null);
+               SysTryReturnResult(NID_NET_SOCK, pCert != null, E_SYSTEM, "Failed to read Certificate(%d).", optionValue);
+
+               if (SSL_CTX_use_certificate(__pSslCtx, pCert) <= 0)
+               {
+                       r = E_SYSTEM;
+                       SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to load the certificate.");
+                       goto CATCH;
+               }
+
+               BIO* pNewBIoKey = BIO_new(BIO_s_mem());
+               unique_ptr<BIO, _BIoDeleter> pBIoKey(pNewBIoKey);
+               SysTryReturnResult(NID_NET_SOCK, pBIoKey != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               BIO_write(pNewBIoKey, (const void*)pCertInfo->privatekey, pCertInfo->privateKeyLen);
+               pKey = PEM_read_bio_PrivateKey(pNewBIoKey, null, 0, null);
+               SysTryReturnResult(NID_NET_SOCK, pKey != null, E_SYSTEM, "Failed to read Private Key.");
+
+               if (SSL_CTX_use_PrivateKey(__pSslCtx, pKey) <= 0)
+               {
+                       r = E_SYSTEM;
+                       SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to load the private key.");
+                       goto CATCH;
+               }
+
+               if (SSL_CTX_check_private_key(__pSslCtx) <= 0)
+               {
+                       r = E_SYSTEM;
+                       SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to check the private key.");
+                       goto CATCH;
+               }
+
+               SysLog(NID_NET_SOCK, "### Certificate loaded successfully. ###");
+       }
+               return r;
+
+       case NET_SOCKET_TCP_NODELAY:
+               optName = TCP_NODELAY;
+               break;
+
+       case NET_SOCKET_TCP_MAXSEG:
+               optName = TCP_MAXSEG;
+               break;
+
+       case NET_SOCKET_IP_TTL:
+               optName = IP_TTL;
+               break;
+
+       case NET_SOCKET_IP_TOS:
+               optName = IP_TOS;
+               break;
+
+       case NET_SOCKET_SO_KEEPALIVE:
+               optName = SO_KEEPALIVE;
+               break;
+
+       case NET_SOCKET_SO_OOBINLINE:
+               optName = SO_OOBINLINE;
+               break;
+
+       case NET_SOCKET_SO_RCVBUF:
+               optName = SO_RCVBUF;
+               break;
+
+       case NET_SOCKET_SO_RCVTIMEO:
+               optName = SO_RCVTIMEO;
+               // milliseconds
+               timeout.tv_sec = optionValue / 1000;
+               timeout.tv_usec = (optionValue % 1000) * 1000;
+               break;
+
+       case NET_SOCKET_SO_REUSEADDR:
+               optName = SO_REUSEADDR;
+               break;
+
+       case NET_SOCKET_SO_SNDBUF:
+               optName = SO_SNDBUF;
+               break;
+
+       case NET_SOCKET_SO_SNDTIMEO:
+               optName = SO_SNDTIMEO;
+               // milliseconds
+               timeout.tv_sec = optionValue / 1000;
+               timeout.tv_usec = (optionValue % 1000) * 1000;
+               break;
+
+       default:
+               r = E_UNSUPPORTED_OPTION;
+               SysLogException(NID_NET_SOCK, r, "[E_UNSUPPORTED_OPTION] %d is unsupported", optionName);
+               return r;
+       }
+
+       if (optName == SO_RCVTIMEO || optName == SO_SNDTIMEO)
+       {
+               optLen = sizeof(timeout);
+               err = setsockopt(__socketFd, optLevel, optName, (struct timeval*) &timeout, optLen);
+       }
+       else
+       {
+               optLen = sizeof(optionValue);
+               err = setsockopt(__socketFd, optLevel, optName, (int*) &optionValue, optLen);
+       }
+
+       if (err < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to get the linger option value.", GetErrorMessage(r));
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_SecureSocketImpl::AsyncSelectByListener(unsigned long socketEventType)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       if (__pGlibSocketInfo == null)
+       {
+               __pGlibSocketInfo = new (std::nothrow) _GlibSecureSocketInfo();
+               SysTryReturnResult(NID_NET_SOCK, __pGlibSocketInfo, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       SysLog(NID_NET_SOCK, "Socket set the socketEvent by AsyncSelectByListener. [Fd : %d]", __socketFd);
+
+       __socketEventType = socketEventType;
+       __isNonblock = true;
+       __isAsync = true;
+
+       return r;
+}
+
+result
+_SecureSocketImpl::AddSecureSocketListener(ISecureSocketEventListener& listener)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       _EventDispatcher* pEventDispatcher = _EventDispatcher::GetCurrentEventDispatcher();
+       SysTryReturnResult(NID_NET_SOCK, pEventDispatcher, E_SYSTEM, "GetCurrentEventDispatcher is null.");
+
+       __pGMainContext = pEventDispatcher->GetGMainContext();
+    SysTryReturnResult(NID_NET_SOCK, __pGMainContext, E_SYSTEM, "GetGMainContext is null.");
+
+       r = __pSecureSocketEvent->AddListener(listener, true);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to add the listener.");
+
+       r = __secureSocketEventListenerList.Add(&listener);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to add the listener to the list.");
+
+       return r;
+}
+
+result
+_SecureSocketImpl::RemoveSecureSocketListener(ISecureSocketEventListener& listener)
+{
+       SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       r = __pSecureSocketEvent->RemoveListener(listener);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to remove the listener.");
+
+       r = __secureSocketEventListenerList.Remove(&listener);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to remove the listener to the list.");
+
+       return r;
+}
+
+int
+_SecureSocketImpl::GetSecureSocketFd(void)
+{
+       SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       return __socketFd;
+}
+
+Object*
+_SecureSocketImpl::Run(void)
+{
+       result r = E_SUCCESS;
+
+       int sslError = 0;
+
+ssl_connect:
+       r = SslConnect(sslError);
+       if ((sslError == SSL_ERROR_WANT_READ) || (sslError == SSL_ERROR_WANT_WRITE) || (sslError == SSL_ERROR_WANT_CONNECT))
+       {
+                       goto ssl_connect;
+       }
+
+       SysLog(NID_NET_SOCK, "Worker thread finished. - SslConnect::Run()");
+
+       if (__isAsync == true)
+       {
+               __isRunFinished = true;
+               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+               SysTryReturn(NID_NET_SOCK, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach All condition.", __socketFd);
+       }
+
+       return null;
+}
+
+SecureSocket*
+_SecureSocketImpl::GetSecureSocket(void) const
+{
+       return __pSecureSocket;
+}
+
+_SecureSocketImpl*
+_SecureSocketImpl::GetInstance(SecureSocket& secureSocket)
+{
+       return secureSocket.__pSecureSocketImpl;
+}
+
+const _SecureSocketImpl*
+_SecureSocketImpl::GetInstance(const SecureSocket& secureSocket)
+{
+       return secureSocket.__pSecureSocketImpl;
+}
+
+result
+_SecureSocketImpl::Dispose(void)
+{
+       SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       r = Close();
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to close the socket.");
+
+       __isClosed = true;
+
+       return r;
+}
+
+// glib event
+gboolean
+_SecureSocketImpl::OnGioEventCallback(GIOChannel* pSource, GIOCondition condition, gpointer pUserData)
+{
+       SysLog(NID_NET_SOCK, "### OnGioEventCallback ###");
+
+       result errorCode = E_SUCCESS;
+       GIOStatus status = G_IO_STATUS_NORMAL;
+       gchar buffer[1024];
+       gsize bytes_read = 0;
+       int readSize = 0;
+       char peekBuf = '\0';
+       int connStatus = 0;
+       int sslError = 0;
+       int timerId = INVALID_HANDLE;
+       int error = 0;
+
+       _SecureUserData* pRecvUserData = (_SecureUserData*) pUserData;
+
+       _SecureSocketEventArg* pEventArg = null;
+
+       _SecureSocketImpl* pSecureSocketImpl = static_cast <_SecureSocketImpl*>(pRecvUserData->pSecureSocketImpl);
+       GSource* pGSource = static_cast <GSource*>(pRecvUserData->pGSource);
+
+       SysLog(NID_NET_SOCK, "====> [Event] OnGioEventCallback : All GIO event is received.(%d).", condition);
+
+       if (condition & G_IO_ERR)
+       {
+           SysLog(NID_NET_SOCK, "====> [Event] Socket event is received.(G_IO_ERR)");
+
+               if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_CLOSE) && (pSecureSocketImpl->__isCloseFired == false))
+               {
+                       // Fire the event(NET_SOCKET_EVENT_CLOSE)
+                       pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+                       SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                       // G_IO_ERROR Converting
+                       status = g_io_channel_read_chars(pSource, buffer, sizeof(buffer), &bytes_read, null);
+                       errorCode = ConvertGioStatus(status);
+                       pEventArg->SetError(errorCode);
+                       pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+
+                       g_source_set_callback(pGSource, null, null, null);
+                       SysLog(NID_NET_SOCK, "### Set giocondition for GSource to null (%d)", g_source_get_id(pGSource));
+
+                       goto CATCH;
+               }
+       }
+
+       if (pSecureSocketImpl->__isServer)  // For Server
+       {
+               SysLog(NID_NET_SOCK, "====> [Event] This is secure socket server");
+
+               if (condition & G_IO_IN)
+               {
+                       SysLog(NID_NET_SOCK, "====> [Event] Secure socket event is received(G_IO_IN).");
+
+                       struct pollfd fds[1];
+                       fds[0].fd = pSecureSocketImpl->__socketFd;
+                       fds[0].events = POLLRDHUP;
+
+                       error = poll(fds, 1, 0);
+                       SysTryCatch(NID_NET_SOCK, error != -1, , null, "Failed to the poll");
+
+                       if (fds[0].revents & POLLRDHUP)
+                       {
+                               SysLog(NID_NET_SOCK, "====> Socket is not available.(POLLRDHUP)");
+
+                               ioctl(pSecureSocketImpl->__socketFd, FIONREAD, &readSize);
+                               SysLog(NID_NET_SOCK, "Amount of data that can be read : %d bytes. [Fd: %d]", readSize, pSecureSocketImpl->__socketFd);
+
+                               if (readSize <= 0)
+                               {
+                                       if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_CLOSE) && (pSecureSocketImpl->__isCloseFired == false))
+                                       {
+                                               //Fire the event(NET_SOCKET_EVENT_CLOSE)
+                                               pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+                                               SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                                               // G_IO_ERROR Converting
+                                               status = g_io_channel_read_chars(pSource, buffer, sizeof(buffer), &bytes_read, null);
+                                               errorCode = ConvertGioStatus(status);
+                                               pEventArg->SetError(errorCode);
+                                               pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+
+                                               g_source_set_callback(pGSource, null, null, null);
+                                               SysLog(NID_NET_SOCK, "### Set giocondition for GSource to null (%d)", g_source_get_id(pGSource));
+
+                                               goto CATCH;
+                                       }
+                               }
+                               else
+                               {
+                                       connStatus = SSL_peek(pSecureSocketImpl->__pSsl, (char*) &peekBuf, 1);
+                                       SysLog(NID_NET_SOCK, "Connection Status : %d.", connStatus);
+
+                                       sslError = SSL_get_error(pSecureSocketImpl->__pSsl, connStatus);
+
+                                       // Error code mapping
+                                       switch (sslError)
+                                       {
+                                       case SSL_ERROR_ZERO_RETURN:
+                                               SysLog(NID_NET_SOCK, "Connection closed by peer : %d.", sslError);
+                                               break;
+
+                                       default:
+                                               SysLog(NID_NET_SOCK, "Connection is active : %d.", sslError);
+                                               break;
+                                       }
+
+                                       if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_CLOSE) &&
+                                                       (pSecureSocketImpl->__isCloseFired == false) && (connStatus == 0))
+                                       {
+                                               // Fire the event(NET_SOCKET_EVENT_CLOSE)
+                                               pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+                                               SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                                               // G_IO_ERROR Converting
+                                               //status = g_io_channel_read_chars(pSource, buffer, sizeof(buffer), &bytes_read, null);
+                                               //errorCode = ConvertGioStatus(status);
+                                               pEventArg->SetError(E_SUCCESS);
+                                               pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+
+                                               g_source_set_callback(pGSource, null, null, null);
+                                               SysLog(NID_NET_SOCK, "### Set giocondition for GSource to null (%d)", g_source_get_id(pGSource));
+
+                                               goto CATCH;
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               SysLog(NID_NET_SOCK, "====> SOCKET is available.(Not POLLRDHUP)");
+
+                               if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_ACCEPT) && (pSecureSocketImpl->__isAcceptFired == false) &&
+                                               (pSecureSocketImpl->__isCloseFired == false))
+                               {
+                                       //Fire the event(NET_SOCKET_EVENT_ACCEPT)
+                                       pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_ACCEPT);
+                                       SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                                       pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+
+                                       goto CATCH;
+                               }
+                       }
+               }
+
+               if (condition & G_IO_OUT)
+               {
+                   SysLog(NID_NET_SOCK, "====> [Event] Secure socket event is received.(G_IO_OUT).");
+               }
+
+       }
+       else  // For Client
+       {
+               SysLog(NID_NET_SOCK, "====> [Event] This is Secure socket client");
+
+               if (condition & G_IO_IN)
+               {
+                   SysLog(NID_NET_SOCK, "====> [Event] Secure socket event is received.(G_IO_IN).");
+
+                       if (pSecureSocketImpl->__isRunFinished == true)
+                       {
+                               if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_CLOSE) &&
+                                               (pSecureSocketImpl->__isConnectFailed == true) && (pSecureSocketImpl->__isCloseFired == false))
+                               {
+                                       // Fire the event(NET_SOCKET_EVENT_CLOSE)
+                                       errorCode = E_SYSTEM;
+                                       pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+                                       SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                                       pEventArg->SetError(errorCode);
+                                       pSecureSocketImpl->__isConnectFailed = false;
+                                       pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+
+                                       g_source_set_callback(pGSource, null, null, null);
+                                       SysLog(NID_NET_SOCK, "### Set giocondition for GSource to null (%d)", g_source_get_id(pGSource));
+
+                                       goto CATCH;
+                               }
+
+                               if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_CLOSE) &&
+                                               (pSecureSocketImpl->__isClientNoCert == true) && (pSecureSocketImpl->__isCloseFired == false))
+                               {
+                                       //Fire the event(NET_SOCKET_EVENT_CLOSE)
+                                       errorCode = E_NO_CERTIFICATE;
+                                       pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+                                       pEventArg->SetError(errorCode);
+                                       pSecureSocketImpl->__isClientNoCert = false;
+                                       pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+
+                                       g_source_set_callback(pGSource, null, null, null);
+                                       SysLog(NID_NET_SOCK, "### Set giocondition for GSource to null (%d)", g_source_get_id(pGSource));
+
+                                       goto CATCH;
+                               }
+
+                               struct pollfd fds[1];
+                               fds[0].fd = pSecureSocketImpl->__socketFd;
+                               fds[0].events = POLLRDHUP;
+
+                   error = poll(fds, 1, 0);
+                   SysTryCatch(NID_NET_SOCK, error != -1, , null, "Failed to the poll");
+
+                               if (fds[0].revents & POLLRDHUP)
+                               {
+                                       SysLog(NID_NET_SOCK, "====> Socket is not available.(POLLRDHUP)");
+
+                                       ioctl(pSecureSocketImpl->__socketFd, FIONREAD, &readSize);
+                                       SysLog(NID_NET_SOCK, "Amount of data that can be read : %d bytes. [Fd: %d]", readSize,
+                                                               pSecureSocketImpl->__socketFd);
+
+                                       if (readSize <= 0)
+                                       {
+                                               if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_CLOSE) &&
+                                                               (pSecureSocketImpl->__isCloseFired == false))
+                                               {
+                                                       //Fire the event(NET_SOCKET_EVENT_CLOSE)
+                                                       pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+                                                       // G_IO_ERROR Converting
+                                                       status = g_io_channel_read_chars(pSource, buffer, sizeof(buffer), &bytes_read, null);
+                                                       errorCode = ConvertGioStatus(status);
+                                                       pEventArg->SetError(errorCode);
+                                                       pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+
+                                                       g_source_set_callback(pGSource, null, null, null);
+                                                       SysLog(NID_NET_SOCK, "### Set giocondition for GSource to null (%d)", g_source_get_id(pGSource));
+
+                                                       goto CATCH;
+                                               }
+                                       }
+                                       else
+                                       {
+                                               connStatus = SSL_peek(pSecureSocketImpl->__pSsl, (char*) &peekBuf, 1);
+                                               SysLog(NID_NET_SOCK, "Connection Status : %d.", connStatus);
+
+                                               sslError = SSL_get_error(pSecureSocketImpl->__pSsl, connStatus);
+
+                                               // Error code mapping
+                                               switch (sslError)
+                                               {
+                                               case SSL_ERROR_ZERO_RETURN:
+                                                       SysLog(NID_NET_SOCK, "Connection closed by peer : %d.", sslError);
+                                                       break;
+
+                                               default:
+                                                       SysLog(NID_NET_SOCK, "Connection is active : %d.", sslError);
+                                                       break;
+                                               }
+
+                                               if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_READ) &&
+                                                               (pSecureSocketImpl->__isConnectFired == true) && (pSecureSocketImpl->__isReadFired == false) &&
+                                                               (pSecureSocketImpl->__isCloseFired == false) && (connStatus > 0))
+                                               {
+                                                       // Fire the event(NET_SOCKET_EVENT_READ)
+                                                       pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_READ);
+                                                       SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                                                       pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+
+                                                       goto CATCH;
+                                               }
+
+                                               if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_CLOSE) &&
+                                                               (pSecureSocketImpl->__isCloseFired == false) && (connStatus == 0))
+                                               {
+                                                       // Fire the event(NET_SOCKET_EVENT_CLOSE)
+                                                       pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+                                                       SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                                                       // G_IO_ERROR Converting
+                                                       //status = g_io_channel_read_chars(pSource, buffer, sizeof(buffer), &bytes_read, null);
+                                                       //errorCode = ConvertGioStatus(status);
+                                                       pEventArg->SetError(E_SUCCESS);
+                                                       pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+
+                                                       g_source_set_callback(pGSource, null, null, null);
+                                                       SysLog(NID_NET_SOCK, "### set giocondition for GSource to null (%d)", g_source_get_id(pGSource));
+
+                                                       goto CATCH;
+                                               }
+                                       }
+                               }
+                               else
+                               {
+                                       SysLog(NID_NET_SOCK, "====> Socket is available.(Not POLLRDHUP)");
+
+                                       connStatus = SSL_peek(pSecureSocketImpl->__pSsl, (char*) &peekBuf, 1);
+                                       SysLog(NID_NET_SOCK, "Connection Status : %d.", connStatus);
+
+                                       sslError = SSL_get_error(pSecureSocketImpl->__pSsl, connStatus);
+
+                                       // Error code mapping
+                                       switch (sslError)
+                                       {
+                                       case SSL_ERROR_ZERO_RETURN:
+                                               SysLog(NID_NET_SOCK, "Connection closed by peer : %d.", sslError);
+                                               break;
+
+                                       default:
+                                               SysLog(NID_NET_SOCK, "Connection is active : %d.", sslError);
+                                               break;
+                                       }
+
+                                       if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_READ) &&
+                                                       (pSecureSocketImpl->__isConnectFired == true) && (pSecureSocketImpl->__isReadFired == false) &&
+                                                       (pSecureSocketImpl->__isCloseFired == false) && (connStatus > 0))
+                                       {
+                                               //Fire the event(NET_SOCKET_EVENT_READ)
+                                               pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_READ);
+                                               SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                                               pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+
+                                               goto CATCH;
+                                       }
+
+                                       if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_CLOSE) &&
+                                                       (pSecureSocketImpl->__isCloseFired == false) && (connStatus == 0))
+                                       {
+                                               // Fire the event(NET_SOCKET_EVENT_CLOSE)
+                                               pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+                                               SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                                               // G_IO_ERROR Converting
+                                               //status = g_io_channel_read_chars(pSource, buffer, sizeof(buffer), &bytes_read, null);
+                                               //errorCode = ConvertGioStatus(status);
+                                               pEventArg->SetError(E_SUCCESS);
+                                               pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+
+                                               g_source_set_callback(pGSource, null, null, null);
+                                               SysLog(NID_NET_SOCK, "### Set giocondition for GSource to null (%d)", g_source_get_id(pGSource));
+
+                                               goto CATCH;
+                                       }
+                               }
+                       }
+               }
+
+               if (condition & G_IO_OUT)
+               {
+                   SysLog(NID_NET_SOCK, "====> [Evesnt] Secure socket event is Received.(G_IO_OUT).");
+
+                       if (pSecureSocketImpl->__isWriteFired == true)
+                       {
+                           errorCode = pSecureSocketImpl->__pGlibSocketInfo->SetSocketEvent(pSecureSocketImpl, pSecureSocketImpl->__socketFd);
+                               SysTryReturn(NID_NET_SOCK, errorCode == E_SUCCESS, true, errorCode, "[%s] Memory allocation failed.", GetErrorMessage(errorCode));
+                               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to release G_IO_OUT condition in OnGioEventCallback.", pSecureSocketImpl->__socketFd);
+
+                               goto CATCH;
+                       }
+
+                       if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_CONNECT) && (pSecureSocketImpl->__isRunFinished == true) &&
+                                       (pSecureSocketImpl->__isConnectFired == false) && (pSecureSocketImpl->__isSslConnected == true) &&
+                                       (((pSecureSocketImpl->__isCertVerifyFailed == true) && (pSecureSocketImpl->__sslVerify == SECURE_SOCKET_VERIFY_DISABLE)) ||
+                                                       (pSecureSocketImpl->__isCertVerifyFailed == false)) && (pSecureSocketImpl->__isCloseFired == false))
+                       {
+                               timerId = g_source_get_id(pSecureSocketImpl->__pTimerSource);
+                               g_source_set_callback(pSecureSocketImpl->__pTimerSource, null, null, null);
+                               pSecureSocketImpl->__pTimerSource = null;
+                               SysLog(NID_NET_SOCK, "### Deleted g_source_destroy(%d)", timerId);
+
+                               // Fire the event(NET_SOCKET_EVENT_CONNECT)
+                               pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_CONNECT);
+                               SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                               pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+
+                               goto CATCH;
+                       }
+
+                       if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_WRITE) && (pSecureSocketImpl->__isRunFinished == true) &&
+                                       (pSecureSocketImpl->__isConnectFired == true) && (pSecureSocketImpl->__isSslConnected == true) &&
+                                       (pSecureSocketImpl->__isWriteFired == false) && (pSecureSocketImpl->__isCloseFired == false))
+                       {
+                               // Fire the event(NET_SOCKET_EVENT_WRITE)
+                               pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_WRITE);
+                               SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                               pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+
+                               goto CATCH;
+                       }
+               }
+       }
+
+       if (condition & G_IO_PRI)
+       {
+               SysLog(NID_NET_SOCK, "====> [Event] Secure socket event is received.(G_IO_PRI).");
+       }
+
+       if (condition & G_IO_HUP)
+       {
+        SysLog(NID_NET_SOCK, "====> [Event] Secure socket event is received.(G_IO_HUP).");
+       }
+
+       if (condition & G_IO_NVAL)
+       {
+        SysLog(NID_NET_SOCK, "====> [Event] Secure socket event is received.(G_IO_NVAL).");
+       }
+
+       return true;
+
+CATCH:
+       return true;
+}
+
+void
+_SecureSocketImpl::SetTimer(void)
+{
+       int timerId = -1;
+       GMainContext* pGMainContext = __pGMainContext;
+       __pTimerSource = g_timeout_source_new(_SECURE_SOCKET_CONNECTION_TIMEOUT * 1000);
+       g_source_set_callback(__pTimerSource, _SecureSocketImpl::OnTimerExpiredEvent, this, null);
+       g_source_attach(__pTimerSource, pGMainContext);
+
+       timerId = g_source_get_id(__pTimerSource);
+       SysLog(NID_NET_SOCK, "Created the TimerSource[%d], timeout[%d].", timerId, _SECURE_SOCKET_CONNECTION_TIMEOUT * 1000);
+}
+
+gboolean
+_SecureSocketImpl::OnTimerExpiredEvent(gpointer data)
+{
+       SysLog(NID_NET_SOCK, "### OnTimerExpiredEvent ###");
+
+       _SecureSocketImpl* pSecureSocketImpl = null;
+       _SecureSocketEventArg* pEventArg = null;
+
+       int timerId = -1;
+
+       pSecureSocketImpl = static_cast <_SecureSocketImpl*>(data);
+
+       if (pSecureSocketImpl->__pTimerSource != null)
+       {
+               timerId = g_source_get_id(pSecureSocketImpl->__pTimerSource);
+               g_source_set_callback(pSecureSocketImpl->__pTimerSource, null, null, null);
+               pSecureSocketImpl->__pTimerSource = null;
+               SysLog(NID_NET_SOCK, "### Deleted g_source_destroy(%d)", timerId);
+
+               if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_CLOSE) && (pSecureSocketImpl->__isCloseFired == false))
+               {
+                       pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+                       SysTryReturn(NID_NET_SOCK, pEventArg, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                       // Fire the event(NET_SOCKET_EVENT_CLOSE)
+                       pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+               }
+       }
+
+       return true;
+}
+
+int
+_SecureSocketImpl::OnVerifyPeerCallback(int preverify_ok, X509_STORE_CTX* pX509Ctx)
+{
+       SysLog(NID_NET_SOCK, "### OnVerifyPeerCallback ###");
+
+       _SecureSocketImpl* pSecureSocketImpl = null;
+       _SecureSocketEventArg* pEventArg = null;
+       X509* pServerCert = null;
+       SSL* pSsl = null;
+       char* pX509Field = null;
+       Integer* pSslTemp = null;
+       Integer* pVal = null;
+       int sslIndex = 0;
+       int sslError = 0;
+       int depth = 0;
+
+       pServerCert = X509_STORE_CTX_get_current_cert(pX509Ctx);
+
+       if (pServerCert != null)
+       {
+               pX509Field = X509_NAME_oneline(X509_get_subject_name(pServerCert), 0, 0);
+               SysLog(NID_NET_SOCK, "Certificate: [Subject: %s]", pX509Field);
+
+               OPENSSL_free(pX509Field);
+
+               pX509Field = X509_NAME_oneline(X509_get_issuer_name(pServerCert), 0, 0);
+               SysLog(NID_NET_SOCK, "Certificate: [Issuer: %s]", pX509Field);
+
+               OPENSSL_free(pX509Field);
+       }
+
+       sslIndex = SSL_get_ex_data_X509_STORE_CTX_idx();
+       SysLog(NID_NET_SOCK, "SSL index(%d).", sslIndex);
+
+       pSsl = (SSL*) X509_STORE_CTX_get_ex_data(pX509Ctx, sslIndex);
+       if (pSsl == null)
+       {
+               SysLog(NID_NET_SOCK, "Failed to get the SSL object.");
+               goto CATCH;
+       }
+
+       pSslTemp = new (std::nothrow) Integer((int)pSsl);
+
+       pthread_mutex_lock(&__mapMutex);
+
+       pVal = static_cast<Integer*>(_Singleton::GetSslMap()->GetValue(*pSslTemp));
+       if (pVal == null)
+       {
+               SysLog(NID_NET_SOCK, "Failed to get the SSL Object.");
+               pthread_mutex_unlock(&__mapMutex);
+               goto CATCH;
+       }
+
+       sslIndex = pVal->ToInt();
+       SysLog(NID_NET_SOCK, "Application index(%d).", sslIndex);
+
+       pthread_mutex_unlock(&__mapMutex);
+
+       delete pSslTemp;
+
+       pSecureSocketImpl = static_cast <_SecureSocketImpl*>(SSL_get_ex_data((SSL*) pSsl, sslIndex));
+       if (pSecureSocketImpl == null)
+       {
+               SysLog(NID_NET_SOCK, "Failed to get the _SecureSocketImpl object.");
+               goto CATCH;
+       }
+
+       depth = X509_STORE_CTX_get_error_depth(pX509Ctx);
+       if (depth > pSecureSocketImpl->__sslDepth)
+       {
+               sslError = X509_V_ERR_CERT_CHAIN_TOO_LONG;
+               X509_STORE_CTX_set_error(pX509Ctx, sslError);
+               goto CATCH;
+       }
+
+       sslError = X509_STORE_CTX_get_error(pX509Ctx);
+       if (sslError == X509_V_OK)
+       {
+               pSecureSocketImpl->__isCertVerifyFailed = false;
+               SysLog(NID_NET_SOCK, "Verification is success.");
+       }
+       else
+       {
+               SysLog(NID_NET_SOCK, "Failed to the peer certificate validation(%d).", sslError);
+
+               if ((pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_SERVCERT_FAIL) && (pSecureSocketImpl->__isCloseFired == false)
+                               && (pSecureSocketImpl->__isCertVerifyFailed == false))
+               {
+                       pEventArg = new (std::nothrow) _SecureSocketEventArg(pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_SERVCERT_FAIL);
+                       SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       // Fire the event(NET_SOCKET_EVENT_SERVCERT_FAIL)
+                       pSecureSocketImpl->__pSecureSocketEvent->Fire(*pEventArg);
+
+                       pSecureSocketImpl->__isCertVerifyFailed = true;
+
+                       pSecureSocketImpl->SetTimer();
+               }
+               else if (!(pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_SERVCERT_FAIL) && (pSecureSocketImpl->__sslVerify == SECURE_SOCKET_VERIFY_DISABLE))
+               {
+                       return 1;
+               }
+               else if (!(pSecureSocketImpl->__socketEventType & NET_SOCKET_EVENT_SERVCERT_FAIL))
+               {
+                       goto CATCH;
+               }
+       }
+
+       return 1;
+
+CATCH:
+       return 0;
+}
+
+int
+_SecureSocketImpl::OnVerifyClientCallback(int preverify_ok, X509_STORE_CTX* pX509Ctx)
+{
+       SysLog(NID_NET_SOCK, "### OnVerifyClientCallback ###");
+
+       _SecureSocketImpl* pSecureSocketImpl = null;
+       X509* pClientCert = null;
+       SSL* pSsl = null;
+       char* pX509Field = null;
+       Integer* pSslTemp = null;
+       Integer* pVal = null;
+       int sslIndex = 0;
+       int sslError = 0;
+       int depth = 0;
+
+       pClientCert = X509_STORE_CTX_get_current_cert(pX509Ctx);
+
+       if (pClientCert != null)
+       {
+               pX509Field = X509_NAME_oneline(X509_get_subject_name(pClientCert), 0, 0);
+               SysLog(NID_NET_SOCK, "Certificate: [Subject: %s]", pX509Field);
+
+               OPENSSL_free(pX509Field);
+
+               pX509Field = X509_NAME_oneline(X509_get_issuer_name(pClientCert), 0, 0);
+               SysLog(NID_NET_SOCK, "Certificate: [Issuer: %s]", pX509Field);
+
+               OPENSSL_free(pX509Field);
+       }
+
+       sslIndex = SSL_get_ex_data_X509_STORE_CTX_idx();
+       SysLog(NID_NET_SOCK, "SSL index(%d).", sslIndex);
+
+       pSsl = (SSL*) X509_STORE_CTX_get_ex_data(pX509Ctx, sslIndex);
+       if (pSsl == null)
+       {
+               SysLog(NID_NET_SOCK, "Failed to get the SSL object.");
+               goto CATCH;
+       }
+
+       pSslTemp = new Integer((int)pSsl);
+
+       pthread_mutex_lock(&__mapMutex);
+
+       pVal = static_cast<Integer*>(_Singleton::GetSslMap()->GetValue(*pSslTemp));
+       if (pVal == null)
+       {
+               SysLog(NID_NET_SOCK, "Failed to get the SSL Object.");
+               pthread_mutex_unlock(&__mapMutex);
+               goto CATCH;
+       }
+
+       sslIndex = pVal->ToInt();
+       SysLog(NID_NET_SOCK, "Application index(%d).", sslIndex);
+
+       pthread_mutex_unlock(&__mapMutex);
+
+       delete pSslTemp;
+
+       pSecureSocketImpl = static_cast <_SecureSocketImpl*>(SSL_get_ex_data((SSL*) pSsl, sslIndex));
+       if (pSecureSocketImpl == null)
+       {
+               SysLog(NID_NET_SOCK, "Failed to get the _SecureSocketImpl object.");
+               goto CATCH;
+       }
+
+       depth = X509_STORE_CTX_get_error_depth(pX509Ctx);
+       if (depth > pSecureSocketImpl->__sslDepth)
+       {
+               sslError = X509_V_ERR_CERT_CHAIN_TOO_LONG;
+               X509_STORE_CTX_set_error(pX509Ctx, sslError);
+               goto CATCH;
+       }
+
+       sslError = X509_STORE_CTX_get_error(pX509Ctx);
+       if (sslError == X509_V_OK)
+       {
+               SysLog(NID_NET_SOCK, "Verification of client certificate is success.");
+       }
+       else
+       {
+               SysLog(NID_NET_SOCK, "Failed to the client certificate validation(%d).", sslError);
+               goto CATCH;
+       }
+
+       return 1;
+
+CATCH:
+       return 0;
+}
+
+int
+_SecureSocketImpl::OnClientCertCallback(SSL* pSsl, X509** ppX509, EVP_PKEY** ppKey)
+{
+       SysLog(NID_NET_SOCK, "### OnClientCertCallback ###");
+
+       _SecureSocketImpl* pSecureSocketImpl = null;
+
+       int sslIndex = 0;
+       Integer* pSslTemp = null;
+       Integer* pVal = null;
+
+       pSslTemp = new (std::nothrow) Integer((int)pSsl);
+
+       pthread_mutex_lock(&__mapMutex);
+
+       pVal = static_cast<Integer*>(_Singleton::GetSslMap()->GetValue(*pSslTemp));
+       if (pVal == null)
+       {
+               SysLog(NID_NET_SOCK, "Failed to get the SSL Object.");
+               pthread_mutex_unlock(&__mapMutex);
+               goto CATCH;
+       }
+
+       sslIndex = pVal->ToInt();
+       SysLog(NID_NET_SOCK, "Application index(%d).", sslIndex);
+
+       pthread_mutex_unlock(&__mapMutex);
+
+       delete pSslTemp;
+
+       pSecureSocketImpl = static_cast <_SecureSocketImpl*>(SSL_get_ex_data((SSL*) pSsl, sslIndex));
+       if (pSecureSocketImpl == null)
+       {
+               SysLog(NID_NET_SOCK, "Failed to get the _SecureSocketImpl object.");
+               goto CATCH;
+       }
+
+       pSecureSocketImpl->__isClientNoCert = true;
+
+CATCH:
+       return 0;
+}
+
+RSA*
+_SecureSocketImpl::OnTmpRsaCallback(SSL* pSsl, int isexport, int keylength)
+{
+       SysLog(NID_NET_SOCK, "### OnTmpRsaCallback ###");
+
+       RSA* pRsa = null;
+
+       switch (keylength)
+       {
+       case _RSA_512_KEY:
+               pRsa = RSA_generate_key(512, RSA_F4, null, null);
+               break;
+       case _RSA_1024_KEY:
+               pRsa = RSA_generate_key(1024, RSA_F4, null, null);
+               break;
+       default:
+               break;
+       }
+
+       return pRsa;
+}
+
+result
+_SecureSocketImpl::SslConnect(int& sslError)
+{
+       result r = E_SUCCESS;
+
+       // char* pErrReason = null;
+       unsigned long errCode = 0;
+
+       // Perform the SSL Handshake
+       sslError = SSL_connect(__pSsl);
+
+       if (sslError < 1)
+       {
+               sslError = SSL_get_error(__pSsl, sslError);
+
+               // sslv3 alert handshake failure
+               // pErrReason = (char*) ERR_reason_error_string(ERR_get_error());
+
+               errCode = ERR_GET_REASON(ERR_get_error());
+
+               switch (sslError)
+               {
+               case SSL_ERROR_SSL: // Error occurred in SSL library or protocol error.
+                       SysLog(NID_NET_SOCK, "SslConnect - SSL_ERROR_SSL");
+                       r = ConvertSslError(errCode);
+                       if (!((errCode == SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE) || (errCode == SSL_R_SSLV3_ALERT_NO_CERTIFICATE)))
+                       {
+                               __isConnectFailed = true;
+                               r = E_SYSTEM;
+                       }
+                       break;
+
+               case SSL_ERROR_SYSCALL: // I/O Error Occurred.
+                       SysLog(NID_NET_SOCK, "SslConnect - SSL_ERROR_SYSCALL");
+                       __isConnectFailed = true;
+                       r = E_SYSTEM;
+                       break;
+
+               case SSL_ERROR_ZERO_RETURN: // TLS/SSL connection has been closed.
+                       SysLog(NID_NET_SOCK, "SslConnect - SSL_ERROR_ZERO_RETURN");
+                       __isConnectFailed = true;
+                       r = E_SYSTEM;
+                       break;
+
+               case SSL_ERROR_WANT_CONNECT: // Operation is not completed.
+               case SSL_ERROR_WANT_READ:
+               case SSL_ERROR_WANT_WRITE:
+//                     SysLog(NID_NET_SOCK, "SslConnect - SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE");
+                       r = E_WOULD_BLOCK;
+                       break;
+
+               default:
+                       SysLog(NID_NET_SOCK, "SslConnect - default");
+                       __isConnectFailed = true;
+                       r = E_SYSTEM;
+                       break;
+               }
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to perform the handshake.", GetErrorMessage(r));
+               }
+
+               goto CATCH;
+       }
+       else
+       {
+               SysLog(NID_NET_SOCK, "SslConnect - SSL_connect is success.");
+
+               if (__isAsync == true)
+               {
+                       __isSslConnected = true;
+               }
+       }
+
+       return r;
+
+CATCH:
+       if (__isAsync == true)
+       {
+               __isSslConnected = false;
+       }
+       return r;
+}
+
+result
+_SecureSocketImpl::SslAccept(SSL* pSsl, int& sslError)
+{
+       result r = E_SUCCESS;
+
+       //char* pErrReason = null;
+       unsigned long errCode = 0;
+
+       sslError = SSL_accept(pSsl);
+
+       if (sslError < 1)
+       {
+               sslError = SSL_get_error(pSsl, sslError);
+
+               //sslv3 alert handshake failure
+               //pErrReason = (char*) ERR_reason_error_string(ERR_get_error());
+
+               errCode = ERR_GET_REASON(ERR_get_error());
+
+               switch (sslError)
+               {
+               case SSL_ERROR_SSL: // Error occurred in SSL library or protocol error.
+                       SysLog(NID_NET_SOCK, "SslAccept - SSL_ERROR_SSL");
+                       r = ConvertSslError(errCode);
+                       if (!((errCode == SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE) || (errCode == SSL_R_PEER_ERROR_NO_CERTIFICATE)
+                                       || (errCode == SSL_R_NO_CERTIFICATE_RETURNED)))
+                       {
+                               __isAcceptFailed = true;
+                               r = E_SYSTEM;
+                       }
+                       break;
+
+               case SSL_ERROR_SYSCALL:     // I/O Error Occurred.
+                       SysLog(NID_NET_SOCK, "SslAccept - SSL_ERROR_SYSCALL");
+                       __isAcceptFailed = true;
+                       r = E_SYSTEM;
+                       break;
+
+               case SSL_ERROR_ZERO_RETURN: // TLS/SSL connection has been closed.
+                       SysLog(NID_NET_SOCK, "SslAccept - SSL_ERROR_ZERO_RETURN");
+                       __isAcceptFailed = true;
+                       r = E_SYSTEM;
+                       break;
+
+               case SSL_ERROR_WANT_READ:
+               case SSL_ERROR_WANT_WRITE:
+//             SysLog(NID_NET_SOCK, "SslAccept - SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE");
+                       r = E_WOULD_BLOCK;
+                       break;
+
+               default:
+                       SysLog(NID_NET_SOCK, "SslAccept - default");
+                       __isAcceptFailed = true;
+                       r = E_SYSTEM;
+                       break;
+
+               }
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to perform the handshake.", GetErrorMessage(r));
+               }
+
+               goto CATCH;
+       }
+       else
+       {
+               SysLog(NID_NET_SOCK, "SslAccept - SSL_accept is success.");
+
+               if (__isAsync == true)
+               {
+                       __isSslAccepted = true;
+               }
+       }
+
+       return r;
+
+CATCH:
+       if (__isAsync == true)
+       {
+               __isSslAccepted = false;
+       }
+       return r;
+}
+
+result
+_SecureSocketImpl::ConvertSslError(int sslError)
+{
+       result r = E_SUCCESS;
+
+       SysLog(NID_NET_SOCK, "SSL error code (%d).", sslError);
+
+       switch (sslError)
+       {
+       case SSL_R_READ_TIMEOUT_EXPIRED:
+               r = E_TIMEOUT;
+               break;
+       case SSL_R_BAD_RESPONSE_ARGUMENT:
+               r = E_INVALID_ARG;
+               break;
+       case SSL_R_BAD_RSA_MODULUS_LENGTH:
+       case SSL_R_BAD_RSA_E_LENGTH:
+       case SSL_R_BAD_SSL_FILETYPE:
+       case SSL_R_BAD_SSL_SESSION_ID_LENGTH:
+       case SSL_R_BAD_STATE:
+       case SSL_R_BAD_MESSAGE_TYPE:
+       case SSL_R_BIO_NOT_SET:
+               r = E_INVALID_STATE;
+               break;
+       case SSL_R_UNKNOWN_CERTIFICATE_TYPE:
+       case SSL_R_UNKNOWN_CIPHER_TYPE:
+       case SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE:
+       case SSL_R_UNKNOWN_PKEY_TYPE:
+       case SSL_R_UNKNOWN_REMOTE_ERROR_TYPE:
+       case SSL_R_UNKNOWN_SSL_VERSION:
+               r = E_RESOURCE_UNAVAILABLE;
+               break;
+       case SSL_R_UNSUPPORTED_SSL_VERSION:
+       case SSL_R_NO_CIPHER_MATCH:
+       case SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY:
+       case SSL_R_TLSV1_ALERT_PROTOCOL_VERSION:
+               r = E_UNSUPPORTED_OPTION;
+               break;
+       case SSL_R_NO_SHARED_CIPHER: // Host(server) has no certificate in server side. Certificates are not loaded to ssl.
+               r = E_SYSTEM;
+               break;
+       case SSL_R_CERTIFICATE_VERIFY_FAILED: // Failed to the verification of server certificate in client side.
+               r = E_CERTIFICATE_VERIFICATION_FAILED;
+               break;
+       case SSL_R_SSLV3_ALERT_BAD_CERTIFICATE:
+       case SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE:
+       case SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED:
+       case SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED:
+       case SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN:
+       case SSL_R_TLSV1_ALERT_ACCESS_DENIED:
+       case SSL_R_TLSV1_ALERT_UNKNOWN_CA:
+               r = E_INVALID_CERTIFICATE;
+               break;
+       case SSL_R_BAD_DECOMPRESSION:
+       case SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE:
+               r = E_INVALID_DATA;
+               break;
+       case SSL_R_SSLV3_ALERT_BAD_RECORD_MAC:
+               r = E_INVALID_STATE;
+               break;
+       case SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED:
+               r = E_SYSTEM;
+               break;
+       case SSL_R_WRONG_NUMBER_OF_KEY_BITS:
+               r = E_INVALID_KEY;
+               break;
+       case SSL_R_UNKNOWN_PROTOCOL:
+       case SSL_R_SSL_HANDSHAKE_FAILURE:
+       case SSL_R_DECRYPTION_FAILED:
+       case SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC:
+       case SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG:
+       case SSL_R_DIGEST_CHECK_FAILED:
+       case SSL_R_DUPLICATE_COMPRESSION_ID:
+       case SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER:
+       case SSL_R_ENCRYPTED_LENGTH_TOO_LONG:
+       case SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST:
+       case SSL_R_EXCESSIVE_MESSAGE_SIZE:
+       case SSL_R_EXTRA_DATA_IN_MESSAGE:
+       case SSL_R_GOT_A_FIN_BEFORE_A_CCS:
+       case SSL_R_ILLEGAL_PADDING:
+       case SSL_R_INVALID_CHALLENGE_LENGTH:
+       case SSL_R_INVALID_COMMAND:
+       case SSL_R_INVALID_PURPOSE:
+       case SSL_R_INVALID_STATUS_RESPONSE:
+       case SSL_R_INVALID_TICKET_KEYS_LENGTH:
+       case SSL_R_KEY_ARG_TOO_LONG:
+       case SSL_R_READ_WRONG_PACKET_TYPE:
+       case SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE:
+       case SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER:
+       case SSL_R_TLSV1_ALERT_DECODE_ERROR:
+       case SSL_R_TLSV1_ALERT_DECRYPTION_FAILED:
+       case SSL_R_TLSV1_ALERT_DECRYPT_ERROR:
+       case SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION:
+       case SSL_R_TLSV1_ALERT_INTERNAL_ERROR:
+       case SSL_R_TLSV1_ALERT_NO_RENEGOTIATION:
+       case SSL_R_TLSV1_ALERT_RECORD_OVERFLOW:
+       case SSL_R_TLSV1_ALERT_USER_CANCELLED:
+       case SSL_R_UNEXPECTED_RECORD:
+               r = E_INVALID_STATE;
+               break;
+       case SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE:
+       case SSL_R_SSLV3_ALERT_NO_CERTIFICATE:
+               r = E_NO_CERTIFICATE;
+               break;
+       case SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE: // Response that peer doesnt have certificate.
+       case SSL_R_PEER_ERROR_NO_CERTIFICATE:
+       case SSL_R_NO_CERTIFICATE_RETURNED:
+               r = E_NO_CERTIFICATE;
+               __isPeerNoCert = true;
+               break;
+       case SSL_R_WRONG_VERSION_NUMBER:
+       case SSL_R_WRONG_SSL_VERSION:
+               r = E_UNSUPPORTED_VERSION;
+               break;
+       default:
+               break;
+
+       }
+
+       return r;
+}
+
+_GlibSecureSocketInfo::_GlibSecureSocketInfo(void)
+       : __pSocketChannel(null)
+       , __pSocketSource(null)
+       , __socketFd(INVALID_HANDLE)
+       , __pUserData(null)
+{
+}
+
+_GlibSecureSocketInfo::~_GlibSecureSocketInfo(void)
+{
+       if (__pSocketSource != null)
+       {
+               g_source_set_callback(__pSocketSource, null, null, null);
+               SysLog(NID_NET_SOCK, "### Deleted g_source_destroy(%d)", g_source_get_id(__pSocketSource));
+               g_source_destroy(__pSocketSource);
+               g_source_unref(__pSocketSource);
+               __pSocketSource = null;
+       }
+
+       if (__pSocketChannel != null)
+       {
+               g_io_channel_unref(__pSocketChannel);
+               __pSocketChannel = null;
+       }
+
+       if (__pUserData)
+       {
+               delete __pUserData;
+               __pUserData = null;
+       }
+}
+
+result
+_GlibSecureSocketInfo::SetSocketEvent(_SecureSocketImpl* pSecureSocketImpl, HSocket socketFd)
+{
+       result r = E_SUCCESS;
+
+       GIOCondition condition = (GIOCondition)0;
+
+       if (__pSocketChannel == null)
+       {
+               __pUserData = new (std::nothrow) _SecureUserData;
+               SysTryReturnResult(NID_NET_SOCK, __pUserData, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               __pSocketChannel = g_io_channel_unix_new(socketFd);
+               SysLog(NID_NET_SOCK, "Created the SocketChannel. [Fd : %d]", socketFd);
+       }
+
+       // Set masking of wanted socket Event
+       if (pSecureSocketImpl->__isWriteFired == false)
+       {
+               condition = static_cast <GIOCondition>(G_IO_IN | G_IO_OUT | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL);
+       }
+       else
+       {
+               condition = static_cast <GIOCondition>(G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL);
+       }
+
+       // G_IO_IN : There is data to read. 1
+       // G_IO_OUT : Data can be written (without blocking). 4
+       // G_IO_PRI : There is urgent data to read. 2
+       // G_IO_ERR : Error condition. 8
+       // G_IO_HUP : Hung up (the connection has been broken, usually for pipes and sockets). 16
+       // G_IO_NVAL : Invalid request. The file descriptor is not open. 32
+
+       if (__pSocketSource != null)
+       {
+               g_source_set_callback(__pSocketSource, null, null, null);
+               SysLog(NID_NET_SOCK, "### Deleted g_source_destroy. (%d)", g_source_get_id(__pSocketSource));
+               g_source_destroy(__pSocketSource);
+               g_source_unref(__pSocketSource);
+               __pSocketSource = null;
+               SysLog(NID_NET_SOCK, "Unref the SocketSource.");
+       }
+
+       __pSocketSource = g_io_create_watch(__pSocketChannel, condition);
+
+       __pUserData->pSecureSocketImpl = (_SecureSocketImpl*) pSecureSocketImpl;
+       __pUserData->pGSource = (GSource*) __pSocketSource;
+
+       g_source_set_callback(__pSocketSource, (GSourceFunc) _SecureSocketImpl::OnGioEventCallback, __pUserData, null);
+       g_source_attach(__pSocketSource, pSecureSocketImpl->__pGMainContext);
+
+       SysLog(NID_NET_SOCK, "Created the GSource Id : [%d]", g_source_get_id(__pSocketSource));
+       SysLog(NID_NET_SOCK, "Created the SocketSource for receiving the event. [%d]", condition);
+
+       return r;
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSock_SecureSocketManagedNetConnectionEventListenerImpl.cpp b/src/sockets/FNetSock_SecureSocketManagedNetConnectionEventListenerImpl.cpp
new file mode 100644 (file)
index 0000000..886a16e
--- /dev/null
@@ -0,0 +1,349 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SecureSocketManagedNetConnectionEventListenerImpl.cpp
+ * @brief              This is the implementation file for _SecureSocketManagedNetConnectionEventListener class.
+ * @version     2.1
+ *
+ * This file contains the implementation of _SecureSocketManagedNetConnectionEventListener class.
+ */
+
+#include <unistd.h>
+#include <errno.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FNetNetConnectionInfo.h>
+#include <FBase_StringConverter.h>
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNetSock_SecureSocketEventArg.h"
+#include "FNetSock_SecureSocketManagedNetConnectionEventListenerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+static const long _VERIFY_DEPTH = 9; // certificate verification depth 9
+
+_SecureSocketManagedNetConnectionEventListener::_SecureSocketManagedNetConnectionEventListener(void)
+       : __isStarted(false)
+       , __isStopped(false)
+       , __pNetConnectionInfo(null)
+       , __socketFd(INVALID_HANDLE)
+       , __backLog(-1)
+       , __flag(FLAG_NONE)
+       , __pSecureSocketEvent(null)
+       , __pThread(null)
+       , __pSecureSocketImpl(null)
+       , __pSslKey(null)
+{
+       memset(&__remoteAddr, 0, sizeof(__remoteAddr));
+       __remoteAddr.sin_family = AF_INET;
+       __remoteAddr.sin_addr.s_addr = htonl(INADDR_ANY);
+       __remoteAddr.sin_port = htons(0);
+}
+
+_SecureSocketManagedNetConnectionEventListener::~_SecureSocketManagedNetConnectionEventListener(void)
+{
+       __pSecureSocketEvent = null;
+       __flag = FLAG_NONE;
+       __backLog = -1;
+       __socketFd = INVALID_HANDLE;
+       __pNetConnectionInfo = null;
+       __pSecureSocketImpl = null;
+       __isStarted = false;
+       __isStopped = false;
+
+       if (__pThread)
+       {
+               delete __pThread;
+               __pThread = null;
+       }
+}
+
+void
+_SecureSocketManagedNetConnectionEventListener::OnManagedNetConnectionBearerChanged(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener - OnManagedNetConnectionBearerChanged - Enter");
+
+       SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener - OnManagedNetConnectionBearerChanged - End");
+}
+
+void
+_SecureSocketManagedNetConnectionEventListener::OnManagedNetConnectionStarted(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener - OnManagedNetConnectionStarted - Enter");
+
+       __isStarted = true;
+       __isStopped = false;
+
+       const _NetConnectionInfoImpl* pNCInfoImpl = null;
+       String deviceName;
+       char* pDeviceName = null;
+       int err = 0;
+
+       result r = E_SUCCESS;
+
+       __pNetConnectionInfo = managedNetConnection.GetNetConnectionInfo();
+       if (__pNetConnectionInfo == null)
+       {
+               SysLogException(NID_NET_SOCK, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] NetConnectionInfo is null. Failed to ManagedNetConnection GetNetConnectionInfo.");
+       }
+       else
+       {
+               pNCInfoImpl = _NetConnectionInfoImpl::GetInstance(*__pNetConnectionInfo);
+
+               deviceName = pNCInfoImpl->GetDeviceName();
+
+               if (deviceName.IsEmpty())
+               {
+                       SysLog(NID_NET_SOCK, "DeviceName is empty string. - Emulator Case");
+               }
+               else
+               {
+                       SysLog(NID_NET_SOCK, "DeviceName is not empty string.[Device name : %ls] - Target Case", deviceName.GetPointer());
+
+                       pDeviceName = _StringConverter::CopyToCharArrayN(deviceName);
+                       SysTryCatch(NID_NET_SOCK, pDeviceName != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       err = setsockopt(__socketFd, SOL_SOCKET, SO_BINDTODEVICE, pDeviceName, strlen(pDeviceName) + 1);
+                       delete[] pDeviceName;
+                       if (err < 0)
+                       {
+                               ConvertErrorToResult(errno);
+
+                               SysLogException(NID_NET_SOCK, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] Failed to bind device name.");
+                       }
+               }
+       }
+
+       switch (__flag)
+       {
+       case FLAG_CONSTRUCT:
+               SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener::OnManagedNetConnectionStarted - Construct");
+               break;
+
+       case FLAG_CONNECT:
+               SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener::OnManagedNetConnectionStarted - Connect");
+               err = connect(__socketFd, (struct sockaddr*) &__remoteAddr, sizeof(__remoteAddr));
+
+               if (err < 0)
+               {
+                       r = ConvertErrorToResult(errno);
+                       SysTryCatch(NID_NET_SOCK,r == E_WOULD_BLOCK, , r, "[%s] Failed to connect the socket.", GetErrorMessage(r));
+               }
+
+               r = SslConnect();
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Failed to sslconnect the socket.",GetErrorMessage(r));
+               break;
+
+       case FLAG_LISTEN:
+               SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener::OnManagedNetConnectionStarted - Listen");
+               err = listen(__socketFd, __backLog);
+               break;
+       default:
+               break;
+       }
+
+       SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener - OnManagedNetConnectionStarted - End");
+
+CATCH:
+       return;
+}
+
+void
+_SecureSocketManagedNetConnectionEventListener::OnManagedNetConnectionStopped(ManagedNetConnection& managedNetConnection, NetConnectionStoppedReason reason)
+{
+       SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener - OnManagedNetConnectionStopped - Enter");
+
+       __isStarted = false;
+       __isStopped = true;
+
+       int sockFd = -1;
+
+       _SecureSocketEventArg* pSecureSocketEventArg = null;
+
+       switch (__flag)
+       {
+       case FLAG_CONSTRUCT:
+               SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener::OnManagedNetConnectionStopped - Construct");
+               break;
+
+       case FLAG_CONNECT:
+               SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener::OnManagedNetConnectionStopped - Connect");
+               break;
+       case FLAG_LISTEN:
+               SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener::OnManagedNetConnectionStopped - Listen");
+               break;
+
+       default:
+               break;
+       }
+
+       pSecureSocketEventArg = new (std::nothrow) _SecureSocketEventArg(__pSecureSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+       pSecureSocketEventArg->SetError(E_NETWORK_UNAVAILABLE);
+       __pSecureSocketEvent->Fire(*pSecureSocketEventArg);
+
+       if (__pSecureSocketImpl->__pGlibSocketInfo != null)
+       {
+               delete __pSecureSocketImpl->__pGlibSocketInfo;
+               __pSecureSocketImpl->__pGlibSocketInfo = null;
+       }
+
+       if (__pSecureSocketImpl->__socketFd >= 0)
+       {
+               sockFd = __pSecureSocketImpl->__socketFd;
+               close(__pSecureSocketImpl->__socketFd);
+               __pSecureSocketImpl->__socketFd = INVALID_HANDLE;
+               SysLog(NID_NET_HTTP, "### SocketFd(%d) was closed..", sockFd);
+       }
+
+       SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener - OnManagedNetConnectionStopped - End");
+}
+
+void
+_SecureSocketManagedNetConnectionEventListener::OnManagedNetConnectionSuspended(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener - OnManagedNetConnectionSuspended - Enter");
+
+       SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener - OnManagedNetConnectionSuspended - End");
+}
+
+void
+_SecureSocketManagedNetConnectionEventListener::OnManagedNetConnectionResumed(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener - OnManagedNetConnectionResumed - Enter");
+
+       SysLog(NID_NET_SOCK, "_SecureSocketManagedNetConnectionEventListener - OnManagedNetConnectionResumed - End");
+}
+
+void
+_SecureSocketManagedNetConnectionEventListener::SetConstructParams(_SecureSocketEvent* pSocketEventSet, HSocket socketFdSet, _SocketMethodFlag flagSet, _SecureSocketImpl* pSecuresSocketImplSet)
+{
+       __pSecureSocketEvent = pSocketEventSet;
+       __socketFd = socketFdSet;
+       __flag = flagSet;
+       __pSecureSocketImpl = pSecuresSocketImplSet;
+}
+
+void
+_SecureSocketManagedNetConnectionEventListener::SetConnectParams(HSocket socketFdSet, sockaddr_in remoteAddrSet, _SocketMethodFlag flagSet,
+               _SecureSocketImpl* pSecureSocketImplSet)
+{
+       __socketFd = socketFdSet;
+       __remoteAddr = remoteAddrSet;
+       __flag = flagSet;
+       __pSecureSocketImpl = pSecureSocketImplSet;
+}
+
+void
+_SecureSocketManagedNetConnectionEventListener::SetListenParams(HSocket __socketFdSet, int backLogSet, _SocketMethodFlag flagSet)
+{
+       __socketFd = __socketFdSet;
+       __backLog = backLogSet;
+       __flag = flagSet;
+}
+
+void
+_SecureSocketManagedNetConnectionEventListener::SetStartedFlag(bool isStartSet)
+{
+       __isStarted = isStartSet;
+}
+
+bool
+_SecureSocketManagedNetConnectionEventListener::GetStartedFlag()
+{
+       return __isStarted;
+}
+
+result
+_SecureSocketManagedNetConnectionEventListener::SslConnect()
+{
+       result r = E_SUCCESS;
+
+       int sslError = 0;
+       int sslIndex = 0;
+
+       __pSecureSocketImpl->__pSsl = SSL_new(__pSecureSocketImpl->__pSslCtx);
+       SysTryCatch(NID_NET_SOCK, __pSecureSocketImpl->__pSsl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the SSL Object.");
+
+       SSL_set_fd(__pSecureSocketImpl->__pSsl, __socketFd);
+
+       SSL_set_options(__pSecureSocketImpl->__pSsl, SSL_OP_ALL);
+
+       if (__pSecureSocketImpl->__isNonblock == true)
+       {
+               SSL_CTX_set_client_cert_cb(__pSecureSocketImpl->__pSslCtx, (int (*)(SSL*, X509**, EVP_PKEY**)) _SecureSocketImpl::OnClientCertCallback);
+
+               SSL_set_mode(__pSecureSocketImpl->__pSsl, SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
+
+               sslIndex = SSL_get_ex_new_index(0, (char*) "_SecureSocketImpl index", null, null, null);
+
+               SSL_set_ex_data(__pSecureSocketImpl->__pSsl, sslIndex, __pSecureSocketImpl);
+
+               __pSslKey = new Integer((int) __pSecureSocketImpl->__pSsl);
+
+               pthread_mutex_lock(&_SecureSocketImpl::__mapMutex);
+               _Singleton::GetSslMap()->Add(*(__pSslKey), *(new Integer((int) sslIndex)));
+               pthread_mutex_unlock(&_SecureSocketImpl::__mapMutex);
+
+               SSL_set_verify(__pSecureSocketImpl->__pSsl, SSL_VERIFY_PEER, (int (*)(int, X509_STORE_CTX*)) _SecureSocketImpl::OnVerifyPeerCallback);
+               // verify certification depth is set to VERIFY_DEPTH.
+               // Allows level 0: peer certificates.
+               //        level 1: CA certificates.
+               //        level 2: higher level CA certificates.
+               //        and so on.
+               __pSecureSocketImpl->__sslDepth = _VERIFY_DEPTH;
+               SSL_set_verify_depth(__pSecureSocketImpl->__pSsl, __pSecureSocketImpl->__sslDepth);
+
+               // Create thread
+               __pThread = new (std::nothrow) Thread();
+               SysTryCatch(NID_NET_SOCK, __pThread != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = __pThread->Construct(*__pSecureSocketImpl);
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, GetErrorMessage(r));
+
+               // Start thread
+               r = __pThread->Start();
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, GetErrorMessage(r));
+       }
+       else
+       {
+               if (__pSecureSocketImpl->__sslVerify == SECURE_SOCKET_VERIFY_NONE)
+               {
+                       SSL_set_verify(__pSecureSocketImpl->__pSsl, SSL_VERIFY_PEER, null);
+               }
+
+               sslError = SSL_connect(__pSecureSocketImpl->__pSsl);
+               SysTryReturnResult(NID_NET_SOCK, sslError >= 1, E_SYSTEM, "Failed to perform the handshake.");
+       }
+
+       return r;
+
+CATCH:
+       if (__pThread)
+       {
+               delete __pThread;
+               __pThread = null;
+       }
+
+       return r;
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSock_SecureSocketManagedNetConnectionEventListenerImpl.h b/src/sockets/FNetSock_SecureSocketManagedNetConnectionEventListenerImpl.h
new file mode 100644 (file)
index 0000000..236d428
--- /dev/null
@@ -0,0 +1,189 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file                       FNetSock_SecureSocketManagedNetConnectionEventListenerImpl.h
+ * @brief                      This is the header file for _SocketManagedNetConnectionListener class.
+ * @version                    2.1
+ *
+ * This header file contains the declarations of _SocketManagedNetConnectionEventListener class.
+ * The _SocketManagedNetConnectionEventListener class can call listener's method. So, when an event is occurred,
+ * application can handle it appropriately.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_SECURE_SOCKET_MANAGED_NET_CONNECTION_EVENT_LISTENER_H_
+#define _FNET_SOCK_INTERNAL_SECURE_SOCKET_MANAGED_NET_CONNECTION_EVENT_LISTENER_H_
+
+
+#include <netinet/in.h>
+#include <openssl/ssl.h>
+#include <pthread.h>
+#include <FBaseRtThread.h>
+#include <FNetManagedNetConnection.h>
+#include <FNetIManagedNetConnectionEventListener.h>
+#include "FNetSock_SocketInternalHelp.h"
+#include "FNetSock_SecureSocketEvent.h"
+
+namespace Tizen { namespace Net
+{
+
+class NetConnectionInfo;
+} } // Tizen::Net
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+class _SecureSocketImpl;
+/**
+ * @class      _SecureSocketManagedNetConnectionEventListener FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.h "OspdOaf/FNet/H/FNetSock_SecureSocketCustomNetConnectionEventListenerImpl.h"
+ * @brief      This class is the listener for network connection events.
+ *
+ * @since 2.1
+ *
+ * The _SecureSocketManagedNetConnectionEventListener class specifies the methods used for notifying different kinds
+ * of network connection events. These events are only sent out when ManagedNetConnectionEventListener is added to the ManagedNetConnection instance,
+ * and this is done by invoking the SetManagedNetConnectionEventListener() method.
+ * When a network connection event is generated, a method of this interface is called.
+ * Thus, if an application does any job related to network connection events, override and use methods of this interface.
+ */
+
+class _SecureSocketManagedNetConnectionEventListener
+       : public Tizen::Net::IManagedNetConnectionEventListener
+       , virtual public Tizen::Base::Runtime::IEventListener
+{
+
+
+public:
+       _SecureSocketManagedNetConnectionEventListener(void);
+
+       virtual ~_SecureSocketManagedNetConnectionEventListener(void);
+
+
+public:
+       /**
+        * Called to notify that the bearer has been changed. @n
+        * An application can send or receive the data through the Socket or HTTP methods and can obtain the information related to the changed bearer.
+        *
+        * @since               2.0
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       void OnManagedNetConnectionBearerChanged(Tizen::Net::ManagedNetConnection& managedNetConnection);
+
+       /**
+        * Called to notify the application that the network connection has been opened and connected. @n
+        * An application can then send or receive the data.
+        *
+        * @since                       2.0
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       void OnManagedNetConnectionStarted(Tizen::Net::ManagedNetConnection& managedNetConnection);
+
+       /**
+        * Called to notify that the network connection has been closed and disconnected.
+        *
+        * @since               2.0
+        * @param[in]   managedNetConnection                                                            The network connection managed by the system
+        * @param[in]   reason                                                                                          A reason code for the error
+        * @exception   NET_CONNECTION_STOPPED_REASON_RESOURCE_RELEASED         The network connection managed by the system has stopped because network resources have been released.
+        * @exception   NET_CONNECTION_STOPPED_REASON_NETWORK_FAILED            The network has failed.
+        * @exception   NET_CONNECTION_STOPPED_REASON_DEVICE_OFFLINE            The device is in the offline mode.
+        * @exception   NET_CONNECTION_STOPPED_REASON_SERVICE_UNAVAILABLE       The device is out of the coverage area or in an emergency mode.
+        * @exception   NET_CONNECTION_STOPPED_REASON_RESOURCE_UNAVAILABLE      The network resource is unavailable.
+        * @exception   NET_CONNECTION_STOPPED_REASON_SYSTEM                            A system error has occurred.
+        *
+        */
+       void OnManagedNetConnectionStopped(Tizen::Net::ManagedNetConnection& managedNetConnection, Tizen::Net::NetConnectionStoppedReason reason);
+
+       /**
+        * Called to notify the application that the connection status has been changed or is in an unstable or suspended state. @n
+        * Thus an application may neither send nor receive data through the Socket or Http until the network connection is resumed.
+        *
+        * @since               2.0
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       void OnManagedNetConnectionSuspended(Tizen::Net::ManagedNetConnection& managedNetConnection);
+
+       /**
+        * Called to notify the application that the network has recovered from a suspended state. @n
+        * Thus an application can send or receive data through the Socket or Http from now on.
+        *
+        * @since               2.0
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       void OnManagedNetConnectionResumed(Tizen::Net::ManagedNetConnection& managedNetConnection);
+
+       // Set Params
+       void SetConstructParams(_SecureSocketEvent* pSocketEventSet, HSocket socketFdSet, _SocketMethodFlag flagSet, _SecureSocketImpl* __pSecureSocketImplSet);
+
+       void SetConnectParams(HSocket socketFdSet, sockaddr_in remoteAddrSet, _SocketMethodFlag flagSet,
+                       _SecureSocketImpl* pSecureSocketImplSet);
+
+       void SetListenParams(HSocket __socketFdSet, int backLogSet, _SocketMethodFlag flagSet);
+
+       void SetStartedFlag(bool isStartSet);
+
+       // Get Params
+       bool GetStartedFlag();
+
+       result SslConnect();
+
+private:
+       /**
+        * This is the copy constructor.
+        *
+        * @param[in]   value   An instance of _SocketManagedNetConnectionEventListener
+        * @remarks             The function is declared but not implemented.
+        */
+       _SecureSocketManagedNetConnectionEventListener(const _SecureSocketManagedNetConnectionEventListener& value);
+
+
+private:
+       /**
+        * This is the assignment operator.
+        *
+        * @param[in]   rhs             An instance of _SocketManagedNetConnectionEventListener
+        * @remarks             The function is declared but not implemented.
+        */
+       _SecureSocketManagedNetConnectionEventListener& operator =(const _SecureSocketManagedNetConnectionEventListener& rhs);
+
+private:
+       bool __isStarted;
+       bool __isStopped;
+
+       const NetConnectionInfo* __pNetConnectionInfo;
+       HSocket __socketFd;
+       sockaddr_in __remoteAddr;
+
+       int __backLog;
+       _SocketMethodFlag __flag;
+
+       _SecureSocketEvent* __pSecureSocketEvent;
+
+       Tizen::Base::Runtime::Thread* __pThread;      // Thread to process request
+
+       _SecureSocketImpl* __pSecureSocketImpl;
+
+       Tizen::Base::Integer* __pSslKey;
+
+       //Tizen::Base::Collection::HashMap* __pSslMap;
+
+       //pthread_mutex_t* __pMapMutex;
+
+};  // _SecureSocketManagedNetConnectionEventListener
+
+} } } // Tizen::Net::Sockets
+
+#endif // _FNET_SOCK_INTERNAL_SECURE_SOCKET_MANAGED_NET_CONNECTION_EVENT_LISTENER_H_
diff --git a/src/sockets/FNetSock_SocketCustomNetConnectionEventListenerImpl.cpp b/src/sockets/FNetSock_SocketCustomNetConnectionEventListenerImpl.cpp
new file mode 100644 (file)
index 0000000..0fe566f
--- /dev/null
@@ -0,0 +1,120 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketCustomNetConnectionEventListenerImpl.cpp
+ * @brief              This is the implementation file for _SocketCustomNetConnectionEventListener class.
+ * @version    2.1
+ *
+ * This file contains the implementation of _SocketCustomNetConnectionEventListener class.
+ */
+
+#include <unistd.h>
+#include <FNetNetConnectionInfo.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNetSock_SocketEventArg.h"
+#include "FNetSock_SocketCustomNetConnectionEventListenerImpl.h"
+
+using namespace Tizen::Net;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+_SocketCustomNetConnectionEventListener::_SocketCustomNetConnectionEventListener(void)
+       : __isStopped(false)
+       , __pNetConnectionInfo(null)
+       , __socketFd(INVALID_HANDLE)
+       , __pSocketImpl(null)
+       , __pSocketEvent(null)
+{
+}
+
+_SocketCustomNetConnectionEventListener::~_SocketCustomNetConnectionEventListener(void)
+{
+       __pSocketEvent = null;
+       __pSocketImpl = null;
+       __socketFd = INVALID_HANDLE;
+       __pNetConnectionInfo = null;
+       __isStopped = false;
+}
+
+void
+_SocketCustomNetConnectionEventListener::OnNetConnectionStarted(NetConnection& netConnection, result r)
+{
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionStarted - Enter");
+
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionStarted - End");
+}
+
+void
+_SocketCustomNetConnectionEventListener::OnNetConnectionStopped(NetConnection& netConnection, result r)
+{
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionStopped - Enter");
+
+       __isStopped = true;
+
+       int sockFd = INVALID_HANDLE;
+
+       _SocketEventArg* pSocketEventArg = null;
+
+       pSocketEventArg = new _SocketEventArg(__pSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+       pSocketEventArg->SetError(E_NETWORK_UNAVAILABLE);
+       __pSocketEvent->Fire(*pSocketEventArg);
+
+       if (__pSocketImpl->__pGlibSocketInfo != null)
+       {
+               delete __pSocketImpl->__pGlibSocketInfo;
+               __pSocketImpl->__pGlibSocketInfo = null;
+       }
+
+       if (__pSocketImpl->__socketFd > INVALID_HANDLE)
+       {
+               sockFd = __pSocketImpl->__socketFd;
+               close(__pSocketImpl->__socketFd);
+               __pSocketImpl->__socketFd = INVALID_HANDLE;
+               SysLog(NID_NET_SOCK, "### SocketFd(%d) was closed..", sockFd);
+       }
+
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionStopped - End");
+}
+
+void
+_SocketCustomNetConnectionEventListener::OnNetConnectionSuspended(NetConnection& netConnection)
+{
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionSuspended - Enter");
+
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionSuspended - End");
+}
+
+void
+_SocketCustomNetConnectionEventListener::OnNetConnectionResumed(NetConnection& netConnection)
+{
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionResumed - Enter");
+
+       SysLog(NID_NET_SOCK, "_SocketCustomNetConnectionEventListener - OnNetConnectionResumed - End");
+}
+
+void
+_SocketCustomNetConnectionEventListener::SetConstructParams(_SocketEvent* __pSocketEventSet, HSocket __socketFdSet, _SocketImpl* __pSocketImplSet)
+{
+       __pSocketEvent = __pSocketEventSet;
+       __socketFd = __socketFdSet;
+       __pSocketImpl = __pSocketImplSet;
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSock_SocketCustomNetConnectionEventListenerImpl.h b/src/sockets/FNetSock_SocketCustomNetConnectionEventListenerImpl.h
new file mode 100644 (file)
index 0000000..b98e2be
--- /dev/null
@@ -0,0 +1,185 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketCustomNetConnectionEventListenerImpl.h
+ * @brief              This is the header file for _SocketCustomNetConnectionListener class.
+ * @version            2.1
+ *
+ * This header file contains the declarations of _SocketCustomNetConnectionListener class.
+ * The _SocketCustomNetConnectionListener class can call listener's method. So, when an event is occurred,
+ * application can handle it appropriately.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_SOCKET_CUSTOM_NET_CONNECTION_EVENT_LISTENER_H_
+#define _FNET_SOCK_INTERNAL_SOCKET_CUSTOM_NET_CONNECTION_EVENT_LISTENER_H_
+
+
+#include <netinet/in.h>
+#include <FNetINetConnectionEventListener.h>
+#include "FNet_NetTypes.h"
+#include "FNetSock_SocketEvent.h"
+
+namespace Tizen { namespace Net
+{
+
+class NetConnection;
+class NetConnectionInfo;
+} } // Tizen::Net
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+class _SocketImpl;
+/**
+ * @class      _SocketCustomNetConnectionEventListener FNetSock_SocketCustomNetConnectionEventListener.h "OspdOaf/FNet/H/FNetSock_SocketCustomNetConnectionEventListener.h"
+ * @brief      This class is the listener for network connection events.
+ *
+ * @since   2.1
+ *
+ * The _SocketCustomNetConnectionEventListener class specifies the methods used for notifying different kinds
+ * of network connection events. These events are only sent out when NetConnectionEventListener is added to the NetConnection instance,
+ * and this is done by invoking the AddNetConnectionListener() method.
+ * When a network connection event is generated, a method of this interface is called.
+ * Thus, if an application does any job related to network connection events, override and use methods of this interface.
+ */
+
+class _SocketCustomNetConnectionEventListener
+       : public Tizen::Net::INetConnectionEventListener
+       , virtual public Tizen::Base::Runtime::IEventListener
+{
+
+
+public:
+       _SocketCustomNetConnectionEventListener(void);
+
+       virtual ~_SocketCustomNetConnectionEventListener(void);
+
+
+public:
+       /**
+        * Called to notify the application that the network connection has been opened and connected. @n
+        * An application can send or receive the data.
+        *
+        * @since               1.0
+        * @param[in]   netConnection                           The network connection
+        * @param[in]   r                                                       An error code
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_TIMEOUT                                       An attempt to connect to the server has timed out.
+        * @exception   E_DEVICE_BUSY                           The device cannot be approached because of other operations.
+        * @exception   E_DEVICE_UNAVAILABLE            The operation has failed due to a missing SIM card.
+        * @exception   E_NETWORK_UNAVAILABLE           The operation has failed because the device is in the offline mode.
+        * @exception   E_SERVICE_UNAVAILABLE           The operation has failed because the device is out of the coverage area or in an emergency mode.
+        * @exception   E_RESOURCE_UNAVAILABLE          The network resource is unavailable.
+        * @exception   E_AUTHENTICATION                        Authentication has failed.
+        * @exception   E_UNSUPPORTED_OPERATION         This operation is not supported.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @exception   E_NETWORK_FAILED                        Requested but an error is received from the network.
+        * @exception   E_INVALID_SIM_STATE                     The network has marked SIM as invalid for the CS and/or PS domain.
+        * @exception   E_FDN_MODE                                      The FDN is enabled and the number is not listed in the FDN list.
+        * @exception   E_DHCP                                          The DHCP operation has failed on WLAN.
+        * @exception   E_LINK                                          A link failure has occurred on WLAN.
+        */
+       void OnNetConnectionStarted(NetConnection& netConnection, result r);
+
+
+       /**
+        * Called to notify the application that the network connection has been closed and disconnected.
+        *
+        * @since               1.0
+        * @param[in]   netConnection                           The network connection
+        * @param[in]   r                                                       An error code
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_NETWORK_UNAVAILABLE           The operation has failed because the device is in the offline mode.
+        * @exception   E_SERVICE_UNAVAILABLE           The operation has failed because the device is out of the coverage area or in an emergency mode.
+        * @exception   E_RESOURCE_UNAVAILABLE          The network resource is unavailable.
+        * @exception   E_UNSUPPORTED_OPERATION         This operation is not supported.
+        * @exception   E_SYSTEM                                        A system error has occurred.
+        * @exception   E_NETWORK_FAILED                        Requested but an error is received from the network.
+        * @exception   E_INVALID_SIM_STATE                     The network has marked SIM as invalid for the CS and/or PS domain.
+        * @exception   E_FDN_MODE                                      The FDN is enabled and the number is not listed in the FDN list.
+        * @exception   E_DHCP                                          The DHCP operation has failed on WLAN.
+        * @exception   E_LINK                                          A link failure has occurred on WLAN.
+        * @remarks             This notification does not imply that the network is stopped permanently and cannot be used.
+        *                              The network can be restarted using NetConnection::Start().
+        *                              The NetConnection::Close() method is used to disconnect the connection
+        *              from the remote server or gateway permanently.
+        * @see                 Tizen::Net::NetConnection::Start(), Tizen::Net::NetConnection::Close()
+        *
+        */
+       void OnNetConnectionStopped(NetConnection& netConnection, result r);
+
+
+       /**
+        * Called to notify the application that the connection status has changed or is in an unstable or suspended state. @n
+        * Thus, an application may neither send nor receive data through Socket or Http until the network connection is resumed.
+        *
+        * @since               1.0
+        * @param[in]   netConnection           The network connection
+        *
+        */
+       void OnNetConnectionSuspended(NetConnection& netConnection);
+
+
+       /**
+        * Called to notify the application that the network has recovered from a suspended state. @n
+        * Thus, an application can send or receive data through Socket or Http from now on.
+        *
+        * @since               1.0
+        * @param[in]   netConnection           The network connection
+        */
+       void OnNetConnectionResumed(NetConnection& netConnection);
+
+
+       // Set Params
+       void SetConstructParams(_SocketEvent* __pSocketEventSet, HSocket __socketFdSet, _SocketImpl* __pSocketImplSet);
+
+
+private:
+       /**
+        * This is the copy constructor.
+        *
+        * @param[in]   value   An instance of _SocketCustomNetConnectionEventListener
+        * @remarks             The function is declared but not implemented.
+        */
+       _SocketCustomNetConnectionEventListener(const _SocketCustomNetConnectionEventListener& value);
+
+
+private:
+       /**
+        * This is the assignment operator.
+        *
+        * @param[in]   rhs             An instance of _SocketCustomNetConnectionEventListener
+        * @remarks             The function is declared but not implemented.
+        */
+       _SocketCustomNetConnectionEventListener& operator =(const _SocketCustomNetConnectionEventListener& rhs);
+
+
+private:
+       bool __isStopped;
+
+       const NetConnectionInfo* __pNetConnectionInfo;
+       HSocket __socketFd;
+
+       _SocketImpl* __pSocketImpl;
+
+       _SocketEvent* __pSocketEvent;
+
+}; // _SocketCustomNetConnectionEventListener
+
+} } } // Tizen::Net::Sockets
+
+#endif // _FNET_SOCK_INTERNAL_SOCKET_CUSTOM_NET_CONNECTION_EVENT_LISTENER_H_
diff --git a/src/sockets/FNetSock_SocketDeleter.h b/src/sockets/FNetSock_SocketDeleter.h
new file mode 100644 (file)
index 0000000..c5caaea
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketDeleter.h
+ * @brief              This is the header file for defining custom deleter for smart pointer.
+ *
+ * This is the header file for defining custom deleter for smart pointer.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_SOCKET_DELETER_H_
+#define _FNET_SOCK_INTERNAL_SOCKET_DELETER_H_
+
+#include <openssl/ssl.h>
+#include <FBaseSysLog.h>
+#include <FSecCert_CertService.h>
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+struct _BIoDeleter
+{
+       void operator()(BIO* pBIo)
+       {
+               BIO_free_all(pBIo);
+       }
+};
+
+struct _CertInfoDeleter
+{
+       void operator()(Tizen::Security::Cert::_CertInfo* pCertInfo)
+       {
+               free(pCertInfo);
+       }
+};
+
+} } } //Tizen::Net::Sockets
+#endif // _FNET_SOCK_INTERNAL_SOCKET_DELETER_H_
diff --git a/src/sockets/FNetSock_SocketEvent.cpp b/src/sockets/FNetSock_SocketEvent.cpp
new file mode 100644 (file)
index 0000000..90e11f4
--- /dev/null
@@ -0,0 +1,195 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketEvent.cpp
+ * @brief              This is the implementation file for _SocketEvent class.
+ * @version     2.1
+ *
+ * This file contains the implementation of _SocketEvent class.
+ */
+
+#include <FNetSockISocketEventListener.h>
+#include <FNetSockSocketTypes.h>
+#include <FBaseRtIEventArg.h>
+#include <FBaseSysLog.h>
+#include "FNetSock_SocketInternalHelp.h"
+#include "FNetSock_SocketEventArg.h"
+#include "FNetSock_SocketEvent.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+_SocketEvent::_SocketEvent(void)
+       : __pSocketImpl(null)
+{
+}
+
+_SocketEvent::~_SocketEvent(void)
+{
+       __pSocketImpl = null;
+}
+
+result
+_SocketEvent::Construct(_SocketImpl* pSocketImpl)
+{
+       result r = E_SUCCESS;
+
+       r = _Event::Initialize();
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Propagating.");
+
+       SysTryReturnResult(NID_NET_SOCK, pSocketImpl != null, E_SYSTEM, "pSocketImpl is null.");
+
+       __pSocketImpl = pSocketImpl;
+
+       SysLog(NID_NET_SOCK, "SocketEvent is Constructed");
+
+       return r;
+}
+
+_SocketImpl*
+_SocketEvent::GetSocket(void)
+{
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+
+       SysTryCatch(NID_NET_SOCK, __pSocketImpl != null, r = E_INVALID_SOCKET, E_INVALID_SOCKET, "[E_INVALID_SOCKET] SocketImpl instance is null.");
+
+       return __pSocketImpl;
+
+CATCH:
+       SetLastResult(r);
+       return null;
+}
+
+void
+_SocketEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+       result r = E_SUCCESS;
+
+       Socket* pSocket = null;
+
+       ISocketEventListener* pSocketEventListener = null;
+       IEventArg* pEventArg = null;
+       _SocketEventArg* pSocketEventArg = null;
+
+       int socketFd = INVALID_HANDLE;
+       NetSocketEventType eventType = NET_SOCKET_EVENT_NONE;
+       NetSocketClosedReason closedReason = NET_SOCKET_CLOSED_REASON_NONE;
+       result errorCode = E_SUCCESS;
+
+       pEventArg = const_cast <IEventArg*>(&arg);
+       pSocketEventListener = dynamic_cast <ISocketEventListener*>(&listener);
+       pSocketEventArg = dynamic_cast <_SocketEventArg*>(pEventArg);
+
+       SysTryReturnVoidResult(NID_NET_SOCK, pSocketEventListener != null, E_SYSTEM, "The socket event listener is null");
+       SysTryReturnVoidResult(NID_NET_SOCK, pSocketEventArg != null, E_SYSTEM, "The socket event argument is null");
+
+       socketFd = __pSocketImpl->GetSocketFd();
+       eventType = pSocketEventArg->GetEventType();
+       errorCode = pSocketEventArg->GetError();
+
+       pSocket = __pSocketImpl->GetSocket();
+
+       SysLog(NID_NET_SOCK, "SocketFd(%d), EventType(%s)", socketFd, ConvertEventTypeToString(eventType));
+
+       switch (eventType)
+       {
+       case NET_SOCKET_EVENT_NONE:
+
+               r = E_SYSTEM;
+               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] ######### NET_SOCKET_EVENT_NONE ##########");
+               break;
+
+       case NET_SOCKET_EVENT_WRITE:
+
+               SysLog(NID_NET_SOCK, "######################################################################");
+               SysLog(NID_NET_SOCK, "####### Calling callback : OnSocketReadyToSend(SocketFd: %d)", socketFd);
+               SysLog(NID_NET_SOCK, "######################################################################");
+
+               __pSocketImpl->__isWriteFired = true;
+
+               pSocketEventListener->OnSocketReadyToSend(*pSocket);
+
+               SysLog(NID_NET_SOCK, "####### Called callback : OnSocketReadyToSend");
+               break;
+
+       case NET_SOCKET_EVENT_READ:
+
+               SysLog(NID_NET_SOCK, "######################################################################");
+               SysLog(NID_NET_SOCK, "####### Calling callback : OnSocketReadyToReceive(SocketFd: %d)", socketFd);
+               SysLog(NID_NET_SOCK, "######################################################################");
+
+               __pSocketImpl->__isReadFired = true;
+
+               pSocketEventListener->OnSocketReadyToReceive(*pSocket);
+
+               SysLog(NID_NET_SOCK, "####### Called callback : OnSocketReadyToReceive");
+               break;
+
+       case NET_SOCKET_EVENT_CLOSE:
+
+               SysLog(NID_NET_SOCK, "######################################################################");
+               SysLog(NID_NET_SOCK, "####### Calling callback : OnSocketClosed(SocketFd: %d, NetSocketClosedReason: %s)", socketFd, GetErrorMessage(errorCode));
+               SysLog(NID_NET_SOCK, "######################################################################");
+
+               __pSocketImpl->__isCloseFired = true;
+
+               closedReason = ConvertClosedReason(errorCode);
+               pSocketEventListener->OnSocketClosed(*pSocket, closedReason);
+
+               SysLog(NID_NET_SOCK, "####### Called callback : OnSocketClosed");
+               break;
+
+       case NET_SOCKET_EVENT_ACCEPT:
+
+               SysLog(NID_NET_SOCK, "######################################################################");
+               SysLog(NID_NET_SOCK, "####### Calling callback : OnSocketAccept(SocketFd: %d)", socketFd);
+               SysLog(NID_NET_SOCK, "######################################################################");
+
+               __pSocketImpl->__isAcceptFired = true;
+
+               pSocketEventListener->OnSocketAccept(*pSocket);
+
+               SysLog(NID_NET_SOCK, "####### Called callback : OnSocketAccept");
+               break;
+
+       case NET_SOCKET_EVENT_CONNECT:
+
+               SysLog(NID_NET_SOCK, "######################################################################");
+               SysLog(NID_NET_SOCK, "####### Calling callback : OnSocketConnected(SocketFd: %d)", socketFd);
+               SysLog(NID_NET_SOCK, "######################################################################");
+
+               __pSocketImpl->__isConnectFired = true;
+
+               pSocketEventListener->OnSocketConnected(*pSocket);
+
+               SysLog(NID_NET_SOCK, "####### Called callback : OnSocketConnected");
+               break;
+
+       default:
+               r = E_SYSTEM;
+               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] The eventType is invalid.");
+               break;
+       }
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSock_SocketEvent.h b/src/sockets/FNetSock_SocketEvent.h
new file mode 100644 (file)
index 0000000..ad25285
--- /dev/null
@@ -0,0 +1,96 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketEvent.h
+ * @brief              This is the header file for _SocketEvent class.
+ * @version            2.1
+ *
+ * This header file contains the declarations of _SocketEvent class.
+ * The _SocketEvent class can call listener's method. So, when an event is occurred,
+ * application can handle it appropriately.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_SOCKET_EVENT_H_
+#define _FNET_SOCK_INTERNAL_SOCKET_EVENT_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FNetSockSocketTypes.h>
+#include <FBaseRt_Event.h>
+#include <FBaseRtIEventArg.h>
+#include "FNetSock_SocketImpl.h"
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+class _SocketImpl;
+
+/**
+ * @class      _SocketEvent FNetSock_SocketEvent.h "OspdOaf/FNet/H/FNetSock_SocketEvent.h"
+ * @brief      This class handles an Socket event. It is inherited from Event class.
+ *
+ * @since   2.1
+ *
+ * When an Socket event is occurred, the _SocketEvent class finds listener and calls
+ * the appropriate listener's method. @n
+ */
+
+class _SocketEvent
+       : public Tizen::Base::Runtime::_Event
+{
+
+
+public:
+       _SocketEvent(void);
+
+       virtual ~_SocketEvent(void);
+
+       result Construct(_SocketImpl* pSocketImpl);
+
+       _SocketImpl* GetSocket(void);
+
+protected:
+       virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+
+private:
+       /**
+        * This is the copy constructor.
+        *
+        * @param[in]   value   An instance of Socket
+        * @remarks             The function is declared but not implemented.
+        */
+       _SocketEvent(const _SocketEvent& value);
+
+
+private:
+       /**
+        * This is the assignment operator.
+        *
+        * @param[in]   rhs             An instance of Socket
+        * @remarks             The function is declared but not implemented.
+        */
+       _SocketEvent& operator =(const _SocketEvent& rhs);
+
+
+private:
+       _SocketImpl* __pSocketImpl;
+
+}; // _SocketEvent
+
+} } } // Tizen::Net::Sockets
+#endif // _FNET_SOCK_INTERNAL_SOCKET_EVENT_H_
diff --git a/src/sockets/FNetSock_SocketEventArg.cpp b/src/sockets/FNetSock_SocketEventArg.cpp
new file mode 100644 (file)
index 0000000..5ef485d
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketEventArg.cpp
+ * @brief              This is the implementation file for _SocketEventArg class.
+ * @version     2.1
+ *
+ * This file contains the implementation of _SocketEventArg class.
+ */
+
+#include <FNetSockSocketTypes.h>
+#include <FBaseSysLog.h>
+#include "FNetSock_SocketImpl.h"
+#include "FNetSock_SocketEventArg.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+_SocketEventArg::_SocketEventArg(int socketFd, NetSocketEventType socketEvent)
+       : __socketFd(socketFd)
+       , __socketEvent(socketEvent)
+       , __errorCode(E_SUCCESS)
+{
+}
+
+_SocketEventArg::~_SocketEventArg(void)
+{
+       __socketFd = INVALID_HANDLE;
+       __socketEvent = NET_SOCKET_EVENT_NONE;
+       __errorCode = E_SUCCESS;
+}
+
+int
+_SocketEventArg::GetSocketFd(void)
+{
+       return __socketFd;
+}
+
+NetSocketEventType
+_SocketEventArg::GetEventType(void)
+{
+       return __socketEvent;
+}
+
+void
+_SocketEventArg::SetError(result error)
+{
+       __errorCode = error;
+}
+
+result
+_SocketEventArg::GetError(void)
+{
+       return __errorCode;
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSock_SocketEventArg.h b/src/sockets/FNetSock_SocketEventArg.h
new file mode 100644 (file)
index 0000000..86d0073
--- /dev/null
@@ -0,0 +1,94 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketEventArg.h
+ * @brief              This is the header file for _SocketEventArg class.
+ * @version            2.1
+ *
+ * This header file contains the declarations of _SocketEventArg class.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_SOCKET_EVENT_ARG_H_
+#define _FNET_SOCK_INTERNAL_SOCKET_EVENT_ARG_H_
+
+
+#include <FBaseResult.h>
+#include <FNetNetTypes.h>
+#include <FNetSockSocketTypes.h>
+#include <FBaseRtIEventArg.h>
+#include "FNetSock_SocketEvent.h"
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+/**
+ * @class      _SocketEventArg FNetSock_SocketEventArg.h "OspdOaf/FNet/H/FNetSock_SocketEventArg.h"
+ * @brief      This class is used as an argument on firing a Socket Event.
+ *
+ * @since   2.1
+ *
+ * _SocketEventArg::FireImpl() receives an argument of this type, when any %Socket event is generated.
+ */
+
+class _SocketEventArg
+       : public Tizen::Base::Object
+       , public Tizen::Base::Runtime::IEventArg
+{
+
+
+public:
+       _SocketEventArg(int socketFd, NetSocketEventType socketEvent);
+
+       virtual ~_SocketEventArg(void);
+
+       int GetSocketFd(void);
+       NetSocketEventType GetEventType(void);
+
+       void SetError(result error);
+       result GetError(void);
+
+
+private:
+       /**
+        * This is the copy constructor.
+        *
+        * @param[in]   value   An instance of _SocketEventArg
+        * @remarks             The function is declared but not implemented.
+        */
+       _SocketEventArg(const _SocketEventArg& value);
+
+
+private:
+       /**
+        * This is the assignment operator.
+        *
+        * @param[in]   rhs             An instance of _SocketEventArg
+        * @remarks             The function is declared but not implemented.
+        */
+       _SocketEventArg& operator =(const _SocketEventArg& rhs);
+
+
+private:
+       int __socketFd;
+       NetSocketEventType __socketEvent;
+       result __errorCode;
+
+}; // _SocketEventArg
+
+} } } // Tizen::Net::Sockets
+#endif // _FNET_SOCK_INTERNAL_SOCKET_EVENT_ARG_H_
diff --git a/src/sockets/FNetSock_SocketImpl.cpp b/src/sockets/FNetSock_SocketImpl.cpp
new file mode 100644 (file)
index 0000000..6b18a5d
--- /dev/null
@@ -0,0 +1,3324 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketImpl.cpp
+ * @brief              This is the implementation for the _SocketImpl class.
+ */
+
+#include <unique_ptr.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <sys/select.h>
+#include <sys/time.h>
+#include <errno.h>
+#include <poll.h>
+#include <FNetNetTypes.h>
+#include <FNetSockSocket.h>
+#include <FNetNetEndPoint.h>
+#include <FNetIpAddress.h>
+#include <FNetIp4Address.h>
+#include <FNetNetConnection.h>
+#include <FNetNetConnectionManager.h>
+#include <FBaseSysLog.h>
+#include "FBase_StringConverter.h"
+#include "FBaseRt_EventDispatcher.h"
+#include "FApp_AppInfo.h"
+#include "FNet_NetEndPointImpl.h"
+#include "FNet_Ip4AddressImpl.h"
+#include "FNet_NetConnectionManagerImpl.h"
+#include "FNet_ManagedNetConnectionImpl.h"
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNet_NetConnectionImpl.h"
+#include "FNetSock_SocketInternalHelp.h"
+#include "FNetSock_SocketEventArg.h"
+#include "FNetSock_SocketInternalHelp.h"
+#include "FNetSock_LingerOptionImpl.h"
+#include "FNetSock_IpMulticastRequestOptionImpl.h"
+#include "FNetSock_SocketManagedNetConnectionEventListenerImpl.h"
+#include "FNetSock_SocketCustomNetConnectionEventListenerImpl.h"
+#include "FNetSock_SocketImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Net;
+using namespace Tizen::App;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+static const long _THREAD_SLEEP_TIMER = 2000; // 2000 milliseconds = 2 seconds (sleep time)
+static const long _MAX_COUNT_THREAD_SLEEP_TIMER = 15; // 2000 * 15 = 30000 milliseconds = 30 seconds (max sleep time)
+
+_SocketImpl::_SocketImpl(Socket* pSocket)
+       : __socketFd(INVALID_HANDLE)
+       , __isConstructed(false)
+       , __isClosed(false)
+       , __isLoopback(false)
+       , __isUdp(false)
+       , __isAsync(false)
+       , __isNonblock(false)
+       , __isServer(false)
+       , __isAcceptFired(false)
+       , __isReadFired(false)
+       , __isErrorReadFired(false)
+       , __isConnectFired(false)
+       , __isWriteFired(false)
+       , __isCloseFired(false)
+       , __socketEventType(NET_SOCKET_EVENT_NONE)
+       , __isTimeout(false)
+       , __protocolFamily(NET_SOCKET_AF_NONE)
+       , __socketType(NET_SOCKET_TYPE_NONE)
+       , __protocol(NET_SOCKET_PROTOCOL_NONE)
+       , __pNetConnectionManager(null)
+       , __pManagedNetConnection(null)
+       , __pManagedNetConnectionEventListener(null)
+       , __pCustomNetConnection(null)
+       , __pCustomNetConnectionEventListener(null)
+       , __pSocket(pSocket)
+       , __pSocketEvent(null)
+       , __pLocal(null)
+       , __pPeer(null)
+       , __pLingerOption(null)
+       , __pMulticastOption(null)
+       , __pGMainContext(null)
+       , __pGlibSocketInfo(null)
+{
+}
+
+_SocketImpl::~_SocketImpl(void)
+{
+       Dispose();
+
+       delete __pGlibSocketInfo;
+       __pGlibSocketInfo = null;
+
+       __pGMainContext = null;
+
+       delete __pMulticastOption;
+       __pMulticastOption = null;
+
+       delete __pLingerOption;
+       __pLingerOption = null;
+
+       delete __pPeer;
+       __pPeer = null;
+
+       delete __pLocal;
+       __pLocal = null;
+
+       __socketEventListenerList.RemoveAll();
+
+       delete __pSocketEvent;
+       __pSocketEvent = null;
+
+       delete __pCustomNetConnection;
+       __pCustomNetConnection = null;
+
+       delete __pCustomNetConnectionEventListener;
+       __pCustomNetConnectionEventListener = null;
+
+       delete __pManagedNetConnection;
+       __pManagedNetConnection = null;
+
+       delete __pManagedNetConnectionEventListener;
+       __pManagedNetConnectionEventListener = null;
+
+       delete __pNetConnectionManager;
+       __pNetConnectionManager = null;
+
+       __protocol = NET_SOCKET_PROTOCOL_NONE;
+       __socketType = NET_SOCKET_TYPE_NONE;
+       __protocolFamily = NET_SOCKET_AF_NONE;
+       __socketEventType = NET_SOCKET_EVENT_NONE;
+       __isTimeout = false;
+       __isCloseFired = false;
+       __isWriteFired = false;
+       __isConnectFired = false;
+       __isErrorReadFired = false;
+       __isReadFired = false;
+       __isAcceptFired = false;
+       __isServer = false;
+       __isNonblock = false;
+       __isAsync = false;
+       __isUdp = false;
+       __isLoopback = false;
+       __isClosed = false;
+       __isConstructed = false;
+       __socketFd = INVALID_HANDLE;
+}
+
+result
+_SocketImpl::Construct(const NetConnection& netConnection, NetSocketAddressFamily addressFamily, NetSocketType socketType,
+        NetSocketProtocol protocol)
+{
+       SysTryReturnResult(NID_NET_SOCK, addressFamily == NET_SOCKET_AF_IPV4, E_UNSUPPORTED_FAMILY, "The AddressFamily is unsupported.");
+       SysTryReturnResult(NID_NET_SOCK, socketType == NET_SOCKET_TYPE_STREAM || socketType == NET_SOCKET_TYPE_DATAGRAM,
+               E_UNSUPPORTED_TYPE, "The SocketType is unsupported.");
+       SysTryReturnResult(NID_NET_SOCK, protocol == NET_SOCKET_PROTOCOL_TCP || protocol == NET_SOCKET_PROTOCOL_UDP ||
+               protocol ==     NET_SOCKET_PROTOCOL_SSL, E_UNSUPPORTED_PROTOCOL, "The Protocol is unsupported.");
+
+       SysLog(NID_NET_SOCK, "Socket uses CustomNetConnection.");
+
+       // Add netConection null check validation
+       NetConnection* pNetConnection = const_cast <NetConnection*>(&netConnection);
+       SysTryReturnResult(NID_NET_SOCK, pNetConnection != null, E_INVALID_ARG, "NetConnection is invalid.");
+
+       result r = E_SUCCESS;
+       int af = 0;
+       int type = 0;
+       int sockFd = INVALID_HANDLE;
+       int err = 0;
+
+       _NetConnectionImpl* pCustomNCImpl = null;
+       NetConnectionState connState = NET_CONNECTION_STATE_NONE;
+
+       String deviceName;
+       char* pDeviceName = null;
+       const NetConnectionInfo* pNetConnectionInfo = null;
+       const _NetConnectionInfoImpl* pNCInfoImpl = null;
+
+       unique_ptr<_SocketEvent> pSocketEvent;
+       unique_ptr<_SocketCustomNetConnectionEventListener> pCustomNetConnectionEventListener;
+       unique_ptr<NetConnection> pCustomNetConnection;
+
+       // Set proper inparam
+       if (addressFamily == NET_SOCKET_AF_IPV4)
+       {
+               af = AF_INET;
+               __protocolFamily = addressFamily;
+       }
+
+       if ((socketType == NET_SOCKET_TYPE_STREAM && protocol != NET_SOCKET_PROTOCOL_TCP) ||
+               (socketType == NET_SOCKET_TYPE_DATAGRAM && protocol != NET_SOCKET_PROTOCOL_UDP))
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[%s] Type mismatch between SocketType [%d] and protocol [%d].", GetErrorMessage(r), socketType, protocol);
+               return r;
+       }
+       else if (socketType == NET_SOCKET_TYPE_STREAM)
+       {
+               type = SOCK_STREAM;
+               __socketType = socketType;
+               __protocol = NET_SOCKET_PROTOCOL_TCP;
+       }
+       else if (socketType == NET_SOCKET_TYPE_DATAGRAM)
+       {
+               type = SOCK_DGRAM;
+               __socketType = socketType;
+               __protocol = NET_SOCKET_PROTOCOL_UDP;
+               __isUdp = true;
+       }
+
+       // Custom Network Check
+       connState = pNetConnection->GetConnectionState();
+
+       if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+       {
+               SysLog(NID_NET_SOCK, "Custom Network is available.");
+       }
+       else
+       {
+               r = E_INVALID_CONNECTION;
+               SysLogException(NID_NET_SOCK, r, "[%s] Custom Network is not available.", GetErrorMessage(r));
+               return r;
+       }
+
+       __socketFd = socket(af, type, 0);
+
+       if (__socketFd < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to construct the socket.", GetErrorMessage(r));
+               goto CATCH;
+       }
+
+       if (fcntl(__socketFd, F_SETFL, O_NONBLOCK) < 0)
+       {
+               __isNonblock = false;
+               r = E_SYSTEM;
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to construct(fcntl) the socket.", GetErrorMessage(r));
+               goto CATCH;
+       }
+       else
+       {
+               __isNonblock = true;
+
+               __socketEventListenerList.Construct();
+
+               pSocketEvent.reset(new (std::nothrow) _SocketEvent());
+               SysTryCatch(NID_NET_SOCK, pSocketEvent != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = pSocketEvent->Construct(this);
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to construct the SocketEvent.", GetErrorMessage(r));
+       }
+
+       // Set the device name (setsockopt)
+       pNetConnectionInfo = pNetConnection->GetNetConnectionInfo();
+       SysTryCatch(NID_NET_SOCK, pNetConnectionInfo != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get the ConnectionInfo Object.");
+
+       pNCInfoImpl = _NetConnectionInfoImpl::GetInstance(*pNetConnectionInfo);
+       SysTryCatch(NID_NET_SOCK, pNCInfoImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get the ConnectionInfoImpl Object.");
+
+       deviceName = pNCInfoImpl->GetDeviceName();
+
+       if (deviceName.IsEmpty())
+       {
+               SysLog(NID_NET_SOCK, "Device Name is empty string. - Emulator Case");
+       }
+       else
+       {
+               SysLog(NID_NET_SOCK, "Device Name is not empty string. [Device Name : %ls] - Target Case", deviceName.GetPointer());
+
+               pDeviceName = _StringConverter::CopyToCharArrayN(deviceName);
+               SysTryCatch(NID_NET_SOCK, pDeviceName != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               err = setsockopt(__socketFd, SOL_SOCKET, SO_BINDTODEVICE, pDeviceName, strlen(pDeviceName) + 1);
+               delete[] pDeviceName;
+               if (err < 0)
+               {
+                       r = ConvertErrorToResult(errno);
+                       SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_INVALID_CONNECTION, E_INVALID_CONNECTION,
+                               "[E_INVALID_CONNECTION] Failed to bind(setsockopt) Device Name.");
+               }
+       }
+
+       // Copy New CustomNetConnection
+       pCustomNCImpl = _NetConnectionImpl::GetInstance(*pNetConnection);
+
+       pCustomNetConnection.reset(pCustomNCImpl->CopyInstanceN());
+       SysTryCatch(NID_NET_SOCK, pCustomNetConnection != null, r = E_INVALID_CONNECTION, E_INVALID_CONNECTION,
+               "[E_INVALID_CONNECTION] CustomNetConnection is null. Failed to copy the InstanceN.");
+
+       // New CustomNetConnectionEventListener
+       pCustomNetConnectionEventListener.reset(new (std::nothrow) _SocketCustomNetConnectionEventListener());
+       SysTryCatch(NID_NET_SOCK, pCustomNetConnectionEventListener != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       // AddNetConnectionListener
+       r = pCustomNetConnection->AddNetConnectionListener(*pCustomNetConnectionEventListener);
+       r = TransExceptionsExclusive(r, E_INVALID_CONNECTION, E_OUT_OF_MEMORY);
+       SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Failed to add the NetConnectionListener.", GetErrorMessage(r));
+
+       // Set the __socketFd
+       pCustomNetConnectionEventListener->SetConstructParams(pSocketEvent.get(), __socketFd, this);
+
+       __pCustomNetConnection = pCustomNetConnection.release();
+       __pCustomNetConnectionEventListener = pCustomNetConnectionEventListener.release();
+       __pSocketEvent = pSocketEvent.release();
+
+       __isConstructed = true;
+
+       SysLog(NID_NET_SOCK, "Socket is constructed by non-blocking mode.(Default) [Fd : %d]", __socketFd);
+
+       return r;
+
+CATCH:
+       if (__socketFd > INVALID_HANDLE)
+       {
+               sockFd = __socketFd;
+               close(__socketFd);
+               SysLog(NID_NET_SOCK, "### SocketFd is closed. [Fd : %d]", sockFd);
+       }
+       return r;
+}
+
+result
+_SocketImpl::Construct(NetSocketAddressFamily addressFamily, NetSocketType socketType, NetSocketProtocol protocol)
+{
+       SysTryReturnResult(NID_NET_SOCK, addressFamily == NET_SOCKET_AF_IPV4, E_UNSUPPORTED_FAMILY,     "The AddressFamily is unsupported.");
+       SysTryReturnResult(NID_NET_SOCK, socketType == NET_SOCKET_TYPE_STREAM || socketType == NET_SOCKET_TYPE_DATAGRAM,
+                               E_UNSUPPORTED_TYPE, "The SocketType is unsupported.");
+       SysTryReturnResult(NID_NET_SOCK, protocol == NET_SOCKET_PROTOCOL_TCP || protocol == NET_SOCKET_PROTOCOL_UDP || protocol ==
+                               NET_SOCKET_PROTOCOL_SSL, E_UNSUPPORTED_PROTOCOL, "The Protocol is unsupported.");
+
+       SysLog(NID_NET_SOCK, "Socket uses DefaultNetConnection.");
+
+       result r = E_SUCCESS;
+       int af = 0;
+       int type = 0;
+       int sockFd = INVALID_HANDLE;
+
+       _ManagedNetConnectionImpl* pManagedNCImpl = null;
+
+       NetConnectionState connState = NET_CONNECTION_STATE_NONE;
+       _SocketMethodFlag flag = FLAG_NONE;
+
+       unique_ptr<_SocketEvent> pSocketEvent;
+       unique_ptr<_SocketManagedNetConnectionEventListener> pManagedNetConnectionEventListener;
+       unique_ptr<ManagedNetConnection> pManagedNetConnection;
+       unique_ptr<NetConnectionManager> pNetConnectionManager;
+
+       // Set proper inparam
+       if (addressFamily == NET_SOCKET_AF_IPV4)
+       {
+               af = AF_INET;
+               __protocolFamily = addressFamily;
+       }
+
+       if ((socketType == NET_SOCKET_TYPE_STREAM && protocol != NET_SOCKET_PROTOCOL_TCP) ||
+               (socketType == NET_SOCKET_TYPE_DATAGRAM && protocol != NET_SOCKET_PROTOCOL_UDP))
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] Invalid SocketType - Mismatch.");
+               return r;
+       }
+       else if (socketType == NET_SOCKET_TYPE_STREAM)
+       {
+               type = SOCK_STREAM;
+               __socketType = socketType;
+               __protocol = NET_SOCKET_PROTOCOL_TCP;
+       }
+       else if (socketType == NET_SOCKET_TYPE_DATAGRAM)
+       {
+               type = SOCK_DGRAM;
+               __socketType = socketType;
+               __protocol = NET_SOCKET_PROTOCOL_UDP;
+               __isUdp = true;
+       }
+
+       __socketFd = socket(af, type, 0);
+
+       if (__socketFd < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to construct the socket.", GetErrorMessage(r));
+               goto CATCH;
+       }
+
+       if (fcntl(__socketFd, F_SETFL, O_NONBLOCK) < 0)
+       {
+               __isNonblock = false;
+               r = E_SYSTEM;
+               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to construct(fcntl) the socket.");
+               goto CATCH;
+       }
+       else
+       {
+               __isNonblock = true;
+
+               __socketEventListenerList.Construct();
+
+               // New SocketEvent
+               pSocketEvent.reset(new (std::nothrow) _SocketEvent());
+               SysTryCatch(NID_NET_SOCK, pSocketEvent != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = pSocketEvent->Construct(this);
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to construct the Socket Event.", GetErrorMessage(r));
+       }
+
+       if (_NetConnectionManagerImpl::IsDefaultMode() != true)
+       {
+               SysLog(NID_NET_SOCK, "Socket uses ManagedNetConnection.");
+
+               pNetConnectionManager.reset(new (std::nothrow) NetConnectionManager());
+               SysTryCatch(NID_NET_SOCK, pNetConnectionManager != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = pNetConnectionManager->Construct();
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_INVALID_CONNECTION, r, "[%s] Failed to construct the ManagedNetConnection.", GetErrorMessage(r));
+
+               pManagedNetConnection.reset(pNetConnectionManager->GetManagedNetConnectionN());
+               SysTryCatch(NID_NET_SOCK, pManagedNetConnection != null, r = E_INVALID_CONNECTION, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] ManagedNetConnection is null. Failed to the GetManagedNetConnectionN.");
+
+               pManagedNCImpl = _ManagedNetConnectionImpl::GetInstance(*pManagedNetConnection);
+
+               // New ManagedNetConnectionEventListener
+               pManagedNetConnectionEventListener.reset(new (std::nothrow) _SocketManagedNetConnectionEventListener());
+               SysTryCatch(NID_NET_SOCK, pManagedNetConnectionEventListener != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               // SetManagedNetConnectionEventListener
+               r = pManagedNetConnection->SetManagedNetConnectionEventListener(pManagedNetConnectionEventListener.get());
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_INVALID_CONNECTION, r, "[%s] Failed to the SetManagedNetConnectionEventListener.", GetErrorMessage(r));
+
+               // Set the __socketFd
+               flag = FLAG_CONSTRUCT;
+               pManagedNetConnectionEventListener->SetConstructParams(pSocketEvent.get(), __socketFd, flag, this);
+
+               // Start ManagedNetConnectionImpl
+               r = pManagedNCImpl->Start();
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_INVALID_CONNECTION, r, "[%s] Failed to start the ManagedNetConnection.", GetErrorMessage(r));
+
+               connState = pManagedNCImpl->GetConnectionState();
+               if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+               {
+                       pManagedNetConnectionEventListener->__isStarted = true;
+               }
+       }
+
+       __pNetConnectionManager = pNetConnectionManager.release();
+       __pManagedNetConnection = pManagedNetConnection.release();
+       __pManagedNetConnectionEventListener = pManagedNetConnectionEventListener.release();
+       __pSocketEvent = pSocketEvent.release();
+
+       __isConstructed = true;
+
+       SysLog(NID_NET_SOCK, "Socket is constructed by Non-blocking mode.(Default) [Fd : %d]", __socketFd);
+
+       return r;
+
+CATCH:
+       if (__socketFd > INVALID_HANDLE)
+       {
+               sockFd = __socketFd;
+               close(__socketFd);
+               SysLog(NID_NET_SOCK, "### SocketFd is closed. [Fd : %d]", sockFd);
+       }
+       return r;
+}
+
+result
+_SocketImpl::Close(void)
+{
+       SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       int sockFd = __socketFd;
+       IEnumeratorT<ISocketEventListener*>* pEnum = null;
+       ISocketEventListener* pSocketEventListener = null;
+
+       pEnum = __socketEventListenerList.GetEnumeratorN();
+
+       if (pEnum != null)
+       {
+               while (pEnum->MoveNext() == E_SUCCESS)
+               {
+                       r = pEnum->GetCurrent(pSocketEventListener);
+
+                       if (pSocketEventListener != null)
+                       {
+                               r = __pSocketEvent->RemoveListener(*pSocketEventListener);
+                               r = __socketEventListenerList.Remove(const_cast<ISocketEventListener*>(pSocketEventListener));
+                       }
+               }
+               delete pEnum;
+       }
+
+       if (__pGlibSocketInfo != null)
+       {
+               delete __pGlibSocketInfo;
+               __pGlibSocketInfo = null;
+       }
+
+       if (__socketFd > INVALID_HANDLE)
+       {
+               if (close(__socketFd) < 0)
+               {
+                       r = ConvertErrorToResult(errno);
+                       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to close the socket.");
+               }
+       }
+       
+       SysLog(NID_NET_SOCK, "Socket is closed. [Fd : %d]", sockFd);
+
+       __socketFd = INVALID_HANDLE;
+       __isClosed = true;
+
+       return r;
+}
+
+result
+_SocketImpl::Bind(const NetEndPoint& localEP)
+{
+       SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       NetAddressFamily af;
+       unsigned long ipAddr = 0;
+       unsigned short port = 0;
+
+       Ip4Address* pIp4Addr = null;
+       const _NetEndPointImpl* pLocalEPImpl = null;
+       struct sockaddr_in localAddr;
+
+       pLocalEPImpl = _NetEndPointImpl::GetInstance(localEP);
+
+       af = pLocalEPImpl->GetNetAddressFamily();
+       SysTryReturnResult(NID_NET_SOCK, af == NET_AF_IPV4, E_INVALID_ARG, "Address family is invalid.");
+
+       pIp4Addr = static_cast <Ip4Address*>(pLocalEPImpl->GetAddress());
+       r = pIp4Addr->GetAddress(ipAddr);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_INVALID_ARG, "Address is invalid.");
+
+       port = pLocalEPImpl->GetPort();
+
+       memset(&localAddr, 0, sizeof(localAddr));
+       localAddr.sin_family = AF_INET;
+       localAddr.sin_addr.s_addr = htonl(ipAddr);
+       localAddr.sin_port = htons(port);
+
+       if (bind(__socketFd, (struct sockaddr*) &localAddr, sizeof(localAddr)) < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to bind the socket.");
+       }
+
+       SysLog(NID_NET_SOCK, "Socket is binded. [Fd : %d]", __socketFd);
+
+       if (__isAsync == true && __isUdp == true)
+       {
+               __isConnectFired = true;
+               __isWriteFired = true;
+               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Memory allocation failed.");
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the SocketEvent to attach all condition except G_IO_OUT.", __socketFd);
+       }
+
+       return r;
+}
+
+result
+_SocketImpl::Connect(const NetEndPoint& remoteEP)
+{
+       SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+       int err = 0;
+
+       NetAddressFamily af;
+       unsigned long ipAddr = 0;
+       unsigned short port = 0;
+
+       Ip4Address* pIp4Addr = null;
+       const _NetEndPointImpl* pRemoteEPImpl = null;
+       struct sockaddr_in remoteAddr;
+       String remoteAddrString;
+
+       NetConnectionState connState = NET_CONNECTION_STATE_NONE;
+       _SocketMethodFlag flag = FLAG_NONE;
+
+       String deviceName;
+       char* pDeviceName = null;
+       const _ManagedNetConnectionImpl* pMNCConnImpl = null;
+       long milliseconds = _THREAD_SLEEP_TIMER;  // 2000 milliseconds (sleep time)
+//     long timeout = OSP_DEFAULT_TIMEOUT; // 30 seconds (blocking time)
+//     guint timerId = -1;
+       int tryCount = 0;
+
+       pRemoteEPImpl = _NetEndPointImpl::GetInstance(remoteEP);
+
+       if (pRemoteEPImpl->IsValid() == true)
+       {
+               pIp4Addr = static_cast <Ip4Address*>(pRemoteEPImpl->GetAddress());
+               remoteAddrString = pIp4Addr->ToString();
+       }
+       else
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] NetEndPoint is invalid.");
+               return r;
+       }
+
+       _ApiVersion apiVersion = _AppInfo::GetApiVersion();
+
+       if (apiVersion == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (__isLoopback == false)
+               {
+                       if (remoteAddrString == LOOPBACK_ADDRESS)
+                       {
+                               r = E_SYSTEM;
+                               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to assign the requested address.");
+                               return r;
+                       }
+               }
+               else
+               {
+                       if (remoteAddrString != LOOPBACK_ADDRESS)
+                       {
+                               r = E_SYSTEM;
+                               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to assign the requested address.");
+                               return r;
+                       }
+               }
+       }
+
+       af = pRemoteEPImpl->GetNetAddressFamily();
+       SysTryReturnResult(NID_NET_SOCK, af == NET_AF_IPV4, E_INVALID_ARG, "Address family is invalid.");
+
+       r = pIp4Addr->GetAddress(ipAddr);
+    SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_INVALID_ARG, "Address is invalid.");
+
+       port = pRemoteEPImpl->GetPort();
+
+       memset(&remoteAddr, 0, sizeof(remoteAddr));
+       remoteAddr.sin_family = AF_INET;
+       remoteAddr.sin_addr.s_addr = htonl(ipAddr);
+       remoteAddr.sin_port = htons(port);
+
+       if (__pManagedNetConnection != null)
+       {
+               SysLog(NID_NET_SOCK, "This socket uses ManagedNetConnection internally. [Fd : %d]", __socketFd);
+
+               if (__isNonblock == false)
+               {
+                       SysLog(NID_NET_SOCK, "This socket is blocking mode.");
+
+                       pMNCConnImpl = _ManagedNetConnectionImpl::GetInstance(*__pManagedNetConnection);
+
+//          timerId = g_timeout_add_seconds(timeout, (GSourceFunc)_SocketImpl::OnTimerCallback, this);
+
+                       // Blocking mode
+                       while (1)
+                       {
+                               connState = pMNCConnImpl->QueryConnectionState(deviceName);
+
+                               switch (connState)
+                               {
+                               case NET_CONNECTION_STATE_STARTED:
+
+                               case NET_CONNECTION_STATE_RESUMED:
+
+                               case NET_CONNECTION_STATE_SUSPENDED:
+                                       SysLog(NID_NET_SOCK, "Network is available.");
+
+                                       if (deviceName.IsEmpty())
+                                       {
+                                               SysLog(NID_NET_SOCK, "Device Name is empty string. - Emulator Case");
+                                       }
+                                       else
+                                       {
+                                               SysLog(NID_NET_SOCK, "Device Name is not empty string. [Device Name : %ls] - Target Case", deviceName.GetPointer());
+
+                                               pDeviceName = _StringConverter::CopyToCharArrayN(deviceName);
+                                               SysTryCatch(NID_NET_SOCK, pDeviceName != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                                               err = setsockopt(__socketFd, SOL_SOCKET, SO_BINDTODEVICE, pDeviceName, strlen(pDeviceName) + 1);
+                                               delete[] pDeviceName;
+                                               if (err < 0)
+                                               {
+                                                       ConvertErrorToResult(errno);
+
+                                                       SysLogException(NID_NET_SOCK, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] Failed to bind the device name.");
+                                               }
+                                       }
+
+                                       err = connect(__socketFd, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr));
+                                       break;
+
+                               case NET_CONNECTION_STATE_STARTING:
+
+                               case NET_CONNECTION_STATE_NONE:
+
+                               case NET_CONNECTION_STATE_STOPPING:
+
+                               case NET_CONNECTION_STATE_STOPPED:
+                                       SysLog(NID_NET_SOCK, "Network is not available.");
+                                       break;
+
+                               default:
+                                       SysLog(NID_NET_SOCK, "Should not come here.");
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+                               {
+//                  g_source_remove(timerId);
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STOPPED)
+                               {
+                                       r = E_INVALID_CONNECTION;
+                                       SysLogException(NID_NET_SOCK, r, "[E_INVALID_CONNECTION] Network is stopped.");
+//                  g_source_remove(timerId);
+                                       break;
+                               }
+
+//              if (__isTimeout)
+//              {
+//                  r = E_TIMEOUT;
+//                  SysLogException(NID_NET_SOCK, r, "[E_TIMEOUT] Network timeout happened. Try Again");
+//                  g_source_remove(timerId);
+//                  __isTimeout = false;
+//                  break;
+//              }
+
+                               tryCount++;
+
+                               if (tryCount > _MAX_COUNT_THREAD_SLEEP_TIMER) // 2000 milliseconds * 15 count = 30 seconds timeout
+                               {
+                                       r = E_TIMEOUT;
+                                       SysLogException(NID_NET_SOCK, r, "[E_TIMEOUT] Network is timeout.");
+                                       tryCount = 0;
+                                       break;
+                               }
+
+                               Thread::Sleep(milliseconds);
+                       }
+               }
+               else
+               {
+                       SysLog(NID_NET_SOCK, "This socket is non-blocking mode.");
+
+                       if (__pManagedNetConnectionEventListener->__isStarted)
+                       {
+                               err = connect(__socketFd, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr));
+                       }
+                       else
+                       {
+                               r = E_WOULD_BLOCK;
+                               flag = FLAG_CONNECT;
+                               __pManagedNetConnectionEventListener->SetConnectParams(__socketFd, remoteAddr, flag);
+                       }
+               }
+       }
+       else
+       {
+               err = connect(__socketFd, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr));
+       }
+
+       if (err < 0)
+       {
+               r = ConvertErrorToResult(errno);
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to connect the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isConnectFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to connect the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isConnectFired = false;
+                               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+                               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Memory allocation failed.");
+                               SysTryReturnResult(NID_NET_SOCK, r != E_SUCCESS, E_WOULD_BLOCK, "SocketFd : [%d], Set the socketEvent to attach all condition.", __socketFd);
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Connect the socket. [Fd : %d]", __socketFd);
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_SocketImpl::Send(ByteBuffer& buffer)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+    result res = E_SUCCESS;
+
+       int sentLength = 0;
+       unsigned int offset = buffer.GetPosition();
+       unsigned int length = buffer.GetRemaining();
+
+       SysTryReturnResult(NID_NET_SOCK, length > 0, E_INVALID_ARG, "Address is invalid.");
+
+       sentLength = send(__socketFd, (char*) (buffer.GetPointer() + offset), length, 0);
+
+       if (sentLength < 0)
+       {
+               r = ConvertErrorToResult(errno);
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to send the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isWriteFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to send the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isWriteFired = false;
+                               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+                               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Memory allocation failed.", GetErrorMessage(r));
+                               SysTryCatch(NID_NET_SOCK, r != E_SUCCESS, r = E_WOULD_BLOCK, E_WOULD_BLOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Actually send byte : %d byte.", sentLength);
+
+       if (__isAsync == true)
+       {
+               __isWriteFired = false;
+               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Memory allocation failed.", GetErrorMessage(r));
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+       }
+
+       r = buffer.SetPosition(offset + sentLength);
+       SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM , E_SYSTEM, "[E_SYSTEM] Failed to Set the position.");
+
+       return r;
+
+CATCH:
+       res = buffer.SetPosition(offset);
+       SysTryReturnResult(NID_NET_SOCK, res == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to Set the position.");
+
+       return r;
+}
+
+result
+_SocketImpl::Send(void* pBuffer, int length, int& sentLength)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       if (!pBuffer || length <= 0)
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] The buffer is null or the length is invalid.");
+               return r;
+       }
+
+       sentLength = send(__socketFd, static_cast <char*>(pBuffer), length, 0);
+
+       if (sentLength < 0)
+       {
+               r = ConvertErrorToResult(errno);
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to send the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isWriteFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to send the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isWriteFired = false;
+                               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+                               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Memory allocation failed.");
+                               SysTryReturnResult(NID_NET_SOCK, r != E_SUCCESS, E_WOULD_BLOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Actually send byte : %d byte.", sentLength);
+
+       if (__isAsync == true)
+       {
+               __isWriteFired = false;
+               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Memory allocation failed.");
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_SocketImpl::SendTo(ByteBuffer& buffer, const NetEndPoint& remoteEP)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+    result res = E_SUCCESS;
+
+       int sentLength = 0;
+
+       NetAddressFamily af;
+       unsigned long ipAddr = 0;
+       unsigned short port = 0;
+
+       Ip4Address* pIp4Addr = null;
+       const _NetEndPointImpl* pRemoteEPImpl = null;
+       struct sockaddr_in remoteAddr;
+       String remoteAddrString;
+
+       NetConnectionState connState = NET_CONNECTION_STATE_NONE;
+       _SocketMethodFlag flag = FLAG_NONE;
+
+       int err = 0;
+       String deviceName;
+       char* pDeviceName = null;
+       const _ManagedNetConnectionImpl* pMNCConnImpl = null;
+       long milliseconds = _THREAD_SLEEP_TIMER;  // 2000 milliseconds (sleep time)
+       int tryCount = 0;
+
+       pRemoteEPImpl = _NetEndPointImpl::GetInstance(remoteEP);
+
+       if (pRemoteEPImpl->IsValid() == true)
+       {
+               pIp4Addr = static_cast <Ip4Address*>(pRemoteEPImpl->GetAddress());
+               remoteAddrString = pIp4Addr->ToString();
+       }
+       else
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] NetEndPoint is invalid.");
+               return r;
+       }
+
+       _ApiVersion apiVersion = _AppInfo::GetApiVersion();
+
+       if (apiVersion == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (__isLoopback == false)
+               {
+                       if (remoteAddrString == LOOPBACK_ADDRESS)
+                       {
+                               r = E_SYSTEM;
+                               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to assign the requested address.");
+                               return r;
+                       }
+               }
+               else
+               {
+                       if (remoteAddrString != LOOPBACK_ADDRESS)
+                       {
+                               r = E_SYSTEM;
+                               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to assign the requested address.");
+                               return r;
+                       }
+               }
+       }
+
+       af = pRemoteEPImpl->GetNetAddressFamily();
+       SysTryReturnResult(NID_NET_SOCK, af == NET_AF_IPV4, E_INVALID_ARG, "Address family is invalid.");
+
+       r = pIp4Addr->GetAddress(ipAddr);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_INVALID_ARG, "[E_INVALID_ARG] Address is invalid.");
+
+       port = pRemoteEPImpl->GetPort();
+
+       memset(&remoteAddr, 0, sizeof(remoteAddr));
+       remoteAddr.sin_family = AF_INET;
+       remoteAddr.sin_addr.s_addr = htonl(ipAddr);
+       remoteAddr.sin_port = htons(port);
+
+       unsigned int offset = buffer.GetPosition();
+       unsigned int length = buffer.GetRemaining();
+
+       if (length <= 0)
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] Address is invalid.");
+               return r;
+       }
+
+       if (__pManagedNetConnection != null)
+       {
+               SysLog(NID_NET_SOCK, "This socket uses ManagedNetConnection internally. [Fd : %d]", __socketFd);
+
+               if (__isNonblock == false)
+               {
+                       SysLog(NID_NET_SOCK, "This socket is blocking mode.");
+
+                       pMNCConnImpl = _ManagedNetConnectionImpl::GetInstance(*__pManagedNetConnection);
+
+                       // Blocking mode
+                       while (1)
+                       {
+                               connState = pMNCConnImpl->QueryConnectionState(deviceName);
+
+                               switch (connState)
+                               {
+                               case NET_CONNECTION_STATE_STARTED:
+
+                               case NET_CONNECTION_STATE_RESUMED:
+
+                               case NET_CONNECTION_STATE_SUSPENDED:
+                                       SysLog(NID_NET_SOCK, "Network is available.");
+
+                                       if (deviceName.IsEmpty())
+                                       {
+                                               SysLog(NID_NET_SOCK, "Device Name is empty string. - Emulator Case");
+                                       }
+                                       else
+                                       {
+                                               SysLog(NID_NET_SOCK, "Device Name is not empty string. [Device Name : %ls] - Target Case", deviceName.GetPointer());
+
+                                               pDeviceName = _StringConverter::CopyToCharArrayN(deviceName);
+                                               SysTryCatch(NID_NET_SOCK, pDeviceName != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                                               err = setsockopt(__socketFd, SOL_SOCKET, SO_BINDTODEVICE, pDeviceName, strlen(pDeviceName) + 1);
+                                               delete[] pDeviceName;
+
+                                               if (err < 0)
+                                               {
+                                                       ConvertErrorToResult(errno);
+                                                       SysLogException(NID_NET_SOCK, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] Failed to bind the device name.");
+                                               }
+                                       }
+
+                                       sentLength = sendto(__socketFd, (char*) (buffer.GetPointer() + offset), length, 0, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr));
+                                       break;
+
+                               case NET_CONNECTION_STATE_STARTING:
+
+                               case NET_CONNECTION_STATE_NONE:
+
+                               case NET_CONNECTION_STATE_STOPPING:
+
+                               case NET_CONNECTION_STATE_STOPPED:
+                                       SysLog(NID_NET_SOCK, "Network is not available.");
+                                       break;
+
+                               default:
+                                       SysLog(NID_NET_SOCK, "Should not come here.");
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+                               {
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STOPPED)
+                               {
+                                       r = E_INVALID_CONNECTION;
+                                       SysLogException(NID_NET_SOCK, r, "[E_INVALID_CONNECTION] Network is stopped.");
+                                       break;
+                               }
+
+                               tryCount++;
+
+                               if (tryCount > _MAX_COUNT_THREAD_SLEEP_TIMER) // 2000 milliseconds * 15 count = 30 seconds timeout
+                               {
+                                       r = E_TIMEOUT;
+                                       SysLogException(NID_NET_SOCK, r, "[E_TIMEOUT] Network is timeout.");
+                                       tryCount = 0;
+                                       break;
+                               }
+
+                               Thread::Sleep(milliseconds);
+                       }
+               }
+               else
+               {
+                       SysLog(NID_NET_SOCK, "This socket is non-blocking mode.");
+
+                       if (__pManagedNetConnectionEventListener->__isStarted)
+                       {
+                               sentLength = sendto(__socketFd, (char*) (buffer.GetPointer() + offset), length, 0, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr));
+                       }
+                       else
+                       {
+                               r = E_WOULD_BLOCK;
+                               flag = FLAG_SENDTO;
+                               __pManagedNetConnectionEventListener->SetSendToParams(__socketFd, flag);
+                       }
+               }
+       }
+       else
+       {
+               sentLength = sendto(__socketFd, (char*) (buffer.GetPointer() + offset), length, 0, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr));
+       }
+
+       if (sentLength < 0)
+       {
+               r = ConvertErrorToResult(errno);
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to sendto() the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isConnectFired = false;
+                               __isWriteFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to sendto() the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isConnectFired = true;
+                               __isWriteFired = false;
+                               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+                               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Memory allocation failed.", GetErrorMessage(r));
+                               SysTryCatch(NID_NET_SOCK, r != E_SUCCESS, r = E_WOULD_BLOCK, E_WOULD_BLOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Actually send byte : %d byte.", sentLength);
+
+       if (__isAsync == true)
+       {
+               __isConnectFired = true;
+               __isWriteFired = false;
+               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Memory allocation failed.", GetErrorMessage(r));
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+       }
+
+       r = buffer.SetPosition(offset + sentLength);
+       SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to Set the position.");
+
+       return r;
+
+CATCH:
+       res = buffer.SetPosition(offset);
+       SysTryReturnResult(NID_NET_SOCK, res == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to Set the position.");
+
+       return r;
+}
+
+result
+_SocketImpl::SendTo(void* pBuffer, int length, const NetEndPoint& remoteEP, int& sentLength)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       NetAddressFamily af;
+       unsigned long ipAddr = 0;
+       unsigned short port = 0;
+       Ip4Address* pIp4Addr = null;
+       const _NetEndPointImpl* pRemoteEPImpl = null;
+       struct sockaddr_in remoteAddr;
+       String remoteAddrString;
+
+       NetConnectionState connState = NET_CONNECTION_STATE_NONE;
+       _SocketMethodFlag flag = FLAG_NONE;
+
+       int err = 0;
+       String deviceName;
+       char* pDeviceName = null;
+       const _ManagedNetConnectionImpl* pMNCConnImpl = null;
+       long milliseconds = _THREAD_SLEEP_TIMER; // 2000 milliseconds (sleep time)
+       int tryCount = 0;
+
+       pRemoteEPImpl = _NetEndPointImpl::GetInstance(remoteEP);
+
+       if (!pBuffer || length <= 0)
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] The buffer is null or the length is invalid.");
+               return r;
+       }
+
+       if (pRemoteEPImpl->IsValid() == true)
+       {
+               pIp4Addr = static_cast <Ip4Address*>(pRemoteEPImpl->GetAddress());
+               remoteAddrString = pIp4Addr->ToString();
+       }
+       else
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] NetEndPoint is invalid.");
+               return r;
+       }
+
+       _ApiVersion apiVersion = _AppInfo::GetApiVersion();
+
+       if (apiVersion == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (__isLoopback == false)
+               {
+                       if (remoteAddrString == LOOPBACK_ADDRESS)
+                       {
+                               r = E_SYSTEM;
+                               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to assign the requested address.");
+                               return r;
+                       }
+               }
+               else
+               {
+                       if (remoteAddrString != LOOPBACK_ADDRESS)
+                       {
+                               r = E_SYSTEM;
+                               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to assign the requested address.");
+                               return r;
+                       }
+               }
+       }
+
+       af = pRemoteEPImpl->GetNetAddressFamily();
+       SysTryReturnResult(NID_NET_SOCK, af == NET_AF_IPV4, E_INVALID_ARG, "Address family is invalid.");
+
+       r = pIp4Addr->GetAddress(ipAddr);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_INVALID_ARG, "[E_INVALID_ARG] Address is invalid.");
+
+       port = pRemoteEPImpl->GetPort();
+
+       memset(&remoteAddr, 0, sizeof(remoteAddr));
+       remoteAddr.sin_family = AF_INET;
+       remoteAddr.sin_addr.s_addr = htonl(ipAddr);
+       remoteAddr.sin_port = htons(port);
+
+       if (__pManagedNetConnection != null)
+       {
+               SysLog(NID_NET_SOCK, "This socket uses ManagedNetConnection internally. [Fd : %d]", __socketFd);
+
+               if (__isNonblock == false)
+               {
+                       SysLog(NID_NET_SOCK, "This socket is blocking mode.");
+
+                       pMNCConnImpl = _ManagedNetConnectionImpl::GetInstance(*__pManagedNetConnection);
+
+                       // Blocking mode
+                       while (1)
+                       {
+                               connState = pMNCConnImpl->QueryConnectionState(deviceName);
+
+                               switch (connState)
+                               {
+                               case NET_CONNECTION_STATE_STARTED:
+
+                               case NET_CONNECTION_STATE_RESUMED:
+
+                               case NET_CONNECTION_STATE_SUSPENDED:
+                                       SysLog(NID_NET_SOCK, "Network is available.");
+
+                                       if (deviceName.IsEmpty())
+                                       {
+                                               SysLog(NID_NET_SOCK, "Device Name is empty string. - Emulator Case");
+                                       }
+                                       else
+                                       {
+                                               SysLog(NID_NET_SOCK, "Device Name is not empty string. [Device Name : %ls] - Target Case", deviceName.GetPointer());
+
+                                               pDeviceName = _StringConverter::CopyToCharArrayN(deviceName);
+                                               SysTryCatch(NID_NET_SOCK, pDeviceName != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                                               err = setsockopt(__socketFd, SOL_SOCKET, SO_BINDTODEVICE, pDeviceName, strlen(pDeviceName) + 1);
+                                               delete[] pDeviceName;
+
+                                               if (err < 0)
+                                               {
+                                                       ConvertErrorToResult(errno);
+                                                       SysLogException(NID_NET_SOCK, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] Failed to bind the device name.");
+                                               }
+                                       }
+
+                                       sentLength = sendto(__socketFd, static_cast <char*>(pBuffer), length, 0, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr));
+                                       break;
+
+                               case NET_CONNECTION_STATE_STARTING:
+
+                               case NET_CONNECTION_STATE_NONE:
+
+                               case NET_CONNECTION_STATE_STOPPING:
+
+                               case NET_CONNECTION_STATE_STOPPED:
+                                       SysLog(NID_NET_SOCK, "Network is not available.");
+                                       break;
+
+                               default:
+                                       SysLog(NID_NET_SOCK, "Should not come here.");
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+                               {
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STOPPED)
+                               {
+                                       r = E_INVALID_CONNECTION;
+                                       SysLogException(NID_NET_SOCK, r, "[E_INVALID_CONNECTION] Network is stopped.");
+                                       break;
+                               }
+
+                               tryCount++;
+
+                               if (tryCount > _MAX_COUNT_THREAD_SLEEP_TIMER) // 2000 milliseconds * 15 count = 30 seconds timeout
+                               {
+                                       r = E_TIMEOUT;
+                                       SysLogException(NID_NET_SOCK, r, "[E_TIMEOUT] Network is timeout.");
+                                       tryCount = 0;
+                                       break;
+                               }
+
+                               Thread::Sleep(milliseconds);
+                       }
+               }
+               else
+               {
+                       SysLog(NID_NET_SOCK, "This socket is non-blocking mode.");
+
+                       if (__pManagedNetConnectionEventListener->__isStarted)
+                       {
+                               sentLength = sendto(__socketFd, static_cast <char*>(pBuffer), length, 0, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr));
+                       }
+                       else
+                       {
+                               r = E_WOULD_BLOCK;
+                               flag = FLAG_SENDTO;
+                               __pManagedNetConnectionEventListener->SetSendToParams(__socketFd, flag);
+                       }
+               }
+       }
+       else
+       {
+               sentLength = sendto(__socketFd, static_cast <char*>(pBuffer), length, 0, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr));
+       }
+
+       if (sentLength < 0)
+       {
+               r = ConvertErrorToResult(errno);
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to sendto() the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isConnectFired = false;
+                               __isWriteFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to sendto() the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isConnectFired = true;
+                               __isWriteFired = false;
+                               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+                               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Memory allocation failed.");
+                               SysTryReturnResult(NID_NET_SOCK, r != E_SUCCESS, E_WOULD_BLOCK, "SocketFd : [%d], Set the socketEvent to attach all condition.", __socketFd);
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Actually sendto() byte : %d byte.", sentLength);
+
+       if (__isAsync == true)
+       {
+               __isConnectFired = true;
+               __isWriteFired = false;
+               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Memory allocation failed.");
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_SocketImpl::Receive(ByteBuffer& buffer)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+       result res = E_SUCCESS;
+
+       int rcvdLength = 0;
+       unsigned int offset = buffer.GetPosition();
+       unsigned int length = buffer.GetRemaining();
+
+       SysTryReturnResult(NID_NET_SOCK, length > 0, E_INVALID_ARG, "Address is invalid.");
+
+       rcvdLength = recv(__socketFd, (char*) (buffer.GetPointer() + offset), length, 0);
+
+       if (rcvdLength < 0)
+       {
+               r = ConvertErrorToResult(errno);
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to receive the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isReadFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to receive the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isReadFired = false;
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Actually receive byte : %d byte", rcvdLength);
+
+       if (__isAsync == true)
+       {
+               __isReadFired = false;
+       }
+
+       r = buffer.SetPosition(offset + rcvdLength);
+       SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to Set the position.");
+
+       return r;
+
+CATCH:
+    res = buffer.SetPosition(offset);
+    SysTryReturnResult(NID_NET_SOCK, res == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to Set the position.");
+
+    return r;
+}
+
+result
+_SocketImpl::Receive(void* pBuffer, int length, int& rcvdLength)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       if (!pBuffer || length <= 0)
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] The buffer is null or the length is invalid.");
+               return r;
+       }
+
+       rcvdLength = recv(__socketFd, static_cast <char*>(pBuffer), length, 0);
+
+       if (rcvdLength < 0)
+       {
+               r = ConvertErrorToResult(errno);
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to receive the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isReadFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to receive the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isReadFired = false;
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Actually receive byte : %d byte.", rcvdLength);
+
+       if (__isAsync == true)
+       {
+               __isReadFired = false;
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_SocketImpl::ReceiveFrom(ByteBuffer& buffer, NetEndPoint& remoteEP)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+       result res = E_SUCCESS;
+
+       int rcvdLength = 0;
+       unsigned int fromSize = 0;
+       unsigned long ipAddr = 0;
+       unsigned short port = 0;
+       Ip4Address* pIp4Addr = null;
+       _NetEndPointImpl* pRemoteEPImpl = null;
+       struct sockaddr_in remoteAddr;
+       String remoteAddrString;
+
+       NetConnectionState connState = NET_CONNECTION_STATE_NONE;
+       _SocketMethodFlag flag = FLAG_NONE;
+
+       int err = 0;
+       String deviceName;
+       char* pDeviceName = null;
+       const _ManagedNetConnectionImpl* pMNCConnImpl = null;
+       long milliseconds = _THREAD_SLEEP_TIMER; // 2000 milliseconds (sleep time)
+       int tryCount = 0;
+
+       pRemoteEPImpl = _NetEndPointImpl::GetInstance(remoteEP);
+
+       memset(&remoteAddr, 0, sizeof(remoteAddr));
+       remoteAddr.sin_family = AF_INET;
+       remoteAddr.sin_addr.s_addr = htonl(ipAddr);
+       remoteAddr.sin_port = htons(port);
+
+       if (pRemoteEPImpl->IsValid() == true)
+       {
+               pIp4Addr = static_cast <Ip4Address*>(pRemoteEPImpl->GetAddress());
+               remoteAddrString = pIp4Addr->ToString();
+       }
+       else
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] NetEndPoint is invalid.");
+               return r;
+       }
+
+       _ApiVersion apiVersion = _AppInfo::GetApiVersion();
+
+       if (apiVersion == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (__isLoopback == false)
+               {
+                       if (remoteAddrString == LOOPBACK_ADDRESS)
+                       {
+                               r = E_SYSTEM;
+                               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to assign the requested address.");
+                               return r;
+                       }
+               }
+               else
+               {
+                       if (remoteAddrString != LOOPBACK_ADDRESS)
+                       {
+                               r = E_SYSTEM;
+                               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to assign the requested address.");
+                               return r;
+                       }
+               }
+       }
+
+       fromSize = sizeof(remoteAddr);
+
+       unsigned int offset = buffer.GetPosition();
+       unsigned int length = buffer.GetRemaining();
+
+       if (length <= 0)
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] Address is invalid.");
+               return r;
+       }
+
+       if (__pManagedNetConnection != null)
+       {
+               SysLog(NID_NET_SOCK, "This socket uses ManagedNetConnection internally. [Fd : %d]", __socketFd);
+
+               if (__isNonblock == false)
+               {
+                       SysLog(NID_NET_SOCK, "This socket is blocking mode.");
+
+                       pMNCConnImpl = _ManagedNetConnectionImpl::GetInstance(*__pManagedNetConnection);
+
+                       // Blocking mode
+                       while (1)
+                       {
+                               connState = pMNCConnImpl->QueryConnectionState(deviceName);
+
+                               switch (connState)
+                               {
+                               case NET_CONNECTION_STATE_STARTED:
+
+                               case NET_CONNECTION_STATE_RESUMED:
+
+                               case NET_CONNECTION_STATE_SUSPENDED:
+                                       SysLog(NID_NET_SOCK, "Network is available.");
+
+                                       if (deviceName.IsEmpty())
+                                       {
+                                               SysLog(NID_NET_SOCK, "Device Name is empty string. - Emulator Case");
+                                       }
+                                       else
+                                       {
+                                               SysLog(NID_NET_SOCK, "Device Name is not empty string. [Device Name : %ls] - Target Case", deviceName.GetPointer());
+
+                                               pDeviceName = _StringConverter::CopyToCharArrayN(deviceName);
+                                               SysTryCatch(NID_NET_SOCK, pDeviceName != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                                               err = setsockopt(__socketFd, SOL_SOCKET, SO_BINDTODEVICE, pDeviceName, strlen(pDeviceName) + 1);
+                                               delete[] pDeviceName;
+
+                                               if (err < 0)
+                                               {
+                                                       ConvertErrorToResult(errno);
+                                                       SysLogException(NID_NET_SOCK, E_INVALID_CONNECTION, "[%s] Failed to bind the device name.", GetErrorMessage(E_INVALID_CONNECTION));
+                                               }
+                                       }
+
+                                       rcvdLength = recvfrom(__socketFd, (char*) (buffer.GetPointer() + offset), length, 0, (struct sockaddr*) &remoteAddr, &fromSize);
+                                       break;
+
+                               case NET_CONNECTION_STATE_STARTING:
+
+                               case NET_CONNECTION_STATE_NONE:
+
+                               case NET_CONNECTION_STATE_STOPPING:
+
+                               case NET_CONNECTION_STATE_STOPPED:
+                                       SysLog(NID_NET_SOCK, "Network is not available.");
+                                       break;
+
+                               default:
+                                       SysLog(NID_NET_SOCK, "Should not come here.");
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+                               {
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STOPPED)
+                               {
+                                       r = E_INVALID_CONNECTION;
+                                       SysLogException(NID_NET_SOCK, r, "[E_INVALID_CONNECTION] Network is stopped.");
+                                       break;
+                               }
+
+                               tryCount++;
+
+                               if (tryCount > _MAX_COUNT_THREAD_SLEEP_TIMER) // 2000 milliseconds * 15 count = 30 seconds timeout
+                               {
+                                       r = E_TIMEOUT;
+                                       SysLogException(NID_NET_SOCK, r, "[E_TIMEOUT] Network is timeout.");
+                                       tryCount = 0;
+                                       break;
+                               }
+
+                               Thread::Sleep(milliseconds);
+                       }
+               }
+               else
+               {
+                       SysLog(NID_NET_SOCK, "This socket is non-blocking mode.");
+
+                       if (__pManagedNetConnectionEventListener->__isStarted)
+                       {
+                               rcvdLength = recvfrom(__socketFd, (char*) (buffer.GetPointer() + offset), length, 0, (struct sockaddr*) &remoteAddr, &fromSize);
+                       }
+                       else
+                       {
+                               r = E_WOULD_BLOCK;
+                               flag = FLAG_RECEIVEFROM;
+                               __pManagedNetConnectionEventListener->SetReceiveFromParams(__socketFd, flag);
+                       }
+               }
+       }
+       else
+       {
+               rcvdLength = recvfrom(__socketFd, (char*) (buffer.GetPointer() + offset), length, 0, (struct sockaddr*) &remoteAddr, &fromSize);
+       }
+
+       if (rcvdLength < 0)
+       {
+               r = ConvertErrorToResult(errno);
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to recvfrom() the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isConnectFired = false;
+                               __isReadFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to recvfrom() the socket.", GetErrorMessage(r));
+
+                       if (__isAsync == true)
+                       {
+                               __isConnectFired = true;
+                               __isReadFired = false;
+                               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+                               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Memory allocation failed.", GetErrorMessage(r));
+                               SysTryCatch(NID_NET_SOCK, r != E_SUCCESS, r = E_WOULD_BLOCK, E_WOULD_BLOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Actually recvfrom() byte : %d byte", rcvdLength);
+
+       if (__isAsync == true)
+       {
+               __isConnectFired = true;
+               __isReadFired = false;
+               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Memory allocation failed.", GetErrorMessage(r));
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+       }
+
+       r = buffer.SetPosition(offset + rcvdLength);
+       SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to Set the position.");
+
+       // Implementation : change from remoteAddr to NetEndPoint
+       ipAddr = ntohl(remoteAddr.sin_addr.s_addr);
+       port = ntohs(remoteAddr.sin_port);
+
+       pIp4Addr = new (std::nothrow) Ip4Address(ipAddr);
+       SysTryReturnResult(NID_NET_SOCK, pIp4Addr, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       r = pRemoteEPImpl->Update(*pIp4Addr, port);
+       delete pIp4Addr;
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryCatch(NID_NET_SOCK, r == E_SUCCESS || r == E_SYSTEM, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to Set the NetEndPoint.");
+
+       return r;
+
+CATCH:
+       res = buffer.SetPosition(offset);
+       SysTryReturnResult(NID_NET_SOCK, res == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to Set the position.");
+
+       return r;
+}
+
+result
+_SocketImpl::ReceiveFrom(void* pBuffer, int length, NetEndPoint& remoteEP, int& rcvdLength)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+       unsigned int fromSize = 0;
+       unsigned long ipAddr = 0;
+       unsigned short port = 0;
+       Ip4Address* pIp4Addr = null;
+       _NetEndPointImpl* pRemoteEPImpl = null;
+       struct sockaddr_in remoteAddr;
+       String remoteAddrString;
+
+       NetConnectionState connState = NET_CONNECTION_STATE_NONE;
+       _SocketMethodFlag flag = FLAG_NONE;
+
+       int err = 0;
+       String deviceName;
+       char* pDeviceName = null;
+       const _ManagedNetConnectionImpl* pMNCConnImpl = null;
+       long milliseconds = _THREAD_SLEEP_TIMER; // 2000 milliseconds (sleep time)
+       int tryCount = 0;
+
+       pRemoteEPImpl = _NetEndPointImpl::GetInstance(remoteEP);
+
+       memset(&remoteAddr, 0, sizeof(remoteAddr));
+       remoteAddr.sin_family = AF_INET;
+       remoteAddr.sin_addr.s_addr = htonl(ipAddr);
+       remoteAddr.sin_port = htons(port);
+
+       if (!pBuffer || length <= 0)
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] The buffer is null or the length is invalid.");
+               return r;
+       }
+
+       if (pRemoteEPImpl->IsValid() == true)
+       {
+               pIp4Addr = static_cast <Ip4Address*>(pRemoteEPImpl->GetAddress());
+               remoteAddrString = pIp4Addr->ToString();
+       }
+       else
+       {
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] NetEndPoint is invalid.");
+               return r;
+       }
+
+       _ApiVersion apiVersion = _AppInfo::GetApiVersion();
+
+       if (apiVersion == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+       {
+               if (__isLoopback == false)
+               {
+                       if (remoteAddrString == LOOPBACK_ADDRESS)
+                       {
+                               r = E_SYSTEM;
+                               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to assign the requested address.");
+                               return r;
+                       }
+               }
+               else
+               {
+                       if (remoteAddrString != LOOPBACK_ADDRESS)
+                       {
+                               r = E_SYSTEM;
+                               SysLogException(NID_NET_SOCK, r, "[E_SYSTEM] Failed to assign the requested address.");
+                               return r;
+                       }
+               }
+       }
+
+       fromSize = sizeof(remoteAddr);
+
+       if (__pManagedNetConnection != null)
+       {
+               SysLog(NID_NET_SOCK, "This socket uses ManagedNetConnection internally. [Fd : %d]", __socketFd);
+
+               if (__isNonblock == false)
+               {
+                       SysLog(NID_NET_SOCK, "This socket is blocking mode.");
+
+                       pMNCConnImpl = _ManagedNetConnectionImpl::GetInstance(*__pManagedNetConnection);
+
+                       // Blocking mode
+                       while (1)
+                       {
+                               connState = pMNCConnImpl->QueryConnectionState(deviceName);
+
+                               switch (connState)
+                               {
+                               case NET_CONNECTION_STATE_STARTED:
+
+                               case NET_CONNECTION_STATE_RESUMED:
+
+                               case NET_CONNECTION_STATE_SUSPENDED:
+                                       SysLog(NID_NET_SOCK, "Network is available.");
+
+                                       if (deviceName.IsEmpty())
+                                       {
+                                               SysLog(NID_NET_SOCK, "Device Name is empty string. - Emulator Case");
+                                       }
+                                       else
+                                       {
+                                               SysLog(NID_NET_SOCK, "Device Name is not empty string. [Device Name : %ls] - Target Case", deviceName.GetPointer());
+
+                                               pDeviceName = _StringConverter::CopyToCharArrayN(deviceName);
+                                               SysTryCatch(NID_NET_SOCK, pDeviceName != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                                               err = setsockopt(__socketFd, SOL_SOCKET, SO_BINDTODEVICE, pDeviceName, strlen(pDeviceName) + 1);
+                                               delete[] pDeviceName;
+
+                                               if (err < 0)
+                                               {
+                                                       ConvertErrorToResult(errno);
+                                                       SysLogException(NID_NET_SOCK, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] Failed to bind the device name.");
+                                               }
+                                       }
+
+                                       rcvdLength = recvfrom(__socketFd, static_cast <char*>(pBuffer), length, 0, (struct sockaddr*) &remoteAddr, &fromSize);
+                                       break;
+
+                               case NET_CONNECTION_STATE_STARTING:
+
+                               case NET_CONNECTION_STATE_NONE:
+
+                               case NET_CONNECTION_STATE_STOPPING:
+
+                               case NET_CONNECTION_STATE_STOPPED:
+                                       SysLog(NID_NET_SOCK, "Network is not available.");
+                                       break;
+
+                               default:
+                                       SysLog(NID_NET_SOCK, "Should not come here.");
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+                               {
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STOPPED)
+                               {
+                                       r = E_INVALID_CONNECTION;
+                                       SysLogException(NID_NET_SOCK, r, "[E_INVALID_CONNECTION] Network is stopped.");
+                                       break;
+                               }
+
+                               tryCount++;
+
+                               if (tryCount > _MAX_COUNT_THREAD_SLEEP_TIMER) // 2000 milliseconds * 15 count = 30 seconds timeout
+                               {
+                                       r = E_TIMEOUT;
+                                       SysLogException(NID_NET_SOCK, r, "[E_TIMEOUT] Network is timeout.");
+                                       tryCount = 0;
+                                       break;
+                               }
+
+                               Thread::Sleep(milliseconds);
+                       }
+               }
+               else
+               {
+                       SysLog(NID_NET_SOCK, "This socket is non-blocking mode.");
+
+                       if (__pManagedNetConnectionEventListener->__isStarted)
+                       {
+                               rcvdLength = recvfrom(__socketFd, static_cast <char*>(pBuffer), length, 0, (struct sockaddr*) &remoteAddr, &fromSize);
+                       }
+                       else
+                       {
+                               r = E_WOULD_BLOCK;
+                               flag = FLAG_RECEIVEFROM;
+                               __pManagedNetConnectionEventListener->SetReceiveFromParams(__socketFd, flag);
+                       }
+               }
+       }
+       else
+       {
+               rcvdLength = recvfrom(__socketFd, static_cast <char*>(pBuffer), length, 0, (struct sockaddr*) &remoteAddr, &fromSize);
+       }
+
+       if (rcvdLength < 0)
+       {
+               r = ConvertErrorToResult(errno);
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to recvfrom() the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isConnectFired = false;
+                               __isReadFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to recvfrom() the socket.", GetErrorMessage(r));
+
+                       if (__isAsync == true)
+                       {
+                               __isConnectFired = true;
+                               __isReadFired = false;
+                               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+                               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Memory allocation failed.");
+                               SysTryReturnResult(NID_NET_SOCK, r != E_SUCCESS, E_WOULD_BLOCK, "SocketFd : [%d], Set the socketEvent to attach all condition.", __socketFd);
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Actually recvfrom() byte : %d byte", rcvdLength);
+
+       if (__isAsync == true)
+       {
+               __isConnectFired = true;
+               __isReadFired = false;
+               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Memory allocation failed.");
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+       }
+
+       // Implementation : change from remoteAddr to NetEndPoint.
+       ipAddr = ntohl(remoteAddr.sin_addr.s_addr);
+       port = ntohs(remoteAddr.sin_port);
+
+       pIp4Addr = new (std::nothrow) Ip4Address(ipAddr);
+       SysTryReturnResult(NID_NET_SOCK, pIp4Addr, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       r = pRemoteEPImpl->Update(*pIp4Addr, port);
+       delete pIp4Addr;
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS || r == E_SYSTEM, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+    SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to Set the NetEndPoint.");
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+result
+_SocketImpl::Listen(int backLog)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+       int err = 0;
+
+       _SocketMethodFlag flag = FLAG_NONE;
+       NetConnectionState connState = NET_CONNECTION_STATE_NONE;
+
+       String deviceName;
+       char* pDeviceName = null;
+       const _ManagedNetConnectionImpl* pMNCConnImpl = null;
+       long milliseconds = _THREAD_SLEEP_TIMER; // 2000 milliseconds (sleep time)
+       int tryCount = 0;
+
+       if (__pManagedNetConnection != null)
+       {
+               SysLog(NID_NET_SOCK, "This socket uses ManagedNetConnection internally. [Fd : %d]", __socketFd);
+
+               if (__isNonblock == false)
+               {
+                       SysLog(NID_NET_SOCK, "This socket is blocking mode.");
+
+                       pMNCConnImpl = _ManagedNetConnectionImpl::GetInstance(*__pManagedNetConnection);
+
+                       // Blocking mode
+                       while (1)
+                       {
+                               connState = pMNCConnImpl->QueryConnectionState(deviceName);
+
+                               switch (connState)
+                               {
+                               case NET_CONNECTION_STATE_STARTED:
+
+                               case NET_CONNECTION_STATE_RESUMED:
+
+                               case NET_CONNECTION_STATE_SUSPENDED:
+                                       SysLog(NID_NET_SOCK, "Network is available.");
+
+                                       if (deviceName.IsEmpty())
+                                       {
+                                               SysLog(NID_NET_SOCK, "Device Name is empty string. - Emulator Case");
+                                       }
+                                       else
+                                       {
+                                               SysLog(NID_NET_SOCK, "Device Name is not empty string. [Device Name : %ls] - Target Case", deviceName.GetPointer());
+
+                                               pDeviceName = _StringConverter::CopyToCharArrayN(deviceName);
+                                               SysTryCatch(NID_NET_SOCK, pDeviceName != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                                               err = setsockopt(__socketFd, SOL_SOCKET, SO_BINDTODEVICE, pDeviceName, strlen(pDeviceName) + 1);
+                                               delete[] pDeviceName;
+                                               if (err < 0)
+                                               {
+                                                       ConvertErrorToResult(errno);
+                                                       SysLogException(NID_NET_SOCK, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] Failed to bind the device name.");
+                                               }
+                                       }
+
+                                       err = listen(__socketFd, backLog);
+                                       break;
+
+                               case NET_CONNECTION_STATE_STARTING:
+
+                               case NET_CONNECTION_STATE_NONE:
+
+                               case NET_CONNECTION_STATE_STOPPING:
+
+                               case NET_CONNECTION_STATE_STOPPED:
+                                       SysLog(NID_NET_SOCK, "Network is not available.");
+                                       break;
+
+                               default:
+                                       SysLog(NID_NET_SOCK, "Should not come here.");
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STARTED || connState == NET_CONNECTION_STATE_RESUMED || connState == NET_CONNECTION_STATE_SUSPENDED)
+                               {
+                                       break;
+                               }
+
+                               if (connState == NET_CONNECTION_STATE_STOPPED)
+                               {
+                                       r = E_INVALID_CONNECTION;
+                                       SysLogException(NID_NET_SOCK, r, "[E_INVALID_CONNECTION] Network is stopped.");
+                                       break;
+                               }
+
+                               tryCount++;
+
+                               if (tryCount > _MAX_COUNT_THREAD_SLEEP_TIMER) // 2000 milliseconds * 15 count = 30 seconds timeout
+                               {
+                                       r = E_TIMEOUT;
+                                       SysLogException(NID_NET_SOCK, r, "[E_TIMEOUT] Network is timeout. Try Again.");
+                                       tryCount = 0;
+                                       break;
+                               }
+
+                               Thread::Sleep(milliseconds);
+                       }
+               }
+               else
+               {
+                       SysLog(NID_NET_SOCK, "This socket is non-blocking mode.");
+
+                       if (__pManagedNetConnectionEventListener->__isStarted)
+                       {
+                               err = listen(__socketFd, backLog);
+                       }
+                       else
+                       {
+                               r = E_WOULD_BLOCK;
+                               flag = FLAG_LISTEN;
+                               __pManagedNetConnectionEventListener->SetListenParams(__socketFd, backLog, flag);
+                       }
+               }
+       }
+       else
+       {
+               err = listen(__socketFd, backLog);
+       }
+
+       if (err < 0)
+       {
+               r = ConvertErrorToResult(errno);
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to listen the socket.", GetErrorMessage(r));
+                       if (__isAsync == true)
+                       {
+                               __isAcceptFired = true;
+                       }
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to listen the socket.", GetErrorMessage(r));
+                       __isServer = true;
+                       if (__isAsync == true)
+                       {
+                               __isAcceptFired = false;
+                               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+                               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Memory allocation failed.");
+                               SysTryReturnResult(NID_NET_SOCK, r != E_SUCCESS, E_WOULD_BLOCK, "SocketFd : [%d], Set the socketEvent to attach all condition.", __socketFd);
+                       }
+                       goto CATCH;
+               }
+       }
+
+       SysLog(NID_NET_SOCK, "Socket is listening. [Fd : %d, backLog : %d]", __socketFd, backLog);
+
+       __isServer = true;
+
+       if (__isAsync == true)
+       {
+               __isAcceptFired = false;
+               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Memory allocation failed.");
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach G_IO_OUT condition.", __socketFd);
+       }
+
+       return r;
+
+CATCH:
+       return r;
+}
+
+Socket*
+_SocketImpl::AcceptN(void)
+{
+    ClearLastResult();
+
+       result r = E_SUCCESS;
+       Socket* pClientSocket = null;
+       _SocketImpl* pClientSocketImpl = null;
+       int clientFd = INVALID_HANDLE;
+       unsigned int clientSize = 0;
+       struct sockaddr_in clientAddr;
+
+       SysTryCatch(NID_NET_SOCK, __isClosed == false, r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Socket is already closed.");
+
+       clientSize = sizeof(clientAddr);
+
+       clientFd = accept(__socketFd, (struct sockaddr*) &clientAddr, &clientSize);
+
+       if (clientFd < 0)
+       {
+               r = ConvertErrorToResult(errno);
+
+               if (r != E_WOULD_BLOCK)
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Failed to accept the socket.", GetErrorMessage(r));
+                       goto CATCH;
+               }
+               else
+               {
+                       SysLogException(NID_NET_SOCK, r, "[%s] Returned EWOULDBLOCK to accept the socket.", GetErrorMessage(r));
+                       goto CATCH;
+               }
+       }
+
+       if (__isAsync == true)
+       {
+               __isAcceptFired = false;
+               r = __pGlibSocketInfo->SetSocketEvent(this, __socketFd);
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Memory allocation failed.", GetErrorMessage(r));
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach All condition.", __socketFd);
+       }
+
+       // Implementation - new Socket
+       pClientSocket = new (std::nothrow) Socket();
+       SysTryCatch(NID_NET_SOCK, pClientSocket != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       pClientSocketImpl = new (std::nothrow) _SocketImpl(pClientSocket);
+       SysTryCatch(NID_NET_SOCK, pClientSocketImpl, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       // Set new SocketEvent
+       pClientSocketImpl->__pSocketEvent = new (std::nothrow) _SocketEvent();
+       SysTryCatch(NID_NET_SOCK, pClientSocketImpl->__pSocketEvent, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pClientSocketImpl->__pSocketEvent->Construct(pClientSocketImpl);
+       SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to construct the socket event.");
+
+       // New socket creation complete.
+       pClientSocketImpl->__socketFd = clientFd;
+       pClientSocketImpl->__isClosed = false;
+       pClientSocketImpl->__isLoopback = this->__isLoopback;
+       pClientSocketImpl->__isNonblock = this->__isNonblock;
+       pClientSocketImpl->__socketEventType = this->__socketEventType;
+       pClientSocketImpl->__isServer = false;
+       pClientSocketImpl->__isConnectFired = true;
+       pClientSocketImpl->__protocolFamily = this->__protocolFamily;
+       pClientSocketImpl->__socketType = this->__socketType;
+       pClientSocketImpl->__protocol = this->__protocol;
+       pClientSocketImpl->__pLocal = this->__pLocal;
+       pClientSocketImpl->__pPeer = this->__pPeer;
+       pClientSocketImpl->__pLingerOption = this->__pLingerOption;
+       pClientSocketImpl->__pMulticastOption = this->__pMulticastOption;
+       pClientSocketImpl->__pGMainContext = this->__pGMainContext;
+       pClientSocketImpl->__isConstructed = true;
+
+       pClientSocket->__pSocketImpl = pClientSocketImpl;
+
+       SysLog(NID_NET_SOCK, "New Socket(Child Socket) is created by Server Socket. [ServerFd : %d] [ChildFd : %d]", pClientSocket->__pSocketImpl->__socketFd, __socketFd);
+
+       if (__isAsync == true)
+       {
+               pClientSocketImpl->__pGlibSocketInfo = new (std::nothrow) _GlibSocketInfo();
+               SysTryCatch(NID_NET_SOCK, __pGlibSocketInfo, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = pClientSocketImpl->__pGlibSocketInfo->SetSocketEvent(pClientSocketImpl, clientFd);
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, , r, "[%s] Memory allocation failed.", GetErrorMessage(r));
+               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to attach All condition to ClientFd.", clientFd);
+       }
+
+       return pClientSocket;
+
+CATCH:
+       SetLastResult(r);
+       return null;
+}
+
+result
+_SocketImpl::Ioctl(NetSocketIoctlCmd cmd, unsigned long& pArg)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+    SysTryReturnResult(NID_NET_SOCK, (cmd == NET_SOCKET_FIONBIO || cmd == NET_SOCKET_FIONREAD || cmd == NET_SOCKET_SIOCATMARK),
+                               E_INVALID_ARG, "IoctlCmd is invalid.");
+
+       result r = E_SUCCESS;
+       int err = 0;
+       int flag = 0;
+
+       if (cmd == NET_SOCKET_FIONBIO && pArg != 0)
+       {
+               // command = FIONBIO;
+               flag = fcntl(__socketFd, F_GETFL);
+               err = fcntl(__socketFd, F_SETFL, flag | O_NONBLOCK);
+               SysLog(NID_NET_SOCK, "Changed the Socket by Non-blocking mode. [Fd : %d]", __socketFd);
+               __isNonblock = true;
+       }
+       else if (cmd == NET_SOCKET_FIONBIO && pArg == 0)
+       {
+               // command = FIONBIO;
+               flag = fcntl(__socketFd, F_GETFL);
+               err = fcntl(__socketFd, F_SETFL, flag & ~O_NONBLOCK);
+               SysLog(NID_NET_SOCK, "Changed the Socket by blocking mode. [Fd : %d]", __socketFd);
+               __isNonblock = false;
+       }
+       else if (cmd == NET_SOCKET_FIONREAD)
+       {
+               // command = FIONREAD;
+               err = ioctl(__socketFd, FIONREAD, (unsigned long*) &pArg);
+               SysLog(NID_NET_SOCK, "Amount of data that can be read : %d bytes. [Fd : %d]", pArg, __socketFd);
+       }
+       else if (cmd == NET_SOCKET_SIOCATMARK)
+       {
+               // command = SIOCATMARK;
+               err = ioctl(__socketFd, SIOCATMARK, (unsigned long*) &pArg);
+               SysLog(NID_NET_SOCK, "All out of band(OOB) data has been read. [Fd : %d]", __socketFd);
+       }
+
+       if (err < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to Ioctl the socket.", GetErrorMessage(r));
+       }
+
+       return r;
+}
+
+result
+_SocketImpl::AsyncSelectByListener(unsigned long socketEventType)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       // New _GlibSocketInfo
+       if (__pGlibSocketInfo == null)
+       {
+               __pGlibSocketInfo = new (std::nothrow) _GlibSocketInfo();
+               SysTryReturnResult(NID_NET_SOCK, __pGlibSocketInfo, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       }
+
+       SysLog(NID_NET_SOCK, "Socket set the socketEvent by AsyncSelectByListener. [Fd : %d]", __socketFd);
+
+       __socketEventType = socketEventType;
+       __isNonblock = true;
+       __isAsync = true;
+
+       return r;
+}
+
+result
+_SocketImpl::AddSocketListener(ISocketEventListener& listener)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       // Get the current GMainContext
+       _EventDispatcher* pEventDispatcher = _EventDispatcher::GetCurrentEventDispatcher();
+       SysTryReturnResult(NID_NET_SOCK, pEventDispatcher, E_SYSTEM, "GetCurrentEventDispatcher is null.");
+
+       __pGMainContext = pEventDispatcher->GetGMainContext();
+       SysTryReturnResult(NID_NET_SOCK, __pGMainContext, E_SYSTEM, "GetGMainContext is null.");
+
+       r = __pSocketEvent->AddListener(listener, true);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to add the listener.");
+
+       r = __socketEventListenerList.Add(const_cast<ISocketEventListener*>(&listener));
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to add the listener to the list.");
+
+       return r;
+}
+
+result
+_SocketImpl::RemoveSocketListener(ISocketEventListener& listener)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       r = __pSocketEvent->RemoveListener(listener);
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to remove the listener.");
+
+       r = __socketEventListenerList.Remove(const_cast<ISocketEventListener*>(&listener));
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to remove the listener to the list.");
+
+       return r;
+}
+
+const NetEndPoint*
+_SocketImpl::GetPeerEndPoint(void)
+{
+    ClearLastResult();
+
+       result r = E_SUCCESS;
+       Ip4Address* pIp4Addr = null;
+       _NetEndPointImpl* pNetEndPointImpl = null;
+       unsigned int addrSize = 0;
+       struct sockaddr_in remoteAddr;
+
+       SysTryCatch(NID_NET_SOCK, __isClosed == false, r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Socket is already closed.");
+
+       addrSize = sizeof(remoteAddr);
+
+       if ((getpeername(__socketFd, (struct sockaddr*) &remoteAddr, &addrSize)) < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to get the PeerEndPoint.", GetErrorMessage(r));
+               goto CATCH;
+       }
+
+       SysLog(NID_NET_SOCK, "Peer Address, Port : [%s], [%d]", inet_ntoa(remoteAddr.sin_addr), ntohs(remoteAddr.sin_port));
+
+       // New and set Ip4Address
+       pIp4Addr = new (std::nothrow) Ip4Address(ntohl(remoteAddr.sin_addr.s_addr));
+       SysTryReturn(NID_NET_SOCK, pIp4Addr, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       if (__pPeer == null)
+       {
+               __pPeer = new (std::nothrow) NetEndPoint(*pIp4Addr, ntohs(remoteAddr.sin_port));
+               SysTryReturn(NID_NET_SOCK, __pPeer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       }
+       else
+       {
+               pNetEndPointImpl = _NetEndPointImpl::GetInstance(*__pPeer);
+
+               r = pNetEndPointImpl->Update(*pIp4Addr, ntohs(remoteAddr.sin_port));
+               //r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+               //SysTryCatch(NID_NET_SOCK, r == E_SUCCESS || r == E_SYSTEM, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               //SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to Set the NetEndPoint.");
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS || r == E_INVALID_ARG, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Failed to Set the NetEndPoint.");
+
+       }
+       delete pIp4Addr;
+       return (NetEndPoint*) __pPeer;
+
+CATCH:
+    delete pIp4Addr;
+       return null;
+}
+
+const NetEndPoint*
+_SocketImpl::GetLocalEndPoint(void)
+{
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+       Ip4Address* pIp4Addr = null;
+       _NetEndPointImpl* pNetEndPointImpl = null;
+       unsigned int addrSize = 0;
+       struct sockaddr_in localAddr;
+
+       SysTryCatch(NID_NET_SOCK, __isClosed == false, r = E_INVALID_STATE, E_INVALID_STATE, "[%s] Socket is already closed.", GetErrorMessage(E_INVALID_STATE));
+
+       addrSize = sizeof(localAddr);
+
+       if ((getsockname(__socketFd, (struct sockaddr*) &localAddr, &addrSize)) < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to get the LocalEndPoint.", GetErrorMessage(r));
+               goto CATCH;
+       }
+
+       SysLog(NID_NET_SOCK, "Local Address, Port : [%s], [%d]", inet_ntoa(localAddr.sin_addr), ntohs(localAddr.sin_port));
+
+       // New and set Ip4Address
+       pIp4Addr = new (std::nothrow) Ip4Address(ntohl(localAddr.sin_addr.s_addr));
+       SysTryReturn(NID_NET_SOCK, pIp4Addr, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       if (__pLocal == null)
+       {
+               __pLocal = new (std::nothrow) NetEndPoint(*pIp4Addr, ntohs(localAddr.sin_port));
+               SysTryReturn(NID_NET_SOCK, __pLocal, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       }
+       else
+       {
+               pNetEndPointImpl = _NetEndPointImpl::GetInstance(*__pLocal);
+
+               r = pNetEndPointImpl->Update(*pIp4Addr, ntohs(localAddr.sin_port));
+        //r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+        //SysTryCatch(NID_NET_SOCK, r == E_SUCCESS || r == E_SYSTEM, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        //SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to Set the NetEndPoint.");
+        SysTryCatch(NID_NET_SOCK, r == E_SUCCESS || r == E_INVALID_ARG, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        SysTryCatch(NID_NET_SOCK, r == E_SUCCESS, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Failed to Set the NetEndPoint.");
+       }
+       delete pIp4Addr;
+       return (NetEndPoint*) __pLocal;
+
+CATCH:
+    delete pIp4Addr;
+       return null;
+}
+
+result
+_SocketImpl::GetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int& pOptVal) const
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+       int err = 0;
+       int optLevel = 0;
+       int optName = 0;
+       unsigned int optLen = 0;
+
+       struct timeval timeout;
+
+       switch (optionLevel)
+       {
+       case NET_SOCKET_IPPROTO_TCP:
+               optLevel = IPPROTO_TCP;
+               break;
+
+       case NET_SOCKET_IPPROTO_IP:
+               optLevel = IPPROTO_IP;
+               break;
+
+       case NET_SOCKET_SOL_SOCKET:
+               optLevel = SOL_SOCKET;
+               break;
+
+       default:
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] Invalid argument is used. Option level = %d", optionLevel);
+               return r;
+       }
+
+       switch (optionName)
+       {
+       case NET_SOCKET_TCP_NODELAY:
+               optName = TCP_NODELAY;
+               break;
+
+       case NET_SOCKET_TCP_MAXSEG:
+               optName = TCP_MAXSEG;
+               break;
+
+       case NET_SOCKET_IP_TTL:
+               optName = IP_TTL;
+               break;
+
+       case NET_SOCKET_IP_TOS:
+               optName = IP_TOS;
+               break;
+
+       case NET_SOCKET_SO_ACCEPTCONN:
+               optName = SO_ACCEPTCONN;
+               break;
+
+       case NET_SOCKET_SO_BROADCAST:
+               optName = SO_BROADCAST;
+               break;
+
+//     case NET_SOCKET_SO_DEBUG:
+//             optName = SO_DEBUG;
+//             break;
+
+       case NET_SOCKET_SO_DONTROUTE:
+               optName = SO_DONTROUTE;
+               break;
+
+       case NET_SOCKET_SO_ERROR:
+               optName = SO_ERROR;
+               break;
+
+       case NET_SOCKET_SO_KEEPALIVE:
+               optName = SO_KEEPALIVE;
+               break;
+
+       case NET_SOCKET_SO_OOBINLINE:
+               optName = SO_OOBINLINE;
+               break;
+
+       case NET_SOCKET_SO_RCVBUF:
+               optName = SO_RCVBUF;
+               break;
+
+       case NET_SOCKET_SO_RCVTIMEO:
+               optName = SO_RCVTIMEO;
+               break;
+
+       case NET_SOCKET_SO_REUSEADDR:
+               optName = SO_REUSEADDR;
+               break;
+
+       case NET_SOCKET_SO_SNDBUF:
+               optName = SO_SNDBUF;
+               break;
+
+       case NET_SOCKET_SO_SNDTIMEO:
+               optName = SO_SNDTIMEO;
+               break;
+
+       case NET_SOCKET_SO_TYPE:
+               optName = SO_TYPE;
+               break;
+
+       default:
+               r = E_UNSUPPORTED_OPTION;
+               SysLogException(NID_NET_SOCK, r, "[E_UNSUPPORTED_OPTION] %d is unsupported", optionName);
+               return r;
+       }
+
+       if (optName == SO_RCVTIMEO || optName == SO_SNDTIMEO)
+       {
+               optLen = sizeof(timeout);
+               err = getsockopt(__socketFd, optLevel, optName, &timeout, &optLen);
+               pOptVal = (timeout.tv_sec * 1000) + (timeout.tv_usec / 1000);
+       }
+       else
+       {
+               optLen = sizeof(pOptVal);
+               err = getsockopt(__socketFd, optLevel, optName, (int*) &pOptVal, &optLen);
+       }
+
+       if (err < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to get the option value.", GetErrorMessage(r));
+       }
+
+       return r;
+}
+
+result
+_SocketImpl::GetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, LingerOption& optionValue) const
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+    SysTryReturnResult(NID_NET_SOCK, optionLevel == NET_SOCKET_SOL_SOCKET, E_INVALID_ARG, "This is only for LingerOption.");
+    SysTryReturnResult(NID_NET_SOCK, optionName == NET_SOCKET_SO_LINGER, E_INVALID_ARG, "This is only for LingerOption.");
+
+       result r = E_SUCCESS;
+
+       int optLevel = SOL_SOCKET;
+       int optName = SO_LINGER;
+       struct linger lingerOption;
+       unsigned int optLen = sizeof(lingerOption);
+
+       _LingerOptionImpl* pLingerOptionImpl = null;
+       pLingerOptionImpl = _LingerOptionImpl::GetInstance(optionValue);
+
+       if (getsockopt(__socketFd, optLevel, optName, (char*) &lingerOption, &optLen) < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to get the linger option value.", GetErrorMessage(r));
+       }
+
+       // Implementation
+       if (lingerOption.l_onoff == 0)
+       {
+               pLingerOptionImpl->__enabled = false;
+       }
+       else
+       {
+               pLingerOptionImpl->__enabled = true;
+       }
+
+       if (lingerOption.l_linger >= 0)
+       {
+               pLingerOptionImpl->__lingerTime = lingerOption.l_linger;
+       }
+       else
+       {
+               pLingerOptionImpl->__lingerTime = 0;
+       }
+
+       return r;
+}
+
+result
+_SocketImpl::SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, int optionValue)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+       int err = 0;
+       int optLevel = NET_SOCKET_OPTLEVEL_NONE;
+       int optName = NET_SOCKET_OPTNAME_NONE;
+       unsigned int optLen = 0;
+       struct timeval timeout;
+
+       switch (optionLevel)
+       {
+       case NET_SOCKET_IPPROTO_TCP:
+               optLevel = IPPROTO_TCP;
+               break;
+
+       case NET_SOCKET_IPPROTO_IP:
+               optLevel = IPPROTO_IP;
+               break;
+
+       case NET_SOCKET_SOL_SOCKET:
+               optLevel = SOL_SOCKET;
+               break;
+
+       default:
+               r = E_INVALID_ARG;
+               SysLogException(NID_NET_SOCK, r, "[E_INVALID_ARG] Invalid argument is used. Option level = %d", optionLevel);
+               return r;
+       }
+
+       switch (optionName)
+       {
+       case NET_SOCKET_TCP_NODELAY:
+               optName = TCP_NODELAY;
+               break;
+
+       case NET_SOCKET_TCP_MAXSEG:
+               optName = TCP_MAXSEG;
+               break;
+
+       case NET_SOCKET_IP_TTL:
+               optName = IP_TTL;
+               break;
+
+       case NET_SOCKET_IP_TOS:
+               optName = IP_TOS;
+               break;
+
+       case NET_SOCKET_SO_BROADCAST:
+               optName = SO_BROADCAST;
+               break;
+
+//     case NET_SOCKET_SO_DEBUG:
+//             optName = SO_DEBUG;
+//             break;
+
+       case NET_SOCKET_SO_DONTROUTE:
+               optName = SO_DONTROUTE;
+               break;
+
+       case NET_SOCKET_SO_KEEPALIVE:
+               optName = SO_KEEPALIVE;
+               break;
+
+       case NET_SOCKET_SO_OOBINLINE:
+               optName = SO_OOBINLINE;
+               break;
+
+       case NET_SOCKET_SO_RCVBUF:
+               optName = SO_RCVBUF;
+               break;
+
+       case NET_SOCKET_SO_RCVTIMEO:
+               optName = SO_RCVTIMEO;
+               // milliseconds
+               timeout.tv_sec = optionValue / 1000;
+               timeout.tv_usec = (optionValue % 1000) * 1000;
+               break;
+
+       case NET_SOCKET_SO_REUSEADDR:
+               optName = SO_REUSEADDR;
+               break;
+
+       case NET_SOCKET_SO_SNDBUF:
+               optName = SO_SNDBUF;
+               break;
+
+       case NET_SOCKET_SO_SNDTIMEO:
+               optName = SO_SNDTIMEO;
+               // milliseconds
+               timeout.tv_sec = optionValue / 1000;
+               timeout.tv_usec = (optionValue % 1000) * 1000;
+               break;
+
+       default:
+               r = E_UNSUPPORTED_OPTION;
+               SysLogException(NID_NET_SOCK, r, "[E_UNSUPPORTED_OPTION] %d is unsupported", optionName);
+               return r;
+       }
+
+       if (optName == SO_RCVTIMEO || optName == SO_SNDTIMEO)
+       {
+               optLen = sizeof(timeout);
+               err = setsockopt(__socketFd, optLevel, optName, (struct timeval*) &timeout, optLen);
+       }
+       else
+       {
+               optLen = sizeof(optionValue);
+               err = setsockopt(__socketFd, optLevel, optName, (int*) &optionValue, optLen);
+       }
+
+       if (err < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to get the option value.", GetErrorMessage(r));
+       }
+
+       return r;
+}
+
+result
+_SocketImpl::SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, const LingerOption& optionValue)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+    SysTryReturnResult(NID_NET_SOCK, optionLevel == NET_SOCKET_SOL_SOCKET, E_INVALID_ARG, "This is only for LingerOption.");
+    SysTryReturnResult(NID_NET_SOCK, optionName == NET_SOCKET_SO_LINGER, E_INVALID_ARG, "This is only for LingerOption.");
+
+       result r = E_SUCCESS;
+
+       int optLevel = SOL_SOCKET;
+       int optName = SO_LINGER;
+       struct linger lingerOption;
+       unsigned int optLen = sizeof(lingerOption);
+
+       const _LingerOptionImpl* pLingerOptionImpl = null;
+       pLingerOptionImpl = _LingerOptionImpl::GetInstance(optionValue);
+
+       if (pLingerOptionImpl->__enabled == false)
+       {
+               lingerOption.l_onoff = 0;
+       }
+       else
+       {
+               lingerOption.l_onoff = 1;
+       }
+
+       lingerOption.l_linger = pLingerOptionImpl->__lingerTime;
+
+       if (setsockopt(__socketFd, optLevel, optName, (char*) &lingerOption, optLen) < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to set the LingerOption value.", GetErrorMessage(r));
+       }
+
+       return r;
+}
+
+result
+_SocketImpl::SetSockOpt(NetSocketOptLevel optionLevel, NetSocketOptName optionName, const IpMulticastRequestOption& optionValue)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+    SysTryReturnResult(NID_NET_SOCK, optionLevel == NET_SOCKET_IPPROTO_IP, E_INVALID_ARG, "This is only for MulticastOption.");
+    SysTryReturnResult(NID_NET_SOCK, (optionName == NET_SOCKET_IP_ADD_MEMBERSHIP) || (optionName == NET_SOCKET_IP_DROP_MEMBERSHIP),
+                               E_INVALID_ARG, "This is only for MulticastOption.");
+
+       result r = E_SUCCESS;
+       int optLevel = SOL_SOCKET;
+       int optName = SO_LINGER;
+       struct ip_mreq multicastOption;
+       unsigned int optLen = sizeof(multicastOption);
+
+       const _IpMulticastRequestOptionImpl* pMulticastOptionImpl = null;
+       Ip4Address* pIp4AddrMulti = null;
+       Ip4Address* pIp4AddrInter = null;
+       IpAddress* pIpAddrMulti = null;
+       IpAddress* pIpAddrInter = null;
+       _Ip4AddressImpl* pIp4AddrImplMulti = null;
+       _Ip4AddressImpl* pIp4AddrImplInter = null;
+
+       unsigned long ipAddrMulti = 0;
+       unsigned long ipAddrInter = 0;
+
+       pMulticastOptionImpl = _IpMulticastRequestOptionImpl::GetInstance(optionValue);
+
+       pIpAddrMulti = pMulticastOptionImpl->__pMulticastAddr->GetAddress();
+       SysTryReturnResult(NID_NET_SOCK, pIpAddrMulti, E_SYSTEM,"Multicast address is null.");
+
+       pIp4AddrMulti = dynamic_cast <Ip4Address*>(pIpAddrMulti);
+       SysTryReturnResult(NID_NET_SOCK, pIp4AddrMulti, E_SYSTEM, "Multicast IpAddress is null.");
+
+       pIp4AddrImplMulti = _Ip4AddressImpl::GetInstance(*pIp4AddrMulti);
+       pIp4AddrImplMulti->GetAddress(ipAddrMulti);
+
+       pIpAddrInter = pMulticastOptionImpl->__pInterfaceAddr->GetAddress();
+       SysTryReturnResult(NID_NET_SOCK, pIpAddrInter, E_SYSTEM, "Interface address is null.");
+
+       pIp4AddrInter = dynamic_cast <Ip4Address*>(pIpAddrInter);
+       SysTryReturnResult(NID_NET_SOCK, pIp4AddrInter, E_SYSTEM, "Interface IpAddress is null.");
+
+       pIp4AddrImplInter = _Ip4AddressImpl::GetInstance(*pIp4AddrInter);
+       pIp4AddrImplInter->GetAddress(ipAddrInter);
+
+       multicastOption.imr_multiaddr.s_addr = ipAddrMulti;
+       multicastOption.imr_interface.s_addr = ipAddrInter;
+
+       if (setsockopt(__socketFd, optLevel, optName, (char*) &multicastOption, optLen) < 0)
+       {
+               r = ConvertErrorToResult(errno);
+               SysLogException(NID_NET_SOCK, r, "[%s] Failed to set the MulticastOption value.", GetErrorMessage(r));
+       }
+
+       return r;
+}
+
+int
+_SocketImpl::GetSocketFd(void)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       return __socketFd;
+}
+
+Socket*
+_SocketImpl::GetSocket(void) const
+{
+       return __pSocket;
+}
+
+_SocketImpl*
+_SocketImpl::GetInstance(Socket& socket)
+{
+       return socket.__pSocketImpl;
+}
+
+const _SocketImpl*
+_SocketImpl::GetInstance(const Socket& socket)
+{
+       return socket.__pSocketImpl;
+}
+
+result
+_SocketImpl::Dispose(void)
+{
+    SysTryReturnResult(NID_NET_SOCK, __isClosed == false, E_INVALID_STATE, "Socket is already closed.");
+
+       result r = E_SUCCESS;
+
+       r = Close();
+       SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to close the socket.");
+
+       __isClosed = true;
+
+       return r;
+}
+
+// glib Event
+gboolean
+_SocketImpl::OnGioEventCallback(GIOChannel* pSource, GIOCondition condition, gpointer pUserData)
+{
+       SysLog(NID_NET_SOCK, "### OnGioEventCallback ###");
+
+       result errorCode = E_SUCCESS;
+       GIOStatus status = G_IO_STATUS_NORMAL;
+       gchar buffer[1024];
+       gsize bytes_read = 0;
+       int readSize = 0;
+       int error = 0;
+
+       _UserData* pRecvUserData = (_UserData*) pUserData;
+
+       _SocketImpl* pSocketImpl = static_cast <_SocketImpl*>(pRecvUserData->pSocketImpl);
+       GSource* pGSource = static_cast <GSource*>(pRecvUserData->pGSource);
+
+       _SocketEventArg* pEventArg = null;
+
+       SysLog(NID_NET_SOCK, "====> [Event] OnGioEventCallback : All GIO event is received.(%d).", condition);
+
+       if (condition & G_IO_ERR)
+       {
+               SysLog(NID_NET_SOCK, "====> [Event] Socket event is received.(G_IO_ERR)");
+
+               if ((pSocketImpl->__socketEventType & NET_SOCKET_EVENT_CLOSE) && (pSocketImpl->__isCloseFired == false))
+               {
+                       // Fire the event(NET_SOCKET_EVENT_CLOSE)
+                       pEventArg = new (std::nothrow) _SocketEventArg(pSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+                       SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                       // G_IO_ERROR Converting
+                       status = g_io_channel_read_chars(pSource, buffer, sizeof(buffer), &bytes_read, null);
+                       errorCode = ConvertGioStatus(status);
+                       pEventArg->SetError(E_SUCCESS);
+                       pSocketImpl->__pSocketEvent->Fire(*pEventArg);
+
+                       g_source_set_callback(pGSource, null, null, null);
+                       SysLog(NID_NET_SOCK, "### Set giocondition for GSource to null (%d)", g_source_get_id(pGSource));
+
+                       goto CATCH;
+               }
+       }
+
+       if (pSocketImpl->__isServer)    // For Server
+       {
+               SysLog(NID_NET_SOCK, "====> [Event] This is server");
+
+               if (condition & (G_IO_IN))
+               {
+                       SysLog(NID_NET_SOCK, "====> [Event] Socket event is received.(G_IO_IN)");
+
+                       struct pollfd fds[1];
+                       fds[0].fd = pSocketImpl->__socketFd;
+                       fds[0].events = POLLRDHUP;
+
+
+                       error = poll(fds, 1, 0);
+            SysTryCatch(NID_NET_SOCK, error != -1, , null, "Failed to the poll");
+
+
+                       if (fds[0].revents & POLLRDHUP)
+                       {
+                               SysLog(NID_NET_SOCK, "====> Socket is not available.(POLLRDHUP)");
+
+                               if ((pSocketImpl->__socketEventType & NET_SOCKET_EVENT_CLOSE) && (pSocketImpl->__isCloseFired == false))
+                               {
+                                       // Fire the event(NET_SOCKET_EVENT_CLOSE)
+                                       pEventArg = new (std::nothrow) _SocketEventArg(pSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+                                       SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                                       // G_IO_ERROR Converting
+                                       status = g_io_channel_read_chars(pSource, buffer, sizeof(buffer), &bytes_read, null);
+                                       errorCode = ConvertGioStatus(status);
+                                       pEventArg->SetError(errorCode);
+                                       pSocketImpl->__pSocketEvent->Fire(*pEventArg);
+
+                                       g_source_set_callback(pGSource, null, null, null);
+                                       SysLog(NID_NET_SOCK, "### Set giocondition for GSource to null.(%d)", g_source_get_id(pGSource));
+
+                                       goto CATCH;
+                               }
+                       }
+                       else
+                       {
+                               SysLog(NID_NET_SOCK, "====> Socket is available.(Not POLLRDHUP)");
+
+                               if ((pSocketImpl->__socketEventType & NET_SOCKET_EVENT_ACCEPT) && (pSocketImpl->__isAcceptFired == false) &&
+                                       (pSocketImpl->__isCloseFired == false) && (pSocketImpl->__socketType == NET_SOCKET_TYPE_STREAM))
+                               {
+                                       // Fire the event(NET_SOCKET_EVENT_ACCEPT)
+                                       pEventArg = new (std::nothrow) _SocketEventArg(pSocketImpl->__socketFd, NET_SOCKET_EVENT_ACCEPT);
+                                       SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                                       pSocketImpl->__pSocketEvent->Fire(*pEventArg);
+
+                                       goto CATCH;
+                               }
+                       }
+               }
+
+               if (condition & (G_IO_OUT))
+               {
+                       SysLog(NID_NET_SOCK, "====> [Event] Socket event is received.(G_IO_OUT).");
+               }
+
+       }
+       else // For Client
+       {
+               SysLog(NID_NET_SOCK, "====> [Event] This is Client");
+
+               if (condition & (G_IO_IN))
+               {
+                   SysLog(NID_NET_SOCK, "====> [Event] Socket event is Received.(G_IO_IN).");
+
+                       struct pollfd fds[1];
+                       fds[0].fd = pSocketImpl->__socketFd;
+                       fds[0].events = POLLRDHUP;
+
+                       error = poll(fds, 1, 0);
+            SysTryCatch(NID_NET_SOCK, error != -1, , null, "Failed to the poll");
+
+                       if (fds[0].revents & POLLRDHUP)
+                       {
+                               SysLog(NID_NET_SOCK, "====> Socket is not available.(POLLRDHUP)");
+
+                               ioctl(pSocketImpl->__socketFd, FIONREAD, &readSize);
+                               SysLog(NID_NET_SOCK, "Amount of data that can be read : %d bytes. [Fd : %d byte]", readSize, pSocketImpl->__socketFd);
+
+                               if (readSize <= 0)
+                               {
+                                       if ((pSocketImpl->__socketEventType & NET_SOCKET_EVENT_CLOSE) && (pSocketImpl->__isCloseFired == false))
+                                       {
+                                               // Fire the event(NET_SOCKET_EVENT_CLOSE)
+                                               pEventArg = new (std::nothrow) _SocketEventArg(pSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+                                               SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                                               // G_IO_ERROR Converting
+                                               status = g_io_channel_read_chars(pSource, buffer, sizeof(buffer), &bytes_read, null);
+                                               errorCode = ConvertGioStatus(status);
+                                               pEventArg->SetError(errorCode);
+                                               pSocketImpl->__pSocketEvent->Fire(*pEventArg);
+
+                                               g_source_set_callback(pGSource, null, null, null);
+                                               SysLog(NID_NET_SOCK, "### Set giocondition for GSource to null (%d)", g_source_get_id(pGSource));
+
+                                               goto CATCH;
+                                       }
+                               }
+                               else
+                               {
+                                       if ((pSocketImpl->__socketEventType & NET_SOCKET_EVENT_READ) && (pSocketImpl->__isReadFired == false) &&
+                                               (pSocketImpl->__isErrorReadFired == false) && (pSocketImpl->__isCloseFired == false))
+                                       {
+                                               // Fire the event(NET_SOCKET_EVENT_READ)
+                                               pEventArg = new (std::nothrow) _SocketEventArg(pSocketImpl->__socketFd, NET_SOCKET_EVENT_READ);
+                                               SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                                               pSocketImpl->__pSocketEvent->Fire(*pEventArg);
+
+                                               pSocketImpl->__isErrorReadFired = true;
+
+                                               goto CATCH;
+                                       }
+
+                                       if ((pSocketImpl->__socketEventType & NET_SOCKET_EVENT_CLOSE) && (pSocketImpl->__isCloseFired == false))
+                                       {
+                                               // Fire the event(NET_SOCKET_EVENT_CLOSE)
+                                               pEventArg = new (std::nothrow) _SocketEventArg(pSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+                                               SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                                               // G_IO_ERROR Converting
+                                               // status = g_io_channel_read_chars(pSource, buffer, sizeof(buffer), &bytes_read, null);
+                                               // errorCode = ConvertGioStatus(status);
+                                               pEventArg->SetError(E_SUCCESS);
+                                               pSocketImpl->__pSocketEvent->Fire(*pEventArg);
+
+                                               g_source_set_callback(pGSource, null, null, null);
+                                               SysLog(NID_NET_SOCK, "### Set giocondition for GSource to null (%d)", g_source_get_id(pGSource));
+
+                                               goto CATCH;
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               SysLog(NID_NET_SOCK, "====> Socket is available.(Not POLLRDHUP)");
+
+                               if ((pSocketImpl->__socketEventType & NET_SOCKET_EVENT_READ) && (pSocketImpl->__isReadFired == false) &&
+                                       (pSocketImpl->__isCloseFired == false))
+                               {
+                                       // Fire the event(NET_SOCKET_EVENT_READ)
+                                       pEventArg = new (std::nothrow) _SocketEventArg(pSocketImpl->__socketFd, NET_SOCKET_EVENT_READ);
+                                       SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                                       pSocketImpl->__pSocketEvent->Fire(*pEventArg);
+
+                                       goto CATCH;
+                               }
+                       }
+               }
+
+               if (condition & (G_IO_OUT))
+               {
+                       SysLog(NID_NET_SOCK, "====> [Event] Socket event is Received.(G_IO_OUT).");
+
+                       if (pSocketImpl->__isWriteFired == true)
+                       {
+                           errorCode = pSocketImpl->__pGlibSocketInfo->SetSocketEvent(pSocketImpl, pSocketImpl->__socketFd);
+                               SysTryReturn(NID_NET_SOCK, errorCode == E_SUCCESS, true, errorCode, "[%s] Memory allocation failed.", GetErrorMessage(errorCode));
+                               SysLog(NID_NET_SOCK, "SocketFd : [%d], Set the socketEvent to release G_IO_OUT condition in OnGioEventCallback.", pSocketImpl->__socketFd);
+
+                               goto CATCH;
+                       }
+
+                       if ((pSocketImpl->__socketEventType & NET_SOCKET_EVENT_CONNECT) && (pSocketImpl->__isConnectFired == false) &&
+                               (pSocketImpl->__isCloseFired == false) && (pSocketImpl->__socketType == NET_SOCKET_TYPE_STREAM))
+                       {
+                               // Fire the event(NET_SOCKET_EVENT_CONNECT)
+                               pEventArg = new (std::nothrow) _SocketEventArg(pSocketImpl->__socketFd, NET_SOCKET_EVENT_CONNECT);
+                               SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                               pSocketImpl->__pSocketEvent->Fire(*pEventArg);
+
+                               goto CATCH;
+                       }
+
+                       if ((pSocketImpl->__socketEventType & NET_SOCKET_EVENT_WRITE) && (pSocketImpl->__isConnectFired == true) &&
+                               (pSocketImpl->__isWriteFired == false) && (pSocketImpl->__isCloseFired == false))
+                       {
+                               // Fire the event(NET_SOCKET_EVENT_WRITE)
+                               pEventArg = new (std::nothrow) _SocketEventArg(pSocketImpl->__socketFd, NET_SOCKET_EVENT_WRITE);
+                               SysTryCatch(NID_NET_SOCK, pEventArg, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                               pSocketImpl->__pSocketEvent->Fire(*pEventArg);
+
+                               goto CATCH;
+                       }
+               }
+       }
+
+       if (condition & G_IO_PRI)
+       {
+               SysLog(NID_NET_SOCK, "====> [Event] Socket event is Received.(G_IO_PRI).");
+       }
+
+       if (condition & G_IO_HUP)
+       {
+               SysLog(NID_NET_SOCK, "====> [Event] Socket event is Received.(G_IO_HUP).");
+       }
+
+       if (condition & G_IO_NVAL)
+       {
+               SysLog(NID_NET_SOCK, "====> [Event] Socket event is Received.(G_IO_NVAL).");
+       }
+
+       return true;
+
+CATCH:
+       return true;
+}
+
+gboolean
+_SocketImpl::OnTimerCallback(gpointer pUserData)
+{
+       SysLog(NID_NET_SOCK, "### OnTimercallback ###");
+
+       _SocketImpl* pSocketImpl = static_cast <_SocketImpl*>(pUserData);
+
+       pSocketImpl->__isTimeout = true;
+
+       return true;
+}
+
+_GlibSocketInfo::_GlibSocketInfo(void)
+       : __pSocketChannel(null)
+       , __pSocketSource(null)
+       , __socketFd(INVALID_HANDLE)
+       , __pUserData(null)
+{
+}
+
+_GlibSocketInfo::~_GlibSocketInfo(void)
+{
+    delete __pUserData;
+    __pUserData = null;
+
+       if (__pSocketSource != null)
+       {
+               g_source_set_callback(__pSocketSource, null, null, null);
+               SysLog(NID_NET_SOCK, "### Deleted g_source_destroy(%d)", g_source_get_id(__pSocketSource));
+               g_source_destroy(__pSocketSource);
+               g_source_unref(__pSocketSource);
+               __pSocketSource = null;
+       }
+
+       if (__pSocketChannel != null)
+       {
+               g_io_channel_unref(__pSocketChannel);
+               __pSocketChannel = null;
+       }
+}
+
+result
+_GlibSocketInfo::SetSocketEvent(_SocketImpl* pSocketImpl, HSocket socketFd)
+{
+       result r = E_SUCCESS;
+
+       GIOCondition condition = (GIOCondition)0;
+
+       if (__pSocketChannel == null)
+       {
+               __pUserData = new (std::nothrow) _UserData;
+               SysTryReturnResult(NID_NET_SOCK, __pUserData, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+               __pSocketChannel = g_io_channel_unix_new(socketFd);
+               SysLog(NID_NET_SOCK, "Created the SocketChannel. [Fd : %d]", socketFd);
+       }
+
+       // Set masking of wanted socket Event
+       if (pSocketImpl->__isWriteFired == false)
+    {
+        condition = static_cast <GIOCondition>(G_IO_IN | G_IO_OUT | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL);
+    }
+       else
+       {
+               condition = static_cast <GIOCondition>(G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL);
+       }
+
+       // G_IO_IN : There is data to read. 1
+       // G_IO_OUT : Data can be written (without blocking). 4
+       // G_IO_PRI : There is urgent data to read. 2
+       // G_IO_ERR : Error condition. 8
+       // G_IO_HUP : Hung up (the connection has been broken, usually for pipes and sockets). 16
+       // G_IO_NVAL : Invalid request. The file descriptor is not open. 32
+
+       if (__pSocketSource != null)
+       {
+               g_source_set_callback(__pSocketSource, null, null, null);
+               SysLog(NID_NET_SOCK, "### Deleted g_source_destroy(%d)", g_source_get_id(__pSocketSource));
+               g_source_destroy(__pSocketSource);
+               g_source_unref(__pSocketSource);
+               __pSocketSource = null;
+               SysLog(NID_NET_SOCK, "Unref the SocketSource.");
+       }
+
+       __pSocketSource = g_io_create_watch(__pSocketChannel, condition);
+
+       __pUserData->pSocketImpl = (_SocketImpl*) pSocketImpl;
+       __pUserData->pGSource = (GSource*) __pSocketSource;
+
+       g_source_set_callback(__pSocketSource, (GSourceFunc) _SocketImpl::OnGioEventCallback, __pUserData, null);
+       g_source_attach(__pSocketSource, pSocketImpl->__pGMainContext);
+
+       SysLog(NID_NET_SOCK, "Created the GSource Id : [%d]", g_source_get_id(__pSocketSource));
+       SysLog(NID_NET_SOCK, "Created the SocketSource for receiving the event. [%d]", condition);
+
+       return r;
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSock_SocketInternalHelp.cpp b/src/sockets/FNetSock_SocketInternalHelp.cpp
new file mode 100644 (file)
index 0000000..d70dbb8
--- /dev/null
@@ -0,0 +1,432 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketInternalHelp.cpp
+ * @brief              This is the implementation for the _SocketInternalHelp methods.
+ */
+
+#include <cstdlib>
+#include <sys/socket.h>
+#include <errno.h>
+#include <FBaseSysLog.h>
+#include "FBase_StringConverter.h"
+#include "FNetSock_SocketInternalHelp.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Net;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+const char*
+ConvertEventTypeToString(NetSocketEventType event)
+{
+       int index = 0;
+       static const char* pNetSocketEventTypesToString[] =
+       {
+               "NET_SOCKET_EVENT_NONE", "NET_SOCKET_EVENT_WRITE", "NET_SOCKET_EVENT_READ", "NET_SOCKET_EVENT_CLOSE",
+               "NET_SOCKET_EVENT_ACCEPT", "NET_SOCKET_EVENT_CONNECT", "NET_SOCKET_EVENT_SERVCERT_FAIL"
+       };
+
+       if (event == 0x00)
+       {
+               index = 0;
+       }
+       else if (event == 0x01)
+       {
+               index = 1;
+       }
+       else if (event == 0x02)
+       {
+               index = 2;
+       }
+       else if (event == 0x04)
+       {
+               index = 3;
+       }
+       else if (event == 0x08)
+       {
+               index = 4;
+       }
+       else if (event == 0x10)
+       {
+               index = 5;
+       }
+       else if (event == 0x20)
+       {
+               index = 6;
+       }
+
+       return pNetSocketEventTypesToString[index];
+}
+
+NetSocketClosedReason
+ConvertClosedReason(result errorCode)
+{
+       NetSocketClosedReason closedReason = NET_SOCKET_CLOSED_REASON_NONE;
+       const char* pErrorMessage = "";
+       switch (errorCode)
+       {
+       case E_SUCCESS:
+               closedReason = NET_SOCKET_CLOSED_REASON_NORMAL;
+               pErrorMessage = "NET_SOCKET_CLOSED_REASON_NORMAL";
+               break;
+
+       case E_TIMEOUT:
+               closedReason = NET_SOCKET_CLOSED_REASON_TIMEOUT;
+               pErrorMessage = "NET_SOCKET_CLOSED_REASON_TIMEOUT";
+               break;
+
+       case E_CONNECTION_RESET:
+       case E_NETWORK_UNAVAILABLE:
+               closedReason = NET_SOCKET_CLOSED_REASON_NETWORK_UNAVAILABLE;
+               pErrorMessage = "NET_SOCKET_CLOSED_REASON_NETWORK_UNAVAILABLE";
+               break;
+
+       default:
+               closedReason = NET_SOCKET_CLOSED_REASON_SYSTEM;
+               pErrorMessage = "NET_SOCKET_CLOSED_REASON_SYSTEM";
+               break;
+       }
+
+       SysLogException(NID_NET_SOCK, errorCode, "errorCode : [%s] converted to NetSocketClosedReason : [%s]", GetErrorMessage(errorCode), pErrorMessage);
+
+       return closedReason;
+}
+
+result
+ConvertGioStatus(GIOStatus giostatus)
+{
+       result errorCode = E_SUCCESS;
+
+       switch (giostatus)
+       {
+       case G_IO_STATUS_ERROR:
+               errorCode = E_SYSTEM;
+               break;
+
+       case G_IO_STATUS_NORMAL:
+               errorCode = E_SUCCESS;
+               break;
+
+       case G_IO_STATUS_EOF:
+               errorCode = E_SUCCESS;
+               break;
+
+       case G_IO_STATUS_AGAIN:
+               errorCode = E_NETWORK_UNAVAILABLE;
+               break;
+
+       default:
+               errorCode = E_SYSTEM;
+               break;
+       }
+
+       return errorCode;
+}
+
+result
+ConvertErrorToResult(int err)
+{
+       result r = E_SUCCESS;
+
+       // Error code mapping (BSD socket error converts to oaf socket exception)
+       switch (err)
+       {
+       case EAFNOSUPPORT:      // The implementation does not support the specified address family.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EAFNOSUPPORT] Address family not supported by protocol.");
+               r = E_UNSUPPORTED_FAMILY;
+               break;
+
+       case ESOCKTNOSUPPORT:   // The protocol or style is not supported by the namespace specified.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ESOCKTNOSUPPORT] Socket type not supported.");
+               r = E_UNSUPPORTED_TYPE;
+               break;
+
+       case EPROTONOSUPPORT:   // The protocol or style is not supported by the namespace specified.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EPROTONOSUPPORT] Protocol not supported.");
+               r = E_UNSUPPORTED_PROTOCOL;
+               break;
+
+       case EINVAL:        // Unknown protocol, or protocol family not available. The socket is already bound to an address. or The length of localAddr is wrong, or the socket was not in the AF_UNIX family. Socket is not listening for connections, or addrlen is invalid (e.g., is negative).
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EINVAL] Invalid argument.");
+               r = E_INVALID_ARG;
+               break;
+
+       case EMFILE:        // The process already has too many file descriptors open. file descriptors are currently open in the calling process.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EMFILE] Too many open files.");
+               r = E_SYSTEM;
+               break;
+
+       case ENFILE:        // The system already has too many file descriptors open. The maximum number of file descriptors in the system are already open.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ENFILE] File table overflow.");
+               r = E_SYSTEM;
+               break;
+
+       case EACCES:        // The process does not have the privilege to create a socket of the specified style or protocol. You do not have permission to access the requested address.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EACCES] Permission denied.");
+               r = E_SYSTEM;
+               break;
+
+       case ENOBUFS:       // The system ran out of internal buffer space.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ENOBUFS] No buffer space available.");
+               r = E_OUT_OF_MEMORY;
+               break;
+
+       case ENOMEM:        // Insufficient memory is available. The socket cannot be created until sufficient resources are freed.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ENOMEM] Out of memory.");
+               r = E_OUT_OF_MEMORY;
+               break;
+
+       case EBADF:         // The filedes argument is not a valid file descriptor. The socket argument is not a valid file descriptor. The socket is not a valid file descriptor.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EBADF] Bad file number.");
+               r = E_INVALID_SOCKET;
+               break;
+
+       case EINTR:         // The close call was interrupted by a signal. The operation was interrupted by a signal before any data was sent.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EINTR] Interrupted system call.");
+               r = E_SYSTEM;
+               break;
+
+       case ENOSPC:        // No space left on device
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ENOSPC] No space left on device.");
+               r = E_OUT_OF_MEMORY;
+               break;
+
+       case EIO:           // An I/O error occurred.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EIO] I/O error.");
+               r = E_SYSTEM;
+               break;
+
+       case EDQUOT:        // When the file is accessed by NFS, these errors from write can sometimes not be detected until close.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EDQUOT] Quota exceeded.");
+               r = E_SYSTEM;
+               break;
+
+       case ENOTSOCK:      // The descriptor socket is not a socket.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ENOTSOCK] Socket operation on non-socket.");
+               r = E_INVALID_SOCKET;
+               break;
+
+       case EADDRNOTAVAIL: // The specified address is not available on this machine. Another socket is already listening on the same port.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EADDRNOTAVAIL] Cannot assign requested address.");
+               r = E_UNSUPPORTED_OPTION;
+               break;
+
+       case EADDRINUSE:    // The given address is already in use.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EADDRINUSE] Address already in use.");
+               r = E_ALREADY_BOUND;
+               break;
+
+       case EFAULT:        // localAddr points outside the user's accessible address space. The socket structure address is outside the user's address space.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EFAULT] Bad address.");
+               r = E_SYSTEM;
+               break;
+
+       case ELOOP:         // Too many symbolic links were encountered in resolving localAddr.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ELOOP] Too many symbolic links encountered.");
+               r = E_SYSTEM;
+               break;
+
+       case ENAMETOOLONG:  // localAddr is too long.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ENAMETOOLONG] File name too long.");
+               r = E_SYSTEM;
+               break;
+
+       case ENOENT:        // The file does not exist.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ENOENT] No such file or directory.");
+               r = E_SYSTEM;
+               break;
+
+       case ENOTDIR:       // A component of the path prefix is not a directory.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ENOTDIR] Not a directory.");
+               r = E_SYSTEM;
+               break;
+
+       case EROFS:         // The socket inode would reside on a read-only file system.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EROFS] Read-only file system.");
+               r = E_SYSTEM;
+               break;
+
+       case EISCONN:       // The socket is already connected.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EISCONN] Transport endpoint is already connected.");
+               r = E_ALREADY_CONNECTED;
+               break;
+
+       case ETIMEDOUT:     // The attempt to establish the connection timed out.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ETIMEDOUT] Connection timed out.");
+               r = E_TIMEOUT;
+               break;
+
+       case ECONNREFUSED:  // The server has actively refused to establish the connection. A remote host refused to allow the network connection (typically because it is not running the requested service).
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ECONNREFUSED] Connection refused.");
+               r = E_CONNECTION_FAILED;    // E_SYSTEM or E_CONNECTION_FAILED
+               break;
+
+       case ENETUNREACH:   // The network of the given addr isn't reachable from this host.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ENETUNREACH] Network is unreachable.");
+               r = E_HOST_UNREACHABLE;
+               break;
+
+       case EINPROGRESS:   // The socket socket is non-blocking and the connection could not be established immediately. You can determine when the connection is completely established with select; see Waiting for I/O. Another connect call on the same socket, before the connection is completely established, will fail with EALREADY.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EINPROGRESS] Operation now in progress.");
+               r = E_WOULD_BLOCK; // E_WOULD_BLOCK
+               break;
+
+       case EALREADY:      // The socket socket is non-blocking and already has a pending connection in progress (see EINPROGRESS above).
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EALREADY] Operation already in progress.");
+               r = E_IN_PROGRESS;
+               break;
+
+       case ECONNRESET:    // Connection reset by peer.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ECONNRESET] Connection reset by peer.");
+               r = E_CONNECTION_FAILED;
+               break;
+
+       case EMSGSIZE:      // The socket type requires that the message be sent atomically, but the message is too large for this to be possible.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EMSGSIZE] Message too long.");
+               r = E_INVALID_ARG;
+               break;
+
+       case EWOULDBLOCK:   // Nonblocking mode has been set on the socket, and the write operation would block. (Normally send blocks until the operation can be completed.) EAGAIN socket has nonblocking mode set, and there are no pending connections immediately available.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EWOULDBLOCK] Operation would block.");
+               r = E_WOULD_BLOCK;
+               break;
+
+       case ENOTCONN:      // You never connected this socket.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ENOTCONN] Transport endpoint is not connected.");
+               r = E_CONNECTION_FAILED;
+               break;
+
+       case EPIPE:         // This socket was connected but the connection is now broken. In this case, send generates a SIGPIPE signal first; if that signal is ignored or blocked, or if its handler returns, then send fails with EPIPE.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EPIPE] Broken pipe.");
+               r = E_CONNECTION_FAILED;   // E_SYSTEM or E_CONNECTION_FAILED
+               break;
+
+       case EDESTADDRREQ:  // The socket is not connection-mode, and no peer address is set.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EDESTADDRREQ] Destination address required.");
+               r = E_CONNECTION_FAILED;
+               break;
+
+       case EOPNOTSUPP:    // Some bit in the flags argument is inappropriate for the socket type. The socket socket does not support this operation.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EOPNOTSUPP] Operation not supported on transport endpoint.");
+               r = E_UNSUPPORTED_OPTION;
+               break;
+
+       case ECONNABORTED:  // A connection has been aborted.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ECONNABORTED] Software caused connection abort.");
+               r = E_NETWORK_UNAVAILABLE;
+               break;
+
+       case EPROTO:        // A protocol error has occurred; for example, the STREAMS protocol stack has not been initialized.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EPROTO] Protocol error.");
+               r = E_UNSUPPORTED_OPTION; // E_UNSUPPORTED_PROTOCOL
+               break;
+
+       case EDEADLK:       // It was detected that the specified F_SETLKW command would cause a deadlock.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EDEADLK] Resource deadlock would occur.");
+               r = E_SYSTEM;
+               break;
+
+       case ENOLCK:        // Too many segment locks open, lock table is full, or a remote locking protocol failed (e.g. locking over NFS).
+               SysLog(NID_NET_SOCK, "Linux socket errno : [ENOLCK] No record locks available.");
+               r = E_SYSTEM;
+               break;
+
+       case EPERM:         // Attempted to clear the O_APPEND flag on a file that has the append-only attribute set.
+               SysLog(NID_NET_SOCK, "Linux socket errno : [EPERM] Operation not permitted.");
+               r = E_SYSTEM;
+               break;
+
+       default:
+               SysLog(NID_NET_SOCK, "Linux socket errno : other error.");
+               r = E_SYSTEM;
+               break;
+       }
+
+       return r;
+}
+
+void
+_Singleton::DestroySecureSocket(void)
+{
+    delete __pSslMap;
+    __initialized = false;
+
+    SysLog(NID_NET_SOCK, "Called Destroy SecureSocket.");
+}
+
+void
+_Singleton::InitializeSecureSocketOnce(void)
+{
+    result r = E_SUCCESS;
+
+    __pSslMap = new (std::nothrow)HashMap();
+
+    r = __pSslMap->Construct();
+
+    __initialized = true;
+
+    SysLog(NID_NET_HTTP, "Allocated the HashMap.");
+
+    //std::atexit(DestroySecureSocket);
+}
+
+void
+_Singleton::InitializeSecureSocket(void)
+{
+    static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+    if (!__initialized)
+    {
+        ClearLastResult();
+        SysLog(NID_NET_SOCK, "Initializing SecureSocket.");
+        pthread_once(&onceBlock, InitializeSecureSocketOnce);
+
+        result r = GetLastResult();
+        if (r != E_SUCCESS)
+        {
+            onceBlock = PTHREAD_ONCE_INIT;
+            SysLogException(NID_NET_SOCK, r, "[%s] Failed to initialize SecureSocket.", GetErrorMessage(r));
+            return;
+        }
+        SysLog(NID_NET_SOCK, "Initialized SecureSocket.");
+    }
+    else
+    {
+        SysLog(NID_NET_SOCK, "SecureSocket is already initialized.");
+    }
+}
+
+HashMap*
+_Singleton::GetSslMap(void)
+{
+    SysAssertf(__pSslMap != null, "__pSslMap is null.");
+    return __pSslMap;
+}
+
+bool
+_Singleton::GetInitialized(void)
+{
+    return __initialized;
+}
+
+} } }   // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSock_SocketInternalHelp.h b/src/sockets/FNetSock_SocketInternalHelp.h
new file mode 100644 (file)
index 0000000..5395274
--- /dev/null
@@ -0,0 +1,122 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketInternalHelp.h
+ * @brief              This is the header file for the _SocketInternalHelp methods.
+ */
+
+#ifndef _FNET_SOCK_SOCKET_INTERNAL_HELP_H_
+#define _FNET_SOCK_SOCKET_INTERNAL_HELP_H_
+
+#include <glib.h>
+#include <FBaseDataType.h>
+#include <FBaseString.h>
+#include <FNetSockSocketTypes.h>
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+static const int _MIN_SELECT_TIMEOUT = 10000;   // minimum timeout value for select() : 10msec = 10000usec
+
+//static const int DEFAULT_BLOCKING_TIMEOUT = 30;      // default timeout value for blocking socket(connect, listen, sendto, recvfrom) : 30 seconds
+
+static const Tizen::Base::String LOOPBACK_ADDRESS = "127.0.0.1"; // loopback address
+
+const char* ConvertEventTypeToString(NetSocketEventType event);
+
+NetSocketClosedReason ConvertClosedReason(result errorCode);
+
+result ConvertGioStatus(GIOStatus giostatus);
+
+result ConvertErrorToResult(int err);
+
+enum _SocketMethodFlag
+{
+       FLAG_NONE = 0,
+       FLAG_CONSTRUCT,
+       FLAG_CONNECT,
+       FLAG_LISTEN,
+       FLAG_SENDTO,
+       FLAG_RECEIVEFROM,
+       FLAG_CLOSE
+};
+
+// SOCKET OPTION LEVEL
+// static const int NET_SOCKET_SOL_PROTO = 4;
+// SOCKET OPTION NAME
+// static const int NET_SOCKET_SO_PROTOBEARER = 28;
+
+/**
+ * @enum    _SecureSocketVerify
+ * Defines the type of secure socket verify events.
+ *
+ * @since 2.1
+ */
+enum _SecureSocketVerify
+{
+       SECURE_SOCKET_VERIFY_NONE,
+       SECURE_SOCKET_VERIFY_ENABLE,
+       SECURE_SOCKET_VERIFY_DISABLE
+};
+
+class _Singleton
+{
+public:
+    /**
+     * Destroy system variables for SecureSocket.
+     */
+    static void DestroySecureSocket(void);
+
+    /**
+     * Once block for thread-safe singleton.
+     */
+    static void InitializeSecureSocketOnce(void);
+
+    /**
+     * Initialize system variables for SecureSocket.
+     */
+    static void InitializeSecureSocket(void);
+
+    /**
+     * Gets sslMap
+     *
+     * @return      The certificate map
+     */
+    static Tizen::Base::Collection::HashMap* GetSslMap(void);
+
+    static bool GetInitialized(void);
+
+
+private:
+    /**
+     * This is the default constructor for this class.
+     */
+    _Singleton(void);
+
+    /**
+     * This is the destructor for this class.
+     */
+    virtual ~_Singleton(void);
+
+private:
+    static bool __initialized;
+    static Tizen::Base::Collection::HashMap* __pSslMap;
+};  // _Singleton
+
+} } }   // Tizen::Net::Sockets
+#endif // _FNET_SOCK_SOCKET_INTERNAL_HELP_H_
diff --git a/src/sockets/FNetSock_SocketManagedNetConnectionEventListenerImpl.cpp b/src/sockets/FNetSock_SocketManagedNetConnectionEventListenerImpl.cpp
new file mode 100644 (file)
index 0000000..5b7bcfd
--- /dev/null
@@ -0,0 +1,270 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file           FNetSock_SocketManagedNetConnectionEventListenerImpl.cpp
+ * @brief              This is the implementation file for _SocketManagedNetConnectionEventListener class.
+ * @version        2.1
+ *
+ * This file contains the implementation of _SocketManagedNetConnectionEventListener class.
+ */
+
+#include <unistd.h>
+#include <errno.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FNetNetConnectionInfo.h>
+#include <FBase_StringConverter.h>
+#include "FNet_NetConnectionInfoImpl.h"
+#include "FNetSock_SocketEventArg.h"
+#include "FNetSock_SocketManagedNetConnectionEventListenerImpl.h"
+
+using namespace Tizen::Net;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+_SocketManagedNetConnectionEventListener::_SocketManagedNetConnectionEventListener(void)
+       : __isStarted(false)
+       , __isStopped(false)
+       , __pNetConnectionInfo(null)
+       , __socketFd(INVALID_HANDLE)
+       , __backLog(-1)
+       , __flag(FLAG_NONE)
+       , __pSocketImpl(null)
+       , __pSocketEvent(null)
+{
+       memset(&__remoteAddr, 0, sizeof(__remoteAddr));
+       __remoteAddr.sin_family = AF_INET;
+       __remoteAddr.sin_addr.s_addr = htonl(INADDR_ANY);
+       __remoteAddr.sin_port = htons(0);
+}
+
+_SocketManagedNetConnectionEventListener::~_SocketManagedNetConnectionEventListener(void)
+{
+       __pSocketEvent = null;
+       __pSocketImpl = null;
+       __flag = FLAG_NONE;
+       __backLog = -1;
+       __socketFd = INVALID_HANDLE;
+       __pNetConnectionInfo = null;
+       __isStopped = false;
+       __isStarted = false;
+}
+
+void
+_SocketManagedNetConnectionEventListener::OnManagedNetConnectionBearerChanged(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener - OnManagedNetConnectionBearerChanged - Enter");
+
+       SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener - OnManagedNetConnectionBearerChanged - End");
+}
+
+void
+_SocketManagedNetConnectionEventListener::OnManagedNetConnectionStarted(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener - OnManagedNetConnectionStarted - Enter");
+
+       __isStarted = true;
+       __isStopped = false;
+
+       const _NetConnectionInfoImpl* pNCInfoImpl = null;
+       String deviceName;
+       char* pDeviceName = null;
+       int err = 0;
+
+       __pNetConnectionInfo = managedNetConnection.GetNetConnectionInfo();
+       if (__pNetConnectionInfo == null)
+       {
+               SysLogException(NID_NET_SOCK, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] NetConnectionInfo is null. Failed to ManagedNetConnection GetNetConnectionInfo.");
+       }
+       else
+       {
+               pNCInfoImpl = _NetConnectionInfoImpl::GetInstance(*__pNetConnectionInfo);
+
+               deviceName = pNCInfoImpl->GetDeviceName();
+
+               if (deviceName.IsEmpty())
+               {
+                       SysLog(NID_NET_SOCK, "DeviceName is empty string. - Emulator Case");
+               }
+               else
+               {
+                       SysLog(NID_NET_SOCK, "DeviceName is not empty string.[Device Name : %ls] - Target Case", deviceName.GetPointer());
+
+                       pDeviceName = _StringConverter::CopyToCharArrayN(deviceName);
+                       SysTryReturnVoidResult(NID_NET_SOCK, pDeviceName != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+                       err = setsockopt(__socketFd, SOL_SOCKET, SO_BINDTODEVICE, pDeviceName, strlen(pDeviceName) + 1);
+                       delete[] pDeviceName;
+                       if (err < 0)
+                       {
+                               ConvertErrorToResult(errno);
+
+                               SysLogException(NID_NET_SOCK, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] Device Name binding is Failed.");
+                       }
+               }
+       }
+
+       switch (__flag)
+       {
+       case FLAG_CONSTRUCT:
+               SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener::OnManagedNetConnectionStarted - Construct");
+               break;
+
+       case FLAG_CONNECT:
+               SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener::OnManagedNetConnectionStarted - Connect");
+               err = connect(__socketFd, (struct sockaddr*) &__remoteAddr, sizeof(__remoteAddr));
+               break;
+
+       case FLAG_LISTEN:
+               SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener::OnManagedNetConnectionStarted - Listen");
+               err = listen(__socketFd, __backLog);
+               break;
+
+       case FLAG_SENDTO:
+               SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener::OnManagedNetConnectionStarted - SendTo");
+               break;
+
+       case FLAG_RECEIVEFROM:
+               SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener::OnManagedNetConnectionStarted - ReceiveFrom");
+               break;
+
+       default:
+               break;
+       }
+
+       SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener - OnManagedNetConnectionStarted - End");
+}
+
+void
+_SocketManagedNetConnectionEventListener::OnManagedNetConnectionStopped(ManagedNetConnection& managedNetConnection, NetConnectionStoppedReason reason)
+{
+       SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener - OnManagedNetConnectionStopped - Enter");
+
+       __isStarted = false;
+       __isStopped = true;
+
+       int sockFd = INVALID_HANDLE;
+
+       _SocketEventArg* pSocketEventArg = null;
+
+       switch (__flag)
+       {
+       case FLAG_CONSTRUCT:
+               SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener::OnManagedNetConnectionStopped - Construct");
+               break;
+
+       case FLAG_CONNECT:
+               SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener::OnManagedNetConnectionStopped - Connect");
+               break;
+
+       case FLAG_LISTEN:
+               SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener::OnManagedNetConnectionStopped - Listen");
+               break;
+
+       case FLAG_SENDTO:
+               SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener::OnManagedNetConnectionStopped - SendTo");
+               break;
+
+       case FLAG_RECEIVEFROM:
+               SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener::OnManagedNetConnectionStopped - ReceiveFrom");
+               break;
+
+       default:
+               break;
+       }
+
+       pSocketEventArg = new (std::nothrow) _SocketEventArg(__pSocketImpl->__socketFd, NET_SOCKET_EVENT_CLOSE);
+       SysTryReturnVoidResult(NID_NET_SOCK, pSocketEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       pSocketEventArg->SetError(E_NETWORK_UNAVAILABLE);
+       __pSocketEvent->Fire(*pSocketEventArg);
+
+       if (__pSocketImpl->__pGlibSocketInfo != null)
+       {
+               delete __pSocketImpl->__pGlibSocketInfo;
+               __pSocketImpl->__pGlibSocketInfo = null;
+       }
+
+       if (__pSocketImpl->__socketFd > INVALID_HANDLE)
+       {
+               sockFd = __pSocketImpl->__socketFd;
+               close(__pSocketImpl->__socketFd);
+               __pSocketImpl->__socketFd = INVALID_HANDLE;
+               SysLog(NID_NET_HTTP, "### SocketFd(%d) was closed..", sockFd);
+       }
+
+       SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener - OnManagedNetConnectionStopped - End");
+}
+
+void
+_SocketManagedNetConnectionEventListener::OnManagedNetConnectionSuspended(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener - OnManagedNetConnectionSuspended - Enter");
+
+       SysLog(NID_NET_SOCK, "_SocketManagedNetConnectionEventListener - OnManagedNetConnectionSuspended - End");
+}
+
+void
+_SocketManagedNetConnectionEventListener::OnManagedNetConnectionResumed(ManagedNetConnection& managedNetConnection)
+{
+       SysLog(NID_NET_SOCK, "__SockDefaultNetConnectionListener - OnManagedNetConnectionResumed - Enter");
+
+       SysLog(NID_NET_SOCK, "__SockDefaultNetConnectionListener - OnManagedNetConnectionResumed - End");
+}
+
+void
+_SocketManagedNetConnectionEventListener::SetConstructParams(_SocketEvent* __pSocketEventSet, HSocket __socketFdSet, _SocketMethodFlag flagSet, _SocketImpl* __pSocketImplSet)
+{
+       __pSocketEvent = __pSocketEventSet;
+       __socketFd = __socketFdSet;
+       __flag = flagSet;
+       __pSocketImpl = __pSocketImplSet;
+}
+
+void
+_SocketManagedNetConnectionEventListener::SetConnectParams(HSocket __socketFdSet, sockaddr_in remoteAddrSet, _SocketMethodFlag flagSet)
+{
+       __socketFd = __socketFdSet;
+       __remoteAddr = remoteAddrSet;
+       __flag = flagSet;
+}
+
+void
+_SocketManagedNetConnectionEventListener::SetListenParams(HSocket __socketFdSet, int backLogSet, _SocketMethodFlag flagSet)
+{
+       __socketFd = __socketFdSet;
+       __backLog = backLogSet;
+       __flag = flagSet;
+}
+
+void
+_SocketManagedNetConnectionEventListener::SetSendToParams(HSocket __socketFdSet, _SocketMethodFlag flagSet)
+{
+       __socketFd = __socketFdSet;
+       __flag = flagSet;
+}
+
+void
+_SocketManagedNetConnectionEventListener::SetReceiveFromParams(HSocket __socketFdSet, _SocketMethodFlag flagSet)
+{
+       __socketFd = __socketFdSet;
+       __flag = flagSet;
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/sockets/FNetSock_SocketManagedNetConnectionEventListenerImpl.h b/src/sockets/FNetSock_SocketManagedNetConnectionEventListenerImpl.h
new file mode 100644 (file)
index 0000000..a56e824
--- /dev/null
@@ -0,0 +1,176 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketManagedNetConnectionEventListenerImpl.h
+ * @brief              This is the header file for _SocketManagedNetConnectionListener class.
+ * @version            2.1
+ *
+ * This header file contains the declarations of _SocketManagedNetConnectionEventListener class.
+ * The _SocketManagedNetConnectionEventListener class can call listener's method. So, when an event is occurred,
+ * application can handle it appropriately.
+ */
+
+#ifndef _FNET_SOCK_INTERNAL_SOCKET_MANAGED_NET_CONNECTION_EVENT_LISTENER_H_
+#define _FNET_SOCK_INTERNAL_SOCKET_MANAGED_NET_CONNECTION_EVENT_LISTENER_H_
+
+#include <netinet/in.h>
+#include <FNetManagedNetConnection.h>
+#include <FNetIManagedNetConnectionEventListener.h>
+#include "FNetSock_SocketInternalHelp.h"
+#include "FNetSock_SocketEvent.h"
+
+namespace Tizen { namespace Net
+{
+
+class NetConnectionInfo;
+} } // Tizen::Net
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+class _SocketImpl;
+/**
+ * @class      _SocketManagedNetConnectionEventListener FNetSock_SocketManagedNetConnectionEventListener.h "OspdOaf/FNet/H/FNetSock_SocketManagedNetConnectionEventListener.h"
+ * @brief      This class is the listener for network connection events.
+ *
+ * @since 2.1
+ *
+ * The _SocketManagedNetConnectionEventListener class specifies the methods used for notifying different kinds
+ * of network connection events. These events are only sent out when ManagedNetConnectionEventListener is added to the ManagedNetConnection instance,
+ * and this is done by invoking the SetManagedNetConnectionEventListener() method.
+ * When a network connection event is generated, a method of this interface is called.
+ * Thus, if an application does any job related to network connection events, override and use methods of this interface.
+ */
+
+class _SocketManagedNetConnectionEventListener
+       : public Tizen::Net::IManagedNetConnectionEventListener
+       , virtual public Tizen::Base::Runtime::IEventListener
+{
+
+
+public:
+       _SocketManagedNetConnectionEventListener(void);
+
+       virtual ~_SocketManagedNetConnectionEventListener(void);
+
+
+public:
+       /**
+        * Called to notify that the bearer has been changed. @n
+        * An application can send or receive the data through the Socket or HTTP methods and can obtain the information related to the changed bearer.
+        *
+        * @since               2.0
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       void OnManagedNetConnectionBearerChanged(Tizen::Net::ManagedNetConnection& managedNetConnection);
+
+       /**
+        * Called to notify the application that the network connection has been opened and connected. @n
+        * An application can then send or receive the data.
+        *
+        * @since                       2.0
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       void OnManagedNetConnectionStarted(Tizen::Net::ManagedNetConnection& managedNetConnection);
+
+       /**
+        * Called to notify that the network connection has been closed and disconnected.
+        *
+        * @since               2.0
+        * @param[in]   managedNetConnection                                                            The network connection managed by the system
+        * @param[in]   reason                                                                                          A reason code for the error
+        * @exception   NET_CONNECTION_STOPPED_REASON_RESOURCE_RELEASED         The network connection managed by the system has stopped because network resources have been released.
+        * @exception   NET_CONNECTION_STOPPED_REASON_NETWORK_FAILED            The network has failed.
+        * @exception   NET_CONNECTION_STOPPED_REASON_DEVICE_OFFLINE            The device is in the offline mode.
+        * @exception   NET_CONNECTION_STOPPED_REASON_SERVICE_UNAVAILABLE       The device is out of the coverage area or in an emergency mode.
+        * @exception   NET_CONNECTION_STOPPED_REASON_RESOURCE_UNAVAILABLE      The network resource is unavailable.
+        * @exception   NET_CONNECTION_STOPPED_REASON_SYSTEM                            A system error has occurred.
+        *
+        */
+       void OnManagedNetConnectionStopped(Tizen::Net::ManagedNetConnection& managedNetConnection, Tizen::Net::NetConnectionStoppedReason reason);
+
+       /**
+        * Called to notify the application that the connection status has been changed or is in an unstable or suspended state. @n
+        * Thus an application may neither send nor receive data through the Socket or Http until the network connection is resumed.
+        *
+        * @since               2.0
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       void OnManagedNetConnectionSuspended(Tizen::Net::ManagedNetConnection& managedNetConnection);
+
+       /**
+        * Called to notify the application that the network has recovered from a suspended state. @n
+        * Thus an application can send or receive data through the Socket or Http from now on.
+        *
+        * @since               2.0
+        * @param[in]   managedNetConnection    The network connection managed by the system
+        */
+       void OnManagedNetConnectionResumed(Tizen::Net::ManagedNetConnection& managedNetConnection);
+
+       // Set Params
+       void SetConstructParams(_SocketEvent* __pSocketEventSet, HSocket __socketFdSet, _SocketMethodFlag flagSet, _SocketImpl* __pSocketImplSet);
+
+       void SetConnectParams(HSocket __socketFdSet, sockaddr_in remoteAddrSet, _SocketMethodFlag flagSet);
+
+       void SetListenParams(HSocket __socketFdSet, int backLogSet, _SocketMethodFlag flagSet);
+
+       void SetSendToParams(HSocket __socketFdSet, _SocketMethodFlag flagSet);
+
+       void SetReceiveFromParams(HSocket __socketFdSet, _SocketMethodFlag flagSet);
+
+
+private:
+       /**
+        * This is the copy constructor.
+        *
+        * @param[in]   value   An instance of _SocketManagedNetConnectionEventListener
+        * @remarks             The function is declared but not implemented.
+        */
+       _SocketManagedNetConnectionEventListener(const _SocketManagedNetConnectionEventListener& value);
+
+
+private:
+       /**
+        * This is the assignment operator.
+        *
+        * @param[in]   rhs             An instance of _SocketManagedNetConnectionEventListener
+        * @remarks             The function is declared but not implemented.
+        */
+       _SocketManagedNetConnectionEventListener& operator =(const _SocketManagedNetConnectionEventListener& rhs);
+
+
+private:
+       bool __isStarted;
+       bool __isStopped;
+
+       const NetConnectionInfo* __pNetConnectionInfo;
+       HSocket __socketFd;
+       sockaddr_in __remoteAddr;
+
+       int __backLog;
+       _SocketMethodFlag __flag;
+
+       _SocketImpl* __pSocketImpl;
+
+       _SocketEvent* __pSocketEvent;
+
+       friend class _SocketImpl;
+}; // _SocketManagedNetConnectionEventListener
+
+} } } // Tizen::Net::Sockets
+
+#endif // _FNET_SOCK_INTERNAL_SOCKET_MANAGED_NET_CONNECTION_EVENT_LISTENER_H_
diff --git a/src/sockets/FNetSock_SocketUtilityImpl.cpp b/src/sockets/FNetSock_SocketUtilityImpl.cpp
new file mode 100644 (file)
index 0000000..4d49676
--- /dev/null
@@ -0,0 +1,375 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetSock_SocketUtilityImpl.cpp
+ * @brief              This is the implementation for the _SocketUtilityImpl class.
+ */
+
+#include <arpa/inet.h>
+#include <sys/select.h>
+#include <sys/time.h>
+#include <errno.h>
+#include <FNetSockSocket.h>
+#include <FNetSockSecureSocket.h>
+#include <FNetSockSocketUtility.h>
+#include <FBaseSysLog.h>
+#include "FNetSock_SocketImpl.h"
+#include "FNetSock_SecureSocketImpl.h"
+#include "FNetSock_SocketUtilityImpl.h"
+#include "FNetSock_SocketInternalHelp.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Net;
+
+namespace Tizen { namespace Net { namespace Sockets
+{
+
+_SocketUtilityImpl::_SocketUtilityImpl(void)
+       : __isConstructed(false)
+{
+}
+
+_SocketUtilityImpl::~_SocketUtilityImpl(void)
+{
+}
+
+result
+_SocketUtilityImpl::Construct(void)
+{
+       SysAssertf(__isConstructed == false, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       __isConstructed = true;
+
+       return E_SUCCESS;
+}
+
+result
+_SocketUtilityImpl::Select(IList* pCheckRead, IList* pCheckWrite, IList* pCheckError, int microSeconds)
+{
+    SysAssertf(__isConstructed == true, "Not yet constructed. Construct() should be called before use.");
+
+       SysTryReturnResult(NID_NET_SOCK, (pCheckRead != null) || (pCheckWrite != null) || (pCheckError != null), E_INVALID_ARG, "All three descriptor parameters were null.");
+
+       result r = E_SUCCESS;
+
+       int nFds = 0;
+       fd_set readFds;
+       fd_set writeFds;
+       fd_set errorFds;
+
+       int ret = 0;
+
+       struct timeval timeout;
+
+       FD_ZERO(&readFds);
+       FD_ZERO(&writeFds);
+       FD_ZERO(&errorFds);
+
+       if (pCheckRead != null)
+       {
+               int count = pCheckRead->GetCount();
+               for (int i = 0; i < count; i++)
+               {
+                       Socket* pSocket = dynamic_cast <Socket*>(pCheckRead->GetAt(i));
+                       SecureSocket* pSecSocket = dynamic_cast <SecureSocket*>(pCheckRead->GetAt(i));
+                       SysTryReturnResult(NID_NET_SOCK, (pSocket != null) || (pSecSocket != null), E_INVALID_ARG, "The given collection contains an element of incompatible class type.");
+               }
+
+               r = IListToSocketFdSet(*pCheckRead, &readFds, nFds);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to pCheckRead IListToSocketFdSet.");
+       }
+       if (pCheckWrite != null)
+       {
+               int count = pCheckWrite->GetCount();
+               for (int i = 0; i < count; i++)
+               {
+                       Socket* pSocket = dynamic_cast <Socket*>(pCheckWrite->GetAt(i));
+                       SecureSocket* pSecSocket = dynamic_cast <SecureSocket*>(pCheckWrite->GetAt(i));
+                       SysTryReturnResult(NID_NET_SOCK, (pSocket != null) || (pSecSocket != null), E_INVALID_ARG, "The given collection contains an element of incompatible class type.");
+               }
+
+               r = IListToSocketFdSet(*pCheckWrite, &writeFds, nFds);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to pCheckWrite IListToSocketFdSet.");
+       }
+       if (pCheckError != null)
+       {
+               int count = pCheckError->GetCount();
+               for (int i = 0; i < count; i++)
+               {
+                       Socket* pSocket = dynamic_cast <Socket*>(pCheckError->GetAt(i));
+                       SecureSocket* pSecSocket = dynamic_cast <SecureSocket*>(pCheckError->GetAt(i));
+                       SysTryReturnResult(NID_NET_SOCK, (pSocket != null) || (pSecSocket != null), E_INVALID_ARG, "The given collection contains an element of incompatible class type.");
+               }
+
+               r = IListToSocketFdSet(*pCheckError, &errorFds, nFds);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to pCheckError IListToSocketFdSet.");
+       }
+
+       if (microSeconds < _MIN_SELECT_TIMEOUT)     // If timeout value is lesser than MINIMUN value - set to minimum value by force
+       {
+               microSeconds = _MIN_SELECT_TIMEOUT;
+       }
+
+       timeout.tv_sec = microSeconds / 1000000;
+       timeout.tv_usec = microSeconds % 1000000;
+
+       ret = select(nFds + 1, &readFds, &writeFds, &errorFds, &timeout);
+       if (ret < 0)
+       {
+               // Error code mapping
+               switch (errno)
+               {
+               case EBADF:     // An invalid file descriptor was given in one of the sets. (Perhaps a file descriptor that was already closed, or one on which an error has occurred.)
+                       r = E_INVALID_SOCKET;
+                       break;
+
+               case EINTR:     // A signal was caught.
+                       r = E_SYSTEM;
+                       break;
+
+               case EINVAL:    // nFds is negative or the value contained within timeout is invalid.
+                       r = E_INVALID_ARG;
+                       break;
+
+               case ENOMEM:    // Unable to allocate memory for internal tables.
+                       r = E_OUT_OF_MEMORY;
+                       break;
+
+               default:
+                       r = E_SYSTEM;
+                       break;
+               }
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to SocketUtility Select().");
+       }
+       else if (ret == 0)
+       {
+               r = E_TIMEOUT;
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to SocketUtility Select().");
+       }
+
+       if (pCheckRead != null)
+       {
+               SysLog(NID_NET_SOCK, "pCheckRead SocketFdSetToIList()");
+               r = SocketFdSetToIList(&readFds, *pCheckRead);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to readFds SocketFdSetToIList.");
+       }
+
+       if (pCheckWrite != null)
+       {
+               SysLog(NID_NET_SOCK, "pCheckWrite SocketFdSetToIList()");
+               r = SocketFdSetToIList(&writeFds, *pCheckWrite);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to writeFds SocketFdSetToIList.");
+       }
+
+       if (pCheckError != null)
+       {
+               SysLog(NID_NET_SOCK, "pCheckError SocketFdSetToIList()");
+               r = SocketFdSetToIList(&errorFds, *pCheckError);
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, r, "Failed to errorFds SocketFdSetToIList.");
+       }
+
+       SysLog(NID_NET_SOCK, "SocketUtility Select() is succeed.");
+
+       return E_SUCCESS;
+}
+
+unsigned short
+_SocketUtilityImpl::HtoNS(unsigned short hostShort)
+{
+       ClearLastResult();
+
+       SysAssertf(__isConstructed != false, "Not Constructed yet or Invocation of the method is not right in this state.");
+
+       return (uint16_t) htons((uint16_t) hostShort);
+}
+
+unsigned long
+_SocketUtilityImpl::HtoNL(unsigned long hostLong)
+{
+       ClearLastResult();
+
+    SysAssertf(__isConstructed != false, "Not Constructed yet or Invocation of the method is not right in this state.");
+
+       return (uint32_t) htonl((uint32_t) hostLong);
+}
+
+unsigned short
+_SocketUtilityImpl::NtoHS(unsigned short netShort)
+{
+       ClearLastResult();
+
+    SysAssertf(__isConstructed != false, "Not Constructed yet or Invocation of the method is not right in this state.");
+
+       return (uint16_t) ntohs((uint16_t) netShort);
+}
+
+unsigned long
+_SocketUtilityImpl::NtoHL(unsigned long netLong)
+{
+       ClearLastResult();
+
+    SysAssertf(__isConstructed != false, "Not Constructed yet or Invocation of the method is not right in this state.");
+
+       return (uint32_t) ntohl((uint32_t) netLong);
+}
+
+result
+_SocketUtilityImpl::IListToSocketFdSet(const Tizen::Base::Collection::IList& iList, fd_set* pSet, int& nFds)
+{
+       result r = E_SUCCESS;
+
+       int index = 0;
+       int count = 0;
+
+       Socket* pSocket = null;
+       _SocketImpl* pSocketImpl = null;
+       SecureSocket* pSecSocket = null;
+       _SecureSocketImpl* pSecSocketImpl = null;
+       IList* pList = null;
+       Object* pObj = null;
+
+       int sockFd = INVALID_HANDLE;
+
+       FD_ZERO(pSet);
+
+       count = iList.GetCount();
+
+       if (count > 0)
+       {
+               pList = iList.GetItemsN(index, count);
+               r = GetLastResult();
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_INVALID_ARG, "pList is a empty.");
+       }
+
+       for (int i = 0; i < count; i++)
+       {
+               pObj = pList->GetAt(i);
+
+               pSocket = dynamic_cast <Socket*>(pObj);
+               pSecSocket = dynamic_cast <SecureSocket*>(pObj);
+               SysTryReturnResult(NID_NET_SOCK, (pSocket != null) || (pSecSocket != null), E_SYSTEM, "The socket is null.");
+
+               if (pSocket != null)
+               {
+                       pSocketImpl = _SocketImpl::GetInstance(*pSocket);
+                       sockFd = pSocketImpl->GetSocketFd();
+                       nFds = sockFd;
+                       (void) FD_SET(sockFd, pSet);
+               }
+
+               if (pSecSocket != null)
+               {
+                       pSecSocketImpl = _SecureSocketImpl::GetInstance(*pSecSocket);
+                       sockFd = pSecSocketImpl->GetSecureSocketFd();
+                       nFds = sockFd;
+                       (void) FD_SET(sockFd, pSet);
+               }
+       }
+
+       if(pList != null)
+       {
+               delete pList;
+               pList = null;
+       }
+
+       return r;
+}
+
+result
+_SocketUtilityImpl::SocketFdSetToIList(const fd_set* pSet, Tizen::Base::Collection::IList& iList)
+{
+       result r = E_SUCCESS;
+
+       int index = 0;
+       int count = 0;
+
+       Socket* pSocket = null;
+       _SocketImpl* pSocketImpl = null;
+       SecureSocket* pSecSocket = null;
+       _SecureSocketImpl* pSecSocketImpl = null;
+       IList* pList = null;
+       Object* pObj = null;
+
+       int sockFd = INVALID_HANDLE;
+
+       count = iList.GetCount();
+
+       if (count > 0)
+       {
+               pList = iList.GetItemsN(index, count);
+               r = GetLastResult();
+               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_INVALID_ARG, "pList is a empty.");
+       }
+
+       for (int i = 0; i < count; i++)
+       {
+               pObj = pList->GetAt(i);
+
+               pSocket = dynamic_cast <Socket*>(pObj);
+               pSecSocket = dynamic_cast <SecureSocket*>(pObj);
+               SysTryReturnResult(NID_NET_SOCK, (pSocket != null) || (pSecSocket != null), E_SYSTEM, "The socket is null.");
+
+               if (pSocket != null)
+               {
+                       pSocketImpl = _SocketImpl::GetInstance(*pSocket);
+                       sockFd = pSocketImpl->GetSocketFd();
+                       if (!(FD_ISSET(sockFd, pSet)))
+                       {
+                               SysLog(NID_NET_SOCK, "Remove pObj in iList.");
+                               r = iList.Remove(*pObj);
+                               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_INVALID_ARG, "iList is a empty.");
+                       }
+               }
+
+               if (pSecSocket != null)
+               {
+                       pSecSocketImpl = _SecureSocketImpl::GetInstance(*pSecSocket);
+                       sockFd = pSecSocketImpl->GetSecureSocketFd();
+                       if (!(FD_ISSET(sockFd, pSet)))
+                       {
+                               SysLog(NID_NET_SOCK, "Remove pObj in iList.");
+                               r = iList.Remove(*pObj);
+                               SysTryReturnResult(NID_NET_SOCK, r == E_SUCCESS, E_INVALID_ARG, "iList is a empty.");
+                       }
+               }
+       }
+
+       if (pList != null)
+       {
+               delete pList;
+               pList = null;
+       }
+
+       return r;
+}
+
+_SocketUtilityImpl*
+_SocketUtilityImpl::GetInstance(SocketUtility& socketUtility)
+{
+       return socketUtility.__pSocketUtilityImpl;
+}
+
+const _SocketUtilityImpl*
+_SocketUtilityImpl::GetInstance(const SocketUtility& socketUtility)
+{
+       return socketUtility.__pSocketUtilityImpl;
+}
+
+} } } // Tizen::Net::Sockets
diff --git a/src/wifi/CMakeLists.txt b/src/wifi/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..4d0340b
--- /dev/null
@@ -0,0 +1,102 @@
+SET (this_target osp-wifi)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR}/inc
+       ${CMAKE_SOURCE_DIR}/src/inc
+       /usr/include/chromium
+       /usr/include/glib-2.0 
+       /usr/lib/glib-2.0/include
+       /usr/include/network
+       /usr/include/osp
+       /usr/include/osp/base
+       /usr/include/osp/io
+       /usr/include/osp/security
+       /usr/include/osp/system
+       /usr/include/system
+       /usr/include/vconf
+       /usr/include/wifi-direct        
+    )
+
+SET (${this_target}_SOURCE_FILES
+    FNetWifiWifiManager.cpp
+    FNetWifi_WifiManagerImpl.cpp
+    FNetWifi_WifiSystemAdapter.cpp
+    FNetWifi_WifiManagerEvent.cpp
+    FNetWifi_WifiManagerEventArg.cpp
+    FNetWifi_WifiSystemMonitoringEvent.cpp
+    FNetWifi_WifiSystemMonitoringEventArg.cpp
+    FNetWifiWifiNetAccountInfo.cpp
+    FNetWifi_WifiNetAccountInfoImpl.cpp
+    FNetWifiWifiSecurityInfo.cpp
+    FNetWifiWifiBssInfo.cpp
+    FNetWifi_WifiBssInfoImpl.cpp
+    FNetWifi_WifiSecurityInfoImpl.cpp
+    FNetWifi_WifiUtility.cpp
+    FNetWifi_WifiProximityManagerImpl.cpp
+    FNetWifiWifiDirectDeviceManager.cpp
+    FNetWifiWifiDirectDevice.cpp
+    FNetWifiWifiDirectGroupMember.cpp
+    FNetWifiWifiDirectGroupOwner.cpp    
+    FNetWifiWifiDirectGroupClient.cpp
+    FNetWifiWifiDirectGroupInfo.cpp
+    FNetWifiWifiDirectDeviceInfo.cpp
+    FNetWifi_WifiDirectDeviceManagerImpl.cpp
+    FNetWifi_WifiDirectDeviceImpl.cpp
+    FNetWifi_WifiDirectGroupOwnerImpl.cpp
+    FNetWifi_WifiDirectGroupClientImpl.cpp
+    FNetWifi_WifiDirectGroupInfoImpl.cpp
+    FNetWifi_WifiDirectDeviceInfoImpl.cpp
+    FNetWifi_WifiDirectSystemAdapter.cpp
+    FNetWifi_WifiDirectEvent.cpp
+    FNetWifi_WifiDirectDeviceEvent.cpp
+    FNetWifi_WifiDirectGroupOwnerEvent.cpp
+    FNetWifi_WifiDirectGroupClientEvent.cpp
+    FNetWifi_WifiDirectEventArg.cpp
+    FNetWifi_WifiDirectUtility.cpp
+    FNetWifi_WifiIpcMessages.cpp
+    FNetWifi_WifiIpcProxy.cpp
+)
+
+SET(EXTRA_CFLAGS  "${EXTRA_CFLAGS} -Wall" )
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## Create Library
+ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+## SET DEPENDENCY FLAGS
+ADD_DEPENDENCIES(${this_target} osp-net)
+
+## SET LINKER FLAGS
+SET(CMAKE_SHARED_LINKER_FLAGS -Wl,--no-undefined)
+
+TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw" )
+TARGET_LINK_LIBRARIES(${this_target} "-losp-net" )
+TARGET_LINK_LIBRARIES(${this_target} "-lpthread" )
+TARGET_LINK_LIBRARIES(${this_target} "-lchromium" )
+TARGET_LINK_LIBRARIES(${this_target} "-lvconf" )
+TARGET_LINK_LIBRARIES(${this_target} "-lglib-2.0" )
+TARGET_LINK_LIBRARIES(${this_target} "-lnetwork" )
+TARGET_LINK_LIBRARIES(${this_target} "-lwifi-direct" )
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-network-wifi" ) 
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-network-connection" ) 
+
+SET_TARGET_PROPERTIES(${this_target} 
+       PROPERTIES 
+       VERSION ${FULLVER}
+       SOVERSION ${MAJORVER}
+       CLEAN_DIRECT_OUTPUT 1
+       )
+
+ADD_CUSTOM_COMMAND(TARGET ${this_target}
+    POST_BUILD
+               COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} 
+               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${MAJORVER}
+               COMMAND ${CMAKE_STRIP} --strip-unneeded ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}
+    COMMENT "strip ${this_target}"
+               )   
diff --git a/src/wifi/FNetWifiWifiBssInfo.cpp b/src/wifi/FNetWifiWifiBssInfo.cpp
new file mode 100644 (file)
index 0000000..7a4f43c
--- /dev/null
@@ -0,0 +1,245 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifiWifiBssInfo.cpp
+ * @brief   This is the implementation file for the WifiBssInfo Class.
+ *
+ * This file contains the implementation of the WifiBssInfo Class.
+ */
+
+#include <FNetWifiWifiSecurityInfo.h>
+#include <FNetWifiWifiBssInfo.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiBssInfoImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+WifiBssInfo::WifiBssInfo(void)
+{
+    __pWifiBssInfoImpl = new (std::nothrow) _WifiBssInfoImpl();
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiBssInfoImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+WifiBssInfo::WifiBssInfo(const WifiBssInfo& value)
+{
+    __pWifiBssInfoImpl = new (std::nothrow) _WifiBssInfoImpl(*(value.__pWifiBssInfoImpl));
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiBssInfoImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+WifiBssInfo::~WifiBssInfo(void)
+{
+    if (__pWifiBssInfoImpl)
+    {
+        delete __pWifiBssInfoImpl;
+        __pWifiBssInfoImpl = null;
+    }
+}
+
+WifiBssInfo&
+WifiBssInfo::operator=(const WifiBssInfo& rhs)
+{
+    if (this != &rhs)
+    {
+       * __pWifiBssInfoImpl = *(rhs.__pWifiBssInfoImpl);
+    }
+
+    return *this;
+}
+
+String
+WifiBssInfo::GetBssId(void) const
+{
+    return __pWifiBssInfoImpl->GetBssId();
+}
+
+String
+WifiBssInfo::GetSsid(void) const
+{
+    return __pWifiBssInfoImpl->GetSsid();
+}
+
+WifiBssType
+WifiBssInfo::GetBssType(void) const
+{
+    return __pWifiBssInfoImpl->GetBssType();
+}
+
+const WifiSecurityInfo*
+WifiBssInfo::GetSecurityInfo(void) const
+{
+    return __pWifiBssInfoImpl->GetSecurityInfo();
+}
+
+WifiRadioChannel
+WifiBssInfo::GetRadioChannel(void) const
+{
+    return __pWifiBssInfoImpl->GetRadioChannel();
+}
+
+long
+WifiBssInfo::GetRssi(void) const
+{
+    return __pWifiBssInfoImpl->GetRssi();
+}
+
+float
+WifiBssInfo::GetDataRate(void) const
+{
+    return __pWifiBssInfoImpl->GetDataRate();
+}
+
+void
+WifiBssInfo::SetSsid(const String& ssid)
+{
+    __pWifiBssInfoImpl->SetSsid(ssid);
+}
+
+bool
+WifiBssInfo::IsKnown(void) const
+{
+    return __pWifiBssInfoImpl->IsKnown();
+}
+
+void
+WifiBssInfo::SetUnknown(void)
+{
+       __pWifiBssInfoImpl->SetKnown(false);
+}
+
+Tizen::Net::NetAddressScheme
+WifiBssInfo::GetLocalAddressScheme(void) const
+{
+    return __pWifiBssInfoImpl->GetLocalAddressScheme();
+}
+
+void
+WifiBssInfo::SetLocalAddressScheme(Tizen::Net::NetAddressScheme scheme)
+{
+    __pWifiBssInfoImpl->SetLocalAddressScheme(scheme);
+}
+
+const Tizen::Net::IpAddress*
+WifiBssInfo::GetLocalAddress(void) const
+{
+    return __pWifiBssInfoImpl->GetLocalAddress();
+}
+
+result
+WifiBssInfo::SetLocalAddress(const Tizen::Net::IpAddress* pAddress)
+{
+    return __pWifiBssInfoImpl->SetLocalAddress(pAddress);
+}
+
+const Tizen::Net::IpAddress*
+WifiBssInfo::GetSubnetMaskAddress(void) const
+{
+    return __pWifiBssInfoImpl->GetSubnetMaskAddress();
+}
+
+result
+WifiBssInfo::SetSubnetMaskAddress(const Tizen::Net::IpAddress* pAddress)
+{
+    return __pWifiBssInfoImpl->SetSubnetMaskAddress(pAddress);
+}
+
+const Tizen::Net::IpAddress*
+WifiBssInfo::GetDefaultGatewayAddress(void) const
+{
+    return __pWifiBssInfoImpl->GetDefaultGatewayAddress();
+}
+
+result
+WifiBssInfo::SetDefaultGatewayAddress(const Tizen::Net::IpAddress* pAddress)
+{
+    return __pWifiBssInfoImpl->SetDefaultGatewayAddress(pAddress);
+}
+
+const Tizen::Net::IpAddress*
+WifiBssInfo::GetPrimaryDnsAddress(void) const
+{
+    return __pWifiBssInfoImpl->GetPrimaryDnsAddress();
+}
+
+result
+WifiBssInfo::SetPrimaryDnsAddress(const Tizen::Net::IpAddress* pAddress)
+{
+    return __pWifiBssInfoImpl->SetPrimaryDnsAddress(pAddress);
+}
+
+const Tizen::Net::IpAddress*
+WifiBssInfo::GetSecondaryDnsAddress(void) const
+{
+    return __pWifiBssInfoImpl->GetSecondaryDnsAddress();
+}
+
+result
+WifiBssInfo::SetSecondaryDnsAddress(const Tizen::Net::IpAddress* pAddress)
+{
+    return __pWifiBssInfoImpl->SetSecondaryDnsAddress(pAddress);
+}
+
+Tizen::Net::NetProxyType
+WifiBssInfo::GetProxyType(void) const
+{
+    return __pWifiBssInfoImpl->GetProxyType();
+}
+
+void
+WifiBssInfo::SetProxyType(Tizen::Net::NetProxyType type)
+{
+    __pWifiBssInfoImpl->SetProxyType(type);
+}
+
+Tizen::Base::String
+WifiBssInfo::GetProxyAddress(void) const
+{
+    return __pWifiBssInfoImpl->GetProxyAddress();
+}
+
+result
+WifiBssInfo::SetProxyAddress(const Tizen::Base::String& address)
+{
+    return __pWifiBssInfoImpl->SetProxyAddress(address);
+}
+
+bool
+WifiBssInfo::Equals(const Tizen::Base::Object& obj) const
+{
+    const WifiBssInfo* pOther = dynamic_cast<const WifiBssInfo*>(&obj);
+
+    if (pOther == null)
+    {
+        return false;
+    }
+
+    if (pOther == this)
+    {
+      return true;
+    }
+
+    return __pWifiBssInfoImpl->Equals(*pOther->__pWifiBssInfoImpl);
+}
+int
+WifiBssInfo::GetHashCode(void) const
+{
+    return __pWifiBssInfoImpl->GetHashCode();
+}
+
+} } } // Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifiWifiDirectDevice.cpp b/src/wifi/FNetWifiWifiDirectDevice.cpp
new file mode 100644 (file)
index 0000000..4043b5e
--- /dev/null
@@ -0,0 +1,580 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifiWifiDirectDevice.cpp
+ * @brief   This is the implementation file for the WifiDirectDevice Class.
+ *
+ * This file contains implementation of the WifiDirectDevice Class.
+ */
+
+#include <unique_ptr.h>
+#include <FNetWifiWifiDirectDevice.h>
+#include <FNetWifiIWifiDirectDeviceListener.h>
+#include <FNetWifiIWifiDirectGroupOwnerListener.h>
+#include <FNetWifiIWifiDirectGroupClientListener.h>
+#include <FNetWifiWifiDirectGroupInfo.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FNetWifi_WifiDirectUtility.h"
+#include "FNetWifi_WifiDirectDeviceImpl.h"
+
+using namespace std;
+using namespace Tizen::Security;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+WifiDirectDevice::~WifiDirectDevice(void)
+{
+    __pWifiDirectDeviceImpl->Release();
+}
+
+result
+WifiDirectDevice::AddWifiDirectDeviceListener(IWifiDirectDeviceListener &listener)
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    result r = __pWifiDirectDeviceImpl->AddWifiDirectDeviceListener(listener);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectDevice::AddWifiDirectGroupOwnerListener(IWifiDirectGroupOwnerListener &listener)
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    result r = __pWifiDirectDeviceImpl->AddWifiDirectGroupOwnerListener(listener);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectDevice::AddWifiDirectGroupClientListener(IWifiDirectGroupClientListener &listener)
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    result r = __pWifiDirectDeviceImpl->AddWifiDirectGroupClientListener(listener);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectDevice::RemoveWifiDirectDeviceListener(IWifiDirectDeviceListener &listener)
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    result r = __pWifiDirectDeviceImpl->RemoveWifiDirectDeviceListener(listener);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectDevice::RemoveWifiDirectGroupOwnerListener(IWifiDirectGroupOwnerListener &listener)
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    result r = __pWifiDirectDeviceImpl->RemoveWifiDirectGroupOwnerListener(listener);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectDevice::RemoveWifiDirectGroupClientListener(IWifiDirectGroupClientListener &listener)
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    result r = __pWifiDirectDeviceImpl->RemoveWifiDirectGroupClientListener(listener);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectDevice::Activate(void)
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_ADMIN);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    r = __pWifiDirectDeviceImpl->Activate();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+bool
+WifiDirectDevice::IsActivated(void) const
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    return __pWifiDirectDeviceImpl->IsActivated();
+}
+
+result
+WifiDirectDevice::Deactivate(void)
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_ADMIN);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    r = __pWifiDirectDeviceImpl->Deactivate();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+WifiDirectGroupInfo*
+WifiDirectDevice::GetGroupSettingInfoN(void) const
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    WifiDirectGroupInfo* pGroupInfo = null;
+    pGroupInfo = __pWifiDirectDeviceImpl->GetGroupSettingInfoN();
+
+    result r = GetLastResult();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return pGroupInfo;
+}
+
+WifiDirectDeviceInfo*
+WifiDirectDevice::GetLocalDeviceInfoN(void) const
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    WifiDirectDeviceInfo* pDeviceInfo = null;
+    pDeviceInfo = __pWifiDirectDeviceImpl->GetLocalDeviceInfoN();
+
+    result r = GetLastResult();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return pDeviceInfo;
+}
+
+WifiWpsConfigurationMode
+WifiDirectDevice::GetWpsConfigurationModePreference(void) const
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    WifiWpsConfigurationMode configMode = WIFI_WPS_CONFIG_MODE_NONE;
+
+    configMode = __pWifiDirectDeviceImpl->GetWpsConfigurationModePreference();
+
+    result r = GetLastResult();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return configMode;
+}
+
+result
+WifiDirectDevice::SetLocalDeviceName(const Tizen::Base::String &name)
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    result r = __pWifiDirectDeviceImpl->SetLocalDeviceName(name);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectDevice::SetWpsConfigurationModePreference(WifiWpsConfigurationMode mode)
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    result r = __pWifiDirectDeviceImpl->SetWpsConfigurationModePreference(mode);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectDevice::CreateGroup(const WifiDirectGroupInfo *pWifiDirectGroupInfo,
+                                                               const WifiDirectDeviceInfo *pWifiDirectRemoteDeviceInfo)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_ADMIN);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    if (pWifiDirectRemoteDeviceInfo != null
+        && (pWifiDirectRemoteDeviceInfo->GetDeviceName().GetLength() < 0
+            || pWifiDirectRemoteDeviceInfo->GetDeviceName().GetLength() > 64
+            || _WifiDirectUtility::CheckMacAddress(pWifiDirectRemoteDeviceInfo->GetMacAddress()) == false))
+    {
+        SysLogException(NID_NET_WIFI, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
+        return E_INVALID_ARG;
+    }
+
+    r = __pWifiDirectDeviceImpl->CreateGroup(pWifiDirectGroupInfo, pWifiDirectRemoteDeviceInfo);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectDevice::CancelGroupCreation(void)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_ADMIN);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    r = __pWifiDirectDeviceImpl->CancelGroupCreation();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectDevice::Scan(void)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_READ);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    r = __pWifiDirectDeviceImpl->Scan();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectDevice::CancelScan(void)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_READ);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    r = __pWifiDirectDeviceImpl->CancelScan();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectDevice::Associate(const WifiDirectDeviceInfo &wifiDirectGroupOwnerDeviceInfo)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_ADMIN);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    r = __pWifiDirectDeviceImpl->Associate(wifiDirectGroupOwnerDeviceInfo);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+WifiDirectGroupMember*
+WifiDirectDevice::GetWifiDirectMemberN(void) const
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    WifiDirectGroupMember* pGroupMember = null;
+
+    pGroupMember = __pWifiDirectDeviceImpl->GetWifiDirectMemberN();
+
+    result r = GetLastResult();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return pGroupMember;
+}
+
+bool
+WifiDirectDevice::IsDiscoverable(void) const
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    bool isDiscoverable = false;
+
+    isDiscoverable = __pWifiDirectDeviceImpl->IsDiscoverable();
+
+    result r = GetLastResult();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return isDiscoverable;
+}
+
+result
+WifiDirectDevice::Connect(const WifiDirectDeviceInfo& remoteDeviceInfo)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_ADMIN);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    if (remoteDeviceInfo.GetDeviceName().GetLength() < 0
+        || remoteDeviceInfo.GetDeviceName().GetLength() > MAX_DEVICE_NAME_LENGTH
+        || _WifiDirectUtility::CheckMacAddress(remoteDeviceInfo.GetMacAddress()) == false)
+    {
+        SysLogException(NID_NET_WIFI, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
+        return E_INVALID_ARG;
+    }
+
+    return __pWifiDirectDeviceImpl->Connect(remoteDeviceInfo);
+}
+
+result
+WifiDirectDevice::CancelConnect(void)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_ADMIN);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    return __pWifiDirectDeviceImpl->CancelConnect();
+}
+
+result
+WifiDirectDevice::CreateAutonomousGroup(void)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_ADMIN);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    return __pWifiDirectDeviceImpl->CreateAutonomousGroup();
+}
+
+result
+WifiDirectDevice::SetGroupSettingInfo(const WifiDirectGroupInfo& groupInfo)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_ADMIN);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    return __pWifiDirectDeviceImpl->SetGroupSettingInfo(groupInfo);
+}
+
+result
+WifiDirectDevice::Disconnect(const WifiDirectDeviceInfo& peerDeviceInfo)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_ADMIN);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    if (peerDeviceInfo.GetDeviceName().GetLength() < 0
+        || peerDeviceInfo.GetDeviceName().GetLength() > MAX_DEVICE_NAME_LENGTH
+        || _WifiDirectUtility::CheckMacAddress(peerDeviceInfo.GetMacAddress()) == false)
+    {
+        SysLogException(NID_NET_WIFI, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
+        return E_INVALID_ARG;
+    }
+
+    return __pWifiDirectDeviceImpl->Disconnect(peerDeviceInfo);
+}
+
+result
+WifiDirectDevice::LeaveGroup(void)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_ADMIN);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    return __pWifiDirectDeviceImpl->LeaveGroup();
+}
+
+WifiDirectDeviceInfo*
+WifiDirectDevice::GetGroupOwnerInfoN(void) const
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    return __pWifiDirectDeviceImpl->GetGroupOwnerInfoN();
+}
+
+IList*
+WifiDirectDevice::GetGroupClientInfoListN(void) const
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    return __pWifiDirectDeviceImpl->GetGroupClientInfoListN();
+}
+
+
+WifiRadioChannel
+WifiDirectDevice::GetOperatingChannel(void) const
+{
+    SysAssertf(__pWifiDirectDeviceImpl != null, "Not constructed properly by platform.");
+
+    return __pWifiDirectDeviceImpl->GetOperatingChannel();
+}
+
+WifiDirectDevice::WifiDirectDevice(void)
+    :__pWifiDirectDeviceImpl(null)
+{
+
+}
+
+WifiDirectDevice::WifiDirectDevice(const WifiDirectDevice& value)
+    : __pWifiDirectDeviceImpl(null)
+{
+    __pWifiDirectDeviceImpl = value.__pWifiDirectDeviceImpl;
+}
+
+WifiDirectDevice&
+WifiDirectDevice::operator=(const WifiDirectDevice& rhs)
+{
+    if (this != &rhs)
+    {
+        __pWifiDirectDeviceImpl = rhs.__pWifiDirectDeviceImpl;
+    }
+
+    return *this;
+}
+
+result
+WifiDirectDevice::Construct(WifiDirectDeviceId localDeviceId)
+{
+    SysTryReturnResult(NID_NET_WIFI, !__pWifiDirectDeviceImpl, E_SYSTEM, "This instance has already been constructed.");
+       unique_ptr<_WifiDirectDeviceImpl> pWifiDirectDeviceImpl;
+    pWifiDirectDeviceImpl.reset(_WifiDirectDeviceImpl::CreateWifiDirectDeviceImplInstanceN());
+
+    SysTryReturnResult(NID_NET_WIFI, pWifiDirectDeviceImpl, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+    result r = pWifiDirectDeviceImpl->Construct(localDeviceId);
+
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Construct failed");
+
+    __pWifiDirectDeviceImpl = pWifiDirectDeviceImpl.release();
+
+    return r;
+}
+
+} } }// Tizen::Net::Wifi
+
diff --git a/src/wifi/FNetWifiWifiDirectDeviceInfo.cpp b/src/wifi/FNetWifiWifiDirectDeviceInfo.cpp
new file mode 100644 (file)
index 0000000..b174087
--- /dev/null
@@ -0,0 +1,152 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetWifiWifiDirectDeviceInfo.cpp
+ * @brief              This is the implementation file for the WifiDirectDeviceInfo Class.
+ *
+ * This file contains implementation of the WifiDirectDeviceInfo Class.
+ */
+
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FNetIpAddress.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiDirectDeviceInfoImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+WifiDirectDeviceInfo::WifiDirectDeviceInfo(void)
+    : __pWifiDirectDeviceInfoImpl(null)
+{
+    __pWifiDirectDeviceInfoImpl = new (std::nothrow) _WifiDirectDeviceInfoImpl();
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiDirectDeviceInfoImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+WifiDirectDeviceInfo::WifiDirectDeviceInfo(const WifiDirectDeviceInfo& value)
+    : __pWifiDirectDeviceInfoImpl(null)
+{
+
+    __pWifiDirectDeviceInfoImpl = new (std::nothrow)_WifiDirectDeviceInfoImpl(*value.__pWifiDirectDeviceInfoImpl);
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiDirectDeviceInfoImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+WifiDirectDeviceInfo::WifiDirectDeviceInfo(const String& deviceName, const String& macAddr)
+    : __pWifiDirectDeviceInfoImpl(null)
+{
+    __pWifiDirectDeviceInfoImpl = new (std::nothrow)_WifiDirectDeviceInfoImpl(deviceName, macAddr);
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiDirectDeviceInfoImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+WifiDirectDeviceInfo::~WifiDirectDeviceInfo(void)
+{
+   delete __pWifiDirectDeviceInfoImpl;
+}
+
+WifiDirectDeviceInfo&
+WifiDirectDeviceInfo::operator=(const WifiDirectDeviceInfo& rhs)
+{
+    SysLog(NID_NET_WIFI, "Enter");
+
+    if (this != &rhs)
+    {
+        *__pWifiDirectDeviceInfoImpl = *rhs.__pWifiDirectDeviceInfoImpl;
+    }
+
+    SysLog(NID_NET_WIFI, "Exit");
+    return *this;
+}
+
+WifiDirectDeviceId
+WifiDirectDeviceInfo::GetDeviceId(void) const
+{
+    return __pWifiDirectDeviceInfoImpl->GetDeviceId();
+}
+
+String
+WifiDirectDeviceInfo::GetDeviceName(void) const
+{
+    return __pWifiDirectDeviceInfoImpl->GetDeviceName();
+}
+
+String
+WifiDirectDeviceInfo::GetMacAddress(void) const
+{
+    return __pWifiDirectDeviceInfoImpl->GetMacAddress();
+}
+
+const IpAddress*
+WifiDirectDeviceInfo::GetIpAddress(void) const
+{
+    return __pWifiDirectDeviceInfoImpl->GetIpAddress();
+}
+
+Tizen::Base::String
+WifiDirectDeviceInfo::GetSsid(void) const
+{
+    return __pWifiDirectDeviceInfoImpl->GetSsid();
+}
+
+WifiDirectDeviceStatus
+WifiDirectDeviceInfo::GetDeviceStatus(void) const
+{
+    return __pWifiDirectDeviceInfoImpl->GetDeviceStatus();
+}
+
+WifiDirectGroupMemberType
+WifiDirectDeviceInfo::GetGroupMemberType(void) const
+{
+    return __pWifiDirectDeviceInfoImpl->GetGroupMemberType();
+}
+
+Tizen::Net::Wifi::WifiDirectDeviceTypeCategory
+WifiDirectDeviceInfo::GetDeviceTypeCategory(void) const
+{
+    return __pWifiDirectDeviceInfoImpl->GetDeviceTypeCategory();
+}
+
+const Tizen::Base::Collection::IListT<WifiWpsConfigurationMode>*
+WifiDirectDeviceInfo::GetSupportedWpsConfigurationModeList(void) const
+{
+    return __pWifiDirectDeviceInfoImpl->GetSupportedWpsConfigurationModeList();
+}
+
+bool
+WifiDirectDeviceInfo::Equals(const Tizen::Base::Object& obj) const
+{
+    const WifiDirectDeviceInfo* pOther = dynamic_cast<const WifiDirectDeviceInfo*>(&obj);
+
+    if (pOther == null)
+    {
+        return false;
+    }
+
+    if (pOther == this)
+    {
+        return true;
+    }
+    return __pWifiDirectDeviceInfoImpl->Equals(*pOther->__pWifiDirectDeviceInfoImpl);
+}
+
+int
+WifiDirectDeviceInfo::GetHashCode(void) const
+{
+    return __pWifiDirectDeviceInfoImpl->GetHashCode();
+}
+
+}}}// Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifiWifiDirectDeviceManager.cpp b/src/wifi/FNetWifiWifiDirectDeviceManager.cpp
new file mode 100644 (file)
index 0000000..64b3c25
--- /dev/null
@@ -0,0 +1,99 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file        FNetWifiWifiDirectDeviceManager.cpp
+ * @brief       This is the implementation file for the WifiDirectDeviceManager
+ *              Class.
+ *
+ * This file contains implementation of the WifiDirectDeviceManager Class.
+ */
+
+#include <FNetWifiWifiDirectDeviceManager.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FNetWifiWifiDirectDevice.h>
+#include <FBaseColArrayList.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include "FSys_SystemInfoImpl.h"
+#include "FNetWifi_WifiDirectDeviceManagerImpl.h"
+
+static const wchar_t* _WIFI_DIRECT = L"http://tizen.org/feature/network.wifi.direct";
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::System;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+WifiDirectDeviceManager::WifiDirectDeviceManager(void)
+    : __pWifiDirectDeviceManagerImpl(null)
+{
+}
+
+WifiDirectDeviceManager::~WifiDirectDeviceManager(void)
+{
+    if (__pWifiDirectDeviceManagerImpl != null)
+    {
+        delete __pWifiDirectDeviceManagerImpl;
+        __pWifiDirectDeviceManagerImpl = null;
+    }
+}
+
+IList*
+WifiDirectDeviceManager::GetAllDeviceInfoN(void)
+{
+    bool isWifiDirectSupported = false;
+    IList* pList = null;
+    result r = _SystemInfoImpl::GetSysInfo(_WIFI_DIRECT, isWifiDirectSupported);
+
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS && isWifiDirectSupported == true, null, E_UNSUPPORTED_OPERATION,
+            "[E_UNSUPPORTED_OPERATION] No WifiDirectDeviceInfo available since the device don't support the Wi-Fi Direct.");
+
+    pList = _WifiDirectDeviceManagerImpl::GetAllDeviceInfoN();
+    r = GetLastResult();
+
+    if (pList == null)
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return pList;
+}
+
+WifiDirectDevice*
+WifiDirectDeviceManager::GetWifiDirectDeviceN(const WifiDirectDeviceInfo* pLocalDeviceInfo)
+{
+    bool isWifiDirectSupported = false;
+    WifiDirectDevice* pWifiDirectDevice = null;
+    result r = _SystemInfoImpl::GetSysInfo(_WIFI_DIRECT, isWifiDirectSupported);
+
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS && isWifiDirectSupported == true, null, E_UNSUPPORTED_OPERATION,
+            "[E_UNSUPPORTED_OPERATION] No WifiDirectDeviceInfo available since the device don't support the Wi-Fi Direct.");
+
+    pWifiDirectDevice = _WifiDirectDeviceManagerImpl::GetWifiDirectDeviceN(pLocalDeviceInfo);
+    r = GetLastResult();
+
+    if (pWifiDirectDevice == null)
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return pWifiDirectDevice;
+}
+
+}}}// Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifiWifiDirectGroupClient.cpp b/src/wifi/FNetWifiWifiDirectGroupClient.cpp
new file mode 100644 (file)
index 0000000..9c8956d
--- /dev/null
@@ -0,0 +1,126 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifiWifiDirectGroupClient.cpp
+ * @brief This is the implementation file for the WifiDirectGroupClient Class.
+ *
+ * This header file contains implementation of the WifiDirectGroupClient Class.
+ */
+
+#include <FNetWifiWifiTypes.h>
+#include <FNetWifiWifiDirectGroupClient.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FNetWifi_WifiDirectGroupClientImpl.h"
+
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+
+WifiDirectGroupClient::~WifiDirectGroupClient(void)
+{
+    if (__pWifiDirectGroupClientImpl != null)
+    {
+        __pWifiDirectGroupClientImpl->Release();
+        __pWifiDirectGroupClientImpl = null;
+    }
+}
+
+
+result
+WifiDirectGroupClient::Disassociate(void)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_ADMIN);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectGroupClientImpl, E_SYSTEM, "This instance has not been constructed yet.");
+
+    r = __pWifiDirectGroupClientImpl->Disassociate();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectGroupClient::RequestGroupOwnerInfo(int portNumber)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_READ);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectGroupClientImpl, E_SYSTEM, "This instance has not been constructed yet.");
+
+    r = __pWifiDirectGroupClientImpl->RequestGroupOwnerInfo(portNumber);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectGroupClient::RequestAllGroupMemberInfo(int portNumber)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_READ);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectGroupClientImpl, E_SYSTEM, "This instance has not been constructed yet.");
+
+    r = __pWifiDirectGroupClientImpl->RequestAllGroupMemberInfo(portNumber);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+WifiDirectGroupClient::WifiDirectGroupClient(void)
+    : __pWifiDirectGroupClientImpl(null)
+{
+}
+
+result
+WifiDirectGroupClient::Construct(_WifiDirectGroupClientImpl& wifiDirectGroupClientImpl)
+{
+    SysTryReturnResult(NID_NET_WIFI, !__pWifiDirectGroupClientImpl, E_SYSTEM , "[E_SYSTEM] This instance has already been constructed.");
+
+    __pWifiDirectGroupClientImpl = &wifiDirectGroupClientImpl;
+
+    _groupMemberType = WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT;
+
+    wifiDirectGroupClientImpl.AddRef();
+
+    return E_SUCCESS;
+}
+
+}}}// Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifiWifiDirectGroupInfo.cpp b/src/wifi/FNetWifiWifiDirectGroupInfo.cpp
new file mode 100644 (file)
index 0000000..771e599
--- /dev/null
@@ -0,0 +1,162 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FNetWifiWifiDirectGroupInfo.cpp
+ * @brief      This is the implementation file for the WifiDirectGroupInfo Class.
+ *
+ * This file contains implementation of the WifiDirectGroupInfo Class.
+ */
+
+#include <FNetWifiWifiDirectGroupInfo.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiDirectGroupInfoImpl.h"
+
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+
+WifiDirectGroupInfo::WifiDirectGroupInfo(void)
+{
+    __pWifiDirectGroupInfoImpl = new (std::nothrow) _WifiDirectGroupInfoImpl;
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiDirectGroupInfoImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+WifiDirectGroupInfo::WifiDirectGroupInfo(const WifiDirectGroupInfo& value)
+{
+    __pWifiDirectGroupInfoImpl = new (std::nothrow) _WifiDirectGroupInfoImpl(*value.__pWifiDirectGroupInfoImpl);
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiDirectGroupInfoImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+WifiDirectGroupInfo::~WifiDirectGroupInfo(void)
+{
+    if (__pWifiDirectGroupInfoImpl != null)
+    {
+        delete __pWifiDirectGroupInfoImpl;
+    }
+}
+
+WifiDirectGroupInfo&
+WifiDirectGroupInfo::operator=(const WifiDirectGroupInfo& rhs)
+{
+    if (this != &rhs)
+    {
+        _WifiDirectGroupInfoImpl* pNewWifiDirectGroupInfoImpl =
+                               new (std::nothrow) _WifiDirectGroupInfoImpl(*rhs.__pWifiDirectGroupInfoImpl);
+        SysTryReturn(NID_NET_WIFI, pNewWifiDirectGroupInfoImpl, *this, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+        delete __pWifiDirectGroupInfoImpl;
+
+        __pWifiDirectGroupInfoImpl = pNewWifiDirectGroupInfoImpl;
+    }
+
+    return *this;
+}
+
+bool
+WifiDirectGroupInfo::GetAutonomousGroupOwnerMode(void) const
+{
+    return __pWifiDirectGroupInfoImpl->GetAutonomousGroupOwnerMode();
+}
+
+int
+WifiDirectGroupInfo::GetGroupOwnerIntent(void) const
+{
+    return __pWifiDirectGroupInfoImpl->GetGroupOwnerIntent();
+}
+
+int
+WifiDirectGroupInfo::GetMaxNumberOfClients(void) const
+{
+    return __pWifiDirectGroupInfoImpl->GetMaxNumberOfClients();
+}
+
+String
+WifiDirectGroupInfo::GetSsid(void) const
+{
+    return __pWifiDirectGroupInfoImpl->GetSsid();
+}
+
+String
+WifiDirectGroupInfo::GetBssId(void) const
+{
+    return __pWifiDirectGroupInfoImpl->GetBssId();
+}
+
+WifiRadioChannel
+WifiDirectGroupInfo::GetOperatingChannel(void) const
+{
+    return __pWifiDirectGroupInfoImpl->GetOperatingChannel();
+}
+
+void
+WifiDirectGroupInfo::SetAutonomousGroupOwnerMode(bool mode)
+{
+    __pWifiDirectGroupInfoImpl->SetAutonomousGroupOwnerMode(mode);
+}
+
+result
+WifiDirectGroupInfo::SetGroupOwnerIntent(int intent)
+{
+    result r = __pWifiDirectGroupInfoImpl->SetGroupOwnerIntent(intent);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectGroupInfo::SetMaxNumberOfClients(int numberOfClient)
+{
+    result r = __pWifiDirectGroupInfoImpl->SetMaxNumberOfClients(numberOfClient);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+bool
+WifiDirectGroupInfo::Equals(const Tizen::Base::Object& obj) const
+{
+    const WifiDirectGroupInfo* pOther = dynamic_cast<const WifiDirectGroupInfo*>(&obj);
+
+    if (pOther == null)
+    {
+        return false;
+    }
+
+    if (pOther == this)
+    {
+        return true;
+    }
+    return __pWifiDirectGroupInfoImpl->Equals(*pOther->__pWifiDirectGroupInfoImpl);
+}
+int
+WifiDirectGroupInfo::GetHashCode(void) const
+{
+    return __pWifiDirectGroupInfoImpl->GetHashCode();
+}
+
+}}}// Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifiWifiDirectGroupMember.cpp b/src/wifi/FNetWifiWifiDirectGroupMember.cpp
new file mode 100644 (file)
index 0000000..d348712
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file   FNetWifiWifiDirectGroupMember.cpp
+ * @brief  This is the implementation file for the WifiDirectGroupMember Class.
+ *
+ * This file contains implementation of the WifiDirectGroupMember Class.
+ */
+
+#include <FNetWifiWifiDirectGroupMember.h>
+
+namespace Tizen {      namespace Net { namespace Wifi {
+WifiDirectGroupMember::WifiDirectGroupMember(void)
+    : _groupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+    , _pWifiDirectGroupMemberImpl(null)
+{
+
+}
+
+
+WifiDirectGroupMemberType
+WifiDirectGroupMember::GetGroupMemberType(void) const
+{
+    return _groupMemberType;
+}
+
+
+}}}// Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifiWifiDirectGroupOwner.cpp b/src/wifi/FNetWifiWifiDirectGroupOwner.cpp
new file mode 100644 (file)
index 0000000..4905046
--- /dev/null
@@ -0,0 +1,171 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FNetWifiWifiDirectGroupOwner.cpp
+ * @brief      This is the implementation file for the WifiDirectGroupOwner Class.
+ *
+ * This file contains implementation of the WifiDirectGroupOwner Class.
+ */
+#include <FNetWifiWifiDirectGroupOwner.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include "FNetWifi_WifiDirectGroupOwnerImpl.h"
+#include "FNetWifi_WifiDirectUtility.h"
+
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+WifiDirectGroupOwner::~WifiDirectGroupOwner(void)
+{
+    if (__pWifiDirectGroupOwnerImpl != null)
+    {
+        __pWifiDirectGroupOwnerImpl->Release();
+        __pWifiDirectGroupOwnerImpl = null;
+    }
+}
+
+result
+WifiDirectGroupOwner::DestroyGroup(void)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_ADMIN);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectGroupOwnerImpl, E_SYSTEM , "This instance has not been constructed yet.");
+
+    r = __pWifiDirectGroupOwnerImpl->DestroyGroup();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectGroupOwner::Disconnect(const WifiDirectDeviceInfo& wifiDirectRemoteDeviceInfo)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_ADMIN);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectGroupOwnerImpl, E_SYSTEM , "This instance has not been constructed yet.");
+
+    if (wifiDirectRemoteDeviceInfo.GetDeviceName().GetLength() < 0
+        || wifiDirectRemoteDeviceInfo.GetDeviceName().GetLength() > 64
+        || _WifiDirectUtility::CheckMacAddress(wifiDirectRemoteDeviceInfo.GetMacAddress()) == false)
+    {
+        SysLogException(NID_NET_WIFI, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
+        return E_INVALID_ARG;
+    }
+
+    r = __pWifiDirectGroupOwnerImpl->Disconnect(wifiDirectRemoteDeviceInfo);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+Tizen::Base::Collection::IList*
+WifiDirectGroupOwner::GetAllGroupMemberInfoListN(void) const
+{
+    SysTryReturn(NID_NET_WIFI, __pWifiDirectGroupOwnerImpl, null, E_SYSTEM , "[E_SYSTEM] This instance has not been constructed yet.");
+
+    IList* pMemberInfoList = null;
+
+    pMemberInfoList = __pWifiDirectGroupOwnerImpl->GetAllGroupMemberInfoListN();
+
+    result r = GetLastResult();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return pMemberInfoList;
+}
+
+result
+WifiDirectGroupOwner::StartGroupMemberInfoService(const int portNumber)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_READ);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectGroupOwnerImpl, E_SYSTEM , "This instance has not been constructed yet.");
+
+    r = __pWifiDirectGroupOwnerImpl->StartGroupMemberInfoService(portNumber);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+result
+WifiDirectGroupOwner::StopGroupMemberInfoService(void)
+{
+    result r = E_SUCCESS;
+
+    r = _AccessController::CheckUserPrivilege(_PRV_WIFI_WIFIDIRECT_READ);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectGroupOwnerImpl, E_SYSTEM , "This instance has not been constructed yet.");
+
+    r = __pWifiDirectGroupOwnerImpl->StopGroupMemberInfoService();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+WifiDirectGroupOwner::WifiDirectGroupOwner(void)
+    : __pWifiDirectGroupOwnerImpl(null)
+{
+}
+
+result
+WifiDirectGroupOwner::Construct(_WifiDirectGroupOwnerImpl& wifiDirectGroupOwnerImpl)
+{
+    SysTryReturnResult(NID_NET_WIFI, !__pWifiDirectGroupOwnerImpl, E_SYSTEM , "This instance has already been constructed.");
+
+    __pWifiDirectGroupOwnerImpl = &wifiDirectGroupOwnerImpl;
+
+    wifiDirectGroupOwnerImpl.AddRef();
+
+    _groupMemberType = WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER;
+
+    return E_SUCCESS;
+}
+
+}}}// Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifiWifiManager.cpp b/src/wifi/FNetWifiWifiManager.cpp
new file mode 100644 (file)
index 0000000..81305cc
--- /dev/null
@@ -0,0 +1,262 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file        FNetWifiWifiManager.cpp
+ * @brief       This is the implementation file for the WifiManager Class.
+ * @version     1.0
+ *
+ * This file contains the implementation of the WifiManager Class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FNetWifiWifiBssInfo.h>
+#include <FNetWifiWifiManager.h>
+#include <FSec_AccessController.h>
+#include "FNetWifi_WifiManagerImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+WifiManager::WifiManager(void)
+       :__pWifiManagerImpl(null)
+{
+}
+
+WifiManager::~WifiManager(void)
+{
+       delete __pWifiManagerImpl;
+}
+
+result
+WifiManager::Construct(IWifiManagerEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pWifiManagerImpl == null,
+                               "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+       unique_ptr<_WifiManagerImpl> pWifiManagerImpl(new (std::nothrow) _WifiManagerImpl());
+       SysTryReturnResult(NID_NET_WIFI, pWifiManagerImpl, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pWifiManagerImpl->Construct(listener);
+
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+       __pWifiManagerImpl = pWifiManagerImpl.release();
+
+       return r;
+}
+
+result
+WifiManager::Activate(void) const
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_WIFI_ADMIN);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pWifiManagerImpl->Activate();
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+WifiManager::Deactivate(void) const
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_WIFI_ADMIN);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pWifiManagerImpl->Deactivate();
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+WifiPowerStatus
+WifiManager::GetPowerStatus(void) const
+{
+       WifiPowerStatus wifiPowerStatus = WIFI_POWER_STATUS_OFF;
+
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       wifiPowerStatus = __pWifiManagerImpl->GetPowerStatus();
+
+       return wifiPowerStatus;
+}
+
+String
+WifiManager::GetMacAddress(void) const
+{
+       String macAddress(L"");
+
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       macAddress = __pWifiManagerImpl->GetMacAddress();
+
+       return macAddress;
+}
+
+bool
+WifiManager::IsActivated(void) const
+{
+       bool isActivated = false;
+
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       isActivated = __pWifiManagerImpl->IsActivated();
+
+       return isActivated;
+}
+
+bool
+WifiManager::IsConnected(void) const
+{
+       bool isConnected = false;
+
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       isConnected = __pWifiManagerImpl->IsConnected();
+
+       return isConnected;
+}
+
+result
+WifiManager::Scan(void)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_WIFI_READ);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pWifiManagerImpl->Scan();
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+WifiManager::Connect(const WifiBssInfo& targetApInfo)
+{
+       result r = E_SUCCESS;
+
+       r = _AccessController::CheckUserPrivilege(_PRV_WIFI_ADMIN);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
+
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       r = __pWifiManagerImpl->Connect(targetApInfo);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+WifiManager::SetWifiSystemScanMode(WifiSystemScanMode mode)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       // Privilege check will be done by Impl class
+       r = __pWifiManagerImpl->SetWifiSystemScanMode(mode);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+WifiManager::AddSystemMonitoringEventListener(IWifiSystemMonitoringEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       // Privilege check will be done by Impl class
+       r = __pWifiManagerImpl->AddSystemMonitoringEventListener(listener);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+WifiManager::RemoveSystemMonitoringEventListener(IWifiSystemMonitoringEventListener& listener)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       // Privilege check will be done by Impl class
+       r = __pWifiManagerImpl->RemoveSystemMonitoringEventListener(listener);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+WifiConnectionState
+WifiManager::GetConnectionState(void) const
+{
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pWifiManagerImpl->GetConnectionState();
+}
+
+WifiBssInfo*
+WifiManager::GetConnectionTargetInfoN(void) const
+{
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pWifiManagerImpl->GetConnectionTargetInfoN();
+}
+
+result
+WifiManager::UpdateBssInfo(const WifiBssInfo& bssInfo)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       // Privilege check will be done by Impl class
+       r = __pWifiManagerImpl->UpdateBssInfo(bssInfo);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+Tizen::Base::Collection::IList*
+WifiManager::GetSystemScanResultN(void) const
+{
+       SysAssertf(__pWifiManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       return __pWifiManagerImpl->GetSystemScanResultN();
+}
+
+} } } // Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifiWifiNetAccountInfo.cpp b/src/wifi/FNetWifiWifiNetAccountInfo.cpp
new file mode 100644 (file)
index 0000000..543e5c5
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifiWifiNetAccountInfo.cpp
+ * @brief   This is the implementation file for the WifiNetAccountInfo Class.
+ * @version 1.0
+ *
+ * This file contains the implementation of the WifiNetAccountInfo Class.
+ */
+
+#include <FNetWifiWifiNetAccountInfo.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiNetAccountInfoImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+WifiNetAccountInfo::WifiNetAccountInfo(void)
+{
+    __pWifiNetAccountInfoImpl = new (std::nothrow) _WifiNetAccountInfoImpl();
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiNetAccountInfoImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+WifiNetAccountInfo::WifiNetAccountInfo(const WifiNetAccountInfo& value)
+{
+    __pWifiNetAccountInfoImpl = new (std::nothrow) _WifiNetAccountInfoImpl(*value.__pWifiNetAccountInfoImpl);
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiNetAccountInfoImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+WifiNetAccountInfo::~WifiNetAccountInfo(void)
+{
+    if (__pWifiNetAccountInfoImpl)
+    {
+        delete __pWifiNetAccountInfoImpl;
+       __pWifiNetAccountInfoImpl = null;
+    }
+}
+
+String
+WifiNetAccountInfo::GetBssId(void) const
+{
+    return __pWifiNetAccountInfoImpl->GetBssId();
+}
+
+String
+WifiNetAccountInfo::GetSsid(void) const
+{
+    return __pWifiNetAccountInfoImpl->GetSsid();
+}
+
+WifiBssType
+WifiNetAccountInfo::GetBssType(void) const
+{
+    return __pWifiNetAccountInfoImpl->GetBssType();
+}
+
+const WifiSecurityInfo*
+WifiNetAccountInfo::GetSecurityInfo(void) const
+{
+    return __pWifiNetAccountInfoImpl->GetSecurityInfo();
+}
+
+
+WifiRadioChannel
+WifiNetAccountInfo::GetRadioChannel(void) const
+{
+    return __pWifiNetAccountInfoImpl->GetRadioChannel();
+}
+
+bool
+WifiNetAccountInfo::Equals(const Tizen::Base::Object& obj) const
+{
+    if (NetAccountInfo::Equals(obj) == false)
+    {
+        return false;
+    }
+
+    const WifiNetAccountInfo* pOther = dynamic_cast<const WifiNetAccountInfo*>(&obj);
+
+    if (pOther == null)
+    {
+        return false;
+    }
+
+    if (pOther == this)
+    {
+      return true;
+    }
+
+    return __pWifiNetAccountInfoImpl->Equals(*pOther->__pWifiNetAccountInfoImpl);
+}
+
+int
+WifiNetAccountInfo::GetHashCode(void) const
+{
+    return __pWifiNetAccountInfoImpl->GetHashCode();
+}
+
+} } } // Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifiWifiSecurityInfo.cpp b/src/wifi/FNetWifiWifiSecurityInfo.cpp
new file mode 100644 (file)
index 0000000..e6d8ae6
--- /dev/null
@@ -0,0 +1,145 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifiWifiSecurityInfo.cpp
+ * @brief   This is the implementation file for the WifiSecurityInfo Class.
+ * @version 1.0
+ *
+ * This file contains the implementation of the WifiSecurityInfo Class.
+ */
+
+#include <FNetWifiWifiSecurityInfo.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiSecurityInfoImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+WifiSecurityInfo::WifiSecurityInfo(void)
+{
+    __pWifiSecurityInfoImpl = new (std::nothrow) _WifiSecurityInfoImpl();
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiSecurityInfoImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+WifiSecurityInfo::WifiSecurityInfo(const WifiSecurityInfo& value)
+{
+    __pWifiSecurityInfoImpl = new (std::nothrow) _WifiSecurityInfoImpl(*(value.__pWifiSecurityInfoImpl));
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiSecurityInfoImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+WifiSecurityInfo::~WifiSecurityInfo(void)
+{
+    if (__pWifiSecurityInfoImpl)
+    {
+        delete __pWifiSecurityInfoImpl;
+        __pWifiSecurityInfoImpl = null;
+    }
+}
+
+WifiSecurityInfo&
+WifiSecurityInfo::operator=(const WifiSecurityInfo& rhs)
+{
+    if (this != &rhs)
+    {
+        _WifiSecurityInfoImpl* pWifiSecurityInfoImpl = new (std::nothrow) _WifiSecurityInfoImpl(*(rhs.__pWifiSecurityInfoImpl));
+
+        SysTryReturn(NID_NET_WIFI, pWifiSecurityInfoImpl, *this, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+        delete __pWifiSecurityInfoImpl;
+
+        __pWifiSecurityInfoImpl = pWifiSecurityInfoImpl;
+    }
+
+    return *this;
+}
+
+WifiAuthenticationType
+WifiSecurityInfo::GetAuthenticationType(void) const
+{
+    return __pWifiSecurityInfoImpl->GetAuthenticationType();
+}
+
+WifiEncryptionType
+WifiSecurityInfo::GetEncryptionType(void) const
+{
+    return __pWifiSecurityInfoImpl->GetEncryptionType();
+}
+
+result
+WifiSecurityInfo::SetNetworkKeyWep(WifiWepKeyLen  keyLen, WifiWepKeyIndex keyIndex, const String& key)
+{
+    return __pWifiSecurityInfoImpl->SetNetworkKeyWep(keyLen, keyIndex, key);
+}
+
+result
+WifiSecurityInfo::SetNetworkKeyAes(const String& key)
+{
+    return __pWifiSecurityInfoImpl->SetNetworkKeyAes(key);
+}
+
+result
+WifiSecurityInfo::SetNetworkKeyTkip(const String& key)
+{
+    return __pWifiSecurityInfoImpl->SetNetworkKeyTkip(key);
+}
+
+result
+WifiSecurityInfo::SetEapMethodInfo(WifiEapType type, const Tizen::Base::String& userId, const Tizen::Base::String& password,
+bool validateServerCertificate)
+{
+    return __pWifiSecurityInfoImpl->SetEapMethodInfo(type, userId, password, validateServerCertificate);
+}
+
+void
+WifiSecurityInfo::SetNetworkKey(const Tizen::Base::String& key)
+{
+    __pWifiSecurityInfoImpl->SetNetworkKey(key);
+}
+
+void
+WifiSecurityInfo::SetAuthenticationType(WifiAuthenticationType type)
+{
+    __pWifiSecurityInfoImpl->SetAuthenticationType(type);
+}
+
+
+bool
+WifiSecurityInfo::Equals(const Tizen::Base::Object& obj) const
+{
+    const WifiSecurityInfo* pOther = dynamic_cast<const WifiSecurityInfo*>(&obj);
+
+    if (pOther == null)
+    {
+        return false;
+    }
+
+    if (pOther == this)
+    {
+        return true;
+    }
+    return __pWifiSecurityInfoImpl->Equals(*pOther->__pWifiSecurityInfoImpl);
+}
+int
+WifiSecurityInfo::GetHashCode(void) const
+{
+    return __pWifiSecurityInfoImpl->GetHashCode();
+}
+
+} } } // Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiBssInfoImpl.cpp b/src/wifi/FNetWifi_WifiBssInfoImpl.cpp
new file mode 100644 (file)
index 0000000..0db76eb
--- /dev/null
@@ -0,0 +1,563 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiBssInfoImpl.cpp
+ * @brief   This is the implementation file for the _WifiBssInfoImpl Class.
+ *
+ * This file contains the implementation of the _WifiBssInfoImpl Class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseFloat.h>
+#include <FBaseSysLog.h>
+#include <FNetWifiWifiBssInfo.h>
+#include <FNetIpAddress.h>
+#include "FNetWifi_WifiBssInfoImpl.h"
+#include "FNetWifi_WifiUtility.h"
+
+using namespace std;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+_WifiBssInfoImpl::_WifiBssInfoImpl(void)
+    : __ssid("")
+    , __bssid("")
+    , __bssType(WIFI_BSS_TYPE_INFRASTRUCTURE)
+    , __channel(WIFI_RADIO_CHANNEL_UNKNOWN)
+    , __rssi(0)
+    , __dataRate(-1.0)
+       , __isKnown(false)
+       , __scheme(NET_ADDRESS_SCHEME_NONE)
+       , __pLocalAddress(null)
+       , __pMaskAddress(null)
+       , __pGatewayAddress(null)
+       , __pPriDnsAddress(null)
+       , __pSecDnsAddress(null)
+       , __proxyType(NET_PROXY_TYPE_NONE)
+       , __proxyAddress()
+       , __pApHandler(null)
+{
+}
+
+_WifiBssInfoImpl::_WifiBssInfoImpl(const _WifiBssInfoImpl& value)
+    : __ssid(value.__ssid)
+    , __bssid(value.__bssid)
+    , __bssType(value.__bssType)
+    , __channel(value.__channel)
+    , __securityInfo(value.__securityInfo)
+    , __rssi(value.__rssi)
+    , __dataRate(value.__dataRate)
+       , __isKnown(value.__isKnown)
+       , __scheme(value.__scheme)
+       , __pLocalAddress(null)
+       , __pMaskAddress(null)
+       , __pGatewayAddress(null)
+       , __pPriDnsAddress(null)
+       , __pSecDnsAddress(null)
+       , __proxyType(NET_PROXY_TYPE_NONE)
+       , __proxyAddress(value.__proxyAddress)
+    , __pApHandler(null)
+{
+       result r = E_SUCCESS;
+       unique_ptr<IpAddress> pTempAddress;
+
+       if (value.__pLocalAddress != null)
+       {
+               pTempAddress.reset(value.__pLocalAddress->CloneN());
+               r = GetLastResult();
+               SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+               __pLocalAddress = pTempAddress.release();
+       }
+
+       if (value.__pMaskAddress != null)
+       {
+               pTempAddress.reset(value.__pMaskAddress->CloneN());
+               r = GetLastResult();
+               SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+               __pMaskAddress = pTempAddress.release();
+       }
+
+       if (value.__pGatewayAddress != null)
+       {
+               pTempAddress.reset(value.__pGatewayAddress->CloneN());
+               r = GetLastResult();
+               SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+               __pGatewayAddress = pTempAddress.release();
+       }
+
+       if (value.__pPriDnsAddress != null)
+       {
+               pTempAddress.reset(value.__pPriDnsAddress->CloneN());
+               r = GetLastResult();
+               SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+               __pPriDnsAddress = pTempAddress.release();
+       }
+
+       if (value.__pSecDnsAddress != null)
+       {
+               pTempAddress.reset(value.__pSecDnsAddress->CloneN());
+               r = GetLastResult();
+               SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+               __pSecDnsAddress = pTempAddress.release();
+       }
+
+    if(value.__pApHandler != null)
+    {
+        _WifiUtility::WifiApDestory(&__pApHandler);
+        _WifiUtility::WifiApClone(&__pApHandler, value.__pApHandler);
+    }
+}
+
+_WifiBssInfoImpl::~_WifiBssInfoImpl(void)
+{
+       delete  __pLocalAddress;
+       delete  __pMaskAddress;
+       delete  __pGatewayAddress;
+       delete  __pPriDnsAddress;
+       delete  __pSecDnsAddress;
+    _WifiUtility::WifiApDestory(&__pApHandler);
+}
+
+String
+_WifiBssInfoImpl::GetBssId(void) const
+{
+    return __bssid;
+}
+
+
+String
+_WifiBssInfoImpl::GetSsid(void) const
+{
+    return __ssid;
+}
+
+WifiBssType
+_WifiBssInfoImpl::GetBssType(void) const
+{
+    return __bssType;
+}
+
+const WifiSecurityInfo*
+_WifiBssInfoImpl::GetSecurityInfo(void) const
+{
+    return &__securityInfo;
+}
+
+WifiRadioChannel
+_WifiBssInfoImpl::GetRadioChannel(void) const
+{
+    return __channel;
+}
+
+long
+_WifiBssInfoImpl::GetRssi(void) const
+{
+    return __rssi;
+}
+
+float
+_WifiBssInfoImpl::GetDataRate(void) const
+{
+    return __dataRate;
+}
+
+void*
+_WifiBssInfoImpl::GetBssHandle(void) const
+{
+    return __pApHandler;
+}
+
+WifiBssInfo*
+_WifiBssInfoImpl::CreateWifiBssInfoN(void)
+{
+    WifiBssInfo* pBssInfo = new (std::nothrow) WifiBssInfo();
+    SysTryReturn(NID_NET_WIFI, pBssInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    return pBssInfo;
+}
+
+void
+_WifiBssInfoImpl::SetBssId(const String& bssid)
+{
+    __bssid = bssid;
+}
+
+void
+_WifiBssInfoImpl::SetSsid(const String& ssid)
+{
+    __ssid = ssid;
+}
+
+void
+_WifiBssInfoImpl::SetBssType(WifiBssType bssType)
+{
+    __bssType = bssType;
+}
+
+void
+_WifiBssInfoImpl::SetSecurityInfo(const WifiSecurityInfo& securityInfo)
+{
+    __securityInfo = securityInfo;
+}
+
+void
+_WifiBssInfoImpl::SetRadioChannel(WifiRadioChannel channel)
+{
+    __channel = channel;
+}
+
+void
+_WifiBssInfoImpl::SetRssi(long rssi)
+{
+    __rssi = rssi;
+}
+
+void
+_WifiBssInfoImpl::SetDataRate(float dataRate)
+{
+    __dataRate = dataRate;
+}
+
+void
+_WifiBssInfoImpl::SetBssHandle(void* apHandler)
+{
+    __pApHandler = apHandler;
+}
+
+bool
+_WifiBssInfoImpl::IsKnown(void) const
+{
+    return __isKnown;
+}
+
+void
+_WifiBssInfoImpl::SetKnown(bool isKnown)
+{
+    __isKnown = isKnown;
+}
+
+Tizen::Net::NetAddressScheme
+_WifiBssInfoImpl::GetLocalAddressScheme(void) const
+{
+    return __scheme;
+}
+
+void
+_WifiBssInfoImpl::SetLocalAddressScheme(Tizen::Net::NetAddressScheme scheme)
+{
+       __scheme = scheme;
+}
+
+const Tizen::Net::IpAddress*
+_WifiBssInfoImpl::GetLocalAddress(void) const
+{
+       SysTryReturn(NID_NET_WIFI, __scheme == NET_ADDRESS_SCHEME_STATIC, null, E_INVALID_OPERATION,
+                       "[E_INVALID_OPERATION] This operation is not allowed when the current IP address scheme is not static.");
+
+    return __pLocalAddress;
+}
+
+result
+_WifiBssInfoImpl::SetLocalAddress(const Tizen::Net::IpAddress* pAddress)
+{
+       unique_ptr<IpAddress> pTempAddress;
+
+       SysTryReturnResult(NID_NET_WIFI, __scheme == NET_ADDRESS_SCHEME_STATIC, E_INVALID_OPERATION,
+                       "This operation is not allowed when the current IP address scheme is not static.");
+
+       if (pAddress != null)
+       {
+               pTempAddress.reset(pAddress->CloneN());
+               SysTryReturnResult(NID_NET_WIFI, pTempAddress != null, E_OUT_OF_MEMORY, "Propagating.");
+       }
+
+       delete __pLocalAddress;
+       __pLocalAddress = pTempAddress.release();
+
+       return E_SUCCESS;
+}
+
+const Tizen::Net::IpAddress*
+_WifiBssInfoImpl::GetSubnetMaskAddress(void) const
+{
+       SysTryReturn(NID_NET_WIFI, __scheme == NET_ADDRESS_SCHEME_STATIC, null, E_INVALID_OPERATION,
+                       "[E_INVALID_OPERATION] This operation is not allowed when the current IP address scheme is not static.");
+
+    return __pMaskAddress;
+}
+
+result
+_WifiBssInfoImpl::SetSubnetMaskAddress(const Tizen::Net::IpAddress* pAddress)
+{
+       unique_ptr<IpAddress> pTempAddress;
+
+       SysTryReturnResult(NID_NET_WIFI, __scheme == NET_ADDRESS_SCHEME_STATIC, E_INVALID_OPERATION,
+                       "This operation is not allowed when the current IP address scheme is not static.");
+
+       if (pAddress != null)
+       {
+               pTempAddress.reset(pAddress->CloneN());
+               SysTryReturnResult(NID_NET_WIFI, pTempAddress != null, E_OUT_OF_MEMORY, "Propagating.");
+       }
+
+       delete __pMaskAddress;
+       __pMaskAddress = pTempAddress.release();
+
+       return E_SUCCESS;
+}
+
+const Tizen::Net::IpAddress*
+_WifiBssInfoImpl::GetDefaultGatewayAddress(void) const
+{
+       SysTryReturn(NID_NET_WIFI, __scheme == NET_ADDRESS_SCHEME_STATIC, null, E_INVALID_OPERATION,
+                       "[E_INVALID_OPERATION] This operation is not allowed when the current IP address scheme is not static.");
+
+    return __pGatewayAddress;
+}
+
+result
+_WifiBssInfoImpl::SetDefaultGatewayAddress(const Tizen::Net::IpAddress* pAddress)
+{
+       unique_ptr<IpAddress> pTempAddress;
+
+       SysTryReturnResult(NID_NET_WIFI, __scheme == NET_ADDRESS_SCHEME_STATIC, E_INVALID_OPERATION,
+                       "This operation is not allowed when the current IP address scheme is not static.");
+
+       if (pAddress != null)
+       {
+               pTempAddress.reset(pAddress->CloneN());
+               SysTryReturnResult(NID_NET_WIFI, pTempAddress != null, E_OUT_OF_MEMORY, "Propagating.");
+       }
+
+       delete __pGatewayAddress;
+       __pGatewayAddress = pTempAddress.release();
+
+       return E_SUCCESS;
+}
+
+const Tizen::Net::IpAddress*
+_WifiBssInfoImpl::GetPrimaryDnsAddress(void) const
+{
+       SysTryReturn(NID_NET_WIFI, __scheme == NET_ADDRESS_SCHEME_STATIC, null, E_INVALID_OPERATION,
+                       "[E_INVALID_OPERATION] This operation is not allowed when the current IP address scheme is not static.");
+
+    return __pPriDnsAddress;
+}
+
+result
+_WifiBssInfoImpl::SetPrimaryDnsAddress(const Tizen::Net::IpAddress* pAddress)
+{
+       unique_ptr<IpAddress> pTempAddress;
+
+       SysTryReturnResult(NID_NET_WIFI, __scheme == NET_ADDRESS_SCHEME_STATIC, E_INVALID_OPERATION,
+                       "This operation is not allowed when the current IP address scheme is not static.");
+
+       if (pAddress != null)
+       {
+               pTempAddress.reset(pAddress->CloneN());
+               SysTryReturnResult(NID_NET_WIFI, pTempAddress != null, E_OUT_OF_MEMORY, "Propagating.");
+       }
+
+       delete __pPriDnsAddress;
+       __pPriDnsAddress = pTempAddress.release();
+
+       return E_SUCCESS;
+}
+
+const Tizen::Net::IpAddress*
+_WifiBssInfoImpl::GetSecondaryDnsAddress(void) const
+{
+       SysTryReturn(NID_NET_WIFI, __scheme == NET_ADDRESS_SCHEME_STATIC, null, E_INVALID_OPERATION,
+                       "[E_INVALID_OPERATION] This operation is not allowed when the current IP address scheme is not static.");
+
+    return __pSecDnsAddress;
+}
+
+result
+_WifiBssInfoImpl::SetSecondaryDnsAddress(const Tizen::Net::IpAddress* pAddress)
+{
+       unique_ptr<IpAddress> pTempAddress;
+
+       SysTryReturnResult(NID_NET_WIFI, __scheme == NET_ADDRESS_SCHEME_STATIC, E_INVALID_OPERATION,
+                       "This operation is not allowed when the current IP address scheme is not static.");
+
+       if (pAddress != null)
+       {
+               pTempAddress.reset(pAddress->CloneN());
+               SysTryReturnResult(NID_NET_WIFI, pTempAddress != null, E_OUT_OF_MEMORY, "Propagating.");
+       }
+
+       delete __pSecDnsAddress;
+       __pSecDnsAddress = pTempAddress.release();
+
+       return E_SUCCESS;
+}
+
+Tizen::Net::NetProxyType
+_WifiBssInfoImpl::GetProxyType(void) const
+{
+    return __proxyType;
+}
+
+void
+_WifiBssInfoImpl::SetProxyType(Tizen::Net::NetProxyType type)
+{
+       __proxyType = type;
+}
+
+Tizen::Base::String
+_WifiBssInfoImpl::GetProxyAddress(void) const
+{
+       SysTryReturn(NID_NET_WIFI, __proxyType != NET_PROXY_TYPE_NONE, null, E_INVALID_OPERATION,
+                       "[E_INVALID_OPERATION] This operation is not allowed when the proxy type is none (not used).");
+
+    return __proxyAddress;
+}
+
+result
+_WifiBssInfoImpl::SetProxyAddress(const Tizen::Base::String& address)
+{
+       SysTryReturnResult(NID_NET_WIFI, __proxyType != NET_PROXY_TYPE_NONE, E_INVALID_OPERATION,
+                       "This operation is not allowed when the proxy type is none (not used).");
+
+       __proxyAddress = address;
+
+       return E_SUCCESS;
+}
+
+bool
+_WifiBssInfoImpl::Equals(const Tizen::Base::Object& obj) const
+{
+    const _WifiBssInfoImpl* pOther = dynamic_cast<const _WifiBssInfoImpl*>(&obj);
+
+    if (pOther == null
+        || __ssid != pOther->__ssid
+        || __bssid != pOther->__bssid
+        || __bssType != pOther->__bssType
+        || __channel != pOther->__channel
+        || !__securityInfo.Equals(pOther->__securityInfo)
+        || __rssi != pOther->__rssi
+        || Float::Compare(__dataRate, pOther->__dataRate)
+       || __isKnown != pOther->__isKnown
+       || __scheme != pOther->__scheme
+       || !_WifiUtility::CheckAddressEquality(__pLocalAddress, pOther->__pLocalAddress)
+       || !_WifiUtility::CheckAddressEquality(__pMaskAddress, pOther->__pMaskAddress)
+       || !_WifiUtility::CheckAddressEquality(__pGatewayAddress, pOther->__pGatewayAddress)
+       || !_WifiUtility::CheckAddressEquality(__pPriDnsAddress, pOther->__pPriDnsAddress)
+       || !_WifiUtility::  CheckAddressEquality(__pSecDnsAddress, pOther->__pSecDnsAddress)
+       || __proxyType != pOther->__proxyType
+       || __proxyAddress != pOther->__proxyAddress)
+    {
+        return false;
+    }
+
+    return true;
+}
+
+int
+_WifiBssInfoImpl::GetHashCode(void) const
+{
+    return __bssid.GetHashCode();
+}
+
+_WifiBssInfoImpl*
+_WifiBssInfoImpl::GetInstance(WifiBssInfo& wifiBssInfo)
+{
+    return wifiBssInfo.__pWifiBssInfoImpl;
+}
+
+const _WifiBssInfoImpl*
+_WifiBssInfoImpl::GetInstance(const WifiBssInfo& wifiBssInfo)
+{
+    return wifiBssInfo.__pWifiBssInfoImpl;
+}
+
+_WifiBssInfoImpl&
+_WifiBssInfoImpl::operator=(const _WifiBssInfoImpl& rhs)
+{
+    if (this == &rhs)
+    {
+       return *this;
+    }
+
+       unique_ptr<IpAddress> pTempAddress;
+
+       __bssid = rhs.__bssid;
+       __bssType = rhs.__bssType;
+       __channel = rhs.__channel;
+       __dataRate = rhs.__dataRate;
+       __rssi = rhs.__rssi;
+       __ssid = rhs.__ssid;
+       __securityInfo = rhs.__securityInfo;
+       __isKnown = rhs.__isKnown;
+       __scheme = rhs.__scheme;
+
+       if (rhs.__pLocalAddress != null)
+       {
+               pTempAddress.reset(rhs.__pLocalAddress->CloneN());
+               SysTryReturn(NID_NET_WIFI, pTempAddress != null, *this, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Propagating.");
+       }
+       delete __pLocalAddress;
+       __pLocalAddress = pTempAddress.release();
+
+       if (rhs.__pMaskAddress != null)
+       {
+               pTempAddress.reset(rhs.__pMaskAddress->CloneN());
+               SysTryReturn(NID_NET_WIFI, pTempAddress != null, *this, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Propagating.");
+       }
+       delete __pMaskAddress;
+       __pMaskAddress = pTempAddress.release();
+
+       if (rhs.__pGatewayAddress != null)
+       {
+               pTempAddress.reset(rhs.__pGatewayAddress->CloneN());
+               SysTryReturn(NID_NET_WIFI, pTempAddress != null, *this, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Propagating.");
+       }
+       delete __pGatewayAddress;
+       __pGatewayAddress = pTempAddress.release();
+
+       if (rhs.__pPriDnsAddress != null)
+       {
+               pTempAddress.reset(rhs.__pPriDnsAddress->CloneN());
+               SysTryReturn(NID_NET_WIFI, pTempAddress != null, *this, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Propagating.");
+       }
+       delete __pPriDnsAddress;
+       __pPriDnsAddress = pTempAddress.release();
+
+       if (rhs.__pSecDnsAddress != null)
+       {
+               pTempAddress.reset(rhs.__pSecDnsAddress->CloneN());
+               SysTryReturn(NID_NET_WIFI, pTempAddress != null, *this, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Propagating.");
+       }
+       delete __pSecDnsAddress;
+       __pSecDnsAddress = pTempAddress.release();
+
+       __proxyType = rhs.__proxyType;
+       __proxyAddress = rhs.__proxyAddress;
+
+       if(rhs.__pApHandler != null)
+       {
+           _WifiUtility::WifiApDestory(&__pApHandler);
+               _WifiUtility::WifiApClone(&__pApHandler, rhs.__pApHandler);
+       }
+
+    return *this;
+}
+
+} } } // Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiDirectDeviceEvent.cpp b/src/wifi/FNetWifi_WifiDirectDeviceEvent.cpp
new file mode 100644 (file)
index 0000000..5a9df47
--- /dev/null
@@ -0,0 +1,186 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectDeviceEvent.cpp
+ * @brief   This is the implementation file for the _WifiDirectDeviceEvent Class.
+ *
+ * This header file contains implementation of the _WifiDirectDeviceEvent Class.
+ */
+
+#include <FBaseRtIEventListener.h>
+#include <FNetWifiIWifiDirectDeviceListener.h>
+#include <FBaseColIList.h>
+#include <FBaseString.h>
+#include <FNetWifiWifiDirectGroupMember.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FNetWifiWifiDirectGroupInfo.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiDirectDeviceImpl.h"
+#include "FNetWifi_WifiDirectDeviceEvent.h"
+#include "FNetWifi_WifiDirectEventArg.h"
+
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+////////////////////////////////////////////////////////////////////////////
+_WifiDirectDeviceEvent::_WifiDirectDeviceEvent(_WifiDirectDeviceImpl* pWifiDirectDeviceImpl)
+{
+    __pWifiDirectDeviceImpl = pWifiDirectDeviceImpl;
+}
+
+_WifiDirectDeviceEvent::~_WifiDirectDeviceEvent(void)
+{
+
+}
+
+_WifiDirectDeviceEvent::_WifiDirectDeviceEvent(void)
+    : __pWifiDirectDeviceImpl(null)
+{
+}
+
+
+result
+_WifiDirectDeviceEvent::Construct(void)
+{
+    return _Event::Initialize();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Operation : Protected
+
+void
+_WifiDirectDeviceEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+    const _WifiDirectEventArg* pArg = dynamic_cast<const _WifiDirectEventArg*>(&arg);
+    SysTryReturnVoidResult(NID_NET_WIFI, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is a null pointer.");
+
+    IWifiDirectDeviceListener* pDeviceListener = dynamic_cast<IWifiDirectDeviceListener*>(&listener);
+    SysTryReturnVoidResult(NID_NET_WIFI, pDeviceListener != null, E_INVALID_ARG,
+            "[E_INVALID_ARG] The result of a dynamic_cast operation is null for external Device listener.");
+
+    _WifiDirectEventType eventType = pArg->GetEventType();
+    WifiDirectDeviceId localDeviceId = pArg->GetDeviceId();
+    result r = pArg->GetError();
+
+    switch (eventType)
+    {
+    case WIFI_DIRECT_DEVICE_EVENT_ACTIVATED:
+        SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_DEVICE_EVENT_ACTIVATED) : %s",GetErrorMessage(r));
+        pDeviceListener->OnWifiDirectDeviceActivated(localDeviceId, r);
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_DEACTIVATED:
+         SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_DEVICE_EVENT_DEACTIVATED) : %s",GetErrorMessage(r));
+        pDeviceListener->OnWifiDirectDeviceDeactivated(localDeviceId, r);
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_GROUP_CREATED:
+        SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_DEVICE_EVENT_GROUP_CREATED) : %s",GetErrorMessage(r));
+        {
+            WifiDirectGroupInfo* pGroupInfo = pArg->GetGroupInfo();
+            WifiDirectDeviceInfo* pGroupOwnerInfo = pArg->GetDeviceInfo();
+            WifiDirectGroupMember* pGroupMember = pArg->GetGroupMember();
+            pDeviceListener->OnWifiDirectGroupCreatedN(localDeviceId, *pGroupInfo, *pGroupOwnerInfo, pGroupMember, r);
+        }
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_SCAN_COMPLETED:
+         SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_DEVICE_EVENT_SCAN_COMPLETED) : %s",GetErrorMessage(r));
+         {
+             if(!IsFailed(r))
+             {
+                 ArrayList* pSrcDeviceInfoList = dynamic_cast<ArrayList*>(pArg->GetDeviceInfoList());
+                 SysTryCatch(NID_NET_WIFI, pSrcDeviceInfoList != null, , E_SYSTEM, "[E_SYSTEM] Failed to dynamic casting DeviceInfo list.");
+
+                 ArrayList* pDescDeviceInfoList = new (std::nothrow) ArrayList();
+                 SysTryCatch(NID_NET_WIFI, pDescDeviceInfoList != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                 result res = pDescDeviceInfoList->Construct(*pSrcDeviceInfoList);
+
+                 if (IsFailed(res))
+                 {
+                     delete pDescDeviceInfoList;
+                     pDescDeviceInfoList = null;
+
+                     r = E_SYSTEM;
+                 }
+
+                pDeviceListener->OnWifiDirectScanCompletedN(localDeviceId, pDescDeviceInfoList, r);
+            }
+            else
+            {
+                pDeviceListener->OnWifiDirectScanCompletedN(localDeviceId, null, r);
+            }
+         }
+         break;
+    case WIFI_DIRECT_DEVICE_EVENT_ASSOCIATED:
+        SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_DEVICE_EVENT_ASSOCIATED) : %s",GetErrorMessage(r));
+        {
+            WifiDirectDeviceInfo* pGroupOwnerInfo = pArg->GetDeviceInfo();
+            if (pGroupOwnerInfo == null)
+            {
+                pDeviceListener->OnWifiDirectAssociationCompleted(localDeviceId, WifiDirectDeviceInfo(), r);
+            }
+            else
+            {
+                pDeviceListener->OnWifiDirectAssociationCompleted(localDeviceId, *pGroupOwnerInfo, r);
+            }
+        }
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_CONNECTED:
+        SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_DEVICE_EVENT_CONNECTED) : %s",GetErrorMessage(r));
+        {
+            WifiDirectDeviceInfo* pDeviceInfo = pArg->GetDeviceInfo();
+            if (pDeviceInfo == null)
+            {
+                pDeviceListener->OnWifiDirectConnected(localDeviceId, WifiDirectDeviceInfo(), r);
+            }
+            else
+            {
+                pDeviceListener->OnWifiDirectConnected(localDeviceId, *pDeviceInfo, r);
+            }
+        }
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_DISCONNECTED:
+    {
+        SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_DEVICE_EVENT_DISCONNECTED) : %s",GetErrorMessage(r));
+        String macAddress = pArg->GetMacAddress();
+        pDeviceListener->OnWifiDirectDisconnected(localDeviceId, macAddress, r);
+    }
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_AUTONOMOS_GROUP_CREATED:
+        SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_DEVICE_EVENT_AUTONOMOS_GROUP_CREATED) : %s",GetErrorMessage(r));
+        pDeviceListener->OnWifiDirectAutonomousGroupCreated(localDeviceId, r);
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_GROUP_LEFT:
+        SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_DEVICE_EVENT_GROUP_LEFT) : %s",GetErrorMessage(r));
+        pDeviceListener->OnWifiDirectGroupLeft(localDeviceId, r);
+        break;
+    default:
+         SysLog(NID_NET_WIFI, "An undefined external WifiDirectDevice event occurs. (Type: %d)",eventType);
+         SysAssert(false);
+         break;
+    }
+    return;
+
+CATCH:
+    pDeviceListener->OnWifiDirectScanCompletedN(localDeviceId, null, r);
+
+}
+
+} } } // Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiDirectDeviceEvent.h b/src/wifi/FNetWifi_WifiDirectDeviceEvent.h
new file mode 100644 (file)
index 0000000..81ef077
--- /dev/null
@@ -0,0 +1,108 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectDeviceEvent.h
+ * @brief   This is the header file for the _WifiDirectDeviceEvent class.
+ *
+ * This header file contains declarations of the _WifiDirectDeviceEvent class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_DIRECT_DEVICE_EVENT_H_
+#define _FNET_WIFI_INTERNAL_WIFI_DIRECT_DEVICE_EVENT_H_
+
+// Includes
+#include <FBaseResult.h>
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventListener;
+class IEventArg;
+}}}
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class _WifiDirectDeviceImpl;
+
+/**
+ * @class   _WifiDirectDeviceEvent
+ * @brief   This class handles WifiDirectDevice events.
+ *
+ * When a WifiDirectDevice event occurs, the _WifiDirectDeviceEvent object finds a IWifiDirectDeviceEventListener object
+ * which is registered for the Device object and calls an appropriate method of the listener.
+ */
+
+class _WifiDirectDeviceEvent
+    : public Tizen::Base::Runtime::_Event
+{
+public:
+    /**
+     * 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.
+     */
+    _WifiDirectDeviceEvent(_WifiDirectDeviceImpl* pWifiDirectDeviceImpl);
+
+    /**
+     * This destructor overrides Tizen::Base::Runtime::_Event::~_Event().
+     */
+    virtual ~_WifiDirectDeviceEvent(void);
+
+    /**
+     * Initializes this instance.
+     */
+    result Construct(void);
+
+protected:
+    /**
+     * Checks the arg and finds out the type of event. After that this method calls appropriate pListener's method.
+     *
+     * @return      A result code.
+     * @param[in]   listener               It is a event listener related to this WifiDirectDevice event.
+     * @param[in]   arg                     It is an argument-like instance of WifiDirectDevice event retransmitted to the listener's method as an argument.
+     * @exception   E_SUCCESS               The method is successful.
+     * @exception   E_INVALID_ARG           The argument passed to a method contains an invalid value.@n
+     */
+    void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+
+    /**
+     * This default constructor is intentionally declared as private so that only the platform can create an instance.
+     *
+     */
+    _WifiDirectDeviceEvent(void);
+
+    /**
+     * This copy constructor is intentionally declared as private to prohibit copying of objects by users.
+     *
+     *
+     * @param[in]   rhs   An instance of %_WifiDirectDeviceEvent
+     */
+    _WifiDirectDeviceEvent(const _WifiDirectDeviceEvent& rhs);
+    
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in] rhs An instance of %_WifiDirectDeviceEvent
+     */
+    _WifiDirectDeviceEvent& operator =(const _WifiDirectDeviceEvent& rhs);
+
+    _WifiDirectDeviceImpl* __pWifiDirectDeviceImpl;
+}; // _WifiDirectDeviceEvent
+
+}}} // Tizen::Net::Wifi
+#endif // _FNET_WIFI_INTERNAL_WIFI_DIRECT_DEVICE_EVENT_H_
diff --git a/src/wifi/FNetWifi_WifiDirectDeviceImpl.cpp b/src/wifi/FNetWifi_WifiDirectDeviceImpl.cpp
new file mode 100644 (file)
index 0000000..96ba0c5
--- /dev/null
@@ -0,0 +1,1782 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file        FNetWifi_WifiDirectDeviceImpl.cpp
+ * @brief       This is the implementation file for _WifiDirectDeviceImpl class.
+ */
+
+// Includes
+#include <unique_ptr.h>
+#include <FNetNetAccountManager.h>
+#include <FNetNetConnection.h>
+#include <FNetNetConnectionInfo.h>
+#include <FNetWifiWifiTypes.h>
+#include <FNetWifiWifiDirectDevice.h>
+#include <FNetWifiWifiDirectGroupInfo.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FNetWifiWifiDirectGroupOwner.h>
+#include <FNetWifiWifiDirectGroupClient.h>
+#include <FNetWifiIWifiDirectDeviceListener.h>
+#include <FNetWifiIWifiDirectGroupOwnerListener.h>
+#include <FNetWifiIWifiDirectGroupClientListener.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FBaseSysLog.h>
+#include "FSys_SystemInfoImpl.h"
+#include "FNetWifi_WifiDirectDeviceImpl.h"
+#include "FNetWifi_WifiDirectGroupOwnerImpl.h"
+#include "FNetWifi_WifiDirectGroupClientImpl.h"
+#include "FNetWifi_WifiDirectDeviceInfoImpl.h"
+#include "FNetWifi_WifiDirectDeviceEvent.h"
+#include "FNetWifi_WifiDirectGroupOwnerEvent.h"
+#include "FNetWifi_WifiDirectGroupClientEvent.h"
+#include "FNetWifi_WifiDirectEventArg.h"
+#include "FNetWifi_WifiDirectSystemAdapter.h"
+#include "FNetWifi_WifiDirectUtility.h"
+
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::System;
+using namespace Tizen::Net;
+
+
+namespace Tizen {      namespace Net { namespace Wifi
+{
+
+
+////////////////////////////////////////////////////////////////////////////////
+/// Lifecycle : Public
+_WifiDirectDeviceImpl::_WifiDirectDeviceImpl(void)
+    : __localDeviceId(-1)
+    , __deviceState(WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATED)
+    , __scanState(WIFI_DIRECT_SCAN_INTERNAL_IDLE)
+    , __pWifiDirectSystemAdapter(null)
+    , __refCount(1)
+{
+
+}
+
+_WifiDirectDeviceImpl::~_WifiDirectDeviceImpl(void)
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Operation : Public
+
+result
+_WifiDirectDeviceImpl::Construct(WifiDirectDeviceId localDeviceId, bool enableIpInfoService /*= true*/)
+{
+    result r = E_SUCCESS;
+
+    WifiDirectDeviceStatus             deviceStatus = WIFI_DIRECT_DEVICE_DEACTIVATED;
+    WifiDirectGroupMemberType  groupMemberType = WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE;
+
+    __localDeviceId = localDeviceId;
+
+    unique_ptr<_WifiDirectDeviceEvent> pWifiDirectDeviceEvent(new (std::nothrow) _WifiDirectDeviceEvent(this));
+    SysTryReturnResult(NID_NET_WIFI, pWifiDirectDeviceEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+    r = pWifiDirectDeviceEvent->Construct();
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to construct _WifiDirectDeviceEvent.");
+
+    unique_ptr<_WifiDirectGroupOwnerEvent> pWifiDirectGroupOwnerEvent(new (std::nothrow) _WifiDirectGroupOwnerEvent());
+    SysTryReturnResult(NID_NET_WIFI, pWifiDirectGroupOwnerEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+    r = pWifiDirectGroupOwnerEvent->Construct();
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to construct _WifiDirectGroupOwnerEvent.");
+
+    unique_ptr<_WifiDirectGroupClientEvent> pWifiDirectGroupClientEvent(new (std::nothrow) _WifiDirectGroupClientEvent());
+    SysTryReturnResult(NID_NET_WIFI, pWifiDirectGroupClientEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+    r = pWifiDirectGroupClientEvent->Construct();
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to construct _WifiDirectGroupClientEvent.");
+
+    r = __groupOwnerImpl.Construct(__localDeviceId, *this, enableIpInfoService);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to construct _WifiDirectGroupOwnerImpl.");
+
+    r = __groupClientImpl.Construct(__localDeviceId, *this, enableIpInfoService);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to construct _WifiDirectGroupClientImpl.");
+
+    __pWifiDirectSystemAdapter = _WifiDirectSystemAdapter::GetInstance();
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectSystemAdapter != null, E_SYSTEM,
+            "Failed to acquire the instance of _WifiDirectSystemAdapter.");
+
+    __pWifiDirectSystemAdapter->AddListener(*this);
+
+    unique_ptr<WifiDirectDeviceInfo> pLocalDeviceInfo(__pWifiDirectSystemAdapter->GetLocalDeviceInfoN());
+    r = GetLastResult();
+
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS && pLocalDeviceInfo != null, r,
+                "Failed to construct WifiDirectDevice while obtaining the device information.");
+
+    deviceStatus = pLocalDeviceInfo->GetDeviceStatus();
+    groupMemberType = pLocalDeviceInfo->GetGroupMemberType();
+
+    r = __stateMutex.Create();
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "The mutex creation failed.");
+
+    __stateMutex.Acquire();
+    if (deviceStatus == WIFI_DIRECT_DEVICE_DEACTIVATED)
+    {
+        __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATED;
+    }
+    else
+    {
+        switch (groupMemberType)
+        {
+        case WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE:
+            __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED;
+            break;
+        case WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER:
+            __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER;
+            break;
+        case WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT:
+            __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT;
+            break;
+        }
+    }
+    __stateMutex.Release();
+
+    __pWifiDirectDeviceEvent = move(pWifiDirectDeviceEvent);
+    __pWifiDirectGroupOwnerEvent = move(pWifiDirectGroupOwnerEvent);
+    __pWifiDirectGroupClientEvent = move(pWifiDirectGroupClientEvent);
+
+    return r;
+}
+
+result
+_WifiDirectDeviceImpl::AddWifiDirectDeviceListener(IWifiDirectDeviceListener &listener)
+{
+       SysTryReturnResult(NID_NET_WIFI, __pWifiDirectDeviceEvent != null, E_SYSTEM, "The event instance has not been constructed yet.");
+       result r = E_SUCCESS;
+
+       r = __pWifiDirectDeviceEvent->AddListener(listener, true);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY, E_OBJ_ALREADY_EXIST);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Adding a new listener has failed.");
+
+       return E_SUCCESS;
+}
+
+result
+_WifiDirectDeviceImpl::AddWifiDirectGroupOwnerListener(IWifiDirectGroupOwnerListener &listener)
+{
+       SysTryReturnResult(NID_NET_WIFI, __pWifiDirectGroupOwnerEvent != null, E_SYSTEM, "The event instance has not been constructed yet.");
+       result r = E_SUCCESS;
+
+       r = __pWifiDirectGroupOwnerEvent->AddListener(listener, true);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY, E_OBJ_ALREADY_EXIST);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Adding a new listener has failed.");
+
+       return E_SUCCESS;
+}
+
+result
+_WifiDirectDeviceImpl::AddWifiDirectGroupClientListener(IWifiDirectGroupClientListener &listener)
+{
+       SysTryReturnResult(NID_NET_WIFI, __pWifiDirectGroupClientEvent != null, E_SYSTEM, "The event instance has not been constructed yet.");
+       result r = E_SUCCESS;
+
+       r = __pWifiDirectGroupClientEvent->AddListener(listener, true);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY, E_OBJ_ALREADY_EXIST);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Adding a new listener has failed.");
+
+       return E_SUCCESS;
+}
+
+result
+_WifiDirectDeviceImpl::RemoveWifiDirectDeviceListener(IWifiDirectDeviceListener &listener)
+{
+       SysTryReturnResult(NID_NET_WIFI, __pWifiDirectDeviceEvent != null, E_SYSTEM, "The event instance has not been constructed yet.");
+
+       return __pWifiDirectDeviceEvent->RemoveListener(listener);
+}
+
+result
+_WifiDirectDeviceImpl::RemoveWifiDirectGroupOwnerListener(IWifiDirectGroupOwnerListener &listener)
+{
+       SysTryReturnResult(NID_NET_WIFI, __pWifiDirectGroupOwnerEvent != null, E_SYSTEM, "The event instance has not been constructed yet.");
+
+       return __pWifiDirectGroupOwnerEvent->RemoveListener(listener);
+}
+
+result
+_WifiDirectDeviceImpl::RemoveWifiDirectGroupClientListener(IWifiDirectGroupClientListener &listener)
+{
+       SysTryReturnResult(NID_NET_WIFI, __pWifiDirectGroupClientEvent != null, E_SYSTEM, "The event instance has not been constructed yet.");
+
+       return __pWifiDirectGroupClientEvent->RemoveListener(listener);
+
+}
+result
+_WifiDirectDeviceImpl::Activate(void)
+{
+    result r = E_SUCCESS;
+
+    __stateMutex.Acquire();
+    switch (__deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATED:
+        r = __pWifiDirectSystemAdapter->Activate();
+        if (r == E_SUCCESS)
+        {
+            __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATING;
+        }
+        break;
+    case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATING:
+        r = E_IN_PROGRESS;
+        break;
+    default:
+        SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+        r = E_INVALID_OPERATION;
+        break;
+    }
+    (void)__stateMutex.Release();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] exception occurred on activating Wi-Fi Direct.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+bool
+_WifiDirectDeviceImpl::IsActivated(void) const
+{
+       if (__deviceState != WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATED &&
+               __deviceState != WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATING)
+       {
+               return true;
+       }
+       else
+       {
+               return false;
+       }
+}
+
+result
+_WifiDirectDeviceImpl::Deactivate(void)
+{
+    result r = E_SUCCESS;
+
+    __stateMutex.Acquire();
+    switch (__deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATED:
+    case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATING:
+        r = E_INVALID_OPERATION;
+        SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+        break;
+    case WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATING:
+        r = E_IN_PROGRESS;
+        break;
+    default:
+        r = __pWifiDirectSystemAdapter->Deactivate();
+        if (r == E_SUCCESS)
+        {
+            __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATING;
+        }
+        break;
+    }
+    __stateMutex.Release();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] exception occurred on deactivating Wi-Fi Direct.", GetErrorMessage(r));
+    }
+
+    return r;
+}
+
+WifiDirectGroupInfo*
+_WifiDirectDeviceImpl::GetGroupSettingInfoN(void) const
+{
+       ClearLastResult();
+       result r = E_SUCCESS;
+
+       WifiDirectGroupInfo* pWifiDirectGroupInfo = null;
+
+       pWifiDirectGroupInfo = __pWifiDirectSystemAdapter->GetGroupSettingInfoN();
+
+       if (pWifiDirectGroupInfo == null)
+       {
+        r = GetLastResult();
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+
+        SetLastResult(r);
+        SysLogException(NID_NET_WIFI, r, "[%s] Failed to acquire a group setting information.", GetErrorMessage(r));
+        SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+       }
+
+       return pWifiDirectGroupInfo;
+}
+
+WifiDirectDeviceInfo*
+_WifiDirectDeviceImpl::GetLocalDeviceInfoN(void) const
+{
+    return __pWifiDirectSystemAdapter->GetLocalDeviceInfoN();
+}
+
+WifiWpsConfigurationMode
+_WifiDirectDeviceImpl::GetWpsConfigurationModePreference(void) const
+{
+       WifiWpsConfigurationMode wifiWpsConfigurationMode = WIFI_WPS_CONFIG_MODE_NONE;
+
+       wifiWpsConfigurationMode = __pWifiDirectSystemAdapter->GetWpsConfigurationModePreference();
+
+       return wifiWpsConfigurationMode;
+}
+
+result
+_WifiDirectDeviceImpl::SetLocalDeviceName(const String &name)
+{
+       result r = E_SUCCESS;
+       int nameLength = name.GetLength();
+
+       SysTryReturnResult(NID_NET_WIFI, nameLength > 0 && nameLength <= MAX_DEVICE_NAME_LENGTH, E_INVALID_ARG,
+                                               "The argument is invalid. The length of name is %d.", nameLength);
+
+       switch (__deviceState)
+       {
+       case WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATED:
+               r = __pWifiDirectSystemAdapter->SetLocalDeviceName(name);
+               break;
+       default:
+               r = E_INVALID_OPERATION;
+               SysLogException(NID_NET_WIFI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The operation is not allowed in this state.");
+               SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+               break;
+       }
+
+       return r;
+}
+
+result
+_WifiDirectDeviceImpl::SetWpsConfigurationModePreference(WifiWpsConfigurationMode mode)
+{
+    result r = E_SUCCESS;
+
+       switch (__deviceState)
+       {
+       case WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATED:
+       case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATING:
+       case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED:
+               r = __pWifiDirectSystemAdapter->SetWpsConfigurationModePreference(mode);
+               break;
+       default:
+               r = E_INVALID_OPERATION;
+               SysLog(NID_NET_WIFI, "[%s] The current state is %s", GetErrorMessage(r), GetStringOfCurrentState());
+               break;
+       }
+
+       return r;
+}
+
+result
+_WifiDirectDeviceImpl::CreateGroup(const WifiDirectGroupInfo *pWifiDirectGroupInfo,
+                                                                       const WifiDirectDeviceInfo *pWifiDirectRemoteDeviceInfo)
+{
+       SysTryReturnResult(NID_NET_WIFI, !(pWifiDirectGroupInfo != null
+                 && pWifiDirectGroupInfo->GetAutonomousGroupOwnerMode() == true
+                 && pWifiDirectRemoteDeviceInfo != null), E_INVALID_OPERATION,
+                 "The operation does not allowed to create an autonomous group with a specified remote device.");
+
+       result r = E_SUCCESS;
+
+       __stateMutex.Acquire();
+       switch (__deviceState)
+       {
+       case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED:
+               r = __pWifiDirectSystemAdapter->CreateGroup(pWifiDirectGroupInfo, pWifiDirectRemoteDeviceInfo);
+               if (r == E_SUCCESS)
+               {
+                       __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CONNECTING;
+               }
+               break;
+       case WIFI_DIRECT_DEVICE_INTERNAL_CONNECTING:
+               r = E_IN_PROGRESS;
+               break;
+       default:
+               r = E_INVALID_OPERATION;
+               SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+               break;
+       }
+    __stateMutex.Release();
+
+       return r;
+}
+
+result
+_WifiDirectDeviceImpl::CancelGroupCreation(void)
+{
+       result r = E_SUCCESS;
+
+    __stateMutex.Acquire();
+       switch (__deviceState)
+       {
+       case WIFI_DIRECT_DEVICE_INTERNAL_CONNECTING:
+               r = __pWifiDirectSystemAdapter->CancelGroupCreation();
+               if (r == E_SUCCESS)
+               {
+                       __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CONNECT_CANCELLING;
+               }
+               break;
+       case WIFI_DIRECT_DEVICE_INTERNAL_CONNECT_CANCELLING:
+               r = E_IN_PROGRESS;
+               break;
+       default:
+               r = E_INVALID_OPERATION;
+               SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+               break;
+       }
+    __stateMutex.Release();
+
+       return r;
+}
+
+result
+_WifiDirectDeviceImpl::Scan(void)
+{
+       result r = E_SUCCESS;
+
+       SysTryReturnResult(NID_NET_WIFI, __scanState != WIFI_DIRECT_SCAN_INTERNAL_SCANNING, E_IN_PROGRESS,
+            "The scanning process is in progress.");
+
+    __stateMutex.Acquire();
+    switch (__deviceState)
+       {
+    case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED:
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER:
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT:
+        if (__scanState == WIFI_DIRECT_SCAN_INTERNAL_IDLE)
+        {
+            r = __pWifiDirectSystemAdapter->Scan();
+            if (r == E_SUCCESS)
+            {
+                __scanState = WIFI_DIRECT_SCAN_INTERNAL_SCANNING;
+            }
+        }
+        else
+        {
+            r = E_INVALID_OPERATION;
+        }
+        break;
+    default:
+        SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+        r = E_INVALID_OPERATION;
+        break;
+       }
+    __stateMutex.Release();
+
+       return r;
+}
+
+result
+_WifiDirectDeviceImpl::CancelScan(void)
+{
+       result r = E_SUCCESS;
+
+    __stateMutex.Acquire();
+       switch (__scanState)
+       {
+       case WIFI_DIRECT_SCAN_INTERNAL_SCANNING:
+               r = __pWifiDirectSystemAdapter->CancelScan();
+               if (r == E_SUCCESS)
+               {
+                       __scanState = WIFI_DIRECT_SCAN_INTERNAL_CANCELLING;
+               }
+               break;
+       case WIFI_DIRECT_SCAN_INTERNAL_CANCELLING:
+               r = E_IN_PROGRESS;
+               break;
+       default:
+               r = E_INVALID_OPERATION;
+               SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+               break;
+       }
+    __stateMutex.Release();
+
+       return r;
+}
+
+result
+_WifiDirectDeviceImpl::Associate(const WifiDirectDeviceInfo &wifiDirectGroupOwnerDeviceInfo)
+{
+       result r = E_SUCCESS;
+
+    __stateMutex.Acquire();
+       switch (__deviceState)
+       {
+       case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED:
+               if (__scanState == WIFI_DIRECT_SCAN_INTERNAL_IDLE)
+               {
+                       r = __pWifiDirectSystemAdapter->Associate(wifiDirectGroupOwnerDeviceInfo);
+               }
+               else
+           {
+                   r = E_INVALID_OPERATION;
+                   SysLog(NID_NET_WIFI, "Discovery process is in progress.");
+           }
+
+               if (!IsFailed(r))
+               {
+                       __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CONNECTING;
+               }
+               break;
+       case WIFI_DIRECT_DEVICE_INTERNAL_CONNECTING:
+               r = E_IN_PROGRESS;
+               break;
+       default:
+           SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+               r = E_INVALID_OPERATION;
+               break;
+       }
+    __stateMutex.Release();
+
+       return r;
+}
+
+WifiDirectGroupMember*
+_WifiDirectDeviceImpl::GetWifiDirectMemberN(void)
+{
+       ClearLastResult();
+
+       result r = E_SUCCESS;
+
+       WifiDirectGroupMember* pWifiDirectGroupMember = null;
+
+       switch (__deviceState)
+       {
+       case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER:
+               pWifiDirectGroupMember = _WifiDirectGroupOwnerImpl::GetWifiDirectGroupOwnerInstanceN(__groupOwnerImpl);
+               break;
+       case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT:
+               pWifiDirectGroupMember = _WifiDirectGroupClientImpl::GetWifiDirectGroupClientInstanceN(__groupClientImpl);
+               break;
+       default:
+               // During Cancel, Delete, and Disassociate operation, the member instance would be meaningless. - Scott.Cho
+               r = E_INVALID_OPERATION;
+               break;
+       }
+
+       if (r == E_SUCCESS && pWifiDirectGroupMember == null)
+       {
+               r = E_OUT_OF_MEMORY;
+       }
+
+       SetLastResult(r);
+
+       return pWifiDirectGroupMember;
+}
+
+bool
+_WifiDirectDeviceImpl::IsDiscoverable(void) const
+{
+       bool isDiscoverable = false;
+
+       isDiscoverable = __pWifiDirectSystemAdapter->IsDiscoverable();
+
+       return isDiscoverable;
+}
+
+result
+_WifiDirectDeviceImpl::Connect(const WifiDirectDeviceInfo& remoteDeviceInfo)
+{
+    result r = E_SUCCESS;
+
+    __stateMutex.Acquire();
+    switch(__deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_INTERNAL_CONNECTING:
+        r = E_IN_PROGRESS;
+        break;
+    case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED:
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER:
+        if (__scanState == WIFI_DIRECT_SCAN_INTERNAL_IDLE)
+        {
+          r = __pWifiDirectSystemAdapter->Connect(remoteDeviceInfo);
+        }
+        else
+        {
+          r = E_INVALID_OPERATION;
+          SysLog(NID_NET_WIFI, "Discovery process is in progress.");
+        }
+
+        if (!IsFailed(r))
+        {
+          __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CONNECTING;
+        }
+        break;
+    default:
+        r = E_INVALID_OPERATION;
+        SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+        break;
+    }
+    __stateMutex.Release();
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_IN_PROGRESS, E_INVALID_OPERATION, E_OUT_OF_MEMORY);
+
+    return r;
+}
+
+result
+_WifiDirectDeviceImpl::CancelConnect(void)
+{
+    result r = E_SUCCESS;
+
+    __stateMutex.Acquire();
+    switch(__deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_INTERNAL_CONNECT_CANCELLING:
+        r = E_IN_PROGRESS;
+        break;
+    case WIFI_DIRECT_DEVICE_INTERNAL_CONNECTING:
+        r = __pWifiDirectSystemAdapter->CancelConnect();
+        if (r == E_SUCCESS)
+        {
+            __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CONNECT_CANCELLING;
+        }
+        break;
+    default:
+        r = E_INVALID_OPERATION;
+        SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+        break;
+    }
+    __stateMutex.Release();
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_IN_PROGRESS, E_INVALID_OPERATION);
+
+    return r;
+}
+
+result
+_WifiDirectDeviceImpl::CreateAutonomousGroup(void)
+{
+    result r = E_SUCCESS;
+
+    __stateMutex.Acquire();
+    switch(__deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED:
+        r = __pWifiDirectSystemAdapter->CreateAutonomousGroup();
+        if (r == E_SUCCESS)
+        {
+            __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_GROUP_CREATING;
+        }
+        break;
+    default:
+        r = E_INVALID_OPERATION;
+        SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+        break;
+    }
+    __stateMutex.Release();
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_INVALID_OPERATION);
+
+    return r;
+}
+
+result
+_WifiDirectDeviceImpl::SetGroupSettingInfo(const WifiDirectGroupInfo& groupConfigurationInfo)
+{
+    result r = E_SUCCESS;
+
+    switch(__deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATED:
+    case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATING:
+    case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED:
+        r = __pWifiDirectSystemAdapter->SetGroupSettingInfo(groupConfigurationInfo);
+        break;
+    default:
+        r = E_INVALID_OPERATION;
+        SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+        break;
+    }
+
+    return r;
+}
+
+result
+_WifiDirectDeviceImpl::Disconnect(const WifiDirectDeviceInfo& remoteDeviceInfo)
+{
+    result r = E_SUCCESS;
+
+    __stateMutex.Acquire();
+    switch(__deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER:
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT:
+        r = __pWifiDirectSystemAdapter->Disconnect(remoteDeviceInfo);
+        if ( r == E_SUCCESS )
+        {
+            __deviceState =  WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING;
+        }
+        break;
+    case WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING:
+        r = E_IN_PROGRESS;
+        break;
+    default:
+        r = E_INVALID_OPERATION;
+        SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+        break;
+    }
+    __stateMutex.Release();
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_IN_PROGRESS, E_INVALID_OPERATION, E_OUT_OF_MEMORY);
+
+    return r;
+}
+
+result
+_WifiDirectDeviceImpl::LeaveGroup(void)
+{
+    result r = E_SUCCESS;
+
+   __stateMutex.Acquire();
+   switch(__deviceState)
+   {
+   case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER:
+   case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT:
+       r = __pWifiDirectSystemAdapter->LeaveGroup();
+       if ( r == E_SUCCESS )
+       {
+           __deviceState =  WIFI_DIRECT_DEVICE_INTERNAL_LEAVING;
+       }
+       break;
+   default:
+       r = E_INVALID_OPERATION;
+       SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+       break;
+   }
+   __stateMutex.Release();
+
+   r = TransExceptionsExclusive(r, E_SYSTEM, E_IN_PROGRESS, E_INVALID_OPERATION);
+
+   return r;
+}
+
+WifiDirectDeviceInfo*
+_WifiDirectDeviceImpl::GetGroupOwnerInfoN(void) const
+{
+    ClearLastResult();
+
+    WifiDirectDeviceInfo* pGroupOwnerInfo = null;
+
+    switch(__deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER:
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT:
+    case WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING:
+       pGroupOwnerInfo = __pWifiDirectSystemAdapter->GetGroupOwnerInfoN();
+       break;
+    default:
+       SetLastResult(E_INVALID_OPERATION);
+       SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(GetLastResult()), GetStringOfCurrentState());
+       break;
+    }
+
+    return pGroupOwnerInfo;
+}
+
+IList*
+_WifiDirectDeviceImpl::GetGroupClientInfoListN(void) const
+{
+    ClearLastResult();
+
+    IList* pClientList = null;
+
+    switch(__deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER:
+    case WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING:
+       pClientList = __pWifiDirectSystemAdapter->GetGroupClientInfoListN();
+       break;
+    default:
+       SetLastResult(E_INVALID_OPERATION);
+       SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(GetLastResult()), GetStringOfCurrentState());
+       break;
+    }
+
+    return pClientList;
+}
+
+WifiRadioChannel
+_WifiDirectDeviceImpl::GetOperatingChannel(void) const
+{
+    WifiRadioChannel channel = WIFI_RADIO_CHANNEL_UNKNOWN;
+
+    switch(__deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER:
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT:
+    case WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING:
+        channel = __pWifiDirectSystemAdapter->GetOperatingChannel();
+       break;
+    default:
+       SysLog(NID_NET_WIFI, "The current state is %s.", GetStringOfCurrentState());
+       break;
+    }
+
+    return channel;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// WifiDirectDevice Event Listener
+
+void
+_WifiDirectDeviceImpl::OnWifiDirectDeviceActivated(const _WifiDirectEventArg& arg, result r)
+{
+       SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                                       GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+
+       bool isFired = false;
+
+    __stateMutex.Acquire();
+       switch (__deviceState)
+       {
+       case WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATED:
+       case WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATING:
+               if (r == E_SUCCESS)
+               {
+                       isFired = true;
+               }
+               break;
+       case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATING:
+               isFired = true;
+               break;
+       default:
+               break;
+       }
+
+       if (r == E_SUCCESS)
+       {
+               __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED;
+       }
+       else
+       {
+               __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATED;
+       }
+
+    __stateMutex.Release();
+       if (isFired)
+       {
+        _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+        SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        __pWifiDirectDeviceEvent->FireAsync(*pNewArg);
+
+       }
+       SysLog(NID_NET_WIFI, "[ACTIVATED_Event:%s]", isFired ? "Fired" : "NotFired");
+       SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                                       GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+}
+
+void
+_WifiDirectDeviceImpl::OnWifiDirectDeviceDeactivated(const _WifiDirectEventArg& arg, result r)
+{
+       SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                                       GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+
+       bool isFired = false;
+       WifiDirectDeviceInfo* pLocalDeviceInfo = null;
+       WifiDirectGroupMemberType groupMemberType = WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE;
+
+    __stateMutex.Acquire();
+
+       switch (__deviceState)
+       {
+       case WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATING:
+               isFired = true;
+               break;
+       default:
+               if (r == E_SUCCESS)
+               {
+                       isFired = true;
+               }
+               break;
+       }
+
+       if (r == E_SUCCESS)
+       {
+               __scanState = WIFI_DIRECT_SCAN_INTERNAL_IDLE;
+               __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATED;
+
+               __groupOwnerImpl.CleanUpServerSocket();
+               __groupClientImpl.CleanUpServerSocket();
+       }
+       else
+       {
+               if (__deviceState == WIFI_DIRECT_DEVICE_INTERNAL_DEACTIVATING)
+               {
+                       pLocalDeviceInfo = __pWifiDirectSystemAdapter->GetLocalDeviceInfoN();
+
+                       r = GetLastResult();
+
+                       if (pLocalDeviceInfo != null)
+                       {
+                               groupMemberType = pLocalDeviceInfo->GetGroupMemberType();
+                               delete pLocalDeviceInfo;
+
+                               switch (groupMemberType)
+                               {
+                               case WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE:
+                                       __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED;
+                                       break;
+                               case WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER:
+                                       __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER;
+                                       break;
+                               case WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT:
+                                       __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT;
+                                       break;
+                               }
+                       }
+                       else
+                       {
+                               __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED;
+                               SysLog(NID_NET_WIFI, "[E_SYSTEM] Failed to acquire information of local device");
+                       }
+               }
+       }
+    __stateMutex.Release();
+
+       if (isFired)
+       {
+           _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+           SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+           __pWifiDirectDeviceEvent->FireAsync(*pNewArg);
+       }
+
+       SysLog(NID_NET_WIFI, "[DEACTIVATED_Event:%s]", isFired ? "Fired" : "NotFired");
+       SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                                       GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+}
+
+void
+_WifiDirectDeviceImpl::OnWifiDirectGroupCreatedN(const _WifiDirectEventArg& arg,
+                                                                                                       WifiDirectGroupMemberType wifiDirectMemberType, result r)
+{
+       SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                                       GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+
+       bool isFired = false;
+
+    __stateMutex.Acquire();
+       // check the state, in case of (ACTIVATED or CREATED) and E_SUCCESS: Fire, CREATING: Fire.
+       switch (__deviceState)
+       {
+       case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED:
+               if (r == E_SUCCESS)
+               {
+                       isFired = true;
+               }
+               break;
+       case WIFI_DIRECT_DEVICE_INTERNAL_GROUP_CREATING:
+       case WIFI_DIRECT_DEVICE_INTERNAL_CONNECTING:
+    case WIFI_DIRECT_DEVICE_INTERNAL_CONNECT_CANCELLING:
+               isFired = true;
+               break;
+       default:
+           SysLog(NID_NET_WIFI, "[%s] The current state is %s", GetErrorMessage(r), GetStringOfCurrentState());
+           break;
+       }
+
+    __stateMutex.Release();
+
+       if (isFired)
+       {
+           WifiDirectGroupMember* pWifiDirectGroupMember = null;
+
+           if (wifiDirectMemberType == WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER)
+           {
+               pWifiDirectGroupMember = _WifiDirectGroupOwnerImpl::GetWifiDirectGroupOwnerInstanceN(__groupOwnerImpl);
+
+           }
+           else if(wifiDirectMemberType == WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT)
+        {
+            pWifiDirectGroupMember = _WifiDirectGroupClientImpl::GetWifiDirectGroupClientInstanceN(__groupClientImpl);
+        }
+
+           _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+           SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+           pNewArg->SetGroupMember(pWifiDirectGroupMember);
+
+           __pWifiDirectDeviceEvent->FireAsync(*pNewArg);
+       }
+
+       SysLog(NID_NET_WIFI, "[CREATED_Event:%s]", isFired ? "Fired" : "NotFired");
+       SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                                       GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+}
+
+void
+_WifiDirectDeviceImpl::OnWifiDirectScanCompletedN(const _WifiDirectEventArg& arg, result r)
+{
+       SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                                       GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+
+       bool isFired = false;
+
+    __stateMutex.Acquire();
+       if (__scanState != WIFI_DIRECT_SCAN_INTERNAL_IDLE)
+       {
+               isFired = true;
+               __scanState = WIFI_DIRECT_SCAN_INTERNAL_IDLE;
+       }
+    __stateMutex.Release();
+
+       if (isFired)
+       {
+           _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+           SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+           __pWifiDirectDeviceEvent->FireAsync(*pNewArg);
+       }
+
+       SysLog(NID_NET_WIFI, "[SCANCOMPLETED_Event:%s]", isFired ? "Fired" : "NotFired");
+       SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                                       GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+}
+
+void
+_WifiDirectDeviceImpl::OnWifiDirectAssociationCompleted(const _WifiDirectEventArg& arg, result r)
+{
+       SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                                       GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+
+       bool isFired = false;
+
+    __stateMutex.Acquire();
+       switch (__deviceState)
+       {
+       case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED:
+               if (r == E_SUCCESS)
+               {
+                       isFired = true;
+               }
+               break;
+       case WIFI_DIRECT_DEVICE_INTERNAL_CONNECTING:
+               isFired = true;
+               break;
+       default:
+           break;
+       }
+    __stateMutex.Release();
+
+       if (isFired)
+       {
+           _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+           SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+           __pWifiDirectDeviceEvent->FireAsync(*pNewArg);
+       }
+
+       SysLog(NID_NET_WIFI, "[ASSOCIATED_Event:%s]", isFired ? "Fired" : "NotFired");
+       SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                                       GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+}
+
+
+void
+_WifiDirectDeviceImpl::OnWifiDirectConnected(const _WifiDirectEventArg& arg, result r)
+{
+    SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                    GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+
+    bool isFired = false;
+
+    __stateMutex.Acquire();
+    switch (__deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED:
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER:
+        if (r == E_SUCCESS)
+        {
+            isFired = true;
+        }
+        break;
+    case WIFI_DIRECT_DEVICE_INTERNAL_CONNECTING:
+    case WIFI_DIRECT_DEVICE_INTERNAL_CONNECT_CANCELLING:
+        isFired = true;
+        break;
+    default:
+        SysLog(NID_NET_WIFI, "[%s] The current state is %s.", GetErrorMessage(r), GetStringOfCurrentState());
+        break;
+    }
+
+    WifiDirectGroupMemberType wifiDirectMemberType = __pWifiDirectSystemAdapter->GetCurrentMemberType();
+    if (r == E_SUCCESS && wifiDirectMemberType != WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+    {
+        if (wifiDirectMemberType == WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER)
+        {
+            __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER;
+        }
+        else if (wifiDirectMemberType == WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT)
+        {
+            __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT;
+        }
+    }
+    else
+    {
+        __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED;
+    }
+
+    __stateMutex.Release();
+
+    if (isFired)
+    {
+        _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+        SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        __pWifiDirectDeviceEvent->FireAsync(*pNewArg);
+    }
+
+    SysLog(NID_NET_WIFI, "[CONNECTED_Event:%s]", isFired ? "Fired" : "NotFired");
+    SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+}
+
+void
+_WifiDirectDeviceImpl::OnWifiDirectDisconnected(const _WifiDirectEventArg& arg, result r)
+{
+    SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                    GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+    bool isFired = false;
+
+    __stateMutex.Acquire();
+
+    switch (__deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER:
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT:
+        if (r == E_SUCCESS)
+        {
+            isFired = true;
+        }
+        break;
+    case WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING:
+        isFired = true;
+        break;
+    default:
+        break;
+    }
+
+    WifiDirectGroupMemberType wifiDirectMemberType = __pWifiDirectSystemAdapter->GetCurrentMemberType();
+
+    if (wifiDirectMemberType == WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER)
+    {
+        __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER;
+    }
+    else if(wifiDirectMemberType == WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT)
+    {
+        __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT;
+    }
+    else
+    {
+        __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED;
+    }
+    __stateMutex.Release();
+
+    if (isFired)
+    {
+        _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+        SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        __pWifiDirectDeviceEvent->FireAsync(*pNewArg);
+    }
+
+    SysLog(NID_NET_WIFI, "[DISCONNECTED_Event:%s]", isFired ? "Fired" : "NotFired");
+    SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+}
+
+void
+_WifiDirectDeviceImpl::OnWifiDirectGroupLeft(const _WifiDirectEventArg& arg, result r)
+{
+    SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                   GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+    bool isFired = false;
+
+    __stateMutex.Acquire();
+
+    switch (__deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER:
+    case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT:
+       if (r == E_SUCCESS)
+       {
+           isFired = true;
+       }
+       break;
+    case WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING:
+    case WIFI_DIRECT_DEVICE_INTERNAL_LEAVING:
+       isFired = true;
+       break;
+    default:
+       break;
+    }
+
+    WifiDirectGroupMemberType wifiDirectMemberType = __pWifiDirectSystemAdapter->GetCurrentMemberType();
+
+    if (wifiDirectMemberType == WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER)
+    {
+       __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER;
+    }
+    else if(wifiDirectMemberType == WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT)
+    {
+       __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT;
+    }
+    else
+    {
+       __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED;
+    }
+    __stateMutex.Release();
+
+    if (isFired)
+    {
+       _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+       SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       __pWifiDirectDeviceEvent->FireAsync(*pNewArg);
+    }
+
+    SysLog(NID_NET_WIFI, "[LEFT_Event:%s]", isFired ? "Fired" : "NotFired");
+    SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s], [result:%s]",
+               GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+}
+
+void
+_WifiDirectDeviceImpl::OnWifiDirectAutonomousGroupCreated(const _WifiDirectEventArg& arg, result r)
+{
+    SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                    GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+
+    bool isFired = false;
+
+    __stateMutex.Acquire();
+    switch (__deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED:
+        if (r == E_SUCCESS)
+        {
+            isFired = true;
+        }
+        break;
+    case WIFI_DIRECT_DEVICE_INTERNAL_CONNECTING:
+    case WIFI_DIRECT_DEVICE_INTERNAL_GROUP_CREATING:
+        isFired = true;
+        break;
+    default:
+        SysLog(NID_NET_WIFI, "[%s] The current state is %s", GetErrorMessage(r), GetStringOfCurrentState());
+        break;
+    }
+
+    if (r == E_SUCCESS )
+    {
+        __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER;
+    }
+    else
+    {
+        __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED;
+    }
+
+    __stateMutex.Release();
+
+    if (isFired)
+    {
+        _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+        SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        __pWifiDirectDeviceEvent->FireAsync(*pNewArg);
+    }
+
+    SysLog(NID_NET_WIFI, "[AUTOGROUP_CREATED_Event:%s]", isFired ? "Fired" : "NotFired");
+    SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+}
+
+//////////////////////////////////////////////////////////////////////////
+// WifiDirectGroupOwner Event Listener
+void
+_WifiDirectDeviceImpl::OnWifiDirectClientAssociated(const _WifiDirectEventArg& arg)
+{
+       SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s]", GetStringOfCurrentState(), GetStringOfScanState());
+       bool isFired = false;
+
+       if (__deviceState == WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER
+               || __deviceState == WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING)
+       {
+               isFired = true;
+
+               _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+               SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               __pWifiDirectGroupOwnerEvent->FireAsync(*pNewArg);
+       }
+       SysLog(NID_NET_WIFI, "[CLIENT_ASSOCIATED_Event:%s]", isFired ? "Fired" : "NotFired");
+       SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s]", GetStringOfCurrentState(), GetStringOfScanState());
+}
+
+void
+_WifiDirectDeviceImpl::OnWifiDirectClientDisassociated(const _WifiDirectEventArg& arg,
+                                                                                                               WifiDirectAssociationTerminationReason reason)
+{
+       SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s]", GetStringOfCurrentState(), GetStringOfScanState());
+       bool isFired = false;
+
+       if (__deviceState == WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER
+               || __deviceState == WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING)
+       {
+               isFired = true;
+
+               if (reason == WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_SELF_INITIATED)
+               {
+                       __groupOwnerImpl.ResetDisconnect();
+               }
+
+        _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+        SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        __pWifiDirectGroupOwnerEvent->FireAsync(*pNewArg);
+       }
+
+       SysLog(NID_NET_WIFI, "[CLIENT_DISASSOCIATED_Event:%s]", isFired ? "Fired" : "NotFired");
+       SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s]", GetStringOfCurrentState(), GetStringOfScanState());
+}
+
+void
+_WifiDirectDeviceImpl::OnWifiDirectGroupDestroyed(const _WifiDirectEventArg& arg, result r)
+{
+       SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                                       GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+       bool isFired = false;
+
+       __stateMutex.Acquire();
+
+       switch (__deviceState)
+       {
+       case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER:
+               if (r == E_SUCCESS)
+               {
+                       isFired = true;
+               }
+               break;
+       case WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING:
+       case WIFI_DIRECT_DEVICE_INTERNAL_LEAVING:
+               isFired = true;
+               break;
+       default:
+           break;
+       }
+
+       if (r == E_SUCCESS)
+       {
+               __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_ACTIVATED;
+               __groupOwnerImpl.CleanUpServerSocket();
+               __groupClientImpl.CleanUpServerSocket();
+       }
+       else
+       {
+               __deviceState = WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER;
+       }
+       __stateMutex.Release();
+
+       if (isFired)
+       {
+        _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+        SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        __pWifiDirectGroupOwnerEvent->FireAsync(*pNewArg);
+       }
+
+       SysLog(NID_NET_WIFI, "[GROUPDELETED_Event:%s]", isFired ? "Fired" : "NotFired");
+       SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                               GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+}
+
+
+
+//////////////////////////////////////////////////////////////////////////
+// WifiDirectGroupClient Event Listener
+void
+_WifiDirectDeviceImpl::OnWifiDirectAssociationTerminated(const _WifiDirectEventArg& arg, result r)
+{
+       SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                                       GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+       bool isFired = false;
+
+    __stateMutex.Acquire();
+       switch (__deviceState)
+       {
+       case WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT:
+               if (r == E_SUCCESS)
+               {
+                       isFired = true;
+               }
+               break;
+       case WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING:
+       case WIFI_DIRECT_DEVICE_INTERNAL_LEAVING:
+               isFired = true;
+               break;
+       default:
+           break;
+       }
+
+       if (r == E_SUCCESS)
+       {
+               __groupOwnerImpl.CleanUpServerSocket();
+               __groupClientImpl.CleanUpServerSocket();
+       }
+
+    __stateMutex.Release();
+
+       if (isFired)
+       {
+        _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+        SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+           __pWifiDirectGroupClientEvent->FireAsync(*pNewArg);
+       }
+
+       SysLog(NID_NET_WIFI, "[DISASSOCIATED_Event:%s]", isFired ? "Fired" : "NotFired");
+       SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                                       GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+
+}
+
+void
+_WifiDirectDeviceImpl::OnWifiDirectGroupOwnerInfoReceived(const _WifiDirectEventArg& arg, result r)
+{
+       SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                               GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+
+       bool isFired = false;
+
+
+       if (__deviceState == WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT)
+       {
+               isFired = true;
+
+        _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+        SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        __pWifiDirectGroupClientEvent->FireAsync(*pNewArg);
+       }
+
+       SysLog(NID_NET_WIFI, "[GROUPINFORESPONDED_Event:%s]", isFired ? "Fired" : "NotFired");
+       SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                               GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+}
+
+void
+_WifiDirectDeviceImpl::OnWifiDirectAllGroupMemberInfoReceivedN(const _WifiDirectEventArg& arg, result r)
+{
+       SysLog(NID_NET_WIFI, "Enter, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                               GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+
+       bool isFired = false;
+
+
+       if (__deviceState == WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT)
+       {
+               isFired = true;
+
+        _WifiDirectEventArg* pNewArg = new (std::nothrow)_WifiDirectEventArg(arg);
+        SysTryReturnVoidResult(NID_NET_WIFI, pNewArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        __pWifiDirectGroupClientEvent->FireAsync(*pNewArg);
+       }
+
+       SysLog(NID_NET_WIFI, "[GROUPINFORESPONDED_Event:%s]", isFired ? "Fired" : "NotFired");
+       SysLog(NID_NET_WIFI, "Exit, [DeviceState:%s], [ScanState:%s], [result:%s]",
+                                       GetStringOfCurrentState(), GetStringOfScanState(), GetErrorMessage(r));
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Internal Function
+int
+_WifiDirectDeviceImpl::AddRef(void)
+{
+       return ++__refCount;
+}
+
+int
+_WifiDirectDeviceImpl::Release(void)
+{
+       __refCount--;
+
+       if (__refCount == 0)
+       {
+               __pWifiDirectSystemAdapter->RemoveListener(*this);
+
+               delete this;
+               return 0;
+       }
+
+       return __refCount;
+}
+
+_WifiDirectDeviceState
+_WifiDirectDeviceImpl::GetWifiDirectDeviceCurrentState(void) const
+{
+       SysLog(NID_NET_WIFI, "[DeviceState:%s], [ScanState:%s]", GetStringOfCurrentState(), GetStringOfScanState());
+       return __deviceState;
+}
+
+void
+_WifiDirectDeviceImpl::SetWifiDirectDeviceCurrentState(_WifiDirectDeviceState currentState)
+{
+       SysLog(NID_NET_WIFI, "[DeviceState:%s], [ScanState:%s]", GetStringOfCurrentState(), GetStringOfScanState());
+       __deviceState = currentState;
+}
+
+
+_WifiDirectGroupOwnerEvent*
+_WifiDirectDeviceImpl::GetWifiDirectGroupOwnerEvent() const
+{
+    return __pWifiDirectGroupOwnerEvent.get();
+}
+
+_WifiDirectGroupClientEvent*
+_WifiDirectDeviceImpl::GetWifiDirectGroupClientEvent() const
+{
+    return __pWifiDirectGroupClientEvent.get();
+}
+
+
+const char*
+_WifiDirectDeviceImpl::GetStringOfCurrentState(void) const
+{
+       const char* pStateStr[] = { "DEACTIVATED",
+                                   "ACTIVATING",
+                                   "DEACTIVATING",
+                                   "ACTIVATED",
+                                   "CONNECTING",
+                                   "CONNECT_CANCELLING",
+                                   "CREATED_OWNER",
+                                   "CREATED_CLIENT",
+                                   "DISCONNECTING",
+                                   "LEAVING",
+                                   "GROUP_CREATING" };
+
+       return pStateStr[__deviceState];
+}
+
+const char*
+_WifiDirectDeviceImpl::GetStringOfScanState(void) const
+{
+       const char* pStateStr[] = { "IDLE",
+                                                               "SCANNING",
+                                                               "CANCELLING"};
+
+       return pStateStr[__scanState];
+}
+
+_WifiDirectDeviceImpl*
+_WifiDirectDeviceImpl::CreateWifiDirectDeviceImplInstanceN(void)
+{
+    _WifiDirectDeviceImpl* pWifiDirectDeviceImpl = null;
+
+    pWifiDirectDeviceImpl = new (std::nothrow) _WifiDirectDeviceImpl();
+
+    SysTryReturn(NID_NET_WIFI, pWifiDirectDeviceImpl != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    return pWifiDirectDeviceImpl;
+}
+
+WifiDirectDevice*
+_WifiDirectDeviceImpl::GetWifiDirectDeviceInstanceN(const WifiDirectDeviceInfo* pDeviceInfo)
+{
+    result r = E_SUCCESS;
+
+    WifiDirectDevice* pWifiDirectDevice = null;
+
+    pWifiDirectDevice = new (std::nothrow) WifiDirectDevice;
+    SysTryCatch(NID_NET_WIFI, pWifiDirectDevice != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    if (pDeviceInfo == null)
+    {
+        _WifiDirectSystemAdapter* pWifiSystemAdapter = null;
+        IList* pWifiDirectDeviceInfoList = null;
+        WifiDirectDeviceInfo* pTempDeviceInfo = null;
+
+        pWifiSystemAdapter = _WifiDirectSystemAdapter::GetInstance();
+
+        SysTryCatch(NID_NET_WIFI, pWifiSystemAdapter != null, , E_SYSTEM,
+                                               "[E_SYSTEM] Failed to acquire the instance of _WifiDirectSystemAdapter.");
+
+        pWifiDirectDeviceInfoList = pWifiSystemAdapter->GetAllDeviceInfoN();
+
+        r = GetLastResult();
+
+        SysTryCatch(NID_NET_WIFI, pWifiDirectDeviceInfoList != null, ,r,
+                                               "[%s] Failed to acquire the list of WifiDiectDeviceInfo.", GetErrorMessage(r));
+
+        // Get the default setting info
+        pTempDeviceInfo = static_cast< WifiDirectDeviceInfo* >(pWifiDirectDeviceInfoList->GetAt(0));
+
+        SysLog(NID_NET_WIFI, "device ID is %d", pTempDeviceInfo->GetDeviceId());
+
+        r = pWifiDirectDevice->Construct(pTempDeviceInfo->GetDeviceId());
+
+        // release resource
+        pWifiDirectDeviceInfoList->RemoveAll(true);
+
+        delete pWifiDirectDeviceInfoList;
+
+    }
+    else
+    {
+        r = pWifiDirectDevice->Construct(pDeviceInfo->GetDeviceId());
+    }
+
+    SetLastResult(r);
+    SysLog(NID_NET_WIFI, "Exit, [result:%s]", GetErrorMessage(r));
+    return pWifiDirectDevice;
+
+CATCH:
+    if (pWifiDirectDevice != null)
+    {
+        delete pWifiDirectDevice;
+    }
+
+    SysLog(NID_NET_WIFI, "Exit, [result:%s]", GetErrorMessage(r));
+    return null;
+}
+
+WifiDirectDevice*
+_WifiDirectDeviceImpl::GetWifiDirectDeviceInstanceWithoutIpServiceN(void)
+{
+    static const wchar_t* _WIFI_DIRECT = L"http://tizen.org/feature/network.wifi.direct";
+    static const int DEFAULT_ID = 0;
+
+    result r = E_SUCCESS;
+    bool isWifiDirectSupported = false;
+
+    r = _SystemInfoImpl::GetSysInfo(_WIFI_DIRECT, isWifiDirectSupported);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS && isWifiDirectSupported == true, null, E_UNSUPPORTED_OPERATION,
+            "[E_UNSUPPORTED_OPERATION] No WifiDirectDeviceInfo available since the device don't support the Wi-Fi Direct.");
+
+    unique_ptr<WifiDirectDevice> pWifiDirectDevice(new (std::nothrow) WifiDirectDevice);
+    SysTryReturn(NID_NET_WIFI, pWifiDirectDevice != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    unique_ptr<_WifiDirectDeviceImpl> pWifiDirectDeviceImpl(_WifiDirectDeviceImpl::CreateWifiDirectDeviceImplInstanceN());
+    SysTryReturn(NID_NET_WIFI, pWifiDirectDeviceImpl != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    r = pWifiDirectDeviceImpl->Construct(DEFAULT_ID, false);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    pWifiDirectDevice->__pWifiDirectDeviceImpl = pWifiDirectDeviceImpl.release();
+
+    return pWifiDirectDevice.release();
+}
+
+IList*
+_WifiDirectDeviceImpl::GetAllDeviceInfoN(void)
+{
+    result r = E_SUCCESS;
+
+    _WifiDirectSystemAdapter* pWifiSystemAdapter = null;
+    IList* pWifiDirectDeviceInfoList = null;
+
+    pWifiSystemAdapter = _WifiDirectSystemAdapter::GetInstance();
+
+    SysTryCatch(NID_NET_WIFI, pWifiSystemAdapter != null, r = E_SYSTEM, E_SYSTEM,
+                                       "[E_SYSTEM] Failed to acquire the instance of _WifiDirectSystemAdapter.");
+
+    pWifiDirectDeviceInfoList = pWifiSystemAdapter->GetAllDeviceInfoN();
+    r = GetLastResult();
+
+    SysTryCatch(NID_NET_WIFI, pWifiDirectDeviceInfoList != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+
+CATCH:
+    SysLog(NID_NET_WIFI, "Exit, [result:%s]", GetErrorMessage(r));
+    SetLastResult(r);
+    return pWifiDirectDeviceInfoList;
+}
+
+_WifiDirectDeviceImpl*
+_WifiDirectDeviceImpl::GetInstance(WifiDirectDevice& wifiDirectDevice)
+{
+    return wifiDirectDevice.__pWifiDirectDeviceImpl;
+}
+
+const _WifiDirectDeviceImpl*
+_WifiDirectDeviceImpl::GetInstance(const WifiDirectDevice& wifiDirectDevice)
+{
+    return wifiDirectDevice.__pWifiDirectDeviceImpl;
+}
+
+}}}// Tizen::Net::Wifi
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+_OSP_EXPORT_ void
+_WifiDirectDeviceImpl_DeleteWifiDirectDevice(Tizen::Net::Wifi::WifiDirectDevice* pWifiDirectDevice, Tizen::Net::Wifi::IWifiDirectDeviceListener* pDeviceListener,
+                                            Tizen::Net::Wifi::IWifiDirectGroupOwnerListener* pOwnerListener, Tizen::Net::Wifi::IWifiDirectGroupClientListener* pClientListener)
+{
+    SysTryReturnVoidResult(NID_NET_WIFI, pWifiDirectDevice != null, E_INVALID_ARG, "[E_INVALID_ARG] WifiDirectDevice is null.");
+
+    pWifiDirectDevice->RemoveWifiDirectGroupClientListener(*pClientListener);
+    pWifiDirectDevice->RemoveWifiDirectGroupOwnerListener(*pOwnerListener);
+    pWifiDirectDevice->RemoveWifiDirectDeviceListener(*pDeviceListener);
+
+    delete pWifiDirectDevice;
+
+    return;
+}
+
+_OSP_EXPORT_ result
+_WifiDirectDeviceImpl_Activate(void)
+{
+    Tizen::Net::Wifi::_WifiDirectSystemAdapter* pWifiDirectSystemAdapter = Tizen::Net::Wifi::_WifiDirectSystemAdapter::GetInstance();
+    SysTryReturnResult(NID_NET_WIFI, pWifiDirectSystemAdapter != null, E_OUT_OF_MEMORY, "Failed to get Wi-Fi System adapter instance");
+
+    return pWifiDirectSystemAdapter->Activate();
+}
+
+_OSP_EXPORT_ result
+_WifiDirectDeviceImpl_Deactivate(void)
+{
+    Tizen::Net::Wifi::_WifiDirectSystemAdapter* pWifiDirectSystemAdapter = Tizen::Net::Wifi::_WifiDirectSystemAdapter::GetInstance();
+    SysTryReturnResult(NID_NET_WIFI, pWifiDirectSystemAdapter != null, E_OUT_OF_MEMORY, "Failed to get Wi-Fi System adapter instance");
+
+    return pWifiDirectSystemAdapter->Deactivate();
+}
+
+_OSP_EXPORT_ bool
+_WifiDirectDeviceImpl_IsActivated(void)
+{
+    Tizen::Net::Wifi::_WifiDirectSystemAdapter* pWifiDirectSystemAdapter = Tizen::Net::Wifi::_WifiDirectSystemAdapter::GetInstance();
+    SysTryReturnResult(NID_NET_WIFI, pWifiDirectSystemAdapter != null, E_OUT_OF_MEMORY, "Failed to get Wi-Fi System adapter instance");
+
+    return pWifiDirectSystemAdapter->IsActivated();
+}
+
+_OSP_EXPORT_ bool
+_WifiDirectDeviceImpl_IsGroupMember(void)
+{
+    Tizen::Net::Wifi::_WifiDirectSystemAdapter* pWifiDirectSystemAdapter = Tizen::Net::Wifi::_WifiDirectSystemAdapter::GetInstance();
+    SysTryReturnResult(NID_NET_WIFI, pWifiDirectSystemAdapter != null, E_OUT_OF_MEMORY, "Failed to get Wi-Fi System adapter instance");
+
+    Tizen::Net::Wifi::WifiDirectGroupMemberType memberType = pWifiDirectSystemAdapter->GetCurrentMemberType();
+
+    if (memberType ==  Tizen::Net::Wifi::WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+    {
+        return false;
+    }
+
+    return true;
+}
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/wifi/FNetWifi_WifiDirectDeviceInfoImpl.cpp b/src/wifi/FNetWifi_WifiDirectDeviceInfoImpl.cpp
new file mode 100644 (file)
index 0000000..9c54276
--- /dev/null
@@ -0,0 +1,497 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifiWifiDirectDeviceInfoImpl.cpp
+ * @brief   This is the implementation file for the _WifiDirectDeviceInfoImpl class.
+ *
+ * This header file contains implementation of the _WifiDirectDeviceInfoImpl class.
+ */
+
+#include <FOspConfig.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FNetIp4Address.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiDirectDeviceInfoImpl.h"
+#include "FNetWifi_WifiDirectUtility.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen {      namespace Net { namespace Wifi
+{
+
+////////////////////////////////////////////////////////////////////////////////
+/// Lifecycle : Public
+_WifiDirectDeviceInfoImpl::_WifiDirectDeviceInfoImpl(void)
+    : __localDeviceId(-1)
+    , __deviceName("")
+    , __macAddress("")
+    , __virtualMacAddress("")
+    , __ssid("")
+    , __pIpAddress(null)
+    , __deviceStatus(WIFI_DIRECT_DEVICE_DEACTIVATED)
+    , __groupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+    , __deviceTypeCategory(WIFI_DIRECT_DEVICE_TYPE_CATEGORY_OTHERS)
+    , __isDisconnecting(false)
+{
+
+}
+
+_WifiDirectDeviceInfoImpl::_WifiDirectDeviceInfoImpl(const _WifiDirectDeviceInfoImpl& value)
+    : __localDeviceId(value.__localDeviceId)
+    , __deviceName(value.__deviceName)
+    , __macAddress(value.__macAddress)
+    , __virtualMacAddress(value.__virtualMacAddress)
+    , __ssid(value.__ssid)
+    , __pIpAddress(null)
+    , __deviceStatus(value.__deviceStatus)
+    , __groupMemberType(value.__groupMemberType)
+    , __deviceTypeCategory(value.__deviceTypeCategory)
+    , __isDisconnecting(false)
+{
+       __wpsConfigurationModeList.Construct(value.__wpsConfigurationModeList);
+
+       if (value.__pIpAddress != null)
+       {
+               Ip4Address* pIp4Addr = null;
+               pIp4Addr = dynamic_cast<Ip4Address*>(value.__pIpAddress);
+
+               if (pIp4Addr != null)
+        {
+                       __pIpAddress = new (std::nothrow) Ip4Address(*pIp4Addr);
+        }
+       }
+}
+
+_WifiDirectDeviceInfoImpl::_WifiDirectDeviceInfoImpl(const String& deviceName, const String& macAddr)
+    :   __localDeviceId(-1)
+    , __deviceName(deviceName)
+    , __macAddress(macAddr)
+    , __virtualMacAddress("")
+    , __ssid("")
+    , __pIpAddress(null)
+    , __deviceStatus(WIFI_DIRECT_DEVICE_DEACTIVATED)
+    , __groupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+    , __deviceTypeCategory(WIFI_DIRECT_DEVICE_TYPE_CATEGORY_OTHERS)
+    , __isDisconnecting(false)
+{
+
+}
+
+_WifiDirectDeviceInfoImpl::~_WifiDirectDeviceInfoImpl(void)
+{
+       if (__pIpAddress != null)
+       {
+               delete __pIpAddress;
+               __pIpAddress = null;
+       }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Operation : Public
+_WifiDirectDeviceInfoImpl&
+_WifiDirectDeviceInfoImpl::operator=(const _WifiDirectDeviceInfoImpl& rhs)
+{
+       if (this != &rhs)
+       {
+               __localDeviceId = rhs.__localDeviceId;
+               __deviceName = rhs.__deviceName;
+               __macAddress = rhs.__macAddress;
+               __virtualMacAddress = rhs.__virtualMacAddress;
+               __ssid = rhs.__ssid;
+               __deviceStatus = rhs.__deviceStatus;
+               __groupMemberType = rhs.__groupMemberType;
+               __deviceTypeCategory = rhs.__deviceTypeCategory;
+                __isDisconnecting = rhs.__isDisconnecting;
+               __wpsConfigurationModeList.Construct(rhs.__wpsConfigurationModeList);
+
+               IpAddress* pOrigIpAddr = null;
+        Ip4Address* pIp4Addr = null;
+
+        pIp4Addr = dynamic_cast<Ip4Address*>(rhs.__pIpAddress);
+
+        if (pIp4Addr != null)
+        {
+            pOrigIpAddr = __pIpAddress;
+            __pIpAddress = new (std::nothrow) Ip4Address(*pIp4Addr);
+
+            SysTryCatch(NID_NET_WIFI, __pIpAddress != null, __pIpAddress = pOrigIpAddr, E_OUT_OF_MEMORY,
+                                "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+            delete pOrigIpAddr;
+        }
+       }
+CATCH:
+       return *this;
+}
+
+WifiDirectDeviceId
+_WifiDirectDeviceInfoImpl::GetDeviceId(void) const
+{
+       return __localDeviceId;
+}
+
+String
+_WifiDirectDeviceInfoImpl::GetDeviceName(void) const
+{
+       return __deviceName;
+}
+
+String
+_WifiDirectDeviceInfoImpl::GetMacAddress(void) const
+{
+       return __macAddress;
+}
+
+const IpAddress*
+_WifiDirectDeviceInfoImpl::GetIpAddress(void) const
+{
+       return __pIpAddress;
+}
+
+Tizen::Base::String
+_WifiDirectDeviceInfoImpl::GetSsid(void) const
+{
+       return __ssid;
+}
+
+WifiDirectDeviceStatus
+_WifiDirectDeviceInfoImpl::GetDeviceStatus(void) const
+{
+       return __deviceStatus;
+}
+
+WifiDirectGroupMemberType
+_WifiDirectDeviceInfoImpl::GetGroupMemberType(void) const
+{
+       return __groupMemberType;
+}
+
+WifiDirectDeviceTypeCategory
+_WifiDirectDeviceInfoImpl::GetDeviceTypeCategory(void) const
+{
+       return __deviceTypeCategory;
+}
+const Tizen::Base::Collection::IListT<WifiWpsConfigurationMode>*
+_WifiDirectDeviceInfoImpl::GetSupportedWpsConfigurationModeList(void) const
+{
+       return &__wpsConfigurationModeList;
+}
+
+void
+_WifiDirectDeviceInfoImpl::SetDeviceId(const WifiDirectDeviceId localDeviceId)
+{
+       __localDeviceId = localDeviceId;
+}
+
+result
+_WifiDirectDeviceInfoImpl::SetDeviceName(const String& deviceName)
+{
+       int nameLength = deviceName.GetLength();
+
+       // need to check(device name's length)
+       SysTryReturnResult(NID_NET_WIFI, nameLength > 0 && nameLength <= MAX_DEVICE_NAME_LENGTH, E_INVALID_ARG,
+                                               "The argument is invalid. The length of name is %d.", nameLength);
+
+       __deviceName = deviceName;
+
+       return E_SUCCESS;
+}
+
+result
+_WifiDirectDeviceInfoImpl::SetMacAddress(const String& macAddress)
+{
+       //need to check(mac address's range)
+       SysTryReturnResult(NID_NET_WIFI, _WifiDirectUtility::CheckMacAddress(macAddress), E_INVALID_ARG,
+                                               "The argument is invalid.");
+
+       __macAddress = macAddress;
+
+       return E_SUCCESS;
+}
+
+result
+_WifiDirectDeviceInfoImpl::SetIpAddress(const String& ipAddress)
+{
+       if (__pIpAddress != null)
+       {
+               delete __pIpAddress;
+       }
+
+       __pIpAddress = new (std::nothrow) Ip4Address(ipAddress);
+    SysTryReturnResult(NID_NET_WIFI, __pIpAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       return E_SUCCESS;
+}
+
+result
+_WifiDirectDeviceInfoImpl::SetSsid(const Tizen::Base::String& ssid)
+{
+       //need to check arg(ssid)
+       result r = E_SUCCESS;
+
+       __ssid = ssid;
+
+       return r;
+}
+
+void
+_WifiDirectDeviceInfoImpl::SetDeviceStatus(const WifiDirectDeviceStatus& deviceStatus)
+{
+       __deviceStatus = deviceStatus;
+}
+
+void
+_WifiDirectDeviceInfoImpl::SetGroupMemberType(const WifiDirectGroupMemberType& groupMemberType)
+{
+       __groupMemberType = groupMemberType;
+}
+
+void
+_WifiDirectDeviceInfoImpl::SetDeviceTypeCategory(const WifiDirectDeviceTypeCategory& deviceTypeCategory)
+{
+       __deviceTypeCategory = deviceTypeCategory;
+}
+
+void
+_WifiDirectDeviceInfoImpl::SetSupportedWpsConfigurationMode(
+                                               const Tizen::Base::Collection::IListT<WifiWpsConfigurationMode>& wpsConfigurationModeList)
+{
+       result r = E_SUCCESS;
+       r = __wpsConfigurationModeList.Construct(wpsConfigurationModeList);
+       SetLastResult(r);
+}
+
+void
+_WifiDirectDeviceInfoImpl::SetSsidOfWifiDirectDeviceInfo(WifiDirectDeviceInfo& wifiDirectDeviceInfo, const String& ssid)
+{
+    wifiDirectDeviceInfo.__pWifiDirectDeviceInfoImpl->SetSsid(ssid);
+}
+
+WifiDirectDeviceInfo*
+_WifiDirectDeviceInfoImpl::GetWifiDirectDeviceInfoInstanceN(_WifiDirectDeviceInfoImpl& wifiDirectDeviceInfoImpl)
+{
+       PrintDeviceInfo(wifiDirectDeviceInfoImpl);
+
+       WifiDirectDeviceInfo* pWifiDirectDeviceInfo = new (std::nothrow) WifiDirectDeviceInfo();
+
+    SysTryReturn(NID_NET_WIFI, pWifiDirectDeviceInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       *(pWifiDirectDeviceInfo->__pWifiDirectDeviceInfoImpl) = wifiDirectDeviceInfoImpl;
+
+       return pWifiDirectDeviceInfo;
+}
+
+void
+_WifiDirectDeviceInfoImpl::PrintDeviceInfo(const _WifiDirectDeviceInfoImpl& wifiDirectDeviceInfo)
+{
+       SysLog(NID_NET_WIFI, "WifiDirectDeviceId : (%d) ", wifiDirectDeviceInfo.GetDeviceId());
+       SysLog(NID_NET_WIFI, "WifiDirectDeviceName : (%ls) ", wifiDirectDeviceInfo.GetDeviceName().GetPointer());
+       SysLog(NID_NET_WIFI, "WifiDirectMacAddress : (%ls) ", wifiDirectDeviceInfo.GetMacAddress().GetPointer());
+       SysLog(NID_NET_WIFI, "WifiDirectVirtualMacAddress : (%ls) ", wifiDirectDeviceInfo.GetVirtualMacAddress().GetPointer());
+       SysLog(NID_NET_WIFI, "WifiDirectSsid : (%ls) ", wifiDirectDeviceInfo.GetSsid().GetPointer());
+       if (wifiDirectDeviceInfo.GetDeviceStatus() == WIFI_DIRECT_DEVICE_ACTIVATED)
+       {
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceStatus : Activated");
+       }
+       else if (wifiDirectDeviceInfo.GetDeviceStatus() == WIFI_DIRECT_DEVICE_DEACTIVATED)
+       {
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceStatus : Deactivated");
+       }
+
+       if (wifiDirectDeviceInfo.GetGroupMemberType() == WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER)
+       {
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceMemberType : OWNER");
+       }
+       else if (wifiDirectDeviceInfo.GetGroupMemberType() == WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT)
+       {
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceMemberType : Client");
+       }
+       else if (wifiDirectDeviceInfo.GetGroupMemberType() == WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+       {
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceMemberType : NONE");
+       }
+
+       switch (wifiDirectDeviceInfo.GetDeviceTypeCategory())
+       {
+       case WIFI_DIRECT_DEVICE_TYPE_CATEGORY_COMPUTER:
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceTypeCategory : WIFI_DIRECT_DEVICE_TYPE_CATEGORY_COMPUTER");
+               break;
+       case WIFI_DIRECT_DEVICE_TYPE_CATEGORY_INPUT_DEVICE:
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceTypeCategory : WIFI_DIRECT_DEVICE_TYPE_CATEGORY_INPUT_DEVICE");
+               break;
+       case WIFI_DIRECT_DEVICE_TYPE_CATEGORY_PRINTER_SCANNER_FAX_COPIER:
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceTypeCategory : WIFI_DIRECT_DEVICE_TYPE_CATEGORY_PRINTER_SCANNER_FAX_COPIER");
+               break;
+       case WIFI_DIRECT_DEVICE_TYPE_CATEGORY_CAMERA:
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceTypeCategory : WIFI_DIRECT_DEVICE_TYPE_CATEGORY_CAMERA");
+               break;
+       case WIFI_DIRECT_DEVICE_TYPE_CATEGORY_STORAGE:
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceTypeCategory : WIFI_DIRECT_DEVICE_TYPE_CATEGORY_STORAGE");
+               break;
+       case WIFI_DIRECT_DEVICE_TYPE_CATEGORY_NETWORK_INFRASTRUCTURE:
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceTypeCategory : WIFI_DIRECT_DEVICE_TYPE_CATEGORY_NETWORK_INFRASTRUCTURE");
+               break;
+       case WIFI_DIRECT_DEVICE_TYPE_CATEGORY_DISPLAY:
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceTypeCategory : WIFI_DIRECT_DEVICE_TYPE_CATEGORY_DISPLAY");
+               break;
+       case WIFI_DIRECT_DEVICE_TYPE_CATEGORY_MULTIMEDIA_DEVICE:
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceTypeCategory : WIFI_DIRECT_DEVICE_TYPE_CATEGORY_MULTIMEDIA_DEVICE");
+               break;
+       case WIFI_DIRECT_DEVICE_TYPE_CATEGORY_GAMING_DEVICE:
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceTypeCategory : WIFI_DIRECT_DEVICE_TYPE_CATEGORY_GAMING_DEVICE");
+               break;
+       case WIFI_DIRECT_DEVICE_TYPE_CATEGORY_TELEPHONE:
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceTypeCategory : WIFI_DIRECT_DEVICE_TYPE_CATEGORY_TELEPHONE");
+               break;
+       case WIFI_DIRECT_DEVICE_TYPE_CATEGORY_AUDIO_DEVICE:
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceTypeCategory : WIFI_DIRECT_DEVICE_TYPE_CATEGORY_AUDIO_DEVICE");
+               break;
+       case WIFI_DIRECT_DEVICE_TYPE_CATEGORY_OTHERS:
+               SysLog(NID_NET_WIFI, "WifiDirectDeviceTypeCategory : WIFI_DIRECT_DEVICE_TYPE_CATEGORY_OTHERS");
+               break;
+       }
+
+       if (wifiDirectDeviceInfo.GetIpAddress())
+       {
+               SysLog(NID_NET_WIFI, "WifiDirectIpAddress : (%ls) ", wifiDirectDeviceInfo.GetIpAddress()->ToString().GetPointer());
+       }
+       else
+       {
+               SysLog(NID_NET_WIFI, "WifiDirectIpAddress is null.");
+       }
+}
+
+Tizen::Base::String
+_WifiDirectDeviceInfoImpl::GetVirtualMacAddress(void) const
+{
+       return __virtualMacAddress;
+}
+
+result
+_WifiDirectDeviceInfoImpl::SetVirtualMacAddress(const Tizen::Base::String& macAddress)
+{
+       //need to check(mac address's range)
+       SysTryReturnResult(NID_NET_WIFI, _WifiDirectUtility::CheckMacAddress(macAddress), E_INVALID_ARG,
+                                                               "The argument is invalid.");
+
+       __virtualMacAddress = macAddress;
+
+       return E_SUCCESS;
+}
+
+bool
+_WifiDirectDeviceInfoImpl::Equals(const Tizen::Base::Object& obj) const
+{
+    const _WifiDirectDeviceInfoImpl* pOther = dynamic_cast<const _WifiDirectDeviceInfoImpl*>(&obj);
+
+    if (pOther == null
+        || __localDeviceId != pOther->__localDeviceId
+        || !__deviceName.Equals(pOther->__deviceName)
+        || !__macAddress.Equals(pOther->__macAddress)
+        || !__virtualMacAddress.Equals(pOther->__virtualMacAddress)
+        || !__ssid.Equals(pOther->__ssid)
+        || __deviceStatus != pOther->__deviceStatus
+        || __groupMemberType != pOther->__groupMemberType
+        || __deviceTypeCategory != pOther->__deviceTypeCategory
+        || !__wpsConfigurationModeList.Equals(pOther->__wpsConfigurationModeList) )
+    {
+        return false;
+    }
+
+    if (__pIpAddress != null && pOther->__pIpAddress != null)
+    {
+        if( !__pIpAddress->Equals(*pOther->__pIpAddress) )
+        {
+            return false;
+        }
+    }
+    else if (__pIpAddress != null && pOther->__pIpAddress == null)
+    {
+        return false;
+    }
+    else if (__pIpAddress == null && pOther->__pIpAddress != null)
+    {
+        return false;
+    }
+
+    return true;
+}
+
+int
+_WifiDirectDeviceInfoImpl::GetHashCode(void) const
+{
+    return  __localDeviceId ^ __deviceName.GetHashCode() ^ __macAddress.GetHashCode() ^ __virtualMacAddress.GetHashCode() ^ __ssid.GetHashCode();
+}
+
+_WifiDirectDeviceInfoImpl*
+_WifiDirectDeviceInfoImpl::GetInstance(WifiDirectDeviceInfo& wifiDirectDeviceInfo)
+{
+    return wifiDirectDeviceInfo.__pWifiDirectDeviceInfoImpl;
+}
+
+const _WifiDirectDeviceInfoImpl*
+_WifiDirectDeviceInfoImpl::GetInstance(const WifiDirectDeviceInfo& wifiDirectDeviceInfo)
+{
+    return wifiDirectDeviceInfo.__pWifiDirectDeviceInfoImpl;
+}
+
+void
+_WifiDirectDeviceInfoImpl::SetDisconnect(bool value)
+{
+    __isDisconnecting = value;
+}
+bool
+_WifiDirectDeviceInfoImpl::IsDisconnecting(void)
+{
+    return __isDisconnecting;
+}
+
+} } }// Tizen::Net::Wifi
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+_OSP_EXPORT_ Tizen::Base::String
+_WifiDirectDeviceInfoImpl_GetDeviceName(const Tizen::Net::Wifi::WifiDirectDeviceInfo& deviceInfo)
+{
+       return deviceInfo.GetDeviceName();
+}
+
+_OSP_EXPORT_ const Tizen::Net::IpAddress*
+_WifiDirectDeviceInfoImpl_GetIpAddress(const Tizen::Net::Wifi::WifiDirectDeviceInfo& deviceInfo)
+{
+       return deviceInfo.GetIpAddress();
+}
+
+_OSP_EXPORT_ Tizen::Base::String
+_WifiDirectDeviceInfoImpl_GetVirtualMacAddress(const Tizen::Net::Wifi::WifiDirectDeviceInfo& deviceInfo)
+{
+       const Tizen::Net::Wifi::_WifiDirectDeviceInfoImpl* pWifiDirectDeviceInfoImpl = null;
+
+       pWifiDirectDeviceInfoImpl = Tizen::Net::Wifi::_WifiDirectDeviceInfoImpl::GetInstance(deviceInfo);
+       SysTryReturn(NID_NET_WIFI, pWifiDirectDeviceInfoImpl != null, Tizen::Base::String(L""), E_SYSTEM, 
+                       "[E_SYSTEM] A system error has occurred. Failed to get WifiDirectDeviceInfo instance.");
+
+       return  pWifiDirectDeviceInfoImpl->GetVirtualMacAddress();
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/wifi/FNetWifi_WifiDirectDeviceManagerImpl.cpp b/src/wifi/FNetWifi_WifiDirectDeviceManagerImpl.cpp
new file mode 100644 (file)
index 0000000..8e60342
--- /dev/null
@@ -0,0 +1,152 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectDeviceManagerImpl.cpp
+ * @brief   This is the implementation file for the _WifiDirectDeviceManagerImpl Class.
+ *
+ * This header file contains implementation of the _WifiDirectDeviceManagerImpl Class.
+ */
+
+#include <FOspConfig.h>
+#include <FNetWifiWifiDirectDeviceManager.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FNetWifiWifiDirectDevice.h>
+#include <FBaseColArrayList.h>
+#include <FBaseResult.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiDirectDeviceManagerImpl.h"
+#include "FNetWifi_WifiDirectDeviceImpl.h"
+
+using namespace Tizen::Base::Collection;
+
+namespace Tizen {      namespace Net { namespace Wifi
+{
+
+////////////////////////////////////////////////////////////////////////////////
+/// Lifecycle : Public
+_WifiDirectDeviceManagerImpl::_WifiDirectDeviceManagerImpl(void)
+{
+
+}
+
+_WifiDirectDeviceManagerImpl::~_WifiDirectDeviceManagerImpl(void)
+{
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Operation : Public
+
+IList*
+_WifiDirectDeviceManagerImpl::GetAllDeviceInfoN(void)
+{
+       IList* pWifiDirectDeviceInfoList = null;
+
+       pWifiDirectDeviceInfoList = _WifiDirectDeviceImpl::GetAllDeviceInfoN();
+       result r = GetLastResult();
+
+    SysTryReturn(NID_NET_WIFI, pWifiDirectDeviceInfoList != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return pWifiDirectDeviceInfoList;
+}
+
+WifiDirectDevice*
+_WifiDirectDeviceManagerImpl::GetWifiDirectDeviceN(const WifiDirectDeviceInfo* pLocalDeviceInfo)
+{
+    if (pLocalDeviceInfo != null && pLocalDeviceInfo->GetDeviceId() == -1)
+    {
+        SysLogException(NID_NET_WIFI, E_INVALID_ARG, "[E_INVALID_ARG] The device ID is invalid.");
+        return null;
+    }
+    return _WifiDirectDeviceImpl::GetWifiDirectDeviceInstanceN(pLocalDeviceInfo);
+}
+
+_WifiDirectDeviceManagerImpl*
+_WifiDirectDeviceManagerImpl::GetInstance(WifiDirectDeviceManager& wifiDirectDeviceManager)
+{
+    return wifiDirectDeviceManager.__pWifiDirectDeviceManagerImpl;
+}
+
+const _WifiDirectDeviceManagerImpl*
+_WifiDirectDeviceManagerImpl::GetInstance(const WifiDirectDeviceManager& wifiDirectDeviceManager)
+{
+    return wifiDirectDeviceManager.__pWifiDirectDeviceManagerImpl;
+}
+
+} } }// Tizen::Net::Wifi
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+_OSP_EXPORT_ Tizen::Net::Wifi::WifiDirectDevice*
+_WifiDirectDeviceManagerImpl_GetWifiDirectDeviceN(Tizen::Net::Wifi::IWifiDirectDeviceListener* pDeviceListener, Tizen::Net::Wifi::IWifiDirectGroupOwnerListener* pOwnerListener, Tizen::Net::Wifi::IWifiDirectGroupClientListener* pClientListener)
+{
+       result r = E_SUCCESS;
+       Tizen::Net::Wifi::WifiDirectDevice* pWifiDirectDevice = null;
+
+       pWifiDirectDevice = Tizen::Net::Wifi::_WifiDirectDeviceImpl::GetWifiDirectDeviceInstanceWithoutIpServiceN();
+
+    SysTryReturn(NID_NET_WIFI, pWifiDirectDevice != null, null, E_SYSTEM, "[E_SYSTEM] Failed to acquire the instance of WifiDirectDevice.");
+
+    if (pDeviceListener != null)
+    {
+       r = pWifiDirectDevice->AddWifiDirectDeviceListener(*pDeviceListener);
+       SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Can't add a device listener.", GetErrorMessage(r));
+    }
+
+    if (pOwnerListener != null)
+    {
+       r = pWifiDirectDevice->AddWifiDirectGroupOwnerListener(*pOwnerListener);
+       SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Can't add an owner listener.", GetErrorMessage(r));
+    }
+
+    if (pClientListener != null)
+    {
+       r = pWifiDirectDevice->AddWifiDirectGroupClientListener(*pClientListener);
+       SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Can't add a client listener.", GetErrorMessage(r));
+    }
+
+       return pWifiDirectDevice;
+
+CATCH:
+       if (pWifiDirectDevice != null)
+       {
+           if (pClientListener != null)
+           {
+               pWifiDirectDevice->RemoveWifiDirectGroupClientListener(*pClientListener);
+           }
+           if (pOwnerListener != null)
+           {
+               pWifiDirectDevice->RemoveWifiDirectGroupOwnerListener(*pOwnerListener);
+           }
+           if (pDeviceListener != null)
+           {
+               pWifiDirectDevice->RemoveWifiDirectDeviceListener(*pDeviceListener);
+           }
+
+               delete pWifiDirectDevice;
+       }
+
+       return null;
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/wifi/FNetWifi_WifiDirectEvent.cpp b/src/wifi/FNetWifi_WifiDirectEvent.cpp
new file mode 100644 (file)
index 0000000..2c78daa
--- /dev/null
@@ -0,0 +1,133 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifiWifiDirectDeviceEvent.cpp
+ * @brief   This is the implementation file for the _WifiDirectEvent Class.
+ *
+ * This header file contains implementation of the _WifiDirectEvent Class.
+ */
+#include <FBaseRtIEventListener.h>
+#include <FNetWifiWifiDirectGroupMember.h>
+#include <FNetWifi_IWifiDirectListener.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiDirectEvent.h"
+#include "FNetWifi_WifiDirectEventArg.h"
+
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+////////////////////////////////////////////////////////////////////////////
+// Lifecycle : Public
+_WifiDirectEvent::_WifiDirectEvent(void)
+{
+}
+
+_WifiDirectEvent::~_WifiDirectEvent(void)
+{
+
+}
+
+result
+_WifiDirectEvent::Construct(void)
+{
+    return _Event::Initialize();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Operation : Protected
+
+void
+_WifiDirectEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+    _WifiDirectEventArg* pArg = const_cast< _WifiDirectEventArg*>(dynamic_cast<const _WifiDirectEventArg*>(&arg));
+    SysTryReturnVoidResult(NID_NET_WIFI, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is a null pointer.");
+
+    _IWifiDirectListener* pInternalListener = dynamic_cast<_IWifiDirectListener*>(&listener);
+    SysTryReturnVoidResult(NID_NET_WIFI, pInternalListener != null, E_INVALID_ARG,
+                "[E_INVALID_ARG] The result of a dynamic_cast operation is null for internal listener.");
+
+    _WifiDirectEventType eventType = pArg->GetEventType();
+    result r = pArg->GetError();
+
+    switch (eventType)
+    {
+    case WIFI_DIRECT_DEVICE_EVENT_ACTIVATED:
+        SysLog(NID_NET_WIFI, "Firing Internal Event (Type: WIFI_DIRECT_DEVICE_EVENT_ACTIVATED) : %s",GetErrorMessage(r));
+        pInternalListener->OnWifiDirectDeviceActivated(*pArg, r);
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_DEACTIVATED:
+        SysLog(NID_NET_WIFI, "Firing Internal Event (Type: WIFI_DIRECT_DEVICE_EVENT_DEACTIVATED) : %s",GetErrorMessage(r));
+        pInternalListener->OnWifiDirectDeviceDeactivated(*pArg, r);
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_GROUP_CREATED:
+        SysLog(NID_NET_WIFI, "Firing Internal Event (Type: WIFI_DIRECT_DEVICE_EVENT_GROUP_CREATED) : %s",GetErrorMessage(r));
+        pInternalListener->OnWifiDirectGroupCreatedN(*pArg, pArg->GetGroupMemberType(), r);
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_SCAN_COMPLETED:
+        SysLog(NID_NET_WIFI, "Firing Internal Event (Type: WIFI_DIRECT_DEVICE_EVENT_SCAN_COMPLETED) : %s",GetErrorMessage(r));
+        pInternalListener->OnWifiDirectScanCompletedN(*pArg, r);
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_ASSOCIATED:
+        SysLog(NID_NET_WIFI, "Firing Internal Event (Type: WIFI_DIRECT_DEVICE_EVENT_ASSOCIATED) : %s",GetErrorMessage(r));
+        pInternalListener->OnWifiDirectAssociationCompleted(*pArg, r);
+        break;
+    case WIFI_DIRECT_GO_EVENT_CLIENT_ASSOCIATED:
+        SysLog(NID_NET_WIFI, "Firing Internal Event (Type: WIFI_DIRECT_GO_EVENT_CLIENT_ASSOCIATED) : %s",GetErrorMessage(r));
+        pInternalListener->OnWifiDirectClientAssociated(*pArg);
+        break;
+    case WIFI_DIRECT_GO_EVENT_CLIENT_DISASSOCIATED:
+        SysLog(NID_NET_WIFI, "Firing Internal Event (Type: WIFI_DIRECT_GO_EVENT_CLIENT_DISASSOCIATED) : %s",GetErrorMessage(r));
+        {
+            WifiDirectAssociationTerminationReason reason = pArg->GetDisassociationReason();
+            pInternalListener->OnWifiDirectClientDisassociated(*pArg, reason);
+        }
+        break;
+    case WIFI_DIRECT_GO_EVENT_GROUP_DESTROYED:
+        SysLog(NID_NET_WIFI, "Firing Internal Event (Type: WIFI_DIRECT_GO_EVENT_GROUP_DESTROYED) : %s",GetErrorMessage(r));
+        pInternalListener->OnWifiDirectGroupDestroyed(*pArg, r);
+        break;
+    case WIFI_DIRECT_GC_EVENT_DISASSOCIATED:
+        SysLog(NID_NET_WIFI, "Firing Internal Event (Type: WIFI_DIRECT_GC_EVENT_DISASSOCIATED) : %s",GetErrorMessage(r));
+        pInternalListener->OnWifiDirectAssociationTerminated(*pArg, r);
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_CONNECTED:
+        SysLog(NID_NET_WIFI, "Firing Internal Event (Type: WIFI_DIRECT_DEVICE_EVENT_CONNECTED) : %s",GetErrorMessage(r));
+        pInternalListener->OnWifiDirectConnected(*pArg, r);
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_DISCONNECTED:
+        SysLog(NID_NET_WIFI, "Firing Internal Event (Type: WIFI_DIRECT_DEVICE_EVENT_DISCONNECTED) : %s",GetErrorMessage(r));
+        pInternalListener->OnWifiDirectDisconnected(*pArg, r);
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_AUTONOMOS_GROUP_CREATED:
+        SysLog(NID_NET_WIFI, "Firing Internal Event (Type: WIFI_DIRECT_DEVICE_EVENT_AUTONOMOS_GROUP_CREATED) : %s",GetErrorMessage(r));
+        pInternalListener->OnWifiDirectAutonomousGroupCreated(*pArg, r);
+        break;
+    case WIFI_DIRECT_DEVICE_EVENT_GROUP_LEFT:
+        SysLog(NID_NET_WIFI, "Firing Internal Event (Type: WIFI_DIRECT_DEVICE_EVENT_GROUP_LEFT) : %s",GetErrorMessage(r));
+        pInternalListener->OnWifiDirectGroupLeft(*pArg, r);
+        break;
+    default:
+        SysLog(NID_NET_WIFI, "An undefined internal WifiDirectDevice event occurs. (Type: %d)",eventType);
+        SysAssert(false);
+        break;
+    }
+}
+
+} } } // Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiDirectEvent.h b/src/wifi/FNetWifi_WifiDirectEvent.h
new file mode 100644 (file)
index 0000000..b3cfad2
--- /dev/null
@@ -0,0 +1,102 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectEvent.h
+ * @brief   This is the header file for the _WifiDirectEvent class.
+ *
+ * This header file contains declarations of the _WifiDirectEvent class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_DIRECT_EVENT_H_
+#define _FNET_WIFI_INTERNAL_WIFI_DIRECT_EVENT_H_
+
+// Includes
+#include <FBaseResult.h>
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventListener;
+class IEventArg;
+}}}
+
+namespace Tizen {      namespace Net { namespace Wifi
+{
+/**
+ * @class      _WifiDirectEvent
+ * @brief      This class handles WifiDirectevents.
+ *
+ * When a WifiDirect event occurs, the _WifiDirectEvent object finds a _IWifiDirectListener object
+ * which is registered for the Device object and calls an appropriate method of the listener.
+ */
+
+class _WifiDirectEvent
+    : public Tizen::Base::Runtime::_Event
+{
+public:
+       /**
+        * 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.
+        */
+       _WifiDirectEvent(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Runtime::_Event::~_Event().
+        */
+       virtual ~_WifiDirectEvent(void);
+
+       /**
+        * Initializes this instance.
+     */
+    result Construct(void);
+
+protected:
+       /**
+        * Checks the arg and finds out the type of event. After that this method calls appropriate pListener's method.
+        *
+        * @return              A result code.
+        * @param[in]   listener                                It is a event listener related to this WifiDirectDevice event.
+        * @param[in]   arg                                             It is an argument-like instance of WifiDirectDevice event retransmitted to the listener's method as an argument.
+        * @exception   E_SUCCESS                               The method is successful.
+        * @exception   E_INVALID_ARG                   The argument passed to a method contains an invalid value.@n
+        */
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+
+private:
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @since   2.0
+     * @param[in]   rhs   An instance of %_WifiDirectEvent
+     */
+       _WifiDirectEvent(const _WifiDirectEvent& rhs);
+    
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @since   2.0
+     *
+     * @param[in]   rhs   An instance of %_WifiDirectEvent
+     */
+       _WifiDirectEvent& operator =(const _WifiDirectEvent& rhs);
+
+}; // _WifiDirectEvent
+
+}}} // Tizen::Net::Wifi
+#endif // _FNET_WIFI_INTERNAL_WIFI_DIRECT_EVENT_H_
diff --git a/src/wifi/FNetWifi_WifiDirectEventArg.cpp b/src/wifi/FNetWifi_WifiDirectEventArg.cpp
new file mode 100644 (file)
index 0000000..ae74f52
--- /dev/null
@@ -0,0 +1,355 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetWifiWifiDirectDeviceEventArg.cpp
+ * @brief              This is the implementation file for the _WifiDirectEventArg Class.
+ *
+ * This header file contains implementation of the _WifiDirectEventArg Class.
+ */
+
+#include <FBaseColArrayList.h>
+#include <FNetWifiWifiDirectGroupInfo.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FNetNetConnection.h>
+#include <FBaseSysLog.h>
+#include <FBaseRtIEventArg.h>
+#include "FNetWifi_WifiDirectEventArg.h"
+
+using namespace Tizen::Base::Collection;
+
+
+namespace Tizen {      namespace Net { namespace Wifi
+{
+
+_WifiDirectEventArg::_WifiDirectEventArg(void)
+       : __eventType(WIFI_DIRECT_DEVICE_EVENT_NONE)
+    , __localDeviceId(-1)
+    , __error(E_SUCCESS)
+    , __pGroupInfo(null)
+    , __pDeviceInfo(null)
+    , __pDeviceInfoList(null)
+    , __wifiDirectGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+    , __disassociationReason(WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_SELF_INITIATED)
+    , __pNetConnection(null)
+    , __pGroupMember(null)
+{
+}
+
+_WifiDirectEventArg::_WifiDirectEventArg(const _WifiDirectEventArg& rhs)
+    : __eventType(rhs.__eventType)
+    , __localDeviceId(rhs.__localDeviceId)
+    , __error(rhs.__error)
+    , __pGroupInfo(null)
+    , __pDeviceInfo(null)
+    , __pDeviceInfoList(null)
+    , __wifiDirectGroupMemberType(rhs.__wifiDirectGroupMemberType)
+    , __disassociationReason(rhs.__disassociationReason)
+    , __pNetConnection(rhs.__pNetConnection)
+    , __pGroupMember(null)
+{
+    if (rhs.__pGroupInfo != null)
+    {
+        __pGroupInfo = new (std::nothrow) WifiDirectGroupInfo(*rhs.__pGroupInfo);
+        SysTryReturnVoidResult(NID_NET_WIFI, __pGroupInfo != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+    }
+
+    if (rhs.__pDeviceInfo != null)
+    {
+        __pDeviceInfo = new (std::nothrow) WifiDirectDeviceInfo(*rhs.__pDeviceInfo);
+        SysTryReturnVoidResult(NID_NET_WIFI, __pDeviceInfo != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+    }
+
+    if (rhs.__pDeviceInfoList != null)
+    {
+        __pDeviceInfoList = new (std::nothrow) ArrayList();
+        SysTryReturnVoidResult(NID_NET_WIFI, __pDeviceInfoList != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        result r = dynamic_cast<ArrayList*>(__pDeviceInfoList)->Construct(*rhs.__pDeviceInfoList);
+        SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+}
+
+_WifiDirectEventArg::~_WifiDirectEventArg(void)
+{
+    delete __pGroupInfo;
+    delete __pDeviceInfo;
+
+    if (__pDeviceInfoList != null)
+    {
+        __pDeviceInfoList->RemoveAll(false);
+
+        delete __pDeviceInfoList;
+    }
+}
+
+_WifiDirectEventArg::_WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId, result r)
+    : __eventType(eventType)
+    , __localDeviceId(localDeviceId)
+    , __error(r)
+    , __pGroupInfo(null)
+    , __pDeviceInfo(null)
+    , __pDeviceInfoList(null)
+    , __wifiDirectGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+    , __disassociationReason(WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_SELF_INITIATED)
+    , __pNetConnection(null)
+    , __pGroupMember(null)
+{
+
+}
+
+_WifiDirectEventArg::_WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId,
+                                    const WifiDirectGroupInfo& wifiDirectGroupInfo,
+                                                                       const WifiDirectDeviceInfo& wifiDirectGroupOwnerDeviceInfo,
+                                                                       const WifiDirectGroupMemberType wifiDirectMemberType, result r)
+    : __eventType(eventType)
+    , __localDeviceId(localDeviceId)
+    , __error(r)
+    , __pDeviceInfoList(null)
+    , __wifiDirectGroupMemberType(wifiDirectMemberType)
+    , __disassociationReason(WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_SELF_INITIATED)
+    , __pNetConnection(null)
+    , __pGroupMember(null)
+{
+    __pGroupInfo = new (std::nothrow) WifiDirectGroupInfo(wifiDirectGroupInfo);
+    SysTryReturnVoidResult(NID_NET_WIFI, __pGroupInfo != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    __pDeviceInfo = new (std::nothrow) WifiDirectDeviceInfo(wifiDirectGroupOwnerDeviceInfo);
+    SysTryReturnVoidResult(NID_NET_WIFI, __pDeviceInfo != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+_WifiDirectEventArg::_WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId,
+                                    Tizen::Base::Collection::IList* pDeviceInfoList, result r)
+    : __eventType(eventType)
+    , __localDeviceId(localDeviceId)
+    , __error(r)
+    , __pGroupInfo(null)
+    , __pDeviceInfo(null)
+    , __pDeviceInfoList(null)
+    , __wifiDirectGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+    , __disassociationReason(WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_SELF_INITIATED)
+    , __pNetConnection(null)
+    , __pGroupMember(null)
+{
+   if (pDeviceInfoList != null)
+   {
+       __pDeviceInfoList = new (std::nothrow) ArrayList();
+       SysTryReturnVoidResult(NID_NET_WIFI, __pDeviceInfoList != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+       result r = __pDeviceInfoList->Construct(*pDeviceInfoList);
+       SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+   }
+}
+
+_WifiDirectEventArg::_WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId,
+                                    const WifiDirectDeviceInfo& wifiDirectDeviceInfo, result r)
+    : __eventType(eventType)
+    , __localDeviceId(localDeviceId)
+    , __error(r)
+    , __pGroupInfo(null)
+    , __pDeviceInfoList(null)
+    , __wifiDirectGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+    , __disassociationReason(WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_SELF_INITIATED)
+    , __pNetConnection(null)
+    , __pGroupMember(null)
+{
+    __pDeviceInfo = new (std::nothrow) WifiDirectDeviceInfo(wifiDirectDeviceInfo);
+    SysTryReturnVoidResult(NID_NET_WIFI, __pDeviceInfo != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+_WifiDirectEventArg::_WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId,
+                                const WifiDirectDeviceInfo& wifiDirectDeviceInfo,
+                                                               WifiDirectAssociationTerminationReason disassociationReason, result r)
+    : __eventType(eventType)
+    , __localDeviceId(localDeviceId)
+    , __error(r)
+    , __pGroupInfo(null)
+    , __pDeviceInfo(null)
+    , __pDeviceInfoList(null)
+    , __wifiDirectGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+    , __disassociationReason(disassociationReason)
+    , __pNetConnection(null)
+    , __pGroupMember(null)
+{
+    __pDeviceInfo = new (std::nothrow) WifiDirectDeviceInfo(wifiDirectDeviceInfo);
+    SysTryReturnVoidResult(NID_NET_WIFI, __pDeviceInfo != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+}
+
+_WifiDirectEventArg::_WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId,
+                                                               WifiDirectAssociationTerminationReason disassociationReason, result r)
+    : __eventType(eventType)
+    , __localDeviceId(localDeviceId)
+    , __error(r)
+    , __pGroupInfo(null)
+    , __pDeviceInfo(null)
+    , __pDeviceInfoList(null)
+    , __wifiDirectGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+    , __disassociationReason(disassociationReason)
+    , __pNetConnection(null)
+    , __pGroupMember(null)
+{
+}
+
+_WifiDirectEventArg::_WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId,
+        Tizen::Net::NetConnection* pNetConnection, result r)
+    : __eventType(eventType)
+    , __localDeviceId(localDeviceId)
+    , __error(r)
+    , __pGroupInfo(null)
+    , __pDeviceInfo(null)
+    , __pDeviceInfoList(null)
+    , __wifiDirectGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+    , __disassociationReason(WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_SELF_INITIATED)
+    , __pNetConnection(pNetConnection)
+    , __pGroupMember(null)
+{
+}
+
+_WifiDirectEventArg::_WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId,
+        const Tizen::Base::String& remoteDeviceMacAddress, result r)
+    : __eventType(eventType)
+    , __localDeviceId(localDeviceId)
+    , __error(r)
+    , __pGroupInfo(null)
+    , __pDeviceInfo(null)
+    , __pDeviceInfoList(null)
+    , __wifiDirectGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+    , __disassociationReason(WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_SELF_INITIATED)
+    , __pNetConnection(null)
+    , __remoteDeviceMacAddress(remoteDeviceMacAddress)
+    , __pGroupMember(null)
+{
+
+}
+
+
+void
+_WifiDirectEventArg::SetGroupMember(WifiDirectGroupMember* pGroupMember)
+{
+    __pGroupMember = pGroupMember;
+}
+
+WifiDirectGroupMember*
+_WifiDirectEventArg::GetGroupMember(void) const
+{
+    return __pGroupMember;
+}
+
+_WifiDirectEventType
+_WifiDirectEventArg::GetEventType(void) const
+{
+       return __eventType;
+}
+
+result
+_WifiDirectEventArg::GetError(void) const
+{
+       return __error;
+}
+
+WifiDirectDeviceId
+_WifiDirectEventArg::GetDeviceId(void) const
+{
+       return __localDeviceId;
+}
+
+IList*
+_WifiDirectEventArg::GetDeviceInfoList(void) const
+{
+       return __pDeviceInfoList;
+}
+WifiDirectGroupInfo*
+_WifiDirectEventArg::GetGroupInfo(void) const
+{
+       return __pGroupInfo;
+}
+
+WifiDirectDeviceInfo*
+_WifiDirectEventArg::GetDeviceInfo(void) const
+{
+    return __pDeviceInfo;
+}
+
+WifiDirectGroupMemberType
+_WifiDirectEventArg::GetGroupMemberType(void) const
+{
+       return __wifiDirectGroupMemberType;
+}
+
+WifiDirectAssociationTerminationReason
+_WifiDirectEventArg::GetDisassociationReason(void) const
+{
+    return __disassociationReason;
+}
+
+Tizen::Net::NetConnection*
+_WifiDirectEventArg::GetNetConnection(void) const
+{
+    return __pNetConnection;
+}
+
+Tizen::Base::String
+_WifiDirectEventArg::GetMacAddress(void) const
+{
+    return __remoteDeviceMacAddress;
+}
+
+_WifiDirectEventArg&
+_WifiDirectEventArg::operator=(const _WifiDirectEventArg& rhs)
+{
+    if (this != &rhs)
+    {
+        __eventType = rhs.__eventType;
+        __localDeviceId = rhs.__localDeviceId;
+        __wifiDirectGroupMemberType = rhs.__wifiDirectGroupMemberType;
+        __disassociationReason = rhs.__disassociationReason;
+        __pNetConnection = rhs.__pNetConnection;
+
+        if (rhs.__pGroupInfo != null)
+        {
+            WifiDirectGroupInfo* pGroupInfo = new (std::nothrow) WifiDirectGroupInfo(*rhs.__pGroupInfo);
+            SysTryCatch(NID_NET_WIFI, pGroupInfo != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+            delete __pGroupInfo;
+            __pGroupInfo = pGroupInfo;
+        }
+
+        if (rhs.__pDeviceInfo != null)
+        {
+            WifiDirectDeviceInfo* pDeviceInfo = new (std::nothrow) WifiDirectDeviceInfo(*rhs.__pDeviceInfo);
+            SysTryCatch(NID_NET_WIFI, pDeviceInfo != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+            delete __pDeviceInfo;
+            __pDeviceInfo = pDeviceInfo;
+        }
+
+        if (rhs.__pDeviceInfoList != null)
+        {
+            ArrayList* pDeviceInfoList = new (std::nothrow) ArrayList();
+            SysTryCatch(NID_NET_WIFI, pDeviceInfoList != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+            result r = pDeviceInfoList->Construct(*rhs.__pDeviceInfoList);
+            SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+            if (__pDeviceInfoList != null)
+            {
+                __pDeviceInfoList->RemoveAll(true);
+                delete __pDeviceInfoList;
+            }
+            __pDeviceInfoList = pDeviceInfoList;
+        }
+    }
+CATCH:
+    return *this;
+}
+
+
+} } }//Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiDirectEventArg.h b/src/wifi/FNetWifi_WifiDirectEventArg.h
new file mode 100644 (file)
index 0000000..60ba314
--- /dev/null
@@ -0,0 +1,366 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FNetWifi_WifiDirectEventArg.h
+ * @brief              This is the header file for the _WifiDirectEventArg Class.
+ *
+ * This header file contains declaration of the _WifiDirectEventArg Class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_DIRECT_EVENT_ARG_H_
+#define _FNET_WIFI_INTERNAL_WIFI_DIRECT_EVENT_ARG_H_
+
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen {      namespace Base { namespace Collection {
+class IList;
+class ArrayList;
+}}}// Tizen::Base::Collection
+
+
+namespace Tizen {      namespace Net {
+class NetConnection;
+
+namespace Wifi {
+class WifiDirectGroupInfo;
+class WifiDirectDeviceInfo;
+class WifiDirectGroupMember;
+
+/**
+ * @enum __WifiDirectDeviceEventType
+ * Enumeration type to specify the type of WifiDirect events.
+ */
+enum _WifiDirectEventType
+{
+       WIFI_DIRECT_DEVICE_EVENT_NONE,
+       WIFI_DIRECT_DEVICE_EVENT_ACTIVATED,
+       WIFI_DIRECT_DEVICE_EVENT_DEACTIVATED,
+       WIFI_DIRECT_DEVICE_EVENT_GROUP_CREATED,
+       WIFI_DIRECT_DEVICE_EVENT_SCAN_COMPLETED,
+       WIFI_DIRECT_DEVICE_EVENT_ASSOCIATED,
+       WIFI_DIRECT_DEVICE_EVENT_CONNECTED,
+       WIFI_DIRECT_DEVICE_EVENT_DISCONNECTED,
+       WIFI_DIRECT_DEVICE_EVENT_AUTONOMOS_GROUP_CREATED,
+       WIFI_DIRECT_DEVICE_EVENT_GROUP_LEFT,
+    WIFI_DIRECT_GO_EVENT_CLIENT_ASSOCIATED,
+    WIFI_DIRECT_GO_EVENT_CLIENT_DISASSOCIATED,
+    WIFI_DIRECT_GO_EVENT_GROUP_DESTROYED,
+    WIFI_DIRECT_GO_EVENT_SERVICE_STARTED,
+    WIFI_DIRECT_GO_EVENT_SERVICE_STOPPED,
+    WIFI_DIRECT_GC_EVENT_DISASSOCIATED,
+    WIFI_DIRECT_GC_EVENT_GROUP_OWNER_INFO_RESPONDED,
+    WIFI_DIRECT_GC_EVENT_GROUP_MEMBER_INFO_LIST_RESPONDED
+};
+/**
+ * @class      _WifiDirectEventArg
+ * @brief      This class is used as an argument of methods of the IWifiDirectDeviceListener class.
+ *
+ * @since      2.0
+ *
+ * This class is used as an argument of IWifiDirectDeviceListener's methods.
+ * When a %WifiDirectDevice event occurs, the __WifiDirectDeviceEvent object finds a IWifiDirectDeviceListener object
+ * which is registered for the WifiDirectDevice object and calls an appropriate method of the listener.
+ */
+
+class _WifiDirectEventArg:
+       public Tizen::Base::Runtime::IEventArg,
+       public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the default constructor for this class.                
+        */
+       _WifiDirectEventArg(void);
+
+       /**
+     * This is the copy constructor.
+     *
+     * @param[in]   rhs   An instance of %_WifiDirectEventArg
+     */
+    _WifiDirectEventArg(const _WifiDirectEventArg& rhs);
+
+       /**
+        * This destructor overrides Tizen::Base::Object::~Object().
+        *
+        */
+       virtual ~_WifiDirectEventArg(void);
+
+    /**
+        * This constructor initializes the instance of this class with the specified values.
+        *
+     * @param[in]      memberType              The type of the member.
+        * @param[in]   eventType               The type of the WifiDirectDeviceEvent.
+        * @param[in]   localDeviceId   An Id for a Wi-Fi Direct device.
+        * @param[in]   r                               The error code.
+        *
+        * @remarks     This method can be used for WIFI_DIRECT_DEVICE_EVENT_ACTIVATED, WIFI_DIRECT_DEVICE_EVENT_DEACTIVATED,
+        *          WIFI_DIRECT_GO_EVENT_GROUP_DESTROYED, WIFI_DIRECT_GO_EVENT_SERVICE_STOPPED
+        *          WIFI_DIRECT_DEVICE_EVENT_AUTONOMOS_GROUP_CREATED or WIFI_DIRECT_DEVICE_EVENT_GROUP_LEFT events.
+        */
+       _WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId, result r = E_SUCCESS);
+
+       /**
+        * This constructor initializes the instance of this class with the specified values.
+        *
+     * @param[in]      memberType                              The type of the member.
+        * @param[in]   eventType                                               The type of the WifiDirectDeviceEvent.
+        * @param[in]   localDeviceId                                   An Id for a Wi-Fi Direct device.
+        * @param[in]   wifiDirectGroupInfo                             A reference to the WifiDirecrGroupInfo instance.
+        * @param[in]   wifiDirectGroupOwnerDeviceInfo  A reference to the WifiDirectDeviceInfo instance of the group owner.
+        * @param[in]   wifiDirectMemberType                    the type of a Wi-Fi Direct device.
+        * @param[in]   r                                                               The error code.
+        *
+        * @remarks     This method can be used for WIFI_DIRECT_DEVICE_EVENT_GROUP_CREATED event.
+        */
+
+       _WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId,
+               const WifiDirectGroupInfo& wifiDirectGroupInfo, const WifiDirectDeviceInfo& wifiDirectGroupOwnerDeviceInfo,
+               const WifiDirectGroupMemberType wifiDirectMemberType, result r = E_SUCCESS);
+
+       /**
+        * This constructor initializes the instance of this class with the specified values.
+        *
+     * @param[in]      memberType                          The type of the member.
+        * @param[in]   eventType                                       The type of the WifiDirectDeviceEvent.
+        * @param[in]   localDeviceId                           An Id for a Wi-Fi Direct device.
+        * @param[in]   pGroupOwnerInfoList                     The list of WifiDirectDeviceInfo information.
+        * @param[in]   pDeviceInfoList                         The list of WifiDirectDeviceInfo information.
+        * @param[in]   r                                                       The error code.
+        *
+        * @remarks     This method can be used for WIFI_DIRECT_DEVICE_EVENT_SCAN_COMPLETED
+        *          or WIFI_DIRECT_GC_EVENT_GROUP_MEMBER_INFO_LIST_RESPONDED event.
+        */
+       _WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId,
+               Tizen::Base::Collection::IList* pDeviceInfoList, result r = E_SUCCESS);
+
+       /**
+        * This constructor initializes the instance of this class with the specified values.
+        *
+     * @param[in]      memberType                              The type of the member.
+        * @param[in]   eventType                                               The type of the WifiDirectDeviceEvent.
+        * @param[in]   localDeviceId                                   An Id for a Wi-Fi Direct device.
+        * @param[in]   wifiDirectGroupOwnerDeviceInfo  A reference to the WifiDirectDeviceInfo instance of the group owner.
+        * @param[in]   r                                                               The error code.
+        *
+        * @remarks     This method can be used for WIFI_DIRECT_DEVICE_EVENT_ASSOCIATED, WIFI_DIRECT_GO_EVENT_CLIENT_ASSOCIATED
+        *          ,WIFI_DIRECT_GC_EVENT_GROUP_OWNER_INFO_RESPONDED or WIFI_DIRECT_DEVICE_EVENT_CONNECTED event.
+        */
+       _WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId,
+               const WifiDirectDeviceInfo& wifiDirectDeviceInfo, result r = E_SUCCESS);
+
+    /**
+        * This constructor initializes the instance of this class with the specified values.
+        *
+     * @param[in]      memberType                      The type of the member.
+        * @param[in]   eventType                               The type of the WifiDirectGroupOwnerEvent.
+        * @param[in]   localDeviceId                   An Id for a Wi-Fi Direct device.
+        * @param[in]   wifiDirectDeviceInfo    A reference to the WifiDirectDeviceInfo instance.
+        * @param[in]   disassociationReason    The reason of association termination
+        * @param[in]   r                                               The error code.
+        *
+        * @remarks     This method can be used for WIFI_DIRECT_GO_EVENT_CLIENT_ASSOCIATED or WIFI_DIRECT_GO_EVENT_CLIENT_DISASSOCIATED
+        */
+       _WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId,
+               const WifiDirectDeviceInfo& wifiDirectDeviceInfo, WifiDirectAssociationTerminationReason disassociationReason,
+               result r = E_SUCCESS);
+
+    /**
+        * This constructor initializes the instance of this class with the specified values.
+        *
+     * @param[in]      memberType                      The type of the member.
+        * @param[in]   eventType                               The type of the WifiDirectGroupClientEvent.
+        * @param[in]   localDeviceId                   An Id for a Wi-Fi Direct device.
+        * @param[in]   disassociationReason    The reason of association termination
+        * @param[in]   r                                               The error code.
+        *
+        * @remarks     This method can be used for WIFI_DIRECT_GC_EVENT_DISASSOCIATED event.
+        */
+       _WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId,
+               WifiDirectAssociationTerminationReason disassociationReason, result r = E_SUCCESS);
+
+       /**
+     * This constructor initializes the instance of this class with the specified values.
+     *
+     * @param[in]   memberType              The type of the member.
+     * @param[in]   eventType               The type of the WifiDirectGroupClientEvent.
+     * @param[in]   localDeviceId           An Id for a Wi-Fi Direct device.
+     * @param[in]   pNetConnection          The network connection that started with the Wi-Fi Direct net account.
+     * @param[in]   r                       The error code.
+     *
+     * @remarks This method can be used for WIFI_DIRECT_GO_EVENT_SERVICE_STARTED event.
+     */
+    _WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId,
+            Tizen::Net::NetConnection* pNetConnection, result r = E_SUCCESS);
+
+    /**
+     * This constructor initializes the instance of this class with the specified values.
+     *
+     * @param[in]   memberType              The type of the member.
+     * @param[in]   eventType               The type of the WifiDirectGroupClientEvent.
+     * @param[in]   localDeviceId           An Id for a Wi-Fi Direct device.
+     * @param[in]   pNetConnection          The network connection that started with the Wi-Fi Direct net account.
+     * @param[in]   r                       The error code.
+     *
+     * @remarks This method can be used for WIFI_DIRECT_DEVICE_EVENT_DISCONNECTED event.
+     */
+    _WifiDirectEventArg(_WifiDirectEventType eventType, WifiDirectDeviceId localDeviceId,
+            const Tizen::Base::String& remoteDeviceMacAddress, result r = E_SUCCESS);
+
+
+    /**
+     * Sets the group member instance.
+     *
+     * @param[in]   pGroupMember            The WifiDirectGroupMember instance.
+     *
+     * @remark This takes the ownership of @c arg. So arg should be created on a heap and should not be deleted.
+     */
+    void SetGroupMember(WifiDirectGroupMember* pGroupMember);
+
+    /**
+     * Gets the group member instance.
+     *
+     * @return  WifiDirectGroupMember     Group member instance.
+     *
+     */
+    WifiDirectGroupMember* GetGroupMember(void) const;
+
+       /**
+        * Gets the event type.
+        *
+        * @return      __WifiDirectDeviceEventType             Event type of this argument.
+        *
+        * @see         __WifiDirectDeviceEventType
+        */
+       _WifiDirectEventType GetEventType(void) const;
+
+       /**
+        * Gets the error code.
+        *
+        * @return      WifiDirectManagerError          Error code of this argument.
+        *
+        * @see         WifiDirectManagerError
+        */
+       result GetError(void) const;
+
+       /**
+        * Gets the device Id.
+        *
+        * @return The Id of Wi-Fi Direct device.
+        *
+        * @see         WifiDirectDeviceId
+        */
+
+       WifiDirectDeviceId GetDeviceId(void) const;
+
+       /**
+        * Gets the list of WifiDirectDeviceInfo.
+        *
+        * @return      Pointer to the ArrayList object which contains information of group members' information @n
+        *                      @c null, if no associated node exists
+        */
+       Tizen::Base::Collection::IList* GetDeviceInfoList(void) const;
+
+       /**
+        * Gets the WifiDirectGroupInfo.
+        *
+        * @return Pointer to the WifiDirectGroupInfo object
+        *
+        */
+       WifiDirectGroupInfo* GetGroupInfo(void) const;
+
+       /**
+        * Gets the WifiDirectDeviceInfo
+        *
+        * @return Pointer to the WifiDirectDeviceInfo object
+        *
+        */
+    WifiDirectDeviceInfo* GetDeviceInfo(void) const;
+
+       /**
+        * Gets the WifiDirectGroupMemberType.
+        *
+        * @return the type of a Wi-Fi Direct device.
+        *
+        */
+       WifiDirectGroupMemberType GetGroupMemberType(void) const;
+
+       /**
+        * Sets the list of WifiDirectDeviceInfo information
+        *
+        * @param[in]   pDeviceInfoList         Pointer to the ArrayList object which contains information of group members' information.
+        *
+        */
+       void SetDeviceInfoList(Tizen::Base::Collection::IList* pDeviceInfoList);
+
+    /**
+        * Gets the reason of Wi-Fi Direct group client association termination.
+        *
+        * @return The reason of association termination
+        *
+        */
+       WifiDirectAssociationTerminationReason GetDisassociationReason(void) const;
+
+
+       /**
+     * Gets the network connection that started with the Wi-Fi Direct net account.
+     *
+     * @return The network connection
+     *
+     */
+       Tizen::Net::NetConnection* GetNetConnection(void) const;
+
+       /**
+     * Gets the mac address of remote device.
+     *
+     * @return The mac address
+     *
+     */
+       Tizen::Base::String GetMacAddress(void) const;
+
+
+    /**
+     * Copying of objects using this copy assignment operator is allowed.
+     *
+     * @param[in]   rhs     An instance of %_WifiDirectEventArg
+     */
+       _WifiDirectEventArg& operator =(const _WifiDirectEventArg& rhs);
+
+private:
+    _WifiDirectEventType __eventType;
+    WifiDirectDeviceId __localDeviceId;
+    result __error;
+
+    WifiDirectGroupInfo* __pGroupInfo;
+    WifiDirectDeviceInfo* __pDeviceInfo;
+    Tizen::Base::Collection::ArrayList* __pDeviceInfoList;
+
+    WifiDirectGroupMemberType __wifiDirectGroupMemberType;
+    WifiDirectAssociationTerminationReason __disassociationReason;
+
+    Tizen::Net::NetConnection* __pNetConnection;
+    Tizen::Base::String __remoteDeviceMacAddress;
+    WifiDirectGroupMember* __pGroupMember;
+
+}; // _WifiDirectEventArg
+
+}}}// Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_DIRECT_EVENT_ARG_H_
+
diff --git a/src/wifi/FNetWifi_WifiDirectGroupClientEvent.cpp b/src/wifi/FNetWifi_WifiDirectGroupClientEvent.cpp
new file mode 100644 (file)
index 0000000..04e9175
--- /dev/null
@@ -0,0 +1,115 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectGroupClientEvent.cpp
+ * @brief   This is the implementation file for the _WifiDirectGroupClientEvent Class.
+ *
+ * This header file contains implementation of the _WifiDirectGroupClientEvent Class.
+ */
+
+#include <FBaseRtIEventListener.h>
+#include <FNetWifiIWifiDirectGroupClientListener.h>
+#include <FBaseColArrayList.h>
+#include <FNetWifiWifiDirectGroupMember.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FNetWifiWifiDirectGroupInfo.h>
+#include <FNetWifiWifiDirectGroupOwner.h>
+#include <FNetWifiWifiDirectGroupClient.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiDirectGroupClientEvent.h"
+#include "FNetWifi_WifiDirectGroupOwnerImpl.h"
+#include "FNetWifi_WifiDirectGroupClientImpl.h"
+#include "FNetWifi_WifiDirectDeviceImpl.h"
+#include "FNetWifi_WifiDirectEventArg.h"
+
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+////////////////////////////////////////////////////////////////////////////
+// Lifecycle : Public
+_WifiDirectGroupClientEvent::_WifiDirectGroupClientEvent(void)
+{
+}
+
+_WifiDirectGroupClientEvent::~_WifiDirectGroupClientEvent(void)
+{
+
+}
+
+result
+_WifiDirectGroupClientEvent::Construct(void)
+{
+    return _Event::Initialize();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Operation : Protected
+
+void
+_WifiDirectGroupClientEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+    const _WifiDirectEventArg* pArg = dynamic_cast<const _WifiDirectEventArg*>(&arg);
+    SysTryReturnVoidResult(NID_NET_WIFI, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is a null pointer.");
+
+    result r = pArg->GetError();
+    SysLog(NID_NET_WIFI, "The result value of IEventArg is %s.", GetErrorMessage(r));
+
+    IWifiDirectGroupClientListener* pGroupClientListener = dynamic_cast<IWifiDirectGroupClientListener*>(&listener);
+
+    if (pGroupClientListener != null)
+    {
+        _WifiDirectEventType eventType = pArg->GetEventType();
+        WifiDirectDeviceId localDeviceId = pArg->GetDeviceId();
+
+        switch (eventType)
+        {
+           case WIFI_DIRECT_GC_EVENT_DISASSOCIATED:
+              SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_GC_EVENT_DISASSOCIATED)");
+              {
+                  WifiDirectAssociationTerminationReason reason = pArg->GetDisassociationReason();
+                  pGroupClientListener->OnWifiDirectAssociationTerminated(localDeviceId, reason, r);
+              }
+              break;
+           case WIFI_DIRECT_GC_EVENT_GROUP_OWNER_INFO_RESPONDED:
+              SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_GC_EVENT_GROUP_OWNER_INFO_RESPONDED)");
+              {
+                  WifiDirectDeviceInfo* pGroupOwnerInfo = pArg->GetDeviceInfo();
+                  pGroupClientListener->OnWifiDirectGroupOwnerInfoReceived(localDeviceId, *pGroupOwnerInfo, r);
+              }
+              break;
+           case WIFI_DIRECT_GC_EVENT_GROUP_MEMBER_INFO_LIST_RESPONDED:
+              SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_GC_EVENT_GROUP_MEMBER_INFO_LIST_RESPONDED)");
+              {
+                  IList* pGroupMemberInfoList = pArg->GetDeviceInfoList();
+                  pGroupClientListener->OnWifiDirectAllGroupMemberInfoReceivedN(localDeviceId, pGroupMemberInfoList, r);
+              }
+              break;
+           default:
+              SysLog(NID_NET_WIFI, "An undefined external WifiDirectGroupClient event occurs. (Type: %d)",eventType);
+              SysAssert(false);
+        }
+    }
+    else
+    {
+        SysLog(NID_NET_WIFI, "The result of a dynamic_cast operation is null for external GC listener.");
+    }
+}
+
+} } } // Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiDirectGroupClientEvent.h b/src/wifi/FNetWifi_WifiDirectGroupClientEvent.h
new file mode 100644 (file)
index 0000000..a296ed9
--- /dev/null
@@ -0,0 +1,101 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectGroupOwnerClient.h
+ * @brief   This is the header file for the _WifiDirectGroupClientEvent class.
+ *
+ * This header file contains declarations of the _WifiDirectGroupClientEvent class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_CLIENT_EVENT_H_
+#define _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_CLIENT_EVENT_H_
+
+// Includes
+#include <FBaseResult.h>
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventListener;
+class IEventArg;
+}}}
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+/**
+ * @class   _WifiDirectGroupClientEvent
+ * @brief   This class handles WifiDirectGroupClient events.
+ *
+ * When a WifiDirectClient event occurs, the _WifiDirectGroupClientEvent object finds a IWifiDirectGroupClientEventListener object
+ * which is registered for the Device object and calls an appropriate method of the listener.
+ */
+
+class _WifiDirectGroupClientEvent
+    : public Tizen::Base::Runtime::_Event
+{
+public:
+    /**
+     * 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.
+     */
+    _WifiDirectGroupClientEvent(void);
+
+    /**
+     * This destructor overrides Tizen::Base::Runtime::_Event::~_Event().
+     */
+    virtual ~_WifiDirectGroupClientEvent(void);
+
+    /**
+     * Initializes this instance.
+     */
+    result Construct(void);
+
+protected:
+    /**
+     * Checks the arg and finds out the type of event. After that this method calls appropriate pListener's method.
+     *
+     * @return      A result code.
+     * @param[in]   listener        It is a event listener related to this WifiDirectGroupClient event.
+     * @param[in]   arg             It is an argument-like instance of WifiDirectGroupClient event retransmitted to the listener's method as an argument.
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_ARG   The argument passed to a method contains an invalid value.@n
+     */
+    void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @since   2.0
+     *
+     * @param[in]   rhs   An instance of %_WifiDirectGroupClientEvent
+     */
+    _WifiDirectGroupClientEvent(const _WifiDirectGroupClientEvent& rhs);
+    
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in] rhs An instance of %_WifiDirectGroupClientEvent
+     */
+    _WifiDirectGroupClientEvent& operator =(const _WifiDirectGroupClientEvent& rhs);
+}; // _WifiDirectGroupClientEvent
+
+}}} // Tizen::Net::Wifi
+#endif // _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_CLIENT_EVENT_H_
diff --git a/src/wifi/FNetWifi_WifiDirectGroupClientImpl.cpp b/src/wifi/FNetWifi_WifiDirectGroupClientImpl.cpp
new file mode 100644 (file)
index 0000000..24b587e
--- /dev/null
@@ -0,0 +1,930 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FNetWifiWifiDirectGroupClientImpl.cpp
+ * @brief      This is the implementation file for the _WifiDirectGroupClientImpl class.
+ * This header file contains implementation of the _WifiDirectGroupClientImpl class.
+ */
+
+#include <FNetNetAccountManager.h>
+#include <FNetNetConnection.h>
+#include <FNetSockSocket.h>
+#include <FNetWifiIWifiDirectGroupClientListener.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FNetWifiWifiDirectGroupClient.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiDirectDeviceImpl.h"
+#include "FNetWifi_WifiDirectDeviceInfoImpl.h"
+#include "FNetWifi_WifiDirectGroupClientImpl.h"
+#include "FNetWifi_WifiDirectSystemAdapter.h"
+#include "FNetWifi_WifiDirectUtility.h"
+#include "FNetWifi_WifiDirectGroupClientEvent.h"
+#include "FNetWifi_WifiDirectEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Net;
+using namespace Tizen::Net::Wifi;
+using namespace Tizen::Net::Sockets;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen {      namespace Net { namespace Wifi
+{
+
+static const int MAX_RETRY_COUNT = 3;
+static const int MAX_REQUEST_TIMEOUT = 3;
+
+////////////////////////////////////////////////////////////////////////////////
+/// Lifecycle : Public
+_WifiDirectGroupClientImpl::_WifiDirectGroupClientImpl(void)
+    : __localDeviceId(-1)
+    , __pWifiDirectDeviceImpl(null)
+    , __pWifiDirectSystemAdapter(null)
+    , __pNetConnection(null)
+    , __pClientSocket(null)
+    , __pLocalIpAddress(null)
+    , __portNumber(DEFAULT_PORT)
+    , __refCount(1)
+    , __currentState(WIFI_DIRECT_DEVICE_INFO_REQUEST_READY)
+    , __retryCount(0)
+{
+
+}
+////////////////////////////////////////////////////////////////////////////////
+/// Operation : Public
+
+result
+_WifiDirectGroupClientImpl::Disassociate(void)
+{
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "This instance has not been constructed yet.");
+    SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s]",
+                    __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+    result r = E_SUCCESS;
+
+    _WifiDirectDeviceState currentState = __pWifiDirectDeviceImpl->GetWifiDirectDeviceCurrentState();
+
+    SysTryReturnResult(NID_NET_WIFI, currentState != WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING, E_IN_PROGRESS,
+                        "The currently device state is DISCONNECTING.");
+
+    if (currentState == WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT)
+    {
+        r = __pWifiDirectSystemAdapter->Disassociate();
+
+        if (r == E_SUCCESS)
+        {
+            __pWifiDirectDeviceImpl->SetWifiDirectDeviceCurrentState(WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING);
+        }
+    }
+    else
+    {
+        r = E_INVALID_OPERATION;
+    }
+
+    SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s] [result:%s]",
+                    __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+    return r;
+}
+
+result
+_WifiDirectGroupClientImpl::RequestGroupOwnerInfo(int portNumber)
+{
+    return RequestInfoProcess(WIFI_DIRECT_OWNER_INFO_REQUEST, portNumber);
+}
+
+result
+_WifiDirectGroupClientImpl::RequestAllGroupMemberInfo(int portNumber)
+{
+    return RequestInfoProcess(WIFI_DIRECT_MEMBER_INFO_REQUEST, portNumber);
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Internal Function
+
+result
+_WifiDirectGroupClientImpl::RequestInfoProcess(_WifiDirectMemberInfoRequestStateType requestType, int portNumber)
+{
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "This instance has not been constructed yet.");
+    SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s]",
+                __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+    result r = E_SUCCESS;
+    _WifiDirectDeviceState deviceImplState = __pWifiDirectDeviceImpl->GetWifiDirectDeviceCurrentState();
+
+    SysTryReturnResult(NID_NET_WIFI, !((portNumber < MIN_PORT_NUMBER) || (portNumber > MAX_PORT_NUMBER)), E_OUT_OF_RANGE,
+                        "The specified argument is not in a valid range.");
+    SysTryReturnResult(NID_NET_WIFI, deviceImplState == WIFI_DIRECT_DEVICE_INTERNAL_CREATED_CLIENT, E_INVALID_OPERATION,
+                        "The operation is not allowed in this state.");
+
+    __stateMutex.Acquire();
+
+    if (__currentState == WIFI_DIRECT_DEVICE_INFO_REQUEST_READY)
+    {
+        __currentState = requestType;
+        __portNumber = portNumber;
+    }
+    else
+    {
+        __stateMutex.Release();
+        r = E_IN_PROGRESS;
+        SysLogException(NID_NET_WIFI, E_IN_PROGRESS, "[%s] Propagating.", GetErrorMessage(r));
+        return r;
+
+    }
+
+    __stateMutex.Release();
+
+    if (__pNetConnection->GetConnectionState() != NET_CONNECTION_STATE_STARTED)
+    {
+        r = __pNetConnection->Start();
+    }
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Failed to start NetConnection.", GetErrorMessage(r));
+
+    SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s] [result:%s]",
+                    __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+    return r;
+CATCH:
+    __currentState = WIFI_DIRECT_DEVICE_INFO_REQUEST_READY;
+    __portNumber = DEFAULT_PORT;
+    SysLog(NID_NET_WIFI, "Exit, [CurrentState:%s], [result:%s]",
+                    __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetErrorMessage(r));
+    return r;
+}
+
+void
+_WifiDirectGroupClientImpl::OnNetConnectionStarted(NetConnection& netConnection, result r)
+{
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "[E_SYSTEM] This instance has not been constructed yet.");
+    SysLog(NID_NET_WIFI, "[DeviceImplCurrentState:%s] [ClientImplCurrentState:%s] [Action Result :%s]",
+                __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+
+    const NetConnectionInfo* pNetConnectionInfo = null;
+    result res = E_SYSTEM;
+
+    if (__currentState != WIFI_DIRECT_DEVICE_INFO_REQUEST_READY)
+    {
+        if (r == E_SUCCESS)
+        {
+            // Get the local IP address using
+            pNetConnectionInfo = netConnection.GetNetConnectionInfo();
+
+            if (pNetConnectionInfo != null)
+            {
+                __pLocalIpAddress = pNetConnectionInfo->GetLocalAddress()->CloneN();
+            }
+
+            res = StartSocketServer();
+
+            if (IsFailed(res))
+            {
+                goto CATCH;
+            }
+
+            if (__currentState == WIFI_DIRECT_OWNER_INFO_REQUEST)
+            {
+                res = SendRequestGroupMemberInfoMessage(REQUEST_OWNER_INFO);
+            }
+            else if (__currentState == WIFI_DIRECT_MEMBER_INFO_REQUEST)
+            {
+                res = SendRequestGroupMemberInfoMessage(REQUEST_ALL_MEMBER_INFO);
+            }
+
+            if (IsFailed(res))
+            {
+                goto CATCH;
+            }
+
+            res = StartTimer();
+            if (IsFailed(res))
+            {
+                goto CATCH;
+            }
+        }
+        else
+        {
+            goto CATCH;
+        }
+    }
+    SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s] [result:%s]",
+                __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(res));
+    return;
+CATCH:
+    __currentState = WIFI_DIRECT_DEVICE_INFO_REQUEST_READY;
+    if (__pLocalIpAddress != null)
+    {
+        delete __pLocalIpAddress;
+        __pLocalIpAddress = null;
+    }
+    _WifiDirectEventArg* pEventArg = null;
+
+    if (__currentState == WIFI_DIRECT_OWNER_INFO_REQUEST
+        || __currentState == WIFI_DIRECT_OWNER_INFO_REQUEST_SENT)
+    {
+        pEventArg  = new (std::nothrow) _WifiDirectEventArg(WIFI_DIRECT_GC_EVENT_GROUP_OWNER_INFO_RESPONDED,
+                    __localDeviceId, WifiDirectDeviceInfo(), E_SYSTEM);
+        SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+    }
+    else if (__currentState == WIFI_DIRECT_MEMBER_INFO_REQUEST
+             || __currentState == WIFI_DIRECT_MEMBER_INFO_REQUEST_SENT)
+    {
+        pEventArg  = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_GC_EVENT_GROUP_MEMBER_INFO_LIST_RESPONDED,
+                            __localDeviceId, (Tizen::Base::Collection::IList*)null, E_SYSTEM);
+        SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+    }
+    __pWifiDirectDeviceImpl->GetWifiDirectGroupClientEvent()->Fire(*pEventArg);
+
+    SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s] [result:%s]",
+                __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(res));
+    }
+
+void
+_WifiDirectGroupClientImpl::OnNetConnectionStopped(NetConnection& netConnection, result r)
+{
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "[E_SYSTEM] This instance has not been constructed yet.");
+    SysLog(NID_NET_WIFI, "[DeviceImplCurrentState:%s] [ClientImplCurrentState:%s] [Action Result :%s]",
+                __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+
+    __currentState = WIFI_DIRECT_DEVICE_INFO_REQUEST_READY;
+
+    StopTimer();
+    ResetRetryCount();
+    if (__pLocalIpAddress != null)
+    {
+        delete __pLocalIpAddress;
+        __pLocalIpAddress = null;
+    }
+    SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s]",
+                __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+}
+
+void
+_WifiDirectGroupClientImpl::OnSocketReadyToReceive(Socket& socket)
+{
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiDirectDeviceImpl, E_SYSTEM, "[E_SYSTEM] This instance has not been constructed yet.");
+    SysLog(NID_NET_WIFI, "[DeviceImplCurrentState:%s] [ClientImplCurrentState:%s]",
+                        __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+    SysTryReturnVoidResult(NID_NET_WIFI, __currentState != WIFI_DIRECT_DEVICE_INFO_REQUEST_READY, E_SYSTEM,
+                        "[CurrentState: %s]", GetStringOfCurrentState());
+
+    result r = E_SUCCESS;
+    {
+        unsigned long arg = 0;
+
+        r = socket.Ioctl(NET_SOCKET_FIONREAD, arg);
+        SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Socket ioctl for read has failed.", GetErrorMessage(r));
+
+        Ip4Address peerAddr("0");
+        NetEndPoint peerEndPoint(peerAddr, 0);
+
+        ByteBuffer rxBuffer;
+        rxBuffer.Construct(arg);
+
+        r = socket.ReceiveFrom(rxBuffer, peerEndPoint);
+
+        SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Receiving data from socket has failed.", GetErrorMessage(r));
+
+        IpAddress* pPeerAddress = peerEndPoint.GetAddress();
+
+        SysTryCatch(NID_NET_WIFI, pPeerAddress != null, , E_SYSTEM, "[E_SYSTEM] PeerAddress is invalid.");
+
+        // Receives only IPV4 Address
+        SysTryCatch(NID_NET_WIFI, pPeerAddress->GetNetAddressFamily() == NET_AF_IPV4, , E_SYSTEM,
+                    "[E_SYSTEM] PeerAddress is not IPV4.");
+
+        String ipAddr = pPeerAddress->ToString();
+        // Skip my address
+        SysTryCatch(NID_NET_WIFI, __pLocalIpAddress != null && __pLocalIpAddress->ToString() != ipAddr, , E_SYSTEM,
+                    "[E_SYSTEM] broadcast received from my address.");
+
+        rxBuffer.Flip();
+
+        String messageString(reinterpret_cast<const char*>(rxBuffer.GetPointer()));
+        SysTryCatch(NID_NET_WIFI, messageString.IsEmpty() != true, , E_SYSTEM, "[E_SYSTEM] Message is Empty.");
+        SysLog(NID_NET_WIFI, "Full message : %ls", messageString.GetPointer());
+        // process the message received
+        _WIFIDIRECT_MESSAGE_TYPE messageType = _WifiDirectUtility::GetMessageType(messageString);
+
+        SysTryCatch(NID_NET_WIFI, messageType == RESPONSE_OWNER_INFO || messageType == RESPONSE_ALL_MEMBER_INFO, , E_SYSTEM,
+                        "[E_SYSTEM] Invalid message received.");
+
+        IList* pList = ParsingMessageN(messageType, messageString);
+
+        if (pList == null)
+        {
+            r = E_SYSTEM;
+        }
+
+        _WifiDirectEventArg* pEventArg  = null;
+
+        if (messageType == RESPONSE_OWNER_INFO)
+        {
+            WifiDirectDeviceInfo* pGroupOwnerInfo = null;
+
+            if (pList != null)
+            {
+                pGroupOwnerInfo = static_cast< WifiDirectDeviceInfo* >(pList->GetAt(0));
+                pEventArg  = new (std::nothrow) _WifiDirectEventArg(WIFI_DIRECT_GC_EVENT_GROUP_OWNER_INFO_RESPONDED,
+                                                __localDeviceId, *pGroupOwnerInfo, r);
+
+                pList->RemoveAll(true);
+                delete pList;
+            }
+            else
+            {
+                pEventArg  = new (std::nothrow) _WifiDirectEventArg(WIFI_DIRECT_GC_EVENT_GROUP_OWNER_INFO_RESPONDED,
+                                            __localDeviceId, WifiDirectDeviceInfo(), r);
+            }
+        }
+        else
+        {
+            pEventArg  = new (std::nothrow) _WifiDirectEventArg(WIFI_DIRECT_GC_EVENT_GROUP_MEMBER_INFO_LIST_RESPONDED,
+                                                    __localDeviceId, pList, r);
+        }
+
+        __pWifiDirectDeviceImpl->GetWifiDirectGroupClientEvent()->Fire(*pEventArg);
+        __currentState = WIFI_DIRECT_DEVICE_INFO_REQUEST_READY;
+    }
+
+    CleanUpServerSocket();
+
+    if (__pNetConnection != null)
+    {
+        __pNetConnection->Stop();
+    }
+
+CATCH:
+    SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s] [result:%s]",
+                    __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+}
+
+void
+_WifiDirectGroupClientImpl::OnTimerExpired(Tizen::Base::Runtime::Timer &timer)
+{
+       SysTryReturnVoidResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "[E_SYSTEM] This instance has not been constructed yet.");
+       SysLog(NID_NET_WIFI, "[DeviceImplCurrentState:%s] [ClientImplCurrentState:%s]",
+                               __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+       result r = E_SUCCESS;
+
+       if (GetRetryCount() < MAX_RETRY_COUNT)
+       {
+               r = StartTimer();
+
+               if (r == E_SUCCESS)
+               {
+                       UpdateRetryCount();
+
+                       // Check the Request type
+                       if (__currentState == WIFI_DIRECT_OWNER_INFO_REQUEST_SENT)
+                       {
+                               r = SendRequestGroupMemberInfoMessage(REQUEST_OWNER_INFO);
+                       }
+                       else if (__currentState == WIFI_DIRECT_MEMBER_INFO_REQUEST_SENT)
+                       {
+                               r = SendRequestGroupMemberInfoMessage(REQUEST_ALL_MEMBER_INFO);
+                       }
+               }
+       }
+       else
+       {
+               r = E_NOT_RESPONDING;
+
+               _WifiDirectEventArg* pEventArg = null;
+
+        if (__currentState == WIFI_DIRECT_OWNER_INFO_REQUEST_SENT)
+        {
+            pEventArg  = new (std::nothrow) _WifiDirectEventArg(WIFI_DIRECT_GC_EVENT_GROUP_OWNER_INFO_RESPONDED,
+                                            __localDeviceId, WifiDirectDeviceInfo(), r);
+        }
+        else if (__currentState == WIFI_DIRECT_MEMBER_INFO_REQUEST_SENT)
+        {
+            pEventArg  = new (std::nothrow) _WifiDirectEventArg(WIFI_DIRECT_GC_EVENT_GROUP_MEMBER_INFO_LIST_RESPONDED,
+                                                                __localDeviceId, (Tizen::Base::Collection::IList*)null, r);
+        }
+        __pWifiDirectDeviceImpl->GetWifiDirectGroupClientEvent()->Fire(*pEventArg);
+
+               CleanUpServerSocket();
+
+               if (__pNetConnection != null)
+               {
+                       __pNetConnection->Stop();
+               }
+
+               __currentState = WIFI_DIRECT_DEVICE_INFO_REQUEST_READY;
+       }
+
+       SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s] [result:%s]",
+                               __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+       return;
+}
+
+result
+_WifiDirectGroupClientImpl::CreateNetConnection(void)
+{
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "This instance has not been constructed yet.");
+       SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+       result r = E_SUCCESS;
+       NetAccountManager accountManager;
+       NetAccountId accountId = INVALID_HANDLE;
+
+       r = accountManager.Construct();
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to construct NetAccountManager.");
+
+       accountId = accountManager.GetNetAccountId(NET_BEARER_WIFI_DIRECT);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, accountId != INVALID_HANDLE, r, "Failed to get net account Id.");
+
+       __pNetConnection = new (std::nothrow) NetConnection();
+       SysTryReturnResult(NID_NET_WIFI, __pNetConnection != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pNetConnection->Construct(accountId);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to construct NetConnection.");
+
+       r = __pNetConnection->AddNetConnectionListener(*this);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to add listner of Netconnection.");
+
+       SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s] [result:%s]",
+                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+       return r;
+}
+
+result
+_WifiDirectGroupClientImpl::SendRequestGroupMemberInfoMessage(_WIFIDIRECT_MESSAGE_TYPE messageType)
+{
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "This instance has not been constructed yet.");
+       SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s]",
+                               __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+       String broadcastMessage;
+       result r = E_SUCCESS;
+       Ip4Address broadcastAddress(BROADCAST_ADDR);
+       ByteBuffer* pTxBuffer = null;
+
+       // Makes NetEndPoint which the message will be sent to
+       NetEndPoint recvEndPoint(broadcastAddress, __portNumber);
+       r = GetLastResult();
+       TryCatch(r == E_SUCCESS, , "[%s] Failed to create NetEndPoint.", GetErrorMessage(r));
+
+       broadcastMessage.Clear();
+
+       broadcastMessage.Append(messageType);
+
+       pTxBuffer = StringUtil::StringToUtf8N(broadcastMessage);
+       r = GetLastResult();
+       TryCatch(r == E_SUCCESS, , "[%s] Failed to convert String.", GetErrorMessage(r));
+
+       r = __pClientSocket->SendTo(*pTxBuffer, recvEndPoint);
+       TryCatch(r == E_SUCCESS, , "[%s] Failed to send.", GetErrorMessage(r));
+
+       if (messageType == REQUEST_OWNER_INFO)
+       {
+               __currentState = WIFI_DIRECT_OWNER_INFO_REQUEST_SENT;
+       }
+       else if (messageType == REQUEST_ALL_MEMBER_INFO)
+       {
+               __currentState = WIFI_DIRECT_MEMBER_INFO_REQUEST_SENT;
+       }
+
+CATCH:
+    r = TransExceptionsExclusive ( r , E_SYSTEM, E_SUCCESS , E_OUT_OF_MEMORY ); 
+
+       if (pTxBuffer != null)
+       {
+               delete pTxBuffer;
+               pTxBuffer = null;
+       }
+       SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s] [result:%s]",
+                               __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+       return r;
+}
+
+result
+_WifiDirectGroupClientImpl::StartSocketServer(void)
+{
+       SysTryReturnResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "This instance has not been constructed yet.");
+       SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+       result r = E_SUCCESS;
+
+       Ip4Address localAddr(L"0");  // IN_ADDR_ANY
+       NetEndPoint localEndPoint(localAddr, __portNumber);
+
+       __pClientSocket = new (std::nothrow) Socket();
+       TryCatch(__pClientSocket, r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = __pClientSocket->Construct(*__pNetConnection, NET_SOCKET_AF_IPV4, NET_SOCKET_TYPE_DATAGRAM, NET_SOCKET_PROTOCOL_UDP);
+       TryCatch(r == E_SUCCESS, , "[%s] Socket Construction has failed.", GetErrorMessage(r));
+
+       r = __pClientSocket->SetSockOpt(NET_SOCKET_SOL_SOCKET, NET_SOCKET_SO_BROADCAST, 1);
+       TryCatch(r == E_SUCCESS, , "[%s] Setting socket option has failed.", GetErrorMessage(r));
+
+       r = __pClientSocket->AddSocketListener(*dynamic_cast<ISocketEventListener*>(this));
+       TryCatch(r == E_SUCCESS, , "[%s] Adding SocketListener has failed.", GetErrorMessage(r));
+
+       r = __pClientSocket->AsyncSelectByListener(NET_SOCKET_EVENT_READ | NET_SOCKET_EVENT_WRITE | NET_SOCKET_EVENT_CLOSE);
+       TryCatch(r == E_SUCCESS, , "[%s] Setting the socket to the asynchronous mode has failed.", GetErrorMessage(r));
+
+       r = __pClientSocket->Bind(localEndPoint);
+       TryCatch(r == E_SUCCESS, , "[%s] Binding UDP socket has Failed.", GetErrorMessage(r));
+
+       SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s] [result:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+       return r;
+
+CATCH:
+    r = TransExceptionsExclusive ( r , E_SYSTEM, E_ALREADY_BOUND , E_OUT_OF_MEMORY ); 
+
+       if (__pClientSocket != null)
+    {
+           delete __pClientSocket;
+           __pClientSocket = null;
+    }
+
+       SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s] [result:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+       return r;
+}
+
+IList*
+_WifiDirectGroupClientImpl::ParsingMessageN(_WIFIDIRECT_MESSAGE_TYPE messageType, const Tizen::Base::String& message)
+{
+       SysTryReturn(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, null, E_SYSTEM, "[E_SYSTEM] This instance has not been constructed yet.");
+       SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+       result r = E_SUCCESS;
+
+       int currentIndex = 0;
+
+       String tempString(0);
+
+       WifiDirectDeviceInfo* pWifiDirectDeviceInfo = null;
+       ArrayList* pWifiDirectDeviceInfoList = null;
+
+       // device count
+       int deviceCount = 0;
+       tempString = Message2String(currentIndex, message);
+       Tizen::Base::Integer::Decode(tempString, static_cast< int& >(deviceCount));
+
+       SysTryCatch(NID_NET_WIFI, deviceCount != 0, , E_SYSTEM, "The device count is 0.");
+
+       pWifiDirectDeviceInfoList = new (std::nothrow) ArrayList();
+       SysTryCatch(NID_NET_WIFI, pWifiDirectDeviceInfoList != null && (pWifiDirectDeviceInfoList->Construct(deviceCount) == E_SUCCESS),
+                                                               , E_SYSTEM, "Failed to construct ArrayList");
+
+       for (int i = 0 ; i < deviceCount ; i++)
+       {
+               pWifiDirectDeviceInfo = GenerateWifiDirectDeviceInfoN(message, currentIndex);
+
+               pWifiDirectDeviceInfoList->Add(*pWifiDirectDeviceInfo);
+
+       }// end of for(int i = 0 ; i < deviceCount ; i++)
+       return pWifiDirectDeviceInfoList;
+
+CATCH:
+       SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s] [result:%s]",
+                                               __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+       return null;
+}
+
+String
+_WifiDirectGroupClientImpl::Message2String(int& currentIndex, const Tizen::Base::String& message)
+{
+       int nextIndex = 0;
+       String tempString(null);
+       result r = E_SUCCESS;
+
+       r = message.IndexOf(":", currentIndex, nextIndex);
+
+       if (IsFailed(r))
+       {
+               SysLog(NID_NET_WIFI, "Getting the starting index of message has failed. [result:%s]", GetErrorMessage(r));
+       }
+
+       currentIndex = nextIndex + 1;
+
+       r = message.IndexOf(":", currentIndex, nextIndex);
+
+       if (IsFailed(r))
+       {
+               SysLog(NID_NET_WIFI, "Getting the starting index of message has failed. [result:%s]", GetErrorMessage(r));
+       }
+
+       r = message.SubString(currentIndex, nextIndex-currentIndex, tempString);
+
+       if (IsFailed(r))
+       {
+               SysLog(NID_NET_WIFI, "Getting a substring of message has failed. [result:%s]", GetErrorMessage(r));
+       }
+
+       return tempString;
+}
+
+String
+_WifiDirectGroupClientImpl::MessageWithLength2String(int& currentIndex, const Tizen::Base::String& message)
+{
+       // e.g. device name or ssid -> "08MyDevice",
+       int nextIndex = 0;
+       String tempString("");
+       result r = E_SUCCESS;
+       int len = 0;
+
+       r = message.IndexOf(":", currentIndex, nextIndex);
+
+       if (IsFailed(r))
+       {
+               SysLog(NID_NET_WIFI, "Getting the starting index of message has failed. [result:%s]", GetErrorMessage(r));
+       }
+
+       currentIndex = nextIndex + 1;
+
+       message.SubString(currentIndex, 2, tempString);
+       tempString.Trim();
+       currentIndex += 2;
+       Tizen::Base::Integer::Decode(tempString, static_cast< int& >(len));
+
+       if (len == 0)
+       {
+               tempString = "";
+       }
+       else
+       {
+               r = message.SubString(currentIndex, len, tempString);
+
+               if (IsFailed(r))
+               {
+                       SysLog(NID_NET_WIFI, "Getting a substring of message has failed. [result:%s]", GetErrorMessage(r));
+               }
+       }
+
+       currentIndex += len;
+
+       return tempString;
+}
+
+WifiDirectDeviceInfo*
+_WifiDirectGroupClientImpl::GenerateWifiDirectDeviceInfoN(const Tizen::Base::String& message, int& currentIndex)
+{
+       WifiDirectDeviceInfo* pWifiDirectDeviceInfo = null;
+
+       _WifiDirectDeviceInfoImpl wifiDirectDeviceInfoImpl;
+
+       wifiDirectDeviceInfoImpl.SetDeviceStatus(WIFI_DIRECT_DEVICE_ACTIVATED);
+
+       int temp = 0;
+       String tempString(0);
+
+       // member type
+       WifiDirectGroupMemberType memberType;
+       tempString = Message2String(currentIndex, message);
+       Tizen::Base::Integer::Decode(tempString, static_cast< int& >(temp));
+       memberType = static_cast< WifiDirectGroupMemberType >(temp);
+       wifiDirectDeviceInfoImpl.SetGroupMemberType(memberType);
+       SysLog(NID_NET_WIFI, "The Member Type is %d.", memberType);
+
+       // category type
+       WifiDirectDeviceTypeCategory categoryType;
+       tempString = Message2String(currentIndex, message);
+       Tizen::Base::Integer::Decode(tempString, static_cast< int& >(temp));
+       categoryType = static_cast< WifiDirectDeviceTypeCategory >(temp);
+       wifiDirectDeviceInfoImpl.SetDeviceTypeCategory(categoryType);
+       SysLog(NID_NET_WIFI, "The Category Type is %d.", categoryType);
+
+       // ipAddress
+       tempString = Message2String(currentIndex, message);
+       wifiDirectDeviceInfoImpl.SetIpAddress(tempString);
+       SysLog(NID_NET_WIFI, "The IP Address is %ls.", tempString.GetPointer());
+
+       // macaddress
+       tempString = Message2String(currentIndex, message);
+       wifiDirectDeviceInfoImpl.SetMacAddress(tempString);
+       SysLog(NID_NET_WIFI, "The Mac Address is %ls.", tempString.GetPointer());
+
+       // device name
+       tempString = MessageWithLength2String(currentIndex, message);
+       wifiDirectDeviceInfoImpl.SetDeviceName(tempString);
+       SysLog(NID_NET_WIFI, "The Device Name is %ls.", tempString.GetPointer());
+
+       // ssid
+       tempString = MessageWithLength2String(currentIndex, message);
+       wifiDirectDeviceInfoImpl.SetSsid(tempString);
+       SysLog(NID_NET_WIFI, "The SSID is %ls.", tempString.GetPointer());
+
+       pWifiDirectDeviceInfo = _WifiDirectDeviceInfoImpl::GetWifiDirectDeviceInfoInstanceN(wifiDirectDeviceInfoImpl);
+
+       return pWifiDirectDeviceInfo;
+}
+
+result
+_WifiDirectGroupClientImpl::StartTimer(void)
+{
+       SysTryReturnResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "This instance has not been constructed yet.");
+       SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+       result r = E_SUCCESS;
+
+       r = __retryTimer.Start(MAX_REQUEST_TIMEOUT*1000);
+       TryReturn(r == E_SUCCESS, r, "[%s] Failed to start timer.", GetErrorMessage(r));
+
+       SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [ClientImplCurrentState:%s] [result:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+       return r;
+}
+
+result
+_WifiDirectGroupClientImpl::StopTimer(void)
+{
+       result r = E_SUCCESS;
+
+       r = __retryTimer.Cancel();
+       TryReturn(r == E_SUCCESS, r, "Failed to cancel timer. (r = %s)", GetErrorMessage(r));
+
+       return r;
+}
+
+int
+_WifiDirectGroupClientImpl::GetRetryCount(void)
+{
+       return __retryCount;
+}
+
+void
+_WifiDirectGroupClientImpl::UpdateRetryCount(void)
+{
+       __retryCount++;
+}
+
+void
+_WifiDirectGroupClientImpl::ResetRetryCount(void)
+{
+       __retryCount = 0;
+}
+////////////////////////////////////////////////////////////////////////////////
+/// Private
+
+int
+_WifiDirectGroupClientImpl::AddRef(void)
+{
+       return __pWifiDirectDeviceImpl->AddRef();
+}
+
+
+int
+_WifiDirectGroupClientImpl::Release(void)
+{
+       return __pWifiDirectDeviceImpl->Release();
+}
+
+const char*
+_WifiDirectGroupClientImpl::GetStringOfCurrentState(void) const
+{
+       const char* pStateStr[] = { "DEVICE_INFO_REQUEST_READY",
+                                                               "OWNER_INFO_REQUEST",
+                                                               "MEMBER_INFO_REQUEST",
+                                                               "OWNER_INFO_REQUEST_SENT",
+                                                               "MEMBER_INFO_REQUEST_SENT"};
+
+       return pStateStr[__currentState];
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Lifecycle : Private
+
+_WifiDirectGroupClientImpl::~_WifiDirectGroupClientImpl(void)
+{
+    result r = E_SUCCESS;
+
+       CleanUpServerSocket();
+
+    if (__pLocalIpAddress != null)
+    {
+        delete __pLocalIpAddress;
+        __pLocalIpAddress = null;
+    }
+
+       if (__pNetConnection != null)
+       {
+               r = __pNetConnection->RemoveNetConnectionListener(*this);
+
+               if (IsFailed(r))
+               {
+                       SysLog(NID_NET_WIFI, "Removing a NetConnectionListener has failed. [result:%s]", GetErrorMessage(r));
+               }
+
+               r = __pNetConnection->Close();
+
+               if (IsFailed(r))
+               {
+                       SysLog(NID_NET_WIFI, "Closing NetConncetion has failed. [result:%s]", GetErrorMessage(r));
+               }
+
+               delete __pNetConnection;
+               __pNetConnection = null;
+       }
+}
+
+result
+_WifiDirectGroupClientImpl::Construct(WifiDirectDeviceId localDeviceId, _WifiDirectDeviceImpl& wifiDirectDeviceImpl, bool enableIpInfoService /*= true */)
+{
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectSystemAdapter == null, E_SYSTEM,
+                                               "This instance has already been constructed.");
+
+    __pWifiDirectSystemAdapter = _WifiDirectSystemAdapter::GetInstance();
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectSystemAdapter != null, E_SYSTEM,
+                       "Failed to acquire the instance of _WifiDirectSystemAdapter.");
+
+       __localDeviceId = localDeviceId;
+       __pWifiDirectDeviceImpl = &wifiDirectDeviceImpl;
+
+       result r = E_SUCCESS;
+
+       if (enableIpInfoService == true)
+    {
+           r = CreateNetConnection();
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       TryReturn(r == E_SUCCESS, r, "[%s] Failed to create netconnection.", GetErrorMessage(r));
+    }
+
+
+    r = __stateMutex.Create();
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to create mutex.");
+
+    r = __retryTimer.Construct(*this);
+    TryReturn(r == E_SUCCESS, r, "[%s] Failed to Construct timer.", GetErrorMessage(r));
+
+       return r;
+}
+
+void
+_WifiDirectGroupClientImpl::CleanUpServerSocket(void)
+{
+       if (__pClientSocket != null)
+       {
+           __pClientSocket->RemoveSocketListener(*this);
+               __pClientSocket->Close();
+               delete __pClientSocket;
+               __pClientSocket = null;
+       }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+// static member function
+WifiDirectGroupClient*
+_WifiDirectGroupClientImpl::GetWifiDirectGroupClientInstanceN(_WifiDirectGroupClientImpl& groupClientImpl)
+{
+    WifiDirectGroupClient* pWifiDirectGroupClient = new (std::nothrow) WifiDirectGroupClient();
+    SysTryReturn(NID_NET_WIFI, pWifiDirectGroupClient != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+    SysLog(NID_NET_WIFI, "Enter");
+
+    result r = pWifiDirectGroupClient->Construct(groupClientImpl);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, GetLastResult(), "[%s] Failed to construct WifiDirectGroupOwner.", GetErrorMessage(r));
+        delete pWifiDirectGroupClient;
+        pWifiDirectGroupClient = null;
+    }
+
+    return pWifiDirectGroupClient;
+}
+
+_WifiDirectGroupClientImpl*
+_WifiDirectGroupClientImpl::GetInstance(WifiDirectGroupClient& wifiDirectGroupClient)
+{
+    return wifiDirectGroupClient.__pWifiDirectGroupClientImpl;
+}
+
+const _WifiDirectGroupClientImpl*
+_WifiDirectGroupClientImpl::GetInstance(const WifiDirectGroupClient& wifiDirectGroupClient)
+{
+    return wifiDirectGroupClient.__pWifiDirectGroupClientImpl;
+}
+
+}}}// Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiDirectGroupInfoImpl.cpp b/src/wifi/FNetWifi_WifiDirectGroupInfoImpl.cpp
new file mode 100644 (file)
index 0000000..8c84442
--- /dev/null
@@ -0,0 +1,240 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectGroupInfoImpl.cpp
+ * @brief   This is the implementation file for _WifiDirectGroupInfoImpl class.
+ */
+
+#include <FNetWifiWifiDirectGroupInfo.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiDirectGroupInfoImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen {      namespace Net { namespace Wifi {
+
+static const int MAX_WIFI_DIRECT_SSID_LENGTH = 32;
+
+////////////////////////////////////////////////////////////////////////////////
+/// Lifecycle : Public
+_WifiDirectGroupInfoImpl::_WifiDirectGroupInfoImpl(void)
+    : __isAutoGroupOwnerMode(false)
+    , __isHiddenMode(false)
+    , __groupOwnerIntent(MAX_WIFI_DIRECT_GROUP_OWNER_INTENT)
+    , __maxNumberOfClient(MAX_WIFI_DIRECT_CONNECTED_CLIENTS)
+    , __ssid("")
+    , __bssId("")
+    , __radioChannel(WIFI_RADIO_CHANNEL_UNKNOWN)
+{
+
+}
+
+_WifiDirectGroupInfoImpl::_WifiDirectGroupInfoImpl(const _WifiDirectGroupInfoImpl& value)
+    : __isAutoGroupOwnerMode(value.__isAutoGroupOwnerMode)
+    , __isHiddenMode(value.__isHiddenMode)
+    , __groupOwnerIntent(value.__groupOwnerIntent)
+    , __maxNumberOfClient(value.__maxNumberOfClient)
+    , __ssid(value.__ssid)
+    , __bssId(value.__bssId)
+    , __radioChannel(value.__radioChannel)
+{
+
+}
+
+_WifiDirectGroupInfoImpl::~_WifiDirectGroupInfoImpl(void)
+{
+
+}
+
+_WifiDirectGroupInfoImpl&
+_WifiDirectGroupInfoImpl::operator=(const _WifiDirectGroupInfoImpl& rhs)
+{
+    if (this != &rhs)
+    {
+        __isAutoGroupOwnerMode = rhs.__isAutoGroupOwnerMode;
+        __isHiddenMode = rhs.__isHiddenMode;
+        __groupOwnerIntent = rhs.__groupOwnerIntent;
+        __maxNumberOfClient = rhs.__maxNumberOfClient;
+        __ssid = rhs.__ssid;
+        __bssId = rhs.__bssId;
+        __radioChannel = rhs.__radioChannel;
+    }
+    return *this;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+/// Operation : Public
+
+bool
+_WifiDirectGroupInfoImpl::GetAutonomousGroupOwnerMode(void) const
+{
+       return __isAutoGroupOwnerMode;
+}
+
+bool
+_WifiDirectGroupInfoImpl::GetHiddenMode(void) const
+{
+       return __isHiddenMode;
+}
+
+String
+_WifiDirectGroupInfoImpl::GetSsid(void) const
+{
+       return __ssid;
+}
+
+int
+_WifiDirectGroupInfoImpl::GetGroupOwnerIntent(void) const
+{
+       return  __groupOwnerIntent;
+}
+
+int
+_WifiDirectGroupInfoImpl::GetMaxNumberOfClients(void) const
+{
+       return __maxNumberOfClient;
+}
+
+String
+_WifiDirectGroupInfoImpl::GetBssId(void) const
+{
+       return __bssId;
+}
+
+WifiRadioChannel
+_WifiDirectGroupInfoImpl::GetOperatingChannel(void) const
+{
+       return __radioChannel;
+}
+
+void
+_WifiDirectGroupInfoImpl::SetAutonomousGroupOwnerMode(bool mode)
+{
+       __isAutoGroupOwnerMode = mode;
+}
+
+void
+_WifiDirectGroupInfoImpl::SetHiddenMode(bool mode)
+{
+       __isHiddenMode = mode;
+}
+
+result
+_WifiDirectGroupInfoImpl::SetGroupOwnerIntent(int intent)
+{
+    SysTryReturnResult(NID_NET_WIFI, intent >= 0 && intent <= MAX_WIFI_DIRECT_GROUP_OWNER_INTENT,
+               E_INVALID_ARG, "The argument is invalid. The intent value is %d.", intent);
+
+       __groupOwnerIntent = intent;
+
+       return E_SUCCESS;
+}
+
+result
+_WifiDirectGroupInfoImpl::SetMaxNumberOfClients(int numberOfClient)
+{
+    SysTryReturnResult(NID_NET_WIFI, numberOfClient >= 0 && numberOfClient <= MAX_WIFI_DIRECT_CONNECTED_CLIENTS,
+               E_INVALID_ARG, "The argument is invalid. The value of numberOfClient is %d.", numberOfClient);
+
+       __maxNumberOfClient = numberOfClient;
+
+       return E_SUCCESS;
+}
+
+result
+_WifiDirectGroupInfoImpl::SetSsid(const String &ssid)
+{
+       int ssidLength = ssid.GetLength();
+
+       SysTryReturnResult(NID_NET_WIFI, ssidLength > 0 && ssidLength <= MAX_WIFI_DIRECT_SSID_LENGTH,
+               E_INVALID_ARG, "The argument is invalid. The length of ssid is %d.", ssidLength);
+
+       __ssid = String(ssid);
+
+       return E_SUCCESS;
+}
+
+bool
+_WifiDirectGroupInfoImpl::Equals(const Tizen::Base::Object& obj) const
+{
+    const _WifiDirectGroupInfoImpl* pOther = dynamic_cast<const _WifiDirectGroupInfoImpl*>(&obj);
+
+    if (pOther == null
+        || __isAutoGroupOwnerMode != pOther->__isAutoGroupOwnerMode
+        || __isHiddenMode != pOther->__isHiddenMode
+        || __groupOwnerIntent != pOther->__groupOwnerIntent
+        || __maxNumberOfClient != pOther->__maxNumberOfClient
+        || !__ssid.Equals(pOther->__ssid)
+        || !__bssId.Equals(pOther->__bssId)
+        || __radioChannel != pOther->__radioChannel )
+     {
+        return false;
+     }
+
+    return true;
+}
+int
+_WifiDirectGroupInfoImpl::GetHashCode(void) const
+{
+    return __maxNumberOfClient ^ __groupOwnerIntent ^ __ssid.GetHashCode() ^ __bssId.GetHashCode();
+}
+
+WifiDirectGroupInfo*
+_WifiDirectGroupInfoImpl::CreateWifiDirectGroupInfoInstanceN(_WifiDirectGroupInfoImpl &wifiDirectGroupInfoImpl)
+{
+       WifiDirectGroupInfo* pWifiDirectGroupInfo = new (std::nothrow) WifiDirectGroupInfo();
+
+    SysTryReturn(NID_NET_WIFI, pWifiDirectGroupInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       *(_WifiDirectGroupInfoImpl::GetInstance(*pWifiDirectGroupInfo)) = wifiDirectGroupInfoImpl;
+
+       return pWifiDirectGroupInfo;
+}
+
+void
+_WifiDirectGroupInfoImpl::SetBssId(const Tizen::Base::String &bssId)
+{
+       __bssId = bssId;
+}
+
+void
+_WifiDirectGroupInfoImpl::SetOperatingChannel(const WifiRadioChannel &radioChannel)
+{
+       __radioChannel = radioChannel;
+}
+void
+_WifiDirectGroupInfoImpl::SetBssIdOfWifiDirectGroupInfo(WifiDirectGroupInfo& wifiDirectGroupInfo, const Tizen::Base::String &bssId)
+{
+       wifiDirectGroupInfo.__pWifiDirectGroupInfoImpl->SetBssId(bssId);
+}
+
+_WifiDirectGroupInfoImpl*
+_WifiDirectGroupInfoImpl::GetInstance(WifiDirectGroupInfo& wifiDirectGroupInfo)
+{
+
+    return wifiDirectGroupInfo.__pWifiDirectGroupInfoImpl;
+}
+
+const _WifiDirectGroupInfoImpl*
+_WifiDirectGroupInfoImpl::GetInstance(const WifiDirectGroupInfo& wifiDirectGroupInfo)
+{
+    return wifiDirectGroupInfo.__pWifiDirectGroupInfoImpl;
+}
+
+} } }// Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiDirectGroupOwnerEvent.cpp b/src/wifi/FNetWifi_WifiDirectGroupOwnerEvent.cpp
new file mode 100644 (file)
index 0000000..7967bf0
--- /dev/null
@@ -0,0 +1,119 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectGroupOwnerEvent.cpp
+ * @brief   This is the implementation file for the _WifiDirectGroupOwnerEvent Class.
+ *
+ * This header file contains implementation of the _WifiDirectGroupOwner Class.
+ */
+
+#include <FBaseRtIEventListener.h>
+#include <FNetWifiIWifiDirectGroupOwnerListener.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FNetNetConnection.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiDirectGroupOwnerEvent.h"
+#include "FNetWifi_WifiDirectEventArg.h"
+
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+////////////////////////////////////////////////////////////////////////////
+// Lifecycle : Public
+_WifiDirectGroupOwnerEvent::_WifiDirectGroupOwnerEvent(void)
+{
+}
+
+_WifiDirectGroupOwnerEvent::~_WifiDirectGroupOwnerEvent(void)
+{
+
+}
+
+result
+_WifiDirectGroupOwnerEvent::Construct(void)
+{
+    return _Event::Initialize();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Operation : Protected
+
+void
+_WifiDirectGroupOwnerEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+    const _WifiDirectEventArg* pArg = dynamic_cast<const _WifiDirectEventArg*>(&arg);
+    SysTryReturnVoidResult(NID_NET_WIFI, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is a null pointer.");
+
+    result r = pArg->GetError();
+    SysLog(NID_NET_WIFI, "The result value of IEventArg is %s.", GetErrorMessage(r));
+
+    IWifiDirectGroupOwnerListener* pGroupOwnerListener = dynamic_cast<IWifiDirectGroupOwnerListener*>(&listener);
+
+    if (pGroupOwnerListener != null)
+    {
+        _WifiDirectEventType eventType = pArg->GetEventType();
+        WifiDirectDeviceId localDeviceId = pArg->GetDeviceId();
+
+        switch (eventType)
+        {
+            case WIFI_DIRECT_GO_EVENT_CLIENT_ASSOCIATED:
+                SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_GO_EVENT_CLIENT_ASSOCIATED)");
+                {
+                    WifiDirectDeviceInfo* pClientDeviceInfo = pArg->GetDeviceInfo();
+                    pGroupOwnerListener->OnWifiDirectClientAssociated(localDeviceId, *pClientDeviceInfo);
+                }
+                break;
+            case WIFI_DIRECT_GO_EVENT_CLIENT_DISASSOCIATED:
+                SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_GO_EVENT_CLIENT_DISASSOCIATED)");
+                {
+                    WifiDirectAssociationTerminationReason reason = pArg->GetDisassociationReason();
+                    WifiDirectDeviceInfo* pClientDeviceInfo = pArg->GetDeviceInfo();
+                    pGroupOwnerListener->OnWifiDirectClientDisassociated(localDeviceId, *pClientDeviceInfo, reason);
+                }
+                break;
+            case WIFI_DIRECT_GO_EVENT_GROUP_DESTROYED:
+            case WIFI_DIRECT_DEVICE_EVENT_GROUP_LEFT:
+
+                SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_GO_EVENT_GROUP_DESTROYED)");
+                pGroupOwnerListener->OnWifiDirectGroupDestroyed(localDeviceId, r);
+                break;
+            case WIFI_DIRECT_GO_EVENT_SERVICE_STARTED:
+                SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_GO_EVENT_SERVICE_STARTED)");
+                {
+                    const Tizen::Net::NetConnection* pNetConnection = pArg->GetNetConnection();
+                    pGroupOwnerListener->OnWifiDirectGroupMemberInfoServiceStarted(localDeviceId, pNetConnection, r);
+                }
+                break;
+            case WIFI_DIRECT_GO_EVENT_SERVICE_STOPPED:
+                SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_GO_EVENT_SERVICE_STOPPED)");
+                pGroupOwnerListener->OnWifiDirectGroupMemberInfoServiceStopped(localDeviceId, r);
+                break;
+            default:
+                SysLog(NID_NET_WIFI, "An undefined external WifiDirectGroupOwner event occurs. (Type: %d)",eventType);
+                SysAssert(false);
+        }
+    }
+    else
+    {
+        SysLog(NID_NET_WIFI, "The result of a dynamic_cast operation is null for external GO listener.");
+    }
+}
+
+} } } // Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiDirectGroupOwnerEvent.h b/src/wifi/FNetWifi_WifiDirectGroupOwnerEvent.h
new file mode 100644 (file)
index 0000000..864eb82
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectGroupOwnerEvent.h
+ * @brief   This is the header file for the _WifiDirectGroupOwnerEvent class.
+ *
+ * This header file contains declarations of the _WifiDirectGroupOwnerEvent class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_OWNER_EVENT_H_
+#define _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_OWNER_EVENT_H_
+
+// Includes
+#include <FBaseResult.h>
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class IEventListener;
+class IEventArg;
+}}}
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+/**
+ * @class   _WifiDirectGroupOwnerEvent
+ * @brief   This class handles WifiDirectGroupOwner events.
+ *
+ * When a WifiDirectOwner event occurs, the _WifiDirectGroupOwnerEvent object finds a IWifiDirectGroupOwnerEventListener object
+ * which is registered for the Device object and calls an appropriate method of the listener.
+ */
+
+class _WifiDirectGroupOwnerEvent
+    : public Tizen::Base::Runtime::_Event
+{
+public:
+    /**
+     * 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.
+     */
+    _WifiDirectGroupOwnerEvent(void);
+
+    /**
+     * This destructor overrides Tizen::Base::Runtime::_Event::~_Event().
+     */
+    virtual ~_WifiDirectGroupOwnerEvent(void);
+
+    /**
+     * Initializes this instance.
+     */
+    result Construct(void);
+
+protected:
+    /**
+     * Checks the arg and finds out the type of event. After that this method calls appropriate pListener's method.
+     *
+     * @return      A result code.
+     * @param[in]   listener        It is a event listener related to this WifiDirectOwner event.
+     * @param[in]   arg             It is an argument-like instance of WifiDirectOwner event retransmitted to the listener's method as an argument.
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_ARG   The argument passed to a method contains an invalid value.@n
+     */
+    void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @since   2.0
+     *
+     * @param[in]   rhs   An instance of %_WifiDirectGroupOwnerEvent
+     */
+    _WifiDirectGroupOwnerEvent(const _WifiDirectGroupOwnerEvent& rhs);
+        
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in] rhs An instance of %_WifiDirectGroupOwnerEvent
+     */
+    _WifiDirectGroupOwnerEvent& operator =(const _WifiDirectGroupOwnerEvent& rhs);
+}; // _WifiDirectGroupOwnerEvent
+
+}}} // Tizen::Net::Wifi
+#endif // _FNET_WIFI_INTERNAL_WIFI_DIRECT_GROUP_OWNER_EVENT_H_
diff --git a/src/wifi/FNetWifi_WifiDirectGroupOwnerImpl.cpp b/src/wifi/FNetWifi_WifiDirectGroupOwnerImpl.cpp
new file mode 100644 (file)
index 0000000..838eff8
--- /dev/null
@@ -0,0 +1,775 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FNetWifiWifiDirectGroupOwnerImpl.cpp
+ * @brief      This is the implementation file for the _WifiDirectGroupOwnerImpl.
+ *
+ * This header file contains implementation of the _WifiDirectGroupOwnerImpl.
+ */
+#include <FBaseColArrayList.h>
+#include <FNetNetAccountManager.h>
+#include <FNetNetConnection.h>
+#include <FNetSockSocket.h>
+#include <FNetWifiWifiDirectGroupOwner.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FNetWifiIWifiDirectGroupOwnerListener.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiDirectGroupOwnerImpl.h"
+#include "FNetWifi_WifiDirectDeviceInfoImpl.h"
+#include "FNetWifi_WifiDirectDeviceImpl.h"
+#include "FNetWifi_WifiDirectSystemAdapter.h"
+#include "FNetWifi_WifiDirectGroupOwnerEvent.h"
+#include "FNetWifi_WifiDirectEventArg.h"
+
+
+using namespace Tizen::Base;
+using namespace Tizen::Net;
+using namespace Tizen::Net::Wifi;
+using namespace Tizen::Net::Sockets;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen {      namespace Net { namespace Wifi {
+
+
+////////////////////////////////////////////////////////////////////////////////
+/// Lifecycle : Public
+_WifiDirectGroupOwnerImpl::_WifiDirectGroupOwnerImpl(void)
+    : __localDeviceId(-1)
+    , __pWifiDirectDeviceImpl(null)
+    , __pWifiDirectSystemAdapter(null)
+    , __pNetConnection(null)
+    , __pServerSocket(null)
+    , __pLocalIpAddress(null)
+    , __portNumber(DEFAULT_PORT)
+    , __currentState(WIFI_DIRECT_MEMBER_INFO_SERVICE_IDLE)
+    , __isDisconnect(false)
+{
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Operation : Public
+
+result
+_WifiDirectGroupOwnerImpl::DestroyGroup(void)
+{
+       SysTryReturnResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "This instance has not been constructed yet.");
+       SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s]",
+                               __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+       result r = E_SUCCESS;
+
+       _WifiDirectDeviceState currentState = __pWifiDirectDeviceImpl->GetWifiDirectDeviceCurrentState();
+
+       SysTryReturnResult(NID_NET_WIFI, currentState != WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING, E_IN_PROGRESS,
+                                                       "DeleteGroup process is in progress.");
+
+       if (currentState == WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER)
+       {
+               r = __pWifiDirectSystemAdapter->DestroyGroup();
+
+               if (r == E_SUCCESS)
+               {
+                       __pWifiDirectDeviceImpl->SetWifiDirectDeviceCurrentState(WIFI_DIRECT_DEVICE_INTERNAL_DISCONNECTING);
+               }
+       }
+       else
+       {
+               r = E_INVALID_OPERATION;
+       }
+
+       SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] [result:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+       return r;
+}
+
+result
+_WifiDirectGroupOwnerImpl::Disconnect(const WifiDirectDeviceInfo& wifiDirectRemoteDeviceInfo)
+{
+       SysTryReturnResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "This instance has not been constructed yet.");
+       SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+       result r = E_SUCCESS;
+
+       _WifiDirectDeviceState currentState = __pWifiDirectDeviceImpl->GetWifiDirectDeviceCurrentState();
+
+       SysTryReturnResult(NID_NET_WIFI, !__isDisconnect, E_IN_PROGRESS, "The currently device state is DISCONNECTING.");
+
+       if (currentState == WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER)
+       {
+               r = __pWifiDirectSystemAdapter->Disconnect(wifiDirectRemoteDeviceInfo);
+
+               if (r == E_SUCCESS)
+               {
+                       __isDisconnect = true;
+               }
+       }
+       else
+       {
+               r = E_INVALID_OPERATION;
+       }
+
+       SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] [result:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+       return r;
+}
+
+IList*
+_WifiDirectGroupOwnerImpl::GetAllGroupMemberInfoListN(void)
+{
+    SysTryReturn(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, null, E_SYSTEM, "[E_SYSTEM] This instance has not been constructed yet.");
+    SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+    ClearLastResult();
+
+    result r = E_SUCCESS;
+
+    IList* pWifiDirectGroupMemberInfoList = null;
+
+       _WifiDirectDeviceState currentState = __pWifiDirectDeviceImpl->GetWifiDirectDeviceCurrentState();
+
+       if (currentState == WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER)
+       {
+           pWifiDirectGroupMemberInfoList = __pWifiDirectSystemAdapter->GetAllGroupMemberInfoImplListN();
+       }
+       else
+    {
+           r = E_INVALID_OPERATION;
+    }
+
+       SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] [result:%s]",
+               __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+
+       return pWifiDirectGroupMemberInfoList;
+}
+
+result
+_WifiDirectGroupOwnerImpl::StartGroupMemberInfoService(const int portNumber)
+{
+       SysTryReturnResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "This instance has not been constructed yet.");
+       SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+       result r = E_SUCCESS;
+
+       _WifiDirectDeviceState currentState = __pWifiDirectDeviceImpl->GetWifiDirectDeviceCurrentState();
+       SysTryReturnResult(NID_NET_WIFI, currentState == WIFI_DIRECT_DEVICE_INTERNAL_CREATED_OWNER, E_INVALID_OPERATION,
+                                                       "The operation is not allowed in this state.");
+
+       switch (__currentState)
+       {
+       case WIFI_DIRECT_MEMBER_INFO_SERVICE_STARTING:
+               r = E_IN_PROGRESS;
+               break;
+       case WIFI_DIRECT_MEMBER_INFO_SERVICE_STARTED:
+       case WIFI_DIRECT_MEMBER_INFO_SERVICE_STOPPING:
+               r = E_INVALID_OPERATION;
+               break;
+       default:
+           SysLog(NID_NET_WIFI, "Exception case occurred.");
+               break;
+       }
+
+       SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] The operation is not allowed in this state.", GetErrorMessage(r));
+
+       SysTryReturnResult(NID_NET_WIFI, !((portNumber < MIN_PORT_NUMBER) || (portNumber > MAX_PORT_NUMBER)), E_OUT_OF_RANGE,
+                                                       "The specified argument is not in a valid range.");
+
+       r = __pNetConnection->Start();
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Failed to start NetConnection.", GetErrorMessage(r));
+
+       __currentState = WIFI_DIRECT_MEMBER_INFO_SERVICE_STARTING;
+
+    __portNumber = portNumber;
+
+CATCH:
+       SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] [result:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+       return r;
+}
+
+result
+_WifiDirectGroupOwnerImpl::StopGroupMemberInfoService(void)
+{
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "This instance has not been constructed yet.");
+    SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s]",
+                                   __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+    result r = E_SUCCESS;
+
+    switch (__currentState)
+    {
+    case WIFI_DIRECT_MEMBER_INFO_SERVICE_IDLE:
+    case WIFI_DIRECT_MEMBER_INFO_SERVICE_STARTING:
+           r = E_INVALID_OPERATION;
+           break;
+    case WIFI_DIRECT_MEMBER_INFO_SERVICE_STOPPING:
+           r = E_IN_PROGRESS;
+           break;
+    default:
+           SysLog(NID_NET_WIFI, "Exception case occurred.");
+           break;
+    }
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] The operation is not allowed in this state.", GetErrorMessage(r));
+
+    CleanUpServerSocket();
+
+    if (__pNetConnection != null)
+    {
+           r = __pNetConnection->Stop();
+
+           if (r == E_SUCCESS)
+        {
+               __currentState = WIFI_DIRECT_MEMBER_INFO_SERVICE_STOPPING;
+        }
+
+    }
+
+    SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] [result:%s]",
+                   __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+    return r;
+}
+
+result
+_WifiDirectGroupOwnerImpl::StartGroupMemberSocketServer(void)
+{
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "This instance has not been constructed yet.");
+    SysLog(NID_NET_WIFI, "Enter ,[DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s]",
+                    __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+    result r = E_SUCCESS;
+
+    Ip4Address localAddr(L"0");  // IN_ADDR_ANY
+    NetEndPoint localEndPoint(localAddr, __portNumber);
+
+    __pServerSocket = new (std::nothrow) Socket();
+    SysTryCatch(NID_NET_WIFI, __pServerSocket != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    r = __pServerSocket->Construct(*__pNetConnection, NET_SOCKET_AF_IPV4, NET_SOCKET_TYPE_DATAGRAM, NET_SOCKET_PROTOCOL_UDP);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Socket Construction has failed.", GetErrorMessage(r));
+
+    r = __pServerSocket->SetSockOpt(NET_SOCKET_SOL_SOCKET, NET_SOCKET_SO_BROADCAST, 1);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Setting socket option has failed.", GetErrorMessage(r));
+
+    r = __pServerSocket->AsyncSelectByListener(NET_SOCKET_EVENT_READ | NET_SOCKET_EVENT_WRITE | NET_SOCKET_EVENT_CLOSE);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Setting the socket to the asynchronous mode has failed.", GetErrorMessage(r));
+
+    r = __pServerSocket->Bind(localEndPoint);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Binding UDP socket has Failed.", GetErrorMessage(r));
+
+    r = __pServerSocket->AddSocketListener(*this);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Adding SocketListener has failed.", GetErrorMessage(r));
+
+    SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] [result:%s]",
+                __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+
+    return r;
+
+CATCH:
+    r = TransExceptionsExclusive ( r , E_SYSTEM, E_ALREADY_BOUND , E_OUT_OF_MEMORY ); 
+
+    if (__pServerSocket != null)
+    {
+        delete __pServerSocket;
+        __pServerSocket = null;
+    }
+
+    SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] [result:%s]",
+                __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+    return r;
+}
+
+void
+_WifiDirectGroupOwnerImpl::OnSocketReadyToReceive(Socket& socket)
+{
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "[E_SYSTEM] This instance has not been constructed yet.");
+    SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s]",
+                                   __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+    SysTryReturnVoidResult(NID_NET_WIFI, __currentState == WIFI_DIRECT_MEMBER_INFO_SERVICE_STARTED, E_SYSTEM,
+                                   "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] current state is not SERVICE_STARTED",
+                                   __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+    result r = E_SUCCESS;
+
+    unsigned long arg = 0;
+
+    r = socket.Ioctl(NET_SOCKET_FIONREAD, arg);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+    SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r,
+                                   "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] Socket ioctl for read has failed. [result:%s]",
+                                   __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+
+    Ip4Address peerAddr("0");
+    NetEndPoint peerEndPoint(peerAddr, 0);
+
+    ByteBuffer rxBuffer;
+    rxBuffer.Construct(arg);
+
+    r = socket.ReceiveFrom(rxBuffer, peerEndPoint);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+    SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r,
+                                   "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] Receiving data from socket has failed. [result:%s]",
+                                   __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+
+    IpAddress* pPeerAddress = peerEndPoint.GetAddress();
+    SysTryReturnVoidResult(NID_NET_WIFI, pPeerAddress != null && pPeerAddress->GetNetAddressFamily() == NET_AF_IPV4, E_SYSTEM,
+                           "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] PeerAddress is null or not IPV4. [result:%s]",
+                           __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+
+    SysTryReturnVoidResult(NID_NET_WIFI, __pLocalIpAddress != null && __pLocalIpAddress->ToString() != pPeerAddress->ToString(), E_SYSTEM,
+                                   "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] broadcast received from my address.",
+                                   __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+    SysLog(NID_NET_WIFI, "Destination IP : %ls, PORT : %d", pPeerAddress->ToString().GetPointer(), peerEndPoint.GetPort());
+
+    rxBuffer.Flip();
+
+    String messageString(reinterpret_cast<const char*>(rxBuffer.GetPointer()));
+
+    // process the message received
+    if (!(messageString.IsEmpty()))
+    {
+        _WIFIDIRECT_MESSAGE_TYPE messageType = _WifiDirectUtility::GetMessageType(messageString);
+
+        if (messageType == REQUEST_OWNER_INFO
+            || messageType == REQUEST_ALL_MEMBER_INFO)
+        {
+            SysLog(NID_NET_WIFI, "IP query request received.");
+            SendResponseGroupMemberInfoMessage(peerEndPoint, messageType);
+        }
+        else
+        {
+            SysLog(NID_NET_WIFI, "Invalid request message received. [message type : %d]", messageType);
+        }
+    }
+    else
+    {
+        SysLog(NID_NET_WIFI, "Message is Empty.");
+    }
+
+    SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] [result:%s]",
+            __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+}
+
+void
+_WifiDirectGroupOwnerImpl::SendResponseGroupMemberInfoMessage(const NetEndPoint& recvEndPoint,
+                                                                                                               _WIFIDIRECT_MESSAGE_TYPE messageType)
+{
+    SysTryReturnVoidResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "[E_SYSTEM] This instance has not been constructed yet.");
+    SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s]",
+                           __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+    result r = E_SUCCESS;
+    String responseMessage;
+    ByteBuffer* pResponseBuff = null;
+    String message;
+    WifiDirectDeviceInfo* pWifiDirectDeviceInfo = null;
+
+
+    if (messageType == REQUEST_ALL_MEMBER_INFO)
+    {
+        IList* pGroupMemberInfoList = GetAllGroupMemberInfoListN();
+        r = GetLastResult();
+        SysTryCatch(NID_NET_WIFI, r == E_SUCCESS && pGroupMemberInfoList != null, , r,
+                                       "[%s] Failed to acquire a list of all group member.", GetErrorMessage(r));
+
+        int numOfMembers = pGroupMemberInfoList->GetCount();
+        SysLog(NID_NET_WIFI, "The number of members is %d.", numOfMembers);
+
+        for (int i = 0 ; i < numOfMembers ; i++)
+        {
+            pWifiDirectDeviceInfo = static_cast< WifiDirectDeviceInfo* >(pGroupMemberInfoList->GetAt(i));
+
+            message.Append(MakeMessageFormat(*pWifiDirectDeviceInfo));
+        }
+
+        pGroupMemberInfoList->RemoveAll(true);
+        delete pGroupMemberInfoList;
+
+        pWifiDirectDeviceInfo = null;
+
+        responseMessage.Append(RESPONSE_ALL_MEMBER_INFO);
+        responseMessage.Append(L":");
+        responseMessage.Append(numOfMembers); // count of Ip address available
+        responseMessage.Append(message);
+    }
+    else // Respond for the RequestGroupOwnerInfo()
+    {
+        pWifiDirectDeviceInfo = __pWifiDirectDeviceImpl->GetLocalDeviceInfoN();
+        r = GetLastResult();
+        SysTryCatch(NID_NET_WIFI, r == E_SUCCESS && pWifiDirectDeviceInfo != null, , r,
+                                       "[%s] Failed to acquire WifiDirectDeviceInfo.", GetErrorMessage(r));
+
+        message = MakeMessageFormat(*pWifiDirectDeviceInfo);
+
+        delete pWifiDirectDeviceInfo;
+        pWifiDirectDeviceInfo = null;
+
+        responseMessage.Append(RESPONSE_OWNER_INFO);
+        responseMessage.Append(L":");
+        responseMessage.Append(1); // count of Ip address available
+        responseMessage.Append(message);
+    }
+
+    SysLog(NID_NET_WIFI, "response message-%ls", responseMessage.GetPointer());
+
+    pResponseBuff = StringUtil::StringToUtf8N(responseMessage);
+    r = GetLastResult();
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Failed to convert String.", GetErrorMessage(r));
+
+    r = __pServerSocket->SendTo(*pResponseBuff, recvEndPoint);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Failed to send.", GetErrorMessage(r));
+
+CATCH:
+    delete pWifiDirectDeviceInfo;
+    delete pResponseBuff;
+    SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] [result:%s]",
+                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+}
+
+String
+_WifiDirectGroupOwnerImpl::MakeMessageFormat(WifiDirectDeviceInfo &wifiDirectDeviceInfo)
+{
+       String message(0);
+
+       // GroupMemberType and DeviceTypeCategory should be added , Status will be ACTIVATED implicitly.
+       //WifiDirectDeviceId deviceId = wifiDirectDeviceInfo.GetDeviceId();
+       WifiDirectGroupMemberType memberType = wifiDirectDeviceInfo.GetGroupMemberType();
+       WifiDirectDeviceTypeCategory categoryType = wifiDirectDeviceInfo.GetDeviceTypeCategory();
+       String ipAddress = wifiDirectDeviceInfo.GetIpAddress()->ToString();
+       String macAddress = wifiDirectDeviceInfo.GetMacAddress();
+       String deviceName = wifiDirectDeviceInfo.GetDeviceName();
+       String ssid = wifiDirectDeviceInfo.GetSsid();
+
+       String deviceNameLen("");
+       String ssidLen("");
+
+
+       message.Append(L":");
+       message.Append(static_cast< int >(memberType));
+
+       message.Append(L":");
+       message.Append(static_cast< int >(categoryType));
+
+       message.Append(L":");
+       message.Append(ipAddress);
+
+       message.Append(L":");
+       message.Append(macAddress);
+
+       deviceNameLen.Format(3, L"%2d", deviceName.GetLength());
+       message.Append(L":");
+       message.Append(deviceNameLen);
+       message.Append(deviceName);
+
+
+       ssidLen.Format(3, L"%2d", ssid.GetLength());
+       message.Append(L":");
+       message.Append(ssidLen);
+       message.Append(ssid);
+
+       SysLog(NID_NET_WIFI, "message :%ls", message.GetPointer());
+
+       return message;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+/// Private
+int
+_WifiDirectGroupOwnerImpl::AddRef(void)
+{
+       return __pWifiDirectDeviceImpl->AddRef();
+}
+
+
+int
+_WifiDirectGroupOwnerImpl::Release(void)
+{
+       return __pWifiDirectDeviceImpl->Release();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Lifecycle : Private
+_WifiDirectGroupOwnerImpl::~_WifiDirectGroupOwnerImpl(void)
+{
+       result r = E_SUCCESS;
+
+       CleanUpServerSocket();
+
+       if (__pNetConnection != null)
+       {
+               r = __pNetConnection->RemoveNetConnectionListener(*this);
+
+               if (IsFailed(r))
+               {
+                       SysLog(NID_NET_WIFI, "Removing NetConnectionListener has failed. [result:%s]", GetErrorMessage(r));
+               }
+
+               r = __pNetConnection->Close();
+
+               if (IsFailed(r))
+               {
+                       SysLog(NID_NET_WIFI, "Closing NetConncetion has failed. [result:%s]", GetErrorMessage(r));
+               }
+
+               delete __pNetConnection;
+               __pNetConnection = null;
+       }
+    if (__pLocalIpAddress != null)
+    {
+        delete __pLocalIpAddress;
+        __pLocalIpAddress = null;
+    }
+}
+
+void
+_WifiDirectGroupOwnerImpl::OnNetConnectionStarted(Tizen::Net::NetConnection& netConnection, result r)
+{
+       SysTryReturnVoidResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "[E_SYSTEM] This instance has not been constructed yet.");
+       SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] [Action Result :%s]",
+                               __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+
+       const NetConnectionInfo* pNetConnectionInfo = null;
+       result res = E_SUCCESS;
+
+       if (__currentState == WIFI_DIRECT_MEMBER_INFO_SERVICE_STARTING)
+       {
+               if (r == E_SUCCESS)
+               {
+                       // Get the local IP address
+                       pNetConnectionInfo = netConnection.GetNetConnectionInfo();
+
+                       if (pNetConnectionInfo != null)
+                       {
+                               __pLocalIpAddress = pNetConnectionInfo->GetLocalAddress()->CloneN();
+                       }
+
+                       res = StartGroupMemberSocketServer();
+
+                       if (res == E_SUCCESS)
+                       {
+                               __currentState = WIFI_DIRECT_MEMBER_INFO_SERVICE_STARTED;
+                       }
+                       else
+                       {
+                               __currentState = WIFI_DIRECT_MEMBER_INFO_SERVICE_IDLE;
+                       }
+
+                       _WifiDirectEventArg* pEventArg  = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_GO_EVENT_SERVICE_STARTED,
+                               __localDeviceId, &netConnection, res);
+                       SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+                       __pWifiDirectDeviceImpl->GetWifiDirectGroupOwnerEvent()->Fire(*pEventArg);
+               }
+               else
+               {
+                       __currentState = WIFI_DIRECT_MEMBER_INFO_SERVICE_IDLE;
+                       __portNumber = DEFAULT_PORT;
+
+                       _WifiDirectEventArg* pEventArg  = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_GO_EVENT_SERVICE_STARTED,
+                                           __localDeviceId, (Tizen::Net::NetConnection*)null, E_SYSTEM);
+            SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+            __pWifiDirectDeviceImpl->GetWifiDirectGroupOwnerEvent()->Fire(*pEventArg);
+
+               }
+       }
+       else
+       {
+               SysLog(NID_NET_WIFI, "The callback is not fired in this state.");
+       }
+
+       SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] [SocketServer-result:%s]",
+                               __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(res));
+}
+
+void
+_WifiDirectGroupOwnerImpl::OnNetConnectionStopped(Tizen::Net::NetConnection& netConnection, result r)
+{
+       SysTryReturnVoidResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "[E_SYSTEM] This instance has not been constructed yet.");
+
+       SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] [Action Result :%s]",
+                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+
+       bool isFired = false;
+       int res = E_SUCCESS;
+
+       switch (__currentState)
+       {
+    case WIFI_DIRECT_MEMBER_INFO_SERVICE_STARTED:
+        if (r == E_SUCCESS)
+        {
+            isFired = true;
+        }
+        break;
+    case WIFI_DIRECT_MEMBER_INFO_SERVICE_STOPPING:
+        isFired = true;
+        break;
+    case WIFI_DIRECT_MEMBER_INFO_SERVICE_STARTING:
+        res = E_SYSTEM;
+        break;
+    default:
+        SysLog(NID_NET_WIFI, "Other case");
+        break;
+       }
+       __currentState = WIFI_DIRECT_MEMBER_INFO_SERVICE_IDLE;
+
+       if (isFired)
+       {
+           _WifiDirectEventArg* pEventArg  =  new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_GO_EVENT_SERVICE_STOPPED,
+                                               __localDeviceId, res);
+           __pWifiDirectDeviceImpl->GetWifiDirectGroupOwnerEvent()->Fire(*pEventArg);
+       }
+    if (__pLocalIpAddress != null)
+    {
+        delete __pLocalIpAddress;
+        __pLocalIpAddress = null;
+    }
+       SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] [ServiceStopped_Event:%s]",
+               __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), isFired ? "Fired" : "NotFired");
+}
+
+result
+_WifiDirectGroupOwnerImpl::Construct(WifiDirectDeviceId localDeviceId, _WifiDirectDeviceImpl& wifiDirectDeviceImpl, bool enableIpInfoService /*= true */)
+{
+       SysTryReturnResult(NID_NET_WIFI, __pWifiDirectSystemAdapter == null, E_SYSTEM, "This instance has already been constructed.");
+
+    __pWifiDirectSystemAdapter = _WifiDirectSystemAdapter::GetInstance();
+    SysTryReturnResult(NID_NET_WIFI, __pWifiDirectSystemAdapter != null, E_SYSTEM,
+                                               "Failed to acquire the instance of _WifiDirectSystemAdapter.");
+
+    __localDeviceId = localDeviceId;
+       __pWifiDirectDeviceImpl = &wifiDirectDeviceImpl;
+
+       result r = E_SUCCESS;
+
+       if (enableIpInfoService == true)
+    {
+               result r = CreateNetConnectionForService();
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Creating NetConnection has failed.");
+    }
+
+       return r;
+}
+
+const char*
+_WifiDirectGroupOwnerImpl::GetStringOfCurrentState(void) const
+{
+       const char* pStateStr[] = { "SERVICE_IDLE",
+                                                               "SERVICE_STARTING",
+                                                               "SERVICE_STARTED",
+                                                               "SERVICE_STOPPING"};
+
+       return pStateStr[__currentState];
+}
+
+void
+_WifiDirectGroupOwnerImpl::ResetDisconnect(void)
+{
+       __isDisconnect = false;
+}
+
+void
+_WifiDirectGroupOwnerImpl::CleanUpServerSocket(void)
+{
+       if (__pServerSocket != null)
+       {
+           __pServerSocket->RemoveSocketListener(*this);
+               __pServerSocket->Close();
+               delete __pServerSocket;
+               __pServerSocket = null;
+       }
+}
+
+result
+_WifiDirectGroupOwnerImpl::CreateNetConnectionForService(void)
+{
+       SysTryReturnResult(NID_NET_WIFI, __pWifiDirectDeviceImpl != null, E_SYSTEM, "This instance has not been constructed yet.");
+       SysLog(NID_NET_WIFI, "Enter, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState());
+
+       result r = E_SUCCESS;
+       NetAccountManager accountManager;
+       NetAccountId accountId = INVALID_HANDLE;
+
+       r = accountManager.Construct();
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to construct NetAccountManager.");
+
+       accountId = accountManager.GetNetAccountId(NET_BEARER_WIFI_DIRECT);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, accountId != INVALID_HANDLE, r, "Getting NetAccountId has failed.");
+
+       __pNetConnection = new (std::nothrow) NetConnection();
+       SysTryReturnResult(NID_NET_WIFI, __pNetConnection != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pNetConnection->Construct(accountId);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to construct NetConnection.");
+
+       r = __pNetConnection->AddNetConnectionListener(*this);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to add listner of Netconnection.");
+
+       SysLog(NID_NET_WIFI, "Exit, [CurrentState: %s], [ActionResult: %s]", GetStringOfCurrentState(), GetErrorMessage(r));
+       SysLog(NID_NET_WIFI, "Exit, [DeviceImplCurrentState:%s] [OwnerImplCurrentState:%s] [result:%s]",
+                                       __pWifiDirectDeviceImpl->GetStringOfCurrentState(), GetStringOfCurrentState(), GetErrorMessage(r));
+
+       return r;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// static member function
+WifiDirectGroupOwner*
+_WifiDirectGroupOwnerImpl::GetWifiDirectGroupOwnerInstanceN(_WifiDirectGroupOwnerImpl& groupOwnerImpl)
+{
+    WifiDirectGroupOwner* pWifiDirectGroupOwner = new (std::nothrow) WifiDirectGroupOwner();
+    SysTryReturn(NID_NET_WIFI, pWifiDirectGroupOwner != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    result r = pWifiDirectGroupOwner->Construct(groupOwnerImpl);
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, GetLastResult(), "[%s] Failed to construct WifiDirectGroupOwner.", GetErrorMessage(r));
+        delete pWifiDirectGroupOwner;
+        pWifiDirectGroupOwner = null;
+    }
+
+    return pWifiDirectGroupOwner;
+}
+
+_WifiDirectGroupOwnerImpl*
+_WifiDirectGroupOwnerImpl::GetInstance(WifiDirectGroupOwner& wifiDirectGroupOwner)
+{
+    return wifiDirectGroupOwner.__pWifiDirectGroupOwnerImpl;
+}
+
+const _WifiDirectGroupOwnerImpl*
+_WifiDirectGroupOwnerImpl::GetInstance(const WifiDirectGroupOwner& wifiDirectGroupOwner)
+{
+    return wifiDirectGroupOwner.__pWifiDirectGroupOwnerImpl;
+}
+
+}}}// Tizen::Net::Wifi
+
diff --git a/src/wifi/FNetWifi_WifiDirectSystemAdapter.cpp b/src/wifi/FNetWifi_WifiDirectSystemAdapter.cpp
new file mode 100644 (file)
index 0000000..3e9470f
--- /dev/null
@@ -0,0 +1,2249 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectSystemAdapter.cpp
+ * @brief   This is the implementation file for _WifiDirectSystemAdapter class
+ */
+#include <pthread.h>
+#include <vconf.h>
+#include <wifi-direct.h>
+#include <FBaseColArrayList.h>
+#include <FBaseColLinkedList.h>
+#include <FTextEncoding.h>
+#include <FBaseUtilStringUtil.h>
+#include <FNetWifiWifiDirectGroupMember.h>
+#include <FNetWifiWifiDirectGroupInfo.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FNetIp4Address.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FBaseColAllElementsDeleter.h>
+#include "FNetWifi_WifiDirectSystemAdapter.h"
+#include "FNetWifi_WifiDirectEvent.h"
+#include "FNetWifi_WifiDirectEventArg.h"
+#include "FNetWifi_WifiDirectUtility.h"
+#include "FNetWifi_WifiDirectDeviceImpl.h"
+#include "FNetWifi_WifiDirectDeviceInfoImpl.h"
+#include "FNetWifi_WifiDirectGroupInfoImpl.h"
+#include "FNetWifi_WifiIpcProxy.h"
+#include "FNetWifi_WifiDirectUtility.h"
+
+#ifdef _WifiDirectConvertErrorResult
+#undef _WifiDirectConvertErrorResult
+#endif
+#define _WifiDirectConvertErrorResult(condition, r, value) \
+               do \
+               { \
+                       if (condition) {   \
+                               r = value; \
+                       } \
+               } while (0);
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Text;
+using namespace Tizen::Net;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+static const int MAX_DEVICE_INFO_COUNT = 32;
+static const int WIFI_DIRECT_DISCOVERY_TIMEOUT = 10;
+
+_WifiDirectSystemAdapter* _WifiDirectSystemAdapter::__pWifiDirectSystemAdapter = null;
+
+void
+_WifiDirectSystemAdapter::InitSingleton(void)
+{
+    unique_ptr<_WifiDirectSystemAdapter> pInst(new (std::nothrow) _WifiDirectSystemAdapter());
+    SysTryReturnVoidResult(NID_NET_WIFI, pInst != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    bool r = true;
+    r = pInst->Construct();
+    SysTryReturnVoidResult(NID_NET_WIFI, r == true, r, "Error occured in construct.");
+
+    __pWifiDirectSystemAdapter = pInst.release();
+    std::atexit(DestroySingleton);
+}
+
+void 
+_WifiDirectSystemAdapter::DestroySingleton(void)
+{
+    delete __pWifiDirectSystemAdapter;
+}
+
+_WifiDirectSystemAdapter*
+_WifiDirectSystemAdapter::GetInstance(void)
+{
+    static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+    if (!__pWifiDirectSystemAdapter)
+    {
+        ClearLastResult();
+        pthread_once(&onceBlock, InitSingleton);
+        
+        result r = GetLastResult();
+        if (IsFailed(r))
+        {
+             onceBlock = PTHREAD_ONCE_INIT;
+        }
+    }
+
+    return __pWifiDirectSystemAdapter;
+}
+
+/////////////////////////////////////////////////////
+// DeviceManager
+
+Tizen::Base::Collection::IList*
+_WifiDirectSystemAdapter::GetAllDeviceInfoN(void)
+{
+    result r = E_SUCCESS;
+
+    unique_ptr<ArrayList> pList(new (std::nothrow) ArrayList());
+    SysTryReturn(NID_NET_WIFI, pList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    r = pList->Construct();
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    unique_ptr<WifiDirectDeviceInfo> pDeviceInfo(GetLocalDeviceInfoN());
+    SysTryReturn(NID_NET_WIFI, pDeviceInfo != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+    r = pList->Add(*pDeviceInfo);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+    pDeviceInfo.release();
+
+    return pList.release();
+}
+
+/////////////////////////////////////////////////////
+// Device
+
+result
+_WifiDirectSystemAdapter::Activate(void)
+{
+    result r = E_SYSTEM;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    err = wifi_direct_activate();
+    _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NOT_PERMITTED, r, E_INVALID_OPERATION);
+    _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    __currentState = WIFI_DIRECT_SYSTEM_ACTIVATING;
+
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::Deactivate(void)
+{
+    result r = E_SYSTEM;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    err = wifi_direct_deactivate();
+    _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NOT_PERMITTED, r, E_INVALID_OPERATION);
+    _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    __currentState = WIFI_DIRECT_SYSTEM_DEACTIVATING;
+
+    return r;
+}
+
+WifiDirectGroupInfo*
+_WifiDirectSystemAdapter::GetGroupSettingInfoN(void) const
+{
+    result r = E_SUCCESS;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    unique_ptr<WifiDirectGroupInfo> pGroupInfo(new (std::nothrow) WifiDirectGroupInfo());
+    SysTryReturn(NID_NET_WIFI, pGroupInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    _WifiDirectGroupInfoImpl* pGroupInfoImpl = _WifiDirectGroupInfoImpl::GetInstance(*pGroupInfo);
+    wifi_direct_state_e status = WIFI_DIRECT_STATE_DEACTIVATED;
+    err = wifi_direct_get_state(&status);
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    // MAC
+    char* pMacAddress = null;
+    err = wifi_direct_get_mac_address(&pMacAddress);
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+    _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
+
+    SysTryReturn(NID_NET_WIFI, pMacAddress != null && r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    String mac = _WifiDirectUtility::ConvertMacCharToString(pMacAddress);
+    free(pMacAddress);
+    pGroupInfoImpl->SetBssId(mac);
+
+    if (status != WIFI_DIRECT_STATE_DEACTIVATED
+            && status != WIFI_DIRECT_STATE_DEACTIVATING
+            && status != WIFI_DIRECT_STATE_ACTIVATING)
+    {
+               // SSID
+        if (status == WIFI_DIRECT_STATE_CONNECTED)
+        {
+                       char* pSsid = null;
+                       err = wifi_direct_get_ssid(&pSsid);
+
+                       if (pSsid == null)
+                       {
+                               SysLog(NID_NET_WIFI, "The ssid is null.");
+                       }
+                       else
+                       {
+                               pGroupInfoImpl->SetSsid(String(pSsid));
+                               free(pSsid);
+                       }
+        }
+
+        // Autonomous group
+        bool isAutonomousGroup = false;
+        err = wifi_direct_is_autonomous_group(&isAutonomousGroup);
+        _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+        pGroupInfoImpl->SetAutonomousGroupOwnerMode(isAutonomousGroup);
+
+        // Intent
+        int groupOwnerIntent = 0;
+        err = wifi_direct_get_group_owner_intent(&groupOwnerIntent);
+        _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+        pGroupInfoImpl->SetGroupOwnerIntent(groupOwnerIntent);
+
+        // Radio channel
+        int channel = 0;
+        err = wifi_direct_get_operating_channel(&channel);
+        _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+        WifiRadioChannel operatingChannel = _WifiDirectUtility::ConvertChannel(channel);
+        pGroupInfoImpl->SetOperatingChannel(operatingChannel);
+    }
+
+    // Max clients
+    int maxClients= 0;
+    err = wifi_direct_get_max_clients(&maxClients);
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    pGroupInfoImpl->SetMaxNumberOfClients(maxClients);
+
+    return pGroupInfo.release();
+}
+
+WifiDirectDeviceInfo*
+_WifiDirectSystemAdapter::GetLocalDeviceInfoN(void) const
+{
+    SysTryReturn(NID_NET_WIFI, __pWifiServiceProxy != null, null, E_SYSTEM, "[E_SYSTEM] IPC instance has not been constructed yet.");
+
+    ClearLastResult();
+
+    result r = E_SUCCESS;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    unique_ptr<WifiDirectDeviceInfo> pDeviceInfo(new (std::nothrow) WifiDirectDeviceInfo());
+    SysTryReturn(NID_NET_WIFI, pDeviceInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    _WifiDirectDeviceInfoImpl* pDeviceInfoImpl = _WifiDirectDeviceInfoImpl::GetInstance(*pDeviceInfo);
+
+    // device ID
+    pDeviceInfoImpl->SetDeviceId(DEFAULT_DEVICE_ID);
+
+    // device name
+    String deviceName;
+    r = __pWifiServiceProxy->GetWifiDirectLocalDeviceName(deviceName);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    pDeviceInfoImpl->SetDeviceName(deviceName);
+    r = GetLastResult();
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, E_SYSTEM, "[%s] The length of device name is invalid.", GetErrorMessage(r));
+
+    // device status / group member type
+    wifi_direct_state_e status = WIFI_DIRECT_STATE_DEACTIVATED;
+    err = wifi_direct_get_state(&status);
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    if (status == WIFI_DIRECT_STATE_DEACTIVATED)
+    {
+        pDeviceInfoImpl->SetDeviceStatus(WIFI_DIRECT_DEVICE_DEACTIVATED);
+    }
+    else
+    {
+        pDeviceInfoImpl->SetDeviceStatus(WIFI_DIRECT_DEVICE_ACTIVATED);
+
+        bool isOwner = false;
+        err = wifi_direct_is_group_owner(&isOwner);
+        _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+        switch (status)
+        {
+        case WIFI_DIRECT_STATE_DISCONNECTING:
+        case WIFI_DIRECT_STATE_CONNECTED:
+            if (isOwner)
+            {
+                pDeviceInfoImpl->SetGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER);
+            }
+            else
+            {
+                pDeviceInfoImpl->SetGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT);
+            }
+            break;
+        case WIFI_DIRECT_STATE_ACTIVATED:
+            if (isOwner)
+            {
+                pDeviceInfoImpl->SetGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER);
+            }
+            else
+            {
+                pDeviceInfoImpl->SetGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE);
+            }
+            break;
+        default:
+            pDeviceInfoImpl->SetGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE);
+            break;
+        }
+
+        if (status == WIFI_DIRECT_STATE_CONNECTED)
+        {
+               // ssid
+               char* pSsid = null;
+               err = wifi_direct_get_ssid(&pSsid);
+
+               if (pSsid == null)
+               {
+                       SysLog(NID_NET_WIFI, "The ssid is null.");
+               }
+               else
+               {
+                       pDeviceInfoImpl->SetSsid(String(pSsid));
+                       free(pSsid);
+               }
+        }
+    }
+
+    // device type category
+    wifi_direct_primary_device_type_e typeCategory = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_OTHER;
+    err = wifi_direct_get_primary_device_type(&typeCategory);
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    WifiDirectDeviceTypeCategory deviceTypeCategory = _WifiDirectUtility::ConvertDeviceTypeCategory(typeCategory);
+    pDeviceInfoImpl->SetDeviceTypeCategory(deviceTypeCategory);
+
+    // mac address
+    char* pMacAddress = null;
+    err = wifi_direct_get_mac_address(&pMacAddress);
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+    _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
+    SysTryReturn(NID_NET_WIFI, pMacAddress != null && r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    String mac = _WifiDirectUtility::ConvertMacCharToString(pMacAddress);
+    pDeviceInfoImpl->SetMacAddress(mac);
+    r = GetLastResult();
+    free(pMacAddress);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, E_SYSTEM, "[%s] The MAC address is invalid.", GetErrorMessage(r));
+
+    // IP address
+    if (pDeviceInfoImpl->GetGroupMemberType() != WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
+    {
+        char* pIp = null;
+        err = wifi_direct_get_ip_address(&pIp);
+        _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+        _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
+        SysTryReturn(NID_NET_WIFI, pIp != null && r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+        r = pDeviceInfoImpl->SetIpAddress(String(pIp));
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+        free(pIp);
+    }
+
+    // supported WPS configuration mode
+    if (status != WIFI_DIRECT_STATE_DEACTIVATED
+                && status != WIFI_DIRECT_STATE_DEACTIVATING
+                && status != WIFI_DIRECT_STATE_ACTIVATING)
+    {
+        ArrayListT<WifiWpsConfigurationMode> wpsModeList;
+        r = wpsModeList.Construct();
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, E_SYSTEM, "[%s] Construction of ArrayListT has failed.", GetErrorMessage(r));
+
+        err = wifi_direct_foreach_supported_wps_types(OnWifiDirectSupportedWpsMode, &wpsModeList);
+        _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+        pDeviceInfoImpl->SetSupportedWpsConfigurationMode(wpsModeList);
+        r = GetLastResult();
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, E_SYSTEM, "[%s] Setting of wps configuration mode has failed.", GetErrorMessage(r));
+
+        wpsModeList.RemoveAll();
+    }
+
+    return pDeviceInfo.release();
+}
+
+WifiWpsConfigurationMode
+_WifiDirectSystemAdapter::GetWpsConfigurationModePreference(void) const
+{
+    result r = E_SYSTEM;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    wifi_direct_wps_type_e wpsType;
+    WifiWpsConfigurationMode wpsMode = WIFI_WPS_CONFIG_MODE_NONE;
+
+    err = wifi_direct_get_wps_type(&wpsType);
+    _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, WIFI_WPS_CONFIG_MODE_NONE, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    switch(wpsType)
+    {
+    case WIFI_DIRECT_WPS_TYPE_PBC:
+        wpsMode = WIFI_WPS_CONFIG_MODE_PBC;
+        break;
+    case WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY:
+        wpsMode = WIFI_WPS_CONFIG_MODE_PIN_DISPLAY;
+        break;
+    case WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD:
+        wpsMode = WIFI_WPS_CONFIG_MODE_PIN_KEYPAD;
+        break;
+    default:
+        SysLog(NID_NET_WIFI, "The WPS type is unknown.");
+        break;
+    }
+
+    return wpsMode;
+}
+
+result
+_WifiDirectSystemAdapter::SetLocalDeviceName(const String &name)
+{
+    SysTryReturnResult(NID_NET_WIFI, __pWifiServiceProxy != null, E_SYSTEM, "IPC instance has not been constructed yet.");
+
+    result r = __pWifiServiceProxy->SetWifiDirectLocalDeviceName(name);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Setting the Wi-Fi Direct local device name through OSP Connectivity daemon has failed.", GetErrorMessage(r));
+
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::SetWpsConfigurationModePreference(WifiWpsConfigurationMode mode)
+{
+    result r = E_SYSTEM;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    wifi_direct_wps_type_e wpsType = WIFI_DIRECT_WPS_TYPE_NONE;
+
+    switch(mode)
+    {
+    case WIFI_WPS_CONFIG_MODE_PBC:
+        wpsType = WIFI_DIRECT_WPS_TYPE_PBC;
+        break;
+    case WIFI_WPS_CONFIG_MODE_PIN_DISPLAY:
+        wpsType = WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY;
+        break;
+    case WIFI_WPS_CONFIG_MODE_PIN_KEYPAD:
+        wpsType = WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD;
+        break;
+    default:
+        SysLog(NID_NET_WIFI, "The WPS type is unknown.");
+        return E_SYSTEM;
+    }
+
+    err = wifi_direct_set_wps_type(wpsType);
+    _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::CreateGroup(const WifiDirectGroupInfo *pWifiDirectGroupInfo,
+                                        const WifiDirectDeviceInfo *pWifiDirectRemoteDeviceInfo)
+{
+    result r = E_SUCCESS;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    SysTryReturnResult(NID_NET_WIFI, !(pWifiDirectGroupInfo != null
+                                   && pWifiDirectGroupInfo->GetAutonomousGroupOwnerMode()
+                                   && pWifiDirectRemoteDeviceInfo), E_INVALID_OPERATION,
+                                    "The operation don't allow to create an autonomous group with a specified remote device.");
+    __remoteMacAddress.Clear();
+    __remoteDeviceName.Clear();
+
+    // autonomous group owner mode
+    if (pWifiDirectGroupInfo != null
+        && pWifiDirectGroupInfo->GetAutonomousGroupOwnerMode())
+    {
+        r = SetGroupSettingInfo(*pWifiDirectGroupInfo);
+        SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+        err = wifi_direct_create_group();
+        _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "Propagating.", GetErrorMessage(r));
+
+        __currentState = WIFI_DIRECT_SYSTEM_AUTONOMOUS_GROUP_CREATING;
+    }
+    else
+    {
+        if (pWifiDirectGroupInfo != null)
+        {
+               r = SetGroupSettingInfo(*pWifiDirectGroupInfo);
+               SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+        }
+
+        if (pWifiDirectRemoteDeviceInfo != null)
+        {
+            unique_ptr<char []> pMacAddress(_WifiDirectUtility::ConvertMacStringToCharN(pWifiDirectRemoteDeviceInfo->GetMacAddress()));
+            SysTryReturnResult(NID_NET_WIFI, pMacAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+            err = wifi_direct_connect(pMacAddress.get());
+            _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+
+            if (IsFailed(r))
+            {
+                SysLog(NID_NET_WIFI, "[%s] Propagating.", GetErrorMessage(r));
+                result ret = StartListenMode();
+                SysLogException(NID_NET_WIFI, ret, "[%s] Propagating.", GetErrorMessage(ret));
+                return r;
+            }
+        }
+        else
+        {
+            if (IsDiscoverable())
+            {
+                r = StopListenModeToScan();
+                SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_SYSTEM, "A system error occurs.");
+            }
+            else
+            {
+                r = StartDiscovery();
+                SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+
+                if (IsFailed(r))
+                {
+                    r = StartListenMode();
+                    SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+                    return E_SYSTEM;
+                }
+            }
+        }
+        __currentState = WIFI_DIRECT_SYSTEM_GROUP_CREATING;
+    }
+
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::CancelGroupCreation(void)
+{
+    result r = E_SYSTEM;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    if (__currentState == WIFI_DIRECT_SYSTEM_GROUP_CREATING || __currentState == WIFI_DIRECT_SYSTEM_AUTONOMOUS_GROUP_CREATING)
+    {
+        switch(__currentScanState)
+        {
+        case WIFI_DIRECT_SYSTEM_SCAN_LISTEN_CANCELING_TO_SCAN:
+        case WIFI_DIRECT_SYSTEM_SCAN_SCANNING:
+            __currentState = WIFI_DIRECT_SYSTEM_CONNECT_CANCELLING;
+            r = CancelDiscovery();
+            break;
+        default:
+            err = wifi_direct_disconnect_all();
+            _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+
+            if (IsFailed(r))
+            {
+                SysLog(NID_NET_WIFI, "[%s] Propagating.", GetErrorMessage(r));
+
+                result ret = StartListenMode();
+                SysLogException(NID_NET_WIFI, ret, "[%s] Propagating.", GetErrorMessage(ret));
+            }
+            else
+            {
+                __currentState = WIFI_DIRECT_SYSTEM_GROUP_CANCELING;
+            }
+        }
+    }
+    else
+    {
+        r = E_INVALID_OPERATION;
+    }
+
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::Scan(void)
+{
+    result r = E_SUCCESS;
+
+    switch(__currentScanState)
+    {
+    case WIFI_DIRECT_SYSTEM_SCAN_IDLE:
+        r = StartDiscovery();
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_SYSTEM_SCAN_LISTEN:
+        r = StopListenModeToScan();
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_SYSTEM_SCAN_LISTEN_CANCELING_TO_SCAN:
+    case WIFI_DIRECT_SYSTEM_SCAN_SCANNING:
+        r = E_IN_PROGRESS;
+        break;
+    case WIFI_DIRECT_SYSTEM_SCAN_CANCELLING:
+        r = E_INVALID_OPERATION;
+        break;
+    }
+
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::CancelScan(void)
+{
+    result r = E_SUCCESS;
+
+    switch(__currentScanState)
+    {
+
+    case WIFI_DIRECT_SYSTEM_SCAN_LISTEN_CANCELING_TO_SCAN:
+        __currentScanState = WIFI_DIRECT_SYSTEM_SCAN_CANCELLING;
+        //fall through
+    case WIFI_DIRECT_SYSTEM_SCAN_CANCELLING:
+        r = E_SUCCESS;
+        break;
+    case WIFI_DIRECT_SYSTEM_SCAN_SCANNING:
+        r = CancelDiscovery();
+        break;
+    default:
+        r = E_INVALID_OPERATION;
+        break;
+    }
+
+   return r;
+}
+
+result
+_WifiDirectSystemAdapter::Associate(const WifiDirectDeviceInfo &wifiDirectGroupOwnerDeviceInfo)
+{
+    result r = E_SYSTEM;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    unique_ptr<char[]> pMacAddress(_WifiDirectUtility::ConvertMacStringToCharN(wifiDirectGroupOwnerDeviceInfo.GetMacAddress()));
+    SysTryReturnResult(NID_NET_WIFI, pMacAddress != null, E_OUT_OF_MEMORY, "Failed to convert MacAddress");
+
+    err = wifi_direct_connect(pMacAddress.get());
+    _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    __currentState = WIFI_DIRECT_SYSTEM_ASSOCIATING;
+
+    return r;
+}
+
+bool
+_WifiDirectSystemAdapter::IsDiscoverable(void) const
+{
+    bool isDiscoverable = false;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    err = wifi_direct_is_discoverable(&isDiscoverable);
+
+    if (err != WIFI_DIRECT_ERROR_NONE)
+    {
+       SysLog(NID_NET_WIFI, "Getting discoverable state has failed.");
+       return false;
+    }
+
+    return isDiscoverable;
+}
+
+bool
+_WifiDirectSystemAdapter::IsActivated(void) const
+{
+    if (__currentState != WIFI_DIRECT_SYSTEM_DEACTIVATED &&
+        __currentState != WIFI_DIRECT_SYSTEM_ACTIVATING )
+    {
+        return true;
+    }
+
+    return false;
+}
+
+result
+_WifiDirectSystemAdapter::Connect(const WifiDirectDeviceInfo& peerDeviceInfo)
+{
+    result r = E_SYSTEM;
+
+    switch(__currentState)
+    {
+    case WIFI_DIRECT_SYSTEM_AUTONOMOUS_GROUP_CREATING:
+    case WIFI_DIRECT_SYSTEM_GROUP_CREATING:
+    case WIFI_DIRECT_SYSTEM_CONNECTING:
+        r = E_IN_PROGRESS;
+        break;
+    case WIFI_DIRECT_SYSTEM_ACTIVATED:
+    case WIFI_DIRECT_SYSTEM_OWNER:
+    {
+        unique_ptr<char[]> pMacAddress(_WifiDirectUtility::ConvertMacStringToCharN(peerDeviceInfo.GetMacAddress()));
+        SysTryReturnResult(NID_NET_WIFI, pMacAddress != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+        int err = wifi_direct_connect(pMacAddress.get());
+        _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+
+        if (r == E_SUCCESS)
+        {
+            __currentState = WIFI_DIRECT_SYSTEM_CONNECTING;
+        }
+    }
+        break;
+    default:
+        r = E_INVALID_OPERATION;
+        break;
+    }
+
+    if (IsFailed(r))
+    {
+        SysLog(NID_NET_WIFI, "[%s] Propagating.", GetErrorMessage(r));
+        result ret = StartListenMode();
+        SysLogException(NID_NET_WIFI, ret, "[%s] Propagating.", GetErrorMessage(ret));
+    }
+
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::CancelConnect(void)
+{
+    result r = E_SYSTEM;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    switch(__currentState)
+    {
+    case WIFI_DIRECT_SYSTEM_GROUP_CREATING:
+    case WIFI_DIRECT_SYSTEM_CONNECTING:
+        err = wifi_direct_disconnect_all();
+        _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+
+        if (r == E_SUCCESS)
+        {
+               __currentState = WIFI_DIRECT_SYSTEM_CONNECT_CANCELLING;
+        }
+        else
+        {
+               SysLog(NID_NET_WIFI, "[%s] Propagating.", GetErrorMessage(r));
+               result ret = StartListenMode();
+               SysLogException(NID_NET_WIFI, ret, "[%s] Propagating.", GetErrorMessage(ret));
+        }
+        break;
+    case WIFI_DIRECT_SYSTEM_GROUP_CANCELING:
+    case WIFI_DIRECT_SYSTEM_CONNECT_CANCELLING:
+        r = E_IN_PROGRESS;
+        break;
+    default:
+        r = E_INVALID_OPERATION;
+        break;
+    }
+
+    SysLog(NID_NET_WIFI, "[%s] The current state is %ls", GetErrorMessage(r), GetStringOfAllCurrentState().GetPointer());
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::CreateAutonomousGroup(void)
+{
+    result r = E_SYSTEM;
+
+    if (__currentState == WIFI_DIRECT_SYSTEM_ACTIVATED)
+    {
+        int err = wifi_direct_create_group();
+        _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+
+        if (r == E_SUCCESS)
+        {
+               __currentState = WIFI_DIRECT_SYSTEM_AUTONOMOUS_GROUP_CREATING;
+        }
+        else
+        {
+               SysLog(NID_NET_WIFI, "[%s] Propagating.", GetErrorMessage(r));
+            result ret = StartListenMode();
+            SysLogException(NID_NET_WIFI, ret, "[%s] Propagating.", GetErrorMessage(ret));
+        }
+    }
+    else
+    {
+        r = E_INVALID_OPERATION;
+        SysLog(NID_NET_WIFI, "[%s] The current state is %ls.", GetErrorMessage(r), GetStringOfAllCurrentState().GetPointer());
+    }
+
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::SetGroupSettingInfo(const WifiDirectGroupInfo& groupSettingInfo)
+{
+    result r = E_SUCCESS;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    // Sets group owner intent
+    err = wifi_direct_set_group_owner_intent(groupSettingInfo.GetGroupOwnerIntent());
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_INVALID_OPERATION);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    // Sets max clients
+    err = wifi_direct_set_max_clients(groupSettingInfo.GetMaxNumberOfClients());
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_INVALID_OPERATION);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::LeaveGroup(void)
+{
+    result r = E_SYSTEM;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    if (__currentState == WIFI_DIRECT_SYSTEM_OWNER)
+    {
+        err = wifi_direct_destroy_group();
+        _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+        __currentState = WIFI_DIRECT_SYSTEM_LEAVING;
+    }
+    else if ( __currentState == WIFI_DIRECT_SYSTEM_CLIENT)
+    {
+        err = wifi_direct_disconnect_all();
+        _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+        __currentState = WIFI_DIRECT_SYSTEM_LEAVING;
+    }
+    else if (__currentState == WIFI_DIRECT_SYSTEM_LEAVING)
+    {
+        r = E_IN_PROGRESS;
+    }
+    else
+    {
+        r = E_INVALID_OPERATION;
+    }
+
+    return r;
+}
+
+WifiDirectDeviceInfo*
+_WifiDirectSystemAdapter::GetGroupOwnerInfoN(void) const
+{
+    ClearLastResult();
+    result r = E_SYSTEM;
+    WifiDirectDeviceInfo* pGroupOwnerInfo = null;
+
+    if (__currentState == WIFI_DIRECT_SYSTEM_OWNER)
+    {
+        pGroupOwnerInfo = GetLocalDeviceInfoN();
+    }
+    else if (__currentState == WIFI_DIRECT_SYSTEM_CLIENT)
+    {
+        pGroupOwnerInfo = GetConnectedPeerDeviceInfoN(WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER);
+
+        char* pSsid = null;
+        int err = wifi_direct_get_ssid(&pSsid);
+        _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+
+        if (pSsid == null)
+        {
+           SetLastResult(r);
+           SysLog(NID_NET_WIFI, "The ssid is null");
+        }
+        else
+        {
+            _WifiDirectDeviceInfoImpl::SetSsidOfWifiDirectDeviceInfo(*pGroupOwnerInfo, String(pSsid));
+            free(pSsid);
+        }
+    }
+    else
+    {
+        SetLastResult(E_INVALID_OPERATION);
+    }
+
+    return pGroupOwnerInfo;
+}
+
+IList*
+_WifiDirectSystemAdapter::GetGroupClientInfoListN(void) const
+{
+    ClearLastResult();
+    result r = E_SYSTEM;
+    LinkedList* pClientInfoList = null;
+
+    pClientInfoList = new (std::nothrow) LinkedList(SingleObjectDeleter);
+    SysTryReturn(NID_NET_WIFI, pClientInfoList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    if (__currentState == WIFI_DIRECT_SYSTEM_OWNER)
+    {
+        int err = wifi_direct_foreach_connected_peers(OnWifiDirectEachConnectedClient, pClientInfoList);
+        _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+    else
+    {
+        SetLastResult(E_INVALID_OPERATION);
+    }
+
+    return pClientInfoList;
+}
+
+WifiRadioChannel
+_WifiDirectSystemAdapter::GetOperatingChannel(void) const
+{
+    int channel = 0;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    err = wifi_direct_get_operating_channel(&channel);
+
+    if (err != WIFI_DIRECT_ERROR_NONE)
+    {
+       SysLog(NID_NET_WIFI, "Getting operating channel has failed.");
+       return WIFI_RADIO_CHANNEL_UNKNOWN;
+    }
+
+    WifiRadioChannel operatingChannel = _WifiDirectUtility::ConvertChannel(channel);
+
+    return operatingChannel;
+}
+
+result
+_WifiDirectSystemAdapter::DestroyGroup(void)
+{
+    result r = E_SYSTEM;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    if (__currentState == WIFI_DIRECT_SYSTEM_OWNER)
+    {
+        err = wifi_direct_destroy_group();
+        _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+        __currentState = WIFI_DIRECT_SYSTEM_DESTROYING;
+    }
+    else if (__currentState == WIFI_DIRECT_SYSTEM_DESTROYING)
+    {
+        r = E_IN_PROGRESS;
+    }
+    else
+    {
+        r = E_INVALID_OPERATION;
+    }
+
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::Disconnect(const WifiDirectDeviceInfo& remoteDeviceInfo)
+{
+    result r = E_SYSTEM;
+
+    switch(__currentState)
+    {
+    case WIFI_DIRECT_SYSTEM_DISCONNECTING:
+       r = E_IN_PROGRESS;
+       break;
+    case WIFI_DIRECT_SYSTEM_OWNER:
+    case WIFI_DIRECT_SYSTEM_CLIENT:
+    {
+       unique_ptr<char[]> pMacAddress(_WifiDirectUtility::ConvertMacStringToCharN(remoteDeviceInfo.GetMacAddress()));
+       SysTryReturnResult(NID_NET_WIFI, pMacAddress != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to convert mac address.");
+       int err = WIFI_DIRECT_ERROR_NONE;
+
+       err = wifi_direct_disconnect(pMacAddress.get());
+       _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       if (__currentState == WIFI_DIRECT_SYSTEM_OWNER)
+       {
+           WifiDirectDeviceInfo* pDeviceInfo = GetPeerInfo(remoteDeviceInfo.GetMacAddress());
+           SysTryLog(NID_NET_WIFI, pDeviceInfo != null, "The client info was not found.");
+
+           if (pDeviceInfo != null)
+           {
+               _WifiDirectDeviceInfoImpl::GetInstance(*pDeviceInfo)->SetDisconnect(true);
+           }
+       }
+
+       __currentState = WIFI_DIRECT_SYSTEM_DISCONNECTING;
+
+    }
+       break;
+    default:
+       r = E_INVALID_OPERATION;
+       break;
+    }
+
+    return r;
+}
+
+IList*
+_WifiDirectSystemAdapter::GetAllGroupMemberInfoImplListN(void)
+{
+    int err = WIFI_DIRECT_ERROR_NONE;
+    result r = E_SUCCESS;
+
+    unique_ptr<ArrayList, AllElementsDeleter> pDeviceInfoList(new (std::nothrow) ArrayList());
+    SysTryReturn(NID_NET_WIFI, pDeviceInfoList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    r = pDeviceInfoList->Construct();
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Constructing ArrayList has failed.", GetErrorMessage(r));
+
+    if(__currentState == WIFI_DIRECT_SYSTEM_OWNER)
+    {
+        WifiDirectDeviceInfo* pDeviceInfo = GetLocalDeviceInfoN();
+        r = GetLastResult();
+        SysTryReturn(NID_NET_WIFI, pDeviceInfo != null, null, r, "[%s] Getting LocalDeviceInfo has failed.", GetErrorMessage(r));
+
+        r = pDeviceInfoList->Add(*pDeviceInfo);
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, E_SYSTEM, "[%s] Adding object in ArrayList has failed.", GetErrorMessage(r));
+    }
+
+    err = wifi_direct_foreach_connected_peers(OnWifiDirectEachConnectedClient, pDeviceInfoList.get());
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    return pDeviceInfoList.release();
+}
+
+/////////////////////////////////////////////////////
+// Client
+
+result
+_WifiDirectSystemAdapter::Disassociate(void)
+{
+    result r = E_SYSTEM;
+
+    if(__currentState == WIFI_DIRECT_SYSTEM_CLIENT)
+    {
+        int err = wifi_direct_disconnect_all();
+        _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+        SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+        __currentState = WIFI_DIRECT_SYSTEM_DISCONNECTING;
+    }
+    else
+    {
+        r = E_INVALID_OPERATION;
+    }
+
+    return E_SUCCESS;
+}
+
+
+///////////////////////////////////////////////////////////////
+// Internal
+
+WifiDirectGroupMemberType
+_WifiDirectSystemAdapter::GetCurrentMemberType(void) const
+{
+    WifiDirectGroupMemberType memberType = WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE;
+
+    switch(__currentState)
+    {
+    case WIFI_DIRECT_SYSTEM_OWNER:
+        memberType = WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER;
+        break;
+    case WIFI_DIRECT_SYSTEM_CLIENT:
+        memberType = WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT;
+        break;
+    case WIFI_DIRECT_SYSTEM_DISCONNECTING:
+    case WIFI_DIRECT_SYSTEM_DESTROYING:
+    {
+        bool isGroupOwner = false;
+        int err = wifi_direct_is_group_owner(&isGroupOwner);
+        SysLog(NID_NET_WIFI, "[0x%x] Return value of wifi_direct_is_group_owner()", err);
+
+        if (isGroupOwner == true)
+        {
+            memberType = WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER;
+        }
+        else
+        {
+            memberType = WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT;
+        }
+    }
+        break;
+    default:
+        memberType = WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE;
+        break;
+    }
+
+    return memberType;
+}
+
+bool
+_WifiDirectSystemAdapter::Construct(void)
+{
+    result r = E_SUCCESS;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    unique_ptr<_WifiDirectEvent,_WifiDirectEventDeleter> pWifiDirectEvent(new (std::nothrow) _WifiDirectEvent());
+    SysTryReturn(NID_NET_WIFI, pWifiDirectEvent != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    r = pWifiDirectEvent->Construct();
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+    
+    __pWifiServiceProxy = _WifiIpcProxy::GetInstance();
+    if (__pWifiServiceProxy != null)
+    {
+        r = __pWifiServiceProxy->InitializeWifiDirect();
+        SysLog(NID_NET_WIFI, "Initializing WifiDirect service of osp-connectivity-service %s.",
+                       (r == E_SUCCESS) ? "is successful" : "fails");
+    }
+    else
+    {
+        SysLog(NID_NET_WIFI, "Creating an IPC instance to connect with the Connectivity service daemon has failed.");
+    }
+    
+    err = wifi_direct_initialize();
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    err = wifi_direct_set_device_state_changed_cb(OnWifiDirectPowerChanged, null);
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+    err = wifi_direct_set_discovery_state_changed_cb(OnWifiDirectScanCompleted, null);
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+    err = wifi_direct_set_connection_state_changed_cb(OnWifiDirectConnectionChanged, null);
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+    err = wifi_direct_set_client_ip_address_assigned_cb(OnWifiDirectClientIpAssigned, null);
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+    r = InitializeCurrentState();
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+    r = __peerList.Construct();
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , E_SYSTEM, "[%s] Construction of ArrayList has failed.", GetErrorMessage(r));
+
+    __pWifiDirectEvent = move(pWifiDirectEvent);
+
+    return true;
+
+CATCH:
+    err = wifi_direct_deinitialize();
+    SysLog(NID_NET_WIFI, "[0x%x] Return value of wifi_direct_deinitialize()", err);
+
+    return false;
+}
+void
+_WifiDirectSystemAdapter::AddListener(const _WifiDirectDeviceImpl& listner)
+{
+    __pWifiDirectEvent->AddListener(listner, true);
+}
+void
+_WifiDirectSystemAdapter::RemoveListener(const _WifiDirectDeviceImpl& listner)
+{
+    __pWifiDirectEvent->RemoveListener(listner);
+}
+
+result
+_WifiDirectSystemAdapter::AddPeerInfo(WifiDirectDeviceInfo* pPeerInfo)
+{
+    WifiDirectDeviceInfo* pPeerInfoTemp = new WifiDirectDeviceInfo(*pPeerInfo);
+    return __peerList.Add(*pPeerInfoTemp);
+}
+result
+_WifiDirectSystemAdapter::RemovePeerInfo(WifiDirectDeviceInfo* pPeerInfo)
+{
+    return __peerList.Remove(*pPeerInfo, true);
+}
+WifiDirectDeviceInfo*
+_WifiDirectSystemAdapter::GetPeerInfo(const String& macAddress)
+{
+    WifiDirectDeviceInfo* pDeviceInfo = null;
+    for(int i = 0; i < __peerList.GetCount(); i++)
+    {
+        pDeviceInfo = dynamic_cast<WifiDirectDeviceInfo*>(__peerList.GetAt(i));
+
+        if (pDeviceInfo != null && pDeviceInfo->GetMacAddress() == macAddress)
+        {
+            return pDeviceInfo;
+        }
+    }
+    return null;
+}
+
+_WifiDirectSystemAdapter::_WifiDirectSystemAdapter(void)
+    : __remoteMacAddress()
+    , __remoteDeviceName()
+    , __pScanResult(null)
+    , __currentState(WIFI_DIRECT_SYSTEM_DEACTIVATED)
+    , __currentScanState(WIFI_DIRECT_SYSTEM_SCAN_IDLE)
+    , __peerList()
+    , __pWifiServiceProxy(null)
+{
+
+}
+
+_WifiDirectSystemAdapter::~_WifiDirectSystemAdapter(void)
+{
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    __peerList.RemoveAll(true);
+
+    err = wifi_direct_deinitialize();
+    SysLog(NID_NET_WIFI, "[0x%x] Return value of wifi_direct_deinitialize()", err);
+}
+
+// Callback function
+void
+_WifiDirectSystemAdapter::OnWifiDirectPowerChanged(int errorCode, wifi_direct_device_state_e deviceState, void* pUserData)
+{
+    SysLog(NID_NET_WIFI, "Enter, [deviceState:0x%x] [ErrorCode:0x%x]", deviceState, errorCode);
+    SysLog(NID_NET_WIFI, "%ls", __pWifiDirectSystemAdapter->GetStringOfAllCurrentState().GetPointer());
+
+    int err = WIFI_DIRECT_ERROR_NONE;
+    result r = E_SYSTEM;
+    _WifiDirectEventArg* pEventArg = null;
+    _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+
+    switch(deviceState)
+    {
+    case WIFI_DIRECT_DEVICE_STATE_ACTIVATED:
+        SysLog(NID_NET_WIFI, "deviceState : WIFI_DIRECT_DEVICE_STATE_ACTIVATED");
+        //Don't fire event here, we will fire event after Listen Mode has started
+        //pEventArg = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_ACTIVATED, DEFAULT_DEVICE_ID, r);
+        //SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+        if (r == E_SUCCESS)
+        {
+            if (__pWifiDirectSystemAdapter->__currentState == WIFI_DIRECT_SYSTEM_ACTIVATING)
+            {
+                result res = __pWifiDirectSystemAdapter->StartListenMode();
+
+                if (IsFailed(res))
+                {
+                       SysLogException(NID_NET_WIFI, res, "[%s] Propagating.", GetErrorMessage(res));
+
+                    err = wifi_direct_deactivate();
+                    r = _WifiDirectUtility::ConvertErrorCode(err);
+                    SysLog(NID_NET_WIFI, "[%s] Propagating.", GetErrorMessage(r));
+
+                    return;
+               }
+           }
+           else if(__pWifiDirectSystemAdapter->__currentState == WIFI_DIRECT_SYSTEM_DEACTIVATED)
+           {
+               __pWifiDirectSystemAdapter->__currentState = WIFI_DIRECT_SYSTEM_ACTIVATED;
+                pEventArg = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_ACTIVATED, DEFAULT_DEVICE_ID, r);
+                SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+           }
+        }
+        else
+        {
+            __pWifiDirectSystemAdapter->__currentState = WIFI_DIRECT_SYSTEM_DEACTIVATED;
+        }
+        break;
+    case WIFI_DIRECT_DEVICE_STATE_DEACTIVATED:
+        SysLog(NID_NET_WIFI, "deviceState : WIFI_DIRECT_DEVICE_STATE_DEACTIVATED");
+        if (__pWifiDirectSystemAdapter->__currentState != WIFI_DIRECT_SYSTEM_ACTIVATING)
+        {
+            pEventArg = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_DEACTIVATED, DEFAULT_DEVICE_ID, r);
+            SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+            if (r == E_SUCCESS)
+            {
+               __pWifiDirectSystemAdapter->__currentState = WIFI_DIRECT_SYSTEM_DEACTIVATED;
+               __pWifiDirectSystemAdapter->__currentScanState = WIFI_DIRECT_SYSTEM_SCAN_IDLE;
+            }
+            else
+            {
+               SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               result res = __pWifiDirectSystemAdapter->InitializeCurrentState();
+               SysLogException(NID_NET_WIFI, res, "[%s] Propagating.", GetErrorMessage(res));
+            }
+        }
+        else
+        {
+            if (r == E_SUCCESS)
+            {
+               __pWifiDirectSystemAdapter->__currentState = WIFI_DIRECT_SYSTEM_DEACTIVATED;
+               __pWifiDirectSystemAdapter->__currentScanState = WIFI_DIRECT_SYSTEM_SCAN_IDLE;
+                pEventArg = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_ACTIVATED, DEFAULT_DEVICE_ID, E_SYSTEM);
+                SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+            }
+
+        }
+        break;
+    }
+
+    if (pEventArg != null)
+    {
+        __pWifiDirectSystemAdapter->__pWifiDirectEvent->FireAsync(*pEventArg);
+    }
+}
+
+void
+_WifiDirectSystemAdapter::OnWifiDirectConnectionChanged(int errorCode, wifi_direct_connection_state_e connectionState,
+        const char* pMacAddress, void* pUserData)
+{
+    SysLog(NID_NET_WIFI, "Enter, [connectionState:0x%x] [ErrorCode:0x%x]", connectionState, errorCode);
+    SysLog(NID_NET_WIFI, "%ls", __pWifiDirectSystemAdapter->GetStringOfAllCurrentState().GetPointer());
+
+    result r = E_SUCCESS;
+    String peerMacAddress = _WifiDirectUtility::ConvertMacCharToString(pMacAddress);
+
+    bool isOwner = false;
+    wifi_direct_is_group_owner(&isOwner);
+
+    switch(connectionState)
+    {
+    // OnWifiDirectGroupCreatedN() with autonomous group owner mode
+    case WIFI_DIRECT_GROUP_CREATED:
+        SysLog(NID_NET_WIFI, "connectionState : WIFI_DIRECT_GROUP_CREATED");
+        if (errorCode == WIFI_DIRECT_ERROR_NONE)
+        {
+            (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+            if (__pWifiDirectSystemAdapter->__currentState == WIFI_DIRECT_SYSTEM_OWNER)
+            {
+                _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+                _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_AUTH_FAILED, r, E_AUTHENTICATION);
+                _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_FAILED, r, E_NOT_RESPONDING);
+                _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT, r, E_REMOTE_DEVICE_NOT_FOUND);
+                __pWifiDirectSystemAdapter->OnWifiDirectGroupCreated(L"", r);
+
+                _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+                __pWifiDirectSystemAdapter->OnWifiDirectAutonomousGroupCreated(r);
+            }
+        }
+        break;
+    case WIFI_DIRECT_CONNECTION_RSP:
+       SysLog(NID_NET_WIFI, "connectionState : WIFI_DIRECT_CONNECTION_RSP");
+       switch(__pWifiDirectSystemAdapter->__currentState)
+       {
+       case WIFI_DIRECT_SYSTEM_GROUP_CREATING:
+       case WIFI_DIRECT_SYSTEM_CONNECTING:
+          if (r == E_SUCCESS && isOwner == false)
+          {
+                  (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+               _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+               _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_AUTH_FAILED, r, E_AUTHENTICATION);
+               _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_FAILED, r, E_NOT_RESPONDING);
+               _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT, r, E_REMOTE_DEVICE_NOT_FOUND);
+                  __pWifiDirectSystemAdapter->OnWifiDirectGroupCreated(peerMacAddress, r);
+
+               _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+               _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_AUTH_FAILED, r, E_AUTHENTICATION);
+               _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_FAILED, r, E_NOT_RESPONDING);
+                  __pWifiDirectSystemAdapter->OnWifiDirectConnected(peerMacAddress, r);
+          }
+          else if(r != E_SUCCESS)
+          {
+                  (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+               _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+               _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_AUTH_FAILED, r, E_AUTHENTICATION);
+               _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_FAILED, r, E_NOT_RESPONDING);
+               _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT, r, E_REMOTE_DEVICE_NOT_FOUND);
+                  __pWifiDirectSystemAdapter->OnWifiDirectGroupCreated(peerMacAddress, r);
+
+               _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+               _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_AUTH_FAILED, r, E_AUTHENTICATION);
+               _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_FAILED, r, E_NOT_RESPONDING);
+                  __pWifiDirectSystemAdapter->OnWifiDirectConnected(peerMacAddress, r);
+          }
+           break;
+       case WIFI_DIRECT_SYSTEM_ASSOCIATING:
+           (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+           _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+           _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_AUTH_FAILED, r, E_AUTHENTICATION);
+           _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_FAILED, r, E_NOT_RESPONDING);
+           _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT, r, E_REMOTE_DEVICE_NOT_FOUND);
+           __pWifiDirectSystemAdapter->OnWifiDirectAssociationCompleted(peerMacAddress, r);
+
+           _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+           _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_AUTH_FAILED, r, E_AUTHENTICATION);
+           _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_FAILED, r, E_NOT_RESPONDING);
+           __pWifiDirectSystemAdapter->OnWifiDirectConnected(peerMacAddress, r);
+           break;
+       case WIFI_DIRECT_SYSTEM_ACTIVATED:
+          (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+          if (r == E_SUCCESS && isOwner == false)
+          {
+              _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+              _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_AUTH_FAILED, r, E_AUTHENTICATION);
+              _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_FAILED, r, E_NOT_RESPONDING);
+              _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT, r, E_REMOTE_DEVICE_NOT_FOUND);
+              __pWifiDirectSystemAdapter->OnWifiDirectAssociationCompleted(peerMacAddress, r);
+
+              _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+              _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_AUTH_FAILED, r, E_AUTHENTICATION);
+              _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_FAILED, r, E_NOT_RESPONDING);
+              __pWifiDirectSystemAdapter->OnWifiDirectConnected(peerMacAddress, r);
+          }
+          break;
+       default:
+           SysLog(NID_NET_WIFI, "Unknown case - current state : %s", __pWifiDirectSystemAdapter->GetStringOfDeviceState());
+           break;
+       }
+       break;
+    case WIFI_DIRECT_DISASSOCIATION_IND:
+        SysLog(NID_NET_WIFI, "connectionState : WIFI_DIRECT_DISASSOCIATION_IND");
+        __pWifiDirectSystemAdapter->OnWifiDirectClientDisassociated(peerMacAddress);
+        __pWifiDirectSystemAdapter->OnWifiDirectDisconnected(peerMacAddress, E_SUCCESS);
+        break;
+    case WIFI_DIRECT_DISCONNECTION_RSP:
+        SysLog(NID_NET_WIFI, "event type : WIFI_DIRECT_DISCONNECTION_RSP");
+        if (__pWifiDirectSystemAdapter->__currentState == WIFI_DIRECT_SYSTEM_DISCONNECTING)
+        {
+            (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+            _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+            _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_FAILED, r, E_NOT_RESPONDING);
+            __pWifiDirectSystemAdapter->OnWifiDirectAssociationTerminated(WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_SELF_INITIATED, r);
+
+            _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+            __pWifiDirectSystemAdapter->OnWifiDirectDisconnected(peerMacAddress, r);
+        }
+        else if(__pWifiDirectSystemAdapter->__currentState == WIFI_DIRECT_SYSTEM_LEAVING)
+        {
+            (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+            _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+            __pWifiDirectSystemAdapter->OnWifiDirectGroupLeft(r);
+        }
+        else if(__pWifiDirectSystemAdapter->__currentState == WIFI_DIRECT_SYSTEM_CONNECT_CANCELLING)
+        {
+            (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+            __pWifiDirectSystemAdapter->OnWifiDirectGroupCreated(peerMacAddress, E_OPERATION_CANCELED);
+            __pWifiDirectSystemAdapter->OnWifiDirectConnected(peerMacAddress, E_OPERATION_CANCELED);
+        }
+        break;
+    case WIFI_DIRECT_DISCONNECTION_IND:
+        SysLog(NID_NET_WIFI, "connectionState : WIFI_DIRECT_DISCONNECTION_IND");
+        (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+        __pWifiDirectSystemAdapter->OnWifiDirectAssociationTerminated(WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_DISCONNECTED, E_SUCCESS);
+
+        _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+        __pWifiDirectSystemAdapter->OnWifiDirectDisconnected(peerMacAddress, r);
+        break;
+    case WIFI_DIRECT_GROUP_DESTROYED:
+        SysLog(NID_NET_WIFI, "connectionState : WIFI_DIRECT_GROUP_DESTROYED");
+        switch(__pWifiDirectSystemAdapter->__currentState)
+        {
+            case WIFI_DIRECT_SYSTEM_GROUP_CANCELING:
+                (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+                _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+                __pWifiDirectSystemAdapter->OnWifiDirectGroupDestroyed(r);
+                break;
+            case WIFI_DIRECT_SYSTEM_OWNER:
+                if (r == E_SUCCESS)
+                {
+                    (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+                    _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+                    __pWifiDirectSystemAdapter->OnWifiDirectGroupDestroyed(r);
+
+                    _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+                    _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_FAILED, r, E_NOT_RESPONDING);
+                    __pWifiDirectSystemAdapter->OnWifiDirectGroupLeft(r);
+                }
+                break;
+            case WIFI_DIRECT_SYSTEM_DESTROYING:
+                (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+                _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+                __pWifiDirectSystemAdapter->OnWifiDirectGroupDestroyed(r);
+                break;
+            case WIFI_DIRECT_SYSTEM_CLIENT:
+                (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+                _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+                _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_FAILED, r, E_NOT_RESPONDING);
+                __pWifiDirectSystemAdapter->OnWifiDirectAssociationTerminated(WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_DISCONNECTED, r);
+
+                _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+                _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_FAILED, r, E_NOT_RESPONDING);
+                __pWifiDirectSystemAdapter->OnWifiDirectGroupLeft(r);
+                break;
+            case WIFI_DIRECT_SYSTEM_LEAVING:
+                (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+                _WifiDirectConvertErrorResult(errorCode != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+                _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_CONNECTION_FAILED, r, E_NOT_RESPONDING);
+                __pWifiDirectSystemAdapter->OnWifiDirectGroupLeft(r);
+                break;
+            default:
+                SysLog(NID_NET_WIFI, "Unknown case - current state : %s", __pWifiDirectSystemAdapter->GetStringOfDeviceState());
+                break;
+        }
+        break;
+    default:
+        SysLog(NID_NET_WIFI, "Unknown case %d", connectionState);
+        break;
+    }
+}
+
+void
+_WifiDirectSystemAdapter::OnWifiDirectClientIpAssigned(const char *mac_address, const char *ip_address,
+                                                    const char *interface_address, void *user_data)
+{
+    SysLog(NID_NET_WIFI, "%ls", __pWifiDirectSystemAdapter->GetStringOfAllCurrentState().GetPointer());
+    SysLog(NID_NET_WIFI, "mac address : %s, interface address : %s, ipaddress : %s", mac_address, interface_address, ip_address);
+
+    switch(__pWifiDirectSystemAdapter->__currentState)
+    {
+    case WIFI_DIRECT_SYSTEM_GROUP_CREATING:
+    case WIFI_DIRECT_SYSTEM_CONNECTING:
+           (void)__pWifiDirectSystemAdapter->InitializeCurrentState();
+           __pWifiDirectSystemAdapter->OnWifiDirectGroupCreated(mac_address, E_SUCCESS);
+           __pWifiDirectSystemAdapter->OnWifiDirectConnected(mac_address, E_SUCCESS);
+           break;
+    case WIFI_DIRECT_SYSTEM_OWNER:
+        __pWifiDirectSystemAdapter->OnWifiDirectClientAssociated(mac_address);
+        __pWifiDirectSystemAdapter->OnWifiDirectConnected(mac_address, E_SUCCESS);
+        break;
+    default:
+        SysLog(NID_NET_WIFI, "unnecessary case %d", __pWifiDirectSystemAdapter->__currentState);
+        break;
+    }
+}
+
+void
+_WifiDirectSystemAdapter::OnWifiDirectScanCompleted(int errorCode, wifi_direct_discovery_state_e discoveryState, void* pUserData)
+{
+    SysLog(NID_NET_WIFI, "Enter, [discoveryState:0x%x] [ErrorCode:0x%x]", discoveryState, errorCode);
+    SysLog(NID_NET_WIFI, "%ls", __pWifiDirectSystemAdapter->GetStringOfAllCurrentState().GetPointer());
+
+    _WifiDirectEventArg* pEventArg = null;
+    result r = E_SYSTEM;
+    _WifiDirectConvertErrorResult(errorCode == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+
+    switch(discoveryState)
+    {
+    case WIFI_DIRECT_ONLY_LISTEN_STARTED:
+        SysLog(NID_NET_WIFI, "discoveryState : WIFI_DIRECT_ONLY_LISTEN_STARTED");
+        SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+        if(__pWifiDirectSystemAdapter->__currentState == WIFI_DIRECT_SYSTEM_ACTIVATING)
+        {
+            __pWifiDirectSystemAdapter->__currentState = WIFI_DIRECT_SYSTEM_ACTIVATED;
+            pEventArg = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_ACTIVATED, DEFAULT_DEVICE_ID, r);
+            SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        }
+        break;
+    case WIFI_DIRECT_DISCOVERY_STARTED:
+        SysLog(NID_NET_WIFI, "discoveryState : WIFI_DIRECT_DISCOVERY_STARTED");
+        break;
+    case WIFI_DIRECT_DISCOVERY_FOUND:
+        SysLog(NID_NET_WIFI, "discoveryState : WIFI_DIRECT_DISCOVERY_FOUND");
+        if (__pWifiDirectSystemAdapter->__currentState == WIFI_DIRECT_SYSTEM_GROUP_CREATING)
+        {
+            int err = wifi_direct_foreach_discovered_peers(OnWifiDirectFindSameDeviceName, null);
+            r = _WifiDirectUtility::ConvertErrorCode(err);
+            SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+        }
+        break;
+    case WIFI_DIRECT_DISCOVERY_FINISHED:
+        SysLog(NID_NET_WIFI, "discoveryState: WIFI_DIRECT_DISCOVERY_FINISHED");
+
+        switch(__pWifiDirectSystemAdapter->__currentScanState)
+        {
+        case WIFI_DIRECT_SYSTEM_SCAN_IDLE:
+            break;
+        case WIFI_DIRECT_SYSTEM_SCAN_LISTEN:
+            break;
+        case WIFI_DIRECT_SYSTEM_SCAN_CANCELLING:
+            __pWifiDirectSystemAdapter->__currentScanState = WIFI_DIRECT_SYSTEM_SCAN_IDLE;
+
+            r = __pWifiDirectSystemAdapter->StartListenMode();
+            SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+            if (__pWifiDirectSystemAdapter->__currentState == WIFI_DIRECT_SYSTEM_CONNECT_CANCELLING)
+            {
+
+                pEventArg = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_GROUP_CREATED, DEFAULT_DEVICE_ID,
+                        WifiDirectGroupInfo(), WifiDirectDeviceInfo(), WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE, E_OPERATION_CANCELED);
+            }
+            else
+            {
+                pEventArg = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_SCAN_COMPLETED, DEFAULT_DEVICE_ID,
+                        (Tizen::Net::NetConnection*)null, E_OPERATION_CANCELED);
+            }
+
+            break;
+        case WIFI_DIRECT_SYSTEM_SCAN_LISTEN_CANCELING_TO_SCAN:
+            if (__pWifiDirectSystemAdapter->__currentState == WIFI_DIRECT_SYSTEM_CONNECT_CANCELLING)
+            {
+                __pWifiDirectSystemAdapter->__currentScanState = WIFI_DIRECT_SYSTEM_SCAN_IDLE;
+
+                r = __pWifiDirectSystemAdapter->StartListenMode();
+                SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+                pEventArg = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_GROUP_CREATED, DEFAULT_DEVICE_ID,
+                        WifiDirectGroupInfo(), WifiDirectDeviceInfo(), WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE, E_OPERATION_CANCELED);
+            }
+            else
+            {
+                __pWifiDirectSystemAdapter->__currentScanState = WIFI_DIRECT_SYSTEM_SCAN_IDLE;
+                r = __pWifiDirectSystemAdapter->StartDiscovery();
+                SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+            }
+            break;
+        case WIFI_DIRECT_SYSTEM_SCAN_SCANNING:
+            __pWifiDirectSystemAdapter->__currentScanState = WIFI_DIRECT_SYSTEM_SCAN_IDLE;
+
+            if (__pWifiDirectSystemAdapter->__currentState == WIFI_DIRECT_SYSTEM_GROUP_CREATING)
+            {
+                bool isFind = false;
+                int err = wifi_direct_foreach_discovered_peers(OnWifiDirectFindSameDeviceName, &isFind);
+                SysLog(NID_NET_WIFI, "[0x%x] Return value of wifi_direct_foreach_discovered_peers() : %ls", err, isFind ? L"Find" : L"Not Find");
+
+                if (isFind == false)
+                {
+                    pEventArg = new _WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_GROUP_CREATED, DEFAULT_DEVICE_ID,
+                            WifiDirectGroupInfo(), WifiDirectDeviceInfo(), WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE,
+                            E_REMOTE_DEVICE_NOT_FOUND);
+
+                    __pWifiDirectSystemAdapter->__currentState = WIFI_DIRECT_SYSTEM_ACTIVATED;
+                }
+            }
+            else
+            {
+                __pWifiDirectSystemAdapter->__currentScanState = WIFI_DIRECT_SYSTEM_SCAN_IDLE;
+
+                result res = E_SUCCESS;
+
+                ArrayList* pDeviceInfoList = new (std::nothrow) ArrayList();
+                SysTryReturnVoidResult(NID_NET_WIFI, pDeviceInfoList != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+                res = pDeviceInfoList->Construct();
+                if(res != E_SUCCESS)
+                {
+                    delete pDeviceInfoList;
+                    SysLog(NID_NET_WIFI, "Failed to construct list");
+                    return;
+                }
+
+                int err = wifi_direct_foreach_discovered_peers(OnWifiDirectEachDiscoveredPeer, pDeviceInfoList);
+                SysLog(NID_NET_WIFI, "[0x%x] Return value of wifi_direct_foreach_discovered_peers()", err);
+                if( err != WIFI_DIRECT_ERROR_NONE
+                    && err != WIFI_DIRECT_ERROR_OPERATION_FAILED) // when can't find any remote device.
+                {
+                    pDeviceInfoList->RemoveAll(true);
+                    delete pDeviceInfoList;
+                    SysLog(NID_NET_WIFI, "Error on wifi_direct_foreach_discovered_peers");
+                    return;
+                }
+
+                res = __pWifiDirectSystemAdapter->StartListenMode();
+                SysTryCatch(NID_NET_WIFI, res == E_SUCCESS, , res, "[%s] Propagating.", GetErrorMessage(res));
+
+                pEventArg = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_SCAN_COMPLETED, DEFAULT_DEVICE_ID,
+                        pDeviceInfoList, r);
+            }
+            break;
+        default:
+            SysLogException(NID_NET_WIFI, E_SYSTEM, "[E_SYSTEM] Not an allowed type : %d", __pWifiDirectSystemAdapter->__currentScanState);
+            break;
+        }
+        break;
+    } // end of switch(discoveryState)
+
+    if (pEventArg != null)
+    {
+        __pWifiDirectSystemAdapter->__pWifiDirectEvent->FireAsync(*pEventArg);
+    }
+
+CATCH:
+    SysLog(NID_NET_WIFI, "Exit, %ls",__pWifiDirectSystemAdapter->GetStringOfAllCurrentState().GetPointer());
+
+}
+
+bool
+_WifiDirectSystemAdapter::OnWifiDirectEachDiscoveredPeer(wifi_direct_discovered_peer_info_s* peer, void* pUserData)
+{
+    ArrayList* pList = static_cast< ArrayList* >(pUserData);
+    SysTryReturn(NID_NET_WIFI, pList != null, false, E_SYSTEM, "[E_SYSTEM] Failed to acquire list of peers");
+
+    WifiDirectDeviceInfo* pDeviceInfo = _WifiDirectUtility::ConvertDiscoveryEntry2DeviceInfoN(*peer);
+    SysTryReturn(NID_NET_WIFI, pDeviceInfo != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    pList->Add(*pDeviceInfo);
+
+    return true;
+}
+
+bool
+_WifiDirectSystemAdapter::OnWifiDirectEachConnectedClient(wifi_direct_connected_peer_info_s* pPeer, void* pUserData)
+{
+       IList* pList = static_cast<IList*>(pUserData);
+    SysTryReturn(NID_NET_WIFI, pList != null, false, E_SYSTEM, "[E_SYSTEM] Failed to acquire list of peers");
+
+    WifiDirectDeviceInfo * pDeviceInfo= _WifiDirectUtility::ConvertPeerInfoToDeviceInfoN(WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT, *pPeer);
+    SysTryReturn(NID_NET_WIFI, pDeviceInfo != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    pList->Add(*pDeviceInfo);
+
+    return true;
+}
+
+bool
+_WifiDirectSystemAdapter::OnWifiDirectConnectedOwner(wifi_direct_connected_peer_info_s* pPeer, void* pUserData)
+{
+    IList* pList = static_cast<IList*>(pUserData);
+    SysTryReturn(NID_NET_WIFI, pList != null, false, E_SYSTEM, "[E_SYSTEM] Failed to acquire list of peers");
+
+    WifiDirectDeviceInfo * pDeviceInfo= _WifiDirectUtility::ConvertPeerInfoToDeviceInfoN(WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER, *pPeer);
+   SysTryReturn(NID_NET_WIFI, pDeviceInfo != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    pList->Add(*pDeviceInfo);
+
+    return true;
+}
+
+bool
+_WifiDirectSystemAdapter::OnWifiDirectFindSameDeviceName(wifi_direct_discovered_peer_info_s* pPeer, void* pUserData)
+{
+    String convertDevicename(pPeer->device_name);
+    String deviceName;
+    result r = __pWifiDirectSystemAdapter->__pWifiServiceProxy->GetWifiDirectLocalDeviceName(deviceName);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    if (deviceName.CompareTo(convertDevicename) == 0 )
+    {
+        if(pUserData != null)
+        {
+            *(static_cast< bool* >(pUserData)) = true;
+        }
+
+        int err = wifi_direct_connect(pPeer->mac_address);
+        result r = _WifiDirectUtility::ConvertErrorCode(err);
+
+        if (IsFailed(r))
+        {
+            _WifiDirectEventArg* pEventArg = new _WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_GROUP_CREATED,
+                 DEFAULT_DEVICE_ID, WifiDirectGroupInfo(), WifiDirectDeviceInfo(), WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE, E_SYSTEM);
+
+            __pWifiDirectSystemAdapter->__currentState = WIFI_DIRECT_SYSTEM_ACTIVATED;
+            __pWifiDirectSystemAdapter->__pWifiDirectEvent->FireAsync(*pEventArg);
+        }
+
+        return false;
+    }
+
+    return true;
+}
+
+bool
+_WifiDirectSystemAdapter::OnWifiDirectSupportedWpsMode(wifi_direct_wps_type_e type, void* pUserData)
+{
+    ArrayListT<WifiWpsConfigurationMode>* pList = static_cast< ArrayListT<WifiWpsConfigurationMode>* >(pUserData);
+    SysTryReturn(NID_NET_WIFI, pList != null, false, E_SYSTEM, "[E_SYSTEM] Failed to acquire list of peers");
+
+    WifiWpsConfigurationMode wpsMode  = _WifiDirectUtility::ConvertSupportedWpsMode(type);
+
+    pList->Add(wpsMode);
+
+    return true;
+}
+
+result
+_WifiDirectSystemAdapter::InitializeCurrentState(void)
+{
+    result r = E_SUCCESS;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    wifi_direct_state_e status = WIFI_DIRECT_STATE_DEACTIVATED;
+
+    err = wifi_direct_get_state(&status);
+    _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+    SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    bool isOwner = false;
+    if (status != WIFI_DIRECT_STATE_DEACTIVATED
+                    && status != WIFI_DIRECT_STATE_DEACTIVATING
+                    && status != WIFI_DIRECT_STATE_ACTIVATING)
+    {
+       err = wifi_direct_is_group_owner(&isOwner);
+       SysLog(NID_NET_WIFI, "[0x%x] Return value of wifi_direct_is_group_owner()", err);
+
+       _WifiDirectConvertErrorResult(err != WIFI_DIRECT_ERROR_NONE, r, E_SYSTEM);
+       SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    switch(status)
+    {
+    case WIFI_DIRECT_STATE_DEACTIVATED:
+        __currentState = WIFI_DIRECT_SYSTEM_DEACTIVATED;
+        break;
+    case WIFI_DIRECT_STATE_DEACTIVATING:
+        __currentState = WIFI_DIRECT_SYSTEM_DEACTIVATING;
+        break;
+    case WIFI_DIRECT_STATE_ACTIVATING:
+        __currentState = WIFI_DIRECT_SYSTEM_ACTIVATING;
+        break;
+    case WIFI_DIRECT_STATE_DISCOVERING:
+        {
+            if (isOwner == true)
+            {
+                __currentState = WIFI_DIRECT_SYSTEM_OWNER;
+            }
+            else
+            {
+                __currentState = WIFI_DIRECT_SYSTEM_ACTIVATED;
+            }
+
+            bool isListenMode = false;
+            wifi_direct_is_listening_only(&isListenMode);
+            if (isListenMode == true)
+            {
+                __currentScanState = WIFI_DIRECT_SYSTEM_SCAN_LISTEN;
+            }
+            else
+            {
+                __currentScanState = WIFI_DIRECT_SYSTEM_SCAN_SCANNING;
+            }
+        }
+        break;
+    case WIFI_DIRECT_STATE_ACTIVATED:
+        __currentState = WIFI_DIRECT_SYSTEM_ACTIVATED;
+        r = StartListenMode();
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_STATE_CONNECTED:
+        if (isOwner == true)
+        {
+            __currentState = WIFI_DIRECT_SYSTEM_OWNER;
+        }
+        else
+        {
+            __currentState = WIFI_DIRECT_SYSTEM_CLIENT;
+        }
+        // ToDo: Getting peer list
+        break;
+    case WIFI_DIRECT_STATE_CONNECTING:
+        __currentState = WIFI_DIRECT_SYSTEM_CONNECTING;
+        break;
+    case WIFI_DIRECT_STATE_DISCONNECTING:
+        if (isOwner == true)
+        {
+            __currentState = WIFI_DIRECT_SYSTEM_DESTROYING;
+        }
+        else
+        {
+            __currentState = WIFI_DIRECT_SYSTEM_DISCONNECTING;
+        }
+        break;
+    default:
+        SysLog(NID_NET_WIFI, "Unknown case : %d", status);
+        r = E_SYSTEM;
+        break;
+    }
+
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::StartListenMode(void)
+{
+       result r = E_SYSTEM;
+    int err = wifi_direct_start_discovery(true, 0);
+    _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+    SysTryReturnResult(NID_NET_WIFI, err == WIFI_DIRECT_ERROR_NONE, E_SYSTEM, "Staring discovery has failed.", GetErrorMessage(r));
+
+    if (r == E_SUCCESS)
+    {
+        __currentScanState = WIFI_DIRECT_SYSTEM_SCAN_LISTEN;
+    }
+
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::StopListenModeToScan(void)
+{
+       result r = E_SYSTEM;
+    int err = wifi_direct_cancel_discovery();
+    _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+    SysTryReturnResult(NID_NET_WIFI, err == WIFI_DIRECT_ERROR_NONE, E_SYSTEM, "Cancelling discovery has failed.", GetErrorMessage(r));
+
+    if (r == E_SUCCESS)
+    {
+        __currentScanState = WIFI_DIRECT_SYSTEM_SCAN_LISTEN_CANCELING_TO_SCAN;
+    }
+
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::StartDiscovery(void)
+{
+       result r = E_SYSTEM;
+    int err = wifi_direct_start_discovery(false, WIFI_DIRECT_DISCOVERY_TIMEOUT);
+    _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+    SysTryReturnResult(NID_NET_WIFI, err == WIFI_DIRECT_ERROR_NONE, E_SYSTEM, "Staring discovery has failed.", GetErrorMessage(r));
+
+    if (r == E_SUCCESS)
+    {
+        __currentScanState = WIFI_DIRECT_SYSTEM_SCAN_SCANNING;
+    }
+
+    return r;
+}
+
+result
+_WifiDirectSystemAdapter::CancelDiscovery(void)
+{
+       result r = E_SYSTEM;
+    int err = wifi_direct_cancel_discovery();
+    _WifiDirectConvertErrorResult(err == WIFI_DIRECT_ERROR_NONE, r, E_SUCCESS);
+    SysTryReturnResult(NID_NET_WIFI, err == WIFI_DIRECT_ERROR_NONE, E_SYSTEM, "Cancelling discovery has failed.", GetErrorMessage(r));
+
+    if (r == E_SUCCESS)
+    {
+        __currentScanState = WIFI_DIRECT_SYSTEM_SCAN_CANCELLING;
+    }
+
+    return r;
+}
+
+const char*
+_WifiDirectSystemAdapter::GetStringOfDeviceState(void) const
+{
+    const char* pStateStr[] = { "DEACTIVATED",
+                                "ACTIVATING",
+                                "DEACTIVATING",
+                                "ACTIVATED",
+                                "AUTONOMOUS_GROUP_CREATING",
+                                "GROUP_CREATING",
+                                "GROUP_CANCELING",
+                                "CONNECTING",
+                                "CONNECT_CANCELLING",
+                                "ASSOCIATING",
+                                "OWNER",
+                                "DESTROYING",
+                                "LEAVING",
+                                "CLIENT",
+                                "DISCONNECTING"};
+
+    return pStateStr[__currentState];
+}
+
+const char*
+_WifiDirectSystemAdapter::GetStringOfScanState(void) const
+{
+    const char* pStateStr[] = { "SCAN_IDLE",
+                                "SCAN_LISTEN",
+                                "SCAN_LISTEN_CANCELING_TO_SCAN",
+                                "SCAN_SCANNING",
+                                "SCAN_CANCELLING" };
+
+    return pStateStr[__currentScanState];
+}
+
+String
+_WifiDirectSystemAdapter::GetStringOfAllCurrentState(void) const
+{
+       String currentState;
+
+       (void)currentState.Append("DeviceState : ");
+       (void)currentState.Append(GetStringOfDeviceState());
+       (void)currentState.Append(" | ");
+       (void)currentState.Append("ScanState : ");
+       (void)currentState.Append(GetStringOfScanState());
+
+       return currentState;
+}
+
+WifiDirectDeviceInfo*
+_WifiDirectSystemAdapter::GetConnectedPeerDeviceInfoN(WifiDirectGroupMemberType peerMemberType, const Tizen::Base::String* pPeerMacAddress /* = null */) const
+{
+    unique_ptr<ArrayList,AllElementsDeleter> pDeviceInfoList(new (std::nothrow) ArrayList());
+    SysTryReturn(NID_NET_WIFI, pDeviceInfoList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    WifiDirectDeviceInfo* pDeviceInfo = null;
+    int err = WIFI_DIRECT_ERROR_NONE;
+
+    if (peerMemberType == WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER)
+    {
+        err = wifi_direct_foreach_connected_peers(OnWifiDirectConnectedOwner, pDeviceInfoList.get());
+        SysTryReturn(NID_NET_WIFI, err == WIFI_DIRECT_ERROR_NONE, null, E_SYSTEM, "Getting the information of connected device has failed.");
+
+        if (pDeviceInfoList->GetCount() != 0)
+        {
+            pDeviceInfo = dynamic_cast<WifiDirectDeviceInfo*>(pDeviceInfoList->GetAt(0));
+            SysTryReturn(NID_NET_WIFI, pDeviceInfo != null, null, E_SYSTEM, "Failed to get a owner owner information.");
+        }
+    }
+    else
+    {
+        err = wifi_direct_foreach_connected_peers(OnWifiDirectEachConnectedClient, pDeviceInfoList.get());
+        SysTryReturn(NID_NET_WIFI, err == WIFI_DIRECT_ERROR_NONE, null, E_SYSTEM, "Getting the information of connected device has failed.");
+
+        for (int i = 0; i < pDeviceInfoList->GetCount(); i++)
+        {
+            pDeviceInfo = dynamic_cast<WifiDirectDeviceInfo*>(pDeviceInfoList->GetAt(i));
+            SysTryReturn(NID_NET_WIFI, pDeviceInfo != null, null, E_SYSTEM, "Failed to get a group client information.");
+
+            if(pDeviceInfo->GetMacAddress() == *pPeerMacAddress)
+            {
+                break;
+            }
+        }
+    }
+
+    return new (std::nothrow) WifiDirectDeviceInfo(*pDeviceInfo);
+}
+
+void
+_WifiDirectSystemAdapter::OnWifiDirectGroupCreated(const String& peerMacAddress, result r)
+{
+    _WifiDirectEventArg* pEventArg = null;
+
+    unique_ptr<WifiDirectGroupInfo> pGroupInfo;
+    unique_ptr<WifiDirectDeviceInfo> pDeviceInfo;
+
+    if (IsFailed(r))
+    {
+      pEventArg = new _WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_GROUP_CREATED, DEFAULT_DEVICE_ID,
+              WifiDirectGroupInfo(), WifiDirectDeviceInfo(), WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE, r);
+    }
+    else
+    {
+        bool isGroupOwner = false;
+        (void)wifi_direct_is_group_owner(&isGroupOwner);
+
+        if (isGroupOwner == true)
+        {
+            pGroupInfo.reset(GetGroupSettingInfoN());
+            pDeviceInfo.reset(GetLocalDeviceInfoN());
+        }
+        else
+        {
+               char* pSsid = null;
+            (void)wifi_direct_get_ssid(&pSsid);
+            String ssid(pSsid);
+            free(pSsid);
+
+            int channel = -1;
+            (void)wifi_direct_get_operating_channel(&channel);
+            WifiRadioChannel operatingChannel = _WifiDirectUtility::ConvertChannel(channel);
+
+            _WifiDirectGroupInfoImpl groupInfoImpl;
+            groupInfoImpl.SetAutonomousGroupOwnerMode(false);
+            groupInfoImpl.SetBssId(peerMacAddress);
+            groupInfoImpl.SetSsid(ssid);
+            groupInfoImpl.SetOperatingChannel(operatingChannel);
+
+            pGroupInfo.reset(_WifiDirectGroupInfoImpl::CreateWifiDirectGroupInfoInstanceN(groupInfoImpl));
+            pDeviceInfo.reset(GetConnectedPeerDeviceInfoN(WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER));
+        }
+
+        if(pGroupInfo != null && pDeviceInfo != null)
+        {
+           pEventArg = new (std::nothrow) _WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_GROUP_CREATED, DEFAULT_DEVICE_ID, *pGroupInfo,
+                   *pDeviceInfo, isGroupOwner ? WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER : WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT, r);
+        }
+        else
+        {
+           SysLogException(NID_NET_WIFI, E_SYSTEM, "[E_SYSTEM] Failed to get group info or device info.");
+           pEventArg = new (std::nothrow) _WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_GROUP_CREATED, DEFAULT_DEVICE_ID, WifiDirectGroupInfo(),
+                   WifiDirectDeviceInfo(), WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE, E_SYSTEM);
+        }
+    }
+
+    if (pEventArg != null)
+    {
+       __pWifiDirectEvent->FireAsync(*pEventArg);
+    }
+}
+
+void
+_WifiDirectSystemAdapter::OnWifiDirectAssociationCompleted(const Tizen::Base::String& peerMacAddress, result r)
+{
+    _WifiDirectEventArg* pEventArg = null;
+    unique_ptr<WifiDirectDeviceInfo> pDeviceInfo;
+
+    if (IsFailed(r))
+    {
+      pEventArg = new (std::nothrow) _WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_ASSOCIATED, DEFAULT_DEVICE_ID, r);
+    }
+    else
+    {
+        // Get the peer device information
+        pDeviceInfo.reset(GetConnectedPeerDeviceInfoN(WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER));
+
+        if (pDeviceInfo != null)
+        {
+            pEventArg = new (std::nothrow) _WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_ASSOCIATED, DEFAULT_DEVICE_ID, *pDeviceInfo, r);
+        }
+        else
+        {
+            pEventArg = new (std::nothrow) _WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_ASSOCIATED, DEFAULT_DEVICE_ID, E_SYSTEM);
+        }
+    }
+
+    if (pEventArg != null)
+    {
+      __pWifiDirectEvent->FireAsync(*pEventArg);
+    }
+}
+
+void
+_WifiDirectSystemAdapter::OnWifiDirectClientAssociated(const Tizen::Base::String& peerMacAddress)
+{
+    _WifiDirectEventArg* pEventArg = null;
+    unique_ptr<WifiDirectDeviceInfo> pDeviceInfo(GetConnectedPeerDeviceInfoN(WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT, &peerMacAddress));
+
+    if (pDeviceInfo != null)
+    {
+        pEventArg = new (std::nothrow) _WifiDirectEventArg(WIFI_DIRECT_GO_EVENT_CLIENT_ASSOCIATED, DEFAULT_DEVICE_ID, *pDeviceInfo);
+
+        __pWifiDirectEvent->FireAsync(*pEventArg);
+    }
+}
+
+void
+_WifiDirectSystemAdapter::OnWifiDirectClientDisassociated(const Tizen::Base::String& peerMacAddress)
+{
+    _WifiDirectEventArg* pEventArg = null;
+
+    WifiDirectDeviceInfo* pDeviceInfo = GetPeerInfo(peerMacAddress);
+    WifiDirectAssociationTerminationReason reason = WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_SELF_INITIATED;
+
+    if (pDeviceInfo != null)
+    {
+        if (_WifiDirectDeviceInfoImpl::GetInstance(*pDeviceInfo)->IsDisconnecting() != true)
+        {
+            reason = WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_DISCONNECTED;
+        }
+
+        pEventArg = new (std::nothrow)_WifiDirectEventArg( WIFI_DIRECT_GO_EVENT_CLIENT_DISASSOCIATED,
+              DEFAULT_DEVICE_ID, *pDeviceInfo, WIFI_DIRECT_ASSOCIATION_TERMINATION_REASON_DISCONNECTED);
+    }
+
+   if (pEventArg != null)
+   {
+     __pWifiDirectEvent->FireAsync(*pEventArg);
+   }
+}
+
+void
+_WifiDirectSystemAdapter::OnWifiDirectAssociationTerminated(WifiDirectAssociationTerminationReason reason, result r)
+{
+    _WifiDirectEventArg* pEventArg = null;
+
+    pEventArg = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_GC_EVENT_DISASSOCIATED, DEFAULT_DEVICE_ID, reason, r);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    __pWifiDirectEvent->FireAsync(*pEventArg);
+}
+
+void
+_WifiDirectSystemAdapter::OnWifiDirectGroupDestroyed(result r)
+{
+    _WifiDirectEventArg* pEventArg = null;
+
+    pEventArg = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_GO_EVENT_GROUP_DESTROYED, DEFAULT_DEVICE_ID, r);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    __pWifiDirectEvent->FireAsync(*pEventArg);
+}
+
+void
+_WifiDirectSystemAdapter::OnWifiDirectConnected(const Tizen::Base::String& peerMacAddress, result r)
+{
+    _WifiDirectEventArg* pEventArg = null;
+    unique_ptr<WifiDirectDeviceInfo> pDeviceInfo;
+
+    if (!IsFailed(r))
+    {
+        bool isGroupOwner = false;
+        int err = wifi_direct_is_group_owner(&isGroupOwner);
+        SysLog(NID_NET_WIFI, "[0x%x] Return value of wifi_direct_is_group_owner()", err);
+
+        if (isGroupOwner == true)
+        {
+            pDeviceInfo.reset(GetConnectedPeerDeviceInfoN(WIFI_DIRECT_GROUP_MEMBER_TYPE_CLIENT, &peerMacAddress));
+        }
+        else
+        {
+            pDeviceInfo.reset(GetConnectedPeerDeviceInfoN(WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER, &peerMacAddress));
+        }
+
+        if (pDeviceInfo != null)
+        {
+            AddPeerInfo(pDeviceInfo.get());
+            pEventArg = new (std::nothrow) _WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_CONNECTED, DEFAULT_DEVICE_ID, *pDeviceInfo, r);
+
+            SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        }
+    }
+    else
+    {
+        pEventArg = new (std::nothrow) _WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_CONNECTED, DEFAULT_DEVICE_ID, WifiDirectDeviceInfo(), r);
+        SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+    }
+
+    __pWifiDirectEvent->FireAsync(*pEventArg);
+}
+
+void
+_WifiDirectSystemAdapter::OnWifiDirectDisconnected(const Tizen::Base::String& peerMacAddress, result r)
+{
+    _WifiDirectEventArg* pEventArg = null;
+
+    pEventArg = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_DISCONNECTED, DEFAULT_DEVICE_ID, peerMacAddress);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    WifiDirectDeviceInfo* pDeviceInfoTemp = GetPeerInfo(peerMacAddress);
+    if (pDeviceInfoTemp != null)
+    {
+        RemovePeerInfo(pDeviceInfoTemp);
+    }
+
+    __pWifiDirectEvent->FireAsync(*pEventArg);
+}
+
+void
+_WifiDirectSystemAdapter::OnWifiDirectAutonomousGroupCreated(result r)
+{
+    _WifiDirectEventArg* pEventArg = new _WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_AUTONOMOS_GROUP_CREATED, DEFAULT_DEVICE_ID, r);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    __pWifiDirectEvent->FireAsync(*pEventArg);
+}
+
+void
+_WifiDirectSystemAdapter::OnWifiDirectGroupLeft(result r)
+{
+    _WifiDirectEventArg* pEventArg = null;
+
+    pEventArg = new (std::nothrow)_WifiDirectEventArg(WIFI_DIRECT_DEVICE_EVENT_GROUP_LEFT, DEFAULT_DEVICE_ID);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    __pWifiDirectEvent->FireAsync(*pEventArg);
+}
+
+} } } // Tizen::Net::Wifi
+
diff --git a/src/wifi/FNetWifi_WifiDirectSystemAdapter.h b/src/wifi/FNetWifi_WifiDirectSystemAdapter.h
new file mode 100644 (file)
index 0000000..990eda1
--- /dev/null
@@ -0,0 +1,559 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectSystemAdapter.h
+ * @brief   This is the header file for the WifiDirectSystemAdapter class.
+ * @version 2.1
+ *
+ * This header file contains declarations of the WifiDirectSystemAdapter class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_DIRECT_SYSTEM_ADAPTER_H_
+#define _FNET_WIFI_INTERNAL_WIFI_DIRECT_SYSTEM_ADAPTER_H_
+
+#include <unique_ptr.h>
+#include <wifi-direct.h>
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+class WifiDirectGroupInfo;
+class WifiDirectDeviceInfo;
+class WifiDirectGroupMember;
+class _WifiDirectEvent;
+class _WifiDirectDeviceImpl;
+class _WifiIpcProxy;
+
+    enum _WifiDirectSystemState
+    {
+        WIFI_DIRECT_SYSTEM_DEACTIVATED,
+        WIFI_DIRECT_SYSTEM_ACTIVATING,
+        WIFI_DIRECT_SYSTEM_DEACTIVATING,
+        WIFI_DIRECT_SYSTEM_ACTIVATED,
+        WIFI_DIRECT_SYSTEM_AUTONOMOUS_GROUP_CREATING,
+        WIFI_DIRECT_SYSTEM_GROUP_CREATING,
+        WIFI_DIRECT_SYSTEM_GROUP_CANCELING,
+        WIFI_DIRECT_SYSTEM_CONNECTING,
+        WIFI_DIRECT_SYSTEM_CONNECT_CANCELLING,
+        WIFI_DIRECT_SYSTEM_ASSOCIATING,
+        WIFI_DIRECT_SYSTEM_OWNER,
+        WIFI_DIRECT_SYSTEM_DESTROYING,
+        WIFI_DIRECT_SYSTEM_LEAVING,
+        WIFI_DIRECT_SYSTEM_CLIENT,
+        WIFI_DIRECT_SYSTEM_DISCONNECTING
+    };
+
+    enum _WifiDirectSystemScanState
+    {
+        WIFI_DIRECT_SYSTEM_SCAN_IDLE,
+        WIFI_DIRECT_SYSTEM_SCAN_LISTEN,
+        WIFI_DIRECT_SYSTEM_SCAN_LISTEN_CANCELING_TO_SCAN,
+        WIFI_DIRECT_SYSTEM_SCAN_SCANNING,
+        WIFI_DIRECT_SYSTEM_SCAN_CANCELLING
+     };
+
+class _WifiDirectSystemAdapter
+    : public Tizen::Base::Object
+{
+public:
+    struct _WifiDirectEventDeleter
+    {
+        template <typename Obj>
+        void operator()(Obj* object)
+        {
+            delete object;
+            wifi_direct_unset_connection_state_changed_cb();
+            wifi_direct_unset_discovery_state_changed_cb();
+            wifi_direct_unset_connection_state_changed_cb();
+        }
+    };
+
+    /**
+     * Gets the instance.
+     *
+     * @return  The pointer to %_WifiDirectSystemAdapter
+     */
+    static _WifiDirectSystemAdapter* GetInstance(void);
+
+    /**
+     * Gets the All Device Info List.
+     *
+     * @return  The pointer to List containing all device info
+     */
+    Tizen::Base::Collection::IList* GetAllDeviceInfoN(void);
+
+    /**
+     * @see WifiDirectDevice::Activate()
+     */
+    result Activate(void);
+
+    /**
+     * @see WifiDirectDevice::Deactivate()
+     */
+    result Deactivate(void);
+    
+    /**
+     * @see WifiDirectDevice::GetGroupSettingInfoN()
+     */
+    WifiDirectGroupInfo* GetGroupSettingInfoN(void) const;
+    
+    /**
+     * @see WifiDirectDevice::GetLocalDeviceInfoN()
+     */    
+    WifiDirectDeviceInfo* GetLocalDeviceInfoN(void) const;
+
+    /**
+     * @see WifiDirectDevice::GetWpsConfigurationModePreference()
+     */
+    WifiWpsConfigurationMode GetWpsConfigurationModePreference(void) const;
+
+    /**
+     * @see WifiDirectDevice::SetLocalDeviceName()
+     */
+    result SetLocalDeviceName(const Tizen::Base::String &name);
+
+    /**
+     * @see WifiDirectDevice::SetWpsConfigurationModePreference()
+     */    
+    result SetWpsConfigurationModePreference(WifiWpsConfigurationMode mode);
+
+    /**
+     * @see WifiDirectDevice::CreateGroup()
+     */  
+    result CreateGroup(const WifiDirectGroupInfo *pWifiDirectGroupInfo = null, const WifiDirectDeviceInfo *pWifiDirectRemoteDeviceInfo = null);
+
+    /**
+     * @see WifiDirectDevice::CancelGroupCreation()
+     */      
+    result CancelGroupCreation(void);
+
+    /**
+     * @see WifiDirectDevice::Scan()
+     */  
+    result Scan(void);
+
+    /**
+     * @see WifiDirectDevice::CancelScan()
+     */  
+    result CancelScan(void);
+
+    /**
+     * @see WifiDirectDevice::Associate()
+     */  
+    result Associate(const WifiDirectDeviceInfo &wifiDirectGroupOwnerDeviceInfo);
+
+    /**
+     * @see WifiDirectDevice::GetWifiDirectMemberN()
+     */  
+    WifiDirectGroupMember* GetWifiDirectMemberN(void);
+
+    /**
+     * @see WifiDirectDevice::IsDiscoverable()
+     */  
+    bool IsDiscoverable(void) const;
+
+    /**
+     * @see WifiDirectDevice::IsActivated()
+     */
+    bool IsActivated(void) const;
+
+    /**
+     * @see WifiDirectDevice::Connect()
+     */
+    result Connect(const WifiDirectDeviceInfo& peerDeviceInfo);
+
+    /**
+     * @see WifiDirectDevice::CancelConnect()
+     */
+    result CancelConnect(void);
+
+    /**
+     * @see WifiDirectDevice::CreateAutonomousGroup()
+     */
+    result CreateAutonomousGroup(void);
+
+    /**
+     * @see WifiDirectDevice::SetGroupSettingInfo()
+     */
+    result SetGroupSettingInfo(const WifiDirectGroupInfo& groupSettingInfo);
+
+    /**
+     * @see WifiDirectDevice::Disconnect()
+     * @see WifiDirectGroupOwner::Disconnect()
+     */
+    result Disconnect(const WifiDirectDeviceInfo& remoteDeviceInfo);
+
+    /**
+     * @see WifiDirectDevice::LeaveGroup()
+     */
+    result LeaveGroup(void);
+
+    /**
+     * @see WifiDirectDevice::GetGroupOwnerInfo()
+     */
+    WifiDirectDeviceInfo* GetGroupOwnerInfoN(void) const;
+
+    /**
+     * @see WifiDirectDevice::GetGroupClientInfoListN()
+     */
+    Tizen::Base::Collection::IList* GetGroupClientInfoListN(void) const;
+
+    /**
+     * @see WifiDirectDevice::GetOperatingChannel()
+     */
+    WifiRadioChannel GetOperatingChannel(void) const;
+
+    /**
+     * @see WifiDirectGroupOwner::DestroyGroup()
+     */  
+    result DestroyGroup(void);
+    
+    /**
+     * @see WifiDirectGroupOwner::GetAllGroupMemberInfoImplListN()
+     */     
+    Tizen::Base::Collection::IList* GetAllGroupMemberInfoImplListN(void);
+
+    /**
+     * @see WifiDirectGroupClient::Disassociate()
+     */ 
+    result Disassociate(void);
+
+    /**
+     * Gets the type of the Wi-Fi Direct group member.
+     *
+     * @return The type of the Wi-Fi Direct group member
+     */
+    WifiDirectGroupMemberType GetCurrentMemberType(void) const;
+
+    /**
+     * Called when the state of device is changed.
+     *
+     * @param[in]   errorCode   Any Error occured on power change
+     * @param[in]   deviceState Device Status
+     * @param[in]   pUserData   The user data passed from the callback registration function
+     */
+    static void OnWifiDirectPowerChanged(int errorCode, wifi_direct_device_state_e deviceState, void* pUserData);
+
+    /**
+     * Called when the state of discovery is changed.
+     *
+     * @param[in]   errorCode       Any Error occured during scan process
+     * @param[in]   discoveryState  Discovery status
+     * @param[in]   pUserData       The user data passed from the callback registration function
+     */
+    static void OnWifiDirectScanCompleted(int errorCode, wifi_direct_discovery_state_e discoveryState, void* pUserData);
+
+    /**
+     * Called when the state of connection is changed.
+     *
+     * @param[in]   errorCode       Any Error occured during connection process
+     * @param[in]   connectionState Connection status
+     * @param[in]   pMacAddress     Mac Address
+     * @param[in]   pUserData       The user data passed from the callback registration function
+     */
+    static void OnWifiDirectConnectionChanged(int errorCode, wifi_direct_connection_state_e connectionState,
+                                                const char* pMacAddress, void* pUserData);
+    /**
+     * Called when IP address of client is assigned when your device is group owner.
+     *
+     * @param[in]   errorCode       Any Error occured during connection process
+     * @param[in]   connectionState Connection status
+     * @param[in]   pMacAddress     Mac Address
+     * @param[in]   pUserData       The user data passed from the callback registration function
+     */
+    static void OnWifiDirectClientIpAssigned(const char *mac_address, const char *ip_address,
+                                             const char *interface_address, void *user_data);
+    /**
+     * Call back for each Discovered device
+     *
+     * @param[in]   pPeer       Device Information
+     * @param[in]   pUserData   The user data passed from the callback registration function
+     */
+    static bool OnWifiDirectEachDiscoveredPeer(wifi_direct_discovered_peer_info_s* pPeer, void* pUserData);
+
+    /**
+     * Call back for each connected device
+     *
+     * @param[in]   pPeer       Device Information
+     * @param[in]   pUserData   The user data passed from the callback registration function
+     */
+    static bool OnWifiDirectEachConnectedClient(wifi_direct_connected_peer_info_s* pPeer, void* pUserData);
+    
+    /**
+     * Call back for connected owner
+     *
+     * @param[in]   pPeer       Device Information
+     * @param[in]   pUserData   The user data passed from the callback registration function
+     */
+    static bool OnWifiDirectConnectedOwner(wifi_direct_connected_peer_info_s* pPeer, void* pUserData);
+
+    /**
+     * Call back for each discovered device, for searching same device for create group
+     *
+     * @param[in]   pPeer       Device Information
+     * @param[in]   pUserData   The user data passed from the callback registration function
+     */
+    static bool OnWifiDirectFindSameDeviceName(wifi_direct_discovered_peer_info_s* pPeer, void* pUserData);
+
+    /**
+     * Call back for each supported WPS mode
+     *
+     * @param[in]   type        WPS mode type
+     * @param[in]   pUserData   The user data passed from the callback registration function
+     */    
+    static bool OnWifiDirectSupportedWpsMode(wifi_direct_wps_type_e type, void* pUserData);
+
+    /**
+     * Adds Listner
+     *
+     * @param[in]   listner     object of _WifiDirectDeviceImpl
+     */
+    void AddListener(const _WifiDirectDeviceImpl& listner);
+
+    /**
+     * Removes Listner
+     *
+     * @param[in]   listner     object of _WifiDirectDeviceImpl
+     */
+    void RemoveListener(const _WifiDirectDeviceImpl& listner);
+
+    /**
+     * Called to notify the application with the result and related information for a request of group creation or group creation
+     * cancellation.
+     *
+     * @param[in]   peerMacAddress  The peer mac address
+     * @param[in]   r               An error code
+     */
+    void OnWifiDirectGroupCreated(const Tizen::Base::String& peerMacAddress, result r);
+
+    /**
+     * Called to notify the application that the connection to a Wi-Fi Direct group owner is completely established.
+     *
+     * @param[in]   peerMacAddress  The peer mac address
+     * @param[in]   r               An error code
+     */
+    void OnWifiDirectAssociationCompleted(const Tizen::Base::String& peerMacAddress, result r);
+
+    /**
+     * Called to notify the application that a successful association has occurred with a client.
+     *
+     * @param[in]   peerMacAddress  The peer mac address
+     */
+    void OnWifiDirectClientAssociated(const Tizen::Base::String& peerMacAddress);
+
+    /**
+     * Called to notify the application that a disassociation has occurred with a client.
+     *
+     * @param[in]   peerMacAddress  The peer mac address
+     */
+    void OnWifiDirectClientDisassociated(const Tizen::Base::String& peerMacAddress);
+
+    /**
+     * Called to notify the application that a connection to a Wi-Fi Direct group owner has terminated.
+     *
+     * @param[in]   reason  The reason of association termination
+     * @param[in]   r       An error code
+     */
+    void OnWifiDirectAssociationTerminated(WifiDirectAssociationTerminationReason reason, result r);
+
+    /**
+     * Called to notify the application that the Wi-Fi Direct group is destroyed.
+     *
+     * @param[in]   r   An error code
+     */
+    void OnWifiDirectGroupDestroyed(result r);
+
+    /**
+     * Called to notify the application that Wi-Fi Direct connection has been established with the remove device.
+     *
+     * @param[in]   peerMacAddress  The peer mac address
+     * @param[in]   r               An error code
+     */
+    void OnWifiDirectConnected(const Tizen::Base::String& peerMacAddress, result r);
+
+    /**
+     * Called to notify the application that the Wi-Fi Direct connection has been disconnected with peer device.
+     *
+     * @param[in]   peerMacAddress  The peer mac address
+     */
+    void OnWifiDirectDisconnected(const Tizen::Base::String& peerMacAddress, result r);
+
+    /**
+     * Called to notify the application that an autonomous group is created.
+     *
+     * @param[in]   r   An error code
+     */
+    void OnWifiDirectAutonomousGroupCreated(result r);
+
+    /**
+     * Called to notify the application that the local device is left from the group.
+     *
+     * @param[in]   r   An error code
+     */
+    void OnWifiDirectGroupLeft(result r);
+
+private:
+    /**
+     * This default constructor is intentionally declared as private to implement the Singleton semantic.
+     *
+     */
+    _WifiDirectSystemAdapter(void);
+
+    /**
+     * This destructor is intentionally declared as private to implement the Singleton semantic.
+     *
+     */
+    virtual ~_WifiDirectSystemAdapter(void);
+
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     */
+    _WifiDirectSystemAdapter(const _WifiDirectSystemAdapter& value);
+
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     */
+    _WifiDirectSystemAdapter& operator =(const _WifiDirectSystemAdapter& rhs);
+
+    /**
+     * Initializes this instance of _WifiDirectSystemAdapter.
+     */
+    bool Construct(void);
+    
+    /**
+     * Adds connected peer to the end of the list.
+     *
+     * @param[in]   pPeerInfo  The peer device information
+     */
+    result AddPeerInfo(WifiDirectDeviceInfo* pPeerInfo);
+
+    /**
+     * Removes disconnected peer.
+     *
+     * @param[in]   pClientInfo  Device Information
+     */
+    result RemovePeerInfo(WifiDirectDeviceInfo* pPeerInfo);
+
+    /**
+     * Returns device information matching with mac address
+     *
+     * @param[in]   macAddress  mac address string to search in the list
+     */
+    WifiDirectDeviceInfo* GetPeerInfo(const Tizen::Base::String& macAddress);
+
+    /**
+     * Returns char buffer of device state
+     *
+     * @return   char buffer of device state
+     */
+    const char* GetStringOfDeviceState(void) const;
+
+    /**
+     * Returns char buffer of scan state
+     *
+     * @return   char buffer of scan state
+     */  
+    const char* GetStringOfScanState(void) const;
+
+    /**
+     * Returns String of all status
+     *
+     * @return   String of all status
+     */      
+    Tizen::Base::String GetStringOfAllCurrentState(void) const;
+    
+    /**
+     * Initializes current state of Wi-Fi Direct
+     *
+     * @return   An error code
+     */
+    result InitializeCurrentState(void);
+
+    /**
+     * Starts listen mode
+     *
+     * @return   An error code
+     */
+    result StartListenMode(void);
+
+    /**
+     * Stops listen mode
+     *
+     * @return   An error code
+     */
+    result StopListenModeToScan(void);
+
+    /**
+     * Starts discovery
+     *
+     * @return   An error code
+     */
+    result StartDiscovery(void);
+
+    /**
+     * Cancels discovery
+     *
+     * @return   An error code
+     */
+    result CancelDiscovery(void);
+
+    /**
+     * Initializes the _WifiDirectSystemAdapter singletone instance.
+     *
+     * @exception   E_SUCCESS           The initialization was successful.
+     * @exception   E_SYSTEM            A system error occurred.
+     * @exception   E_OUT_OF_MEMORY     The memory is insufficient.     
+     */
+    static void InitSingleton(void);
+
+    /**
+     * Destorys instance of singleton class.
+     */
+    static void DestroySingleton(void);
+    
+    /**
+     * Gets the connected peer device info.
+     */
+    WifiDirectDeviceInfo* GetConnectedPeerDeviceInfoN(WifiDirectGroupMemberType peerMemberType, const Tizen::Base::String* pPeerMacAddress = null) const;
+
+
+
+private:
+    static _WifiDirectSystemAdapter* __pWifiDirectSystemAdapter;
+    std::unique_ptr<_WifiDirectEvent,_WifiDirectEventDeleter> __pWifiDirectEvent;
+
+    Tizen::Base::String __remoteMacAddress;
+    Tizen::Base::String __remoteDeviceName;
+    Tizen::Base::Collection::IList* __pScanResult;
+    _WifiDirectSystemState __currentState;
+    _WifiDirectSystemScanState __currentScanState;
+    Tizen::Base::Collection::ArrayList __peerList;
+    _WifiIpcProxy* __pWifiServiceProxy;
+    friend class std::default_delete<_WifiDirectSystemAdapter>;
+};
+} } } // Tizen::Net::Wifi
+
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_DIRECT_SYSTEM_ADAPTER_H_
diff --git a/src/wifi/FNetWifi_WifiDirectUtility.cpp b/src/wifi/FNetWifi_WifiDirectUtility.cpp
new file mode 100644 (file)
index 0000000..771e3e6
--- /dev/null
@@ -0,0 +1,492 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiDirectUtil.h
+ * @brief   This is the implementation file for the _WifiDirectUtility Class.
+ *
+ * This file contains implementation of the _WifiDirectUtility Class.
+ */
+#include <unique_ptr.h>
+#include <FBaseErrors.h>
+#include <FBaseDataType.h>
+#include <FBaseColArrayListT.h>
+#include <FNetWifiWifiDirectDeviceInfo.h>
+#include <FNetWifiWifiDirectGroupInfo.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FNetWifi_WifiDirectDeviceInfoImpl.h"
+#include "FNetWifi_WifiDirectUtility.h"
+#include "FNetWifi_WifiDirectGroupInfoImpl.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+_WIFIDIRECT_MESSAGE_TYPE
+_WifiDirectUtility::GetMessageType(String message)
+{
+    result r = E_SUCCESS;
+
+    int messageType = 0;
+
+    String type;
+
+    r = message.SubString(0, MESSAGE_TYPE_LENGTH, type);
+
+    if (IsFailed(r))
+    {
+        type.Clear();
+        return UNKNOWN;
+    }
+
+    type.Trim();
+
+    r = Integer::Decode(type, messageType);
+
+    if (IsFailed(r))
+    {
+        return UNKNOWN;
+    }
+    else
+    {
+        return static_cast< _WIFIDIRECT_MESSAGE_TYPE >(messageType);
+    }
+}
+
+bool
+_WifiDirectUtility::CheckMacFormat(wchar_t* pMacAddress)
+{
+    int temp = 0;
+
+    while (*pMacAddress)
+    {
+        if ((*pMacAddress >= '0') && (*pMacAddress < '9'+1))
+        {
+            temp = *pMacAddress - '0';
+        }
+        else if ((*pMacAddress >= 'A') && (*pMacAddress < 'G'))
+        {
+            temp = *pMacAddress - 'A' + 10;
+        }
+        else if ((*pMacAddress >= 'a') && (*pMacAddress < 'g'))
+        {
+            temp = *pMacAddress - 'a' + 10;
+        }
+        else
+        {
+            return false;
+        }
+
+        pMacAddress++;
+    }
+
+    return true;
+}
+
+bool
+_WifiDirectUtility::CheckMacAddress(Tizen::Base::String macAddress)
+{
+    String tempString("");
+
+    bool ret = true;
+
+    const int lastDelimiterIndex = 5;
+    int currentIndex = 0;
+    int nextIndex = 0;
+    int count = 0;
+    int checkIndex = 2;
+
+
+    macAddress.Trim();
+
+    if (MAX_MAC_ADDRESS_LENGTH != macAddress.GetLength())
+    {
+        return false;
+    }
+
+    while (E_SUCCESS == macAddress.IndexOf("-", currentIndex, nextIndex))
+    {
+        if (nextIndex != checkIndex)
+        {
+            ret = false;
+            break;
+        }
+
+        macAddress.SubString(currentIndex, 2, tempString);
+        ret = _WifiDirectUtility::CheckMacFormat(const_cast<wchar_t*>(tempString.GetPointer()));
+
+        if (ret == false)
+        {
+            break;
+        }
+
+        checkIndex += 3;
+        currentIndex = nextIndex + 1;
+        count++;
+    };
+
+    if (count == lastDelimiterIndex
+        && E_SUCCESS == macAddress.SubString(currentIndex, 2, tempString))
+    {
+        ret = _WifiDirectUtility::CheckMacFormat(const_cast<wchar_t*>(tempString.GetPointer()));
+    }
+    else
+    {
+        ret = false;
+    }
+
+    return ret;
+}
+
+result
+_WifiDirectUtility::ConvertErrorCode(int err)
+{
+    result r = E_SUCCESS;
+    String message;
+    static const int MAX_LOG_LENGTH = 256;
+
+    switch (err)
+    {
+    case WIFI_DIRECT_ERROR_NONE:
+        message.Format(MAX_LOG_LENGTH, L"[%s] Error None", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_ERROR_CONNECTION_FAILED:
+        r = E_NOT_RESPONDING;
+        message.Format(MAX_LOG_LENGTH, L"[%s] Connection failed", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_ERROR_OUT_OF_MEMORY:
+        r = E_OUT_OF_MEMORY;
+        message.Format(MAX_LOG_LENGTH, L"[%s] Out of memory", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_ERROR_COMMUNICATION_FAILED:
+        r = E_SYSTEM;
+        message.Format(MAX_LOG_LENGTH, L"[%s] I/O error", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_ERROR_NOT_PERMITTED:
+        r = E_INVALID_OPERATION;
+        message.Format(MAX_LOG_LENGTH, L"[%s] Operation not permitted", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_ERROR_INVALID_PARAMETER:
+        r = E_INVALID_ARG;
+        message.Format(MAX_LOG_LENGTH, L"[%s] Invalid function parameter", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_ERROR_TOO_MANY_CLIENT:
+        r = E_INVALID_ARG;
+        message.Format(MAX_LOG_LENGTH, L"[%s] Too many users", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_ERROR_RESOURCE_BUSY:
+        r = E_SYSTEM;
+        message.Format(MAX_LOG_LENGTH, L"[%s] Device or resource busy", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT:
+        r =  E_REMOTE_DEVICE_NOT_FOUND;
+        message.Format(MAX_LOG_LENGTH, L"[%s] Connection timed out", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_ERROR_OPERATION_FAILED:
+        r = E_SYSTEM;
+        message.Format(MAX_LOG_LENGTH, L"[%s] Operation failed", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_ERROR_WIFI_USED:
+        r = E_SYSTEM;
+        message.Format(MAX_LOG_LENGTH, L"[%s] Wifi is ON", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_ERROR_MOBILE_AP_USED:
+        r = E_SYSTEM;
+        message.Format(MAX_LOG_LENGTH, L"[%s] Mobile AP is ON", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_ERROR_AUTH_FAILED:
+        r = E_AUTHENTICATION;
+        message.Format(MAX_LOG_LENGTH, L"[%s] Authentication failed", GetErrorMessage(r));
+        break;
+    case WIFI_DIRECT_ERROR_NOT_INITIALIZED:
+        r = E_SYSTEM;
+        message.Format(MAX_LOG_LENGTH, L"[%s] Not initialized", GetErrorMessage(r));
+        break;        
+    default:
+        r = E_SYSTEM;
+        message.Format(MAX_LOG_LENGTH, L"[%s] Unknown Error", GetErrorMessage(r));
+        break;
+    }
+
+    SysLog(NID_NET_WIFI, "[ErrorCode : %d] %ls", err, message.GetPointer());
+
+    return r;
+}
+
+WifiRadioChannel
+_WifiDirectUtility::ConvertChannel(int channel)
+{
+    WifiRadioChannel radioChannel = WIFI_RADIO_CHANNEL_UNKNOWN;
+
+    switch (channel)
+    {
+    case 1:
+        radioChannel = WIFI_RADIO_CHANNEL_1;
+        break;
+    case 2:
+        radioChannel = WIFI_RADIO_CHANNEL_2;
+        break;
+    case 3:
+        radioChannel = WIFI_RADIO_CHANNEL_3;
+        break;
+    case 4:
+        radioChannel = WIFI_RADIO_CHANNEL_4;
+        break;
+    case 5:
+        radioChannel = WIFI_RADIO_CHANNEL_5;
+        break;
+    case 6:
+        radioChannel = WIFI_RADIO_CHANNEL_6;
+        break;
+    case 7:
+        radioChannel = WIFI_RADIO_CHANNEL_7;
+        break;
+    case 8:
+        radioChannel = WIFI_RADIO_CHANNEL_8;
+        break;
+    case 9:
+        radioChannel = WIFI_RADIO_CHANNEL_9;
+        break;
+    case 10:
+        radioChannel = WIFI_RADIO_CHANNEL_10;
+        break;
+    case 11:
+        radioChannel = WIFI_RADIO_CHANNEL_11;
+        break;
+    case 12:
+        radioChannel = WIFI_RADIO_CHANNEL_12;
+        break;
+    case 13:
+        radioChannel = WIFI_RADIO_CHANNEL_13;
+        break;
+    case 14:
+        radioChannel = WIFI_RADIO_CHANNEL_14;
+        break;
+    default:
+        break;
+    }
+    SysLog(NID_NET_WIFI, "channel value : %d", channel);
+
+    return radioChannel;
+}
+Tizen::Base::String
+_WifiDirectUtility::ConvertMacCharToString(const char macAddress[])
+{
+    result r = E_SUCCESS;
+    String mac;
+    mac.Append(macAddress);
+
+    int curIndex = 0;
+    int findIndex = 0;
+
+    while(E_OBJ_NOT_FOUND != mac.IndexOf(":", curIndex, findIndex))
+    {
+        r = mac.SetCharAt('-',findIndex);
+
+        if (IsFailed(r))
+        {
+            mac.Clear();
+            return mac;
+        }
+
+        curIndex = ++findIndex;
+    }
+
+    return mac;
+}
+
+char*
+_WifiDirectUtility::ConvertMacStringToCharN(const Tizen::Base::String macAddress)
+{
+    result r = E_SUCCESS;
+    char* pMacAddress = null;
+    String mac = macAddress;;
+
+    int curIndex = 0;
+    int findIndex = 0;
+
+    while(E_OBJ_NOT_FOUND != mac.IndexOf("-", curIndex, findIndex))
+    {
+        r = mac.SetCharAt(':',findIndex);
+
+        if (IsFailed(r))
+        {
+            mac.Clear();
+            break;
+        }
+
+        curIndex = ++findIndex;
+    }
+
+    pMacAddress = _StringConverter::CopyToCharArrayN(mac);
+    SysTryReturn(NID_NET_WIFI, pMacAddress != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    return pMacAddress;
+}
+
+WifiDirectDeviceTypeCategory
+_WifiDirectUtility::ConvertDeviceTypeCategory(wifi_direct_primary_device_type_e primary_dev_type)
+{
+    if (primary_dev_type >= WIFI_DIRECT_PRIMARY_DEVICE_TYPE_COMPUTER
+        && primary_dev_type <=WIFI_DIRECT_PRIMARY_DEVICE_TYPE_AUDIO)
+    {
+        return (WifiDirectDeviceTypeCategory)(primary_dev_type-1);
+    }
+    else
+    {
+        return WIFI_DIRECT_DEVICE_TYPE_CATEGORY_OTHERS;
+    }
+}
+
+WifiWpsConfigurationMode
+_WifiDirectUtility::ConvertSupportedWpsMode(wifi_direct_wps_type_e wpsType)
+{
+    WifiWpsConfigurationMode wpsMode = WIFI_WPS_CONFIG_MODE_NONE;
+
+    if(wpsType == WIFI_DIRECT_WPS_TYPE_PBC)
+    {
+        wpsMode = WIFI_WPS_CONFIG_MODE_PBC;
+    }
+
+    else if(wpsType == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY)
+    {
+        wpsMode = WIFI_WPS_CONFIG_MODE_PIN_DISPLAY;
+    }
+
+   else if(wpsType == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD)
+   {
+        wpsMode = WIFI_WPS_CONFIG_MODE_PIN_KEYPAD;
+   }
+
+    return wpsMode;
+}
+
+WifiDirectDeviceInfo*
+_WifiDirectUtility::ConvertPeerInfoToDeviceInfoN(WifiDirectGroupMemberType memberType,
+        const wifi_direct_connected_peer_info_s &peerInfo)
+{
+    unique_ptr<WifiDirectDeviceInfo> pDeviceInfo(new (std::nothrow) WifiDirectDeviceInfo());
+    SysTryReturn(NID_NET_WIFI, pDeviceInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    _WifiDirectDeviceInfoImpl* pDeviceInfoImpl = _WifiDirectDeviceInfoImpl::GetInstance(*pDeviceInfo);
+    SysTryReturn(NID_NET_WIFI, pDeviceInfoImpl != null, null, E_SYSTEM,
+            "[E_SYSTEM] Failed to acquire the instance of _WifiDirectDeviceInfoImpl.");
+
+    // DeviceId
+    pDeviceInfoImpl->SetDeviceId(DEFAULT_DEVICE_ID);
+
+    // DeviceName
+    pDeviceInfoImpl->SetDeviceName(String(peerInfo.device_name));
+
+    // DeviceStatus
+    pDeviceInfoImpl->SetDeviceStatus(WIFI_DIRECT_DEVICE_ACTIVATED);
+
+    // DeviceTypeCategory
+    pDeviceInfoImpl->SetDeviceTypeCategory(_WifiDirectUtility::ConvertDeviceTypeCategory(
+            static_cast< wifi_direct_primary_device_type_e >(peerInfo.primary_device_type)));
+
+    // GroupMemberType
+    pDeviceInfoImpl->SetGroupMemberType(memberType);
+
+    // IpAddress
+    pDeviceInfoImpl->SetIpAddress(String(peerInfo.ip_address));
+
+    // MacAddress
+    pDeviceInfoImpl->SetMacAddress(_WifiDirectUtility::ConvertMacCharToString(peerInfo.mac_address));
+    pDeviceInfoImpl->SetVirtualMacAddress(_WifiDirectUtility::ConvertMacCharToString(peerInfo.interface_address));
+
+    // SupportedWpsConfigurationModeList(Not Required)
+    _WifiDirectDeviceInfoImpl::PrintDeviceInfo(*pDeviceInfoImpl);
+
+    return pDeviceInfo.release();
+}
+
+WifiDirectDeviceInfo*
+_WifiDirectUtility::ConvertDiscoveryEntry2DeviceInfoN(const wifi_direct_discovered_peer_info_s& peerInfo)
+{
+    unique_ptr<WifiDirectDeviceInfo> pDeviceInfo(new (std::nothrow) WifiDirectDeviceInfo());
+    SysTryReturn(NID_NET_WIFI, pDeviceInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    _WifiDirectDeviceInfoImpl* pDeviceInfoImpl = _WifiDirectDeviceInfoImpl::GetInstance(*pDeviceInfo);
+    SysTryReturn(NID_NET_WIFI, pDeviceInfoImpl != null, null, E_SYSTEM,
+            "[E_SYSTEM] Failed to acquire the instance of _WifiDirectDeviceInfoImpl.");
+
+    // DeviceId
+    pDeviceInfoImpl->SetDeviceId(DEFAULT_DEVICE_ID);
+
+    // DeviceName
+    pDeviceInfoImpl->SetDeviceName(String(peerInfo.device_name));
+    //pDeviceInfoImpl->SetDeviceName(String(peerInfo.ssid));
+
+    // DeviceStatus
+    pDeviceInfoImpl->SetDeviceStatus(WIFI_DIRECT_DEVICE_ACTIVATED);
+
+    // DeviceTypeCategory
+    pDeviceInfoImpl->SetDeviceTypeCategory(_WifiDirectUtility::ConvertDeviceTypeCategory(
+           static_cast< wifi_direct_primary_device_type_e >(peerInfo.primary_device_type)));
+
+    // GroupMemberType
+    if (peerInfo.is_group_owner == true)
+    {
+        pDeviceInfoImpl->SetGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_OWNER);
+    }
+    else
+    {
+        pDeviceInfoImpl->SetGroupMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE);
+    }
+
+    // IpAddress(Not Required)
+
+    // MacAddress
+    pDeviceInfoImpl->SetMacAddress(_WifiDirectUtility::ConvertMacCharToString(peerInfo.mac_address));
+    pDeviceInfoImpl->SetVirtualMacAddress(_WifiDirectUtility::ConvertMacCharToString(peerInfo.interface_address));
+
+    // SupportedWpsConfigurationModeList
+    ArrayListT<WifiWpsConfigurationMode> wpsList;
+    wpsList.Construct();
+    WifiWpsConfigurationMode wpsMode;
+
+    if (peerInfo.supported_wps_types == WIFI_DIRECT_WPS_TYPE_PBC)
+    {
+        wpsMode = _WifiDirectUtility::ConvertSupportedWpsMode((wifi_direct_wps_type_e)peerInfo.supported_wps_types);
+        wpsList.Add(wpsMode);
+    }
+
+    if (peerInfo.supported_wps_types == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY)
+    {
+        wpsMode = _WifiDirectUtility::ConvertSupportedWpsMode((wifi_direct_wps_type_e)peerInfo.supported_wps_types);
+        wpsList.Add(wpsMode);
+    }
+
+    if (peerInfo.supported_wps_types == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD)
+    {
+        wpsMode = _WifiDirectUtility::ConvertSupportedWpsMode((wifi_direct_wps_type_e)peerInfo.supported_wps_types);
+        wpsList.Add(wpsMode);
+    }
+    pDeviceInfoImpl->SetSupportedWpsConfigurationMode(wpsList);
+
+    _WifiDirectDeviceInfoImpl::PrintDeviceInfo(*pDeviceInfoImpl);
+
+    return pDeviceInfo.release();
+}
+
+} } } //Tizen::Net::Wifi
+
diff --git a/src/wifi/FNetWifi_WifiIpcMessages.cpp b/src/wifi/FNetWifi_WifiIpcMessages.cpp
new file mode 100644 (file)
index 0000000..89a1e2a
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiIpcMessages.cpp
+ * @brief   This is the generator of IPC messages for the Connectivity service daemon.
+ */
+
+#define IPC_MESSAGE_IMPL
+#include "FNetWifi_ConnectivityIpcMessages.h"
+
+// Generate constructors.
+#include <ipc/struct_constructor_macros.h>
+#include "FNetWifi_ConnectivityIpcMessages.h"
+
+// Generate destructors.
+#include <ipc/struct_destructor_macros.h>
+#include "FNetWifi_ConnectivityIpcMessages.h"
+
+// Generate param traits write methods.
+#include <ipc/param_traits_write_macros.h>
+namespace IPC {
+#include "FNetWifi_ConnectivityIpcMessages.h"
+}  // namespace IPC
+
+// Generate param traits read methods.
+#include <ipc/param_traits_read_macros.h>
+namespace IPC {
+#include "FNetWifi_ConnectivityIpcMessages.h"
+}  // namespace IPC
diff --git a/src/wifi/FNetWifi_WifiIpcProxy.cpp b/src/wifi/FNetWifi_WifiIpcProxy.cpp
new file mode 100644 (file)
index 0000000..6379143
--- /dev/null
@@ -0,0 +1,394 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiIpcProxy.cpp
+ * @brief   This is the implementation file for the %_WifiIpcProxy class.
+ *
+ * This file contains the implementation of the %_WifiIpcProxy class.
+ */
+
+#include <pthread.h>
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FNetWifiWifiBssInfo.h>
+#include <FIo_IpcClient.h>
+#include "FNetWifi_WifiProximityManagerImpl.h"
+#include "FNetWifi_WifiIpcProxy.h"
+#include "FNetWifi_ConnectivityIpcMessages.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+static _WifiIpcProxy* pSingleton = null;
+
+_WifiIpcProxy::_WifiIpcProxy(void)
+       : __pIpcClient(null)
+{
+}
+
+_WifiIpcProxy::~_WifiIpcProxy(void)
+{
+       delete __pIpcClient;
+    pSingleton = null;
+}
+
+result
+_WifiIpcProxy::Construct(void)
+{
+       result r = E_SUCCESS;
+
+       unique_ptr<_IpcClient> pClient(new (std::nothrow) _IpcClient);
+       SysTryReturnResult(NID_NET_WIFI, pClient != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pClient->Construct(WIFI_CONNECTIVITY_IPC_SERVER_NAME, this);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Construction of _IpcClient has failed.");
+
+       __pIpcClient = pClient.release();
+       SysLog(NID_NET_WIFI, "An instance of the Wifi IPC Proxy has been constructed.");
+
+       return E_SUCCESS;
+}
+
+void
+_WifiIpcProxy::InitSingleton(void)
+{
+    result r = E_SUCCESS;
+    unique_ptr<_WifiIpcProxy> pInst(new (std::nothrow) _WifiIpcProxy());
+    
+    SysTryReturnVoidResult(NID_NET_WIFI, pInst != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    r = pInst->Construct();
+    SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r, "[%s] Construction of the _WifiIpcProxy has failed.", GetErrorMessage(r));
+
+    pSingleton = pInst.release();
+
+    std::atexit(DestroySingleton);
+}
+
+void 
+_WifiIpcProxy::DestroySingleton(void)
+{
+    delete pSingleton;
+}
+
+_WifiIpcProxy*
+_WifiIpcProxy::GetInstance(void)
+{
+    static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+    if (!pSingleton)
+    {
+        ClearLastResult();
+        pthread_once(&onceBlock, InitSingleton);
+        
+        result r = GetLastResult();
+        if (IsFailed(r))
+        {
+             onceBlock = PTHREAD_ONCE_INIT;
+        }
+    }
+
+    return pSingleton;
+}
+
+result
+_WifiIpcProxy::InitializeWifiDirect(void) const
+{
+       result r = E_SUCCESS;
+       IPC::Message* pMessage = null;
+       unsigned long ret = 0;
+
+       pMessage = new (std::nothrow) ConnectivityWifiServiceMsg_initializeWifiDirect(&ret);
+       SysTryReturnResult(NID_NET_WIFI, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pIpcClient->SendRequest(*pMessage);
+       delete pMessage;
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Sending a request message to an IPC server failed.");
+       SysTryReturnResult(NID_NET_WIFI, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+       SysLog(NID_NET_WIFI, "Initializing the Wi-Fi Direct of osp-connectivity-service through IPC is successful.");
+
+       return E_SUCCESS;
+}
+
+result
+_WifiIpcProxy::GetWifiDirectLocalDeviceName(Tizen::Base::String& deviceName) const
+{
+       result r = E_SUCCESS;
+       IPC::Message* pMessage = null;
+       unsigned long ret = 0;
+
+       pMessage = new (std::nothrow) ConnectivityWifiServiceMsg_getWifiDirectLocalDeviceName(&deviceName, &ret);
+       SysTryReturnResult(NID_NET_WIFI, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pIpcClient->SendRequest(*pMessage);
+       delete pMessage;
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Sending a request message to an IPC server failed.");
+       SysTryReturnResult(NID_NET_WIFI, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+       SysLog(NID_NET_WIFI, "The Wi-Fi Direct local name obtained through IPC is [%ls].", deviceName.GetPointer());
+
+       return E_SUCCESS;
+}
+
+result
+_WifiIpcProxy::SetWifiDirectLocalDeviceName(const Tizen::Base::String& deviceName) const
+{
+       result r = E_SUCCESS;
+       IPC::Message* pMessage = null;
+       unsigned long ret = 0;
+
+       pMessage = new (std::nothrow) ConnectivityWifiServiceMsg_setWifiDirectLocalDeviceName(deviceName, &ret);
+       SysTryReturnResult(NID_NET_WIFI, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pIpcClient->SendRequest(*pMessage);
+       delete pMessage;
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Sending a request message to an IPC server failed.");
+       SysTryReturnResult(NID_NET_WIFI, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+       SysLog(NID_NET_WIFI, "Setting the Wi-Fi Direct local name through IPC is successful.");
+
+       return E_SUCCESS;
+}
+
+result
+_WifiIpcProxy::SetWifiSystemScanMode(WifiSystemScanMode mode)
+{
+       result r = E_SUCCESS;
+       IPC::Message* pMessage = null;
+       unsigned long ret = 0;
+
+       pMessage = new (std::nothrow) ConnectivityWifiServiceMsg_setSystemScanMode((int)mode, &ret);
+       SysTryReturnResult(NID_NET_WIFI, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pIpcClient->SendRequest(*pMessage);
+       delete pMessage;
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Sending a request message to an IPC server failed.");
+       SysTryReturnResult(NID_NET_WIFI, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+       SysLog(NID_NET_WIFI, "Setting the Wi-Fi system scan mode through IPC is successful.");
+
+       return E_SUCCESS;
+}
+
+result
+_WifiIpcProxy::CheckSystemSettingPrivilege(void)
+{
+       result r = E_SUCCESS;
+       IPC::Message* pMessage = null;
+       unsigned long ret = 0;
+
+       pMessage = new (std::nothrow) ConnectivityWifiServiceMsg_checkSystemSettingPrivilege(&ret);
+       SysTryReturnResult(NID_NET_WIFI, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pIpcClient->SendRequest(*pMessage);
+       delete pMessage;
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Sending a request message to an IPC server failed.");
+       SysTryReturnResult(NID_NET_WIFI, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+       SysLog(NID_NET_WIFI, "Checking the Wi-Fi system setting privilege through IPC is successful.");
+
+       return E_SUCCESS;
+}
+
+result
+_WifiIpcProxy::UpdateBssInfo(const WifiBssInfo& bssInfo)
+{
+       result r = E_SUCCESS;
+       IPC::Message* pMessage = null;
+       unsigned long ret = 0;
+
+       pMessage = new (std::nothrow) ConnectivityWifiServiceMsg_updateWifiBssInfo(bssInfo, &ret);
+       SysTryReturnResult(NID_NET_WIFI, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pIpcClient->SendRequest(*pMessage);
+       delete pMessage;
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Sending a request message to an IPC server failed.");
+       SysTryReturnResult(NID_NET_WIFI, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+       SysLog(NID_NET_WIFI, "Updating the Wi-Fi BSS info IPC is successful.");
+
+       return E_SUCCESS;
+}
+
+void
+_WifiIpcProxy::SetWifiProximityManagerImpl(Tizen::Net::Wifi::_WifiProximityManagerImpl& impl)
+{
+    __pWifiProximityManagerImpl = &impl;
+}
+
+result
+_WifiIpcProxy::RegisterBssId(const Tizen::Base::String& bssId) const
+{
+       result r = E_SUCCESS;
+       IPC::Message* pMessage = null;
+       unsigned long ret = 0;
+
+       pMessage = new (std::nothrow) ConnectivityWifiServiceMsg_registerBssId(bssId, &ret);
+       SysTryReturnResult(NID_NET_WIFI, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pIpcClient->SendRequest(*pMessage);
+       delete pMessage;
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Sending a request message to an IPC server failed.");
+       SysTryReturnResult(NID_NET_WIFI, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+       SysLog(NID_NET_WIFI, "Registering the BSS ID through IPC is successful.");
+
+       return E_SUCCESS;
+}
+
+result
+_WifiIpcProxy::UnRegisterBssId(const Tizen::Base::String& bssId) const
+{
+       result r = E_SUCCESS;
+       IPC::Message* pMessage = null;
+       unsigned long ret = 0;
+
+       pMessage = new (std::nothrow) ConnectivityWifiServiceMsg_unregisterBssId(bssId, &ret);
+       SysTryReturnResult(NID_NET_WIFI, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pIpcClient->SendRequest(*pMessage);
+       delete pMessage;
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Sending a request message to an IPC server failed.");
+       SysTryReturnResult(NID_NET_WIFI, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+       SysLog(NID_NET_WIFI, "Unregistering the BSS ID through IPC is successful.");
+
+       return E_SUCCESS;
+}
+
+result
+_WifiIpcProxy::ActivateProximityCheck(void) const
+{
+       result r = E_SUCCESS;
+       IPC::Message* pMessage = null;
+       unsigned long ret = 0;
+
+       pMessage = new (std::nothrow) ConnectivityWifiServiceMsg_activateProximityCheck(&ret);
+       SysTryReturnResult(NID_NET_WIFI, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pIpcClient->SendRequest(*pMessage);
+       delete pMessage;
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Sending a request message to an IPC server failed.");
+       SysTryReturnResult(NID_NET_WIFI, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+       SysLog(NID_NET_WIFI, "Activating proximity service through IPC is successful.");
+
+       return E_SUCCESS;
+}
+
+result
+_WifiIpcProxy::DeactivateProximityCheck(void) const
+{
+       result r = E_SUCCESS;
+       IPC::Message* pMessage = null;
+       unsigned long ret = 0;
+
+       pMessage = new (std::nothrow) ConnectivityWifiServiceMsg_deactivateProximityCheck(&ret);
+       SysTryReturnResult(NID_NET_WIFI, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pIpcClient->SendRequest(*pMessage);
+       delete pMessage;
+
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Sending a request message to an IPC server failed.");
+       SysTryReturnResult(NID_NET_WIFI, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+       SysLog(NID_NET_WIFI, "Deactivating proximity service through IPC is successful.");
+
+       return E_SUCCESS;
+}
+
+result
+_WifiIpcProxy::IsProximityCheckActivated(bool& isActivated) const
+{
+       result r = E_SUCCESS;
+       IPC::Message* pMessage = null;
+       unsigned long ret = 0;
+
+       pMessage = new (std::nothrow) ConnectivityWifiServiceMsg_isProximityCheckActivated(&isActivated, &ret);
+       SysTryReturnResult(NID_NET_WIFI, pMessage != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = __pIpcClient->SendRequest(*pMessage);
+       delete pMessage;
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Sending a request message to an IPC server failed.");
+       SysTryReturnResult(NID_NET_WIFI, ret == E_SUCCESS, ret, "Propagating through IPC.");
+
+       SysLog(NID_NET_WIFI, "Getting the Wi-Fi Proximity activation status through IPC is successful.");
+
+       return E_SUCCESS;
+}
+
+void
+_WifiIpcProxy::OnProximityCheckActivated()
+{
+    __pWifiProximityManagerImpl->OnWifiProximityCheckActivated();
+}
+
+void
+_WifiIpcProxy::OnProximityCheckDeactivated()
+{
+    __pWifiProximityManagerImpl->OnWifiProximityCheckDeactivated();
+}
+
+void
+_WifiIpcProxy::OnWifiBssDetected(const Tizen::Net::Wifi::WifiBssInfo& wifiBssInfo)
+{
+    __pWifiProximityManagerImpl->OnWifiBssDetected(wifiBssInfo);
+}
+
+void
+_WifiIpcProxy::OnWifiBssLost(const Tizen::Base::String& bssId)
+{
+    __pWifiProximityManagerImpl->OnWifiBssLost(bssId);
+}
+
+void
+_WifiIpcProxy::OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message)
+{
+    IPC_BEGIN_MESSAGE_MAP(_WifiIpcProxy, message)
+    IPC_MESSAGE_HANDLER(ConnectivityWifiServiceMsg_onProximityCheckActivated, OnProximityCheckActivated, &client)
+    IPC_MESSAGE_HANDLER(ConnectivityWifiServiceMsg_onProximityCheckDeactivated, OnProximityCheckDeactivated, &client)
+    IPC_MESSAGE_HANDLER(ConnectivityWifiServiceMsg_onWifiBssDetected, OnWifiBssDetected, &client);
+    IPC_MESSAGE_HANDLER(ConnectivityWifiServiceMsg_onWifiBssLost, OnWifiBssLost, &client);
+    IPC_END_MESSAGE_MAP()
+}
+
+} } } // Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiIpcProxy.h b/src/wifi/FNetWifi_WifiIpcProxy.h
new file mode 100644 (file)
index 0000000..db247f1
--- /dev/null
@@ -0,0 +1,207 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file       FNetWifi_WifiIpcProxy.h
+ * @brief      This is the header file for the %_WifiIpcProxy class.
+ *
+ * This header file contains the declarations of the %_WifiIpcProxy class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_IPC_PROXY_H_
+#define _FNET_WIFI_INTERNAL_WIFI_IPC_PROXY_H_
+
+#include <FBaseObject.h>
+#include <FNetWifiWifiTypes.h>
+#include <FIo_IIpcClientEventListener.h>
+
+// Forward declaration
+namespace Tizen { namespace Base
+{
+class String;
+} }
+
+namespace Tizen { namespace Io
+{
+class _IpcClient;
+} }
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+class WifiBssInfo;
+class _WifiProximityManagerImpl;
+
+/**
+ * @class   _WifiIpcProxy
+ * @brief   This class represents an IPC proxy for %Wifi service.
+ *
+ * This class represents an IPC proxy for %Wifi service to communicate with Connectivity service daemon.
+ */
+class _WifiIpcProxy
+       : public Tizen::Base::Object
+       , public Tizen::Io::_IIpcClientEventListener
+{
+public:
+
+    /**
+     * Gets the instance.
+     *
+     * @return  The pointer to %_WifiIpcProxy
+     */
+    static _WifiIpcProxy* GetInstance(void);
+
+    /**
+     * Initialize Wifi Direct of osp-connectivity-service daemon using IPC Proxy.
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method was successful.
+     * @exception   E_SYSTEM            A system error occurred.
+     */
+    result InitializeWifiDirect(void) const;
+
+    /**
+     * Gets Wifi Direct Local Device Name using IPC Proxy.
+     *
+     * @return      An error code
+     * @param[out]  deviceName          Local device name
+     * @exception   E_SUCCESS           The method was successful.
+     * @exception   E_SYSTEM            A system error occurred.
+     */
+    result GetWifiDirectLocalDeviceName(Tizen::Base::String& deviceName) const;
+
+    /**
+     * Sets Wifi Direct Local Device Name using IPC Proxy.
+     *
+     * @return      An error code
+     * @param[out]  deviceName          Local device name
+     * @exception   E_SUCCESS           The method was successful.
+     * @exception   E_SYSTEM            A system error occurred.
+     */
+    result SetWifiDirectLocalDeviceName(const Tizen::Base::String& deviceName) const;
+
+    /**
+     * Sets the behavior mode of the Wi-Fi background system about connection and background scanning through the IPC
+     *
+     * @return      An error code
+     * @param[in]   mode                A Wi-Fi system mode
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege(SYSTEM_NET_SETTING) to call this method.
+     * @exception   E_OPERATION_FAILED  The operation has failed.
+     * @exception   E_SYSTEM            The method cannot proceed due to a severe system error.
+     */
+    result SetWifiSystemScanMode(WifiSystemScanMode mode);
+
+    /**
+     * Checks whether the caller has SYSTEM_NET_SETTING privilege throuth the IPC.
+     *
+     * @return      An error code
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege(SYSTEM_NET_SETTING) to call this method.
+     * @exception   E_SYSTEM            The method cannot proceed due to a severe system error.
+     */
+    result CheckSystemSettingPrivilege(void);
+
+    /**
+     * Updates the Wi-Fi BSS information which is saved in the underlying Wi-Fi system through the IPC.
+     *
+     * @return      An error code
+     * @param[in]   bssInfo             A BSS information representing the access point
+     * @exception   E_SUCCESS           The method is successful.
+     * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege(SYSTEM_NET_SETTING) to call this method.
+     * @exception   E_OBJ_NOT_FOUND     The specified input parameter is not found.
+     * @exception   E_OPERATION_FAILED  The operation has failed.
+     * @exception   E_SYSTEM            The method cannot proceed due to a severe system error.
+     */
+    result UpdateBssInfo(const WifiBssInfo& bssInfo);
+
+    result RegisterBssId(const Tizen::Base::String& bssId) const;
+    result UnRegisterBssId(const Tizen::Base::String& bssId) const;
+    result ActivateProximityCheck(void) const;
+    result DeactivateProximityCheck(void) const;
+    result IsProximityCheckActivated(bool& isActivated) const;
+
+       void OnProximityCheckActivated();
+       void OnProximityCheckDeactivated();
+       void OnWifiBssDetected(const Tizen::Net::Wifi::WifiBssInfo& wifiBssInfo);
+       void OnWifiBssLost(const Tizen::Base::String& macAddress);
+
+       void SetWifiProximityManagerImpl(Tizen::Net::Wifi::_WifiProximityManagerImpl& impl);
+
+    // from _IIpcClientEventListener
+    virtual void OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message);
+
+private:
+    /**
+     * This default constructor is intentionally declared as private so that only the platform can create an instance.
+     *
+     */
+    _WifiIpcProxy(void);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     *
+     */
+    virtual ~_WifiIpcProxy(void);
+
+    /**
+     * Initializes a new instance of this class.
+     *
+     * @return  An error code
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_OUT_OF_MEMORY Failed to allocated memory.
+     */    
+    result Construct(void);
+
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in] rhs   An instance of %_WifiIpcProxy
+     */
+    _WifiIpcProxy(const _WifiIpcProxy& rhs);
+   
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in] rhs An instance of %_WifiIpcProxy
+     */
+    _WifiIpcProxy& operator =(const _WifiIpcProxy& rhs);
+
+    /**
+     * Initializes the _WifiIpcProxy singletone instance.
+     *
+     * @exception   E_SUCCESS           The initialization was successful.
+     * @exception   E_SYSTEM            A system error occurred.
+     * @exception   E_OUT_OF_MEMORY     The memory is insufficient.     
+     */
+    static void InitSingleton(void);
+
+    /**
+     * Destorys instance of singleton class.
+     *
+     */
+    static void DestroySingleton(void);
+
+private:
+       Tizen::Io::_IpcClient* __pIpcClient;
+    friend class std::default_delete<_WifiIpcProxy>;
+       Tizen::Net::Wifi::_WifiProximityManagerImpl* __pWifiProximityManagerImpl;
+
+}; // _WifiIpcProxy
+
+} } }
+#endif // _FNET_WIFI_INTERNAL_WIFI_IPC_PROXY_H_
diff --git a/src/wifi/FNetWifi_WifiManagerEvent.cpp b/src/wifi/FNetWifi_WifiManagerEvent.cpp
new file mode 100644 (file)
index 0000000..9c21c1a
--- /dev/null
@@ -0,0 +1,147 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file        FNetWifi_WifiManagerEvent.cpp
+ * @brief       This is the implementation file for the _WifiManagerEvent Class
+ * @version     1.0
+ *
+ * This file contains the implementation of the _WifiManagerEvent Class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseColArrayList.h>
+#include <FBaseSysLog.h>
+#include <FBaseColAllElementsDeleter.h>
+#include <FNetWifiWifiBssInfo.h>
+#include "FNetWifi_WifiManagerEvent.h"
+#include "FNetWifi_WifiManagerEventArg.h"
+#include "FNetWifi_IWifiManagerEventListener.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+_WifiManagerEvent::_WifiManagerEvent(void)
+{
+}
+
+_WifiManagerEvent::~_WifiManagerEvent(void)
+{
+}
+
+result
+_WifiManagerEvent::Construct(void)
+{
+       return _Event::Initialize();
+}
+
+void
+_WifiManagerEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+       result r = E_SUCCESS;
+       IList* pBssInfoList = null;
+
+       _IWifiManagerEventListener* pEventListener = dynamic_cast<_IWifiManagerEventListener*>(&listener);
+       SysTryReturnVoidResult(NID_NET_WIFI, pEventListener != null, E_INVALID_ARG, "[E_INVALID_ARG] Listener argument is invalid.");
+
+       const _WifiManagerEventArg* pEventArg = dynamic_cast<const _WifiManagerEventArg*>(&arg);
+       SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_INVALID_ARG, "[E_INVALID_ARG] Event argument type is invalid.");
+
+       _WifiManagerEventType eventType = pEventArg->GetEventType();
+       r = pEventArg->GetError();
+
+       switch (eventType)
+       {
+       case _WIFI_EVENT_ACTIVATED:
+               SysLog(NID_NET_WIFI, "Firing Wi-Fi Manager Event (Type: _WIFI_EVENT_ACTIVATED)");
+               pEventListener->OnWifiActivated(r);
+               break;
+       case _WIFI_EVENT_DEACTIVATED:
+               SysLog(NID_NET_WIFI, "Firing Wi-Fi Manager Event (Type: _WIFI_EVENT_DEACTIVATED)");
+               pEventListener->OnWifiDeactivated(r);
+               break;
+       case _WIFI_EVENT_CONNECTED:
+               SysLog(NID_NET_WIFI, "Firing Wi-Fi Manager Event (Type: _WIFI_EVENT_CONNECTED)");
+               pEventListener->OnWifiConnected(pEventArg->GetSsid(), r);
+               break;
+       case _WIFI_EVENT_DISCONNECTED:
+               SysLog(NID_NET_WIFI, "Firing Wi-Fi Manager Event (Type: _WIFI_EVENT_DISCONNECTED)");
+               pEventListener->OnWifiDisconnected();
+               break;
+       case _WIFI_EVENT_RSSI_CHANGED:
+               SysLog(NID_NET_WIFI, "Firing Wi-Fi Manager Event (Type: _WIFI_EVENT_RSSI_CHANGED)");
+               pEventListener->OnWifiRssiChanged(pEventArg->GetRssi());
+               break;
+       case _WIFI_EVENT_SCAN_COMPLETED:
+               SysLog(NID_NET_WIFI, "Firing Wi-Fi Manager Event (Type: _WIFI_EVENT_SCAN_COMPLETED)");
+               pBssInfoList = GetWifiBssInfoListCloneN(pEventArg->GetBssInfoList());
+               r = GetLastResult();
+               pEventListener->OnWifiScanCompletedN(pBssInfoList, r);
+               break;
+       case _WIFI_EVENT_CONNECTION_CHNAGED:
+               SysLog(NID_NET_WIFI, "Firing Wi-Fi Manager Event (Type: _WIFI_EVENT_CONNECTION_CHNAGED)");
+               pEventListener->OnWifiConnectionStateChanged(pEventArg->GetConnectionState());
+               break;
+       case _WIFI_EVENT_SCAN_UPDATED:
+               SysLog(NID_NET_WIFI, "Firing Wi-Fi Manager Event (Type: _WIFI_EVENT_SCAN_UPDATED)");
+               pEventListener->OnWifiSystemScanResultUpdated();
+               break;
+       default:
+               break;
+       }
+}
+
+Tizen::Base::Collection::IList*
+_WifiManagerEvent::GetWifiBssInfoListCloneN(const Tizen::Base::Collection::IList* pSrcList)
+{
+       result r = E_SUCCESS;
+       unique_ptr<ArrayList, AllElementsDeleter> pDescList;
+       int count = 0;
+
+       SysTryReturn(NID_NET_WIFI, pSrcList != null, null, E_FAILURE, "[E_FAILURE] Failed to get the BSS info list.");
+
+       count = pSrcList->GetCount();
+
+       pDescList.reset(new (std::nothrow) ArrayList(SingleObjectDeleter));
+       SysTryReturn(NID_NET_WIFI, pDescList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       r = pDescList->Construct(count);
+       r = TransExceptionsExclusive(r, E_FAILURE, E_OUT_OF_MEMORY);
+       SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Failed to construct a new BSS info list.", GetErrorMessage(r));
+
+       for (int i = 0; i < count; i++)
+       {
+               const WifiBssInfo* pSrcBssInfo = dynamic_cast<const WifiBssInfo*>(pSrcList->GetAt(i));
+               SysTryReturn(NID_NET_WIFI, pSrcBssInfo != null, null, E_FAILURE, "[E_FAILURE] Failed to get the BSS Info for the list.");
+
+               WifiBssInfo* pDescBssInfo = new (std::nothrow) WifiBssInfo(*pSrcBssInfo);
+               SysTryReturn(NID_NET_WIFI, pDescBssInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               r = pDescList->Add(*pDescBssInfo);
+               r = TransExceptionsExclusive(r, E_FAILURE, E_OUT_OF_MEMORY);
+               SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Failed to add a new BSS info to the list.", GetErrorMessage(r));
+       }
+
+       return pDescList.release();
+}
+
+} } } //Tizen::Net::Wifi
+
diff --git a/src/wifi/FNetWifi_WifiManagerEvent.h b/src/wifi/FNetWifi_WifiManagerEvent.h
new file mode 100644 (file)
index 0000000..2c6585d
--- /dev/null
@@ -0,0 +1,103 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file        FNetWifi_WifiManagerEvent.h
+ * @brief       This is the header file for the _WifiManagerEvent Class.
+ * @version     1.0
+ *
+ * This header file contains declaration of the WlanAgentEvent Class.
+ * The _WifiManagerEvent class can call a method of a listener (I_WifiManagerEventListener object).
+ * So, when a WifiManager event is occurred, an application can handle it appropriately.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_MANAGER_EVENT_H_
+#define _FNET_WIFI_INTERNAL_WIFI_MANAGER_EVENT_H_
+
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Base { namespace Collection {
+class IList;
+} } }
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+/**
+ * @class   _WifiManagerEvent
+ * @brief   This class handles WifiManager events.
+ *
+ * @since   2.0
+ *
+ * When a WifiManager event occurs, the WlanAgentEvent object finds a I_WifiManagerEventListener object
+ * which is registered for the Device object and calls an appropriate method of the listener.
+ */
+class _WifiManagerEvent:
+    public Tizen::Base::Runtime::_Event
+{
+
+public:
+    /**
+     * 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.
+     */
+    _WifiManagerEvent(void);
+
+    /**
+     * This destructor overrides Tizen::Base::Runtime::_Event::~_Event().
+     */
+    virtual ~_WifiManagerEvent(void);
+
+    /**
+     * Initializes this instance.
+     */
+    result Construct(void);
+
+protected:
+    /**
+     * Checks the arg and finds out the type of event. After that this method calls appropriate pListener's method.
+     *
+     * @param[in]   listener       It is a event listener related to this WifiManager event.
+     * @param[in]   arg             It is an argument-like instance of WifiManager event retransmitted to the listener's method as an argument.
+     * @exception   E_SUCCESS       The method is successful.
+     * @exception   E_INVALID_ARG   The argument passed to a method contains an invalid value.@n
+     * @exception   E_INVALID_ARG   The argument passed to a method is @c null.
+     */
+    void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in]   rhs   An instance of %_WifiManagerEvent
+     */
+    _WifiManagerEvent(const _WifiManagerEvent& rhs);
+
+    /**
+    * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+    *
+    * @param[in]   rhs An instance of %_WifiManagerEvent
+    */
+    _WifiManagerEvent& operator=(const _WifiManagerEvent& rhs);
+
+    Tizen::Base::Collection::IList* GetWifiBssInfoListCloneN(const Tizen::Base::Collection::IList* pSrcList);
+
+}; // _WifiManagerEvent
+
+} } } // Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_MANAGER_EVENT_H_
diff --git a/src/wifi/FNetWifi_WifiManagerEventArg.cpp b/src/wifi/FNetWifi_WifiManagerEventArg.cpp
new file mode 100644 (file)
index 0000000..5b4e41d
--- /dev/null
@@ -0,0 +1,147 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiManagerEventArg.cpp
+ * @brief   This is the implementation file for the _WifiManagerEventArg Class
+ * @version 1.0
+ *
+ * This file contains the implementation of the _WifiManagerEventArg Class.
+ */
+
+#include <FBaseColArrayList.h>
+#include "FNetWifi_WifiManagerEventArg.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+
+// This is the class constructor for WIFI_EVENT_ACTIVATED and WIFI_EVENT_DEACTIVATED.
+_WifiManagerEventArg::_WifiManagerEventArg(_WifiManagerEventType eventType, result r)
+    : __eventType(eventType)
+    , __error(r)
+    , __rssi(-1)
+    , __ssid()
+    , __pBssInfoList(null)
+       , __connState(WIFI_CONN_STATE_NOT_CONNECTED)
+{
+}
+
+// This is the class constructor for WIFI_EVENT_RSSI_CHANGED.
+_WifiManagerEventArg::_WifiManagerEventArg(_WifiManagerEventType eventType, long rssi)
+    : __eventType(eventType)
+    , __error(E_SUCCESS)
+    , __rssi(rssi)
+    , __ssid()
+    , __pBssInfoList(null)
+       , __connState(WIFI_CONN_STATE_NOT_CONNECTED)
+{
+}
+
+// This is the class constructor for WIFI_EVENT_SCAN_COMPLETED.
+_WifiManagerEventArg::_WifiManagerEventArg(_WifiManagerEventType eventType, IList* pBssInfoList, result r)
+    : __eventType(eventType)
+    , __error(r)
+    , __rssi(-1)
+    , __ssid()
+    , __pBssInfoList(pBssInfoList)
+       , __connState(WIFI_CONN_STATE_NOT_CONNECTED)
+{
+}
+
+// This is the class constructor for WIFI_EVENT_CONNECTED
+_WifiManagerEventArg::_WifiManagerEventArg(_WifiManagerEventType eventType, Tizen::Base::String ssid, result r)
+       : __eventType(eventType)
+       , __error(r)
+       , __rssi(-1)
+       , __ssid(ssid)
+       , __pBssInfoList(null)
+       , __connState(WIFI_CONN_STATE_NOT_CONNECTED)
+{
+}
+
+// This is the class constructor for WIFI_EVENT_DISCONNECTED and WIFI_EVENT_SCAN_UPDATED.
+_WifiManagerEventArg::_WifiManagerEventArg(_WifiManagerEventType eventType)
+       : __eventType(eventType)
+       , __error(E_SUCCESS)
+       , __rssi(-1)
+       , __ssid()
+       , __pBssInfoList(null)
+       , __connState(WIFI_CONN_STATE_NOT_CONNECTED)
+{
+}
+
+// This is the class constructor for WIFI_EVENT_CONNECTION_CHNAGED.
+_WifiManagerEventArg::_WifiManagerEventArg(_WifiManagerEventType eventType, WifiConnectionState state)
+       : __eventType(eventType)
+       , __error(E_SUCCESS)
+       , __rssi(-1)
+       , __ssid()
+       , __pBssInfoList(null)
+       , __connState(state)
+{
+}
+
+_WifiManagerEventArg::~_WifiManagerEventArg(void)
+{
+       if (__pBssInfoList != null)
+       {
+               __pBssInfoList->RemoveAll(true);
+           delete __pBssInfoList;
+       }
+}
+
+_WifiManagerEventType
+_WifiManagerEventArg::GetEventType(void) const
+{
+    return __eventType;
+}
+
+result
+_WifiManagerEventArg::GetError(void) const
+{
+    return __error;
+}
+
+long
+_WifiManagerEventArg::GetRssi(void) const
+{
+    return __rssi;
+}
+
+Tizen::Base::String
+_WifiManagerEventArg::GetSsid(void) const
+{
+    return __ssid;
+}
+
+IList*
+_WifiManagerEventArg::GetBssInfoList(void) const
+{
+    return __pBssInfoList;
+}
+
+WifiConnectionState
+_WifiManagerEventArg::GetConnectionState(void) const
+{
+       return __connState;
+}
+
+} } } //Tizen::Net::Wifi
+
diff --git a/src/wifi/FNetWifi_WifiManagerEventArg.h b/src/wifi/FNetWifi_WifiManagerEventArg.h
new file mode 100644 (file)
index 0000000..fd01262
--- /dev/null
@@ -0,0 +1,178 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifiWifiManagerEventArg.h
+ * @brief   This is the header file for the _WifiManagerEventArg Class.
+ * @version 1.0
+ *
+ * This header file contains declaration of the _WifiManagerEventArg Class.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_MANAGER_EVENT_ARG_H_
+#define _FNET_WIFI_INTERNAL_WIFI_MANAGER_EVENT_ARG_H_
+
+#include <FBaseObject.h>
+#include <FBaseRtIEventArg.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+
+class IList;
+
+} } } // Tizen::Base::Collection
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+class WifiManager;
+
+/**
+ * @enum _WifiManagerEventType
+ * Enumeration type to specify the type of Wi-Fi events.
+ */
+enum _WifiManagerEventType
+{
+    _WIFI_EVENT_ACTIVATED,           //< Event which notifies activation of the local Wi-Fi device
+    _WIFI_EVENT_DEACTIVATED,         //< Event which notifies deactivation of the local Wi-Fi device
+    _WIFI_EVENT_CONNECTED,           //< Event which notifies connection of the local Wi-Fi device
+    _WIFI_EVENT_DISCONNECTED,        //< Event which notifies disconnection of the local Wi-Fi device
+    _WIFI_EVENT_RSSI_CHANGED,        //< Event which notifies updated RSSI value of the local Wi-Fi device
+    _WIFI_EVENT_SCAN_COMPLETED,      //< Event which notifies end of scan
+    _WIFI_EVENT_CONNECTION_CHNAGED,  //< Event which notifies that the current connection state is changed
+    _WIFI_EVENT_SCAN_UPDATED         //< Event which notifies that the result of background scan is updated
+};
+
+/**
+ * @class   _WifiManagerEventArg
+ * @brief   This class is used as an argument of methods of the IWifiManagerEventListener class.
+ *
+ * @since   2.0
+ *
+ * This class is used as an argument of IWifiManagerEventListener's methods.
+ * When a %WifiManager event occurs, the _WifiManagerEvent object finds a IWifiManagerEventListener object
+ * which is registered for the WifiManager object and calls an appropriate method of the listener.
+ * @see IWifiManagerEventListener for example codes
+ */
+class _WifiManagerEventArg:
+    public Tizen::Base::Runtime::IEventArg,
+    public Tizen::Base::Object
+{
+public:
+       /**
+        * This is the class constructor for WIFI_EVENT_ACTIVATED and WIFI_EVENT_DEACTIVATED.
+        */
+       _WifiManagerEventArg(_WifiManagerEventType eventType, result r);
+
+    /**
+     * This is the class constructor for WIFI_EVENT_CONNECTED
+     */
+    _WifiManagerEventArg(_WifiManagerEventType eventType, Tizen::Base::String ssid, result r);
+
+    /**
+     * This is the class constructor for WIFI_EVENT_RSSI_CHANGED.
+     */
+    _WifiManagerEventArg(_WifiManagerEventType eventType, long rssi);
+
+    /**
+     * This is the class constructor for WIFI_EVENT_SCAN_COMPLETED.
+     */
+    _WifiManagerEventArg(_WifiManagerEventType eventType, Tizen::Base::Collection::IList* pBssInfoList, result r);
+
+    /**
+     * This is the class constructor for WIFI_EVENT_DISCONNECTED and WIFI_EVENT_SCAN_UPDATED.
+     */
+    _WifiManagerEventArg(_WifiManagerEventType eventType);
+
+    /**
+     * This is the class constructor for WIFI_EVENT_CONNECTION_CHNAGED.
+     */
+    _WifiManagerEventArg(_WifiManagerEventType eventType, WifiConnectionState state);
+
+    /**
+     * This destructor overrides Tizen::Base::Object::~Object().
+     */
+    virtual ~_WifiManagerEventArg(void);
+
+public:
+    /**
+     * @brief   Gets the event type.
+     * @return  WifiManagerEventType    Event type of this argument.
+     * @see     WifiManagerEventType
+     */
+    _WifiManagerEventType GetEventType(void) const;
+
+    /**
+     * @brief   Gets the error code.
+     * @return  WifiManagerError        Error code of this argument.
+     * @see     WifiManagerError
+     */
+    result GetError(void) const;
+
+    /**
+     * @brief   Gets the RSSI value.
+     * @return  long                    RSSI value of this argument.
+     */
+    long GetRssi(void) const;
+
+    /**
+     * @brief   Gets the Ssid.
+     * @return  String                  SSID value of this argument.
+     */
+    Tizen::Base::String GetSsid(void) const;
+
+    /**
+     * @brief       Gets the list of scanned BSS.
+     * @return      ArrayList           Pointer to the ArrayList object which contains information of scanned BSS.
+     */
+    Tizen::Base::Collection::IList* GetBssInfoList(void) const;
+
+    /**
+     * @brief       Gets the connection states of the local device.
+     */
+    WifiConnectionState GetConnectionState(void) const;
+
+private:
+    /**
+     * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in]   rhs        An instance of %_WifiManagerEventArg
+     */
+    _WifiManagerEventArg(const _WifiManagerEventArg& rhs);
+
+    /**
+     * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+     *
+     * @param[in]   rhs  An instance of %_WifiManagerEventArg
+     */
+    _WifiManagerEventArg& operator =(const _WifiManagerEventArg& rhs);
+
+private:
+    _WifiManagerEventType __eventType;
+    result __error;
+    long __rssi;
+    Tizen::Base::String __ssid;
+    Tizen::Base::Collection::IList* __pBssInfoList;
+    WifiConnectionState __connState;
+
+}; // _WifiManagerEventArg
+
+} } } // Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_MANAGER_EVENT_ARG_H_
+
diff --git a/src/wifi/FNetWifi_WifiManagerImpl.cpp b/src/wifi/FNetWifi_WifiManagerImpl.cpp
new file mode 100644 (file)
index 0000000..4253ff0
--- /dev/null
@@ -0,0 +1,889 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiManagerImpl.cpp
+ * @brief   This is the implementation file for the _WifiManagerImpl Class.
+ * @version 1.0
+ *
+ * This file contains the implementation of the _WifiManagerImpl Class.
+ */
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FNetWifiWifiManager.h>
+#include <FNetWifiWifiBssInfo.h>
+#include <FNetWifiIWifiManagerEventListener.h>
+#include <FNetWifiIWifiSystemMonitoringEventListener.h>
+#include "FNetWifi_WifiManagerImpl.h"
+#include "FNetWifi_WifiSystemAdapter.h"
+#include "FNetWifi_WifiIpcProxy.h"
+#include "FNetWifi_WifiSystemMonitoringEvent.h"
+#include "FNetWifi_WifiSystemMonitoringEventArg.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+_WifiManagerImpl::_WifiManagerImpl(void)
+    : __pWifiSystemAdapter(null)
+       , __pMonitoringEvt(null)
+    , __pManagerEvtListener(null)
+    , __pTargetApInfo(null)
+       , __stateMutex()
+    , __currentState(WIFI_MANAGER_DEACTIVATED)
+    , __currentScanState(WIFI_SCAN_IDLE)
+    , __wasConnected(false)
+{
+}
+
+_WifiManagerImpl::~_WifiManagerImpl(void)
+{
+    __pWifiSystemAdapter->UnregisterManagerEventListener(*this);
+       delete __pMonitoringEvt;
+}
+
+result
+_WifiManagerImpl::Construct(IWifiManagerEventListener& listener)
+{
+    result r = E_SUCCESS;
+       unique_ptr<_WifiSystemMonitoringEvent> pMonitoringEvt;
+
+    SysAssertf(__pWifiSystemAdapter == null,
+                    "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+    pMonitoringEvt.reset(new (std::nothrow) _WifiSystemMonitoringEvent());
+       SysTryReturnResult(NID_NET_WIFI, pMonitoringEvt != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+       r = pMonitoringEvt->Construct();
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to construct the system monitoring event.");
+
+    r = __stateMutex.Create();
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to create mutex.");
+
+    __pWifiSystemAdapter = _WifiSystemAdapter::GetInstance();
+    SysTryReturnResult(NID_NET_WIFI, __pWifiSystemAdapter != null, E_OUT_OF_MEMORY, "Failed to get Wi-Fi System adapter instance");
+
+    __stateMutex.Acquire();
+
+    if (__pWifiSystemAdapter->IsActivated())
+    {
+        if (__pWifiSystemAdapter->IsConnected())
+        {
+            __currentState = WIFI_MANAGER_CONNECTED;
+            __wasConnected = true;
+        }
+        else
+        {
+            __currentState = WIFI_MANAGER_ACTIVATED;
+        }
+    }
+
+    __stateMutex.Release();
+
+    __pManagerEvtListener = &listener;
+    __pMonitoringEvt = pMonitoringEvt.release();
+    __pWifiSystemAdapter->RegisterManagerEventListener(*this);
+
+    return r;
+}
+
+result
+_WifiManagerImpl::Activate(void)
+{
+    result r = E_SUCCESS;
+
+    SysLog(NID_NET_WIFI, "Enter, [Current State : %s],[Scan State: %s]",
+        GetStringOfCurrentState(), GetStringOfCurrentScanState());
+
+    __stateMutex.Acquire();
+
+    switch (__currentState)
+    {
+    case WIFI_MANAGER_DEACTIVATED:
+        r = __pWifiSystemAdapter->Activate();
+        if (r == E_SUCCESS)
+        {
+               __currentState = WIFI_MANAGER_ACTIVATING;
+        }
+        else if (r == E_IN_PROGRESS)
+        {
+               __currentState = WIFI_MANAGER_ACTIVATING;
+               SysLog(NID_NET_WIFI, "SLP returned E_IN_PROGRESS, return E_SUCCESS (Same as 2.0)");
+               r = E_SUCCESS;
+        }
+        break;
+    case WIFI_MANAGER_ACTIVATING:
+        r = E_IN_PROGRESS;
+        break;
+    default:
+        r = E_INVALID_OPERATION;
+        break;
+    }
+
+    __stateMutex.Release();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] exception occurred on activating Wifi.", GetErrorMessage(r));
+    }
+
+    SysLog(NID_NET_WIFI, "Exit, [Current State : %s], [Scan State: %s], [Result : %s]",
+                            GetStringOfCurrentState(), GetStringOfCurrentScanState(), GetErrorMessage(r));
+
+    return r;
+}
+
+result
+_WifiManagerImpl::Deactivate(void)
+{
+    result r = E_SUCCESS;
+
+    SysLog(NID_NET_WIFI, "Enter, [Current State : %s], [Scan State: %s]",
+                        GetStringOfCurrentState(), GetStringOfCurrentScanState());
+
+    __stateMutex.Acquire();
+
+    switch (__currentState)
+    {
+    case WIFI_MANAGER_DEACTIVATED:
+    case WIFI_MANAGER_ACTIVATING:
+        r = E_INVALID_OPERATION;
+        break;
+    case WIFI_MANAGER_DEACTIVATING:
+        r = E_IN_PROGRESS;
+        break;
+    default:
+        r = __pWifiSystemAdapter->Deactivate();
+        if (r == E_SUCCESS)
+        {
+            __currentState = WIFI_MANAGER_DEACTIVATING;
+        }
+         else if (r == E_IN_PROGRESS)
+        {
+            __currentState = WIFI_MANAGER_DEACTIVATING;
+            SysLog(NID_NET_WIFI, "SLP returned E_IN_PROGRESS, return E_SUCCESS (Same as 2.0)");
+            r = E_SUCCESS;
+        }
+        break;
+    }
+
+    __stateMutex.Release();
+
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    SysLog(NID_NET_WIFI, "Exit, [Current State : %s], [Scan State: %s], [Result : %s]",
+                            GetStringOfCurrentState(), GetStringOfCurrentScanState(), GetErrorMessage(r));
+
+    return r;
+}
+
+WifiPowerStatus
+_WifiManagerImpl::GetPowerStatus(void) const
+{
+    WifiPowerStatus wifiPowerStatus = WIFI_POWER_STATUS_OFF;
+
+    if (__currentState != WIFI_MANAGER_DEACTIVATED)
+    {
+        wifiPowerStatus = WIFI_POWER_STATUS_ON;
+    }
+
+    return wifiPowerStatus;
+}
+
+String
+_WifiManagerImpl::GetMacAddress(void) const
+{
+    String macAddress(L"");
+
+    switch (__currentState)
+    {
+    case WIFI_MANAGER_DEACTIVATED:
+    case WIFI_MANAGER_ACTIVATING:
+        return macAddress;
+        break;
+    default:
+        macAddress = __pWifiSystemAdapter->GetMacAddress();
+        break;
+    }
+
+    return macAddress;
+}
+
+bool
+_WifiManagerImpl::IsActivated(void) const
+{
+    bool isActivated = false;
+
+    SysLog(NID_NET_WIFI, "Enter, [Current State : %s], [Scan State: %s]",
+                            GetStringOfCurrentState(), GetStringOfCurrentScanState());
+
+    if ((__currentState != WIFI_MANAGER_DEACTIVATED) && (__currentState != WIFI_MANAGER_ACTIVATING))
+    {
+        isActivated = true;
+    }
+    else
+    {
+        isActivated = false;
+    }
+
+    return isActivated;
+}
+
+bool
+_WifiManagerImpl::IsConnected(void) const
+{
+    bool isConnected = false;
+
+    SysLog(NID_NET_WIFI, "Enter, [Current State : %s], [Scan State: %s]",
+                            GetStringOfCurrentState(), GetStringOfCurrentScanState());
+
+    if (__currentState == WIFI_MANAGER_CONNECTED)
+    {
+        isConnected = true;
+    }
+    else
+    {
+        isConnected = false;
+    }
+
+    return isConnected;
+}
+
+result
+_WifiManagerImpl::Scan(void)
+{
+    result r = E_SUCCESS;
+
+    SysLog(NID_NET_WIFI, "Enter, [Current State : %s], [Scan State: %s]",
+                            GetStringOfCurrentState(), GetStringOfCurrentScanState());
+
+    __stateMutex.Acquire();
+
+    switch (__currentState)
+    {
+    case WIFI_MANAGER_DEACTIVATED:
+    case WIFI_MANAGER_ACTIVATING:
+    case WIFI_MANAGER_DEACTIVATING:
+        r = E_INVALID_STATE;
+        break;
+    default:
+        if (__currentScanState == WIFI_SCAN_IDLE)
+        {
+            r = __pWifiSystemAdapter->Scan();
+            if (r == E_SUCCESS)
+            {
+                __currentScanState = WIFI_SCAN_SCANNING;
+            }
+            else if (r == E_IN_PROGRESS)
+            {
+                SysLog(NID_NET_WIFI, "SLP returned E_IN_PROGRESS, return E_SUCCESS (Same as 2.0)");
+                __currentScanState = WIFI_SCAN_SCANNING;
+                r = E_SUCCESS;
+            }
+        }
+        else
+        {
+            r = E_SUCCESS;
+            SysLog(NID_NET_WIFI, "Current Scan request is not processed as scan is either in progress or canceling.");
+        }
+        break;
+    }
+
+    __stateMutex.Release();
+
+    if (IsFailed(r))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+    }
+
+    SysLog(NID_NET_WIFI, "Exit, [Current State : %s], [Scan State: %s], [Result : %s]",
+                            GetStringOfCurrentState(), GetStringOfCurrentScanState(), GetErrorMessage(r));
+    return r;
+}
+
+result
+_WifiManagerImpl::Connect(const WifiBssInfo& targetApInfo)
+{
+    result r = E_SUCCESS;
+
+    SysLog(NID_NET_WIFI, "Enter, [Current State : %s], [Scan State: %s]",
+                            GetStringOfCurrentState(), GetStringOfCurrentScanState());
+
+    __stateMutex.Acquire();
+
+    switch (__currentState)
+    {
+    case WIFI_MANAGER_DEACTIVATED:
+    case WIFI_MANAGER_ACTIVATING:
+    case WIFI_MANAGER_DEACTIVATING:
+        r = E_INVALID_STATE;
+        break;
+    case WIFI_MANAGER_ACTIVATED:
+    case WIFI_MANAGER_CONNECTED:
+        if (targetApInfo.GetBssType() != WIFI_BSS_TYPE_INFRASTRUCTURE)
+        {
+            r = E_INVALID_ARG;
+        }
+        else
+        {
+            r = __pWifiSystemAdapter->Connect(targetApInfo);
+            if (r == E_SUCCESS)
+            {
+                __currentState = WIFI_MANAGER_CONNECTING;
+            }
+        }
+        break;
+    case WIFI_MANAGER_CONNECTING:
+        r = E_IN_PROGRESS;
+        break;
+    }
+
+    __stateMutex.Release();
+
+   if (IsFailed(r))
+   {
+       SysLogException(NID_NET_WIFI, r, "[%s] Propagating.", GetErrorMessage(r));
+   }
+
+    SysLog(NID_NET_WIFI, "Exit, [Current State : %s], [Scan State: %s], [Result : %s]",
+                            GetStringOfCurrentState(), GetStringOfCurrentScanState(), GetErrorMessage(r));
+
+    return r;
+}
+
+result
+_WifiManagerImpl::SetWifiSystemScanMode(WifiSystemScanMode mode)
+{
+       result r = E_SUCCESS;
+       _WifiIpcProxy* pProxy = null;
+
+       pProxy = _WifiIpcProxy::GetInstance();
+    SysTryReturnResult(NID_NET_WIFI, pProxy != null, E_SYSTEM, "Failed to get _WifiIpcProxy instance.");
+
+    r = pProxy->SetWifiSystemScanMode(mode);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       return E_SUCCESS;
+}
+
+result
+_WifiManagerImpl::AddSystemMonitoringEventListener(IWifiSystemMonitoringEventListener& listener)
+{
+       result r = E_SUCCESS;
+       _WifiIpcProxy* pProxy = null;
+
+       pProxy = _WifiIpcProxy::GetInstance();
+    SysTryReturnResult(NID_NET_WIFI, pProxy != null, E_SYSTEM, "Failed to get _WifiIpcProxy instance.");
+
+    r = pProxy->CheckSystemSettingPrivilege();
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       // add the specified new IWifiSystemMonitoringEventListener instance to the _WifiSystemMonitoringEvent.
+       r = __pMonitoringEvt->AddListener(listener, true);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY, E_OBJ_ALREADY_EXIST);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to add the new listener.");
+
+       SysLog(NID_NET_WIFI, "Adding the new IWifiSystemMonitoringEventListener is successful.");
+
+       return E_SUCCESS;
+}
+
+result
+_WifiManagerImpl::RemoveSystemMonitoringEventListener(IWifiSystemMonitoringEventListener& listener)
+{
+       result r = E_SUCCESS;
+       _WifiIpcProxy* pProxy = null;
+
+       pProxy = _WifiIpcProxy::GetInstance();
+    SysTryReturnResult(NID_NET_WIFI, pProxy != null, E_SYSTEM, "Failed to get _WifiIpcProxy instance.");
+
+    r = pProxy->CheckSystemSettingPrivilege();
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       // remove the previous IWifiSystemMonitoringEventListener instance from the _WifiSystemMonitoringEvent.
+       r = __pMonitoringEvt->RemoveListener(listener);
+       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY, E_OBJ_NOT_FOUND);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to remove the previous listener.");
+
+       SysLog(NID_NET_WIFI, "Removing the previous IWifiSystemMonitoringEventListener is successful.");
+
+       return E_SUCCESS;
+}
+
+WifiConnectionState
+_WifiManagerImpl::GetConnectionState(void) const
+{
+    return __pWifiSystemAdapter->GetConnectionState();
+}
+
+WifiBssInfo*
+_WifiManagerImpl::GetConnectionTargetInfoN(void) const
+{
+    return __pWifiSystemAdapter->GetConnectionTargetInfoN();
+}
+
+result
+_WifiManagerImpl::UpdateBssInfo(const WifiBssInfo& bssInfo)
+{
+       result r = E_SUCCESS;
+       _WifiIpcProxy* pProxy = null;
+
+       pProxy = _WifiIpcProxy::GetInstance();
+       SysTryReturnResult(NID_NET_WIFI, pProxy != null, E_SYSTEM, "Failed to get _WifiIpcProxy instance.");
+
+       r = pProxy->UpdateBssInfo(bssInfo);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       return E_SUCCESS;
+}
+
+Tizen::Base::Collection::IList*
+_WifiManagerImpl::GetSystemScanResultN(void) const
+{
+    return __pWifiSystemAdapter->GetSystemScanResultN();
+}
+
+void
+_WifiManagerImpl::OnWifiActivated(result r)
+{
+    SysLog(NID_NET_WIFI, "Enter, [CurrentState:%s], [Scan State: %s], [result:%s]",
+                            GetStringOfCurrentState(), GetStringOfCurrentScanState(), GetErrorMessage(r));
+    bool isFired = false;
+
+    __stateMutex.Acquire();
+
+    switch (__currentState)
+    {
+    case WIFI_MANAGER_DEACTIVATED:
+        if (r == E_SUCCESS)
+        {
+            __currentState = WIFI_MANAGER_ACTIVATED;
+            isFired = true;
+        }
+        break;
+    case WIFI_MANAGER_ACTIVATING:
+        if (r == E_SUCCESS)
+        {
+            __currentState = WIFI_MANAGER_ACTIVATED;
+        }
+        else
+        {
+            __currentState = WIFI_MANAGER_DEACTIVATED;
+        }
+
+        isFired = true;
+        break;
+    default:
+        break;
+    }
+
+    __stateMutex.Release();
+
+    if (isFired)
+    {
+        __pManagerEvtListener->OnWifiActivated(r);
+    }
+
+    if ((isFired) && (IsFailed(r)))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] exception occurred on Wifi-activate callback.", GetErrorMessage(r));
+    }
+
+    SysLog(NID_NET_WIFI, "ExitPoint, [CurrentState:%s], [Scan State: %s], [result:%s], [ACTIVATED_Event:%s]",
+                   GetStringOfCurrentState(), GetStringOfCurrentScanState(), GetErrorMessage(r), isFired ? "Fired" : "NotFired");
+}
+
+void
+_WifiManagerImpl::OnWifiDeactivated(result r)
+{
+    SysLog(NID_NET_WIFI, "Enter, [CurrentState:%s], [Scan State: %s], [result:%s]",
+                            GetStringOfCurrentState(), GetStringOfCurrentScanState(), GetErrorMessage(r));
+    bool isFired = false;
+
+    __stateMutex.Acquire();
+
+    switch (__currentState)
+    {
+    case WIFI_MANAGER_DEACTIVATING:
+        if (r == E_SUCCESS)
+        {
+            __currentState = WIFI_MANAGER_DEACTIVATED;
+            __currentScanState = WIFI_SCAN_IDLE;
+        }
+        else
+        {
+            if (__pWifiSystemAdapter->IsConnected())
+            {
+                __currentState = WIFI_MANAGER_CONNECTED;
+            }
+            else
+            {
+                __currentState = WIFI_MANAGER_ACTIVATED;
+            }
+        }
+
+        isFired = true;
+        break;
+    case WIFI_MANAGER_ACTIVATED:
+    case WIFI_MANAGER_CONNECTING:
+    case WIFI_MANAGER_CONNECTED:
+    case WIFI_MANAGER_ACTIVATING:
+        if (r == E_SUCCESS)
+        {
+            __currentState = WIFI_MANAGER_DEACTIVATED;
+            __currentScanState = WIFI_SCAN_IDLE;
+            isFired = true;
+        }
+        break;
+    default:
+        break;
+    }
+
+    __stateMutex.Release();
+
+    if (r == E_SUCCESS)
+    {
+        __wasConnected = false;
+    }
+
+    if (isFired)
+    {
+        __pManagerEvtListener->OnWifiDeactivated(r);
+    }
+
+    if ((isFired) && (IsFailed(r)))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] exception occurred on Wifi-deactive callback.", GetErrorMessage(r));
+    }
+
+    SysLog(NID_NET_WIFI, "ExitPoint, [CurrentState:%s], [Scan State: %s] , [result:%s], [DEACTIVATED_Event:%s]",
+                    GetStringOfCurrentState(), GetStringOfCurrentScanState(), GetErrorMessage(r), isFired ? "Fired" :"NotFired");
+}
+
+void
+_WifiManagerImpl::OnWifiConnected(const Tizen::Base::String &ssid, result r)
+{
+    SysLog(NID_NET_WIFI, "Enter, [CurrentState:%s], [Scan State: %s] , [result:%s]",
+                            GetStringOfCurrentState(), GetStringOfCurrentScanState(), GetErrorMessage(r));
+    bool isFired = false;
+
+    __stateMutex.Acquire();
+
+    switch (__currentState)
+    {
+    case WIFI_MANAGER_DEACTIVATING:
+        if (r == E_SUCCESS)
+        {
+            __currentState = WIFI_MANAGER_CONNECTED;
+            __wasConnected = true;
+            isFired = true;
+        }
+        else
+        {
+            isFired = true;
+        }
+        break;
+    case WIFI_MANAGER_ACTIVATED:
+        if (r == E_SUCCESS)
+        {
+            __currentState = WIFI_MANAGER_CONNECTED;
+            __wasConnected = true;
+            isFired = true;
+        }
+        break;
+    case WIFI_MANAGER_CONNECTING:
+        if (r == E_SUCCESS)
+        {
+            __currentState = WIFI_MANAGER_CONNECTED;
+            __wasConnected = true;
+        }
+        else
+        {
+            __currentState = WIFI_MANAGER_ACTIVATED;
+        }
+
+        isFired = true;
+        break;
+    default:
+        break;
+    }
+
+    __stateMutex.Release();
+
+
+    if (isFired)
+    {
+        __pManagerEvtListener->OnWifiConnected(ssid, r);
+    }
+
+    if ((isFired) && (IsFailed(r)))
+    {
+        SysLogException(NID_NET_WIFI, r, "[%s] exception occurred on Wifi-connect callback.", GetErrorMessage(r));
+    }
+
+    SysLog(NID_NET_WIFI, "ExitPoint, [CurrentState:%s], [Scan State: %s] , [result:%s], [CONNECTED_Event:%s]",
+    GetStringOfCurrentState(), GetStringOfCurrentScanState(), GetErrorMessage(r), isFired ? "Fired" : "NotFired");
+}
+
+void
+_WifiManagerImpl::OnWifiDisconnected(void)
+{
+    SysLog(NID_NET_WIFI, "Enter, [CurrentState:%s], [Scan State: %s]", GetStringOfCurrentState(), GetStringOfCurrentScanState());
+    bool isFired = false;
+
+    __stateMutex.Acquire();
+    switch (__currentState)
+    {
+    case WIFI_MANAGER_DEACTIVATING:
+               if (__wasConnected == true)
+               {
+                       isFired = true;
+               }
+        break;
+
+    case WIFI_MANAGER_CONNECTING:
+               __currentState = WIFI_MANAGER_DEACTIVATED;
+               if (__wasConnected == true)
+               {
+                       isFired = true;
+               }
+        break;
+
+    case WIFI_MANAGER_CONNECTED:
+               __currentState = WIFI_MANAGER_ACTIVATED;
+               isFired = true;
+        break;
+    default:
+        break;
+    }
+    __stateMutex.Release();
+
+       __wasConnected = false;
+
+    if (isFired)
+    {
+        __pManagerEvtListener->OnWifiDisconnected();
+    }
+
+    SysLog(NID_NET_WIFI, "ExitPoint, [CurrentState:%s], [Scan State: %s], [DISCONNECTED_Event:%s]",
+               GetStringOfCurrentState(), GetStringOfCurrentScanState(), isFired ? "Fired" : "NotFired");
+}
+
+void
+_WifiManagerImpl::OnWifiRssiChanged(long rssi)
+{
+    SysLog(NID_NET_WIFI, "Enter, [CurrentState:%s], [Scan State: %s]",
+                            GetStringOfCurrentState(), GetStringOfCurrentScanState());
+    if (__currentState == WIFI_MANAGER_CONNECTED)
+    {
+            SysLog(NID_NET_WIFI, "[CurrentState:%s], [RSSI_CHANGED_Event:Fired]", GetStringOfCurrentState());
+            __pManagerEvtListener->OnWifiRssiChanged(rssi);
+    }
+    else
+    {
+        SysLog(NID_NET_WIFI, "[CurrentState:%s], [RSSI_CHANGED_Event:Not Fired]", GetStringOfCurrentState());
+    }
+}
+
+void
+_WifiManagerImpl::OnWifiScanCompletedN(Tizen::Base::Collection::IList* pWifiBssInfoList, result r)
+{
+    bool isFired = false;
+    SysLog(NID_NET_WIFI, "Enter, [CurrentState:%s], [Scan State: %s], [result:%s]",
+                            GetStringOfCurrentState(), GetStringOfCurrentScanState(), GetErrorMessage(r));
+
+    __stateMutex.Acquire();
+
+    if (__currentScanState == WIFI_SCAN_SCANNING)
+    {
+            isFired = true;
+            __currentScanState = WIFI_SCAN_IDLE;
+    }
+
+    __stateMutex.Release();
+
+    if (isFired == true)
+    {
+        __pManagerEvtListener->OnWifiScanCompletedN(pWifiBssInfoList, r);
+    }
+
+    SysLog(NID_NET_WIFI, "Exit, [CurrentState:%s], [Scan State: %s], [SCAN_COMPLETED_Event:%s]",
+                    GetStringOfCurrentState(), GetStringOfCurrentScanState(), isFired ? "Fired" : "Not Fired");
+}
+
+void
+_WifiManagerImpl::OnWifiConnectionStateChanged(WifiConnectionState state)
+{
+       SysLog(NID_NET_WIFI, "Enter, [CurrentState:%s], [Connection State: %s]",
+                                       GetStringOfCurrentState(), GetStringOfConnectionState(state));
+
+       _WifiSystemMonitoringEventArg* pArg = new (std::nothrow) _WifiSystemMonitoringEventArg(state);
+       SysTryReturnVoidResult(NID_NET_WIFI, pArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       __pMonitoringEvt->FireAsync(*pArg);
+
+    SysLog(NID_NET_WIFI, "Exit, [CurrentState:%s], [CONN_STATE_Event:Fired]", GetStringOfCurrentState());
+}
+
+void
+_WifiManagerImpl::OnWifiSystemScanResultUpdated(void)
+{
+       SysLog(NID_NET_WIFI, "Enter, [CurrentState:%s]", GetStringOfCurrentState());
+
+       _WifiSystemMonitoringEventArg* pArg = new (std::nothrow) _WifiSystemMonitoringEventArg();
+       SysTryReturnVoidResult(NID_NET_WIFI, pArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       __pMonitoringEvt->FireAsync(*pArg);
+
+    SysLog(NID_NET_WIFI, "Exit, [CurrentState:%s], [BACKSCAN_RESULT_Event:Fired]", GetStringOfCurrentState());
+}
+
+_WifiManagerImpl*
+_WifiManagerImpl::GetInstance(WifiManager& wifiManager)
+{
+    return wifiManager.__pWifiManagerImpl;
+}
+
+const _WifiManagerImpl*
+_WifiManagerImpl::GetInstance(const WifiManager& wifiManager)
+{
+    return wifiManager.__pWifiManagerImpl;
+}
+
+const char*
+_WifiManagerImpl::GetStringOfCurrentState(void) const
+{
+    const char* pStateString = null;
+
+    switch (__currentState)
+    {
+    case WIFI_MANAGER_DEACTIVATED:
+        pStateString = "__WIFI_MANAGER_DEACTIVATED";
+        break;
+    case WIFI_MANAGER_ACTIVATING:
+        pStateString = "__WIFI_MANAGER_ACTIVATING";
+        break;
+    case WIFI_MANAGER_DEACTIVATING:
+        pStateString = "__WIFI_MANAGER_DEACTIVATING";
+        break;
+    case WIFI_MANAGER_ACTIVATED:
+        pStateString = "__WIFI_MANAGER_ACTIVATED";
+        break;
+    case WIFI_MANAGER_CONNECTING:
+        pStateString = "__WIFI_MANAGER_CONNECTING";
+        break;
+    case WIFI_MANAGER_CONNECTED:
+        pStateString = "__WIFI_MANAGER_CONNECTED";
+        break;
+    default:
+        pStateString = "Unknown";
+        break;
+    }
+
+    return pStateString;
+}
+
+const char*
+_WifiManagerImpl::GetStringOfCurrentScanState(void) const
+{
+    const char* pStateString = null;
+
+    switch (__currentScanState)
+    {
+    case WIFI_SCAN_IDLE:
+        pStateString = "__WIFI_SCAN_IDLE";
+        break;
+    case WIFI_SCAN_SCANNING:
+        pStateString = "__WIFI_SCAN_SCANNING";
+        break;
+    case WIFI_SCAN_CANCELLING:
+        pStateString = "__WIFI_SCAN_CANCELLING";
+        break;
+    default:
+        pStateString = "Unknown";
+        break;
+    }
+
+    return pStateString;
+}
+
+const char*
+_WifiManagerImpl::GetStringOfConnectionState(WifiConnectionState state) const
+{
+    const char* pStateString = null;
+
+    switch (state)
+    {
+    case WIFI_CONN_STATE_NOT_CONNECTED:
+        pStateString = "IDLE";
+        break;
+    case WIFI_CONN_STATE_ASSOCIATING:
+        pStateString = "ASSOCIATING";
+        break;
+    case WIFI_CONN_STATE_CONFIGURING:
+        pStateString = "CONFIGURING";
+        break;
+    case WIFI_CONN_STATE_CONNECTED:
+        pStateString = "CONNECTED";
+        break;
+    default:
+        pStateString = "Unknown";
+        break;
+    }
+
+    return pStateString;
+}
+
+} } } // Tizen::Net::Wifi
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+_OSP_EXPORT_ result
+_WifiManagerImpl_Activate(void)
+{
+    Tizen::Net::Wifi::_WifiSystemAdapter* __pWifiSystemAdapter = Tizen::Net::Wifi::_WifiSystemAdapter::GetInstance();
+    SysTryReturnResult(NID_NET_WIFI, __pWifiSystemAdapter != null, E_OUT_OF_MEMORY, "Failed to get Wi-Fi System adapter instance");
+
+    return __pWifiSystemAdapter->Activate();
+}
+
+_OSP_EXPORT_ result
+_WifiManagerImpl_Deactivate(void)
+{
+    Tizen::Net::Wifi::_WifiSystemAdapter* __pWifiSystemAdapter = Tizen::Net::Wifi::_WifiSystemAdapter::GetInstance();
+    SysTryReturnResult(NID_NET_WIFI, __pWifiSystemAdapter != null, E_OUT_OF_MEMORY, "Failed to get Wi-Fi System adapter instance");
+
+    return __pWifiSystemAdapter->Deactivate();
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+
diff --git a/src/wifi/FNetWifi_WifiNetAccountInfoImpl.cpp b/src/wifi/FNetWifi_WifiNetAccountInfoImpl.cpp
new file mode 100644 (file)
index 0000000..13e7b8e
--- /dev/null
@@ -0,0 +1,245 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file   FNetWifi_WifiNetAccountInfoImpl.cpp
+ * @brief  This is the implementation file for the _WifiNetAccountInfoImpl
+ * @version     1.0
+ *
+ * This file contains the implementation of the _WifiNetAccountInfoImpl Class.
+ */
+#include <net_connection.h>
+#include <FOspConfig.h>
+#include <FNetWifiWifiNetAccountInfo.h>
+#include <FBaseSysLog.h>
+#include "FNet_NetExporter.h"
+#include "FNetWifi_WifiNetAccountInfoImpl.h"
+#include "FNetWifi_WifiSecurityInfoImpl.h"
+#include "FNetWifi_WifiUtility.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+_WifiNetAccountInfoImpl::_WifiNetAccountInfoImpl(void)
+    :__bssType(WIFI_BSS_TYPE_INFRASTRUCTURE)
+    ,__ssid("")
+    ,__bssid("")
+    ,__channel(WIFI_RADIO_CHANNEL_UNKNOWN)
+{
+
+}
+
+_WifiNetAccountInfoImpl::_WifiNetAccountInfoImpl(const _WifiNetAccountInfoImpl &value)
+    :__bssType(value.__bssType)
+    ,__ssid(value.__ssid)
+    ,__securityInfo(value.__securityInfo)
+    ,__bssid(value.__bssid)
+    ,__channel(value.__channel)
+{
+}
+
+_WifiNetAccountInfoImpl::~_WifiNetAccountInfoImpl(void)
+{
+}
+
+String
+_WifiNetAccountInfoImpl::GetBssId(void) const
+{
+    return __bssid;
+}
+
+String
+_WifiNetAccountInfoImpl::GetSsid(void) const
+{
+    return __ssid;
+}
+
+WifiBssType
+_WifiNetAccountInfoImpl::GetBssType(void) const
+{
+    return __bssType;
+}
+
+const WifiSecurityInfo*
+_WifiNetAccountInfoImpl::GetSecurityInfo(void) const
+{
+    return &__securityInfo;
+}
+
+WifiRadioChannel
+_WifiNetAccountInfoImpl::GetRadioChannel(void) const
+{
+    return __channel;
+}
+
+void
+_WifiNetAccountInfoImpl::SetBssId(String& bssid)
+{
+    __bssid = bssid;
+}
+
+void
+_WifiNetAccountInfoImpl::SetSsid(String& ssid)
+{
+    __ssid = ssid;
+}
+
+void
+_WifiNetAccountInfoImpl::SetBssType(WifiBssType bssType)
+{
+    __bssType = bssType;
+}
+
+void
+_WifiNetAccountInfoImpl::SetSecurityInfo(const WifiSecurityInfo& securityInfo)
+{
+    __securityInfo = securityInfo;
+}
+
+void
+_WifiNetAccountInfoImpl::SetRadioChannel(WifiRadioChannel channel)
+{
+    __channel = channel;
+}
+
+
+bool
+_WifiNetAccountInfoImpl::Equals(const Tizen::Base::Object& obj) const
+{
+    const _WifiNetAccountInfoImpl* pOther = dynamic_cast<const _WifiNetAccountInfoImpl*>(&obj);
+
+    if (pOther == null
+        || __bssType != pOther->__bssType
+        || __ssid != pOther->__ssid
+        || !__securityInfo.Equals(pOther->__securityInfo)
+        || __bssid != pOther->__bssid
+        || __channel != pOther->__channel)
+    {
+        return false;
+    }
+
+    return true;
+}
+int
+_WifiNetAccountInfoImpl::GetHashCode(void) const
+{
+    return __bssid.GetHashCode();
+}
+
+
+WifiNetAccountInfo*
+_WifiNetAccountInfoImpl::CreateWifiNetAccountInfoN(void* pProfileInfo)
+{
+       result r = E_SUCCESS;
+       WifiNetAccountInfo* pWifiNetAccountInfo = null;
+       _WifiNetAccountInfoImpl* pWifiNetAccountInfoImpl = null;
+    connection_profile_h profileHandle = static_cast<connection_profile_h>(pProfileInfo);
+
+    char *pSsid = null;
+    char *pBssid = null;
+    int radioChannel = 0;
+    connection_wifi_security_type_e secType = CONNECTION_WIFI_SECURITY_TYPE_NONE;
+    connection_wifi_encryption_type_e encType = CONNECTION_WIFI_ENCRYPTION_TYPE_NONE;
+       String ssid;
+       String bssid;
+
+       WifiBssType wifiBssType = WIFI_BSS_TYPE_INFRASTRUCTURE;
+       WifiRadioChannel wifiRadioChannel = WIFI_RADIO_CHANNEL_UNKNOWN;
+       WifiSecurityInfo securityInfo;
+       _WifiSecurityInfoImpl* pSecuInfoImpl = _WifiSecurityInfoImpl::GetInstance(securityInfo);
+
+       SysTryCatch(NID_NET_WIFI, pProfileInfo, , E_INVALID_ARG, "[E_INVALID_ARG] A profile is NULL.");
+
+       pWifiNetAccountInfo = new (std::nothrow) WifiNetAccountInfo();
+       SysTryCatch(NID_NET_WIFI, pWifiNetAccountInfo, , E_OUT_OF_MEMORY,
+                                    "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       pWifiNetAccountInfoImpl = _WifiNetAccountInfoImpl::GetInstance(*pWifiNetAccountInfo);
+       SysTryCatch(NID_NET_WIFI, pWifiNetAccountInfoImpl, , E_OUT_OF_MEMORY,
+                                   "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    connection_profile_get_wifi_essid(profileHandle, &pSsid);
+    SysTryCatch(NID_NET_WIFI, pSsid, , E_SYSTEM,
+                                   "[E_SYSTEM] connection_profile_get_wifi_essid failed.");
+       ssid = String(pSsid);
+    free(pSsid);
+
+    connection_profile_get_wifi_bssid(profileHandle, &pBssid);
+    SysTryCatch(NID_NET_WIFI, pBssid, , E_SYSTEM,
+                                   "[E_SYSTEM] connection_profile_get_wifi_essid failed.");
+
+       bssid = String(pBssid);
+    free(pBssid);
+
+       wifiBssType = WIFI_BSS_TYPE_INFRASTRUCTURE;
+    connection_profile_get_wifi_frequency(profileHandle, &radioChannel);
+
+       wifiRadioChannel = Tizen::Net::Wifi::_WifiUtility::ConvertRadioChannel(radioChannel);
+
+    connection_profile_get_wifi_security_type(profileHandle,&secType);
+    connection_profile_get_wifi_encryption_type(profileHandle,&encType);
+    pSecuInfoImpl->SetAuthenticationType(_WifiUtility::ConvertAuthType(static_cast <wifi_security_type_e>(secType), static_cast <wifi_encryption_type_e>(encType)));
+    pSecuInfoImpl->SetEncryptionType(_WifiUtility::ConvertEncryptionType(static_cast <wifi_encryption_type_e>(encType)));
+
+    pWifiNetAccountInfoImpl->SetSsid(ssid);
+    pWifiNetAccountInfoImpl->SetBssType(wifiBssType);
+    pWifiNetAccountInfoImpl->SetBssId(bssid);
+    pWifiNetAccountInfoImpl->SetRadioChannel(wifiRadioChannel);
+    pWifiNetAccountInfoImpl->SetSecurityInfo(securityInfo);
+
+       r = _NetExporter::InitializeNetAccountInfo(pWifiNetAccountInfo, pProfileInfo);
+
+       return pWifiNetAccountInfo;
+
+CATCH:
+       if (pWifiNetAccountInfo)
+       {
+               delete pWifiNetAccountInfo;
+       }
+
+       return null;
+}
+
+_WifiNetAccountInfoImpl*
+_WifiNetAccountInfoImpl::GetInstance(WifiNetAccountInfo& wifiNetAccountInfo)
+{
+    return wifiNetAccountInfo.__pWifiNetAccountInfoImpl;
+}
+
+const _WifiNetAccountInfoImpl*
+_WifiNetAccountInfoImpl::GetInstance(const WifiNetAccountInfo& wifiNetAccountInfo)
+{
+    return wifiNetAccountInfo.__pWifiNetAccountInfoImpl;
+}
+
+} } } // Tizen::Net::Wifi
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+_OSP_EXPORT_ Tizen::Net::Wifi::WifiNetAccountInfo*
+_WifiNetAccountInfoImpl_CreateWifiNetAccountInfoN(void* pProfileInfo)
+{
+       return Tizen::Net::Wifi::_WifiNetAccountInfoImpl::CreateWifiNetAccountInfoN(pProfileInfo);
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/wifi/FNetWifi_WifiProximityManagerImpl.cpp b/src/wifi/FNetWifi_WifiProximityManagerImpl.cpp
new file mode 100644 (file)
index 0000000..6ed6e70
--- /dev/null
@@ -0,0 +1,457 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiProximityManagerImpl.cpp
+ * @brief   This is the implementation file for the _WifiProximityManagerImpl Class.
+ * @version 3.0
+ *
+ * This file contains the implementation of the _WifiProximityManagerImpl Class.
+ */
+
+#include <pthread.h>
+#include <unique_ptr.h>
+#include <FBaseDataType.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FBaseColIListT.h>
+#include <FBaseColHashMapT.h>
+#include <FBaseColMultiHashMapT.h>
+#include <FBaseColIEnumeratorT.h>
+#include <FNetWifiWifiBssInfo.h>
+#include "FNetWifi_IWifiProximityEventListener.h"
+#include "FNetWifi_WifiProximityManagerImpl.h"
+#include "FNetWifi_WifiIpcProxy.h"
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+
+/*
+ * @class   _StringComparer
+ * @brief   The _StringComparer class provides the comparer about two specified String.
+ */
+class _StringComparer
+       : public Tizen::Base::Collection::IComparerT <Tizen::Base::String>
+       , public Tizen::Base::Object
+{
+public:
+       _StringComparer(void) {}
+       virtual ~_StringComparer(void) {}
+
+       virtual result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const
+       {
+               cmp = obj1.CompareTo(obj2);
+               return E_SUCCESS;
+       }
+
+private:
+       _StringComparer(const _StringComparer& value);
+       _StringComparer& operator =(const _StringComparer& value);
+
+};     //_StringComparer
+
+/*
+ * @class   _StringHashCodeProvider
+ * @brief   The _StringHashCodeProvider class provides the hash code of a specified String.
+ */
+class _StringHashCodeProvider
+       : public Tizen::Base::Collection::IHashCodeProviderT <Tizen::Base::String>
+{
+public:
+       _StringHashCodeProvider(void) {}
+       virtual ~_StringHashCodeProvider(void) {}
+       virtual int GetHashCode(const Tizen::Base::String& obj) const
+       {
+               return obj.GetHashCode();
+       }
+
+private:
+       _StringHashCodeProvider(const _StringHashCodeProvider& value);
+       _StringHashCodeProvider& operator =(const _StringHashCodeProvider& value);
+
+};     //_StringHashCodeProvider
+
+_WifiProximityManagerImpl* _WifiProximityManagerImpl::__pWifiProximityManagerImpl = null;
+
+_WifiProximityManagerImpl*
+_WifiProximityManagerImpl::GetInstance(void)
+{
+    static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+    if (!__pWifiProximityManagerImpl)
+    {
+        ClearLastResult();
+        pthread_once(&onceBlock, InitSingleton);
+
+        result r = GetLastResult();
+
+        if (IsFailed(r))
+        {
+             onceBlock = PTHREAD_ONCE_INIT;
+        }
+    }
+
+    return __pWifiProximityManagerImpl;
+}
+
+void
+_WifiProximityManagerImpl::InitSingleton(void)
+{
+    result r = E_SUCCESS;
+
+    unique_ptr<_WifiProximityManagerImpl> pInst(new (std::nothrow) _WifiProximityManagerImpl());
+    SysTryReturnVoidResult(NID_NET_WIFI, pInst != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    r = pInst->Construct();
+    SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r, "[%s] Construct() of the singleton has failed.", GetErrorMessage(r));
+
+    __pWifiProximityManagerImpl = pInst.release();
+    std::atexit(DestroySingleton);
+}
+
+void
+_WifiProximityManagerImpl::DestroySingleton(void)
+{
+    delete __pWifiProximityManagerImpl;
+}
+
+_WifiProximityManagerImpl::_WifiProximityManagerImpl(void)
+       : __pListenerStateMap(null)
+       , __pWifiServiceProxy(null)
+{
+}
+
+_WifiProximityManagerImpl::~_WifiProximityManagerImpl(void)
+{
+       delete __pListenerStateMap;
+       delete __pBssListenerMap;
+}
+
+result
+_WifiProximityManagerImpl::Construct(void)
+{
+       result r = E_SUCCESS;
+       unique_ptr< HashMapT<_IWifiProximityEventListener*, bool> > pTempMap;
+       unique_ptr< MultiHashMapT<String, _IWifiProximityEventListener*> > pTempMultiMap;
+       static _StringHashCodeProvider strHashCodeProvider;
+       static _StringComparer strComparer;
+
+       pTempMap.reset(new (std::nothrow) HashMapT<_IWifiProximityEventListener*, bool>());
+       SysTryReturnResult(NID_NET_WIFI, pTempMap != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pTempMap->Construct();
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Construct of the listener hash map has failed.");
+
+       pTempMultiMap.reset(new (std::nothrow) MultiHashMapT<String, _IWifiProximityEventListener*>());
+       SysTryReturnResult(NID_NET_WIFI, pTempMultiMap != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+       r = pTempMultiMap->Construct(16, 0.75f, strHashCodeProvider, strComparer);
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Construct of the listener hash map has failed.");
+
+    __pWifiServiceProxy = _WifiIpcProxy::GetInstance();
+    SysTryReturnResult(NID_NET_WIFI, __pWifiServiceProxy != null, E_SYSTEM, "Getting WifiIpcProxy instance has failed.");
+
+    __pWifiServiceProxy->SetWifiProximityManagerImpl(*this);
+
+    __pListenerStateMap = pTempMap.release();
+    __pBssListenerMap = pTempMultiMap.release();
+
+       return r;
+}
+
+result
+_WifiProximityManagerImpl::AddProximityEventListener(_IWifiProximityEventListener& listener, const Tizen::Base::String& bssId)
+{
+       result r = E_SUCCESS;
+       bool contains = false;
+
+       // register the listener with an empty string as the BSS ID
+       if (bssId.GetLength() == 0)
+       {
+               contains = __pListenerStateMap->ContainsValue(true);
+               // the specified listener is the first listener in this process when it comes to an empty string.
+               if (!contains)
+               {
+                       r = __pWifiServiceProxy->RegisterBssId(L"");
+                       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+                       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r,
+                                       "Registering the listener regardless of BSS ID to IPC instance has failed.");
+               }
+
+               __pListenerStateMap->ContainsKey(&listener, contains);
+               if (contains)
+               {
+                       bool isDefault = false;
+
+                       __pListenerStateMap->GetValue(&listener, isDefault);
+                       SysTryReturnResult(NID_NET_WIFI, isDefault == false, E_OBJ_ALREADY_EXIST, "The listener was already registered.");
+
+                       __pListenerStateMap->SetValue(&listener, true);
+               }
+               else
+               {
+                       r = __pListenerStateMap->Add(&listener, true);
+                       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+                       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating. Internal map error.");
+               }
+       }
+       // register the listener with the specified BSS ID (not an empty string)
+       else
+       {
+               __pBssListenerMap->ContainsKey(bssId, contains);
+               if (!contains)
+               {
+                       r = __pWifiServiceProxy->RegisterBssId(bssId);
+                       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+                       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r,
+                                       "Registering BSS ID and listener to IPC instance has failed.");
+               }
+
+               r = __pBssListenerMap->Add(bssId, &listener);
+               r = TransExceptionsExclusive(r, E_SYSTEM, E_OBJ_ALREADY_EXIST, E_OUT_OF_MEMORY);
+               SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating. Internal map error.");
+
+               __pListenerStateMap->ContainsKey(&listener, contains);
+               if (!contains)
+               {
+                       r = __pListenerStateMap->Add(&listener, false);
+                       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+                       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating. Internal map error.");
+               }
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_WifiProximityManagerImpl::RemoveProximityEventListener(_IWifiProximityEventListener& listener, const Tizen::Base::String& bssId)
+{
+       result r = E_SUCCESS;
+       bool contains = false;
+
+       // unregister the listener with an empty string as the BSS ID
+       if (bssId.GetLength() == 0)
+       {
+               __pListenerStateMap->ContainsKey(&listener, contains);
+               SysTryReturnResult(NID_NET_WIFI, contains == true, E_OBJ_NOT_FOUND, "The listener was not registered.");
+
+               __pListenerStateMap->Remove(&listener);
+
+               unique_ptr< IMapEnumeratorT<String, _IWifiProximityEventListener*> > pMapEnum(__pBssListenerMap->GetMapEnumeratorN());
+               SysTryReturnResult(NID_NET_WIFI, pMapEnum != null, E_OUT_OF_MEMORY, "Propagating. Internal map error.");
+
+               while(pMapEnum->MoveNext() == E_SUCCESS)
+               {
+                       String regBssId;
+                       _IWifiProximityEventListener* pRegListener = null;
+
+                       r = pMapEnum->GetKey(regBssId);
+                       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+                       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Internal map error.");
+
+                       r = pMapEnum->GetValue(pRegListener);
+                       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+                       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Internal map error.");
+
+                       if (pRegListener == &listener)
+                       {
+                               __pBssListenerMap->Remove(regBssId, pRegListener);
+                               SysLog(NID_NET_WIFI, "BSS(ID:%d) is removed from the internal map.", regBssId.GetPointer());
+
+                               __pBssListenerMap->ContainsKey(regBssId, contains);
+                               if (!contains)
+                               {
+                                       r = __pWifiServiceProxy->UnRegisterBssId(regBssId);
+                                       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+                                       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r,
+                                                       "Unregistering BSS ID and listener to IPC instance has failed.");
+                               }
+                       }
+               }
+
+               contains = __pListenerStateMap->ContainsValue(true);
+               // the specified listener is the last listener in this process when it comes to an empty string.
+               if (!contains)
+               {
+                       r = __pWifiServiceProxy->UnRegisterBssId(L"");
+                       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+                       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r,
+                                       "Unregistering the listener regardless of BSS ID to IPC instance has failed.");
+               }
+       }
+       // unregister the listener with the specified BSS ID (not an empty string)
+       else
+       {
+               r = __pBssListenerMap->Remove(bssId, &listener);
+               r = TransExceptionsExclusive(r, E_SYSTEM, E_OBJ_NOT_FOUND);
+               SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+               SysLog(NID_NET_WIFI, "BSS(ID:%d) is removed from the internal map.", bssId.GetPointer());
+
+               __pBssListenerMap->ContainsKey(bssId, contains);
+               if (!contains)
+               {
+                       r = __pWifiServiceProxy->UnRegisterBssId(bssId);
+                       r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+                       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r,
+                                       "Unregistering BSS ID and listener to IPC instance has failed.");
+               }
+
+               __pListenerStateMap->ContainsKey(&listener, contains);
+               if (contains)
+               {
+                       bool isDefault = false;
+
+                       __pListenerStateMap->GetValue(&listener, isDefault);
+                       if (!isDefault)
+                       {
+                               __pListenerStateMap->Remove(&listener);
+                       }
+               }
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_WifiProximityManagerImpl::ActivateProximityCheck(void)
+{
+       result r = E_SUCCESS;
+
+    r = __pWifiServiceProxy->ActivateProximityCheck();
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+result
+_WifiProximityManagerImpl::DeactivateProximityCheck(void)
+{
+       result r = E_SUCCESS;
+
+    r = __pWifiServiceProxy->DeactivateProximityCheck();
+       SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Propagating.");
+
+       return r;
+}
+
+bool
+_WifiProximityManagerImpl::IsProximityCheckActivated(void)
+{
+       bool isActivated = false;
+    result r = E_SUCCESS;
+
+    r = __pWifiServiceProxy->IsProximityCheckActivated(isActivated);
+       SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+
+    return isActivated;
+}
+
+void
+_WifiProximityManagerImpl::OnWifiBssDetected(const WifiBssInfo& wifiBssInfo)
+{
+       result r = E_SUCCESS;
+       unique_ptr< IEnumeratorT<_IWifiProximityEventListener*> > pValueEnum(__pBssListenerMap->GetValuesN(wifiBssInfo.GetBssId()));
+       SysTryReturnVoidResult(NID_NET_WIFI, pValueEnum != null, E_OUT_OF_MEMORY,
+                       "[E_OUT_OF_MEMORY] Propagating. Internal map error.");
+
+       while (pValueEnum->MoveNext() == E_SUCCESS)
+       {
+               _IWifiProximityEventListener* pListener = null;
+
+               r = pValueEnum->GetCurrent(pListener);
+               r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+               SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r, "[E_SYSTEM] Internal map error.");
+
+               pListener->OnWifiBssDetectedN(new WifiBssInfo(wifiBssInfo));
+       }
+}
+
+void
+_WifiProximityManagerImpl::OnWifiBssLost(const Tizen::Base::String& bssId)
+{
+       result r = E_SUCCESS;
+       unique_ptr< IEnumeratorT<_IWifiProximityEventListener*> > pValueEnum(__pBssListenerMap->GetValuesN(bssId));
+       SysTryReturnVoidResult(NID_NET_WIFI, pValueEnum != null, E_OUT_OF_MEMORY,
+                       "[E_OUT_OF_MEMORY] Propagating. Internal map error.");
+
+       while (pValueEnum->MoveNext() == E_SUCCESS)
+       {
+               _IWifiProximityEventListener* pListener = null;
+
+               r = pValueEnum->GetCurrent(pListener);
+               r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+               SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r, "[E_SYSTEM] Internal map error.");
+
+               pListener->OnWifiBssLost(bssId);
+       }
+}
+
+void
+_WifiProximityManagerImpl::OnWifiProximityCheckActivated()
+{
+       unique_ptr< IListT<_IWifiProximityEventListener*> > pListenerList;
+       int count = 0;
+
+       pListenerList.reset(__pListenerStateMap->GetKeysN());
+       SysTryReturnVoidResult(NID_NET_WIFI, pListenerList != null, E_OUT_OF_MEMORY,
+                       "[E_OUT_OF_MEMORY] Propagating. Internal map error.");
+       count = pListenerList->GetCount();
+
+       for (int i = 0; i < count; i++)
+       {
+               result r = E_SUCCESS;
+               _IWifiProximityEventListener* pListener = null;
+
+               r = pListenerList->GetAt(i, pListener);
+               r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+               SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r, "[E_SYSTEM] Internal map error.");
+
+               pListener->OnWifiProximityCheckActivated();
+       }
+}
+
+void
+_WifiProximityManagerImpl::OnWifiProximityCheckDeactivated()
+{
+       unique_ptr< IListT<_IWifiProximityEventListener*> > pListenerList;
+       int count = 0;
+
+       pListenerList.reset(__pListenerStateMap->GetKeysN());
+       SysTryReturnVoidResult(NID_NET_WIFI, pListenerList != null, E_OUT_OF_MEMORY,
+                       "[E_OUT_OF_MEMORY] Propagating. Internal map error.");
+       count = pListenerList->GetCount();
+
+       for (int i = 0; i < count; i++)
+       {
+               result r = E_SUCCESS;
+               _IWifiProximityEventListener* pListener = null;
+
+               r = pListenerList->GetAt(i, pListener);
+               r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+               SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r, "[E_SYSTEM] Internal map error.");
+
+               pListener->OnWifiProximityCheckDeactivated();
+       }
+}
+
+} } } // Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiSecurityInfoImpl.cpp b/src/wifi/FNetWifi_WifiSecurityInfoImpl.cpp
new file mode 100644 (file)
index 0000000..2ac4b64
--- /dev/null
@@ -0,0 +1,412 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiSecurityInfoImpl.cpp
+ * @brief   This is the implementation file for the _WifiSecurityInfoImpl Class
+ * @version 1.0
+ *
+ * This file contains the implementation of the _WifiSecurityInfoImpl Class.
+ */
+
+#include <FBaseUtilStringUtil.h>
+#include <FNetWifiWifiSecurityInfo.h>
+#include <FBaseSysLog.h>
+#include "FNetWifi_WifiSecurityInfoImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+_WifiSecurityInfoImpl::_WifiSecurityInfoImpl(void)
+    :__authenticationType(WIFI_AUTHENTICATION_MAX)
+    ,__encryptionType(WIFI_ENCRYPTION_MAX)
+{
+    memset(__aesKey.key, '\0', WIFI_AES_KEY_LENGTH+1);
+    memset(__tkipKey.key, '\0', WIFI_TKIP_KEY_LENGTH+1);
+    memset(__wepKey.key, '\0', WIFI_WEP_128BIT_KEY_LENGTH+1);
+    __wepKey.keyIndex = 1;
+    __wepKey.keyLen = WIFI_WEP_KEY_LEN_64BIT;
+    __eapInfo.eapType = WIFI_EAP_NONE;
+    __eapInfo.userId[0] = '\0';
+    __eapInfo.password[0] = '\0';
+    __eapInfo.validateCertificate = true;
+}
+
+_WifiSecurityInfoImpl::_WifiSecurityInfoImpl(const _WifiSecurityInfoImpl& value)
+    :__authenticationType(value.__authenticationType)
+    ,__encryptionType(value.__encryptionType)
+    ,__wepKey(value.__wepKey)
+    ,__aesKey(value.__aesKey)
+    ,__tkipKey(value.__tkipKey)
+    ,__eapInfo(value.__eapInfo)
+    ,__networkKey(value.__networkKey)
+{
+}
+
+_WifiSecurityInfoImpl::~_WifiSecurityInfoImpl(void)
+{
+}
+
+_WifiSecurityInfoImpl&
+_WifiSecurityInfoImpl::operator=(const _WifiSecurityInfoImpl& rhs)
+{
+    if ( this != &rhs )
+    {
+        __aesKey = rhs.__aesKey;
+        __authenticationType = rhs.__authenticationType;
+        __encryptionType = rhs.__encryptionType;
+        __tkipKey = rhs.__tkipKey;
+        __wepKey = rhs.__wepKey;
+        __eapInfo = rhs.__eapInfo;
+        __networkKey = rhs.__networkKey;
+    }
+
+    return *this;
+}
+
+WifiAuthenticationType
+_WifiSecurityInfoImpl::GetAuthenticationType(void) const
+{
+    return __authenticationType;
+}
+
+WifiEncryptionType
+_WifiSecurityInfoImpl::GetEncryptionType(void) const
+{
+    return __encryptionType;
+}
+
+result
+_WifiSecurityInfoImpl::SetNetworkKeyWep(WifiWepKeyLen keyLen, WifiWepKeyIndex keyIndex, const String& key)
+{
+    int len = 0;
+    result r = E_SUCCESS;
+    len = key.GetLength();
+    ByteBuffer* pKey = null;
+
+       if (keyLen == WIFI_WEP_KEY_LEN_64BIT)
+       {
+               if (len > WIFI_WEP_64BIT_KEY_LENGTH)
+               {
+                       r = E_INVALID_ARG;
+               }
+       }
+       else if (keyLen == WIFI_WEP_KEY_LEN_128BIT)
+       {
+               if (len > WIFI_WEP_128BIT_KEY_LENGTH)
+               {
+                       r = E_INVALID_ARG;
+               }
+       }
+       else
+       {
+               r = E_INVALID_ARG;
+       }
+
+       SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[E_INVALID_ARG] The length of key is invalid.");
+
+    pKey = StringUtil::StringToUtf8N(key);
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+    SysTryReturnResult(NID_NET_WIFI, pKey != null, r, "String to UTF-8 Conversion failed.");
+
+    __wepKey.keyLen = keyLen;
+
+    switch (keyIndex)
+    {
+    case WIFI_WEP_KEY_INDEX_1:
+        __wepKey.keyIndex = 1;
+        break;
+    case WIFI_WEP_KEY_INDEX_2:
+        __wepKey.keyIndex = 2;
+        break;
+    case WIFI_WEP_KEY_INDEX_3:
+        __wepKey.keyIndex = 3;
+        break;
+    case WIFI_WEP_KEY_INDEX_4:
+        __wepKey.keyIndex = 4;
+        break;
+    default:
+        delete pKey;
+        return E_INVALID_ARG;
+    }
+
+    r = pKey->GetArray(reinterpret_cast<byte*>(__wepKey.key), 0, len);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[E_SYSTEM] Getting the specified number of bytes from the ByteBuffer has failed.");
+    __wepKey.key[len] = '\0';
+
+    delete pKey;
+    return r;
+
+CATCH:
+    delete pKey;
+    return r;
+}
+
+result
+_WifiSecurityInfoImpl::SetNetworkKeyAes(const String& key)
+{
+    int len = 0;
+    result r = E_SUCCESS;
+    len = key.GetLength();
+    SysTryReturnResult(NID_NET_WIFI, len <= WIFI_AES_KEY_LENGTH, E_INVALID_ARG, "The length of key is invalid.");
+
+    ByteBuffer* pKey = null;
+    pKey = StringUtil::StringToUtf8N(key);
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+    SysTryReturnResult(NID_NET_WIFI, pKey != null, r, "String to UTF-8 Conversion failed.");
+
+    r = pKey->GetArray(reinterpret_cast<byte*>(__aesKey.key), 0, len);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[E_SYSTEM] Getting the specified number of bytes from the ByteBuffer has failed.");
+    __aesKey.key[len] = '\0';
+
+    delete pKey;
+
+    return r;
+
+CATCH:
+    delete pKey;
+    return r;
+}
+
+result
+_WifiSecurityInfoImpl::SetNetworkKeyTkip(const String& key)
+{
+    int len = 0;
+    result r = E_SUCCESS;
+    len = key.GetLength();
+    SysTryReturnResult(NID_NET_WIFI, len <= WIFI_TKIP_KEY_LENGTH, E_INVALID_ARG, "The length of key is invalid.");
+
+    ByteBuffer* pKey = null;
+    pKey = StringUtil::StringToUtf8N(key);
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+    SysTryReturnResult(NID_NET_WIFI, pKey != null, r, "String to UTF-8 Conversion failed.");
+
+    r = pKey->GetArray(reinterpret_cast<byte*>(__tkipKey.key), 0, len);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[E_SYSTEM] Getting the specified number of bytes from the ByteBuffer has failed.");
+    __tkipKey.key[len] = '\0';
+
+    delete pKey;
+
+    return r;
+
+CATCH:
+    delete pKey;
+    return r;
+}
+
+const unsigned char*
+_WifiSecurityInfoImpl::GetNetworkKeyWep(void) const
+{
+    return __wepKey.key;
+}
+
+const unsigned char*
+_WifiSecurityInfoImpl::GetNetworkKeyAes(void) const
+{
+    return __aesKey.key;
+}
+
+const unsigned char*
+_WifiSecurityInfoImpl::GetNetworkKeyTkip(void) const
+{
+    return __tkipKey.key;
+}
+
+result
+_WifiSecurityInfoImpl::SetEapMethodInfo(WifiEapType type, const Tizen::Base::String& userId, const Tizen::Base::String& password,
+                                            bool validateServerCertificate)
+{
+    int userIdLen = 0;
+    int passwordLen = 0;
+    result r = E_SUCCESS;
+    ByteBuffer* pUserIdByte = null;
+    ByteBuffer* pPasswordByte = null;
+
+    userIdLen = userId.GetLength();
+    passwordLen = password.GetLength();
+
+    // WIFI_EAP_TLS is not supported in v.1.2
+    SysTryReturnResult(NID_NET_WIFI, type != WIFI_EAP_TLS, E_UNSUPPORTED_TYPE,
+                        "EAP type is not supported, only supports WIFI_EAP_TLS.");
+    SysTryReturnResult(NID_NET_WIFI, (userIdLen <= WIFI_EAP_KEY_LENGTH) , E_INVALID_ARG, "User ID length should be lesser then 256 character.");
+    SysTryReturnResult(NID_NET_WIFI, (passwordLen <= WIFI_EAP_KEY_LENGTH) , E_INVALID_ARG, "Password length should be lesser then 256 character.");
+
+    pUserIdByte = StringUtil::StringToUtf8N(userId);
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+    SysTryCatch(NID_NET_WIFI, pUserIdByte != null, , r, "[%s] String to UTF-8 Conversion failed.", GetErrorMessage(r));
+
+    r = pUserIdByte->GetArray(reinterpret_cast<byte*>(__eapInfo.userId), 0, userIdLen);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[E_SYSTEM] Getting the specified number of bytes from the ByteBuffer has failed.");
+    __eapInfo.userId[userIdLen] = '\0';
+
+    pPasswordByte = StringUtil::StringToUtf8N(password);
+    r = TransExceptionsExclusive(r, E_SYSTEM, E_OUT_OF_MEMORY);
+    SysTryCatch(NID_NET_WIFI, pPasswordByte != null, , r, "[%s] String to UTF-8 Conversion failed.", GetErrorMessage(r));
+
+    r = pPasswordByte->GetArray(reinterpret_cast<byte*>(__eapInfo.password), 0, passwordLen);
+    SysTryCatch(NID_NET_WIFI, r == E_SUCCESS, , r, "[E_SYSTEM] Getting the specified number of bytes from the ByteBuffer has failed.");
+    __eapInfo.password[passwordLen] = '\0';
+
+    __eapInfo.eapType = type;
+    __eapInfo.validateCertificate = validateServerCertificate;
+
+    delete pUserIdByte;
+    delete pPasswordByte;
+
+    return E_SUCCESS;
+
+CATCH:
+    if (pUserIdByte)
+    {
+        delete pUserIdByte;
+        pUserIdByte = null;
+    }
+
+    if (pPasswordByte)
+    {
+        delete pPasswordByte;
+        pPasswordByte = null;
+    }
+
+    return r;
+}
+
+WifiEapType
+_WifiSecurityInfoImpl::GetEapType(void) const
+{
+    return __eapInfo.eapType;
+}
+
+const char*
+_WifiSecurityInfoImpl::GetEapUserId(void) const
+{
+    return __eapInfo.userId;
+}
+
+const char*
+_WifiSecurityInfoImpl::GetEapPassword(void) const
+{
+    return __eapInfo.password;
+}
+
+void
+_WifiSecurityInfoImpl::SetNetworkKey(const Tizen::Base::String& key)
+{
+    __networkKey = key;
+}
+
+void
+_WifiSecurityInfoImpl::SetAuthenticationType(WifiAuthenticationType authType)
+{
+    __authenticationType = authType;
+}
+
+Tizen::Base::String
+_WifiSecurityInfoImpl::GetNetworkKey(void) const
+{
+    return __networkKey;
+}
+
+void
+_WifiSecurityInfoImpl::SetEncryptionType(WifiEncryptionType encryptionType)
+{
+    __encryptionType = encryptionType;
+}
+
+bool
+_WifiSecurityInfoImpl::Equals(const Tizen::Base::Object& obj) const
+{
+    const _WifiSecurityInfoImpl* pOther = dynamic_cast<const _WifiSecurityInfoImpl*>(&obj);
+
+    if (pOther == null
+        || __authenticationType != pOther->__authenticationType
+        || __encryptionType != pOther->__encryptionType)
+    {
+        return false;
+    }
+
+    if (__authenticationType != WIFI_AUTHENTICATION_OPEN)
+    {
+        switch (__authenticationType)
+        {
+        case WIFI_AUTHENTICATION_SHARED:
+            if (__wepKey.keyIndex != pOther->__wepKey.keyIndex
+                || __wepKey.keyLen != pOther->__wepKey.keyLen)
+            {
+                return false;
+            }
+            break;
+        case WIFI_AUTHENTICATION_WPA_PSK:
+        case WIFI_AUTHENTICATION_WPA2_PSK:
+        case WIFI_AUTHENTICATION_WPA_WPA2_MIXED_PSK:
+            if (memcmp(&__aesKey.key, &pOther->__aesKey.key, sizeof(__aesKey.key)) != 0
+                || memcmp(&__tkipKey.key, &pOther->__tkipKey.key, sizeof(__tkipKey.key)) != 0)
+            {
+                return false;
+            }
+            break;
+        case WIFI_AUTHENTICATION_WPA:
+        case WIFI_AUTHENTICATION_WPA2:
+            if ( __eapInfo.eapType != pOther->__eapInfo.eapType
+                || memcmp(&__eapInfo.userId, &pOther->__eapInfo.userId, sizeof(__eapInfo.userId)) != 0
+                || memcmp(&__eapInfo.password, &pOther->__eapInfo.password, sizeof(__eapInfo.password)) != 0
+                || __eapInfo.validateCertificate != pOther->__eapInfo.validateCertificate)
+            {
+                return false;
+            }
+            break;
+        default:
+            break;
+        }
+    }
+
+    if (__networkKey != pOther->__networkKey)
+    {
+        return false;
+    }
+
+
+    return true;
+}
+
+int
+_WifiSecurityInfoImpl::GetHashCode(void) const
+{
+    static const int _HASH_CODE_INITIAL_VALUE = 17;
+    int hashCode = _HASH_CODE_INITIAL_VALUE;
+
+    hashCode = __authenticationType * __encryptionType;
+    hashCode ^= __networkKey.GetHashCode();
+
+    return hashCode;
+}
+
+_WifiSecurityInfoImpl*
+_WifiSecurityInfoImpl::GetInstance(WifiSecurityInfo& wifiSecurityInfo)
+{
+    return wifiSecurityInfo.__pWifiSecurityInfoImpl;
+}
+
+const _WifiSecurityInfoImpl*
+_WifiSecurityInfoImpl::GetInstance(const WifiSecurityInfo& wifiSecurityInfo)
+{
+    return wifiSecurityInfo.__pWifiSecurityInfoImpl;
+}
+} } } // Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiSystemAdapter.cpp b/src/wifi/FNetWifi_WifiSystemAdapter.cpp
new file mode 100644 (file)
index 0000000..c50bd25
--- /dev/null
@@ -0,0 +1,660 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file    FNetWifi_WifiSystemAdapter.cpp
+ * @brief   This is the implementation file for the _WifiSystemAdapter Class.
+ */
+#include <pthread.h>
+#include <FBaseUtilStringUtil.h>
+#include <FBaseSysLog.h>
+#include <FNetWifiWifiBssInfo.h>
+#include <FBase_StringConverter.h>
+#include "FNetWifi_WifiBssInfoImpl.h"
+#include "FNetWifi_WifiManagerEvent.h"
+#include "FNetWifi_WifiManagerEventArg.h"
+#include "FNetWifi_WifiManagerImpl.h"
+#include "FNetWifi_WifiSystemAdapter.h"
+#include "FNetWifi_WifiSecurityInfoImpl.h"
+#include "FNetWifi_WifiUtility.h"
+
+#ifdef _WifiConvertErrorResult
+#undef _WifiConvertErrorResult
+#endif
+#define _WifiConvertErrorResult(condition, r, value) \
+               do \
+               { \
+                       if (condition) {   \
+                               r = value; \
+                       } \
+               } while (0);
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+static _WifiSystemAdapter* pInstance = null;
+
+_WifiSystemAdapter::_WifiSystemAdapter(void)
+       : __pWifiManagerEvent()
+       , __pBssInfo(null)
+{
+}
+
+_WifiSystemAdapter::~_WifiSystemAdapter(void)
+{
+    int err = WIFI_ERROR_NONE;
+
+    wifi_unset_connection_state_changed_cb();
+    wifi_unset_device_state_changed_cb();
+    wifi_unset_rssi_level_changed_cb();
+    wifi_unset_background_scan_cb();
+
+    err = wifi_deinitialize();
+    if (err != WIFI_ERROR_NONE)
+    {
+       SysLogException(NID_NET_WIFI, E_SYSTEM, "[E_SYSTEM] Failed to de-initialize the wifi manager [0x%08X]", err);
+    }
+
+    pInstance = null;
+}
+
+result
+_WifiSystemAdapter::Construct(void)
+{
+    __pWifiManagerEvent.reset(new (std::nothrow) _WifiManagerEvent());
+    SysTryReturnResult(NID_NET_WIFI, __pWifiManagerEvent != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+    result r = __pWifiManagerEvent->Construct();
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to construct event");
+
+    int err = WIFI_ERROR_NONE;
+
+    err = wifi_initialize();
+    SysTryReturnResult(NID_NET_WIFI, err == WIFI_ERROR_NONE, E_SYSTEM, "Failed to wifi_initialize()");
+
+    err = wifi_set_device_state_changed_cb(OnWifiDeviceStateChanged, __pWifiManagerEvent.get());
+    SysTryReturnResult(NID_NET_WIFI, err == WIFI_ERROR_NONE, E_SYSTEM, "Failed to wifi_set_device_state_changed_cb()");
+
+    err = wifi_set_connection_state_changed_cb(OnWifiConnectionStateChanged, __pWifiManagerEvent.get());
+    SysTryReturnResult(NID_NET_WIFI, err == WIFI_ERROR_NONE, E_SYSTEM, "Failed to wifi_set_connection_state_changed_cb()");
+
+    err = wifi_set_rssi_level_changed_cb(OnWifiRssiLevelChanged, __pWifiManagerEvent.get());
+    SysTryReturnResult(NID_NET_WIFI, err == WIFI_ERROR_NONE, E_SYSTEM, "Failed to wifi_set_rssi_level_changed_cb()");
+
+    err = wifi_set_background_scan_cb(OnWifiBackgroundScanResultUpdated, __pWifiManagerEvent.get());
+    SysTryReturnResult(NID_NET_WIFI, err == WIFI_ERROR_NONE, E_SYSTEM, "Failed to wifi_set_background_scan_cb()");
+
+    return E_SUCCESS;
+}
+
+void
+_WifiSystemAdapter::InitSingleton(void)
+{
+    result r = E_SUCCESS;
+    unique_ptr<_WifiSystemAdapter> pInst(new (std::nothrow) _WifiSystemAdapter());
+    
+    SysTryReturnVoidResult(NID_NET_WIFI, pInst != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    r = pInst->Construct();
+    SysTryReturnVoidResult(NID_NET_WIFI, r == E_SUCCESS, r, "[%s] Error occurred in construct.", GetErrorMessage(r));
+
+    pInstance = pInst.release();
+
+    std::atexit(DestroySingleton);
+}
+
+void 
+_WifiSystemAdapter::DestroySingleton(void)
+{
+    delete pInstance;
+}
+
+_WifiSystemAdapter*
+_WifiSystemAdapter::GetInstance(void)
+{
+       static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+       if (!pInstance)
+       {
+               ClearLastResult();
+               pthread_once(&onceBlock, InitSingleton);
+
+               result r = GetLastResult();
+               if (IsFailed(r))
+               {
+                       onceBlock = PTHREAD_ONCE_INIT;
+               }
+       }
+
+       return pInstance;
+}
+
+result
+_WifiSystemAdapter::RegisterManagerEventListener(_IWifiManagerEventListener& listener)
+{
+    return __pWifiManagerEvent->AddListener(listener, true);
+}
+
+result
+_WifiSystemAdapter::UnregisterManagerEventListener(const _IWifiManagerEventListener& listener)
+{
+    return __pWifiManagerEvent->RemoveListener(listener);
+}
+
+result
+_WifiSystemAdapter::Activate(void)
+{
+    result r = E_SYSTEM;
+    int err = WIFI_ERROR_NONE;
+
+    err = wifi_activate(OnWifiActivated, __pWifiManagerEvent.get());
+    _WifiConvertErrorResult(err == WIFI_ERROR_OPERATION_FAILED, r, E_FAILURE);
+    _WifiConvertErrorResult(err == WIFI_ERROR_INVALID_OPERATION, r, E_INVALID_OPERATION);
+    _WifiConvertErrorResult(err == WIFI_ERROR_NONE, r, E_SUCCESS);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to activate Wi-Fi. [0x%08X]", err);
+
+    return E_SUCCESS;
+}
+
+result
+_WifiSystemAdapter::Deactivate(void)
+{
+    result r = E_SYSTEM;
+    int err = WIFI_ERROR_NONE;
+
+    err = wifi_deactivate(OnWifiDeactivated, __pWifiManagerEvent.get());
+    _WifiConvertErrorResult(err == WIFI_ERROR_OPERATION_FAILED, r, E_FAILURE);
+    _WifiConvertErrorResult(err == WIFI_ERROR_INVALID_OPERATION, r, E_INVALID_OPERATION);
+    _WifiConvertErrorResult(err == WIFI_ERROR_NONE, r, E_SUCCESS);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to deactivate Wi-Fi. [0x%08X]", err);
+
+    return E_SUCCESS;
+}
+
+String
+_WifiSystemAdapter::GetMacAddress(void) const
+{
+    int err = 0;
+    char *pMacAddress;
+    err = wifi_get_mac_address(&pMacAddress);
+    String macAddress(_WifiUtility::ConvertMacAddress(pMacAddress));
+    free(pMacAddress);
+
+    return macAddress;
+}
+
+bool
+_WifiSystemAdapter::IsActivated(void) const
+{
+    bool val = false;
+    wifi_is_activated(&val);
+
+    return val;
+}
+
+bool
+_WifiSystemAdapter::IsConnected(void) const
+{
+    wifi_connection_state_e connectionState = WIFI_CONNECTION_STATE_DISCONNECTED;
+
+    wifi_get_connection_state(&connectionState);
+
+    switch (connectionState)
+    {
+    case WIFI_CONNECTION_STATE_CONNECTED:
+        return true;
+    default:
+        return false;
+    }
+}
+
+result
+_WifiSystemAdapter::Scan(void)
+{
+    result r = E_FAILURE;
+    int err = WIFI_ERROR_NONE;
+
+    err = wifi_scan(OnWifiScanCompleted, __pWifiManagerEvent.get());
+    _WifiConvertErrorResult(err == WIFI_ERROR_NONE, r, E_SUCCESS);
+    SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to scan for a nearby BSS. [0x%08X]", err);
+
+    return E_SUCCESS;
+}
+
+WifiConnectionState
+_WifiSystemAdapter::GetConnectionState(void) const
+{
+       WifiConnectionState currentState = WIFI_CONN_STATE_NOT_CONNECTED;
+
+    wifi_foreach_found_aps(OnWifiEachAccessPointChecked, &currentState);
+
+       return currentState;
+}
+
+WifiBssInfo*
+_WifiSystemAdapter::GetConnectionTargetInfoN(void) const
+{
+    WifiBssInfo* pBssInfo = null;
+    int apRes = WIFI_ERROR_NONE;
+    wifi_ap_h pApHandle = null;
+
+    apRes = wifi_get_connected_ap(&pApHandle);
+    SysTryReturn(NID_NET_WIFI, apRes != WIFI_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY,
+               "[E_OUT_OF_MEMORY] Memory allocation failed.");
+    SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_SYSTEM, "[E_SYSTEM] Failed to get the connected AP handle.");
+
+    pBssInfo = _WifiUtility::CreateWifiBssInfoInstanceN(pApHandle);
+       SysTryReturn(NID_NET_WIFI, pBssInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       return pBssInfo;
+}
+
+Tizen::Base::Collection::IList*
+_WifiSystemAdapter::GetSystemScanResultN(void) const
+{
+    LinkedList* pBssInfoList = null;
+
+    pBssInfoList = new (std::nothrow) LinkedList(SingleObjectDeleter);
+    SysTryReturn(NID_NET_WIFI, pBssInfoList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    wifi_foreach_found_aps(OnWifiEachAccessPointFound, pBssInfoList);
+
+    return pBssInfoList;
+}
+
+void
+_WifiSystemAdapter::OnWifiDeviceStateChanged(wifi_device_state_e state, void* pUserData)
+{
+    _WifiManagerEvent* pEvent = static_cast<_WifiManagerEvent*>(pUserData);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEvent != null, E_SYSTEM, "[E_SYSTEM] _WifiManagerEvent is invalid.");
+    
+    _WifiManagerEventArg* pEventArg = null;
+    result r = E_SUCCESS;
+
+    switch (state)
+    {
+    case WIFI_DEVICE_STATE_DEACTIVATED:
+        pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_DEACTIVATED, r);
+        SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+        SysLog(NID_NET_WIFI, "Fire event [WIFI_EVENT_DEACTIVATED],[result:%s]", GetErrorMessage(r));
+        pEvent->Fire(*pEventArg);
+        break;
+    case WIFI_DEVICE_STATE_ACTIVATED:
+        pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_ACTIVATED, r);
+        SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+        SysLog(NID_NET_WIFI, "Fire event [WIFI_EVENT_ACTIVATED],[result:%s]", GetErrorMessage(r));
+        pEvent->Fire(*pEventArg);
+        break;
+    }
+}
+
+void 
+_WifiSystemAdapter::OnWifiActivated(wifi_error_e errorCode, void* pUserData)
+{
+    result r = E_FAILURE;
+    int err = WIFI_ERROR_NONE;
+    _WifiManagerEvent* pEvent = static_cast<_WifiManagerEvent*>(pUserData);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEvent != null, E_SYSTEM, "[E_SYSTEM] _WifiManagerEvent is invalid.");
+    
+    _WifiManagerEventArg* pEventArg = null;
+    _WifiConvertErrorResult(err == WIFI_ERROR_NONE, r, E_SUCCESS);
+
+    pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_ACTIVATED, r);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    SysLog(NID_NET_WIFI, "Fire event [WIFI_EVENT_ACTIVATED],[result:%s]", GetErrorMessage(r));
+    pEvent->Fire(*pEventArg);
+}
+
+void 
+_WifiSystemAdapter::OnWifiDeactivated(wifi_error_e errorCode, void* pUserData)
+{
+    result r = E_FAILURE;
+    int err = WIFI_ERROR_NONE;
+    _WifiManagerEvent* pEvent = static_cast<_WifiManagerEvent*>(pUserData);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEvent != null, E_SYSTEM, "[E_SYSTEM] _WifiManagerEvent is invalid.");
+    
+    _WifiManagerEventArg* pEventArg = null;
+    _WifiConvertErrorResult(err == WIFI_ERROR_NONE, r, E_SUCCESS);
+
+    pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_DEACTIVATED, r);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    SysLog(NID_NET_WIFI, "Fire event [WIFI_EVENT_DEACTIVATED],[result:%s]", GetErrorMessage(r));
+    pEvent->Fire(*pEventArg);
+}
+
+void
+_WifiSystemAdapter::OnWifiConnected(wifi_error_e errorCode, void* pUserData)
+{
+    _WifiManagerEvent* pEvent = static_cast<_WifiManagerEvent*>(pUserData);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEvent != null, E_SYSTEM, "[E_SYSTEM] _WifiManagerEvent is invalid.");
+    
+    _WifiManagerEventArg* pEventArg = null;
+    result r = E_SUCCESS;
+    char* pEssid = null; 
+    _WifiConvertErrorResult(errorCode != WIFI_ERROR_NONE, r, E_FAILURE);
+    _WifiConvertErrorResult(errorCode == WIFI_ERROR_INVALID_KEY, r, E_AUTHENTICATION);
+    _WifiConvertErrorResult(errorCode == WIFI_ERROR_NO_REPLY, r, E_NOT_RESPONDING);
+    _WifiConvertErrorResult(errorCode == WIFI_ERROR_DHCP_FAILED, r, E_DHCP);
+
+    if(r == E_SUCCESS)
+    {
+        wifi_ap_h apHandler;
+        int err = wifi_get_connected_ap(&apHandler);
+        _WifiConvertErrorResult(errorCode != WIFI_ERROR_NONE, r, E_FAILURE);
+        _WifiConvertErrorResult(err == WIFI_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
+
+        wifi_ap_get_essid(apHandler, &pEssid);
+        String ssid(pEssid);
+        free(pEssid);
+        pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_CONNECTED, ssid, r);
+        SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+    }
+    else
+    {
+        String ssid(L"");
+        pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_CONNECTED, ssid, r);
+        SysTryReturnVoidResult(NID_NET_WIFI, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+    }
+    pEvent->Fire(*pEventArg);
+}
+
+void
+_WifiSystemAdapter::OnWifiConnectionStateChanged(wifi_connection_state_e state, wifi_ap_h apHandler, void *pUserData)
+{
+    _WifiManagerEvent* pEvent = static_cast<_WifiManagerEvent*>(pUserData);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEvent != null, E_SYSTEM, "[E_SYSTEM] _WifiManagerEvent is invalid.");
+    
+    _WifiManagerEventArg* pEventArg = null;
+    char* pEssid = null; 
+    
+    switch(state)
+    {
+    case WIFI_CONNECTION_STATE_CONNECTED:
+        // Fire a CONNECTED event for notifying that the connection is established not by this system adapter.
+               wifi_ap_get_essid(apHandler, &pEssid);
+               pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_CONNECTED, String(pEssid), E_SUCCESS);
+               free(pEssid);
+               SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        pEvent->FireAsync(*pEventArg);
+
+        // Fire a CONNECTION_CHANGED event for notifying that the connection state is changed to 'CONNECTED' state.
+        // This seems a little redundant but the purpose of it is quite different from CONNECTED event.
+               pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_CONNECTION_CHNAGED, WIFI_CONN_STATE_CONNECTED);
+               SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        pEvent->FireAsync(*pEventArg);
+        break;
+
+    case WIFI_CONNECTION_STATE_DISCONNECTED:
+        // Fire a DISCONNECTED event for notifying that the connection is broken off not by this system adapter.
+        pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_DISCONNECTED);
+        SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        SysLog(NID_NET_WIFI, "Fire event [WIFI_EVENT_DISCONNECTED]");
+        pEvent->Fire(*pEventArg);
+
+        // Fire a CONNECTION_CHANGED event for notifying that the connection state is changed to "IDLE' state.
+        // This seems a little redundant but the purpose of it is quite different from DISCONNECTED event.
+               pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_CONNECTION_CHNAGED, WIFI_CONN_STATE_NOT_CONNECTED);
+               SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        pEvent->FireAsync(*pEventArg);
+        break;
+
+    case WIFI_CONNECTION_STATE_ASSOCIATION:
+        // Fire a CONNECTION_CHANGED event for notifying that the connection state is changed to "ASSOCIATING" state.
+               pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_CONNECTION_CHNAGED, WIFI_CONN_STATE_ASSOCIATING);
+               SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        pEvent->FireAsync(*pEventArg);
+        break;
+
+    case WIFI_CONNECTION_STATE_CONFIGURATION:
+        // Fire a CONNECTION_CHANGED event for notifying that the connection state is changed to "CONFIGURING" state.
+               pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_CONNECTION_CHNAGED, WIFI_CONN_STATE_CONFIGURING);
+               SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+        pEvent->FireAsync(*pEventArg);
+        break;
+    }   
+}
+
+bool
+_WifiSystemAdapter::OnWifiEachAccessPointFound(wifi_ap_h pApHandle, void* pUserData)
+{
+    WifiBssInfo* pBssInfo = null;
+    LinkedList* pBssInfoList = static_cast<LinkedList*>(pUserData);
+    wifi_ap_h pApHandleClone = null;
+
+    wifi_ap_clone(&pApHandleClone, pApHandle);
+    pBssInfo = _WifiUtility::CreateWifiBssInfoInstanceN(pApHandleClone);
+    // keep gonig even though creating one WifiBssInfo instance.
+    SysTryReturn(NID_NET_WIFI, pBssInfo != null, true, GetLastResult(),
+               "[%s] Propagating because of creating a new WifiBssInfo fails.", GetErrorMessage(GetLastResult()));
+
+    pBssInfoList->Add(*pBssInfo);
+
+    return true;
+}
+
+bool
+_WifiSystemAdapter::OnWifiEachAccessPointChecked(wifi_ap_h pApHandle, void* pUserData)
+{
+       wifi_connection_state_e apState = WIFI_CONNECTION_STATE_DISCONNECTED;
+       WifiConnectionState* pLocalState = static_cast<WifiConnectionState*>(pUserData);
+       bool isContinued = true;
+
+       wifi_ap_get_connection_state(pApHandle, &apState);
+
+       switch (apState)
+       {
+       case WIFI_CONNECTION_STATE_ASSOCIATION:
+               *pLocalState = WIFI_CONN_STATE_ASSOCIATING;
+               isContinued = false;
+               break;
+       case WIFI_CONNECTION_STATE_CONFIGURATION:
+               *pLocalState = WIFI_CONN_STATE_CONFIGURING;
+               isContinued = false;
+               break;
+       case WIFI_CONNECTION_STATE_CONNECTED:
+               *pLocalState = WIFI_CONN_STATE_CONNECTED;
+               isContinued = false;
+               break;
+       case WIFI_CONNECTION_STATE_DISCONNECTED:
+       default:
+               *pLocalState = WIFI_CONN_STATE_NOT_CONNECTED;
+               break;
+       }
+
+       return isContinued;
+}
+
+void
+_WifiSystemAdapter::OnWifiScanCompleted(wifi_error_e errorCode, void *pUserData)
+{
+    _WifiManagerEventArg* pEventArg = null;
+    LinkedList* pBssInfoList = null;
+    result r = E_FAILURE;
+    _WifiConvertErrorResult(errorCode == WIFI_ERROR_NONE, r, E_SUCCESS);
+
+    _WifiManagerEvent* pEvent = static_cast<_WifiManagerEvent*>(pUserData);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEvent != null, E_FAILURE, "[E_FAILURE] _WifiManagerEventArg is invalid.");
+     
+    pBssInfoList = new (std::nothrow) LinkedList(SingleObjectDeleter);
+    SysTryReturnVoidResult(NID_NET_WIFI, pBssInfoList != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    wifi_foreach_found_aps(OnWifiEachAccessPointFound, pBssInfoList);
+    pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_SCAN_COMPLETED, pBssInfoList, r);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    pEvent->Fire(*pEventArg);
+}
+
+void
+_WifiSystemAdapter::OnWifiBackgroundScanResultUpdated(wifi_error_e errorCode, void* pUserData)
+{
+    _WifiManagerEvent* pEvent = null;
+    _WifiManagerEventArg* pEventArg = null;
+
+    if (errorCode == WIFI_ERROR_NONE)
+    {
+       pEvent = static_cast<_WifiManagerEvent*>(pUserData);
+
+               pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_SCAN_UPDATED);
+               SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+               pEvent->Fire(*pEventArg);
+    }
+}
+
+result
+_WifiSystemAdapter::Connect(const WifiBssInfo& targetApInfo)
+{
+    result r = E_SUCCESS;
+    int err = WIFI_ERROR_NONE;
+
+    wifi_ap_h ap;
+    wifi_security_type_e securityType;
+    const _WifiBssInfoImpl* pBssInfoImpl = _WifiBssInfoImpl::GetInstance(targetApInfo);
+    const WifiSecurityInfo* pSecurityInfo = targetApInfo.GetSecurityInfo();
+    const _WifiSecurityInfoImpl* pSecurityInfoImpl = _WifiSecurityInfoImpl::GetInstance(*pSecurityInfo);
+
+    if(pBssInfoImpl->GetBssHandle() == null)
+    {
+        SysLog(NID_NET_WIFI, "It's Hidden AP");
+
+        // Sets SSID
+        unique_ptr<char[]> pSsidTemp(_StringConverter::CopyToCharArrayN(targetApInfo.GetSsid()));
+        SysTryReturnResult(NID_NET_WIFI, pSsidTemp != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+        err = wifi_ap_create(pSsidTemp.get(), &ap);
+        _WifiConvertErrorResult(err != WIFI_ERROR_NONE, r, E_FAILURE);
+        _WifiConvertErrorResult(err == WIFI_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
+        SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to create handle of ap.");
+
+        // Sets Authentication Type
+        securityType = _WifiUtility::ConvertSecurityType(pSecurityInfo->GetAuthenticationType());
+        err = wifi_ap_set_security_type(ap, securityType);
+        _WifiConvertErrorResult(err != WIFI_ERROR_NONE, r, E_FAILURE);
+        SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to set authenticatino type.");
+
+        // Sets Network Key
+        unique_ptr<char[]> pKeyTemp(_StringConverter::CopyToCharArrayN(pSecurityInfoImpl->GetNetworkKey()));
+        SysTryReturnResult(NID_NET_WIFI, pKeyTemp != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+        err = wifi_ap_set_passphrase(ap,pKeyTemp.get());
+        _WifiConvertErrorResult(err != WIFI_ERROR_NONE, r, E_FAILURE);
+        SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to set network key.");
+    }
+    else
+    {
+        ap = static_cast <wifi_ap_h> (pBssInfoImpl->GetBssHandle());
+
+        const unsigned char* pSecurityKey = null;
+
+        switch (targetApInfo.GetSecurityInfo()->GetEncryptionType())
+        {
+        case WIFI_ENCRYPTION_NONE:
+            break;
+
+        case WIFI_ENCRYPTION_WEP:
+            {
+                pSecurityKey = pSecurityInfoImpl->GetNetworkKeyWep();
+                wifi_ap_set_passphrase(ap,reinterpret_cast <const char*>(pSecurityKey));
+            }
+            break;
+
+        case WIFI_ENCRYPTION_TKIP:
+            {
+                SysLog(NID_NET_WIFI, "WIFI_ENCRYPTION_TKIP");
+
+                pSecurityKey = pSecurityInfoImpl->GetNetworkKeyTkip();
+
+                wifi_ap_set_passphrase(ap,reinterpret_cast <const char*>(pSecurityKey));
+            }
+            break;
+
+        case WIFI_ENCRYPTION_AES:
+            {
+                pSecurityKey = pSecurityInfoImpl->GetNetworkKeyAes();
+
+                wifi_ap_set_passphrase(ap,reinterpret_cast <const char*>(pSecurityKey));                }
+            break;
+
+        case WIFI_ENCRYPTION_TKIP_AES_MIXED:
+            {
+                pSecurityKey = pSecurityInfoImpl->GetNetworkKeyTkip();
+
+                if (strlen(reinterpret_cast <const char*>(pSecurityKey)) == 0)
+                {
+                    pSecurityKey = pSecurityInfoImpl->GetNetworkKeyAes();
+
+                    if (strlen(reinterpret_cast <const char*>(pSecurityKey)) > 0)
+                    {
+                        wifi_ap_set_passphrase(ap,reinterpret_cast <const char*>(pSecurityKey));
+                    }
+                }
+                else
+                {
+                    wifi_ap_set_passphrase(ap,reinterpret_cast <const char*>(pSecurityKey));
+                }
+            }
+            break;
+        default:
+            break;
+        }
+    }
+
+    if (pSecurityInfoImpl->GetAuthenticationType() == WIFI_AUTHENTICATION_WPA ||
+        pSecurityInfoImpl->GetAuthenticationType() == WIFI_AUTHENTICATION_WPA2 )
+    {
+        wifi_eap_type_e eapType = _WifiUtility::ConvertEapType(pSecurityInfoImpl->GetEapType());
+        err = wifi_ap_set_eap_type(ap, eapType);
+        r = TransExceptionsExclusive(_WifiUtility::ConvertErrorCode(err), E_FAILURE, E_INVALID_ARG);
+        SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to set eap type.");
+
+        wifi_eap_auth_type_e eapAuthType = _WifiUtility::ConvertEapAuthType(pSecurityInfoImpl->GetEapType());
+        err = wifi_ap_set_eap_auth_type(ap, eapAuthType);
+        r = TransExceptionsExclusive(_WifiUtility::ConvertErrorCode(err), E_FAILURE, E_INVALID_ARG);
+        SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to set eap authentication type.");
+
+        err = wifi_ap_set_eap_passphrase(ap, pSecurityInfoImpl->GetEapUserId(), pSecurityInfoImpl->GetEapPassword());
+        r = TransExceptionsExclusive(_WifiUtility::ConvertErrorCode(err), E_FAILURE, E_INVALID_ARG);
+        SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to set eap authentication type.");
+    }
+
+    err = wifi_connect(ap, OnWifiConnected, pInstance->__pWifiManagerEvent.get());
+    _WifiConvertErrorResult(err != WIFI_ERROR_NONE, r, E_FAILURE);
+    return E_SUCCESS;
+}
+
+void
+_WifiSystemAdapter::OnWifiRssiLevelChanged(wifi_rssi_level_e rssiLevel, void *pUserData)
+{
+    _WifiManagerEventArg* pEventArg = null;
+    _WifiManagerEvent* pEvent = static_cast<_WifiManagerEvent*>(pUserData);
+    SysTryReturnVoidResult(NID_NET_WIFI, pEvent != null, E_SYSTEM, "[E_SYSTEM] _WifiManagerEventArg is invalid.");
+    
+    pEventArg = new (std::nothrow) _WifiManagerEventArg(_WIFI_EVENT_RSSI_CHANGED,
+                                    _WifiUtility::ConvertLeveltoRssiValue(rssiLevel));
+    SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    pEvent->Fire(*pEventArg);
+}
+
+} } } // Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiSystemMonitoringEvent.cpp b/src/wifi/FNetWifi_WifiSystemMonitoringEvent.cpp
new file mode 100644 (file)
index 0000000..dd9cd83
--- /dev/null
@@ -0,0 +1,76 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// @file    FNetWifi_WifiSystemMonitoringEvent.cpp
+// @brief   This is the implementation file for the _WifiSystemMonitoringEvent class.
+//
+
+#include <FBaseRtIEventListener.h>
+#include <FBaseSysLog.h>
+#include <FBaseRtIEventArg.h>
+#include <FNetWifiWifiTypes.h>
+#include <FNetWifiIWifiSystemMonitoringEventListener.h>
+#include "FNetWifi_WifiSystemMonitoringEvent.h"
+#include "FNetWifi_WifiSystemMonitoringEventArg.h"
+
+
+namespace Tizen { namespace Net { namespace Wifi {
+
+_WifiSystemMonitoringEvent::_WifiSystemMonitoringEvent(void)
+{
+}
+
+_WifiSystemMonitoringEvent::~_WifiSystemMonitoringEvent(void)
+{
+}
+
+result
+_WifiSystemMonitoringEvent::Construct(void)
+{
+       return _Event::Initialize();
+}
+
+void
+_WifiSystemMonitoringEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
+{
+       IWifiSystemMonitoringEventListener* pEventListener = dynamic_cast <IWifiSystemMonitoringEventListener*>(&listener);
+       SysTryReturnVoidResult(NID_NET_WIFI, pEventListener != null, E_INVALID_ARG,
+                       "[E_INVALID_ARG] The listener argument is invalid.");
+
+       const _WifiSystemMonitoringEventArg* pEventArg = dynamic_cast <const _WifiSystemMonitoringEventArg*>(&arg);
+       SysTryReturnVoidResult(NID_NET_WIFI, pEventArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The event argument is invalid type.");
+
+       _WifiSystemMonitoringEventType eventType = pEventArg->GetEventType();
+
+       switch (eventType)
+       {
+       case _WIFI_SYSTEM_MONITORING_EVENT_CONNECTION_STATUS_CHANGED:
+               SysLog(NID_NET_WIFI, "Firing Wi-Fi System Monitoring Event \
+                               (Type: _WIFI_SYSTEM_MONITORING_EVENT_CONNECTION_STATUS_CHANGED)");
+               pEventListener->OnWifiConnectionStateChanged(pEventArg->GetConnectionState());
+               break;
+
+       case _WIFI_SYSTEM_MONITORING_EVENT_SCAN_RESULT_UPDATED:
+               SysLog(NID_NET_WIFI, "Firing Wi-Fi System Monitoring Event (Type: _WIFI_SYSTEM_MONITORING_EVENT_SCAN_RESULT_UPDATED)");
+               pEventListener->OnWifiSystemScanResultUpdated();
+               break;
+
+       default:
+               break;
+       }
+}
+
+} } } //Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiSystemMonitoringEvent.h b/src/wifi/FNetWifi_WifiSystemMonitoringEvent.h
new file mode 100644 (file)
index 0000000..e48eadb
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file        FNetWifi_WifiSystemMonitoringEvent.h
+ * @brief       This is the header file for the _WifiSystemMonitoringEvent Class.
+ *
+ * This header file contains the declarations of the _WifiSystemMonitoringEvent class.
+ * The _WifiSystemMonitoringEvent class can call a method of a listener (IWifiSystemMonitoringEventListener object).
+ * So, when a device event is occurred, listener instances can handle it appropriately.
+ */
+
+#ifndef _FNET_WIFI_INTERNAL_WIFI_SYSTEM_MONITORING_EVENT_H_
+#define _FNET_WIFI_INTERNAL_WIFI_SYSTEM_MONITORING_EVENT_H_
+
+#include <FBaseRt_Event.h>
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+/**
+ * @class   _WifiSystemMonitoringEvent
+ * @brief   This class handles Wi-Fi background system monitoring events.
+ *
+ * When a Wi-Fi background system monitoring event occurs, the _WifiSystemMonitoringEvent object finds an
+ * IWifiSystemMonitoringEventListener object and calls an appropriate method of the listener.
+ */
+class _WifiSystemMonitoringEvent:
+    public Tizen::Base::Runtime::_Event
+{
+
+public:
+       /**
+        * 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.
+        */
+       _WifiSystemMonitoringEvent(void);
+
+       /**
+        * This destructor overrides Tizen::Base::Runtime::_Event::~_Event().
+        */
+       virtual ~_WifiSystemMonitoringEvent(void);
+
+       /**
+        * Initializes this instance.
+        */
+       result Construct(void);
+
+protected:
+       /**
+        * Checks the arg and finds out the type of event. After that this method calls appropriate pListener's method.
+        *
+        * @param[in]   listener        It is a event listener related to this WifiManage       ent.
+        * @param[in]   arg             It is an argument-like instance of WifiManager event retransmitted to the listener's method
+        *                              as an argument.
+        * @exception   E_SUCCESS       The method is successful.
+        * @exception   E_INVALID_ARG   The argument passed to a method contains an invalid value.@n
+        * @exception   E_INVALID_ARG   The argument passed to a method is @c null.
+        */
+       void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+       _WifiSystemMonitoringEvent(const _WifiSystemMonitoringEvent& rhs);
+       _WifiSystemMonitoringEvent& operator=(const _WifiSystemMonitoringEvent& rhs);
+
+}; // _WifiSystemMonitoringEvent
+
+} } } // Tizen::Net::Wifi
+
+#endif // _FNET_WIFI_INTERNAL_WIFI_SYSTEM_MONITORING_EVENT_H_
diff --git a/src/wifi/FNetWifi_WifiSystemMonitoringEventArg.cpp b/src/wifi/FNetWifi_WifiSystemMonitoringEventArg.cpp
new file mode 100644 (file)
index 0000000..8c5563b
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// @file    FNetWifi_WifiSystemMonitoringEventArg.cpp
+// @brief   This is the implementation file for the _WifiSystemMonitoringEvent class.
+//
+
+#include "FNetWifi_WifiSystemMonitoringEventArg.h"
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+// This is a default constructor and it is for _WIFI_SYSTEM_MONITORING_EVENT_SCAN_RESULT_UPDATED.
+_WifiSystemMonitoringEventArg::_WifiSystemMonitoringEventArg(void)
+       : __evt(_WIFI_SYSTEM_MONITORING_EVENT_SCAN_RESULT_UPDATED)
+       , __state(WIFI_CONN_STATE_NOT_CONNECTED)
+{
+}
+
+// This is a class constructor for _WIFI_SYSTEM_MONITORING_EVENT_CONNECTION_STATUS_CHANGED.
+_WifiSystemMonitoringEventArg::_WifiSystemMonitoringEventArg(WifiConnectionState state)
+       : __evt(_WIFI_SYSTEM_MONITORING_EVENT_CONNECTION_STATUS_CHANGED)
+       , __state(state)
+{
+}
+
+_WifiSystemMonitoringEventArg::~_WifiSystemMonitoringEventArg(void)
+{
+}
+
+_WifiSystemMonitoringEventType
+_WifiSystemMonitoringEventArg::GetEventType(void) const
+{
+       return __evt;
+}
+
+WifiConnectionState
+_WifiSystemMonitoringEventArg::GetConnectionState(void) const
+{
+       return __state;
+}
+
+} } } // Tizen::Net::Wifi
diff --git a/src/wifi/FNetWifi_WifiSystemMonitoringEventArg.h b/src/wifi/FNetWifi_WifiSystemMonitoringEventArg.h
new file mode 100644 (file)
index 0000000..9e9eabd
--- /dev/null
@@ -0,0 +1,101 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file    FNetWifi_WifiSystemMonitoringEventArg.h
+ * @brief   This is the header file for the _WifiSystemMonitoringEventArg class.
+ *
+ * This header file contains the declarations of the _WifiSystemMonitoringEventArg class which includes information to be
+ * passed to the event listeners
+ */
+#ifndef _FNET_WIFI_INTERNAL_WIFI_SYSTEM_MONITORING_EVENT_ARG_H_
+#define _FNET_WIFI_INTERNAL_WIFI_SYSTEM_MONITORING_EVENT_ARG_H_
+
+#include <FBaseObject.h>
+#include <FBaseResult.h>
+#include <FOspConfig.h>
+#include <FBaseRtIEventArg.h>
+#include <FNetWifiWifiTypes.h>
+
+namespace Tizen { namespace Net { namespace Wifi
+{
+
+/**
+ * @enum    _WifiSystemMonitoringEventType
+ * Type for specifying the type of _WifiSystemMonitoringEvent
+ */
+enum _WifiSystemMonitoringEventType
+{
+       _WIFI_SYSTEM_MONITORING_EVENT_CONNECTION_STATUS_CHANGED,  /**< For notifying that Wi-Fi connection status is changed */
+       _WIFI_SYSTEM_MONITORING_EVENT_SCAN_RESULT_UPDATED         /**< For notifying that Wi-Fi background scan result is updated */
+};
+
+/**
+ * @class   _WifiSystemMonitoringEventArg
+ * @brief   This class is used as an argument for callback methods of the IWifiSystemMonitoringEventListener class.
+ *
+ * When a _WifiSystemMonitoringEvent occurs, the _WifiSystemMonitoringEvent finds a IWifiSystemMonitoringEventListener instance
+ * which is registered for the _WifiSystemMonitoringEvent and calls an appropriate method of the listener.
+ * @see     IWifiSystemMonitoringEventListener
+ */
+class _WifiSystemMonitoringEventArg
+       : public Tizen::Base::Object
+       , public Tizen::Base::Runtime::IEventArg
+{
+public:
+       /**
+        * This is a default constructor and it is for _WIFI_SYSTEM_MONITORING_EVENT_SCAN_RESULT_UPDATED.
+        */
+       _WifiSystemMonitoringEventArg(void);
+
+       /**
+        * This is a class constructor for _WIFI_SYSTEM_MONITORING_EVENT_CONNECTION_STATUS_CHANGED.
+        *
+        * @param[in]    state              The state of the Wi-Fi current connection
+        */
+       _WifiSystemMonitoringEventArg(WifiConnectionState state);
+
+       /**
+        * This is the class destructor.
+        */
+       ~_WifiSystemMonitoringEventArg(void);
+
+       /**
+        * Gets the type of this event.
+        *
+        * @return      The type of the event
+        */
+       _WifiSystemMonitoringEventType GetEventType(void) const;
+
+       /**
+        * Gets the current connection state of this event.
+        *
+        * @return      The state of the Wi-Fi current connection
+        */
+       WifiConnectionState GetConnectionState(void) const;
+
+private:
+       _WifiSystemMonitoringEventArg(const _WifiSystemMonitoringEventArg& eventArg);
+       _WifiSystemMonitoringEventArg& operator =(const _WifiSystemMonitoringEventArg& rValue);
+
+private:
+       _WifiSystemMonitoringEventType __evt;
+       WifiConnectionState __state;
+
+}; // _WifiSystemMonitoringEventArg
+
+} } }
+#endif // _FNET_WIFI_INTERNAL_WIFI_SYSTEM_MONITORING_EVENT_ARG_H_
diff --git a/src/wifi/FNetWifi_WifiUtility.cpp b/src/wifi/FNetWifi_WifiUtility.cpp
new file mode 100644 (file)
index 0000000..59902f6
--- /dev/null
@@ -0,0 +1,739 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file        FNetWifi_WifiUtility.cpp
+ * @brief       This is the implementation file for _WifiUtility class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FNetIpAddress.h>
+#include <FNetIp4Address.h>
+#include <FNetWifiWifiBssInfo.h>
+#include <FNetWifiWifiSecurityInfo.h>
+#include "FNetWifi_WifiUtility.h"
+#include "FNetWifi_WifiBssInfoImpl.h"
+#include "FNetWifi_WifiSecurityInfoImpl.h"
+
+
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Net;
+
+namespace Tizen {      namespace Net { namespace Wifi {
+
+_WifiUtility::_WifiUtility(void)
+{
+}
+
+_WifiUtility::~_WifiUtility(void)
+{
+}
+
+result
+_WifiUtility::ConvertErrorCode(int error)
+{
+    result r = E_SUCCESS;
+
+    switch (error)
+    {
+    case WIFI_ERROR_NONE:
+        r = E_SUCCESS;
+        break;
+    case WIFI_ERROR_INVALID_PARAMETER:
+        r = E_INVALID_ARG;
+        SysLogException(NID_NET_WIFI, E_SYSTEM, "[E_INVALID_ARG] Invalid parameter.");
+        break;
+    case WIFI_ERROR_OUT_OF_MEMORY:
+        r = E_OUT_OF_MEMORY;
+        SysLogException(NID_NET_WIFI, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Out of Memory Error.");
+        break;
+    case WIFI_ERROR_INVALID_OPERATION:
+        r = E_INVALID_OPERATION;
+        SysLogException(NID_NET_WIFI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Invalid Operation.");
+        break;
+    case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+        r = E_UNSUPPORTED_FAMILY;
+        SysLogException(NID_NET_WIFI, E_FAILURE, "[E_FAILURE] Address family not supported.");
+        break;
+    case WIFI_ERROR_OPERATION_FAILED:
+        r = E_FAILURE;
+        SysLogException(NID_NET_WIFI, E_FAILURE, "[E_FAILURE] Operation Failed.");
+        break;
+     case WIFI_ERROR_NO_CONNECTION:
+        r = E_INVALID_CONNECTION;
+        SysLogException(NID_NET_WIFI, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] There is no connected AP.");
+        break;
+    case WIFI_ERROR_NOW_IN_PROGRESS:
+        r = E_IN_PROGRESS;
+        SysLogException(NID_NET_WIFI, E_IN_PROGRESS, "[E_IN_PROGRESS] Now in progress.");
+        break;
+    case WIFI_ERROR_ALREADY_EXISTS:
+        r = E_SYSTEM;
+        SysLogException(NID_NET_WIFI, E_SYSTEM, "[E_SYSTEM] Already exists.");
+        break;
+    case WIFI_ERROR_OPERATION_ABORTED:
+        r = E_SYSTEM;
+        SysLogException(NID_NET_WIFI, E_SYSTEM, "[E_SYSTEM] Operation is aborted.");
+        break;
+    case WIFI_ERROR_DHCP_FAILED:
+        r = E_DHCP;
+        SysLogException(NID_NET_WIFI, E_DHCP, "[E_DHCP] DHCP failed.");
+        break;
+    case WIFI_ERROR_INVALID_KEY:
+        r = E_AUTHENTICATION;
+        SysLogException(NID_NET_WIFI, E_AUTHENTICATION, "[E_AUTHENTICATION] Invalid key.");
+        break;
+    case WIFI_ERROR_NO_REPLY:
+        r = E_NOT_RESPONDING;
+        SysLogException(NID_NET_WIFI, E_INVALID_CONNECTION, "[E_NOT_RESPONDING] No reply.");
+        break;
+    default:
+        r = E_SYSTEM;
+        SysLogException(NID_NET_WIFI, E_SYSTEM, "[E_SYSTEM] Other case.");
+        break;
+    }
+
+    return r;
+}
+
+WifiAuthenticationType
+_WifiUtility::ConvertAuthType(wifi_security_type_e securityMode, wifi_encryption_type_e encryptionMode)
+{
+    WifiAuthenticationType authenticationType = WIFI_AUTHENTICATION_OPEN;
+
+    switch (securityMode)
+    {
+    case WIFI_SECURITY_TYPE_NONE:
+    {
+        authenticationType = WIFI_AUTHENTICATION_OPEN;
+        break;
+    }
+    case WIFI_SECURITY_TYPE_WEP:
+    {
+        authenticationType = WIFI_AUTHENTICATION_SHARED;
+        break;
+    }
+    case WIFI_SECURITY_TYPE_EAP:
+    {
+        if (encryptionMode == WIFI_ENCRYPTION_TYPE_TKIP)
+        {
+            authenticationType = WIFI_AUTHENTICATION_WPA;
+        }
+        else if (encryptionMode == WIFI_ENCRYPTION_TYPE_AES)
+        {
+            authenticationType = WIFI_AUTHENTICATION_WPA2;
+        }
+        break;
+    }
+    case WIFI_SECURITY_TYPE_WPA_PSK:
+    {
+        if (encryptionMode == WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED)
+        {
+            authenticationType = WIFI_AUTHENTICATION_WPA_WPA2_MIXED_PSK;
+        }
+        else
+        {
+            authenticationType = WIFI_AUTHENTICATION_WPA_PSK;
+        }
+        break;
+    }
+    case WIFI_SECURITY_TYPE_WPA2_PSK:
+    {
+        if (encryptionMode == WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED)
+        {
+            authenticationType = WIFI_AUTHENTICATION_WPA_WPA2_MIXED_PSK;
+        }
+        else
+        {
+            authenticationType = WIFI_AUTHENTICATION_WPA2_PSK;
+        }
+        break;
+    }
+    default:
+        break;
+    }
+
+    return authenticationType;
+}
+
+wifi_security_type_e
+_WifiUtility::ConvertSecurityType(WifiAuthenticationType authMode)
+{
+    wifi_security_type_e authenticationType = WIFI_SECURITY_TYPE_NONE;
+
+    switch (authMode)
+    {
+    case WIFI_AUTHENTICATION_OPEN:
+    {
+        authenticationType = WIFI_SECURITY_TYPE_NONE;
+        break;
+    }
+    case WIFI_AUTHENTICATION_SHARED:
+    {
+        authenticationType = WIFI_SECURITY_TYPE_WEP;
+        break;
+    }
+    case WIFI_AUTHENTICATION_WPA:
+    case WIFI_AUTHENTICATION_WPA2:
+    {
+        authenticationType = WIFI_SECURITY_TYPE_EAP;
+        break;
+    }
+    case WIFI_AUTHENTICATION_WPA_PSK:
+    {
+        authenticationType = WIFI_SECURITY_TYPE_WPA_PSK;
+        break;
+    }
+    case WIFI_AUTHENTICATION_WPA2_PSK:
+    {
+        authenticationType = WIFI_SECURITY_TYPE_WPA_PSK;
+        break;
+    }
+    default:
+        break;
+    }
+
+    return authenticationType;
+}
+
+WifiRadioChannel
+_WifiUtility::ConvertRadioChannel(int frequency)
+{
+    WifiRadioChannel radioChannel = WIFI_RADIO_CHANNEL_UNKNOWN;
+
+    switch (frequency)
+    {
+    case 2412:
+        radioChannel = WIFI_RADIO_CHANNEL_1;
+        break;
+    case 2417:
+        radioChannel = WIFI_RADIO_CHANNEL_2;
+        break;
+    case 2422:
+        radioChannel = WIFI_RADIO_CHANNEL_3;
+        break;
+    case 2427:
+        radioChannel = WIFI_RADIO_CHANNEL_4;
+        break;
+    case 2432:
+        radioChannel = WIFI_RADIO_CHANNEL_5;
+        break;
+    case 2437:
+        radioChannel = WIFI_RADIO_CHANNEL_6;
+        break;
+    case 2442:
+        radioChannel = WIFI_RADIO_CHANNEL_7;
+        break;
+    case 2447:
+        radioChannel = WIFI_RADIO_CHANNEL_8;
+        break;
+    case 2452:
+        radioChannel = WIFI_RADIO_CHANNEL_9;
+        break;
+    case 2457:
+        radioChannel = WIFI_RADIO_CHANNEL_10;
+        break;
+    case 2462:
+        radioChannel = WIFI_RADIO_CHANNEL_11;
+        break;
+    case 2467:
+        radioChannel = WIFI_RADIO_CHANNEL_12;
+        break;
+    case 2472:
+        radioChannel = WIFI_RADIO_CHANNEL_13;
+        break;
+    case 2484:
+        radioChannel = WIFI_RADIO_CHANNEL_14;
+        break;
+    default:
+        radioChannel = WIFI_RADIO_CHANNEL_UNKNOWN;
+        break;
+    }
+
+    return radioChannel;
+}
+
+long
+_WifiUtility::ConvertPercentagetoRssiValue(char val)
+{
+    if (val >= 75)
+    {
+        return -55;
+    }
+    else if (val > 50)
+    {
+        return -70;
+    }
+    else if (val > 25)
+    {
+        return -85;
+    }
+    else
+    {
+        return -100;
+    }
+}
+
+long
+_WifiUtility::ConvertLeveltoRssiValue(wifi_rssi_level_e val)
+{
+    long rssiValue = 0;
+    SysLog(NID_NET_WIFI, "Enter: [Rssi Level %d]", val);
+
+    switch (val)
+    {
+    case WIFI_RSSI_LEVEL_4:
+        rssiValue = -55;
+        break;
+    case WIFI_RSSI_LEVEL_3:
+        rssiValue = -70;
+        break;
+    case WIFI_RSSI_LEVEL_2:
+        rssiValue = -85;
+        break;
+    case WIFI_RSSI_LEVEL_1:
+        rssiValue = -100;
+        break;
+    default:
+        rssiValue = 0;
+        break;
+    }
+    SysLog(NID_NET_WIFI, "Exit: [Rssi dbm %ld]", rssiValue);
+
+    return rssiValue;
+}
+
+WifiEncryptionType
+_WifiUtility::ConvertEncryptionType(wifi_encryption_type_e encryptionMode)
+{
+    WifiEncryptionType encryptionType = WIFI_ENCRYPTION_NONE;
+
+    switch (encryptionMode)
+    {
+    case WIFI_ENCRYPTION_TYPE_NONE:
+    {
+        encryptionType = WIFI_ENCRYPTION_NONE;
+        break;
+    }
+    case WIFI_ENCRYPTION_TYPE_WEP:
+    {
+        encryptionType = WIFI_ENCRYPTION_WEP;
+        break;
+    }
+    case WIFI_ENCRYPTION_TYPE_TKIP:
+    {
+        encryptionType = WIFI_ENCRYPTION_TKIP;
+        break;
+    }
+    case WIFI_ENCRYPTION_TYPE_AES:
+    {
+        encryptionType = WIFI_ENCRYPTION_AES;
+        break;
+    }
+    case WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED:
+    {
+        encryptionType = WIFI_ENCRYPTION_TKIP_AES_MIXED;
+        break;
+    }
+    default:
+        break;
+    }
+
+    return encryptionType;
+}
+
+wifi_encryption_type_e
+_WifiUtility::ConvertEncryptionType(WifiEncryptionType encryptionMode)
+{
+    wifi_encryption_type_e encryptionType = WIFI_ENCRYPTION_TYPE_NONE;
+
+    switch (encryptionMode)
+    {
+    case WIFI_ENCRYPTION_NONE:
+    {
+        encryptionType = WIFI_ENCRYPTION_TYPE_NONE;
+        break;
+    }
+    case WIFI_ENCRYPTION_WEP:
+    {
+        encryptionType = WIFI_ENCRYPTION_TYPE_WEP;
+        break;
+    }
+    case WIFI_ENCRYPTION_TKIP:
+    {
+        encryptionType = WIFI_ENCRYPTION_TYPE_TKIP;
+        break;
+    }
+    case WIFI_ENCRYPTION_AES:
+    {
+        encryptionType = WIFI_ENCRYPTION_TYPE_AES;
+        break;
+    }
+    case WIFI_ENCRYPTION_TKIP_AES_MIXED:
+    {
+        encryptionType = WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED;
+        break;
+    }
+    default:
+        break;
+    }
+
+    return encryptionType;
+}
+
+WifiEapType
+_WifiUtility::ConvertEapType(wifi_eap_type_e eapType, wifi_eap_auth_type_e eapAuthType)
+{
+    WifiEapType eapReturnType = WIFI_EAP_NONE;
+
+    switch (eapType)
+    {
+    case WIFI_EAP_TYPE_PEAP:
+        if (eapAuthType == WIFI_EAP_AUTH_TYPE_MSCHAPV2)
+        {
+            eapReturnType = WIFI_EAP_PEAP_MSCHAPV2;
+        }
+        else if(eapAuthType == WIFI_EAP_AUTH_TYPE_GTC)
+        {
+            eapReturnType = WIFI_EAP_PEAP_GTC;
+        }
+        else
+        {
+            SysLog(NID_NET_WIFI,"Not supported EAP authentication type.");
+        }
+        break;
+    case WIFI_EAP_TYPE_TLS:
+        SysLog(NID_NET_WIFI,"Not supported EAP TLS.");
+        break;
+    case WIFI_EAP_TYPE_TTLS:
+        if (eapAuthType == WIFI_EAP_AUTH_TYPE_MSCHAPV2)
+        {
+            eapReturnType = WIFI_EAP_TTLS_MSCHAPV2;
+        }
+        else
+        {
+           SysLog(NID_NET_WIFI,"Not supported EAP authentication type.");
+        }
+        break;
+    case WIFI_EAP_TYPE_SIM:
+        eapReturnType = WIFI_EAP_SIM;
+        break;
+    case WIFI_EAP_TYPE_AKA:
+        eapReturnType = WIFI_EAP_AKA;
+        break;
+    default:
+           break;
+    }
+
+    return eapReturnType;
+}
+
+wifi_eap_type_e
+_WifiUtility::ConvertEapType(WifiEapType eapType)
+{
+    wifi_eap_type_e eapReturnType = WIFI_EAP_TYPE_PEAP;
+    switch(eapType)
+    {
+    case WIFI_EAP_SIM:
+        eapReturnType = WIFI_EAP_TYPE_SIM;
+        break;
+    case WIFI_EAP_AKA:
+        eapReturnType = WIFI_EAP_TYPE_AKA;
+        break;
+    case WIFI_EAP_TTLS_MSCHAPV2:
+        eapReturnType = WIFI_EAP_TYPE_TTLS;
+        break;
+    case WIFI_EAP_PEAP_MSCHAPV2:
+        eapReturnType = WIFI_EAP_TYPE_PEAP;
+        break;
+    case WIFI_EAP_PEAP_GTC:
+        eapReturnType = WIFI_EAP_TYPE_PEAP;
+        break;
+    case WIFI_EAP_TLS:
+        eapReturnType = WIFI_EAP_TYPE_TLS;
+        break;
+    default:
+        break;
+    }
+
+    return eapReturnType;
+}
+
+wifi_eap_auth_type_e
+_WifiUtility::ConvertEapAuthType(WifiEapType eapType)
+{
+    wifi_eap_auth_type_e eapAuthType = WIFI_EAP_AUTH_TYPE_NONE;
+    switch(eapType)
+    {
+    case WIFI_EAP_SIM:
+        eapAuthType = WIFI_EAP_AUTH_TYPE_NONE;
+        break;
+    case WIFI_EAP_AKA:
+        eapAuthType = WIFI_EAP_AUTH_TYPE_NONE;
+        break;
+    case WIFI_EAP_TTLS_MSCHAPV2:
+        eapAuthType = WIFI_EAP_AUTH_TYPE_MSCHAPV2;
+        break;
+    case WIFI_EAP_PEAP_MSCHAPV2:
+        eapAuthType = WIFI_EAP_AUTH_TYPE_MSCHAPV2;
+        break;
+    case WIFI_EAP_PEAP_GTC:
+        eapAuthType = WIFI_EAP_AUTH_TYPE_GTC;
+        break;
+    case WIFI_EAP_TLS:
+        eapAuthType = WIFI_EAP_AUTH_TYPE_NONE;
+        break;
+    default:
+        break;
+    }
+    return eapAuthType;
+}
+
+String
+_WifiUtility::ConvertMacAddress(char macAddress[])
+{
+    static  const int MAX_MAC_ADDRESS_LENGTH = 17;
+    String convertMacAddress;
+
+    for (int  i = 0; i < MAX_MAC_ADDRESS_LENGTH; i++)
+    {
+        if (macAddress[i] == ':')
+        {
+            convertMacAddress.Append('-');
+        }
+        else
+        {
+            convertMacAddress.Append(macAddress[i]);
+        }
+    }
+
+    return convertMacAddress;
+}
+
+WifiBssInfo*
+_WifiUtility::CreateWifiBssInfoInstanceN(wifi_ap_h& apHandle)
+{
+    unique_ptr<WifiBssInfo> pBssInfo;
+    _WifiBssInfoImpl* pBssInfoImpl = null;
+    result r = E_SUCCESS;
+    int apRes = WIFI_ERROR_NONE;
+    bool isKnown = false;
+    char* pSsid = null;
+    char* pBssid = null;
+    WifiSecurityInfo secuInfo;
+    _WifiSecurityInfoImpl* pSecuInfoImpl = null;
+    wifi_security_type_e secType;
+    wifi_encryption_type_e encType;
+    int frequency = -1;
+    int rssi = -1;
+    int speed = -1;
+    wifi_ip_config_type_e ipType = WIFI_IP_CONFIG_TYPE_NONE;
+    NetAddressScheme netIpScheme = NET_ADDRESS_SCHEME_NONE;
+    char* pAddrStr = null;
+    unique_ptr<IpAddress> pAddress;
+    wifi_proxy_type_e proxyType = WIFI_PROXY_TYPE_DIRECT;
+    NetProxyType netProxyType = NET_PROXY_TYPE_NONE;
+
+    pBssInfo.reset(_WifiBssInfoImpl::CreateWifiBssInfoN());
+    SysTryReturn(NID_NET_WIFI, pBssInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+    pBssInfoImpl = _WifiBssInfoImpl::GetInstance(*pBssInfo);
+    pBssInfoImpl->SetBssHandle(apHandle);
+
+    // SSID
+    apRes = wifi_ap_get_essid(apHandle, &pSsid);
+    SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+               "[E_OPERATION_FAILED] Getting the SSID of the AP has failed. [0x%08X].", apRes);
+    pBssInfoImpl->SetSsid(String(pSsid));
+    free(pSsid);
+
+    // BSSID
+    apRes = wifi_ap_get_bssid(apHandle, &pBssid);
+    SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+               "[E_OPERATION_FAILED] Getting the BSSID of the AP has failed. [0x%08X].", apRes);
+    pBssInfoImpl->SetBssId(ConvertMacAddress(pBssid));
+    free(pBssid);
+
+    // Security type - Authentication type & Encryption type
+    apRes = wifi_ap_get_security_type(apHandle, &secType);
+    SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+               "[E_OPERATION_FAILED] Getting the security type of the AP has failed. [0x%08X].", apRes);
+
+    apRes = wifi_ap_get_encryption_type(apHandle, &encType);
+    SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+               "[E_OPERATION_FAILED] Getting the encryption type of the AP has failed. [0x%08X].", apRes);
+
+    pSecuInfoImpl = _WifiSecurityInfoImpl::GetInstance(secuInfo);
+    pSecuInfoImpl->SetAuthenticationType(ConvertAuthType(secType, encType));
+    pSecuInfoImpl->SetEncryptionType(ConvertEncryptionType(encType));
+    pBssInfoImpl->SetSecurityInfo(secuInfo);
+
+    // BSS Type
+    pBssInfoImpl->SetBssType(WIFI_BSS_TYPE_INFRASTRUCTURE);
+
+    // Radio Channel
+    apRes = wifi_ap_get_frequency(apHandle, &frequency);
+    SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+               "[E_OPERATION_FAILED] Getting the frequency band of the AP has failed. [0x%08X].", apRes);
+    pBssInfoImpl->SetRadioChannel(ConvertRadioChannel(frequency));
+
+    // RSSI
+    apRes = wifi_ap_get_rssi(apHandle, &rssi);
+    SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+               "[E_OPERATION_FAILED] Getting the RSSI value of the AP has failed. [0x%08X].", apRes);
+    pBssInfoImpl->SetRssi(ConvertPercentagetoRssiValue(rssi));
+
+    // Data Rate
+    apRes = wifi_ap_get_max_speed(apHandle, &speed);
+    SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+               "[E_OPERATION_FAILED] Getting the MAX speed of the AP has failed. [0x%08X].", apRes);
+    pBssInfoImpl->SetDataRate(speed);
+
+    // Known.
+    apRes = wifi_ap_is_favorite(apHandle, &isKnown);
+    SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+               "[E_OPERATION_FAILED] Checking the AP is a known device has failed. [0x%08X].", apRes);
+    pBssInfoImpl->SetKnown(isKnown);
+
+    // IP Address Scheme. Only IPv4 as the address family is taken into consideration for now.
+    apRes = wifi_ap_get_ip_config_type(apHandle, WIFI_ADDRESS_FAMILY_IPV4, &ipType);
+    SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE && ipType != WIFI_IP_CONFIG_TYPE_NONE, null, E_OPERATION_FAILED,
+               "[E_OPERATION_FAILED] Getting the IP address scheme to AP has failed. [0x%08X].", apRes);
+    netIpScheme = (ipType == WIFI_IP_CONFIG_TYPE_STATIC) ? NET_ADDRESS_SCHEME_STATIC : NET_ADDRESS_SCHEME_DYNAMIC;
+    pBssInfoImpl->SetLocalAddressScheme(netIpScheme);
+
+    if (netIpScheme == NET_ADDRESS_SCHEME_STATIC)
+    {
+        // IP Address. Only IPv4 as the address family is taken into consideration for now.
+       apRes = wifi_ap_get_ip_address(apHandle, WIFI_ADDRESS_FAMILY_IPV4, &pAddrStr);
+       SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+                       "[E_OPERATION_FAILED] Getting the IP address to AP has failed. [0x%08X].", apRes);
+       pAddress.reset(new (std::nothrow) Ip4Address(String(pAddrStr)));
+        r = GetLastResult();
+        free(pAddrStr);
+       SysTryReturn(NID_NET_WIFI, pAddress != null && r == E_SUCCESS, null, E_OPERATION_FAILED,
+                       "[E_OPERATION_FAILED] Creating an Ip4Address instance has faield. (from [%s])", GetErrorMessage(r));
+        pBssInfoImpl->SetLocalAddress(pAddress.release()); // ignore result
+
+        // Subnet Mask. Only IPv4 as the address family is taken into consideration for now.
+       apRes = wifi_ap_get_subnet_mask(apHandle, WIFI_ADDRESS_FAMILY_IPV4, &pAddrStr);
+       SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+                       "[E_OPERATION_FAILED] Getting the subnet mask to AP has failed. [0x%08X].", apRes);
+       pAddress.reset(new (std::nothrow) Ip4Address(String(pAddrStr)));
+        r = GetLastResult();
+        free(pAddrStr);
+       SysTryReturn(NID_NET_WIFI, pAddress != null && r == E_SUCCESS, null, E_OPERATION_FAILED,
+                       "[E_OPERATION_FAILED] Creating an Ip4Address instance has faield. (from [%s])", GetErrorMessage(r));
+        pBssInfoImpl->SetSubnetMaskAddress(pAddress.release()); // ignore result
+
+        // Default Gateway Address. Only IPv4 as the address family is taken into consideration for now.
+       apRes = wifi_ap_get_gateway_address(apHandle, WIFI_ADDRESS_FAMILY_IPV4, &pAddrStr);
+       SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+                       "[E_OPERATION_FAILED] Getting the default gateway address to AP has failed. [0x%08X].", apRes);
+       pAddress.reset(new (std::nothrow) Ip4Address(String(pAddrStr)));
+        r = GetLastResult();
+        free(pAddrStr);
+       SysTryReturn(NID_NET_WIFI, pAddress != null && r == E_SUCCESS, null, E_OPERATION_FAILED,
+                       "[E_OPERATION_FAILED] Creating an Ip4Address instance has faield. (from [%s])", GetErrorMessage(r));
+        pBssInfoImpl->SetDefaultGatewayAddress(pAddress.release()); // ignore result
+
+        // Primary DNS Address. Only IPv4 as the address family is taken into consideration for now.
+       apRes = wifi_ap_get_dns_address(apHandle, 1, WIFI_ADDRESS_FAMILY_IPV4, &pAddrStr);
+       SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+                       "[E_OPERATION_FAILED] Getting the primary DNS address to AP has failed. [0x%08X].", apRes);
+       pAddress.reset(new (std::nothrow) Ip4Address(String(pAddrStr)));
+        r = GetLastResult();
+        free(pAddrStr);
+       SysTryReturn(NID_NET_WIFI, pAddress != null && r == E_SUCCESS, null, E_OPERATION_FAILED,
+                       "[E_OPERATION_FAILED] Creating an Ip4Address instance has faield. (from [%s])", GetErrorMessage(r));
+        pBssInfoImpl->SetPrimaryDnsAddress(pAddress.release()); // ignore result
+
+        // Secondary DNS Address. Only IPv4 as the address family is taken into consideration for now.
+       apRes = wifi_ap_get_dns_address(apHandle, 2, WIFI_ADDRESS_FAMILY_IPV4, &pAddrStr);
+       SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+                       "[E_OPERATION_FAILED] Getting the secondary DNS address to AP has failed. [0x%08X].", apRes);
+       pAddress.reset(new (std::nothrow) Ip4Address(String(pAddrStr)));
+        r = GetLastResult();
+        free(pAddrStr);
+       SysTryReturn(NID_NET_WIFI, pAddress != null && r == E_SUCCESS, null, E_OPERATION_FAILED,
+                       "[E_OPERATION_FAILED] Creating an Ip4Address instance has faield. (from [%s])", GetErrorMessage(r));
+        pBssInfoImpl->SetSecondaryDnsAddress(pAddress.release()); // ignore result
+    }
+
+    // Proxy Type.
+    apRes = wifi_ap_get_proxy_type(apHandle, &proxyType);
+    SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+                       "[E_OPERATION_FAILED] Getting the proxy type to AP has failed. [0x%08X].", apRes);
+    netProxyType = (proxyType == WIFI_PROXY_TYPE_MANUAL) ? NET_PROXY_TYPE_MANUAL : NET_PROXY_TYPE_NONE;
+    pBssInfoImpl->SetProxyType(netProxyType);
+
+    if (netProxyType != NET_PROXY_TYPE_NONE)
+    {
+               // Proxy Address. Only IPv4 as the address family is taken into consideration for now.
+               apRes = wifi_ap_get_proxy_address(apHandle, WIFI_ADDRESS_FAMILY_IPV4, &pAddrStr);
+               SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
+                               "[E_OPERATION_FAILED] Getting the proxy address to AP has failed. [0x%08X].", apRes);
+        pBssInfoImpl->SetProxyAddress(String(pAddrStr)); // ignore result
+        free(pAddrStr);
+    }
+
+    return pBssInfo.release();
+}
+
+void
+_WifiUtility::WifiApClone(void** pDest, void* pSrc)
+{
+    wifi_ap_h *pDestAp = static_cast<wifi_ap_h*>(pDest);
+    wifi_ap_h pSrcAp = static_cast<wifi_ap_h>(pSrc);
+    wifi_ap_clone(pDestAp, pSrcAp);
+}
+
+void
+_WifiUtility::WifiApDestory(void** pApHandler)
+{
+    wifi_ap_destroy(*pApHandler);
+    *pApHandler = null;
+}
+
+bool
+_WifiUtility::CheckAddressEquality(Tizen::Net::IpAddress* pFirstAddress, Tizen::Net::IpAddress* pSecondAddress)
+{
+    if (pFirstAddress == null && pSecondAddress == null)
+    {
+        SysLog(NID_NET_WIFI, "if (pFirstAddress == null && pSecondAddress == null) true");
+        return true;
+    }
+    else if(pFirstAddress == null && pSecondAddress != null)
+    {
+        SysLog(NID_NET_WIFI, "if (pFirstAddress == null && pSecondAddress == null) false");
+        return false;
+    }
+    else if(pFirstAddress != null && pSecondAddress == null)
+    {
+        SysLog(NID_NET_WIFI, "if (pFirstAddress == null && pSecondAddress == null) false");
+        return false;
+    }
+
+    return pFirstAddress->Equals(*pSecondAddress);
+}
+
+
+
+} } } // Tizen::Net::Wifi