Skip to content

Commit

Permalink
Daemon: add fingerprint property and export over DBus
Browse files Browse the repository at this point in the history
  • Loading branch information
andyholmes committed Oct 4, 2017
1 parent e0ad4d6 commit c030686
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions data/org.gnome.shell.extensions.gsconnect.daemon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<interface name="org.gnome.shell.extensions.gsconnect.daemon">
<property type="s" name="name" access="readwrite"/>
<property type="as" name="devices" access="read"/>
<property type="s" name="fingerprint" access="read"/>

<method name="discover">
<arg name="name" type="s" direction="in"/>
Expand Down
29 changes: 22 additions & 7 deletions src/service/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ var Daemon = new Lang.Class({
new GLib.VariantType("as"),
null,
GObject.ParamFlags.READABLE
),
"fingerprint": GObject.ParamSpec.string(
"fingerprint",
"deviceFingerprint",
"SHA1 fingerprint for the device certificate",
GObject.ParamFlags.READABLE,
""
)
},

Expand Down Expand Up @@ -82,6 +89,18 @@ var Daemon = new Lang.Class({
);
},

get devices() {
return Array.from(this._devices.keys());
},

get fingerprint () {
return Common.getFingerprint(
GLib.file_get_contents(
Common.CONFIG_PATH + "/certificate.pem"
)[1].toString()
);
},

get name() {
return Common.Settings.get_string("public-name");
},
Expand All @@ -92,10 +111,6 @@ var Daemon = new Lang.Class({
this.broadcast();
},

get devices() {
return Array.from(this._devices.keys());
},

/**
* Special method to accomodate nautilus-gsconnect.py
*
Expand Down Expand Up @@ -175,8 +190,8 @@ var Daemon = new Lang.Class({
* Discovery Methods
*
* TODO: cleanup discover()
* export a "discovering" property
* error check broadcast()?
* TODO: export a "discovering" property
* TODO: error check broadcast()?
*/
broadcast: function () {
Common.debug("Daemon.broadcast()");
Expand Down Expand Up @@ -265,8 +280,8 @@ var Daemon = new Lang.Class({
/**
* Start listening for incoming broadcast packets
*
* FIXME: conflicts with running KDE Connect, for some reason
* TODO: TCP Listener
* conflicts with running KDE Connect, for some reason
*/
_listen: function (port=1716) {
this._listener = new Gio.Socket({
Expand Down

0 comments on commit c030686

Please sign in to comment.