* More or less rewrote BTranslatorRoster - it now has a private implementation

class, and only wraps around that one.
* Translating is no longer serialized, you can translate more than one object
  at a time now.
* A BTranslator that is released (ie. deleted) will no longer let its BTranslatorRoster
  crash.
* Removed BTranslatorRoster::Version() - this kind of call definitely makes no
  sense at all. It's still exported from the sources, though, for backwards
  compatibility.
* Simplified and improved code.
* Images are now unloaded only once.
* Added new method IsTranslator() that will be used by the DataTranslations preferences
  application.
* Began implementing new methods StartWatching()/StopWatching() that will notify
  you if new translators are installed or old ones removed (this will also be used
  by DataTranslations once it's ready).
* The private BTranslatorRoster class will now add itself to the existing BApplication,
  in order to provide automatic updating of the translators if needed (not yet implemented
  though).
* Not heavily tested yet, there might be some regressions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17247 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-04-27 18:40:28 +00:00
parent 11add5a5d7
commit f90e454336
9 changed files with 1559 additions and 2768 deletions

View File

@ -1,127 +1,67 @@
/*****************************************************************************/
// File: Translator.h
// Class: BTranslator
// Reimplemented by: Michael Wilber, Translation Kit Team
// Reimplementation: 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.
/*****************************************************************************/
/*
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _TRANSLATOR_H
#define _TRANSLATOR_H
#include <TranslationDefs.h>
#include <Archivable.h>
#include <TranslationDefs.h>
#include <TranslatorRoster.h>
class BTranslator : public BArchivable {
public:
BTranslator();
// Sets refcount to 1 (the object is initially Acquired()'d once)
public:
BTranslator();
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"
BTranslator* Acquire();
BTranslator* Release();
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
int32 ReferenceCount();
// returns the refcount, THIS IS NOT THREAD SAFE, ITS ONLY FOR "FUN"
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 const char *TranslatorName() const = 0;
virtual const char *TranslatorInfo() const = 0;
virtual int32 TranslatorVersion() const = 0;
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 const translation_format *InputFormats(int32 *out_count)
const = 0;
virtual const translation_format *OutputFormats(int32 *out_count)
const = 0;
virtual status_t Identify(BPositionIO *inSource,
const translation_format *inFormat, BMessage *ioExtension,
translator_info *outInfo, uint32 outType) = 0;
virtual status_t Translate(BPositionIO *inSource,
const translator_info *inInfo, BMessage *ioExtension,
uint32 outType, BPositionIO *outDestination) = 0;
virtual status_t MakeConfigurationView(BMessage *ioExtension,
BView **outView, BRect *outExtent);
virtual status_t GetConfigurationMessage(BMessage *ioExtension);
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
protected:
virtual ~BTranslator();
// this is protected because the object is deleted by the
// Release() function instead of being deleted directly by
// the user
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
private:
friend class BTranslatorRoster::Private;
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
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 *);
protected:
virtual ~BTranslator();
// this is protected because the object is deleted by the
// Release() function instead of being deleted directly by
// the user
BTranslatorRoster::Private* fOwningRoster;
translator_id fID;
int32 fRefCount;
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 *);
uint32 _reserved[7];
};
// The post-4.5 API suggests implementing this function in your translator
@ -132,6 +72,4 @@ private:
extern "C" _EXPORT BTranslator *make_nth_translator(int32 n, image_id you,
uint32 flags, ...);
#endif /* _TRANSLATOR_H */

View File

@ -1,63 +1,13 @@
/*****************************************************************************/
// File: TranslatorRoster.h
// Class: BTranslatorRoster
// Reimplemented by: Michael Wilber, Translation Kit Team
// Reimplementation: 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.
/*****************************************************************************/
/*
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#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>
struct translation_format;
@ -67,174 +17,84 @@ 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();
BTranslatorRoster(BMessage* model);
virtual ~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
static BTranslatorRoster *Default();
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
virtual status_t Archive(BMessage* into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* from);
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
status_t AddTranslators(const char* loadPath = NULL);
status_t AddTranslator(BTranslator* translator);
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
virtual status_t Identify(BPositionIO* source, BMessage* ioExtension,
translator_info* _info, uint32 hintType = 0,
const char* hintMIME = NULL, uint32 wantType = 0);
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
virtual status_t GetTranslators(BPositionIO* source,
BMessage* ioExtension, translator_info** _info, int32* _numInfo,
uint32 hintType = 0, const char* hintMIME = NULL,
uint32 wantType = 0);
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 GetAllTranslators(translator_id** _list,
int32* _count);
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 GetTranslatorInfo(translator_id translatorID,
const char** _name, const char** _info, int32* _version);
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 GetInputFormats(translator_id translatorID,
const translation_format** _formats, int32* _numFormats);
virtual status_t GetAllTranslators(translator_id **outList,
int32 *outCount);
// returns all translators that this object contains
virtual status_t GetOutputFormats(translator_id translatorID,
const translation_format** _formats, int32* _numFormats);
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 Translate(BPositionIO* source,
const translator_info* info, BMessage* ioExtension,
BPositionIO* destination, uint32 wantOutType,
uint32 hintType = 0, const char* hintMIME = NULL);
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 Translate(translator_id translatorID,
BPositionIO* source, BMessage* ioExtension,
BPositionIO* destination, uint32 wantOutType);
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 MakeConfigurationView(translator_id translatorID,
BMessage* ioExtension, BView** _view, BRect* _extent);
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 GetConfigurationMessage(translator_id translatorID,
BMessage* ioExtension);
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
status_t GetRefFor(translator_id translatorID, entry_ref* ref);
bool IsTranslator(entry_ref* ref);
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
status_t StartWatching(BMessenger target);
status_t StopWatching(BMessenger target);
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
private:
// unimplemented
BTranslatorRoster(const BTranslatorRoster& other);
BTranslatorRoster& operator=(const BTranslatorRoster& other);
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
virtual void ReservedTranslatorRoster1();
virtual void ReservedTranslatorRoster2();
virtual void ReservedTranslatorRoster3();
virtual void ReservedTranslatorRoster4();
virtual void ReservedTranslatorRoster5();
virtual void ReservedTranslatorRoster6();
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
void _Initialize();
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
private:
class Private;
// 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);
Private* fPrivate;
int32 fUnused[6];
static BTranslatorRoster *fspDefaultTranslators;
// object that contains the default translators
// list of translators maintained by this object
translator_node *fpTranslators;
translator_node *fpLastTranslator;
sem_id fSem;
// semaphore used to lock this object
// used to maintain binary combatibility with
// past and future versions of this object
int32 fUnused[4];
virtual void ReservedTranslatorRoster1();
virtual void ReservedTranslatorRoster2();
virtual void ReservedTranslatorRoster3();
virtual void ReservedTranslatorRoster4();
virtual void ReservedTranslatorRoster5();
virtual void ReservedTranslatorRoster6();
static BTranslatorRoster* sDefaultRoster;
};
#endif /* _TRANSLATOR_ROSTER_H */

View File

@ -1,130 +0,0 @@
/*****************************************************************************/
// File: FuncTranslator.h
// Class: BFuncTranslator
// Author: Michael Wilber, Translation Kit Team
// Originally Created: 2002-06-11
//
// Description:
// This header file contains the BTranslator based object for
// function based translators, i.e. the translators which export
// each translator function individually, instead of exporting
// the make_nth_translator() function, which returns the
// translator as a class derived from BTranslator.
//
// All of the BeOS R5 translators are function based translators.
// All of the Gobe Productive translators are function based
// translators. Nearly all of the translators I've found, with
// the exception of the Haiku translators, are function based.
//
// This class is used by the OpenBeOS BTranslatorRoster
// so that function based translators, make_nth_translator()
// 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 _FUNC_TRANSLATOR_H
#define _FUNC_TRANSLATOR_H
#include <Translator.h>
#include <image.h>
#include <TranslationDefs.h>
// Structure used to hold the collection of function pointers and
// public variables exported by function based translator add-ons.
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);
};
class BFuncTranslator : public BTranslator {
public:
BFuncTranslator(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 ~BFuncTranslator();
// 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 // _FUNC_TRANSLATOR_H

View File

@ -1,365 +1,133 @@
/*****************************************************************************/
// File: FuncTranslator.cpp
// Class: BFuncTranslator
// Author: Michael Wilber, Translation Kit Team
// Originally Created: 2002-06-11
//
// Description: This file contains the BTranslator based object for
// function based translators, aka, the translators
// that don't use the make_nth_translator() mechanism.
//
// This class is used by the OpenBeOS BTranslatorRoster
// so that function based translators, make_nth_translator()
// 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.
/*****************************************************************************/
/*
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Michael Wilber
* Axel Dörfler, axeld@pinc-software.de
*/
#include <FuncTranslator.h>
/*!
This file contains the BTranslator based object for
function based translators, aka, the translators
that don't use the make_nth_translator() mechanism.
// ---------------------------------------------------------------
// Constructor
//
// Initializes class data.
//
// Preconditions:
//
// Parameters: kpData, data and function pointers that do all of
// the useful work for this class
//
// Postconditions: If kpData is freed before the BFuncTranslator,
// the BFuncTranslator will fail to work and
// could the computer to crash. kpData may point
// to a translator add-on image, this image
// should not be unloaded before the
// BFuncTranslator is freed.
//
//
// Returns:
// ---------------------------------------------------------------
BFuncTranslator::BFuncTranslator(const translator_data *kpData) : BTranslator()
This class is used by the BTranslatorRoster class
so that function based translators, make_nth_translator()
translators and private BTranslator objects could be
accessed in the same way.
*/
#include "FuncTranslator.h"
namespace BPrivate {
BFuncTranslator::BFuncTranslator(const translator_data& data)
{
fpData = new translator_data;
if (fpData) {
fpData->translatorName = kpData->translatorName;
fpData->translatorInfo = kpData->translatorInfo;
fpData->translatorVersion = kpData->translatorVersion;
fpData->inputFormats = kpData->inputFormats;
fpData->outputFormats = kpData->outputFormats;
fpData->Identify = kpData->Identify;
fpData->Translate = kpData->Translate;
fpData->MakeConfig = kpData->MakeConfig;
fpData->GetConfigMessage = kpData->GetConfigMessage;
}
memcpy(&fData, &data, sizeof(translator_data));
}
// ---------------------------------------------------------------
// Destructor
//
// Frees memory used by this object. Note that none of the members
// of the struct have delete used on them, this is because most
// are const pointers and the one that isn't is a regular int32.
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns:
// ---------------------------------------------------------------
BFuncTranslator::~BFuncTranslator()
{
delete fpData;
fpData = NULL;
}
// ---------------------------------------------------------------
// TranslatorName
//
// Returns a short name for the translator that this object stores
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns: NULL if fpData was not allocated successfully,
// or the short name of the translator otherwise
// ---------------------------------------------------------------
const char *BFuncTranslator::TranslatorName() const
const char *
BFuncTranslator::TranslatorName() const
{
if (fpData)
return fpData->translatorName;
else
return NULL;
return fData.name;
}
// ---------------------------------------------------------------
// TranslatorInfo
//
// Returns a verbose name/description for the translator that this
// object stores
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns: NULL if fpData was not allocated successfully,
// or the verbose name of the translator otherwise
// ---------------------------------------------------------------
const char *BFuncTranslator::TranslatorInfo() const
const char *
BFuncTranslator::TranslatorInfo() const
{
if (fpData)
return fpData->translatorInfo;
else
return NULL;
return fData.info;
}
// ---------------------------------------------------------------
// TranslatorVersion
//
// Returns the version number for this translator
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns: B_ERROR if fpData was not allocated successfully,
// or the integer representation of the translator
// version otherwise
// ---------------------------------------------------------------
int32 BFuncTranslator::TranslatorVersion() const
int32
BFuncTranslator::TranslatorVersion() const
{
if (fpData)
return fpData->translatorVersion;
else
return B_ERROR;
return fData.version;
}
// ---------------------------------------------------------------
// InputFormats
//
// Returns the list of supported input formats and the count
// of supported input formats
//
// Preconditions:
//
// Parameters: out_count, the number of input formats is stored
// here after the function completes
//
// Postconditions:
//
// Returns: NULL if out_count is NULL,
// NULL if fpData is not allocated,
// or the list of supported input formats if all is well
// ---------------------------------------------------------------
const translation_format *BFuncTranslator::InputFormats(int32 *out_count) const
const translation_format *
BFuncTranslator::InputFormats(int32* _count) const
{
if (!out_count)
return NULL;
if (fpData && fpData->inputFormats != NULL) {
int32 i;
for (i = 0; fpData->inputFormats[i].type; i++);
*out_count = i;
return fpData->inputFormats;
} else {
*out_count = 0;
if (_count == NULL || fData.input_formats == NULL)
return NULL;
int32 count = 0;
while (fData.input_formats[count].type) {
count++;
}
*_count = count;
return fData.input_formats;
}
// ---------------------------------------------------------------
// OutputFormats
//
// Returns the list of supported output formats
//
// Preconditions:
//
// Parameters: out_count, the number of output formats is stored
// here after the function completes
//
// Postconditions:
//
// Returns: NULL if out_count is NULL,
// NULL if fpData is not allocated,
// or the list of supported output formats if all is well
// ---------------------------------------------------------------
const translation_format *BFuncTranslator::OutputFormats(int32 *out_count) const
const translation_format *
BFuncTranslator::OutputFormats(int32* _count) const
{
if (!out_count)
return NULL;
if (fpData && fpData->outputFormats != NULL) {
int32 i;
for (i = 0; fpData->outputFormats[i].type; i++);
*out_count = i;
return fpData->outputFormats;
} else {
*out_count = 0;
if (_count == NULL || fData.output_formats == NULL)
return NULL;
int32 count = 0;
while (fData.output_formats[count].type) {
count++;
}
*_count = count;
return fData.output_formats;
}
// ---------------------------------------------------------------
// Identify
//
// If the translator understands how to convert the data contained
// in inSource to media type outType, it fills outInfo with
// details about the input format and return B_OK. If it doesn't
// know how to translate the data, it returns B_NO_TRANSLATOR.
//
// The actual work for this function is done by the translator
// add-on at the other end of the Identify function pointer.
// So, there's no telling the actual behavior of this function
// it depends on the translator add-on.
//
// Preconditions:
//
// Parameters: inSource, the data that wants to be converted
// inFormat, (can be null) hint about the data in
// inSource
// ioExtension, (can be null) contains additional
// information for the translator
// add-on
// outInfo, information about the capabilities
// of this translator
// outType, the output type
//
//
// Postconditions:
//
// Returns: B_OK if this translator can handle the data,
// B_ERROR, if fpData is unallocated or something else
// went wrong
// B_NO_TRANSLATOR if it can't
// ---------------------------------------------------------------
status_t BFuncTranslator::Identify(BPositionIO *inSource,
const translation_format *inFormat, BMessage *ioExtension,
translator_info *outInfo, uint32 outType)
status_t
BFuncTranslator::Identify(BPositionIO* source, const translation_format* format,
BMessage* ioExtension, translator_info* info, uint32 type)
{
if (fpData && fpData->Identify)
return fpData->Identify(inSource, inFormat, ioExtension, outInfo,
outType);
else
if (fData.identify_hook == NULL)
return B_ERROR;
return fData.identify_hook(source, format, ioExtension, info, type);
}
// ---------------------------------------------------------------
// Translate
//
// The translator translates data from inSource to format outType,
// writing the output to outDestination.
//
// The actual work for this function is done by the translator
// add-on at the other end of the Translate function pointer.
// So, there's no telling the actual behavior of this function
// it depends on the translator add-on.
//
// Preconditions:
//
// Parameters: inSource, data to be translated
// inInfo, hint about the data in inSource
// ioExtension, contains configuration information
// outType, the format to translate the data to
// outDestination, where the source is translated to
//
// Postconditions:
//
// Returns: B_OK, if it converted the data
// B_NO_TRANSLATOR, if it couldn't
// B_ERROR, if fpData is unallocated or something else
// went wrong
// some other value, if it feels like it
// ---------------------------------------------------------------
status_t BFuncTranslator::Translate(BPositionIO *inSource,
const translator_info *inInfo, BMessage *ioExtension, uint32 outType,
BPositionIO *outDestination)
status_t
BFuncTranslator::Translate(BPositionIO* source, const translator_info *info,
BMessage* ioExtension, uint32 type, BPositionIO* destination)
{
if (fpData && fpData->Translate)
return fpData->Translate(inSource, inInfo, ioExtension, outType,
outDestination);
else
if (fData.translate_hook == NULL)
return B_ERROR;
return fData.translate_hook(source, info, ioExtension, type, destination);
}
// ---------------------------------------------------------------
// MakeConfigurationView
//
// This creates a BView object that allows the user to configure
// the options for the translator. Not all translators support
// this feature, and for those that don't, this function
// returns B_NO_TRANSLATOR.
//
// Preconditions:
//
// Parameters: ioExtension, the settings for the translator
// outView, the view created by the translator
// outExtent, the bounds of the view
//
// Postconditions:
//
// Returns: B_ERROR, if this function is not supported
// anything else, whatever the translator feels like
// returning
// ---------------------------------------------------------------
status_t BFuncTranslator::MakeConfigurationView(BMessage *ioExtension,
BView **outView, BRect *outExtent)
status_t
BFuncTranslator::MakeConfigurationView(BMessage* ioExtension,
BView** _view, BRect* _extent)
{
if (fpData && fpData->MakeConfig)
return fpData->MakeConfig(ioExtension, outView, outExtent);
else
if (fData.make_config_hook == NULL)
return B_ERROR;
return fData.make_config_hook(ioExtension, _view, _extent);
}
// ---------------------------------------------------------------
// GetConfigurationMessage
//
// This function stores the current configuration for the
// translator into ioExtension. Not all translators
// support this function.
//
// Preconditions:
//
// Parameters: ioExtension, where the configuration is stored
//
// Postconditions:
//
// Returns: B_ERROR, if function is not supported
// something else, if it is
// ---------------------------------------------------------------
status_t BFuncTranslator::GetConfigurationMessage(BMessage *ioExtension)
status_t
BFuncTranslator::GetConfigurationMessage(BMessage* ioExtension)
{
if (fpData && fpData->GetConfigMessage)
return fpData->GetConfigMessage(ioExtension);
else
return B_ERROR;
if (fData.get_config_message_hook == NULL)
return B_ERROR;
return fData.get_config_message_hook(ioExtension);
}
} // namespace BPrivate

View File

@ -0,0 +1,69 @@
/*
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Michael Wilber
* Axel Dörfler, axeld@pinc-software.de
*/
#ifndef _FUNC_TRANSLATOR_H
#define _FUNC_TRANSLATOR_H
#include <Translator.h>
// Structure used to hold the collection of function pointers and
// public variables exported by function based translator add-ons.
struct translator_data {
const char* name;
const char* info;
int32 version;
const translation_format* input_formats;
const translation_format* output_formats;
status_t (*identify_hook)(BPositionIO* source, const translation_format* format,
BMessage* ioExtension, translator_info* outInfo, uint32 outType);
status_t (*translate_hook)(BPositionIO* source, const translator_info* info,
BMessage* ioExtension, uint32 outType, BPositionIO* destination);
status_t (*make_config_hook)(BMessage* ioExtension, BView** _view, BRect* _extent);
status_t (*get_config_message_hook)(BMessage* ioExtension);
};
namespace BPrivate {
class BFuncTranslator : public BTranslator {
public:
BFuncTranslator(const translator_data& data);
virtual const char *TranslatorName() const;
virtual const char *TranslatorInfo() const;
virtual int32 TranslatorVersion() const;
virtual const translation_format *InputFormats(int32 *out_count) const;
virtual const translation_format *OutputFormats(int32 *out_count) const;
virtual status_t Identify(BPositionIO *inSource,
const translation_format *inFormat, BMessage *ioExtension,
translator_info *outInfo, uint32 outType);
virtual status_t Translate(BPositionIO *inSource,
const translator_info *inInfo, BMessage *ioExtension, uint32 outType,
BPositionIO * outDestination);
virtual status_t MakeConfigurationView(BMessage *ioExtension,
BView **outView, BRect *outExtent);
virtual status_t GetConfigurationMessage(BMessage *ioExtension);
protected:
virtual ~BFuncTranslator();
// This object is deleted by calling Release(),
// it can not be deleted directly. See BTranslator in the Be Book
private:
translator_data fData;
};
} // namespace BPrivate
#endif // _FUNC_TRANSLATOR_H

View File

@ -15,8 +15,8 @@ SharedLibrary libtranslation.so :
TranslationUtils.cpp
Translator.cpp
TranslatorRoster.cpp
:
be
: be
;
Package haiku-translationkit-cvs :

View File

@ -1,356 +1,101 @@
/*****************************************************************************/
// File: Translator.cpp
// Class: BTranslator
// Reimplemented by: Michael Wilber, Translation Kit Team
// Reimplementation: 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.
/*****************************************************************************/
/*
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Michael Wilber
* Axel Dörfler, axeld@pinc-software.de
*/
#include "TranslatorRosterPrivate.h"
#include <Translator.h>
// Set refcount to 1
// ---------------------------------------------------------------
// Constructor
//
// Sets refcount to 1 and creates a semaphore for locking the
// object.
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns:
// ---------------------------------------------------------------
BTranslator::BTranslator()
:
fOwningRoster(NULL),
fID(0),
fRefCount(1)
{
fRefCount = 1;
fSem = create_sem(1, "BTranslator Lock");
}
// ---------------------------------------------------------------
// Destructor
//
// Deletes the semaphore and resets it.
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns:
// ---------------------------------------------------------------
BTranslator::~BTranslator()
{
delete_sem(fSem);
fSem = 0;
if (fOwningRoster != NULL)
fOwningRoster->TranslatorDeleted(fID);
}
// ---------------------------------------------------------------
// Acquire
//
// Increments the refcount and returns a pointer to this object.
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns: NULL, if failed to acquire the sempaphore
// pointer to this object if successful
// ---------------------------------------------------------------
/*!
Increments the refcount and returns a pointer to this object.
*/
BTranslator *BTranslator::Acquire()
{
if (fSem > 0 && acquire_sem(fSem) == B_OK) {
fRefCount++;
release_sem(fSem);
if (atomic_add(&fRefCount, 1) > 0)
return this;
} else
return NULL;
return NULL;
}
// ---------------------------------------------------------------
// Release
//
// Decrements the refcount and returns a pointer to this object.
// When the refcount hits zero, the object is destroyed. This is
// so multiple objects can own the BTranslator and it won't get
// deleted until all of them are done with it.
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns: NULL, if failed to acquire the sempaphore or the
// object was just deleted
// pointer to this object if successful
// ---------------------------------------------------------------
/*!
Decrements the refcount and returns a pointer to this object.
When the refcount hits zero, the object is destroyed. This is
so multiple objects can own the BTranslator and it won't get
deleted until all of them are done with it.
\return NULL, if the object was just deleted
*/
BTranslator *BTranslator::Release()
{
if (fSem > 0 && acquire_sem(fSem) == B_OK) {
fRefCount--;
if (fRefCount > 0) {
release_sem(fSem);
return this;
} else {
delete this;
return NULL;
}
} else
return NULL;
int32 oldValue = atomic_add(&fRefCount, -1);
if (oldValue > 0)
return this;
delete this;
return NULL;
}
// ---------------------------------------------------------------
// ReferenceCount
//
// This function returns the current
// refcount. Notice that it is not thread safe.
// This function is only meant for fun/debugging.
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns: the current refcount
// ---------------------------------------------------------------
int32 BTranslator::ReferenceCount()
int32
BTranslator::ReferenceCount()
{
return fRefCount;
}
// ---------------------------------------------------------------
// MakeConfigurationView
//
// This virtual function is for creating a configuration view
// for the translator so the user can change its settings. This
// base class version does nothing. Not all BTranslator derived
// object are required to support this function.
//
// Preconditions:
//
// Parameters: ioExtension, configuration data for the translator
// outView, where the created view is stored
// outText, the bounds of the view are stored here
//
// Postconditions:
//
// Returns: B_ERROR
// ---------------------------------------------------------------
status_t BTranslator::MakeConfigurationView(BMessage *ioExtension,
BView **outView, BRect *outExtent)
/*!
This virtual function is for creating a configuration view
for the translator so the user can change its settings.
This method is optional.
*/
status_t
BTranslator::MakeConfigurationView(BMessage* ioExtension,
BView** outView, BRect* outExtent)
{
return B_ERROR;
}
// ---------------------------------------------------------------
// GetConfigurationMessage
//
// Puts the current configuration for the translator into
// ioExtension. Not all translators are required to support
// this function
//
// Preconditions:
//
// Parameters: ioExtension, where the configuration data is stored
//
// Postconditions:
//
// Returns: B_ERROR
// ---------------------------------------------------------------
status_t BTranslator::GetConfigurationMessage(BMessage *ioExtension)
/*!
Puts the current configuration for the translator into
ioExtension. This method is optional.
*/
status_t
BTranslator::GetConfigurationMessage(BMessage* ioExtension)
{
return B_ERROR;
}
// ---------------------------------------------------------------
// _Reserved_Translator_0
//
// It does nothing! :) Its only here for past/future binary
// compatiblity.
//
// Preconditions:
//
// Parameters: n, not used
// p, not used
//
// Postconditions:
//
// Returns: B_ERROR
// ---------------------------------------------------------------
status_t BTranslator::_Reserved_Translator_0(int32 n, void *p)
{
return B_ERROR;
}
// ---------------------------------------------------------------
// _Reserved_Translator_1
//
// It does nothing! :) Its only here for past/future binary
// compatiblity.
//
// Preconditions:
//
// Parameters: n, not used
// p, not used
//
// Postconditions:
//
// Returns: B_ERROR
// ---------------------------------------------------------------
status_t BTranslator::_Reserved_Translator_1(int32 n, void *p)
{
return B_ERROR;
}
// ---------------------------------------------------------------
// _Reserved_Translator_2
//
// It does nothing! :) Its only here for past/future binary
// compatiblity.
//
// Preconditions:
//
// Parameters: n, not used
// p, not used
//
// Postconditions:
//
// Returns: B_ERROR
// ---------------------------------------------------------------
status_t BTranslator::_Reserved_Translator_2(int32 n, void *p)
{
return B_ERROR;
}
// ---------------------------------------------------------------
// _Reserved_Translator_3
//
// It does nothing! :) Its only here for past/future binary
// compatiblity.
//
// Preconditions:
//
// Parameters: n, not used
// p, not used
//
// Postconditions:
//
// Returns: B_ERROR
// ---------------------------------------------------------------
status_t BTranslator::_Reserved_Translator_3(int32 n, void *p)
{
return B_ERROR;
}
// ---------------------------------------------------------------
// _Reserved_Translator_4
//
// It does nothing! :) Its only here for past/future binary
// compatiblity.
//
// Preconditions:
//
// Parameters: n, not used
// p, not used
//
// Postconditions:
//
// Returns: B_ERROR
// ---------------------------------------------------------------
status_t BTranslator::_Reserved_Translator_4(int32 n, void *p)
{
return B_ERROR;
}
// ---------------------------------------------------------------
// _Reserved_Translator_5
//
// It does nothing! :) Its only here for past/future binary
// compatiblity.
//
// Preconditions:
//
// Parameters: n, not used
// p, not used
//
// Postconditions:
//
// Returns: B_ERROR
// ---------------------------------------------------------------
status_t BTranslator::_Reserved_Translator_5(int32 n, void *p)
{
return B_ERROR;
}
// ---------------------------------------------------------------
// _Reserved_Translator_6
//
// It does nothing! :) Its only here for past/future binary
// compatiblity.
//
// Preconditions:
//
// Parameters: n, not used
// p, not used
//
// Postconditions:
//
// Returns: B_ERROR
// ---------------------------------------------------------------
status_t BTranslator::_Reserved_Translator_6(int32 n, void *p)
{
return B_ERROR;
}
// ---------------------------------------------------------------
// _Reserved_Translator_7
//
// It does nothing! :) Its only here for past/future binary
// compatiblity.
//
// Preconditions:
//
// Parameters: n, not used
// p, not used
//
// Postconditions:
//
// Returns: B_ERROR
// ---------------------------------------------------------------
status_t BTranslator::_Reserved_Translator_7(int32 n, void *p)
{
return B_ERROR;
}
status_t BTranslator::_Reserved_Translator_0(int32 n, void *p) { return B_ERROR; }
status_t BTranslator::_Reserved_Translator_1(int32 n, void *p) { return B_ERROR; }
status_t BTranslator::_Reserved_Translator_2(int32 n, void *p) { return B_ERROR; }
status_t BTranslator::_Reserved_Translator_3(int32 n, void *p) { return B_ERROR; }
status_t BTranslator::_Reserved_Translator_4(int32 n, void *p) { return B_ERROR; }
status_t BTranslator::_Reserved_Translator_5(int32 n, void *p) { return B_ERROR; }
status_t BTranslator::_Reserved_Translator_6(int32 n, void *p) { return B_ERROR; }
status_t BTranslator::_Reserved_Translator_7(int32 n, void *p) { return B_ERROR; }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,82 @@
/*
* Copyright 2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Author:
* Axel Dörfler, axeld@pinc-software.de
*/
#ifndef TRANSLATOR_ROSTER_PRIVATE_H
#define TRANSLATOR_ROSTER_PRIVATE_H
#include <Entry.h>
#include <Handler.h>
#include <Locker.h>
#include <Messenger.h>
#include <TranslatorRoster.h>
#include <map>
#include <vector>
struct translator_data;
struct translator_item {
BTranslator* translator;
entry_ref ref;
image_id image;
};
typedef std::map<translator_id, translator_item> TranslatorMap;
typedef std::vector<BMessenger> MessengerList;
class BTranslatorRoster::Private : public BHandler, public BLocker {
public:
Private();
virtual ~Private();
virtual void MessageReceived(BMessage* message);
void AddDefaultPaths();
status_t AddPaths(const char* paths);
status_t AddPath(const char* path, int32* _added = NULL);
status_t AddTranslator(BTranslator* translator, image_id image = -1,
const entry_ref* ref = NULL);
BTranslator* FindTranslator(translator_id id);
status_t StoreTranslators(BMessage& archive);
status_t Identify(BPositionIO* source, BMessage* ioExtension,
uint32 hintType, const char* hintMIME, uint32 wantType,
translator_info* _info);
status_t GetTranslators(BPositionIO* source, BMessage* ioExtension,
uint32 hintType, const char* hintMIME, uint32 wantType,
translator_info** _info, int32* _numInfo);
status_t GetAllTranslators(translator_id** _ids, int32* _count);
status_t GetRefFor(translator_id id, entry_ref& ref);
bool IsActive() const { return Looper(); }
status_t CreateTranslators(const entry_ref& ref, int32& count);
status_t GetTranslatorData(image_id image, translator_data& data);
status_t StartWatching(BMessenger target);
status_t StopWatching(BMessenger target);
void TranslatorDeleted(translator_id id);
private:
static int _CompareSupport(const void* _a, const void* _b);
const translation_format* _CheckHints(const translation_format* formats,
int32 formatsCount, uint32 hintType, const char* hintMIME);
const translator_item* _FindTranslator(translator_id id) const;
const translator_item* _FindTranslator(const char* name) const;
TranslatorMap fTranslators;
MessengerList fMessengers;
int32 fNextID;
};
#endif // TRANSLATOR_ROSTER_PRIVATE_H