]> git.pld-linux.org Git - packages/google-gadgets.git/blame - nm09.patch
Drop XUL support, as it doesn't build since xulrunner 4.0 (15.0 is current)
[packages/google-gadgets.git] / nm09.patch
CommitLineData
de154302
JR
1Description: Update for NetworkManager 0.9 API changes
2 This patch updates the code for a few NM 0.9 API changes.
3 It builds, but I have not extensively tested the functionality.
4 NM 0.9 has added a few new connection and device states, and renumbered the
5 existing ones.
6 This means it's possible to keep compatibility with both old and new versions
7 of NM since the state numbers don't conflict.
8 The patch does this by removing some usage of defines from NetworkManager.h.
9 .
10 Furthermore, the device enums aren't going to get renumbered so I added them
11 to the code instead of using the defines. They've been the same since the
12 beginning.
13Author: danielcbwilliams@gmail.com
14Bug: http://code.google.com/p/google-gadgets-for-linux/issues/detail?id=377
15
16diff -up google-gadgets-for-linux-0.11.2/extensions/linux_system_framework/network.cc.nm09 google-gadgets-for-linux-0.11.2/extensions/linux_system_framework/network.cc
17--- google-gadgets-for-linux-0.11.2/extensions/linux_system_framework/network.cc.nm09 2009-03-14 23:12:42.000000000 -0500
18+++ google-gadgets-for-linux-0.11.2/extensions/linux_system_framework/network.cc 2011-03-25 10:58:29.022771149 -0500
19@@ -23,19 +23,21 @@ namespace ggadget {
20 namespace framework {
21 namespace linux_system {
22
23-#ifdef NM_DEVICE_TYPE_WIFI
24-static const int kDeviceTypeWifi = NM_DEVICE_TYPE_WIFI;
25-#else
26-static const int kDeviceTypeWifi = DEVICE_TYPE_802_11_WIRELESS;
27-#endif
28-
29-#ifdef NM_DEVICE_TYPE_ETHERNET
30-static const int kDeviceTypeEthernet = NM_DEVICE_TYPE_ETHERNET;
31-#else
32-static const int kDeviceTypeEthernet = DEVICE_TYPE_802_3_ETHERNET;
33-#endif
34-
35 static const int kDeviceTypeUnknown = 0;
36+static const int kDeviceTypeEthernet = 1;
37+static const int kDeviceTypeWifi = 2;
38+
39+// 0.6, 0.7, and 0.8 connected state
40+static const int kOldConnected = 3;
41+// New 0.9 connected states
42+static const int kConnectedLocal = 50;
43+static const int kConnectedSite = 60;
44+static const int kConnectedGlobal = 70;
45+
46+// 0.6, 0.7, and 0.8 activated device state
47+static const int kOldDeviceStateActivated = 8;
48+// New 0.9 activated device state
49+static const int kDeviceStateActivated = 100;
50
51 Network::Network()
52 : is_new_api_(false),
53@@ -59,14 +61,14 @@ Network::Network()
54 is_new_api_ = true;
55 int state;
56 if (network_manager_->GetProperty("State").v().ConvertToInt(&state)) {
57- is_online_ = (state == NM_STATE_CONNECTED);
58+ is_online_ = IsOnlineState(state);
59 }
60 } else {
61 DLOG("network manager 0.6.x might be used.");
62 DBusIntReceiver result;
63 if (network_manager_->CallMethod("state", true, kDefaultDBusTimeout,
64 result.NewSlot(), MESSAGE_TYPE_INVALID)) {
65- is_online_ = (result.GetValue() == NM_STATE_CONNECTED);
66+ is_online_ = IsOnlineState(result.GetValue());
67 }
68 }
69
70@@ -87,14 +89,21 @@ Network::~Network() {
71 delete network_manager_;
72 }
73
74+bool Network::IsOnlineState(int state) {
75+ return (state == kOldConnected ||
76+ state == kConnectedLocal ||
77+ state == kConnectedSite ||
78+ state == kConnectedGlobal);
79+}
80+
81 void Network::OnSignal(const std::string &name, int argc, const Variant *argv) {
82 DLOG("Got signal from network manager: %s", name.c_str());
83 bool need_update = false;
84- // nm 0.6.x uses "StateChange", 0.7.x uses "StateChanged".
85+ // nm 0.6.x uses "StateChange", 0.7.x and later use "StateChanged".
86 if (name == "StateChange" || name == "StateChanged") {
87 int state;
88 if (argc >= 1 && argv[0].ConvertToInt(&state)) {
89- is_online_ = (state == NM_STATE_CONNECTED);
90+ is_online_ = IsOnlineState(state);
91 DLOG("Network is %s.", is_online_ ? "connected" : "disconnected");
92 if (is_online_) {
93 need_update = true;
94@@ -133,7 +142,8 @@ void Network::Update() {
95 if (is_new_api_) {
96 int state;
97 if (dev->GetProperty("State").v().ConvertToInt(&state))
98- active = (state == 8); // NM_DEVICE_STATE_ACTIVATED
99+ active = (state == kOldDeviceStateActivated ||
100+ state == kDeviceStateActivated);
101 } else {
102 DBusBooleanReceiver result;
103 if (dev->CallMethod("getLinkActive", true, kDefaultDBusTimeout,
104diff -up google-gadgets-for-linux-0.11.2/extensions/linux_system_framework/network.h.nm09 google-gadgets-for-linux-0.11.2/extensions/linux_system_framework/network.h
105--- google-gadgets-for-linux-0.11.2/extensions/linux_system_framework/network.h.nm09 2011-03-25 10:51:31.120995640 -0500
106+++ google-gadgets-for-linux-0.11.2/extensions/linux_system_framework/network.h 2011-03-25 10:52:03.881586075 -0500
107@@ -55,6 +55,7 @@ class Network : public NetworkInterface
108 private:
109 void OnSignal(const std::string &name, int argc, const Variant *argv);
110 void Update();
111+ bool IsOnlineState(int state);
112
113 private:
114 // true if using nm 0.7 or above, false if using nm 0.6.x
115diff -up google-gadgets-for-linux-0.11.2/extensions/linux_system_framework/wireless.cc.nm09 google-gadgets-for-linux-0.11.2/extensions/linux_system_framework/wireless.cc
116--- google-gadgets-for-linux-0.11.2/extensions/linux_system_framework/wireless.cc.nm09 2011-03-25 10:53:42.462353647 -0500
117+++ google-gadgets-for-linux-0.11.2/extensions/linux_system_framework/wireless.cc 2011-03-25 11:01:53.707212241 -0500
118@@ -28,11 +28,10 @@
119 #include <ggadget/string_utils.h>
120 #include <ggadget/slot.h>
121
122-// defined in <linux/wireless.h>, but we don't want to introduce such
123-// dependency.
124-#define IW_MODE_AUTO 0
125-#define IW_MODE_ADHOC 1
126-#define IW_MODE_INFRA 2
127+// Define them anyway for all versions of NM
128+static const int kNmWifiModeUnknown = 0;
129+static const int kNmWifiModeAdhoc = 1;
130+static const int kNmWifiModeInfra = 2;
131
132 #if !defined(NM_DBUS_SERVICE) || !defined(NM_DBUS_PATH) || \
133 !defined(NM_DBUS_INTERFACE)
134@@ -77,15 +76,15 @@ namespace linux_system {
135
136 using namespace ggadget::dbus;
137
138-#ifdef NM_DEVICE_TYPE_WIFI
139-static const int kDeviceTypeWifi = NM_DEVICE_TYPE_WIFI;
140-#else
141-static const int kDeviceTypeWifi = DEVICE_TYPE_802_11_WIRELESS;
142-#endif
143+static const int kDeviceTypeWifi = 2;
144
145 // Defined in nm 0.7
146-static const int kDeviceStateActivated = 8;
147-static const int kDeviceStateFailed = 9;
148+static const int kOldDeviceStateActivated = 8;
149+static const int kOldDeviceStateFailed = 9;
150+// New 0.9 activated device state
151+static const int kDeviceStateActivated = 100;
152+static const int kDeviceStateDeactivating = 110;
153+static const int kDeviceStateFailed = 120;
154
155 class Wireless::Impl {
156 class WirelessAccessPoint : public WirelessAccessPointInterface {
157@@ -191,7 +190,7 @@ class Wireless::Impl {
158
159 void UpdateInfo() {
160 if (ap_) {
161- int mode = IW_MODE_AUTO;
162+ int mode = kNmWifiModeUnknown;
163 if (new_api_) { // nm 0.7.x
164 ResultVariant prop = ap_->GetProperty("Ssid");
165 if (prop.v().type() == Variant::TYPE_SCRIPTABLE) {
166@@ -223,9 +222,9 @@ class Wireless::Impl {
167 }
168 }
169
170- if (mode == IW_MODE_ADHOC)
171+ if (mode == kNmWifiModeAdhoc)
172 type_ = WIRELESS_TYPE_INDEPENDENT;
173- else if (mode == IW_MODE_INFRA)
174+ else if (mode == kNmWifiModeInfra)
175 type_ = WIRELESS_TYPE_INFRASTRUCTURE;
176 else
177 type_ = WIRELESS_TYPE_ANY;
178@@ -404,9 +403,13 @@ class Wireless::Impl {
179 } else if (signal == "StateChanged") { // nm 0.7.x
180 int new_state;
181 if (argc >= 1 && argv[0].ConvertToInt(&new_state)) {
182- connected_ = (new_state == kDeviceStateActivated);
183+ connected_ = (new_state == kDeviceStateActivated ||
184+ new_state == kOldDeviceStateActivated);
185 connect_performed = (new_state == kDeviceStateActivated ||
186- new_state == kDeviceStateFailed);
187+ new_state == kDeviceStateDeactivating ||
188+ new_state == kDeviceStateFailed ||
189+ new_state == kOldDeviceStateActivated ||
190+ new_state == kOldDeviceStateFailed);
191 }
192 } else if (signal == "AccessPointAdded") { // nm 0.7.x
193 std::string ap_path;
194@@ -441,7 +444,9 @@ class Wireless::Impl {
195 if (new_api_ && dev_ && dev_wireless_) {
196 ResultVariant prop = dev_->GetProperty("State");
197 if (prop.v().type() == Variant::TYPE_INT64) {
198- connected_ = (VariantValue<int>()(prop.v()) == kDeviceStateActivated);
199+ int state = VariantValue<int>()(prop.v());
200+ connected_ = (state == kDeviceStateActivated ||
201+ state == kOldDeviceStateActivated);
202 }
203 } else if (!new_api_ && dev_) {
204 DBusBooleanReceiver bool_receiver;
This page took 0.126808 seconds and 4 git commands to generate.