test/message_api_test.cc
author vb
Tue, 30 Dec 2014 18:39:59 +0100
changeset 40 3e7aa2f67b7e
parent 39 66b5cc6cb987
child 45 37a80387790d
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…\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 << "freeing messages…\n";
    33     free_message(msg);
    34     free_message(enc_msg);
    35     cout << "done.\n";
    36 
    37     cout << "calling release()\n";
    38     release(session);
    39     return 0;
    40 }
    41