Make BLocaleRoster::GetLocalizedFileName() take a const entry_ref& rather than a non-const entry_ref&. Remove private GetLocalizedFileName() from libtracker and make Tracker and Deskbar use the one in BLocaleRoster.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41075 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -68,7 +68,7 @@ public:
|
|||||||
|
|
||||||
bool IsFilesystemTranslationPreferred() const;
|
bool IsFilesystemTranslationPreferred() const;
|
||||||
|
|
||||||
status_t GetLocalizedFileName(entry_ref& ref,
|
status_t GetLocalizedFileName(const entry_ref& ref,
|
||||||
BString& localizedFileName,
|
BString& localizedFileName,
|
||||||
bool traverse = false);
|
bool traverse = false);
|
||||||
|
|
||||||
|
|||||||
@@ -619,7 +619,8 @@ TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref)
|
|||||||
BAppFileInfo appMime(&file);
|
BAppFileInfo appMime(&file);
|
||||||
|
|
||||||
BString name;
|
BString name;
|
||||||
if (!gLocalizedNamePreferred || GetLocalizedFileName(*ref, name) != B_OK)
|
if (!gLocalizedNamePreferred
|
||||||
|
|| BLocaleRoster::Default()->GetLocalizedFileName(*ref, name) != B_OK)
|
||||||
name = ref->name;
|
name = ref->name;
|
||||||
|
|
||||||
BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig),
|
BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig),
|
||||||
|
|||||||
@@ -400,8 +400,8 @@ BLocaleRoster::IsFilesystemTranslationPreferred() const
|
|||||||
Lookup fails if a comment is present in the catalog entry.
|
Lookup fails if a comment is present in the catalog entry.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BLocaleRoster::GetLocalizedFileName(entry_ref& ref, BString& localizedFileName,
|
BLocaleRoster::GetLocalizedFileName(const entry_ref& ref,
|
||||||
bool traverse)
|
BString& localizedFileName, bool traverse)
|
||||||
{
|
{
|
||||||
BEntry entry(&ref, traverse);
|
BEntry entry(&ref, traverse);
|
||||||
if (!entry.Exists())
|
if (!entry.Exists())
|
||||||
|
|||||||
@@ -781,7 +781,8 @@ TFilePanel::Init(const BMessage *)
|
|||||||
BString title;
|
BString title;
|
||||||
if (be_app->GetAppInfo(&info) == B_OK) {
|
if (be_app->GetAppInfo(&info) == B_OK) {
|
||||||
if (!gLocalizedNamePreferred
|
if (!gLocalizedNamePreferred
|
||||||
|| GetLocalizedFileName(info.ref, title, false) != B_OK)
|
|| BLocaleRoster::Default()->GetLocalizedFileName(
|
||||||
|
info.ref, title, false) != B_OK)
|
||||||
title = info.ref.name;
|
title = info.ref.name;
|
||||||
title << ": ";
|
title << ": ";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -567,7 +567,8 @@ Model::SetupBaseType()
|
|||||||
void
|
void
|
||||||
Model::CacheLocalizedName()
|
Model::CacheLocalizedName()
|
||||||
{
|
{
|
||||||
if (GetLocalizedFileName(fEntryRef, fLocalizedName, true) == B_OK)
|
if (BLocaleRoster::Default()->GetLocalizedFileName(
|
||||||
|
fEntryRef, fLocalizedName, true) == B_OK)
|
||||||
fHasLocalizedName = true;
|
fHasLocalizedName = true;
|
||||||
else
|
else
|
||||||
fHasLocalizedName = false;
|
fHasLocalizedName = false;
|
||||||
|
|||||||
@@ -87,6 +87,9 @@ const rgb_color kBlack = {0, 0, 0, 255};
|
|||||||
const rgb_color kWhite = {255, 255, 255, 255};
|
const rgb_color kWhite = {255, 255, 255, 255};
|
||||||
|
|
||||||
|
|
||||||
|
bool gLocalizedNamePreferred;
|
||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
HashString(const char *string, uint32 seed)
|
HashString(const char *string, uint32 seed)
|
||||||
{
|
{
|
||||||
@@ -1470,82 +1473,6 @@ GetFileIconFromAttr(BNode *file, BBitmap *result, icon_size size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool gLocalizedNamePreferred;
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Looks up a localized filename in a catalog, using attribute data
|
|
||||||
on the entry.
|
|
||||||
\param ref An entry_ref with an attribute holding data for catalog lookup.
|
|
||||||
\param localizedFileName A pre-allocated BString object for the result
|
|
||||||
of the lookup.
|
|
||||||
\param traverse A boolean to decide if symlinks are to be traversed.
|
|
||||||
\return
|
|
||||||
- \c B_OK: success
|
|
||||||
- \c B_ENTRY_NOT_FOUND: failure. Attribute not found, entry not found
|
|
||||||
in catalog, etc
|
|
||||||
- other error codes: failure
|
|
||||||
|
|
||||||
Attribute format: "signature:context:string"
|
|
||||||
(no colon in any of signature, context and string)
|
|
||||||
|
|
||||||
Lookup is done for the top preferred language, only.
|
|
||||||
Lookup fails if a comment is present in the catalog entry.
|
|
||||||
*/
|
|
||||||
status_t
|
|
||||||
GetLocalizedFileName(entry_ref& ref, BString& localizedFileName, bool traverse)
|
|
||||||
{
|
|
||||||
BEntry entry(&ref, traverse);
|
|
||||||
if (!entry.Exists())
|
|
||||||
return B_ENTRY_NOT_FOUND;
|
|
||||||
|
|
||||||
BNode node(&entry);
|
|
||||||
status_t status = node.InitCheck();
|
|
||||||
if (status != B_OK)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
attr_info attr;
|
|
||||||
status = node.GetAttrInfo("SYS:NAME", &attr);
|
|
||||||
if (status != B_OK)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
char attribute[attr.size + 1];
|
|
||||||
ssize_t bytes = node.ReadAttr("SYS:NAME", B_MIME_TYPE, 0, &attribute,
|
|
||||||
attr.size);
|
|
||||||
|
|
||||||
if (bytes < 0)
|
|
||||||
return bytes;
|
|
||||||
|
|
||||||
if (bytes == 0 || bytes != attr.size)
|
|
||||||
return B_ENTRY_NOT_FOUND;
|
|
||||||
|
|
||||||
attribute[bytes] = '\0';
|
|
||||||
|
|
||||||
char* signature = attribute;
|
|
||||||
char* context = strchr(signature, ':');
|
|
||||||
if (context == NULL)
|
|
||||||
return B_ENTRY_NOT_FOUND;
|
|
||||||
|
|
||||||
context[0] = '\0';
|
|
||||||
context++;
|
|
||||||
|
|
||||||
char* string = strchr(context, ':');
|
|
||||||
if (string == NULL)
|
|
||||||
return B_ENTRY_NOT_FOUND;
|
|
||||||
|
|
||||||
string[0] = '\0';
|
|
||||||
string++;
|
|
||||||
|
|
||||||
BCatalog catalog(signature);
|
|
||||||
|
|
||||||
const char* temp = catalog.GetString(string, context);
|
|
||||||
if (temp == NULL)
|
|
||||||
return B_ENTRY_NOT_FOUND;
|
|
||||||
|
|
||||||
localizedFileName = temp;
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintToStream(rgb_color color)
|
PrintToStream(rgb_color color)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ const color_space kDefaultIconDepth = B_RGBA32;
|
|||||||
const color_space kDefaultIconDepth = B_CMAP8;
|
const color_space kDefaultIconDepth = B_CMAP8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
extern bool gLocalizedNamePreferred;
|
||||||
|
|
||||||
|
|
||||||
// misc typedefs, constants and structs
|
// misc typedefs, constants and structs
|
||||||
|
|
||||||
// Periodically updated poses (ones with a volume space bar) register
|
// Periodically updated poses (ones with a volume space bar) register
|
||||||
@@ -523,11 +527,6 @@ status_t GetAppSignatureFromAttr(BFile *, char *);
|
|||||||
status_t GetAppIconFromAttr(BFile *, BBitmap *, icon_size);
|
status_t GetAppIconFromAttr(BFile *, BBitmap *, icon_size);
|
||||||
status_t GetFileIconFromAttr(BNode *, BBitmap *, icon_size);
|
status_t GetFileIconFromAttr(BNode *, BBitmap *, icon_size);
|
||||||
|
|
||||||
extern bool gLocalizedNamePreferred;
|
|
||||||
|
|
||||||
status_t GetLocalizedFileName(entry_ref& ref, BString& localizedFileName,
|
|
||||||
bool traverse = false);
|
|
||||||
|
|
||||||
// debugging
|
// debugging
|
||||||
void HexDump(const void *buffer, int32 length);
|
void HexDump(const void *buffer, int32 length);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user