It is accomplished ...
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
/*****************************************************************************/
|
||||
// File: BitmapStream.h
|
||||
// Class: BBitmapStream
|
||||
// Reimplimented by: Travis Smith, Michael Wilber, Translation Kit Team
|
||||
// Reimplimentation: 2002-04
|
||||
//
|
||||
// Description: BPositionIO based object to read/write bitmap format to/from
|
||||
// a BBitmap object.
|
||||
//
|
||||
// The BTranslationUtils class uses this object and makes it
|
||||
// easy for users to load bitmaps.
|
||||
//
|
||||
// Copyright (c) 2002 OpenBeOS Project
|
||||
//
|
||||
// Original Version: Copyright 1998, Be Incorporated, All Rights Reserved.
|
||||
// Copyright 1995-1997, Jon Watte
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#if !defined(_BITMAP_STREAM_H)
|
||||
#define _BITMAP_STREAM_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
#include <TranslationDefs.h>
|
||||
#include <DataIO.h>
|
||||
#include <TranslatorFormats.h>
|
||||
#include <ByteOrder.h>
|
||||
|
||||
class BBitmap;
|
||||
|
||||
class BBitmapStream : public BPositionIO {
|
||||
public:
|
||||
BBitmapStream(BBitmap *bitmap = NULL);
|
||||
// Initializes the stream to use map as the bitmap for stream
|
||||
// operations. If map is null, a BBitmap is created when properly
|
||||
// formatted data is written to the stream.
|
||||
|
||||
~BBitmapStream();
|
||||
// Destroys the BBitmap held by this object if it has not been
|
||||
// detached and frees fpBigEndianHeader
|
||||
|
||||
// Overrides from BPositionIO
|
||||
ssize_t ReadAt(off_t pos, void *buffer, size_t size);
|
||||
// reads data from the bitmap into buffer
|
||||
ssize_t WriteAt(off_t pos, const void *data, size_t size);
|
||||
// writes the data from data into this bitmap
|
||||
// (if the data is properly formatted)
|
||||
off_t Seek(off_t position, uint32 whence);
|
||||
// sets the stream position member
|
||||
off_t Position() const;
|
||||
// returns the current stream position
|
||||
off_t Size() const;
|
||||
// returns the size of the data
|
||||
status_t SetSize(off_t size);
|
||||
// sets the amount of memory to be used by this object
|
||||
|
||||
status_t DetachBitmap(BBitmap **outMap);
|
||||
// "Detaches" the bitmap used by this stream and returns it
|
||||
// to the user through outMap. This allows the user to
|
||||
// use the bitmap even after the BBitmapStream that it
|
||||
// came from has been deleted.
|
||||
|
||||
protected:
|
||||
TranslatorBitmap fHeader;
|
||||
// stores the bitmap header information in the
|
||||
// host format, used to determine the format of
|
||||
// the bitmap data and to see if the data is valid
|
||||
BBitmap *fBitmap;
|
||||
// the actual bitmap used by this object
|
||||
size_t fPosition;
|
||||
// current data position
|
||||
size_t fSize;
|
||||
// size of the data stored
|
||||
bool fDetached;
|
||||
// true if the bitmap has been detached, false if not
|
||||
|
||||
static status_t ConvertBEndianToHost(TranslatorBitmap *);
|
||||
// Converts a TranslatorBitmap struct from the Big Endian
|
||||
// format to the host format. This is needed because
|
||||
// the headers are always stored in the Big Endian format
|
||||
// when read in from or written out to files.
|
||||
status_t SetBigEndianHeader();
|
||||
// Sets fpBigEndianHeader to be the Big Endian version
|
||||
// of the data in fHeader. I need a Big Endian copy
|
||||
// of fHeader for the ReadAt() function.
|
||||
|
||||
private:
|
||||
TranslatorBitmap *fpBigEndianHeader;
|
||||
// same data as in fHeader, but in Big Endian format
|
||||
// (Intel machines are Little Endian)
|
||||
|
||||
// For maintaining binary compatibility with past and future
|
||||
// versions of this object
|
||||
long fUnused[5];
|
||||
virtual void _ReservedBitmapStream1();
|
||||
virtual void _ReservedBitmapStream2();
|
||||
};
|
||||
|
||||
#endif /* _BITMAP_STREAM_H */
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*****************************************************************************/
|
||||
// File: R4xTranslator.h
|
||||
// Class: BR4xTranslator
|
||||
// Author: Michael Wilber, Translation Kit Team
|
||||
// Originally Created: 2002-06-11
|
||||
//
|
||||
// Description: This header file contains the BTranslator based object for
|
||||
// BeOS R4.0 and R4.5 type translators, aka, the translators
|
||||
// that don't use the make_nth_translator() mechanism.
|
||||
//
|
||||
// This class is used by the OpenBeOS BTranslatorRoster
|
||||
// so that R4x translators, post R4.5 translators and private
|
||||
// BTranslator objects could be accessed in the same way.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2002 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef _R4X_TRANSLATOR_H
|
||||
#define _R4X_TRANSLATOR_H
|
||||
|
||||
#include <Translator.h>
|
||||
#include <image.h>
|
||||
#include <TranslationDefs.h>
|
||||
|
||||
class BR4xTranslator : public BTranslator {
|
||||
public:
|
||||
BR4xTranslator(const translator_data *kpData);
|
||||
// assigns the translator to the object
|
||||
|
||||
virtual const char *TranslatorName() const;
|
||||
// returns the short translator name
|
||||
|
||||
virtual const char *TranslatorInfo() const;
|
||||
// returns the verbose translator name/description
|
||||
|
||||
virtual int32 TranslatorVersion() const;
|
||||
// returns the translator's version
|
||||
|
||||
virtual const translation_format *InputFormats(int32 *out_count) const;
|
||||
// returns the list of supported input formats
|
||||
|
||||
virtual const translation_format *OutputFormats(int32 *out_count) const;
|
||||
// returns the list of supported output formats
|
||||
|
||||
virtual status_t Identify(BPositionIO *inSource,
|
||||
const translation_format *inFormat, BMessage *ioExtension,
|
||||
translator_info *outInfo, uint32 outType);
|
||||
// identifies wether or not the translator can handle
|
||||
// translating the data in inSource
|
||||
|
||||
virtual status_t Translate(BPositionIO *inSource,
|
||||
const translator_info *inInfo, BMessage *ioExtension, uint32 outType,
|
||||
BPositionIO * outDestination);
|
||||
// translates the data from inSource to outDestination
|
||||
// in the format outType
|
||||
|
||||
virtual status_t MakeConfigurationView(BMessage *ioExtension,
|
||||
BView **outView, BRect *outExtent);
|
||||
// creates a view object that allows the user to change
|
||||
// the translator's options
|
||||
// (not required to be in all translators)
|
||||
|
||||
virtual status_t GetConfigurationMessage(BMessage *ioExtension);
|
||||
// returns the current settings of the translator
|
||||
// (not required to be in all translators)
|
||||
|
||||
protected:
|
||||
virtual ~BR4xTranslator();
|
||||
// This object is deleted by calling Release(),
|
||||
// it can not be deleted directly. See BTranslator in the Be Book
|
||||
|
||||
private:
|
||||
translator_data *fpData;
|
||||
// This contains all of the member variables used by this class.
|
||||
// It also contains pointers to functions that the member functions
|
||||
// use to do all of the actual work for this class.
|
||||
};
|
||||
|
||||
#endif // _R4X_TRANSLATOR_H
|
||||
@@ -0,0 +1,86 @@
|
||||
/********************************************************************************
|
||||
/
|
||||
/ File: TranslationDefs.h
|
||||
/
|
||||
/ Description: Miscellaneous basic definitions for the Translation Kit
|
||||
/
|
||||
/ Copyright 1998, Be Incorporated, All Rights Reserved.
|
||||
/ Copyright 1995-1997, Jon Watte
|
||||
/
|
||||
/ 2002 - translation_data struct added by Michael Wilber, OBOS TransKit Team
|
||||
********************************************************************************/
|
||||
|
||||
#if !defined(_TRANSLATION_DEFS_H)
|
||||
#define _TRANSLATION_DEFS_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <TranslationErrors.h>
|
||||
|
||||
|
||||
typedef unsigned long translator_id;
|
||||
|
||||
|
||||
/* when you export this struct, end with an empty */
|
||||
/* record that has 0 for "type" */
|
||||
|
||||
|
||||
/* These are defines, because they reflect the state at which the app was compiled */
|
||||
#define B_TRANSLATION_CURRENT_VERSION B_BEOS_VERSION
|
||||
#define B_TRANSLATION_MIN_VERSION 161
|
||||
|
||||
extern const char * B_TRANSLATOR_MIME_TYPE;
|
||||
|
||||
struct translation_format {
|
||||
uint32 type; /* B_ASCII_TYPE, ...*/
|
||||
uint32 group; /* B_TRANSLATOR_BITMAP, B_TRANSLATOR_TEXT, ...*/
|
||||
float quality; /* format quality 0.0-1.0*/
|
||||
float capability; /* translator capability 0.0-1.0*/
|
||||
char MIME[251]; /* MIME string*/
|
||||
char name[251]; /* only descriptive */
|
||||
};
|
||||
|
||||
|
||||
/* This struct is different from the format struct for a reason: */
|
||||
/* to separate the notion of formats from the notion of translations */
|
||||
|
||||
struct translator_info { /* Info about a specific translation*/
|
||||
uint32 type; /* B_ASCII_TYPE, ...*/
|
||||
translator_id translator; /* Filled in by BTranslationRoster*/
|
||||
uint32 group; /* B_TRANSLATOR_BITMAP, B_TRANSLATOR_TEXT, ...*/
|
||||
float quality; /* Quality of format in group 0.0-1.0*/
|
||||
float capability; /* How much of the format do we do? 0.0-1.0*/
|
||||
char name[251];
|
||||
char MIME[251];
|
||||
};
|
||||
|
||||
// BEGIN: Added by Michael Wilber
|
||||
struct translator_data {
|
||||
const char * translatorName;
|
||||
const char * translatorInfo;
|
||||
int32 translatorVersion;
|
||||
const translation_format * inputFormats;
|
||||
const translation_format * outputFormats;
|
||||
|
||||
status_t (*Identify)(
|
||||
BPositionIO * inSource,
|
||||
const translation_format * inFormat,
|
||||
BMessage * ioExtension,
|
||||
translator_info * outInfo,
|
||||
uint32 outType);
|
||||
status_t (*Translate)(
|
||||
BPositionIO * inSource,
|
||||
const translator_info * inInfo,
|
||||
BMessage * ioExtension,
|
||||
uint32 outType,
|
||||
BPositionIO * outDestination);
|
||||
status_t (*MakeConfig)(
|
||||
BMessage * ioExtension,
|
||||
BView * * outView,
|
||||
BRect * outExtent);
|
||||
status_t (*GetConfigMessage)(
|
||||
BMessage * ioExtension);
|
||||
};
|
||||
// END: Added by Michael Wilber
|
||||
|
||||
#endif /* _TRANSLATION_DEFS_H */
|
||||
@@ -0,0 +1,27 @@
|
||||
/********************************************************************************
|
||||
/
|
||||
/ File: TranslationErrors.h
|
||||
/
|
||||
/ Description: Error codes for the Translation Kit
|
||||
/
|
||||
/ Copyright 1998, Be Incorporated, All Rights Reserved.
|
||||
/ Copyright 1995-1997, Jon Watte
|
||||
/
|
||||
********************************************************************************/
|
||||
|
||||
#if !defined(_TRANSLATION_ERRORS_H)
|
||||
#define _TRANSLATION_ERRORS_H
|
||||
|
||||
#include <Errors.h>
|
||||
|
||||
|
||||
enum B_TRANSLATION_ERROR {
|
||||
B_TRANSLATION_BASE_ERROR = B_TRANSLATION_ERROR_BASE,
|
||||
B_NO_TRANSLATOR = B_TRANSLATION_BASE_ERROR, /* no translator exists for data */
|
||||
B_ILLEGAL_DATA, /* data is not what it said it was */
|
||||
/* aliases */
|
||||
B_NOT_INITIALIZED = B_NO_INIT
|
||||
};
|
||||
|
||||
|
||||
#endif /* _TRANSLATION_ERRORS_H */
|
||||
@@ -0,0 +1,18 @@
|
||||
/***************************************************************
|
||||
/
|
||||
/ File: TranslationKit.h
|
||||
/
|
||||
/ Copyright 1998, Be Incorporated.
|
||||
/
|
||||
***************************************************************/
|
||||
|
||||
#include <BitmapStream.h>
|
||||
#include <TranslationDefs.h>
|
||||
#include <TranslationErrors.h>
|
||||
#include <TranslationUtils.h>
|
||||
#include <TranslatorFormats.h>
|
||||
#include <TranslatorRoster.h>
|
||||
#include <Translator.h>
|
||||
|
||||
/* we do not include TranslatorAddOn.h because it's only used when building an add-on */
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/*****************************************************************************/
|
||||
// File: TranslationUtils.h
|
||||
// Class: BTranslationUtils
|
||||
// Reimplimented by: Michael Wilber, Translation Kit Team
|
||||
// Reimplimentation: 2002-04
|
||||
//
|
||||
// Description: Utility functions for the Translation Kit
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2002 OpenBeOS Project
|
||||
//
|
||||
// Original Version: Copyright 1998, Be Incorporated, All Rights Reserved.
|
||||
// Copyright 1995-1997, Jon Watte
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#if !defined(_TRANSLATION_UTILS_H)
|
||||
#define _TRANSLATION_UTILS_H
|
||||
|
||||
#include <TranslationDefs.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
class BBitmap;
|
||||
class BTranslatorRoster;
|
||||
class BPositionIO;
|
||||
class BMenu;
|
||||
|
||||
// This class is a little different from many other classes.
|
||||
// You don't create an instance of it; you just call its various
|
||||
// static member functions for utility-like operations.
|
||||
class BTranslationUtils {
|
||||
BTranslationUtils();
|
||||
~BTranslationUtils();
|
||||
BTranslationUtils(const BTranslationUtils &);
|
||||
BTranslationUtils & operator=(const BTranslationUtils &);
|
||||
|
||||
public:
|
||||
|
||||
// BITMAP getters - allocate the BBitmap; you call delete on it!
|
||||
|
||||
static BBitmap *GetBitmap(const char *kName, BTranslatorRoster *roster = NULL);
|
||||
// Get bitmap - first try as file name, then as B_TRANSLATOR_BITMAP
|
||||
// resource type from app file -- can be of any kind for which a
|
||||
// translator is installed (TGA, etc)
|
||||
|
||||
static BBitmap *GetBitmap(uint32 type, int32 id,
|
||||
BTranslatorRoster *roster = NULL);
|
||||
// Get bitmap - from app resource by id
|
||||
|
||||
static BBitmap *GetBitmap(uint32 type, const char *kName,
|
||||
BTranslatorRoster *roster = NULL);
|
||||
// Get Bitmap - from app resource by name
|
||||
|
||||
static BBitmap *GetBitmapFile(const char *kName,
|
||||
BTranslatorRoster *roster = NULL);
|
||||
// Get bitmap - from file only
|
||||
|
||||
static BBitmap *GetBitmap(const entry_ref *kRef,
|
||||
BTranslatorRoster *roster = NULL);
|
||||
// Get bitmap - from open file (or BMemoryIO)
|
||||
|
||||
static BBitmap *GetBitmap(BPositionIO *stream,
|
||||
BTranslatorRoster *roster = NULL);
|
||||
// Get bitmap - from open file or IO type object
|
||||
|
||||
static status_t GetStyledText(BPositionIO *fromStream, BTextView *intoView,
|
||||
BTranslatorRoster *roster = NULL);
|
||||
// For styled text, we can translate from a stream
|
||||
// directly into a BTextView
|
||||
|
||||
static status_t PutStyledText(BTextView *fromView, BPositionIO *intoStream,
|
||||
BTranslatorRoster *roster = NULL);
|
||||
// Saving is slightly different -- given the BTextView, a
|
||||
// B_STYLED_TEXT_FORMAT stream is written to intoStream. You can then call
|
||||
// Translate() yourself to translate that stream into something else if
|
||||
// you want, if it is a temp file or a BMallocIO. It's also OK to write
|
||||
// the B_STYLED_TEXT_FORMAT to a file, although the StyledEdit format
|
||||
// (TEXT file + style attributes) is preferred. This convenience function
|
||||
// is only marginally part of the Translation Kit, but what the hey :-)
|
||||
|
||||
static status_t WriteStyledEditFile(BTextView *fromView, BFile *intoFile);
|
||||
// Writes the styled text data from fromView to intoFile
|
||||
|
||||
static BMessage *GetDefaultSettings(translator_id forTranslator,
|
||||
BTranslatorRoster *roster = NULL);
|
||||
// Get default settings for the translator with the id forTranslator
|
||||
|
||||
static BMessage *GetDefaultSettings(const char *kTranslatorName,
|
||||
int32 translatorVersion);
|
||||
// Get default settings for the translator with the name kTranslatorName
|
||||
|
||||
// Envious of that "Save As" menu in ShowImage? Well, you can have your own!
|
||||
// AddTranslationItems will add menu items for all translations from the
|
||||
// basic format you specify (B_TRANSLATOR_BITMAP, B_TRANSLATOR_TEXT etc).
|
||||
// The translator ID and format constant chosen will be added to the message
|
||||
// that is sent to you when the menu item is selected.
|
||||
enum {
|
||||
B_TRANSLATION_MENU = 'BTMN'
|
||||
};
|
||||
static status_t AddTranslationItems(BMenu *intoMenu, uint32 fromType,
|
||||
const BMessage *kModel = NULL, // default B_TRANSLATION_MENU
|
||||
const char *kTranslatorIdName = NULL, // default "be:translator"
|
||||
const char *kTranslatorTypeName = NULL, // default "be:type"
|
||||
BTranslatorRoster *roster = NULL);
|
||||
|
||||
// BEGIN: Added by Michael Wilber
|
||||
private:
|
||||
|
||||
static BBitmap * TranslateToBitmap(BPositionIO *pio,
|
||||
BTranslatorRoster *roster = NULL);
|
||||
// Translates the image data from pio to the type type using the
|
||||
// supplied BTranslatorRoster. If BTranslatorRoster is not supplied
|
||||
// the default BTranslatorRoster is used.
|
||||
|
||||
// END: Added by Michael Wilber
|
||||
|
||||
};
|
||||
|
||||
#endif /* _TRANSLATION_UTILS_H */
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/*****************************************************************************/
|
||||
// File: Translator.h
|
||||
// Class: BTranslator
|
||||
// Reimplimented by: Michael Wilber, Translation Kit Team
|
||||
// Reimplimentation: 2002-06-15
|
||||
//
|
||||
// Description: This file contains the BTranslator class, the base class for
|
||||
// all translators that don't use the BeOS R4/R4.5 add-on method.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2002 OpenBeOS Project
|
||||
//
|
||||
// Original Version: Copyright 1998, Be Incorporated, All Rights Reserved.
|
||||
// Copyright 1995-1997, Jon Watte
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
#ifndef _TRANSLATOR_H
|
||||
#define _TRANSLATOR_H
|
||||
|
||||
#include <TranslationDefs.h>
|
||||
#include <Archivable.h>
|
||||
|
||||
class BTranslator : public BArchivable {
|
||||
public:
|
||||
BTranslator();
|
||||
// Sets refcount to 1 (the object is initially Acquired()'d once)
|
||||
|
||||
BTranslator *Acquire();
|
||||
// return actual object and increment the refcount
|
||||
|
||||
BTranslator *Release();
|
||||
// Decrements the refcount and returns pointer to the object.
|
||||
// When the refcount is zero, NULL is returned and the object is
|
||||
// deleted
|
||||
|
||||
int32 ReferenceCount();
|
||||
// returns the refcount, THIS IS NOT THREAD SAFE, ITS ONLY FOR "FUN"
|
||||
|
||||
virtual const char *TranslatorName() const = 0;
|
||||
// returns the short name of the translator
|
||||
|
||||
virtual const char *TranslatorInfo() const = 0;
|
||||
// returns a verbose name/description for the translator
|
||||
|
||||
virtual int32 TranslatorVersion() const = 0;
|
||||
// returns the version of the translator
|
||||
|
||||
virtual const translation_format *InputFormats(int32 *out_count)
|
||||
const = 0;
|
||||
// returns the input formats and the count of input formats
|
||||
// that this translator supports
|
||||
|
||||
virtual const translation_format *OutputFormats(int32 *out_count)
|
||||
const = 0;
|
||||
// returns the output formats and the count of output formats
|
||||
// that this translator supports
|
||||
|
||||
virtual status_t Identify(BPositionIO *inSource,
|
||||
const translation_format *inFormat, BMessage *ioExtension,
|
||||
translator_info *outInfo, uint32 outType) = 0;
|
||||
// determines whether or not this translator can convert the
|
||||
// data in inSource to the type outType
|
||||
|
||||
virtual status_t Translate(BPositionIO *inSource,
|
||||
const translator_info *inInfo, BMessage *ioExtension,
|
||||
uint32 outType, BPositionIO *outDestination) = 0;
|
||||
// this function is the whole point of the Translation Kit,
|
||||
// it translates the data in inSource to outDestination
|
||||
// using the format outType
|
||||
|
||||
virtual status_t MakeConfigurationView(BMessage *ioExtension,
|
||||
BView **outView, BRect *outExtent);
|
||||
// this function creates a view that allows the user to
|
||||
// configure the translator, this function is not
|
||||
// required for all translators
|
||||
|
||||
virtual status_t GetConfigurationMessage(BMessage *ioExtension);
|
||||
// puts information about the current configuration of the
|
||||
// translator into ioExtension so that it can be used with
|
||||
// Identify or Translate or whatever, this function is
|
||||
// not required for all translators
|
||||
|
||||
protected:
|
||||
virtual ~BTranslator();
|
||||
// this is protected because the object is deleted by the
|
||||
// Release() function instead of being deleted directly by
|
||||
// the user
|
||||
|
||||
private:
|
||||
int32 fRefCount;
|
||||
// number of times this object has been referenced
|
||||
// by the Acquire() function
|
||||
|
||||
sem_id fSem;
|
||||
// used to lock object for Acquire() and Release()
|
||||
|
||||
// For binary compatibility with past and future
|
||||
// version of this class
|
||||
uint32 fUnused[8];
|
||||
virtual status_t _Reserved_Translator_0(int32, void *);
|
||||
virtual status_t _Reserved_Translator_1(int32, void *);
|
||||
virtual status_t _Reserved_Translator_2(int32, void *);
|
||||
virtual status_t _Reserved_Translator_3(int32, void *);
|
||||
virtual status_t _Reserved_Translator_4(int32, void *);
|
||||
virtual status_t _Reserved_Translator_5(int32, void *);
|
||||
virtual status_t _Reserved_Translator_6(int32, void *);
|
||||
virtual status_t _Reserved_Translator_7(int32, void *);
|
||||
};
|
||||
|
||||
// The post-4.5 API suggests implementing this function in your translator
|
||||
// add-on rather than the separate functions and variables of the previous
|
||||
// API. You will be called for values of n starting at 0 and increasing;
|
||||
// return 0 when you can't make another kind of translator (i.e. for n=1
|
||||
// if you only implement one subclass of BTranslator). Ignore flags for now.
|
||||
extern "C" _EXPORT BTranslator *make_nth_translator(int32 n, image_id you,
|
||||
uint32 flags, ...);
|
||||
|
||||
|
||||
|
||||
#endif /* _TRANSLATOR_H */
|
||||
@@ -0,0 +1,92 @@
|
||||
/********************************************************************************
|
||||
/
|
||||
/ File: TranslatorAddOn.h
|
||||
/
|
||||
/ Description: This header file defines the interface that should be
|
||||
/ implemented and exported by a Tanslation Kit add-on.
|
||||
/ You will only need to include this header when building
|
||||
/ an actual add-on, not when just using the kit.
|
||||
/
|
||||
/ Copyright 1998, Be Incorporated, All Rights Reserved.
|
||||
/ Copyright 1995-1997, Jon Watte
|
||||
/
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef _TRANSLATOR_ADD_ON_H
|
||||
#define _TRANSLATOR_ADD_ON_H
|
||||
|
||||
#include <TranslationDefs.h>
|
||||
|
||||
|
||||
class BView;
|
||||
class BRect;
|
||||
class BPositionIO;
|
||||
|
||||
|
||||
/* This is the 4.0 and 4.5 compatible API. For later versions, use the */
|
||||
/* BTranslator-based API (make_nth_translator) */
|
||||
|
||||
/* These variables and functions should be exported by a translator add-on */
|
||||
|
||||
extern "C" {
|
||||
|
||||
_EXPORT extern char translatorName[]; /* required, C string, ex "Jon's Sound" */
|
||||
_EXPORT extern char translatorInfo[]; /* required, descriptive C string, ex "Jon's Sound Translator (shareware $5: [email protected]) v1.00" */
|
||||
_EXPORT extern int32 translatorVersion; /* required, integer, ex 100 */
|
||||
|
||||
_EXPORT extern translation_format inputFormats[]; /* optional (else Identify is always called) */
|
||||
_EXPORT extern translation_format outputFormats[]; /* optional (else Translate is called anyway) */
|
||||
/* Translators that don't export outputFormats */
|
||||
/* will not be considered by files looking for */
|
||||
/* specific output formats. */
|
||||
|
||||
/* Return B_NO_TRANSLATOR if not handling this data. */
|
||||
/* Even if inputFormats exists, may be called for data without hints */
|
||||
/* Ff outType is not 0, must be able to export in wanted format */
|
||||
|
||||
_EXPORT extern status_t Identify( /* required */
|
||||
BPositionIO * inSource,
|
||||
const translation_format * inFormat, /* can beNULL */
|
||||
BMessage * ioExtension, /* can be NULL */
|
||||
translator_info * outInfo,
|
||||
uint32 outType);
|
||||
|
||||
/* Return B_NO_TRANSLATOR if not handling the output format */
|
||||
/* If outputFormats exists, will only be called for those formats */
|
||||
|
||||
_EXPORT extern status_t Translate( /* required */
|
||||
BPositionIO * inSource,
|
||||
const translator_info * inInfo,
|
||||
BMessage * ioExtension, /* can be NULL */
|
||||
uint32 outType,
|
||||
BPositionIO * outDestination);
|
||||
|
||||
/* The view will get resized to what the parent thinks is */
|
||||
/* reasonable. However, it will still receive MouseDowns etc. */
|
||||
/* Your view should change settings in the translator immediately, */
|
||||
/* taking care not to change parameters for a translation that is */
|
||||
/* currently running. Typically, you'll have a global struct for */
|
||||
/* settings that is atomically copied into the translator function */
|
||||
/* as a local when translation starts. */
|
||||
/* Store your settings wherever you feel like it. */
|
||||
|
||||
_EXPORT extern status_t MakeConfig( /* optional */
|
||||
BMessage * ioExtension, /* can be NULL */
|
||||
BView * * outView,
|
||||
BRect * outExtent);
|
||||
|
||||
/* Copy your current settings to a BMessage that may be passed */
|
||||
/* to BTranslators::Translate at some later time when the user wants to */
|
||||
/* use whatever settings you're using right now. */
|
||||
|
||||
_EXPORT extern status_t GetConfigMessage( /* optional */
|
||||
BMessage * ioExtension);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* _TRANSLATOR_ADD_ON_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
/********************************************************************************
|
||||
/
|
||||
/ File: TranslatorFormats.h
|
||||
/
|
||||
/ Description: Defines for common "lowest common denominator" formats
|
||||
/ used in the Translation Kit.
|
||||
/
|
||||
/ Copyright 1998, Be Incorporated, All Rights Reserved.
|
||||
/ Copyright 1995-1997, Jon Watte
|
||||
/
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
#ifndef _TRANSLATOR_FORMATS_H
|
||||
#define _TRANSLATOR_FORMATS_H
|
||||
|
||||
|
||||
#include <GraphicsDefs.h>
|
||||
#include <Rect.h>
|
||||
|
||||
/* extensions used in the extension BMessage. Use of these */
|
||||
/* is described in the documentation. */
|
||||
|
||||
_IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_HEADER_ONLY[];
|
||||
_IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_DATA_ONLY[];
|
||||
_IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_COMMENT[];
|
||||
_IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_TIME[];
|
||||
_IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_FRAME[];
|
||||
_IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_BITMAP_RECT[];
|
||||
_IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_BITMAP_COLOR_SPACE[];
|
||||
_IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_BITMAP_PALETTE[];
|
||||
_IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_SOUND_CHANNEL[];
|
||||
_IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_SOUND_MONO[];
|
||||
_IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_SOUND_MARKER[];
|
||||
_IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_SOUND_LOOP[];
|
||||
|
||||
#if defined(_DATATYPES_COMPATIBLE_)
|
||||
#define kCommentExtension "/comment"
|
||||
#define kTimeExtension "/time"
|
||||
#define kFrameExtension "/frame"
|
||||
#define kBitsRectExtension "bits/Rect"
|
||||
#define kBitsSpaceExtension "bits/space"
|
||||
#define kHeaderExtension "/headerOnly"
|
||||
#define kDataExtension "/dataOnly"
|
||||
#define kNoisChannelExtension "nois/channel"
|
||||
#define kNoisMonoExtension "nois/mono"
|
||||
#define kNoisMarkerExtension "nois/marker"
|
||||
#define kNoisLoopExtension "nois/loop"
|
||||
#endif
|
||||
|
||||
|
||||
/* For each data group, there is a "standard" format that */
|
||||
/* all translators should support. */
|
||||
/* These type codes are lower-case because they are already */
|
||||
/* established standards in the Be developer community. */
|
||||
enum TranslatorGroups {
|
||||
B_TRANSLATOR_BITMAP = 'bits', /* TranslatorBitmap */
|
||||
B_TRANSLATOR_PICTURE = 'pict', /* BPicture data */
|
||||
B_TRANSLATOR_TEXT = 'TEXT', /* B_ASCII_TYPE */
|
||||
B_TRANSLATOR_SOUND = 'nois', /* TranslatorSound */
|
||||
B_TRANSLATOR_MIDI = 'midi', /* standard MIDI */
|
||||
B_TRANSLATOR_MEDIA = 'mhi!', /* a stream of stuff */
|
||||
B_TRANSLATOR_NONE = 'none',
|
||||
B_TRANSLATOR_ANY_TYPE = 0
|
||||
};
|
||||
#if defined(_DATATYPES_COMPATIBLE_)
|
||||
#define kAnyType 0
|
||||
#endif
|
||||
|
||||
|
||||
/* some pre-defined data format type codes */
|
||||
|
||||
enum {
|
||||
/* bitmap formats (B_TRANSLATOR_BITMAP) */
|
||||
B_GIF_FORMAT = 'GIF ',
|
||||
B_JPEG_FORMAT = 'JPEG',
|
||||
B_PNG_FORMAT = 'PNG ',
|
||||
B_PPM_FORMAT = 'PPM ',
|
||||
B_TGA_FORMAT = 'TGA ',
|
||||
B_BMP_FORMAT = 'BMP ',
|
||||
B_TIFF_FORMAT = 'TIFF',
|
||||
|
||||
/* line drawing formats (B_TRANSLATOR_PICTURE) */
|
||||
B_DXF_FORMAT = 'DXF ',
|
||||
B_EPS_FORMAT = 'EPS ',
|
||||
B_PICT_FORMAT = 'PICT', /* MacOS PICT file */
|
||||
|
||||
/* sound file formats (B_TRANSLATOR_SOUND) */
|
||||
B_WAV_FORMAT = 'WAV ',
|
||||
B_AIFF_FORMAT = 'AIFF',
|
||||
B_CD_FORMAT = 'CD ', /* 44 kHz, stereo, 16 bit, linear, big-endian */
|
||||
B_AU_FORMAT = 'AU ', /* Sun ulaw */
|
||||
|
||||
/* text file formats (B_TRANSLATOR_TEXT) */
|
||||
B_STYLED_TEXT_FORMAT = 'STXT'
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* This is the standard bitmap format */
|
||||
/* Note that data is always in big-endian format in the stream! */
|
||||
struct TranslatorBitmap {
|
||||
uint32 magic; /* B_TRANSLATOR_BITMAP */
|
||||
BRect bounds;
|
||||
uint32 rowBytes;
|
||||
color_space colors;
|
||||
uint32 dataSize;
|
||||
}; /* data follows, padded to rowBytes */
|
||||
|
||||
/* This is the standard sound format */
|
||||
/* Note that data is always in big-endian format in the stream! */
|
||||
struct TranslatorSound {
|
||||
uint32 magic; /* B_TRANSLATOR_SOUND */
|
||||
uint32 channels; /* Left should always be first */
|
||||
float sampleFreq; /* 16 bit linear is assumed */
|
||||
uint32 numFrames;
|
||||
}; /* data follows */
|
||||
|
||||
/* This is the standard styled text format */
|
||||
/* Note that it is of group type text! */
|
||||
/* Skip any records types you don't know about. */
|
||||
/* Always big-endian. */
|
||||
struct TranslatorStyledTextRecordHeader {
|
||||
uint32 magic;
|
||||
uint32 header_size;
|
||||
uint32 data_size;
|
||||
}; /* any number of records */
|
||||
struct TranslatorStyledTextStreamHeader {
|
||||
#if defined(__cplusplus)
|
||||
enum {
|
||||
STREAM_HEADER_MAGIC = 'STXT'
|
||||
};
|
||||
#endif
|
||||
TranslatorStyledTextRecordHeader header;
|
||||
int32 version; /* 100 */
|
||||
}; /* no data for this header */
|
||||
struct TranslatorStyledTextTextHeader {
|
||||
#if defined(__cplusplus)
|
||||
enum {
|
||||
TEXT_HEADER_MAGIC = 'TEXT'
|
||||
};
|
||||
#endif
|
||||
TranslatorStyledTextRecordHeader header;
|
||||
int32 charset; /* Always write B_UTF8 for now! */
|
||||
}; /* text data follows */
|
||||
struct TranslatorStyledTextStyleHeader {
|
||||
#if defined(__cplusplus)
|
||||
enum {
|
||||
STYLE_HEADER_MAGIC = 'STYL'
|
||||
};
|
||||
#endif
|
||||
TranslatorStyledTextRecordHeader header;
|
||||
uint32 apply_offset;
|
||||
uint32 apply_length;
|
||||
}; /* flattened R3 BTextView style records for preceding text */
|
||||
#if 0
|
||||
/* format of the STYL record data (always big-endian) FYI: */
|
||||
struct {
|
||||
uchar magic[4]; /* 41 6c 69 21 */
|
||||
uchar version[4]; /* 00 00 00 00 */
|
||||
int32 count;
|
||||
struct {
|
||||
int32 offset;
|
||||
char family[64];
|
||||
char style[64];
|
||||
float size;
|
||||
float shear; /* typically 90.0 */
|
||||
uint16 face; /* typically 0 */
|
||||
uint8 red;
|
||||
uint8 green;
|
||||
uint8 blue;
|
||||
uint8 alpha; /* 255 == opaque */
|
||||
uint16 _reserved_; /* 0 */
|
||||
} styles[];
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* _TRANSLATOR_FORMATS_H */
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
/*****************************************************************************/
|
||||
// File: TranslatorRoster.h
|
||||
// Class: BTranslatorRoster
|
||||
// Reimplimented by: Michael Wilber, Translation Kit Team
|
||||
// Reimplimentation: 2002-06-11
|
||||
//
|
||||
// Description: This class is the guts of the translation kit, it makes the
|
||||
// whole thing happen. It bridges the applications using this
|
||||
// object with the translators that the apps need to access.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2002 OpenBeOS Project
|
||||
//
|
||||
// Original Version: Copyright 1998, Be Incorporated, All Rights Reserved.
|
||||
// Copyright 1995-1997, Jon Watte
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef _TRANSLATOR_ROSTER_H
|
||||
#define _TRANSLATOR_ROSTER_H
|
||||
|
||||
#include <TranslationDefs.h>
|
||||
#include <OS.h>
|
||||
#include <StorageDefs.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <Archivable.h>
|
||||
#include <TranslatorFormats.h>
|
||||
#include <TranslationDefs.h>
|
||||
#include <TranslationErrors.h>
|
||||
#include <Translator.h>
|
||||
#include <String.h>
|
||||
#include <image.h>
|
||||
#include <File.h>
|
||||
#include <Directory.h>
|
||||
#include <Volume.h>
|
||||
#include <string.h>
|
||||
#include <OS.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <alloca.h>
|
||||
#include <R4xTranslator.h>
|
||||
|
||||
struct translation_format;
|
||||
|
||||
class BBitmap;
|
||||
class BView;
|
||||
class BPositionIO;
|
||||
class BQuery;
|
||||
class BMessage;
|
||||
|
||||
const char kgDefaultTranslatorPath[] = "/boot/home/config/add-ons/Translators:/boot/home/config/add-ons/Datatypes:/system/add-ons/Translators";
|
||||
|
||||
// used by BTranslatorRoster to store the list of translators
|
||||
struct translator_node {
|
||||
BTranslator *translator;
|
||||
char *path;
|
||||
image_id image;
|
||||
translator_id id;
|
||||
translator_node *next;
|
||||
};
|
||||
|
||||
class BTranslatorRoster : public BArchivable {
|
||||
// private, unimplemented functions
|
||||
// (I'm not sure if there is a need for them anyway)
|
||||
BTranslatorRoster(const BTranslatorRoster &);
|
||||
BTranslatorRoster & operator=(const BTranslatorRoster &);
|
||||
|
||||
public:
|
||||
BTranslatorRoster();
|
||||
// initializes the object with no translators
|
||||
|
||||
BTranslatorRoster(BMessage *model);
|
||||
// initializes the object and loads all translators from the
|
||||
// "be:translator_path" string array in model
|
||||
|
||||
~BTranslatorRoster();
|
||||
// frees memory used by this object
|
||||
|
||||
virtual status_t Archive(BMessage *into, bool deep = true) const;
|
||||
// store the BTranslatorRoster in into so it can later be
|
||||
// used with Instantiate or the BMessage constructor
|
||||
|
||||
static BArchivable *Instantiate(BMessage *from);
|
||||
// creates a BTranslatorRoster object from the from archive
|
||||
|
||||
static const char *Version(int32 *outCurVersion, int32 *outMinVersion,
|
||||
int32 inAppVersion = B_TRANSLATION_CURRENT_VERSION);
|
||||
// returns the version of BTranslator roster as a string
|
||||
// and through the int32 pointers; inAppVersion appears
|
||||
// to be ignored
|
||||
|
||||
static BTranslatorRoster *Default();
|
||||
// returns the "default" set of translators, they are translators
|
||||
// that are loaded from the default paths
|
||||
// /boot/home/config/add-ons/Translators,
|
||||
// /boot/home/config/add-ons/Datatypes,
|
||||
// /system/add-ons/Translators or the paths in the
|
||||
// TRANSLATORS environment variable, if it exists
|
||||
|
||||
status_t AddTranslators(const char *load_path = NULL);
|
||||
// this adds a translator, all of the translators in a folder or
|
||||
// the default translators if the path is NULL
|
||||
|
||||
status_t AddTranslator(BTranslator * translator);
|
||||
// adds a translator that you've created yourself to the
|
||||
// BTranslatorRoster; this is useful if you have translators
|
||||
// that you don't want to make public or don't want loaded as
|
||||
// an add-on
|
||||
|
||||
virtual status_t Identify(BPositionIO *inSource, BMessage *ioExtension,
|
||||
translator_info *outInfo, uint32 inHintType = 0,
|
||||
const char *inHintMIME = NULL, uint32 inWantType = 0);
|
||||
// identifies the translator that can handle the data in inSource
|
||||
|
||||
virtual status_t GetTranslators(BPositionIO *inSource,
|
||||
BMessage *ioExtension, translator_info **outInfo, int32 *outNumInfo,
|
||||
uint32 inHintType = 0, const char *inHintMIME = NULL,
|
||||
uint32 inWantType = 0);
|
||||
// finds all translators for the given type
|
||||
|
||||
virtual status_t GetAllTranslators(translator_id **outList,
|
||||
int32 *outCount);
|
||||
// returns all translators that this object contains
|
||||
|
||||
virtual status_t GetTranslatorInfo(translator_id forTranslator,
|
||||
const char **outName, const char **outInfo, int32 *outVersion);
|
||||
// gets user visible info about a specific translator
|
||||
|
||||
virtual status_t GetInputFormats(translator_id forTranslator,
|
||||
const translation_format **outFormats, int32 *outNumFormats);
|
||||
// finds all input formats for a translator;
|
||||
// note that translators don't always publish the formats
|
||||
// that they support
|
||||
|
||||
virtual status_t GetOutputFormats(translator_id forTranslator,
|
||||
const translation_format **outFormats, int32 *outNumFormats);
|
||||
// finds all output formats for a translator;
|
||||
// note that translators don't always publish the formats
|
||||
// that they support
|
||||
|
||||
virtual status_t Translate(BPositionIO *inSource,
|
||||
const translator_info *inInfo, BMessage *ioExtension,
|
||||
BPositionIO *outDestination, uint32 inWantOutType,
|
||||
uint32 inHintType = 0, const char *inHintMIME = NULL);
|
||||
// the whole point of this entire kit boils down to this function;
|
||||
// this translates the data in inSource into outDestination
|
||||
// using the format inWantOutType
|
||||
|
||||
virtual status_t Translate(translator_id inTranslator,
|
||||
BPositionIO *inSource, BMessage *ioExtension,
|
||||
BPositionIO *outDestination, uint32 inWantOutType);
|
||||
// the whole point of this entire kit boils down to this function;
|
||||
// this translates the data in inSource into outDestination
|
||||
// using the format inWantOutType and the translator inTranslator
|
||||
|
||||
virtual status_t MakeConfigurationView(translator_id forTranslator,
|
||||
BMessage *ioExtension, BView **outView, BRect *outExtent);
|
||||
// create the view for forTranslator that allows the user
|
||||
// to configure it;
|
||||
// NOTE: translators are not required to support this function
|
||||
|
||||
virtual status_t GetConfigurationMessage(translator_id forTranslator,
|
||||
BMessage *ioExtension);
|
||||
// this is used to save the settings for a translator so that
|
||||
// they can be written to disk or used in an Indentify or
|
||||
// Translate call
|
||||
|
||||
status_t GetRefFor(translator_id translator, entry_ref *out_ref);
|
||||
// I'm guessing that this returns the entry_ref for the
|
||||
// translator add-on file for the translator_id translator
|
||||
|
||||
private:
|
||||
void Initialize();
|
||||
// class initialization code used by all constructors
|
||||
|
||||
translator_node *FindTranslatorNode(translator_id id);
|
||||
// used to find the translator_node for the translator_id id
|
||||
// returns NULL if the id is not valid
|
||||
|
||||
status_t LoadTranslator(const char *path);
|
||||
// loads the translator add-on specified by path
|
||||
|
||||
void LoadDir(const char *path, int32 &loadErr, int32 &nLoaded);
|
||||
// loads all of the translator add-ons from path and
|
||||
// returns error status in loadErr and the number of
|
||||
// translators loaded in nLoaded
|
||||
|
||||
bool CheckFormats(const translation_format *inputFormats,
|
||||
int32 inputFormatsCount, uint32 hintType, const char *hintMIME,
|
||||
const translation_format **outFormat);
|
||||
// determines how the Identify function is called
|
||||
|
||||
// adds the translator to the list of translators
|
||||
// that this object maintains
|
||||
status_t AddTranslatorToList(BTranslator *translator);
|
||||
status_t AddTranslatorToList(BTranslator *translator,
|
||||
const char *path, image_id image, bool acquire);
|
||||
|
||||
static BTranslatorRoster *fspDefaultTranslators;
|
||||
// object that contains the default translators
|
||||
translator_node *fpTranslators;
|
||||
// list of translators maintained by this object
|
||||
sem_id fSem;
|
||||
// semaphore used to lock this object
|
||||
|
||||
// used to maintain binary combatibility with
|
||||
// past and future versions of this object
|
||||
int32 fUnused[5];
|
||||
virtual void ReservedTranslatorRoster1();
|
||||
virtual void ReservedTranslatorRoster2();
|
||||
virtual void ReservedTranslatorRoster3();
|
||||
virtual void ReservedTranslatorRoster4();
|
||||
virtual void ReservedTranslatorRoster5();
|
||||
virtual void ReservedTranslatorRoster6();
|
||||
};
|
||||
|
||||
#endif /* _TRANSLATOR_ROSTER_H */
|
||||
|
||||
Reference in New Issue
Block a user