X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FBasicLibrary.java;h=d324008f0b4c2294e503d907a25b0edc226ed944;hb=085a2f9a3a811a910de7c3011eb6f5ef2ab18aa0;hp=cf17a2bef49fce8591150c6e93eb50eb9b41a30b;hpb=b89dfb6ece936486563734818ed62488a59e5897;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/library/BasicLibrary.java b/src/be/nikiroo/fanfix/library/BasicLibrary.java index cf17a2b..d324008 100644 --- a/src/be/nikiroo/fanfix/library/BasicLibrary.java +++ b/src/be/nikiroo/fanfix/library/BasicLibrary.java @@ -29,6 +29,17 @@ import be.nikiroo.utils.Progress; * @author niki */ abstract public class BasicLibrary { + /** + * Return a name for this library (the UI may display this). + *

+ * Must not be NULL. + * + * @return the name, or an empty {@link String} if none + */ + public String getLibraryName() { + return ""; + } + /** * Retrieve the main {@link File} corresponding to the given {@link Story}, * which can be passed to an external reader or instance. @@ -37,10 +48,12 @@ abstract public class BasicLibrary { * * @param luid * the Library UID of the story + * @param pg + * the optional {@link Progress} * * @return the corresponding {@link Story} */ - public abstract File getFile(String luid); + public abstract File getFile(String luid, Progress pg); /** * Return the cover image associated to this story. @@ -283,21 +296,30 @@ abstract public class BasicLibrary { * @return the corresponding {@link Story} or NULL if not found */ public synchronized Story getStory(String luid, Progress pg) { - // TODO: pg if (pg == null) { pg = new Progress(); } + Progress pgGet = new Progress(); + Progress pgProcess = new Progress(); + + pg.setMinMax(0, 2); + pg.addProgress(pgGet, 1); + pg.addProgress(pgProcess, 1); + Story story = null; for (MetaData meta : getMetas(null)) { if (meta.getLuid().equals(luid)) { - File file = getFile(luid); + File file = getFile(luid, pgGet); + pgGet.done(); try { SupportType type = SupportType.valueOfAllOkUC(meta .getType()); URL url = file.toURI().toURL(); if (type != null) { - story = BasicSupport.getSupport(type).process(url, pg); + story = BasicSupport.getSupport(type).process(url, + pgProcess); + story.setMeta(meta); } else { throw new IOException("Unknown type: " + meta.getType()); } @@ -307,6 +329,7 @@ abstract public class BasicLibrary { Instance.syserr(new IOException( "Cannot load file from library: " + file, e)); } finally { + pgProcess.done(); pg.done(); }