10e1ba39fSStephan Aßmus /* 21f3678c1SStephan Aßmus * Copyright 2006, 2007, 2011, Stephan Aßmus <superstippi@gmx.de>. 31f3678c1SStephan Aßmus * All rights reserved. Distributed under the terms of the MIT License. 40e1ba39fSStephan Aßmus */ 50e1ba39fSStephan Aßmus #ifndef EXPORTER_H 60e1ba39fSStephan Aßmus #define EXPORTER_H 70e1ba39fSStephan Aßmus 8325a6253SAxel Dörfler 9*405c9dc3SZardshard #include <string.h> 10*405c9dc3SZardshard 110e1ba39fSStephan Aßmus #include <Entry.h> 120e1ba39fSStephan Aßmus #include <OS.h> 130e1ba39fSStephan Aßmus 1425dc253dSIngo Weinhold #include "IconBuild.h" 1525dc253dSIngo Weinhold 1625dc253dSIngo Weinhold 170e1ba39fSStephan Aßmus class BPositionIO; 180e1ba39fSStephan Aßmus class Document; 19325a6253SAxel Dörfler 20325a6253SAxel Dörfler 2125dc253dSIngo Weinhold _BEGIN_ICON_NAMESPACE 220e1ba39fSStephan Aßmus class Icon; 2325dc253dSIngo Weinhold _END_ICON_NAMESPACE 240e1ba39fSStephan Aßmus 2525dc253dSIngo Weinhold _USING_ICON_NAMESPACE 26325a6253SAxel Dörfler 2741bd89a9SZardshard /*! Base class for all exporters to implement. */ 280e1ba39fSStephan Aßmus class Exporter { 290e1ba39fSStephan Aßmus public: 300e1ba39fSStephan Aßmus Exporter(); 310e1ba39fSStephan Aßmus virtual ~Exporter(); 320e1ba39fSStephan Aßmus 3341bd89a9SZardshard /*! Export the Document to the specified entry_ref. 3441bd89a9SZardshard Spawns a separate thread to do the actual exporting. 3541bd89a9SZardshard Uses the virtual Export function defined after this function to do the 3641bd89a9SZardshard actual export. 3741bd89a9SZardshard */ 380e1ba39fSStephan Aßmus status_t Export(Document* document, 390e1ba39fSStephan Aßmus const entry_ref& ref); 400e1ba39fSStephan Aßmus 410e1ba39fSStephan Aßmus virtual status_t Export(const Icon* icon, 420e1ba39fSStephan Aßmus BPositionIO* stream) = 0; 43*405c9dc3SZardshard /*! Turns the status_t error code returned by \c Export into a string. */ ErrorCodeToString(status_t code)44*405c9dc3SZardshard virtual const char* ErrorCodeToString(status_t code) 45*405c9dc3SZardshard { return strerror(code); } 460e1ba39fSStephan Aßmus virtual const char* MIMEType() = 0; 470e1ba39fSStephan Aßmus 4841bd89a9SZardshard /*! If \a selfDestroy is true, class deletes itself when export thread is 4941bd89a9SZardshard finished. 5041bd89a9SZardshard */ 510e1ba39fSStephan Aßmus void SetSelfDestroy(bool selfDestroy); 520e1ba39fSStephan Aßmus 531f3678c1SStephan Aßmus void WaitForExportThread(); 541f3678c1SStephan Aßmus 550e1ba39fSStephan Aßmus private: 560e1ba39fSStephan Aßmus static int32 _ExportThreadEntry(void* cookie); 570e1ba39fSStephan Aßmus int32 _ExportThread(); 580e1ba39fSStephan Aßmus status_t _Export(const Icon* icon, 590e1ba39fSStephan Aßmus const entry_ref* docRef); 600e1ba39fSStephan Aßmus 610e1ba39fSStephan Aßmus Document* fDocument; 620e1ba39fSStephan Aßmus Icon* fClonedIcon; 630e1ba39fSStephan Aßmus entry_ref fRef; 640e1ba39fSStephan Aßmus thread_id fExportThread; 650e1ba39fSStephan Aßmus bool fSelfDestroy; 660e1ba39fSStephan Aßmus }; 670e1ba39fSStephan Aßmus 680e1ba39fSStephan Aßmus #endif // EXPORTER_H 69