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--
...
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@39
     8
    PEP_SESSION session;
vb@39
     9
    
vb@39
    10
    cout << "calling init()\n";
vb@39
    11
    PEP_STATUS status1 = init(&session);   
vb@39
    12
    assert(status1 == PEP_STATUS_OK);
vb@39
    13
    assert(session);
vb@39
    14
    cout << "init() completed.\n";
vb@39
    15
vb@40
    16
    cout << "creating message…\n";
vb@39
    17
    pEp_identity * me = new_identity("outlooktest@dingens.org", NULL, "23", "Outlook Test");
vb@39
    18
    me->me = true;
vb@39
    19
    identity_list *to = new_identity_list(new_identity("vb@dingens.org", NULL, "42", "Volker Birk"));
vb@40
    20
    message *msg = new_message(PEP_dir_outgoing, me, to, "hello, world");
vb@40
    21
    assert(msg);
vb@40
    22
    cout << "message created.\n";
vb@39
    23
vb@40
    24
    cout << "encrypting message…\n";
vb@40
    25
    message *enc_msg;
vb@40
    26
    cout << "calling encrypt_message()\n";
vb@40
    27
    PEP_STATUS status2 = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_pieces);
vb@40
    28
    assert(status2 == PEP_STATUS_OK);
vb@40
    29
    assert(enc_msg);
vb@40
    30
    cout << "message encrypted.\n";
vb@39
    31
vb@40
    32
    cout << "freeing messages…\n";
vb@39
    33
    free_message(msg);
vb@40
    34
    free_message(enc_msg);
vb@40
    35
    cout << "done.\n";
vb@39
    36
vb@39
    37
    cout << "calling release()\n";
vb@39
    38
    release(session);
vb@39
    39
    return 0;
vb@39
    40
}
vb@39
    41