* LocaleRoster.h was not self-containing.

* Moved the locale stuff to the data directory as well (some parts were in /etc).
* The DefaultCatalog will now also scan the user directory for catalogs.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33983 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-11-10 13:44:22 +00:00
parent c6106a595d
commit f9a80fec95
10 changed files with 75 additions and 82 deletions
+2 -2
View File
@@ -276,7 +276,7 @@ actions ResAttr1
# linkcatkeys. # linkcatkeys.
rule ExtractCatalogEntries target : source : signature rule ExtractCatalogEntries target : source : signature
{ {
# get compiler and defines for the platform # get compiler and defines for the platform
local headers ; local headers ;
local sysHeaders ; local sysHeaders ;
local cc ; local cc ;
@@ -381,6 +381,6 @@ rule DoCatalogs appName # Application name
: $(signature) : $(catalog:B) ; : $(signature) : $(catalog:B) ;
} }
AddFilesToHaikuImage system etc locale catalogs $(signature) : AddFilesToHaikuImage system data locale catalogs $(signature) :
$(genCat) $(trans:S=.catalog) ; $(genCat) $(trans:S=.catalog) ;
} }
+9 -5
View File
@@ -384,7 +384,7 @@ SEARCH on $(spellFiles)
AddFilesToHaikuImage system etc word_dictionary : $(spellFiles) ; AddFilesToHaikuImage system etc word_dictionary : $(spellFiles) ;
# Locale kit language files # Locale kit language files
local languageDir = [ FDirName $(HAIKU_TOP) src data etc locale languages ] ; local languageDir = [ FDirName $(HAIKU_TOP) src data locale languages ] ;
local languages = [ Glob $(languageDir) : *.language ] ; local languages = [ Glob $(languageDir) : *.language ] ;
AddFilesToHaikuImage system data locale languages : $(languages) ; AddFilesToHaikuImage system data locale languages : $(languages) ;
@@ -491,17 +491,21 @@ AddFilesToHaikuImage system add-ons opengl
: Mesa\ Software\ Renderer ; : Mesa\ Software\ Renderer ;
AddFilesToHaikuHybridImage system add-ons Translators AddFilesToHaikuHybridImage system add-ons Translators
: $(SYSTEM_ADD_ONS_TRANSLATORS) : : true ; : $(SYSTEM_ADD_ONS_TRANSLATORS) : : true ;
AddFilesToHaikuImage system add-ons locale catalogs : $(SYSTEM_ADD_ONS_LOCALE_CATALOGS) ; AddFilesToHaikuImage system add-ons locale catalogs
: $(SYSTEM_ADD_ONS_LOCALE_CATALOGS) ;
AddFilesToHaikuImage system add-ons mail_daemon inbound_protocols : POP3 IMAP ; AddFilesToHaikuImage system add-ons mail_daemon inbound_protocols : POP3 IMAP ;
AddFilesToHaikuImage system add-ons mail_daemon outbound_protocols : SMTP ; AddFilesToHaikuImage system add-ons mail_daemon outbound_protocols : SMTP ;
AddFilesToHaikuImage system add-ons mail_daemon inbound_filters : Match\ Header Spam\ Filter R5\ Daemon\ Filter ; AddFilesToHaikuImage system add-ons mail_daemon inbound_filters
: Match\ Header Spam\ Filter R5\ Daemon\ Filter ;
AddFilesToHaikuImage system add-ons mail_daemon outbound_filters : Fortune ; AddFilesToHaikuImage system add-ons mail_daemon outbound_filters : Fortune ;
AddFilesToHaikuImage system add-ons mail_daemon system_filters : Inbox New\ Mail\ Notification Outbox Message\ Parser ; AddFilesToHaikuImage system add-ons mail_daemon system_filters
: Inbox New\ Mail\ Notification Outbox Message\ Parser ;
AddFilesToHaikuImage system add-ons media : $(SYSTEM_ADD_ONS_MEDIA) ; AddFilesToHaikuImage system add-ons media : $(SYSTEM_ADD_ONS_MEDIA) ;
AddFilesToHaikuImage system add-ons media plugins AddFilesToHaikuImage system add-ons media plugins
: $(SYSTEM_ADD_ONS_MEDIA_PLUGINS) ; : $(SYSTEM_ADD_ONS_MEDIA_PLUGINS) ;
AddFilesToHaikuImage system add-ons Tracker AddFilesToHaikuImage system add-ons Tracker
: FileType-F Mark\ as… Mark\ as\ Read-R Open\ Target\ Folder-O OpenTerminal-T ZipOMatic-Z ; : FileType-F Mark\ as… Mark\ as\ Read-R Open\ Target\ Folder-O OpenTerminal-T
ZipOMatic-Z ;
AddSymlinkToHaikuImage system add-ons Tracker AddSymlinkToHaikuImage system add-ons Tracker
: /boot/system/preferences/Backgrounds : Background-B ; : /boot/system/preferences/Backgrounds : Background-B ;
AddSymlinkToHaikuImage system add-ons Tracker AddSymlinkToHaikuImage system add-ons Tracker
+1
View File
@@ -11,6 +11,7 @@ class BCollator;
class BCountry; class BCountry;
class BCatalog; class BCatalog;
class BCatalogAddOn; class BCatalogAddOn;
class BMessage;
struct entry_ref; struct entry_ref;
+43 -53
View File
@@ -36,11 +36,10 @@ using std::max;
using std::pair; using std::pair;
/* /*! This file implements the default catalog-type for the opentracker locale
* This file implements the default catalog-type for the opentracker locale kit. Alternatively, this could be used as a full add-on, but currently this
* kit. Alternatively, this could be used as a full add-on, but currently this is provided as part of liblocale.so.
* is provided as part of liblocale.so. */
*/
static const char *kCatFolder = "catalogs"; static const char *kCatFolder = "catalogs";
@@ -52,13 +51,15 @@ const char *DefaultCatalog::kCatMimeType
static int16 kCatArchiveVersion = 1; static int16 kCatArchiveVersion = 1;
// version of the catalog archive structure, bump this if you change it! // version of the catalog archive structure, bump this if you change it!
const uint8 DefaultCatalog::kDefaultCatalogAddOnPriority = 1;
// give highest priority to our embedded catalog-add-on
/*
* constructs a DefaultCatalog with given signature and language and reads /*! Constructs a DefaultCatalog with given signature and language and reads
* the catalog from disk. the catalog from disk.
* InitCheck() will be B_OK if catalog could be loaded successfully, it will InitCheck() will be B_OK if catalog could be loaded successfully, it will
* give an appropriate error-code otherwise. give an appropriate error-code otherwise.
*/ */
DefaultCatalog::DefaultCatalog(const char *signature, const char *language, DefaultCatalog::DefaultCatalog(const char *signature, const char *language,
uint32 fingerprint) uint32 fingerprint)
: :
@@ -80,30 +81,26 @@ DefaultCatalog::DefaultCatalog(const char *signature, const char *language,
status_t status = ReadFromFile(catalogPath.Path()); status_t status = ReadFromFile(catalogPath.Path());
if (status != B_OK) { if (status != B_OK) {
// look in common-etc folder (/boot/home/config/etc): // search in data folders
BPath commonEtcPath;
find_directory(B_COMMON_ETC_DIRECTORY, &commonEtcPath);
if (commonEtcPath.InitCheck() == B_OK) {
catalogName = BString(commonEtcPath.Path())
<< "/locale/" << kCatFolder
<< "/" << fSignature
<< "/" << fLanguageName
<< kCatExtension;
status = ReadFromFile(catalogName.String());
}
}
if (status != B_OK) { directory_which which[] = {
// look in system-etc folder (/boot/beos/etc): B_USER_DATA_DIRECTORY,
BPath systemEtcPath; B_COMMON_DATA_DIRECTORY,
find_directory(B_BEOS_ETC_DIRECTORY, &systemEtcPath); B_SYSTEM_DATA_DIRECTORY
if (systemEtcPath.InitCheck() == B_OK) { };
catalogName = BString(systemEtcPath.Path())
<< "/locale/" << kCatFolder for (size_t i = 0; i < sizeof(which) / sizeof(which[0]); i++) {
<< "/" << fSignature BPath path;
<< "/" << fLanguageName if (find_directory(which[i], &path) == B_OK) {
<< kCatExtension; catalogName = BString(path.Path())
status = ReadFromFile(catalogName.String()); << "/locale/" << kCatFolder
<< "/" << fSignature
<< "/" << fLanguageName
<< kCatExtension;
status = ReadFromFile(catalogName.String());
if (status == B_OK)
break;
}
} }
} }
@@ -114,12 +111,11 @@ DefaultCatalog::DefaultCatalog(const char *signature, const char *language,
} }
/* /*! Constructs a DefaultCatalog and reads it from the resources of the
* constructs a DefaultCatalog and reads it from the resources of the given entry-ref (which usually is an app- or add-on-file).
* given entry-ref (which usually is an app- or add-on-file). InitCheck() will be B_OK if catalog could be loaded successfully, it will
* InitCheck() will be B_OK if catalog could be loaded successfully, it will give an appropriate error-code otherwise.
* give an appropriate error-code otherwise. */
*/
DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef) DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef)
: :
BHashMapCatalog("", "", 0) BHashMapCatalog("", "", 0)
@@ -131,11 +127,10 @@ DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef)
} }
/* /*! Constructs an empty DefaultCatalog with given sig and language.
* constructs an empty DefaultCatalog with given sig and language. This is used for editing/testing purposes.
* This is used for editing/testing purposes. InitCheck() will always be B_OK.
* InitCheck() will always be B_OK. */
*/
DefaultCatalog::DefaultCatalog(const char *path, const char *signature, DefaultCatalog::DefaultCatalog(const char *path, const char *signature,
const char *language) const char *language)
: :
@@ -387,10 +382,9 @@ DefaultCatalog::WriteToResource(entry_ref *appOrAddOnRef)
} }
/* /*! Writes mimetype, language-name and signature of catalog into the
* writes mimetype, language-name and signature of catalog into the catalog-file.
* catalog-file. */
*/
void void
DefaultCatalog::UpdateAttributes(BFile& catalogFile) DefaultCatalog::UpdateAttributes(BFile& catalogFile)
{ {
@@ -581,7 +575,3 @@ DefaultCatalog::Create(const char *signature, const char *language)
} }
return catalog; return catalog;
} }
const uint8 DefaultCatalog::kDefaultCatalogAddOnPriority = 1;
// give highest priority to our embedded catalog-add-on
+3 -3
View File
@@ -1,7 +1,7 @@
/* /*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2003-2009, Axel Dörfler, [email protected].
** Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include <Language.h> #include <Language.h>
+11 -8
View File
@@ -1,10 +1,14 @@
/* /*
** Distributed under the terms of the OpenBeOS License. * Copyright 2003-2004, Haiku. All rights reserved.
** Copyright 2003-2004. All rights reserved. * Distributed under the terms of the MIT License.
** *
** Authors: Axel Dörfler, [email protected] * Authors:
** Oliver Tappe, zooey@hirschkaefer.de * Axel Dörfler, axeld@pinc-software.de
*/ * Oliver Tappe, [email protected]
*/
#include <LocaleRoster.h>
#include <set> #include <set>
@@ -23,7 +27,6 @@
#include <FindDirectory.h> #include <FindDirectory.h>
#include <Language.h> #include <Language.h>
#include <Locale.h> #include <Locale.h>
#include <LocaleRoster.h>
#include <Node.h> #include <Node.h>
#include <Path.h> #include <Path.h>
#include <String.h> #include <String.h>
@@ -177,7 +180,7 @@ RosterData::RosterData()
InitializeCatalogAddOns(); InitializeCatalogAddOns();
// Load preferences to get the preffered languages // Load preferences to get the preferred languages
BPath path; BPath path;
BFile file; BFile file;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
+6 -11
View File
@@ -1,7 +1,7 @@
/* /*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2003-2009, Axel Dörfler, [email protected].
** Distributed under the terms of the OpenBeOS License. * Distributed under the terms of the MIT License.
*/ */
#include "PropertyFile.h" #include "PropertyFile.h"
@@ -10,18 +10,13 @@
#include <Path.h> #include <Path.h>
#include <FindDirectory.h> #include <FindDirectory.h>
#if B_BEOS_VERSION <= B_BEOS_VERSION_5 && !defined(__HAIKU__)
// B_BAD_DATA was introduced with DANO, so we define it for R5:
# define B_BAD_DATA -2147483632L
#endif
status_t status_t
PropertyFile::SetTo(const char *directory, const char *name) PropertyFile::SetTo(const char *directory, const char *name)
{ {
BPath path; BPath path;
status_t status = find_directory(B_BEOS_ETC_DIRECTORY, &path); status_t status = find_directory(B_BEOS_DATA_DIRECTORY, &path);
if (status < B_OK) if (status != B_OK)
return status; return status;
path.Append(directory); path.Append(directory);