Initialize Tizen 2.3
[framework/osp/net.git] / src / wifi / FNetWifi_WifiDirectGroupOwnerEvent.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file    FNetWifi_WifiDirectGroupOwnerEvent.cpp
20  * @brief   This is the implementation file for the _WifiDirectGroupOwnerEvent Class.
21  *
22  * This header file contains implementation of the _WifiDirectGroupOwner Class.
23  */
24
25 #include <FBaseRtIEventListener.h>
26 #include <FNetWifiIWifiDirectGroupOwnerListener.h>
27 #include <FNetWifiWifiDirectDeviceInfo.h>
28 #include <FNetNetConnection.h>
29 #include <FBaseSysLog.h>
30 #include "FNetWifi_WifiDirectGroupOwnerEvent.h"
31 #include "FNetWifi_WifiDirectEventArg.h"
32
33 using namespace Tizen::Base::Collection;
34
35 namespace Tizen { namespace Net { namespace Wifi
36 {
37
38 _WifiDirectGroupOwnerEvent::_WifiDirectGroupOwnerEvent(void)
39 {
40 }
41
42 _WifiDirectGroupOwnerEvent::~_WifiDirectGroupOwnerEvent(void)
43 {
44
45 }
46
47 result
48 _WifiDirectGroupOwnerEvent::Construct(void)
49 {
50         return _Event::Initialize();
51 }
52
53 void
54 _WifiDirectGroupOwnerEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
55 {
56         const _WifiDirectEventArg* pArg = dynamic_cast< const _WifiDirectEventArg* >(&arg);
57         SysTryReturnVoidResult(NID_NET_WIFI, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is a null pointer.");
58
59         result r = pArg->GetError();
60         SysLog(NID_NET_WIFI, "The result value of IEventArg is %s.", GetErrorMessage(r));
61
62         IWifiDirectGroupOwnerListener* pGroupOwnerListener = dynamic_cast< IWifiDirectGroupOwnerListener* >(&listener);
63         SysTryReturnVoidResult(NID_NET_WIFI, pGroupOwnerListener != null, E_INVALID_ARG, "[E_INVALID_ARG] The listener argument is invalid.");
64
65         _WifiDirectEventType eventType = pArg->GetEventType();
66         WifiDirectDeviceId localDeviceId = pArg->GetDeviceId();
67
68         switch (eventType)
69         {
70         case WIFI_DIRECT_GO_EVENT_CLIENT_ASSOCIATED:
71                 SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_GO_EVENT_CLIENT_ASSOCIATED)");
72                 {
73                         WifiDirectDeviceInfo* pClientDeviceInfo = pArg->GetDeviceInfo();
74                         pGroupOwnerListener->OnWifiDirectClientAssociated(localDeviceId, *pClientDeviceInfo);
75                 }
76                 break;
77
78         case WIFI_DIRECT_GO_EVENT_CLIENT_DISASSOCIATED:
79                 SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_GO_EVENT_CLIENT_DISASSOCIATED)");
80                 {
81                         WifiDirectAssociationTerminationReason reason = pArg->GetDisassociationReason();
82                         WifiDirectDeviceInfo* pClientDeviceInfo = pArg->GetDeviceInfo();
83                         pGroupOwnerListener->OnWifiDirectClientDisassociated(localDeviceId, *pClientDeviceInfo, reason);
84                 }
85                 break;
86
87         case WIFI_DIRECT_GO_EVENT_GROUP_DESTROYED:
88         case WIFI_DIRECT_DEVICE_EVENT_GROUP_LEFT:
89
90                 SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_GO_EVENT_GROUP_DESTROYED)");
91                 pGroupOwnerListener->OnWifiDirectGroupDestroyed(localDeviceId, r);
92                 break;
93
94         case WIFI_DIRECT_GO_EVENT_SERVICE_STARTED:
95                 SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_GO_EVENT_SERVICE_STARTED)");
96                 {
97                         const Tizen::Net::NetConnection* pNetConnection = pArg->GetNetConnection();
98                         pGroupOwnerListener->OnWifiDirectGroupMemberInfoServiceStarted(localDeviceId, pNetConnection, r);
99                 }
100                 break;
101
102         case WIFI_DIRECT_GO_EVENT_SERVICE_STOPPED:
103                 SysLog(NID_NET_WIFI, "Firing External Event (Type: WIFI_DIRECT_GO_EVENT_SERVICE_STOPPED)");
104                 pGroupOwnerListener->OnWifiDirectGroupMemberInfoServiceStopped(localDeviceId, r);
105                 break;
106
107         default:
108                 SysLog(NID_NET_WIFI, "An undefined external WifiDirectGroupOwner event occurs. (Type: %d)", eventType);
109                 SysAssert(false);
110         }
111 }
112
113 } } } // Tizen::Net::Wifi