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
vb@39
     1
#include <iostream>
vb@39
     2
#include <assert.h>
vb@39
     3
#include "message_api.h"
vb@39
     4
vb@39
     5
using namespace std;
vb@39
     6
vb@39
     7
int main() {
vb@53
     8
    cout << "\n*** message_api_test ***\n\n";
vb@51
     9
vb@39
    10
    PEP_SESSION session;
vb@39
    11
    
vb@39
    12
    cout << "calling init()\n";
vb@39
    13
    PEP_STATUS status1 = init(&session);   
vb@39
    14
    assert(status1 == PEP_STATUS_OK);
vb@39
    15
    assert(session);
vb@39
    16
    cout << "init() completed.\n";
vb@39
    17
vb@53
    18
    // message_api test code
vb@53
    19
vb@40
    20
    cout << "creating message…\n";
vb@39
    21
    pEp_identity * me = new_identity("outlooktest@dingens.org", NULL, "23", "Outlook Test");
vb@39
    22
    me->me = true;
vb@39
    23
    identity_list *to = new_identity_list(new_identity("vb@dingens.org", NULL, "42", "Volker Birk"));
vb@40
    24
    message *msg = new_message(PEP_dir_outgoing, me, to, "hello, world");
vb@40
    25
    assert(msg);
vb@40
    26
    cout << "message created.\n";
vb@39
    27
vb@48
    28
    cout << "encrypting message as MIME multipart…\n";
vb@63
    29
    message *enc_msg3;
vb@40
    30
    cout << "calling encrypt_message()\n";
vb@63
    31
    PEP_STATUS status3 = encrypt_message(session, msg, NULL, &enc_msg3, PEP_enc_MIME_multipart);
vb@48
    32
    assert(status3 == PEP_STATUS_OK);
vb@63
    33
    assert(enc_msg3);
vb@40
    34
    cout << "message encrypted.\n";
vb@63
    35
    free_message(enc_msg3);
vb@48
    36
    
vb@40
    37
    cout << "freeing messages…\n";
vb@39
    38
    free_message(msg);
vb@40
    39
    cout << "done.\n";
vb@39
    40
vb@39
    41
    cout << "calling release()\n";
vb@39
    42
    release(session);
vb@39
    43
    return 0;
vb@39
    44
}
vb@39
    45