1 /* 2 * Copyright 2002-2015, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _TRANSLATOR_ROSTER_H 6 #define _TRANSLATOR_ROSTER_H 7 8 9 #include <Archivable.h> 10 #include <TranslationDefs.h> 11 12 13 struct translation_format; 14 15 class BBitmap; 16 class BMessage; 17 class BMessenger; 18 class BPositionIO; 19 class BQuery; 20 class BRect; 21 class BTranslator; 22 class BView; 23 struct entry_ref; 24 25 26 class BTranslatorReleaseDelegate { 27 public: 28 BTranslatorReleaseDelegate(BTranslator* translator); 29 30 void Release(); 31 32 private: 33 BTranslator* fUnderlying; 34 }; 35 36 37 class BTranslatorRoster : public BArchivable { 38 public: 39 BTranslatorRoster(); 40 BTranslatorRoster(BMessage* model); 41 virtual ~BTranslatorRoster(); 42 43 static BTranslatorRoster* Default(); 44 45 virtual status_t Archive(BMessage* into, bool deep = true) const; 46 static BArchivable* Instantiate(BMessage* from); 47 48 status_t AddTranslators(const char* loadPath = NULL); 49 status_t AddTranslator(BTranslator* translator); 50 51 virtual status_t Identify(BPositionIO* source, 52 BMessage* ioExtension, 53 translator_info* _info, uint32 hintType = 0, 54 const char* hintMIME = NULL, 55 uint32 wantType = 0); 56 57 virtual status_t GetTranslators(BPositionIO* source, 58 BMessage* ioExtension, 59 translator_info** _info, int32* _numInfo, 60 uint32 hintType = 0, 61 const char* hintMIME = NULL, 62 uint32 wantType = 0); 63 64 virtual status_t GetAllTranslators(translator_id** _list, 65 int32* _count); 66 67 virtual status_t GetTranslatorInfo(translator_id translatorID, 68 const char** _name, const char** _info, 69 int32* _version); 70 71 virtual status_t GetInputFormats(translator_id translatorID, 72 const translation_format** _formats, 73 int32* _numFormats); 74 75 virtual status_t GetOutputFormats(translator_id translatorID, 76 const translation_format** _formats, 77 int32* _numFormats); 78 79 virtual status_t Translate(BPositionIO* source, 80 const translator_info* info, 81 BMessage* ioExtension, 82 BPositionIO* destination, 83 uint32 wantOutType, uint32 hintType = 0, 84 const char* hintMIME = NULL); 85 86 virtual status_t Translate(translator_id translatorID, 87 BPositionIO* source, BMessage* ioExtension, 88 BPositionIO* destination, 89 uint32 wantOutType); 90 91 virtual status_t MakeConfigurationView( 92 translator_id translatorID, 93 BMessage* ioExtension, BView** _view, 94 BRect* _extent); 95 96 virtual status_t GetConfigurationMessage( 97 translator_id translatorID, 98 BMessage* ioExtension); 99 100 BTranslatorReleaseDelegate* AcquireTranslator(int32 translatorID); 101 102 status_t GetRefFor(translator_id translatorID, 103 entry_ref* ref); 104 bool IsTranslator(entry_ref* ref); 105 106 status_t StartWatching(BMessenger target); 107 status_t StopWatching(BMessenger target); 108 109 class Private; 110 111 private: 112 // unimplemented 113 BTranslatorRoster( 114 const BTranslatorRoster& other); 115 BTranslatorRoster& operator=(const BTranslatorRoster& other); 116 117 virtual void ReservedTranslatorRoster1(); 118 virtual void ReservedTranslatorRoster2(); 119 virtual void ReservedTranslatorRoster3(); 120 virtual void ReservedTranslatorRoster4(); 121 virtual void ReservedTranslatorRoster5(); 122 virtual void ReservedTranslatorRoster6(); 123 124 void _Initialize(); 125 126 static const char* Version(int32* outCurVersion, 127 int32* outMinVersion, 128 int32 inAppVersion); 129 // for backward compatiblity only 130 131 private: 132 friend class Private; 133 134 Private* fPrivate; 135 int32 fUnused[6]; 136 137 static BTranslatorRoster* sDefaultRoster; 138 }; 139 140 141 #endif // _TRANSLATOR_ROSTER_H 142