2010-08-02 00:28:19 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2010, Haiku. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT license.
|
|
|
|
*/
|
|
|
|
#ifndef _MUTABLE_LOCALE_ROSTER_H_
|
|
|
|
#define _MUTABLE_LOCALE_ROSTER_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include <Collator.h>
|
2010-10-24 16:57:55 +04:00
|
|
|
#include <FormattingConventions.h>
|
2010-08-02 00:28:19 +04:00
|
|
|
#include <image.h>
|
|
|
|
#include <Language.h>
|
|
|
|
#include <List.h>
|
2010-08-04 22:45:06 +04:00
|
|
|
#include <Locale.h>
|
2010-08-02 00:28:19 +04:00
|
|
|
#include <Locker.h>
|
|
|
|
#include <LocaleRoster.h>
|
|
|
|
#include <Message.h>
|
2010-10-20 01:36:44 +04:00
|
|
|
#include <Resources.h>
|
2010-08-02 00:28:19 +04:00
|
|
|
#include <TimeZone.h>
|
|
|
|
|
|
|
|
|
|
|
|
class BLocale;
|
|
|
|
class BCatalog;
|
|
|
|
class BCatalogAddOn;
|
|
|
|
|
|
|
|
struct entry_ref;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
|
|
|
|
|
|
class MutableLocaleRoster : public BLocaleRoster {
|
|
|
|
public:
|
|
|
|
MutableLocaleRoster();
|
|
|
|
~MutableLocaleRoster();
|
|
|
|
|
2010-11-22 16:06:36 +03:00
|
|
|
static MutableLocaleRoster* Default();
|
|
|
|
|
2010-10-24 16:57:55 +04:00
|
|
|
status_t SetDefaultFormattingConventions(
|
|
|
|
const BFormattingConventions& conventions);
|
2010-08-02 00:28:19 +04:00
|
|
|
status_t SetDefaultTimeZone(const BTimeZone& zone);
|
|
|
|
|
|
|
|
status_t SetPreferredLanguages(const BMessage* message);
|
|
|
|
// the message contains one or more
|
|
|
|
// 'language'-string-fields which
|
|
|
|
// contain the language-name(s)
|
2011-03-11 22:52:15 +03:00
|
|
|
status_t SetFilesystemTranslationPreferred(bool preferred);
|
2010-08-02 00:28:19 +04:00
|
|
|
|
|
|
|
status_t GetSystemCatalog(BCatalogAddOn** catalog) const;
|
|
|
|
|
2011-10-31 12:57:09 +04:00
|
|
|
BCatalogAddOn* LoadCatalog(const entry_ref& catalogOwner,
|
2010-08-02 00:28:19 +04:00
|
|
|
const char* language = NULL,
|
|
|
|
int32 fingerprint = 0) const;
|
|
|
|
status_t UnloadCatalog(BCatalogAddOn* addOn);
|
|
|
|
|
|
|
|
BCatalogAddOn* CreateCatalog(const char* type,
|
|
|
|
const char* signature,
|
|
|
|
const char* language);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-10-31 12:57:09 +04:00
|
|
|
typedef BCatalogAddOn* (*InstantiateCatalogFunc)(const entry_ref& catalogOwner,
|
2010-08-02 00:28:19 +04:00
|
|
|
const char* language, uint32 fingerprint);
|
|
|
|
|
|
|
|
typedef BCatalogAddOn* (*CreateCatalogFunc)(const char* name,
|
|
|
|
const char* language);
|
|
|
|
|
|
|
|
typedef BCatalogAddOn* (*InstantiateEmbeddedCatalogFunc)(
|
|
|
|
entry_ref* appOrAddOnRef);
|
|
|
|
|
|
|
|
typedef status_t (*GetAvailableLanguagesFunc)(BMessage*, const char*,
|
|
|
|
const char*, int32);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* info about a single catalog-add-on (representing a catalog type):
|
|
|
|
*/
|
|
|
|
struct CatalogAddOnInfo {
|
|
|
|
InstantiateCatalogFunc fInstantiateFunc;
|
|
|
|
CreateCatalogFunc fCreateFunc;
|
|
|
|
GetAvailableLanguagesFunc fLanguagesFunc;
|
|
|
|
|
|
|
|
BString fName;
|
|
|
|
BString fPath;
|
|
|
|
image_id fAddOnImage;
|
|
|
|
uint8 fPriority;
|
|
|
|
BList fLoadedCatalogs;
|
|
|
|
bool fIsEmbedded;
|
|
|
|
// an embedded add-on actually isn't an
|
|
|
|
// add-on, it is included as part of the
|
|
|
|
// library.
|
|
|
|
// The DefaultCatalog is such a beast!
|
|
|
|
|
|
|
|
CatalogAddOnInfo(const BString& name,
|
|
|
|
const BString& path, uint8 priority);
|
|
|
|
~CatalogAddOnInfo();
|
|
|
|
|
|
|
|
bool MakeSureItsLoaded();
|
|
|
|
void UnloadIfPossible();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The global data that is shared between all roster-objects of a process.
|
|
|
|
*/
|
|
|
|
struct RosterData {
|
|
|
|
BLocker fLock;
|
|
|
|
BList fCatalogAddOnInfos;
|
|
|
|
BMessage fPreferredLanguages;
|
|
|
|
|
2010-08-04 22:45:06 +04:00
|
|
|
BLocale fDefaultLocale;
|
2010-08-02 00:28:19 +04:00
|
|
|
BTimeZone fDefaultTimeZone;
|
2011-03-11 22:52:15 +03:00
|
|
|
|
|
|
|
bool fIsFilesystemTranslationPreferred;
|
2010-08-02 00:28:19 +04:00
|
|
|
|
2010-10-20 01:36:44 +04:00
|
|
|
bool fAreResourcesLoaded;
|
|
|
|
BResources fResources;
|
|
|
|
|
2011-02-16 18:27:33 +03:00
|
|
|
status_t fInitStatus;
|
|
|
|
|
2010-11-22 16:06:36 +03:00
|
|
|
RosterData(const BLanguage& language,
|
|
|
|
const BFormattingConventions& conventions);
|
2010-08-02 00:28:19 +04:00
|
|
|
~RosterData();
|
|
|
|
|
2010-11-22 16:06:36 +03:00
|
|
|
static RosterData* Default();
|
|
|
|
|
2011-02-16 18:27:33 +03:00
|
|
|
status_t InitCheck() const;
|
|
|
|
|
2010-08-02 00:28:19 +04:00
|
|
|
status_t Refresh();
|
|
|
|
|
|
|
|
static int CompareInfos(const void* left,
|
|
|
|
const void* right);
|
|
|
|
|
2010-10-24 16:57:55 +04:00
|
|
|
status_t SetDefaultFormattingConventions(
|
|
|
|
const BFormattingConventions& convetions);
|
2010-08-02 00:28:19 +04:00
|
|
|
status_t SetDefaultTimeZone(const BTimeZone& zone);
|
|
|
|
status_t SetPreferredLanguages(const BMessage* msg);
|
2011-03-11 22:52:15 +03:00
|
|
|
status_t SetFilesystemTranslationPreferred(
|
|
|
|
bool preferred);
|
2010-08-02 00:28:19 +04:00
|
|
|
private:
|
2011-02-16 18:27:33 +03:00
|
|
|
status_t _Initialize();
|
|
|
|
|
|
|
|
status_t _InitializeCatalogAddOns();
|
|
|
|
void _CleanupCatalogAddOns();
|
|
|
|
|
2010-08-02 00:28:19 +04:00
|
|
|
status_t _LoadLocaleSettings();
|
|
|
|
status_t _SaveLocaleSettings();
|
|
|
|
|
|
|
|
status_t _LoadTimeSettings();
|
|
|
|
status_t _SaveTimeSettings();
|
|
|
|
|
2010-10-24 16:57:55 +04:00
|
|
|
status_t _SetDefaultFormattingConventions(
|
|
|
|
const BFormattingConventions& conventions);
|
2010-08-02 00:28:19 +04:00
|
|
|
status_t _SetDefaultTimeZone(const BTimeZone& zone);
|
|
|
|
status_t _SetPreferredLanguages(const BMessage* msg);
|
2011-03-12 03:53:30 +03:00
|
|
|
void _SetFilesystemTranslationPreferred(
|
|
|
|
bool preferred);
|
2010-08-02 00:28:19 +04:00
|
|
|
|
2010-10-24 16:57:55 +04:00
|
|
|
status_t _AddDefaultFormattingConventionsToMessage(
|
2010-08-02 00:28:19 +04:00
|
|
|
BMessage* message) const;
|
|
|
|
status_t _AddDefaultTimeZoneToMessage(
|
|
|
|
BMessage* message) const;
|
|
|
|
status_t _AddPreferredLanguagesToMessage(
|
|
|
|
BMessage* message) const;
|
2011-03-11 22:52:15 +03:00
|
|
|
status_t _AddFilesystemTranslationPreferenceToMessage(
|
|
|
|
BMessage* message) const;
|
2010-08-02 00:28:19 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _MUTABLE_LOCALE_ROSTER_H_
|