[gnome-shell/wip/gdbus-2: 1/3] Port to GDBus 2



commit a6b4d68a1d2124c017d57a16bbbed4bb01a1e5a5
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sat Dec 10 14:54:39 2011 +0100

    Port to GDBus 2
    
    The GDBus bindings in gjs have been updated to leverage metaclasses
    and gobject inheritance, which should result in cleaner and more
    maintainable code.

 js/extensionPrefs/main.js          |   14 +++-
 js/gdm/fingerprint.js              |   22 +++---
 js/gdm/realmd.js                   |   53 ++++++++++----
 js/gdm/util.js                     |   15 +++-
 js/misc/gnomeSession.js            |   44 ++++++++---
 js/misc/loginManager.js            |  144 ++++++++++++++++++++++++------------
 js/misc/modemManager.js            |   86 ++++++++++++++-------
 js/ui/calendar.js                  |   76 +++++++++++--------
 js/ui/components/autorunManager.js |   29 +++++---
 js/ui/endSessionDialog.js          |   45 ++++++++++--
 js/ui/keyboard.js                  |    8 +-
 js/ui/magnifierDBus.js             |   20 +++--
 js/ui/messageTray.js               |   11 ++-
 js/ui/notificationDaemon.js        |   38 ++++++----
 js/ui/remoteSearch.js              |   71 +++++++++++-------
 js/ui/scripting.js                 |   25 ++++--
 js/ui/shellDBus.js                 |   30 ++++----
 js/ui/shellMountOperation.js       |   12 ++-
 js/ui/status/power.js              |   38 +++++++--
 js/ui/userMenu.js                  |   46 +++++++----
 20 files changed, 542 insertions(+), 285 deletions(-)
---
diff --git a/js/extensionPrefs/main.js b/js/extensionPrefs/main.js
index 53a6966..42bc922 100644
--- a/js/extensionPrefs/main.js
+++ b/js/extensionPrefs/main.js
@@ -21,7 +21,16 @@ const GnomeShellIface = <interface name="org.gnome.Shell.Extensions">
 </signal>
 </interface>;
 
-const GnomeShellProxy = Gio.DBusProxy.makeProxyWrapper(GnomeShellIface);
+const GnomeShellProxy = new Gio.DBusProxyClass({
+    Name: 'GnomeShellProxy',
+    Interface: GnomeShellIface,
+
+    _init: function() {
+	this.parent({ g_bus_type: Gio.BusType.SESSION,
+		      g_name: 'org.gnome.Shell',
+		      g_object_path: '/org/gnome/Shell' });
+    }
+});
 
 function stripPrefix(string, prefix) {
     if (string.slice(0, prefix.length) == prefix)
@@ -191,7 +200,8 @@ const Application = new Lang.Class({
 
         this._extensionPrefsBin.add(label);
 
-        this._shellProxy = new GnomeShellProxy(Gio.DBus.session, 'org.gnome.Shell', '/org/gnome/Shell');
+        this._shellProxy = new GnomeShellProxy();
+        this._shellProxy.init(null);
         this._shellProxy.connectSignal('ExtensionStatusChanged', Lang.bind(this, function(proxy, senderName, [uuid, state, error]) {
             if (ExtensionUtils.extensions[uuid] !== undefined)
                 this._scanExtensions();
diff --git a/js/gdm/fingerprint.js b/js/gdm/fingerprint.js
index 41b6b35..e3c3039 100644
--- a/js/gdm/fingerprint.js
+++ b/js/gdm/fingerprint.js
@@ -11,16 +11,14 @@ const FprintManagerIface = <interface name='net.reactivated.Fprint.Manager'>
 </method>
 </interface>;
 
-const FprintManagerInfo = Gio.DBusInterfaceInfo.new_for_xml(FprintManagerIface);
+const FprintManager = new Gio.DBusProxyClass({
+    Name: 'FprintManager',
+    Interface: FprintManagerIface,
 
-function FprintManager() {
-    var self = new Gio.DBusProxy({ g_connection: Gio.DBus.system,
-                                   g_interface_name: FprintManagerInfo.name,
-                                   g_interface_info: FprintManagerInfo,
-                                   g_name: 'net.reactivated.Fprint',
-                                   g_object_path: '/net/reactivated/Fprint/Manager',
-                                   g_flags: (Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES) });
-
-    self.init(null);
-    return self;
-}
+    _init: function() {
+        this.parent({ g_bus_type: Gio.BusType.SYSTEM,
+                      g_name: 'net.reactivated.Fprint',
+                      g_object_path: '/net/reactivated/Fprint/Manager',
+                      g_flags: (Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES) });
+    }
+});
diff --git a/js/gdm/realmd.js b/js/gdm/realmd.js
index e64b0b2..4e93ce1 100644
--- a/js/gdm/realmd.js
+++ b/js/gdm/realmd.js
@@ -1,6 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
 const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
 const Lang = imports.lang;
 const Shell = imports.gi.Shell;
 const Signals = imports.signals;
@@ -16,7 +17,16 @@ const ProviderIface = <interface name='org.freedesktop.realmd.Provider'>
         <arg name="realm" type="ao" direction="out"/>
     </method>
 </interface>;
-const Provider = Gio.DBusProxy.makeProxyWrapper(ProviderIface);
+const Provider = new Gio.DBusProxyClass({
+    Name: 'RealmdProvider',
+    Interface: ProviderIface,
+
+    _init: function() {
+        this.parent({ g_bus_type: Gio.BusType.SYSTEM,
+                      g_name: 'org.freedesktop.realmd',
+                      g_object_path: '/org/freedesktop/realmd' });
+    }
+});
 
 const ServiceIface = <interface name="org.freedesktop.realmd.Service">
     <method name="Cancel">
@@ -31,7 +41,16 @@ const ServiceIface = <interface name="org.freedesktop.realmd.Service">
         <arg name="operation" type="s"/>
     </signal>
 </interface>;
-const Service = Gio.DBusProxy.makeProxyWrapper(ServiceIface);
+const Service = new Gio.DBusProxyClass({
+    Name: 'RealmdService',
+    Interface: ServiceIface,
+
+    _init: function(service) {
+        this.parent({ g_bus_type: Gio.BusType.SYSTEM,
+                      g_name: 'org.freedesktop.realmd',
+                      g_object_path: service });
+    }
+});
 
 const RealmIface = <interface name="org.freedesktop.realmd.Realm">
     <property name="Name" type="s" access="read"/>
@@ -51,16 +70,23 @@ const RealmIface = <interface name="org.freedesktop.realmd.Realm">
         <arg name="options" type="a{sv}" direction="in"/>
     </method>
 </interface>;
-const Realm = Gio.DBusProxy.makeProxyWrapper(RealmIface);
+const Realm = new Gio.DBusProxyClass({
+    Name: 'RealmdRealm',
+    Interface: RealmIface,
+
+    _init: function(realm) {
+        this.parent({ g_bus_type: Gio.BusType.SYSTEM,
+                      g_name: 'org.freedesktop.realmd',
+                      g_object_path: realm });
+    }
+});
 
 const Manager = new Lang.Class({
     Name: 'Manager',
 
     _init: function(parentActor) {
-        this._aggregateProvider = Provider(Gio.DBus.system,
-                                           'org.freedesktop.realmd',
-                                           '/org/freedesktop/realmd',
-                                           Lang.bind(this, this._reloadRealms))
+        this._aggregateProvider = new Provider();
+        this._aggregateProvider.init(null);
         this._realms = {};
 
         this._aggregateProvider.connect('g-properties-changed',
@@ -77,10 +103,8 @@ const Manager = new Lang.Class({
             return;
 
         for (let i = 0; i < realmPaths.length; i++) {
-            let realm = Realm(Gio.DBus.system,
-                              'org.freedesktop.realmd',
-                              realmPaths[i],
-                              Lang.bind(this, this._onRealmLoaded));
+            let realm = new Realm(realmPaths[i]);
+            realm.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, this._onRealmLoaded));
         }
     },
 
@@ -97,9 +121,10 @@ const Manager = new Lang.Class({
         this._updateLoginFormat();
     },
 
-    _onRealmLoaded: function(realm, error) {
-        if (error)
-            return;
+    _onRealmLoaded: function(realm, result) {
+        try {
+            realm.init_finish(result);
+        } catch(e) { return; }
 
         this._reloadRealm(realm);
 
diff --git a/js/gdm/util.js b/js/gdm/util.js
index d71e55f..1fba3fc 100644
--- a/js/gdm/util.js
+++ b/js/gdm/util.js
@@ -82,6 +82,8 @@ const ShellUserVerifier = new Lang.Class({
         this._settings = new Gio.Settings({ schema: LOGIN_SCREEN_SCHEMA });
 
         this._fprintManager = new Fprint.FprintManager();
+        this._fprintManager.init(null);
+
         this._realmManager = new Realmd.Manager();
 
         this._failCounter = 0;
@@ -137,11 +139,14 @@ const ShellUserVerifier = new Lang.Class({
         if (!this._settings.get_boolean(FINGERPRINT_AUTHENTICATION_KEY))
             return;
 
-        this._fprintManager.GetDefaultDeviceRemote(Gio.DBusCallFlags.NONE, this._cancellable, Lang.bind(this,
-            function(device, error) {
-                if (!error && device)
-                    this._haveFingerprintReader = true;
-            }));
+        this._fprintManager.GetDefaultDeviceRemote(this._cancellable, Lang.bind(this, function(manager, result) {
+            try {
+                let device = manager.GetDefaultDeviceFinish(result);
+                this._haveFingerprintReader = !!device;
+            } catch(e) {
+                this._haveFingerprintReader = false;
+            }
+        }));
     },
 
     _reportInitError: function(where, error) {
diff --git a/js/misc/gnomeSession.js b/js/misc/gnomeSession.js
index f8bd58e..4817de6 100644
--- a/js/misc/gnomeSession.js
+++ b/js/misc/gnomeSession.js
@@ -21,11 +21,16 @@ const PresenceStatus = {
     IDLE: 3
 };
 
-var PresenceProxy = Gio.DBusProxy.makeProxyWrapper(PresenceIface);
-function Presence(initCallback, cancellable) {
-    return new PresenceProxy(Gio.DBus.session, 'org.gnome.SessionManager',
-                             '/org/gnome/SessionManager/Presence', initCallback, cancellable);
-}
+const Presence = new Gio.DBusProxyClass({
+    Name: 'GnomeSessionPresence',
+    Interface: PresenceIface,
+
+    _init: function() {
+        this.parent({ g_bus_type: Gio.BusType.SESSION,
+                      g_name: 'org.gnome.SessionManager',
+                      g_object_path: '/org/gnome/SessionManager/Presence' });
+    }
+});
 
 // Note inhibitors are immutable objects, so they don't
 // change at runtime (changes always come in the form
@@ -39,10 +44,16 @@ const InhibitorIface = <interface name="org.gnome.SessionManager.Inhibitor">
 </method>
 </interface>;
 
-var InhibitorProxy = Gio.DBusProxy.makeProxyWrapper(InhibitorIface);
-function Inhibitor(objectPath, initCallback, cancellable) {
-    return new InhibitorProxy(Gio.DBus.session, 'org.gnome.SessionManager', objectPath, initCallback, cancellable);
-}
+const Inhibitor = new Gio.DBusProxyClass({
+    Name: 'GnomeSessionInhibitor',
+    Interface: InhibitorIface,
+
+    _init: function(inhibitor) {
+        this.parent({ g_bus_type: Gio.BusType.SESSION,
+                      g_name: 'org.gnome.SessionManager',
+                      g_object_path: inhibitor });
+    }
+});
 
 // Not the full interface, only the methods we use
 const SessionManagerIface = <interface name="org.gnome.SessionManager">
@@ -66,7 +77,14 @@ const SessionManagerIface = <interface name="org.gnome.SessionManager">
 </signal>
 </interface>;
 
-var SessionManagerProxy = Gio.DBusProxy.makeProxyWrapper(SessionManagerIface);
-function SessionManager(initCallback, cancellable) {
-    return new SessionManagerProxy(Gio.DBus.session, 'org.gnome.SessionManager', '/org/gnome/SessionManager', initCallback, cancellable);
-}
+const SessionManager = new Gio.DBusProxyClass({
+    Name: 'GnomeSessionManager',
+    Interface: SessionManagerIface,
+
+    _init: function() {
+        this.parent({ g_bus_type: Gio.BusType.SESSION,
+                      g_name: 'org.gnome.SessionManager',
+                      g_object_path: '/org/gnome/SessionManager' });
+    },
+});
+
diff --git a/js/misc/loginManager.js b/js/misc/loginManager.js
index 7fc189f..7fca78d 100644
--- a/js/misc/loginManager.js
+++ b/js/misc/loginManager.js
@@ -33,8 +33,26 @@ const SystemdLoginSessionIface = <interface name='org.freedesktop.login1.Session
 <signal name='Unlock' />
 </interface>;
 
-const SystemdLoginManager = Gio.DBusProxy.makeProxyWrapper(SystemdLoginManagerIface);
-const SystemdLoginSession = Gio.DBusProxy.makeProxyWrapper(SystemdLoginSessionIface);
+const SystemdLoginManager = new Gio.DBusProxyClass({
+    Name: 'SystemdLoginManager',
+    Interface: SystemdLoginManagerIface,
+
+    _init: function() {
+        this.parent({ g_bus_type: Gio.BusType.SYSTEM,
+                      g_name: 'org.freedesktop.login1',
+                      g_object_path: '/org/freedesktop/login1' });
+    }
+});
+const SystemdLoginSession = new Gio.DBusProxyClass({
+    Name: 'SystemdLoginSession',
+    Interface: SystemdLoginSessionIface,
+
+    _init: function(session) {
+        this.parent({ g_bus_type: Gio.BusType.SYSTEM,
+                      g_name: 'org.freedesktop.login1',
+                      g_object_path: session });
+    }
+});
 
 const ConsoleKitManagerIface = <interface name='org.freedesktop.ConsoleKit.Manager'>
 <method name='CanRestart'>
@@ -61,8 +79,26 @@ const ConsoleKitSessionIface = <interface name='org.freedesktop.ConsoleKit.Sessi
 <signal name='Unlock' />
 </interface>;
 
-const ConsoleKitSession = Gio.DBusProxy.makeProxyWrapper(ConsoleKitSessionIface);
-const ConsoleKitManager = Gio.DBusProxy.makeProxyWrapper(ConsoleKitManagerIface);
+const ConsoleKitSession = new Gio.DBusProxyClass({
+    Name: 'ConsoleKitSession',
+    Interface: ConsoleKitSessionIface,
+
+    _init: function(session) {
+        this.parent({ g_bus_type: Gio.BusType.SYSTEM,
+                      g_name: 'org.freedesktop.ConsoleKit',
+                      g_object_path: session });
+    }
+});
+const ConsoleKitManager = new Gio.DBusProxyClass({
+    Name: 'ConsoleKitManager',
+    Interface: ConsoleKitManagerIface,
+
+    _init: function() {
+        this.parent({ g_bus_type: Gio.BusType.SYSTEM,
+                      g_name: 'org.freedesktop.ConsoleKit',
+                      g_object_path: '/org/freedesktop/ConsoleKit/Manager' });
+    }
+});
 
 function haveSystemd() {
     return GLib.access("/sys/fs/cgroup/systemd", 0) >= 0;
@@ -90,9 +126,8 @@ const LoginManagerSystemd = new Lang.Class({
     Name: 'LoginManagerSystemd',
 
     _init: function() {
-        this._proxy = new SystemdLoginManager(Gio.DBus.system,
-                                              'org.freedesktop.login1',
-                                              '/org/freedesktop/login1');
+        this._proxy = new SystemdLoginManager();
+        this._proxy.init(null);
     },
 
     // Having this function is a bit of a hack since the Systemd and ConsoleKit
@@ -100,10 +135,9 @@ const LoginManagerSystemd = new Lang.Class({
     // Lock/Unlock signals, and that's all we count upon at the moment.
     getCurrentSessionProxy: function() {
         if (!this._currentSession) {
-            this._currentSession = new SystemdLoginSession(Gio.DBus.system,
-                                                           'org.freedesktop.login1',
-                                                           '/org/freedesktop/login1/session/' +
+            this._currentSession = new SystemdLoginSession('/org/freedesktop/login1/session/' +
                                                            GLib.getenv('XDG_SESSION_ID'));
+            this._currentSession.init(null);
         }
 
         return this._currentSession;
@@ -114,42 +148,51 @@ const LoginManagerSystemd = new Lang.Class({
     },
 
     canPowerOff: function(asyncCallback) {
-        this._proxy.CanPowerOffRemote(function(result, error) {
-            if (error)
-                asyncCallback(false);
-            else
-                asyncCallback(result[0] != 'no');
+        this._proxy.CanPowerOffRemote(null, function(proxy, result) {
+            let val = false;
+
+            try {
+                val = proxy.CanPowerOffFinish(result)[0] != 'no';
+            } catch(e) { }
+
+            asyncCallback(val);
         });
     },
 
     canReboot: function(asyncCallback) {
-        this._proxy.CanRebootRemote(function(result, error) {
-            if (error)
-                asyncCallback(false);
-            else
-                asyncCallback(result[0] != 'no');
+        this._proxy.CanRebootRemote(null, function(proxy, result) {
+            let val = false;
+
+            try {
+                val = proxy.CanRebootFinish(result)[0] != 'no';
+            } catch(e) { }
+
+            asyncCallback(val);
         });
     },
 
     canSuspend: function(asyncCallback) {
-        this._proxy.CanSuspendRemote(function(result, error) {
-            if (error)
-                asyncCallback(false);
-            else
-                asyncCallback(result[0] != 'no');
+        this._proxy.CanSuspendRemote(null, function(proxy, result) {
+            let val = false;
+
+            try {
+                val = proxy.CanRebootFinish(result)[0] != 'no';
+            } catch(e) { }
+
+            asyncCallback(val);
         });
     },
 
     powerOff: function() {
-        this._proxy.PowerOffRemote(true);
+        this._proxy.PowerOffRemote(true, null, null);
     },
 
     reboot: function() {
-        this._proxy.RebootRemote(true);
+        this._proxy.RebootRemote(true, null, null);
     },
 
     suspend: function() {
-        this._proxy.SuspendRemote(true);
+        this._proxy.SuspendRemote(true, null, null);
     }
 });
 
@@ -157,9 +200,9 @@ const LoginManagerConsoleKit = new Lang.Class({
     Name: 'LoginManagerConsoleKit',
 
     _init: function() {
-        this._proxy = new ConsoleKitManager(Gio.DBus.system,
-                                            'org.freedesktop.ConsoleKit',
-                                            '/org/freedesktop/ConsoleKit/Manager');
+        this._proxy = new ConsoleKitManager();
+        this._proxy.init(null);
+
         this._upClient = new UPowerGlib.Client();
     },
 
@@ -168,10 +211,9 @@ const LoginManagerConsoleKit = new Lang.Class({
     // Lock/Unlock signals, and that's all we count upon at the moment.
     getCurrentSessionProxy: function() {
         if (!this._currentSession) {
-            let [currentSessionId] = this._proxy.GetCurrentSessionSync();
-            this._currentSession = new ConsoleKitSession(Gio.DBus.system,
-                                                         'org.freedesktop.ConsoleKit',
-                                                         currentSessionId);
+            let [currentSessionId] = this._proxy.GetCurrentSessionSync(null);
+            this._currentSession = new ConsoleKitSession(currentSessionId);
+            this._currentSession.init(null);
         }
 
         return this._currentSession;
@@ -185,26 +227,32 @@ const LoginManagerConsoleKit = new Lang.Class({
         session.connectSignal('ActiveChanged', Lang.bind(this, function(object, senderName, [isActive]) {
             this._sessionActive = isActive;
         }));
-        [this._sessionActive] = session.IsActiveSync();
+        [this._sessionActive] = session.IsActiveSync(null);
 
         return this._sessionActive;
     },
 
     canPowerOff: function(asyncCallback) {
-        this._proxy.CanStopRemote(function(result, error) {
-            if (error)
-                asyncCallback(false);
-            else
-                asyncCallback(result[0]);
+        this._proxy.CanStopRemote(null, function(proxy, result) {
+            let val = false;
+
+            try {
+                [val] = proxy.CanStopFinish(result);
+            } catch(e) { }
+
+            asyncCallback(val);
         });
     },
 
     canReboot: function(asyncCallback) {
-        this._proxy.CanRestartRemote(function(result, error) {
-            if (error)
-                asyncCallback(false);
-            else
-                asyncCallback(result[0]);
+        this._proxy.CanRestartRemote(null, function(proxy, result) {
+            let val = false;
+
+            try {
+                [val] = proxy.CanRestartFinish(result);
+            } catch(e) { }
+
+            asyncCallback(val);
         });
     },
 
@@ -216,11 +264,11 @@ const LoginManagerConsoleKit = new Lang.Class({
     },
 
     powerOff: function() {
-        this._proxy.StopRemote();
+        this._proxy.StopRemote(null, null);
     },
 
     reboot: function() {
-        this._proxy.RestartRemote();
+        this._proxy.RestartRemote(null, null);
     },
 
     suspend: function() {
diff --git a/js/misc/modemManager.js b/js/misc/modemManager.js
index 35b80b1..1551033 100644
--- a/js/misc/modemManager.js
+++ b/js/misc/modemManager.js
@@ -1,6 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
 const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
 const Lang = imports.lang;
 const Shell = imports.gi.Shell;
 const Signals = imports.signals;
@@ -26,7 +27,16 @@ const ModemGsmNetworkInterface = <interface name="org.freedesktop.ModemManager.M
 </signal>
 </interface>;
 
-const ModemGsmNetworkProxy = Gio.DBusProxy.makeProxyWrapper(ModemGsmNetworkInterface);
+const ModemGsmNetworkProxy = new Gio.DBusProxyClass({
+    Name: 'ModemGsmNetworkProxy',
+    Interface: ModemGsmNetworkInterface,
+
+    _init: function(modem) {
+        this.parent({ g_bus_type: Gio.BusType.SYSTEM,
+                      g_name: 'org.freedesktop.ModemManager',
+                      g_object_path: modem });
+    }
+});
 
 const ModemCdmaInterface = <interface name="org.freedesktop.ModemManager.Modem.Cdma">
 <method name="GetSignalQuality">
@@ -40,7 +50,16 @@ const ModemCdmaInterface = <interface name="org.freedesktop.ModemManager.Modem.C
 </signal>
 </interface>;
 
-const ModemCdmaProxy = Gio.DBusProxy.makeProxyWrapper(ModemCdmaInterface);
+const ModemCdmaProxy = new Gio.DBusProxyClass({
+    Name: 'ModemCdmaProxy',
+    Interface: ModemCdmaInterface,
+
+    _init: function(modem) {
+        this.parent({ g_bus_type: Gio.BusType.SYSTEM,
+                      g_name: 'org.freedesktop.ModemManager',
+                      g_object_path: modem });
+    },
+});
 
 let _providersTable;
 function _getProvidersTable() {
@@ -54,11 +73,18 @@ const ModemGsm = new Lang.Class({
     Name: 'ModemGsm',
 
     _init: function(path) {
-        this._proxy = new ModemGsmNetworkProxy(Gio.DBus.system, 'org.freedesktop.ModemManager', path);
+        this._proxy = new ModemGsmNetworkProxy(path);
+        this._proxy.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(obj, result) {
+            obj.init_finish(result);
+
+            this._finishInit();
+        }));
 
         this.signal_quality = 0;
         this.operator_name = null;
+    },
 
+    _finishInit: function() {
         // Code is duplicated because the function have different signatures
         this._proxy.connectSignal('SignalQuality', Lang.bind(this, function(proxy, sender, [quality]) {
             this.signal_quality = quality;
@@ -68,24 +94,19 @@ const ModemGsm = new Lang.Class({
             this.operator_name = this._findOperatorName(name, code);
             this.emit('notify::operator-name');
         }));
-        this._proxy.GetRegistrationInfoRemote(Lang.bind(this, function([result], err) {
-            if (err) {
-                log(err);
-                return;
-            }
-
-            let [status, code, name] = result;
+        this._proxy.GetRegistrationInfoRemote(null, Lang.bind(this, function(proxy, result) {
+            let [status, code, name] = proxy.GetRegistrationInfoFinish(result);
             this.operator_name = this._findOperatorName(name, code);
             this.emit('notify::operator-name');
         }));
-        this._proxy.GetSignalQualityRemote(Lang.bind(this, function(result, err) {
-            if (err) {
+        this._proxy.GetSignalQualityRemote(null, Lang.bind(this, function(proxy, result) {
+            try {
+                [this.signal_quality] = proxy.GetSignalQualityFinish(result);
+            } catch(e) {
                 // it will return an error if the device is not connected
                 this.signal_quality = 0;
-            } else {
-                let [quality] = result;
-                this.signal_quality = quality;
             }
+
             this.emit('notify::signal-quality');
         }));
     },
@@ -157,10 +178,18 @@ const ModemCdma = new Lang.Class({
     Name: 'ModemCdma',
 
     _init: function(path) {
-        this._proxy = new ModemCdmaProxy(Gio.DBus.system, 'org.freedesktop.ModemManager', path);
+        this._proxy = new ModemCdmaProxy(path);
+        this._proxy.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(obj, result) {
+            obj.init_finish(result);
+
+            this._finishInit();
+        }));
 
         this.signal_quality = 0;
         this.operator_name = null;
+    },
+
+    _finishInit: function() {
         this._proxy.connectSignal('SignalQuality', Lang.bind(this, function(proxy, sender, params) {
             this.signal_quality = params[0];
             this.emit('notify::signal-quality');
@@ -170,30 +199,31 @@ const ModemCdma = new Lang.Class({
             if (this.operator_name == null)
                 this._refreshServingSystem();
         }));
-        this._proxy.GetSignalQualityRemote(Lang.bind(this, function(result, err) {
-            if (err) {
+        this._proxy.GetSignalQualityRemote(null, Lang.bind(this, function(proxy, result) {
+            try {
+                [this.signal_quality] = proxy.GetSignalQualityFinish(result);
+            } catch(e) {
                 // it will return an error if the device is not connected
                 this.signal_quality = 0;
-            } else {
-                let [quality] = result;
-                this.signal_quality = quality;
             }
+
             this.emit('notify::signal-quality');
         }));
     },
 
     _refreshServingSystem: function() {
-        this._proxy.GetServingSystemRemote(Lang.bind(this, function([result], err) {
-            if (err) {
-                // it will return an error if the device is not connected
-                this.operator_name = null;
-            } else {
-                let [bandClass, band, id] = result;
+        this._proxy.GetServingSystemRemote(null, Lang.bind(this, function(proxy, result) {
+            try {
+                let [bandClass, band, name] = proxy.GetServingSystemFinish(result);
                 if (name.length > 0)
-                    this.operator_name = this._findProviderForSid(id);
+                    this.operator_name = this._findProviderForSid(name);
                 else
                     this.operator_name = null;
+            } catch(e) {
+                // it will return an error if the device is not connected
+                this.operator_name = null;
             }
+
             this.emit('notify::operator-name');
         }));
     },
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index 3a3e73c..3da38f8 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -1,6 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
 const Clutter = imports.gi.Clutter;
+const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
 const Lang = imports.lang;
 const St = imports.gi.St;
@@ -200,19 +201,17 @@ const CalendarServerIface = <interface name="org.gnome.Shell.CalendarServer">
 <signal name="Changed" />
 </interface>;
 
-const CalendarServerInfo  = Gio.DBusInterfaceInfo.new_for_xml(CalendarServerIface);
+const CalendarServer = new Gio.DBusProxyClass({
+    Name: 'CalendarServer',
+    Interface: CalendarServerIface,
 
-function CalendarServer() {
-    var self = new Gio.DBusProxy({ g_connection: Gio.DBus.session,
-                                   g_interface_name: CalendarServerInfo.name,
-                                   g_interface_info: CalendarServerInfo,
-                                   g_name: 'org.gnome.Shell.CalendarServer',
-                                   g_object_path: '/org/gnome/Shell/CalendarServer',
-                                   g_flags: Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES });
-
-    self.init(null);
-    return self;
-}
+    _init: function() {
+        this.parent({ g_bus_type: Gio.BusType.SESSION,
+                      g_name: 'org.gnome.Shell.CalendarServer',
+                      g_object_path: '/org/gnome/Shell/CalendarServer',
+                      g_flags: Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES });
+    }
+});
 
 function _datesEqual(a, b) {
     if (a < b)
@@ -240,6 +239,7 @@ const DBusEventSource = new Lang.Class({
         this._resetCache();
 
         this._dbusProxy = new CalendarServer();
+        this._dbusProxy.init(null);
         this._dbusProxy.connectSignal('Changed', Lang.bind(this, this._onChanged));
 
         this._dbusProxy.connect('notify::g-name-owner', Lang.bind(this, function() {
@@ -270,23 +270,28 @@ const DBusEventSource = new Lang.Class({
         this._loadEvents(false);
     },
 
-    _onEventsReceived: function(results, error) {
+    _onEventsReceived: function(proxy, result) {
+        let appointments;
+        try {
+            [appointments] = proxy.call_finish(result).deep_unpack();
+        } catch(e if e instanceof GLib.Error) {
+            // ignore errors coming from DBus
+            appointments = [];
+        }
+
         let newEvents = [];
-        let appointments = results ? results[0] : null;
-        if (appointments != null) {
-            for (let n = 0; n < appointments.length; n++) {
-                let a = appointments[n];
-                let date = new Date(a[4] * 1000);
-                let end = new Date(a[5] * 1000);
-                let summary = a[1];
-                let allDay = a[3];
-                let event = new CalendarEvent(date, end, summary, allDay);
-                newEvents.push(event);
-            }
-            newEvents.sort(function(event1, event2) {
-                return event1.date.getTime() - event2.date.getTime();
-            });
+        for (let n = 0; n < appointments.length; n++) {
+            let a = appointments[n];
+            let date = new Date(a[4] * 1000);
+            let end = new Date(a[5] * 1000);
+            let summary = a[1];
+            let allDay = a[3];
+            let event = new CalendarEvent(date, end, summary, allDay);
+            newEvents.push(event);
         }
+        newEvents.sort(function(event1, event2) {
+            return event1.date.getTime() - event2.date.getTime();
+        });
 
         this._events = newEvents;
         this.emit('changed');
@@ -294,14 +299,19 @@ const DBusEventSource = new Lang.Class({
 
     _loadEvents: function(forceReload) {
         if (this._curRequestBegin && this._curRequestEnd){
+            /* Can't use GetEventsRemote because we need to pass the
+               flags here */
             let callFlags = Gio.DBusCallFlags.NO_AUTO_START;
             if (forceReload)
-                callFlags = Gio.DBusCallFlags.NONE;
-            this._dbusProxy.GetEventsRemote(this._curRequestBegin.getTime() / 1000,
-                                            this._curRequestEnd.getTime() / 1000,
-                                            forceReload,
-                                            Lang.bind(this, this._onEventsReceived),
-                                            callFlags);
+                 callFlags = Gio.DBusCallFlags.NONE;
+            this._dbusProxy.call("GetEvents",
+                                 GLib.Variant.new("(xxb)", [this._curRequestBegin.getTime() / 1000,
+                                                            this._curRequestEnd.getTime() / 1000,
+                                                            forceReload]),
+                                 callFlags,
+                                 -1,
+                                 null,
+                                 Lang.bind(this, this._onEventsReceived));
         }
     },
 
diff --git a/js/ui/components/autorunManager.js b/js/ui/components/autorunManager.js
index 7709a3d..fc55b0d 100644
--- a/js/ui/components/autorunManager.js
+++ b/js/ui/components/autorunManager.js
@@ -2,6 +2,7 @@
 
 const Lang = imports.lang;
 const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
 const St = imports.gi.St;
 
 const LoginManager = imports.misc.loginManager;
@@ -82,12 +83,16 @@ const HotplugSnifferIface = <interface name="org.gnome.Shell.HotplugSniffer">
 </method>
 </interface>;
 
-const HotplugSnifferProxy = Gio.DBusProxy.makeProxyWrapper(HotplugSnifferIface);
-function HotplugSniffer() {
-    return new HotplugSnifferProxy(Gio.DBus.session,
-                                   'org.gnome.Shell.HotplugSniffer',
-                                   '/org/gnome/Shell/HotplugSniffer');
-}
+const HotplugSniffer = new Gio.DBusProxyClass({
+    Name: 'HotplugSnifferProxy',
+    Interface: HotplugSnifferIface,
+
+    _init: function() {
+        this.parent({ g_bus_type: Gio.BusType.SESSION,
+                      g_name: 'org.gnome.Shell.HotplugSniffer',
+                      g_object_path: '/org/gnome/Shell/HotplugSniffer' });
+    }
+});
 
 const ContentTypeDiscoverer = new Lang.Class({
     Name: 'ContentTypeDiscoverer',
@@ -127,10 +132,14 @@ const ContentTypeDiscoverer = new Lang.Class({
             let root = mount.get_root();
 
             let hotplugSniffer = new HotplugSniffer();
-            hotplugSniffer.SniffURIRemote(root.get_uri(),
-                 Lang.bind(this, function([contentTypes]) {
-                     this._emitCallback(mount, contentTypes);
-                 }));
+            hotplugSniffer.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
+                proxy.init_finish(result);
+
+                proxy.SniffURIRemote(root.get_uri(), null, Lang.bind(this, function(proxy, result) {
+                    let [contentTypes] = proxy.SniffURIFinish(result);
+                    this._emitCallback(mount, contentTypes);
+                }));
+            }));
         }
     },
 
diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js
index 57a7dcd..02a6119 100644
--- a/js/ui/endSessionDialog.js
+++ b/js/ui/endSessionDialog.js
@@ -218,6 +218,34 @@ function init() {
     _endSessionDialog = new EndSessionDialog();
 }
 
+const EndSessionExporter = new Gio.DBusImplementerClass({
+    Name: 'EndSessionExporter',
+    Interface: EndSessionDialogIface,
+
+    _init: function() {
+        this.parent();
+
+        this.export(Gio.DBus.session, '/org/gnome/SessionManager/EndSessionDialog');
+    },
+
+    OpenAsync: function(parameters, invocation) {
+        this.emit('open', parameters, invocation);
+    },
+
+    close: function() {
+        this.emit_signal('Closed');
+    },
+
+    cancel: function() {
+        this.emit_signal('Canceled');
+    },
+
+    confirm: function(type) {
+        this.emit_signal(type);
+    },
+});
+Signals.addSignalMethods(EndSessionExporter.prototype);
+
 const EndSessionDialog = new Lang.Class({
     Name: 'EndSessionDialog',
     Extends: ModalDialog.ModalDialog,
@@ -295,8 +323,8 @@ const EndSessionDialog = new Lang.Class({
                                               scrollView.hide();
                                       }));
 
-        this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(EndSessionDialogIface, this);
-        this._dbusImpl.export(Gio.DBus.session, '/org/gnome/SessionManager/EndSessionDialog');
+        this._exporter = new EndSessionExporter();
+        this._exporter.connect('open', Lang.bind(this, this._onOpenRequest));
     },
 
     _onDestroy: function() {
@@ -387,19 +415,19 @@ const EndSessionDialog = new Lang.Class({
 
     close: function() {
         this.parent();
-        this._dbusImpl.emit_signal('Closed', null);
+        this._exporter.close();
     },
 
     cancel: function() {
         this._stopTimer();
-        this._dbusImpl.emit_signal('Canceled', null);
+        this._exporter.cancel();
         this.close(global.get_current_time());
     },
 
     _confirm: function(signal) {
         this._fadeOutDialog();
         this._stopTimer();
-        this._dbusImpl.emit_signal(signal, null);
+        this._exporter.confirm(signal);
     },
 
     _onOpened: function() {
@@ -452,7 +480,7 @@ const EndSessionDialog = new Lang.Class({
         this._updateContent();
     },
 
-    OpenAsync: function(parameters, invocation) {
+    _onOpenRequest: function(exporter, parameters, invocation) {
         let [type, timestamp, totalSecondsToStayOpen, inhibitorObjectPaths] = parameters;
         this._totalSecondsToStayOpen = totalSecondsToStayOpen;
         this._inhibitors = [];
@@ -466,7 +494,10 @@ const EndSessionDialog = new Lang.Class({
         }
 
         for (let i = 0; i < inhibitorObjectPaths.length; i++) {
-            let inhibitor = new GnomeSession.Inhibitor(inhibitorObjectPaths[i], Lang.bind(this, function(proxy, error) {
+            let inhibitor = new GnomeSession.Inhibitor(inhibitorObjectPaths[i]);
+            inhibitor.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
+                proxy.init_finish(result);
+
                 this._onInhibitorLoaded(proxy);
             }));
 
diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js
index 4d97a9d..6fa9613 100644
--- a/js/ui/keyboard.js
+++ b/js/ui/keyboard.js
@@ -2,7 +2,6 @@
 
 const Caribou = imports.gi.Caribou;
 const Clutter = imports.gi.Clutter;
-const DBus = imports.dbus;
 const Gdk = imports.gi.Gdk;
 const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
@@ -191,13 +190,14 @@ const Key = new Lang.Class({
     }
 });
 
-const Keyboard = new Lang.Class({
+const Keyboard = new Gio.DBusImplementerClass({
     // HACK: we can't set Name, because it collides with Name dbus property
     // Name: 'Keyboard',
+    Interface: CaribouKeyboardIface,
 
     _init: function () {
-        this._impl = Gio.DBusExportedObject.wrapJSObject(CaribouKeyboardIface, this);
-        this._impl.export(Gio.DBus.session, '/org/gnome/Caribou/Keyboard');
+        this.parent();
+        this.export(Gio.DBus.session, '/org/gnome/Caribou/Keyboard');
 
         this.actor = null;
         this._focusInTray = false;
diff --git a/js/ui/magnifierDBus.js b/js/ui/magnifierDBus.js
index 8204e72..58accb5 100644
--- a/js/ui/magnifierDBus.js
+++ b/js/ui/magnifierDBus.js
@@ -96,14 +96,15 @@ const ZoomRegionIface = <interface name={ZOOM_SERVICE_NAME}>
 // '/org/gnome/Magnifier/ZoomRegion/zoomer1', etc.
 let _zoomRegionInstanceCount = 0;
 
-const ShellMagnifier = new Lang.Class({
+const ShellMagnifier = new Gio.DBusImplementerClass({
     Name: 'ShellMagnifier',
+    Interface: MagnifierIface,
 
     _init: function() {
-        this._zoomers = {};
+        this.parent();
+        this.export(Gio.DBus.session, MAG_SERVICE_PATH);
 
-        this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(MagnifierIface, this);
-        this._dbusImpl.export(Gio.DBus.session, MAG_SERVICE_PATH);
+        this._zoomers = {};
     },
 
     /**
@@ -332,14 +333,15 @@ const ShellMagnifier = new Lang.Class({
  * @zoomerObjectPath:   String that is the path to a DBus ZoomRegion.
  * @zoomRegion:         The actual zoom region associated with the object path.
  */
-const ShellMagnifierZoomRegion = new Lang.Class({
+const ShellMagnifierZoomRegion = new Gio.DBusImplementerClass({
     Name: 'ShellMagnifierZoomRegion',
+    Interface: ZoomRegionIface,
 
     _init: function(zoomerObjectPath, zoomRegion) {
-        this._zoomRegion = zoomRegion;
+        this.parent();
+        this.export(Gio.DBus.session, zoomerObjectPath);
 
-        this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ZoomRegionIface, this);
-        this._dbusImpl.export(Gio.DBus.session, zoomerObjectPath);
+        this._zoomRegion = zoomRegion;
     },
 
     /**
@@ -417,6 +419,6 @@ const ShellMagnifierZoomRegion = new Lang.Class({
     },
 
     destroy: function() {
-        this._dbusImpl.unexport();
+        this.unexport();
     }
 });
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 20358e1..ca69238 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -1365,13 +1365,16 @@ const MessageTray = new Lang.Class({
     Name: 'MessageTray',
 
     _init: function() {
-        this._presence = new GnomeSession.Presence(Lang.bind(this, function(proxy, error) {
+        this._presence = new GnomeSession.Presence();
+        this._presence.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
+            proxy.init_finish(result);
+
             this._onStatusChanged(proxy.status);
+            this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
+                this._onStatusChanged(status);
+            }));
         }));
         this._busy = false;
-        this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
-            this._onStatusChanged(status);
-        }));
 
         this.actor = new St.Widget({ name: 'message-tray',
                                      reactive: true,
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index ff421f6..1a7a483 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -25,10 +25,16 @@ const BusIface = <interface name="org.freedesktop.DBus">
 </method>
 </interface>;
 
-var BusProxy = Gio.DBusProxy.makeProxyWrapper(BusIface);
-function Bus() {
-    return new BusProxy(Gio.DBus.session, 'org.freedesktop.DBus', '/org/freedesktop/DBus');
-}
+const Bus = new Gio.DBusProxyClass({
+    Name: 'SessionBusProxy',
+    Interface: BusIface,
+
+    _init: function() {
+        this.parent({ g_bus_type: Gio.BusType.SESSION,
+                      g_name: 'org.freedesktop.DBus',
+                      g_object_path: '/org/freedesktop/DBus' });
+    }
+});
 
 const NotificationDaemonIface = <interface name="org.freedesktop.Notifications">
 <method name="Notify">
@@ -103,17 +109,19 @@ const STANDARD_TRAY_ICON_IMPLEMENTATIONS = {
     'ibus-ui-gtk': 'keyboard'
 };
 
-const NotificationDaemon = new Lang.Class({
+const NotificationDaemon = new Gio.DBusImplementerClass({
     Name: 'NotificationDaemon',
+    Interface: NotificationDaemonIface,
 
     _init: function() {
-        this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(NotificationDaemonIface, this);
-        this._dbusImpl.export(Gio.DBus.session, '/org/freedesktop/Notifications');
+        this.parent();
+        this.export(Gio.DBus.session, '/org/freedesktop/Notifications');
 
         this._sources = [];
         this._senderToPid = {};
         this._notifications = {};
         this._busProxy = new Bus();
+        this._busProxy.init(null);
 
         this._trayManager = new Shell.TrayManager();
         this._trayIconAddedId = this._trayManager.connect('tray-icon-added', Lang.bind(this, this._onTrayIconAdded));
@@ -316,18 +324,20 @@ const NotificationDaemon = new Lang.Class({
             return invocation.return_value(GLib.Variant.new('(u)', [id]));;
         }
 
-        this._busProxy.GetConnectionUnixProcessIDRemote(sender, Lang.bind(this, function (result, excp) {
+        this._busProxy.GetConnectionUnixProcessIDRemote(sender, null, Lang.bind(this, function (proxy, result) {
             // The app may have updated or removed the notification
             ndata = this._notifications[id];
             if (!ndata)
                 return;
-
-            if (excp) {
+            
+            let pid;
+            try {
+                [pid] = proxy.GetConnectionUnixProcessIDFinish(result);
+            } catch(excp) {
                 logError(excp, 'Call to GetConnectionUnixProcessID failed');
                 return;
             }
 
-            let [pid] = result;
             source = this._getSource(appName, pid, ndata, sender, null);
 
             // We only store sender-pid entries for persistent sources.
@@ -487,13 +497,11 @@ const NotificationDaemon = new Lang.Class({
     },
 
     _emitNotificationClosed: function(id, reason) {
-        this._dbusImpl.emit_signal('NotificationClosed',
-                                   GLib.Variant.new('(uu)', [id, reason]));
+        this.emit_signal('NotificationClosed', id, reason);
     },
 
     _emitActionInvoked: function(id, action) {
-        this._dbusImpl.emit_signal('ActionInvoked',
-                                   GLib.Variant.new('(us)', [id, action]));
+        this.emit_signal('ActionInvoked', id, action);
     },
 
     _onTrayIconAdded: function(o, icon) {
diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js
index 35176f4..5f45157 100644
--- a/js/ui/remoteSearch.js
+++ b/js/ui/remoteSearch.js
@@ -29,8 +29,15 @@ const SearchProviderIface = <interface name="org.gnome.Shell.SearchProvider">
 </method>
 </interface>;
 
-var SearchProviderProxy = Gio.DBusProxy.makeProxyWrapper(SearchProviderIface);
+var SearchProviderProxy = new Gio.DBusProxyClass({
+    Name: 'SearchProviderProxy',
+    Interface: SearchProviderIface,
 
+    _init: function(params) {
+        params.g_bus_type = Gio.BusType.SESSION;
+        this.parent(params);
+    }
+});
 
 function loadRemoteSearchProviders(addProviderCallback) {
     let dataDirs = GLib.get_system_data_dirs();
@@ -107,8 +114,9 @@ const RemoteSearchProvider = new Lang.Class({
     Extends: Search.SearchProvider,
 
     _init: function(title, icon, dbusName, dbusPath) {
-        this._proxy = new SearchProviderProxy(Gio.DBus.session,
-                                              dbusName, dbusPath);
+        this._proxy = new SearchProviderProxy({ g_name: dbusName,
+                                                g_object_path: dbusPath });
+        this._proxy.init(null);
 
         this.parent(title.toUpperCase());
         this._cancellable = new Gio.Cancellable();
@@ -131,10 +139,17 @@ const RemoteSearchProvider = new Lang.Class({
                              icon_size: size });
     },
 
-    _getResultsFinished: function(results, error) {
-        if (error)
-            return;
-        this.searchSystem.pushResults(this, results[0]);
+    _getResultsFinished: function(proxy, result) {
+        try {
+            // We rely on a small implementation detail of the
+            // GDBus bindings here: all *Finish are equal
+
+            let [results] = proxy.GetInitialResultSetFinish(result);
+            this.searchSystem.pushResults(this, results);
+        } catch(e) {
+            if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
+                log('Received error from search provider %s: %s'.format(this.title, String(e)));
+        }
     },
 
     getInitialResultSet: function(terms) {
@@ -142,8 +157,8 @@ const RemoteSearchProvider = new Lang.Class({
         this._cancellable.reset();
         try {
             this._proxy.GetInitialResultSetRemote(terms,
-                                                  Lang.bind(this, this._getResultsFinished),
-                                                  this._cancellable);
+                                                  this._cancellable,
+                                                  Lang.bind(this, this._getResultsFinished));
         } catch(e) {
             log('Error calling GetInitialResultSet for provider %s: %s'.format( this.title, e.toString()));
             this.searchSystem.pushResults(this, []);
@@ -155,30 +170,30 @@ const RemoteSearchProvider = new Lang.Class({
         this._cancellable.reset();
         try {
             this._proxy.GetSubsearchResultSetRemote(previousResults, newTerms,
-                                                    Lang.bind(this, this._getResultsFinished),
-                                                    this._cancellable);
+                                                    this._cancellable,
+                                                    Lang.bind(this, this._getResultsFinished))
         } catch(e) {
             log('Error calling GetSubsearchResultSet for provider %s: %s'.format(this.title, e.toString()));
             this.searchSystem.pushResults(this, []);
         }
     },
 
-    _getResultMetasFinished: function(results, error, callback) {
-        if (error) {
+    _getResultMetasFinished: function(proxy, result, callback) {
+        try {
+            let [metas] = results.GetResultMetasFinish(result);
+            let resultMetas = [];
+            for (let i = 0; i < metas.length; i++) {
+                for (let prop in metas[i])
+                    metas[i][prop] = metas[i][prop].deep_unpack();
+                resultMetas.push({ id: metas[i]['id'],
+                                   name: metas[i]['name'],
+                                   createIcon: Lang.bind(this,
+                                                         this.createIcon, metas[i]) });
+            }
+            callback(resultMetas);
+        } catch(e) {
             callback([]);
-            return;
-        }
-        let metas = results[0];
-        let resultMetas = [];
-        for (let i = 0; i < metas.length; i++) {
-            for (let prop in metas[i])
-                metas[i][prop] = metas[i][prop].deep_unpack();
-            resultMetas.push({ id: metas[i]['id'],
-                               name: metas[i]['name'],
-                               createIcon: Lang.bind(this,
-                                                     this.createIcon, metas[i]) });
         }
-        callback(resultMetas);
     },
 
     getResultMetas: function(ids, callback) {
@@ -186,8 +201,8 @@ const RemoteSearchProvider = new Lang.Class({
         this._cancellable.reset();
         try {
             this._proxy.GetResultMetasRemote(ids,
-                                             Lang.bind(this, this._getResultMetasFinished, callback),
-                                             this._cancellable);
+                                             this._cancellable,
+                                             Lang.bind(this, this._getResultMetasFinished, callback));
         } catch(e) {
             log('Error calling GetResultMetas for provider %s: %s'.format(this.title, e.toString()));
             callback([]);
@@ -195,7 +210,7 @@ const RemoteSearchProvider = new Lang.Class({
     },
 
     activateResult: function(id) {
-        this._proxy.ActivateResultRemote(id);
+        this._proxy.ActivateResultRemote(id, null, null);
     }
 });
 
diff --git a/js/ui/scripting.js b/js/ui/scripting.js
index d5e2eae..f8322ef 100644
--- a/js/ui/scripting.js
+++ b/js/ui/scripting.js
@@ -80,15 +80,23 @@ const PerfHelperIface = <interface name="org.gnome.Shell.PerfHelper">
 <method name="DestroyWindows" />
 </interface>;
 
-var PerfHelperProxy = Gio.DBusProxy.makeProxyWrapper(PerfHelperIface);
-function PerfHelper() {
-    return new PerfHelperProxy(Gio.DBus.session, 'org.gnome.Shell.PerfHelper', '/org/gnome/Shell/PerfHelper');
-}
+const PerfHelper = new Gio.DBusProxyClass({
+    Name: 'PerfHelperProxy',
+    Interface: PerfHelperIface,
+
+    _init: function() {
+        this.parent({ g_bus_type: Gio.BusType.SESSION,
+                      g_name: 'org.gnome.Shell.PerfHelper',
+                      g_object_path: '/org/gnome/Shell/PerfHelper' });
+    }
+});
 
 let _perfHelper = null;
 function _getPerfHelper() {
-    if (_perfHelper == null)
+    if (_perfHelper == null) {
         _perfHelper = new PerfHelper();
+        _perfHelper.init(null);
+    }
 
     return _perfHelper;
 }
@@ -111,7 +119,8 @@ function createTestWindow(width, height, alpha, maximized) {
     let perfHelper = _getPerfHelper();
 
     perfHelper.CreateWindowRemote(width, height, alpha, maximized,
-                                  function(result, excp) {
+                                  null,
+                                  function(proxy, result) {
                                       if (cb)
                                           cb();
                                   });
@@ -131,7 +140,7 @@ function waitTestWindows() {
     let cb;
     let perfHelper = _getPerfHelper();
 
-    perfHelper.WaitWindowsRemote(function(result, excp) {
+    perfHelper.WaitWindowsRemote(null, function(proxy, result) {
                                      if (cb)
                                          cb();
                                  });
@@ -154,7 +163,7 @@ function destroyTestWindows() {
     let cb;
     let perfHelper = _getPerfHelper();
 
-    perfHelper.DestroyWindowsRemote(function(result, excp) {
+    perfHelper.DestroyWindowsRemote(null, function(proxy, result) {
                                         if (cb)
                                             cb();
                                     });
diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index 7a625af..d57bffb 100644
--- a/js/ui/shellDBus.js
+++ b/js/ui/shellDBus.js
@@ -67,14 +67,16 @@ const ScreenSaverIface = <interface name="org.gnome.ScreenSaver">
 </signal>
 </interface>;
 
-const GnomeShell = new Lang.Class({
+const GnomeShell = new Gio.DBusImplementerClass({
     Name: 'GnomeShellDBus',
+    Interface: GnomeShellIface,
 
     _init: function() {
-        this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellIface, this);
-        this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
+        this.parent();
+
+        this.export(Gio.DBus.session, '/org/gnome/Shell');
 
-        this._extensionsSerivce = new GnomeShellExtensions();
+        this._extensionsService = new GnomeShellExtensions();
     },
 
     /**
@@ -236,12 +238,14 @@ const GnomeShellExtensionsIface = <interface name="org.gnome.Shell.Extensions">
 <property name="ShellVersion" type="s" access="read" />
 </interface>;
 
-const GnomeShellExtensions = new Lang.Class({
+const GnomeShellExtensions = new Gio.DBusImplementerClass({
     Name: 'GnomeShellExtensionsDBus',
+    Interface: GnomeShellExtensionsIface,
 
     _init: function() {
-        this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellExtensionsIface, this);
-        this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
+        this.parent();
+
+        this.export(Gio.DBus.session, '/org/gnome/Shell');
         ExtensionSystem.connect('extension-state-changed',
                                 Lang.bind(this, this._extensionStateChanged));
     },
@@ -335,25 +339,23 @@ const GnomeShellExtensions = new Lang.Class({
     ShellVersion: Config.PACKAGE_VERSION,
 
     _extensionStateChanged: function(_, newState) {
-        this._dbusImpl.emit_signal('ExtensionStatusChanged',
-                                   GLib.Variant.new('(sis)', [newState.uuid, newState.state, newState.error]));
+        this.emit_signal('ExtensionStatusChanged', newState.uuid, newState.state, newState.error);
     }
 });
 
-const ScreenSaverDBus = new Lang.Class({
+const ScreenSaverDBus = new Gio.DBusImplementerClass({
     Name: 'ScreenSaverDBus',
+    Interface: ScreenSaverIface,
 
     _init: function(screenShield) {
         this.parent();
 
         this._screenShield = screenShield;
         screenShield.connect('lock-status-changed', Lang.bind(this, function(shield) {
-            this._dbusImpl.emit_signal('ActiveChanged', GLib.Variant.new('(b)', [shield.locked]));
+            this.emit_signal('ActiveChanged', shield.locked);
         }));
 
-        this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenSaverIface, this);
-        this._dbusImpl.export(Gio.DBus.session, '/org/gnome/ScreenSaver');
-
+        this.export(Gio.DBus.session, '/org/gnome/ScreenSaver');
         Gio.DBus.session.own_name('org.gnome.ScreenSaver', Gio.BusNameOwnerFlags.REPLACE, null, null);
     },
 
diff --git a/js/ui/shellMountOperation.js b/js/ui/shellMountOperation.js
index 06eb814..fd1c791 100644
--- a/js/ui/shellMountOperation.js
+++ b/js/ui/shellMountOperation.js
@@ -554,14 +554,16 @@ const ShellMountOperationType = {
     SHOW_PROCESSES: 3
 };
 
-const GnomeShellMountOpHandler = new Lang.Class({
+const GnomeShellMountOpHandler = new Gio.DBusImplementerClass({
     Name: 'GnomeShellMountOpHandler',
+    Interface: GnomeShellMountOpIface,
 
     _init: function() {
-        this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellMountOpIface, this);
-        this._dbusImpl.export(Gio.DBus.session, '/org/gtk/MountOperationHandler');
-        Gio.bus_own_name_on_connection(Gio.DBus.session, 'org.gtk.MountOperationHandler',
-                                       Gio.BusNameOwnerFlags.REPLACE, null, null);
+        this.parent();
+
+        this.export(Gio.DBus.session, '/org/gtk/MountOperationHandler');
+        Gio.DBus.session.own_name('org.gtk.MountOperationHandler',
+                                  Gio.BusNameOwnerFlags.REPLACE, null, null);
 
         this._dialog = null;
         this._volumeMonitor = Gio.VolumeMonitor.get();
diff --git a/js/ui/status/power.js b/js/ui/status/power.js
index a5f2625..111c1e4 100644
--- a/js/ui/status/power.js
+++ b/js/ui/status/power.js
@@ -1,6 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
 const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
 const Lang = imports.lang;
 const St = imports.gi.St;
 
@@ -45,7 +46,16 @@ const PowerManagerInterface = <interface name="org.gnome.SettingsDaemon.Power">
 <property name="Icon" type="s" access="read" />
 </interface>;
 
-const PowerManagerProxy = Gio.DBusProxy.makeProxyWrapper(PowerManagerInterface);
+const PowerManagerProxy = new Gio.DBusProxyClass({
+    Name: 'PowerManagerProxy',
+    Interface: PowerManagerInterface,
+
+    _init: function() {
+        this.parent({ g_bus_type: Gio.BusType.SESSION,
+                      g_name: BUS_NAME,
+                      g_object_path: OBJECT_PATH });
+    }
+});
 
 const Indicator = new Lang.Class({
     Name: 'PowerIndicator',
@@ -54,7 +64,7 @@ const Indicator = new Lang.Class({
     _init: function() {
         this.parent('battery-missing-symbolic', _("Battery"));
 
-        this._proxy = new PowerManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH);
+        this._proxy = new PowerManagerProxy();
 
         this._deviceItems = [ ];
         this._hasPrimary = false;
@@ -73,18 +83,26 @@ const Indicator = new Lang.Class({
 
         this._proxy.connect('g-properties-changed',
                             Lang.bind(this, this._devicesChanged));
-        this._devicesChanged();
+        this._proxy.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
+            proxy.init_finish(result);
+
+            this._devicesChanged();
+        }));
     },
 
     _readPrimaryDevice: function() {
-        this._proxy.GetPrimaryDeviceRemote(Lang.bind(this, function(result, error) {
-            if (error) {
+        this._proxy.GetPrimaryDeviceRemote(null, Lang.bind(this, function(proxy, result) {
+            let device_id, device_type, icon, percentage, state, seconds;
+            try {
+                [[device_id, device_type, icon, percentage, state, seconds]] =
+                    proxy.GetPrimaryDeviceFinish(result);
+            } catch(e) {
                 this._hasPrimary = false;
                 this._primaryDeviceId = null;
                 this._batteryItem.actor.hide();
                 return;
             }
-            let [[device_id, device_type, icon, percentage, state, seconds]] = result;
+
             if (device_type == UPDeviceType.BATTERY) {
                 this._hasPrimary = true;
                 let time = Math.round(seconds / 60);
@@ -121,16 +139,18 @@ const Indicator = new Lang.Class({
     },
 
     _readOtherDevices: function() {
-        this._proxy.GetDevicesRemote(Lang.bind(this, function(result, error) {
+        this._proxy.GetDevicesRemote(null, Lang.bind(this, function(proxy, result) {
             this._deviceItems.forEach(function(i) { i.destroy(); });
             this._deviceItems = [];
 
-            if (error) {
+            let devices;
+            try {
+                [devices] = proxy.GetDevicesFinish(result);
+            } catch(e) {
                 return;
             }
 
             let position = 0;
-            let [devices] = result;
             for (let i = 0; i < devices.length; i++) {
                 let [device_id, device_type] = devices[i];
                 if (device_type == UPDeviceType.AC_POWER || device_id == this._primaryDeviceId)
diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js
index d1bfdb8..eecb75a 100644
--- a/js/ui/userMenu.js
+++ b/js/ui/userMenu.js
@@ -195,8 +195,12 @@ const IMStatusChooserItem = new Lang.Class({
                             Lang.bind(this, this._changeIMStatus));
 
         this._presence = new GnomeSession.Presence();
-        this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
-            this._sessionStatusChanged(status);
+        this._presence.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(obj, result) {
+            obj.init_finish(result);
+
+            this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
+                this._sessionStatusChanged(status);
+            }));
         }));
 
         this._sessionPresenceRestored = false;
@@ -480,8 +484,19 @@ const UserMenuButton = new Lang.Class({
         this._userManager = AccountsService.UserManager.get_default();
 
         this._user = this._userManager.get_user(GLib.get_user_name());
+
         this._presence = new GnomeSession.Presence();
+        this._presence.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(proxy, result) {
+            proxy.init_finish(result);
+
+            this._updateSwitch(this._presence.status);
+            this._presence.connectSignal('StatusChanged', Lang.bind(this, function (proxy, senderName, [status]) {
+                this._updateSwitch(status);
+            }));
+        }));
+
         this._session = new GnomeSession.SessionManager();
+        this._session.init(null);
         this._haveShutdown = true;
         this._haveSuspend = true;
 
@@ -533,11 +548,6 @@ const UserMenuButton = new Lang.Class({
 
         this._createSubMenu();
 
-        this._updateSwitch(this._presence.status);
-        this._presence.connectSignal('StatusChanged', Lang.bind(this, function (proxy, senderName, [status]) {
-            this._updateSwitch(status);
-        }));
-
         this._userManager.connect('notify::is-loaded',
                                   Lang.bind(this, this._updateMultiUser));
         this._userManager.connect('notify::has-multiple-users',
@@ -637,14 +647,16 @@ const UserMenuButton = new Lang.Class({
     },
 
     _updateHaveShutdown: function() {
-        this._session.CanShutdownRemote(Lang.bind(this,
-            function(result, error) {
-                if (!error) {
-                    this._haveShutdown = result[0];
-                    this._updateInstallUpdates();
-                    this._updateSuspendOrPowerOff();
-                }
-            }));
+        this._session.CanShutdownRemote(null, Lang.bind(this, function(proxy, result) {
+            try {
+                [this._haveShutdown] = proxy.CanShutdownFinish(result);
+            } catch(e) {
+                this._haveShutdown = false;
+            }
+
+            this._updateInstallUpdates();
+            this._updateSuspendOrPowerOff();
+        }));
     },
 
     _updateHaveSuspend: function() {
@@ -837,7 +849,7 @@ const UserMenuButton = new Lang.Class({
 
     _onQuitSessionActivate: function() {
         Main.overview.hide();
-        this._session.LogoutRemote(0);
+        this._session.LogoutRemote(0, null, null);
     },
 
     _onInstallUpdatesActivate: function() {
@@ -852,7 +864,7 @@ const UserMenuButton = new Lang.Class({
 
         if (this._haveShutdown &&
             this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {
-            this._session.ShutdownRemote();
+            this._session.ShutdownRemote(null, null);
         } else {
             if (this._screenSaverSettings.get_boolean(LOCK_ENABLED_KEY)) {
                 let tmpId = Main.screenShield.connect('lock-screen-shown', Lang.bind(this, function() {



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