2 * This file contains library initialization code.
3 * The required mimetypes and attribute-indices are created here.
9 #include <VolumeRoster.h>
11 #include <DefaultCatalog.h>
12 #include <MutableLocaleRoster.h>
13 #include <SystemCatalog.h>
18 BCatalog gSystemCatalog
;
23 using BPrivate::DefaultCatalog
;
24 using BPrivate::MutableLocaleRoster
;
25 using BPrivate::gSystemCatalog
;
28 // helper function that makes sure an attribute-index exists:
29 static void EnsureIndexExists(const char *attrName
)
32 BVolumeRoster volRoster
;
33 if (volRoster
.GetBootVolume(&bootVol
) != B_OK
)
35 struct index_info idxInfo
;
36 if (fs_stat_index(bootVol
.Device(), attrName
, &idxInfo
) != 0)
37 fs_create_index(bootVol
.Device(), attrName
, B_STRING_TYPE
, 0);
42 * prepares the system for use by the Locale Kit catalogs,
43 * it makes sure that the required indices and mimetype exist:
48 // make sure the indices required for catalog-traversal are there:
49 EnsureIndexExists(BLocaleRoster::kCatLangAttr
);
50 EnsureIndexExists(BLocaleRoster::kCatSigAttr
);
52 // install mimetype for default-catalog:
54 status_t res
= mt
.SetTo(DefaultCatalog::kCatMimeType
);
55 if (res
== B_OK
&& !mt
.IsInstalled()) {
56 // install supertype, if it isn't available
58 res
= mt
.GetSupertype(&supertype
);
59 if (res
== B_OK
&& !supertype
.IsInstalled()) {
60 res
= supertype
.Install();
64 // info about the attributes of a catalog...
66 // ...the catalog signature...
67 attrMsg
.AddString("attr:public_name", "Signature");
68 attrMsg
.AddString("attr:name", BLocaleRoster::kCatSigAttr
);
69 attrMsg
.AddInt32("attr:type", B_STRING_TYPE
);
70 attrMsg
.AddBool("attr:editable", false);
71 attrMsg
.AddBool("attr:viewable", true);
72 attrMsg
.AddBool("attr:extra", false);
73 attrMsg
.AddInt32("attr:alignment", 0);
74 attrMsg
.AddInt32("attr:width", 140);
75 // ...the catalog language...
76 attrMsg
.AddString("attr:public_name", "Language");
77 attrMsg
.AddString("attr:name", BLocaleRoster::kCatLangAttr
);
78 attrMsg
.AddInt32("attr:type", B_STRING_TYPE
);
79 attrMsg
.AddBool("attr:editable", false);
80 attrMsg
.AddBool("attr:viewable", true);
81 attrMsg
.AddBool("attr:extra", false);
82 attrMsg
.AddInt32("attr:alignment", 0);
83 attrMsg
.AddInt32("attr:width", 60);
84 // ...and the catalog fingerprint...
85 attrMsg
.AddString("attr:public_name", "Fingerprint");
86 attrMsg
.AddString("attr:name", BLocaleRoster::kCatFingerprintAttr
);
87 attrMsg
.AddInt32("attr:type", B_INT32_TYPE
);
88 attrMsg
.AddBool("attr:editable", false);
89 attrMsg
.AddBool("attr:viewable", true);
90 attrMsg
.AddBool("attr:extra", false);
91 attrMsg
.AddInt32("attr:alignment", 0);
92 attrMsg
.AddInt32("attr:width", 70);
93 res
= mt
.SetAttrInfo(&attrMsg
);
97 // file extensions (.catalog):
99 extMsg
.AddString("extensions", "catalog");
100 res
= mt
.SetFileExtensions(&extMsg
);
104 // short and long descriptions:
105 mt
.SetShortDescription("Translation Catalog");
106 res
= mt
.SetLongDescription("Catalog with translated application resources");
116 __initialize_locale_kit()
118 SetupCatalogBasics();
120 MutableLocaleRoster::Default()->LoadSystemCatalog(&gSystemCatalog
);