Adjust Locale Kit to no longer use syslog
This commit is contained in:
@@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
|
||||||
#include <syslog.h>
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <CatalogData.h>
|
#include <CatalogData.h>
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <syslog.h>
|
|
||||||
|
|
||||||
#include <AppFileInfo.h>
|
#include <AppFileInfo.h>
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
@@ -118,9 +117,6 @@ DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner, const char *langua
|
|||||||
}
|
}
|
||||||
|
|
||||||
fInitCheck = status;
|
fInitCheck = status;
|
||||||
log_team(LOG_DEBUG,
|
|
||||||
"trying to load default-catalog(sig=%s, lang=%s) results in %s",
|
|
||||||
fSignature.String(), language, strerror(fInitCheck));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -134,9 +130,6 @@ DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef)
|
|||||||
HashMapCatalog("", "", 0)
|
HashMapCatalog("", "", 0)
|
||||||
{
|
{
|
||||||
fInitCheck = ReadFromResource(*appOrAddOnRef);
|
fInitCheck = ReadFromResource(*appOrAddOnRef);
|
||||||
log_team(LOG_DEBUG,
|
|
||||||
"trying to load embedded catalog from resources results in %s",
|
|
||||||
strerror(fInitCheck));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -167,8 +160,6 @@ DefaultCatalog::SetSignature(const entry_ref &catalogOwner)
|
|||||||
BAppFileInfo objectInfo(&objectFile);
|
BAppFileInfo objectInfo(&objectFile);
|
||||||
char objectSignature[B_MIME_TYPE_LENGTH];
|
char objectSignature[B_MIME_TYPE_LENGTH];
|
||||||
if (objectInfo.GetSignature(objectSignature) != B_OK) {
|
if (objectInfo.GetSignature(objectSignature) != B_OK) {
|
||||||
log_team(LOG_ERR, "File %s has no mimesignature, so it can't use"
|
|
||||||
" localization.", catalogOwner.name);
|
|
||||||
fSignature = "";
|
fSignature = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -183,8 +174,6 @@ DefaultCatalog::SetSignature(const entry_ref &catalogOwner)
|
|||||||
else
|
else
|
||||||
stripSignature ++;
|
stripSignature ++;
|
||||||
|
|
||||||
log_team(LOG_DEBUG, "Image %s requested catalog with mimetype %s",
|
|
||||||
catalogOwner.name, stripSignature);
|
|
||||||
fSignature = stripSignature;
|
fSignature = stripSignature;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,40 +193,25 @@ DefaultCatalog::ReadFromFile(const char *path)
|
|||||||
|
|
||||||
BFile catalogFile;
|
BFile catalogFile;
|
||||||
status_t res = catalogFile.SetTo(path, B_READ_ONLY);
|
status_t res = catalogFile.SetTo(path, B_READ_ONLY);
|
||||||
if (res != B_OK) {
|
if (res != B_OK)
|
||||||
log_team(LOG_DEBUG, "LocaleKit DefaultCatalog: no catalog at %s", path);
|
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
}
|
|
||||||
|
|
||||||
fPath = path;
|
fPath = path;
|
||||||
log_team(LOG_DEBUG, "LocaleKit DefaultCatalog: found catalog at %s", path);
|
|
||||||
|
|
||||||
off_t sz = 0;
|
off_t sz = 0;
|
||||||
res = catalogFile.GetSize(&sz);
|
res = catalogFile.GetSize(&sz);
|
||||||
if (res != B_OK) {
|
if (res != B_OK) {
|
||||||
log_team(LOG_ERR, "LocaleKit DefaultCatalog: couldn't get size for "
|
|
||||||
"catalog-file %s", path);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto_ptr<char> buf(new(std::nothrow) char [sz]);
|
auto_ptr<char> buf(new(std::nothrow) char [sz]);
|
||||||
if (buf.get() == NULL) {
|
if (buf.get() == NULL)
|
||||||
log_team(LOG_ERR, "LocaleKit DefaultCatalog: couldn't allocate array "
|
|
||||||
"of %d chars", sz);
|
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
|
||||||
res = catalogFile.Read(buf.get(), sz);
|
res = catalogFile.Read(buf.get(), sz);
|
||||||
if (res < B_OK) {
|
if (res < B_OK)
|
||||||
log_team(LOG_ERR, "LocaleKit DefaultCatalog: couldn't read from "
|
|
||||||
"catalog-file %s", path);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
if (res < sz)
|
||||||
if (res < sz) {
|
|
||||||
log_team(LOG_ERR,
|
|
||||||
"LocaleKit DefaultCatalog: only got %lu instead of %Lu bytes from "
|
|
||||||
"catalog-file %s", res, sz, path);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
|
||||||
BMemoryIO memIO(buf.get(), sz);
|
BMemoryIO memIO(buf.get(), sz);
|
||||||
res = Unflatten(&memIO);
|
res = Unflatten(&memIO);
|
||||||
|
|
||||||
@@ -260,43 +234,24 @@ DefaultCatalog::ReadFromAttribute(const entry_ref &appOrAddOnRef)
|
|||||||
{
|
{
|
||||||
BNode node;
|
BNode node;
|
||||||
status_t res = node.SetTo(&appOrAddOnRef);
|
status_t res = node.SetTo(&appOrAddOnRef);
|
||||||
if (res != B_OK) {
|
if (res != B_OK)
|
||||||
log_team(LOG_ERR,
|
|
||||||
"couldn't find app or add-on (dev=%lu, dir=%Lu, name=%s)",
|
|
||||||
appOrAddOnRef.device, appOrAddOnRef.directory,
|
|
||||||
appOrAddOnRef.name);
|
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
}
|
|
||||||
|
|
||||||
log_team(LOG_DEBUG,
|
|
||||||
"looking for embedded catalog-attribute in app/add-on"
|
|
||||||
"(dev=%lu, dir=%Lu, name=%s)", appOrAddOnRef.device,
|
|
||||||
appOrAddOnRef.directory, appOrAddOnRef.name);
|
|
||||||
|
|
||||||
attr_info attrInfo;
|
attr_info attrInfo;
|
||||||
res = node.GetAttrInfo(BLocaleRoster::kEmbeddedCatAttr, &attrInfo);
|
res = node.GetAttrInfo(BLocaleRoster::kEmbeddedCatAttr, &attrInfo);
|
||||||
if (res != B_OK) {
|
if (res != B_OK)
|
||||||
log_team(LOG_DEBUG, "no embedded catalog found");
|
|
||||||
return B_NAME_NOT_FOUND;
|
return B_NAME_NOT_FOUND;
|
||||||
}
|
if (attrInfo.type != B_MESSAGE_TYPE)
|
||||||
if (attrInfo.type != B_MESSAGE_TYPE) {
|
|
||||||
log_team(LOG_ERR, "attribute %s has incorrect type and is ignored!",
|
|
||||||
BLocaleRoster::kEmbeddedCatAttr);
|
|
||||||
return B_BAD_TYPE;
|
return B_BAD_TYPE;
|
||||||
}
|
|
||||||
|
|
||||||
size_t size = attrInfo.size;
|
size_t size = attrInfo.size;
|
||||||
auto_ptr<char> buf(new(std::nothrow) char [size]);
|
auto_ptr<char> buf(new(std::nothrow) char [size]);
|
||||||
if (buf.get() == NULL) {
|
if (buf.get() == NULL)
|
||||||
log_team(LOG_ERR, "couldn't allocate array of %d chars", size);
|
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
|
||||||
res = node.ReadAttr(BLocaleRoster::kEmbeddedCatAttr, B_MESSAGE_TYPE, 0,
|
res = node.ReadAttr(BLocaleRoster::kEmbeddedCatAttr, B_MESSAGE_TYPE, 0,
|
||||||
buf.get(), size);
|
buf.get(), size);
|
||||||
if (res < (ssize_t)size) {
|
if (res < (ssize_t)size)
|
||||||
log_team(LOG_ERR, "unable to read embedded catalog from attribute");
|
|
||||||
return res < B_OK ? res : B_BAD_DATA;
|
return res < B_OK ? res : B_BAD_DATA;
|
||||||
}
|
|
||||||
|
|
||||||
BMemoryIO memIO(buf.get(), size);
|
BMemoryIO memIO(buf.get(), size);
|
||||||
res = Unflatten(&memIO);
|
res = Unflatten(&memIO);
|
||||||
@@ -310,35 +265,20 @@ DefaultCatalog::ReadFromResource(const entry_ref &appOrAddOnRef)
|
|||||||
{
|
{
|
||||||
BFile file;
|
BFile file;
|
||||||
status_t res = file.SetTo(&appOrAddOnRef, B_READ_ONLY);
|
status_t res = file.SetTo(&appOrAddOnRef, B_READ_ONLY);
|
||||||
if (res != B_OK) {
|
if (res != B_OK)
|
||||||
log_team(LOG_ERR,
|
|
||||||
"couldn't find app or add-on (dev=%lu, dir=%Lu, name=%s)",
|
|
||||||
appOrAddOnRef.device, appOrAddOnRef.directory,
|
|
||||||
appOrAddOnRef.name);
|
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
}
|
|
||||||
|
|
||||||
log_team(LOG_DEBUG,
|
|
||||||
"looking for embedded catalog-resource in app/add-on"
|
|
||||||
"(dev=%lu, dir=%Lu, name=%s)", appOrAddOnRef.device,
|
|
||||||
appOrAddOnRef.directory, appOrAddOnRef.name);
|
|
||||||
|
|
||||||
BResources rsrc;
|
BResources rsrc;
|
||||||
res = rsrc.SetTo(&file);
|
res = rsrc.SetTo(&file);
|
||||||
if (res != B_OK) {
|
if (res != B_OK)
|
||||||
log_team(LOG_DEBUG, "file has no resources");
|
|
||||||
return res;
|
return res;
|
||||||
}
|
|
||||||
|
|
||||||
int mangledLanguage = CatKey::HashFun(fLanguageName.String(), 0);
|
int mangledLanguage = CatKey::HashFun(fLanguageName.String(), 0);
|
||||||
|
|
||||||
size_t sz;
|
size_t sz;
|
||||||
const void *buf = rsrc.LoadResource('CADA',
|
const void *buf = rsrc.LoadResource('CADA', mangledLanguage, &sz);
|
||||||
mangledLanguage, &sz);
|
if (!buf)
|
||||||
if (!buf) {
|
|
||||||
log_team(LOG_DEBUG, "file has no catalog-resource");
|
|
||||||
return B_NAME_NOT_FOUND;
|
return B_NAME_NOT_FOUND;
|
||||||
}
|
|
||||||
|
|
||||||
BMemoryIO memIO(buf, sz);
|
BMemoryIO memIO(buf, sz);
|
||||||
res = Unflatten(&memIO);
|
res = Unflatten(&memIO);
|
||||||
@@ -540,11 +480,6 @@ DefaultCatalog::Unflatten(BDataIO *dataIO)
|
|||||||
// not accept this catalog:
|
// not accept this catalog:
|
||||||
if (foundFingerprint != 0 && fFingerprint != 0
|
if (foundFingerprint != 0 && fFingerprint != 0
|
||||||
&& foundFingerprint != fFingerprint) {
|
&& foundFingerprint != fFingerprint) {
|
||||||
log_team(LOG_INFO, "default-catalog(sig=%s, lang=%s) "
|
|
||||||
"has mismatching fingerprint (%ld instead of the requested %ld), "
|
|
||||||
"so this catalog is skipped.",
|
|
||||||
fSignature.String(), fLanguageName.String(), foundFingerprint,
|
|
||||||
fFingerprint);
|
|
||||||
res = B_MISMATCHED_VALUES;
|
res = B_MISMATCHED_VALUES;
|
||||||
} else
|
} else
|
||||||
fFingerprint = foundFingerprint;
|
fFingerprint = foundFingerprint;
|
||||||
@@ -580,14 +515,8 @@ DefaultCatalog::Unflatten(BDataIO *dataIO)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint32 checkFP = ComputeFingerprint();
|
uint32 checkFP = ComputeFingerprint();
|
||||||
if (fFingerprint != checkFP) {
|
if (fFingerprint != checkFP)
|
||||||
log_team(LOG_WARNING, "default-catalog(sig=%s, lang=%s) "
|
|
||||||
"has wrong fingerprint after load (%ld instead of the %ld). "
|
|
||||||
"The catalog data may be corrupted, so this catalog is skipped.",
|
|
||||||
fSignature.String(), fLanguageName.String(), checkFP,
|
|
||||||
fFingerprint);
|
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
* The required mimetypes and attribute-indices are created here.
|
* The required mimetypes and attribute-indices are created here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <syslog.h>
|
|
||||||
|
|
||||||
#include <fs_attr.h>
|
#include <fs_attr.h>
|
||||||
#include <fs_index.h>
|
#include <fs_index.h>
|
||||||
#include <Volume.h>
|
#include <Volume.h>
|
||||||
@@ -35,19 +33,8 @@ static void EnsureIndexExists(const char *attrName)
|
|||||||
if (volRoster.GetBootVolume(&bootVol) != B_OK)
|
if (volRoster.GetBootVolume(&bootVol) != B_OK)
|
||||||
return;
|
return;
|
||||||
struct index_info idxInfo;
|
struct index_info idxInfo;
|
||||||
if (fs_stat_index(bootVol.Device(), attrName, &idxInfo) != 0) {
|
if (fs_stat_index(bootVol.Device(), attrName, &idxInfo) != 0)
|
||||||
status_t res = fs_create_index(bootVol.Device(), attrName,
|
fs_create_index(bootVol.Device(), attrName, B_STRING_TYPE, 0);
|
||||||
B_STRING_TYPE, 0);
|
|
||||||
if (res == 0) {
|
|
||||||
log_team(LOG_INFO,
|
|
||||||
"successfully created the required index for attribute %s",
|
|
||||||
attrName);
|
|
||||||
} else {
|
|
||||||
log_team(LOG_ERR,
|
|
||||||
"failed to create the required index for attribute %s (%s)",
|
|
||||||
attrName, strerror(res));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -122,10 +109,6 @@ SetupCatalogBasics()
|
|||||||
if (res == B_OK)
|
if (res == B_OK)
|
||||||
res = mt.Install();
|
res = mt.Install();
|
||||||
}
|
}
|
||||||
if (res != B_OK) {
|
|
||||||
log_team(LOG_ERR, "Could not install mimetype %s (%s)",
|
|
||||||
DefaultCatalog::kCatMimeType, strerror(res));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <syslog.h>
|
|
||||||
|
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
@@ -521,11 +520,8 @@ BLocaleRoster::GetLocalizedFileName(BString& localizedFileName,
|
|||||||
// The signature is missing application/
|
// The signature is missing application/
|
||||||
signature.Prepend("application/");
|
signature.Prepend("application/");
|
||||||
status = roster.FindApp(signature, &catalogRef);
|
status = roster.FindApp(signature, &catalogRef);
|
||||||
if (status != B_OK) {
|
if (status != B_OK)
|
||||||
log_team(LOG_ERR, "Could not find the entry_ref for signature %s"
|
|
||||||
" to load a catalog.", signature.String());
|
|
||||||
return status;
|
return status;
|
||||||
}
|
|
||||||
|
|
||||||
BCatalog catalog(catalogRef);
|
BCatalog catalog(catalogRef);
|
||||||
const char* temp = catalog.GetString(string, context);
|
const char* temp = catalog.GetString(string, context);
|
||||||
@@ -562,11 +558,8 @@ BLocaleRoster::_GetCatalog(BCatalog* catalog, vint32* catalogInitStatus)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found)
|
||||||
log_team(LOG_DEBUG, "Catalog %x doesn't belong to any image!",
|
|
||||||
catalog);
|
|
||||||
return catalog;
|
return catalog;
|
||||||
}
|
|
||||||
|
|
||||||
// load the catalog for this mimetype and return it to the app
|
// load the catalog for this mimetype and return it to the app
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <syslog.h>
|
|
||||||
|
|
||||||
#include <AppFileInfo.h>
|
#include <AppFileInfo.h>
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
@@ -91,13 +90,8 @@ CatalogAddOnInfo::MakeSureItsLoaded()
|
|||||||
B_SYMBOL_TYPE_TEXT, (void**)&fCreateFunc);
|
B_SYMBOL_TYPE_TEXT, (void**)&fCreateFunc);
|
||||||
get_image_symbol(fAddOnImage, "get_available_languages",
|
get_image_symbol(fAddOnImage, "get_available_languages",
|
||||||
B_SYMBOL_TYPE_TEXT, (void**)&fLanguagesFunc);
|
B_SYMBOL_TYPE_TEXT, (void**)&fLanguagesFunc);
|
||||||
log_team(LOG_DEBUG, "catalog-add-on %s has been loaded",
|
} else
|
||||||
fName.String());
|
|
||||||
} else {
|
|
||||||
log_team(LOG_DEBUG, "could not load catalog-add-on %s (%s)",
|
|
||||||
fName.String(), strerror(fAddOnImage));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
} else if (fIsEmbedded) {
|
} else if (fIsEmbedded) {
|
||||||
// The built-in catalog still has to provide this function
|
// The built-in catalog still has to provide this function
|
||||||
fLanguagesFunc = default_catalog_get_available_languages;
|
fLanguagesFunc = default_catalog_get_available_languages;
|
||||||
@@ -115,8 +109,6 @@ CatalogAddOnInfo::UnloadIfPossible()
|
|||||||
fInstantiateFunc = NULL;
|
fInstantiateFunc = NULL;
|
||||||
fCreateFunc = NULL;
|
fCreateFunc = NULL;
|
||||||
fLanguagesFunc = NULL;
|
fLanguagesFunc = NULL;
|
||||||
// log_team(LOG_DEBUG, "catalog-add-on %s has been unloaded",
|
|
||||||
// fName.String());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +168,6 @@ RosterData::~RosterData()
|
|||||||
BAutolock lock(fLock);
|
BAutolock lock(fLock);
|
||||||
|
|
||||||
_CleanupCatalogAddOns();
|
_CleanupCatalogAddOns();
|
||||||
closelog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -320,11 +311,6 @@ RosterData::SetFilesystemTranslationPreferred(bool preferred)
|
|||||||
status_t
|
status_t
|
||||||
RosterData::_Initialize()
|
RosterData::_Initialize()
|
||||||
{
|
{
|
||||||
openlog_team("liblocale.so", LOG_PID, LOG_USER);
|
|
||||||
#ifndef DEBUG
|
|
||||||
setlogmask_team(LOG_UPTO(LOG_WARNING));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
status_t result = _InitializeCatalogAddOns();
|
status_t result = _InitializeCatalogAddOns();
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
@@ -429,16 +415,8 @@ RosterData::_InitializeCatalogAddOns()
|
|||||||
priority = *prioPtr;
|
priority = *prioPtr;
|
||||||
node.WriteAttr(kPriorityAttr, B_INT8_TYPE, 0,
|
node.WriteAttr(kPriorityAttr, B_INT8_TYPE, 0,
|
||||||
&priority, sizeof(int8));
|
&priority, sizeof(int8));
|
||||||
} else {
|
|
||||||
log_team(LOG_ERR,
|
|
||||||
"couldn't get priority for add-on %s\n",
|
|
||||||
fullAddOnPath.String());
|
|
||||||
}
|
}
|
||||||
unload_add_on(image);
|
unload_add_on(image);
|
||||||
} else {
|
|
||||||
log_team(LOG_ERR,
|
|
||||||
"couldn't load add-on %s, error: %s\n",
|
|
||||||
fullAddOnPath.String(), strerror(image));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -793,11 +771,8 @@ MutableLocaleRoster::LoadSystemCatalog(BCatalog* catalog) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found)
|
||||||
log_team(LOG_DEBUG, "Unable to find libbe-image!");
|
|
||||||
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
|
||||||
|
|
||||||
// load the catalog for libbe into the given catalog
|
// load the catalog for libbe into the given catalog
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
|
|||||||
Reference in New Issue
Block a user