2010-05-06 19:42:48 +04:00
|
|
|
/*
|
2010-07-26 02:47:39 +04:00
|
|
|
* Copyright 2003-2010, Haiku, Inc.
|
2009-09-19 16:19:46 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2009-05-01 23:23:59 +04:00
|
|
|
#ifndef _CATALOG_H_
|
|
|
|
#define _CATALOG_H_
|
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
|
2010-07-20 15:38:34 +04:00
|
|
|
#include <LocaleRoster.h>
|
2009-05-01 23:23:59 +04:00
|
|
|
#include <SupportDefs.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
class BCatalogAddOn;
|
|
|
|
class BLocale;
|
|
|
|
class BMessage;
|
|
|
|
struct entry_ref;
|
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
class BCatalog {
|
2010-11-03 00:36:35 +03:00
|
|
|
public:
|
|
|
|
BCatalog();
|
2011-10-31 12:57:09 +04:00
|
|
|
BCatalog(const entry_ref& catalogOwner,
|
2010-11-03 00:36:35 +03:00
|
|
|
const char* language = NULL,
|
|
|
|
uint32 fingerprint = 0);
|
|
|
|
virtual ~BCatalog();
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
const char* GetString(const char* string,
|
|
|
|
const char* context = NULL,
|
|
|
|
const char* comment = NULL);
|
|
|
|
const char* GetString(uint32 id);
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
const char* GetNoAutoCollectString(const char* string,
|
|
|
|
const char* context = NULL,
|
|
|
|
const char* comment = NULL);
|
|
|
|
const char* GetNoAutoCollectString(uint32 id);
|
2010-07-26 02:47:39 +04:00
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
status_t GetData(const char* name, BMessage* msg);
|
|
|
|
status_t GetData(uint32 id, BMessage* msg);
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
status_t GetSignature(BString* signature);
|
|
|
|
status_t GetLanguage(BString* language);
|
|
|
|
status_t GetFingerprint(uint32* fingerprint);
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2011-10-31 12:57:09 +04:00
|
|
|
status_t SetCatalog(const entry_ref& catalogOwner,
|
2010-11-03 00:36:35 +03:00
|
|
|
uint32 fingerprint);
|
2010-07-01 15:54:09 +04:00
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
status_t InitCheck() const;
|
|
|
|
int32 CountItems() const;
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
BCatalogAddOn* CatalogAddOn();
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
protected:
|
|
|
|
BCatalog(const BCatalog&);
|
|
|
|
const BCatalog& operator= (const BCatalog&);
|
|
|
|
// hide assignment and copy-constructor
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
BCatalogAddOn* fCatalog;
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
private:
|
|
|
|
friend class BLocale;
|
|
|
|
friend status_t get_add_on_catalog(BCatalog*, const char*);
|
2009-05-01 23:23:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-03-26 01:13:48 +03:00
|
|
|
#undef B_TRANSLATE_SYSTEM_NAME_CONTEXT
|
|
|
|
#define B_TRANSLATE_SYSTEM_NAME_CONTEXT "System name"
|
2011-03-13 20:29:10 +03:00
|
|
|
|
|
|
|
|
2010-07-26 02:47:39 +04:00
|
|
|
#ifndef B_COLLECTING_CATKEYS
|
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
#ifndef B_AVOID_TRANSLATION_MACROS
|
|
|
|
// macros for easy catalog-access, define B_AVOID_TRANSLATION_MACROS if
|
2010-07-26 02:47:39 +04:00
|
|
|
// you don't want these (in which case you need to collect the catalog keys
|
|
|
|
// manually, as collectcatkeys won't do it for you):
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
// TODO: maybe rename this to B_TRANSLATE_DEFAULT_CONTEXT, so that
|
|
|
|
// B_TRANSLATE_WITH_CONTEXT() can just be called B_TRANSLATE_CONTEXT()
|
2010-05-08 02:59:42 +04:00
|
|
|
#undef B_TRANSLATE_CONTEXT
|
2009-05-02 01:56:16 +04:00
|
|
|
// In a single application, several strings (e.g. 'Ok') will be used
|
|
|
|
// more than once, in different contexts.
|
2009-05-01 23:23:59 +04:00
|
|
|
// As the application programmer can not know if all translations of
|
|
|
|
// this string will be the same for all languages, each occurrence of
|
|
|
|
// the string must be translated on its own.
|
|
|
|
// Specifying the context explicitly with each string allows the person
|
|
|
|
// translating a catalog to separate these different occurrences of the
|
2009-05-02 01:56:16 +04:00
|
|
|
// same string and tell which strings appears in what context of the
|
2009-05-01 23:23:59 +04:00
|
|
|
// application.
|
|
|
|
// In order to give the translator a useful hint, the application
|
2010-05-08 02:59:42 +04:00
|
|
|
// programmer needs to define B_TRANSLATE_CONTEXT with the context he'd
|
|
|
|
// like to be associated with the strings used in this specifc source file.
|
2009-05-01 23:23:59 +04:00
|
|
|
// example:
|
2010-05-08 02:59:42 +04:00
|
|
|
// #define B_TRANSLATE_CONTEXT "Folder-Window"
|
2009-05-02 01:56:16 +04:00
|
|
|
// Tip: Use a descriptive name of the class implemented in that
|
|
|
|
// source-file.
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
// Translation macros which may be used to shorten translation requests:
|
2010-05-10 18:44:54 +04:00
|
|
|
#undef B_TRANSLATE
|
2010-11-03 00:36:35 +03:00
|
|
|
#define B_TRANSLATE(string) \
|
2010-11-22 16:06:36 +03:00
|
|
|
BLocaleRoster::Default()->GetCatalog()->GetString((string), \
|
|
|
|
B_TRANSLATE_CONTEXT)
|
2010-11-03 00:36:35 +03:00
|
|
|
|
|
|
|
#undef B_TRANSLATE_WITH_CONTEXT
|
|
|
|
#define B_TRANSLATE_WITH_CONTEXT(string, context) \
|
2010-11-22 16:06:36 +03:00
|
|
|
BLocaleRoster::Default()->GetCatalog()->GetString((string), (context))
|
2010-07-01 15:54:09 +04:00
|
|
|
|
|
|
|
#undef B_TRANSLATE_COMMENT
|
2010-11-03 00:36:35 +03:00
|
|
|
#define B_TRANSLATE_COMMENT(string, comment) \
|
2010-11-22 16:06:36 +03:00
|
|
|
BLocaleRoster::Default()->GetCatalog()->GetString((string), \
|
|
|
|
B_TRANSLATE_CONTEXT, (comment))
|
2010-07-01 15:54:09 +04:00
|
|
|
|
|
|
|
#undef B_TRANSLATE_ALL
|
2010-11-03 00:36:35 +03:00
|
|
|
#define B_TRANSLATE_ALL(string, context, comment) \
|
2010-11-22 16:06:36 +03:00
|
|
|
BLocaleRoster::Default()->GetCatalog()->GetString((string), (context), \
|
|
|
|
(comment))
|
2010-07-01 15:54:09 +04:00
|
|
|
|
|
|
|
#undef B_TRANSLATE_ID
|
|
|
|
#define B_TRANSLATE_ID(id) \
|
2010-11-22 16:06:36 +03:00
|
|
|
BLocaleRoster::Default()->GetCatalog()->GetString((id))
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2011-03-26 01:13:48 +03:00
|
|
|
#undef B_TRANSLATE_SYSTEM_NAME
|
|
|
|
#define B_TRANSLATE_SYSTEM_NAME(string) \
|
2011-03-15 19:00:58 +03:00
|
|
|
BLocaleRoster::Default()->IsFilesystemTranslationPreferred() \
|
|
|
|
? BLocaleRoster::Default()->GetCatalog()->GetString((string), \
|
2011-03-26 01:13:48 +03:00
|
|
|
B_TRANSLATE_SYSTEM_NAME_CONTEXT) : (string)
|
2011-03-15 19:00:58 +03:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
// Translation markers which can be used to mark static strings/IDs which
|
|
|
|
// are used as key for translation requests (at other places in the code):
|
|
|
|
/* example:
|
2010-05-08 02:59:42 +04:00
|
|
|
#define B_TRANSLATE_CONTEXT "MyDecentApp-Menu"
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
static const char *choices[] = {
|
2010-05-10 18:44:54 +04:00
|
|
|
B_TRANSLATE_MARK("left"),
|
|
|
|
B_TRANSLATE_MARK("right"),
|
|
|
|
B_TRANSLATE_MARK("up"),
|
|
|
|
B_TRANSLATE_MARK("down")
|
2009-05-01 23:23:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
void MyClass::AddChoices(BMenu *menu) {
|
|
|
|
for (char **ch = choices; *ch; ch++) {
|
|
|
|
menu->AddItem(
|
|
|
|
new BMenuItem(
|
2010-05-10 18:44:54 +04:00
|
|
|
B_TRANSLATE(*ch),
|
2009-05-01 23:23:59 +04:00
|
|
|
new BMessage(...)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2010-05-10 18:44:54 +04:00
|
|
|
#undef B_TRANSLATE_MARK
|
2010-05-06 19:42:48 +04:00
|
|
|
#define B_TRANSLATE_MARK(str) \
|
2010-05-08 02:59:42 +04:00
|
|
|
BCatalogAddOn::MarkForTranslation((str), B_TRANSLATE_CONTEXT, "")
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2010-05-10 18:44:54 +04:00
|
|
|
#undef B_TRANSLATE_MARK_COMMENT
|
2010-05-06 19:42:48 +04:00
|
|
|
#define B_TRANSLATE_MARK_COMMENT(str, cmt) \
|
2010-05-08 02:59:42 +04:00
|
|
|
BCatalogAddOn::MarkForTranslation((str), B_TRANSLATE_CONTEXT, (cmt))
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2010-05-10 18:44:54 +04:00
|
|
|
#undef B_TRANSLATE_MARK_ALL
|
2010-05-06 19:42:48 +04:00
|
|
|
#define B_TRANSLATE_MARK_ALL(str, ctx, cmt) \
|
|
|
|
BCatalogAddOn::MarkForTranslation((str), (ctx), (cmt))
|
2009-05-02 01:56:16 +04:00
|
|
|
|
2010-05-10 18:44:54 +04:00
|
|
|
#undef B_TRANSLATE_MARK_ID
|
2010-05-06 19:42:48 +04:00
|
|
|
#define B_TRANSLATE_MARK_ID(id) \
|
|
|
|
BCatalogAddOn::MarkForTranslation((id))
|
2009-05-02 01:56:16 +04:00
|
|
|
|
2011-03-26 01:13:48 +03:00
|
|
|
#undef B_TRANSLATE_MARK_SYSTEM_NAME
|
|
|
|
#define B_TRANSLATE_MARK_SYSTEM_NAME(str) \
|
|
|
|
BCatalogAddOn::MarkForTranslation((str), B_TRANSLATE_SYSTEM_NAME_CONTEXT, "")
|
2011-03-13 20:29:10 +03:00
|
|
|
|
2010-07-26 02:47:39 +04:00
|
|
|
// Translation macros which do not let collectcatkeys try to collect the key
|
|
|
|
// (useful in combination with the marking macros above):
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT
|
|
|
|
#define B_TRANSLATE_NOCOLLECT(str) \
|
|
|
|
B_TRANSLATE(str)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT_COMMENT
|
|
|
|
#define B_TRANSLATE_NOCOLLECT_COMMENT(str, cmt) \
|
|
|
|
B_TRANSLATE_COMMENT(str, cmt)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT_ALL
|
|
|
|
#define B_TRANSLATE_NOCOLLECT_ALL(str, ctx, cmt) \
|
|
|
|
B_TRANSLATE_ALL(str, ctx, cmt)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT_ID
|
|
|
|
#define B_TRANSLATE_NOCOLLECT_ID(id) \
|
|
|
|
B_TRANSLATE_ID(id)
|
|
|
|
|
2011-03-26 01:13:48 +03:00
|
|
|
#undef B_TRANSLATE_NOCOLLECT_SYSTEM_NAME
|
|
|
|
#define B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(str) \
|
|
|
|
B_TRANSLATE_SYSTEM_NAME(str)
|
2011-03-15 19:00:58 +03:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
#endif /* B_AVOID_TRANSLATION_MACROS */
|
|
|
|
|
2010-07-26 02:47:39 +04:00
|
|
|
#else /* B_COLLECTING_CATKEYS */
|
2010-11-03 00:36:35 +03:00
|
|
|
// TODO: why define them here? Since we obviously control the preprocessor, we
|
|
|
|
// could simply always include a certain file that defines them; this doesn't
|
|
|
|
// really belong into a public header.
|
2010-07-26 02:47:39 +04:00
|
|
|
|
|
|
|
// Translation macros used when executing collectcatkeys
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_CONTEXT
|
|
|
|
|
|
|
|
#undef B_TRANSLATE
|
2010-11-03 00:36:35 +03:00
|
|
|
#define B_TRANSLATE(string) \
|
|
|
|
B_CATKEY((string), B_TRANSLATE_CONTEXT)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_WITH_CONTEXT
|
|
|
|
#define B_TRANSLATE_WITH_CONTEXT(string, context) \
|
|
|
|
B_CATKEY((string), (context))
|
2010-07-26 02:47:39 +04:00
|
|
|
|
|
|
|
#undef B_TRANSLATE_COMMENT
|
2010-11-03 00:36:35 +03:00
|
|
|
#define B_TRANSLATE_COMMENT(string, comment) \
|
|
|
|
B_CATKEY((string), B_TRANSLATE_CONTEXT, (comment))
|
2010-07-26 02:47:39 +04:00
|
|
|
|
|
|
|
#undef B_TRANSLATE_ALL
|
2010-11-03 00:36:35 +03:00
|
|
|
#define B_TRANSLATE_ALL(string, context, comment) \
|
|
|
|
B_CATKEY((string), (context), (comment))
|
2010-07-26 02:47:39 +04:00
|
|
|
|
|
|
|
#undef B_TRANSLATE_ID
|
|
|
|
#define B_TRANSLATE_ID(id) \
|
|
|
|
B_CATKEY((id))
|
|
|
|
|
2011-03-26 01:13:48 +03:00
|
|
|
#undef B_TRANSLATE_SYSTEM_NAME
|
|
|
|
#define B_TRANSLATE_SYSTEM_NAME(string) \
|
|
|
|
B_CATKEY((string), B_TRANSLATE_SYSTEM_NAME_CONTEXT)
|
2011-03-15 19:00:58 +03:00
|
|
|
|
2010-07-26 02:47:39 +04:00
|
|
|
#undef B_TRANSLATE_MARK
|
|
|
|
#define B_TRANSLATE_MARK(str) \
|
|
|
|
B_CATKEY((str), B_TRANSLATE_CONTEXT)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_MARK_COMMENT
|
|
|
|
#define B_TRANSLATE_MARK_COMMENT(str, cmt) \
|
|
|
|
B_CATKEY((str), B_TRANSLATE_CONTEXT, (cmt))
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_MARK_ALL
|
|
|
|
#define B_TRANSLATE_MARK_ALL(str, ctx, cmt) \
|
|
|
|
B_CATKEY((str), (ctx), (cmt))
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_MARK_ID
|
|
|
|
#define B_TRANSLATE_MARK_ID(id) \
|
|
|
|
B_CATKEY((id))
|
|
|
|
|
2011-03-26 01:13:48 +03:00
|
|
|
#undef B_TRANSLATE_MARK_SYSTEM_NAME
|
|
|
|
#define B_TRANSLATE_MARK_SYSTEM_NAME(str) \
|
|
|
|
B_CATKEY((str), B_TRANSLATE_SYSTEM_NAME_CONTEXT, "")
|
2011-03-13 20:29:10 +03:00
|
|
|
|
2010-07-26 02:47:39 +04:00
|
|
|
#undef B_TRANSLATE_NOCOLLECT
|
|
|
|
#define B_TRANSLATE_NOCOLLECT(str) \
|
|
|
|
(void)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT_COMMENT
|
|
|
|
#define B_TRANSLATE_NOCOLLECT_COMMENT(str, cmt) \
|
|
|
|
(void)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT_ALL
|
|
|
|
#define B_TRANSLATE_NOCOLLECT_ALL(str, ctx, cmt) \
|
|
|
|
(void)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT_ID
|
|
|
|
#define B_TRANSLATE_NOCOLLECT_ID(id) \
|
|
|
|
(void)
|
|
|
|
|
2011-03-26 01:13:48 +03:00
|
|
|
#undef B_TRANSLATE_NOCOLLECT_SYSTEM_NAME
|
|
|
|
#define B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(str) \
|
2011-03-15 19:00:58 +03:00
|
|
|
(void)
|
|
|
|
|
2010-07-26 02:47:39 +04:00
|
|
|
#endif /* B_COLLECTING_CATKEYS */
|
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
// For BCatalog add-on implementations:
|
2010-11-03 00:36:35 +03:00
|
|
|
// TODO: should go into another header
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
class BCatalogAddOn {
|
2010-11-03 00:36:35 +03:00
|
|
|
public:
|
|
|
|
BCatalogAddOn(const char* signature,
|
|
|
|
const char* language,
|
|
|
|
uint32 fingerprint);
|
|
|
|
virtual ~BCatalogAddOn();
|
|
|
|
|
|
|
|
virtual const char* GetString(const char* string,
|
|
|
|
const char* context = NULL,
|
|
|
|
const char* comment = NULL) = 0;
|
|
|
|
virtual const char* GetString(uint32 id) = 0;
|
|
|
|
|
|
|
|
status_t InitCheck() const;
|
|
|
|
BCatalogAddOn* Next();
|
|
|
|
|
|
|
|
// the following could be used to localize non-textual data (e.g.
|
|
|
|
// icons), but these will only be implemented if there's demand for such
|
|
|
|
// a feature:
|
|
|
|
virtual bool CanHaveData() const;
|
|
|
|
virtual status_t GetData(const char* name, BMessage* msg);
|
|
|
|
virtual status_t GetData(uint32 id, BMessage* msg);
|
|
|
|
|
|
|
|
// interface for catalog-editor-app and testing apps:
|
|
|
|
virtual status_t SetString(const char* string,
|
|
|
|
const char* translated,
|
|
|
|
const char* context = NULL,
|
|
|
|
const char* comment = NULL);
|
|
|
|
virtual status_t SetString(int32 id, const char* translated);
|
|
|
|
|
|
|
|
virtual bool CanWriteData() const;
|
|
|
|
virtual status_t SetData(const char* name, BMessage* msg);
|
|
|
|
virtual status_t SetData(uint32 id, BMessage* msg);
|
|
|
|
|
|
|
|
virtual status_t ReadFromFile(const char* path = NULL);
|
2011-11-01 14:13:34 +04:00
|
|
|
virtual status_t ReadFromAttribute(
|
|
|
|
const entry_ref& appOrAddOnRef);
|
|
|
|
virtual status_t ReadFromResource(
|
|
|
|
const entry_ref& appOrAddOnRef);
|
2010-11-03 00:36:35 +03:00
|
|
|
virtual status_t WriteToFile(const char* path = NULL);
|
2011-11-01 14:13:34 +04:00
|
|
|
virtual status_t WriteToAttribute(
|
|
|
|
const entry_ref& appOrAddOnRef);
|
|
|
|
virtual status_t WriteToResource(
|
|
|
|
const entry_ref& appOrAddOnRef);
|
2010-11-03 00:36:35 +03:00
|
|
|
|
|
|
|
virtual void MakeEmpty();
|
|
|
|
virtual int32 CountItems() const;
|
|
|
|
|
|
|
|
// magic marker functions which are used to mark a string/id
|
|
|
|
// which will be translated elsewhere in the code (where it can
|
|
|
|
// not be found since it is references by a variable):
|
|
|
|
static const char* MarkForTranslation(const char* string,
|
|
|
|
const char* context, const char* comment);
|
|
|
|
static int32 MarkForTranslation(int32 id);
|
|
|
|
|
|
|
|
void SetNext(BCatalogAddOn* next);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void UpdateFingerprint();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
friend class BCatalog;
|
|
|
|
friend status_t get_add_on_catalog(BCatalog*, const char*);
|
|
|
|
|
|
|
|
status_t fInitCheck;
|
|
|
|
BString fSignature;
|
|
|
|
BString fLanguageName;
|
|
|
|
uint32 fFingerprint;
|
|
|
|
BCatalogAddOn* fNext;
|
2009-05-01 23:23:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// every catalog-add-on should export these symbols...
|
|
|
|
// ...the function that instantiates a catalog for this add-on-type...
|
2009-05-02 01:56:16 +04:00
|
|
|
extern "C"
|
2009-05-01 23:23:59 +04:00
|
|
|
BCatalogAddOn *instantiate_catalog(const char *signature,
|
2009-09-19 02:23:34 +04:00
|
|
|
const char *language, uint32 fingerprint);
|
2009-05-01 23:23:59 +04:00
|
|
|
// ...the function that creates an empty catalog for this add-on-type...
|
2009-05-02 01:56:16 +04:00
|
|
|
extern "C"
|
2009-05-01 23:23:59 +04:00
|
|
|
BCatalogAddOn *create_catalog(const char *signature,
|
|
|
|
const char *language);
|
|
|
|
// ...and the priority which will be used to order the catalog-add-ons:
|
2009-05-02 01:56:16 +04:00
|
|
|
extern uint8 gCatalogAddOnPriority;
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BCatalog - inlines for trivial accessors:
|
|
|
|
*/
|
|
|
|
inline status_t
|
2009-05-02 01:56:16 +04:00
|
|
|
BCatalog::GetSignature(BString *sig)
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
|
|
|
if (!sig)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
if (!fCatalog)
|
|
|
|
return B_NO_INIT;
|
|
|
|
*sig = fCatalog->fSignature;
|
|
|
|
return B_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
inline status_t
|
|
|
|
BCatalog::GetLanguage(BString *lang)
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
|
|
|
if (!lang)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
if (!fCatalog)
|
|
|
|
return B_NO_INIT;
|
|
|
|
*lang = fCatalog->fLanguageName;
|
|
|
|
return B_OK;
|
2009-05-02 01:56:16 +04:00
|
|
|
}
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
inline status_t
|
2009-09-19 02:23:34 +04:00
|
|
|
BCatalog::GetFingerprint(uint32 *fp)
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
|
|
|
if (!fp)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
if (!fCatalog)
|
|
|
|
return B_NO_INIT;
|
|
|
|
*fp = fCatalog->fFingerprint;
|
|
|
|
return B_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-26 02:47:39 +04:00
|
|
|
inline const char *
|
|
|
|
BCatalog::GetNoAutoCollectString(const char *string, const char *context,
|
|
|
|
const char *comment)
|
|
|
|
{
|
|
|
|
return GetString(string, context, comment);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline const char *
|
|
|
|
BCatalog::GetNoAutoCollectString(uint32 id)
|
|
|
|
{
|
|
|
|
return GetString(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
inline status_t
|
|
|
|
BCatalog::InitCheck() const
|
|
|
|
{
|
2009-05-02 01:56:16 +04:00
|
|
|
return fCatalog
|
|
|
|
? fCatalog->InitCheck()
|
2009-05-01 23:23:59 +04:00
|
|
|
: B_NO_INIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
inline int32
|
2009-05-01 23:23:59 +04:00
|
|
|
BCatalog::CountItems() const
|
|
|
|
{
|
|
|
|
if (!fCatalog)
|
|
|
|
return 0;
|
|
|
|
return fCatalog->CountItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline BCatalogAddOn *
|
2009-05-02 01:56:16 +04:00
|
|
|
BCatalog::CatalogAddOn()
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
|
|
|
return fCatalog;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BCatalogAddOn - inlines for trivial accessors:
|
|
|
|
*/
|
|
|
|
inline BCatalogAddOn *
|
2009-05-02 01:56:16 +04:00
|
|
|
BCatalogAddOn::Next()
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
|
|
|
return fNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const char *
|
2010-07-26 02:47:39 +04:00
|
|
|
BCatalogAddOn::MarkForTranslation(const char *str, const char *ctx,
|
2009-05-02 01:56:16 +04:00
|
|
|
const char *cmt)
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline int32
|
2010-07-26 02:47:39 +04:00
|
|
|
BCatalogAddOn::MarkForTranslation(int32 id)
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
// TODO: does not belong here, either
|
2009-05-01 23:23:59 +04:00
|
|
|
namespace BPrivate {
|
|
|
|
|
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
class EditableCatalog : public BCatalog {
|
|
|
|
public:
|
|
|
|
EditableCatalog(const char* type,
|
|
|
|
const char* signature,
|
|
|
|
const char* language);
|
|
|
|
virtual ~EditableCatalog();
|
|
|
|
|
|
|
|
status_t SetString(const char* string,
|
|
|
|
const char* translated,
|
|
|
|
const char* context = NULL,
|
|
|
|
const char* comment = NULL);
|
|
|
|
status_t SetString(int32 id, const char* translated);
|
|
|
|
|
|
|
|
bool CanWriteData() const;
|
|
|
|
status_t SetData(const char* name, BMessage* msg);
|
|
|
|
status_t SetData(uint32 id, BMessage* msg);
|
|
|
|
|
|
|
|
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);
|
2010-11-03 00:36:35 +03: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);
|
2010-11-03 00:36:35 +03:00
|
|
|
|
|
|
|
void MakeEmpty();
|
|
|
|
|
|
|
|
private:
|
|
|
|
EditableCatalog();
|
|
|
|
EditableCatalog(const EditableCatalog& other);
|
|
|
|
const EditableCatalog& operator=(const EditableCatalog& other);
|
|
|
|
// hide assignment, default-, and
|
|
|
|
// copy-constructor
|
2009-05-01 23:23:59 +04:00
|
|
|
};
|
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
} // namespace BPrivate
|
|
|
|
|
2010-11-03 00:36:35 +03:00
|
|
|
|
2009-09-20 21:57:06 +04:00
|
|
|
#endif /* _CATALOG_H_ */
|