~ubuntu-branches/debian/jessie/openchange/jessie

« back to all changes in this revision

Viewing changes to utils/exchange2mbox.c

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2014-04-24 00:29:19 UTC
  • mfrom: (1.2.8) (4.1.6 experimental)
  • Revision ID: package-import@ubuntu.com-20140424002919-96es5uhyy3jjzgid
Tags: 1:2.1-1
* New upstream release.
 + Stop removing broken manpages, upstream on longer installs them.
* Add upstream signing key.
* Run test suite during build.
 + Add dependency on python-twisted-core for trial and python-testtools.
 + Add fix-tests patch, cherry-picked from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
523
523
   Sample mbox mail:
524
524
 
525
525
   From Administrator Mon Apr 23 14:43:01 2007
 
526
   Archived-At: <outlook:$message_entryID>
526
527
   Date: Mon Apr 23 14:43:01 2007
527
528
   From: Administrator 
528
529
   To: Julien Kerihuel
533
534
**/
534
535
 
535
536
static bool message2mbox(TALLOC_CTX *mem_ctx, FILE *fp, 
536
 
                         struct SRow *aRow, mapi_object_t *obj_message,
 
537
                         struct SRow *aRow, mapi_object_t *obj_store,
 
538
                         mapi_object_t *obj_folder, mapi_object_t *obj_message,
537
539
                         int base_level)
538
540
{
539
541
        enum MAPISTATUS                 retval;
591
593
 
592
594
        /* First line From - but only if base_level == 0 */
593
595
        if (base_level == 0) {
594
 
                char *f, *p;
 
596
                char                            *f, *p;
 
597
                const struct SBinary_short      *entry_id;
 
598
                struct SBinary_short            entry_id_for_2010;
 
599
                uint8_t                         *ptr;
 
600
 
595
601
                f = talloc_strdup(mem_ctx, from);
596
602
                /* strip out all '"'s, ugly but works */
597
603
                for (p = f; p && *p; ) {
602
608
                        p++;
603
609
                }
604
610
                fprintf(fp, "From \"%s\" %s\n", f, date);
 
611
                entry_id = (const struct SBinary_short *) find_SPropValue_data(aRow, PR_ENTRYID);
 
612
                if (!entry_id) {
 
613
                        EntryIDFromSourceIDForMessage(mem_ctx, obj_store, obj_folder, &obj_message, &entry_id_for_2010);
 
614
                        entry_id = &entry_id_for_2010;
 
615
                }
 
616
                ptr = entry_id->lpb;
 
617
                if (ptr) {
 
618
                        size_t c = entry_id->cb;
 
619
                        fprintf(fp, "Archived-At: <outlook:");
 
620
                        while (c--) {
 
621
                                fprintf(fp, "%02X", (unsigned char)*ptr++);
 
622
                        }
 
623
                        fprintf(fp, ">\n");
 
624
                }
605
625
                talloc_free(f);
606
626
        }
607
627
 
942
962
                                                        fprintf(fp, "Content-Disposition: inline\n");
943
963
                                                        fprintf(fp, "\n");
944
964
 
945
 
                                                        message2mbox(mem_ctx, fp, &eRow, &obj_embeddedmsg,
 
965
                                                        message2mbox(mem_ctx, fp, &eRow, NULL, NULL, &obj_embeddedmsg,
946
966
                                                                        base_level + 2 /* 0 = main, 1 = alt */);
947
967
                                                        talloc_free(embProps);
948
968
                                                        } break;
1166
1186
                                             rowset.aRow[i].lpProps[1].value.d, 
1167
1187
                                             &obj_message, 0);
1168
1188
                        if (retval == MAPI_E_SUCCESS) {
1169
 
                                SPropTagArray = set_SPropTagArray(mem_ctx, 0x1b,
 
1189
                                SPropTagArray = set_SPropTagArray(mem_ctx, 0x1c,
1170
1190
                                                                  PR_INTERNET_MESSAGE_ID,
1171
1191
                                                                  PR_INTERNET_MESSAGE_ID_UNICODE,
1172
1192
                                                                  PR_CONVERSATION_TOPIC,
1193
1213
                                                                  PR_NORMALIZED_SUBJECT,
1194
1214
                                                                  PR_NORMALIZED_SUBJECT_UNICODE,
1195
1215
                                                                  PR_SUBJECT,
1196
 
                                                                  PR_SUBJECT_UNICODE);
 
1216
                                                                  PR_SUBJECT_UNICODE,
 
1217
                                                                  PR_ENTRYID);
1197
1218
                                retval = GetProps(&obj_message, MAPI_UNICODE, SPropTagArray, &lpProps, &count);
1198
1219
                                MAPIFreeBuffer(SPropTagArray);
1199
1220
                                if (retval != MAPI_E_SUCCESS) {
1213
1234
                                                bool ok;
1214
1235
                                                
1215
1236
                                                message_error = 0;
1216
 
                                                ok = message2mbox(mem_ctx, fp, &aRow, &obj_message, 0);
 
1237
                                                ok = message2mbox(mem_ctx, fp, &aRow, &obj_store, &obj_inbox, &obj_message, 0);
1217
1238
                                                if (!ok) {
1218
1239
                                                        printf("Message-ID: %s error, not added to %s\n", msgid, profile->profname);
1219
1240
                                                } else if (message_error) {