test/message_api_test.cc
author vb
Sun, 08 Feb 2015 13:27:08 -0500
changeset 51 761bc0b46b98
parent 48 9ff5d2dfa75a
child 53 d9eacd197962
permissions -rw-r--r--
mime encode
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@51
     8
    cout << "*** 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@40
    18
    cout << "creating message…\n";
vb@39
    19
    pEp_identity * me = new_identity("outlooktest@dingens.org", NULL, "23", "Outlook Test");
vb@39
    20
    me->me = true;
vb@39
    21
    identity_list *to = new_identity_list(new_identity("vb@dingens.org", NULL, "42", "Volker Birk"));
vb@40
    22
    message *msg = new_message(PEP_dir_outgoing, me, to, "hello, world");
vb@40
    23
    assert(msg);
vb@40
    24
    cout << "message created.\n";
vb@39
    25
vb@48
    26
//     cout << "encrypting message in pieces…\n";
vb@48
    27
//     message *enc_msg;
vb@48
    28
//     cout << "calling encrypt_message()\n";
vb@48
    29
//     PEP_STATUS status2 = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_pieces);
vb@48
    30
//     assert(status2 == PEP_STATUS_OK);
vb@48
    31
//     assert(enc_msg);
vb@48
    32
//     cout << "message encrypted.\n";
vb@48
    33
vb@48
    34
    cout << "encrypting message as MIME multipart…\n";
vb@48
    35
    message *enc_msg2;
vb@40
    36
    cout << "calling encrypt_message()\n";
vb@48
    37
    PEP_STATUS status3 = encrypt_message(session, msg, NULL, &enc_msg2, PEP_enc_MIME_multipart);
vb@48
    38
    assert(status3 == PEP_STATUS_OK);
vb@48
    39
    assert(enc_msg2);
vb@40
    40
    cout << "message encrypted.\n";
vb@48
    41
    
vb@40
    42
    cout << "freeing messages…\n";
vb@39
    43
    free_message(msg);
vb@48
    44
//    free_message(enc_msg);
vb@48
    45
    free_message(enc_msg2);
vb@40
    46
    cout << "done.\n";
vb@39
    47
vb@39
    48
    cout << "calling release()\n";
vb@39
    49
    release(session);
vb@39
    50
    return 0;
vb@39
    51
}
vb@39
    52