Mercurial > libpst
comparison src/pst2dii.cpp.in @ 151:cda7c812ec01
track character set individually for each mapi element
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Sun, 08 Mar 2009 14:35:26 -0700 |
parents | 0695de3b5a98 |
children | 581fab9f1dc7 |
comparison
equal
deleted
inserted
replaced
150:06aa84023b48 | 151:cda7c812ec01 |
---|---|
173 int x = 0; | 173 int x = 0; |
174 char *temp = NULL; | 174 char *temp = NULL; |
175 | 175 |
176 // If there is a long filename (filename2) use that, otherwise | 176 // If there is a long filename (filename2) use that, otherwise |
177 // use the 8.3 filename (filename1) | 177 // use the 8.3 filename (filename1) |
178 char *attach_filename = (current_attach->filename2) ? current_attach->filename2 | 178 char *attach_filename = (current_attach->filename2.str) ? current_attach->filename2.str |
179 : current_attach->filename1; | 179 : current_attach->filename1.str; |
180 DEBUG_ENT("write_separate_attachment"); | 180 DEBUG_ENT("write_separate_attachment"); |
181 check_filename(fname); | 181 check_filename(fname); |
182 const char* f_name = fname.c_str(); | 182 const char* f_name = fname.c_str(); |
183 DEBUG_EMAIL(("dirname=%s, pathname=%s, filename=%s\n", output_directory, f_name, attach_filename)); | 183 DEBUG_EMAIL(("dirname=%s, pathname=%s, filename=%s\n", output_directory, f_name, attach_filename)); |
184 int len = strlen(output_directory) + 1 + strlen(f_name) + 15; | 184 int len = strlen(output_directory) + 1 + strlen(f_name) + 15; |
443 static void write_normal_email(file_ll &f, pst_item* item, pst_file* pst); | 443 static void write_normal_email(file_ll &f, pst_item* item, pst_file* pst); |
444 static void write_normal_email(file_ll &f, pst_item* item, pst_file* pst) | 444 static void write_normal_email(file_ll &f, pst_item* item, pst_file* pst) |
445 { | 445 { |
446 DEBUG_ENT("write_normal_email"); | 446 DEBUG_ENT("write_normal_email"); |
447 char *soh = NULL; // real start of headers. | 447 char *soh = NULL; // real start of headers. |
448 if (item->email->header) { | 448 if (item->email->header.str) { |
449 // some of the headers we get from the file are not properly defined. | 449 // some of the headers we get from the file are not properly defined. |
450 // they can contain some email stuff too. We will cut off the header | 450 // they can contain some email stuff too. We will cut off the header |
451 // when we see a \n\n or \r\n\r\n | 451 // when we see a \n\n or \r\n\r\n |
452 removeCR(item->email->header); | 452 removeCR(item->email->header.str); |
453 char *temp = strstr(item->email->header, "\n\n"); | 453 char *temp = strstr(item->email->header.str, "\n\n"); |
454 if (temp) { | 454 if (temp) { |
455 DEBUG_EMAIL(("Found body text in header\n")); | 455 DEBUG_EMAIL(("Found body text in header\n")); |
456 temp[1] = '\0'; // stop after first \n | 456 temp[1] = '\0'; // stop after first \n |
457 } | 457 } |
458 soh = skip_header_prologue(item->email->header); | 458 soh = skip_header_prologue(item->email->header.str); |
459 } | 459 } |
460 | 460 |
461 char folder_line[LINE_SIZE]; | 461 char folder_line[LINE_SIZE]; |
462 char line[LINE_SIZE]; | 462 char line[LINE_SIZE]; |
463 // reset pdf writer to new file | 463 // reset pdf writer to new file |
469 fprintf(dii_file, "@FOLDERNAME %s\n", f.name.c_str()); | 469 fprintf(dii_file, "@FOLDERNAME %s\n", f.name.c_str()); |
470 string myfrom = extract_header(soh, "From"); | 470 string myfrom = extract_header(soh, "From"); |
471 string myto = extract_header(soh, "To"); | 471 string myto = extract_header(soh, "To"); |
472 string mycc = extract_header(soh, "Cc"); | 472 string mycc = extract_header(soh, "Cc"); |
473 string mybcc = extract_header(soh, "Bcc"); | 473 string mybcc = extract_header(soh, "Bcc"); |
474 if (myfrom.empty()) write_simple("FROM", item->email->outlook_sender_name, item->email->sender_address); | 474 if (myfrom.empty()) write_simple("FROM", item->email->outlook_sender_name.str, item->email->sender_address.str); |
475 else write_simple("FROM", myfrom); | 475 else write_simple("FROM", myfrom); |
476 if (myto.empty()) write_simple("TO", item->email->sentto_address, item->email->recip_address); | 476 if (myto.empty()) write_simple("TO", item->email->sentto_address.str, item->email->recip_address.str); |
477 else write_simple("TO", myto); | 477 else write_simple("TO", myto); |
478 if (mycc.empty()) write_simple("CC", item->email->cc_address); | 478 if (mycc.empty()) write_simple("CC", item->email->cc_address.str); |
479 else write_simple("CC", mycc); | 479 else write_simple("CC", mycc); |
480 if (mybcc.empty()) write_simple("BCC", item->email->bcc_address); | 480 if (mybcc.empty()) write_simple("BCC", item->email->bcc_address.str); |
481 else write_simple("BCC", mybcc); | 481 else write_simple("BCC", mybcc); |
482 if (item->email->sent_date) { | 482 if (item->email->sent_date) { |
483 time_t t = fileTimeToUnixTime(item->email->sent_date, NULL); | 483 time_t t = fileTimeToUnixTime(item->email->sent_date, NULL); |
484 char c_time[C_TIME_SIZE]; | 484 char c_time[C_TIME_SIZE]; |
485 strftime(c_time, C_TIME_SIZE, "%F", gmtime(&t)); | 485 strftime(c_time, C_TIME_SIZE, "%F", gmtime(&t)); |
493 strftime(c_time, C_TIME_SIZE, "%F", gmtime(&t)); | 493 strftime(c_time, C_TIME_SIZE, "%F", gmtime(&t)); |
494 write_simple("DATERCVD", c_time); | 494 write_simple("DATERCVD", c_time); |
495 strftime(c_time, C_TIME_SIZE, "%T+0000", gmtime(&t)); | 495 strftime(c_time, C_TIME_SIZE, "%T+0000", gmtime(&t)); |
496 write_simple("TIMERCVD", c_time); | 496 write_simple("TIMERCVD", c_time); |
497 } | 497 } |
498 if (item->email->subject) { | 498 if (item->subject.str) { |
499 write_simple("SUBJECT", item->email->subject->subj); | 499 write_simple("SUBJECT", item->subject.str); |
500 } | 500 } |
501 write_simple("MSGID", item->email->messageid); | 501 write_simple("MSGID", item->email->messageid.str); |
502 if (item->email->flag) { | 502 if (item->email->flag) { |
503 write_simple("READ", (item->email->flag & 1) ? "Y" : "N"); | 503 write_simple("READ", (item->email->flag & 1) ? "Y" : "N"); |
504 } | 504 } |
505 | 505 |
506 DEBUG_EMAIL(("About to print Header\n")); | 506 DEBUG_EMAIL(("About to print Header\n")); |
507 fprintf(dii_file, "@HEADER\n"); | 507 fprintf(dii_file, "@HEADER\n"); |
508 | 508 |
509 if (item && item->email && item->email->subject && item->email->subject->subj) { | 509 if (item && item->subject.str) { |
510 DEBUG_EMAIL(("item->email->subject->subj = %s\n", item->email->subject->subj)); | 510 DEBUG_EMAIL(("item->subject = %s\n", item->subject.str)); |
511 } | 511 } |
512 | 512 |
513 if (soh) { | 513 if (soh) { |
514 // Now, write out the header... | 514 // Now, write out the header... |
515 print_pdf(soh); | 515 print_pdf(soh); |
519 print_pdf(line); | 519 print_pdf(line); |
520 } | 520 } |
521 | 521 |
522 } else { | 522 } else { |
523 //make up our own headers | 523 //make up our own headers |
524 const char *temp = item->email->outlook_sender; | 524 const char *temp = item->email->outlook_sender.str; |
525 if (!temp) temp = ""; | 525 if (!temp) temp = ""; |
526 snprintf(line, sizeof(line), "From: \"%s\" <%s>\n", item->email->outlook_sender_name, temp); | 526 snprintf(line, sizeof(line), "From: \"%s\" <%s>\n", item->email->outlook_sender_name.str, temp); |
527 print_pdf(line); | 527 print_pdf(line); |
528 | 528 |
529 if (item->email->subject) { | 529 if (item->subject.str) { |
530 snprintf(line, sizeof(line), "Subject: %s\n", item->email->subject->subj); | 530 snprintf(line, sizeof(line), "Subject: %s\n", item->subject.str); |
531 } else { | 531 } else { |
532 snprintf(line, sizeof(line), "Subject: \n"); | 532 snprintf(line, sizeof(line), "Subject: \n"); |
533 } | 533 } |
534 print_pdf(line); | 534 print_pdf(line); |
535 | 535 |
536 snprintf(line, sizeof(line), "To: %s\n", item->email->sentto_address); | 536 snprintf(line, sizeof(line), "To: %s\n", item->email->sentto_address.str); |
537 print_pdf(line); | 537 print_pdf(line); |
538 | 538 |
539 if (item->email->cc_address) { | 539 if (item->email->cc_address.str) { |
540 snprintf(line, sizeof(line), "Cc: %s\n", item->email->cc_address); | 540 snprintf(line, sizeof(line), "Cc: %s\n", item->email->cc_address.str); |
541 print_pdf(line); | 541 print_pdf(line); |
542 } | 542 } |
543 | 543 |
544 if (item->email->sent_date) { | 544 if (item->email->sent_date) { |
545 time_t em_time = fileTimeToUnixTime(item->email->sent_date, 0); | 545 time_t em_time = fileTimeToUnixTime(item->email->sent_date, 0); |
553 print_pdf_only(line, black); | 553 print_pdf_only(line, black); |
554 fprintf(dii_file, "@HEADER-END\n"); | 554 fprintf(dii_file, "@HEADER-END\n"); |
555 | 555 |
556 DEBUG_EMAIL(("About to print Body\n")); | 556 DEBUG_EMAIL(("About to print Body\n")); |
557 fprintf(dii_file, "@EMAIL-BODY\n"); | 557 fprintf(dii_file, "@EMAIL-BODY\n"); |
558 if (item->email->body) { | 558 if (item->body.str) { |
559 removeCR(item->email->body); | 559 removeCR(item->body.str); |
560 print_pdf(item->email->body); | 560 print_pdf(item->body.str); |
561 } else if (item->email->htmlbody) { | 561 } else if (item->email->htmlbody.str) { |
562 removeCR(item->email->htmlbody); | 562 removeCR(item->email->htmlbody.str); |
563 print_pdf(item->email->htmlbody); | 563 print_pdf(item->email->htmlbody.str); |
564 } else if (item->email->encrypted_body || item->email->encrypted_htmlbody) { | 564 } else if (item->email->encrypted_body || item->email->encrypted_htmlbody) { |
565 char ln[LINE_SIZE]; | 565 char ln[LINE_SIZE]; |
566 snprintf(ln, sizeof(ln), "%s", "The body of this email is encrypted. This isn't supported yet, but the body is now an attachment\n"); | 566 snprintf(ln, sizeof(ln), "%s", "The body of this email is encrypted. This isn't supported yet, but the body is now an attachment\n"); |
567 print_pdf(ln); | 567 print_pdf(ln); |
568 } | 568 } |
589 { | 589 { |
590 f.email_count = 0; | 590 f.email_count = 0; |
591 f.skip_count = 0; | 591 f.skip_count = 0; |
592 f.type = item->type; | 592 f.type = item->type; |
593 f.stored_count = (item->folder) ? item->folder->email_count : 0; | 593 f.stored_count = (item->folder) ? item->folder->email_count : 0; |
594 f.name = ((parent) ? parent->name + "/" : "") + string(item->file_as); | 594 f.name = ((parent) ? parent->name + "/" : "") + string(item->file_as.str); |
595 } | 595 } |
596 | 596 |
597 | 597 |
598 static void close_enter_dir(file_ll &f); | 598 static void close_enter_dir(file_ll &f); |
599 static void close_enter_dir(file_ll &f) | 599 static void close_enter_dir(file_ll &f) |