View Single Post
Old 09-05-2010, 10:07 AM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by timlegge View Post
I am trying to figure out how to add collections support to the Kobo.

What is it that the manage collections action from the device popup menu does?

I assume that it would add the currently selected collection to the currently selected book. Is that correct?

I will probably have other questions as I work on this...

Tim
I assume you are asking about something calibre does, and not what the kobo does?

From the point of view of a device driver, collection management is currently arranged in the class CollectionsBookList. There is one interface method, rebuild_collections, and one utility method, get_collections. Both of these interact with the Metadata Management setting in preferences -> add/save -> send to device.

When a device is plugged in: if a device supports collections, then the 'books' interface method *must* ensure that the book.device_collections contains a list of the collections of which the book is a member. If it does not, and if metadata management is set to manual, then the collections will be lost. In addition, the GUI will not be able to display the information.

If Metadata management is manual, then the user can add and remove collections on the device view. After editing, calibre modifies book.device_collections and calls rebuild_collections with that book (or books). Rebuild_collections must do whatever is necessary to make the device's collections match the contents of the 'device_collections' attribute. It is not necessary (nor desirable) to call booklist.get_collections

Devices that support collections should call booklist.get_collections whenever metadata is changed, i.e. when sync_booklists is called. Get_collections returns a dictionary {collection:[list of books], c:[bl], ...}. The list of books is in the order that they should appear on the device. The device driver's job is to ensure that collections on the device match what is in the dict, deleting and adding as needed. Get_collections uses the Metadata management setting, the new_book flag, and the book's device_collections attribute to build the dict.

If metadata management is set to either automatic or on_send, then collections are built exclusively from the calibre attributes specified in the device customization. Custom field attributes are being added real-soon-now. The user cannot add or remove collections on the device view.

The Sony drivers are a good but complicated example of how collection management works. It is very possible that some sony-only stuff has crept into the general code. Don't hesitate to point that out. It would be best to try to avoid creating another collection management structure.
chaley is offline   Reply With Quote