Style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30855 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -5,10 +5,10 @@
|
|||||||
#ifndef _TRANSLATOR_ROSTER_H
|
#ifndef _TRANSLATOR_ROSTER_H
|
||||||
#define _TRANSLATOR_ROSTER_H
|
#define _TRANSLATOR_ROSTER_H
|
||||||
|
|
||||||
|
|
||||||
#include <Archivable.h>
|
#include <Archivable.h>
|
||||||
#include <TranslationDefs.h>
|
#include <TranslationDefs.h>
|
||||||
|
|
||||||
|
|
||||||
struct translation_format;
|
struct translation_format;
|
||||||
|
|
||||||
class BBitmap;
|
class BBitmap;
|
||||||
@@ -23,12 +23,12 @@ struct entry_ref;
|
|||||||
|
|
||||||
|
|
||||||
class BTranslatorRoster : public BArchivable {
|
class BTranslatorRoster : public BArchivable {
|
||||||
public:
|
public:
|
||||||
BTranslatorRoster();
|
BTranslatorRoster();
|
||||||
BTranslatorRoster(BMessage* model);
|
BTranslatorRoster(BMessage* model);
|
||||||
virtual ~BTranslatorRoster();
|
virtual ~BTranslatorRoster();
|
||||||
|
|
||||||
static BTranslatorRoster *Default();
|
static BTranslatorRoster* Default();
|
||||||
|
|
||||||
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
||||||
static BArchivable* Instantiate(BMessage* from);
|
static BArchivable* Instantiate(BMessage* from);
|
||||||
@@ -36,43 +36,57 @@ class BTranslatorRoster : public BArchivable {
|
|||||||
status_t AddTranslators(const char* loadPath = NULL);
|
status_t AddTranslators(const char* loadPath = NULL);
|
||||||
status_t AddTranslator(BTranslator* translator);
|
status_t AddTranslator(BTranslator* translator);
|
||||||
|
|
||||||
virtual status_t Identify(BPositionIO* source, BMessage* ioExtension,
|
virtual status_t Identify(BPositionIO* source,
|
||||||
|
BMessage* ioExtension,
|
||||||
translator_info* _info, uint32 hintType = 0,
|
translator_info* _info, uint32 hintType = 0,
|
||||||
const char* hintMIME = NULL, uint32 wantType = 0);
|
const char* hintMIME = NULL,
|
||||||
|
uint32 wantType = 0);
|
||||||
|
|
||||||
virtual status_t GetTranslators(BPositionIO* source,
|
virtual status_t GetTranslators(BPositionIO* source,
|
||||||
BMessage* ioExtension, translator_info** _info, int32* _numInfo,
|
BMessage* ioExtension,
|
||||||
uint32 hintType = 0, const char* hintMIME = NULL,
|
translator_info** _info, int32* _numInfo,
|
||||||
|
uint32 hintType = 0,
|
||||||
|
const char* hintMIME = NULL,
|
||||||
uint32 wantType = 0);
|
uint32 wantType = 0);
|
||||||
|
|
||||||
virtual status_t GetAllTranslators(translator_id** _list,
|
virtual status_t GetAllTranslators(translator_id** _list,
|
||||||
int32* _count);
|
int32* _count);
|
||||||
|
|
||||||
virtual status_t GetTranslatorInfo(translator_id translatorID,
|
virtual status_t GetTranslatorInfo(translator_id translatorID,
|
||||||
const char** _name, const char** _info, int32* _version);
|
const char** _name, const char** _info,
|
||||||
|
int32* _version);
|
||||||
|
|
||||||
virtual status_t GetInputFormats(translator_id translatorID,
|
virtual status_t GetInputFormats(translator_id translatorID,
|
||||||
const translation_format** _formats, int32* _numFormats);
|
const translation_format** _formats,
|
||||||
|
int32* _numFormats);
|
||||||
|
|
||||||
virtual status_t GetOutputFormats(translator_id translatorID,
|
virtual status_t GetOutputFormats(translator_id translatorID,
|
||||||
const translation_format** _formats, int32* _numFormats);
|
const translation_format** _formats,
|
||||||
|
int32* _numFormats);
|
||||||
|
|
||||||
virtual status_t Translate(BPositionIO* source,
|
virtual status_t Translate(BPositionIO* source,
|
||||||
const translator_info* info, BMessage* ioExtension,
|
const translator_info* info,
|
||||||
BPositionIO* destination, uint32 wantOutType,
|
BMessage* ioExtension,
|
||||||
uint32 hintType = 0, const char* hintMIME = NULL);
|
BPositionIO* destination,
|
||||||
|
uint32 wantOutType, uint32 hintType = 0,
|
||||||
|
const char* hintMIME = NULL);
|
||||||
|
|
||||||
virtual status_t Translate(translator_id translatorID,
|
virtual status_t Translate(translator_id translatorID,
|
||||||
BPositionIO* source, BMessage* ioExtension,
|
BPositionIO* source, BMessage* ioExtension,
|
||||||
BPositionIO* destination, uint32 wantOutType);
|
BPositionIO* destination,
|
||||||
|
uint32 wantOutType);
|
||||||
|
|
||||||
virtual status_t MakeConfigurationView(translator_id translatorID,
|
virtual status_t MakeConfigurationView(
|
||||||
BMessage* ioExtension, BView** _view, BRect* _extent);
|
translator_id translatorID,
|
||||||
|
BMessage* ioExtension, BView** _view,
|
||||||
|
BRect* _extent);
|
||||||
|
|
||||||
virtual status_t GetConfigurationMessage(translator_id translatorID,
|
virtual status_t GetConfigurationMessage(
|
||||||
|
translator_id translatorID,
|
||||||
BMessage* ioExtension);
|
BMessage* ioExtension);
|
||||||
|
|
||||||
status_t GetRefFor(translator_id translatorID, entry_ref* ref);
|
status_t GetRefFor(translator_id translatorID,
|
||||||
|
entry_ref* ref);
|
||||||
bool IsTranslator(entry_ref* ref);
|
bool IsTranslator(entry_ref* ref);
|
||||||
|
|
||||||
status_t StartWatching(BMessenger target);
|
status_t StartWatching(BMessenger target);
|
||||||
@@ -80,9 +94,10 @@ class BTranslatorRoster : public BArchivable {
|
|||||||
|
|
||||||
class Private;
|
class Private;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// unimplemented
|
// unimplemented
|
||||||
BTranslatorRoster(const BTranslatorRoster& other);
|
BTranslatorRoster(
|
||||||
|
const BTranslatorRoster& other);
|
||||||
BTranslatorRoster& operator=(const BTranslatorRoster& other);
|
BTranslatorRoster& operator=(const BTranslatorRoster& other);
|
||||||
|
|
||||||
virtual void ReservedTranslatorRoster1();
|
virtual void ReservedTranslatorRoster1();
|
||||||
@@ -94,11 +109,12 @@ class BTranslatorRoster : public BArchivable {
|
|||||||
|
|
||||||
void _Initialize();
|
void _Initialize();
|
||||||
|
|
||||||
static const char* Version(int32* outCurVersion, int32* outMinVersion,
|
static const char* Version(int32* outCurVersion,
|
||||||
|
int32* outMinVersion,
|
||||||
int32 inAppVersion);
|
int32 inAppVersion);
|
||||||
// for backward compatiblity only
|
// for backward compatiblity only
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Private;
|
friend class Private;
|
||||||
|
|
||||||
Private* fPrivate;
|
Private* fPrivate;
|
||||||
|
|||||||
@@ -13,13 +13,12 @@
|
|||||||
object with the translators that the apps need to access.
|
object with the translators that the apps need to access.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <TranslatorRoster.h>
|
||||||
|
|
||||||
#include "FuncTranslator.h"
|
#include <new>
|
||||||
#include "TranslatorRosterPrivate.h"
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <driver_settings.h>
|
#include <stdlib.h>
|
||||||
#include <image.h>
|
|
||||||
#include <safemode_defs.h>
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
@@ -28,23 +27,26 @@
|
|||||||
#include <NodeMonitor.h>
|
#include <NodeMonitor.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <TranslatorRoster.h>
|
|
||||||
|
|
||||||
#include <new>
|
#include <driver_settings.h>
|
||||||
#include <string.h>
|
#include <image.h>
|
||||||
#include <stdio.h>
|
#include <safemode_defs.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
#include "FuncTranslator.h"
|
||||||
|
#include "TranslatorRosterPrivate.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
extern "C" status_t _kern_get_safemode_option(const char *parameter,
|
extern "C" status_t _kern_get_safemode_option(const char* parameter,
|
||||||
char *buffer, size_t *_bufferSize);
|
char* buffer, size_t* _bufferSize);
|
||||||
#else
|
#else
|
||||||
extern "C" status_t _kget_safemode_option_(const char *parameter,
|
extern "C" status_t _kget_safemode_option_(const char* parameter,
|
||||||
char *buffer, size_t *_bufferSize);
|
char* buffer, size_t* _bufferSize);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if !defined(HAIKU_TARGET_PLATFORM_HAIKU) && !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
|
#if !defined(HAIKU_TARGET_PLATFORM_HAIKU) \
|
||||||
|
&& !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
|
||||||
// building under R5 or Dano/Zeta
|
// building under R5 or Dano/Zeta
|
||||||
enum {
|
enum {
|
||||||
B_TRANSLATOR_ADDED = '_ART',
|
B_TRANSLATOR_ADDED = '_ART',
|
||||||
@@ -55,14 +57,15 @@ enum {
|
|||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
class QuarantineTranslatorImage {
|
class QuarantineTranslatorImage {
|
||||||
public:
|
public:
|
||||||
QuarantineTranslatorImage(BTranslatorRoster::Private& privateRoster);
|
QuarantineTranslatorImage(
|
||||||
|
BTranslatorRoster::Private& privateRoster);
|
||||||
~QuarantineTranslatorImage();
|
~QuarantineTranslatorImage();
|
||||||
|
|
||||||
void Put(const entry_ref& ref);
|
void Put(const entry_ref& ref);
|
||||||
void Remove();
|
void Remove();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BTranslatorRoster::Private& fRoster;
|
BTranslatorRoster::Private& fRoster;
|
||||||
entry_ref fRef;
|
entry_ref fRef;
|
||||||
bool fRemove;
|
bool fRemove;
|
||||||
@@ -91,14 +94,16 @@ namespace BPrivate {
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
The purpose of this class is to put a translator entry_ref into - and remove
|
The purpose of this class is to put a translator entry_ref into - and remove
|
||||||
it from the list of translators on destruction (if Remove() was called before).
|
it from the list of translators on destruction (if Remove() was called
|
||||||
|
before).
|
||||||
|
|
||||||
This is used in Private::CreateTranslators() in case a translator hides a
|
This is used in Private::CreateTranslators() in case a translator hides a
|
||||||
previous one (ie. if you install a translator in the user's translators directory
|
previous one (ie. if you install a translator in the user's translators
|
||||||
that has the same name as one in the system's directory, it will hide this
|
directory that has the same name as one in the system's directory, it will
|
||||||
entry).
|
hide this entry).
|
||||||
*/
|
*/
|
||||||
QuarantineTranslatorImage::QuarantineTranslatorImage(BTranslatorRoster::Private& privateRoster)
|
QuarantineTranslatorImage::QuarantineTranslatorImage(
|
||||||
|
BTranslatorRoster::Private& privateRoster)
|
||||||
:
|
:
|
||||||
fRoster(privateRoster),
|
fRoster(privateRoster),
|
||||||
fRemove(false)
|
fRemove(false)
|
||||||
@@ -135,7 +140,8 @@ QuarantineTranslatorImage::Remove()
|
|||||||
|
|
||||||
|
|
||||||
BTranslatorRoster::Private::Private()
|
BTranslatorRoster::Private::Private()
|
||||||
: BHandler("translator roster"), BLocker("translator list"),
|
:
|
||||||
|
BHandler("translator roster"), BLocker("translator list"),
|
||||||
fNextID(1),
|
fNextID(1),
|
||||||
fLazyScanning(true),
|
fLazyScanning(true),
|
||||||
fSafeMode(false)
|
fSafeMode(false)
|
||||||
@@ -145,9 +151,11 @@ BTranslatorRoster::Private::Private()
|
|||||||
size_t parameterLength = sizeof(parameter);
|
size_t parameterLength = sizeof(parameter);
|
||||||
|
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
if (_kern_get_safemode_option(B_SAFEMODE_SAFE_MODE, parameter, ¶meterLength) == B_OK)
|
if (_kern_get_safemode_option(B_SAFEMODE_SAFE_MODE, parameter,
|
||||||
|
¶meterLength) == B_OK)
|
||||||
#else
|
#else
|
||||||
if (_kget_safemode_option_(B_SAFEMODE_SAFE_MODE, parameter, ¶meterLength) == B_OK)
|
if (_kget_safemode_option_(B_SAFEMODE_SAFE_MODE, parameter,
|
||||||
|
¶meterLength) == B_OK)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on")
|
if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on")
|
||||||
@@ -157,9 +165,11 @@ BTranslatorRoster::Private::Private()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
if (_kern_get_safemode_option(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter, ¶meterLength) == B_OK)
|
if (_kern_get_safemode_option(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter,
|
||||||
|
¶meterLength) == B_OK)
|
||||||
#else
|
#else
|
||||||
if (_kget_safemode_option_(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter, ¶meterLength) == B_OK)
|
if (_kget_safemode_option_(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter,
|
||||||
|
¶meterLength) == B_OK)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on")
|
if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on")
|
||||||
@@ -235,13 +245,15 @@ BTranslatorRoster::Private::MessageReceived(BMessage* message)
|
|||||||
const char* name;
|
const char* name;
|
||||||
node_ref nodeRef;
|
node_ref nodeRef;
|
||||||
if (message->FindInt32("device", &nodeRef.device) != B_OK
|
if (message->FindInt32("device", &nodeRef.device) != B_OK
|
||||||
|| message->FindInt64("directory", &nodeRef.node) != B_OK
|
|| message->FindInt64("directory", &nodeRef.node)
|
||||||
|
!= B_OK
|
||||||
|| message->FindString("name", &name) != B_OK)
|
|| message->FindString("name", &name) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// TODO: make this better (possible under Haiku)
|
// TODO: make this better (possible under Haiku)
|
||||||
snooze(100000);
|
snooze(100000);
|
||||||
// let the font be written completely before trying to open it
|
// let the font be written completely before trying to
|
||||||
|
// open it
|
||||||
|
|
||||||
_EntryAdded(nodeRef, name);
|
_EntryAdded(nodeRef, name);
|
||||||
break;
|
break;
|
||||||
@@ -249,17 +261,20 @@ BTranslatorRoster::Private::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case B_ENTRY_MOVED:
|
case B_ENTRY_MOVED:
|
||||||
{
|
{
|
||||||
// has the entry been moved into a monitored directory or has
|
// has the entry been moved into a monitored directory or
|
||||||
// it been removed from one?
|
// has it been removed from one?
|
||||||
const char* name;
|
const char* name;
|
||||||
node_ref toNodeRef;
|
node_ref toNodeRef;
|
||||||
node_ref fromNodeRef;
|
node_ref fromNodeRef;
|
||||||
node_ref nodeRef;
|
node_ref nodeRef;
|
||||||
|
|
||||||
if (message->FindInt32("device", &nodeRef.device) != B_OK
|
if (message->FindInt32("device", &nodeRef.device) != B_OK
|
||||||
|| message->FindInt64("to directory", &toNodeRef.node) != B_OK
|
|| message->FindInt64("to directory", &toNodeRef.node)
|
||||||
|| message->FindInt64("from directory", (int64 *)&fromNodeRef.node) != B_OK
|
!= B_OK
|
||||||
|| message->FindInt64("node", (int64 *)&nodeRef.node) != B_OK
|
|| message->FindInt64("from directory",
|
||||||
|
(int64*)&fromNodeRef.node) != B_OK
|
||||||
|
|| message->FindInt64("node", (int64*)&nodeRef.node)
|
||||||
|
!= B_OK
|
||||||
|| message->FindString("name", &name) != B_OK)
|
|| message->FindString("name", &name) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -287,8 +302,8 @@ BTranslatorRoster::Private::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
if (_IsKnownDirectory(fromNodeRef)
|
if (_IsKnownDirectory(fromNodeRef)
|
||||||
&& _IsKnownDirectory(toNodeRef)) {
|
&& _IsKnownDirectory(toNodeRef)) {
|
||||||
// TODO: we should rescan for the name, there might be name
|
// TODO: we should rescan for the name, there might be
|
||||||
// clashes with translators in other directories
|
// name clashes with translators in other directories
|
||||||
// (as well as old ones revealed)
|
// (as well as old ones revealed)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -300,7 +315,8 @@ BTranslatorRoster::Private::MessageReceived(BMessage* message)
|
|||||||
node_ref nodeRef;
|
node_ref nodeRef;
|
||||||
uint64 directoryNode;
|
uint64 directoryNode;
|
||||||
if (message->FindInt32("device", &nodeRef.device) != B_OK
|
if (message->FindInt32("device", &nodeRef.device) != B_OK
|
||||||
|| message->FindInt64("directory", (int64 *)&directoryNode) != B_OK
|
|| message->FindInt64("directory",
|
||||||
|
(int64*)&directoryNode) != B_OK
|
||||||
|| message->FindInt64("node", &nodeRef.node) != B_OK)
|
|| message->FindInt64("node", &nodeRef.node) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -330,7 +346,8 @@ BTranslatorRoster::Private::AddDefaultPaths()
|
|||||||
B_BEOS_ADDONS_DIRECTORY,
|
B_BEOS_ADDONS_DIRECTORY,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (uint32 i = fSafeMode ? 1 : 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
|
for (uint32 i = fSafeMode ? 1 : 0; i < sizeof(paths) / sizeof(paths[0]);
|
||||||
|
i++) {
|
||||||
BPath path;
|
BPath path;
|
||||||
status_t status = find_directory(paths[i], &path, true);
|
status_t status = find_directory(paths[i], &path, true);
|
||||||
if (status == B_OK && path.Append("Translators") == B_OK) {
|
if (status == B_OK && path.Append("Translators") == B_OK) {
|
||||||
@@ -487,7 +504,8 @@ BTranslatorRoster::Private::FindTranslator(translator_id id)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BTranslatorRoster::Private::GetTranslatorData(image_id image, translator_data& data)
|
BTranslatorRoster::Private::GetTranslatorData(image_id image,
|
||||||
|
translator_data& data)
|
||||||
{
|
{
|
||||||
// If this is a translator add-on, it is in the C format
|
// If this is a translator add-on, it is in the C format
|
||||||
memset(&data, 0, sizeof(translator_data));
|
memset(&data, 0, sizeof(translator_data));
|
||||||
@@ -495,28 +513,38 @@ BTranslatorRoster::Private::GetTranslatorData(image_id image, translator_data& d
|
|||||||
// find all the symbols
|
// find all the symbols
|
||||||
|
|
||||||
int32* version;
|
int32* version;
|
||||||
if (get_image_symbol(image, "translatorName", B_SYMBOL_TYPE_DATA, (void**)&data.name) < B_OK
|
if (get_image_symbol(image, "translatorName", B_SYMBOL_TYPE_DATA,
|
||||||
|| get_image_symbol(image, "translatorInfo", B_SYMBOL_TYPE_DATA, (void**)&data.info) < B_OK
|
(void**)&data.name) < B_OK
|
||||||
|| get_image_symbol(image, "translatorVersion", B_SYMBOL_TYPE_DATA, (void**)&version) < B_OK || version == NULL
|
|| get_image_symbol(image, "translatorInfo", B_SYMBOL_TYPE_DATA,
|
||||||
|| get_image_symbol(image, "inputFormats", B_SYMBOL_TYPE_DATA, (void**)&data.input_formats) < B_OK
|
(void**)&data.info) < B_OK
|
||||||
|| get_image_symbol(image, "outputFormats", B_SYMBOL_TYPE_DATA, (void**)&data.output_formats) < B_OK
|
|| get_image_symbol(image, "translatorVersion", B_SYMBOL_TYPE_DATA,
|
||||||
|| get_image_symbol(image, "Identify", B_SYMBOL_TYPE_TEXT, (void**)&data.identify_hook) < B_OK
|
(void**)&version) < B_OK || version == NULL
|
||||||
|| get_image_symbol(image, "Translate", B_SYMBOL_TYPE_TEXT, (void**)&data.translate_hook) < B_OK)
|
|| get_image_symbol(image, "inputFormats", B_SYMBOL_TYPE_DATA,
|
||||||
|
(void**)&data.input_formats) < B_OK
|
||||||
|
|| get_image_symbol(image, "outputFormats", B_SYMBOL_TYPE_DATA,
|
||||||
|
(void**)&data.output_formats) < B_OK
|
||||||
|
|| get_image_symbol(image, "Identify", B_SYMBOL_TYPE_TEXT,
|
||||||
|
(void**)&data.identify_hook) < B_OK
|
||||||
|
|| get_image_symbol(image, "Translate", B_SYMBOL_TYPE_TEXT,
|
||||||
|
(void**)&data.translate_hook) < B_OK) {
|
||||||
return B_BAD_TYPE;
|
return B_BAD_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
data.version = *version;
|
data.version = *version;
|
||||||
|
|
||||||
// those calls are optional
|
// those calls are optional
|
||||||
get_image_symbol(image, "MakeConfig", B_SYMBOL_TYPE_TEXT, (void**)&data.make_config_hook);
|
get_image_symbol(image, "MakeConfig", B_SYMBOL_TYPE_TEXT,
|
||||||
get_image_symbol(image, "GetConfigMessage", B_SYMBOL_TYPE_TEXT, (void**)&data.get_config_message_hook);
|
(void**)&data.make_config_hook);
|
||||||
|
get_image_symbol(image, "GetConfigMessage", B_SYMBOL_TYPE_TEXT,
|
||||||
|
(void**)&data.get_config_message_hook);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BTranslatorRoster::Private::CreateTranslators(const entry_ref& ref, int32& count,
|
BTranslatorRoster::Private::CreateTranslators(const entry_ref& ref,
|
||||||
BMessage* update)
|
int32& count, BMessage* update)
|
||||||
{
|
{
|
||||||
BAutolock locker(this);
|
BAutolock locker(this);
|
||||||
|
|
||||||
@@ -556,7 +584,8 @@ BTranslatorRoster::Private::CreateTranslators(const entry_ref& ref, int32& count
|
|||||||
// until MakeNthTranslator stops returning them.
|
// until MakeNthTranslator stops returning them.
|
||||||
BTranslator* translator = NULL;
|
BTranslator* translator = NULL;
|
||||||
int32 created = 0;
|
int32 created = 0;
|
||||||
for (int32 n = 0; (translator = makeNthTranslator(n, image, 0)) != NULL; n++) {
|
for (int32 n = 0; (translator = makeNthTranslator(n, image, 0)) != NULL;
|
||||||
|
n++) {
|
||||||
if (AddTranslator(translator, image, &ref, nodeRef.node) == B_OK) {
|
if (AddTranslator(translator, image, &ref, nodeRef.node) == B_OK) {
|
||||||
if (update)
|
if (update)
|
||||||
update->AddInt32("translator_id", translator->fID);
|
update->AddInt32("translator_id", translator->fID);
|
||||||
@@ -582,7 +611,8 @@ BTranslatorRoster::Private::CreateTranslators(const entry_ref& ref, int32& count
|
|||||||
// add this translator to the list
|
// add this translator to the list
|
||||||
BPrivate::BFuncTranslator* translator = NULL;
|
BPrivate::BFuncTranslator* translator = NULL;
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
translator = new (std::nothrow) BPrivate::BFuncTranslator(translatorData);
|
translator = new (std::nothrow) BPrivate::BFuncTranslator(
|
||||||
|
translatorData);
|
||||||
if (translator == NULL)
|
if (translator == NULL)
|
||||||
status = B_NO_MEMORY;
|
status = B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
@@ -688,13 +718,15 @@ BTranslatorRoster::Private::Identify(BPositionIO* source,
|
|||||||
return pos < 0 ? (status_t)pos : B_IO_ERROR;
|
return pos < 0 ? (status_t)pos : B_IO_ERROR;
|
||||||
|
|
||||||
int32 formatsCount = 0;
|
int32 formatsCount = 0;
|
||||||
const translation_format* formats = translator.InputFormats(&formatsCount);
|
const translation_format* formats = translator.InputFormats(
|
||||||
const translation_format* format = _CheckHints(formats, formatsCount, hintType,
|
&formatsCount);
|
||||||
hintMIME);
|
const translation_format* format = _CheckHints(formats, formatsCount,
|
||||||
|
hintType, hintMIME);
|
||||||
|
|
||||||
BMessage extension(baseExtension);
|
BMessage extension(baseExtension);
|
||||||
translator_info info;
|
translator_info info;
|
||||||
if (translator.Identify(source, format, &extension, &info, wantType) == B_OK) {
|
if (translator.Identify(source, format, &extension, &info, wantType)
|
||||||
|
== B_OK) {
|
||||||
float weight = info.quality * info.capability;
|
float weight = info.quality * info.capability;
|
||||||
if (weight > bestWeight) {
|
if (weight > bestWeight) {
|
||||||
if (ioExtension != NULL)
|
if (ioExtension != NULL)
|
||||||
@@ -743,12 +775,14 @@ BTranslatorRoster::Private::GetTranslators(BPositionIO* source,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32 formatsCount = 0;
|
int32 formatsCount = 0;
|
||||||
const translation_format* formats = translator.InputFormats(&formatsCount);
|
const translation_format* formats = translator.InputFormats(
|
||||||
const translation_format* format = _CheckHints(formats, formatsCount, hintType,
|
&formatsCount);
|
||||||
hintMIME);
|
const translation_format* format = _CheckHints(formats, formatsCount,
|
||||||
|
hintType, hintMIME);
|
||||||
|
|
||||||
translator_info info;
|
translator_info info;
|
||||||
if (translator.Identify(source, format, ioExtension, &info, wantType) == B_OK) {
|
if (translator.Identify(source, format, ioExtension, &info, wantType)
|
||||||
|
== B_OK) {
|
||||||
info.translator = iterator->first;
|
info.translator = iterator->first;
|
||||||
array[count++] = info;
|
array[count++] = info;
|
||||||
}
|
}
|
||||||
@@ -758,7 +792,8 @@ BTranslatorRoster::Private::GetTranslators(BPositionIO* source,
|
|||||||
|
|
||||||
*_info = array;
|
*_info = array;
|
||||||
*_numInfo = count;
|
*_numInfo = count;
|
||||||
qsort(array, count, sizeof(translator_info), BTranslatorRoster::Private::_CompareSupport);
|
qsort(array, count, sizeof(translator_info),
|
||||||
|
BTranslatorRoster::Private::_CompareSupport);
|
||||||
// translators are sorted by best support
|
// translators are sorted by best support
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -766,7 +801,8 @@ BTranslatorRoster::Private::GetTranslators(BPositionIO* source,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BTranslatorRoster::Private::GetAllTranslators(translator_id** _ids, int32* _count)
|
BTranslatorRoster::Private::GetAllTranslators(translator_id** _ids,
|
||||||
|
int32* _count)
|
||||||
{
|
{
|
||||||
BAutolock locker(this);
|
BAutolock locker(this);
|
||||||
|
|
||||||
@@ -971,8 +1007,8 @@ BTranslatorRoster::Private::_FindTranslator(node_ref& nodeRef)
|
|||||||
chosen.
|
chosen.
|
||||||
*/
|
*/
|
||||||
int32
|
int32
|
||||||
BTranslatorRoster::Private::_CompareTranslatorDirectoryPriority(const entry_ref& a,
|
BTranslatorRoster::Private::_CompareTranslatorDirectoryPriority(
|
||||||
const entry_ref& b) const
|
const entry_ref& a, const entry_ref& b) const
|
||||||
{
|
{
|
||||||
// priority is determined by the order in the list
|
// priority is determined by the order in the list
|
||||||
|
|
||||||
@@ -1057,7 +1093,8 @@ BTranslatorRoster::Private::_RemoveTranslators(const node_ref* nodeRef,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BTranslatorRoster::Private::_EntryAdded(const node_ref& nodeRef, const char* name)
|
BTranslatorRoster::Private::_EntryAdded(const node_ref& nodeRef,
|
||||||
|
const char* name)
|
||||||
{
|
{
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
ref.device = nodeRef.device;
|
ref.device = nodeRef.device;
|
||||||
@@ -1123,7 +1160,8 @@ BTranslatorRoster::BTranslatorRoster(BMessage* model)
|
|||||||
|
|
||||||
if (model) {
|
if (model) {
|
||||||
const char* path;
|
const char* path;
|
||||||
for (int32 i = 0; model->FindString("be:translator_path", i, &path) == B_OK; i++) {
|
for (int32 i = 0;
|
||||||
|
model->FindString("be:translator_path", i, &path) == B_OK; i++) {
|
||||||
BEntry entry(path);
|
BEntry entry(path);
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
if (entry.GetRef(&ref) == B_OK) {
|
if (entry.GetRef(&ref) == B_OK) {
|
||||||
@@ -1165,7 +1203,7 @@ BTranslatorRoster::Archive(BMessage* into, bool deep) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BArchivable *
|
BArchivable*
|
||||||
BTranslatorRoster::Instantiate(BMessage* from)
|
BTranslatorRoster::Instantiate(BMessage* from)
|
||||||
{
|
{
|
||||||
if (!from || !validate_instantiation(from, "BTranslatorRoster"))
|
if (!from || !validate_instantiation(from, "BTranslatorRoster"))
|
||||||
@@ -1175,7 +1213,7 @@ BTranslatorRoster::Instantiate(BMessage* from)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BTranslatorRoster *
|
BTranslatorRoster*
|
||||||
BTranslatorRoster::Default()
|
BTranslatorRoster::Default()
|
||||||
{
|
{
|
||||||
static int32 lock = 0;
|
static int32 lock = 0;
|
||||||
@@ -1265,7 +1303,7 @@ BTranslatorRoster::IsTranslator(entry_ref* ref)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Function pointer used to create post R4.5 style translators
|
// Function pointer used to create post R4.5 style translators
|
||||||
BTranslator *(*makeNthTranslator)(int32 n, image_id you, uint32 flags, ...);
|
BTranslator* (*makeNthTranslator)(int32 n, image_id you, uint32 flags, ...);
|
||||||
|
|
||||||
status_t status = get_image_symbol(image, "make_nth_translator",
|
status_t status = get_image_symbol(image, "make_nth_translator",
|
||||||
B_SYMBOL_TYPE_TEXT, (void**)&makeNthTranslator);
|
B_SYMBOL_TYPE_TEXT, (void**)&makeNthTranslator);
|
||||||
@@ -1305,7 +1343,8 @@ BTranslatorRoster::Identify(BPositionIO* source, BMessage* ioExtension,
|
|||||||
if (source == NULL || _info == NULL)
|
if (source == NULL || _info == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
return fPrivate->Identify(source, ioExtension, hintType, hintMIME, wantType, _info);
|
return fPrivate->Identify(source, ioExtension, hintType, hintMIME, wantType,
|
||||||
|
_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1509,8 +1548,8 @@ BTranslatorRoster::Translate(BPositionIO* source, const translator_info* info,
|
|||||||
BTranslator* translator = fPrivate->FindTranslator(info->translator);
|
BTranslator* translator = fPrivate->FindTranslator(info->translator);
|
||||||
if (translator != NULL) {
|
if (translator != NULL) {
|
||||||
translator->Acquire();
|
translator->Acquire();
|
||||||
// make sure this translator is not removed while we're playing with it;
|
// make sure this translator is not removed while we're playing with
|
||||||
// translating shouldn't be serialized!
|
// it; translating shouldn't be serialized!
|
||||||
}
|
}
|
||||||
|
|
||||||
fPrivate->Unlock();
|
fPrivate->Unlock();
|
||||||
@@ -1561,8 +1600,8 @@ BTranslatorRoster::Translate(translator_id id, BPositionIO* source,
|
|||||||
BTranslator* translator = fPrivate->FindTranslator(id);
|
BTranslator* translator = fPrivate->FindTranslator(id);
|
||||||
if (translator != NULL) {
|
if (translator != NULL) {
|
||||||
translator->Acquire();
|
translator->Acquire();
|
||||||
// make sure this translator is not removed while we're playing with it;
|
// make sure this translator is not removed while we're playing with
|
||||||
// translating shouldn't be serialized!
|
// it; translating shouldn't be serialized!
|
||||||
}
|
}
|
||||||
|
|
||||||
fPrivate->Unlock();
|
fPrivate->Unlock();
|
||||||
@@ -1574,14 +1613,15 @@ BTranslatorRoster::Translate(translator_id id, BPositionIO* source,
|
|||||||
off_t pos = source->Seek(0, SEEK_SET);
|
off_t pos = source->Seek(0, SEEK_SET);
|
||||||
if (pos == 0) {
|
if (pos == 0) {
|
||||||
translator_info info;
|
translator_info info;
|
||||||
status = translator->Identify(source, NULL, ioExtension, &info, wantOutType);
|
status = translator->Identify(source, NULL, ioExtension, &info,
|
||||||
|
wantOutType);
|
||||||
if (status >= B_OK) {
|
if (status >= B_OK) {
|
||||||
off_t pos = source->Seek(0, SEEK_SET);
|
off_t pos = source->Seek(0, SEEK_SET);
|
||||||
if (pos != 0)
|
if (pos != 0)
|
||||||
status = pos < 0 ? (status_t)pos : B_IO_ERROR;
|
status = pos < 0 ? (status_t)pos : B_IO_ERROR;
|
||||||
else {
|
else {
|
||||||
status = translator->Translate(source, &info, ioExtension, wantOutType,
|
status = translator->Translate(source, &info, ioExtension,
|
||||||
destination);
|
wantOutType, destination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@@ -1606,8 +1646,8 @@ BTranslatorRoster::Translate(translator_id id, BPositionIO* source,
|
|||||||
B_NO_TRANSLATOR, \id didn't identify an existing translator
|
B_NO_TRANSLATOR, \id didn't identify an existing translator
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BTranslatorRoster::MakeConfigurationView(translator_id id, BMessage* ioExtension,
|
BTranslatorRoster::MakeConfigurationView(translator_id id,
|
||||||
BView** _view, BRect* _extent)
|
BMessage* ioExtension, BView** _view, BRect* _extent)
|
||||||
{
|
{
|
||||||
if (_view == NULL || _extent == NULL)
|
if (_view == NULL || _extent == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -1634,7 +1674,8 @@ BTranslatorRoster::MakeConfigurationView(translator_id id, BMessage* ioExtension
|
|||||||
B_NO_TRANSLATOR, \id didn't identify an existing translator
|
B_NO_TRANSLATOR, \id didn't identify an existing translator
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BTranslatorRoster::GetConfigurationMessage(translator_id id, BMessage* ioExtension)
|
BTranslatorRoster::GetConfigurationMessage(translator_id id,
|
||||||
|
BMessage* ioExtension)
|
||||||
{
|
{
|
||||||
if (!ioExtension)
|
if (!ioExtension)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -1713,9 +1754,9 @@ BTranslatorRoster::Version(int32* outCurVersion, int32* outMinVersion,
|
|||||||
static char vDate[] = __DATE__;
|
static char vDate[] = __DATE__;
|
||||||
if (!vString[0]) {
|
if (!vString[0]) {
|
||||||
sprintf(vString, "Translation Kit v%d.%d.%d %s\n",
|
sprintf(vString, "Translation Kit v%d.%d.%d %s\n",
|
||||||
static_cast<int>(B_TRANSLATION_MAJOR_VERSION(B_TRANSLATION_CURRENT_VERSION)),
|
int(B_TRANSLATION_MAJOR_VERSION(B_TRANSLATION_CURRENT_VERSION)),
|
||||||
static_cast<int>(B_TRANSLATION_MINOR_VERSION(B_TRANSLATION_CURRENT_VERSION)),
|
int(B_TRANSLATION_MINOR_VERSION(B_TRANSLATION_CURRENT_VERSION)),
|
||||||
static_cast<int>(B_TRANSLATION_REVISION_VERSION(B_TRANSLATION_CURRENT_VERSION)),
|
int(B_TRANSLATION_REVISION_VERSION(B_TRANSLATION_CURRENT_VERSION)),
|
||||||
vDate);
|
vDate);
|
||||||
}
|
}
|
||||||
*outCurVersion = B_TRANSLATION_CURRENT_VERSION;
|
*outCurVersion = B_TRANSLATION_CURRENT_VERSION;
|
||||||
|
|||||||
Reference in New Issue
Block a user