Bug 459956 - Outlook address book cards don't persist changes r=standard8, sr=neil
authorJoshua Cranmer <Pidgeot18@gmail.com>
Fri, 14 Nov 2008 17:23:30 -0500
changeset 1114 0079f40161ba6fed6ea02828b0e35934d484aaef
parent 1113 d095d41fcdba508f4f7f726edda9c08cc624ae0b
child 1115 f46a87cfb094ca6d990314b9944ebfb0185efb99
push idunknown
push userunknown
push dateunknown
reviewersstandard8, neil
bugs459956
Bug 459956 - Outlook address book cards don't persist changes r=standard8, sr=neil
mailnews/addrbook/src/nsAbOutlookDirectory.cpp
--- a/mailnews/addrbook/src/nsAbOutlookDirectory.cpp
+++ b/mailnews/addrbook/src/nsAbOutlookDirectory.cpp
@@ -1334,24 +1334,33 @@ static void UnicodeToWord(const PRUnicha
 }
 
 #define PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST "mail.addr_book.lastnamefirst"
 
 NS_IMETHODIMP nsAbOutlookDirectory::ModifyCard(nsIAbCard *aModifiedCard)
 {
   NS_ENSURE_ARG_POINTER(aModifiedCard);
 
-  nsresult retCode = NS_OK;
   nsString *properties = nsnull;
   nsAutoString utility;
   nsAbWinHelperGuard mapiAddBook(mAbWinType);
 
   if (!mapiAddBook->IsOK())
     return NS_ERROR_FAILURE;
 
+  nsCString entry;
+  nsresult retCode = ExtractCardEntry(aModifiedCard, entry);
+  NS_ENSURE_SUCCESS(retCode, retCode);
+  // If we don't have the card entry, we can't work.
+  if (entry.IsEmpty())
+    return NS_ERROR_FAILURE;
+
+  nsMapiEntry mapiData;
+  mapiData.Assign(entry);
+
   // First, all the standard properties in one go
   properties = new nsString[index_LastProp];
   if (!properties) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
   aModifiedCard->GetFirstName(properties[index_FirstName]);
   aModifiedCard->GetLastName(properties[index_LastName]);
   // This triple search for something to put in the name
@@ -1395,17 +1404,17 @@ NS_IMETHODIMP nsAbOutlookDirectory::Modi
   aModifiedCard->GetPropertyAsAString(kWorkZipCodeProperty, properties[index_WorkZip]);
   aModifiedCard->GetPropertyAsAString(kWorkCountryProperty, properties[index_WorkCountry]);
   aModifiedCard->GetPropertyAsAString(kJobTitleProperty, properties[index_JobTitle]);
   aModifiedCard->GetPropertyAsAString(kDepartmentProperty, properties[index_Department]);
   aModifiedCard->GetPropertyAsAString(kCompanyProperty, properties[index_Company]);
   aModifiedCard->GetPropertyAsAString(kWorkWebPageProperty, properties[index_WorkWebPage]);
   aModifiedCard->GetPropertyAsAString(kHomeWebPageProperty, properties[index_HomeWebPage]);
   aModifiedCard->GetPropertyAsAString(kNotesProperty, properties[index_Comments]);
-  if (!mapiAddBook->SetPropertiesUString(*mMapiData, OutlookCardMAPIProps,
+  if (!mapiAddBook->SetPropertiesUString(mapiData, OutlookCardMAPIProps,
                                          index_LastProp, properties)) {
     PRINTF(("Cannot set general properties.\n")) ;
   }
 
   delete [] properties;
   nsString unichar;
   nsString unichar2;
   WORD year = 0;
@@ -1415,44 +1424,44 @@ NS_IMETHODIMP nsAbOutlookDirectory::Modi
   aModifiedCard->GetPropertyAsAString(kHomeAddressProperty, unichar);
   aModifiedCard->GetPropertyAsAString(kHomeAddress2Property, unichar2);
 
   utility.Assign(unichar.get());
   if (!utility.IsEmpty())
     utility.AppendLiteral("\r\n");
 
   utility.Append(unichar2.get());
-  if (!mapiAddBook->SetPropertyUString(*mMapiData, PR_HOME_ADDRESS_STREET_W, utility.get())) {
+  if (!mapiAddBook->SetPropertyUString(mapiData, PR_HOME_ADDRESS_STREET_W, utility.get())) {
     PRINTF(("Cannot set home address.\n")) ;
   }
 
   unichar.Truncate();
   aModifiedCard->GetPropertyAsAString(kWorkAddressProperty, unichar);
   unichar2.Truncate();
   aModifiedCard->GetPropertyAsAString(kWorkAddress2Property, unichar2);
 
   utility.Assign(unichar.get());
   if (!utility.IsEmpty())
     utility.AppendLiteral("\r\n");
 
   utility.Append(unichar2.get());
-  if (!mapiAddBook->SetPropertyUString(*mMapiData, PR_BUSINESS_ADDRESS_STREET_W, utility.get())) {
+  if (!mapiAddBook->SetPropertyUString(mapiData, PR_BUSINESS_ADDRESS_STREET_W, utility.get())) {
     PRINTF(("Cannot set work address.\n")) ;
   }
 
   unichar.Truncate();
   aModifiedCard->GetPropertyAsAString(kBirthYearProperty, unichar);
   UnicodeToWord(unichar.get(), year);
   unichar.Truncate();
   aModifiedCard->GetPropertyAsAString(kBirthMonthProperty, unichar);
   UnicodeToWord(unichar.get(), month);
   unichar.Truncate();
   aModifiedCard->GetPropertyAsAString(kBirthDayProperty, unichar);
   UnicodeToWord(unichar.get(), day);
-  if (!mapiAddBook->SetPropertyDate(*mMapiData, PR_BIRTHDAY, year, month, day)) {
+  if (!mapiAddBook->SetPropertyDate(mapiData, PR_BIRTHDAY, year, month, day)) {
     PRINTF(("Cannot set date.\n")) ;
   }
 
   return retCode;
 }
 
 NS_IMETHODIMP nsAbOutlookDirectory::OnQueryFoundCard(nsIAbCard *aCard)
 {