This commit is contained in:
chuang%netscape.com 1999-09-14 21:55:54 +00:00
Родитель 27693bcc6d
Коммит 83853d3743
25 изменённых файлов: 848 добавлений и 557 удалений

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

@ -29,51 +29,51 @@ interface nsIAddrDatabase;
[scriptable, uuid(FA5C977F-04C8-11d3-A2EB-001083003D0C)]
interface nsIAbCard : nsISupports {
attribute string FirstName;
attribute string LastName;
attribute string DisplayName;
attribute string NickName;
attribute string PrimaryEmail;
attribute string SecondEmail;
attribute string WorkPhone;
attribute string HomePhone;
attribute string FaxNumber;
attribute string PagerNumber;
attribute string CellularNumber;
attribute string HomeAddress;
attribute string HomeAddress2;
attribute string HomeCity;
attribute string HomeState;
attribute string HomeZipCode;
attribute string HomeCountry;
attribute string WorkAddress;
attribute string WorkAddress2;
attribute string WorkCity;
attribute string WorkState;
attribute string WorkZipCode;
attribute string WorkCountry;
attribute string JobTitle;
attribute string Department;
attribute string Company;
attribute string WebPage1;
attribute string WebPage2;
attribute string BirthYear;
attribute string BirthMonth;
attribute string BirthDay;
attribute string Custom1;
attribute string Custom2;
attribute string Custom3;
attribute string Custom4;
attribute string Notes;
attribute string LastModifiedDate;
attribute wstring FirstName;
attribute wstring LastName;
attribute wstring DisplayName;
attribute wstring NickName;
attribute wstring PrimaryEmail;
attribute wstring SecondEmail;
attribute wstring WorkPhone;
attribute wstring HomePhone;
attribute wstring FaxNumber;
attribute wstring PagerNumber;
attribute wstring CellularNumber;
attribute wstring HomeAddress;
attribute wstring HomeAddress2;
attribute wstring HomeCity;
attribute wstring HomeState;
attribute wstring HomeZipCode;
attribute wstring HomeCountry;
attribute wstring WorkAddress;
attribute wstring WorkAddress2;
attribute wstring WorkCity;
attribute wstring WorkState;
attribute wstring WorkZipCode;
attribute wstring WorkCountry;
attribute wstring JobTitle;
attribute wstring Department;
attribute wstring Company;
attribute wstring WebPage1;
attribute wstring WebPage2;
attribute wstring BirthYear;
attribute wstring BirthMonth;
attribute wstring BirthDay;
attribute wstring Custom1;
attribute wstring Custom2;
attribute wstring Custom3;
attribute wstring Custom4;
attribute wstring Notes;
attribute unsigned long LastModifiedDate;
attribute boolean SendPlainText;
attribute unsigned long DbTableID;
attribute unsigned long DbRowID;
void GetCardValue(in string attrname, out string value);
void SetCardValue(in string attrname, in string value);
void GetCardValue(in string attrname, out wstring value);
void SetCardValue(in string attrname, in wstring value);
void SetAbDatabase(in nsIAddrDatabase database);
[noscript] void GetAnonymousStrAttrubutesList(out nsVoidArray attrlist);

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

@ -31,8 +31,8 @@
[scriptable, uuid(1920E485-0709-11d3-A2EC-001083003D0C)]
interface nsIAbDirectory : nsISupports {
attribute string DirName;
attribute string LastModifiedDate;
attribute wstring DirName;
attribute unsigned long LastModifiedDate;
attribute DIR_Server server;
void GetDirFilePath(out string dbPath);
@ -45,7 +45,7 @@ interface nsIAbDirectory : nsISupports {
void HasCard(in nsIAbCard cards, out boolean hasCard);
void HasDirectory(in nsIAbDirectory dir, out boolean hasDir);
void GetMailingList(out nsIEnumerator mailingList);
void CreateNewDirectory(in string dirName, in string fileName);
void CreateNewDirectory(in wstring dirName, in string fileName);
void GetDirUri(out string uri);
};

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

@ -24,6 +24,6 @@ interface nsIAbListener : nsISupports {
void OnItemAdded(in nsISupports parentDir, in nsISupports item);
void OnItemRemoved(in nsISupports parentDir, in nsISupports item);
void OnItemPropertyChanged(in nsISupports item, in string property, in string oldValue, in string newValue);
void OnItemPropertyChanged(in nsISupports item, in string property, in wstring oldValue, in wstring newValue);
};

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

@ -39,8 +39,8 @@ interface nsIAddrBookSession : nsISupports {
void RemoveAddressBookListener(in nsIAbListener listener);
void NotifyItemPropertyChanged(in nsISupports item,
in string property,
in string oldValue,
in string newValue);
in wstring oldValue,
in wstring newValue);
void NotifyDirectoryItemAdded(in nsIAbDirectory directory, in nsISupports item);
void NotifyDirectoryItemDeleted(in nsIAbDirectory directory, in nsISupports item);

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

@ -33,7 +33,7 @@ interface nsIDOMWindow;
interface nsIAddressBook : nsISupports {
void DeleteCards(in nsIDOMXULElement tree, in nsIDOMXULElement srcDir, in nsIDOMNodeList node);
void NewAddressBook(in nsIRDFCompositeDataSource db, in nsIDOMXULElement srcDir, in string name);
void NewAddressBook(in nsIRDFCompositeDataSource db, in nsIDOMXULElement srcDir, in wstring name);
void DeleteAddressBooks(in nsIRDFCompositeDataSource db, in nsIDOMXULElement srcDir, in nsIDOMNodeList node);
void PrintCard();
void PrintAddressbook();

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

@ -116,15 +116,16 @@ NS_IMETHODIMP nsAbAddressCollecter::CollectAddress(const char *address)
}
else
{
nsCAutoString senderFromEmail(curAddress);
nsAutoString senderFromEmail(curAddress);
PRInt32 atSignIndex = senderFromEmail.FindChar('@');
if (atSignIndex > 0)
{
senderFromEmail.Truncate(atSignIndex + 1);
senderCard->SetDisplayName(senderFromEmail);
senderCard->SetDisplayName((PRUnichar*)senderFromEmail.GetUnicode());
}
}
senderCard->SetPrimaryEmail(curAddress);
nsAutoString email(curAddress);
senderCard->SetPrimaryEmail((PRUnichar*)email.GetUnicode());
senderCard->AddCardToDatabase("abdirectory://history.mab");
}
}
@ -228,19 +229,29 @@ nsresult nsAbAddressCollecter::IsDomainExcluded(const char *address, nsIPref *pP
nsresult nsAbAddressCollecter::SetNamesForCard(nsIAbCard *senderCard, const char *fullName)
{
PRUnichar *unicodeFirstName = nsnull;
char *firstName = nsnull;
char *lastName = nsnull;
PRUnichar *unicodeStr = nsnull;
PRInt32 unicharLength = 0;
nsresult rv = senderCard->GetFirstName(&firstName);
nsresult rv = senderCard->GetFirstName(&unicodeFirstName);
if (NS_SUCCEEDED(rv) && firstName)
{
}
senderCard->SetDisplayName((char *) fullName);
INTL_ConvertToUnicode((const char *)fullName, nsCRT::strlen(fullName), (void**)&unicodeStr, &unicharLength);
senderCard->SetDisplayName(unicodeStr);
PR_Free(unicodeStr);
rv = SplitFullName (fullName, &firstName, &lastName);
if (NS_SUCCEEDED(rv))
{
senderCard->SetFirstName(firstName);
senderCard->SetLastName(lastName);
INTL_ConvertToUnicode((const char *)firstName, nsCRT::strlen(firstName), (void**)&unicodeStr, &unicharLength);
senderCard->SetFirstName(unicodeStr);
PR_Free(unicodeStr);
INTL_ConvertToUnicode((const char *)lastName, nsCRT::strlen(lastName), (void**)&unicodeStr, &unicharLength);
senderCard->SetLastName(unicodeStr);
PR_Free(unicodeStr);
}
PR_FREEIF(firstName);
PR_FREEIF(lastName);

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

@ -24,6 +24,7 @@
#include "nsIRDFService.h"
#include "nsIAbDirectory.h"
#include "nsIAbCard.h"
#include "nsXPIDLString.h"
static NS_DEFINE_CID(kHeaderParserCID, NS_MSGHEADERPARSER_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
@ -87,17 +88,24 @@ nsresult nsAbAutoCompleteSession::InitializeTable()
nsCOMPtr<nsIAbCard> card(do_QueryInterface(i, &rv));
if (NS_FAILED(rv)) break;
rv=card->GetDisplayName(&m_searchNameCompletionEntryTable[m_numEntries].userName);
/* card holds unicode string, convert to utf8 String for autocomplete*/
nsXPIDLString pUnicodeStr;
PRInt32 unicharLength = 0;
rv=card->GetDisplayName(getter_Copies(pUnicodeStr));
if (NS_FAILED(rv)) {
m_searchNameCompletionEntryTable[m_numEntries].userName = nsnull;
break;
}
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&m_searchNameCompletionEntryTable[m_numEntries].userName);
rv=card->GetPrimaryEmail(&m_searchNameCompletionEntryTable[m_numEntries].emailAddress);
rv=card->GetPrimaryEmail(getter_Copies(pUnicodeStr));
if (NS_FAILED(rv)) {
m_searchNameCompletionEntryTable[m_numEntries].emailAddress = nsnull;
break;
}
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&m_searchNameCompletionEntryTable[m_numEntries].emailAddress);
rv = cards->Next();
m_numEntries++;

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

@ -74,27 +74,29 @@ NS_IMETHODIMP nsAbCard::OnCardEntryChange
card->GetDbRowID(&rowID);
if (m_dbTableID == tableID && m_dbRowID == rowID)
{
char* pNewStr = nsnull;
card->GetDisplayName(&pNewStr);
if (pNewStr)
NotifyPropertyChanged("DisplayName", nsnull, pNewStr);
PR_FREEIF(pNewStr);
nsXPIDLString pDisplayName;
card->GetDisplayName(getter_Copies(pDisplayName));
if (pDisplayName)
NotifyPropertyChanged("DisplayName", nsnull,
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pDisplayName));
card->GetPrimaryEmail(&pNewStr);
if (pNewStr)
NotifyPropertyChanged("PrimaryEmail", nsnull, pNewStr);
PR_FREEIF(pNewStr);
nsXPIDLString pEmail;
card->GetPrimaryEmail(getter_Copies(pEmail));
if (pEmail)
NotifyPropertyChanged("PrimaryEmail", nsnull,
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pEmail));
card->GetWorkPhone(&pNewStr);
if (pNewStr)
NotifyPropertyChanged("WorkPhone", nsnull, pNewStr);
PR_FREEIF(pNewStr);
nsXPIDLString pWorkPhone;
card->GetWorkPhone(getter_Copies(pWorkPhone));
if (pWorkPhone)
NotifyPropertyChanged("WorkPhone", nsnull,
NS_CONST_CAST(PRUnichar*, (const PRUnichar*)pWorkPhone));
}
}
return NS_OK;
}
nsresult nsAbCard::NotifyPropertyChanged(char *property, char* oldValue, char* newValue)
nsresult nsAbCard::NotifyPropertyChanged(char *property, PRUnichar* oldValue, PRUnichar* newValue)
{
nsCOMPtr<nsISupports> supports;
if(NS_SUCCEEDED(QueryInterface(nsCOMTypeInfo<nsISupports>::GetIID(), getter_AddRefs(supports))))

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

@ -51,7 +51,7 @@ public:
protected:
nsresult NotifyPropertyChanged(char *property, char* oldValue, char* newValue);
nsresult NotifyPropertyChanged(char *property, PRUnichar* oldValue, PRUnichar* newValue);
nsresult AddSubNode(nsAutoString name, nsIAbCard **childDir);
protected:

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

@ -85,44 +85,44 @@ nsAbCardProperty::nsAbCardProperty(void)
{
NS_INIT_REFCNT();
m_pFirstName = nsnull;
m_pLastName = nsnull;
m_pDisplayName = nsnull;
m_pNickName = nsnull;
m_pPrimaryEmail = nsnull;
m_pSecondEmail = nsnull;
m_pWorkPhone = nsnull;
m_pHomePhone = nsnull;
m_pFaxNumber = nsnull;
m_pPagerNumber = nsnull;
m_pCellularNumber = nsnull;
m_FirstName = "";
m_LastName = "";
m_DisplayName = "";
m_NickName = "";
m_PrimaryEmail = "";
m_SecondEmail = "";
m_WorkPhone = "";
m_HomePhone = "";
m_FaxNumber = "";
m_PagerNumber = "";
m_CellularNumber = "";
m_pHomeAddress = nsnull;
m_pHomeAddress2 = nsnull;
m_pHomeCity = nsnull;
m_pHomeState = nsnull;
m_pHomeZipCode = nsnull;
m_pHomeCountry = nsnull;
m_pWorkAddress = nsnull;
m_pWorkAddress2 = nsnull;
m_pWorkCity = nsnull;
m_pWorkState = nsnull;
m_pWorkZipCode = nsnull;
m_pWorkCountry = nsnull;
m_pJobTitle = nsnull;
m_pDepartment = nsnull;
m_pCompany = nsnull;
m_pWebPage1 = nsnull;
m_pWebPage2 = nsnull;
m_pBirthYear = nsnull;
m_pBirthMonth = nsnull;
m_pBirthDay = nsnull;
m_pCustom1 = nsnull;
m_pCustom2 = nsnull;
m_pCustom3 = nsnull;
m_pCustom4 = nsnull;
m_pNote = nsnull;
m_pLastModDate = nsnull;
m_HomeAddress = "";
m_HomeAddress2 = "";
m_HomeCity = "";
m_HomeState = "";
m_HomeZipCode = "";
m_HomeCountry = "";
m_WorkAddress = "";
m_WorkAddress2 = "";
m_WorkCity = "";
m_WorkState = "";
m_WorkZipCode = "";
m_WorkCountry = "";
m_JobTitle = "";
m_Department = "";
m_Company = "";
m_WebPage1 = "";
m_WebPage2 = "";
m_BirthYear = "";
m_BirthMonth = "";
m_BirthDay = "";
m_Custom1 = "";
m_Custom2 = "";
m_Custom3 = "";
m_Custom4 = "";
m_Note = "";
m_LastModDate = 0;
m_bSendPlainText = PR_FALSE;
@ -139,44 +139,6 @@ nsAbCardProperty::nsAbCardProperty(void)
nsAbCardProperty::~nsAbCardProperty(void)
{
PR_FREEIF(m_pFirstName);
PR_FREEIF(m_pLastName);
PR_FREEIF(m_pDisplayName);
PR_FREEIF(m_pNickName);
PR_FREEIF(m_pPrimaryEmail);
PR_FREEIF(m_pSecondEmail);
PR_FREEIF(m_pWorkPhone);
PR_FREEIF(m_pHomePhone);
PR_FREEIF(m_pFaxNumber);
PR_FREEIF(m_pPagerNumber);
PR_FREEIF(m_pCellularNumber);
PR_FREEIF(m_pHomeAddress);
PR_FREEIF(m_pHomeAddress2);
PR_FREEIF(m_pHomeCity);
PR_FREEIF(m_pHomeState);
PR_FREEIF(m_pHomeZipCode);
PR_FREEIF(m_pHomeCountry);
PR_FREEIF(m_pWorkAddress);
PR_FREEIF(m_pWorkAddress2);
PR_FREEIF(m_pWorkCity);
PR_FREEIF(m_pWorkState);
PR_FREEIF(m_pWorkZipCode);
PR_FREEIF(m_pWorkCountry);
PR_FREEIF(m_pJobTitle);
PR_FREEIF(m_pDepartment);
PR_FREEIF(m_pCompany);
PR_FREEIF(m_pWebPage1);
PR_FREEIF(m_pWebPage2);
PR_FREEIF(m_pBirthYear);
PR_FREEIF(m_pBirthMonth);
PR_FREEIF(m_pBirthDay);
PR_FREEIF(m_pCustom1);
PR_FREEIF(m_pCustom2);
PR_FREEIF(m_pCustom3);
PR_FREEIF(m_pCustom4);
PR_FREEIF(m_pNote);
PR_FREEIF(m_pLastModDate);
if (m_pAnonymousStrAttributes)
RemoveAnonymousList(m_pAnonymousStrAttributes);
if (m_pAnonymousIntAttributes)
@ -233,29 +195,25 @@ NS_IMETHODIMP nsAbCardProperty::QueryInterface(REFNSIID aIID, void** aResult)
////////////////////////////////////////////////////////////////////////////////
nsresult nsAbCardProperty::GetAttributeName(char **aName, char* pValue)
nsresult nsAbCardProperty::GetAttributeName(PRUnichar **aName, nsString& value)
{
if (aName)
{
if (pValue)
*aName = nsCRT::strdup(pValue);
*aName = value.ToNewUnicode();
if (!(*aName))
return NS_ERROR_OUT_OF_MEMORY;
else
*aName = nsCRT::strdup("");
return NS_OK;
return NS_OK;
}
else
return NS_RDF_NO_VALUE;
return NS_ERROR_NULL_POINTER;
}
nsresult nsAbCardProperty::SetAttributeName(char *aName, char **arrtibute)
nsresult nsAbCardProperty::SetAttributeName(PRUnichar *aName, nsString& arrtibute)
{
if (aName)
{
char *pValue = *arrtibute;
nsCRT::free(pValue);
*arrtibute = nsCRT::strdup(aName);
}
arrtibute = aName;
return NS_OK;
}
@ -295,7 +253,7 @@ NS_IMETHODIMP nsAbCardProperty::SetDbRowID(PRUint32 aDbRowID)
return NS_OK;
}
NS_IMETHODIMP nsAbCardProperty::GetCardValue(const char *attrname, char **value)
NS_IMETHODIMP nsAbCardProperty::GetCardValue(const char *attrname, PRUnichar **value)
{
if (!PL_strcmp(attrname, kFirstNameColumn))
GetFirstName(value);
@ -368,86 +326,86 @@ NS_IMETHODIMP nsAbCardProperty::GetCardValue(const char *attrname, char **value)
return NS_OK;
}
NS_IMETHODIMP nsAbCardProperty::SetCardValue(const char *attrname, const char *value)
NS_IMETHODIMP nsAbCardProperty::SetCardValue(const char *attrname, const PRUnichar *value)
{
if (!attrname && !value)
return NS_ERROR_NULL_POINTER;
nsresult rv = NS_OK;
nsAutoString cardValue(value);
char* valueStr = cardValue.ToNewCString();
if (!PL_strcmp(attrname, kFirstNameColumn))
rv = SetFirstName(valueStr);
rv = SetFirstName((PRUnichar *)value);
else if (!PL_strcmp(attrname, kLastNameColumn))
rv = SetLastName(valueStr);
rv = SetLastName((PRUnichar *)value);
else if (!PL_strcmp(attrname, kDisplayNameColumn))
rv = SetDisplayName(valueStr);
rv = SetDisplayName((PRUnichar *)value);
else if (!PL_strcmp(attrname, kNicknameColumn))
rv = SetNickName(valueStr);
rv = SetNickName((PRUnichar *)value);
else if (!PL_strcmp(attrname, kPriEmailColumn))
rv = SetPrimaryEmail(valueStr);
rv = SetPrimaryEmail((PRUnichar *)value);
else if (!PL_strcmp(attrname, k2ndEmailColumn))
rv = SetSecondEmail(valueStr);
rv = SetSecondEmail((PRUnichar *)value);
else if (!PL_strcmp(attrname, kWorkPhoneColumn))
rv = SetWorkPhone(valueStr);
rv = SetWorkPhone((PRUnichar *)value);
else if (!PL_strcmp(attrname, kHomePhoneColumn))
rv = SetHomePhone(valueStr);
rv = SetHomePhone((PRUnichar *)value);
else if (!PL_strcmp(attrname, kFaxColumn))
rv = SetFaxNumber(valueStr);
rv = SetFaxNumber((PRUnichar *)value);
else if (!PL_strcmp(attrname, kPagerColumn))
rv = SetPagerNumber(valueStr);
rv = SetPagerNumber((PRUnichar *)value);
else if (!PL_strcmp(attrname, kCellularColumn))
rv = SetCellularNumber(valueStr);
rv = SetCellularNumber((PRUnichar *)value);
else if (!PL_strcmp(attrname, kHomeAddressColumn))
rv = SetHomeAddress(valueStr);
rv = SetHomeAddress((PRUnichar *)value);
else if (!PL_strcmp(attrname, kHomeAddress2Column))
rv = SetHomeAddress2(valueStr);
rv = SetHomeAddress2((PRUnichar *)value);
else if (!PL_strcmp(attrname, kHomeCityColumn))
rv = SetHomeCity(valueStr);
rv = SetHomeCity((PRUnichar *)value);
else if (!PL_strcmp(attrname, kHomeStateColumn))
rv = SetHomeState(valueStr);
rv = SetHomeState((PRUnichar *)value);
else if (!PL_strcmp(attrname, kHomeZipCodeColumn))
rv = SetHomeZipCode(valueStr);
rv = SetHomeZipCode((PRUnichar *)value);
else if (!PL_strcmp(attrname, kHomeCountryColumn))
rv = SetHomeCountry(valueStr);
rv = SetHomeCountry((PRUnichar *)value);
else if (!PL_strcmp(attrname, kWorkAddressColumn))
rv = SetWorkAddress(valueStr);
rv = SetWorkAddress((PRUnichar *)value);
else if (!PL_strcmp(attrname, kWorkAddress2Column))
rv = SetWorkAddress2(valueStr);
rv = SetWorkAddress2((PRUnichar *)value);
else if (!PL_strcmp(attrname, kWorkCityColumn))
rv = SetWorkCity(valueStr);
rv = SetWorkCity((PRUnichar *)value);
else if (!PL_strcmp(attrname, kWorkStateColumn))
rv = SetWorkState(valueStr);
rv = SetWorkState((PRUnichar *)value);
else if (!PL_strcmp(attrname, kWorkZipCodeColumn))
rv = SetWorkZipCode(valueStr);
rv = SetWorkZipCode((PRUnichar *)value);
else if (!PL_strcmp(attrname, kWorkCountryColumn))
rv = SetWorkCountry(valueStr);
rv = SetWorkCountry((PRUnichar *)value);
else if (!PL_strcmp(attrname, kWebPage1Column))
rv = SetWebPage1(valueStr);
rv = SetWebPage1((PRUnichar *)value);
else if (!PL_strcmp(attrname, kWebPage2Column))
rv = SetWebPage2(valueStr);
rv = SetWebPage2((PRUnichar *)value);
else if (!PL_strcmp(attrname, kBirthYearColumn))
rv = SetBirthYear(valueStr);
rv = SetBirthYear((PRUnichar *)value);
else if (!PL_strcmp(attrname, kBirthMonthColumn))
rv = SetBirthMonth(valueStr);
rv = SetBirthMonth((PRUnichar *)value);
else if (!PL_strcmp(attrname, kBirthDayColumn))
rv = SetBirthDay(valueStr);
rv = SetBirthDay((PRUnichar *)value);
else if (!PL_strcmp(attrname, kCustom1Column))
rv = SetCustom1(valueStr);
rv = SetCustom1((PRUnichar *)value);
else if (!PL_strcmp(attrname, kCustom2Column))
rv = SetCustom2(valueStr);
rv = SetCustom2((PRUnichar *)value);
else if (!PL_strcmp(attrname, kCustom3Column))
rv = SetCustom3(valueStr);
rv = SetCustom3((PRUnichar *)value);
else if (!PL_strcmp(attrname, kCustom4Column))
rv = SetCustom4(valueStr);
rv = SetCustom4((PRUnichar *)value);
else if (!PL_strcmp(attrname, kNotesColumn))
rv = SetNotes(valueStr);
rv = SetNotes((PRUnichar *)value);
else
rv = SetAnonymousStringAttribute(attrname, value);
delete[] valueStr;
{
nsAutoString cardValue(value);
char* valueStr = cardValue.ToNewCString();
rv = SetAnonymousStringAttribute(attrname, valueStr);
delete[] valueStr;
}
return rv;
}
@ -723,7 +681,7 @@ NS_IMETHODIMP nsAbCardProperty::EditCardToDatabase(const char *uri)
NS_IMETHODIMP nsAbCardProperty::CopyCard(nsIAbCard* srcCard)
{
char *str = nsnull;
PRUnichar *str = nsnull;
srcCard->GetFirstName(&str);
SetFirstName(str);
PR_FREEIF(str);

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

@ -45,81 +45,81 @@ public:
virtual ~nsAbCardProperty(void);
// nsIAbCard methods:
NS_IMETHOD GetFirstName(char * *aFirstName) { return GetAttributeName(aFirstName, m_pFirstName); }
NS_IMETHOD GetLastName(char * *aLastName) { return GetAttributeName(aLastName, m_pLastName); }
NS_IMETHOD GetDisplayName(char * *aDisplayName) { return GetAttributeName(aDisplayName, m_pDisplayName); }
NS_IMETHOD GetNickName(char * *aNickName) { return GetAttributeName(aNickName, m_pNickName); }
NS_IMETHOD GetPrimaryEmail(char * *aPrimaryEmail) { return GetAttributeName(aPrimaryEmail, m_pPrimaryEmail); }
NS_IMETHOD GetSecondEmail(char * *aSecondEmail) { return GetAttributeName(aSecondEmail, m_pSecondEmail); }
NS_IMETHOD GetWorkPhone(char * *aWorkPhone) { return GetAttributeName(aWorkPhone, m_pWorkPhone); }
NS_IMETHOD GetHomePhone(char * *aHomePhone) { return GetAttributeName(aHomePhone, m_pHomePhone); }
NS_IMETHOD GetFaxNumber(char * *aFaxNumber) { return GetAttributeName(aFaxNumber, m_pFaxNumber); }
NS_IMETHOD GetPagerNumber(char * *aPagerNumber) { return GetAttributeName(aPagerNumber, m_pPagerNumber); }
NS_IMETHOD GetCellularNumber(char * *aCellularNumber) { return GetAttributeName(aCellularNumber, m_pCellularNumber); }
NS_IMETHOD GetHomeAddress(char * *aHomeAddress) { return GetAttributeName(aHomeAddress, m_pHomeAddress); }
NS_IMETHOD GetHomeAddress2(char * *aHomeAddress2) { return GetAttributeName(aHomeAddress2, m_pHomeAddress2); }
NS_IMETHOD GetHomeCity(char * *aHomeCity) { return GetAttributeName(aHomeCity, m_pHomeCity); }
NS_IMETHOD GetHomeState(char * *aHomeState) { return GetAttributeName(aHomeState, m_pHomeState); }
NS_IMETHOD GetHomeZipCode(char * *aHomeZipCode) { return GetAttributeName(aHomeZipCode, m_pHomeZipCode); }
NS_IMETHOD GetHomeCountry(char * *aHomecountry) { return GetAttributeName(aHomecountry, m_pHomeCountry); }
NS_IMETHOD GetWorkAddress(char * *aWorkAddress) { return GetAttributeName(aWorkAddress, m_pWorkAddress); }
NS_IMETHOD GetWorkAddress2(char * *aWorkAddress2) { return GetAttributeName(aWorkAddress2, m_pWorkAddress2); }
NS_IMETHOD GetWorkCity(char * *aWorkCity) { return GetAttributeName(aWorkCity, m_pWorkCity); }
NS_IMETHOD GetWorkState(char * *aWorkState) { return GetAttributeName(aWorkState, m_pWorkState); }
NS_IMETHOD GetWorkZipCode(char * *aWorkZipCode) { return GetAttributeName(aWorkZipCode, m_pWorkZipCode); }
NS_IMETHOD GetWorkCountry(char * *aWorkCountry) { return GetAttributeName(aWorkCountry, m_pWorkCountry); }
NS_IMETHOD GetJobTitle(char * *aJobTitle) { return GetAttributeName(aJobTitle, m_pJobTitle); }
NS_IMETHOD GetDepartment(char * *aDepartment) { return GetAttributeName(aDepartment, m_pDepartment); }
NS_IMETHOD GetCompany(char * *aCompany) { return GetAttributeName(aCompany, m_pCompany); }
NS_IMETHOD GetWebPage1(char * *aWebPage1) { return GetAttributeName(aWebPage1, m_pWebPage1); }
NS_IMETHOD GetWebPage2(char * *aWebPage2) { return GetAttributeName(aWebPage2, m_pWebPage2); }
NS_IMETHOD GetBirthYear(char * *aBirthYear) { return GetAttributeName(aBirthYear, m_pBirthYear); }
NS_IMETHOD GetBirthMonth(char * *aBirthMonth) { return GetAttributeName(aBirthMonth, m_pBirthMonth); }
NS_IMETHOD GetBirthDay(char * *aBirthDay) { return GetAttributeName(aBirthDay, m_pBirthDay); }
NS_IMETHOD GetCustom1(char * *aCustom1) { return GetAttributeName(aCustom1, m_pCustom1); }
NS_IMETHOD GetCustom2(char * *aCustom2) { return GetAttributeName(aCustom2, m_pCustom2); }
NS_IMETHOD GetCustom3(char * *aCustom3) { return GetAttributeName(aCustom3, m_pCustom3); }
NS_IMETHOD GetCustom4(char * *aCustom4) { return GetAttributeName(aCustom4, m_pCustom4); }
NS_IMETHOD GetNotes(char * *aNotes) { return GetAttributeName(aNotes, m_pNote); }
NS_IMETHOD GetLastModifiedDate(char * *aLastModifiedDate) { return GetAttributeName(aLastModifiedDate, m_pLastModDate); }
NS_IMETHOD GetFirstName(PRUnichar * *aFirstName) { return GetAttributeName(aFirstName, m_FirstName); }
NS_IMETHOD GetLastName(PRUnichar * *aLastName) { return GetAttributeName(aLastName, m_LastName); }
NS_IMETHOD GetDisplayName(PRUnichar * *aDisplayName) { return GetAttributeName(aDisplayName, m_DisplayName); }
NS_IMETHOD GetNickName(PRUnichar * *aNickName) { return GetAttributeName(aNickName, m_NickName); }
NS_IMETHOD GetPrimaryEmail(PRUnichar * *aPrimaryEmail) { return GetAttributeName(aPrimaryEmail, m_PrimaryEmail); }
NS_IMETHOD GetSecondEmail(PRUnichar * *aSecondEmail) { return GetAttributeName(aSecondEmail, m_SecondEmail); }
NS_IMETHOD GetWorkPhone(PRUnichar * *aWorkPhone) { return GetAttributeName(aWorkPhone, m_WorkPhone); }
NS_IMETHOD GetHomePhone(PRUnichar * *aHomePhone) { return GetAttributeName(aHomePhone, m_HomePhone); }
NS_IMETHOD GetFaxNumber(PRUnichar * *aFaxNumber) { return GetAttributeName(aFaxNumber, m_FaxNumber); }
NS_IMETHOD GetPagerNumber(PRUnichar * *aPagerNumber) { return GetAttributeName(aPagerNumber, m_PagerNumber); }
NS_IMETHOD GetCellularNumber(PRUnichar * *aCellularNumber) { return GetAttributeName(aCellularNumber, m_CellularNumber); }
NS_IMETHOD GetHomeAddress(PRUnichar * *aHomeAddress) { return GetAttributeName(aHomeAddress, m_HomeAddress); }
NS_IMETHOD GetHomeAddress2(PRUnichar * *aHomeAddress2) { return GetAttributeName(aHomeAddress2, m_HomeAddress2); }
NS_IMETHOD GetHomeCity(PRUnichar * *aHomeCity) { return GetAttributeName(aHomeCity, m_HomeCity); }
NS_IMETHOD GetHomeState(PRUnichar * *aHomeState) { return GetAttributeName(aHomeState, m_HomeState); }
NS_IMETHOD GetHomeZipCode(PRUnichar * *aHomeZipCode) { return GetAttributeName(aHomeZipCode, m_HomeZipCode); }
NS_IMETHOD GetHomeCountry(PRUnichar * *aHomecountry) { return GetAttributeName(aHomecountry, m_HomeCountry); }
NS_IMETHOD GetWorkAddress(PRUnichar * *aWorkAddress) { return GetAttributeName(aWorkAddress, m_WorkAddress); }
NS_IMETHOD GetWorkAddress2(PRUnichar * *aWorkAddress2) { return GetAttributeName(aWorkAddress2, m_WorkAddress2); }
NS_IMETHOD GetWorkCity(PRUnichar * *aWorkCity) { return GetAttributeName(aWorkCity, m_WorkCity); }
NS_IMETHOD GetWorkState(PRUnichar * *aWorkState) { return GetAttributeName(aWorkState, m_WorkState); }
NS_IMETHOD GetWorkZipCode(PRUnichar * *aWorkZipCode) { return GetAttributeName(aWorkZipCode, m_WorkZipCode); }
NS_IMETHOD GetWorkCountry(PRUnichar * *aWorkCountry) { return GetAttributeName(aWorkCountry, m_WorkCountry); }
NS_IMETHOD GetJobTitle(PRUnichar * *aJobTitle) { return GetAttributeName(aJobTitle, m_JobTitle); }
NS_IMETHOD GetDepartment(PRUnichar * *aDepartment) { return GetAttributeName(aDepartment, m_Department); }
NS_IMETHOD GetCompany(PRUnichar * *aCompany) { return GetAttributeName(aCompany, m_Company); }
NS_IMETHOD GetWebPage1(PRUnichar * *aWebPage1) { return GetAttributeName(aWebPage1, m_WebPage1); }
NS_IMETHOD GetWebPage2(PRUnichar * *aWebPage2) { return GetAttributeName(aWebPage2, m_WebPage2); }
NS_IMETHOD GetBirthYear(PRUnichar * *aBirthYear) { return GetAttributeName(aBirthYear, m_BirthYear); }
NS_IMETHOD GetBirthMonth(PRUnichar * *aBirthMonth) { return GetAttributeName(aBirthMonth, m_BirthMonth); }
NS_IMETHOD GetBirthDay(PRUnichar * *aBirthDay) { return GetAttributeName(aBirthDay, m_BirthDay); }
NS_IMETHOD GetCustom1(PRUnichar * *aCustom1) { return GetAttributeName(aCustom1, m_Custom1); }
NS_IMETHOD GetCustom2(PRUnichar * *aCustom2) { return GetAttributeName(aCustom2, m_Custom2); }
NS_IMETHOD GetCustom3(PRUnichar * *aCustom3) { return GetAttributeName(aCustom3, m_Custom3); }
NS_IMETHOD GetCustom4(PRUnichar * *aCustom4) { return GetAttributeName(aCustom4, m_Custom4); }
NS_IMETHOD GetNotes(PRUnichar * *aNotes) { return GetAttributeName(aNotes, m_Note); }
NS_IMETHOD GetLastModifiedDate(PRUint32 *aLastModifiedDate) { return *aLastModifiedDate = m_LastModDate; }
NS_IMETHOD SetFirstName(char * aFirstName) { return SetAttributeName(aFirstName, &m_pFirstName); }
NS_IMETHOD SetLastName(char * aLastName) { return SetAttributeName(aLastName, &m_pLastName); }
NS_IMETHOD SetDisplayName(char * aDisplayName) { return SetAttributeName(aDisplayName, &m_pDisplayName); }
NS_IMETHOD SetNickName(char * aNickName) { return SetAttributeName(aNickName, &m_pNickName); }
NS_IMETHOD SetPrimaryEmail(char * aPrimaryEmail) { return SetAttributeName(aPrimaryEmail, &m_pPrimaryEmail); }
NS_IMETHOD SetSecondEmail(char * aSecondEmail) { return SetAttributeName(aSecondEmail, &m_pSecondEmail); }
NS_IMETHOD SetWorkPhone(char * aWorkPhone) { return SetAttributeName(aWorkPhone, &m_pWorkPhone); }
NS_IMETHOD SetHomePhone(char * aHomePhone) { return SetAttributeName(aHomePhone, &m_pHomePhone); }
NS_IMETHOD SetFaxNumber(char * aFaxNumber) { return SetAttributeName(aFaxNumber, &m_pFaxNumber); }
NS_IMETHOD SetPagerNumber(char * aPagerNumber) { return SetAttributeName(aPagerNumber, &m_pPagerNumber); }
NS_IMETHOD SetCellularNumber(char * aCellularNumber) { return SetAttributeName(aCellularNumber, &m_pCellularNumber); }
NS_IMETHOD SetHomeAddress(char * aHomeAddress) { return SetAttributeName(aHomeAddress, &m_pHomeAddress); }
NS_IMETHOD SetHomeAddress2(char * aHomeAddress2) { return SetAttributeName(aHomeAddress2, &m_pHomeAddress2); }
NS_IMETHOD SetHomeCity(char * aHomeCity) { return SetAttributeName(aHomeCity, &m_pHomeCity); }
NS_IMETHOD SetHomeState(char * aHomeState) { return SetAttributeName(aHomeState, &m_pHomeState); }
NS_IMETHOD SetHomeZipCode(char * aHomeZipCode) { return SetAttributeName(aHomeZipCode, &m_pHomeZipCode); }
NS_IMETHOD SetHomeCountry(char * aHomecountry) { return SetAttributeName(aHomecountry, &m_pHomeCountry); }
NS_IMETHOD SetWorkAddress(char * aWorkAddress) { return SetAttributeName(aWorkAddress, &m_pWorkAddress); }
NS_IMETHOD SetWorkAddress2(char * aWorkAddress2) { return SetAttributeName(aWorkAddress2, &m_pWorkAddress2); }
NS_IMETHOD SetWorkCity(char * aWorkCity) { return SetAttributeName(aWorkCity, &m_pWorkCity); }
NS_IMETHOD SetWorkState(char * aWorkState) { return SetAttributeName(aWorkState, &m_pWorkState); }
NS_IMETHOD SetWorkZipCode(char * aWorkZipCode) { return SetAttributeName(aWorkZipCode, &m_pWorkZipCode); }
NS_IMETHOD SetWorkCountry(char * aWorkCountry) { return SetAttributeName(aWorkCountry, &m_pWorkCountry); }
NS_IMETHOD SetJobTitle(char * aJobTitle) { return SetAttributeName(aJobTitle, &m_pJobTitle); }
NS_IMETHOD SetDepartment(char * aDepartment) { return SetAttributeName(aDepartment, &m_pDepartment); }
NS_IMETHOD SetCompany(char * aCompany) { return SetAttributeName(aCompany, &m_pCompany); }
NS_IMETHOD SetWebPage1(char * aWebPage1) { return SetAttributeName(aWebPage1, &m_pWebPage1); }
NS_IMETHOD SetWebPage2(char * aWebPage2) { return SetAttributeName(aWebPage2, &m_pWebPage2); }
NS_IMETHOD SetBirthYear(char * aBirthYear) { return SetAttributeName(aBirthYear, &m_pBirthYear); }
NS_IMETHOD SetBirthMonth(char * aBirthMonth) { return SetAttributeName(aBirthMonth, &m_pBirthMonth); }
NS_IMETHOD SetBirthDay(char * aBirthDay) { return SetAttributeName(aBirthDay, &m_pBirthDay); }
NS_IMETHOD SetCustom1(char * aCustom1) { return SetAttributeName(aCustom1, &m_pCustom1); }
NS_IMETHOD SetCustom2(char * aCustom2) { return SetAttributeName(aCustom2, &m_pCustom2); }
NS_IMETHOD SetCustom3(char * aCustom3) { return SetAttributeName(aCustom3, &m_pCustom3); }
NS_IMETHOD SetCustom4(char * aCustom4) { return SetAttributeName(aCustom4, &m_pCustom4); }
NS_IMETHOD SetNotes(char * aNotes) { return SetAttributeName(aNotes, &m_pNote); }
NS_IMETHOD SetLastModifiedDate(char * aLastModifiedDate) { return SetAttributeName(aLastModifiedDate, &m_pLastModDate); }
NS_IMETHOD SetFirstName(PRUnichar * aFirstName) { return SetAttributeName(aFirstName, m_FirstName); }
NS_IMETHOD SetLastName(PRUnichar * aLastName) { return SetAttributeName(aLastName, m_LastName); }
NS_IMETHOD SetDisplayName(PRUnichar * aDisplayName) { return SetAttributeName(aDisplayName, m_DisplayName); }
NS_IMETHOD SetNickName(PRUnichar * aNickName) { return SetAttributeName(aNickName, m_NickName); }
NS_IMETHOD SetPrimaryEmail(PRUnichar * aPrimaryEmail) { return SetAttributeName(aPrimaryEmail, m_PrimaryEmail); }
NS_IMETHOD SetSecondEmail(PRUnichar * aSecondEmail) { return SetAttributeName(aSecondEmail, m_SecondEmail); }
NS_IMETHOD SetWorkPhone(PRUnichar * aWorkPhone) { return SetAttributeName(aWorkPhone, m_WorkPhone); }
NS_IMETHOD SetHomePhone(PRUnichar * aHomePhone) { return SetAttributeName(aHomePhone, m_HomePhone); }
NS_IMETHOD SetFaxNumber(PRUnichar * aFaxNumber) { return SetAttributeName(aFaxNumber, m_FaxNumber); }
NS_IMETHOD SetPagerNumber(PRUnichar * aPagerNumber) { return SetAttributeName(aPagerNumber, m_PagerNumber); }
NS_IMETHOD SetCellularNumber(PRUnichar * aCellularNumber) { return SetAttributeName(aCellularNumber, m_CellularNumber); }
NS_IMETHOD SetHomeAddress(PRUnichar * aHomeAddress) { return SetAttributeName(aHomeAddress, m_HomeAddress); }
NS_IMETHOD SetHomeAddress2(PRUnichar * aHomeAddress2) { return SetAttributeName(aHomeAddress2, m_HomeAddress2); }
NS_IMETHOD SetHomeCity(PRUnichar * aHomeCity) { return SetAttributeName(aHomeCity, m_HomeCity); }
NS_IMETHOD SetHomeState(PRUnichar * aHomeState) { return SetAttributeName(aHomeState, m_HomeState); }
NS_IMETHOD SetHomeZipCode(PRUnichar * aHomeZipCode) { return SetAttributeName(aHomeZipCode, m_HomeZipCode); }
NS_IMETHOD SetHomeCountry(PRUnichar * aHomecountry) { return SetAttributeName(aHomecountry, m_HomeCountry); }
NS_IMETHOD SetWorkAddress(PRUnichar * aWorkAddress) { return SetAttributeName(aWorkAddress, m_WorkAddress); }
NS_IMETHOD SetWorkAddress2(PRUnichar * aWorkAddress2) { return SetAttributeName(aWorkAddress2, m_WorkAddress2); }
NS_IMETHOD SetWorkCity(PRUnichar * aWorkCity) { return SetAttributeName(aWorkCity, m_WorkCity); }
NS_IMETHOD SetWorkState(PRUnichar * aWorkState) { return SetAttributeName(aWorkState, m_WorkState); }
NS_IMETHOD SetWorkZipCode(PRUnichar * aWorkZipCode) { return SetAttributeName(aWorkZipCode, m_WorkZipCode); }
NS_IMETHOD SetWorkCountry(PRUnichar * aWorkCountry) { return SetAttributeName(aWorkCountry, m_WorkCountry); }
NS_IMETHOD SetJobTitle(PRUnichar * aJobTitle) { return SetAttributeName(aJobTitle, m_JobTitle); }
NS_IMETHOD SetDepartment(PRUnichar * aDepartment) { return SetAttributeName(aDepartment, m_Department); }
NS_IMETHOD SetCompany(PRUnichar * aCompany) { return SetAttributeName(aCompany, m_Company); }
NS_IMETHOD SetWebPage1(PRUnichar * aWebPage1) { return SetAttributeName(aWebPage1, m_WebPage1); }
NS_IMETHOD SetWebPage2(PRUnichar * aWebPage2) { return SetAttributeName(aWebPage2, m_WebPage2); }
NS_IMETHOD SetBirthYear(PRUnichar * aBirthYear) { return SetAttributeName(aBirthYear, m_BirthYear); }
NS_IMETHOD SetBirthMonth(PRUnichar * aBirthMonth) { return SetAttributeName(aBirthMonth, m_BirthMonth); }
NS_IMETHOD SetBirthDay(PRUnichar * aBirthDay) { return SetAttributeName(aBirthDay, m_BirthDay); }
NS_IMETHOD SetCustom1(PRUnichar * aCustom1) { return SetAttributeName(aCustom1, m_Custom1); }
NS_IMETHOD SetCustom2(PRUnichar * aCustom2) { return SetAttributeName(aCustom2, m_Custom2); }
NS_IMETHOD SetCustom3(PRUnichar * aCustom3) { return SetAttributeName(aCustom3, m_Custom3); }
NS_IMETHOD SetCustom4(PRUnichar * aCustom4) { return SetAttributeName(aCustom4, m_Custom4); }
NS_IMETHOD SetNotes(PRUnichar * aNotes) { return SetAttributeName(aNotes, m_Note); }
NS_IMETHOD SetLastModifiedDate(PRUint32 aLastModifiedDate) { return m_LastModDate = aLastModifiedDate; }
NS_IMETHOD GetSendPlainText(PRBool *aSendPlainText);
NS_IMETHOD SetSendPlainText(PRBool aSendPlainText);
@ -129,8 +129,8 @@ public:
NS_IMETHOD GetDbRowID(PRUint32 *aDbRowID);
NS_IMETHOD SetDbRowID(PRUint32 aDbRowID);
NS_IMETHOD GetCardValue(const char *attrname, char **value);
NS_IMETHOD SetCardValue(const char *attrname, const char *value);
NS_IMETHOD GetCardValue(const char *attrname, PRUnichar **value);
NS_IMETHOD SetCardValue(const char *attrname, const PRUnichar *value);
NS_IMETHOD SetAbDatabase(nsIAddrDatabase* database);
NS_IMETHOD GetAnonymousStrAttrubutesList(nsVoidArray **attrlist);
@ -155,49 +155,49 @@ public:
protected:
nsresult GetCardDatabase(const char *uri);
nsresult GetAttributeName(char **aName, char* pValue);
nsresult SetAttributeName(char *aName, char** arrtibute);
nsresult GetAttributeName(PRUnichar **aName, nsString& value);
nsresult SetAttributeName(PRUnichar *aName, nsString& arrtibute);
nsresult RemoveAnonymousList(nsVoidArray* pArray);
nsresult SetAnonymousAttribute(nsVoidArray** pAttrAray,
nsVoidArray** pValueArray, void *attrname, void *value);
char* m_pFirstName;
char* m_pLastName;
char* m_pDisplayName;
char* m_pNickName;
char* m_pPrimaryEmail;
char* m_pSecondEmail;
char* m_pWorkPhone;
char* m_pHomePhone;
char* m_pFaxNumber;
char* m_pPagerNumber;
char* m_pCellularNumber;
char* m_pHomeAddress;
char* m_pHomeAddress2;
char* m_pHomeCity;
char* m_pHomeState;
char* m_pHomeZipCode;
char* m_pHomeCountry;
char* m_pWorkAddress;
char* m_pWorkAddress2;
char* m_pWorkCity;
char* m_pWorkState;
char* m_pWorkZipCode;
char* m_pWorkCountry;
char* m_pJobTitle;
char* m_pDepartment;
char* m_pCompany;
char* m_pWebPage1;
char* m_pWebPage2;
char* m_pBirthYear;
char* m_pBirthMonth;
char* m_pBirthDay;
char* m_pCustom1;
char* m_pCustom2;
char* m_pCustom3;
char* m_pCustom4;
char* m_pNote;
char* m_pLastModDate;
nsString m_FirstName;
nsString m_LastName;
nsString m_DisplayName;
nsString m_NickName;
nsString m_PrimaryEmail;
nsString m_SecondEmail;
nsString m_WorkPhone;
nsString m_HomePhone;
nsString m_FaxNumber;
nsString m_PagerNumber;
nsString m_CellularNumber;
nsString m_HomeAddress;
nsString m_HomeAddress2;
nsString m_HomeCity;
nsString m_HomeState;
nsString m_HomeZipCode;
nsString m_HomeCountry;
nsString m_WorkAddress;
nsString m_WorkAddress2;
nsString m_WorkCity;
nsString m_WorkState;
nsString m_WorkZipCode;
nsString m_WorkCountry;
nsString m_JobTitle;
nsString m_Department;
nsString m_Company;
nsString m_WebPage1;
nsString m_WebPage2;
nsString m_BirthYear;
nsString m_BirthMonth;
nsString m_BirthDay;
nsString m_Custom1;
nsString m_Custom2;
nsString m_Custom3;
nsString m_Custom4;
nsString m_Note;
PRUint32 m_LastModDate;
PRBool m_bSendPlainText;

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

@ -41,7 +41,7 @@ static NS_DEFINE_CID(kAddressBookDBCID, NS_ADDRESSBOOKDB_CID);
static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID);
nsAbDirProperty::nsAbDirProperty(void)
: m_DirName(nsnull), m_LastModifiedDate(nsnull),
: m_DirName(""), m_LastModifiedDate(0),
m_DbPath(nsnull), m_Server(nsnull)
{
NS_INIT_REFCNT();
@ -49,8 +49,6 @@ nsAbDirProperty::nsAbDirProperty(void)
nsAbDirProperty::~nsAbDirProperty(void)
{
PR_FREEIF(m_DirName);
PR_FREEIF(m_LastModifiedDate);
PR_FREEIF(m_DbPath);
// m_Server will free with the list
}
@ -96,50 +94,43 @@ NS_IMETHODIMP nsAbDirProperty::GetDirFilePath(char **dbPath)
////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsAbDirProperty::GetDirName(char **name)
NS_IMETHODIMP nsAbDirProperty::GetDirName(PRUnichar **aDirName)
{
if (name)
if (aDirName)
{
if (m_DirName)
*name = PL_strdup(m_DirName);
*aDirName = m_DirName.ToNewUnicode();
if (!(*aDirName))
return NS_ERROR_OUT_OF_MEMORY;
else
*name = PL_strdup("");
return NS_OK;
return NS_OK;
}
else
return NS_RDF_NO_VALUE;
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsAbDirProperty::SetDirName(char * name)
NS_IMETHODIMP nsAbDirProperty::SetDirName(PRUnichar * aDirName)
{
if (name)
{
PR_FREEIF(m_DirName);
m_DirName = PL_strdup(name);
}
if (aDirName)
m_DirName = aDirName;
return NS_OK;
}
NS_IMETHODIMP nsAbDirProperty::GetLastModifiedDate(char * *aLastModifiedDate)
NS_IMETHODIMP nsAbDirProperty::GetLastModifiedDate(PRUint32 *aLastModifiedDate)
{
if (aLastModifiedDate)
{
if (m_DirName)
*aLastModifiedDate = PL_strdup(m_LastModifiedDate);
else
*aLastModifiedDate = PL_strdup("");
*aLastModifiedDate = m_LastModifiedDate;
return NS_OK;
}
else
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP nsAbDirProperty::SetLastModifiedDate(char * aLastModifiedDate)
NS_IMETHODIMP nsAbDirProperty::SetLastModifiedDate(PRUint32 aLastModifiedDate)
{
if (aLastModifiedDate)
{
PR_FREEIF(m_LastModifiedDate);
m_LastModifiedDate = PL_strdup(aLastModifiedDate);
m_LastModifiedDate = aLastModifiedDate;
}
return NS_OK;
}

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

@ -45,10 +45,10 @@ public:
NS_DECL_ISUPPORTS
// nsIAbDirectory methods:
NS_IMETHOD GetDirName(char **name);
NS_IMETHOD SetDirName(char * name);
NS_IMETHOD GetLastModifiedDate(char * *aLastModifiedDate);
NS_IMETHOD SetLastModifiedDate(char * aLastModifiedDate);
NS_IMETHOD GetDirName(PRUnichar **aDirName);
NS_IMETHOD SetDirName(PRUnichar * aDirName);
NS_IMETHOD GetLastModifiedDate(PRUint32 *aLastModifiedDate);
NS_IMETHOD SetLastModifiedDate(PRUint32 aLastModifiedDate);
NS_IMETHOD GetServer(DIR_Server * *aServer);
NS_IMETHOD SetServer(DIR_Server * aServer);
NS_IMETHOD GetDirFilePath(char **dbPath);
@ -62,13 +62,13 @@ public:
NS_IMETHOD HasCard(nsIAbCard *cards, PRBool *hasCard) { return NS_OK; }
NS_IMETHOD HasDirectory(nsIAbDirectory *dir, PRBool *hasDir) { return NS_OK; }
NS_IMETHOD GetMailingList(nsIEnumerator **mailingList) { return NS_OK; }
NS_IMETHOD CreateNewDirectory(const char *dirName, const char *fileName) { return NS_OK; }
NS_IMETHOD CreateNewDirectory(const PRUnichar *dirName, const char *fileName) { return NS_OK; }
NS_IMETHOD GetDirUri(char **uri) { return NS_OK; }
protected:
char* m_DirName;
char* m_LastModifiedDate;
nsString m_DirName;
PRUint32 m_LastModifiedDate;
nsFileSpec* m_DbPath;
DIR_Server* m_Server;
};

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

@ -157,8 +157,14 @@ NS_IMETHODIMP nsAbDirectory::GetChildNodes(nsIEnumerator* *result)
if (childDir)
{
childDir->SetDirName(server->description);
PRUnichar *unichars = nsnull;
PRInt32 unicharLength = 0;
PRInt32 descLength = PL_strlen(server->description);
INTL_ConvertToUnicode((const char *)server->description,
descLength, (void**)&unichars, &unicharLength);
childDir->SetDirName(unichars);
childDir->SetServer(server);
PR_FREEIF(unichars);
}
}
}
@ -217,7 +223,7 @@ NS_IMETHODIMP nsAbDirectory::GetMailingList(nsIEnumerator **mailingList)
return rv;
}
NS_IMETHODIMP nsAbDirectory::CreateNewDirectory(const char *dirName, const char *fileName)
NS_IMETHODIMP nsAbDirectory::CreateNewDirectory(const PRUnichar *dirName, const char *fileName)
{
if (!dirName)
return NS_ERROR_NULL_POINTER;
@ -233,7 +239,7 @@ NS_IMETHODIMP nsAbDirectory::CreateNewDirectory(const char *dirName, const char
PR_smprintf_free(uri);
if (NS_SUCCEEDED(rv) && newDir)
{
newDir->SetDirName(server->description);
newDir->SetDirName((PRUnichar *)dirName);
newDir->SetServer(server);
// nsCOMPtr<nsISupports> dirSupports(do_QueryInterface(newDir, &rv));
@ -447,7 +453,7 @@ NS_IMETHODIMP nsAbDirectory::HasDirectory(nsIAbDirectory *dir, PRBool *hasDir)
return rv;
}
nsresult nsAbDirectory::NotifyPropertyChanged(char *property, char* oldValue, char* newValue)
nsresult nsAbDirectory::NotifyPropertyChanged(char *property, PRUnichar* oldValue, PRUnichar* newValue)
{
return NS_OK;
}

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

@ -54,7 +54,7 @@ public:
NS_IMETHOD HasCard(nsIAbCard *cards, PRBool *hasCard);
NS_IMETHOD HasDirectory(nsIAbDirectory *dir, PRBool *hasDir);
NS_IMETHOD GetMailingList(nsIEnumerator **mailingList);
NS_IMETHOD CreateNewDirectory(const char *dirName, const char *fileName);
NS_IMETHOD CreateNewDirectory(const PRUnichar *dirName, const char *fileName);
NS_IMETHOD GetDirUri(char **uri);
// nsIAddrDBListener methods:
@ -62,7 +62,7 @@ public:
NS_IMETHOD OnCardEntryChange(PRUint32 abCode, nsIAbCard *card, nsIAddrDBListener *instigator);
protected:
nsresult NotifyPropertyChanged(char *property, char* oldValue, char* newValue);
nsresult NotifyPropertyChanged(char *property, PRUnichar* oldValue, PRUnichar* newValue);
nsresult NotifyItemAdded(nsISupports *item);
nsresult NotifyItemDeleted(nsISupports *item);
nsresult AddChildCards(nsAutoString name, nsIAbCard **childDir);

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

@ -111,8 +111,8 @@ nsresult nsAbRDFDataSource::NotifyObservers(nsIRDFResource *subject,
}
nsresult nsAbRDFDataSource::NotifyPropertyChanged(nsIRDFResource *resource,
nsIRDFResource *propertyResource,
const char *oldValue, const char *newValue)
nsIRDFResource *propertyResource,
const PRUnichar *oldValue, const PRUnichar *newValue)
{
nsCOMPtr<nsIRDFNode> newValueNode;
nsString newValueStr = newValue;

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

@ -53,7 +53,7 @@ protected:
void createNode(PRUint32 value, nsIRDFNode **node);
nsresult NotifyPropertyChanged(nsIRDFResource *resource, nsIRDFResource *propertyResource,
const char *oldValue, const char *newValue);
const PRUnichar *oldValue, const PRUnichar *newValue);
nsresult NotifyObservers(nsIRDFResource *subject, nsIRDFResource *property,
nsIRDFNode *object, PRBool assert);

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

@ -61,7 +61,7 @@ NS_IMETHODIMP nsAddrBookSession::RemoveAddressBookListener(nsIAbListener * liste
}
NS_IMETHODIMP nsAddrBookSession::NotifyItemPropertyChanged
(nsISupports *item, const char *property, const char* oldValue, const char* newValue)
(nsISupports *item, const char *property, const PRUnichar* oldValue, const PRUnichar* newValue)
{
PRInt32 i;
PRInt32 count = mListeners->Count();

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

@ -946,150 +946,297 @@ nsresult nsAddrDatabase::AddAttributeColumnsToRow(nsIAbCard *card, nsIMdbRow *ca
// add the row to the singleton table.
if (NS_SUCCEEDED(err) && cardRow)
{
nsXPIDLCString pStr;
card->GetFirstName(getter_Copies(pStr));
if (pStr)
AddFirstName(cardRow, pStr);
card->GetLastName(getter_Copies(pStr));
if (pStr)
AddLastName(cardRow, pStr);
card->GetDisplayName(getter_Copies(pStr));
if (pStr)
AddDisplayName(cardRow, pStr);
card->GetNickName(getter_Copies(pStr));
if (pStr)
AddNickName(cardRow, pStr);
card->GetPrimaryEmail(getter_Copies(pStr));
if (pStr)
AddPrimaryEmail(cardRow, pStr);
card->GetSecondEmail(getter_Copies(pStr));
if (pStr)
Add2ndEmail(cardRow, pStr);
card->GetWorkPhone(getter_Copies(pStr));
if (pStr)
AddWorkPhone(cardRow, pStr);
card->GetHomePhone(getter_Copies(pStr));
if (pStr)
AddHomePhone(cardRow, pStr);
card->GetFaxNumber(getter_Copies(pStr));
if (pStr)
AddFaxNumber(cardRow, pStr);
card->GetPagerNumber(getter_Copies(pStr));
if (pStr)
AddPagerNumber(cardRow,pStr);
card->GetCellularNumber(getter_Copies(pStr));
if (pStr)
AddCellularNumber(cardRow,pStr);
card->GetHomeAddress(getter_Copies(pStr));
if (pStr)
AddHomeAddress(cardRow, pStr);
card->GetHomeAddress2(getter_Copies(pStr));
if (pStr)
AddHomeAddress2(cardRow, pStr);
card->GetHomeCity(getter_Copies(pStr));
if (pStr)
AddHomeCity(cardRow,pStr);
card->GetHomeState(getter_Copies(pStr));
if (pStr)
AddHomeState(cardRow, pStr);
card->GetHomeZipCode(getter_Copies(pStr));
if (pStr)
AddHomeZipCode(cardRow, pStr);
card->GetHomeCountry(getter_Copies(pStr));
if (pStr)
AddHomeCountry(cardRow, pStr);
card->GetWorkAddress(getter_Copies(pStr));
if (pStr)
AddWorkAddress(cardRow, pStr);
card->GetWorkAddress2(getter_Copies(pStr));
if (pStr)
AddWorkAddress2(cardRow, pStr);
card->GetWorkCity(getter_Copies(pStr));
if (pStr)
AddWorkCity(cardRow, pStr);
card->GetWorkState(getter_Copies(pStr));
if (pStr)
AddWorkState(cardRow, pStr);
card->GetWorkZipCode(getter_Copies(pStr));
if (pStr)
AddWorkZipCode(cardRow, pStr);
card->GetWorkCountry(getter_Copies(pStr));
if (pStr)
AddWorkCountry(cardRow, pStr);
card->GetJobTitle(getter_Copies(pStr));
if (pStr)
AddJobTitle(cardRow, pStr);
card->GetDepartment(getter_Copies(pStr));
if (pStr)
AddDepartment(cardRow, pStr);
card->GetCompany(getter_Copies(pStr));
if (pStr)
AddCompany(cardRow, pStr);
card->GetWebPage1(getter_Copies(pStr));
if (pStr)
AddWebPage1(cardRow,pStr);
card->GetWebPage2(getter_Copies(pStr));
if (pStr)
AddWebPage2(cardRow, pStr);
card->GetBirthYear(getter_Copies(pStr));
if (pStr)
AddBirthYear(cardRow, pStr);
card->GetBirthMonth(getter_Copies(pStr));
if (pStr)
AddBirthMonth(cardRow, pStr);
card->GetBirthDay(getter_Copies(pStr));
if (pStr)
AddBirthDay(cardRow, pStr);
card->GetCustom1(getter_Copies(pStr));
if (pStr)
AddCustom1(cardRow,pStr);
card->GetCustom2(getter_Copies(pStr));
if (pStr)
AddCustom2(cardRow, pStr);
card->GetCustom3(getter_Copies(pStr));
if (pStr)
AddCustom3(cardRow, pStr);
card->GetCustom4(getter_Copies(pStr));
if (pStr)
AddCustom4(cardRow, pStr);
card->GetNotes(getter_Copies(pStr));
if (pStr)
AddNotes(cardRow, pStr);
nsXPIDLString pUnicodeStr;
PRInt32 unicharLength = 0;
char* pUTF8Str = nsnull;
card->GetFirstName(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddFirstName(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetLastName(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddLastName(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetDisplayName(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddDisplayName(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetNickName(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddNickName(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetPrimaryEmail(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddPrimaryEmail(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetSecondEmail(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
Add2ndEmail(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetWorkPhone(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddWorkPhone(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetHomePhone(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddHomePhone(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetFaxNumber(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddFaxNumber(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetPagerNumber(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddPagerNumber(cardRow,pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetCellularNumber(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddCellularNumber(cardRow,pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetHomeAddress(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddHomeAddress(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetHomeAddress2(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddHomeAddress2(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetHomeCity(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddHomeCity(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetHomeState(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddHomeState(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetHomeZipCode(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddHomeZipCode(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetHomeCountry(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddHomeCountry(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetWorkAddress(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddWorkAddress(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetWorkAddress2(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddWorkAddress2(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetWorkCity(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddWorkCity(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetWorkState(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddWorkState(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetWorkZipCode(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddWorkZipCode(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetWorkCountry(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddWorkCountry(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetJobTitle(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddJobTitle(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetDepartment(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddDepartment(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetCompany(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddCompany(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetWebPage1(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddWebPage1(cardRow,pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetWebPage2(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddWebPage2(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetBirthYear(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddBirthYear(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetBirthMonth(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddBirthMonth(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetBirthDay(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddBirthDay(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetCustom1(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddCustom1(cardRow,pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetCustom2(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddCustom2(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetCustom3(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddCustom3(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetCustom4(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddCustom4(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
card->GetNotes(getter_Copies(pUnicodeStr));
unicharLength = nsCRT::strlen(pUnicodeStr);
INTL_ConvertFromUnicode(pUnicodeStr, unicharLength, (char**)&pUTF8Str);
if (pUTF8Str)
{
AddNotes(cardRow, pUTF8Str);
PR_FREEIF(pUTF8Str);
}
}
return NS_OK;
}
@ -1837,293 +1984,367 @@ nsresult nsAddrDatabase::GetCardFromDB(nsIAbCard *newCard, nsIMdbRow* cardRow)
nsAutoString tempString;
char *tempCString = nsnull;
PRUnichar *unicodeStr = nsnull;
PRInt32 unicharLength = 0;
err = GetStringColumn(cardRow, m_FirstNameColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetFirstName(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetFirstName(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_LastNameColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetLastName(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetLastName(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_DisplayNameColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetDisplayName(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetDisplayName(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_NickNameColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetNickName(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetNickName(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_PriEmailColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetPrimaryEmail(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetPrimaryEmail(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_2ndEmailColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetSecondEmail(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetSecondEmail(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_WorkPhoneColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetWorkPhone(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetWorkPhone(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_HomePhoneColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetHomePhone(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetHomePhone(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_FaxColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetFaxNumber(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetFaxNumber(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_PagerColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetPagerNumber(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetPagerNumber(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_CellularColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetCellularNumber(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetCellularNumber(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_HomeAddressColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetHomeAddress(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetHomeAddress(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_HomeAddress2ColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetHomeAddress2(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetHomeAddress2(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_HomeCityColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetHomeCity(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetHomeCity(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_HomeStateColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetHomeState(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetHomeState(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_HomeZipCodeColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetHomeZipCode(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetHomeZipCode(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_HomeCountryColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetHomeCountry(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetHomeCountry(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_WorkAddressColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetWorkAddress(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetWorkAddress(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_WorkAddress2ColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetWorkAddress2(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetWorkAddress2(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_WorkCityColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetWorkCity(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetWorkCity(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_WorkStateColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetWorkState(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetWorkState(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_WorkZipCodeColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetWorkZipCode(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetWorkZipCode(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_WorkCountryColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetWorkCountry(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetWorkCountry(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_JobTitleColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetJobTitle(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetJobTitle(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_DepartmentColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetDepartment(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetDepartment(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_CompanyColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetCompany(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetCompany(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_WebPage1ColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetWebPage1(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetWebPage1(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_WebPage2ColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetWebPage2(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetWebPage2(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_BirthYearColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetBirthYear(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetBirthYear(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_BirthMonthColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetBirthMonth(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetBirthMonth(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_BirthDayColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetBirthDay(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetBirthDay(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_Custom1ColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetCustom1(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetCustom1(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_Custom2ColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetCustom2(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetCustom2(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_Custom3ColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetCustom3(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetCustom3(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_Custom4ColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetCustom4(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetCustom4(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
err = GetStringColumn(cardRow, m_NotesColumnToken, tempString);
if (NS_SUCCEEDED(err) && tempString.Length())
{
tempCString = tempString.ToNewCString();
newCard->SetNotes(tempCString);
INTL_ConvertToUnicode((const char *)tempCString, nsCRT::strlen(tempCString), (void**)&unicodeStr, &unicharLength);
newCard->SetNotes(unicodeStr);
delete [] tempCString;
PR_Free(unicodeStr);
}
return err;
}

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

@ -155,7 +155,7 @@ NS_IMETHODIMP nsAddressBook::DeleteCards
}
NS_IMETHODIMP nsAddressBook::NewAddressBook
(nsIRDFCompositeDataSource* db, nsIDOMXULElement *srcDirectory, const char *name)
(nsIRDFCompositeDataSource* db, nsIDOMXULElement *srcDirectory, const PRUnichar *name)
{
if(!db || !srcDirectory || !name)
return NS_ERROR_NULL_POINTER;
@ -184,7 +184,7 @@ NS_IMETHODIMP nsAddressBook::NewAddressBook
rv = NS_NewISupportsArray(getter_AddRefs(nameArray));
if(NS_FAILED(rv))
return NS_ERROR_OUT_OF_MEMORY;
nsString nameStr = name;
nsString nameStr(name);
nsCOMPtr<nsIRDFLiteral> nameLiteral;
rdfService->GetLiteral(nameStr.GetUnicode(), getter_AddRefs(nameLiteral));
@ -373,11 +373,13 @@ nsresult AddressBookParser::ParseFile(PRFileDesc* file)
if (! file)
return NS_ERROR_NULL_POINTER;
/* Get database file name */
char *leafName = nsnull;
nsString fileString;
if (mFileSpec)
{
mFileSpec->GetLeafName(&leafName);
nsString fileString(leafName);
fileString = leafName;
if (-1 != fileString.Find(kTabExtension))
mFileType = TABFile;
else if (-1 != fileString.Find(kLdifExtension))
@ -408,6 +410,7 @@ nsresult AddressBookParser::ParseFile(PRFileDesc* file)
if(NS_SUCCEEDED(rv))
abSession->GetUserProfileDirectory(&dbPath);
/* create address book database */
if (dbPath)
{
(*dbPath) += fileName;
@ -423,9 +426,12 @@ nsresult AddressBookParser::ParseFile(PRFileDesc* file)
mLine.Truncate();
if (mFileType == TABFile)
ParseTabFile(file);
rv = ParseTabFile(file);
if (mFileType == LDIFFile)
ParseLdifFile(file);
rv = ParseLdifFile(file);
if(NS_FAILED(rv))
return rv;
NS_WITH_SERVICE(nsIRDFService, rdfService, kRDFServiceCID, &rv);
if(NS_FAILED(rv))
@ -439,7 +445,7 @@ nsresult AddressBookParser::ParseFile(PRFileDesc* file)
if (parentUri)
PR_smprintf_free(parentUri);
parentDir->CreateNewDirectory(leafName, fileName);
parentDir->CreateNewDirectory(fileString.GetUnicode(), fileName);
if (leafName)
nsCRT::free(leafName);

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

@ -349,7 +349,7 @@ NS_IMETHODIMP nsAbCardDataSource::OnItemRemoved(nsISupports *parentDirectory, ns
}
NS_IMETHODIMP nsAbCardDataSource::OnItemPropertyChanged(nsISupports *item, const char *property,
const char *oldValue, const char *newValue)
const PRUnichar *oldValue, const PRUnichar *newValue)
{
@ -378,7 +378,7 @@ nsresult nsAbCardDataSource::createCardNode(nsIAbCard* card,
nsIRDFResource* property,
nsIRDFNode** target)
{
char *name = nsnull;
PRUnichar *name = nsnull;
nsresult rv = NS_RDF_NO_VALUE;
if ((kNC_DisplayName == property))

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

@ -26,6 +26,7 @@
#include "nsCOMPtr.h"
#include "nsAbBaseCID.h"
#include "nsIAddrBookSession.h"
#include "nsICharsetConverterManager.h"
#include "plstr.h"
@ -35,6 +36,7 @@
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID);
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
#define LDAP_PORT 389
#define LDAPS_PORT 636
@ -259,6 +261,89 @@ void DIR_SetFileName(char** filename, const char* leafName);
static PRInt32 PR_CALLBACK dir_ServerPrefCallback(const char *pref, void *inst_data);
PRInt32 INTL_ConvertToUnicode(const char* aBuffer, const PRInt32 aLength,
void** uniBuffer, PRInt32* uniLength)
{
nsresult res;
if (nsnull == aBuffer)
{
return -1;
}
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
if(NS_SUCCEEDED(res) && (nsnull != ccm))
{
nsString aCharset("UTF-8");
nsIUnicodeDecoder* decoder = nsnull;
PRUnichar *unichars;
PRInt32 unicharLength;
// convert to unicode
res = ccm->GetUnicodeDecoder(&aCharset, &decoder);
if(NS_SUCCEEDED(res) && (nsnull != decoder))
{
PRInt32 srcLen = aLength;
res = decoder->GetMaxLength(aBuffer, srcLen, &unicharLength);
// allocale an output buffer
unichars = (PRUnichar *) PR_Malloc((unicharLength + 1) * sizeof(PRUnichar));
if (unichars != nsnull)
{
res = decoder->Convert(aBuffer, &srcLen, unichars, &unicharLength);
unichars[unicharLength] = 0;
*uniBuffer = (void *) unichars;
*uniLength = unicharLength;
}
else
{
res = NS_ERROR_OUT_OF_MEMORY;
}
NS_IF_RELEASE(decoder);
}
}
return NS_SUCCEEDED(res) ? 0 : -1;
}
PRInt32 INTL_ConvertFromUnicode(const void* uniBuffer, const PRInt32 uniLength, char** aBuffer)
{
nsresult res;
if (nsnull == uniBuffer)
{
return -1;
}
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
if(NS_SUCCEEDED(res) && (nsnull != ccm))
{
nsString aCharset("UTF-8");
nsIUnicodeEncoder* encoder = nsnull;
// convert from unicode
res = ccm->GetUnicodeEncoder(&aCharset, &encoder);
if(NS_SUCCEEDED(res) && (nsnull != encoder))
{
const PRUnichar *unichars = (const PRUnichar *) uniBuffer;
PRInt32 unicharLength = uniLength;
PRInt32 dstLength;
res = encoder->GetMaxLength(unichars, unicharLength, &dstLength);
// allocale an output buffer
*aBuffer = (char *) PR_Malloc(dstLength + 1);
if (*aBuffer != nsnull)
{
res = encoder->Convert(unichars, &unicharLength, *aBuffer, &dstLength);
(*aBuffer)[dstLength] = '\0';
}
else
{
res = NS_ERROR_OUT_OF_MEMORY;
}
NS_IF_RELEASE(encoder);
}
}
return NS_SUCCEEDED(res) ? 0 : -1;
}
/*****************************************************************************
* Functions for creating the new back end managed DIR_Server list.
*/
@ -403,7 +488,7 @@ nsresult DIR_ContainsServer(DIR_Server* pServer, PRBool *hasDir)
return NS_OK;
}
nsresult DIR_AddNewAddressBook(const char *dirName, const char *fileName, DIR_Server** pServer)
nsresult DIR_AddNewAddressBook(const PRUnichar *dirName, const char *fileName, DIR_Server** pServer)
{
DIR_Server * server = (DIR_Server *) PR_Malloc(sizeof(DIR_Server));
DIR_InitServerWithType (server, PABDirectory);
@ -412,7 +497,10 @@ nsresult DIR_AddNewAddressBook(const char *dirName, const char *fileName, DIR_Se
if (dir_ServerList)
{
PRInt32 count = dir_ServerList->Count();
server->description = PL_strdup(dirName);
nsString descString(dirName);
PRInt32 unicharLength = descString.Length();
INTL_ConvertFromUnicode(dirName, unicharLength, &server->description);
server->position = count + 1;
if (fileName)

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

@ -22,6 +22,11 @@
class nsVoidArray;
class nsIPref;
PRInt32 INTL_ConvertToUnicode(const char* aBuffer, const PRInt32 aLength,
void** uniBuffer, PRInt32* uniLength);
PRInt32 INTL_ConvertFromUnicode(const void* uniBuffer,
const PRInt32 uniLength, char** aBuffer);
#define kPreviousListVersion 2
#define kCurrentListVersion 3
#define PREF_LDAP_GLOBAL_TREE_NAME "ldap_2"
@ -232,7 +237,7 @@ nsVoidArray* DIR_GetDirectories();
nsresult DIR_GetDirServers();
nsresult DIR_ShutDown(void); /* FEs should call this when the app is shutting down. It frees all DIR_Servers regardless of ref count values! */
nsresult DIR_AddNewAddressBook(const char *dirName, const char *fileName, DIR_Server** pServer);
nsresult DIR_AddNewAddressBook(const PRUnichar *dirName, const char *fileName, DIR_Server** pServer);
nsresult DIR_ContainsServer(DIR_Server* pServer, PRBool *hasDir);
nsresult DIR_DecrementServerRefCount (DIR_Server *);

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

@ -497,7 +497,7 @@ NS_IMETHODIMP nsAbDirectoryDataSource::OnItemRemoved(nsISupports *parentDirector
}
NS_IMETHODIMP nsAbDirectoryDataSource::OnItemPropertyChanged(nsISupports *item, const char *property,
const char *oldValue, const char *newValue)
const PRUnichar *oldValue, const PRUnichar *newValue)
{
nsresult rv;
@ -531,7 +531,7 @@ nsresult nsAbDirectoryDataSource::createDirectoryNode(nsIAbDirectory* directory,
nsresult nsAbDirectoryDataSource::createDirectoryNameNode(nsIAbDirectory *directory,
nsIRDFNode **target)
{
char *name;
PRUnichar *name = nsnull;
nsresult rv = directory->GetDirName(&name);
if (NS_FAILED(rv)) return rv;
nsString nameString(name);
@ -564,8 +564,8 @@ nsAbDirectoryDataSource::createDirectoryChildNode(nsIAbDirectory *directory,
nsresult
nsAbDirectoryDataSource::createCardChildNode(nsIAbDirectory *directory,
nsIRDFNode **target)
{
char *name;
{
PRUnichar *name;
nsresult rv = directory->GetDirName(&name);
if (NS_FAILED(rv)) return rv;
nsString nameString(name);
@ -626,10 +626,8 @@ nsresult nsAbDirectoryDataSource::DoNewDirectory(nsIAbDirectory *directory, nsIS
{
PRUnichar *name;
literal->GetValue(&name);
nsString tempStr = name;
nsAutoCString nameStr(tempStr);
rv = directory->CreateNewDirectory(nameStr, nsnull);
rv = directory->CreateNewDirectory(name, nsnull);
}
return rv;
}

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

@ -614,7 +614,6 @@ nsIAddrDatabase *GetAddressBookFromUri( const char *pUri)
nsIAddrDatabase *GetAddressBook( const PRUnichar *name, PRBool makeNew)
{
nsresult rv = NS_OK;
nsString theName = name;
if (!makeNew) {
// FIXME: How do I get the list of address books and look for a
@ -654,10 +653,8 @@ nsIAddrDatabase *GetAddressBook( const PRUnichar *name, PRBool makeNew)
if (parentUri)
PR_smprintf_free(parentUri);
if (parentDir) {
char *pName = theName.ToNewCString();
char *fileName = (*dbPath).GetLeafName();
parentDir->CreateNewDirectory( pName, fileName);
nsCRT::free( pName);
parentDir->CreateNewDirectory( name, fileName);
nsCRT::free( fileName);
}
}