Skip to content

Commit

Permalink
Service: setup property bindings in _init()
Browse files Browse the repository at this point in the history
  • Loading branch information
andyholmes committed Jan 5, 2019
1 parent 01f0fc4 commit 3e7b271
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/service/daemon.js
Expand Up @@ -96,6 +96,10 @@ const Service = GObject.registerClass({

// Track devices with id as key
this._devices = new Map();

// Properties
gsconnect.settings.bind('discoverable', this, 'discoverable', 0);
gsconnect.settings.bind('public-name', this, 'name', 0);
}

get certificate() {
Expand Down Expand Up @@ -124,7 +128,7 @@ const Service = GObject.registerClass({
type: 'kdeconnect.identity',
body: {
deviceId: this.certificate.common_name,
deviceName: gsconnect.settings.get_string('public-name'),
deviceName: this.name,
deviceType: this.type,
tcpPort: 1716,
protocolVersion: 7,
Expand Down Expand Up @@ -612,7 +616,7 @@ const Service = GObject.registerClass({
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
);

// Ensure out handlers are registered
// Ensure our handlers are registered
try {
let appInfo = Gio.DesktopAppInfo.new(`${gsconnect.app_id}.desktop`);
appInfo.add_supports_type('x-scheme-handler/sms');
Expand All @@ -621,21 +625,6 @@ const Service = GObject.registerClass({
warning(e);
}

// Properties
gsconnect.settings.bind(
'discoverable',
this,
'discoverable',
Gio.SettingsBindFlags.DEFAULT
);

gsconnect.settings.bind(
'public-name',
this,
'name',
Gio.SettingsBindFlags.DEFAULT
);

// Keep identity updated and broadcast any name changes
gsconnect.settings.connect('changed::public-name', (settings) => {
this.identity.body.deviceName = this.name;
Expand Down

0 comments on commit 3e7b271

Please sign in to comment.