本文整理汇总了C++中LPMAPITABLE::Restrict方法的典型用法代码示例。如果您正苦于以下问题:C++ LPMAPITABLE::Restrict方法的具体用法?C++ LPMAPITABLE::Restrict怎么用?C++ LPMAPITABLE::Restrict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPMAPITABLE
的用法示例。
在下文中一共展示了LPMAPITABLE::Restrict方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCurrentProfileName
HRESULT GetCurrentProfileName(IN LPMAPISESSION& lpSession, OUT std::string* szProfileName)
{
if ( !szProfileName->empty() )
return S_OK;
HRESULT hr = GetCurrentMAPISession(lpSession);
if ( FAILED(hr) )
return hr;
LPMAPITABLE lpStatusTable = NULL;
SRestriction sres;
SPropValue spvResType;
LPSRowSet pRows = NULL;
LPTSTR lpszProfileName = NULL;
SizedSPropTagArray(2, Columns) =
{
2,
PR_DISPLAY_NAME,
PR_RESOURCE_TYPE
};
hr = lpSession->GetStatusTable(NULL, &lpStatusTable);
if ( SUCCEEDED(hr) )
hr = lpStatusTable->SetColumns((LPSPropTagArray)&Columns, NULL);
if ( SUCCEEDED(hr) )
{
spvResType.ulPropTag = PR_RESOURCE_TYPE;
spvResType.Value.ul = MAPI_SUBSYSTEM;
sres.rt = RES_PROPERTY;
sres.res.resProperty.relop = RELOP_EQ;
sres.res.resProperty.ulPropTag = PR_RESOURCE_TYPE;
sres.res.resProperty.lpProp = &spvResType;
if ( SUCCEEDED(hr) )
hr = lpStatusTable->Restrict(&sres, TBL_ASYNC);
if ( SUCCEEDED(hr) )
hr = lpStatusTable->FindRow(&sres, BOOKMARK_BEGINNING, 0);
if ( SUCCEEDED(hr) )
hr = lpStatusTable->QueryRows(1,0,&pRows);
if (SUCCEEDED(hr))
{
lpszProfileName = pRows->aRow[0].lpProps[0].Value.lpszA;
*szProfileName = lpszProfileName;
}
}
ULRELEASE(lpStatusTable);
FREEPROWS(pRows);
if ( FAILED(hr) )
PR_TRACE((0, prtIMPORTANT, "GetCurrentProfileName failed"));
return hr;
}
示例2: CheckServerQuota
/**
* Checks in the ECStatsTable PR_EC_STATSTABLE_USERS for quota
* information per connected server given in lpAdminStore.
*
* @param[in] cUsers number of users in lpsUserList
* @param[in] lpsUserList array of ECUser struct, containing all Zarafa from all companies, on any server
* @param[in] lpecCompany same company struct as in ECQuotaMonitor::CheckCompanyQuota()
* @param[in] lpAdminStore IMsgStore of SYSTEM user on a specific server instance.
* @return hrSuccess or any MAPI error code.
*/
HRESULT ECQuotaMonitor::CheckServerQuota(ULONG cUsers, LPECUSER lpsUserList, LPECCOMPANY lpecCompany, LPMDB lpAdminStore)
{
HRESULT hr = hrSuccess;
LPSRestriction lpsRestriction = NULL;
SPropValue sRestrictProp;
LPMAPITABLE lpTable = NULL;
LPSRowSet lpRowSet = NULL;
ECQUOTASTATUS sQuotaStatus;
ULONG i, u;
SizedSPropTagArray(5, sCols) = {
5, {
PR_EC_USERNAME_A,
PR_MESSAGE_SIZE_EXTENDED,
PR_QUOTA_WARNING_THRESHOLD,
PR_QUOTA_SEND_THRESHOLD,
PR_QUOTA_RECEIVE_THRESHOLD,
}
};
hr = lpAdminStore->OpenProperty(PR_EC_STATSTABLE_USERS, &IID_IMAPITable, 0, 0, (LPUNKNOWN*)&lpTable);
if (hr != hrSuccess) {
m_lpThreadMonitor->lpLogger->Log(EC_LOGLEVEL_FATAL, "Unable to open stats table for quota sizes, error 0x%08X", hr);
goto exit;
}
hr = lpTable->SetColumns((LPSPropTagArray)&sCols, MAPI_DEFERRED_ERRORS);
if (hr != hrSuccess) {
m_lpThreadMonitor->lpLogger->Log(EC_LOGLEVEL_FATAL, "Unable to set columns on stats table for quota sizes, error 0x%08X", hr);
goto exit;
}
if (lpecCompany->sCompanyId.cb != 0 && lpecCompany->sCompanyId.lpb != NULL) {
sRestrictProp.ulPropTag = PR_EC_COMPANY_NAME_A;
sRestrictProp.Value.lpszA = (char*)lpecCompany->lpszCompanyname;
CREATE_RESTRICTION(lpsRestriction);
CREATE_RES_OR(lpsRestriction, lpsRestriction, 2);
CREATE_RES_NOT(lpsRestriction, &lpsRestriction->res.resOr.lpRes[0]);
DATA_RES_EXIST(lpsRestriction, lpsRestriction->res.resOr.lpRes[0].res.resNot.lpRes[0], PR_EC_COMPANY_NAME_A);
DATA_RES_PROPERTY(lpsRestriction, lpsRestriction->res.resOr.lpRes[1], RELOP_EQ, PR_EC_COMPANY_NAME_A, &sRestrictProp);
hr = lpTable->Restrict(lpsRestriction, MAPI_DEFERRED_ERRORS);
if (hr != hrSuccess) {
m_lpThreadMonitor->lpLogger->Log(EC_LOGLEVEL_FATAL, "Unable to restrict stats table, error 0x%08X", hr);
goto exit;
}
}
while (TRUE) {
hr = lpTable->QueryRows(50, 0, &lpRowSet);
if (hr != hrSuccess) {
m_lpThreadMonitor->lpLogger->Log(EC_LOGLEVEL_FATAL, "Unable to receive stats table data, error 0x%08X", hr);
goto exit;
}
if (lpRowSet->cRows == 0)
break;
for (i = 0; i < lpRowSet->cRows; i++) {
LPSPropValue lpUsername = NULL;
LPSPropValue lpStoreSize = NULL;
LPSPropValue lpQuotaWarn = NULL;
LPSPropValue lpQuotaSoft = NULL;
LPSPropValue lpQuotaHard = NULL;
MsgStorePtr ptrStore;
lpUsername = PpropFindProp(lpRowSet->aRow[i].lpProps, lpRowSet->aRow[i].cValues, PR_EC_USERNAME_A);
lpStoreSize = PpropFindProp(lpRowSet->aRow[i].lpProps, lpRowSet->aRow[i].cValues, PR_MESSAGE_SIZE_EXTENDED);
lpQuotaWarn = PpropFindProp(lpRowSet->aRow[i].lpProps, lpRowSet->aRow[i].cValues, PR_QUOTA_WARNING_THRESHOLD);
lpQuotaSoft = PpropFindProp(lpRowSet->aRow[i].lpProps, lpRowSet->aRow[i].cValues, PR_QUOTA_SEND_THRESHOLD);
lpQuotaHard = PpropFindProp(lpRowSet->aRow[i].lpProps, lpRowSet->aRow[i].cValues, PR_QUOTA_RECEIVE_THRESHOLD);
if (!lpUsername || !lpStoreSize)
continue; // don't log error: could be for several valid reasons (contacts, other server, etc)
if (lpStoreSize->Value.li.QuadPart == 0)
continue;
m_ulProcessed++;
memset(&sQuotaStatus, 0, sizeof(ECQUOTASTATUS));
sQuotaStatus.llStoreSize = lpStoreSize->Value.li.QuadPart;
sQuotaStatus.quotaStatus = QUOTA_OK;
if (lpQuotaHard && lpQuotaHard->Value.ul > 0 && lpStoreSize->Value.li.QuadPart > ((long long)lpQuotaHard->Value.ul * 1024))
sQuotaStatus.quotaStatus = QUOTA_HARDLIMIT;
else if (lpQuotaSoft && lpQuotaSoft->Value.ul > 0 && lpStoreSize->Value.li.QuadPart > ((long long)lpQuotaSoft->Value.ul * 1024))
sQuotaStatus.quotaStatus = QUOTA_SOFTLIMIT;
else if (lpQuotaWarn && lpQuotaWarn->Value.ul > 0 && lpStoreSize->Value.li.QuadPart > ((long long)lpQuotaWarn->Value.ul * 1024))
sQuotaStatus.quotaStatus = QUOTA_WARN;
//.........这里部分代码省略.........
示例3: DelFavoriteFolder
/**
* Remove a favorite in the private store. also the sub favorites will be deleted
*
* @param lpShortcutFolder The shortcut folder in the private store.
* @param lpPropSourceKey Pointer to the sourcekey of a favorite folder
*/
HRESULT DelFavoriteFolder(IMAPIFolder *lpShortcutFolder, LPSPropValue lpPropSourceKey)
{
HRESULT hr = hrSuccess;
LPMAPITABLE lpTable = NULL;
LPSRestriction lpRestriction = NULL;
SRowSet *lpRows = NULL;
LPENTRYLIST lpsMsgList = NULL;
SizedSPropTagArray(2, sPropDelFavo) = {2, { PR_ENTRYID, PR_FAV_PUBLIC_SOURCE_KEY }};
std::list<string> listSourceKey;
std::list<string>::iterator ilistSourceKey;
string strSourceKey;
SPropValue sPropSourceKey;
ULONG ulMaxRows = 0;
if (lpShortcutFolder == NULL || lpPropSourceKey == NULL) {
hr = MAPI_E_INVALID_PARAMETER;
goto exit;
}
hr = lpShortcutFolder->GetContentsTable(0, &lpTable);
if (hr != hrSuccess)
goto exit;
hr = lpTable->GetRowCount(0, &ulMaxRows);
if (hr != hrSuccess)
goto exit;
hr = lpTable->SetColumns((LPSPropTagArray)&sPropDelFavo, 0);
if (hr != hrSuccess)
goto exit;
// build restriction
CREATE_RESTRICTION(lpRestriction);
CREATE_RES_AND(lpRestriction, lpRestriction, 1);
DATA_RES_PROPERTY(lpRestriction, lpRestriction->res.resAnd.lpRes[0], RELOP_EQ, PR_FAV_PUBLIC_SOURCE_KEY, lpPropSourceKey);
if (lpTable->FindRow(lpRestriction, BOOKMARK_BEGINNING , 0) != hrSuccess)
goto exit; // Folder already removed
hr = lpTable->QueryRows (1, 0, &lpRows);
if (hr != hrSuccess)
goto exit;
if (lpRows->cRows == 0)
goto exit; // Folder already removed
hr = MAPIAllocateBuffer(sizeof(ENTRYLIST), (void**)&lpsMsgList);
if (hr != hrSuccess)
goto exit;
hr = MAPIAllocateMore(sizeof(SBinary)*ulMaxRows, lpsMsgList, (void**)&lpsMsgList->lpbin);
if (hr != hrSuccess)
goto exit;
//FIXME: check the properties in the row!!!!
lpsMsgList->cValues = 0;
// add entryid
lpsMsgList->lpbin[lpsMsgList->cValues].cb = lpRows->aRow[0].lpProps[0].Value.bin.cb;
MAPIAllocateMore(lpsMsgList->lpbin[lpsMsgList->cValues].cb, lpsMsgList, (void **) &lpsMsgList->lpbin[lpsMsgList->cValues].lpb);
memcpy(lpsMsgList->lpbin[lpsMsgList->cValues].lpb, lpRows->aRow[0].lpProps[0].Value.bin.lpb, lpsMsgList->lpbin[lpsMsgList->cValues].cb);
lpsMsgList->cValues++;
strSourceKey.assign((char*)lpRows->aRow[0].lpProps[1].Value.bin.lpb, lpRows->aRow[0].lpProps[1].Value.bin.cb);
listSourceKey.push_back(strSourceKey);
if (lpRows){ FreeProws(lpRows); lpRows = NULL; }
FREE_RESTRICTION(lpRestriction);
for(ilistSourceKey = listSourceKey.begin(); ilistSourceKey != listSourceKey.end(); ilistSourceKey++)
{
sPropSourceKey.ulPropTag = PR_FAV_PUBLIC_SOURCE_KEY;
sPropSourceKey.Value.bin.cb = ilistSourceKey->size();
sPropSourceKey.Value.bin.lpb = (LPBYTE)ilistSourceKey->c_str();
CREATE_RESTRICTION(lpRestriction);
CREATE_RES_AND(lpRestriction, lpRestriction, 1);
DATA_RES_PROPERTY(lpRestriction, lpRestriction->res.resAnd.lpRes[0], RELOP_EQ, PR_FAV_PARENT_SOURCE_KEY, &sPropSourceKey);
hr = lpTable->Restrict(lpRestriction, TBL_BATCH );
if (hr != hrSuccess)
goto exit;
hr = lpTable->SeekRow(BOOKMARK_BEGINNING, 0, NULL);
if (hr != hrSuccess)
goto exit;
while(true)
{
hr = lpTable->QueryRows (1, 0, &lpRows);
if (hr != hrSuccess)
//.........这里部分代码省略.........