2 * Copyright 2010-2012, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT license.
5 #ifndef _LOCALE_ROSTER_DATA_H_
6 #define _LOCALE_ROSTER_DATA_H_
10 #include <DateFormat.h>
11 #include <FormattingConventions.h>
18 #include <Resources.h>
32 * Struct containing the actual locale data.
34 struct LocaleRosterData
{
36 BList fCatalogAddOnInfos
;
37 BMessage fPreferredLanguages
;
39 BLocale fDefaultLocale
;
40 BTimeZone fDefaultTimeZone
;
42 bool fIsFilesystemTranslationPreferred
;
44 LocaleRosterData(const BLanguage
& language
,
45 const BFormattingConventions
& conventions
);
48 status_t
InitCheck() const;
52 static int CompareInfos(const void* left
,
55 status_t
GetResources(BResources
** resources
);
57 status_t
SetDefaultFormattingConventions(
58 const BFormattingConventions
& convetions
);
59 status_t
SetDefaultTimeZone(const BTimeZone
& zone
);
60 status_t
SetPreferredLanguages(const BMessage
* msg
);
61 status_t
SetFilesystemTranslationPreferred(
64 status_t
_Initialize();
66 status_t
_InitializeCatalogAddOns();
67 void _CleanupCatalogAddOns();
69 status_t
_LoadLocaleSettings();
70 status_t
_SaveLocaleSettings();
72 status_t
_LoadTimeSettings();
73 status_t
_SaveTimeSettings();
75 status_t
_SetDefaultFormattingConventions(
76 const BFormattingConventions
& conventions
);
77 status_t
_SetDefaultTimeZone(const BTimeZone
& zone
);
78 status_t
_SetPreferredLanguages(const BMessage
* msg
);
79 void _SetFilesystemTranslationPreferred(
82 status_t
_AddDefaultFormattingConventionsToMessage(
83 BMessage
* message
) const;
84 status_t
_AddDefaultTimeZoneToMessage(
85 BMessage
* message
) const;
86 status_t
_AddPreferredLanguagesToMessage(
87 BMessage
* message
) const;
88 status_t
_AddFilesystemTranslationPreferenceToMessage(
89 BMessage
* message
) const;
94 bool fAreResourcesLoaded
;
95 BResources fResources
;
99 typedef BCatalogData
* (*InstantiateCatalogFunc
)(const entry_ref
& catalogOwner
,
100 const char* language
, uint32 fingerprint
);
102 typedef BCatalogData
* (*CreateCatalogFunc
)(const char* name
,
103 const char* language
);
105 typedef BCatalogData
* (*InstantiateEmbeddedCatalogFunc
)(
106 entry_ref
* appOrAddOnRef
);
108 typedef status_t (*GetAvailableLanguagesFunc
)(BMessage
*, const char*,
113 * info about a single catalog-add-on (representing a catalog type):
115 struct CatalogAddOnInfo
{
116 InstantiateCatalogFunc fInstantiateFunc
;
117 CreateCatalogFunc fCreateFunc
;
118 GetAvailableLanguagesFunc fLanguagesFunc
;
122 image_id fAddOnImage
;
124 BList fLoadedCatalogs
;
126 // an embedded add-on actually isn't an
127 // add-on, it is included as part of the
129 // The DefaultCatalog is such a beast!
131 CatalogAddOnInfo(const BString
& name
,
132 const BString
& path
, uint8 priority
);
135 bool MakeSureItsLoaded();
136 void UnloadIfPossible();
140 } // namespace BPrivate
143 #endif // _LOCALE_ROSTER_DATA_H_