haiku/headers/private/locale/DefaultCatalog.h
Adrien Destugues 54fad654ce Rework the handling of catalog loading in locale kit :
Instead of computing the mime signature and giving this to the catalog system,
give an entry_ref instead. The default catalog add-on can thus look at the
right place when searching local catalogs (embedded as resources, or stored
as files next to the executable.
  * This allows different versions of the same app to each have their own
catalog set,
  * And also make the embedded/local catalog searching work for add-ons and
libs, instead it only worked for apps because of a getAppInfo call.

Fix cpufrequency to make use of it properly (that wouldhave worked without the
change, but nowit's mandatory, since loading a catlog by mimesignature is not
possible anymore).

Should fix #8037.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43021 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-10-31 08:57:09 +00:00

76 lines
2.1 KiB
C++

/*
* Copyright 2009, Adrien Destugues, pulkomandy@gmail.com.
* Distributed under the terms of the MIT License.
*/
#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).
*/
class DefaultCatalog : public BHashMapCatalog {
public:
DefaultCatalog(const entry_ref &catalogOwner, const char *language,
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);
status_t ReadFromAttribute(entry_ref *appOrAddOnRef);
status_t ReadFromResource(entry_ref *appOrAddOnRef);
status_t WriteToFile(const char *path = NULL);
status_t WriteToAttribute(entry_ref *appOrAddOnRef);
status_t WriteToResource(entry_ref *appOrAddOnRef);
status_t SetRawString(const CatKey& key, const char *translated);
void SetSignature(const entry_ref &catalogOwner);
static BCatalogAddOn *Instantiate(const entry_ref& catalogOwner,
const char *language, uint32 fingerprint);
static BCatalogAddOn *Create(const char *signature,
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;
};
extern "C" status_t
default_catalog_get_available_languages(BMessage* availableLanguages,
const char* sigPattern, const char* langPattern = NULL,
int32 fingerprint = 0);
} // namespace BPrivate
using namespace BPrivate;
#endif /* _DEFAULT_CATALOG_H_ */