Fix instanciate_catalog prototype
The prototype didn't match what the Locale Kit actually uses, making the plaintext catalog (and any other add-on) unusable.
This commit is contained in:
parent
412f030b0f
commit
4bb4130ff2
headers
src/add-ons/locale/catalogs/plaintext
@ -99,8 +99,8 @@ BCatalogData::Next()
|
||||
//
|
||||
// 1. the function that instantiates a catalog for this add-on-type
|
||||
extern "C"
|
||||
BCatalogData* instantiate_catalog(const char* signature, const char* language,
|
||||
uint32 fingerprint);
|
||||
BCatalogData* instantiate_catalog(const entry_ref& signature,
|
||||
const char* language, uint32 fingerprint);
|
||||
|
||||
// 2. the function that creates an empty catalog for this add-on-type
|
||||
extern "C"
|
||||
|
@ -18,22 +18,22 @@ namespace BPrivate {
|
||||
|
||||
class PlainTextCatalog : public HashMapCatalog {
|
||||
public:
|
||||
PlainTextCatalog(const char *signature, const char *language,
|
||||
PlainTextCatalog(const entry_ref& owner, const char *language,
|
||||
uint32 fingerprint);
|
||||
// constructor for normal use
|
||||
PlainTextCatalog(entry_ref *appOrAddOnRef);
|
||||
// constructor for embedded catalog
|
||||
PlainTextCatalog(const char *path, const char *signature,
|
||||
const char *language);
|
||||
// constructor for editor-app
|
||||
|
||||
~PlainTextCatalog();
|
||||
|
||||
void SetSignature(const entry_ref &catalogOwner);
|
||||
|
||||
// implementation for editor-interface:
|
||||
status_t ReadFromFile(const char *path = NULL);
|
||||
status_t WriteToFile(const char *path = NULL);
|
||||
|
||||
static BCatalogData *Instantiate(const char *signature,
|
||||
static BCatalogData *Instantiate(const entry_ref &signature,
|
||||
const char *language, uint32 fingerprint);
|
||||
|
||||
static const char *kCatMimeType;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <AppFileInfo.h>
|
||||
#include <Application.h>
|
||||
#include <Directory.h>
|
||||
#include <File.h>
|
||||
@ -74,11 +75,14 @@ escapeQuotedChars(BString& stringToEscape)
|
||||
* InitCheck() will be B_OK if catalog could be loaded successfully, it will
|
||||
* give an appropriate error-code otherwise.
|
||||
*/
|
||||
PlainTextCatalog::PlainTextCatalog(const char *signature, const char *language,
|
||||
PlainTextCatalog::PlainTextCatalog(const entry_ref &owner, const char *language,
|
||||
uint32 fingerprint)
|
||||
:
|
||||
HashMapCatalog(signature, language, fingerprint)
|
||||
HashMapCatalog("", language, fingerprint)
|
||||
{
|
||||
// We created the catalog with an invalid signature, but we fix that now.
|
||||
SetSignature(owner);
|
||||
|
||||
// give highest priority to catalog living in sub-folder of app's folder:
|
||||
app_info appInfo;
|
||||
be_app->GetAppInfo(&appInfo);
|
||||
@ -146,6 +150,32 @@ PlainTextCatalog::~PlainTextCatalog()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlainTextCatalog::SetSignature(const entry_ref &catalogOwner)
|
||||
{
|
||||
// figure out mimetype from image
|
||||
BFile objectFile(&catalogOwner, B_READ_ONLY);
|
||||
BAppFileInfo objectInfo(&objectFile);
|
||||
char objectSignature[B_MIME_TYPE_LENGTH];
|
||||
if (objectInfo.GetSignature(objectSignature) != B_OK) {
|
||||
fSignature = "";
|
||||
return;
|
||||
}
|
||||
|
||||
// drop supertype from mimetype (should be "application/"):
|
||||
char* stripSignature = objectSignature;
|
||||
while (*stripSignature != '/' && *stripSignature != '\0')
|
||||
stripSignature ++;
|
||||
|
||||
if (*stripSignature == '\0')
|
||||
stripSignature = objectSignature;
|
||||
else
|
||||
stripSignature ++;
|
||||
|
||||
fSignature = stripSignature;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
PlainTextCatalog::ReadFromFile(const char *path)
|
||||
{
|
||||
@ -353,11 +383,11 @@ PlainTextCatalog::UpdateAttributes(const char* path)
|
||||
|
||||
|
||||
BCatalogData *
|
||||
PlainTextCatalog::Instantiate(const char *signature, const char *language,
|
||||
PlainTextCatalog::Instantiate(const entry_ref& owner, const char *language,
|
||||
uint32 fingerprint)
|
||||
{
|
||||
PlainTextCatalog *catalog
|
||||
= new(std::nothrow) PlainTextCatalog(signature, language, fingerprint);
|
||||
= new(std::nothrow) PlainTextCatalog(owner, language, fingerprint);
|
||||
if (catalog && catalog->InitCheck() != B_OK) {
|
||||
delete catalog;
|
||||
return NULL;
|
||||
@ -367,11 +397,11 @@ PlainTextCatalog::Instantiate(const char *signature, const char *language,
|
||||
|
||||
|
||||
extern "C" BCatalogData *
|
||||
instantiate_catalog(const char *signature, const char *language,
|
||||
instantiate_catalog(const entry_ref& owner, const char *language,
|
||||
uint32 fingerprint)
|
||||
{
|
||||
PlainTextCatalog *catalog
|
||||
= new(std::nothrow) PlainTextCatalog(signature, language, fingerprint);
|
||||
= new(std::nothrow) PlainTextCatalog(owner, language, fingerprint);
|
||||
if (catalog && catalog->InitCheck() != B_OK) {
|
||||
delete catalog;
|
||||
return NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user