remoteSearch: Fix remote search providers

Commit 289f982949 broke all remote providers when adding support for
non-auto-started search providers: Whether the provider should be
auto-started needs to be known in the constructor, so setting the
property on the constructed object doesn't work.

https://bugzilla.gnome.org/show_bug.cgi?id=787986
This commit is contained in:
Florian Müllner 2017-09-19 23:58:29 +02:00
parent 9f0bb526f7
commit f5a28c2f24

View File

@ -98,6 +98,13 @@ function loadRemoteSearchProviders(searchSettings, callback) {
return; return;
} }
let autoStart = true;
try {
autoStart = keyfile.get_boolean(group, 'AutoStart');
} catch(e) {
// ignore error
}
let version = '1'; let version = '1';
try { try {
version = keyfile.get_string(group, 'Version'); version = keyfile.get_string(group, 'Version');
@ -106,9 +113,9 @@ function loadRemoteSearchProviders(searchSettings, callback) {
} }
if (version >= 2) if (version >= 2)
remoteProvider = new RemoteSearchProvider2(appInfo, busName, objectPath); remoteProvider = new RemoteSearchProvider2(appInfo, busName, objectPath, autoStart);
else else
remoteProvider = new RemoteSearchProvider(appInfo, busName, objectPath); remoteProvider = new RemoteSearchProvider(appInfo, busName, objectPath, autoStart);
remoteProvider.defaultEnabled = true; remoteProvider.defaultEnabled = true;
try { try {
@ -117,13 +124,6 @@ function loadRemoteSearchProviders(searchSettings, callback) {
// ignore error // ignore error
} }
remoteProvider.autoStart = true;
try {
remoteProvider.autoStart = keyfile.get_boolean(group, 'AutoStart');
} catch(e) {
// ignore error
}
objectPaths[objectPath] = remoteProvider; objectPaths[objectPath] = remoteProvider;
loadedProviders.push(remoteProvider); loadedProviders.push(remoteProvider);
} catch(e) { } catch(e) {
@ -191,12 +191,12 @@ function loadRemoteSearchProviders(searchSettings, callback) {
var RemoteSearchProvider = new Lang.Class({ var RemoteSearchProvider = new Lang.Class({
Name: 'RemoteSearchProvider', Name: 'RemoteSearchProvider',
_init: function(appInfo, dbusName, dbusPath, proxyInfo) { _init: function(appInfo, dbusName, dbusPath, autoStart, proxyInfo) {
if (!proxyInfo) if (!proxyInfo)
proxyInfo = SearchProviderProxyInfo; proxyInfo = SearchProviderProxyInfo;
let g_flags = Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES; let g_flags = Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES;
if (remoteProvider.autoStart) if (autoStart)
g_flags |= Gio.DBusProxyFlags.DO_NOT_AUTO_START_AT_CONSTRUCTION; g_flags |= Gio.DBusProxyFlags.DO_NOT_AUTO_START_AT_CONSTRUCTION;
else else
g_flags |= Gio.DBusProxyFlags.DO_NOT_AUTO_START; g_flags |= Gio.DBusProxyFlags.DO_NOT_AUTO_START;
@ -319,8 +319,8 @@ var RemoteSearchProvider2 = new Lang.Class({
Name: 'RemoteSearchProvider2', Name: 'RemoteSearchProvider2',
Extends: RemoteSearchProvider, Extends: RemoteSearchProvider,
_init: function(appInfo, dbusName, dbusPath) { _init: function(appInfo, dbusName, dbusPath, autoStart) {
this.parent(appInfo, dbusName, dbusPath, SearchProvider2ProxyInfo); this.parent(appInfo, dbusName, dbusPath, autoStart, SearchProvider2ProxyInfo);
this.canLaunchSearch = true; this.canLaunchSearch = true;
}, },