RemoteSearch: don't autostart dbus search providers at login

Use the new glib flag that allows us to create the proxy immediately
but only activate the service when making the first call.

https://bugzilla.gnome.org/show_bug.cgi?id=708830
This commit is contained in:
Giovanni Campagna 2013-09-26 13:22:22 +02:00 committed by Giovanni Campagna
parent eb66407926
commit da19b344b5

View File

@ -59,8 +59,8 @@ const SearchProvider2Iface = '<node> \
</interface> \ </interface> \
</node>'; </node>';
var SearchProviderProxy = Gio.DBusProxy.makeProxyWrapper(SearchProviderIface); var SearchProviderProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProviderIface);
var SearchProvider2Proxy = Gio.DBusProxy.makeProxyWrapper(SearchProvider2Iface); var SearchProvider2ProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProvider2Iface);
function loadRemoteSearchProviders(addProviderCallback) { function loadRemoteSearchProviders(addProviderCallback) {
let objectPaths = {}; let objectPaths = {};
@ -176,12 +176,18 @@ function loadRemoteSearchProviders(addProviderCallback) {
const RemoteSearchProvider = new Lang.Class({ const RemoteSearchProvider = new Lang.Class({
Name: 'RemoteSearchProvider', Name: 'RemoteSearchProvider',
_init: function(appInfo, dbusName, dbusPath, proxyType) { _init: function(appInfo, dbusName, dbusPath, proxyInfo) {
if (!proxyType) if (!proxyInfo)
proxyType = SearchProviderProxy; proxyInfo = SearchProviderProxyInfo;
this.proxy = new proxyType(Gio.DBus.session, this.proxy = new Gio.DBusProxy({ g_bus_type: Gio.BusType.SESSION,
dbusName, dbusPath, Lang.bind(this, this._onProxyConstructed)); g_name: dbusName,
g_object_path: dbusPath,
g_interface_info: proxyInfo,
g_interface_name: proxyInfo.name,
g_flags: (Gio.DBusProxyFlags.DO_NOT_AUTO_START_AT_CONSTRUCTION |
Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES) });
this.proxy.init_async(GLib.PRIORITY_DEFAULT, null, null);
this.appInfo = appInfo; this.appInfo = appInfo;
this.id = appInfo.get_id(); this.id = appInfo.get_id();
@ -190,10 +196,6 @@ const RemoteSearchProvider = new Lang.Class({
this._cancellable = new Gio.Cancellable(); this._cancellable = new Gio.Cancellable();
}, },
_onProxyConstructed: function(proxy) {
// Do nothing
},
createIcon: function(size, meta) { createIcon: function(size, meta) {
let gicon; let gicon;
if (meta['icon']) { if (meta['icon']) {
@ -222,39 +224,34 @@ const RemoteSearchProvider = new Lang.Class({
}, },
_getResultsFinished: function(results, error) { _getResultsFinished: function(results, error) {
if (error) if (error) {
return; if (!error.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
log('Received error from DBus search provider %s: %s'.format(this.id, String(error)));
} else {
this.searchSystem.setResults(this, results[0]); this.searchSystem.setResults(this, results[0]);
}
}, },
getInitialResultSet: function(terms) { getInitialResultSet: function(terms) {
this._cancellable.cancel(); this._cancellable.cancel();
this._cancellable.reset(); this._cancellable.reset();
try {
this.proxy.GetInitialResultSetRemote(terms, this.proxy.GetInitialResultSetRemote(terms,
Lang.bind(this, this._getResultsFinished), Lang.bind(this, this._getResultsFinished),
this._cancellable); this._cancellable);
} catch(e) {
log('Error calling GetInitialResultSet for provider %s: %s'.format(this.id, e.toString()));
this.searchSystem.setResults(this, []);
}
}, },
getSubsearchResultSet: function(previousResults, newTerms) { getSubsearchResultSet: function(previousResults, newTerms) {
this._cancellable.cancel(); this._cancellable.cancel();
this._cancellable.reset(); this._cancellable.reset();
try {
this.proxy.GetSubsearchResultSetRemote(previousResults, newTerms, this.proxy.GetSubsearchResultSetRemote(previousResults, newTerms,
Lang.bind(this, this._getResultsFinished), Lang.bind(this, this._getResultsFinished),
this._cancellable); this._cancellable);
} catch(e) {
log('Error calling GetSubsearchResultSet for provider %s: %s'.format(this.id, e.toString()));
this.searchSystem.setResults(this, []);
}
}, },
_getResultMetasFinished: function(results, error, callback) { _getResultMetasFinished: function(results, error, callback) {
if (error) { if (error) {
if (!error.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
log('Received error from DBus search provider %s during GetResultMetas: %s'.format(this.id, String(error)));
callback([]); callback([]);
return; return;
} }
@ -279,14 +276,9 @@ const RemoteSearchProvider = new Lang.Class({
getResultMetas: function(ids, callback) { getResultMetas: function(ids, callback) {
this._cancellable.cancel(); this._cancellable.cancel();
this._cancellable.reset(); this._cancellable.reset();
try {
this.proxy.GetResultMetasRemote(ids, this.proxy.GetResultMetasRemote(ids,
Lang.bind(this, this._getResultMetasFinished, callback), Lang.bind(this, this._getResultMetasFinished, callback),
this._cancellable); this._cancellable);
} catch(e) {
log('Error calling GetResultMetas for provider %s: %s'.format(this.id, e.toString()));
callback([]);
}
}, },
activateResult: function(id) { activateResult: function(id) {
@ -306,7 +298,7 @@ const RemoteSearchProvider2 = new Lang.Class({
Extends: RemoteSearchProvider, Extends: RemoteSearchProvider,
_init: function(appInfo, dbusName, dbusPath) { _init: function(appInfo, dbusName, dbusPath) {
this.parent(appInfo, dbusName, dbusPath, SearchProvider2Proxy); this.parent(appInfo, dbusName, dbusPath, SearchProvider2ProxyInfo);
this.canLaunchSearch = true; this.canLaunchSearch = true;
}, },