Switch to side-by-side view

--- a/src/internfile/mimehandler.h
+++ b/src/internfile/mimehandler.h
@@ -16,60 +16,74 @@
  */
 #ifndef _MIMEHANDLER_H_INCLUDED_
 #define _MIMEHANDLER_H_INCLUDED_
-/* @(#$Id: mimehandler.h,v 1.12 2006-03-29 13:08:08 dockes Exp $  (C) 2004 J.F.Dockes */
+/* @(#$Id: mimehandler.h,v 1.13 2006-12-15 12:40:02 dockes Exp $  (C) 2004 J.F.Dockes */
 
 #include <string>
 #include <list>
+using std::string;
+using std::list;
 
-#include "rclconfig.h"
-#include "rcldb.h"
+#include <Filter.h>
 
+class RclConfig;
 
-/**
- * Document interner class. 
- */
-class MimeHandler {
- public:
-    MimeHandler() : m_forPreview(false) {}
-    virtual ~MimeHandler() {}
+class RecollFilter : public Dijon::Filter {
+public:
+    RecollFilter(const string& mtype)
+	: Dijon::Filter(mtype), m_forPreview(false), m_havedoc(false)
+    {}
+    virtual ~RecollFilter() {}
+    virtual bool set_property(Properties p, const string &v) {
+	switch (p) {
+	case DEFAULT_CHARSET: 
+	    m_defcharset = v;
+	    break;
+	case OPERATING_MODE: 
+	    if (!v.empty() && v[0] == 'v') 
+		m_forPreview = true; 
+	    else 
+		m_forPreview = false;
+	    break;
+	}
+	return true;
+    }
 
-    /// Status from mkDoc method.
-    enum Status {MHError, MHDone, MHAgain};
-    /**
-     * Transform external data into internal utf8 document
-     *
-     * @param conf the global configuration
-     * @param filename File from which the data comes from
-     * @param mimetype its mime type (from the mimemap configuration file)
-     * @param outdoc   The output document
-     * @param ipath the access path for the document inside the file. 
-     *              For mono-document file types, this will always be empty. 
-     *              It is used, for example for mbox files which may contain
-     *              multiple emails. If this is not empty in input, then the
-     *              caller is requesting a single document (ie: for display).
-     *              If this is empty (during indexation), it will be filled-up
-     *              by the function, and all the file's documents will be 
-     *              returned by successive calls.
-     * @return The return value indicates if there are more documents to be 
-     *         fetched from the same file.
-     */
-    virtual MimeHandler::Status mkDoc(RclConfig * conf, 
-				      const std::string &filename, 
-				      const std::string &mimetype, 
-				      Rcl::Doc& outdoc,
-				      string& ipath) = 0;
+    // We don't use this for now
+    virtual bool set_document_uri(const std::string &) {return false;}
 
-    virtual void setForPreview(bool onoff) {m_forPreview = onoff;};
+    // Default implementations
+    virtual bool set_document_string(const std::string &) {return false;}
+    virtual bool set_document_data(const char *cp, unsigned int sz) {
+	return set_document_string(string(cp, sz));
+    }
 
- protected:
-    bool m_forPreview;
+    virtual bool has_documents() const {return m_havedoc;}
+
+    // Most doc types are single-doc
+    virtual bool skip_to_document(const string& s) {
+	if (s.empty())
+	    return true;
+	return false;
+    }
+
+    virtual DataInput get_required_data_input() const 
+    {return DOCUMENT_FILE_NAME;}
+    virtual string get_error() const {
+	return m_reason;
+    }
+
+protected:
+    bool   m_forPreview;
+    string m_defcharset;
+    string m_reason;
+    bool   m_havedoc;
 };
 
 /**
  * Return indexing handler object for the given mime type
  * returned pointer should be deleted by caller
  */
-extern MimeHandler *getMimeHandler(const std::string &mtyp, RclConfig *cfg);
+extern Dijon::Filter *getMimeHandler(const std::string &mtyp, RclConfig *cfg);
 
 /// Can this mime type be interned ?
 extern bool canIntern(const std::string mimetype, RclConfig *cfg);