test/message_api_test.cc
author vb
Sun, 22 Feb 2015 13:40:25 +0100
changeset 63 f5b2641f4ae7
parent 53 d9eacd197962
child 71 3a036da3e479
permissions -rw-r--r--
some redesign and bugfixing
     1 #include <iostream>
     2 #include <assert.h>
     3 #include "message_api.h"
     4 
     5 using namespace std;
     6 
     7 int main() {
     8     cout << "\n*** 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     // message_api test code
    19 
    20     cout << "creating message…\n";
    21     pEp_identity * me = new_identity("outlooktest@dingens.org", NULL, "23", "Outlook Test");
    22     me->me = true;
    23     identity_list *to = new_identity_list(new_identity("vb@dingens.org", NULL, "42", "Volker Birk"));
    24     message *msg = new_message(PEP_dir_outgoing, me, to, "hello, world");
    25     assert(msg);
    26     cout << "message created.\n";
    27 
    28     cout << "encrypting message as MIME multipart…\n";
    29     message *enc_msg3;
    30     cout << "calling encrypt_message()\n";
    31     PEP_STATUS status3 = encrypt_message(session, msg, NULL, &enc_msg3, PEP_enc_MIME_multipart);
    32     assert(status3 == PEP_STATUS_OK);
    33     assert(enc_msg3);
    34     cout << "message encrypted.\n";
    35     free_message(enc_msg3);
    36     
    37     cout << "freeing messages…\n";
    38     free_message(msg);
    39     cout << "done.\n";
    40 
    41     cout << "calling release()\n";
    42     release(session);
    43     return 0;
    44 }
    45