diff --git a/mailnews/addrbook/public/nsIAddrDatabase.idl b/mailnews/addrbook/public/nsIAddrDatabase.idl index 1c90b70771b7..8e7d811381df 100644 --- a/mailnews/addrbook/public/nsIAddrDatabase.idl +++ b/mailnews/addrbook/public/nsIAddrDatabase.idl @@ -79,6 +79,7 @@ interface nsIAddrDatabase : nsIAddrDBAnnouncer { [noscript] void addNickName(in nsIMdbRow row, in string value); [noscript] void addPrimaryEmail(in nsIMdbRow row, in string value); [noscript] void add2ndEmail(in nsIMdbRow row, in string value); + [noscript] void addSendPlainText(in nsIMdbRow row, in boolean value); [noscript] void addWorkPhone(in nsIMdbRow row, in string value); [noscript] void addHomePhone(in nsIMdbRow row, in string value); [noscript] void addFaxNumber(in nsIMdbRow row, in string value); diff --git a/mailnews/addrbook/resources/content/abCardOverlay.js b/mailnews/addrbook/resources/content/abCardOverlay.js index a42e6217313a..f6e7da49a8fb 100644 --- a/mailnews/addrbook/resources/content/abCardOverlay.js +++ b/mailnews/addrbook/resources/content/abCardOverlay.js @@ -179,8 +179,15 @@ function GetCardValues(cardproperty, doc) doc.getElementById('PrimaryEmail').value = cardproperty.primaryEmail; doc.getElementById('SecondEmail').value = cardproperty.secondEmail; - //doc.getElementById('SendPlainText').value = cardproperty.sendPlainText; - + + var checkbox = doc.getElementById('SendPlainText'); + if (checkbox) + { + if (cardproperty.sendPlainText) + checkbox.checked = true; + else + checkbox.removeAttribute('checked', 'false'); + } doc.getElementById('WorkPhone').value = cardproperty.workPhone; doc.getElementById('HomePhone').value = cardproperty.homePhone; doc.getElementById('FaxNumber').value = cardproperty.faxNumber; @@ -227,7 +234,10 @@ function SetCardValues(cardproperty, doc) cardproperty.primaryEmail = doc.getElementById('PrimaryEmail').value; cardproperty.secondEmail = doc.getElementById('SecondEmail').value; - //cardproperty.SendPlainText = doc.getElementById('SendPlainText').value; + + var checkbox = doc.getElementById('SendPlainText'); + if (checkbox) + cardproperty.sendPlainText = checkbox.checked; cardproperty.workPhone = doc.getElementById('WorkPhone').value; cardproperty.homePhone = doc.getElementById('HomePhone').value; diff --git a/mailnews/addrbook/src/nsAbCardProperty.cpp b/mailnews/addrbook/src/nsAbCardProperty.cpp index 06487fbb601e..8b1577761659 100644 --- a/mailnews/addrbook/src/nsAbCardProperty.cpp +++ b/mailnews/addrbook/src/nsAbCardProperty.cpp @@ -711,6 +711,11 @@ NS_IMETHODIMP nsAbCardProperty::CopyCard(nsIAbCard* srcCard) srcCard->GetSecondEmail(&str); SetSecondEmail(str); PR_FREEIF(str); + + PRBool bValue = PR_FALSE; + srcCard->GetSendPlainText(&bValue); + SetSendPlainText(bValue); + srcCard->GetWorkPhone(&str); SetWorkPhone(str); PR_FREEIF(str); diff --git a/mailnews/addrbook/src/nsAddrDatabase.cpp b/mailnews/addrbook/src/nsAddrDatabase.cpp index c213f55d53a4..f7ef972eccbf 100644 --- a/mailnews/addrbook/src/nsAddrDatabase.cpp +++ b/mailnews/addrbook/src/nsAddrDatabase.cpp @@ -890,6 +890,7 @@ nsresult nsAddrDatabase::InitMDBInfo() GetStore()->StringToToken(GetEnv(), kNicknameColumn, &m_NickNameColumnToken); GetStore()->StringToToken(GetEnv(), kPriEmailColumn, &m_PriEmailColumnToken); GetStore()->StringToToken(GetEnv(), k2ndEmailColumn, &m_2ndEmailColumnToken); + GetStore()->StringToToken(GetEnv(), kPlainTextColumn, &m_PlainTextColumnToken); GetStore()->StringToToken(GetEnv(), kWorkPhoneColumn, &m_WorkPhoneColumnToken); GetStore()->StringToToken(GetEnv(), kHomePhoneColumn, &m_HomePhoneColumnToken); GetStore()->StringToToken(GetEnv(), kFaxColumn, &m_FaxColumnToken); @@ -1023,6 +1024,11 @@ nsresult nsAddrDatabase::AddAttributeColumnsToRow(nsIAbCard *card, nsIMdbRow *ca } } PR_FREEIF(pUnicodeStr); + + PRBool bValue = PR_FALSE; + card->GetSendPlainText(&bValue); + AddSendPlainText(cardRow, bValue); + card->GetWorkPhone(&pUnicodeStr); unicharLength = nsCRT::strlen(pUnicodeStr); if (pUnicodeStr && unicharLength) @@ -1837,6 +1843,19 @@ mdb_err nsAddrDatabase::AddIntColumn(nsIMdbRow* cardRow, mdb_column inColumn, PR return cardRow->AddColumn(GetEnv(), inColumn, &yarn); } +mdb_err nsAddrDatabase::AddBoolColumn(nsIMdbRow* cardRow, mdb_column inColumn, PRBool bValue) +{ + struct mdbYarn yarn; + char yarnBuf[100]; + + yarn.mYarn_Buf = (void *) yarnBuf; + if (bValue) + GetIntYarn(1, &yarn); + else + GetIntYarn(0, &yarn); + return cardRow->AddColumn(GetEnv(), inColumn, &yarn); +} + nsresult nsAddrDatabase::GetStringColumn(nsIMdbRow *cardRow, mdb_token outToken, nsString& str) { nsresult err = NS_ERROR_FAILURE; @@ -2209,6 +2228,11 @@ nsresult nsAddrDatabase::GetCardFromDB(nsIAbCard *newCard, nsIMdbRow* cardRow) PR_Free(unicodeStr); } + PRBool bValue = PR_FALSE; + err = GetBoolColumn(cardRow, m_PlainTextColumnToken, &bValue); + if (NS_SUCCEEDED(err)) + newCard->SetSendPlainText(bValue); + err = GetStringColumn(cardRow, m_WorkPhoneColumnToken, tempString); if (NS_SUCCEEDED(err) && tempString.Length()) { diff --git a/mailnews/addrbook/src/nsAddrDatabase.h b/mailnews/addrbook/src/nsAddrDatabase.h index ff1f3fd6c404..b5cc9ea48808 100644 --- a/mailnews/addrbook/src/nsAddrDatabase.h +++ b/mailnews/addrbook/src/nsAddrDatabase.h @@ -119,6 +119,9 @@ public: NS_IMETHOD Add2ndEmail(nsIMdbRow * row, const char * value) { return AddCharStringColumn(row, m_2ndEmailColumnToken, value); } + NS_IMETHOD AddSendPlainText(nsIMdbRow * row, PRBool value) + { return AddBoolColumn(row, m_PlainTextColumnToken, value); } + NS_IMETHOD AddWorkPhone(nsIMdbRow * row, const char * value) { return AddCharStringColumn(row, m_WorkPhoneColumnToken, value); } @@ -252,6 +255,7 @@ protected: mdb_err AddCharStringColumn(nsIMdbRow* cardRow, mdb_column inColumn, const char* str); mdb_err AddStringColumn(nsIMdbRow* cardRow, mdb_column inColumn, nsString* str); mdb_err AddIntColumn(nsIMdbRow* cardRow, mdb_column inColumn, PRUint32 nValue); + mdb_err AddBoolColumn(nsIMdbRow* cardRow, mdb_column inColumn, PRBool bValue); nsresult GetStringColumn(nsIMdbRow *cardRow, mdb_token outToken, nsString& str); nsresult GetIntColumn(nsIMdbRow *cardRow, mdb_token outToken, PRUint32* pValue, PRUint32 defaultValue);