network_fixes_up_to_5090a4ccce.patch 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. From d0780d16224d7bb2ad183542337c48324fdd2185 Mon Sep 17 00:00:00 2001
  2. From: Giovanni Campagna <gcampagna@src.gnome.org>
  3. Date: Wed, 06 Apr 2011 16:11:23 +0000
  4. Subject: NetworkMenu: keep wirelesss networks in predictable order
  5. Adds a function that compares wireless networks and keeps them sorted
  6. at all times. Order is: first already configured connections, then
  7. first secure networks, then alphabtic. Also, the appearance of a new access
  8. point no longer causes the whole menu to be rebuilt (but it still linear
  9. searches for the position, I guess that could be skipped), which caused
  10. the addition of more code for tracking the active access point.
  11. https://bugzilla.gnome.org/show_bug.cgi?id=646580
  12. ---
  13. (limited to 'js/ui/status/network.js')
  14. diff --git a/js/ui/status/network.js b/js/ui/status/network.js
  15. index 6fa5642..49cb3f0 100644
  16. --- a/js/ui/status/network.js
  17. +++ b/js/ui/status/network.js
  18. @@ -42,6 +42,10 @@ const NM80211Mode = NetworkManager['80211Mode'];
  19. const NM80211ApFlags = NetworkManager['80211ApFlags'];
  20. const NM80211ApSecurityFlags = NetworkManager['80211ApSecurityFlags'];
  21. +// number of wireless networks that should be visible
  22. +// (the remaining are placed into More...)
  23. +const NUM_VISIBLE_NETWORKS = 5;
  24. +
  25. function macToArray(string) {
  26. return string.split(':').map(function(el) {
  27. return parseInt(el, 16);
  28. @@ -1036,6 +1040,7 @@ NMDeviceWireless.prototype = {
  29. item: null,
  30. accessPoints: [ ap ]
  31. };
  32. + obj.ssidText = NetworkManager.utils_ssid_to_utf8(obj.ssid);
  33. this._networks.push(obj);
  34. }
  35. @@ -1048,6 +1053,14 @@ NMDeviceWireless.prototype = {
  36. }
  37. }
  38. }
  39. + if (this.device.active_access_point) {
  40. + this._activeNetwork = this._networks[this._findNetwork(this.device.active_access_point)];
  41. + } else {
  42. + this._activeNetwork = null;
  43. + }
  44. + this._networks.sort(this._networkSortFunction);
  45. +
  46. + this._apChangedId = device.connect('notify::active-access-point', Lang.bind(this, this._activeApChanged));
  47. this._apAddedId = device.connect('access-point-added', Lang.bind(this, this._accessPointAdded));
  48. this._apRemovedId = device.connect('access-point-removed', Lang.bind(this, this._accessPointRemoved));
  49. @@ -1055,8 +1068,13 @@ NMDeviceWireless.prototype = {
  50. },
  51. destroy: function() {
  52. - if (this._apAddedId) {
  53. + if (this._apChangedId) {
  54. // see above for this HACK
  55. + GObject.Object.prototype.disconnect.call(this.device, this._apChangedId);
  56. + this._apChangedId = 0;
  57. + }
  58. +
  59. + if (this._apAddedId) {
  60. GObject.Object.prototype.disconnect.call(this.device, this._apAddedId);
  61. this._apAddedId = 0;
  62. }
  63. @@ -1122,6 +1140,19 @@ NMDeviceWireless.prototype = {
  64. }
  65. },
  66. + _activeApChanged: function() {
  67. + this._activeNetwork = null;
  68. +
  69. + let activeAp = this.device.active_access_point;
  70. +
  71. + if (activeAp) {
  72. + let pos = this._findNetwork(activeAp);
  73. + this._activeNetwork = this._networks[pos];
  74. + }
  75. +
  76. + // we don't refresh the view here, setActiveConnection will
  77. + },
  78. +
  79. _getApSecurityType: function(accessPoint) {
  80. if (accessPoint._secType)
  81. return accessPoint._secType;
  82. @@ -1151,6 +1182,32 @@ NMDeviceWireless.prototype = {
  83. return type;
  84. },
  85. + _networkSortFunction: function(one, two) {
  86. + let oneHasConnection = one.connections.length != 0;
  87. + let twoHasConnection = two.connections.length != 0;
  88. +
  89. + // place known connections first
  90. + // (-1 = good order, 1 = wrong order)
  91. + if (oneHasConnection && !twoHasConnection)
  92. + return -1;
  93. + else if (!oneHasConnection && twoHasConnection)
  94. + return 1;
  95. +
  96. + let oneHasSecurity = one.security != NMAccessPointSecurity.NONE;
  97. + let twoHasSecurity = two.security != NMAccessPointSecurity.NONE;
  98. +
  99. + // place secure connections first
  100. + // (we treat WEP/WPA/WPA2 the same as there is no way to
  101. + // take them apart from the UI)
  102. + if (oneHasSecurity && !twoHasSecurity)
  103. + return -1;
  104. + else if (!oneHasSecurity && twoHasSecurity)
  105. + return 1;
  106. +
  107. + // sort alphabetically
  108. + return GLib.utf8_collate(one.ssidText, two.ssidText);
  109. + },
  110. +
  111. _networkCompare: function(network, accessPoint) {
  112. if (!ssidCompare(network.ssid, accessPoint.get_ssid()))
  113. return false;
  114. @@ -1173,6 +1230,8 @@ NMDeviceWireless.prototype = {
  115. _accessPointAdded: function(device, accessPoint) {
  116. let pos = this._findNetwork(accessPoint);
  117. let apObj;
  118. + let needsupdate = false;
  119. +
  120. if (pos != -1) {
  121. apObj = this._networks[pos];
  122. if (apObj.accessPoints.indexOf(accessPoint) != -1) {
  123. @@ -1181,6 +1240,8 @@ NMDeviceWireless.prototype = {
  124. }
  125. apObj.accessPoints.push(accessPoint);
  126. + if (apObj.item)
  127. + apObj.item.updateAccessPoints(apObj.accessPoints);
  128. } else {
  129. apObj = { ssid: accessPoint.get_ssid(),
  130. mode: accessPoint.mode,
  131. @@ -1189,7 +1250,8 @@ NMDeviceWireless.prototype = {
  132. item: null,
  133. accessPoints: [ accessPoint ]
  134. };
  135. - this._networks.push(apObj);
  136. + apObj.ssidText = NetworkManager.utils_ssid_to_utf8(apObj.ssid);
  137. + needsupdate = true;
  138. }
  139. // check if this enables new connections for this group
  140. @@ -1198,12 +1260,44 @@ NMDeviceWireless.prototype = {
  141. if (this._connectionValidForAP(connection, accessPoint) &&
  142. apObj.connections.indexOf(connection) == -1) {
  143. apObj.connections.push(connection);
  144. +
  145. + // this potentially changes the order
  146. + needsupdate = true;
  147. }
  148. }
  149. - // update everything
  150. - this._clearSection();
  151. - this._createSection();
  152. + if (needsupdate) {
  153. + if (apObj.item)
  154. + apObj.item.destroy();
  155. +
  156. + if (pos != -1)
  157. + this._networks.splice(pos, 1);
  158. +
  159. + if (this._networks.length == 0) {
  160. + // only network in the list
  161. + this._networks.push(apObj);
  162. + this._clearSection();
  163. + this._createSection();
  164. + return;
  165. + }
  166. +
  167. + // skip networks that should appear earlier
  168. + let menuPos = 0;
  169. + for (pos = 0;
  170. + pos < this._networks.length &&
  171. + this._networkSortFunction(this._networks[i], apObj) < 0; ++pos) {
  172. + if (this._networks[pos] != this._activeNetwork)
  173. + menuPos++;
  174. + }
  175. +
  176. + // (re-)add the network
  177. + this._networks.splice(pos, 0, apObj);
  178. +
  179. + if (this._shouldShowConnectionList()) {
  180. + menuPos += (this._activeConnectionItem ? 1 : 0);
  181. + this._createNetworkItem(apObj, menuPos);
  182. + }
  183. + }
  184. },
  185. _accessPointRemoved: function(device, accessPoint) {
  186. @@ -1315,6 +1409,12 @@ NMDeviceWireless.prototype = {
  187. // remove the connection from the access point group
  188. connections.splice(k);
  189. anyauto = connections.length == 0;
  190. +
  191. + if (anyauto) {
  192. + // this potentially changes the sorting order
  193. + forceupdate = true;
  194. + break;
  195. + }
  196. if (apObj.item) {
  197. if (apObj.item instanceof PopupMenu.PopupSubMenuMenuItem) {
  198. let items = apObj.item.menu.getMenuItems();
  199. @@ -1340,6 +1440,7 @@ NMDeviceWireless.prototype = {
  200. }
  201. if (forceupdate || anyauto) {
  202. + this._networks.sort(this._networkSortFunction);
  203. this._clearSection();
  204. this._createSection();
  205. }
  206. @@ -1355,42 +1456,24 @@ NMDeviceWireless.prototype = {
  207. this._connections.push(obj);
  208. // find an appropriate access point
  209. - let any = false, forceupdate = false;
  210. + let forceupdate = false;
  211. for (let i = 0; i < this._networks.length; i++) {
  212. let apObj = this._networks[i];
  213. // Check if connection is valid for any of these access points
  214. - let any = false;
  215. for (let k = 0; k < apObj.accessPoints.length; k++) {
  216. let ap = apObj.accessPoints[k];
  217. if (this._connectionValidForAP(connection, ap)) {
  218. apObj.connections.push(connection);
  219. - any = true;
  220. + // this potentially changes the sorting order
  221. + forceupdate = true;
  222. break;
  223. }
  224. }
  225. -
  226. - if (any && this._shouldShowConnectionList()) {
  227. - // we need to show this connection
  228. - if (apObj.item && apObj.item.menu) {
  229. - // We're already showing the submenu for this access point
  230. - apObj.item.menu.addMenuItem(this._createAPItem(connection, apObj, true));
  231. - } else {
  232. - if (apObj.item)
  233. - apObj.item.destroy();
  234. - if (apObj.connections.length == 1) {
  235. - apObj.item = this._createAPItem(connection, apObj, false);
  236. - this.section.addMenuItem(apObj.item);
  237. - } else {
  238. - apObj.item = null;
  239. - // we need to force an update to create the submenu
  240. - forceupdate = true;
  241. - }
  242. - }
  243. - }
  244. }
  245. if (forceupdate) {
  246. + this._networks.sort(this._networkSortFunction);
  247. this._clearSection();
  248. this._createSection();
  249. }
  250. @@ -1473,6 +1556,37 @@ NMDeviceWireless.prototype = {
  251. return connection;
  252. },
  253. + _createNetworkItem: function(apObj, position) {
  254. + if(apObj.connections.length > 0) {
  255. + if (apObj.connections.length == 1)
  256. + apObj.item = this._createAPItem(apObj.connections[0], apObj, false);
  257. + else {
  258. + let title = apObj.ssidText;
  259. + apObj.item = new PopupMenu.PopupSubMenuMenuItem(title);
  260. + apObj.item._apObj = apObj;
  261. + for (let i = 0; i < apObj.connections.length; i++)
  262. + apObj.item.menu.addMenuItem(this._createAPItem(apObj.connections[i], apObj, true));
  263. + }
  264. + } else {
  265. + apObj.item = new NMNetworkMenuItem(apObj.accessPoints);
  266. + apObj.item._apObj = apObj;
  267. + apObj.item.connect('activate', Lang.bind(this, function() {
  268. + let connection = this._createAutomaticConnection(apObj);
  269. + let accessPoints = sortAccessPoints(apObj.accessPoints);
  270. + this._client.add_and_activate_connection(connection, this.device, accessPoints[0].dbus_path, null)
  271. + }));
  272. + }
  273. + if (position < NUM_VISIBLE_NETWORKS)
  274. + this.section.addMenuItem(apObj.item);
  275. + else {
  276. + if (!this._overflowItem) {
  277. + this._overflowItem = new PopupMenu.PopupSubMenuMenuItem(_("More..."));
  278. + this.section.addMenuItem(this._overflowItem);
  279. + }
  280. + this._overflowItem.menu.addMenuItem(apObj.item, position - NUM_VISIBLE_NETWORKS);
  281. + }
  282. + },
  283. +
  284. _createSection: function() {
  285. if (!this._shouldShowConnectionList())
  286. return;
  287. @@ -1482,47 +1596,14 @@ NMDeviceWireless.prototype = {
  288. this.section.addMenuItem(this._activeConnectionItem);
  289. }
  290. - let activeAp = this.device.active_access_point;
  291. - let activeApSsid = activeAp ? activeAp.get_ssid() : null;
  292. -
  293. - // we want five access points in the menu, including the active one
  294. - let numItems = this._activeConnection ? 4 : 5;
  295. + let activeOffset = this._activeConnectionItem ? 1 : 0;
  296. for(let j = 0; j < this._networks.length; j++) {
  297. let apObj = this._networks[j];
  298. - if(activeAp && ssidCompare(apObj.ssid, activeApSsid))
  299. + if (apObj == this._activeNetwork)
  300. continue;
  301. - let menuItem;
  302. - if(apObj.connections.length > 0) {
  303. - if (apObj.connections.length == 1)
  304. - apObj.item = this._createAPItem(apObj.connections[0], apObj, false);
  305. - else {
  306. - let title = NetworkManager.utils_ssid_to_utf8(apObj.ssid) || _("<unknown>");
  307. - apObj.item = new PopupMenu.PopupSubMenuMenuItem(title);
  308. - apObj.item._apObj = apObj;
  309. - for (let i = 0; i < apObj.connections.length; i++)
  310. - apObj.item.menu.addMenuItem(this._createAPItem(apObj.connections[i], apObj, true));
  311. - }
  312. - } else {
  313. - apObj.item = new NMNetworkMenuItem(apObj.accessPoints);
  314. - apObj.item._apObj = apObj;
  315. - apObj.item.connect('activate', Lang.bind(this, function() {
  316. - let connection = this._createAutomaticConnection(apObj);
  317. - let accessPoints = sortAccessPoints(apObj.accessPoints);
  318. - this._client.add_and_activate_connection(connection, this.device, accessPoints[0].dbus_path, null)
  319. - }));
  320. - }
  321. -
  322. - if (j < numItems)
  323. - this.section.addMenuItem(apObj.item);
  324. - else {
  325. - if (!this._overflowItem) {
  326. - this._overflowItem = new PopupMenu.PopupSubMenuMenuItem(_("More..."));
  327. - this.section.addMenuItem(this._overflowItem);
  328. - }
  329. - this._overflowItem.menu.addMenuItem(apObj.item);
  330. - }
  331. + this._createNetworkItem(apObj, j + activeOffset);
  332. }
  333. },
  334. };
  335. --
  336. cgit v0.9
  337. From 42a5531f1588ae3063e7d8ff7642e9f81c13afbd Mon Sep 17 00:00:00 2001
  338. From: Dan Winship <danw@gnome.org>
  339. Date: Wed, 27 Apr 2011 13:05:39 +0000
  340. Subject: network: fix a variable name
  341. ---
  342. (limited to 'js/ui/status/network.js')
  343. diff --git a/js/ui/status/network.js b/js/ui/status/network.js
  344. index 49cb3f0..d56c0b1 100644
  345. --- a/js/ui/status/network.js
  346. +++ b/js/ui/status/network.js
  347. @@ -1285,7 +1285,7 @@ NMDeviceWireless.prototype = {
  348. let menuPos = 0;
  349. for (pos = 0;
  350. pos < this._networks.length &&
  351. - this._networkSortFunction(this._networks[i], apObj) < 0; ++pos) {
  352. + this._networkSortFunction(this._networks[pos], apObj) < 0; ++pos) {
  353. if (this._networks[pos] != this._activeNetwork)
  354. menuPos++;
  355. }
  356. --
  357. cgit v0.9
  358. From c31109800b3267df433841bff08c9383a5d669cb Mon Sep 17 00:00:00 2001
  359. From: Dan Williams <dcbw@redhat.com>
  360. Date: Mon, 25 Apr 2011 22:13:12 +0000
  361. Subject: network: simplify connection sorting by using libnm-glib functions
  362. Instead of rolling our own code, use new libnm-glib functions to do
  363. the same thing. Requires libnm-glib as of
  364. 779215c742bbe29a2c66202ec7e2e6d43edeb8ff (which will be part of 0.9).
  365. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=648648
  366. ---
  367. (limited to 'js/ui/status/network.js')
  368. diff --git a/js/ui/status/network.js b/js/ui/status/network.js
  369. index d56c0b1..bf8e272 100644
  370. --- a/js/ui/status/network.js
  371. +++ b/js/ui/status/network.js
  372. @@ -505,7 +505,7 @@ NMDevice.prototype = {
  373. },
  374. connectionValid: function(connection) {
  375. - throw new TypeError('Invoking pure virtual function NMDevice.connectionValid');
  376. + return this.device.connection_valid(connection);
  377. },
  378. setEnabled: function(enabled) {
  379. @@ -723,17 +723,6 @@ NMDeviceWired.prototype = {
  380. NMDevice.prototype._init.call(this, client, device, connections);
  381. },
  382. - connectionValid: function(connection) {
  383. - if (connection._type != NetworkManager.SETTING_WIRED_SETTING_NAME)
  384. - return false;
  385. -
  386. - let ethernetSettings = connection.get_setting_by_name(NetworkManager.SETTING_WIRED_SETTING_NAME);
  387. - let fixedMac = ethernetSettings.get_mac_address();
  388. - if (fixedMac)
  389. - return macCompare(fixedMac, macToArray(this.device.perm_hw_address));
  390. - return true;
  391. - },
  392. -
  393. _createSection: function() {
  394. NMDevice.prototype._createSection.call(this);
  395. @@ -876,10 +865,6 @@ NMDeviceModem.prototype = {
  396. NMDevice.prototype._clearSection.call(this);
  397. },
  398. - connectionValid: function(connection) {
  399. - return connection._type == this._connectionType;
  400. - },
  401. -
  402. _createAutomaticConnection: function() {
  403. // FIXME: we need to summon the mobile wizard here
  404. // or NM will not have the necessary parameters to complete the connection
  405. @@ -913,18 +898,6 @@ NMDeviceBluetooth.prototype = {
  406. NMDevice.prototype._init.call(this, client, device, connections);
  407. },
  408. - connectionValid: function(connection) {
  409. - if (connection._type != NetworkManager.SETTING_BLUETOOTH_SETTING_NAME)
  410. - return false;
  411. -
  412. - let bluetoothSettings = connection.get_setting_by_name(NetworkManager.SETTING_BLUETOOTH_SETTING_NAME);
  413. - let fixedBdaddr = bluetoothSettings.get_bdaddr();
  414. - if (fixedBdaddr)
  415. - return macCompare(fixedBdaddr, macToArray(this.device.hw_address));
  416. -
  417. - return true;
  418. - },
  419. -
  420. _createAutomaticConnection: function() {
  421. let connection = new NetworkManager.Connection;
  422. connection._uuid = NetworkManager.utils_uuid_generate();
  423. @@ -1047,7 +1020,7 @@ NMDeviceWireless.prototype = {
  424. // Check if some connection is valid for this AP
  425. for (let j = 0; j < validConnections.length; j++) {
  426. let connection = validConnections[j];
  427. - if (this._connectionValidForAP(connection, ap) &&
  428. + if (ap.connection_valid(connection) &&
  429. obj.connections.indexOf(connection) == -1) {
  430. obj.connections.push(connection);
  431. }
  432. @@ -1121,7 +1094,7 @@ NMDeviceWireless.prototype = {
  433. if (best) {
  434. for (let i = 0; i < bestApObj.accessPoints.length; i++) {
  435. let ap = bestApObj.accessPoints[i];
  436. - if (this._connectionValidForAP(best, ap)) {
  437. + if (ap.connection_valid(best)) {
  438. this._client.activate_connection(best, this.device, ap.dbus_path, null);
  439. break;
  440. }
  441. @@ -1257,7 +1230,7 @@ NMDeviceWireless.prototype = {
  442. // check if this enables new connections for this group
  443. for (let i = 0; i < this._connections.length; i++) {
  444. let connection = this._connections[i].connection;
  445. - if (this._connectionValidForAP(connection, accessPoint) &&
  446. + if (accessPoint.connection_valid(connection) &&
  447. apObj.connections.indexOf(connection) == -1) {
  448. apObj.connections.push(connection);
  449. @@ -1337,7 +1310,7 @@ NMDeviceWireless.prototype = {
  450. item.connect('activate', Lang.bind(this, function() {
  451. let accessPoints = sortAccessPoints(accessPointObj.accessPoints);
  452. for (let i = 0; i < accessPoints.length; i++) {
  453. - if (this._connectionValidForAP(connection, accessPoints[i])) {
  454. + if (accessPoints[i].connection_valid(connection)) {
  455. this._client.activate_connection(connection, this.device, accessPoints[i].dbus_path, null);
  456. break;
  457. }
  458. @@ -1346,40 +1319,6 @@ NMDeviceWireless.prototype = {
  459. return item;
  460. },
  461. - connectionValid: function(connection) {
  462. - if (connection._type != NetworkManager.SETTING_WIRELESS_SETTING_NAME)
  463. - return false;
  464. -
  465. - let wirelessSettings = connection.get_setting_by_name(NetworkManager.SETTING_WIRELESS_SETTING_NAME);
  466. - let wirelessSecuritySettings = connection.get_setting_by_name(NetworkManager.SETTING_WIRELESS_SECURITY_SETTING_NAME);
  467. -
  468. - let fixedMac = wirelessSettings.get_mac_address();
  469. - if (fixedMac && !macCompare(fixedMac, macToArray(this.device.perm_hw_address)))
  470. - return false;
  471. -
  472. - if (wirelessSecuritySettings &&
  473. - wirelessSecuritySettings.key_mgmt != 'none' &&
  474. - wirelessSecuritySettings.key_mgmt != 'ieee8021x') {
  475. - let capabilities = this.device.wireless_capabilities;
  476. - if (!(capabilities & NetworkManager.DeviceWifiCapabilities.WPA) ||
  477. - !(capabilities & NetworkManager.DeviceWifiCapabilities.CIPHER_TKIP))
  478. - return false;
  479. - if (wirelessSecuritySettings.get_num_protos() == 1 &&
  480. - wirelessSecuritySettings.get_proto(0) == 'rsn' &&
  481. - !(capabilities & NetworkManager.DeviceWifiCapabilities.RSN))
  482. - return false;
  483. - if (wirelessSecuritySettings.get_num_pairwise() == 1 &&
  484. - wirelessSecuritySettings.get_pairwise(0) == 'ccmp' &&
  485. - !(capabilities & NetworkManager.DeviceWifiCapabilities.CIPHER_CCMP))
  486. - return false;
  487. - if (wirelessSecuritySettings.get_num_groups() == 1 &&
  488. - wirelessSecuritySettings.get_group(0) == 'ccmp' &&
  489. - !(capabilities & NetworkManager.DeviceWifiCapabilities.CIPHER_CCMP))
  490. - return false;
  491. - }
  492. - return true;
  493. - },
  494. -
  495. _clearSection: function() {
  496. NMDevice.prototype._clearSection.call(this);
  497. @@ -1463,7 +1402,7 @@ NMDeviceWireless.prototype = {
  498. // Check if connection is valid for any of these access points
  499. for (let k = 0; k < apObj.accessPoints.length; k++) {
  500. let ap = apObj.accessPoints[k];
  501. - if (this._connectionValidForAP(connection, ap)) {
  502. + if (ap.connection_valid(connection)) {
  503. apObj.connections.push(connection);
  504. // this potentially changes the sorting order
  505. forceupdate = true;
  506. @@ -1479,37 +1418,6 @@ NMDeviceWireless.prototype = {
  507. }
  508. },
  509. - _connectionValidForAP: function(connection, ap) {
  510. - // copied and adapted from nm-applet
  511. - let wirelessSettings = connection.get_setting_by_name(NetworkManager.SETTING_WIRELESS_SETTING_NAME);
  512. - if (!ssidCompare(wirelessSettings.get_ssid(), ap.get_ssid()))
  513. - return false;
  514. -
  515. - let wirelessSecuritySettings = connection.get_setting_by_name(NetworkManager.SETTING_WIRELESS_SECURITY_SETTING_NAME);
  516. -
  517. - let fixedBssid = wirelessSettings.get_bssid();
  518. - if (fixedBssid && !macCompare(fixedBssid, macToArray(ap.hw_address)))
  519. - return false;
  520. -
  521. - let fixedBand = wirelessSettings.band;
  522. - if (fixedBand) {
  523. - let freq = ap.frequency;
  524. - if (fixedBand == 'a' && (freq < 4915 || freq > 5825))
  525. - return false;
  526. - if (fixedBand == 'bg' && (freq < 2412 || freq > 2484))
  527. - return false;
  528. - }
  529. -
  530. - let fixedChannel = wirelessSettings.channel;
  531. - if (fixedChannel && fixedChannel != NetworkManager.utils_wifi_freq_to_channel(ap.frequency))
  532. - return false;
  533. -
  534. - if (!wirelessSecuritySettings)
  535. - return true;
  536. -
  537. - return wirelessSettings.ap_security_compatible(wirelessSecuritySettings, ap.flags, ap.wpa_flags, ap.rsn_flags, ap.mode);
  538. - },
  539. -
  540. _createActiveConnectionItem: function() {
  541. let activeAp = this.device.active_access_point;
  542. let icon, title;
  543. --
  544. cgit v0.9
  545. From 101a07a3d79223cc153a6c65f22acd76cbae4818 Mon Sep 17 00:00:00 2001
  546. From: Dan Williams <dcbw@redhat.com>
  547. Date: Tue, 03 May 2011 17:21:45 +0000
  548. Subject: network: fix handling of AP flags and enhance for 802.1x
  549. All WPA APs were getting set as WPA2 due to the check for privacy;
  550. WPA/WPA2 APs *must* set the Privacy bit according to the standard,
  551. so we'd never end up in the case for NMAccessPointSecurity.WPA.
  552. Fix that, and also add flags for WPA[2] Enterprise which we'll
  553. use a bit later for the first-time connect case for 802.1x enabled
  554. access points.
  555. ---
  556. (limited to 'js/ui/status/network.js')
  557. diff --git a/js/ui/status/network.js b/js/ui/status/network.js
  558. index bf8e272..6f0cdac 100644
  559. --- a/js/ui/status/network.js
  560. +++ b/js/ui/status/network.js
  561. @@ -33,8 +33,10 @@ const NMAccessPointSecurity = {
  562. UNKNOWN: 0,
  563. NONE: 1,
  564. WEP: 2,
  565. - WPA: 3,
  566. - WPA2: 4
  567. + WPA_PSK: 3,
  568. + WPA2_PSK: 4,
  569. + WPA_ENT: 5,
  570. + WPA2_ENT: 6
  571. };
  572. // small optimization, to avoid using [] all the time
  573. @@ -1129,26 +1131,28 @@ NMDeviceWireless.prototype = {
  574. _getApSecurityType: function(accessPoint) {
  575. if (accessPoint._secType)
  576. return accessPoint._secType;
  577. - // XXX: have this checked by someone familiar with IEEE 802.1x
  578. let flags = accessPoint.flags;
  579. let wpa_flags = accessPoint.wpa_flags;
  580. let rsn_flags = accessPoint.rsn_flags;
  581. let type;
  582. - if ( !(flags & NM80211ApFlags.PRIVACY)
  583. - && (wpa_flags == NM80211ApSecurityFlags.NONE)
  584. - && (rsn_flags == NM80211ApSecurityFlags.NONE))
  585. - type = NMAccessPointSecurity.NONE;
  586. - else if ( (flags & NM80211ApFlags.PRIVACY)
  587. - && (wpa_flags == NM80211ApSecurityFlags.NONE)
  588. - && (rsn_flags == NM80211ApSecurityFlags.NONE))
  589. - type = NMAccessPointSecurity.WEP;
  590. - else if ( !(flags & NM80211ApFlags.PRIVACY)
  591. - && (wpa_flags != NM80211ApSecurity.NONE)
  592. - && (rsn_flags != NM80211ApSecurity.NONE))
  593. - type = NMAccessPointSecurity.WPA;
  594. - else
  595. - type = NMAccessPointSecurity.WPA2;
  596. + if (rsn_flags != NM80211ApSecurityFlags.NONE) {
  597. + /* RSN check first so that WPA+WPA2 APs are treated as RSN/WPA2 */
  598. + if (rsn_flags & NM80211ApSecurityFlags.KEY_MGMT_802_1X)
  599. + type = NMAccessPointSecurity.WPA2_ENT;
  600. + else if (rsn_flags & NM80211ApSecurityFlags.KEY_MGMT_PSK)
  601. + type = NMAccessPointSecurity.WPA2_PSK;
  602. + } else if (wpa_flags != NM80211ApSecurityFlags.NONE) {
  603. + if (wpa_flags & NM80211ApSecurityFlags.KEY_MGMT_802_1X)
  604. + type = NMAccessPointSecurity.WPA_ENT;
  605. + else if (wpa_flags & NM80211ApSecurityFlags.KEY_MGMT_PSK)
  606. + type = NMAccessPointSecurity.WPA_PSK;
  607. + } else {
  608. + if (flags & NM80211ApFlags.PRIVACY)
  609. + type = NMAccessPointSecurity.WEP;
  610. + else
  611. + type = NMAccessPointSecurity.NONE;
  612. + }
  613. // cache the found value to avoid checking flags all the time
  614. accessPoint._secType = type;
  615. --
  616. cgit v0.9
  617. From ae0652d13fc2d7caa3d64f2b87d174253cae5901 Mon Sep 17 00:00:00 2001
  618. From: Dan Williams <dcbw@redhat.com>
  619. Date: Tue, 03 May 2011 18:31:45 +0000
  620. Subject: network: fix initial connections to WPA[2] Enterprise APs
  621. Call out to nm-applet to do the dirty work since the dialog of
  622. doom is pretty complicated and we don't have a JS equivalent
  623. of it for now.
  624. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=648171
  625. ---
  626. (limited to 'js/ui/status/network.js')
  627. diff --git a/js/ui/status/network.js b/js/ui/status/network.js
  628. index 6f0cdac..ca4facf 100644
  629. --- a/js/ui/status/network.js
  630. +++ b/js/ui/status/network.js
  631. @@ -48,6 +48,16 @@ const NM80211ApSecurityFlags = NetworkManager['80211ApSecurityFlags'];
  632. // (the remaining are placed into More...)
  633. const NUM_VISIBLE_NETWORKS = 5;
  634. +const NMAppletHelperInterface = {
  635. + name: 'org.gnome.network_manager_applet',
  636. + methods: [
  637. + { name: 'ConnectToHiddenNetwork', inSignature: '', outSignature: '' },
  638. + { name: 'CreateWifiNetwork', inSignature: '', outSignature: '' },
  639. + { name: 'ConnectTo8021xNetwork', inSignature: 'oo', outSignature: '' }
  640. + ],
  641. +};
  642. +const NMAppletProxy = DBus.makeProxyClass(NMAppletHelperInterface);
  643. +
  644. function macToArray(string) {
  645. return string.split(':').map(function(el) {
  646. return parseInt(el, 16);
  647. @@ -991,6 +1001,10 @@ NMDeviceWireless.prototype = {
  648. this._overflowItem = null;
  649. this._networks = [ ];
  650. + this._applet_proxy = new NMAppletProxy(DBus.session,
  651. + 'org.gnome.network_manager_applet',
  652. + '/org/gnome/network_manager_applet');
  653. +
  654. // breaking the layers with this, but cannot call
  655. // this.connectionValid until I have a device
  656. this.device = device;
  657. @@ -1483,9 +1497,20 @@ NMDeviceWireless.prototype = {
  658. apObj.item = new NMNetworkMenuItem(apObj.accessPoints);
  659. apObj.item._apObj = apObj;
  660. apObj.item.connect('activate', Lang.bind(this, function() {
  661. - let connection = this._createAutomaticConnection(apObj);
  662. let accessPoints = sortAccessPoints(apObj.accessPoints);
  663. - this._client.add_and_activate_connection(connection, this.device, accessPoints[0].dbus_path, null)
  664. + if ( (accessPoints[0]._secType == NMAccessPointSecurity.WPA2_ENT)
  665. + || (accessPoints[0]._secType == NMAccessPointSecurity.WPA_ENT)) {
  666. + // 802.1x-enabled APs get handled by nm-applet for now...
  667. + this._applet_proxy.ConnectTo8021xNetworkRemote(this.device.get_path(),
  668. + accessPoints[0].dbus_path,
  669. + Lang.bind(this, function(results, err) {
  670. + if (err)
  671. + log(err);
  672. + }));
  673. + } else {
  674. + let connection = this._createAutomaticConnection(apObj);
  675. + this._client.add_and_activate_connection(connection, this.device, accessPoints[0].dbus_path, null)
  676. + }
  677. }));
  678. }
  679. if (position < NUM_VISIBLE_NETWORKS)
  680. --
  681. cgit v0.9
  682. From 5090a4ccce87643081138272fb8a2fe687f1ed0a Mon Sep 17 00:00:00 2001
  683. From: Dan Williams <dcbw@redhat.com>
  684. Date: Tue, 03 May 2011 19:48:10 +0000
  685. Subject: network: request that nm-applet show the mobile broadband wizard
  686. Use nm-applet 0.8.999 API to call the mobile broadband wizard and
  687. activate the new connection.
  688. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=649318
  689. ---
  690. (limited to 'js/ui/status/network.js')
  691. diff --git a/js/ui/status/network.js b/js/ui/status/network.js
  692. index ca4facf..756b27f 100644
  693. --- a/js/ui/status/network.js
  694. +++ b/js/ui/status/network.js
  695. @@ -53,7 +53,8 @@ const NMAppletHelperInterface = {
  696. methods: [
  697. { name: 'ConnectToHiddenNetwork', inSignature: '', outSignature: '' },
  698. { name: 'CreateWifiNetwork', inSignature: '', outSignature: '' },
  699. - { name: 'ConnectTo8021xNetwork', inSignature: 'oo', outSignature: '' }
  700. + { name: 'ConnectTo8021xNetwork', inSignature: 'oo', outSignature: '' },
  701. + { name: 'ConnectTo3gNetwork', inSignature: 'o', outSignature: '' }
  702. ],
  703. };
  704. const NMAppletProxy = DBus.makeProxyClass(NMAppletHelperInterface);
  705. @@ -440,7 +441,8 @@ NMDevice.prototype = {
  706. this._client.activate_connection(this._connections[0].connection, this.device, null, null);
  707. } else if (this._autoConnectionName) {
  708. let connection = this._createAutomaticConnection();
  709. - this._client.add_and_activate_connection(connection, this.device, null, null);
  710. + if (connection)
  711. + this._client.add_and_activate_connection(connection, this.device, null, null);
  712. }
  713. },
  714. @@ -620,7 +622,8 @@ NMDevice.prototype = {
  715. this._autoConnectionItem = new PopupMenu.PopupMenuItem(this._autoConnectionName);
  716. this._autoConnectionItem.connect('activate', Lang.bind(this, function() {
  717. let connection = this._createAutomaticConnection();
  718. - this._client.add_and_activate_connection(connection, this.device, null, null);
  719. + if (connection)
  720. + this._client.add_and_activate_connection(connection, this.device, null, null);
  721. }));
  722. this.section.addMenuItem(this._autoConnectionItem);
  723. }
  724. @@ -777,6 +780,10 @@ NMDeviceModem.prototype = {
  725. this.mobileDevice = null;
  726. this._connectionType = 'ppp';
  727. + this._applet_proxy = new NMAppletProxy(DBus.session,
  728. + 'org.gnome.network_manager_applet',
  729. + '/org/gnome/network_manager_applet');
  730. +
  731. this._capabilities = device.current_capabilities;
  732. if (this._capabilities & NetworkManager.DeviceModemCapabilities.GSM_UMTS) {
  733. is_wwan = true;
  734. @@ -878,19 +885,13 @@ NMDeviceModem.prototype = {
  735. },
  736. _createAutomaticConnection: function() {
  737. - // FIXME: we need to summon the mobile wizard here
  738. - // or NM will not have the necessary parameters to complete the connection
  739. - // pending a DBus method on nm-applet
  740. -
  741. - let connection = new NetworkManager.Connection;
  742. - connection._uuid = NetworkManager.utils_uuid_generate();
  743. - connection.add_setting(new NetworkManager.SettingConnection({
  744. - uuid: connection._uuid,
  745. - id: this._autoConnectionName,
  746. - type: this._connectionType,
  747. - autoconnect: false
  748. - }));
  749. - return connection;
  750. + // Mobile wizard is handled by nm-applet for now...
  751. + this._applet_proxy.ConnectTo3gNetworkRemote(this.device.get_path(),
  752. + Lang.bind(this, function(results, err) {
  753. + if (err)
  754. + log(err);
  755. + }));
  756. + return null;
  757. }
  758. };
  759. --
  760. cgit v0.9