Adding sort/search support for phonetic names,

bug 179823, r=cavin, sr=sspitzer.
This commit is contained in:
nhotta%netscape.com 2002-12-02 22:27:38 +00:00
Родитель bee0d09613
Коммит 02c6eb19f8
12 изменённых файлов: 83 добавлений и 10 удалений

Просмотреть файл

@ -85,5 +85,11 @@ interface nsIAddrBookSession : nsISupports {
* we allow the caller to cache the pref value, so we don't have to go to prefs every time.
*/
wstring generateNameFromCard(in nsIAbCard card, in long generateFormat);
/**
* generate the phonetic name from the card, using the firstName and lastName
*
*/
wstring generatePhoneticNameFromCard(in nsIAbCard aCard, in boolean aLastNameFirst);
};

Просмотреть файл

@ -59,6 +59,7 @@ interface nsIMdbRow;
#define kLastNameColumn "LastName"
#define kPhoneticFirstNameColumn "PhoneticFirstName"
#define kPhoneticLastNameColumn "PhoneticLastName"
#define kPhoneticNameColumn "_PhoneticName"
#define kDisplayNameColumn "DisplayName"
#define kNicknameColumn "NickName"
#define kPriEmailColumn "PrimaryEmail"

Просмотреть файл

@ -70,6 +70,14 @@
<treecol id="Company" class="sortDirectionIndicator"
persist="hidden ordinal width" flex="1" label="&Company.label;"/>
<splitter class="tree-splitter"/>
<!-- LOCALIZATION NOTE: _PhoneticName may be enabled for Japanese builds. -->
<!--
<treecol id="_PhoneticName" class="sortDirectionIndicator"
persist="hidden ordinal width"
hiddenbydefault="true"
flex="1" label="&_PhoneticName.label;"/>
<splitter class="tree-splitter"/>
-->
<treecol id="NickName" class="sortDirectionIndicator"
persist="hidden ordinal width"
hiddenbydefault="true"

Просмотреть файл

@ -392,7 +392,8 @@ function onEnterInSearchBar()
return;
if (!gQueryURIFormat) {
gQueryURIFormat = gPrefs.getCharPref("mail.addr_book.quicksearchquery.format");
gQueryURIFormat = gPrefs.getComplexValue("mail.addr_book.quicksearchquery.format",
Components.interfaces.nsIPrefLocalizedString).data;
}
var sortColumn = selectedNode.getAttribute("sortColumn");

Просмотреть файл

@ -192,6 +192,16 @@ function GetCurrentPrefs()
var menuitem = top.document.getElementById(menuitemID);
if ( menuitem )
menuitem.setAttribute('checked', 'true');
// initialize phonetic
var showPhoneticFields =
gPrefs.getComplexValue("mail.addr_book.show_phonetic_fields",
Components.interfaces.nsIPrefLocalizedString).data;
// show phonetic fields if indicated by the pref
if (showPhoneticFields == "true")
document.getElementById("cmd_SortBy_PhoneticName")
.setAttribute("hidden", "false");
}
@ -528,7 +538,8 @@ function onEnterInSearchBar()
ClearCardViewPane();
if (!gQueryURIFormat)
gQueryURIFormat = gPrefs.getCharPref("mail.addr_book.quicksearchquery.format");
gQueryURIFormat = gPrefs.getComplexValue("mail.addr_book.quicksearchquery.format",
Components.interfaces.nsIPrefLocalizedString).data;
var searchURI = GetSelectedDirectory();
if (!searchURI) return;

Просмотреть файл

@ -240,6 +240,15 @@ Contributor(s):
id="cmd_SortByCompany"
accesskey="&Company.accesskey;"
oncommand="SortResultPane('Company');" name="sortas" type="radio" checked="true"/>
<!-- LOCALIZATION NOTE:
Fields for phonetic are disabled as default and can be enabled by
editing "mail.addr_book.show_phonetic_fields"
-->
<menuitem label="&_PhoneticName.label;"
id="cmd_SortBy_PhoneticName"
hidden="true"
accesskey="&_PhoneticName.accesskey;"
oncommand="SortResultPane('_PhoneticName');" name="sortas" type="radio" checked="true"/>
<menuitem label="&NickName.label;"
id="cmd_SortByNickName"
accesskey="&NickName.accesskey;"

Просмотреть файл

@ -38,8 +38,10 @@
<!ENTITY GeneratedName.accesskey "N">
<!ENTITY PrimaryEmail.label "Email">
<!ENTITY PrimaryEmail.accesskey "E">
<!ENTITY Company.label "Organization">
<!ENTITY Company.accesskey "O">
<!ENTITY Company.label "Company">
<!ENTITY Company.accesskey "C">
<!ENTITY _PhoneticName.label "Phonetic Name">
<!ENTITY _PhoneticName.accesskey "O">
<!ENTITY NickName.label "Nickname">
<!ENTITY NickName.accesskey "i">
<!ENTITY SecondEmail.label "Additional Email">

Просмотреть файл

@ -447,15 +447,20 @@ nsresult nsAbView::GetCardValue(nsIAbCard *card, const PRUnichar *colID, PRUnich
{
nsresult rv;
// "G" == "GeneratedName"
// "G" == "GeneratedName", "_P" == "_PhoneticName"
// else, standard column (like PrimaryEmail and _AimScreenName)
if (colID[0] == PRUnichar('G')) {
if ((colID[0] == PRUnichar('G')) ||
(colID[0] == PRUnichar('_') && colID[1] == PRUnichar('P'))) {
// XXX todo
// cache the ab session?
nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = abSession->GenerateNameFromCard(card, mGeneratedNameFormat, _retval);
if (colID[0] == PRUnichar('G'))
rv = abSession->GenerateNameFromCard(card, mGeneratedNameFormat, _retval);
else
// use LN/FN order for the phonetic name
rv = abSession->GeneratePhoneticNameFromCard(card, PR_TRUE, _retval);
NS_ENSURE_SUCCESS(rv,rv);
}
else {

Просмотреть файл

@ -261,4 +261,22 @@ NS_IMETHODIMP nsAddrBookSession::GenerateNameFromCard(nsIAbCard *card, PRInt32 g
return NS_OK;
}
NS_IMETHODIMP nsAddrBookSession::GeneratePhoneticNameFromCard(nsIAbCard *aCard, PRBool aLastNameFirst, PRUnichar **aName)
{
NS_ENSURE_ARG_POINTER(aCard);
NS_ENSURE_ARG_POINTER(aName);
nsXPIDLString firstName;
nsXPIDLString lastName;
nsresult rv = aCard->GetPhoneticFirstName(getter_Copies(firstName));
NS_ENSURE_SUCCESS(rv, rv);
rv = aCard->GetPhoneticLastName(getter_Copies(lastName));
NS_ENSURE_SUCCESS(rv,rv);
if (aLastNameFirst)
*aName = ToNewUnicode(lastName + firstName);
else
*aName = ToNewUnicode(firstName + lastName);
}

Просмотреть файл

@ -50,6 +50,7 @@ var gAddressBookBundle;
var gSearchStopButton;
var gPropertiesButton;
var gComposeButton;
var gSearchPhoneticName = "false";
var gRDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
@ -73,6 +74,14 @@ function searchOnLoad()
gAddressBookBundle = document.getElementById("bundle_addressBook");
gSearchSession = Components.classes[searchSessionContractID].createInstance(Components.interfaces.nsIMsgSearchSession);
// initialize a flag for phonetic name search
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
var prefBranch = prefService.getBranch(null).QueryInterface(Components.interfaces.nsIPrefBranchInternal);
gSearchPhoneticName =
prefBranch.getComplexValue("mail.addr_book.show_phonetic_fields",
Components.interfaces.nsIPrefLocalizedString).data;
if (window.arguments && window.arguments[0])
SelectDirectory(window.arguments[0].directory);
@ -194,7 +203,10 @@ function onSearch()
switch (searchTerm.attrib) {
case nsMsgSearchAttrib.Name:
// when doing an "and" search, we'll use the first one
attrs = ["DisplayName","FirstName","LastName"];
if (gSearchPhoneticName == "false")
attrs = ["DisplayName","FirstName","LastName"];
else
attrs = ["DisplayName","FirstName","LastName","PhoneticFirstName","PhoneticLastName"];
break;
case nsMsgSearchAttrib.Email:
attrs = ["PrimaryEmail"];

Просмотреть файл

@ -128,7 +128,7 @@ pref("mail.addr_book.mapit_url.format", "chrome://messenger-region/locale/region
//
// note, changing this might require a change to SearchNameOrEmail.label
// in messenger.dtd
pref("mail.addr_book.quicksearchquery.format","?(or(PrimaryEmail,c,@V)(DisplayName,c,@V)(FirstName,c,@V)(LastName,c,@V))");
pref("mail.addr_book.quicksearchquery.format", "chrome://messenger/locale/messenger.properties");
// values for "mail.addr_book.lastnamefirst" are:
//0=displayname, 1=lastname first, 2=firstname first

Просмотреть файл

@ -128,7 +128,7 @@ pref("mail.addr_book.mapit_url.format", "chrome://messenger-region/locale/region
//
// note, changing this might require a change to SearchNameOrEmail.label
// in messenger.dtd
pref("mail.addr_book.quicksearchquery.format","?(or(PrimaryEmail,c,@V)(DisplayName,c,@V)(FirstName,c,@V)(LastName,c,@V))");
pref("mail.addr_book.quicksearchquery.format", "chrome://messenger/locale/messenger.properties");
// values for "mail.addr_book.lastnamefirst" are:
//0=displayname, 1=lastname first, 2=firstname first