Index: mailnews/addrbook/public/nsIAddrDatabase.idl =================================================================== RCS file: /cvsroot/mozilla/mailnews/addrbook/public/nsIAddrDatabase.idl,v --- mailnews/addrbook/public/nsIAddrDatabase.idl 1.28.2.2 +++ mailnews/addrbook/public/nsIAddrDatabase.idl @@ -205,0 +205,6 @@ + [noscript] nsIAbCard AddListCardColumnsToRow(in nsIAbCard pCard, in nsIMdbRow pListRow, in PRUint32 pos); + [noscript] void GetCardFromDB(in nsIAbCard newCard, in nsIMdbRow cardRow); + [noscript] void CreateABList(in nsIMdbRow listRow,out nsIAbDirectory result); + [noscript] void SetListAddressTotal(in nsIMdbRow listRow, in PRUint32 total); + [noscript] boolean FindRow(in nsIAbCard card, out nsIMdbRow oldRow); + Index: mailnews/addrbook/src/nsAddrDatabase.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/addrbook/src/nsAddrDatabase.cpp,v --- mailnews/addrbook/src/nsAddrDatabase.cpp 1.96.2.2 +++ mailnews/addrbook/src/nsAddrDatabase.cpp @@ -1381,1 +1381,1 @@ -nsresult nsAddrDatabase::AddListCardColumnsToRow --- +NS_IMETHODIMP nsAddrDatabase::AddListCardColumnsToRow @@ -1386,0 +1386,4 @@ + + //PRUint32 total=GetListAddressTotal(pListRow)+1; + //SetListAddressTotal(pListRow,total); + @@ -1529,1 +1533,1 @@ -nsresult nsAddrDatabase::SetListAddressTotal(nsIMdbRow* listRow, PRUint32 total) --- +NS_IMETHODIMP nsAddrDatabase::SetListAddressTotal(nsIMdbRow* listRow, PRUint32 total) @@ -1534,1 +1538,12 @@ - --- +NS_IMETHODIMP nsAddrDatabase::FindRow(nsIAbCard * card, nsIMdbRow * *oldRow, PRBool *_retval) +{ + PRUnichar *aPrimaryEmail; + card->GetPrimaryEmail(&aPrimaryEmail); + nsresult hr=GetRowForCharColumn (aPrimaryEmail,m_PriEmailColumnToken,PR_FALSE,oldRow); + + if (NS_SUCCEEDED(hr)) + { + *_retval=PR_TRUE; + } + return hr; +} @@ -2295,1 +2310,1 @@ -nsresult nsAddrDatabase::GetCardFromDB(nsIAbCard *newCard, nsIMdbRow* cardRow) --- +NS_IMETHODIMP nsAddrDatabase::GetCardFromDB(nsIAbCard *newCard, nsIMdbRow* cardRow) @@ -3017,1 +3032,1 @@ -nsresult nsAddrDatabase::CreateABList(nsIMdbRow* listRow, nsIAbDirectory **result) --- +NS_IMETHODIMP nsAddrDatabase::CreateABList(nsIMdbRow* listRow, nsIAbDirectory **result) Index: mailnews/addrbook/src/nsAddrDatabase.h =================================================================== RCS file: /cvsroot/mozilla/mailnews/addrbook/src/nsAddrDatabase.h,v --- mailnews/addrbook/src/nsAddrDatabase.h 1.35.16.1 +++ mailnews/addrbook/src/nsAddrDatabase.h @@ -254,1 +254,1 @@ - nsresult CreateABList(nsIMdbRow* listRow, nsIAbDirectory **result); --- + NS_IMETHOD CreateABList(nsIMdbRow* listRow, nsIAbDirectory **result); @@ -265,0 +265,7 @@ + NS_IMETHOD AddListCardColumnsToRow(nsIAbCard *pCard, nsIMdbRow *pListRow, PRUint32 pos, nsIAbCard** pNewCard); + NS_IMETHOD GetCardFromDB(nsIAbCard *newCard, nsIMdbRow* cardRow); + NS_IMETHOD SetListAddressTotal(nsIMdbRow* listRow, PRUint32 total); + + NS_IMETHOD FindRow(nsIAbCard * card, nsIMdbRow * *oldRow, PRBool *_retval); + + @@ -284,1 +291,0 @@ - nsresult AddIntColumn(nsIMdbRow* cardRow, mdb_column inColumn, PRUint32 nValue); @@ -290,1 +296,0 @@ - nsresult GetCardFromDB(nsIAbCard *newCard, nsIMdbRow* cardRow); @@ -295,1 +300,0 @@ - nsresult AddListCardColumnsToRow(nsIAbCard *pCard, nsIMdbRow *pListRow, PRUint32 pos, nsIAbCard** pNewCard); @@ -299,1 +303,0 @@ - nsresult SetListAddressTotal(nsIMdbRow* listRow, PRUint32 total); @@ -303,1 +306,1 @@ - --- + nsresult AddIntColumn(nsIMdbRow* cardRow, mdb_column inColumn, PRUint32 nValue); Index: mailnews/import/outlook/src/MapiApi.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/import/outlook/src/MapiApi.cpp,v --- mailnews/import/outlook/src/MapiApi.cpp 1.23.8.1 +++ mailnews/import/outlook/src/MapiApi.cpp @@ -508,1 +508,1 @@ - hr = lpMdb->OpenEntry( cbEntry, --- + hr = m_lpSession->OpenEntry( cbEntry, Index: mailnews/import/outlook/src/nsOutlookMail.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/import/outlook/src/nsOutlookMail.cpp,v --- mailnews/import/outlook/src/nsOutlookMail.cpp 1.26.2.1 +++ mailnews/import/outlook/src/nsOutlookMail.cpp @@ -57,0 +57,1 @@ +#include "nsAddrDatabase.h" @@ -62,0 +63,2 @@ +#include "prprf.h" + @@ -946,1 +949,1 @@ - CreateList(subject.get(), pDb); --- + CreateList(subject.get(), pDb, lpMsg, pFieldMap); @@ -948,0 +951,1 @@ + @@ -959,1 +963,23 @@ -nsresult nsOutlookMail::CreateList( const PRUnichar * pName, nsIAddrDatabase *pDb) --- +void GetIntYarn(PRUint32 nValue, struct mdbYarn* intYarn) +{ + intYarn->mYarn_Size = sizeof(intYarn->mYarn_Buf); + intYarn->mYarn_Fill = intYarn->mYarn_Size; + intYarn->mYarn_Form = 0; + intYarn->mYarn_Grow = nsnull; + + PR_snprintf((char*)intYarn->mYarn_Buf, intYarn->mYarn_Size, "%lx", nValue); + intYarn->mYarn_Fill = PL_strlen((const char *) intYarn->mYarn_Buf); +} +nsresult AddIntColumn(nsAddrDatabase*pDb,nsIMdbRow* cardRow, mdb_column inColumn, PRUint32 nValue) +{ + struct mdbYarn yarn; + char yarnBuf[100]; + + yarn.mYarn_Buf = (void *) yarnBuf; + GetIntYarn(nValue, &yarn); + mdb_err err = cardRow->AddColumn(pDb->GetEnv(), inColumn, &yarn); + + return (err == NS_OK) ? NS_OK : NS_ERROR_FAILURE; +} + +nsresult nsOutlookMail::CreateList( const PRUnichar * pName, nsIAddrDatabase *pDb, LPMAPIPROP pUserList, nsIImportFieldMap *pFieldMap) @@ -970,2 +996,2 @@ - nsCOMPtr newRow; - rv = pDb->GetNewListRow(getter_AddRefs(newRow)); --- + nsCOMPtr newListRow; + rv = pDb->GetNewListRow(getter_AddRefs(newListRow)); @@ -973,1 +999,0 @@ - @@ -976,1 +1001,1 @@ - rv = pDb->AddListName(newRow, column.get()); --- + rv = pDb->AddListName(newListRow, column.get()); @@ -978,1 +1003,86 @@ - rv = pDb->AddCardRowToDB(newRow); --- +//need AddListCardColumnsToRow + + HRESULT hr; + LPSPropValue aValue = NULL ; + ULONG aValueCount = 0 ; + + LPSPropTagArray properties = NULL ; + m_mapi.MAPIAllocateBuffer(CbNewSPropTagArray(1), + (void **)&properties) ; + properties->cValues = 1 ; + properties->aulPropTag [0] = m_mapi.GetEmailPropertyTag(pUserList,0x8054);//PR_CONTACT_ENTRYIDS; + hr = pUserList->GetProps(properties, 0, &aValueCount, &aValue) ; + + SBinaryArray *sa=(SBinaryArray *)&aValue->Value.bin; + //LPSPropTagArray dists=(LPSPropTagArray)&aValue->Value.bin.lpb; + + LPENTRYID lpEid; + ULONG cbEid; + PRInt32 idx; + LPMESSAGE lpMsg; + nsCString type; + LPSPropValue pVal; + nsString subject; + ULONG ulObjType; + PRUint32 total; + + + total=sa->cValues; + for (idx=0;idxcValues ;idx++) + { + lpEid= (LPENTRYID) sa->lpbin[idx].lpb; + cbEid = sa->lpbin[idx].cb; + //GetMAPIProperties(cbEID,lpEID); + + + if (!m_mapi.OpenEntry(cbEid, lpEid, (LPUNKNOWN *) &lpMsg)) + { + + IMPORT_LOG1( "*** Error opening messages in mailbox: %S\n", pName); + return( NS_ERROR_FAILURE); + } + { + { + // This is a contact, add it to the address book! + subject.Truncate( 0); + pVal = m_mapi.GetMapiProperty( lpMsg, PR_SUBJECT); + if (pVal) + m_mapi.GetStringFromProp( pVal, subject); + + nsIMdbRow* newRow = nsnull; + nsIMdbRow* oldRow = nsnull; + pDb->GetNewRow( &newRow); + if (newRow) { + if (BuildCard( subject.get(), pDb, newRow, lpMsg, pFieldMap)) + { + nsCOMPtr userCard; + nsCOMPtr newCard; + userCard = do_CreateInstance(NS_ABMDBCARD_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv,rv); + pDb->GetCardFromDB(userCard,newRow); + + //add card to db + PRBool bl=PR_FALSE; + pDb->FindRow(userCard,&oldRow,&bl); + if (!bl) + pDb->AddCardRowToDB( newRow); + else + { + NS_RELEASE(newRow); + newRow = oldRow; + } + + //add card to list + + pDb->AddListCardColumnsToRow(userCard,newListRow,idx+1,getter_AddRefs(newCard)); + + NS_RELEASE(newRow); + } + } + + + } + } + } + + rv = pDb->AddCardRowToDB(newListRow); @@ -980,1 +1090,4 @@ - rv = pDb->AddListDirNode(newRow); --- + + rv = pDb->SetListAddressTotal(newListRow, total); + + rv = pDb->AddListDirNode(newListRow); Index: mailnews/import/outlook/src/nsOutlookMail.h =================================================================== RCS file: /cvsroot/mozilla/mailnews/import/outlook/src/nsOutlookMail.h,v --- mailnews/import/outlook/src/nsOutlookMail.h 1.10.2.1 +++ mailnews/import/outlook/src/nsOutlookMail.h @@ -81,1 +81,1 @@ - nsresult CreateList( const PRUnichar * pName, nsIAddrDatabase *pDb); --- + nsresult CreateList( const PRUnichar * pName, nsIAddrDatabase *pDb, LPMAPIPROP pUserList, nsIImportFieldMap *pFieldMap);