retrieving contact list: works in looking-glass, not in extension



Hi gnome-mailing-list,

I've recently delved into the world of writing gnome shell extensions.
Pretty fun, but quite frustrating.

As an introductory exercise I wanted to retrieve a list of all the
contacts I have (from gnome-contacts, I guess).

In any case, with looking-glass I was able to experiment and discover
the following two snippets of code that both return a list of contact
IDs. These are similar to what the overview uses when you search to
display matching contacts. I searched on '' to get the entire contact
list:

// METHOD 1:
const ContactDisplay = imports.ui.contactDisplay;
let csp = new ContactDisplay.ContactSearchProvider();
let contacts = csp.getInitialResultSet(['']);
contacts.length // 120 contacts

// METHOD 2:
const ContactSystem = Shell.ContactSystem;
let cs = ContactSystem.get_default();
let contacts2 = cs.initial_search(['']);
contacts2.length // 120 contacts

However, when I put this exact same code into a gnome shell extension
(say the enable() method of extension.js) and `global.log(
contacts.length )`, I *always* get 0, that is, it didn't find any
contacts.

Can anyone tell me why this is and how I can work around it? Do the
extensions operate in some sort of quarantined little sandbox that the
looking glass doesn't?

cheers!


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