[polari/wip/fmuellner/disconnect-accounts: 22/25] accountsMonitor: Use a custom account type



commit 5cc705e3ecd89cf166856a325a67b9f35c34db5e
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Nov 9 03:11:55 2017 +0100

    accountsMonitor: Use a custom account type
    
    Use the newly added factory class to register a custom account type,
    which we will soon extend with custom properties.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=771889

 src/accountsMonitor.js | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js
index 1ae5900..38a5a5e 100644
--- a/src/accountsMonitor.js
+++ b/src/accountsMonitor.js
@@ -1,4 +1,6 @@
 const Gio = imports.gi.Gio;
+const GObject = imports.gi.GObject;
+const Polari = imports.gi.Polari;
 const Signals = imports.signals;
 const Tp = imports.gi.TelepathyGLib;
 
@@ -17,13 +19,14 @@ var AccountsMonitor = class {
         this._app.connect('prepare-shutdown',
                           this._onPrepareShutdown.bind(this));
 
-        this._accountManager = Tp.AccountManager.dup();
-
-        let factory = this._accountManager.get_factory();
+        let factory = new ClientFactory();
         factory.add_channel_features([Tp.Channel.get_feature_quark_group()]);
         factory.add_channel_features([Tp.Channel.get_feature_quark_contacts()]);
         factory.add_contact_features([Tp.ContactFeature.ALIAS]);
 
+        this._accountManager = Tp.AccountManager.new_with_factory(factory);
+        this._accountManager.set_default();
+
         this._preparedCallbacks = [];
         this._accountManager.prepare_async(null, this._onPrepared.bind(this));
     }
@@ -144,3 +147,17 @@ var AccountsMonitor = class {
     }
 };
 Signals.addSignalMethods(AccountsMonitor.prototype);
+
+const ClientFactory = GObject.registerClass(
+class ClientFactory extends Polari.ClientFactory {
+    vfunc_create_account(objectPath) {
+        return new PolariAccount({ factory: this,
+                                   dbus_daemon: this.dbus_daemon,
+                                   bus_name: Tp.ACCOUNT_MANAGER_BUS_NAME,
+                                   object_path: objectPath });
+    }
+});
+
+const PolariAccount = GObject.registerClass(
+class PolariAccount extends Tp.Account {
+});


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]