2 // Tizen Web Device API
3 // Copyright (c) 2012 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 #ifndef WRTPLUGINS_PLATFORM_NETWORKBEARERSELECTION_H_
19 #define WRTPLUGINS_PLATFORM_NETWORKBEARERSELECTION_H_
21 #include <JavaScriptCore/JavaScript.h>
22 #include <dpl/shared_ptr.h>
23 #include <dpl/noncopyable.h>
24 #include "NetworkBearerSelectionFactory.h"
25 #include "INetworkBearerSelection.h"
26 #include "EventNetworkBearerSelection.h"
27 #include "EventNetworkBearerRelease.h"
28 #include "OnNetworkBearerSelectionStateChanged.h"
29 #include <CommonsJavaScript/Converter.h>
30 #include <net_connection.h>
33 namespace NetworkBearerSelection {
37 NETWORK_CONNECTED = 1,
38 NETWORK_DISCONNECTED = 2,
39 NETWORK_CONNECTION_FAILED = 3
42 class NetworkBearerSelection : public INetworkBearerSelection
44 friend class NetworkBearerSelectionFactory;
45 friend class EventNetworkBearerSelection;
46 friend class EventNetworkBearerRelease;
49 NetworkBearerSelection();
50 virtual ~NetworkBearerSelection();
51 virtual void requestRouteToHost(const EventNetworkBearerSelectionPtr &event);
52 virtual void releaseRouteToHost(const EventNetworkBearerReleasePtr &event);
53 virtual bool checkCellularNetworkEnable();
54 void reLaunchConnection(const EventNetworkBearerSelectionPtr &event);;
55 void removeStateChangeListener(const EventNetworkBearerSelectionPtr &event);
56 void registStateChangeListener(const EventNetworkBearerSelectionPtr &event);
57 void deregistStateChangeListener(const EventNetworkBearerReleasePtr &event);
58 void makeCallback(const EventNetworkBearerSelectionPtr &event, const connectionStateType state);
59 bool checkProfileHandle();
62 virtual void OnRequestReceived(const EventNetworkBearerSelectionPtr &event);
63 virtual void OnRequestReceived(const EventNetworkBearerReleasePtr &event);
66 connection_h m_connectionHandle;
67 connection_profile_h m_profileHandle;
68 std::string m_domainName;
69 long m_connectionState;
72 class NewtorkBearerSelectionPendingEvent
75 NewtorkBearerSelectionPendingEvent(void *thisObject, const EventNetworkBearerSelectionPtr &event) :
76 m_thisObject(thisObject),
81 virtual ~NewtorkBearerSelectionPendingEvent()
85 void* getThisObject() const { return m_thisObject; }
86 EventNetworkBearerSelectionPtr getEvent() const { return m_event; }
90 EventNetworkBearerSelectionPtr m_event;
93 class NewtorkBearerReleasePendingEvent
96 NewtorkBearerReleasePendingEvent(void *thisObject, const EventNetworkBearerReleasePtr &event) :
97 m_thisObject(thisObject),
102 virtual ~NewtorkBearerReleasePendingEvent()
106 void* getThisObject() const { return m_thisObject; }
107 EventNetworkBearerReleasePtr getEvent() const { return m_event; }
111 EventNetworkBearerReleasePtr m_event;