1 /* 2 * Copyright 2009, Adrien Destugues, pulkomandy@gmail.com. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _DEFAULT_CATALOG_H_ 6 #define _DEFAULT_CATALOG_H_ 7 8 9 #include <DataIO.h> 10 #include <HashMapCatalog.h> 11 #include <String.h> 12 13 14 class BFile; 15 16 namespace BPrivate { 17 18 19 /* 20 * The implementation of the Locale Kit's standard catalog-type. 21 * Currently it only maps CatKey to a BString (the translated string), 22 * but the value-type might change to add support for shortcuts and/or 23 * graphical data (button-images and the like). 24 */ 25 class DefaultCatalog : public HashMapCatalog { 26 public: 27 DefaultCatalog(const entry_ref &catalogOwner, const char *language, 28 uint32 fingerprint); 29 // constructor for normal use 30 DefaultCatalog(entry_ref *appOrAddOnRef); 31 // constructor for embedded catalog 32 DefaultCatalog(const char *path, const char *signature, 33 const char *language); 34 // constructor for editor-app 35 36 ~DefaultCatalog(); 37 38 // implementation for editor-interface: 39 status_t ReadFromFile(const char *path = NULL); 40 status_t ReadFromAttribute(const entry_ref &appOrAddOnRef); 41 status_t ReadFromResource(const entry_ref &appOrAddOnRef); 42 status_t WriteToFile(const char *path = NULL); 43 status_t WriteToAttribute(const entry_ref &appOrAddOnRef); 44 status_t WriteToResource(const entry_ref &appOrAddOnRef); 45 46 status_t SetRawString(const CatKey& key, const char *translated); 47 void SetSignature(const entry_ref &catalogOwner); 48 49 static BCatalogData *Instantiate(const entry_ref& catalogOwner, 50 const char *language, uint32 fingerprint); 51 static BCatalogData *Create(const char *signature, 52 const char *language); 53 54 static const uint8 kDefaultCatalogAddOnPriority; 55 static const char *kCatMimeType; 56 57 private: 58 status_t Flatten(BDataIO *dataIO); 59 status_t Unflatten(BDataIO *dataIO); 60 void UpdateAttributes(BFile& catalogFile); 61 62 mutable BString fPath; 63 }; 64 65 66 extern "C" status_t 67 default_catalog_get_available_languages(BMessage* availableLanguages, 68 const char* sigPattern, const char* langPattern = NULL, 69 int32 fingerprint = 0); 70 71 72 } // namespace BPrivate 73 74 75 #endif /* _DEFAULT_CATALOG_H_ */ 76