LPSPropValue CMapiApi::GetMapiProperty( LPMAPIPROP pProp, ULONG tag) { if (!pProp) return( NULL); int sz = CbNewSPropTagArray( 1); SPropTagArray *pTag = (SPropTagArray *) new char[sz]; pTag->cValues = 1; pTag->aulPropTag[0] = tag; LPSPropValue lpProp = NULL; ULONG cValues = 0; HRESULT hr = pProp->GetProps( pTag, 0, &cValues, &lpProp); delete [] pTag; if (HR_FAILED( hr) || (cValues != 1)) { if (lpProp) MAPIFreeBuffer( lpProp); return( NULL); } else { if (PROP_TYPE( lpProp->ulPropTag) == PT_ERROR) { if (lpProp->Value.l == MAPI_E_NOT_FOUND) { MAPIFreeBuffer( lpProp); lpProp = NULL; } } } return( lpProp); }
HRESULT MailboxDataCollector::GetRequiredPropTags(LPMAPIPROP lpProp, LPSPropTagArray *lppPropTagArray) const { HRESULT hr = hrSuccess; SPropTagArrayPtr ptrPropTagArray; PROPMAP_START PROPMAP_NAMED_ID(STORE_ENTRYIDS, PT_MV_BINARY, PSETID_Archive, "store-entryids") PROPMAP_NAMED_ID(ITEM_ENTRYIDS, PT_MV_BINARY, PSETID_Archive, "item-entryids") PROPMAP_INIT(lpProp); hr = MAPIAllocateBuffer(CbNewSPropTagArray(4), &ptrPropTagArray); if (hr != hrSuccess) goto exit; ptrPropTagArray->cValues = 4; ptrPropTagArray->aulPropTag[0] = PR_ENTRYID; ptrPropTagArray->aulPropTag[1] = PR_MAILBOX_OWNER_ENTRYID; ptrPropTagArray->aulPropTag[2] = PROP_STORE_ENTRYIDS; ptrPropTagArray->aulPropTag[3] = PROP_ITEM_ENTRYIDS; *lppPropTagArray = ptrPropTagArray.release(); exit: return hr; }
void CTagArrayEditor::WriteListToTagArray(ULONG ulListNum) { if (!IsValidList(ulListNum)) return; // If we're not dirty, don't write if (!IsDirty(ulListNum)) return; HRESULT hRes = S_OK; ULONG ulListCount = GetListCount(ulListNum); EC_H(MAPIAllocateBuffer( CbNewSPropTagArray(ulListCount), (LPVOID*)&m_lpOutputTagArray)); if (m_lpOutputTagArray) { m_lpOutputTagArray->cValues = ulListCount; ULONG iTagCount = 0; for (iTagCount = 0; iTagCount < m_lpOutputTagArray->cValues; iTagCount++) { SortListData* lpData = GetListRowData(ulListNum, iTagCount); if (lpData) m_lpOutputTagArray->aulPropTag[iTagCount] = lpData->data.Tag.ulPropTag; } } } // CTagArrayEditor::WriteListToTagArray
LPSPropValue CWAB::GetUserProperty( LPMAILUSER pUser, ULONG tag) { if (!pUser) return( NULL); ULONG uTag = tag; /* Getting Unicode does not help with getting the right international charset. Windoze bloze. */ /* if (PROP_TYPE( uTag) == PT_STRING8) { uTag = CHANGE_PROP_TYPE( tag, PT_UNICODE); } */ int sz = CbNewSPropTagArray( 1); SPropTagArray *pTag = (SPropTagArray *) new char[sz]; pTag->cValues = 1; pTag->aulPropTag[0] = uTag; LPSPropValue lpProp = NULL; ULONG cValues = 0; HRESULT hr = pUser->GetProps( pTag, 0, &cValues, &lpProp); if (HR_FAILED( hr) || (cValues != 1)) { if (lpProp) m_lpWABObject->FreeBuffer( lpProp); lpProp = NULL; if (uTag != tag) { pTag->cValues = 1; pTag->aulPropTag[0] = tag; cValues = 0; hr = pUser->GetProps( pTag, 0, &cValues, &lpProp); if (HR_FAILED( hr) || (cValues != 1)) { if (lpProp) m_lpWABObject->FreeBuffer( lpProp); lpProp = NULL; } } } delete [] pTag; return( lpProp); }
LPSPropValue CWAB::GetListProperty( LPDISTLIST pUser, ULONG tag) { if (!pUser) return( NULL); int sz = CbNewSPropTagArray( 1); SPropTagArray *pTag = (SPropTagArray *) new char[sz]; pTag->cValues = 1; pTag->aulPropTag[0] = tag; LPSPropValue lpProp = NULL; ULONG cValues = 0; HRESULT hr = pUser->GetProps( pTag, 0, &cValues, &lpProp); delete [] pTag; if (HR_FAILED( hr) || (cValues != 1)) { if (lpProp) m_lpWABObject->FreeBuffer( lpProp); return( NULL); } return( lpProp); }
nsresult nsOutlookMail::CreateList(const PRUnichar * pName, nsIAddrDatabase *pDb, LPMAPIPROP pUserList, nsIImportFieldMap *pFieldMap) { // If no name provided then we're done. if (!pName || !(*pName)) return NS_OK; nsresult rv = NS_ERROR_FAILURE; // Make sure we have db to work with. if (!pDb) return rv; nsCOMPtr <nsIMdbRow> newListRow; rv = pDb->GetNewListRow(getter_AddRefs(newListRow)); NS_ENSURE_SUCCESS(rv, rv); nsAutoCString column; LossyCopyUTF16toASCII(nsDependentString(pName), column); rv = pDb->AddListName(newListRow, column.get()); NS_ENSURE_SUCCESS(rv, rv); HRESULT hr; LPSPropValue value = NULL; ULONG valueCount = 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, &valueCount, &value); m_mapi.MAPIFreeBuffer(properties); if (HR_FAILED(hr)) return NS_ERROR_FAILURE; if (!value) return NS_ERROR_NOT_AVAILABLE; // XXX from here out, value must be freed with MAPIFreeBuffer SBinaryArray *sa=(SBinaryArray *)&value->Value.bin; if (!sa || !sa->lpbin) { m_mapi.MAPIFreeBuffer(value); return NS_ERROR_NULL_POINTER; } LPENTRYID lpEid; ULONG cbEid; int32_t idx; LPMESSAGE lpMsg; nsCString type; LPSPropValue pVal; nsString subject; uint32_t 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); m_mapi.MAPIFreeBuffer(value); return NS_ERROR_FAILURE; } // This is a contact, add it to the address book! subject.Truncate(); 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); pDb->InitCardFromRow(userCard,newRow); //add card to db bool bl=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), true, nullptr, nullptr); } } } m_mapi.MAPIFreeBuffer(value); rv = pDb->AddCardRowToDB(newListRow); NS_ENSURE_SUCCESS(rv, rv); rv = pDb->SetListAddressTotal(newListRow, total); rv = pDb->AddListDirNode(newListRow); return rv; }