~ken-vandine/ubuntu-system-settings/rtm_click_framework_check

« back to all changes in this revision

Viewing changes to plugins/wifi/wifidbushelper.cpp

[ CI bot ]
* Resync trunk
[ Michael Zanetti ]
* update code to reset launcher after launcher backend implementation
  was reworked (LP: #1376707)
[ Sebastien Bacher ]
* [storage] translator comment for the string "%1 free" (LP: #1377929)
* [system-update] ellipsize labels if needed (LP: #1376286)
* [sound] Use the correct low icon (LP: #1376286)
[ Lars Uebernickel ]
* notification-manager: fix issues with GVariant API usage
[ jonas-drange ]
* [security/privacy] allow user to change HERE and location detection
  settings. (LP: #1375322)
[ Ken VanDine ]
* Updated the pot file.
[ jonas-drange ]
* [cellular] indirectly recreate ConnectionManager interface's dbus
  proxy so it reports the true value of 'Powered' after flight mode
  (LP: #1376957)
[ Iain Lane ]
* [sound] Make listSounds take a list of directories and list all of
  the files in them, instead of assuming "/custom" all the time.
[ Ubuntu daily release ]
* New rebuild forced
[ Sebastien Bacher ]
* [sound] list custom ringtones as well (LP: #1381528)
[ Ken VanDine ]
* Add an APN editor. (LP: #1225174)
[ Michael Terry ]
* Complete the unlock security screens and update a host of other
  small design issues. (LP: #1365034, LP: #1348362) (LP: #1365034,
  #1348362)
[ Diego Sarmentero ]
* Improves in network backend. Detect network connection and show
  "Connect to the internet..." message or retry on netword detected. .
* Detect account added on online accounts (LP: #1362149)
[ jonas-drange ]
* [wifi/phone] dynamically chooses what SIM to use when there's only
  one present. (LP: #1375832)
[ Iain Lane ]
* [storage/about] Use a QSharedPointer to manage freeing of the
  counter which we use to display all of the collected sizes at once.
  If the measuring process was cancelled, we were freeing it multiple
  times - once for each outstanding size measurement. This led to a
  crash. (LP: #1375988)
* [security-privacy] Link with gobject, uses symbols from this
  library. Prevents "[…]libUbuntuSecurityPrivacyPanel.so contains an
  unresolvable reference to symbol
  g_signal_handlers_disconnect_matched: it's probably a plugin"
  warnings.
[ jonas-drange ]
* [cellular] react to application.state changes and update potential
  out-of-date default SIM settings (LP: #1364103)
* [wifi] let removed networks update the previous network model so
  that we can reuse the model (and not pop the pagestack twice,
  causing this ux issue) (LP: #1370389)
[ Sebastien Bacher ]
* [location] use a flickable so the list can be scrolled (LP:
  #1374017)
* [security] get localized application names from the trust-store (LP:
  #1374018)
[ Ken VanDine ]
* Fixed handling of the Downloading/Installing label based on actual
  state. . Forward updateProgress signals for system updates. Layout
  fixes (LP: #1312587)
* Use new splash screen (LP: #1376242)
* Improved tracking download states
* Use new target_build_number from system-image-dbus to determine
  visibility of the update notification (LP: #1355803)
[ CI bot ]
* Resync trunk
[ Sebastien Bacher ]
* [storage] use libclick rather than calling the command line (LP:
  #1368967)
* [storage] tweaks to the disk informations, limit the free space to
  the user available one (excluding the system partitions), don't list
  the external mounts, that's described in the design and is going to
  require work on the categories computation to give correct values
  (LP: #1284247)
* [about] display the free space value next to the storage label (LP:
  #1335144)
[ Albert Astals ]
* Add i18n.tr
[ jonas-drange ]
* [wifi] connect to hidden network is now a dialog (LP: #1366005)
[ Ken VanDine ]
* Provide more keywords to make search useful (LP: #1370219) (LP:
  #1370219)
* [background] set sourceSize in the image preview to work around an
  issue loading large images (LP: #1373462)
[ CI bot ]
* Resync trunk
[ Mathieu Trudel-Lapierre ]
* [bluetooth] Properly handle device types for connection and
  disconnection. (LP: #1369964)
[ Michael Terry ]
* Add a translator comment for what HERE means. (LP: #1368838) (LP:
  #1368838)
* Prevent a crash in unity8 when the wizard also crashes or stops
  early. (LP: #1355892) (LP: #1355892)
[ Michael Terry ]
* Prevent the buttons of the wizard's password page from overlapping
  its content when the OSK appears. (LP: #1368346) (LP: #1368346)
[ Ken VanDine ]
* Set the version information in the SystemUpdate constructor (LP:
  #1371810) (LP: #1371810)
* [reset] Don't bail out on an isValid() check on the SystemImage
  QDBusInterface, the docs say isValid() may not be reliable for
  remote interfaces (LP: #1370815) (LP: #1370815)
* Fixed reference error for count on the various device models (LP:
  #1362517) (LP: #1362517)
* [background] Use the ContentPeerPicker to select sources for
  backgrounds (LP: #1356542) (LP: #1356542)
[ Iain Lane ]
* Don't check if the timedated interface is valid before calling
  SetTime on it, it might have timed out and we should reactivate it
  in that case.
* [about] Fix developerMode property to be QMLish - read & write
  instead of separate "read" and "toggle" properties.
* [about] Don't display a frame for icons that can't be found,
  improving the visual appearance. Also return the correct path for
  click packages which use the icon theme.
[ Sebastien Bacher ]
* [storage] handle the scope click .ini and get the correct icons (LP:
  #1368920)
[ Albert Astals ]
* make pot
[ Oliver Grawert ]
* fix LP: #1365903, add a watch to Developer Mode page so the page
  gets refreshed when going back through the page stack, also fix the
  page id and bounds (LP: #1365903)
* Some packaging fixes
  - > is not a valid relationship. It should be >>
  - Don't recommend suru-icon-theme since we also depend on it
  - Bump S-V to 3.9.6 which for example allows the images we ship in
    /usr/lib/
  - Override binary-no-manpage lintian warnings. We're not going to get man
    pages for u-s-s any time soon
[ Ken VanDine ]
* Make UpdateManager a singleton and refresh the availableUpdates
  count when the model updates (LP: #1325629) (LP: #1325629)
[ Ken VanDine ]
* Include an icon instead of using the themed icon (LP: #1365408) (LP:
  #1365408)
[ Mathieu Trudel-Lapierre ]
* [bluetooth] don't try to enable Discoverable if the device isn't
  powered yet. (LP: #1355904)
[ Ken VanDine ]
* When activated by a url request for a specific panel, clear the
  pageStack to maintain the natural navigation instead of pushing a
  new page on top of a page from a the previous panel (LP: #1362025)
  (LP: #1362025, #1359953)
[ Lars Uebernickel ]
* Use Icon instead of StatusIcon
[ CI bot ]
* Resync trunk
[ John R. Lenton ]
* Take the system settings push helper closer to implementing the spec
  at https://wiki.ubuntu.com/SoftwareUpdates#Prompting (LP: #1363972)
[ Ken VanDine ]
* Don't try to tweak the bottomMargin for the OSK, it was trying to
  calculate it based on an undefined component so failing. It
  shouldn't be needed anyway.
[ jonas-drange ]
* [wifi] "Other Network" -> "Connect to hidden network" (LP: #1365984)
* [wifi] fix bad looking buttons in "Other Networks" panel (LP:
  #1362127)
[ Jussi Pakkanen ]
* Hide entry to connect to hidden network when wifi is off. (LP:
  #1365960)
[ Ken VanDine ]
* Fixed tests for the dialpad settings failing on mako
* Don't call downloadUpdate when we see a system update ready, the
  service does that for us (LP: #1368294) (LP: #1368294)
* Translate desktop file (LP: #1318008) (LP: #1318008)
[ Martin Pitt ]
* update POT
[ Sebastien Bacher ]
* [system-update] open the ubuntuone subpanel rather than the list
  (LP: #1348580)
* [security-privacy] use ngettext strings when needed (LP: #1368159)
* Increase vertical spacing in the settings grid (LP: #1348579)
[ jonas-drange ]
* [background] always keep custom images, and remove press-and-hold
  action. (LP: #1365167)
* [wifi] do not use predictive text for network name input (LP:
  #1365992)
* [language] workaround for transition bug in keyboard layout menu
  (LP: #1350809)
* [wifi] factory was setting the icon property, which was causing the
  icon to not render (LP: #1364366)
[ Alejandro J. Cura ]
* Fixing the refreshing of the apps scope (LP: #1360369)
[ Sebastien Bacher ]
* [sound] use the correct backend to control the keyboard sound toggle
  (LP: #1366208)
[ Ken VanDine ]
* Don't call downloadUpdate for system updates that are already
  downloading (LP: #1365646) (LP: #1311219, #1365646)
[ Ken VanDine ]
* Notify the user if the phone needs to be plug to power for update.
[ Sebastien Bacher ]
* [system-update] don't draw a frame around ubuntu updates (LP:
  #1367136)
[ Mathieu Trudel-Lapierre ]
* Also allow Speakers and Carkits as valid audio devices to pair.
[ Michael Terry ]
* Allow switch from PIN code to passphrase and back using the same
  password. (LP: #1357043) (LP: #1357043)
* Fix false-negatives from AccountsService when switching from swipe
  to password (LP: #1363405) (LP: #1363405)
[ Ricardo Salveti de Araujo ]
* sound: setting default audio role for ringtone and messages
[ Michael Terry ]
* Don't crash when destructing the Wizard.Utils.System plugin. This
  fixes the crash on wizard exit and the crash when pressing back on
  the HERE license.
[ CI bot ]
* Resync trunk
[ Sebastien Bacher ]
* [developer-mode] working scrolling and correct spacing
* Use standard items for the categories and don't display dividers
  (LP: #1365563)
* [orientation-lock] don't display a frame around the icon (LP:
  #1365450)
[ jonas-drange ]
* [about/versions] create reusable component of singlevalue items that
  have long values (LP: #1363927)
[ David Barth ]
* Enable location panel, display contols for authorized applications.
[ Ken VanDine ]
* Tweak the depends for accountsservice-ubuntu-schemas to handle a "~"
  version
[ CI bot ]
* Resync trunk
[ Guillermo Gonzalez ]
* Basic unittest for the push-helper script
[ Mathieu Trudel-Lapierre ]
* Downgrade qFatal failure to register bluetooth agent to a qCritical.
[ Andrea Cimitan ]
* Various fixes for wifi wizard page (LP: #1362296)
[ Sebastien Bacher ]
* [security] don't mark "%1" string as translatable
* [security] give a translation context to the 'None' string (LP:
  #1362143)
* [licenses] display an error when the copyright can't be read (LP:
  #1206150)
[ Michael Terry ]
* Avoid another race condition when switching password types by
  completing all DBus operations synchronously as we exit the
  policykit agent. LP: 1361137 (LP: #1361137)
* Fix the OSK not working on first boot. When the wizard closes, shut
  down maliit-server and the indicators so that unity8 can start them
  itself. LP: 1362679 (LP: #1362679)
[ jonas-drange ]
* [about] print out phone numbers for dual sims as well
* [about/wifi] adding mac addresses for bt and wifi, and ip for wifi
  (LP: #1356239)
* [language] explain to the user that a reboot is necessary for the
  change to take effect (LP: #1240875)
[ Michael Terry ]
* Make the HERE license optional, clearly mark it as a HERE license
  instead of an Ubuntu license, and connect it to the HERE backend.
[ CI bot ]
* Resync trunk
[ Martin Pitt ]
* POT update
[ Ken VanDine ]
* Added setting for dialpad sounds to both the sound and phone panels.
[ CI bot ]
* Resync trunk
[ Diego Sarmentero ]
* Fix out of sync image download. Refresh scope after installation
  (LP: #1324923)
[ Sebastien Bacher ]
* [battery] refresh the graph on a minute basis
* [notifications] use normal text style and ubuntushaped icons
[ Michael Terry ]
* When changing to swipe mode, it was possible that our policykit
  agent would not unregister itself, making the next attempt to change
  modes appear to work, but in truth fail. Also, no longer ask for a
  password to switch to swipe mode if policykit has a cached
  authentication for us. (LP: #1350381)
[ Sebastien Bacher ]
* [security] tweak some pin locking details to match the design better
[ Michael Terry ]
* Implement the "When locked, allow:" portion of the Security &
  Privacy panel, so now the user can control whether the launcher
  and/or indicators are available while locked. (LP: #1358340) (LP:
  #1358340)
[ Michael Terry ]
* Update look and feel of wizard to more closely match the visual
  design.
[ Jussi Pakkanen ]
* Minor cleanups.
[ Roberto Alsina ]
* Don't crash the push helper in locales that have no .mo file (LP:
  #1357506)
[ Ken VanDine ]
* SIM PIN lock implementation
[ jonas-drange ]
* [main panel] add visual feedback on press
* [cellular] uses modemtechnologies property from ofono to populate
  technology preference options (LP: #1346790)
[ Sebastien Bacher ]
* [language] workaround inconsistent languages casing (LP: #1362123)
* [background] Display the default background selected (LP: #1349329)
* [storage] display translated names (LP: #1360207)
* [updates] don't display animations when clicking on update rows (LP:
  #1360364)
* [background] don't use an icon in the headerbar (LP: #1362122)
[ Mathieu Trudel-Lapierre ]
* Fix PIN code or passcode requests by properly matching the tag for
  the original request. (LP: #1355152)
[ Martin Pitt ]
* Update PO template
[ Sebastien Bacher ]
* Include extra files for translations (LP: #1359267)
[ jonas-drange ]
* [main panel] show rotation lock, point to correct setting
[ Ken VanDine ]
* Hide sleep locks immediately setting, which isn't implemented yet
  (LP: #1361297) (LP: #1361297)
[ Sebastien Bacher ]
* [system-update] rework the ui to use a column rather than anchors,
  the layout is quite dynamic and it should be easier to position and
  stack widgets this way (LP: #1343172)
[ Michael Terry ]
* After selecting the language, update the session environment
  immediately and restart indicators so that their notifications (like
  wifi prompt) are translated. (LP: #1354325)
[ Ken VanDine ]
* Added autopilot tests for security-privacy
[ jonas-drange ]
* [phone] adding dual sim functionality to phone panel
[ Charles Kerr ]
* In the welcome wizard, refresh the text in the 'no sim card' and
  'all done' pages to match the latest from design.
[ Michael Terry ]
* Add a location page and a terms and conditions page for the HERE
  service.
[ Ken VanDine ]
* Settings for idle/lock timeout (LP: #1230345)
* Added flickable to fix scrolling (LP: #1354161)
[ Jussi Pakkanen ]
* Fix a bunch of compiler warnings.
[ jonas-drange ]
* [cellular] displays cellular UIs based on how many SIMs are present.
  (LP: #1357393)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <QtDebug>
24
24
#include <QDBusInterface>
25
25
#include <algorithm>
 
26
#include <arpa/inet.h>
26
27
 
27
28
#include "nm_manager_proxy.h"
28
29
#include "nm_settings_proxy.h"
29
30
#include "nm_settings_connection_proxy.h"
30
31
 
 
32
#define NM_SERVICE "org.freedesktop.NetworkManager"
 
33
#define NM_PATH "/org/freedesktop/NetworkManager"
 
34
#define NM_DEVICE_IFACE "org.freedesktop.NetworkManager.Device"
 
35
 
31
36
typedef QMap<QString,QVariantMap> ConfigurationData;
32
37
Q_DECLARE_METATYPE(ConfigurationData)
33
38
 
34
 
WifiDbusHelper::WifiDbusHelper(QObject *parent) : QObject(parent)
 
39
WifiDbusHelper::WifiDbusHelper(QObject *parent) : QObject(parent),
 
40
      m_systemBusConnection(QDBusConnection::systemBus())
35
41
{
36
42
    qDBusRegisterMetaType<ConfigurationData>();
37
43
}
43
49
        return;
44
50
    }
45
51
 
46
 
    OrgFreedesktopNetworkManagerInterface mgr("org.freedesktop.NetworkManager",
47
 
                                              "/org/freedesktop/NetworkManager",
48
 
                                              QDBusConnection::systemBus());
 
52
    OrgFreedesktopNetworkManagerInterface mgr(NM_SERVICE,
 
53
                                              NM_PATH,
 
54
                                              m_systemBusConnection);
49
55
 
50
56
    QMap<QString, QVariantMap> configuration;
51
57
 
91
97
 
92
98
    QDBusObjectPath dev;
93
99
    for (const auto &d : devices) {
94
 
        QDBusInterface iface("org.freedesktop.NetworkManager",
 
100
        QDBusInterface iface(NM_SERVICE,
95
101
                             d.path(),
96
 
                             "org.freedesktop.NetworkManager.Device",
 
102
                             NM_DEVICE_IFACE,
97
103
                             QDBusConnection::systemBus());
98
104
 
99
105
        auto type_v = iface.property("DeviceType");
105
111
 
106
112
    if (dev.path().isEmpty()) {
107
113
        // didn't find a wifi device
 
114
        qWarning() << "Could not find wifi device.";
108
115
        return;
109
116
    }
110
117
 
 
118
    mgr.connection().disconnect(
 
119
        mgr.service(),
 
120
        dev.path(),
 
121
        NM_DEVICE_IFACE,
 
122
        "StateChanged",
 
123
        this,
 
124
        SLOT(nmDeviceStateChanged(uint, uint, uint)));
 
125
 
 
126
    mgr.connection().connect(
 
127
        mgr.service(),
 
128
        dev.path(),
 
129
        NM_DEVICE_IFACE,
 
130
        "StateChanged",
 
131
        this,
 
132
        SLOT(nmDeviceStateChanged(uint, uint, uint)));
 
133
 
111
134
    QDBusObjectPath tmp;
112
135
    auto reply2 = mgr.AddAndActivateConnection(configuration,
113
136
                                               dev,
114
137
                                               QDBusObjectPath("/"),
115
138
                                               tmp);
 
139
    if(!reply2.isValid()) {
 
140
        qWarning() << "Could not connect: " << reply2.error().message() << "\n";
 
141
    }
 
142
}
 
143
 
 
144
void WifiDbusHelper::nmDeviceStateChanged(uint newState,
 
145
                                           uint oldState,
 
146
                                           uint reason)
 
147
{
 
148
    Q_UNUSED (oldState);
 
149
    Q_EMIT (deviceStateChanged(newState, reason));
 
150
}
 
151
 
 
152
QString WifiDbusHelper::getWifiIpAddress()
 
153
{
 
154
    OrgFreedesktopNetworkManagerInterface mgr(NM_SERVICE,
 
155
                                              NM_PATH,
 
156
                                              m_systemBusConnection);
 
157
 
 
158
    // find the first wlan adapter for now
 
159
    auto reply1 = mgr.GetDevices();
 
160
    reply1.waitForFinished();
 
161
    if(!reply1.isValid()) {
 
162
        qWarning() << "Could not get network device: " << reply1.error().message() << "\n";
 
163
        return QString();
 
164
    }
 
165
    auto devices = reply1.value();
 
166
    int ip4addr;
 
167
 
 
168
    QDBusObjectPath dev;
 
169
    for (const auto &d : devices) {
 
170
        QDBusInterface iface(NM_SERVICE, d.path(), NM_DEVICE_IFACE, m_systemBusConnection);
 
171
        auto type_v = iface.property("DeviceType");
 
172
        if (type_v.toUInt() == 2 /* NM_DEVICE_TYPE_WIFI */) {
 
173
            ip4addr = iface.property("Ip4Address").toInt();
 
174
            dev = d;
 
175
            break;
 
176
        }
 
177
    }
 
178
 
 
179
    if (dev.path().isEmpty()) {
 
180
        // didn't find a wifi device
 
181
        return QString();
 
182
    }
 
183
 
 
184
    if (!ip4addr) {
 
185
        // no ip address
 
186
        return QString();
 
187
    }
 
188
 
 
189
 
 
190
    struct in_addr ip_addr;
 
191
    ip_addr.s_addr = ip4addr;
 
192
    return QString(inet_ntoa(ip_addr));
116
193
}
117
194
 
118
195
struct Network : public QObject
232
309
    }
233
310
 
234
311
    Network() = delete;
235
 
    Network(QString path)
 
312
    explicit Network(QString path)
236
313
        : path{path},
237
314
          m_iface("org.freedesktop.NetworkManager",
238
315
                  path,
271
348
    QList<QStringList> networks;
272
349
 
273
350
   OrgFreedesktopNetworkManagerSettingsInterface foo
274
 
            ("org.freedesktop.NetworkManager",
 
351
            (NM_SERVICE,
275
352
             "/org/freedesktop/NetworkManager/Settings",
276
353
             QDBusConnection::systemBus());
277
354
    auto reply = foo.ListConnections();
307
384
 
308
385
void WifiDbusHelper::forgetConnection(const QString dbus_path) {
309
386
    OrgFreedesktopNetworkManagerSettingsConnectionInterface bar
310
 
            ("org.freedesktop.NetworkManager",
 
387
            (NM_SERVICE,
311
388
             dbus_path,
312
389
             QDBusConnection::systemBus());
313
390
    auto reply = bar.Delete();
316
393
        qWarning() << "Error forgetting network: " << reply.error().message() << "\n";
317
394
    }
318
395
}
 
396
 
 
397
bool WifiDbusHelper::disconnectDevice() {
 
398
    OrgFreedesktopNetworkManagerInterface mgr(NM_SERVICE,
 
399
                                              NM_PATH,
 
400
                                              m_systemBusConnection);
 
401
    // find the first wlan adapter for now
 
402
    auto reply1 = mgr.GetDevices();
 
403
    reply1.waitForFinished();
 
404
    if(!reply1.isValid()) {
 
405
        qWarning() << "disconnectDevice: Could not get network device: " << reply1.error().message() << "\n";
 
406
        return false;
 
407
    }
 
408
    auto devices = reply1.value();
 
409
 
 
410
    QDBusObjectPath dev;
 
411
    for (const auto &d : devices) {
 
412
        QDBusInterface iface(NM_SERVICE, d.path(), NM_DEVICE_IFACE, m_systemBusConnection);
 
413
 
 
414
        auto type_v = iface.property("DeviceType");
 
415
        if (type_v.toUInt() == 2 /* NM_DEVICE_TYPE_WIFI */) {
 
416
            if (d.path().isEmpty()) {
 
417
                // didn't find a wifi device
 
418
                qWarning() << "disconnectDevice: Could not find wifi device\n";
 
419
                return false;
 
420
            } else {
 
421
                iface.call("Disconnect");
 
422
                return true;
 
423
            }
 
424
            break;
 
425
        }
 
426
    }
 
427
    return false;
 
428
}