View Single Post
Old 11-25-2019, 04:43 AM   #11
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: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
For the adventurous: the base calibre device interface provides a method, synchronize_with_db(), that is called during device connection. It was added to support syncing by the wireless device driver (WD). This method supports a device:
  • telling calibre to send a format to the device. The WD sets this if the format on the device is older than the format in calibre.
  • updating the calibre database with information coming back from the device. The WD uses this if the device hands back a new is_read boolean or date.
  • telling calibre to update the GUI for a book. In the WD this happens if the device driver updates the calibre database.
The method in the device driver (synchronize_with_db) is called on the GUI thread and is given a handle to the calibre database. As mentioned above, it is called while calibre is generating the list of books on the device.

For an example, see devices/interface.py, gui/devices.py, and devices/smart_device_app/driver.py. I admit that the code is complicated (sigh), and I am very willing to help if someone is interested.
chaley is offline   Reply With Quote