138ac8defSOliver Tappe /* 2*541ff51aSOliver Tappe * Copyright 2010-2012, Haiku. All rights reserved. 338ac8defSOliver Tappe * Distributed under the terms of the MIT license. 438ac8defSOliver Tappe */ 538ac8defSOliver Tappe #ifndef _MUTABLE_LOCALE_ROSTER_H_ 638ac8defSOliver Tappe #define _MUTABLE_LOCALE_ROSTER_H_ 738ac8defSOliver Tappe 838ac8defSOliver Tappe 938ac8defSOliver Tappe #include <Collator.h> 106fd2f4a0SOliver Tappe #include <FormattingConventions.h> 1138ac8defSOliver Tappe #include <image.h> 1238ac8defSOliver Tappe #include <Language.h> 1338ac8defSOliver Tappe #include <List.h> 145c3a3034SAdrien Destugues #include <Locale.h> 1538ac8defSOliver Tappe #include <Locker.h> 1638ac8defSOliver Tappe #include <LocaleRoster.h> 1738ac8defSOliver Tappe #include <Message.h> 18d1d8fda6SOliver Tappe #include <Resources.h> 1938ac8defSOliver Tappe #include <TimeZone.h> 2038ac8defSOliver Tappe 2138ac8defSOliver Tappe 2238ac8defSOliver Tappe class BLocale; 2338ac8defSOliver Tappe class BCatalog; 24*541ff51aSOliver Tappe class BCatalogData; 2538ac8defSOliver Tappe 2638ac8defSOliver Tappe struct entry_ref; 2738ac8defSOliver Tappe 2838ac8defSOliver Tappe 2938ac8defSOliver Tappe namespace BPrivate { 3038ac8defSOliver Tappe 3138ac8defSOliver Tappe 3238ac8defSOliver Tappe class MutableLocaleRoster : public BLocaleRoster { 3338ac8defSOliver Tappe public: 3438ac8defSOliver Tappe MutableLocaleRoster(); 3538ac8defSOliver Tappe ~MutableLocaleRoster(); 3638ac8defSOliver Tappe 3725dc253dSIngo Weinhold static MutableLocaleRoster* Default(); 3825dc253dSIngo Weinhold 396fd2f4a0SOliver Tappe status_t SetDefaultFormattingConventions( 406fd2f4a0SOliver Tappe const BFormattingConventions& conventions); 4138ac8defSOliver Tappe status_t SetDefaultTimeZone(const BTimeZone& zone); 4238ac8defSOliver Tappe 4338ac8defSOliver Tappe status_t SetPreferredLanguages(const BMessage* message); 4438ac8defSOliver Tappe // the message contains one or more 4538ac8defSOliver Tappe // 'language'-string-fields which 4638ac8defSOliver Tappe // contain the language-name(s) 47*541ff51aSOliver Tappe status_t SetFilesystemTranslationPreferred( 48*541ff51aSOliver Tappe bool preferred); 4938ac8defSOliver Tappe 50eaa5e093SOliver Tappe status_t LoadSystemCatalog(BCatalog* catalog) const; 5138ac8defSOliver Tappe 52*541ff51aSOliver Tappe BCatalogData* LoadCatalog(const entry_ref& catalogOwner, 5338ac8defSOliver Tappe const char* language = NULL, 5438ac8defSOliver Tappe int32 fingerprint = 0) const; 55*541ff51aSOliver Tappe status_t UnloadCatalog(BCatalogData* catalogData); 5638ac8defSOliver Tappe 57*541ff51aSOliver Tappe BCatalogData* CreateCatalog(const char* type, 5838ac8defSOliver Tappe const char* signature, 5938ac8defSOliver Tappe const char* language); 6038ac8defSOliver Tappe }; 6138ac8defSOliver Tappe 6238ac8defSOliver Tappe 63*541ff51aSOliver Tappe typedef BCatalogData* (*InstantiateCatalogFunc)(const entry_ref& catalogOwner, 6438ac8defSOliver Tappe const char* language, uint32 fingerprint); 6538ac8defSOliver Tappe 66*541ff51aSOliver Tappe typedef BCatalogData* (*CreateCatalogFunc)(const char* name, 6738ac8defSOliver Tappe const char* language); 6838ac8defSOliver Tappe 69*541ff51aSOliver Tappe typedef BCatalogData* (*InstantiateEmbeddedCatalogFunc)( 7038ac8defSOliver Tappe entry_ref* appOrAddOnRef); 7138ac8defSOliver Tappe 7238ac8defSOliver Tappe typedef status_t (*GetAvailableLanguagesFunc)(BMessage*, const char*, 7338ac8defSOliver Tappe const char*, int32); 7438ac8defSOliver Tappe 7538ac8defSOliver Tappe /* 7638ac8defSOliver Tappe * info about a single catalog-add-on (representing a catalog type): 7738ac8defSOliver Tappe */ 7838ac8defSOliver Tappe struct CatalogAddOnInfo { 7938ac8defSOliver Tappe InstantiateCatalogFunc fInstantiateFunc; 8038ac8defSOliver Tappe CreateCatalogFunc fCreateFunc; 8138ac8defSOliver Tappe GetAvailableLanguagesFunc fLanguagesFunc; 8238ac8defSOliver Tappe 8338ac8defSOliver Tappe BString fName; 8438ac8defSOliver Tappe BString fPath; 8538ac8defSOliver Tappe image_id fAddOnImage; 8638ac8defSOliver Tappe uint8 fPriority; 8738ac8defSOliver Tappe BList fLoadedCatalogs; 8838ac8defSOliver Tappe bool fIsEmbedded; 8938ac8defSOliver Tappe // an embedded add-on actually isn't an 9038ac8defSOliver Tappe // add-on, it is included as part of the 9138ac8defSOliver Tappe // library. 9238ac8defSOliver Tappe // The DefaultCatalog is such a beast! 9338ac8defSOliver Tappe 9438ac8defSOliver Tappe CatalogAddOnInfo(const BString& name, 9538ac8defSOliver Tappe const BString& path, uint8 priority); 9638ac8defSOliver Tappe ~CatalogAddOnInfo(); 9738ac8defSOliver Tappe 9838ac8defSOliver Tappe bool MakeSureItsLoaded(); 9938ac8defSOliver Tappe void UnloadIfPossible(); 10038ac8defSOliver Tappe }; 10138ac8defSOliver Tappe 10238ac8defSOliver Tappe 10338ac8defSOliver Tappe /* 10438ac8defSOliver Tappe * The global data that is shared between all roster-objects of a process. 10538ac8defSOliver Tappe */ 10638ac8defSOliver Tappe struct RosterData { 10738ac8defSOliver Tappe BLocker fLock; 10838ac8defSOliver Tappe BList fCatalogAddOnInfos; 10938ac8defSOliver Tappe BMessage fPreferredLanguages; 11038ac8defSOliver Tappe 1115c3a3034SAdrien Destugues BLocale fDefaultLocale; 11238ac8defSOliver Tappe BTimeZone fDefaultTimeZone; 11338ac8defSOliver Tappe 11407cffb47SJonas Sundström bool fIsFilesystemTranslationPreferred; 11507cffb47SJonas Sundström 116d1d8fda6SOliver Tappe bool fAreResourcesLoaded; 117d1d8fda6SOliver Tappe BResources fResources; 118d1d8fda6SOliver Tappe 1191d8dff01SOliver Tappe status_t fInitStatus; 1201d8dff01SOliver Tappe 12125dc253dSIngo Weinhold RosterData(const BLanguage& language, 12225dc253dSIngo Weinhold const BFormattingConventions& conventions); 12338ac8defSOliver Tappe ~RosterData(); 12438ac8defSOliver Tappe 12525dc253dSIngo Weinhold static RosterData* Default(); 12625dc253dSIngo Weinhold 1271d8dff01SOliver Tappe status_t InitCheck() const; 1281d8dff01SOliver Tappe 12938ac8defSOliver Tappe status_t Refresh(); 13038ac8defSOliver Tappe 13138ac8defSOliver Tappe static int CompareInfos(const void* left, 13238ac8defSOliver Tappe const void* right); 13338ac8defSOliver Tappe 1346fd2f4a0SOliver Tappe status_t SetDefaultFormattingConventions( 1356fd2f4a0SOliver Tappe const BFormattingConventions& convetions); 13638ac8defSOliver Tappe status_t SetDefaultTimeZone(const BTimeZone& zone); 13738ac8defSOliver Tappe status_t SetPreferredLanguages(const BMessage* msg); 13807cffb47SJonas Sundström status_t SetFilesystemTranslationPreferred( 13907cffb47SJonas Sundström bool preferred); 14038ac8defSOliver Tappe private: 1411d8dff01SOliver Tappe status_t _Initialize(); 1421d8dff01SOliver Tappe 1431d8dff01SOliver Tappe status_t _InitializeCatalogAddOns(); 1441d8dff01SOliver Tappe void _CleanupCatalogAddOns(); 1451d8dff01SOliver Tappe 14638ac8defSOliver Tappe status_t _LoadLocaleSettings(); 14738ac8defSOliver Tappe status_t _SaveLocaleSettings(); 14838ac8defSOliver Tappe 14938ac8defSOliver Tappe status_t _LoadTimeSettings(); 15038ac8defSOliver Tappe status_t _SaveTimeSettings(); 15138ac8defSOliver Tappe 1526fd2f4a0SOliver Tappe status_t _SetDefaultFormattingConventions( 1536fd2f4a0SOliver Tappe const BFormattingConventions& conventions); 15438ac8defSOliver Tappe status_t _SetDefaultTimeZone(const BTimeZone& zone); 15538ac8defSOliver Tappe status_t _SetPreferredLanguages(const BMessage* msg); 156ed7ee7a4SJonas Sundström void _SetFilesystemTranslationPreferred( 157ed7ee7a4SJonas Sundström bool preferred); 15838ac8defSOliver Tappe 1596fd2f4a0SOliver Tappe status_t _AddDefaultFormattingConventionsToMessage( 16038ac8defSOliver Tappe BMessage* message) const; 16138ac8defSOliver Tappe status_t _AddDefaultTimeZoneToMessage( 16238ac8defSOliver Tappe BMessage* message) const; 16338ac8defSOliver Tappe status_t _AddPreferredLanguagesToMessage( 16438ac8defSOliver Tappe BMessage* message) const; 16507cffb47SJonas Sundström status_t _AddFilesystemTranslationPreferenceToMessage( 16607cffb47SJonas Sundström BMessage* message) const; 16738ac8defSOliver Tappe }; 16838ac8defSOliver Tappe 16938ac8defSOliver Tappe 17038ac8defSOliver Tappe } // namespace BPrivate 17138ac8defSOliver Tappe 17238ac8defSOliver Tappe 17338ac8defSOliver Tappe #endif // _MUTABLE_LOCALE_ROSTER_H_ 174