Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for fwupd #150

Merged
merged 106 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
a1b9a7a
Add D-Bus interface to interact with fwupd
meisenzahl Dec 10, 2020
2414d8f
Get device names
meisenzahl Dec 10, 2020
e8159de
Add class for devices
meisenzahl Dec 10, 2020
1e86f4d
Split into separate views
meisenzahl Dec 11, 2020
8957080
Add view for firmware devices
meisenzahl Dec 11, 2020
e73558c
Add more information to view
meisenzahl Dec 11, 2020
39ac818
Add function of verify button
meisenzahl Dec 11, 2020
23e9f46
Add function to get releases
meisenzahl Dec 11, 2020
a3e9647
Add page for releases
meisenzahl Dec 11, 2020
60c094c
Add reference on how to decode device flags
meisenzahl Dec 11, 2020
acdf32b
Merge branch 'master' into add-support-for-fwupd
meisenzahl Dec 14, 2020
43d03a8
Merge branch 'master' into add-support-for-fwupd
meisenzahl Dec 15, 2020
b0aa849
Merge branch 'add-support-for-fwupd' of github.com:elementary/switchb…
meisenzahl Dec 15, 2020
d9d69a7
Check if releases are available for device
meisenzahl Dec 22, 2020
705efac
Merge branch 'add-support-for-fwupd' of github.com:elementary/switchb…
meisenzahl Dec 22, 2020
6168c64
Get releases
meisenzahl Dec 22, 2020
8d88c77
Show list of releases
meisenzahl Dec 22, 2020
82217a5
Show install duration
meisenzahl Dec 22, 2020
18ad2ab
Catch error
meisenzahl Dec 24, 2020
7335737
Decode device flags
meisenzahl Dec 24, 2020
691f150
Show icon and text for device flags
meisenzahl Dec 24, 2020
2ca5466
Save releases as property of device
meisenzahl Dec 24, 2020
e7f0298
Add update error
meisenzahl Dec 24, 2020
7cc1de1
Satisfy linter
meisenzahl Dec 24, 2020
3f2bfa8
Show release information
meisenzahl Dec 24, 2020
14cfd82
Pretty print file size and time
meisenzahl Dec 24, 2020
9e07a09
Add dialog to install release
meisenzahl Dec 25, 2020
ad144c2
Format release description
meisenzahl Dec 25, 2020
58e05b9
Add todo
meisenzahl Dec 25, 2020
673835a
Add support to install upgrade or reinstall
meisenzahl Dec 27, 2020
b578a1c
Add support to install downgrade
meisenzahl Dec 27, 2020
24f2d5c
List device only if updatable
meisenzahl Dec 27, 2020
0e467da
Separate operating system and hardware views
meisenzahl Dec 27, 2020
b2280eb
Add list of available firmware updates
meisenzahl Dec 27, 2020
8ee28c8
Download update
meisenzahl Dec 27, 2020
f8b54d8
Merge branch 'master' into add-support-for-fwupd
meisenzahl Dec 27, 2020
7a9c113
Remove unused code
meisenzahl Dec 27, 2020
5d4dbd8
Refactor
meisenzahl Dec 29, 2020
b48aee4
Make calls async
meisenzahl Dec 29, 2020
96bed5d
Refactor handle
meisenzahl Dec 29, 2020
e08d741
Refactor handle
meisenzahl Dec 29, 2020
ef6a622
Refactor handle
meisenzahl Dec 30, 2020
cfd904f
Show feedback during update
meisenzahl Jan 3, 2021
da2620c
Remove dummy update all button
meisenzahl Jan 3, 2021
2d1fbdc
Update layout
meisenzahl Jan 3, 2021
8cc6677
Refactor
meisenzahl Jan 3, 2021
b068d38
Remove unused code
meisenzahl Jan 13, 2021
25a3ea8
Update src/Interfaces/FwupdManager.vala
meisenzahl Jan 13, 2021
ed5e1f5
Update src/Plug.vala
meisenzahl Jan 13, 2021
30399a7
Update src/Plug.vala
meisenzahl Jan 13, 2021
f7bb77f
Update src/Views/FirmwareView.vala
meisenzahl Jan 13, 2021
cbdb26a
Refactor reference type
meisenzahl Jan 13, 2021
bfee445
Update src/Widgets/FirmwareUpdateWidget.vala
meisenzahl Jan 13, 2021
3d7ba6b
Update src/Widgets/FirmwareUpdateWidget.vala
meisenzahl Jan 13, 2021
db3f7ed
Merge branch 'master' into add-support-for-fwupd
meisenzahl Jan 13, 2021
a9ccd73
Show placeholder when no devices are available
meisenzahl Jan 13, 2021
1671569
Show error dialog
meisenzahl Jan 13, 2021
34f936d
Update src/Views/FirmwareView.vala
meisenzahl Jan 13, 2021
162b272
Add GetDetails
meisenzahl Jan 14, 2021
fde76d6
Show dialog if manual steps are required
meisenzahl Jan 14, 2021
c13493b
Set transient_for
meisenzahl Jan 14, 2021
acf3016
Use listbox placeholder (#167)
danirabbit Jan 15, 2021
365c5b6
Get rid of page header
meisenzahl Jan 15, 2021
5f98d6f
Add icon to list placeholder
meisenzahl Jan 15, 2021
f5589fb
Show dialog to shutdown or reboot if needed
meisenzahl Jan 15, 2021
033ba8c
Refactor
meisenzahl Jan 15, 2021
463611b
Provide specifc error text
meisenzahl Jan 15, 2021
27778be
Rename to FirmwareUpdateRow
meisenzahl Jan 15, 2021
3c4adf0
Be more verbose for shutdown and reboot
meisenzahl Jan 15, 2021
52a250d
Reduce number of iterations
meisenzahl Jan 15, 2021
5d109cf
Provide a hopefully more understandable text
meisenzahl Jan 15, 2021
83bc832
Apply suggestions from code review
meisenzahl Jan 15, 2021
ef91aa3
Update icons
meisenzahl Jan 15, 2021
b8de755
Show name of device during update
meisenzahl Jan 15, 2021
d1c2cb7
Update button label
meisenzahl Jan 15, 2021
8cb9f57
Apply suggestions from code review
meisenzahl Jan 16, 2021
8f6ccb4
Use device icon if possible
meisenzahl Jan 16, 2021
a3d38b0
Always provide device on error
meisenzahl Jan 16, 2021
2227ae8
Reload when new device is plugged in
meisenzahl Jan 16, 2021
1900d60
Reload when device is removed
meisenzahl Jan 16, 2021
ca75aef
Remove unused signal
meisenzahl Jan 16, 2021
fd5e50f
Merge branch 'master' into add-support-for-fwupd
meisenzahl Jan 18, 2021
5d8c033
Merge branch 'master' into add-support-for-fwupd
cassidyjames Jan 19, 2021
cb1389f
Use flags properly
meisenzahl Jan 19, 2021
e93c949
Refactor get_devices (#168)
davidmhewitt Jan 19, 2021
c3e064c
Refactor get_releases
meisenzahl Jan 19, 2021
ba53c53
Refactor install
meisenzahl Jan 19, 2021
9248292
Refactor get_details
meisenzahl Jan 19, 2021
e09001e
Remove unnecessary async
meisenzahl Jan 20, 2021
c8b22a9
Use Posix.open
meisenzahl Jan 20, 2021
004d844
Refactor namespace
meisenzahl Jan 20, 2021
cca55b9
Refactor warning messages
meisenzahl Jan 20, 2021
5224903
Make interface private
meisenzahl Jan 20, 2021
79592ef
Refactor to use different variables
meisenzahl Jan 20, 2021
015396b
Refactor translator comments
meisenzahl Jan 20, 2021
def4ec6
Add cancel button for details view
meisenzahl Jan 20, 2021
ac9f7e9
Get rid of singleton
meisenzahl Jan 20, 2021
dc54b5a
Always download file
meisenzahl Jan 20, 2021
16072aa
Rename to get_release_details
meisenzahl Jan 20, 2021
5f4093d
Refactor get path of file
meisenzahl Jan 22, 2021
331022e
Add TODO
meisenzahl Jan 22, 2021
a4b8808
Close filedescriptor
meisenzahl Jan 22, 2021
bdb0677
Refactor to use property
meisenzahl Jan 22, 2021
bf25535
Refactor dialog to decide if we want to continue the update
meisenzahl Jan 22, 2021
f8392a3
Merge branch 'master' into add-support-for-fwupd
meisenzahl Jan 22, 2021
e6f2689
Merge branch 'master' into add-support-for-fwupd
danirabbit Jan 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions src/Interfaces/FwupdManager.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* Copyright (c) 2020 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Marius Meisenzahl <[email protected]>
*/

[DBus (name="org.freedesktop.fwupd")]
public interface About.FwupdInterface : Object {
[DBus (name = "HostProduct")]
public abstract string host_product { owned get; }

[DBus (name = "GetDevices")]
public abstract HashTable<string, Variant>[] get_devices () throws Error;

[DBus (name = "GetReleases")]
public abstract HashTable<string, Variant>[] get_releases (string id) throws Error;

[DBus (name = "Verify")]
public abstract void verify (string id) throws Error;
}

public class About.FwupdManager : Object {
private FwupdInterface interface;

static FwupdManager? instance = null;
meisenzahl marked this conversation as resolved.
Show resolved Hide resolved
public static FwupdManager get_instance () {
if (instance == null) {
instance = new FwupdManager ();
}

return instance;
}

private FwupdManager () {}

public List<Device> get_devices () {
var devices_list = new List<Device> ();

try {
foreach (var _device in interface.get_devices ()) {
var device = new Device ();
foreach (var key in _device.get_keys ()) {
switch (key) {
case "DeviceId":
device.id = _device.lookup (key).get_string ();
break;
case "Name":
device.name = _device.lookup (key).get_string ();
break;
case "Summary":
device.summary = _device.lookup (key).get_string ();
break;
case "Vendor":
device.vendor = _device.lookup (key).get_string ();
break;
case "Version":
device.version = _device.lookup (key).get_string ();
break;
case "Icon":
var icons = _device.lookup (key).get_strv ();
device.icon = icons.length > 0 ? icons[0] : "unknown";
meisenzahl marked this conversation as resolved.
Show resolved Hide resolved
break;
case "Guid":
device.guids = _device.lookup (key).get_strv ();
break;
case "Flags":
device.flags = _device.lookup (key).get_uint64 ();
break;
case "InstallDuration":
device.install_duration = _device.lookup (key).get_uint64 ();
break;
default:
break;
}
}
devices_list.append (device);
}
} catch (Error e) {
warning ("Could not connect to fwupd interface: %s", e.message);
meisenzahl marked this conversation as resolved.
Show resolved Hide resolved
}

return devices_list;
}

public List<Release> get_releases (string id) throws Error {
var releases_list = new List<Release> ();

foreach (var _release in interface.get_releases (id)) {
var release = new Release ();
foreach (var key in _release.get_keys ()) {
}
releases_list.append (release);
}

return releases_list;
}

public void verify (string id) throws Error {
interface.verify (id);
}

construct {
try {
interface = Bus.get_proxy_sync (BusType.SYSTEM, "org.freedesktop.fwupd", "/");
} catch (Error e) {
warning ("Could not connect to fwupd interface: %s", e.message);
}
}
}
32 changes: 32 additions & 0 deletions src/Objects/Device.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2020 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Marius Meisenzahl <[email protected]>
*/

public class About.Device : Object {
public string id { get; set; }
public string name { get; set; }
public string summary { get; set; }
public string icon { get; set; }
public string vendor { get; set; }
public string version { get; set; }
public string[] guids { get; set; }
public uint64 flags { get; set; } // https://github.com/fwupd/fwupd/blob/72df1147933de747312aa7c9892f07e7916b8a39/libfwupd/fwupd-enums.h#L133
public uint64? install_duration { get; set; }
}
27 changes: 27 additions & 0 deletions src/Objects/Release.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2020 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Marius Meisenzahl <[email protected]>
*/

public class About.Release : Object {
public string id { get; set; }
public string name { get; set; }
public string summary { get; set; }
public string icon { get; set; }
}
Loading