btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / locale / LocaleRosterData.h
blobb5574f7435e352de27980508978a3293af5f3994
1 /*
2 * Copyright 2010-2012, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT license.
4 */
5 #ifndef _LOCALE_ROSTER_DATA_H_
6 #define _LOCALE_ROSTER_DATA_H_
9 #include <Collator.h>
10 #include <DateFormat.h>
11 #include <FormattingConventions.h>
12 #include <image.h>
13 #include <Language.h>
14 #include <List.h>
15 #include <Locale.h>
16 #include <Locker.h>
17 #include <Message.h>
18 #include <Resources.h>
19 #include <TimeZone.h>
22 class BCatalogData;
23 class BLocale;
25 struct entry_ref;
28 namespace BPrivate {
32 * Struct containing the actual locale data.
34 struct LocaleRosterData {
35 BLocker fLock;
36 BList fCatalogAddOnInfos;
37 BMessage fPreferredLanguages;
39 BLocale fDefaultLocale;
40 BTimeZone fDefaultTimeZone;
42 bool fIsFilesystemTranslationPreferred;
44 LocaleRosterData(const BLanguage& language,
45 const BFormattingConventions& conventions);
46 ~LocaleRosterData();
48 status_t InitCheck() const;
50 status_t Refresh();
52 static int CompareInfos(const void* left,
53 const void* right);
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(
62 bool preferred);
63 private:
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(
80 bool preferred);
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;
91 private:
92 status_t fInitStatus;
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*,
109 const char*, int32);
113 * info about a single catalog-add-on (representing a catalog type):
115 struct CatalogAddOnInfo {
116 InstantiateCatalogFunc fInstantiateFunc;
117 CreateCatalogFunc fCreateFunc;
118 GetAvailableLanguagesFunc fLanguagesFunc;
120 BString fName;
121 BString fPath;
122 image_id fAddOnImage;
123 uint8 fPriority;
124 BList fLoadedCatalogs;
125 bool fIsEmbedded;
126 // an embedded add-on actually isn't an
127 // add-on, it is included as part of the
128 // library.
129 // The DefaultCatalog is such a beast!
131 CatalogAddOnInfo(const BString& name,
132 const BString& path, uint8 priority);
133 ~CatalogAddOnInfo();
135 bool MakeSureItsLoaded();
136 void UnloadIfPossible();
140 } // namespace BPrivate
143 #endif // _LOCALE_ROSTER_DATA_H_