138ac8defSOliver Tappe /* 238ac8defSOliver Tappe * Copyright 2010, 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> 1038ac8defSOliver Tappe #include <Country.h> 1138ac8defSOliver Tappe #include <image.h> 1238ac8defSOliver Tappe #include <Language.h> 1338ac8defSOliver Tappe #include <List.h> 14*5c3a3034SAdrien Destugues #include <Locale.h> 1538ac8defSOliver Tappe #include <Locker.h> 1638ac8defSOliver Tappe #include <LocaleRoster.h> 1738ac8defSOliver Tappe #include <Message.h> 1838ac8defSOliver Tappe #include <TimeZone.h> 1938ac8defSOliver Tappe 2038ac8defSOliver Tappe 2138ac8defSOliver Tappe class BLocale; 2238ac8defSOliver Tappe class BCatalog; 2338ac8defSOliver Tappe class BCatalogAddOn; 2438ac8defSOliver Tappe 2538ac8defSOliver Tappe struct entry_ref; 2638ac8defSOliver Tappe 2738ac8defSOliver Tappe 2838ac8defSOliver Tappe namespace BPrivate { 2938ac8defSOliver Tappe 3038ac8defSOliver Tappe 3138ac8defSOliver Tappe class MutableLocaleRoster : public BLocaleRoster { 3238ac8defSOliver Tappe public: 3338ac8defSOliver Tappe MutableLocaleRoster(); 3438ac8defSOliver Tappe ~MutableLocaleRoster(); 3538ac8defSOliver Tappe 3638ac8defSOliver Tappe status_t SetDefaultCountry(const BCountry& country); 37*5c3a3034SAdrien Destugues status_t SetDefaultLocale(const BLocale& locale); 3838ac8defSOliver Tappe status_t SetDefaultTimeZone(const BTimeZone& zone); 3938ac8defSOliver Tappe 4038ac8defSOliver Tappe status_t SetPreferredLanguages(const BMessage* message); 4138ac8defSOliver Tappe // the message contains one or more 4238ac8defSOliver Tappe // 'language'-string-fields which 4338ac8defSOliver Tappe // contain the language-name(s) 4438ac8defSOliver Tappe 4538ac8defSOliver Tappe status_t GetSystemCatalog(BCatalogAddOn** catalog) const; 4638ac8defSOliver Tappe 4738ac8defSOliver Tappe BCatalogAddOn* LoadCatalog(const char* signature, 4838ac8defSOliver Tappe const char* language = NULL, 4938ac8defSOliver Tappe int32 fingerprint = 0) const; 5038ac8defSOliver Tappe BCatalogAddOn* LoadEmbeddedCatalog(entry_ref* appOrAddOnRef); 5138ac8defSOliver Tappe status_t UnloadCatalog(BCatalogAddOn* addOn); 5238ac8defSOliver Tappe 5338ac8defSOliver Tappe BCatalogAddOn* CreateCatalog(const char* type, 5438ac8defSOliver Tappe const char* signature, 5538ac8defSOliver Tappe const char* language); 5638ac8defSOliver Tappe }; 5738ac8defSOliver Tappe 5838ac8defSOliver Tappe 5938ac8defSOliver Tappe extern MutableLocaleRoster* mutable_locale_roster; 6038ac8defSOliver Tappe 6138ac8defSOliver Tappe 6238ac8defSOliver Tappe typedef BCatalogAddOn* (*InstantiateCatalogFunc)(const char* name, 6338ac8defSOliver Tappe const char* language, uint32 fingerprint); 6438ac8defSOliver Tappe 6538ac8defSOliver Tappe typedef BCatalogAddOn* (*CreateCatalogFunc)(const char* name, 6638ac8defSOliver Tappe const char* language); 6738ac8defSOliver Tappe 6838ac8defSOliver Tappe typedef BCatalogAddOn* (*InstantiateEmbeddedCatalogFunc)( 6938ac8defSOliver Tappe entry_ref* appOrAddOnRef); 7038ac8defSOliver Tappe 7138ac8defSOliver Tappe typedef status_t (*GetAvailableLanguagesFunc)(BMessage*, const char*, 7238ac8defSOliver Tappe const char*, int32); 7338ac8defSOliver Tappe 7438ac8defSOliver Tappe /* 7538ac8defSOliver Tappe * info about a single catalog-add-on (representing a catalog type): 7638ac8defSOliver Tappe */ 7738ac8defSOliver Tappe struct CatalogAddOnInfo { 7838ac8defSOliver Tappe InstantiateCatalogFunc fInstantiateFunc; 7938ac8defSOliver Tappe InstantiateEmbeddedCatalogFunc fInstantiateEmbeddedFunc; 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 111*5c3a3034SAdrien Destugues BLocale fDefaultLocale; 11238ac8defSOliver Tappe BTimeZone fDefaultTimeZone; 11338ac8defSOliver Tappe 11438ac8defSOliver Tappe RosterData(); 11538ac8defSOliver Tappe ~RosterData(); 11638ac8defSOliver Tappe 11738ac8defSOliver Tappe void InitializeCatalogAddOns(); 11838ac8defSOliver Tappe void CleanupCatalogAddOns(); 11938ac8defSOliver Tappe status_t Refresh(); 12038ac8defSOliver Tappe 12138ac8defSOliver Tappe static int CompareInfos(const void* left, 12238ac8defSOliver Tappe const void* right); 12338ac8defSOliver Tappe 12438ac8defSOliver Tappe status_t SetDefaultCountry(const BCountry& country); 125*5c3a3034SAdrien Destugues status_t SetDefaultLocale(const BLocale& locale); 12638ac8defSOliver Tappe status_t SetDefaultTimeZone(const BTimeZone& zone); 12738ac8defSOliver Tappe status_t SetPreferredLanguages(const BMessage* msg); 12838ac8defSOliver Tappe private: 12938ac8defSOliver Tappe status_t _LoadLocaleSettings(); 13038ac8defSOliver Tappe status_t _SaveLocaleSettings(); 13138ac8defSOliver Tappe 13238ac8defSOliver Tappe status_t _LoadTimeSettings(); 13338ac8defSOliver Tappe status_t _SaveTimeSettings(); 13438ac8defSOliver Tappe 13538ac8defSOliver Tappe status_t _SetDefaultCountry(const BCountry& country); 136*5c3a3034SAdrien Destugues status_t _SetDefaultLocale(const BLocale& locale); 13738ac8defSOliver Tappe status_t _SetDefaultTimeZone(const BTimeZone& zone); 13838ac8defSOliver Tappe status_t _SetPreferredLanguages(const BMessage* msg); 13938ac8defSOliver Tappe 14038ac8defSOliver Tappe status_t _AddDefaultCountryToMessage( 14138ac8defSOliver Tappe BMessage* message) const; 14238ac8defSOliver Tappe status_t _AddDefaultTimeZoneToMessage( 14338ac8defSOliver Tappe BMessage* message) const; 14438ac8defSOliver Tappe status_t _AddPreferredLanguagesToMessage( 14538ac8defSOliver Tappe BMessage* message) const; 14638ac8defSOliver Tappe }; 14738ac8defSOliver Tappe 14838ac8defSOliver Tappe 14938ac8defSOliver Tappe extern RosterData gRosterData; 15038ac8defSOliver Tappe 15138ac8defSOliver Tappe 15238ac8defSOliver Tappe } // namespace BPrivate 15338ac8defSOliver Tappe 15438ac8defSOliver Tappe 15538ac8defSOliver Tappe #endif // _MUTABLE_LOCALE_ROSTER_H_ 156