1 package be
.nikiroo
.fanfix
.reader
;
3 import java
.awt
.EventQueue
;
5 import java
.io
.IOException
;
7 import be
.nikiroo
.fanfix
.Instance
;
8 import be
.nikiroo
.fanfix
.Library
;
9 import be
.nikiroo
.fanfix
.bundles
.Config
;
10 import be
.nikiroo
.fanfix
.data
.MetaData
;
11 import be
.nikiroo
.fanfix
.data
.Story
;
12 import be
.nikiroo
.fanfix
.output
.BasicOutput
.OutputType
;
13 import be
.nikiroo
.fanfix
.supported
.BasicSupport
.SupportType
;
15 class LocalReader
extends BasicReader
{
18 public LocalReader() throws IOException
{
19 File dir
= Instance
.getReaderDir();
22 throw new IOException(
23 "Cannote create cache directory for local reader: " + dir
);
26 // TODO: can throw an exception, manage that (convert to IOEx ?)
27 OutputType text
= OutputType
.valueOfNullOkUC(Instance
.getConfig()
28 .getString(Config
.LOCAL_READER_NON_IMAGES_DOCUMENT_TYPE
));
30 text
= OutputType
.HTML
;
33 OutputType images
= OutputType
.valueOfNullOkUC(Instance
.getConfig()
34 .getString(Config
.LOCAL_READER_IMAGES_DOCUMENT_TYPE
));
36 images
= OutputType
.CBZ
;
40 lib
= new Library(dir
, text
, images
);
44 public void read() throws IOException
{
48 public void read(int chapter
) {
52 public String
imprt(String luid
) {
54 Story story
= Instance
.getLibrary().getStory(luid
);
55 story
= lib
.save(story
);
56 return story
.getMeta().getLuid();
57 } catch (IOException e
) {
58 Instance
.syserr(new IOException(
59 "Cannot import story from library to LocalReader library: "
66 public File
getTarget(String luid
) {
67 MetaData meta
= lib
.getInfo(luid
);
68 File file
= lib
.getFile(luid
);
71 file
= lib
.getFile(luid
);
72 meta
= lib
.getInfo(luid
);
79 public void start(SupportType type
) {
80 final SupportType typeFinal
= type
;
81 EventQueue
.invokeLater(new Runnable() {
83 new LocalReaderFrame(LocalReader
.this, typeFinal
)
89 public static void main(String
[] args
) throws IOException
{
90 new LocalReader().start(null);