12 void test_mime_decoding(string filename) {
13 cout << "opening " << filename << " for reading\n";
14 ifstream inFile3 (filename);
15 assert(inFile3.is_open());
19 cout << "reading mime sample\n";
20 while (!inFile3.eof()) {
22 getline(inFile3, line);
23 mimetext3 += line + "\n";
27 cout << "decoding message…\n";
29 PEP_STATUS status3 = mime_decode_message(mimetext3.c_str(), mimetext3.length(), &msg3);
30 assert(status3 == PEP_STATUS_OK);
32 cout << "decoded.\n\n";
33 cout << "Subject: " << msg3->shortmsg << "\n\n";
35 cout << msg3->longmsg << "\n\n";
36 if (msg3->longmsg_formatted)
37 cout << msg3->longmsg_formatted << "\n\n";
39 for (_b = msg3->attachments; _b; _b = _b->next) {
40 cout << "attachment of type " << _b->mime_type << "\n";
42 cout << "filename: " << _b->filename << "\n";
44 ofstream outFile3(_b->filename);
45 outFile3.write(_b->value, _b->size);
54 cout << "\n*** mime_test ***\n\n";
58 cout << "calling init()\n";
59 PEP_STATUS status1 = init(&session);
60 assert(status1 == PEP_STATUS_OK);
62 cout << "init() completed.\n";
66 // testing multipart/alternative
68 message *msg2 = new_message(PEP_dir_incoming);
70 msg2->from = new_identity("vb@dingens.org", NULL, NULL, "Volker Birk");
71 msg2->to = new_identity_list(new_identity("trischa@dingens.org", NULL, NULL, "Patricia Bädnar")),
72 msg2->shortmsg = strdup("my sübject");
74 string text2 = "my mèssage to yoü";
75 msg2->longmsg = strdup(text2.c_str());
76 string html2 = "<html><body><p>my message to you</p></body></html>";
77 msg2->longmsg_formatted = strdup(html2.c_str());
78 assert(msg2->longmsg_formatted);
80 cout << "encoding message…\n";
82 PEP_STATUS status2 = mime_encode_message(msg2, false, &result2);
84 assert(status2 == PEP_STATUS_OK);
87 cout << result2 << "\n";
92 test_mime_decoding("msg1.asc");
93 test_mime_decoding("msg2.asc");
94 test_mime_decoding("msg3.asc");
96 cout << "calling release()\n";