Back to index

lightning-sunbird  0.9+nobinonly
nsAbIPCCard.cpp
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is mozilla.org code.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 2002
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Created by: Rajiv Dayal <rdayal@netscape.com>
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include <windows.h>
00039 #include <tchar.h>
00040 
00041 #include "nsAbIPCCard.h"
00042 #include "nsUnicharUtils.h"
00043 #include "nsIAbMDBCard.h"
00044 #include "prdtoa.h"
00045 #include "PalmSyncImp.h"
00046 
00047 extern PRLogModuleInfo *PALMSYNC;
00048 
00049 #define CONVERT_ASSIGNTO_UNICODE(d, s, convertCRLF)  d.Truncate();\
00050                                         if((char*) s) d.AppendASCII((char*)s);\
00051                                         if (convertCRLF) \
00052                                           d.ReplaceSubstring(NS_LITERAL_STRING("\x0D\x0A").get(),NS_LITERAL_STRING(" ").get());
00053 
00054 #define CONVERT_CRLF_TO_SPACE(d, s) d.Assign(s); \
00055                                     d.ReplaceSubstring(NS_LITERAL_STRING("\x0D\x0A").get(),NS_LITERAL_STRING(" ").get());
00056 
00057 NS_IMPL_ISUPPORTS_INHERITED1(nsAbIPCCard, nsAbCardProperty, nsIAbMDBCard)
00058 
00059 nsAbIPCCard::nsAbIPCCard()
00060 {
00061     mRecordId = 0;
00062     mCategoryId = -1;
00063     mStatus = -1;
00064     PR_LOG(PALMSYNC, PR_LOG_DEBUG, ("nsAbIPCCard::nsAbIPCCard \n"));
00065 }
00066 
00067 nsAbIPCCard::~nsAbIPCCard()
00068 {
00069    
00070 }
00071 
00072 nsAbIPCCard::nsAbIPCCard(nsIAbCard *card)
00073 {
00074     Copy(card);
00075 }
00076 
00077 nsAbIPCCard::nsAbIPCCard(nsABCOMCardStruct *card, PRBool isUnicode)
00078 {
00079     if(isUnicode)
00080         Copy(card);
00081     else
00082         ConvertToUnicodeAndCopy(card);
00083 }
00084 
00085 NS_IMETHODIMP nsAbIPCCard::Copy(nsIAbCard *srcCard)
00086 {
00087     NS_ENSURE_ARG_POINTER(srcCard);
00088 
00089     nsresult rv;
00090     nsCOMPtr<nsIAbMDBCard> dbCard;
00091     dbCard = do_QueryInterface(srcCard, &rv);
00092     if(NS_SUCCEEDED(rv) && dbCard) {
00093         nsXPIDLString palmIDStr;
00094         nsresult rv = dbCard->GetStringAttribute(CARD_ATTRIB_PALMID, getter_Copies(palmIDStr));
00095         if(NS_SUCCEEDED(rv) && palmIDStr.get()) {
00096             PRFloat64 f = PR_strtod(NS_LossyConvertUCS2toASCII(palmIDStr).get(), nsnull);
00097             PRInt64 l;
00098             LL_D2L(l, f);
00099             LL_L2UI(mRecordId, l);
00100         }
00101         else
00102             mRecordId = 0;
00103         // set tableID, RowID and Key for the card
00104         PRUint32 tableID=0;
00105         dbCard->GetDbTableID(&tableID);
00106         SetDbTableID(tableID);
00107         PRUint32 rowID=0;
00108         dbCard->GetDbRowID(&rowID);
00109         SetDbRowID(rowID);
00110         PRUint32 key;
00111         dbCard->GetKey(&key);
00112         SetKey(key);
00113     }
00114     PRUint32 lastModifiedDate = 0;
00115     srcCard->GetLastModifiedDate(&lastModifiedDate);
00116     mStatus = (lastModifiedDate) ? ATTR_MODIFIED : ATTR_NEW;
00117 
00118     rv = nsAbCardProperty::Copy(srcCard);
00119     // do we need to join the work and home addresses?
00120     // or split them?
00121 
00122     return rv;
00123 }
00124 
00125 nsresult nsAbIPCCard::Copy(nsABCOMCardStruct * srcCard)
00126 {
00127     NS_ENSURE_ARG_POINTER(srcCard);
00128 
00129     mRecordId = srcCard->dwRecordId;
00130     mCategoryId = srcCard->dwCategoryId;
00131     mStatus = srcCard->dwStatus;
00132     srcCard->addressToUse = CPalmSyncImp::nsUseABHomeAddressForPalmAddress(); // 0 == work, 1 == home
00133     PR_LOG(PALMSYNC, PR_LOG_DEBUG, ("nsAbIPCCard::Copy using %d\n", srcCard->addressToUse));
00134 
00135     // Each palm address field is allowed to have multiple lines
00136     // so replace CRLFs with spaces (since other than Notes field
00137     // moz only displays fields in a single line).
00138     nsAutoString str;
00139     CONVERT_CRLF_TO_SPACE(str, srcCard->firstName);
00140     SetFirstName(str.get());
00141 
00142     CONVERT_CRLF_TO_SPACE(str, srcCard->lastName);
00143     SetLastName(str.get());
00144 
00145     CONVERT_CRLF_TO_SPACE(str, srcCard->displayName);
00146     SetDisplayName(str.get());
00147 
00148     CONVERT_CRLF_TO_SPACE(str, srcCard->nickName);
00149     SetNickName(str.get());
00150 
00151     CONVERT_CRLF_TO_SPACE(str, srcCard->primaryEmail);
00152     SetPrimaryEmail(str.get());
00153 
00154     CONVERT_CRLF_TO_SPACE(str, srcCard->secondEmail);
00155     SetSecondEmail(str.get());
00156 
00157     SetPreferMailFormat(srcCard->preferMailFormat);
00158 
00159     CONVERT_CRLF_TO_SPACE(str, srcCard->workPhone);
00160     SetWorkPhone(str.get());
00161 
00162     CONVERT_CRLF_TO_SPACE(str, srcCard->homePhone);
00163     SetHomePhone(str.get());
00164 
00165     CONVERT_CRLF_TO_SPACE(str, srcCard->faxNumber);
00166     SetFaxNumber(str.get());
00167 
00168     CONVERT_CRLF_TO_SPACE(str, srcCard->pagerNumber);
00169     SetPagerNumber(str.get());
00170 
00171     CONVERT_CRLF_TO_SPACE(str, srcCard->cellularNumber);
00172     SetCellularNumber(str.get());
00173 
00174     // See if home address contains multiple lines.
00175     SplitHomeAndWorkAddresses(srcCard, PR_TRUE);
00176 
00177     CONVERT_CRLF_TO_SPACE(str, srcCard->homeCity);
00178     SetHomeCity(str.get());
00179 
00180     CONVERT_CRLF_TO_SPACE(str, srcCard->homeState);
00181     SetHomeState(str.get());
00182 
00183     CONVERT_CRLF_TO_SPACE(str, srcCard->homeZipCode);
00184     SetHomeZipCode(str.get());
00185 
00186     CONVERT_CRLF_TO_SPACE(str, srcCard->homeCountry);
00187     SetHomeCountry(str.get());
00188 
00189     CONVERT_CRLF_TO_SPACE(str, srcCard->workCity);
00190     SetWorkCity(str.get());
00191 
00192     CONVERT_CRLF_TO_SPACE(str, srcCard->workState);
00193     SetWorkState(str.get());
00194 
00195     CONVERT_CRLF_TO_SPACE(str, srcCard->workZipCode);
00196     SetWorkZipCode(str.get());
00197 
00198     CONVERT_CRLF_TO_SPACE(str, srcCard->workCountry);
00199     SetWorkCountry(str.get());
00200 
00201     CONVERT_CRLF_TO_SPACE(str, srcCard->jobTitle);
00202     SetJobTitle(str.get());
00203 
00204     CONVERT_CRLF_TO_SPACE(str, srcCard->department);
00205     SetDepartment(str.get());
00206 
00207     CONVERT_CRLF_TO_SPACE(str, srcCard->company);
00208     SetCompany(str.get());
00209 
00210     CONVERT_CRLF_TO_SPACE(str, srcCard->webPage1);
00211     SetWebPage1(str.get());
00212 
00213     CONVERT_CRLF_TO_SPACE(str, srcCard->webPage2);
00214     SetWebPage2(str.get());
00215 
00216     CONVERT_CRLF_TO_SPACE(str, srcCard->birthYear);
00217     SetBirthYear(str.get());
00218 
00219     CONVERT_CRLF_TO_SPACE(str, srcCard->birthMonth);
00220     SetBirthMonth(str.get());
00221 
00222     CONVERT_CRLF_TO_SPACE(str, srcCard->birthDay);
00223     SetBirthDay(str.get());
00224 
00225     CONVERT_CRLF_TO_SPACE(str, srcCard->custom1);
00226     SetCustom1(str.get());
00227 
00228     CONVERT_CRLF_TO_SPACE(str, srcCard->custom2);
00229     SetCustom2(str.get());
00230 
00231     CONVERT_CRLF_TO_SPACE(str, srcCard->custom3);
00232     SetCustom3(str.get());
00233 
00234     CONVERT_CRLF_TO_SPACE(str, srcCard->custom4);
00235     SetCustom4(str.get());
00236 
00237     SetNotes(srcCard->notes);
00238     SetLastModifiedDate(srcCard->lastModifiedDate);
00239     SetIsMailList(srcCard->isMailList);
00240     SetMailListURI(srcCard->mailListURI);
00241 
00242     return NS_OK;
00243 }
00244 
00245 nsresult nsAbIPCCard::ConvertToUnicodeAndCopy(nsABCOMCardStruct * srcCard)
00246 {
00247     NS_ENSURE_ARG_POINTER(srcCard);
00248 
00249     mRecordId = srcCard->dwRecordId;
00250     mCategoryId = srcCard->dwCategoryId;
00251     mStatus = srcCard->dwStatus;
00252 
00253     nsAutoString str;
00254 
00255     // Each palm address field is allowed to have multiple lines
00256     // so replace CRLFs with spaces (since other than Notes field
00257     // moz only displays fields in a single line).
00258     CONVERT_ASSIGNTO_UNICODE(str, srcCard->firstName, PR_TRUE);
00259     SetFirstName(str.get());
00260 
00261     CONVERT_ASSIGNTO_UNICODE(str, srcCard->lastName, PR_TRUE);
00262     SetLastName(str.get());
00263 
00264     CONVERT_ASSIGNTO_UNICODE(str, srcCard->displayName, PR_TRUE);
00265     SetDisplayName(str.get());
00266 
00267     CONVERT_ASSIGNTO_UNICODE(str, srcCard->nickName, PR_TRUE);
00268     SetNickName(str.get());
00269 
00270     CONVERT_ASSIGNTO_UNICODE(str, srcCard->primaryEmail, PR_TRUE);
00271     SetPrimaryEmail(str.get());
00272 
00273     CONVERT_ASSIGNTO_UNICODE(str, srcCard->secondEmail, PR_TRUE);
00274     SetSecondEmail(str.get());
00275 
00276     SetPreferMailFormat(srcCard->preferMailFormat);
00277 
00278     CONVERT_ASSIGNTO_UNICODE(str, srcCard->workPhone, PR_TRUE);
00279     SetWorkPhone(str.get());
00280 
00281     CONVERT_ASSIGNTO_UNICODE(str, srcCard->homePhone, PR_TRUE);
00282     SetHomePhone(str.get());
00283 
00284     CONVERT_ASSIGNTO_UNICODE(str, srcCard->faxNumber, PR_TRUE);
00285     SetFaxNumber(str.get());
00286 
00287     CONVERT_ASSIGNTO_UNICODE(str, srcCard->pagerNumber, PR_TRUE);
00288     SetPagerNumber(str.get());
00289 
00290     CONVERT_ASSIGNTO_UNICODE(str, srcCard->cellularNumber, PR_TRUE);
00291     SetCellularNumber(str.get());
00292 
00293     // See if home address contains multiple lines.
00294     SplitHomeAndWorkAddresses(srcCard, PR_FALSE);
00295 
00296     CONVERT_ASSIGNTO_UNICODE(str, srcCard->homeCity, PR_TRUE);
00297     SetHomeCity(str.get());
00298 
00299     CONVERT_ASSIGNTO_UNICODE(str, srcCard->homeState, PR_TRUE);
00300     SetHomeState(str.get());
00301 
00302     CONVERT_ASSIGNTO_UNICODE(str, srcCard->homeZipCode, PR_TRUE);
00303     SetHomeZipCode(str.get());
00304 
00305     CONVERT_ASSIGNTO_UNICODE(str, srcCard->homeCountry, PR_TRUE);
00306     SetHomeCountry(str.get());
00307 
00308     CONVERT_ASSIGNTO_UNICODE(str, srcCard->workCity, PR_TRUE);
00309     SetWorkCity(str.get());
00310 
00311     CONVERT_ASSIGNTO_UNICODE(str, srcCard->workState, PR_TRUE);
00312     SetWorkState(str.get());
00313 
00314     CONVERT_ASSIGNTO_UNICODE(str, srcCard->workZipCode, PR_TRUE);
00315     SetWorkZipCode(str.get());
00316 
00317     CONVERT_ASSIGNTO_UNICODE(str, srcCard->workCountry, PR_TRUE);
00318     SetWorkCountry(str.get());
00319 
00320     CONVERT_ASSIGNTO_UNICODE(str, srcCard->jobTitle, PR_TRUE);
00321     SetJobTitle(str.get());
00322 
00323     CONVERT_ASSIGNTO_UNICODE(str, srcCard->department, PR_TRUE);
00324     SetDepartment(str.get());
00325 
00326     CONVERT_ASSIGNTO_UNICODE(str, srcCard->company, PR_TRUE);
00327     SetCompany(str.get());
00328 
00329     CONVERT_ASSIGNTO_UNICODE(str, srcCard->webPage1, PR_TRUE);
00330     SetWebPage1(str.get());
00331 
00332     CONVERT_ASSIGNTO_UNICODE(str, srcCard->webPage2, PR_TRUE);
00333     SetWebPage2(str.get());
00334 
00335     CONVERT_ASSIGNTO_UNICODE(str, srcCard->birthYear, PR_TRUE);
00336     SetBirthYear(str.get());
00337 
00338     CONVERT_ASSIGNTO_UNICODE(str, srcCard->birthMonth, PR_TRUE);
00339     SetBirthMonth(str.get());
00340 
00341     CONVERT_ASSIGNTO_UNICODE(str, srcCard->birthDay, PR_TRUE);
00342     SetBirthDay(str.get());
00343 
00344     CONVERT_ASSIGNTO_UNICODE(str, srcCard->custom1, PR_TRUE);
00345     SetCustom1(str.get());
00346 
00347     CONVERT_ASSIGNTO_UNICODE(str, srcCard->custom2, PR_TRUE);
00348     SetCustom2(str.get());
00349 
00350     CONVERT_ASSIGNTO_UNICODE(str, srcCard->custom3, PR_TRUE);
00351     SetCustom3(str.get());
00352 
00353     CONVERT_ASSIGNTO_UNICODE(str, srcCard->custom4, PR_TRUE);
00354     SetCustom4(str.get());
00355 
00356     CONVERT_ASSIGNTO_UNICODE(str, srcCard->notes, PR_FALSE);
00357     SetNotes(str.get());
00358 
00359     SetLastModifiedDate(srcCard->lastModifiedDate);
00360     SetIsMailList(srcCard->isMailList);
00361     SetMailListURI(srcCard->mailListURI);
00362 
00363     return NS_OK;
00364 }
00365 
00366 void nsAbIPCCard::SplitAddresses(PRBool isUnicode, LPTSTR homeAddress, LPTSTR workAddress)
00367 {
00368   PRInt32 idx;
00369   nsAutoString homeAddressStr;
00370   nsAutoString workAddressStr;
00371   if (isUnicode)
00372   {
00373     homeAddressStr.Assign(homeAddress);
00374     workAddressStr.Assign(workAddress);
00375   }
00376   else
00377   {
00378     CONVERT_ASSIGNTO_UNICODE(homeAddressStr, homeAddress, PR_FALSE);
00379     CONVERT_ASSIGNTO_UNICODE(workAddressStr, workAddress, PR_FALSE);
00380   }
00381   nsAutoString addr1, addr2;
00382   if ((idx = homeAddressStr.Find( "\x0D\x0A")) != kNotFound)
00383   {
00384     homeAddressStr.Left(addr1, idx);
00385     homeAddressStr.Right( addr2, homeAddressStr.Length() - idx - 2);  // need to minus string lenght of CRLF.
00386     addr2.ReplaceSubstring(NS_LITERAL_STRING("\x0D\x0A").get(),NS_LITERAL_STRING(", ").get());
00387 
00388     SetHomeAddress(addr1.get());
00389     SetHomeAddress2(addr2.get());
00390   }
00391   else
00392     SetHomeAddress(homeAddressStr.get());
00393   if ((idx = workAddressStr.Find( "\x0D\x0A")) != kNotFound)
00394   {
00395     workAddressStr.Left(addr1, idx);
00396     workAddressStr.Right( addr2, workAddressStr.Length() - idx - 2);  // need to minus string lenght of CRLF.
00397     addr2.ReplaceSubstring(NS_LITERAL_STRING("\x0D\x0A").get(),NS_LITERAL_STRING(", ").get());
00398 
00399     SetWorkAddress(addr1.get());
00400     SetWorkAddress2(addr2.get());
00401   }
00402   else
00403     SetWorkAddress(workAddressStr.get());
00404 }
00405 
00406 void nsAbIPCCard::SplitHomeAndWorkAddresses(nsABCOMCardStruct * card, PRBool isUnicode)
00407 {
00408   // If the address contains more than one line then split it into two 
00409   // (since moz only allows two address lines) and make sure all CRLFs
00410   // are converted to spaces in the 2nd address line. Lines are ended
00411   // with CRLF (done by moz conduit). So card->homeAddress2 
00412   // and card->workAddress2 are never used.
00413   SplitAddresses(isUnicode, card->homeAddress, card->workAddress);
00414 }
00415 
00416 
00417 PRBool nsAbIPCCard::EqualsAfterUnicodeConversion(nsABCOMCardStruct * card, nsStringArray & differingAttrs)
00418 {
00419     if(!card)
00420         return PR_FALSE;
00421 
00422     // convert to Unicode first
00423     nsAbIPCCard card1(card, PR_FALSE);
00424     card1.SplitAddresses(PR_FALSE, card->homeAddress, card->workAddress);
00425     nsABCOMCardStruct * newCard = new nsABCOMCardStruct;
00426     // get the unicode nsABCOMCardStruct and compare
00427     card1.GetABCOMCardStruct(PR_TRUE, newCard);
00428     // want to split newCard home and work address
00429 
00430     // I think this leaks...need to free up the original values
00431     card1.CopyValue(PR_TRUE, m_HomeAddress, &newCard->homeAddress);
00432     card1.CopyValue(PR_TRUE, m_HomeAddress2, &newCard->homeAddress2);
00433     card1.CopyValue(PR_TRUE, m_WorkAddress, &newCard->workAddress);
00434     card1.CopyValue(PR_TRUE, m_WorkAddress2, &newCard->workAddress2);
00435   
00436     PRBool ret = Equals(newCard, differingAttrs);
00437     delete newCard;
00438     return ret;
00439 }
00440 
00441 
00442 PRBool nsAbIPCCard::Equals(nsABCOMCardStruct * card, nsStringArray & differingAttrs)
00443 {
00444     if(!card)
00445         return PR_FALSE;
00446 
00447     differingAttrs.Clear();
00448 
00449     if(card->firstName)
00450         if (Compare(nsDependentString(card->firstName), m_FirstName, nsCaseInsensitiveStringComparator()))
00451             differingAttrs.AppendString(NS_LITERAL_STRING(kFirstNameColumn));
00452     if(card->lastName)
00453         if (Compare(nsDependentString(card->lastName), m_LastName, nsCaseInsensitiveStringComparator()))
00454             differingAttrs.AppendString(NS_LITERAL_STRING(kLastNameColumn));
00455     if(card->displayName)
00456         if (Compare(nsDependentString(card->displayName), m_DisplayName, nsCaseInsensitiveStringComparator()))
00457             differingAttrs.AppendString(NS_LITERAL_STRING(kDisplayNameColumn));
00458     if(card->nickName)
00459         if (Compare(nsDependentString(card->nickName), m_NickName, nsCaseInsensitiveStringComparator()))
00460             differingAttrs.AppendString(NS_LITERAL_STRING(kNicknameColumn));
00461     if(card->primaryEmail)
00462         if (Compare(nsDependentString(card->primaryEmail), m_PrimaryEmail, nsCaseInsensitiveStringComparator()))
00463             differingAttrs.AppendString(NS_LITERAL_STRING(kPriEmailColumn));
00464     if(card->secondEmail)
00465         if (Compare(nsDependentString(card->secondEmail), m_SecondEmail, nsCaseInsensitiveStringComparator()))
00466             differingAttrs.AppendString(NS_LITERAL_STRING(k2ndEmailColumn));
00467     if(card->workPhone)
00468         if (Compare(nsDependentString(card->workPhone), m_WorkPhone, nsCaseInsensitiveStringComparator()))
00469             differingAttrs.AppendString(NS_LITERAL_STRING(kWorkPhoneColumn));
00470     if(card->homePhone)
00471         if (Compare(nsDependentString(card->homePhone), m_HomePhone, nsCaseInsensitiveStringComparator()))
00472             differingAttrs.AppendString(NS_LITERAL_STRING(kHomePhoneColumn));
00473     if(card->faxNumber)
00474         if (Compare(nsDependentString(card->faxNumber), m_FaxNumber, nsCaseInsensitiveStringComparator()))
00475             differingAttrs.AppendString(NS_LITERAL_STRING(kFaxColumn));
00476     if(card->pagerNumber)
00477         if (Compare(nsDependentString(card->pagerNumber), m_PagerNumber, nsCaseInsensitiveStringComparator()))
00478             differingAttrs.AppendString(NS_LITERAL_STRING(kPagerColumn));
00479     if(card->cellularNumber)
00480         if (Compare(nsDependentString(card->cellularNumber), m_CellularNumber, nsCaseInsensitiveStringComparator()))
00481             differingAttrs.AppendString(NS_LITERAL_STRING(kCellularColumn));
00482     // card  has home and work addresses joined, but "this" has them split
00483     if(card->homeAddress)
00484         if (Compare(nsDependentString(card->homeAddress), m_HomeAddress, nsCaseInsensitiveStringComparator()))
00485             differingAttrs.AppendString(NS_LITERAL_STRING(kHomeAddressColumn));
00486     if(card->homeAddress2)
00487         if (Compare(nsDependentString(card->homeAddress2), m_HomeAddress2, nsCaseInsensitiveStringComparator()))
00488             differingAttrs.AppendString(NS_LITERAL_STRING(kHomeAddress2Column));
00489     if(card->homeCity)
00490         if (Compare(nsDependentString(card->homeCity), m_HomeCity, nsCaseInsensitiveStringComparator()))
00491             differingAttrs.AppendString(NS_LITERAL_STRING(kHomeCityColumn));
00492     if(card->homeState)
00493         if (Compare(nsDependentString(card->homeState), m_HomeState, nsCaseInsensitiveStringComparator()))
00494             differingAttrs.AppendString(NS_LITERAL_STRING(kHomeStateColumn));
00495     if(card->homeZipCode)
00496         if (Compare(nsDependentString(card->homeZipCode), m_HomeZipCode, nsCaseInsensitiveStringComparator()))
00497             differingAttrs.AppendString(NS_LITERAL_STRING(kHomeZipCodeColumn));
00498     if(card->homeCountry)
00499         if (Compare(nsDependentString(card->homeCountry), m_HomeCountry, nsCaseInsensitiveStringComparator()))
00500             differingAttrs.AppendString(NS_LITERAL_STRING(kHomeCountryColumn));
00501     // card->workAddress is Joined, m_workAddress and m_workAddress2 are split
00502     if(card->workAddress)
00503         if (Compare(nsDependentString(card->workAddress), m_WorkAddress, nsCaseInsensitiveStringComparator()))
00504             differingAttrs.AppendString(NS_LITERAL_STRING(kWorkAddressColumn));
00505     if(card->workAddress2)
00506         if (Compare(nsDependentString(card->workAddress2), m_WorkAddress2, nsCaseInsensitiveStringComparator()))
00507             differingAttrs.AppendString(NS_LITERAL_STRING(kWorkAddress2Column));
00508     if(card->workCity)
00509         if (Compare(nsDependentString(card->workCity), m_WorkCity, nsCaseInsensitiveStringComparator()))
00510             differingAttrs.AppendString(NS_LITERAL_STRING(kWorkCityColumn));
00511     if(card->workState)
00512         if (Compare(nsDependentString(card->workState), m_WorkState, nsCaseInsensitiveStringComparator()))
00513             differingAttrs.AppendString(NS_LITERAL_STRING(kWorkStateColumn));
00514     if(card->workZipCode)
00515         if (Compare(nsDependentString(card->workZipCode), m_WorkZipCode, nsCaseInsensitiveStringComparator()))
00516             differingAttrs.AppendString(NS_LITERAL_STRING(kWorkZipCodeColumn));
00517     if(card->workCountry)
00518         if (Compare(nsDependentString(card->workCountry), m_WorkCountry, nsCaseInsensitiveStringComparator()))
00519             differingAttrs.AppendString(NS_LITERAL_STRING(kWorkCountryColumn));
00520     if(card->jobTitle)
00521         if (Compare(nsDependentString(card->jobTitle), m_JobTitle, nsCaseInsensitiveStringComparator()))
00522             differingAttrs.AppendString(NS_LITERAL_STRING(kJobTitleColumn));
00523     if(card->department)
00524         if (Compare(nsDependentString(card->department), m_Department, nsCaseInsensitiveStringComparator()))
00525             differingAttrs.AppendString(NS_LITERAL_STRING(kDepartmentColumn));
00526     if(card->company)
00527         if (Compare(nsDependentString(card->company), m_Company, nsCaseInsensitiveStringComparator()))
00528             differingAttrs.AppendString(NS_LITERAL_STRING(kCompanyColumn));
00529     if(card->webPage1)
00530         if (Compare(nsDependentString(card->webPage1), m_WebPage1, nsCaseInsensitiveStringComparator()))
00531             differingAttrs.AppendString(NS_LITERAL_STRING(kWebPage1Column));
00532     if(card->webPage2)
00533         if (Compare(nsDependentString(card->webPage2), m_WebPage2, nsCaseInsensitiveStringComparator()))
00534             differingAttrs.AppendString(NS_LITERAL_STRING(kWebPage2Column));
00535     if(card->birthYear)
00536         if (Compare(nsDependentString(card->birthYear), m_BirthYear, nsCaseInsensitiveStringComparator()))
00537             differingAttrs.AppendString(NS_LITERAL_STRING(kBirthYearColumn));
00538     if(card->birthMonth)
00539         if (Compare(nsDependentString(card->birthMonth), m_BirthMonth, nsCaseInsensitiveStringComparator()))
00540             differingAttrs.AppendString(NS_LITERAL_STRING(kBirthMonthColumn));
00541     if(card->birthDay)
00542         if (Compare(nsDependentString(card->birthDay), m_BirthDay, nsCaseInsensitiveStringComparator()))
00543             differingAttrs.AppendString(NS_LITERAL_STRING(kBirthDayColumn));
00544     if(card->custom1)
00545         if (Compare(nsDependentString(card->custom1), m_Custom1, nsCaseInsensitiveStringComparator()))
00546             differingAttrs.AppendString(NS_LITERAL_STRING(kCustom1Column));
00547     if(card->custom2)
00548         if (Compare(nsDependentString(card->custom2), m_Custom2, nsCaseInsensitiveStringComparator()))
00549             differingAttrs.AppendString(NS_LITERAL_STRING(kCustom2Column));
00550     if(card->custom3)
00551         if (Compare(nsDependentString(card->custom3), m_Custom3, nsCaseInsensitiveStringComparator()))
00552             differingAttrs.AppendString(NS_LITERAL_STRING(kCustom3Column));
00553     if(card->custom4)
00554         if (Compare(nsDependentString(card->custom4), m_Custom4, nsCaseInsensitiveStringComparator()))
00555             differingAttrs.AppendString(NS_LITERAL_STRING(kCustom4Column));
00556     if (card->isMailList != m_IsMailList)
00557         differingAttrs.AppendString(NS_LITERAL_STRING(kMailListName));
00558     if(card->mailListURI) {
00559         nsCAutoString str(card->mailListURI);
00560         if (str.Equals(m_MailListURI, nsCaseInsensitiveCStringComparator()))
00561             differingAttrs.AppendString(NS_LITERAL_STRING(kMailListDescription));
00562     }
00563 
00564     return (differingAttrs.Count() == 0);
00565 }
00566 
00567 
00568 NS_IMETHODIMP nsAbIPCCard::Equals(nsIAbCard *card, PRBool *_retval)
00569 {
00570     NS_ENSURE_ARG_POINTER(card);
00571     NS_ENSURE_ARG_POINTER(_retval);
00572 
00573     nsXPIDLString str;
00574     *_retval = PR_FALSE;
00575 
00576     card->GetFirstName(getter_Copies(str));
00577     if (Compare(str, m_FirstName, nsCaseInsensitiveStringComparator()))
00578         return NS_OK;
00579 
00580     card->GetLastName(getter_Copies(str));
00581     if (Compare(str, m_LastName, nsCaseInsensitiveStringComparator()))
00582         return NS_OK;
00583 
00584     card->GetDisplayName(getter_Copies(str));
00585     if (Compare(str, m_DisplayName, nsCaseInsensitiveStringComparator()))
00586         return NS_OK;
00587 
00588     card->GetNickName(getter_Copies(str));
00589     if (Compare(str, m_NickName, nsCaseInsensitiveStringComparator()))
00590         return NS_OK;
00591 
00592     card->GetPrimaryEmail(getter_Copies(str));
00593     if (Compare(str, m_PrimaryEmail, nsCaseInsensitiveStringComparator()))
00594         return NS_OK;
00595 
00596     card->GetSecondEmail(getter_Copies(str));
00597     if (Compare(str, m_SecondEmail, nsCaseInsensitiveStringComparator()))
00598         return NS_OK;
00599 
00600     card->GetWorkPhone(getter_Copies(str));
00601     if (Compare(str, m_WorkPhone, nsCaseInsensitiveStringComparator()))
00602         return NS_OK;
00603 
00604     card->GetHomePhone(getter_Copies(str));
00605     if (Compare(str, m_HomePhone, nsCaseInsensitiveStringComparator()))
00606         return NS_OK;
00607 
00608     card->GetFaxNumber(getter_Copies(str));
00609     if (Compare(str, m_FaxNumber, nsCaseInsensitiveStringComparator()))
00610         return NS_OK;
00611 
00612     card->GetPagerNumber(getter_Copies(str));
00613     if (Compare(str, m_PagerNumber, nsCaseInsensitiveStringComparator()))
00614         return NS_OK;
00615 
00616     card->GetCellularNumber(getter_Copies(str));
00617     if (Compare(str, m_CellularNumber, nsCaseInsensitiveStringComparator()))
00618         return NS_OK;
00619 
00620     card->GetHomeAddress(getter_Copies(str));
00621     if (Compare(str, m_HomeAddress, nsCaseInsensitiveStringComparator()))
00622         return NS_OK;
00623 
00624     card->GetHomeAddress2(getter_Copies(str));
00625     if (Compare(str, m_HomeAddress2, nsCaseInsensitiveStringComparator()))
00626         return NS_OK;
00627 
00628     card->GetHomeCity(getter_Copies(str));
00629     if (Compare(str, m_HomeCity, nsCaseInsensitiveStringComparator()))
00630         return NS_OK;
00631 
00632     card->GetHomeState(getter_Copies(str));
00633     if (Compare(str, m_HomeState, nsCaseInsensitiveStringComparator()))
00634         return NS_OK;
00635 
00636     card->GetHomeZipCode(getter_Copies(str));
00637     if (Compare(str, m_HomeZipCode, nsCaseInsensitiveStringComparator()))
00638         return NS_OK;
00639 
00640     card->GetHomeCountry(getter_Copies(str));
00641     if (Compare(str, m_HomeCountry, nsCaseInsensitiveStringComparator()))
00642         return NS_OK;
00643 
00644     // both card and this have their addresses split, which is correct
00645     card->GetWorkAddress(getter_Copies(str));
00646     if (Compare(str, m_WorkAddress, nsCaseInsensitiveStringComparator()))
00647         return NS_OK;
00648 
00649     card->GetWorkAddress2(getter_Copies(str));
00650     if (Compare(str, m_WorkAddress2, nsCaseInsensitiveStringComparator()))
00651         return NS_OK;
00652 
00653     card->GetWorkCity(getter_Copies(str));
00654     if (Compare(str, m_WorkCity, nsCaseInsensitiveStringComparator()))
00655         return NS_OK;
00656 
00657     card->GetWorkState(getter_Copies(str));
00658     if (Compare(str, m_WorkState, nsCaseInsensitiveStringComparator()))
00659         return NS_OK;
00660 
00661     card->GetWorkZipCode(getter_Copies(str));
00662     if (Compare(str, m_WorkZipCode, nsCaseInsensitiveStringComparator()))
00663         return NS_OK;
00664 
00665     card->GetWorkCountry(getter_Copies(str));
00666     if (Compare(str, m_WorkCountry, nsCaseInsensitiveStringComparator()))
00667         return NS_OK;
00668 
00669     card->GetJobTitle(getter_Copies(str));
00670     if (Compare(str, m_JobTitle, nsCaseInsensitiveStringComparator()))
00671         return NS_OK;
00672 
00673     card->GetDepartment(getter_Copies(str));
00674     if (Compare(str, m_Department, nsCaseInsensitiveStringComparator()))
00675         return NS_OK;
00676 
00677     card->GetCompany(getter_Copies(str));
00678     if (Compare(str, m_Company, nsCaseInsensitiveStringComparator()))
00679         return NS_OK;
00680 
00681     card->GetWebPage1(getter_Copies(str));
00682     if (Compare(str, m_WebPage1, nsCaseInsensitiveStringComparator()))
00683         return NS_OK;
00684 
00685     card->GetWebPage2(getter_Copies(str));
00686     if (Compare(str, m_WebPage2, nsCaseInsensitiveStringComparator()))
00687         return NS_OK;
00688 
00689     card->GetBirthYear(getter_Copies(str));
00690     if (Compare(str, m_BirthYear, nsCaseInsensitiveStringComparator()))
00691         return NS_OK;
00692 
00693     card->GetBirthMonth(getter_Copies(str));
00694     if (Compare(str, m_BirthMonth, nsCaseInsensitiveStringComparator()))
00695         return NS_OK;
00696 
00697     card->GetBirthDay(getter_Copies(str));
00698     if (Compare(str, m_BirthDay, nsCaseInsensitiveStringComparator()))
00699         return NS_OK;
00700 
00701     card->GetCustom1(getter_Copies(str));
00702     if (Compare(str, m_Custom1, nsCaseInsensitiveStringComparator()))
00703         return NS_OK;
00704 
00705     card->GetCustom2(getter_Copies(str));
00706     if (Compare(str, m_Custom2, nsCaseInsensitiveStringComparator()))
00707         return NS_OK;
00708 
00709     card->GetCustom3(getter_Copies(str));
00710     if (Compare(str, m_Custom3, nsCaseInsensitiveStringComparator()))
00711         return NS_OK;
00712 
00713     card->GetCustom4(getter_Copies(str));
00714     if (Compare(str, m_Custom4, nsCaseInsensitiveStringComparator()))
00715         return NS_OK;
00716 
00717     PRBool isMailList=PR_FALSE;
00718     card->GetIsMailList(&isMailList);
00719     if (isMailList != m_IsMailList)
00720         return NS_OK;
00721 
00722     nsXPIDLCString str2;
00723     card->GetMailListURI(getter_Copies(str2));
00724     if (m_MailListURI.Equals(str2, nsCaseInsensitiveCStringComparator()))
00725         return NS_OK;
00726 
00727     *_retval = PR_TRUE;
00728     return NS_OK;
00729 }
00730 
00731 PRBool nsAbIPCCard::CompareValue(PRBool isUnicode, LPTSTR cardValue, nsString & attribValue)
00732 {
00733     if(cardValue) {
00734         if(isUnicode) {
00735             if (Compare(nsDependentString(cardValue), attribValue, nsCaseInsensitiveStringComparator()))
00736                 return PR_FALSE;
00737         }
00738         else {
00739             nsAutoString str;
00740             CONVERT_ASSIGNTO_UNICODE(str, cardValue, PR_TRUE);
00741             if (Compare(str, attribValue, nsCaseInsensitiveStringComparator()))
00742                 return PR_FALSE;
00743         }
00744     }
00745 
00746     return PR_TRUE;
00747 }
00748 
00749 PRBool nsAbIPCCard::Same(nsABCOMCardStruct * card, PRBool isUnicode)
00750 {
00751     if(!card)
00752         return PR_FALSE;
00753 
00754     if(mRecordId && card->dwRecordId) 
00755         return (mRecordId == card->dwRecordId);
00756 
00757     if(CompareValue(isUnicode, card->firstName, m_FirstName))
00758         if(CompareValue(isUnicode, card->lastName, m_LastName))
00759             if(CompareValue(isUnicode, card->displayName, m_DisplayName))
00760                 if(CompareValue(isUnicode, card->nickName, m_NickName))
00761                     return PR_TRUE;
00762 
00763     return PR_FALSE;
00764 }
00765 
00766 
00767 PRBool nsAbIPCCard::Same(nsIAbCard *card)
00768 {
00769     if(!card)
00770         return PR_FALSE;
00771 
00772     nsresult rv;
00773     nsCOMPtr<nsIAbMDBCard> dbCard;
00774     dbCard = do_QueryInterface(card, &rv);
00775     if(NS_SUCCEEDED(rv)) {
00776         // first check the palmID for the cards if they exist
00777         nsXPIDLString palmIDStr;
00778         rv = dbCard->GetStringAttribute(CARD_ATTRIB_PALMID, getter_Copies(palmIDStr));
00779         if(NS_SUCCEEDED(rv) && palmIDStr.get()) {
00780             PRInt32 palmID=0;
00781             PRFloat64 f = PR_strtod(NS_LossyConvertUCS2toASCII(palmIDStr).get(), nsnull);
00782             PRInt64 l;
00783             LL_D2L(l, f);
00784             LL_L2UI(palmID, l);
00785             if(palmID && mRecordId)
00786                 return mRecordId == palmID;
00787         }
00788     }
00789 
00790     nsXPIDLString str;
00791     card->GetFirstName(getter_Copies(str));
00792     if (Compare(str, m_FirstName, nsCaseInsensitiveStringComparator()))
00793         return PR_FALSE;
00794     card->GetLastName(getter_Copies(str));
00795     if (Compare(str, m_LastName, nsCaseInsensitiveStringComparator()))
00796         return PR_FALSE;
00797     card->GetDisplayName(getter_Copies(str));
00798     if (Compare(str, m_DisplayName, nsCaseInsensitiveStringComparator()))
00799         return PR_FALSE;
00800     card->GetNickName(getter_Copies(str));
00801     if (Compare(str, m_NickName, nsCaseInsensitiveStringComparator()))
00802         return PR_FALSE;
00803 
00804     return PR_TRUE;
00805 }
00806 
00807 
00808 void nsAbIPCCard::CopyValue(PRBool isUnicode, nsString & attribValue, LPTSTR * result)
00809 {
00810     *result = NULL;
00811     if(attribValue.Length() && attribValue.get()) {
00812         PRInt32 length;
00813         if(isUnicode) {                                 
00814             length = attribValue.Length()+1;
00815             PRUnichar * Str = (PRUnichar *) CoTaskMemAlloc(sizeof(PRUnichar) * length);
00816             wcsncpy(Str, attribValue.get(), length-1);
00817             Str[length-1] = '\0';
00818             *result = Str;
00819         } 
00820         else { 
00821             NS_LossyConvertUTF16toASCII cStr(attribValue);
00822             // These strings are defined as wide in the idl, so we need to add up to 3
00823             // bytes of 0 byte padding at the end (if the string is an odd number of 
00824             // bytes long, we need one null byte to pad out the last char to a wide char
00825             // and then  two more nulls as a wide null terminator.
00826             length = cStr.Length()+3;
00827             char * str = (char *) CoTaskMemAlloc(length);
00828             strncpy(str, cStr.get(), length-1);
00829             str[length-1] = '\0';
00830             *result = (LPTSTR) str;
00831         } 
00832     }
00833 }
00834 
00835 nsresult nsAbIPCCard::GetABCOMCardStruct(PRBool isUnicode, nsABCOMCardStruct * card)
00836 {
00837     NS_ENSURE_ARG_POINTER(card);
00838 
00839     // If memset() call is missing, callers of MS COM nsSynchronizeAB() will
00840     // receive a different return code even if nsSynchronizeAB() return S_OK.
00841     memset(card, 0, sizeof(nsABCOMCardStruct));
00842     card->dwRecordId = mRecordId;
00843     card->dwCategoryId = mCategoryId;
00844     card->dwStatus = mStatus;
00845     card->addressToUse = CPalmSyncImp::nsUseABHomeAddressForPalmAddress(); // 0 == home, 1 == work
00846     PR_LOG(PALMSYNC, PR_LOG_DEBUG, ("nsAbIPCCard::GetABCOMCardStruct using %d\n", card->addressToUse));
00847 
00848     CopyValue(isUnicode, m_FirstName, &card->firstName);
00849     CopyValue(isUnicode, m_LastName, &card->lastName);
00850     CopyValue(isUnicode, m_DisplayName, &card->displayName);
00851     CopyValue(isUnicode, m_NickName, &card->nickName);
00852     CopyValue(isUnicode, m_PrimaryEmail, &card->primaryEmail);
00853     CopyValue(isUnicode, m_SecondEmail, &card->secondEmail);
00854     CopyValue(isUnicode, m_WorkPhone, &card->workPhone);
00855     CopyValue(isUnicode, m_HomePhone, &card->homePhone);
00856     CopyValue(isUnicode, m_FaxNumber, &card->faxNumber);
00857     CopyValue(isUnicode, m_PagerNumber, &card->pagerNumber);
00858     CopyValue(isUnicode, m_CellularNumber, &card->cellularNumber);
00859     // See if home address contains multiple lines.
00860     JoinHomeAndWorkAddresses(isUnicode, card);
00861     CopyValue(isUnicode, m_HomeCity, &card->homeCity);
00862     CopyValue(isUnicode, m_HomeState, &card->homeState);
00863     CopyValue(isUnicode, m_HomeZipCode, &card->homeZipCode);
00864     CopyValue(isUnicode, m_HomeCountry, &card->homeCountry);
00865     CopyValue(isUnicode, m_WorkCity, &card->workCity);
00866     CopyValue(isUnicode, m_WorkState, &card->workState);
00867     CopyValue(isUnicode, m_WorkZipCode, &card->workZipCode);
00868     CopyValue(isUnicode, m_WorkCountry, &card->workCountry);
00869     CopyValue(isUnicode, m_JobTitle, &card->jobTitle);
00870     CopyValue(isUnicode, m_Department, &card->department);
00871     CopyValue(isUnicode, m_Company, &card->company);
00872     CopyValue(isUnicode, m_WebPage1, &card->webPage1);
00873     CopyValue(isUnicode, m_WebPage2, &card->webPage2);
00874     CopyValue(isUnicode, m_BirthYear, &card->birthYear);
00875     CopyValue(isUnicode, m_BirthMonth, &card->birthMonth);
00876     CopyValue(isUnicode, m_BirthDay, &card->birthDay);
00877     CopyValue(isUnicode, m_Custom1, &card->custom1);
00878     CopyValue(isUnicode, m_Custom2, &card->custom2);
00879     CopyValue(isUnicode, m_Custom3, &card->custom3);
00880     CopyValue(isUnicode, m_Custom4, &card->custom4);
00881     CopyValue(isUnicode, m_Note, &card->notes);
00882 
00883     card->lastModifiedDate = m_LastModDate;
00884     card->preferMailFormat = m_PreferMailFormat;
00885     card->addressToUse = CPalmSyncImp::nsUseABHomeAddressForPalmAddress(); // 0 == home, 1 == work
00886     if (CPalmSyncImp::nsPreferABHomePhoneForPalmPhone())
00887       card->preferredPhoneNum = (m_HomePhone.IsEmpty()) ? (m_WorkPhone.IsEmpty() ? 4 : 1) : 2;
00888     else
00889       card->preferredPhoneNum = (m_WorkPhone.IsEmpty()) ? 2 : (m_WorkPhone.IsEmpty() ? 4 : 1);
00890     card->isMailList = m_IsMailList;
00891     // Can't use ToNewCString() call here becasue MSCOM will complaint about
00892     // memory deallocation (ie, NdrPointerFree()) use CoTaskMemAlloc() instead.
00893     if (m_MailListURI.IsEmpty())
00894       card->mailListURI = NULL;
00895     else
00896     {
00897       PRInt32 length = m_MailListURI.Length()+1;
00898       char * str = (char *) CoTaskMemAlloc(sizeof(char) * length);
00899       strncpy(str, m_MailListURI.get(), length-1);
00900       str[length-1] = '\0';
00901       card->mailListURI = str;
00902     }
00903 
00904     return NS_OK;
00905 }
00906 
00907 void nsAbIPCCard::JoinAddress(PRBool isUnicode, LPTSTR *ptrAddress, nsString &address1, nsString &address2)
00908 {
00909   // If the two address lines in a moz card are not empty
00910   // then join the lines into a single line separated by
00911   // '\x0A'. This is the format expected by Palm.
00912   *ptrAddress = NULL;
00913   PRUint32 strLength= address1.Length() + address2.Length();
00914   if(!strLength)
00915     return;
00916 
00917   // Allocate space for 'strLength' plus three for nulls and one for "\x0A".
00918   // These strings are defined as wide in the idl, so we need to add up to 3
00919   // bytes of 0 byte padding at the end (if the string is an odd number of 
00920   // bytes long, we need one null byte to pad out the last char to a wide char
00921   // and then  two more nulls as a wide null terminator.
00922   strLength += 4;
00923   if(isUnicode)
00924   { 
00925     PRUnichar * uniStr = (PRUnichar *) CoTaskMemAlloc(sizeof(PRUnichar) * (strLength));
00926     if(address1.Length())
00927     {
00928       wcsncpy(uniStr, address1.get(), strLength-1);
00929       uniStr[strLength-1] = '\0';
00930       if(address2.Length())
00931       {
00932         wcsncat(uniStr, (const wchar_t *)"\x0A", strLength-1);
00933         wcsncat(uniStr, address2.get(), strLength-1);
00934         uniStr[strLength-1] = '\0';
00935       }
00936     }
00937     else
00938     {
00939       wcsncpy(uniStr, address2.get(), strLength-1);
00940       uniStr[strLength-1] = '\0';
00941     }
00942 
00943     *ptrAddress = uniStr;
00944   } 
00945   else
00946   { 
00947     char * str = (char *) CoTaskMemAlloc(strLength);
00948     if(address1.Length())
00949     {
00950       NS_LossyConvertUTF16toASCII cStr(address1);
00951       strncpy(str, cStr.get(), strLength-1);
00952       str[strLength-1] = '\0';
00953       if(address2.Length())
00954       {
00955         LossyCopyUTF16toASCII(address2, cStr);
00956         strncat(str, "\x0A", strLength-1);
00957         strncat(str, cStr.get(), strLength-1);
00958         str[strLength-1] = '\0';
00959       }
00960     }
00961     else
00962     {
00963       NS_LossyConvertUTF16toASCII cStr(address2);
00964       strncpy(str, cStr.get(), strLength-1);
00965       str[strLength-1] = '\0';
00966     }
00967     *ptrAddress = (LPTSTR) str;
00968   } 
00969 }
00970 void nsAbIPCCard::JoinHomeAndWorkAddresses(PRBool isUnicode, nsABCOMCardStruct * card)
00971 {
00972   JoinAddress(isUnicode, &card->homeAddress, m_HomeAddress, m_HomeAddress2);
00973   JoinAddress(isUnicode, &card->workAddress, m_WorkAddress, m_WorkAddress2);
00974 }
00975 
00976