comparison src/pst2dii.cpp.in @ 213:4a659f3138b7

fix pst2dii for shared library changes
author Carl Byington <carl@five-ten-sg.com>
date Mon, 08 Jun 2009 14:47:39 -0700
parents 2f38c4ce606f
children 7fcff97ca5a9
comparison
equal deleted inserted replaced
212:8e17efed33c1 213:4a659f3138b7
200 DIE(("error finding attachment name. exhausted possibilities to %s\n", temp)); 200 DIE(("error finding attachment name. exhausted possibilities to %s\n", temp));
201 } 201 }
202 } 202 }
203 DEBUG_INFO(("Saving attachment to %s\n", temp)); 203 DEBUG_INFO(("Saving attachment to %s\n", temp));
204 if (!(fp = fopen(temp, "wb"))) { 204 if (!(fp = fopen(temp, "wb"))) {
205 WARN(("write_separate_attachment: Cannot open attachment save file \"%s\"\n", temp)); 205 DEBUG_WARN(("write_separate_attachment: Cannot open attachment save file \"%s\"\n", temp));
206 } else { 206 } else {
207 (void)pst_attach_to_file(pst, current_attach, fp); 207 (void)pst_attach_to_file(pst, current_attach, fp);
208 fclose(fp); 208 fclose(fp);
209 } 209 }
210 string rc(temp); 210 string rc(temp);
561 print_pdf(ln); 561 print_pdf(ln);
562 } 562 }
563 fprintf(dii_file, "@EMAIL-END\n"); 563 fprintf(dii_file, "@EMAIL-END\n");
564 564
565 int attach_num = 0; 565 int attach_num = 0;
566 for (pst_item_attach* current_attach = item->attach; current_attach; current_attach = current_attach->next) { 566 for (pst_item_attach* attach = item->attach; attach; attach = attach->next) {
567 pst_convert_utf8_null(item, &attach->filename1);
568 pst_convert_utf8_null(item, &attach->filename2);
569 pst_convert_utf8_null(item, &attach->mimetype);
567 DEBUG_INFO(("Attempting Attachment encoding\n")); 570 DEBUG_INFO(("Attempting Attachment encoding\n"));
568 if (!current_attach->data.data) { 571 if (attach->data.data || attach->i_id) {
569 DEBUG_WARN(("Data of attachment is NULL!. Size is supposed to be %i\n", current_attach->data.size)); 572 string an = write_separate_attachment(f.name, attach, ++attach_num, pst);
570 } 573 fprintf(dii_file, "@EATTACH %s\n", an.c_str());
571 string an = write_separate_attachment(f.name, current_attach, ++attach_num, pst); 574 }
572 fprintf(dii_file, "@EATTACH %s\n", an.c_str());
573 } 575 }
574 close_pdf(); 576 close_pdf();
575 fprintf(dii_file, "@BATESBEG %d\n", bates); 577 fprintf(dii_file, "@BATESBEG %d\n", bates);
576 fprintf(dii_file, "@BATESEND %d\n", bates_index-1); 578 fprintf(dii_file, "@BATESEND %d\n", bates_index-1);
577 DEBUG_RET(); 579 DEBUG_RET();
579 581
580 582
581 static void create_enter_dir(file_ll &f, file_ll *parent, pst_item *item); 583 static void create_enter_dir(file_ll &f, file_ll *parent, pst_item *item);
582 static void create_enter_dir(file_ll &f, file_ll *parent, pst_item *item) 584 static void create_enter_dir(file_ll &f, file_ll *parent, pst_item *item)
583 { 585 {
584 f.email_count = 0; 586 pst_convert_utf8(item, &item->file_as);
585 f.skip_count = 0;
586 f.type = item->type; 587 f.type = item->type;
587 f.stored_count = (item->folder) ? item->folder->item_count : 0; 588 f.stored_count = (item->folder) ? item->folder->item_count : 0;
588 f.name = ((parent) ? parent->name + "/" : "") + string(item->file_as.str); 589 f.name = ((parent) ? parent->name + "/" : "") + string(item->file_as.str);
589 } 590 }
590 591
600 { 601 {
601 file_ll ff; 602 file_ll ff;
602 pst_item *item = NULL; 603 pst_item *item = NULL;
603 DEBUG_ENT("process"); 604 DEBUG_ENT("process");
604 create_enter_dir(ff, parent, outeritem); 605 create_enter_dir(ff, parent, outeritem);
605 while (d_ptr) { 606 for (; d_ptr; d_ptr = d_ptr->next) {
606 if (d_ptr->desc) { 607 if (d_ptr->desc) {
607 item = pst_parse_item(&pstfile, d_ptr, NULL); 608 item = pst_parse_item(&pstfile, d_ptr, NULL);
608 DEBUG_INFO(("item pointer is %p\n", item)); 609 DEBUG_INFO(("item pointer is %p\n", item));
609 if (item) { 610 if (item) {
610 if (item->folder && d_ptr->child ) { 611 if (item->folder && item->file_as.str && d_ptr->child ) {
611 //if this is a non-empty folder, we want to recurse into it 612 //if this is a non-empty folder, we want to recurse into it
612 fprintf(stderr, "entering folder %s\n", item->file_as.str); 613 fprintf(stderr, "entering folder %s\n", item->file_as.str);
613 process(item, &ff, d_ptr->child); 614 process(item, &ff, d_ptr->child);
614 } else if (item->email && (item->type == PST_TYPE_NOTE || item->type == PST_TYPE_REPORT || item->type == PST_TYPE_OTHER)) { 615 } else if (item->email && (item->type == PST_TYPE_NOTE || item->type == PST_TYPE_SCHEDULE || item->type == PST_TYPE_REPORT)) {
615 ff.email_count++; 616 ff.email_count++;
616 DEBUG_INFO(("Processing Email\n"));
617 if ((ff.type != PST_TYPE_NOTE) && (ff.type != PST_TYPE_REPORT) && (ff.type != PST_TYPE_OTHER)) {
618 DEBUG_INFO(("I have an email, but the folder isn't an email folder. Processing anyway\n"));
619 }
620 write_normal_email(ff, item, &pstfile); 617 write_normal_email(ff, item, &pstfile);
618 }
619 else {
620 ff.skip_count++; // other mapi objects
621 } 621 }
622 pst_freeItem(item); 622 pst_freeItem(item);
623 } else { 623 } else {
624 ff.skip_count++; 624 ff.skip_count++;
625 DEBUG_INFO(("A NULL item was seen\n")); 625 DEBUG_INFO(("A NULL item was seen\n"));
626 } 626 }
627 } 627 }
628 d_ptr = d_ptr->next;
629 } 628 }
630 close_enter_dir(ff); 629 close_enter_dir(ff);
631 DEBUG_RET(); 630 DEBUG_RET();
632 } 631 }
633 632