Mercurial > libpst
comparison src/libpst.c @ 154:581fab9f1dc7
avoid emitting bogus empty email messages into contacts and calendar files
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Sat, 14 Mar 2009 15:13:27 -0700 |
parents | 0b1766da9be8 |
children | 252ad66d3d6e |
comparison
equal
deleted
inserted
replaced
153:0b1766da9be8 | 154:581fab9f1dc7 |
---|---|
273 static void add_descriptor_to_list(pst_desc_ll *node, pst_desc_ll **head, pst_desc_ll **tail); | 273 static void add_descriptor_to_list(pst_desc_ll *node, pst_desc_ll **head, pst_desc_ll **tail); |
274 static void add_descriptor_to_list(pst_desc_ll *node, pst_desc_ll **head, pst_desc_ll **tail) | 274 static void add_descriptor_to_list(pst_desc_ll *node, pst_desc_ll **head, pst_desc_ll **tail) |
275 { | 275 { |
276 DEBUG_ENT("add_descriptor_to_list"); | 276 DEBUG_ENT("add_descriptor_to_list"); |
277 //DEBUG_INDEX(("Added node %#"PRIx64" parent %#"PRIx64" real parent %#"PRIx64" prev %#"PRIx64" next %#"PRIx64"\n", | 277 //DEBUG_INDEX(("Added node %#"PRIx64" parent %#"PRIx64" real parent %#"PRIx64" prev %#"PRIx64" next %#"PRIx64"\n", |
278 // node->id, node->parent_id, | 278 // node->id, node->parent_d_id, |
279 // (node->parent ? node->parent->id : (uint64_t)0), | 279 // (node->parent ? node->parent->id : (uint64_t)0), |
280 // (node->prev ? node->prev->id : (uint64_t)0), | 280 // (node->prev ? node->prev->id : (uint64_t)0), |
281 // (node->next ? node->next->id : (uint64_t)0))); | 281 // (node->next ? node->next->id : (uint64_t)0))); |
282 if (*tail) (*tail)->next = node; | 282 if (*tail) (*tail)->next = node; |
283 if (!(*head)) *head = node; | 283 if (!(*head)) *head = node; |
333 else if (node->parent_d_id == node->d_id) { | 333 else if (node->parent_d_id == node->d_id) { |
334 // add top level node to the descriptor tree | 334 // add top level node to the descriptor tree |
335 DEBUG_INDEX(("%#"PRIx64" is its own parent. What is this world coming to?\n")); | 335 DEBUG_INDEX(("%#"PRIx64" is its own parent. What is this world coming to?\n")); |
336 add_descriptor_to_list(node, &pf->d_head, &pf->d_tail); | 336 add_descriptor_to_list(node, &pf->d_head, &pf->d_tail); |
337 } else { | 337 } else { |
338 //DEBUG_INDEX(("Searching for parent %#"PRIx64" of %#"PRIx64"\n", node->parent_id, node->id)); | 338 //DEBUG_INDEX(("Searching for parent %#"PRIx64" of %#"PRIx64"\n", node->parent_d_id, node->d_id)); |
339 pst_desc_ll *parent = pst_getDptr(pf, node->parent_d_id); | 339 pst_desc_ll *parent = pst_getDptr(pf, node->parent_d_id); |
340 if (parent) { | 340 if (parent) { |
341 //DEBUG_INDEX(("Found parent %#"PRIx64"\n", node->parent_id)); | 341 //DEBUG_INDEX(("Found parent %#"PRIx64"\n", node->parent_d_id)); |
342 parent->no_child++; | 342 parent->no_child++; |
343 node->parent = parent; | 343 node->parent = parent; |
344 add_descriptor_to_list(node, &parent->child, &parent->child_tail); | 344 add_descriptor_to_list(node, &parent->child, &parent->child_tail); |
345 } | 345 } |
346 else { | 346 else { |
685 DEBUG_INDEX(("Decoding desc64\n")); | 685 DEBUG_INDEX(("Decoding desc64\n")); |
686 DEBUG_HEXDUMPC(buf, sizeof(pst_descn), 0x10); | 686 DEBUG_HEXDUMPC(buf, sizeof(pst_descn), 0x10); |
687 memcpy(desc, buf, sizeof(pst_descn)); | 687 memcpy(desc, buf, sizeof(pst_descn)); |
688 LE64_CPU(desc->d_id); | 688 LE64_CPU(desc->d_id); |
689 LE64_CPU(desc->desc_id); | 689 LE64_CPU(desc->desc_id); |
690 LE64_CPU(desc->list_id); | 690 LE64_CPU(desc->tree_id); |
691 LE32_CPU(desc->parent_id); | 691 LE32_CPU(desc->parent_d_id); |
692 LE32_CPU(desc->u1); | 692 LE32_CPU(desc->u1); |
693 r = sizeof(pst_descn); | 693 r = sizeof(pst_descn); |
694 } | 694 } |
695 else { | 695 else { |
696 pst_desc32 d32; | 696 pst_desc32 d32; |
1997 DEBUG_EMAIL(("Extended Attributes Table - NOT PROCESSED\n")); | 1997 DEBUG_EMAIL(("Extended Attributes Table - NOT PROCESSED\n")); |
1998 break; | 1998 break; |
1999 case 0x0017: // PR_IMPORTANCE - How important the sender deems it to be | 1999 case 0x0017: // PR_IMPORTANCE - How important the sender deems it to be |
2000 LIST_COPY_EMAIL_ENUM("Importance Level", item->email->importance, 0, 3, "Low", "Normal", "High"); | 2000 LIST_COPY_EMAIL_ENUM("Importance Level", item->email->importance, 0, 3, "Low", "Normal", "High"); |
2001 break; | 2001 break; |
2002 case 0x001A: // PR_MESSAGE_CLASS Ascii type of messages - NOT FOLDERS | 2002 case 0x001A: // PR_MESSAGE_CLASS IPM.x |
2003 // must be case insensitive | |
2004 LIST_COPY(item->ascii_type, (char*)); | 2003 LIST_COPY(item->ascii_type, (char*)); |
2005 if (pst_strincmp("IPM.Note", item->ascii_type, 8) == 0) | 2004 if (pst_strincmp("IPM.Note", item->ascii_type, 8) == 0) |
2006 // the string begins with IPM.Note... | |
2007 item->type = PST_TYPE_NOTE; | 2005 item->type = PST_TYPE_NOTE; |
2008 else if (pst_stricmp("IPM", item->ascii_type) == 0) | 2006 else if (pst_stricmp("IPM", item->ascii_type) == 0) |
2009 // the whole string is just IPM | |
2010 item->type = PST_TYPE_NOTE; | 2007 item->type = PST_TYPE_NOTE; |
2011 else if (pst_strincmp("IPM.Contact", item->ascii_type, 11) == 0) | 2008 else if (pst_strincmp("IPM.Contact", item->ascii_type, 11) == 0) |
2012 // the string begins with IPM.Contact... | |
2013 item->type = PST_TYPE_CONTACT; | 2009 item->type = PST_TYPE_CONTACT; |
2014 else if (pst_strincmp("REPORT.IPM.Note", item->ascii_type, 15) == 0) | 2010 else if (pst_strincmp("REPORT.IPM.Note", item->ascii_type, 15) == 0) |
2015 // the string begins with the above | |
2016 item->type = PST_TYPE_REPORT; | 2011 item->type = PST_TYPE_REPORT; |
2017 else if (pst_strincmp("IPM.Activity", item->ascii_type, 12) == 0) | 2012 else if (pst_strincmp("IPM.Activity", item->ascii_type, 12) == 0) |
2018 item->type = PST_TYPE_JOURNAL; | 2013 item->type = PST_TYPE_JOURNAL; |
2019 else if (pst_strincmp("IPM.Appointment", item->ascii_type, 15) == 0) | 2014 else if (pst_strincmp("IPM.Appointment", item->ascii_type, 15) == 0) |
2020 item->type = PST_TYPE_APPOINTMENT; | 2015 item->type = PST_TYPE_APPOINTMENT; |
2021 else if (pst_strincmp("IPM.Task", item->ascii_type, 8) == 0) | 2016 else if (pst_strincmp("IPM.Task", item->ascii_type, 8) == 0) |
2022 item->type = PST_TYPE_TASK; | 2017 item->type = PST_TYPE_TASK; |
2023 else | 2018 else |
2024 item->type = PST_TYPE_OTHER; | 2019 item->type = PST_TYPE_OTHER; |
2025 | 2020 DEBUG_EMAIL(("Message class %s [%"PRIi32"] \n", item->ascii_type, item->type)); |
2026 DEBUG_EMAIL(("IPM.x - %s\n", item->ascii_type)); | |
2027 break; | 2021 break; |
2028 case 0x0023: // PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED | 2022 case 0x0023: // PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED |
2029 // set if the sender wants a delivery report from all recipients | 2023 // set if the sender wants a delivery report from all recipients |
2030 LIST_COPY_EMAIL_BOOL("Global Delivery Report", item->email->delivery_report); | 2024 LIST_COPY_EMAIL_BOOL("Global Delivery Report", item->email->delivery_report); |
2031 break; | 2025 break; |
2032 case 0x0026: // PR_PRIORITY | 2026 case 0x0026: // PR_PRIORITY |
2033 // Priority of a message | |
2034 // -1 NonUrgent | |
2035 // 0 Normal | |
2036 // 1 Urgent | |
2037 LIST_COPY_EMAIL_ENUM("Priority", item->email->priority, 1, 3, "NonUrgent", "Normal", "Urgent"); | 2027 LIST_COPY_EMAIL_ENUM("Priority", item->email->priority, 1, 3, "NonUrgent", "Normal", "Urgent"); |
2038 break; | 2028 break; |
2039 case 0x0029: // PR_READ_RECEIPT_REQUESTED | 2029 case 0x0029: // PR_READ_RECEIPT_REQUESTED |
2040 LIST_COPY_EMAIL_BOOL("Read Receipt", item->email->read_receipt); | 2030 LIST_COPY_EMAIL_BOOL("Read Receipt", item->email->read_receipt); |
2041 break; | 2031 break; |
2042 case 0x002B: // PR_RECIPIENT_REASSIGNMENT_PROHIBITED | 2032 case 0x002B: // PR_RECIPIENT_REASSIGNMENT_PROHIBITED |
2043 LIST_COPY_BOOL("Reassignment Prohibited (Private)", item->private_member); | 2033 LIST_COPY_BOOL("Reassignment Prohibited (Private)", item->private_member); |
2044 break; | 2034 break; |
2045 case 0x002E: // PR_ORIGINAL_SENSITIVITY - the sensitivity of the message before being replied to or forwarded | 2035 case 0x002E: // PR_ORIGINAL_SENSITIVITY - the sensitivity of the message before being replied to or forwarded |
2046 LIST_COPY_EMAIL_ENUM("Original Sensitivity", item->email->orig_sensitivity, 0, 4, "None", "Personal", "Private", "Company Confidential"); | 2036 LIST_COPY_EMAIL_ENUM("Original Sensitivity", item->email->original_sensitivity, 0, 4, |
2037 "None", "Personal", "Private", "Company Confidential"); | |
2047 break; | 2038 break; |
2048 case 0x0032: // PR_REPORT_TIME | 2039 case 0x0032: // PR_REPORT_TIME |
2049 LIST_COPY_EMAIL_TIME("Report time", item->email->report_time); | 2040 LIST_COPY_EMAIL_TIME("Report time", item->email->report_time); |
2050 break; | 2041 break; |
2051 case 0x0036: // PR_SENSITIVITY - sender's opinion of the sensitivity of an email | 2042 case 0x0036: // PR_SENSITIVITY - sender's opinion of the sensitivity of an email |
2052 LIST_COPY_EMAIL_ENUM("Sensitivity", item->email->sensitivity, 0, 4, "None", "Personal", "Private", "Company Confidential"); | 2043 LIST_COPY_EMAIL_ENUM("Sensitivity", item->email->sensitivity, 0, 4, |
2044 "None", "Personal", "Private", "Company Confidential"); | |
2053 break; | 2045 break; |
2054 case 0x0037: // PR_SUBJECT raw subject | 2046 case 0x0037: // PR_SUBJECT raw subject |
2055 { | 2047 { |
2056 int off = 0; | 2048 int off = 0; |
2057 if ((list->elements[x]->size > 2) && (((uint8_t)list->elements[x]->data[0]) < 0x20)) { | 2049 if ((list->elements[x]->size > 2) && (((uint8_t)list->elements[x]->data[0]) < 0x20)) { |
2198 break; | 2190 break; |
2199 case 0x0E06: // PR_MESSAGE_DELIVERY_TIME Date 3 - Email Arrival Date | 2191 case 0x0E06: // PR_MESSAGE_DELIVERY_TIME Date 3 - Email Arrival Date |
2200 LIST_COPY_EMAIL_TIME("Date 3 (Delivery Time)", item->email->arrival_date); | 2192 LIST_COPY_EMAIL_TIME("Date 3 (Delivery Time)", item->email->arrival_date); |
2201 break; | 2193 break; |
2202 case 0x0E07: // PR_MESSAGE_FLAGS Email Flag | 2194 case 0x0E07: // PR_MESSAGE_FLAGS Email Flag |
2203 // 0x01 - Read | 2195 LIST_COPY_EMAIL_INT32("Message Flags", item->flags); |
2204 // 0x02 - Unmodified | |
2205 // 0x04 - Submit | |
2206 // 0x08 - Unsent | |
2207 // 0x10 - Has Attachments | |
2208 // 0x20 - From Me | |
2209 // 0x40 - Associated | |
2210 // 0x80 - Resend | |
2211 // 0x100 - RN Pending | |
2212 // 0x200 - NRN Pending | |
2213 LIST_COPY_EMAIL_INT32("Message Flags", item->email->flag); | |
2214 break; | 2196 break; |
2215 case 0x0E08: // PR_MESSAGE_SIZE Total size of a message object | 2197 case 0x0E08: // PR_MESSAGE_SIZE Total size of a message object |
2216 LIST_COPY_INT32("Message Size", item->message_size); | 2198 LIST_COPY_INT32("Message Size", item->message_size); |
2217 break; | 2199 break; |
2218 case 0x0E0A: // PR_SENTMAIL_ENTRYID | 2200 case 0x0E0A: // PR_SENTMAIL_ENTRYID |
2301 break; | 2283 break; |
2302 case 0x300B: // PR_SEARCH_KEY Record Header 2 | 2284 case 0x300B: // PR_SEARCH_KEY Record Header 2 |
2303 DEBUG_EMAIL(("Record Search 2 -- NOT HANDLED\n")); | 2285 DEBUG_EMAIL(("Record Search 2 -- NOT HANDLED\n")); |
2304 break; | 2286 break; |
2305 case 0x35DF: // PR_VALID_FOLDER_MASK | 2287 case 0x35DF: // PR_VALID_FOLDER_MASK |
2306 // States which folders are valid for this message store | |
2307 // FOLDER_IPM_SUBTREE_VALID 0x1 | |
2308 // FOLDER_IPM_INBOX_VALID 0x2 | |
2309 // FOLDER_IPM_OUTBOX_VALID 0x4 | |
2310 // FOLDER_IPM_WASTEBOX_VALID 0x8 | |
2311 // FOLDER_IPM_SENTMAIL_VALID 0x10 | |
2312 // FOLDER_VIEWS_VALID 0x20 | |
2313 // FOLDER_COMMON_VIEWS_VALID 0x40 | |
2314 // FOLDER_FINDER_VALID 0x80 | |
2315 LIST_COPY_STORE_INT32("Valid Folder Mask", item->message_store->valid_mask); | 2288 LIST_COPY_STORE_INT32("Valid Folder Mask", item->message_store->valid_mask); |
2316 break; | 2289 break; |
2317 case 0x35E0: // PR_IPM_SUBTREE_ENTRYID Top of Personal Folder Record | 2290 case 0x35E0: // PR_IPM_SUBTREE_ENTRYID Top of Personal Folder Record |
2318 LIST_COPY_STORE_ENTRYID("Top of Personal Folder Record", item->message_store->top_of_personal_folder); | 2291 LIST_COPY_STORE_ENTRYID("Top of Personal Folder Record", item->message_store->top_of_personal_folder); |
2319 break; | 2292 break; |
2344 case 0x360A: // PR_SUBFOLDERS Has children | 2317 case 0x360A: // PR_SUBFOLDERS Has children |
2345 MALLOC_FOLDER(item); | 2318 MALLOC_FOLDER(item); |
2346 LIST_COPY_BOOL("Has Subfolders", item->folder->subfolder); | 2319 LIST_COPY_BOOL("Has Subfolders", item->folder->subfolder); |
2347 break; | 2320 break; |
2348 case 0x3613: // PR_CONTAINER_CLASS IPF.x | 2321 case 0x3613: // PR_CONTAINER_CLASS IPF.x |
2349 DEBUG_EMAIL(("IPF.x - ")); | |
2350 LIST_COPY(item->ascii_type, (char*)); | 2322 LIST_COPY(item->ascii_type, (char*)); |
2351 if (strncmp("IPF.Note", item->ascii_type, 8) == 0) | 2323 if (pst_strincmp("IPF.Note", item->ascii_type, 8) == 0) |
2352 item->type = PST_TYPE_NOTE; | 2324 item->type = PST_TYPE_NOTE; |
2353 else if (strncmp("IPF.Contact", item->ascii_type, 11) == 0) | 2325 else if (pst_stricmp("IPF", item->ascii_type) == 0) |
2326 item->type = PST_TYPE_NOTE; | |
2327 else if (pst_strincmp("IPF.Contact", item->ascii_type, 11) == 0) | |
2354 item->type = PST_TYPE_CONTACT; | 2328 item->type = PST_TYPE_CONTACT; |
2355 else if (strncmp("IPF.Journal", item->ascii_type, 11) == 0) | 2329 else if (pst_strincmp("IPF.Journal", item->ascii_type, 11) == 0) |
2356 item->type = PST_TYPE_JOURNAL; | 2330 item->type = PST_TYPE_JOURNAL; |
2357 else if (strncmp("IPF.Appointment", item->ascii_type, 15) == 0) | 2331 else if (pst_strincmp("IPF.Appointment", item->ascii_type, 15) == 0) |
2358 item->type = PST_TYPE_APPOINTMENT; | 2332 item->type = PST_TYPE_APPOINTMENT; |
2359 else if (strncmp("IPF.StickyNote", item->ascii_type, 14) == 0) | 2333 else if (pst_strincmp("IPF.StickyNote", item->ascii_type, 14) == 0) |
2360 item->type = PST_TYPE_STICKYNOTE; | 2334 item->type = PST_TYPE_STICKYNOTE; |
2361 else if (strncmp("IPF.Task", item->ascii_type, 8) == 0) | 2335 else if (pst_strincmp("IPF.Task", item->ascii_type, 8) == 0) |
2362 item->type = PST_TYPE_TASK; | 2336 item->type = PST_TYPE_TASK; |
2363 else | 2337 else |
2364 item->type = PST_TYPE_OTHER; | 2338 item->type = PST_TYPE_OTHER; |
2365 | 2339 |
2366 DEBUG_EMAIL(("%s [%i]\n", item->ascii_type, item->type)); | 2340 DEBUG_EMAIL(("Container class %s [%"PRIi32"]\n", item->ascii_type, item->type)); |
2367 break; | 2341 break; |
2368 case 0x3617: // PR_ASSOC_CONTENT_COUNT | 2342 case 0x3617: // PR_ASSOC_CONTENT_COUNT |
2369 // associated content are items that are attached to this folder | 2343 // associated content are items that are attached to this folder |
2370 // but are hidden from users | 2344 // but are hidden from users |
2371 LIST_COPY_FOLDER_INT32("Associate Content count", item->folder->assoc_count); | 2345 LIST_COPY_FOLDER_INT32("Associated Content count", item->folder->assoc_count); |
2372 break; | 2346 break; |
2373 case 0x3701: // PR_ATTACH_DATA_OBJ binary data of attachment | 2347 case 0x3701: // PR_ATTACH_DATA_OBJ binary data of attachment |
2374 DEBUG_EMAIL(("Binary Data [Size %i] - ", list->elements[x]->size)); | 2348 DEBUG_EMAIL(("Binary Data [Size %i] - ", list->elements[x]->size)); |
2375 NULL_CHECK(attach); | 2349 NULL_CHECK(attach); |
2376 if (!list->elements[x]->data) { //special case | 2350 if (!list->elements[x]->data) { //special case |
2762 break; | 2736 break; |
2763 case 0x80D8: // Internet Free/Busy | 2737 case 0x80D8: // Internet Free/Busy |
2764 LIST_COPY_CONTACT_STR("Internet Free/Busy", item->contact->free_busy_address); | 2738 LIST_COPY_CONTACT_STR("Internet Free/Busy", item->contact->free_busy_address); |
2765 break; | 2739 break; |
2766 case 0x8205: // Show on Free/Busy as | 2740 case 0x8205: // Show on Free/Busy as |
2767 LIST_COPY_APPT_ENUM("Appointment shows as", item->appointment->showas, 0, 4, "Free", "Tentative", "Busy", "Out Of Office"); | 2741 LIST_COPY_APPT_ENUM("Appointment shows as", item->appointment->showas, 0, 4, |
2742 "Free", "Tentative", "Busy", "Out Of Office"); | |
2768 break; | 2743 break; |
2769 case 0x8208: // Location of an appointment | 2744 case 0x8208: // Location of an appointment |
2770 LIST_COPY_APPT_STR("Appointment Location", item->appointment->location); | 2745 LIST_COPY_APPT_STR("Appointment Location", item->appointment->location); |
2771 break; | 2746 break; |
2772 case 0x820d: // Appointment start | 2747 case 0x820d: // Appointment start |
2791 break; | 2766 break; |
2792 case 0x8215: // All day appointment flag | 2767 case 0x8215: // All day appointment flag |
2793 LIST_COPY_APPT_BOOL("All day flag", item->appointment->all_day); | 2768 LIST_COPY_APPT_BOOL("All day flag", item->appointment->all_day); |
2794 break; | 2769 break; |
2795 case 0x8231: // Recurrence type | 2770 case 0x8231: // Recurrence type |
2796 LIST_COPY_APPT_ENUM("Appointment reccurs", item->appointment->recurrence_type, 0, 5, | 2771 LIST_COPY_APPT_ENUM("Appointment reccurence", item->appointment->recurrence_type, 0, 5, |
2797 "None", | 2772 "None", |
2798 "Daily", | 2773 "Daily", |
2799 "Weekly", | 2774 "Weekly", |
2800 "Monthly", | 2775 "Monthly", |
2801 "Yearly"); | 2776 "Yearly"); |