forked from microsoft/mfcmapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapiProcessor.cpp
812 lines (688 loc) · 18.9 KB
/
MapiProcessor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
#include "stdafx.h"
#include "MAPIProcessor.h"
#include "MAPIFunctions.h"
#include "MAPIStoreFunctions.h"
#include "File.h"
#include "ColumnTags.h"
CMAPIProcessor::CMAPIProcessor()
{
m_lpSession = nullptr;
m_lpMDB = nullptr;
m_lpFolder = nullptr;
m_lpListHead = nullptr;
m_lpListTail = nullptr;
m_lpResFolderContents = nullptr;
m_lpSort = nullptr;
m_ulCount = 0;
}
CMAPIProcessor::~CMAPIProcessor()
{
FreeFolderList();
if (m_lpFolder) m_lpFolder->Release();
if (m_lpMDB) m_lpMDB->Release();
if (m_lpSession) m_lpSession->Release();
}
// --------------------------------------------------------------------------------- //
void CMAPIProcessor::InitSession(_In_ LPMAPISESSION lpSession)
{
if (m_lpSession) m_lpSession->Release();
m_lpSession = lpSession;
if (m_lpSession) m_lpSession->AddRef();
}
void CMAPIProcessor::InitMDB(_In_ LPMDB lpMDB)
{
if (m_lpMDB) m_lpMDB->Release();
m_lpMDB = lpMDB;
if (m_lpMDB) m_lpMDB->AddRef();
}
void CMAPIProcessor::InitFolder(_In_ LPMAPIFOLDER lpFolder)
{
if (m_lpFolder) m_lpFolder->Release();
m_lpFolder = lpFolder;
if (m_lpFolder) m_lpFolder->AddRef();
m_szFolderOffset = L"\\"; // STRING_OK
}
void CMAPIProcessor::InitFolderContentsRestriction(_In_opt_ LPSRestriction lpRes)
{
// If we ever need to hold this past the scope of the caller we'll need to copy the restriction.
// For now, just grab a pointer.
m_lpResFolderContents = lpRes;
}
void CMAPIProcessor::InitMaxOutput(_In_ ULONG ulCount)
{
m_ulCount = ulCount;
}
void CMAPIProcessor::InitSortOrder(_In_ LPSSortOrderSet lpSort)
{
// If we ever need to hold this past the scope of the caller we'll need to copy the sort order.
// For now, just grab a pointer.
m_lpSort = lpSort;
}
// --------------------------------------------------------------------------------- //
// Server name MUST be passed
void CMAPIProcessor::ProcessMailboxTable(
_In_ wstring szExchangeServerName)
{
if (szExchangeServerName.empty()) return;
auto hRes = S_OK;
LPMAPITABLE lpMailBoxTable = nullptr;
LPSRowSet lpRows = nullptr;
LPMDB lpPrimaryMDB = nullptr;
ULONG ulOffset = 0;
ULONG ulRowNum = 0;
auto ulFlags = LOGOFF_NO_WAIT;
if (!m_lpSession) return;
BeginMailboxTableWork(szExchangeServerName);
WC_H(OpenMessageStoreGUID(m_lpSession, pbExchangeProviderPrimaryUserGuid, &lpPrimaryMDB));
if (lpPrimaryMDB && StoreSupportsManageStore(lpPrimaryMDB)) do
{
hRes = S_OK;
WC_H(GetMailboxTable(
lpPrimaryMDB,
wstringTostring(szExchangeServerName),
ulOffset,
&lpMailBoxTable));
if (lpMailBoxTable)
{
WC_MAPI(lpMailBoxTable->SetColumns(LPSPropTagArray(&sptMBXCols), NULL));
hRes = S_OK;
// go to the first row
WC_MAPI(lpMailBoxTable->SeekRow(
BOOKMARK_BEGINNING,
0,
NULL));
// get each row in turn and process it
if (!FAILED(hRes)) for (ulRowNum = 0;; ulRowNum++)
{
if (lpRows) FreeProws(lpRows);
lpRows = nullptr;
hRes = S_OK;
WC_MAPI(lpMailBoxTable->QueryRows(
1,
NULL,
&lpRows));
if (FAILED(hRes) || !lpRows || !lpRows->cRows) break;
DoMailboxTablePerRowWork(lpPrimaryMDB, lpRows->aRow, ulRowNum + ulOffset + 1);
auto lpEmailAddress = PpropFindProp(lpRows->aRow->lpProps, lpRows->aRow->cValues, PR_EMAIL_ADDRESS);
if (!CheckStringProp(lpEmailAddress, PT_TSTRING)) continue;
if (m_lpMDB)
{
WC_MAPI(m_lpMDB->StoreLogoff(&ulFlags));
m_lpMDB->Release();
m_lpMDB = nullptr;
hRes = S_OK;
}
WC_H(OpenOtherUsersMailbox(
m_lpSession,
lpPrimaryMDB,
wstringTostring(szExchangeServerName),
wstringTostring(LPCTSTRToWstring(lpEmailAddress->Value.LPSZ)),
OPENSTORE_USE_ADMIN_PRIVILEGE | OPENSTORE_TAKE_OWNERSHIP,
false,
&m_lpMDB));
if (m_lpMDB) ProcessStore();
}
if (lpRows) FreeProws(lpRows);
lpRows = nullptr;
lpMailBoxTable->Release();
ulOffset += ulRowNum;
}
} while (ulRowNum);
if (m_lpMDB)
{
WC_MAPI(m_lpMDB->StoreLogoff(&ulFlags));
m_lpMDB->Release();
m_lpMDB = nullptr;
}
if (lpPrimaryMDB) lpPrimaryMDB->Release();
EndMailboxTableWork();
}
void CMAPIProcessor::ProcessStore()
{
if (!m_lpMDB) return;
BeginStoreWork();
AddFolderToFolderList(nullptr, L"\\"); // STRING_OK
ProcessFolders(true, true, true);
EndStoreWork();
}
void CMAPIProcessor::ProcessFolders(bool bDoRegular, bool bDoAssociated, bool bDoDescent)
{
BeginProcessFoldersWork();
if (ContinueProcessingFolders())
{
if (!m_lpFolder)
{
OpenFirstFolderInList();
}
while (m_lpFolder)
{
DoProcessFoldersPerFolderWork();
ProcessFolder(bDoRegular, bDoAssociated, bDoDescent);
if (!ContinueProcessingFolders()) break;
OpenFirstFolderInList();
}
}
EndProcessFoldersWork();
}
bool CMAPIProcessor::ContinueProcessingFolders()
{
return true;
}
bool CMAPIProcessor::ShouldProcessContentsTable()
{
return true;
}
void CMAPIProcessor::ProcessFolder(bool bDoRegular,
bool bDoAssociated,
bool bDoDescent)
{
if (!m_lpMDB || !m_lpFolder) return;
auto hRes = S_OK;
BeginFolderWork();
if (bDoRegular && ShouldProcessContentsTable())
{
ProcessContentsTable(NULL);
}
if (bDoAssociated && ShouldProcessContentsTable())
{
ProcessContentsTable(MAPI_ASSOCIATED);
}
// If we're not processing subfolders, then get outta here
if (bDoDescent)
{
LPMAPITABLE lpHierarchyTable = nullptr;
// We need to walk down the tree
// and get the list of kids of the folder
WC_MAPI(m_lpFolder->GetHierarchyTable(fMapiUnicode, &lpHierarchyTable));
if (lpHierarchyTable)
{
enum
{
NAME,
EID,
SUBFOLDERS,
FLAGS,
NUMCOLS
};
static const SizedSPropTagArray(NUMCOLS, sptHierarchyCols) =
{
NUMCOLS,
PR_DISPLAY_NAME,
PR_ENTRYID,
PR_SUBFOLDERS,
PR_CONTAINER_FLAGS,
};
LPSRowSet lpRows = nullptr;
// If I don't do this, the MSPST provider can blow chunks (MAPI_E_EXTENDED_ERROR) for some folders when I get a row
// For some reason, this fixes it.
WC_MAPI(lpHierarchyTable->SetColumns(
LPSPropTagArray(&sptHierarchyCols),
TBL_BATCH));
// go to the first row
WC_MAPI(lpHierarchyTable->SeekRow(
BOOKMARK_BEGINNING,
0,
NULL));
if (S_OK == hRes) for (;;)
{
hRes = S_OK;
if (lpRows) FreeProws(lpRows);
lpRows = nullptr;
WC_MAPI(lpHierarchyTable->QueryRows(
255,
NULL,
&lpRows));
if (FAILED(hRes))
{
hRes = S_OK;
break;
}
if (!lpRows || !lpRows->cRows) break;
for (ULONG ulRow = 0; ulRow < lpRows->cRows; ulRow++)
{
DoFolderPerHierarchyTableRowWork(&lpRows->aRow[ulRow]);
if (lpRows->aRow[ulRow].lpProps)
{
wstring szSubFolderOffset; // Holds subfolder name
auto lpFolderDisplayName = PpropFindProp(
lpRows->aRow[ulRow].lpProps,
lpRows->aRow[ulRow].cValues,
PR_DISPLAY_NAME);
if (CheckStringProp(lpFolderDisplayName, PT_TSTRING))
{
// Clean up the folder name before appending it to the offset
szSubFolderOffset = m_szFolderOffset + SanitizeFileNameW(LPCTSTRToWstring(lpFolderDisplayName->Value.LPSZ)) + L'\\'; // STRING_OK
}
else
{
szSubFolderOffset = m_szFolderOffset + L"UnknownFolder\\"; // STRING_OK
}
AddFolderToFolderList(&lpRows->aRow[ulRow].lpProps[EID].Value.bin, szSubFolderOffset);
}
}
}
if (lpRows) FreeProws(lpRows);
lpHierarchyTable->Release();
}
}
EndFolderWork();
}
void CMAPIProcessor::ProcessContentsTable(ULONG ulFlags)
{
if (!m_lpFolder) return;
enum
{
contPR_SUBJECT,
contPR_MESSAGE_CLASS,
contPR_MESSAGE_DELIVERY_TIME,
contPR_HASATTACH,
contPR_ENTRYID,
contPR_SEARCH_KEY,
contPR_RECORD_KEY,
contPidTagMid,
contNUM_COLS
};
static const SizedSPropTagArray(contNUM_COLS, contCols) =
{
contNUM_COLS,
PR_MESSAGE_CLASS,
PR_SUBJECT,
PR_MESSAGE_DELIVERY_TIME,
PR_HASATTACH,
PR_ENTRYID,
PR_SEARCH_KEY,
PR_RECORD_KEY,
PidTagMid,
};
auto hRes = S_OK;
LPMAPITABLE lpContentsTable = nullptr;
WC_MAPI(m_lpFolder->GetContentsTable(
ulFlags | fMapiUnicode,
&lpContentsTable));
if (SUCCEEDED(hRes) && lpContentsTable)
{
WC_MAPI(lpContentsTable->SetColumns(LPSPropTagArray(&contCols), TBL_BATCH));
}
if (SUCCEEDED(hRes) && lpContentsTable && m_lpResFolderContents)
{
DebugPrintRestriction(DBGGeneric, m_lpResFolderContents, NULL);
WC_MAPI(lpContentsTable->Restrict(m_lpResFolderContents, TBL_BATCH));
hRes = S_OK;
}
if (SUCCEEDED(hRes) && lpContentsTable && m_lpSort)
{
WC_MAPI(lpContentsTable->SortTable(m_lpSort, TBL_BATCH));
hRes = S_OK;
}
if (SUCCEEDED(hRes) && lpContentsTable)
{
ULONG ulCountRows = 0;
WC_MAPI(lpContentsTable->GetRowCount(0, &ulCountRows));
BeginContentsTableWork(ulFlags, ulCountRows);
LPSRowSet lpRows = nullptr;
ULONG i = 0;
for (;;)
{
// If we've output enough rows, stop
if (m_ulCount && i >= m_ulCount) break;
hRes = S_OK;
if (lpRows) FreeProws(lpRows);
lpRows = nullptr;
WC_MAPI(lpContentsTable->QueryRows(
255,
NULL,
&lpRows));
if (FAILED(hRes))
{
hRes = S_OK;
break;
}
if (!lpRows || !lpRows->cRows) break;
for (ULONG iRow = 0; iRow < lpRows->cRows; iRow++)
{
// If we've output enough rows, stop
if (m_ulCount && i >= m_ulCount) break;
if (!DoContentsTablePerRowWork(&lpRows->aRow[iRow], i++)) continue;
auto lpMsgEID = PpropFindProp(
lpRows->aRow[iRow].lpProps,
lpRows->aRow[iRow].cValues,
PR_ENTRYID);
if (!lpMsgEID) continue;
LPMESSAGE lpMessage = nullptr;
WC_H(CallOpenEntry(
NULL,
NULL,
m_lpFolder,
NULL,
lpMsgEID->Value.bin.cb,
reinterpret_cast<LPENTRYID>(lpMsgEID->Value.bin.lpb),
NULL,
MAPI_BEST_ACCESS,
NULL,
reinterpret_cast<LPUNKNOWN*>(&lpMessage)));
if (lpMessage)
{
auto bHasAttach = true;
auto lpMsgHasAttach = PpropFindProp(
lpRows->aRow[iRow].lpProps,
lpRows->aRow[iRow].cValues,
PR_HASATTACH);
if (lpMsgHasAttach)
{
bHasAttach = 0 != lpMsgHasAttach->Value.b;
}
ProcessMessage(lpMessage, bHasAttach, nullptr);
lpMessage->Release();
}
lpMessage = nullptr;
}
}
if (lpRows) FreeProws(lpRows);
lpContentsTable->Release();
}
EndContentsTableWork();
}
void CMAPIProcessor::ProcessMessage(_In_ LPMESSAGE lpMessage, bool bHasAttach, _In_opt_ LPVOID lpParentMessageData)
{
if (!lpMessage) return;
LPVOID lpData = nullptr;
if (BeginMessageWork(lpMessage, lpParentMessageData, &lpData))
{
ProcessRecipients(lpMessage, lpData);
ProcessAttachments(lpMessage, bHasAttach, lpData);
EndMessageWork(lpMessage, lpData);
}
}
void CMAPIProcessor::ProcessRecipients(_In_ LPMESSAGE lpMessage, _In_opt_ LPVOID lpData)
{
if (!lpMessage) return;
auto hRes = S_OK;
LPMAPITABLE lpRecipTable = nullptr;
LPSRowSet lpRows = nullptr;
if (!BeginRecipientWork(lpMessage, lpData)) return;
// get the recipient table
WC_MAPI(lpMessage->GetRecipientTable(
NULL,
&lpRecipTable));
if (lpRecipTable)
{
ULONG i = 0;
for (;;)
{
hRes = S_OK;
if (lpRows) FreeProws(lpRows);
lpRows = nullptr;
WC_MAPI(lpRecipTable->QueryRows(
255,
NULL,
&lpRows));
if (FAILED(hRes))
{
hRes = S_OK;
break;
}
if (!lpRows || !lpRows->cRows) break;
for (ULONG iRow = 0; iRow < lpRows->cRows; iRow++)
{
DoMessagePerRecipientWork(lpMessage, lpData, &lpRows->aRow[iRow], i++);
}
}
if (lpRows) FreeProws(lpRows);
if (lpRecipTable) lpRecipTable->Release();
}
EndRecipientWork(lpMessage, lpData);
}
void CMAPIProcessor::ProcessAttachments(_In_ LPMESSAGE lpMessage, bool bHasAttach, _In_opt_ LPVOID lpData)
{
if (!lpMessage) return;
enum
{
attPR_ATTACH_NUM,
atPR_ATTACH_METHOD,
attPR_ATTACH_FILENAME,
attPR_DISPLAY_NAME,
attNUM_COLS
};
static const SizedSPropTagArray(attNUM_COLS, attCols) =
{
attNUM_COLS,
PR_ATTACH_NUM,
PR_ATTACH_METHOD,
PR_ATTACH_FILENAME,
PR_DISPLAY_NAME,
};
auto hRes = S_OK;
LPMAPITABLE lpAttachTable = nullptr;
LPSRowSet lpRows = nullptr;
if (!BeginAttachmentWork(lpMessage, lpData)) return;
// Only get the attachment table if PR_HASATTACH was true or didn't exist.
if (bHasAttach)
{
// get the attachment table
WC_MAPI(lpMessage->GetAttachmentTable(
NULL,
&lpAttachTable));
}
if (SUCCEEDED(hRes) && lpAttachTable)
{
// Make sure we have the columns we need
WC_MAPI(lpAttachTable->SetColumns(LPSPropTagArray(&attCols), TBL_BATCH));
}
if (SUCCEEDED(hRes) && lpAttachTable)
{
ULONG i = 0;
for (;;)
{
hRes = S_OK;
if (lpRows) FreeProws(lpRows);
lpRows = nullptr;
WC_MAPI(lpAttachTable->QueryRows(
255,
NULL,
&lpRows));
if (FAILED(hRes))
{
hRes = S_OK;
break;
}
if (!lpRows || !lpRows->cRows) break;
for (ULONG iRow = 0; iRow < lpRows->cRows; iRow++)
{
hRes = S_OK;
auto lpAttachNum = PpropFindProp(
lpRows->aRow[iRow].lpProps,
lpRows->aRow[iRow].cValues,
PR_ATTACH_NUM);
if (lpAttachNum)
{
LPATTACH lpAttach = nullptr;
WC_MAPI(lpMessage->OpenAttach(
lpAttachNum->Value.l,
NULL,
MAPI_BEST_ACCESS,
static_cast<LPATTACH*>(&lpAttach)));
DoMessagePerAttachmentWork(lpMessage, lpData, &lpRows->aRow[iRow], lpAttach, i++);
// Check if the attachment is an embedded message - if it is, parse it as such!
auto lpAttachMethod = PpropFindProp(
lpRows->aRow->lpProps,
lpRows->aRow->cValues,
PR_ATTACH_METHOD);
if (lpAttach && lpAttachMethod && ATTACH_EMBEDDED_MSG == lpAttachMethod->Value.l)
{
LPMESSAGE lpAttachMsg = nullptr;
WC_MAPI(lpAttach->OpenProperty(
PR_ATTACH_DATA_OBJ,
const_cast<LPIID>(&IID_IMessage),
0,
NULL, // MAPI_MODIFY,
reinterpret_cast<LPUNKNOWN *>(&lpAttachMsg)));
if (lpAttachMsg)
{
// Just assume this message might have attachments
ProcessMessage(lpAttachMsg, true, lpData);
lpAttachMsg->Release();
}
}
if (lpAttach)
{
lpAttach->Release();
lpAttach = nullptr;
}
}
}
}
if (lpRows) FreeProws(lpRows);
lpAttachTable->Release();
}
EndAttachmentWork(lpMessage, lpData);
}
// --------------------------------------------------------------------------------- //
// List Functions
// --------------------------------------------------------------------------------- //
void CMAPIProcessor::AddFolderToFolderList(_In_opt_ LPSBinary lpFolderEID, _In_ wstring szFolderOffsetPath)
{
auto hRes = S_OK;
LPFOLDERNODE lpNewNode = nullptr;
WC_H(MAPIAllocateBuffer(sizeof(FolderNode), reinterpret_cast<LPVOID*>(&lpNewNode)));
lpNewNode->lpNextFolder = nullptr;
lpNewNode->lpFolderEID = nullptr;
if (lpFolderEID)
{
WC_H(MAPIAllocateMore(
static_cast<ULONG>(sizeof(SBinary)),
lpNewNode,
reinterpret_cast<LPVOID*>(&lpNewNode->lpFolderEID)));
WC_H(CopySBinary(lpNewNode->lpFolderEID, lpFolderEID, lpNewNode));
}
lpNewNode->szFolderOffsetPath = szFolderOffsetPath;
if (!m_lpListHead)
{
m_lpListHead = lpNewNode;
m_lpListTail = lpNewNode;
}
else
{
m_lpListTail->lpNextFolder = lpNewNode;
m_lpListTail = lpNewNode;
}
}
// Call OpenEntry on the first folder in the list, remove it from the list
// If we fail to open a folder, move on to the next item in the list
void CMAPIProcessor::OpenFirstFolderInList()
{
auto hRes = S_OK;
LPMAPIFOLDER lpFolder = nullptr;
m_szFolderOffset.clear();
if (m_lpFolder) m_lpFolder->Release();
m_lpFolder = nullptr;
// loop over nodes until we open one or run out
while (!lpFolder && m_lpListHead)
{
hRes = S_OK;
WC_H(CallOpenEntry(
m_lpMDB,
NULL,
NULL,
NULL,
m_lpListHead->lpFolderEID,
NULL,
MAPI_BEST_ACCESS,
NULL,
reinterpret_cast<LPUNKNOWN*>(&lpFolder)));
if (!m_lpListHead->szFolderOffsetPath.empty())
{
m_szFolderOffset = m_lpListHead->szFolderOffsetPath;
}
auto lpTempNode = m_lpListHead;
m_lpListHead = m_lpListHead->lpNextFolder;
if (m_lpListHead == lpTempNode) m_lpListTail = nullptr;
MAPIFreeBuffer(lpTempNode);
}
m_lpFolder = lpFolder;
}
// Clean up the list
void CMAPIProcessor::FreeFolderList()
{
if (!m_lpListHead) return;
while (m_lpListHead)
{
auto lpTempNode = m_lpListHead->lpNextFolder;
MAPIFreeBuffer(m_lpListHead);
m_lpListHead = lpTempNode;
}
m_lpListTail = nullptr;
}
// --------------------------------------------------------------------------------- //
// Worker Functions
// --------------------------------------------------------------------------------- //
void CMAPIProcessor::BeginMailboxTableWork(_In_ wstring /*szExchangeServerName*/)
{
}
void CMAPIProcessor::DoMailboxTablePerRowWork(_In_ LPMDB /*lpMDB*/, _In_ LPSRow /*lpSRow*/, ULONG /*ulCurRow*/)
{
}
void CMAPIProcessor::EndMailboxTableWork()
{
}
void CMAPIProcessor::BeginStoreWork()
{
}
void CMAPIProcessor::EndStoreWork()
{
}
void CMAPIProcessor::BeginProcessFoldersWork()
{
}
void CMAPIProcessor::DoProcessFoldersPerFolderWork()
{
}
void CMAPIProcessor::EndProcessFoldersWork()
{
}
void CMAPIProcessor::BeginFolderWork()
{
}
void CMAPIProcessor::DoFolderPerHierarchyTableRowWork(_In_ LPSRow /*lpSRow*/)
{
}
void CMAPIProcessor::EndFolderWork()
{
}
void CMAPIProcessor::BeginContentsTableWork(ULONG /*ulFlags*/, ULONG /*ulCountRows*/)
{
}
bool CMAPIProcessor::DoContentsTablePerRowWork(_In_ LPSRow /*lpSRow*/, ULONG /*ulCurRow*/)
{
return true; // Keep processing
}
void CMAPIProcessor::EndContentsTableWork()
{
}
bool CMAPIProcessor::BeginMessageWork(_In_ LPMESSAGE /*lpMessage*/, _In_opt_ LPVOID /*lpParentMessageData*/, _Deref_out_opt_ LPVOID* lpData)
{
if (lpData) *lpData = nullptr;
return true; // Keep processing
}
bool CMAPIProcessor::BeginRecipientWork(_In_ LPMESSAGE /*lpMessage*/, _In_opt_ LPVOID /*lpData*/)
{
return true; // Keep processing
}
void CMAPIProcessor::DoMessagePerRecipientWork(_In_ LPMESSAGE /*lpMessage*/, _In_ LPVOID /*lpData*/, _In_ LPSRow /*lpSRow*/, ULONG /*ulCurRow*/)
{
}
void CMAPIProcessor::EndRecipientWork(_In_ LPMESSAGE /*lpMessage*/, _In_ LPVOID /*lpData*/)
{
}
bool CMAPIProcessor::BeginAttachmentWork(_In_ LPMESSAGE /*lpMessage*/, _In_opt_ LPVOID /*lpData*/)
{
return true; // Keep processing
}
void CMAPIProcessor::DoMessagePerAttachmentWork(_In_ LPMESSAGE /*lpMessage*/, _In_ LPVOID /*lpData*/, _In_ LPSRow /*lpSRow*/, _In_ LPATTACH /*lpAttach*/, ULONG /*ulCurRow*/)
{
}
void CMAPIProcessor::EndAttachmentWork(_In_ LPMESSAGE /*lpMessage*/, _In_opt_ LPVOID /*lpData*/)
{
}
void CMAPIProcessor::EndMessageWork(_In_ LPMESSAGE /*lpMessage*/, _In_opt_ LPVOID /*lpData*/)
{
}