* Coding style

* Stub out the unneeded code in the buildtool version of DefaultCatalog.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43022 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues 2011-10-31 09:16:38 +00:00
parent 54fad654ce
commit 924ead9a3e
2 changed files with 42 additions and 58 deletions

View File

@ -56,35 +56,6 @@ const uint8 DefaultCatalog::kDefaultCatalogAddOnPriority = 1;
// give highest priority to our embedded catalog-add-on
void DefaultCatalog::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) {
log_team(LOG_ERR, "File %s has no mimesignature, so it can't use"
" localization.", catalogOwner.name);
fSignature = "";
return;
}
// drop supertype from mimetype (should be "application/"):
char* stripSignature = objectSignature;
while (*stripSignature != '/' && *stripSignature != '\0')
stripSignature ++;
if (*stripSignature == '\0')
stripSignature = objectSignature;
else
stripSignature ++;
log_team(LOG_DEBUG, "Image %s requested catalog with mimetype %s",
catalogOwner.name, stripSignature);
fSignature = stripSignature;
}
/*! Constructs a DefaultCatalog with given signature and language and reads
the catalog from disk.
InitCheck() will be B_OK if catalog could be loaded successfully, it will
@ -187,6 +158,36 @@ DefaultCatalog::~DefaultCatalog()
}
void
DefaultCatalog::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) {
log_team(LOG_ERR, "File %s has no mimesignature, so it can't use"
" localization.", catalogOwner.name);
fSignature = "";
return;
}
// drop supertype from mimetype (should be "application/"):
char* stripSignature = objectSignature;
while (*stripSignature != '/' && *stripSignature != '\0')
stripSignature ++;
if (*stripSignature == '\0')
stripSignature = objectSignature;
else
stripSignature ++;
log_team(LOG_DEBUG, "Image %s requested catalog with mimetype %s",
catalogOwner.name, stripSignature);
fSignature = stripSignature;
}
status_t
DefaultCatalog::SetRawString(const CatKey& key, const char *translated)
{

View File

@ -56,45 +56,20 @@ static int16 kCatArchiveVersion = 1;
// version of the catalog archive structure, bump this if you change it!
const char* getCatalogSignature(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) {
log_team(LOG_ERR, "File %s has no mimesignature, so it can't use"
" localization.", catalogOwner.name);
return NULL;
}
// drop supertype from mimetype (should be "application/"):
char* stripSignature = objectSignature;
while (*stripSignature != '/')
stripSignature ++;
stripSignature ++;
log_team(LOG_DEBUG, "Image %s requested catalog with mimetype %s",
catalogOwner.name, stripSignature);
return stripSignature;
}
/*! Constructs a DefaultCatalog with given signature and language and reads
the catalog from disk.
InitCheck() will be B_OK if catalog could be loaded successfully, it will
give an appropriate error-code otherwise.
*/
DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner, const char *language,
uint32 fingerprint)
DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner,
const char *language, uint32 fingerprint)
:
BHashMapCatalog(getCatalogSignature(catalogOwner), language, fingerprint)
BHashMapCatalog("", language, fingerprint)
{
fInitCheck = B_NOT_SUPPORTED;
fprintf(stderr,
"trying to load default-catalog(sig=%s, lang=%s) results in %s",
getCatalogSignature(catalogOwner), language, strerror(fInitCheck));
"", language, strerror(fInitCheck));
}
@ -133,6 +108,14 @@ DefaultCatalog::~DefaultCatalog()
}
void
DefaultCatalog::SetSignature(const entry_ref &catalogOwner)
{
// Not allowed for the build-tool version.
return;
}
status_t
DefaultCatalog::SetRawString(const CatKey& key, const char *translated)
{