зеркало из https://github.com/mozilla/pjs.git
fix problem importing mailing lists from outlook, patch by wind.li@sun.com, r=me, sr=mscott 149961
This commit is contained in:
Родитель
f4cc4a66e9
Коммит
f051a570f3
|
@ -257,4 +257,14 @@ interface nsIAddrDatabase : nsIAddrDBAnnouncer {
|
||||||
* The column value (example: jabroni316)
|
* The column value (example: jabroni316)
|
||||||
*/
|
*/
|
||||||
[noscript] void addRowValue(in nsIMdbRow aRow, in ACString aLDIFAttributeName, in AString aColValue);
|
[noscript] void addRowValue(in nsIMdbRow aRow, in ACString aLDIFAttributeName, in AString aColValue);
|
||||||
|
|
||||||
|
void AddListCardColumnsToRow(in nsIAbCard aPCard,
|
||||||
|
in nsIMdbRow aPListRow,
|
||||||
|
in unsigned long aPos,
|
||||||
|
out nsIAbCard aPNewCard,
|
||||||
|
in boolean aInMailingList);
|
||||||
|
void InitCardFromRow(in nsIAbCard aNewCard,in nsIMdbRow aCardRow);
|
||||||
|
void SetListAddressTotal(in nsIMdbRow aListRow, in PRUint32 aTotal);
|
||||||
|
nsIMdbRow FindRowByCard(in nsIAbCard aCard);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1618,7 +1618,7 @@ NS_IMETHODIMP nsAddrDatabase::CreateNewListCardAndAddToDB(nsIAbDirectory *aList,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsAddrDatabase::AddListCardColumnsToRow
|
NS_IMETHODIMP nsAddrDatabase::AddListCardColumnsToRow
|
||||||
(nsIAbCard *pCard, nsIMdbRow *pListRow, PRUint32 pos, nsIAbCard** pNewCard, PRBool aInMailingList)
|
(nsIAbCard *pCard, nsIMdbRow *pListRow, PRUint32 pos, nsIAbCard** pNewCard, PRBool aInMailingList)
|
||||||
{
|
{
|
||||||
if (!pCard && !pListRow )
|
if (!pCard && !pListRow )
|
||||||
|
@ -1782,11 +1782,17 @@ PRUint32 nsAddrDatabase::GetListAddressTotal(nsIMdbRow* listRow)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsAddrDatabase::SetListAddressTotal(nsIMdbRow* listRow, PRUint32 total)
|
NS_IMETHODIMP nsAddrDatabase::SetListAddressTotal(nsIMdbRow* aListRow, PRUint32 aTotal)
|
||||||
{
|
{
|
||||||
return AddIntColumn(listRow, m_ListTotalColumnToken, total);
|
return AddIntColumn(aListRow, m_ListTotalColumnToken, aTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsAddrDatabase::FindRowByCard(nsIAbCard * aCard,nsIMdbRow **aRow)
|
||||||
|
{
|
||||||
|
nsXPIDLString primaryEmail;
|
||||||
|
aCard->GetPrimaryEmail(getter_Copies(primaryEmail));
|
||||||
|
return GetRowForCharColumn(primaryEmail, m_PriEmailColumnToken, PR_TRUE, aRow);
|
||||||
|
}
|
||||||
|
|
||||||
nsresult nsAddrDatabase::GetAddressRowByPos(nsIMdbRow* listRow, PRUint16 pos, nsIMdbRow** cardRow)
|
nsresult nsAddrDatabase::GetAddressRowByPos(nsIMdbRow* listRow, PRUint16 pos, nsIMdbRow** cardRow)
|
||||||
{
|
{
|
||||||
|
@ -2607,7 +2613,7 @@ nsresult nsAddrDatabase::AddLowercaseColumn
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsAddrDatabase::GetCardFromDB(nsIAbCard *newCard, nsIMdbRow* cardRow)
|
NS_IMETHODIMP nsAddrDatabase::InitCardFromRow(nsIAbCard *newCard, nsIMdbRow* cardRow)
|
||||||
{
|
{
|
||||||
nsresult err = NS_OK;
|
nsresult err = NS_OK;
|
||||||
if (!newCard || !cardRow)
|
if (!newCard || !cardRow)
|
||||||
|
@ -3348,7 +3354,7 @@ nsresult nsAddrDatabase::CreateCardFromDeletedCardsTable(nsIMdbRow* cardRow, mdb
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv) && dbpersonCard)
|
if (NS_SUCCEEDED(rv) && dbpersonCard)
|
||||||
{
|
{
|
||||||
GetCardFromDB(personCard, cardRow);
|
InitCardFromRow(personCard, cardRow);
|
||||||
mdbOid tableOid;
|
mdbOid tableOid;
|
||||||
m_mdbDeletedCardsTable->GetOid(GetEnv(), &tableOid);
|
m_mdbDeletedCardsTable->GetOid(GetEnv(), &tableOid);
|
||||||
|
|
||||||
|
@ -3383,7 +3389,7 @@ nsresult nsAddrDatabase::CreateCard(nsIMdbRow* cardRow, mdb_id listRowID, nsIAbC
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv) && dbpersonCard)
|
if (NS_SUCCEEDED(rv) && dbpersonCard)
|
||||||
{
|
{
|
||||||
GetCardFromDB(personCard, cardRow);
|
InitCardFromRow(personCard, cardRow);
|
||||||
mdbOid tableOid;
|
mdbOid tableOid;
|
||||||
m_mdbPabTable->GetOid(GetEnv(), &tableOid);
|
m_mdbPabTable->GetOid(GetEnv(), &tableOid);
|
||||||
|
|
||||||
|
|
|
@ -322,6 +322,12 @@ public:
|
||||||
|
|
||||||
static void PRTime2Seconds(PRTime prTime, PRUint32 *seconds);
|
static void PRTime2Seconds(PRTime prTime, PRUint32 *seconds);
|
||||||
|
|
||||||
|
|
||||||
|
NS_IMETHOD AddListCardColumnsToRow(nsIAbCard *aPCard, nsIMdbRow *aPListRow, PRUint32 aPos, nsIAbCard** aPNewCard, PRBool aInMailingList);
|
||||||
|
NS_IMETHOD InitCardFromRow(nsIAbCard *aNewCard, nsIMdbRow* aCardRow);
|
||||||
|
NS_IMETHOD SetListAddressTotal(nsIMdbRow* aListRow, PRUint32 aTotal);
|
||||||
|
NS_IMETHOD FindRowByCard(nsIAbCard * card,nsIMdbRow **aRow);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static void AddToCache(nsAddrDatabase* pAddrDB) {GetDBCache()->AppendElement(pAddrDB);}
|
static void AddToCache(nsAddrDatabase* pAddrDB) {GetDBCache()->AppendElement(pAddrDB);}
|
||||||
|
@ -346,16 +352,13 @@ protected:
|
||||||
nsresult GetIntColumn(nsIMdbRow *cardRow, mdb_token outToken,
|
nsresult GetIntColumn(nsIMdbRow *cardRow, mdb_token outToken,
|
||||||
PRUint32* pValue, PRUint32 defaultValue);
|
PRUint32* pValue, PRUint32 defaultValue);
|
||||||
nsresult GetBoolColumn(nsIMdbRow *cardRow, mdb_token outToken, PRBool* pValue);
|
nsresult GetBoolColumn(nsIMdbRow *cardRow, mdb_token outToken, PRBool* pValue);
|
||||||
nsresult GetCardFromDB(nsIAbCard *newCard, nsIMdbRow* cardRow);
|
|
||||||
nsresult GetListCardFromDB(nsIAbCard *listCard, nsIMdbRow* listRow);
|
nsresult GetListCardFromDB(nsIAbCard *listCard, nsIMdbRow* listRow);
|
||||||
nsresult GetListFromDB(nsIAbDirectory *newCard, nsIMdbRow* listRow);
|
nsresult GetListFromDB(nsIAbDirectory *newCard, nsIMdbRow* listRow);
|
||||||
nsresult AddRecordKeyColumnToRow(nsIMdbRow *pRow);
|
nsresult AddRecordKeyColumnToRow(nsIMdbRow *pRow);
|
||||||
nsresult AddAttributeColumnsToRow(nsIAbCard *card, nsIMdbRow *cardRow);
|
nsresult AddAttributeColumnsToRow(nsIAbCard *card, nsIMdbRow *cardRow);
|
||||||
nsresult AddListCardColumnsToRow(nsIAbCard *pCard, nsIMdbRow *pListRow, PRUint32 pos, nsIAbCard** pNewCard, PRBool aInMailingList);
|
|
||||||
nsresult AddListAttributeColumnsToRow(nsIAbDirectory *list, nsIMdbRow *listRow);
|
nsresult AddListAttributeColumnsToRow(nsIAbDirectory *list, nsIMdbRow *listRow);
|
||||||
nsresult CreateCard(nsIMdbRow* cardRow, mdb_id listRowID, nsIAbCard **result);
|
nsresult CreateCard(nsIMdbRow* cardRow, mdb_id listRowID, nsIAbCard **result);
|
||||||
nsresult CreateCardFromDeletedCardsTable(nsIMdbRow* cardRow, mdb_id listRowID, nsIAbCard **result);
|
nsresult CreateCardFromDeletedCardsTable(nsIMdbRow* cardRow, mdb_id listRowID, nsIAbCard **result);
|
||||||
nsresult SetListAddressTotal(nsIMdbRow* listRow, PRUint32 total);
|
|
||||||
nsresult DeleteCardFromListRow(nsIMdbRow* pListRow, mdb_id cardRowID);
|
nsresult DeleteCardFromListRow(nsIMdbRow* pListRow, mdb_id cardRowID);
|
||||||
void DeleteCardFromAllMailLists(mdb_id cardRowID);
|
void DeleteCardFromAllMailLists(mdb_id cardRowID);
|
||||||
nsresult NotifyListEntryChange(PRUint32 abCode, nsIAbDirectory *dir, nsIAddrDBListener *instigator);
|
nsresult NotifyListEntryChange(PRUint32 abCode, nsIAbDirectory *dir, nsIAddrDBListener *instigator);
|
||||||
|
|
|
@ -505,13 +505,12 @@ BOOL CMapiApi::OpenMdbEntry( LPMDB lpMdb, ULONG cbEntry, LPENTRYID pEntryId, LPU
|
||||||
{
|
{
|
||||||
ULONG ulObjType;
|
ULONG ulObjType;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
hr = lpMdb->OpenEntry( cbEntry,
|
hr = m_lpSession->OpenEntry(cbEntry,
|
||||||
pEntryId,
|
pEntryId,
|
||||||
NULL,
|
NULL,
|
||||||
0,
|
0,
|
||||||
&ulObjType,
|
&ulObjType,
|
||||||
(LPUNKNOWN *) ppOpen);
|
(LPUNKNOWN *) ppOpen);
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
MAPI_TRACE2( "OpenMdbEntry failed: 0x%lx, %d\n", (long)hr, (int)hr);
|
MAPI_TRACE2( "OpenMdbEntry failed: 0x%lx, %d\n", (long)hr, (int)hr);
|
||||||
return( FALSE);
|
return( FALSE);
|
||||||
|
|
|
@ -1005,7 +1005,7 @@ nsresult nsOutlookMail::ImportAddresses( PRUint32 *pCount, PRUint32 *pTotal, con
|
||||||
pVal = m_mapi.GetMapiProperty( lpMsg, PR_SUBJECT);
|
pVal = m_mapi.GetMapiProperty( lpMsg, PR_SUBJECT);
|
||||||
if (pVal)
|
if (pVal)
|
||||||
m_mapi.GetStringFromProp( pVal, subject);
|
m_mapi.GetStringFromProp( pVal, subject);
|
||||||
CreateList(subject.get(), pDb);
|
CreateList(subject.get(), pDb, lpMsg, pFieldMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,8 +1017,10 @@ nsresult nsOutlookMail::ImportAddresses( PRUint32 *pCount, PRUint32 *pTotal, con
|
||||||
rv = pDb->Commit(nsAddrDBCommitType::kLargeCommit);
|
rv = pDb->Commit(nsAddrDBCommitType::kLargeCommit);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
nsresult nsOutlookMail::CreateList( const PRUnichar * pName,
|
||||||
nsresult nsOutlookMail::CreateList( const PRUnichar * pName, nsIAddrDatabase *pDb)
|
nsIAddrDatabase *pDb,
|
||||||
|
LPMAPIPROP pUserList,
|
||||||
|
nsIImportFieldMap *pFieldMap)
|
||||||
{
|
{
|
||||||
// If no name provided then we're done.
|
// If no name provided then we're done.
|
||||||
if (!pName || !(*pName))
|
if (!pName || !(*pName))
|
||||||
|
@ -1029,18 +1031,105 @@ nsresult nsOutlookMail::CreateList( const PRUnichar * pName, nsIAddrDatabase *pD
|
||||||
if (!pDb)
|
if (!pDb)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
nsCOMPtr <nsIMdbRow> newRow;
|
nsCOMPtr <nsIMdbRow> newListRow;
|
||||||
rv = pDb->GetNewListRow(getter_AddRefs(newRow));
|
rv = pDb->GetNewListRow(getter_AddRefs(newListRow));
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
nsCAutoString column;
|
||||||
|
column.AssignWithConversion(pName);
|
||||||
|
rv = pDb->AddListName(newListRow, column.get());
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = pDb->AddListName(newRow, NS_ConvertUCS2toUTF8(pName).get());
|
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);
|
||||||
|
hr = pUserList->GetProps(properties, 0, &aValueCount, &aValue) ;
|
||||||
|
|
||||||
|
SBinaryArray *sa=(SBinaryArray *)&aValue->Value.bin;
|
||||||
|
|
||||||
|
LPENTRYID lpEid;
|
||||||
|
ULONG cbEid;
|
||||||
|
PRInt32 idx;
|
||||||
|
LPMESSAGE lpMsg;
|
||||||
|
nsCString type;
|
||||||
|
LPSPropValue pVal;
|
||||||
|
nsString subject;
|
||||||
|
PRUint32 total;
|
||||||
|
|
||||||
|
|
||||||
|
total=sa->cValues;
|
||||||
|
for (idx=0;idx<sa->cValues ;idx++)
|
||||||
|
{
|
||||||
|
lpEid= (LPENTRYID) sa->lpbin[idx].lpb;
|
||||||
|
cbEid = sa->lpbin[idx].cb;
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
nsCOMPtr <nsIMdbRow> newRow;
|
||||||
|
nsCOMPtr <nsIMdbRow> oldRow;
|
||||||
|
pDb->GetNewRow( getter_AddRefs(newRow));
|
||||||
|
if (newRow) {
|
||||||
|
if (BuildCard( subject.get(), pDb, newRow, lpMsg, pFieldMap))
|
||||||
|
{
|
||||||
|
nsCOMPtr <nsIAbCard> userCard;
|
||||||
|
nsCOMPtr <nsIAbCard> newCard;
|
||||||
|
userCard = do_CreateInstance(NS_ABMDBCARD_CONTRACTID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = pDb->AddCardRowToDB(newRow);
|
pDb->InitCardFromRow(userCard,newRow);
|
||||||
|
|
||||||
|
//add card to db
|
||||||
|
PRBool bl=PR_FALSE;
|
||||||
|
pDb->FindRowByCard(userCard,getter_AddRefs(oldRow));
|
||||||
|
if (oldRow)
|
||||||
|
{
|
||||||
|
newRow = oldRow;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pDb->AddCardRowToDB( newRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
//add card list
|
||||||
|
pDb->AddListCardColumnsToRow(userCard,
|
||||||
|
newListRow,idx+1,
|
||||||
|
getter_AddRefs(newCard),PR_TRUE);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = pDb->AddCardRowToDB(newListRow);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = pDb->AddListDirNode(newRow);
|
|
||||||
|
rv = pDb->SetListAddressTotal(newListRow, total);
|
||||||
|
rv = pDb->AddListDirNode(newListRow);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void nsOutlookMail::SanitizeValue( nsString& val)
|
void nsOutlookMail::SanitizeValue( nsString& val)
|
||||||
{
|
{
|
||||||
val.ReplaceSubstring(NS_LITERAL_STRING("\x0D\x0A").get(),
|
val.ReplaceSubstring(NS_LITERAL_STRING("\x0D\x0A").get(),
|
||||||
|
|
|
@ -78,7 +78,7 @@ private:
|
||||||
void SanitizeValue( nsString& val);
|
void SanitizeValue( nsString& val);
|
||||||
void SplitString( nsString& val1, nsString& val2);
|
void SplitString( nsString& val1, nsString& val2);
|
||||||
PRBool BuildCard( const PRUnichar *pName, nsIAddrDatabase *pDb, nsIMdbRow *newRow, LPMAPIPROP pUser, nsIImportFieldMap *pFieldMap);
|
PRBool BuildCard( const PRUnichar *pName, nsIAddrDatabase *pDb, nsIMdbRow *newRow, LPMAPIPROP pUser, nsIImportFieldMap *pFieldMap);
|
||||||
nsresult CreateList( const PRUnichar * pName, nsIAddrDatabase *pDb);
|
nsresult CreateList( const PRUnichar * pName, nsIAddrDatabase *pDb, LPMAPIPROP pUserList, nsIImportFieldMap *pFieldMap);
|
||||||
void SetDefaultContentType(CMapiMessage &msg, nsCString &cType);
|
void SetDefaultContentType(CMapiMessage &msg, nsCString &cType);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче