remote: fix 30s timeout bug
[nikiroo-utils.git] / src / be / nikiroo / fanfix / reader / Reader.java
... / ...
CommitLineData
1package be.nikiroo.fanfix.reader;
2
3import java.io.IOException;
4import java.net.URL;
5
6import be.nikiroo.fanfix.data.MetaData;
7import be.nikiroo.fanfix.data.Story;
8import be.nikiroo.fanfix.library.BasicLibrary;
9import be.nikiroo.utils.Progress;
10
11/**
12 * A {@link Reader} is a class that will handle {@link Story} reading and
13 * browsing.
14 *
15 * @author niki
16 */
17public interface Reader {
18 /**
19 * A type of {@link BasicReader}.
20 *
21 * @author niki
22 */
23 public enum ReaderType {
24 /** Simple reader that outputs everything on the console */
25 CLI,
26 /** Reader that starts local programs to handle the stories */
27 GUI,
28 /** A text (UTF-8) reader with menu and text windows */
29 TUI,
30 /** A GUI reader implemented with the Android framework */
31 ANDROID,
32
33 ;
34
35 /**
36 * Return the full class name of a type that implements said
37 * {@link ReaderType}.
38 *
39 * @return the class name
40 */
41 public String getTypeName() {
42 String pkg = "be.nikiroo.fanfix.reader.";
43 switch (this) {
44 case CLI:
45 return pkg + "cli.CliReader";
46 case TUI:
47 return pkg + "tui.TuiReader";
48 case GUI:
49 return pkg + "ui.GuiReader";
50 case ANDROID:
51 return pkg + "android.AndroidReader";
52 }
53
54 return null;
55 }
56 }
57
58 /**
59 * Return the current target {@link MetaData}.
60 *
61 * @return the meta
62 */
63 public MetaData getMeta();
64
65 /**
66 * Return the current {@link Story} as described by the current
67 * {@link MetaData}.
68 *
69 * @param pg
70 * the optional progress
71 *
72 * @return the {@link Story}
73 */
74 public Story getStory(Progress pg);
75
76 /**
77 * The {@link BasicLibrary} to load the stories from (by default, takes the
78 * default {@link BasicLibrary}).
79 *
80 * @return the {@link BasicLibrary}
81 */
82 public BasicLibrary getLibrary();
83
84 /**
85 * Change the {@link BasicLibrary} that will be managed by this
86 * {@link BasicReader}.
87 *
88 * @param lib
89 * the new {@link BasicLibrary}
90 */
91 public void setLibrary(BasicLibrary lib);
92
93 /**
94 * Set a {@link Story} from the current {@link BasicLibrary} into the
95 * {@link Reader}.
96 *
97 * @param luid
98 * the {@link Story} ID
99 *
100 * @throws IOException
101 * in case of I/O error
102 */
103 public void setMeta(String luid) throws IOException;
104
105 /**
106 * Set a {@link Story} from the current {@link BasicLibrary} into the
107 * {@link Reader}.
108 *
109 * @param meta
110 * the meta
111 *
112 * @throws IOException
113 * in case of I/O error
114 */
115 public void setMeta(MetaData meta) throws IOException;
116
117 /**
118 * Set an external {@link Story} into this {@link Reader}.
119 *
120 * @param source
121 * the {@link Story} {@link URL}
122 * @param pg
123 * the optional progress reporter
124 *
125 * @throws IOException
126 * in case of I/O error
127 */
128 public void setMeta(URL source, Progress pg) throws IOException;
129
130 /**
131 * Start the {@link Story} Reading.
132 *
133 * @throws IOException
134 * in case of I/O error or if the {@link Story} was not
135 * previously set
136 */
137 public void read() throws IOException;
138
139 /**
140 * The selected chapter to start reading at (starting at 1, 0 = description,
141 * -1 = none).
142 *
143 * @return the chapter, or -1 for "no chapter"
144 */
145 public int getChapter();
146
147 /**
148 * The selected chapter to start reading at (starting at 1, 0 = description,
149 * -1 = none).
150 *
151 * @param chapter
152 * the chapter, or -1 for "no chapter"
153 */
154 public void setChapter(int chapter);
155
156 /**
157 * Start the reader in browse mode for the given source (or pass NULL for
158 * all sources).
159 *
160 * @param source
161 * the type of {@link Story} to take into account, or NULL for
162 * all
163 */
164 public void browse(String source);
165
166 /**
167 * Open the {@link Story} with an external reader (the program will be
168 * passed the main file associated with this {@link Story}).
169 *
170 * @param lib
171 * the {@link BasicLibrary} to select the {@link Story} from
172 * @param luid
173 * the {@link Story} LUID
174 *
175 * @throws IOException
176 * in case of I/O error
177 */
178 public void openExternal(BasicLibrary lib, String luid) throws IOException;
179}