quicksilver/Quicksilver — pull request #1455 by skurfer (2013-04-02 14:17:05+00:00)
Title: allow object sources to manage their contents

Looks like a lot of changes, but it was all really just to allow for one thing: I thought we could address the asynchronous object source problem by making `objectsForEntry:` act more like `loadChildrenForObject:`. That is, it sets a variable on the object passed in instead of returning results to QS.

I think all object sources should be changed to use `loadObjectsForEntry:` and `objectsForEntry:` should be phased out. If there's agreement on that, I'll go change all the object sources in the app itself as part of this pull request. FYI, updating an object source is pretty easy.

1. Change the method signature from `- (NSArray *)objectsForEntry:(NSDictionary *)theEntry` to `- (BOOL)loadObjectsForEntry:(QSCatalogEntry *)theEntry`
2. Return `NO` instead of `nil` or an empty array when something fails.
3. When results are gathered, call `[theEntry completeScanWithContents:objects]` and return `YES`.

Step 3 applies to the existing "return immediately" object sources. But the whole purpose of this change is to allow `completeScanWithContents:` to be called at a later point by another method.

Other small changes:

* The object source won't always be an instance or descendant of `QSObjectSource`, so I've changed it to `id` everywhere.
* I rethought the way `loadIndex` handles errors and empty arrays.
* Instead of testing things so see if `saveIndex` should be called, I just moved the tests into the method itself, so we can just call it without worrying about whether or not we should.