test/message_api_test.cc
author vb
Sun, 08 Feb 2015 13:27:08 -0500
changeset 51 761bc0b46b98
parent 48 9ff5d2dfa75a
child 53 d9eacd197962
permissions -rw-r--r--
mime encode
     1 #include <iostream>
     2 #include <assert.h>
     3 #include "message_api.h"
     4 
     5 using namespace std;
     6 
     7 int main() {
     8     cout << "*** message_api_test ***\n\n";
     9 
    10     PEP_SESSION session;
    11     
    12     cout << "calling init()\n";
    13     PEP_STATUS status1 = init(&session);   
    14     assert(status1 == PEP_STATUS_OK);
    15     assert(session);
    16     cout << "init() completed.\n";
    17 
    18     cout << "creating message…\n";
    19     pEp_identity * me = new_identity("outlooktest@dingens.org", NULL, "23", "Outlook Test");
    20     me->me = true;
    21     identity_list *to = new_identity_list(new_identity("vb@dingens.org", NULL, "42", "Volker Birk"));
    22     message *msg = new_message(PEP_dir_outgoing, me, to, "hello, world");
    23     assert(msg);
    24     cout << "message created.\n";
    25 
    26 //     cout << "encrypting message in pieces…\n";
    27 //     message *enc_msg;
    28 //     cout << "calling encrypt_message()\n";
    29 //     PEP_STATUS status2 = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_pieces);
    30 //     assert(status2 == PEP_STATUS_OK);
    31 //     assert(enc_msg);
    32 //     cout << "message encrypted.\n";
    33 
    34     cout << "encrypting message as MIME multipart…\n";
    35     message *enc_msg2;
    36     cout << "calling encrypt_message()\n";
    37     PEP_STATUS status3 = encrypt_message(session, msg, NULL, &enc_msg2, PEP_enc_MIME_multipart);
    38     assert(status3 == PEP_STATUS_OK);
    39     assert(enc_msg2);
    40     cout << "message encrypted.\n";
    41     
    42     cout << "freeing messages…\n";
    43     free_message(msg);
    44 //    free_message(enc_msg);
    45     free_message(enc_msg2);
    46     cout << "done.\n";
    47 
    48     cout << "calling release()\n";
    49     release(session);
    50     return 0;
    51 }
    52