wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / NetworkBearerSelection / NetworkBearerSelection.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 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 #ifndef WRTPLUGINS_PLATFORM_NETWORKBEARERSELECTION_H_
19 #define WRTPLUGINS_PLATFORM_NETWORKBEARERSELECTION_H_
20
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>
31
32 namespace DeviceAPI {
33 namespace NetworkBearerSelection {
34
35 enum {
36     NETWORK_UNKNOWN = 0,
37     NETWORK_CONNECTED = 1,
38     NETWORK_DISCONNECTED = 2,
39     NETWORK_CONNECTION_FAILED = 3
40 };
41
42 class NetworkBearerSelection : public INetworkBearerSelection
43 {
44     friend class NetworkBearerSelectionFactory;
45     friend class EventNetworkBearerSelection;
46     friend class EventNetworkBearerRelease;
47
48   public:
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();
60
61   protected:
62     virtual void OnRequestReceived(const EventNetworkBearerSelectionPtr &event);
63     virtual void OnRequestReceived(const EventNetworkBearerReleasePtr &event);    
64
65   private:
66     connection_h m_connectionHandle;
67     connection_profile_h m_profileHandle;
68     std::string m_domainName;
69     long m_connectionState;
70 };
71
72 class NewtorkBearerSelectionPendingEvent
73 {
74   public:
75     NewtorkBearerSelectionPendingEvent(void *thisObject, const EventNetworkBearerSelectionPtr &event) :
76         m_thisObject(thisObject),
77         m_event(event)
78     {
79     }
80
81     virtual ~NewtorkBearerSelectionPendingEvent()
82     {
83     }
84
85     void* getThisObject() const { return m_thisObject; }
86     EventNetworkBearerSelectionPtr getEvent() const { return m_event; }
87     
88   private:
89     void *m_thisObject;
90     EventNetworkBearerSelectionPtr m_event;
91 };
92
93 class NewtorkBearerReleasePendingEvent
94 {
95   public:
96     NewtorkBearerReleasePendingEvent(void *thisObject, const EventNetworkBearerReleasePtr &event) :
97         m_thisObject(thisObject),
98         m_event(event)
99     {
100     }
101
102     virtual ~NewtorkBearerReleasePendingEvent()
103     {
104     }
105
106     void* getThisObject() const { return m_thisObject; }
107     EventNetworkBearerReleasePtr getEvent() const { return m_event; }
108     
109   private:
110     void *m_thisObject;
111     EventNetworkBearerReleasePtr m_event;
112 };
113
114
115 }
116 }
117
118 #endif