reader: sync/async work
[fanfix.git] / src / be / nikiroo / fanfix / reader / Reader.java
index d2984bd5221c693fe2a3b2afda1a71e675ba55c3..b001e304842f4956095050160d5bf65b8795d3f3 100644 (file)
@@ -27,6 +27,8 @@ public interface Reader {
                GUI,
                /** A text (UTF-8) reader with menu and text windows */
                TUI,
+               /** A GUI reader implemented with the Android framework */
+               ANDROID,
 
                ;
 
@@ -40,16 +42,18 @@ public interface Reader {
                        String pkg = "be.nikiroo.fanfix.reader.";
                        switch (this) {
                        case CLI:
-                               return pkg + "CliReader";
+                               return pkg + "cli.CliReader";
                        case TUI:
-                               return pkg + "TuiReader";
+                               return pkg + "tui.TuiReader";
                        case GUI:
-                               return pkg + "GuiReader";
+                               return pkg + "ui.GuiReader";
+                       case ANDROID:
+                               return pkg + "android.AndroidReader";
                        }
 
                        return null;
                }
-       };
+       }
 
        /**
         * Return the current target {@link MetaData}.
@@ -126,11 +130,15 @@ public interface Reader {
        /**
         * Start the {@link Story} Reading.
         * 
+        * @param sync
+        *            execute the process synchronously (wait until it is terminated
+        *            before returning)
+        * 
         * @throws IOException
         *             in case of I/O error or if the {@link Story} was not
         *             previously set
         */
-       public void read() throws IOException;
+       public void read(boolean sync) throws IOException;
 
        /**
         * The selected chapter to start reading at (starting at 1, 0 = description,
@@ -152,10 +160,30 @@ public interface Reader {
        /**
         * Start the reader in browse mode for the given source (or pass NULL for
         * all sources).
+        * <p>
+        * Note that this must be a <b>synchronous</b> action.
         * 
         * @param source
         *            the type of {@link Story} to take into account, or NULL for
         *            all
         */
        public void browse(String source);
+
+       /**
+        * Open the {@link Story} with an external reader (the program should be
+        * passed the main file associated with this {@link Story}).
+        * 
+        * @param lib
+        *            the {@link BasicLibrary} to select the {@link Story} from
+        * @param luid
+        *            the {@link Story} LUID
+        * @param sync
+        *            execute the process synchronously (wait until it is terminated
+        *            before returning)
+        * 
+        * @throws IOException
+        *             in case of I/O error
+        */
+       public void openExternal(BasicLibrary lib, String luid, boolean sync)
+                       throws IOException;
 }