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