2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FNet_NetConnectionEvent.h
19 * @brief This is the header file for _NetConnectionEvent class.
22 * This header file contains the declarations of _NetConnectionEvent class.
23 * The _NetConnectionEvent class can call listener's method. So, when an event is occurred,
24 * application can handle it appropriately.
27 #ifndef _FNET_INTERNAL_NET_CONNECTION_EVENT_H_
28 #define _FNET_INTERNAL_NET_CONNECTION_EVENT_H_
30 #include <FBaseDataType.h>
31 #include <FBaseColIHashCodeProviderT.h>
32 #include <FBaseColIComparerT.h>
33 #include <FNetNetTypes.h>
34 #include <FBaseRt_Event.h>
35 #include "FNet_NetTypes.h"
37 namespace Tizen { namespace Base
42 namespace Tizen { namespace Base { namespace Runtime
46 } } } // Tizen::Base::Runtime
48 namespace Tizen { namespace Net
50 class _SystemNetConnection;
52 enum _NetConnectionEventType
54 _NET_CONNECTION_EVENT_TYPE_NONE,
55 _NET_CONNECTION_EVENT_TYPE_STARTED,
56 _NET_CONNECTION_EVENT_TYPE_STOPPED,
57 _NET_CONNECTION_EVENT_TYPE_SUSPENDED,
58 _NET_CONNECTION_EVENT_TYPE_RESUMED,
59 _NET_CONNECTION_EVENT_TYPE_CHANGED
62 typedef Tizen::Base::Runtime::IEventListener* _NetListenerKey;
64 class _NetListenerHashCodeProvider
65 : public Tizen::Base::Collection::IHashCodeProviderT<_NetListenerKey>
68 _NetListenerHashCodeProvider(void);
69 ~_NetListenerHashCodeProvider(void);
71 virtual int GetHashCode(const _NetListenerKey& obj) const;
74 _NetListenerHashCodeProvider(const _NetListenerHashCodeProvider& rhs);
75 _NetListenerHashCodeProvider& operator =(const _NetListenerHashCodeProvider& rhs);
76 }; // _NetListenerHashCodeProvider
78 class _NetListenerComparer
79 : public Tizen::Base::Collection::IComparerT<_NetListenerKey>
82 _NetListenerComparer(void);
83 ~_NetListenerComparer(void);
85 virtual result Compare(const _NetListenerKey& obj1, const _NetListenerKey& obj2, int& cmp) const;
88 _NetListenerComparer(const _NetListenerComparer& rhs);
89 _NetListenerComparer& operator =(const _NetListenerComparer& rhs);
90 }; // _NetListenerComparer
92 class _NetConnectionEvent :
93 public Tizen::Base::Runtime::_Event
96 _NetConnectionEvent(void);
97 virtual ~_NetConnectionEvent(void);
99 virtual result Construct(void);
102 result AddNetConnectionEventListener(const Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Object* pConnection);
103 result RemoveNetConnectionEventListener(const Tizen::Base::Runtime::IEventListener& listener);
104 void RemoveAllNetConnectionEventListener(const Tizen::Base::Object* pConnection);
106 void SetConnectionState(NetConnectionState connectionState);
107 NetConnectionState GetConnectionState(void) const;
109 void SetSystemConnection(_SystemNetConnection* pConnection, bool isManaged = true);
110 bool IsManagedSystemConnection(void) const;
116 virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
120 * This is the copy constructor.
122 * @param[in] rhs An instance of _NetConnectionEvent
124 _NetConnectionEvent(const _NetConnectionEvent& rhs);
127 * This is the assignment operator.
129 * @param[in] rhs An instance of _NetConnectionEvent
131 _NetConnectionEvent& operator =(const _NetConnectionEvent& rhs);
135 _NetListenerHashCodeProvider __hashCodeProvider;
136 _NetListenerComparer __comparer;
137 NetConnectionState __connectionState;
138 _SystemNetConnection* __pSystemConnection;
139 bool __isManagedSystemConnection;
140 Tizen::Base::Collection::HashMapT<_NetListenerKey, Tizen::Base::Object*>* __pListenerMap;
141 }; // _NetConnectionEvent
144 #endif // _FNET_INTERNAL_NET_CONNECTION_EVENT_H_