remote-search: first implementation of SearchProvider2

We read the implemented version from the search provider's keyfile, and
then create a RemoteSearchProvider object from the right class
accordingly.
Wire ActivateResult() to the new method (without actually passing the
new parameters along) - an actual implementation will be added in a
future commit.

https://bugzilla.gnome.org/show_bug.cgi?id=689735
This commit is contained in:
Cosimo Cecchi 2012-12-05 17:20:22 -05:00
parent b390b82e9d
commit 72d54d9915

View File

@ -29,7 +29,32 @@ const SearchProviderIface = <interface name="org.gnome.Shell.SearchProvider">
</method> </method>
</interface>; </interface>;
const SearchProvider2Iface = <interface name="org.gnome.Shell.SearchProvider2">
<method name="GetInitialResultSet">
<arg type="as" direction="in" />
<arg type="as" direction="out" />
</method>
<method name="GetSubsearchResultSet">
<arg type="as" direction="in" />
<arg type="as" direction="in" />
<arg type="as" direction="out" />
</method>
<method name="GetResultMetas">
<arg type="as" direction="in" />
<arg type="aa{sv}" direction="out" />
</method>
<method name="ActivateResult">
<arg type="s" direction="in" />
<arg type="as" direction="in" />
<arg type="u" direction="in" />
</method>
<method name="LaunchSearch">
<arg type="as" direction="in" />
</method>
</interface>;
var SearchProviderProxy = Gio.DBusProxy.makeProxyWrapper(SearchProviderIface); var SearchProviderProxy = Gio.DBusProxy.makeProxyWrapper(SearchProviderIface);
var SearchProvider2Proxy = Gio.DBusProxy.makeProxyWrapper(SearchProvider2Iface);
function loadRemoteSearchProviders(addProviderCallback) { function loadRemoteSearchProviders(addProviderCallback) {
let data = { loadedProviders: [], let data = { loadedProviders: [],
@ -73,9 +98,18 @@ function loadRemoteSearchProvider(file, info, data) {
return; return;
} }
remoteProvider = new RemoteSearchProvider(appInfo, let version = '1';
busName, try {
objectPath); version = keyfile.get_string(group, 'Version');
} catch (e) {
// ignore error
}
if (version >= 2)
remoteProvider = new RemoteSearchProvider2(appInfo, busName, objectPath);
else
remoteProvider = new RemoteSearchProvider(appInfo, busName, objectPath);
data.objectPaths[objectPath] = remoteProvider; data.objectPaths[objectPath] = remoteProvider;
data.loadedProviders.push(remoteProvider); data.loadedProviders.push(remoteProvider);
} catch(e) { } catch(e) {
@ -134,8 +168,11 @@ const RemoteSearchProvider = new Lang.Class({
Name: 'RemoteSearchProvider', Name: 'RemoteSearchProvider',
Extends: Search.SearchProvider, Extends: Search.SearchProvider,
_init: function(appInfo, dbusName, dbusPath) { _init: function(appInfo, dbusName, dbusPath, proxyType) {
this._proxy = new SearchProviderProxy(Gio.DBus.session, if (!proxyType)
proxyType = SearchProviderProxy;
this.proxy = new proxyType(Gio.DBus.session,
dbusName, dbusPath, Lang.bind(this, this._onProxyConstructed)); dbusName, dbusPath, Lang.bind(this, this._onProxyConstructed));
this.parent(appInfo.get_name().toUpperCase(), appInfo, true); this.parent(appInfo.get_name().toUpperCase(), appInfo, true);
@ -173,7 +210,7 @@ const RemoteSearchProvider = new Lang.Class({
this._cancellable.cancel(); this._cancellable.cancel();
this._cancellable.reset(); this._cancellable.reset();
try { 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) { } catch(e) {
@ -186,7 +223,7 @@ const RemoteSearchProvider = new Lang.Class({
this._cancellable.cancel(); this._cancellable.cancel();
this._cancellable.reset(); this._cancellable.reset();
try { 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) { } catch(e) {
@ -217,7 +254,7 @@ const RemoteSearchProvider = new Lang.Class({
this._cancellable.cancel(); this._cancellable.cancel();
this._cancellable.reset(); this._cancellable.reset();
try { 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) { } catch(e) {
@ -227,8 +264,19 @@ const RemoteSearchProvider = new Lang.Class({
}, },
activateResult: function(id) { activateResult: function(id) {
this._proxy.ActivateResultRemote(id); this.proxy.ActivateResultRemote(id);
} }
}); });
const RemoteSearchProvider2 = new Lang.Class({
Name: 'RemoteSearchProvider2',
Extends: RemoteSearchProvider,
_init: function(appInfo, dbusName, dbusPath) {
this.parent(appInfo, dbusName, dbusPath, SearchProvider2Proxy);
},
activateResult: function(id) {
this.proxy.ActivateResultRemote(id, [], 0);
}
});