Bug 891271 - Remove some redundant methods from nsIImportFieldMap. r=kent,sr=Neil

This commit is contained in:
Mark Banner 2013-07-12 07:37:06 +01:00
Родитель 20c800e9e7
Коммит 2a3f0c33f7
3 изменённых файлов: 1 добавлений и 227 удалений

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

@ -19,8 +19,7 @@ interface nsIAddrDatabase;
interface nsIMdbRow;
interface nsIAbCard;
[scriptable, uuid(0e376da3-e289-4d14-bdec-867764585eb7)]
[scriptable, uuid(deee9264-1fe3-47b1-b745-47b22de454e2)]
interface nsIImportFieldMap : nsISupports
{
/*
@ -56,11 +55,6 @@ interface nsIImportFieldMap : nsISupports
*/
void SetFieldMap( in long index, in long fieldNum);
/*
Set the field that this index maps to, -1 for no field
*/
void SetFieldMapByDescription( in long index, in wstring fieldDesc);
/*
Return if this field is "active" in the map.
*/
@ -75,26 +69,4 @@ interface nsIImportFieldMap : nsISupports
Set the value of the given field in the database row
*/
void SetFieldValue( in nsIAddrDatabase database, in nsIMdbRow row, in long fieldNum, in wstring value);
/*
Set the value of the given field in the database row
*/
void SetFieldValueByDescription( in nsIAddrDatabase database, in nsIMdbRow row, in wstring fieldDesc, in wstring value);
/*
Get the value of the given field from the address card
*/
wstring GetFieldValue( in nsIAbCard card, in long fieldNum);
/*
Get the value of the given field from the address card
*/
wstring GetFieldValueByDescription( in nsIAbCard card, in wstring fieldDesc);
};
%{ C++
%}

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

@ -167,20 +167,6 @@ NS_IMETHODIMP nsImportFieldMap::SetFieldMap(int32_t index, int32_t fieldNum)
return NS_OK;
}
NS_IMETHODIMP nsImportFieldMap::SetFieldMapByDescription(int32_t index, const PRUnichar *fieldDesc)
{
NS_PRECONDITION(fieldDesc != nullptr, "null ptr");
if (!fieldDesc)
return NS_ERROR_NULL_POINTER;
int32_t i = FindFieldNum(fieldDesc);
if (i == -1)
return NS_ERROR_FAILURE;
return SetFieldMap(index, i);
}
NS_IMETHODIMP nsImportFieldMap::GetFieldActive(int32_t index, bool *active)
{
NS_PRECONDITION(active != nullptr, "null ptr");
@ -350,176 +336,6 @@ NS_IMETHODIMP nsImportFieldMap::SetFieldValue(nsIAddrDatabase *database, nsIMdbR
}
NS_IMETHODIMP nsImportFieldMap::SetFieldValueByDescription(nsIAddrDatabase *database, nsIMdbRow *row, const PRUnichar *fieldDesc, const PRUnichar *value)
{
NS_PRECONDITION(fieldDesc != nullptr, "null ptr");
if (!fieldDesc)
return NS_ERROR_NULL_POINTER;
int32_t i = FindFieldNum(fieldDesc);
if (i == -1)
return NS_ERROR_FAILURE;
return SetFieldValue(database, row, i, value);
}
NS_IMETHODIMP nsImportFieldMap::GetFieldValue(nsIAbCard *card, int32_t fieldNum, PRUnichar **_retval)
{
if (!_retval || !card)
return NS_ERROR_NULL_POINTER;
if (fieldNum == -1) {
PRUnichar c = 0;
*_retval = NS_strdup(&c);
return NS_OK;
}
if ((fieldNum < 0) || (fieldNum >= m_mozFieldCount))
return NS_ERROR_FAILURE;
// ARRGGG!!! Lots of typing again
// get the field from the card
nsresult rv;
nsAutoString value;
switch (fieldNum) {
case 0:
rv = card->GetFirstName(value);
break;
case 1:
rv = card->GetLastName(value);
break;
case 2:
rv = card->GetDisplayName(value);
break;
case 3:
rv = card->GetPropertyAsAString(kNicknameProperty, value);
break;
case 4:
rv = card->GetPrimaryEmail(value);
break;
case 5:
rv = card->GetPropertyAsAString(k2ndEmailProperty, value);
break;
case 6:
rv = card->GetPropertyAsAString(kWorkPhoneProperty, value);
break;
case 7:
rv = card->GetPropertyAsAString(kHomePhoneProperty, value);
break;
case 8:
rv = card->GetPropertyAsAString(kFaxProperty, value);
break;
case 9:
rv = card->GetPropertyAsAString(kPagerProperty, value);
break;
case 10:
rv = card->GetPropertyAsAString(kCellularProperty, value);
break;
case 11:
rv = card->GetPropertyAsAString(kHomeAddressProperty, value);
break;
case 12:
rv = card->GetPropertyAsAString(kHomeAddress2Property, value);
break;
case 13:
rv = card->GetPropertyAsAString(kHomeCityProperty, value);
break;
case 14:
rv = card->GetPropertyAsAString(kHomeStateProperty, value);
break;
case 15:
rv = card->GetPropertyAsAString(kHomeZipCodeProperty, value);
break;
case 16:
rv = card->GetPropertyAsAString(kHomeCountryProperty, value);
break;
case 17:
rv = card->GetPropertyAsAString(kWorkAddressProperty, value);
break;
case 18:
rv = card->GetPropertyAsAString(kWorkAddress2Property, value);
break;
case 19:
rv = card->GetPropertyAsAString(kWorkCityProperty, value);
break;
case 20:
rv = card->GetPropertyAsAString(kWorkStateProperty, value);
break;
case 21:
rv = card->GetPropertyAsAString(kWorkZipCodeProperty, value);
break;
case 22:
rv = card->GetPropertyAsAString(kWorkCountryProperty, value);
break;
case 23:
rv = card->GetPropertyAsAString(kJobTitleProperty, value);
break;
case 24:
rv = card->GetPropertyAsAString(kDepartmentProperty, value);
break;
case 25:
rv = card->GetPropertyAsAString(kCompanyProperty, value);
break;
case 26:
rv = card->GetPropertyAsAString(kWorkWebPageProperty, value);
break;
case 27:
rv = card->GetPropertyAsAString(kHomeWebPageProperty, value);
break;
case 28:
rv = card->GetPropertyAsAString(kBirthYearProperty, value);
break;
case 29:
rv = card->GetPropertyAsAString(kBirthMonthProperty, value);
break;
case 30:
rv = card->GetPropertyAsAString(kBirthDayProperty, value);
break;
case 31:
rv = card->GetPropertyAsAString(kCustom1Property, value);
break;
case 32:
rv = card->GetPropertyAsAString(kCustom2Property, value);
break;
case 33:
rv = card->GetPropertyAsAString(kCustom3Property, value);
break;
case 34:
rv = card->GetPropertyAsAString(kCustom4Property, value);
break;
case 35:
rv = card->GetPropertyAsAString(kNotesProperty, value);
break;
case 36:
rv = card->GetPropertyAsAString(kScreenNameProperty, value);
break;
default:
/* Get the field description, and add it as an anonymous attr? */
/* OR WHAT???? */
{
rv = NS_ERROR_FAILURE;
}
}
if (rv == NS_ERROR_NOT_AVAILABLE)
value = EmptyString();
*_retval = ToNewUnicode(value);
return rv;
}
NS_IMETHODIMP nsImportFieldMap::GetFieldValueByDescription(nsIAbCard *card, const PRUnichar *fieldDesc, PRUnichar **_retval)
{
NS_PRECONDITION(fieldDesc != nullptr, "null ptr");
if (!fieldDesc)
return NS_ERROR_NULL_POINTER;
int32_t i = FindFieldNum(fieldDesc);
if (i == -1)
return NS_ERROR_FAILURE;
return GetFieldValue(card, i, _retval);
}
nsresult nsImportFieldMap::Allocate(int32_t newSize)
{
if (newSize <= m_allocated)
@ -556,15 +372,3 @@ nsresult nsImportFieldMap::Allocate(int32_t newSize)
m_pActive = pActive;
return NS_OK;
}
int32_t nsImportFieldMap::FindFieldNum(const PRUnichar *pDesc)
{
nsString *pStr;
for (int32_t i = 0; i < m_mozFieldCount; i++) {
pStr = (nsString *)m_descriptions.ElementAt(i);
if (!pStr->Equals(pDesc))
return i;
}
return -1;
}

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

@ -30,8 +30,6 @@ public:
private:
nsresult Allocate(int32_t newSize);
int32_t FindFieldNum(const PRUnichar *pDesc);
private:
int32_t m_numFields;