pst-extractor 1.9.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ColumnDescriptor.class.d.ts +26 -26
- package/dist/ColumnDescriptor.class.js +51 -51
- package/dist/DescriptorIndexNode.class.d.ts +25 -26
- package/dist/DescriptorIndexNode.class.js +53 -53
- package/dist/LZFu.class.d.ts +11 -12
- package/dist/LZFu.class.js +95 -95
- package/dist/NodeInfo.class.d.ts +33 -33
- package/dist/NodeInfo.class.js +52 -52
- package/dist/NodeMap.class.d.ts +35 -35
- package/dist/NodeMap.class.js +86 -86
- package/dist/OffsetIndexItem.class.d.ts +23 -24
- package/dist/OffsetIndexItem.class.js +45 -45
- package/dist/OutlookProperties.d.ts +275 -275
- package/dist/OutlookProperties.js +281 -281
- package/dist/PSTActivity.class.d.ts +103 -103
- package/dist/PSTActivity.class.js +144 -144
- package/dist/PSTAppointment.class.d.ts +270 -271
- package/dist/PSTAppointment.class.js +376 -376
- package/dist/PSTAttachment.class.d.ts +172 -172
- package/dist/PSTAttachment.class.js +317 -317
- package/dist/PSTContact.class.d.ts +884 -884
- package/dist/PSTContact.class.js +1227 -1227
- package/dist/PSTDescriptorItem.class.d.ts +45 -46
- package/dist/PSTDescriptorItem.class.js +99 -99
- package/dist/PSTFile.class.d.ts +215 -216
- package/dist/PSTFile.class.js +830 -818
- package/dist/PSTFolder.class.d.ts +129 -129
- package/dist/PSTFolder.class.js +318 -310
- package/dist/PSTMessage.class.d.ts +788 -789
- package/dist/PSTMessage.class.js +1321 -1321
- package/dist/PSTMessageStore.class.d.ts +13 -13
- package/dist/PSTMessageStore.class.js +17 -17
- package/dist/PSTNodeInputStream.class.d.ts +122 -123
- package/dist/PSTNodeInputStream.class.js +524 -514
- package/dist/PSTObject.class.d.ts +133 -134
- package/dist/PSTObject.class.js +326 -326
- package/dist/PSTRecipient.class.d.ts +65 -65
- package/dist/PSTRecipient.class.js +103 -103
- package/dist/PSTTable.class.d.ts +52 -52
- package/dist/PSTTable.class.js +175 -175
- package/dist/PSTTable7C.class.d.ts +45 -45
- package/dist/PSTTable7C.class.js +282 -281
- package/dist/PSTTableBC.class.d.ts +31 -31
- package/dist/PSTTableBC.class.js +111 -111
- package/dist/PSTTableItem.class.d.ts +47 -48
- package/dist/PSTTableItem.class.js +124 -124
- package/dist/PSTTask.class.d.ts +146 -146
- package/dist/PSTTask.class.js +205 -205
- package/dist/PSTUtil.class.d.ts +134 -135
- package/dist/PSTUtil.class.js +795 -795
- package/dist/RecurrencePattern.class.d.ts +49 -50
- package/dist/RecurrencePattern.class.js +120 -120
- package/dist/index.d.ts +6 -6
- package/dist/index.js +15 -15
- package/example/package.json +6 -6
- package/example/yarn.lock +120 -67
- package/junit.xml +68 -68
- package/package.json +26 -26
- package/readme.md +3 -3
package/dist/PSTFolder.class.js
CHANGED
|
@@ -1,310 +1,318 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PSTFolder = void 0;
|
|
7
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
-
const long_1 = __importDefault(require("long"));
|
|
9
|
-
const OutlookProperties_1 = require("./OutlookProperties");
|
|
10
|
-
const PSTNodeInputStream_class_1 = require("./PSTNodeInputStream.class");
|
|
11
|
-
const PSTTable7C_class_1 = require("./PSTTable7C.class");
|
|
12
|
-
const PSTObject_class_1 = require("./PSTObject.class");
|
|
13
|
-
const PSTUtil_class_1 = require("./PSTUtil.class");
|
|
14
|
-
/**
|
|
15
|
-
* Represents a folder in the PST File. Allows you to access child folders or items.
|
|
16
|
-
* Items are accessed through a sort of cursor arrangement. This allows for
|
|
17
|
-
* incremental reading of a folder which may have _lots_ of emails.
|
|
18
|
-
* @export
|
|
19
|
-
* @class PSTFolder
|
|
20
|
-
* @extends {PSTObject}
|
|
21
|
-
*/
|
|
22
|
-
class PSTFolder extends PSTObject_class_1.PSTObject {
|
|
23
|
-
/**
|
|
24
|
-
* Creates an instance of PSTFolder.
|
|
25
|
-
* Represents a folder in the PST File. Allows you to access child folders or items.
|
|
26
|
-
* Items are accessed through a sort of cursor arrangement. This allows for
|
|
27
|
-
* incremental reading of a folder which may have _lots_ of emails.
|
|
28
|
-
* @param {PSTFile} pstFile
|
|
29
|
-
* @param {DescriptorIndexNode} descriptorIndexNode
|
|
30
|
-
* @param {PSTTableBC} [table]
|
|
31
|
-
* @param {Map<number, PSTDescriptorItem>} [localDescriptorItems]
|
|
32
|
-
* @memberof PSTFolder
|
|
33
|
-
*/
|
|
34
|
-
constructor(pstFile, descriptorIndexNode, table, localDescriptorItems) {
|
|
35
|
-
super(pstFile, descriptorIndexNode);
|
|
36
|
-
this.currentEmailIndex = 0;
|
|
37
|
-
this.subfoldersTable = null;
|
|
38
|
-
this.emailsTable = null;
|
|
39
|
-
this.fallbackEmailsTable = null;
|
|
40
|
-
if (table) {
|
|
41
|
-
// pre-populate folder object with values
|
|
42
|
-
this.prePopulate(descriptorIndexNode, table, localDescriptorItems);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Get folders in one fell swoop, since there's not usually thousands of them.
|
|
47
|
-
* @returns {PSTFolder[]}
|
|
48
|
-
* @memberof PSTFolder
|
|
49
|
-
*/
|
|
50
|
-
getSubFolders() {
|
|
51
|
-
const output = [];
|
|
52
|
-
try {
|
|
53
|
-
this.initSubfoldersTable();
|
|
54
|
-
if (this.subfoldersTable) {
|
|
55
|
-
const itemMapSet = this.subfoldersTable.getItems();
|
|
56
|
-
for (const itemMap of itemMapSet) {
|
|
57
|
-
const item = itemMap.get(26610);
|
|
58
|
-
if (item) {
|
|
59
|
-
output.push(PSTUtil_class_1.PSTUtil.detectAndLoadPSTObject(this.pstFile, long_1.default.fromNumber(item.entryValueReference)));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch (err) {
|
|
65
|
-
console.error("PSTFolder::getSubFolders Can't get child folders for folder " +
|
|
66
|
-
this.displayName +
|
|
67
|
-
'\n' +
|
|
68
|
-
err);
|
|
69
|
-
throw err;
|
|
70
|
-
}
|
|
71
|
-
return output;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Load subfolders table.
|
|
75
|
-
* @private
|
|
76
|
-
* @returns
|
|
77
|
-
* @memberof PSTFolder
|
|
78
|
-
*/
|
|
79
|
-
initSubfoldersTable() {
|
|
80
|
-
if (this.subfoldersTable) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
if (!this.descriptorIndexNode) {
|
|
84
|
-
throw new Error('PSTFolder::initSubfoldersTable descriptorIndexNode is null');
|
|
85
|
-
}
|
|
86
|
-
const folderDescriptorIndex = long_1.default.fromValue(this.descriptorIndexNode.descriptorIdentifier + 11);
|
|
87
|
-
try {
|
|
88
|
-
const folderDescriptor = this.pstFile.getDescriptorIndexNode(folderDescriptorIndex);
|
|
89
|
-
let tmp = undefined;
|
|
90
|
-
if (folderDescriptor.localDescriptorsOffsetIndexIdentifier.greaterThan(0)) {
|
|
91
|
-
tmp = this.pstFile.getPSTDescriptorItems(folderDescriptor.localDescriptorsOffsetIndexIdentifier);
|
|
92
|
-
}
|
|
93
|
-
const offsetIndexItem = this.pstFile.getOffsetIndexNode(folderDescriptor.dataOffsetIndexIdentifier);
|
|
94
|
-
const pstNodeInputStream = new PSTNodeInputStream_class_1.PSTNodeInputStream(this.pstFile, offsetIndexItem);
|
|
95
|
-
this.subfoldersTable = new PSTTable7C_class_1.PSTTable7C(pstNodeInputStream, tmp);
|
|
96
|
-
}
|
|
97
|
-
catch (err) {
|
|
98
|
-
console.error("PSTFolder::initSubfoldersTable Can't get child folders for folder " +
|
|
99
|
-
this.displayName +
|
|
100
|
-
'\n' +
|
|
101
|
-
err);
|
|
102
|
-
throw err;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
// get all of the children
|
|
106
|
-
initEmailsTable() {
|
|
107
|
-
if (this.emailsTable || this.fallbackEmailsTable) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
// some folder types don't have children:
|
|
111
|
-
if (this.getNodeType() == PSTUtil_class_1.PSTUtil.NID_TYPE_SEARCH_FOLDER) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (!this.descriptorIndexNode) {
|
|
115
|
-
throw new Error('PSTFolder::initEmailsTable descriptorIndexNode is null');
|
|
116
|
-
}
|
|
117
|
-
try {
|
|
118
|
-
const folderDescriptorIndex = this.descriptorIndexNode.descriptorIdentifier + 12;
|
|
119
|
-
const folderDescriptor = this.pstFile.getDescriptorIndexNode(long_1.default.fromNumber(folderDescriptorIndex));
|
|
120
|
-
let tmp = undefined;
|
|
121
|
-
if (folderDescriptor.localDescriptorsOffsetIndexIdentifier.greaterThan(0)) {
|
|
122
|
-
tmp = this.pstFile.getPSTDescriptorItems(folderDescriptor.localDescriptorsOffsetIndexIdentifier);
|
|
123
|
-
}
|
|
124
|
-
const offsetIndexItem = this.pstFile.getOffsetIndexNode(folderDescriptor.dataOffsetIndexIdentifier);
|
|
125
|
-
const pstNodeInputStream = new PSTNodeInputStream_class_1.PSTNodeInputStream(this.pstFile, offsetIndexItem);
|
|
126
|
-
this.emailsTable = new PSTTable7C_class_1.PSTTable7C(pstNodeInputStream, tmp, 0x67f2);
|
|
127
|
-
}
|
|
128
|
-
catch (err) {
|
|
129
|
-
// fallback to children as listed in the descriptor b-tree
|
|
130
|
-
// console.log(`PSTFolder::initEmailsTable Can't get child folders for folder {this.displayName}, resorting to using alternate tree`);
|
|
131
|
-
const tree = this.pstFile.getChildDescriptorTree();
|
|
132
|
-
this.fallbackEmailsTable = [];
|
|
133
|
-
const allChildren = tree.get(this.descriptorIndexNode.descriptorIdentifier);
|
|
134
|
-
if (allChildren) {
|
|
135
|
-
// remove items that aren't messages
|
|
136
|
-
for (const node of allChildren) {
|
|
137
|
-
if (node != null &&
|
|
138
|
-
this.getNodeType(node.descriptorIdentifier) ==
|
|
139
|
-
PSTUtil_class_1.PSTUtil.NID_TYPE_NORMAL_MESSAGE) {
|
|
140
|
-
this.fallbackEmailsTable.push(node);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Get the next child of this folder. As there could be thousands of emails, we have these
|
|
148
|
-
* kind of cursor operations.
|
|
149
|
-
* @returns {*}
|
|
150
|
-
* @memberof PSTFolder
|
|
151
|
-
*/
|
|
152
|
-
getNextChild() {
|
|
153
|
-
this.initEmailsTable();
|
|
154
|
-
if (this.emailsTable) {
|
|
155
|
-
if (this.currentEmailIndex == this.contentCount) {
|
|
156
|
-
// no more!
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
// get the emails from the rows in the main email table
|
|
160
|
-
const rows = this.emailsTable.getItems(this.currentEmailIndex, 1);
|
|
161
|
-
const emailRow = rows[0].get(0x67f2);
|
|
162
|
-
if ((emailRow && emailRow.itemIndex == -1) || !emailRow) {
|
|
163
|
-
// no more!
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
const childDescriptor = this.pstFile.getDescriptorIndexNode(long_1.default.fromNumber(emailRow.entryValueReference));
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
this.currentEmailIndex
|
|
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
|
-
this.
|
|
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
|
-
* @memberof PSTFolder
|
|
295
|
-
*/
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PSTFolder = void 0;
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
+
const long_1 = __importDefault(require("long"));
|
|
9
|
+
const OutlookProperties_1 = require("./OutlookProperties");
|
|
10
|
+
const PSTNodeInputStream_class_1 = require("./PSTNodeInputStream.class");
|
|
11
|
+
const PSTTable7C_class_1 = require("./PSTTable7C.class");
|
|
12
|
+
const PSTObject_class_1 = require("./PSTObject.class");
|
|
13
|
+
const PSTUtil_class_1 = require("./PSTUtil.class");
|
|
14
|
+
/**
|
|
15
|
+
* Represents a folder in the PST File. Allows you to access child folders or items.
|
|
16
|
+
* Items are accessed through a sort of cursor arrangement. This allows for
|
|
17
|
+
* incremental reading of a folder which may have _lots_ of emails.
|
|
18
|
+
* @export
|
|
19
|
+
* @class PSTFolder
|
|
20
|
+
* @extends {PSTObject}
|
|
21
|
+
*/
|
|
22
|
+
class PSTFolder extends PSTObject_class_1.PSTObject {
|
|
23
|
+
/**
|
|
24
|
+
* Creates an instance of PSTFolder.
|
|
25
|
+
* Represents a folder in the PST File. Allows you to access child folders or items.
|
|
26
|
+
* Items are accessed through a sort of cursor arrangement. This allows for
|
|
27
|
+
* incremental reading of a folder which may have _lots_ of emails.
|
|
28
|
+
* @param {PSTFile} pstFile
|
|
29
|
+
* @param {DescriptorIndexNode} descriptorIndexNode
|
|
30
|
+
* @param {PSTTableBC} [table]
|
|
31
|
+
* @param {Map<number, PSTDescriptorItem>} [localDescriptorItems]
|
|
32
|
+
* @memberof PSTFolder
|
|
33
|
+
*/
|
|
34
|
+
constructor(pstFile, descriptorIndexNode, table, localDescriptorItems) {
|
|
35
|
+
super(pstFile, descriptorIndexNode);
|
|
36
|
+
this.currentEmailIndex = 0;
|
|
37
|
+
this.subfoldersTable = null;
|
|
38
|
+
this.emailsTable = null;
|
|
39
|
+
this.fallbackEmailsTable = null;
|
|
40
|
+
if (table) {
|
|
41
|
+
// pre-populate folder object with values
|
|
42
|
+
this.prePopulate(descriptorIndexNode, table, localDescriptorItems);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get folders in one fell swoop, since there's not usually thousands of them.
|
|
47
|
+
* @returns {PSTFolder[]}
|
|
48
|
+
* @memberof PSTFolder
|
|
49
|
+
*/
|
|
50
|
+
getSubFolders() {
|
|
51
|
+
const output = [];
|
|
52
|
+
try {
|
|
53
|
+
this.initSubfoldersTable();
|
|
54
|
+
if (this.subfoldersTable) {
|
|
55
|
+
const itemMapSet = this.subfoldersTable.getItems();
|
|
56
|
+
for (const itemMap of itemMapSet) {
|
|
57
|
+
const item = itemMap.get(26610);
|
|
58
|
+
if (item) {
|
|
59
|
+
output.push(PSTUtil_class_1.PSTUtil.detectAndLoadPSTObject(this.pstFile, long_1.default.fromNumber(item.entryValueReference)));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
console.error("PSTFolder::getSubFolders Can't get child folders for folder " +
|
|
66
|
+
this.displayName +
|
|
67
|
+
'\n' +
|
|
68
|
+
err);
|
|
69
|
+
throw err;
|
|
70
|
+
}
|
|
71
|
+
return output;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Load subfolders table.
|
|
75
|
+
* @private
|
|
76
|
+
* @returns
|
|
77
|
+
* @memberof PSTFolder
|
|
78
|
+
*/
|
|
79
|
+
initSubfoldersTable() {
|
|
80
|
+
if (this.subfoldersTable) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (!this.descriptorIndexNode) {
|
|
84
|
+
throw new Error('PSTFolder::initSubfoldersTable descriptorIndexNode is null');
|
|
85
|
+
}
|
|
86
|
+
const folderDescriptorIndex = long_1.default.fromValue(this.descriptorIndexNode.descriptorIdentifier + 11);
|
|
87
|
+
try {
|
|
88
|
+
const folderDescriptor = this.pstFile.getDescriptorIndexNode(folderDescriptorIndex);
|
|
89
|
+
let tmp = undefined;
|
|
90
|
+
if (folderDescriptor.localDescriptorsOffsetIndexIdentifier.greaterThan(0)) {
|
|
91
|
+
tmp = this.pstFile.getPSTDescriptorItems(folderDescriptor.localDescriptorsOffsetIndexIdentifier);
|
|
92
|
+
}
|
|
93
|
+
const offsetIndexItem = this.pstFile.getOffsetIndexNode(folderDescriptor.dataOffsetIndexIdentifier);
|
|
94
|
+
const pstNodeInputStream = new PSTNodeInputStream_class_1.PSTNodeInputStream(this.pstFile, offsetIndexItem);
|
|
95
|
+
this.subfoldersTable = new PSTTable7C_class_1.PSTTable7C(pstNodeInputStream, tmp);
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
console.error("PSTFolder::initSubfoldersTable Can't get child folders for folder " +
|
|
99
|
+
this.displayName +
|
|
100
|
+
'\n' +
|
|
101
|
+
err);
|
|
102
|
+
throw err;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// get all of the children
|
|
106
|
+
initEmailsTable() {
|
|
107
|
+
if (this.emailsTable || this.fallbackEmailsTable) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
// some folder types don't have children:
|
|
111
|
+
if (this.getNodeType() == PSTUtil_class_1.PSTUtil.NID_TYPE_SEARCH_FOLDER) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (!this.descriptorIndexNode) {
|
|
115
|
+
throw new Error('PSTFolder::initEmailsTable descriptorIndexNode is null');
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const folderDescriptorIndex = this.descriptorIndexNode.descriptorIdentifier + 12;
|
|
119
|
+
const folderDescriptor = this.pstFile.getDescriptorIndexNode(long_1.default.fromNumber(folderDescriptorIndex));
|
|
120
|
+
let tmp = undefined;
|
|
121
|
+
if (folderDescriptor.localDescriptorsOffsetIndexIdentifier.greaterThan(0)) {
|
|
122
|
+
tmp = this.pstFile.getPSTDescriptorItems(folderDescriptor.localDescriptorsOffsetIndexIdentifier);
|
|
123
|
+
}
|
|
124
|
+
const offsetIndexItem = this.pstFile.getOffsetIndexNode(folderDescriptor.dataOffsetIndexIdentifier);
|
|
125
|
+
const pstNodeInputStream = new PSTNodeInputStream_class_1.PSTNodeInputStream(this.pstFile, offsetIndexItem);
|
|
126
|
+
this.emailsTable = new PSTTable7C_class_1.PSTTable7C(pstNodeInputStream, tmp, 0x67f2);
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
// fallback to children as listed in the descriptor b-tree
|
|
130
|
+
// console.log(`PSTFolder::initEmailsTable Can't get child folders for folder {this.displayName}, resorting to using alternate tree`);
|
|
131
|
+
const tree = this.pstFile.getChildDescriptorTree();
|
|
132
|
+
this.fallbackEmailsTable = [];
|
|
133
|
+
const allChildren = tree.get(this.descriptorIndexNode.descriptorIdentifier);
|
|
134
|
+
if (allChildren) {
|
|
135
|
+
// remove items that aren't messages
|
|
136
|
+
for (const node of allChildren) {
|
|
137
|
+
if (node != null &&
|
|
138
|
+
this.getNodeType(node.descriptorIdentifier) ==
|
|
139
|
+
PSTUtil_class_1.PSTUtil.NID_TYPE_NORMAL_MESSAGE) {
|
|
140
|
+
this.fallbackEmailsTable.push(node);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get the next child of this folder. As there could be thousands of emails, we have these
|
|
148
|
+
* kind of cursor operations.
|
|
149
|
+
* @returns {*}
|
|
150
|
+
* @memberof PSTFolder
|
|
151
|
+
*/
|
|
152
|
+
getNextChild() {
|
|
153
|
+
this.initEmailsTable();
|
|
154
|
+
if (this.emailsTable) {
|
|
155
|
+
if (this.currentEmailIndex == this.contentCount) {
|
|
156
|
+
// no more!
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
// get the emails from the rows in the main email table
|
|
160
|
+
const rows = this.emailsTable.getItems(this.currentEmailIndex, 1);
|
|
161
|
+
const emailRow = rows[0].get(0x67f2);
|
|
162
|
+
if ((emailRow && emailRow.itemIndex == -1) || !emailRow) {
|
|
163
|
+
// no more!
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
const childDescriptor = this.pstFile.getDescriptorIndexNode(long_1.default.fromNumber(emailRow.entryValueReference));
|
|
167
|
+
let child;
|
|
168
|
+
try {
|
|
169
|
+
child = PSTUtil_class_1.PSTUtil.detectAndLoadPSTObject(this.pstFile, childDescriptor);
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
console.log('Exception Error in No: ', this.currentEmailIndex);
|
|
173
|
+
this.currentEmailIndex++;
|
|
174
|
+
return this.getNextChild();
|
|
175
|
+
}
|
|
176
|
+
this.currentEmailIndex++;
|
|
177
|
+
return child;
|
|
178
|
+
}
|
|
179
|
+
else if (this.fallbackEmailsTable) {
|
|
180
|
+
if (this.currentEmailIndex >= this.contentCount ||
|
|
181
|
+
this.currentEmailIndex >= this.fallbackEmailsTable.length) {
|
|
182
|
+
// no more!
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
const childDescriptor = this.fallbackEmailsTable[this.currentEmailIndex];
|
|
186
|
+
const child = PSTUtil_class_1.PSTUtil.detectAndLoadPSTObject(this.pstFile, childDescriptor);
|
|
187
|
+
this.currentEmailIndex++;
|
|
188
|
+
return child;
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Move the internal folder cursor to the desired position position 0 is before the first record.
|
|
194
|
+
* @param {number} newIndex
|
|
195
|
+
* @returns
|
|
196
|
+
* @memberof PSTFolder
|
|
197
|
+
*/
|
|
198
|
+
moveChildCursorTo(newIndex) {
|
|
199
|
+
this.initEmailsTable();
|
|
200
|
+
if (newIndex < 1) {
|
|
201
|
+
this.currentEmailIndex = 0;
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (newIndex > this.contentCount) {
|
|
205
|
+
newIndex = this.contentCount;
|
|
206
|
+
}
|
|
207
|
+
this.currentEmailIndex = newIndex;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The number of child folders in this folder
|
|
211
|
+
* @readonly
|
|
212
|
+
* @type {number}
|
|
213
|
+
* @memberof PSTFolder
|
|
214
|
+
*/
|
|
215
|
+
get subFolderCount() {
|
|
216
|
+
this.initSubfoldersTable();
|
|
217
|
+
if (this.subfoldersTable != null) {
|
|
218
|
+
return this.subfoldersTable.rowCount;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
return 0;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Number of emails in this folder
|
|
226
|
+
* @readonly
|
|
227
|
+
* @type {number}
|
|
228
|
+
* @memberof PSTFolder
|
|
229
|
+
*/
|
|
230
|
+
get emailCount() {
|
|
231
|
+
this.initEmailsTable();
|
|
232
|
+
if (this.emailsTable == null) {
|
|
233
|
+
return -1;
|
|
234
|
+
}
|
|
235
|
+
return this.emailsTable.rowCount;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Contains a constant that indicates the folder type.
|
|
239
|
+
* https://msdn.microsoft.com/en-us/library/office/cc815373.aspx
|
|
240
|
+
* @readonly
|
|
241
|
+
* @type {number}
|
|
242
|
+
* @memberof PSTFolder
|
|
243
|
+
*/
|
|
244
|
+
get folderType() {
|
|
245
|
+
return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_FOLDER_TYPE);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Contains the number of messages in a folder, as computed by the message store.
|
|
249
|
+
* For a number calculated by the library use getEmailCount
|
|
250
|
+
* @readonly
|
|
251
|
+
* @type {number}
|
|
252
|
+
* @memberof PSTFolder
|
|
253
|
+
*/
|
|
254
|
+
get contentCount() {
|
|
255
|
+
return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTENT_COUNT);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Contains the number of unread messages in a folder, as computed by the message store.
|
|
259
|
+
* https://msdn.microsoft.com/en-us/library/office/cc841964.aspx
|
|
260
|
+
* @readonly
|
|
261
|
+
* @type {number}
|
|
262
|
+
* @memberof PSTFolder
|
|
263
|
+
*/
|
|
264
|
+
get unreadCount() {
|
|
265
|
+
return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTENT_UNREAD);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Contains TRUE if a folder contains subfolders.
|
|
269
|
+
* once again, read from the PST, use getSubFolderCount if you want to know
|
|
270
|
+
* @readonly
|
|
271
|
+
* @type {boolean}
|
|
272
|
+
* @memberof PSTFolder
|
|
273
|
+
*/
|
|
274
|
+
get hasSubfolders() {
|
|
275
|
+
return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_SUBFOLDERS) != 0;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Contains a text string describing the type of a folder. Although this property is
|
|
279
|
+
* generally ignored, versions of Microsoft® Exchange Server prior to Exchange Server
|
|
280
|
+
* 2003 Mailbox Manager expect this property to be present.
|
|
281
|
+
* https://msdn.microsoft.com/en-us/library/office/cc839839.aspx
|
|
282
|
+
* @readonly
|
|
283
|
+
* @type {string}
|
|
284
|
+
* @memberof PSTFolder
|
|
285
|
+
*/
|
|
286
|
+
get containerClass() {
|
|
287
|
+
return this.getStringItem(OutlookProperties_1.OutlookProperties.PR_CONTAINER_CLASS);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Contains a bitmask of flags describing capabilities of an address book container.
|
|
291
|
+
* https://msdn.microsoft.com/en-us/library/office/cc839610.aspx
|
|
292
|
+
* @readonly
|
|
293
|
+
* @type {number}
|
|
294
|
+
* @memberof PSTFolder
|
|
295
|
+
*/
|
|
296
|
+
get containerFlags() {
|
|
297
|
+
return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTAINER_FLAGS);
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* JSON stringify the object properties.
|
|
301
|
+
* @returns {string}
|
|
302
|
+
* @memberof PSTFolder
|
|
303
|
+
*/
|
|
304
|
+
toJSON() {
|
|
305
|
+
const clone = Object.assign({
|
|
306
|
+
subFolderCount: this.subFolderCount,
|
|
307
|
+
emailCount: this.emailCount,
|
|
308
|
+
folderType: this.folderType,
|
|
309
|
+
contentCount: this.contentCount,
|
|
310
|
+
unreadCount: this.unreadCount,
|
|
311
|
+
hasSubfolders: this.hasSubfolders,
|
|
312
|
+
containerClass: this.containerClass,
|
|
313
|
+
containerFlags: this.containerFlags,
|
|
314
|
+
}, this);
|
|
315
|
+
return clone;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
exports.PSTFolder = PSTFolder;
|