Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 02-26-2011, 04:55 PM   #1
meme
Sigil developer
meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.
 
Posts: 1,275
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
Library names

Is there a library code/number/id stored for a library besides the library's name, that can be accessed via a function call?

I'm looking at storing configuration data per library - so separate entries in the json file for each library. I can use the library name - but if the user renames the library, then they 'loose' the customizations (they could edit the json file of course).
meme is offline   Reply With Quote
Old 02-26-2011, 05:16 PM   #2
chaley
"chaley", not "charley"
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: 4,926
Karma: 802238
Join Date: Jan 2010
Location: France
Device: Many android devices
Not that I know of.

It would be possible to store a UUID in db.prefs. This is something to take up with Kovid.
chaley is offline   Reply With Quote
 
Enthusiast
Old 02-26-2011, 09:38 PM   #3
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,282
Karma: 4961457
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you want to store per library settings, you should store the settings in the library. Use the interface in database2 for storing plugin settings.
kovidgoyal is offline   Reply With Quote
Old 02-27-2011, 03:22 AM   #4
chaley
"chaley", not "charley"
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: 4,926
Karma: 802238
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by kovidgoyal View Post
If you want to store per library settings, you should store the settings in the library. Use the interface in database2 for storing plugin settings.
Are you saying that plugins should put configuration information in db.prefs? It would seem that that would lead to accumulation of cruft and potential uninstall problems.

That aside, it might be a good idea to have a library UUID. Such a thing would help validation of persistent caches, and could be useful in the face of library renames verifying which operations have been done to which libraries. It is true that copying a library outside of calibre would duplicate UUIDs, but as it would duplicate anything else, I don't see that as a deal-breaker.
chaley is offline   Reply With Quote
Old 02-27-2011, 04:19 AM   #5
meme
Sigil developer
meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.
 
Posts: 1,275
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
I see how to set/get the data in the DB, although like Chaley I'm a little hesitant.

Is there a naming convention I should use for plugin data (# is user, @ is category, etc.), e.g. name_plugin_setting, or plugin_MyName_setting, etc. to avoid clashes.

This data will be persistent after the plugin is removed, and unlike a file can't be deleted. I suppose I could provide a delete customizations button on the customization window like reset all which could be used before the plugin is removed.

The reason I want to do settings per library is because the columns/categories change per library - and if I use a file that's not aware of libraries then the old data would get re-written on each library switch.

I guess if the library did contain a unique ID, if you just copied it as mentioned, then I couldn't tell the difference between the 2 libraries based on the ID (unless to 'copy' a db you had to export it and this cleared the ID).

In my customization window I could provide a 'Library name' which could be overridden by the user in case of a rename. These are likely to be rare with this plugin, but its interesting to make sure the plugin is flexible - but not confusing to the user.

I'm also debating how to store config settings per device. Either I put the config settings on the device (JSONConfig forces the path to be in Calibre's config_dir so I'd have to use my own version), or I store the device name in a central settings store. But since the Kindle has no unique identifier accessible to me, I'd have to store a name in a file anyway, or just allow the user to select a profile (or most likely a combination of default name/selection).

I was just about to finish testing too - always one more thing to go in before the next version
meme is offline   Reply With Quote
Old 02-27-2011, 04:55 AM   #6
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,223
Karma: 1334002
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
I'll be interested to see any outcome of this discussion. The only plugin that I have written to date that persists what could be considered library specific information is the new Goodreads sync plugin. In theory a user could want to specify different sync action custom columns for different libraries which would be a problem. However given that a shelf sync requires all the books to be in the same library it really isn't very likely.

That is not to say that there aren't other plugins I may write in future which may have the same challenge of course.
kiwidude is offline   Reply With Quote
Old 02-27-2011, 09:54 AM   #7
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,282
Karma: 4961457
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you're storing the prefs in the db, then prefix your variable name with the plugin name.

We can certainly add a uuid to the db. I'll do this when I modify the schema for the identifiers table.
kovidgoyal is offline   Reply With Quote
Old 02-27-2011, 10:34 AM   #8
meme
Sigil developer
meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.
 
Posts: 1,275
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
OK. I think I'll leave out the multiple library/multiple Kindle for now as there's enough to test and I need to consider how to do both multiple libraries and multiple devices. (not sure if you are updating the identifier's table any time soon).

There doesn't appear to be a uuid for the device saved in metadata.calibre so I'll have to manage separate ones in some other way.
meme is offline   Reply With Quote
Old 02-27-2011, 10:47 AM   #9
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,282
Karma: 4961457
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
No, there is no uuid saved in metadata.calibre, though I suppose that could be changed as well, I'll leave that to chaley to comment on.
kovidgoyal is offline   Reply With Quote
Old 02-27-2011, 11:33 AM   #10
chaley
"chaley", not "charley"
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: 4,926
Karma: 802238
Join Date: Jan 2010
Location: France
Device: Many android devices
Are you suggesting that a UUID stored in metadata.calibre be a proxy for a device ID? The difficulty is it's transience; if the file is deleted or damaged, then a new UUID will be assigned. Would the application be able to recover from that?
chaley is offline   Reply With Quote
Old 02-27-2011, 11:46 AM   #11
meme
Sigil developer
meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.
 
Posts: 1,275
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
Is there a device ID available from somewhere?

I was just looking for some way to say that Kindle X is attached so that I could recognize it the next time it attaches to present just its configuration settings. If the device had no ID I guess I would default to using a default name and present/update the default settings.

I don't know if metadata.calibre is the right place for it (I see it uses a straight list of books so I don't know if you could add a new key without messing up anything that reads it. That might not be many programs - it would break my 1.3.3 version, but not my next one if I ever get it done )

If a uuid was saved, it might need a name too, although that might not be needed in my case (I would just present settings based on which Kindle was attached and save according to uuid and library uuid). I notice in kiwidude's Book Sync plugin he also mentions lack of multiple device support. I think he just uses 1 list to sync whichever Kindle is next attached. To use multiple would require presenting a list to select from - and choosing from 1aX7 versus 2b84 might not be intuitive to users
meme is offline   Reply With Quote
Old 02-27-2011, 12:26 PM   #12
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,282
Karma: 4961457
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Some devices have serial numbers some dont. The Kindle's do, IIRC, but calibre only reads that info on OSX and linux, not windows.
kovidgoyal is offline   Reply With Quote
Old 02-27-2011, 12:27 PM   #13
chaley
"chaley", not "charley"
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: 4,926
Karma: 802238
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by meme View Post
Is there a device ID available from somewhere?
Not that I know of.
Quote:
I don't know if metadata.calibre is the right place for it (I see it uses a straight list of books so I don't know if you could add a new key without messing up anything that reads it. That might not be many programs - it would break my 1.3.3 version, but not my next one if I ever get it done )
I am leery about creating another file. There was a lot of controversy the first time. However, it is probable that using 'uuid.calibre' is the right way to go, because having a separate file would help avoid UUID reassignment if metadata.calibre was corrupted, and would avoid breaking programs that read metadata.calibre.
Quote:
If a uuid was saved, it might need a name too, although that might not be needed in my case (I would just present settings based on which Kindle was attached and save according to uuid and library uuid).
I think that would be the problem of the GUI tool. When it encounters a new UUID, it would ask the user what name it should use for that device, then store that name along with the UUID. I don't want the device code to ask that question, because the *vast* majority of users won't care.
chaley is offline   Reply With Quote
Old 02-27-2011, 12:55 PM   #14
Manichean
Wizard
Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!
 
Manichean's Avatar
 
Posts: 3,130
Karma: 80446
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
I know the discussion has drifted a little, and I'm no developer, but I just had an idea re managing plugin config stored in the db: I don't know if there is one already, but shouldn't it be possible to add an uninstall function to plugins that gets called when the user selects to remove the plugin via the plugins dialog? That way, each plugin could (and should) clean up after itself before it gets removed.
Manichean is offline   Reply With Quote
Old 02-27-2011, 01:16 PM   #15
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,282
Karma: 4961457
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by Manichean View Post
I know the discussion has drifted a little, and I'm no developer, but I just had an idea re managing plugin config stored in the db: I don't know if there is one already, but shouldn't it be possible to add an uninstall function to plugins that gets called when the user selects to remove the plugin via the plugins dialog? That way, each plugin could (and should) clean up after itself before it gets removed.
That's a possibility, the problem is it is not very reliable. You can in principle "remove" a plugin by just deleting its zip file in the calibre config directory. In such a case calibre has no way to run plugin specific cleanup code.
kovidgoyal is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you pick names? AgentBEATS Writers' Corner 32 02-22-2011 10:03 AM
Confused about names shinnosuke BeBook 8 04-24-2010 11:33 AM
Publisher's Names emonti8384 General Discussions 10 04-05-2010 12:05 AM
Author names superplinio Calibre 6 02-27-2010 04:58 AM
Help me out with a couple of names ardeegee Lounge 12 09-27-2009 03:41 AM


All times are GMT -4. The time now is 04:32 AM.


MobileRead.com is a privately owned, operated and funded community.