зеркало из https://github.com/mozilla/pjs.git
Bug 406921 Address book listener on nsIAddrBookSession.added notify flag receives multiple onItemAdded calls. p=Siva <sivakrishna@synovel.com>,r=me,sr=Neil
This commit is contained in:
Родитель
626ce47015
Коммит
9d10902315
|
@ -37,18 +37,31 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIAbCard.idl"
|
||||
#include "nsIAbDirectory.idl"
|
||||
|
||||
interface nsIAddrDBListener;
|
||||
|
||||
[scriptable, uuid(0d8fe8e3-ad48-4dbd-b0c2-a1d374e39b93)]
|
||||
[scriptable, uuid(166b19a1-1235-4613-9601-816dedc48c9e)]
|
||||
interface nsIAddrDBAnnouncer : nsISupports {
|
||||
|
||||
void addListener(in nsIAddrDBListener listener);
|
||||
void removeListener(in nsIAddrDBListener listener);
|
||||
|
||||
void notifyCardAttribChange(in unsigned long abCode);
|
||||
void notifyCardEntryChange (in unsigned long abCode,
|
||||
in nsIAbCard card);
|
||||
|
||||
/**
|
||||
* Notify all the listeners of the database about an event performed
|
||||
* on a card entry.
|
||||
*
|
||||
* @param aAbCode The code to indicate the type of event
|
||||
* (see nsAddrDatabase.h AB_NOTIFY_CODE for values).
|
||||
* @param aCard The card entry on which the event occurred.
|
||||
* @param aParent The parent of card entry. This is set by
|
||||
* object which performs the operation.
|
||||
*/
|
||||
void notifyCardEntryChange(in unsigned long aAbCode,
|
||||
in nsIAbCard aCard,
|
||||
in nsIAbDirectory aParent);
|
||||
|
||||
void notifyAnnouncerGoingAway();
|
||||
};
|
||||
|
|
|
@ -40,12 +40,27 @@
|
|||
|
||||
interface nsIAddrDBAnnouncer;
|
||||
|
||||
[scriptable, uuid(96876e1d-50a8-4264-8cd0-953d75d0e81b)]
|
||||
[scriptable, uuid(5d7e5a7a-1ac9-46dc-abfd-758c98be26e9)]
|
||||
interface nsIAddrDBListener : nsISupports {
|
||||
|
||||
void onCardAttribChange(in unsigned long abCode);
|
||||
void onCardEntryChange (in unsigned long abCode,
|
||||
in nsIAbCard card);
|
||||
|
||||
/**
|
||||
* Handle the card entry change event.
|
||||
*
|
||||
* @param aAbCode The code to indicate the type of event
|
||||
* (see nsAddrDatabase.h AB_NOTIFY_CODE for values).
|
||||
* @param aCard The card entry on which the event occurred.
|
||||
* @param aParent The parent of card entry.
|
||||
* If set to null, the event can be ignored.
|
||||
* This happens during import & sync operations when
|
||||
* listeners of a database need not be notified about
|
||||
* card entry changes.
|
||||
*/
|
||||
void onCardEntryChange (in unsigned long aAbCode,
|
||||
in nsIAbCard aCard,
|
||||
in nsIAbDirectory aParent);
|
||||
|
||||
void onListEntryChange (in unsigned long abCode,
|
||||
in nsIAbDirectory list);
|
||||
void onAnnouncerGoingAway();
|
||||
|
|
|
@ -138,7 +138,7 @@ interface nsAddrDBCommitType
|
|||
const long kCompressCommit = 3;
|
||||
};
|
||||
|
||||
[scriptable, uuid(e93e3483-4586-4c2d-8e4e-ae573c5d7a41)]
|
||||
[scriptable, uuid(ae789049-8b41-492c-a210-8dc36a7e731f)]
|
||||
interface nsIAddrDatabase : nsIAddrDBAnnouncer {
|
||||
|
||||
/**
|
||||
|
@ -171,9 +171,31 @@ interface nsIAddrDatabase : nsIAddrDBAnnouncer {
|
|||
void commit(in unsigned long commitType);
|
||||
void forceClosed();
|
||||
|
||||
void createNewCardAndAddToDB(in nsIAbCard newCard, in boolean aNotify);
|
||||
/**
|
||||
* Create a new card and add to the database
|
||||
*
|
||||
* @param aNewCard the card to be added
|
||||
* @param aNotify if set to true, all the listeners of the
|
||||
* database will be notified.
|
||||
* @param aParent parent directory or mailing list to which the
|
||||
* card is added. If set to null, listeners of the
|
||||
* database will not be notified of card creation.
|
||||
*/
|
||||
void createNewCardAndAddToDB(in nsIAbCard aNewCard, in boolean aNotify, in nsIAbDirectory aParent);
|
||||
|
||||
void createNewListCardAndAddToDB(in nsIAbDirectory list, in unsigned long listRowID, in nsIAbCard newCard, in boolean aNotify);
|
||||
void createMailListAndAddToDB(in nsIAbDirectory newList, in boolean aNotify);
|
||||
|
||||
/**
|
||||
* Create a new mailing list and add to the database
|
||||
*
|
||||
* @param aNewList the mailing list to be added.
|
||||
* @param aNotify if set to true, all the listeners of the
|
||||
* database will be notified.
|
||||
* @param aParent parent directory to which the mailing list
|
||||
* is added. If set to null, listeners of the database
|
||||
* will not be notified of mailing list creation.
|
||||
*/
|
||||
void createMailListAndAddToDB(in nsIAbDirectory aNewList, in boolean aNotify, in nsIAbDirectory aParent);
|
||||
|
||||
/**
|
||||
* Enumerate the cards in the directory. The enumerator will return the
|
||||
|
@ -193,8 +215,31 @@ interface nsIAddrDatabase : nsIAddrDBAnnouncer {
|
|||
nsISimpleEnumerator enumerateListAddresses(in nsIAbDirectory directory);
|
||||
|
||||
void getMailingListsFromDB(in nsIAbDirectory parentDir);
|
||||
void deleteCard(in nsIAbCard card, in boolean aNotify);
|
||||
void editCard(in nsIAbCard card, in boolean aNotify);
|
||||
|
||||
/**
|
||||
* Delete a card from the database.
|
||||
*
|
||||
* @param aCard the card to be deleted.
|
||||
* @param aNotify if set to true, all the listeners of the
|
||||
* database will be notified.
|
||||
* @param aParent parent directory from which the card
|
||||
* is to be deleted. If set to null, listeners of
|
||||
* the database will not be notified of card deletion.
|
||||
*/
|
||||
void deleteCard(in nsIAbCard aCard, in boolean aNotify, in nsIAbDirectory aParent);
|
||||
|
||||
/**
|
||||
* Edit a card in the database.
|
||||
*
|
||||
* @param aCard the card to be edited.
|
||||
* @param aNotify if set to true, all the listeners of the
|
||||
* database will be notified.
|
||||
* @param aParent parent directory in which the card
|
||||
* is to be edited. If set to null, listeners of
|
||||
* the database will not be notified of card entry
|
||||
* change.
|
||||
*/
|
||||
void editCard(in nsIAbCard aCard, in boolean aNotify, in nsIAbDirectory aParent);
|
||||
boolean containsCard(in nsIAbCard card);
|
||||
void deleteMailList(in nsIAbDirectory mailList, in boolean aNotify);
|
||||
void editMailList(in nsIAbDirectory mailList, in nsIAbCard listCard, in boolean aNotify);
|
||||
|
@ -301,11 +346,26 @@ interface nsIAddrDatabase : nsIAddrDBAnnouncer {
|
|||
*/
|
||||
readonly attribute unsigned long deletedCardCount;
|
||||
|
||||
/**
|
||||
* Add the column representing the card to the mailing list row
|
||||
* in the database.
|
||||
*
|
||||
* @param aPCard the card to be added.
|
||||
* @param aPListRow the row to which the column will be added.
|
||||
* @param aPos the position of the card in the mailing list.
|
||||
* @param aPNewCard a pointer to hold the new card added to the row.
|
||||
* @param aInMailingList If set to true, the card is already present
|
||||
* in the mailing list
|
||||
* @param aParent parent mailing list to which the card
|
||||
* is added. If set to null, listeners of the
|
||||
* database will not be notified of card creation.
|
||||
*/
|
||||
void AddListCardColumnsToRow(in nsIAbCard aPCard,
|
||||
in nsIMdbRow aPListRow,
|
||||
in unsigned long aPos,
|
||||
out nsIAbCard aPNewCard,
|
||||
in boolean aInMailingList);
|
||||
in boolean aInMailingList,
|
||||
in nsIAbDirectory aParent);
|
||||
void InitCardFromRow(in nsIAbCard aNewCard,in nsIMdbRow aCardRow);
|
||||
void SetListAddressTotal(in nsIMdbRow aListRow, in PRUint32 aTotal);
|
||||
nsIMdbRow FindRowByCard(in nsIAbCard aCard);
|
||||
|
|
|
@ -301,7 +301,7 @@ nsresult nsAbLDAPProcessReplicationData::OnLDAPSearchEntry(nsILDAPMessage *aMess
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = mReplicationDB->CreateNewCardAndAddToDB(newCard, PR_FALSE);
|
||||
rv = mReplicationDB->CreateNewCardAndAddToDB(newCard, PR_FALSE, nsnull);
|
||||
if(NS_FAILED(rv)) {
|
||||
Abort();
|
||||
return rv;
|
||||
|
@ -322,7 +322,7 @@ nsresult nsAbLDAPProcessReplicationData::OnLDAPSearchEntry(nsILDAPMessage *aMess
|
|||
return rv;
|
||||
}
|
||||
|
||||
rv = mReplicationDB->EditCard(newCard, PR_FALSE);
|
||||
rv = mReplicationDB->EditCard(newCard, PR_FALSE, nsnull);
|
||||
if(NS_FAILED(rv)) {
|
||||
Abort();
|
||||
return rv;
|
||||
|
@ -538,5 +538,5 @@ nsresult nsAbLDAPProcessReplicationData::DeleteCard(nsString & aDn)
|
|||
nsCOMPtr<nsIAbCard> cardToDelete;
|
||||
mReplicationDB->GetCardFromAttribute(nsnull, "_DN", NS_ConvertUTF16toUTF8(aDn),
|
||||
PR_FALSE, getter_AddRefs(cardToDelete));
|
||||
return mReplicationDB->DeleteCard(cardToDelete, PR_FALSE);
|
||||
return mReplicationDB->DeleteCard(cardToDelete, PR_FALSE, nsnull);
|
||||
}
|
||||
|
|
|
@ -210,13 +210,12 @@ nsresult nsAbMDBDirectory::RemoveCardFromAddressList(nsIAbCard* card)
|
|||
nsCOMPtr<nsIAbCard> cardInList(do_QueryElementAt(pAddressLists, j, &rv));
|
||||
PRBool equals;
|
||||
nsresult rv = cardInList->Equals(card, &equals); // should we checking email?
|
||||
if (NS_SUCCEEDED(rv) && equals) {
|
||||
if (NS_SUCCEEDED(rv) && equals)
|
||||
pAddressLists->RemoveElementAt(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -533,7 +532,7 @@ NS_IMETHODIMP nsAbMDBDirectory::DeleteCards(nsIArray *aCards)
|
|||
}
|
||||
else
|
||||
{
|
||||
mDatabase->DeleteCard(card, PR_TRUE);
|
||||
mDatabase->DeleteCard(card, PR_TRUE, this);
|
||||
PRBool bIsMailList = PR_FALSE;
|
||||
card->GetIsMailList(&bIsMailList);
|
||||
if (bIsMailList)
|
||||
|
@ -654,10 +653,10 @@ NS_IMETHODIMP nsAbMDBDirectory::AddMailList(nsIAbDirectory *list)
|
|||
dblist = do_QueryInterface(newlist, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mDatabase->CreateMailListAndAddToDB(newlist, PR_TRUE);
|
||||
mDatabase->CreateMailListAndAddToDB(newlist, PR_TRUE, this);
|
||||
}
|
||||
else
|
||||
mDatabase->CreateMailListAndAddToDB(list, PR_TRUE);
|
||||
mDatabase->CreateMailListAndAddToDB(list, PR_TRUE, this);
|
||||
|
||||
mDatabase->Commit(nsAddrDBCommitType::kLargeCommit);
|
||||
|
||||
|
@ -717,7 +716,7 @@ NS_IMETHODIMP nsAbMDBDirectory::AddCard(nsIAbCard* card, nsIAbCard **addedCard)
|
|||
if (m_IsMailList)
|
||||
mDatabase->CreateNewListCardAndAddToDB(this, m_dbRowID, newCard, PR_TRUE /* notify */);
|
||||
else
|
||||
mDatabase->CreateNewCardAndAddToDB(newCard, PR_TRUE);
|
||||
mDatabase->CreateNewCardAndAddToDB(newCard, PR_TRUE, this);
|
||||
mDatabase->Commit(nsAddrDBCommitType::kLargeCommit);
|
||||
|
||||
NS_IF_ADDREF(*addedCard = newCard);
|
||||
|
@ -735,7 +734,7 @@ NS_IMETHODIMP nsAbMDBDirectory::ModifyCard(nsIAbCard *aModifiedCard)
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = mDatabase->EditCard(aModifiedCard, PR_TRUE);
|
||||
rv = mDatabase->EditCard(aModifiedCard, PR_TRUE, this);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return mDatabase->Commit(nsAddrDBCommitType::kLargeCommit);
|
||||
}
|
||||
|
@ -783,7 +782,7 @@ NS_IMETHODIMP nsAbMDBDirectory::DropCard(nsIAbCard* aCard, PRBool needToCopyCard
|
|||
// contains the mailing list.
|
||||
mDatabase->FindRowByCard(newCard, getter_AddRefs(cardRow));
|
||||
if (!cardRow)
|
||||
mDatabase->CreateNewCardAndAddToDB(newCard, PR_TRUE /* notify */);
|
||||
mDatabase->CreateNewCardAndAddToDB(newCard, PR_TRUE /* notify */, this);
|
||||
else
|
||||
mDatabase->InitCardFromRow(newCard, cardRow);
|
||||
}
|
||||
|
@ -791,7 +790,7 @@ NS_IMETHODIMP nsAbMDBDirectory::DropCard(nsIAbCard* aCard, PRBool needToCopyCard
|
|||
mDatabase->CreateNewListCardAndAddToDB(this, m_dbRowID, newCard, PR_FALSE /* notify */);
|
||||
}
|
||||
else {
|
||||
mDatabase->CreateNewCardAndAddToDB(newCard, PR_TRUE /* notify */);
|
||||
mDatabase->CreateNewCardAndAddToDB(newCard, PR_TRUE /* notify */, this);
|
||||
}
|
||||
mDatabase->Commit(nsAddrDBCommitType::kLargeCommit);
|
||||
return NS_OK;
|
||||
|
@ -814,6 +813,34 @@ NS_IMETHODIMP nsAbMDBDirectory::EditMailListToDatabase(nsIAbCard *listCard)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static PRBool ContainsDirectory(nsIAbDirectory *parent, nsIAbDirectory *directory)
|
||||
{
|
||||
// If parent is a maillist, 'addressLists' contains AbCards.
|
||||
PRBool bIsMailList = PR_FALSE;
|
||||
nsresult rv = parent->GetIsMailList(&bIsMailList);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (bIsMailList)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr <nsISupportsArray> pAddressLists;
|
||||
parent->GetAddressLists(getter_AddRefs(pAddressLists));
|
||||
if (pAddressLists)
|
||||
{
|
||||
PRUint32 total;
|
||||
rv = pAddressLists->Count(&total);
|
||||
for (PRUint32 i = total - 1; i >= 0; i--)
|
||||
{
|
||||
nsCOMPtr<nsIAbDirectory> pList(do_QueryElementAt(pAddressLists, i, &rv));
|
||||
|
||||
if (directory == pList)
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// nsIAddrDBListener methods
|
||||
|
||||
NS_IMETHODIMP nsAbMDBDirectory::OnCardAttribChange(PRUint32 abCode)
|
||||
|
@ -822,13 +849,37 @@ NS_IMETHODIMP nsAbMDBDirectory::OnCardAttribChange(PRUint32 abCode)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP nsAbMDBDirectory::OnCardEntryChange
|
||||
(PRUint32 abCode, nsIAbCard *card)
|
||||
(PRUint32 aAbCode, nsIAbCard *aCard, nsIAbDirectory *aParent)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(card);
|
||||
nsCOMPtr<nsISupports> cardSupports(do_QueryInterface(card));
|
||||
// Don't notify AbManager unless we have the parent
|
||||
if (!aParent)
|
||||
return NS_OK;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aCard);
|
||||
nsCOMPtr<nsISupports> cardSupports(do_QueryInterface(aCard));
|
||||
nsresult rv;
|
||||
|
||||
switch (abCode) {
|
||||
// Notify when
|
||||
// - any operation is done to a card belonging to this
|
||||
// => if <this> is <aParent>, or
|
||||
// - a card belonging to a directory which is parent of this is deleted
|
||||
// => if aAbCode is AB_NotifyDeleted && <this> is child of <aParent>, or
|
||||
// - a card belonging to a directory which is child of this is added/modified
|
||||
// => if aAbCode is !AB_NotifyDeleted && <this> is parent of <aParent>
|
||||
|
||||
if (aParent != this)
|
||||
{
|
||||
PRBool isChild = PR_FALSE;
|
||||
if (aAbCode != AB_NotifyDeleted)
|
||||
isChild = ContainsDirectory(this, aParent);
|
||||
else
|
||||
isChild = ContainsDirectory(aParent, this);
|
||||
|
||||
if (!isChild)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
switch (aAbCode) {
|
||||
case AB_NotifyInserted:
|
||||
rv = NotifyItemAdded(cardSupports);
|
||||
break;
|
||||
|
|
|
@ -229,10 +229,10 @@ NS_IMETHODIMP nsAddrDatabase::NotifyCardAttribChange(PRUint32 abCode)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddrDatabase::NotifyCardEntryChange(PRUint32 abCode, nsIAbCard *card)
|
||||
NS_IMETHODIMP nsAddrDatabase::NotifyCardEntryChange(PRUint32 aAbCode, nsIAbCard *aCard, nsIAbDirectory *aParent)
|
||||
{
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(m_ChangeListeners, nsIAddrDBListener,
|
||||
OnCardEntryChange, (abCode, card));
|
||||
OnCardEntryChange, (aAbCode, aCard, aParent));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1407,24 +1407,24 @@ nsresult nsAddrDatabase::AddAttributeColumnsToRow(nsIAbCard *card, nsIMdbRow *ca
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddrDatabase::CreateNewCardAndAddToDB(nsIAbCard *newCard, PRBool notify /* = FALSE */)
|
||||
NS_IMETHODIMP nsAddrDatabase::CreateNewCardAndAddToDB(nsIAbCard *aNewCard, PRBool aNotify /* = FALSE */, nsIAbDirectory *aParent)
|
||||
{
|
||||
nsCOMPtr <nsIMdbRow> cardRow;
|
||||
|
||||
if (!newCard || !m_mdbPabTable || !m_mdbEnv)
|
||||
if (!aNewCard || !m_mdbPabTable || !m_mdbEnv)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv = GetNewRow(getter_AddRefs(cardRow));
|
||||
if (NS_SUCCEEDED(rv) && cardRow)
|
||||
{
|
||||
AddAttributeColumnsToRow(newCard, cardRow);
|
||||
AddAttributeColumnsToRow(aNewCard, cardRow);
|
||||
AddRecordKeyColumnToRow(cardRow);
|
||||
|
||||
// we need to do this for dnd
|
||||
PRUint32 key = 0;
|
||||
rv = GetIntColumn(cardRow, m_RecordKeyColumnToken, &key, 0);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIAbMDBCard> dbnewCard = do_QueryInterface(newCard);
|
||||
nsCOMPtr<nsIAbMDBCard> dbnewCard = do_QueryInterface(aNewCard);
|
||||
if (dbnewCard)
|
||||
dbnewCard->SetKey(key);
|
||||
}
|
||||
|
@ -1437,9 +1437,9 @@ NS_IMETHODIMP nsAddrDatabase::CreateNewCardAndAddToDB(nsIAbCard *newCard, PRBool
|
|||
return rv;
|
||||
|
||||
// do notification
|
||||
if (notify)
|
||||
if (aNotify)
|
||||
{
|
||||
NotifyCardEntryChange(AB_NotifyInserted, newCard);
|
||||
NotifyCardEntryChange(AB_NotifyInserted, aNewCard, aParent);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -1501,26 +1501,26 @@ NS_IMETHODIMP nsAddrDatabase::CreateNewListCardAndAddToDB(nsIAbDirectory *aList,
|
|||
PRUint32 totalAddress = GetListAddressTotal(pListRow) + 1;
|
||||
SetListAddressTotal(pListRow, totalAddress);
|
||||
nsCOMPtr<nsIAbCard> pNewCard;
|
||||
rv = AddListCardColumnsToRow(newCard, pListRow, totalAddress, getter_AddRefs(pNewCard), PR_TRUE /* aInMailingList */);
|
||||
rv = AddListCardColumnsToRow(newCard, pListRow, totalAddress, getter_AddRefs(pNewCard), PR_TRUE /* aInMailingList */, aList);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
addressList->AppendElement(newCard);
|
||||
|
||||
if (notify)
|
||||
NotifyCardEntryChange(AB_NotifyInserted, newCard);
|
||||
NotifyCardEntryChange(AB_NotifyInserted, newCard, aList);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddrDatabase::AddListCardColumnsToRow
|
||||
(nsIAbCard *pCard, nsIMdbRow *pListRow, PRUint32 pos, nsIAbCard** pNewCard, PRBool aInMailingList)
|
||||
(nsIAbCard *aPCard, nsIMdbRow *aPListRow, PRUint32 aPos, nsIAbCard** aPNewCard, PRBool aInMailingList, nsIAbDirectory *aParent)
|
||||
{
|
||||
if (!pCard || !pListRow || !m_mdbStore || !m_mdbEnv)
|
||||
if (!aPCard || !aPListRow || !m_mdbStore || !m_mdbEnv)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult err = NS_OK;
|
||||
nsString email;
|
||||
pCard->GetPrimaryEmail(email);
|
||||
aPCard->GetPrimaryEmail(email);
|
||||
if (!email.IsEmpty())
|
||||
{
|
||||
nsIMdbRow *pCardRow = nsnull;
|
||||
|
@ -1549,7 +1549,7 @@ NS_IMETHODIMP nsAddrDatabase::AddListCardColumnsToRow
|
|||
NS_ENSURE_TRUE(pCardRow, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsString name;
|
||||
pCard->GetDisplayName(name);
|
||||
aPCard->GetDisplayName(name);
|
||||
if (!name.IsEmpty()) {
|
||||
AddDisplayName(pCardRow, NS_ConvertUTF16toUTF8(name).get());
|
||||
err = m_mdbPabTable->AddRow(m_mdbEnv, pCardRow);
|
||||
|
@ -1557,23 +1557,29 @@ NS_IMETHODIMP nsAddrDatabase::AddListCardColumnsToRow
|
|||
|
||||
nsCOMPtr<nsIAbCard> newCard;
|
||||
CreateABCard(pCardRow, 0, getter_AddRefs(newCard));
|
||||
NS_IF_ADDREF(*pNewCard = newCard);
|
||||
NS_IF_ADDREF(*aPNewCard = newCard);
|
||||
|
||||
if (cardWasAdded) {
|
||||
NotifyCardEntryChange(AB_NotifyInserted, newCard);
|
||||
NotifyCardEntryChange(AB_NotifyInserted, newCard, aParent);
|
||||
}
|
||||
else if (!aInMailingList) {
|
||||
NotifyCardEntryChange(AB_NotifyInserted, pCard);
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIAddrDBListener> parentListener(do_QueryInterface(aParent, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Ensure the parent is in the listener list (and hence wants to be notified)
|
||||
if (m_ChangeListeners.Contains(parentListener))
|
||||
parentListener->OnCardEntryChange(AB_NotifyInserted, aPCard, aParent);
|
||||
}
|
||||
else {
|
||||
NotifyCardEntryChange(AB_NotifyPropertyChanged, pCard);
|
||||
NotifyCardEntryChange(AB_NotifyPropertyChanged, aPCard, aParent);
|
||||
}
|
||||
|
||||
//add a column with address row id to the list row
|
||||
mdb_token listAddressColumnToken;
|
||||
|
||||
char columnStr[COLUMN_STR_MAX];
|
||||
PR_snprintf(columnStr, COLUMN_STR_MAX, kMailListAddressFormat, pos);
|
||||
PR_snprintf(columnStr, COLUMN_STR_MAX, kMailListAddressFormat, aPos);
|
||||
m_mdbStore->StringToToken(m_mdbEnv, columnStr, &listAddressColumnToken);
|
||||
|
||||
mdbOid outOid;
|
||||
|
@ -1581,7 +1587,7 @@ NS_IMETHODIMP nsAddrDatabase::AddListCardColumnsToRow
|
|||
if (pCardRow->GetOid(m_mdbEnv, &outOid) == NS_OK)
|
||||
{
|
||||
//save address row ID to the list row
|
||||
err = AddIntColumn(pListRow, listAddressColumnToken, outOid.mOid_Id);
|
||||
err = AddIntColumn(aPListRow, listAddressColumnToken, outOid.mOid_Id);
|
||||
}
|
||||
NS_RELEASE(pCardRow);
|
||||
|
||||
|
@ -1590,7 +1596,7 @@ NS_IMETHODIMP nsAddrDatabase::AddListCardColumnsToRow
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAddrDatabase::AddListAttributeColumnsToRow(nsIAbDirectory *list, nsIMdbRow *listRow)
|
||||
nsresult nsAddrDatabase::AddListAttributeColumnsToRow(nsIAbDirectory *list, nsIMdbRow *listRow, nsIAbDirectory *aParent)
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
|
||||
|
@ -1659,7 +1665,7 @@ nsresult nsAddrDatabase::AddListAttributeColumnsToRow(nsIAbDirectory *list, nsIM
|
|||
if (!email.IsEmpty())
|
||||
{
|
||||
nsCOMPtr<nsIAbCard> pNewCard;
|
||||
err = AddListCardColumnsToRow(pCard, listRow, pos, getter_AddRefs(pNewCard), listHasCard);
|
||||
err = AddListCardColumnsToRow(pCard, listRow, pos, getter_AddRefs(pNewCard), listHasCard, aParent);
|
||||
if (pNewCard)
|
||||
pAddressLists->ReplaceElementAt(pNewCard, i);
|
||||
}
|
||||
|
@ -1706,9 +1712,9 @@ nsresult nsAddrDatabase::GetAddressRowByPos(nsIMdbRow* listRow, PRUint16 pos, ns
|
|||
return GetCardRowByRowID(rowID, cardRow);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddrDatabase::CreateMailListAndAddToDB(nsIAbDirectory *newList, PRBool notify /* = FALSE */)
|
||||
NS_IMETHODIMP nsAddrDatabase::CreateMailListAndAddToDB(nsIAbDirectory *aNewList, PRBool aNotify /* = FALSE */, nsIAbDirectory *aParent)
|
||||
{
|
||||
if (!newList || !m_mdbPabTable || !m_mdbEnv)
|
||||
if (!aNewList || !m_mdbPabTable || !m_mdbEnv)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIMdbRow *listRow;
|
||||
|
@ -1716,7 +1722,7 @@ NS_IMETHODIMP nsAddrDatabase::CreateMailListAndAddToDB(nsIAbDirectory *newList,
|
|||
|
||||
if (NS_SUCCEEDED(err) && listRow)
|
||||
{
|
||||
AddListAttributeColumnsToRow(newList, listRow);
|
||||
AddListAttributeColumnsToRow(aNewList, listRow, aParent);
|
||||
AddRecordKeyColumnToRow(listRow);
|
||||
mdb_err merror = m_mdbPabTable->AddRow(m_mdbEnv, listRow);
|
||||
if (merror != NS_OK)
|
||||
|
@ -1724,7 +1730,7 @@ NS_IMETHODIMP nsAddrDatabase::CreateMailListAndAddToDB(nsIAbDirectory *newList,
|
|||
|
||||
nsCOMPtr<nsIAbCard> listCard;
|
||||
CreateABListCard(listRow, getter_AddRefs(listCard));
|
||||
NotifyCardEntryChange(AB_NotifyInserted, listCard);
|
||||
NotifyCardEntryChange(AB_NotifyInserted, listCard, aParent);
|
||||
|
||||
NS_RELEASE(listRow);
|
||||
return NS_OK;
|
||||
|
@ -1763,14 +1769,14 @@ void nsAddrDatabase::DeleteCardFromAllMailLists(mdb_id cardRowID)
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddrDatabase::DeleteCard(nsIAbCard *card, PRBool notify)
|
||||
NS_IMETHODIMP nsAddrDatabase::DeleteCard(nsIAbCard *aCard, PRBool aNotify, nsIAbDirectory *aParent)
|
||||
{
|
||||
if (!card || !m_mdbPabTable || !m_mdbStore || !m_mdbEnv)
|
||||
if (!aCard || !m_mdbPabTable || !m_mdbStore || !m_mdbEnv)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult err = NS_OK;
|
||||
PRBool bIsMailList = PR_FALSE;
|
||||
card->GetIsMailList(&bIsMailList);
|
||||
aCard->GetIsMailList(&bIsMailList);
|
||||
|
||||
// get the right row
|
||||
nsIMdbRow* pCardRow = nsnull;
|
||||
|
@ -1778,7 +1784,7 @@ NS_IMETHODIMP nsAddrDatabase::DeleteCard(nsIAbCard *card, PRBool notify)
|
|||
|
||||
rowOid.mOid_Scope = bIsMailList ? m_ListRowScopeToken : m_CardRowScopeToken;
|
||||
|
||||
nsCOMPtr<nsIAbMDBCard> dbcard(do_QueryInterface(card, &err));
|
||||
nsCOMPtr<nsIAbMDBCard> dbcard(do_QueryInterface(aCard, &err));
|
||||
NS_ENSURE_SUCCESS(err, err);
|
||||
|
||||
dbcard->GetDbRowID((PRUint32*)&rowOid.mOid_Id);
|
||||
|
@ -1790,7 +1796,7 @@ NS_IMETHODIMP nsAddrDatabase::DeleteCard(nsIAbCard *card, PRBool notify)
|
|||
|
||||
// Add the deleted card to the deletedcards table
|
||||
nsCOMPtr <nsIMdbRow> cardRow;
|
||||
AddRowToDeletedCardsTable(card, getter_AddRefs(cardRow));
|
||||
AddRowToDeletedCardsTable(aCard, getter_AddRefs(cardRow));
|
||||
err = DeleteRow(m_mdbPabTable, pCardRow);
|
||||
|
||||
//delete the person card from all mailing list
|
||||
|
@ -1798,8 +1804,8 @@ NS_IMETHODIMP nsAddrDatabase::DeleteCard(nsIAbCard *card, PRBool notify)
|
|||
DeleteCardFromAllMailLists(rowOid.mOid_Id);
|
||||
|
||||
if (NS_SUCCEEDED(err)) {
|
||||
if (notify)
|
||||
NotifyCardEntryChange(AB_NotifyDeleted, card);
|
||||
if (aNotify)
|
||||
NotifyCardEntryChange(AB_NotifyDeleted, aCard, aParent);
|
||||
}
|
||||
else
|
||||
DeleteRowFromDeletedCardsTable(cardRow);
|
||||
|
@ -1857,6 +1863,7 @@ nsresult nsAddrDatabase::DeleteCardFromListRow(nsIMdbRow* pListRow, mdb_id cardR
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1891,7 +1898,7 @@ NS_IMETHODIMP nsAddrDatabase::DeleteCardFromMailList(nsIAbDirectory *mailList, n
|
|||
|
||||
err = DeleteCardFromListRow(pListRow, cardRowID);
|
||||
if (NS_SUCCEEDED(err) && aNotify) {
|
||||
NotifyCardEntryChange(AB_NotifyDeleted, card);
|
||||
NotifyCardEntryChange(AB_NotifyDeleted, card, mailList);
|
||||
}
|
||||
NS_RELEASE(pListRow);
|
||||
return NS_OK;
|
||||
|
@ -2075,10 +2082,10 @@ NS_IMETHODIMP nsAddrDatabase::PurgeDeletedCardTable()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddrDatabase::EditCard(nsIAbCard *card, PRBool notify)
|
||||
NS_IMETHODIMP nsAddrDatabase::EditCard(nsIAbCard *aCard, PRBool aNotify, nsIAbDirectory *aParent)
|
||||
{
|
||||
// XXX make sure this isn't getting called when we're just editing one or two well known fields
|
||||
if (!card || !m_mdbPabTable || !m_mdbStore || !m_mdbEnv)
|
||||
if (!aCard || !m_mdbPabTable || !m_mdbStore || !m_mdbEnv)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult err = NS_OK;
|
||||
|
@ -2090,8 +2097,8 @@ NS_IMETHODIMP nsAddrDatabase::EditCard(nsIAbCard *card, PRBool notify)
|
|||
PRUint32 nowInSeconds;
|
||||
PRTime now = PR_Now();
|
||||
PRTime2Seconds(now, &nowInSeconds);
|
||||
card->SetLastModifiedDate(nowInSeconds);
|
||||
nsCOMPtr<nsIAbMDBCard> dbcard(do_QueryInterface(card, &err));
|
||||
aCard->SetLastModifiedDate(nowInSeconds);
|
||||
nsCOMPtr<nsIAbMDBCard> dbcard(do_QueryInterface(aCard, &err));
|
||||
NS_ENSURE_SUCCESS(err, err);
|
||||
dbcard->GetDbRowID((PRUint32*)&rowOid.mOid_Id);
|
||||
|
||||
|
@ -2101,11 +2108,11 @@ NS_IMETHODIMP nsAddrDatabase::EditCard(nsIAbCard *card, PRBool notify)
|
|||
if (!cardRow)
|
||||
return NS_OK;
|
||||
|
||||
err = AddAttributeColumnsToRow(card, cardRow);
|
||||
err = AddAttributeColumnsToRow(aCard, cardRow);
|
||||
NS_ENSURE_SUCCESS(err, err);
|
||||
|
||||
if (notify)
|
||||
NotifyCardEntryChange(AB_NotifyPropertyChanged, card);
|
||||
if (aNotify)
|
||||
NotifyCardEntryChange(AB_NotifyPropertyChanged, aCard, aParent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2188,7 +2195,7 @@ NS_IMETHODIMP nsAddrDatabase::EditMailList(nsIAbDirectory *mailList, nsIAbCard *
|
|||
if (!pListRow)
|
||||
return NS_OK;
|
||||
|
||||
err = AddListAttributeColumnsToRow(mailList, pListRow);
|
||||
err = AddListAttributeColumnsToRow(mailList, pListRow, mailList);
|
||||
NS_ENSURE_SUCCESS(err, err);
|
||||
|
||||
if (notify)
|
||||
|
@ -2197,7 +2204,7 @@ NS_IMETHODIMP nsAddrDatabase::EditMailList(nsIAbDirectory *mailList, nsIAbCard *
|
|||
|
||||
if (listCard)
|
||||
{
|
||||
NotifyCardEntryChange(AB_NotifyPropertyChanged, listCard);
|
||||
NotifyCardEntryChange(AB_NotifyPropertyChanged, listCard, mailList);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,14 +73,14 @@ public:
|
|||
NS_IMETHOD Commit(PRUint32 commitType);
|
||||
NS_IMETHOD ForceClosed();
|
||||
|
||||
NS_IMETHOD CreateNewCardAndAddToDB(nsIAbCard *newCard, PRBool notify);
|
||||
NS_IMETHOD CreateNewCardAndAddToDB(nsIAbCard *newCard, PRBool notify, nsIAbDirectory *parent);
|
||||
NS_IMETHOD CreateNewListCardAndAddToDB(nsIAbDirectory *list, PRUint32 listRowID, nsIAbCard *newCard, PRBool notify);
|
||||
NS_IMETHOD CreateMailListAndAddToDB(nsIAbDirectory *newList, PRBool notify);
|
||||
NS_IMETHOD CreateMailListAndAddToDB(nsIAbDirectory *newList, PRBool notify, nsIAbDirectory *parent);
|
||||
NS_IMETHOD EnumerateCards(nsIAbDirectory *directory, nsISimpleEnumerator **result);
|
||||
NS_IMETHOD GetMailingListsFromDB(nsIAbDirectory *parentDir);
|
||||
NS_IMETHOD EnumerateListAddresses(nsIAbDirectory *directory, nsISimpleEnumerator **result);
|
||||
NS_IMETHOD DeleteCard(nsIAbCard *newCard, PRBool notify);
|
||||
NS_IMETHOD EditCard(nsIAbCard *card, PRBool notify);
|
||||
NS_IMETHOD DeleteCard(nsIAbCard *newCard, PRBool notify, nsIAbDirectory *parent);
|
||||
NS_IMETHOD EditCard(nsIAbCard *card, PRBool notify, nsIAbDirectory *parent);
|
||||
NS_IMETHOD ContainsCard(nsIAbCard *card, PRBool *hasCard);
|
||||
NS_IMETHOD DeleteMailList(nsIAbDirectory *mailList, PRBool notify);
|
||||
NS_IMETHOD EditMailList(nsIAbDirectory *mailList, nsIAbCard *listCard, PRBool notify);
|
||||
|
@ -304,7 +304,7 @@ public:
|
|||
PRUint32 GetListAddressTotal(nsIMdbRow* listRow);
|
||||
nsresult GetAddressRowByPos(nsIMdbRow* listRow, PRUint16 pos, nsIMdbRow** cardRow);
|
||||
|
||||
NS_IMETHOD AddListCardColumnsToRow(nsIAbCard *aPCard, nsIMdbRow *aPListRow, PRUint32 aPos, nsIAbCard** aPNewCard, PRBool aInMailingList);
|
||||
NS_IMETHOD AddListCardColumnsToRow(nsIAbCard *aPCard, nsIMdbRow *aPListRow, PRUint32 aPos, nsIAbCard** aPNewCard, PRBool aInMailingList, nsIAbDirectory *parent);
|
||||
NS_IMETHOD InitCardFromRow(nsIAbCard *aNewCard, nsIMdbRow* aCardRow);
|
||||
NS_IMETHOD SetListAddressTotal(nsIMdbRow* aListRow, PRUint32 aTotal);
|
||||
NS_IMETHOD FindRowByCard(nsIAbCard * card,nsIMdbRow **aRow);
|
||||
|
@ -332,7 +332,7 @@ protected:
|
|||
nsresult GetListFromDB(nsIAbDirectory *newCard, nsIMdbRow* listRow);
|
||||
nsresult AddRecordKeyColumnToRow(nsIMdbRow *pRow);
|
||||
nsresult AddAttributeColumnsToRow(nsIAbCard *card, nsIMdbRow *cardRow);
|
||||
nsresult AddListAttributeColumnsToRow(nsIAbDirectory *list, nsIMdbRow *listRow);
|
||||
nsresult AddListAttributeColumnsToRow(nsIAbDirectory *list, nsIMdbRow *listRow, nsIAbDirectory *parent);
|
||||
nsresult CreateCard(nsIMdbRow* cardRow, mdb_id listRowID, nsIAbCard **result);
|
||||
nsresult CreateCardFromDeletedCardsTable(nsIMdbRow* cardRow, mdb_id listRowID, nsIAbCard **result);
|
||||
nsresult DeleteCardFromListRow(nsIMdbRow* pListRow, mdb_id cardRowID);
|
||||
|
|
|
@ -4576,7 +4576,8 @@ nsMsgCompose::CheckAndPopulateRecipients(PRBool aPopulateMailList,
|
|||
if (NS_SUCCEEDED(existingCard->GetPopularityIndex(&popularityIndex)))
|
||||
{
|
||||
existingCard->SetPopularityIndex(++popularityIndex);
|
||||
abDataBase->EditCard(existingCard, PR_FALSE);
|
||||
// Since we are not notifying anyway, send null
|
||||
abDataBase->EditCard(existingCard, PR_FALSE, nsnull);
|
||||
dirtyABDatabase = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -656,7 +656,7 @@ PRBool nsAbPalmHotSync::CardExistsInPalmList(nsAbIPCCard * aIPCCard)
|
|||
if(!aIPCCard->GetRecordId())
|
||||
{
|
||||
ConvertAssignPalmIDAttrib(palmRec->dwRecordId, aIPCCard);
|
||||
mABDB->EditCard(aIPCCard, PR_FALSE);
|
||||
mABDB->EditCard(aIPCCard, PR_FALSE, nsnull);
|
||||
aIPCCard->SetRecordId(palmRec->dwRecordId);
|
||||
}
|
||||
|
||||
|
@ -837,7 +837,7 @@ nsresult nsAbPalmHotSync::UpdateMozABWithPalmRecords()
|
|||
// Archived is the same as deleted in palm.
|
||||
if(palmRec->dwStatus & ATTR_DELETED || palmRec->dwStatus & ATTR_ARCHIVED)
|
||||
{
|
||||
mABDB->DeleteCard(existingCard, PR_FALSE);
|
||||
mABDB->DeleteCard(existingCard, PR_FALSE, nsnull);
|
||||
continue;
|
||||
}
|
||||
if(palmRec->dwStatus & ATTR_NEW)
|
||||
|
@ -851,7 +851,7 @@ nsresult nsAbPalmHotSync::UpdateMozABWithPalmRecords()
|
|||
else
|
||||
{
|
||||
existingCard->Copy(&ipcCard);
|
||||
rv = mABDB->EditCard(existingCard, PR_FALSE);
|
||||
rv = mABDB->EditCard(existingCard, PR_FALSE, nsnull);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -879,7 +879,7 @@ nsresult nsAbPalmHotSync::UpdateMozABWithPalmRecords()
|
|||
PRUint32 modTimeInSec;
|
||||
PRTime2Seconds(PR_Now(), &modTimeInSec);
|
||||
ipcCard.SetLastModifiedDate(modTimeInSec);
|
||||
rv = mABDB->CreateNewCardAndAddToDB(newCard, PR_FALSE);
|
||||
rv = mABDB->CreateNewCardAndAddToDB(newCard, PR_FALSE, nsnull);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
// now set the attribute for the PalmRecID in the card in the DB
|
||||
|
@ -887,7 +887,7 @@ nsresult nsAbPalmHotSync::UpdateMozABWithPalmRecords()
|
|||
dbCard->SetStringAttribute(CARD_ATTRIB_PALMID, NS_ConvertASCIItoUTF16(recordIDBuf).get());
|
||||
newCard = do_QueryInterface(dbCard, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
rv = mABDB->EditCard(newCard, PR_FALSE);
|
||||
rv = mABDB->EditCard(newCard, PR_FALSE, nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -915,7 +915,7 @@ nsresult nsAbPalmHotSync::Done(PRBool aSuccess, PRInt32 aPalmCatIndex, PRUint32
|
|||
nsCOMPtr<nsIAbCard> newCard;
|
||||
newCard = do_QueryInterface(dbCard, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
mABDB->EditCard(newCard, PR_FALSE);
|
||||
mABDB->EditCard(newCard, PR_FALSE, nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,7 +239,7 @@ nsresult nsOEAddressIterator::EnumList( const PRUnichar * pName, LPENTRYID pEid,
|
|||
m_database->InitCardFromRow(userCard,cardRow);
|
||||
|
||||
m_database->AddListCardColumnsToRow(userCard, listRow, ++numListElems,
|
||||
getter_AddRefs(newCard),PR_TRUE);
|
||||
getter_AddRefs(newCard),PR_TRUE, nsnull);
|
||||
}
|
||||
m_pWab->FreeProperty( pProp);
|
||||
m_pWab->ReleaseUser( pUser);
|
||||
|
|
|
@ -1090,7 +1090,7 @@ nsresult nsOutlookMail::CreateList( const PRUnichar * pName,
|
|||
//add card list
|
||||
pDb->AddListCardColumnsToRow(userCard,
|
||||
newListRow,idx+1,
|
||||
getter_AddRefs(newCard),PR_TRUE);
|
||||
getter_AddRefs(newCard),PR_TRUE, nsnull);
|
||||
|
||||
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче