Exemplo n.º 1
0
// ---
static AVP_dword DATA_PARAM DATA_Get( Serialize* sz, AVP_Data* dad, AVP_Data** out ) {
	AVP_byte      key_byte;
	AVP_Property  prop;
	AVP_Data*     add;
	AVP_dword     total = sz->tsize;

	if ( get_byte( sz, &key_byte) != sizeof(key_byte) ) 
		return 0;

	if ( key_byte & ~(PUT_VAL_PROP|PUT_CHILD_DATA|PUT_NEXT_DATA) ) {
		_RPT0( _CRT_ASSERT, "Bad stream" );
		return 0;
	}

	if ( get_avp_property( sz, &prop) != sizeof(prop) ) 
		return 0;

	*out = (AVP_Data*)DATA_Add( DATA_HANDLE(dad), 0, PROP_ID(&prop), 0, 0 );
	if ( *out ) {
		AVP_Property pr;
		AVP_dword    id;

		if ( (key_byte&PUT_VAL_PROP) && !PROP_Get(sz,&(*out)->value.data) )
			return 0;

		if ( get_avp_property( sz, &pr) != sizeof(pr) )
			return 0;

		id = PROP_ID(&pr);

		while( id != AVP_PID_END ) {
			AVP_Property* ptr = (AVP_Property*)DATA_Add_Prop( DATA_HANDLE(*out), 0, id, 0, 0 );

			if ( !ptr )
				return 0;

			if ( !PROP_Get(sz,ptr) )
				return 0;

			if ( get_avp_property( sz, &pr) != sizeof(pr) )
				return 0;

			id = PROP_ID(&pr);
		}
	}
	if (  (key_byte & PUT_CHILD_DATA)  &&  (!DATA_Get(sz,*out,&add))  ) 
		return 0;
	if ( key_byte & PUT_NEXT_DATA ) {
		AVP_byte end;
		while( next_byte(sz) != AVP_NEXT_END ) {
			if ( !DATA_Get(sz,dad,&add) )
				return 0;
		}
		get_byte( sz, &end );
	}

	return sz->tsize - total;
}
Exemplo n.º 2
0
void CAclDlg::OnAddItem()
{
    HRESULT			hRes = S_OK;

    CEditor MyData(
        this,
        IDS_ACLADDITEM,
        IDS_ACLADDITEMPROMPT,
        2,
        CEDITOR_BUTTON_OK|CEDITOR_BUTTON_CANCEL);
    MyData.SetPromptPostFix(AllFlagsToString(PROP_ID(PR_MEMBER_RIGHTS),true));
    MyData.InitPane(0, CreateSingleLinePane(IDS_USEREID, NULL, false));
    MyData.InitPane(1, CreateSingleLinePane(IDS_MASKINHEX, NULL, false));
    MyData.SetHex(1,0);

    WC_H(MyData.DisplayDialog());
    if (S_OK != hRes)
    {
        DebugPrint(DBGGeneric,_T("OnAddItem cancelled.\n"));
        return;
    }

    LPROWLIST lpNewItem = NULL;

    EC_H(MAPIAllocateBuffer(CbNewROWLIST(1),(LPVOID*) &lpNewItem));

    if (lpNewItem)
    {
        lpNewItem->cEntries = 1;
        lpNewItem->aEntries[0].ulRowFlags = ROW_ADD;
        lpNewItem->aEntries[0].cValues = 2;
        lpNewItem->aEntries[0].rgPropVals = 0;

        EC_H(MAPIAllocateMore(2 * sizeof(SPropValue), lpNewItem, (LPVOID*)&lpNewItem->aEntries[0].rgPropVals));

        if (lpNewItem->aEntries[0].rgPropVals)
        {
            LPENTRYID lpEntryID = NULL;
            size_t cbBin = 0;
            EC_H(MyData.GetEntryID(0, false, &cbBin, &lpEntryID));

            lpNewItem->aEntries[0].rgPropVals[0].ulPropTag = PR_MEMBER_ENTRYID;
            lpNewItem->aEntries[0].rgPropVals[0].Value.bin.cb = (ULONG)cbBin;
            lpNewItem->aEntries[0].rgPropVals[0].Value.bin.lpb = (LPBYTE)lpEntryID;
            lpNewItem->aEntries[0].rgPropVals[1].ulPropTag = PR_MEMBER_RIGHTS;
            lpNewItem->aEntries[0].rgPropVals[1].Value.ul = MyData.GetHex(1);

            EC_MAPI(m_lpExchTbl->ModifyTable(
                        m_ulTableFlags,
                        lpNewItem));
            MAPIFreeBuffer(lpNewItem);
            if (S_OK == hRes)
                OnRefreshView();

            delete[] lpEntryID;
        }
    }
} // CAclDlg::OnAddItem
Exemplo n.º 3
0
// ---
static AVP_bool DATA_PARAM In_Process( AVP_dword id, AVP_dword* include_list, AVP_dword* exclude_list ) {
  AVP_dword* list;
  AVP_bool in_process = 1;
  if ( include_list ) {
    list = include_list;
    while( *list && PROP_ID(list) != id )
      list++;
    if ( !*list )
      in_process = 0;
  }
  if ( in_process && exclude_list ) {
    list = exclude_list;
    while( *list && PROP_ID(list) != id )
      list++;
    if ( *list )
      in_process = 0;
  }
  return in_process;
}
Exemplo n.º 4
0
// ---
static AVP_dword DATA_PARAM DATA_Put( Serialize* sz, AVP_Data* data, AVP_bool next, AVP_dword* include_list, AVP_dword* exclude_list ) {
  if ( data ) {
    AVP_dword id;
    AVP_dword saved = sizeof(AVP_BYTE_Property);
    AVP_dword total = 0;
    AVP_bool  start = 1;
    AVP_bool  value = In_Process( AVP_PID_VALUE, include_list, exclude_list );
    AVP_byte  key_byte = ( value ? PUT_VAL_PROP : 0 ) | ( data->child ? PUT_CHILD_DATA : 0 ) | ( (next && data->next) ? PUT_NEXT_DATA : 0 );
    AVP_Linked_Property* prop;

    saved = put_bytes( sz, &key_byte, sizeof(key_byte) );
    if ( saved < sizeof(key_byte) )
      return 0;
    else
      total += saved;

    prop = &data->value;
    while( 1 ) {
      if ( !prop ) {
        _RPT0( _CRT_ASSERT, "Bad property list" );
        return 0;
      }
      id = PROP_ID(&prop->data);
      if ( id == AVP_PID_END ) {
		saved = put_avp_property (sz, (AVP_Property*) &id);
        if ( saved < sizeof(id) )
          return 0;
        else
          total += saved;
        break;
      }
      if ( start ) {
        if ( value ) {
          saved = PROP_Put( sz, &prop->data );
          if ( !saved )
            return 0;
        }
        else {
          saved = put_avp_property (sz, &prop->data);
          if ( saved < sizeof(AVP_Property) )
            return 0;
        }
        total += saved;
        start = 0;
      }
      else if ( In_Process(id,include_list,exclude_list) ) {
        saved = PROP_Put( sz, &prop->data );
        if ( saved )
          total += saved;
        else
          return 0;
      }
      prop = prop->next;
    }
    if ( data->child ) {
      saved = DATA_Put( sz, data->child, 1, include_list, exclude_list );
      if ( saved )
        total += saved;
      else
        return 0;
    }
    if ( next && data->next ) {
      AVP_byte  e = AVP_NEXT_END;
      AVP_Data* n = data->next;
      while( n ) {
        saved = DATA_Put( sz, n, 0, include_list, exclude_list );
        if ( saved )
          total += saved;
        else
          return 0;
        n = n->next;
      }
      saved = put_bytes( sz, &e, sizeof(e) );
      if ( saved == sizeof(AVP_byte) )
        total += saved;
      else
        return 0;
    }

    return total;
  }
  else {
    _RPT0( _CRT_ASSERT, "Data handle is zero" );
    return 0;
  }
}
Exemplo n.º 5
0
ECRESULT ECUserStoreTable::QueryRowData(ECGenericObjectTable *lpThis, struct soap *soap, ECSession *lpSession, ECObjectTableList* lpRowList, struct propTagArray *lpsPropTagArray, void* lpObjectData, struct rowSet **lppRowSet, bool bCacheTableData, bool bTableLimit)
{
	ECRESULT er = erSuccess;
	ECUserStoreTable *pThis = dynamic_cast<ECUserStoreTable*>(lpThis);
	struct rowSet *lpsRowSet = NULL;
	ECObjectTableList::iterator iterRowList;
	int i, k;
	GUID sZeroGuid = {0};

	if (!lpThis) {
		er = ZARAFA_E_INVALID_PARAMETER;
		goto exit;
	}

	lpsRowSet = s_alloc<rowSet>(soap);
	lpsRowSet->__size = 0;
	lpsRowSet->__ptr = NULL;

	if(lpRowList->empty()) {
		*lppRowSet = lpsRowSet;
		goto exit; // success
	}

	// We return a square array with all the values
	lpsRowSet->__size = lpRowList->size();
	lpsRowSet->__ptr = s_alloc<propValArray>(soap, lpsRowSet->__size);
	memset(lpsRowSet->__ptr, 0, sizeof(propValArray) * lpsRowSet->__size);

	// Allocate memory for all rows
	for (i = 0; i < lpsRowSet->__size; i++) {
		lpsRowSet->__ptr[i].__size = lpsPropTagArray->__size;
		lpsRowSet->__ptr[i].__ptr = s_alloc<propVal>(soap, lpsPropTagArray->__size);
		memset(lpsRowSet->__ptr[i].__ptr, 0, sizeof(propVal) * lpsPropTagArray->__size);
	}

	for (i = 0, iterRowList = lpRowList->begin(); iterRowList != lpRowList->end(); iterRowList++, i++) {
		for (k = 0; k < lpsPropTagArray->__size; k++) {

			lpsRowSet->__ptr[i].__ptr[k].ulPropTag = PROP_TAG(PT_ERROR, lpsPropTagArray->__ptr[k]);
			lpsRowSet->__ptr[i].__ptr[k].__union = SOAP_UNION_propValData_ul;
			lpsRowSet->__ptr[i].__ptr[k].Value.ul = ZARAFA_E_NOT_FOUND;

			switch (PROP_ID(lpsPropTagArray->__ptr[k])) {
			case PROP_ID(PR_INSTANCE_KEY):
				// generate key 
				lpsRowSet->__ptr[i].__ptr[k].__union = SOAP_UNION_propValData_bin;
				lpsRowSet->__ptr[i].__ptr[k].ulPropTag = PR_INSTANCE_KEY;
				lpsRowSet->__ptr[i].__ptr[k].Value.bin = s_alloc<xsd__base64Binary>(soap);
				lpsRowSet->__ptr[i].__ptr[k].Value.bin->__size = sizeof(sObjectTableKey);
				lpsRowSet->__ptr[i].__ptr[k].Value.bin->__ptr = s_alloc<unsigned char>(soap, sizeof(sObjectTableKey));
				memcpy(lpsRowSet->__ptr[i].__ptr[k].Value.bin->__ptr, (void*)&(*iterRowList), sizeof(sObjectTableKey));
				break;

			case PROP_ID(PR_EC_USERNAME):
				if (!pThis->m_mapUserStoreData[iterRowList->ulObjId].strUsername.empty()) {
					lpsRowSet->__ptr[i].__ptr[k].ulPropTag = lpsPropTagArray->__ptr[k];

					lpsRowSet->__ptr[i].__ptr[k].__union = SOAP_UNION_propValData_lpszA;
					lpsRowSet->__ptr[i].__ptr[k].Value.lpszA = s_strcpy(soap, (char*)pThis->m_mapUserStoreData[iterRowList->ulObjId].strUsername.c_str());
				}
				break;
			case PROP_ID(PR_DISPLAY_NAME):
				if (!pThis->m_mapUserStoreData[iterRowList->ulObjId].strGuessname.empty()) {
					lpsRowSet->__ptr[i].__ptr[k].ulPropTag = lpsPropTagArray->__ptr[k];

					lpsRowSet->__ptr[i].__ptr[k].__union = SOAP_UNION_propValData_lpszA;
					lpsRowSet->__ptr[i].__ptr[k].Value.lpszA = s_strcpy(soap, (char*)pThis->m_mapUserStoreData[iterRowList->ulObjId].strGuessname.c_str());
				}
				break;
			case PROP_ID(PR_EC_STOREGUID):
				if (pThis->m_mapUserStoreData[iterRowList->ulObjId].sGuid != sZeroGuid) {
					lpsRowSet->__ptr[i].__ptr[k].ulPropTag = lpsPropTagArray->__ptr[k];

					lpsRowSet->__ptr[i].__ptr[k].__union = SOAP_UNION_propValData_bin;
					lpsRowSet->__ptr[i].__ptr[k].Value.bin = s_alloc<xsd__base64Binary>(soap);
					lpsRowSet->__ptr[i].__ptr[k].Value.bin->__size = sizeof(GUID);
					lpsRowSet->__ptr[i].__ptr[k].Value.bin->__ptr = s_alloc<unsigned char>(soap, sizeof(GUID));
					memcpy(lpsRowSet->__ptr[i].__ptr[k].Value.bin->__ptr, (unsigned char*)&pThis->m_mapUserStoreData[iterRowList->ulObjId].sGuid, sizeof(GUID));
				}
				break;
			case PROP_ID(PR_EC_STORETYPE):
				lpsRowSet->__ptr[i].__ptr[k].ulPropTag = lpsPropTagArray->__ptr[k];

				lpsRowSet->__ptr[i].__ptr[k].__union = SOAP_UNION_propValData_ul;
				lpsRowSet->__ptr[i].__ptr[k].Value.ul = pThis->m_mapUserStoreData[iterRowList->ulObjId].ulStoreType;
				break;
			case PROP_ID(PR_EC_COMPANYID):
				if (pThis->m_mapUserStoreData[iterRowList->ulObjId].ulCompanyId != 0) {
					lpsRowSet->__ptr[i].__ptr[k].ulPropTag = lpsPropTagArray->__ptr[k];

					lpsRowSet->__ptr[i].__ptr[k].__union = SOAP_UNION_propValData_ul;
					lpsRowSet->__ptr[i].__ptr[k].Value.ul = pThis->m_mapUserStoreData[iterRowList->ulObjId].ulCompanyId;
				}
				break;
			case PROP_ID(PR_EC_COMPANY_NAME):
				if (!pThis->m_mapUserStoreData[iterRowList->ulObjId].strCompanyName.empty()) {
					lpsRowSet->__ptr[i].__ptr[k].ulPropTag = lpsPropTagArray->__ptr[k];

					lpsRowSet->__ptr[i].__ptr[k].__union = SOAP_UNION_propValData_lpszA;
					lpsRowSet->__ptr[i].__ptr[k].Value.lpszA = s_strcpy(soap, (char*)pThis->m_mapUserStoreData[iterRowList->ulObjId].strCompanyName.c_str());
				}
				break;
			case PROP_ID(PR_STORE_ENTRYID):
				// ignore errors
				ECGenProps::GetPropComputedUncached(soap, NULL ,lpSession, PR_STORE_ENTRYID, pThis->m_mapUserStoreData[iterRowList->ulObjId].ulObjId, 0,
							   				pThis->m_mapUserStoreData[iterRowList->ulObjId].ulObjId, 0, MAPI_STORE, &lpsRowSet->__ptr[i].__ptr[k]);
				break;
			case PROP_ID(PR_LAST_MODIFICATION_TIME):
				if (pThis->m_mapUserStoreData[iterRowList->ulObjId].tModTime != 0) {
					FILETIME ftTmp;
					UnixTimeToFileTime(pThis->m_mapUserStoreData[iterRowList->ulObjId].tModTime, &ftTmp);

					lpsRowSet->__ptr[i].__ptr[k].ulPropTag = lpsPropTagArray->__ptr[k];
					lpsRowSet->__ptr[i].__ptr[k].__union = SOAP_UNION_propValData_hilo;
					lpsRowSet->__ptr[i].__ptr[k].Value.hilo = s_alloc<struct hiloLong>(soap);
					lpsRowSet->__ptr[i].__ptr[k].Value.hilo->hi = ftTmp.dwHighDateTime;
					lpsRowSet->__ptr[i].__ptr[k].Value.hilo->lo = ftTmp.dwLowDateTime;
				}
				break;
			case PROP_ID(PR_MESSAGE_SIZE_EXTENDED):
				lpsRowSet->__ptr[i].__ptr[k].ulPropTag = lpsPropTagArray->__ptr[k];
				lpsRowSet->__ptr[i].__ptr[k].__union = SOAP_UNION_propValData_li;
				lpsRowSet->__ptr[i].__ptr[k].Value.li = pThis->m_mapUserStoreData[iterRowList->ulObjId].ullStoreSize;
				break;
			default:
				lpsRowSet->__ptr[i].__ptr[k].ulPropTag = PROP_TAG(PT_ERROR, lpsPropTagArray->__ptr[k]);

				lpsRowSet->__ptr[i].__ptr[k].__union = SOAP_UNION_propValData_ul;
				lpsRowSet->__ptr[i].__ptr[k].Value.ul = ZARAFA_E_NOT_FOUND;
				break;
			};
		}
	}

	*lppRowSet = lpsRowSet;

exit:
	return er;
}