mirror of
https://review.haiku-os.org/haiku
synced 2025-01-22 06:16:03 +01:00
38ac8def5a
* refactored private/mutable stuff out of LocaleRoster into MutableLocaleRoster * moved management of Locale/Time settings file and broadcasting of any changes out of preflets and into MutableLocaleRoster * added proper sorting to the listviews of the Locale preflet * the Time preflet no longer overlaps long timezone names into the actual time * several fixes with respect to leaking ICU objects, esp. in BCountry * the locale roster no longer passes out references to its own BCountry object, but uses copies, instead - this makes locking superfluous, as the clients' BCountry objects can no longer be changed by the setting a new default country in the locale roster * removed pretty useless POSIX-style symbol fetching from BCountry - if we need that at all, it should live in the dedicated formatter classes * adjusted readonlybootprompt, dstcheck and Deskbar to the changed Locale API * refactored existing Time-formatter into TimeUnitFormat and DurationFormat (the latter of which is now used by AboutSystem) * added stubs for Date, DateTime and Time formatters * lots of coding style fixes throughout the Locale Kit and the Locale and Time preflets This will probably break most external apps making use of the Locale Kit - it does break WebPositive. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37831 a95241bf-73f2-0310-859d-f6bbb57e9c96
154 lines
3.9 KiB
C++
154 lines
3.9 KiB
C++
/*
|
|
* 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>
|
|
#include <Country.h>
|
|
#include <image.h>
|
|
#include <Language.h>
|
|
#include <List.h>
|
|
#include <Locker.h>
|
|
#include <LocaleRoster.h>
|
|
#include <Message.h>
|
|
#include <TimeZone.h>
|
|
|
|
|
|
class BLocale;
|
|
class BCatalog;
|
|
class BCatalogAddOn;
|
|
|
|
struct entry_ref;
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
class MutableLocaleRoster : public BLocaleRoster {
|
|
public:
|
|
MutableLocaleRoster();
|
|
~MutableLocaleRoster();
|
|
|
|
status_t SetDefaultCountry(const BCountry& country);
|
|
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)
|
|
|
|
status_t GetSystemCatalog(BCatalogAddOn** catalog) const;
|
|
|
|
BCatalogAddOn* LoadCatalog(const char* signature,
|
|
const char* language = NULL,
|
|
int32 fingerprint = 0) const;
|
|
BCatalogAddOn* LoadEmbeddedCatalog(entry_ref* appOrAddOnRef);
|
|
status_t UnloadCatalog(BCatalogAddOn* addOn);
|
|
|
|
BCatalogAddOn* CreateCatalog(const char* type,
|
|
const char* signature,
|
|
const char* language);
|
|
};
|
|
|
|
|
|
extern MutableLocaleRoster* mutable_locale_roster;
|
|
|
|
|
|
typedef BCatalogAddOn* (*InstantiateCatalogFunc)(const char* name,
|
|
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;
|
|
InstantiateEmbeddedCatalogFunc fInstantiateEmbeddedFunc;
|
|
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;
|
|
|
|
BCollator fDefaultCollator;
|
|
BCountry fDefaultCountry;
|
|
BLanguage fDefaultLanguage;
|
|
BTimeZone fDefaultTimeZone;
|
|
|
|
RosterData();
|
|
~RosterData();
|
|
|
|
void InitializeCatalogAddOns();
|
|
void CleanupCatalogAddOns();
|
|
status_t Refresh();
|
|
|
|
static int CompareInfos(const void* left,
|
|
const void* right);
|
|
|
|
status_t SetDefaultCountry(const BCountry& country);
|
|
status_t SetDefaultTimeZone(const BTimeZone& zone);
|
|
status_t SetPreferredLanguages(const BMessage* msg);
|
|
private:
|
|
status_t _LoadLocaleSettings();
|
|
status_t _SaveLocaleSettings();
|
|
|
|
status_t _LoadTimeSettings();
|
|
status_t _SaveTimeSettings();
|
|
|
|
status_t _SetDefaultCountry(const BCountry& country);
|
|
status_t _SetDefaultTimeZone(const BTimeZone& zone);
|
|
status_t _SetPreferredLanguages(const BMessage* msg);
|
|
|
|
status_t _AddDefaultCountryToMessage(
|
|
BMessage* message) const;
|
|
status_t _AddDefaultTimeZoneToMessage(
|
|
BMessage* message) const;
|
|
status_t _AddPreferredLanguagesToMessage(
|
|
BMessage* message) const;
|
|
};
|
|
|
|
|
|
extern RosterData gRosterData;
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
|
|
#endif // _MUTABLE_LOCALE_ROSTER_H_
|