nsresult nsAbIPCCard::Copy(nsABCOMCardStruct * srcCard) { NS_ENSURE_ARG_POINTER(srcCard); mRecordId = srcCard->dwRecordId; mCategoryId = srcCard->dwCategoryId; mStatus = srcCard->dwStatus; srcCard->addressToUse = CPalmSyncImp::nsUseABHomeAddressForPalmAddress(); // 0 == work, 1 == home PR_LOG(PALMSYNC, PR_LOG_DEBUG, ("nsAbIPCCard::Copy using %d\n", srcCard->addressToUse)); // Each palm address field is allowed to have multiple lines // so replace CRLFs with spaces (since other than Notes field // moz only displays fields in a single line). nsAutoString str; CONVERT_CRLF_TO_SPACE(str, srcCard->firstName); SetFirstName(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->lastName); SetLastName(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->displayName); SetDisplayName(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->nickName); SetNickName(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->primaryEmail); SetPrimaryEmail(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->secondEmail); SetSecondEmail(str.get()); SetPreferMailFormat(srcCard->preferMailFormat); CONVERT_CRLF_TO_SPACE(str, srcCard->workPhone); SetWorkPhone(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->homePhone); SetHomePhone(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->faxNumber); SetFaxNumber(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->pagerNumber); SetPagerNumber(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->cellularNumber); SetCellularNumber(str.get()); // See if home address contains multiple lines. SplitHomeAndWorkAddresses(srcCard, PR_TRUE); CONVERT_CRLF_TO_SPACE(str, srcCard->homeCity); SetHomeCity(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->homeState); SetHomeState(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->homeZipCode); SetHomeZipCode(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->homeCountry); SetHomeCountry(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->workCity); SetWorkCity(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->workState); SetWorkState(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->workZipCode); SetWorkZipCode(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->workCountry); SetWorkCountry(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->jobTitle); SetJobTitle(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->department); SetDepartment(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->company); SetCompany(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->webPage1); SetWebPage1(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->webPage2); SetWebPage2(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->birthYear); SetBirthYear(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->birthMonth); SetBirthMonth(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->birthDay); SetBirthDay(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->custom1); SetCustom1(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->custom2); SetCustom2(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->custom3); SetCustom3(str.get()); CONVERT_CRLF_TO_SPACE(str, srcCard->custom4); SetCustom4(str.get()); SetNotes(srcCard->notes); SetLastModifiedDate(srcCard->lastModifiedDate); SetIsMailList(srcCard->isMailList); SetMailListURI(srcCard->mailListURI); return NS_OK; }
nsresult nsAbIPCCard::ConvertToUnicodeAndCopy(nsABCOMCardStruct * srcCard) { NS_ENSURE_ARG_POINTER(srcCard); mRecordId = srcCard->dwRecordId; mCategoryId = srcCard->dwCategoryId; mStatus = srcCard->dwStatus; nsAutoString str; // Each palm address field is allowed to have multiple lines // so replace CRLFs with spaces (since other than Notes field // moz only displays fields in a single line). CONVERT_ASSIGNTO_UNICODE(str, srcCard->firstName, PR_TRUE); SetFirstName(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->lastName, PR_TRUE); SetLastName(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->displayName, PR_TRUE); SetDisplayName(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->nickName, PR_TRUE); SetNickName(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->primaryEmail, PR_TRUE); SetPrimaryEmail(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->secondEmail, PR_TRUE); SetSecondEmail(str.get()); SetPreferMailFormat(srcCard->preferMailFormat); CONVERT_ASSIGNTO_UNICODE(str, srcCard->workPhone, PR_TRUE); SetWorkPhone(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->homePhone, PR_TRUE); SetHomePhone(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->faxNumber, PR_TRUE); SetFaxNumber(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->pagerNumber, PR_TRUE); SetPagerNumber(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->cellularNumber, PR_TRUE); SetCellularNumber(str.get()); // See if home address contains multiple lines. SplitHomeAndWorkAddresses(srcCard, PR_FALSE); CONVERT_ASSIGNTO_UNICODE(str, srcCard->homeCity, PR_TRUE); SetHomeCity(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->homeState, PR_TRUE); SetHomeState(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->homeZipCode, PR_TRUE); SetHomeZipCode(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->homeCountry, PR_TRUE); SetHomeCountry(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->workCity, PR_TRUE); SetWorkCity(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->workState, PR_TRUE); SetWorkState(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->workZipCode, PR_TRUE); SetWorkZipCode(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->workCountry, PR_TRUE); SetWorkCountry(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->jobTitle, PR_TRUE); SetJobTitle(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->department, PR_TRUE); SetDepartment(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->company, PR_TRUE); SetCompany(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->webPage1, PR_TRUE); SetWebPage1(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->webPage2, PR_TRUE); SetWebPage2(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->birthYear, PR_TRUE); SetBirthYear(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->birthMonth, PR_TRUE); SetBirthMonth(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->birthDay, PR_TRUE); SetBirthDay(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->custom1, PR_TRUE); SetCustom1(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->custom2, PR_TRUE); SetCustom2(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->custom3, PR_TRUE); SetCustom3(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->custom4, PR_TRUE); SetCustom4(str.get()); CONVERT_ASSIGNTO_UNICODE(str, srcCard->notes, PR_FALSE); SetNotes(str.get()); SetLastModifiedDate(srcCard->lastModifiedDate); SetIsMailList(srcCard->isMailList); SetMailListURI(srcCard->mailListURI); return NS_OK; }
nsresult nsAbOutlookCard::Init(const char *aUri) { nsresult retCode = nsRDFResource::Init(aUri) ; NS_ENSURE_SUCCESS(retCode, retCode) ; nsCAutoString entry ; nsCAutoString stub ; mAbWinType = getAbWinType(kOutlookCardScheme, mURI.get(), stub, entry) ; if (mAbWinType == nsAbWinType_Unknown) { PRINTF(("Huge problem URI=%s.\n", mURI.get())) ; return NS_ERROR_INVALID_ARG ; } nsAbWinHelperGuard mapiAddBook (mAbWinType) ; if (!mapiAddBook->IsOK()) { return NS_ERROR_FAILURE ; } mMapiData->Assign(entry) ; nsStringArray unichars ; ULONG i = 0 ; if (mapiAddBook->GetPropertiesUString(*mMapiData, OutlookCardMAPIProps, index_LastProp, unichars)) { SetFirstName(*unichars[index_FirstName]); SetLastName(*unichars[index_LastName]); SetDisplayName(*unichars[index_DisplayName]); SetNickName(*unichars[index_NickName]); SetPrimaryEmail(*unichars[index_EmailAddress]); SetWorkPhone(*unichars[index_WorkPhoneNumber]); SetHomePhone(*unichars[index_HomePhoneNumber]); SetFaxNumber(*unichars[index_WorkFaxNumber]); SetPagerNumber(*unichars[index_PagerNumber]); SetCellularNumber(*unichars[index_MobileNumber]); SetHomeCity(*unichars[index_HomeCity]); SetHomeState(*unichars[index_HomeState]); SetHomeZipCode(*unichars[index_HomeZip]); SetHomeCountry(*unichars[index_HomeCountry]); SetWorkCity(*unichars[index_WorkCity]); SetWorkState(*unichars[index_WorkState]); SetWorkZipCode(*unichars[index_WorkZip]); SetWorkCountry(*unichars[index_WorkCountry]); SetJobTitle(*unichars[index_JobTitle]); SetDepartment(*unichars[index_Department]); SetCompany(*unichars[index_Company]); SetWebPage1(*unichars[index_WorkWebPage]); SetWebPage2(*unichars[index_HomeWebPage]); SetNotes(*unichars[index_Comments]); } ULONG cardType = 0 ; nsCAutoString normalChars ; if (mapiAddBook->GetPropertyLong(*mMapiData, PR_OBJECT_TYPE, cardType)) { SetIsMailList(cardType == MAPI_DISTLIST) ; if (cardType == MAPI_DISTLIST) { buildAbWinUri(kOutlookDirectoryScheme, mAbWinType, normalChars) ; normalChars.Append(entry) ; SetMailListURI(normalChars.get()) ; } } nsAutoString unichar ; nsAutoString unicharBis ; if (mapiAddBook->GetPropertyUString(*mMapiData, PR_HOME_ADDRESS_STREET_W, unichar)) { splitString(unichar, unicharBis) ; SetHomeAddress(unichar) ; SetHomeAddress2(unicharBis) ; } if (mapiAddBook->GetPropertyUString(*mMapiData, PR_BUSINESS_ADDRESS_STREET_W, unichar)) { splitString(unichar, unicharBis) ; SetWorkAddress(unichar) ; SetWorkAddress2(unicharBis) ; } WORD year = 0 ; WORD month = 0 ; WORD day = 0 ; if (mapiAddBook->GetPropertyDate(*mMapiData, PR_BIRTHDAY, year, month, day)) { wordToUnicode(year, unichar); SetBirthYear(unichar); wordToUnicode(month, unichar); SetBirthMonth(unichar); wordToUnicode(day, unichar); SetBirthDay(unichar); } return retCode ; }