2010-04-13 01:02:09 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Adrien Destugues, pulkomandy@gmail.com.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2009-09-19 02:23:34 +04:00
|
|
|
#ifndef _DEFAULT_CATALOG_H_
|
|
|
|
#define _DEFAULT_CATALOG_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include <DataIO.h>
|
|
|
|
#include <HashMapCatalog.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
|
|
|
|
|
|
|
class BFile;
|
|
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The implementation of the Locale Kit's standard catalog-type.
|
|
|
|
* Currently it only maps CatKey to a BString (the translated string),
|
|
|
|
* but the value-type might change to add support for shortcuts and/or
|
|
|
|
* graphical data (button-images and the like).
|
|
|
|
*/
|
2012-04-14 22:38:05 +04:00
|
|
|
class DefaultCatalog : public HashMapCatalog {
|
2009-09-19 02:23:34 +04:00
|
|
|
public:
|
2011-10-31 12:57:09 +04:00
|
|
|
DefaultCatalog(const entry_ref &catalogOwner, const char *language,
|
2009-09-19 02:23:34 +04:00
|
|
|
uint32 fingerprint);
|
|
|
|
// constructor for normal use
|
|
|
|
DefaultCatalog(entry_ref *appOrAddOnRef);
|
|
|
|
// constructor for embedded catalog
|
|
|
|
DefaultCatalog(const char *path, const char *signature,
|
|
|
|
const char *language);
|
|
|
|
// constructor for editor-app
|
|
|
|
|
|
|
|
~DefaultCatalog();
|
|
|
|
|
|
|
|
// implementation for editor-interface:
|
|
|
|
status_t ReadFromFile(const char *path = NULL);
|
2011-11-01 14:13:34 +04:00
|
|
|
status_t ReadFromAttribute(const entry_ref &appOrAddOnRef);
|
|
|
|
status_t ReadFromResource(const entry_ref &appOrAddOnRef);
|
2009-09-19 02:23:34 +04:00
|
|
|
status_t WriteToFile(const char *path = NULL);
|
2011-11-01 14:13:34 +04:00
|
|
|
status_t WriteToAttribute(const entry_ref &appOrAddOnRef);
|
|
|
|
status_t WriteToResource(const entry_ref &appOrAddOnRef);
|
2009-09-19 02:23:34 +04:00
|
|
|
|
2011-04-02 17:37:59 +04:00
|
|
|
status_t SetRawString(const CatKey& key, const char *translated);
|
2011-10-31 12:57:09 +04:00
|
|
|
void SetSignature(const entry_ref &catalogOwner);
|
2011-04-02 17:37:59 +04:00
|
|
|
|
2012-04-15 21:04:02 +04:00
|
|
|
static BCatalogData *Instantiate(const entry_ref& catalogOwner,
|
2009-09-19 02:23:34 +04:00
|
|
|
const char *language, uint32 fingerprint);
|
2012-04-15 21:04:02 +04:00
|
|
|
static BCatalogData *Create(const char *signature,
|
2009-09-19 02:23:34 +04:00
|
|
|
const char *language);
|
|
|
|
|
|
|
|
static const uint8 kDefaultCatalogAddOnPriority;
|
|
|
|
static const char *kCatMimeType;
|
|
|
|
|
|
|
|
private:
|
|
|
|
status_t Flatten(BDataIO *dataIO);
|
|
|
|
status_t Unflatten(BDataIO *dataIO);
|
|
|
|
void UpdateAttributes(BFile& catalogFile);
|
|
|
|
|
|
|
|
mutable BString fPath;
|
|
|
|
};
|
|
|
|
|
2012-04-14 22:38:05 +04:00
|
|
|
|
2010-04-15 03:48:01 +04:00
|
|
|
extern "C" status_t
|
|
|
|
default_catalog_get_available_languages(BMessage* availableLanguages,
|
|
|
|
const char* sigPattern, const char* langPattern = NULL,
|
|
|
|
int32 fingerprint = 0);
|
2009-09-19 02:23:34 +04:00
|
|
|
|
2012-04-14 22:38:05 +04:00
|
|
|
|
2009-09-19 02:23:34 +04:00
|
|
|
} // namespace BPrivate
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* _DEFAULT_CATALOG_H_ */
|