コード例 #1
0
void CMapiApi::ListProperties( LPMAPIPROP lpProp, BOOL getValues)
{
  LPSPropTagArray    pArray;
  HRESULT        hr = lpProp->GetPropList( 0, &pArray);
  if (FAILED(hr)) {
    MAPI_TRACE0( "    Unable to retrieve property list\n");
    return;
  }
  ULONG count = 0;
  LPMAPINAMEID FAR * lppPropNames;
  SPropTagArray    tagArray;
  LPSPropTagArray lpTagArray = &tagArray;
  tagArray.cValues = (ULONG)1;
  nsCString  desc;
  for (ULONG i = 0; i < pArray->cValues; i++) {
    GetPropTagName( pArray->aulPropTag[i], desc);
    if (getValues) {
      tagArray.aulPropTag[0] = pArray->aulPropTag[i];
      hr = lpProp->GetNamesFromIDs(&lpTagArray, nsnull, 0, &count, &lppPropNames);
      if (hr == S_OK)
        MAPIFreeBuffer(lppPropNames);

      LPSPropValue pVal = GetMapiProperty( lpProp, pArray->aulPropTag[i]);
      if (pVal) {
        desc += ", ";
        ListPropertyValue( pVal, desc);
        MAPIFreeBuffer( pVal);
      }
    }
    MAPI_TRACE2( "    Tag #%d: %s\n", (int)i, (const char *)desc);
  }

  MAPIFreeBuffer( pArray);
}
コード例 #2
0
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);
}
コード例 #3
0
void CProviderTableDlg::OnOpenProfileSection()
{
    HRESULT			hRes = S_OK;

    if (!m_lpProviderAdmin) return;

    CEditor MyUID(
        this,
        IDS_OPENPROFSECT,
        IDS_OPENPROFSECTPROMPT,
        2,
        CEDITOR_BUTTON_OK|CEDITOR_BUTTON_CANCEL);

    MyUID.InitPane(0, CreateDropDownGuidPane(IDS_MAPIUID, false));
    MyUID.InitPane(1, CreateCheckPane(IDS_MAPIUIDBYTESWAPPED, false, false));

    WC_H(MyUID.DisplayDialog());
    if (S_OK != hRes) return;

    GUID guid = {0};
    SBinary MapiUID = {sizeof(GUID),(LPBYTE) &guid};
    (void) MyUID.GetSelectedGUID(0, MyUID.GetCheck(1), &guid);

    LPPROFSECT lpProfSect = NULL;
    EC_H(OpenProfileSection(
             m_lpProviderAdmin,
             &MapiUID,
             &lpProfSect));
    if (lpProfSect)
    {
        LPMAPIPROP lpTemp = NULL;
        EC_MAPI(lpProfSect->QueryInterface(IID_IMAPIProp,(LPVOID*) &lpTemp));
        if (lpTemp)
        {
            EC_H(DisplayObject(
                     lpTemp,
                     MAPI_PROFSECT,
                     otContents,
                     this));
            lpTemp->Release();
        }
        lpProfSect->Release();
    }
    MAPIFreeBuffer(MapiUID.lpb);
} // CProviderTableDlg::OnOpenProfileSection
コード例 #4
0
BOOL CExMapi::AreSame(LPMAPIPROP lpMapiProp1,LPMAPIPROP lpMapiProp2)
{
	if(!m_pSession) return FALSE;
	BOOL bResult=FALSE;

	if(lpMapiProp1 != NULL && lpMapiProp2 != NULL)
	{
		ULONG cbEntryId1;
		ULONG cbEntryId2;
		LPENTRYID lpEntryId1 = NULL;	
		LPENTRYID lpEntryId2 = NULL;

		SPropValue * rgprops1 = NULL;
		SPropValue * rgprops2 = NULL;
		ULONG rgTags[] = {1, PR_ENTRYID};
		ULONG cCount1   = 0;
		ULONG cCount2   = 0;
		// Get the message store entryid properties.
		if(SUCCEEDED(lpMapiProp1->GetProps((LPSPropTagArray) rgTags, MAPI_UNICODE, &cCount1, &rgprops1)))
		{
			cbEntryId1 = rgprops1[0].Value.bin.cb;
			lpEntryId1 = (ENTRYID*)rgprops1[0].Value.bin.lpb;
		}

		if(SUCCEEDED(lpMapiProp2->GetProps((LPSPropTagArray) rgTags, MAPI_UNICODE, &cCount2, &rgprops2)))
		{
			cbEntryId2 = rgprops2[0].Value.bin.cb;
			lpEntryId2 = (ENTRYID*)rgprops2[0].Value.bin.lpb;
		}

		if(lpEntryId1 != NULL && lpEntryId2 != NULL)
		{
			ULONG lResult;
			if(SUCCEEDED(m_pSession->CompareEntryIDs(cbEntryId1,lpEntryId1,cbEntryId2,lpEntryId2,0,&lResult)))
			{
				bResult = (BOOL)lResult;
			}			
		}

		MAPIFreeBuffer(rgprops1);
		MAPIFreeBuffer(rgprops2);
	}
	return bResult;
}
コード例 #5
0
BOOL CMapiApi::GetLargeStringProperty( LPMAPIPROP pProp, ULONG tag, nsCString& val)
{
  LPSTREAM  lpStream;
  HRESULT    hr = pProp->OpenProperty( tag, &IID_IStream, 0, 0, (LPUNKNOWN *)&lpStream);
  if (HR_FAILED( hr))
    return( FALSE);
  STATSTG    st;
  BOOL bResult = TRUE;
  hr = lpStream->Stat( &st, STATFLAG_NONAME);
  if (HR_FAILED( hr))
    bResult = FALSE;
  else {
    if (!st.cbSize.QuadPart)
      st.cbSize.QuadPart = 1;
    char *pVal = new char[ (int) st.cbSize.QuadPart + 1];
    // val.SetCapacity( (int) st.cbSize.QuadPart);
    if (pVal) {
      ULONG  sz;
      hr = lpStream->Read( pVal, (ULONG) st.cbSize.QuadPart, &sz);
      if (HR_FAILED( hr)) {
        bResult = FALSE;
        *pVal = 0;
        sz = 0;
      }
      else
        pVal[(int) st.cbSize.QuadPart] = 0;
      val = pVal;
      delete [] pVal;
    }
    else
      bResult = FALSE;
  }

  lpStream->Release();

  return( bResult);
}
コード例 #6
0
ULONG CMapiApi::GetEmailPropertyTag(LPMAPIPROP lpProp, LONG nameID)
{
static GUID emailGUID = {
   0x00062004, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46
};

  MAPINAMEID mapiNameID;
  mapiNameID.lpguid = &emailGUID;
  mapiNameID.ulKind = MNID_ID;
  mapiNameID.Kind.lID = nameID;

  LPMAPINAMEID lpMapiNames = &mapiNameID;
  LPSPropTagArray lpMailTagArray = nsnull;

  HRESULT result = lpProp->GetIDsFromNames(1L, &lpMapiNames, 0, &lpMailTagArray);
  if (result == S_OK)
  {
    ULONG lTag = lpMailTagArray->aulPropTag[0];
    MAPIFreeBuffer(lpMailTagArray);
    return lTag;
  }
  else
    return 0L;
}
コード例 #7
0
ファイル: BaseDialog.cpp プロジェクト: JasonSchlauch/mfcmapi
void CBaseDialog::OnOpenEntryID(_In_opt_ LPSBinary lpBin)
{
	HRESULT			hRes = S_OK;
	if (!m_lpMapiObjects) return;

	CEditor MyEID(
		this,
		IDS_OPENEID,
		IDS_OPENEIDPROMPT,
		10,
		CEDITOR_BUTTON_OK | CEDITOR_BUTTON_CANCEL);

	MyEID.InitPane(0, CreateSingleLinePane(IDS_EID, BinToHexString(lpBin, false), false));

	LPMDB lpMDB = m_lpMapiObjects->GetMDB(); // do not release
	MyEID.InitPane(1, CreateCheckPane(IDS_USEMDB, lpMDB ? true : false, lpMDB ? false : true));

	LPADRBOOK lpAB = m_lpMapiObjects->GetAddrBook(false); // do not release
	MyEID.InitPane(2, CreateCheckPane(IDS_USEAB, lpAB ? true : false, lpAB ? false : true));

	LPMAPISESSION lpMAPISession = m_lpMapiObjects->GetSession(); // do not release
	MyEID.InitPane(3, CreateCheckPane(IDS_SESSION, lpMAPISession ? true : false, lpMAPISession ? false : true));

	MyEID.InitPane(4, CreateCheckPane(IDS_PASSMAPIMODIFY, false, false));

	MyEID.InitPane(5, CreateCheckPane(IDS_PASSMAPINOCACHE, false, false));

	MyEID.InitPane(6, CreateCheckPane(IDS_PASSMAPICACHEONLY, false, false));

	MyEID.InitPane(7, CreateCheckPane(IDS_EIDBASE64ENCODED, false, false));

	MyEID.InitPane(8, CreateCheckPane(IDS_ATTEMPTIADDRBOOKDETAILSCALL, false, lpAB ? false : true));

	MyEID.InitPane(9, CreateCheckPane(IDS_EIDISCONTAB, false, false));

	WC_H(MyEID.DisplayDialog());
	if (S_OK != hRes) return;

	// Get the entry ID as a binary
	LPENTRYID lpEnteredEntryID = NULL;
	LPENTRYID lpEntryID = NULL;
	size_t cbBin = NULL;
	EC_H(MyEID.GetEntryID(0, MyEID.GetCheck(7), &cbBin, &lpEnteredEntryID));

	if (MyEID.GetCheck(9) && lpEnteredEntryID)
	{
		(void)UnwrapContactEntryID((ULONG)cbBin, (LPBYTE)lpEnteredEntryID, (ULONG*)&cbBin, (LPBYTE*)&lpEntryID);
	}
	else
	{
		lpEntryID = lpEnteredEntryID;
	}

	if (MyEID.GetCheck(8) && lpAB) // Do IAddrBook->Details here
	{
		ULONG_PTR ulUIParam = (ULONG_PTR)(void*)m_hWnd;

		EC_H_CANCEL(lpAB->Details(
			&ulUIParam,
			NULL,
			NULL,
			(ULONG)cbBin,
			lpEntryID,
			NULL,
			NULL,
			NULL,
			DIALOG_MODAL)); // API doesn't like unicode
	}
	else
	{
		LPUNKNOWN lpUnk = NULL;
		ULONG ulObjType = NULL;

		EC_H(CallOpenEntry(
			MyEID.GetCheck(1) ? lpMDB : 0,
			MyEID.GetCheck(2) ? lpAB : 0,
			NULL,
			MyEID.GetCheck(3) ? lpMAPISession : 0,
			(ULONG)cbBin,
			lpEntryID,
			NULL,
			(MyEID.GetCheck(4) ? MAPI_MODIFY : MAPI_BEST_ACCESS) |
			(MyEID.GetCheck(5) ? MAPI_NO_CACHE : 0) |
			(MyEID.GetCheck(6) ? MAPI_CACHE_ONLY : 0),
			&ulObjType,
			&lpUnk));

		if (lpUnk)
		{
			LPWSTR szFlags = NULL;
			InterpretNumberAsStringProp(ulObjType, PR_OBJECT_TYPE, &szFlags);
			DebugPrint(DBGGeneric, _T("OnOpenEntryID: Got object (%p) of type 0x%08X = %ws\n"), lpUnk, ulObjType, szFlags);
			delete[] szFlags;
			szFlags = NULL;

			LPMAPIPROP lpTemp = NULL;
			WC_MAPI(lpUnk->QueryInterface(IID_IMAPIProp, (LPVOID*)&lpTemp));
			if (lpTemp)
			{
				WC_H(DisplayObject(
					lpTemp,
					ulObjType,
					otHierarchy,
					this));
				lpTemp->Release();
			}
			lpUnk->Release();
		}
	}

	delete[] lpEnteredEntryID;
} // CBaseDialog::OnOpenEntryID
コード例 #8
0
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;
}