123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- #include <new>
- #include <kopano/platform.h>
- #include "ECMsgStore.h"
- #include "WSStoreTableView.h"
- #include "Mem.h"
- #include <kopano/ECGuid.h>
- #include "SOAPUtils.h"
- #include "WSUtil.h"
- WSStoreTableView::WSStoreTableView(ULONG ulType, ULONG ulFlags, KCmd *lpCmd,
- std::recursive_mutex &lpDataLock, ECSESSIONID ecSessionId, ULONG cbEntryId,
- LPENTRYID lpEntryId, ECMsgStore *lpMsgStore, WSTransport *lpTransport) :
- WSTableView(ulType, ulFlags, lpCmd, lpDataLock, ecSessionId, cbEntryId,
- lpEntryId, lpTransport, "WSStoreTableView")
- {
-
-
-
-
-
-
- this->m_lpProvider = (void *)lpMsgStore;
- this->m_ulTableType = TABLETYPE_MS;
- }
- HRESULT WSStoreTableView::Create(ULONG ulType, ULONG ulFlags, KCmd *lpCmd,
- std::recursive_mutex &lpDataLock, ECSESSIONID ecSessionId, ULONG cbEntryId,
- LPENTRYID lpEntryId, ECMsgStore *lpMsgStore, WSTransport *lpTransport,
- WSTableView **lppTableView)
- {
- HRESULT hr = hrSuccess;
- auto lpTableView = new(std::nothrow) WSStoreTableView(ulType, ulFlags,
- lpCmd, lpDataLock, ecSessionId, cbEntryId,
- lpEntryId, lpMsgStore, lpTransport);
- if (lpTableView == nullptr)
- return MAPI_E_NOT_ENOUGH_MEMORY;
- hr = lpTableView->QueryInterface(IID_ECTableView, (void **) lppTableView);
-
- if(hr != hrSuccess)
- delete lpTableView;
- return hr;
- }
- HRESULT WSStoreTableView::QueryInterface(REFIID refiid, void **lppInterface)
- {
- REGISTER_INTERFACE3(ECTableView, WSTableView, this);
- return MAPI_E_INTERFACE_NOT_SUPPORTED;
- }
- WSTableMultiStore::WSTableMultiStore(ULONG ulFlags, KCmd *lpCmd,
- std::recursive_mutex &lpDataLock, ECSESSIONID ecSessionId, ULONG cbEntryId,
- LPENTRYID lpEntryId, ECMsgStore *lpMsgStore, WSTransport *lpTransport) :
- WSStoreTableView(MAPI_MESSAGE, ulFlags, lpCmd, lpDataLock, ecSessionId,
- cbEntryId, lpEntryId, lpMsgStore, lpTransport)
- {
- memset(&m_sEntryList, 0, sizeof(m_sEntryList));
- m_ulTableType = TABLETYPE_MULTISTORE;
- ulTableId = 0;
- }
- WSTableMultiStore::~WSTableMultiStore()
- {
- FreeEntryList(&m_sEntryList, false);
- }
- HRESULT WSTableMultiStore::Create(ULONG ulFlags, KCmd *lpCmd,
- std::recursive_mutex &lpDataLock, ECSESSIONID ecSessionId, ULONG cbEntryId,
- LPENTRYID lpEntryId, ECMsgStore *lpMsgStore, WSTransport *lpTransport,
- WSTableMultiStore **lppTableMultiStore)
- {
- HRESULT hr = hrSuccess;
- WSTableMultiStore *lpTableMultiStore = NULL;
- lpTableMultiStore = new WSTableMultiStore(ulFlags, lpCmd, lpDataLock, ecSessionId, cbEntryId, lpEntryId, lpMsgStore, lpTransport);
-
- hr = lpTableMultiStore->QueryInterface(IID_ECTableView, (void **) lppTableMultiStore);
-
- if(hr != hrSuccess)
- delete lpTableMultiStore;
- return hr;
- }
- HRESULT WSTableMultiStore::HrOpenTable()
- {
- ECRESULT er = erSuccess;
- HRESULT hr = hrSuccess;
- struct tableOpenResponse sResponse;
- LockSoap();
- if(this->ulTableId != 0)
- goto exit;
-
- if(SOAP_OK != lpCmd->ns__tableOpen(ecSessionId, m_sEntryId, m_ulTableType, MAPI_MESSAGE, this->ulFlags, &sResponse))
- er = KCERR_NETWORK_ERROR;
- else
- er = sResponse.er;
- hr = kcerr_to_mapierr(er);
- if(hr != hrSuccess)
- goto exit;
- this->ulTableId = sResponse.ulTableId;
- if (SOAP_OK != lpCmd->ns__tableSetMultiStoreEntryIDs(ecSessionId, ulTableId, &m_sEntryList, &er))
- er = KCERR_NETWORK_ERROR;
- hr = kcerr_to_mapierr(er);
- if(hr != hrSuccess)
- goto exit;
- exit:
- UnLockSoap();
- return hr;
- }
- HRESULT WSTableMultiStore::HrSetEntryIDs(LPENTRYLIST lpMsgList)
- {
-
- return CopyMAPIEntryListToSOAPEntryList(lpMsgList, &m_sEntryList);
- }
- WSTableMisc::WSTableMisc(ULONG ulTableType, ULONG ulFlags, KCmd *lpCmd,
- std::recursive_mutex &lpDataLock, ECSESSIONID ecSessionId, ULONG cbEntryId,
- LPENTRYID lpEntryId, ECMsgStore *lpMsgStore, WSTransport *lpTransport) :
-
- WSStoreTableView(MAPI_STATUS, ulFlags, lpCmd, lpDataLock, ecSessionId,
- cbEntryId, lpEntryId, lpMsgStore, lpTransport)
- {
- m_ulTableType = ulTableType;
- ulTableId = 0;
- }
- HRESULT WSTableMisc::Create(ULONG ulTableType, ULONG ulFlags, KCmd *lpCmd,
- std::recursive_mutex &lpDataLock, ECSESSIONID ecSessionId, ULONG cbEntryId,
- LPENTRYID lpEntryId, ECMsgStore *lpMsgStore, WSTransport *lpTransport,
- WSTableMisc **lppTableMisc)
- {
- HRESULT hr = hrSuccess;
- auto lpTableMisc = new(std::nothrow) WSTableMisc(ulTableType, ulFlags,
- lpCmd, lpDataLock, ecSessionId, cbEntryId,
- lpEntryId, lpMsgStore, lpTransport);
- if (lpTableMisc == nullptr)
- return MAPI_E_NOT_ENOUGH_MEMORY;
- hr = lpTableMisc->QueryInterface(IID_ECTableView, (void **) lppTableMisc);
- if (hr != hrSuccess)
- delete lpTableMisc;
- return hr;
- }
- HRESULT WSTableMisc::HrOpenTable()
- {
- ECRESULT er = erSuccess;
- HRESULT hr = hrSuccess;
- struct tableOpenResponse sResponse;
- LockSoap();
-
- if(ulTableId != 0)
- goto exit;
-
- if(SOAP_OK != lpCmd->ns__tableOpen(ecSessionId, m_sEntryId, m_ulTableType, ulType, this->ulFlags, &sResponse))
- er = KCERR_NETWORK_ERROR;
- else
- er = sResponse.er;
- hr = kcerr_to_mapierr(er);
- if(hr != hrSuccess)
- goto exit;
- this->ulTableId = sResponse.ulTableId;
- exit:
- UnLockSoap();
- return hr;
- }
- WSTableMailBox::WSTableMailBox(ULONG ulFlags, KCmd *lpCmd,
- std::recursive_mutex &lpDataLock, ECSESSIONID ecSessionId,
- ECMsgStore *lpMsgStore, WSTransport *lpTransport) :
- WSStoreTableView(MAPI_STORE, ulFlags, lpCmd, lpDataLock, ecSessionId,
- 0, NULL, lpMsgStore, lpTransport)
- {
- m_ulTableType = TABLETYPE_MAILBOX;
- }
- HRESULT WSTableMailBox::Create(ULONG ulFlags, KCmd *lpCmd,
- std::recursive_mutex &lpDataLock, ECSESSIONID ecSessionId,
- ECMsgStore *lpMsgStore, WSTransport *lpTransport, WSTableMailBox **lppTable)
- {
- HRESULT hr = hrSuccess;
- auto lpTable = new(std::nothrow) WSTableMailBox(ulFlags, lpCmd,
- lpDataLock, ecSessionId, lpMsgStore, lpTransport);
- if (lpTable == nullptr)
- return MAPI_E_NOT_ENOUGH_MEMORY;
-
- hr = lpTable->QueryInterface(IID_ECTableView, (void **) lppTable);
-
- if(hr != hrSuccess)
- delete lpTable;
- return hr;
- }
|