зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 183087. Disallow certain types of cards to be members of a list and/or be editable. r=ducarroz, sr=sspitzer.
This commit is contained in:
Родитель
3b4e35ca3a
Коммит
e6bd6d0b4b
|
@ -46,7 +46,7 @@
|
|||
|
||||
// Constants used for card types.
|
||||
// "" or "0": normal, "1": AOL groups, "2": AOL additional email address
|
||||
#define AB_CARD_IS_NORMAL_CRAD "0"
|
||||
#define AB_CARD_IS_NORMAL_CARD "0"
|
||||
#define AB_CARD_IS_AOL_GROUPS "1"
|
||||
#define AB_CARD_IS_AOL_ADDITIONAL_EMAIL "2"
|
||||
|
||||
|
@ -132,6 +132,13 @@ interface nsIAbCard : nsISupports {
|
|||
*/
|
||||
attribute string mailListURI;
|
||||
|
||||
/**
|
||||
* Card type helper attributes
|
||||
*/
|
||||
readonly attribute boolean isANormalCard;
|
||||
readonly attribute boolean isASpecialGroup;
|
||||
readonly attribute boolean isAnEmailAddress;
|
||||
|
||||
wstring getCardValue(in string name);
|
||||
|
||||
void setCardValue(in string attrname, in wstring value);
|
||||
|
|
|
@ -367,6 +367,10 @@ function AbEditCard(card)
|
|||
if (!card)
|
||||
return;
|
||||
|
||||
// Not allowing AOL special groups to be edited.
|
||||
if (card.isASpecialGroup)
|
||||
return;
|
||||
|
||||
if (card.isMailList) {
|
||||
goEditListDialog(GetSelectedDirectory(), card, card.mailListURI, UpdateCardView);
|
||||
}
|
||||
|
|
|
@ -416,6 +416,12 @@ nsresult nsAbAutoCompleteSession::SearchCards(nsIAbDirectory* directory, nsAbAut
|
|||
card = do_QueryInterface(item, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
// Skip if it's not a normal card (ie, they can't be added as members).
|
||||
PRBool isNormal;
|
||||
rv = card->GetIsANormalCard(&isNormal);
|
||||
if (NS_FAILED(rv) || !isNormal)
|
||||
continue;
|
||||
|
||||
nsXPIDLString pEmailStr[MAX_NUMBER_OF_EMAIL_ADDRESSES]; //[0]=primary email, [1]=secondary email (no available with mailing list)
|
||||
nsXPIDLString pDisplayNameStr;
|
||||
nsXPIDLString pFirstNameStr;
|
||||
|
|
|
@ -133,6 +133,35 @@ NS_IMPL_ISUPPORTS1(nsAbCardProperty, nsIAbCard)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult nsAbCardProperty::GetCardTypeFromString(const char *aCardTypeStr, PRBool aEmptyIsTrue, PRBool *aValue)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCardTypeStr);
|
||||
NS_ENSURE_ARG_POINTER(aValue);
|
||||
|
||||
*aValue = PR_FALSE;
|
||||
nsXPIDLString cardType;
|
||||
nsresult rv = GetCardType(getter_Copies(cardType));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
*aValue = ((aEmptyIsTrue && cardType.IsEmpty()) || cardType.Equals(NS_ConvertASCIItoUCS2(aCardTypeStr)));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetIsANormalCard(PRBool *aIsNormal)
|
||||
{
|
||||
return GetCardTypeFromString(AB_CARD_IS_NORMAL_CARD, PR_TRUE, aIsNormal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetIsASpecialGroup(PRBool *aIsSpecailGroup)
|
||||
{
|
||||
return GetCardTypeFromString(AB_CARD_IS_AOL_GROUPS, PR_FALSE, aIsSpecailGroup);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetIsAnEmailAddress(PRBool *aIsEmailAddress)
|
||||
{
|
||||
return GetCardTypeFromString(AB_CARD_IS_AOL_ADDITIONAL_EMAIL, PR_FALSE, aIsEmailAddress);
|
||||
}
|
||||
|
||||
nsresult nsAbCardProperty::GetAttributeName(PRUnichar **aName, nsString& value)
|
||||
{
|
||||
if (aName)
|
||||
|
|
|
@ -134,6 +134,7 @@ protected:
|
|||
private:
|
||||
nsresult AppendData(const char *aAttrName, mozITXTToHTMLConv *aConv, nsString &aResult);
|
||||
nsresult AppendSection(AppendItem *aArray, PRInt16 aCount, const PRUnichar *aHeading, mozITXTToHTMLConv *aConv, nsString &aResult);
|
||||
nsresult GetCardTypeFromString(const char *aCardTypeStr, PRBool aEmptyIsTrue, PRBool *aValue);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -742,6 +742,12 @@ NS_IMETHODIMP nsAbMDBDirectory::DropCard(nsIAbCard* aCard, PRBool needToCopyCard
|
|||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Don't add the card if it's not a normal one (ie, they can't be added as members).
|
||||
PRBool isNormal;
|
||||
rv = aCard->GetIsANormalCard(&isNormal);
|
||||
if (!isNormal)
|
||||
return NS_OK;
|
||||
|
||||
if (mURI && mIsMailingList == -1)
|
||||
{
|
||||
/* directory URIs are of the form
|
||||
|
|
Загрузка…
Ссылка в новой задаче