src/transport.h
author vb
Tue, 09 Sep 2014 13:00:10 +0200
changeset 29 31881fe94d3c
parent 28 7fc9fc3e680c
child 30 49f7cbcb91df
permissions -rw-r--r--
message implementation
vb@23
     1
#pragma once
vb@23
     2
vb@23
     3
#include "pEpEngine.h"
vb@29
     4
#include <time.h>
vb@29
     5
#include <stdlib.h>
vb@29
     6
vb@29
     7
typedef struct tm timestamp;
vb@23
     8
vb@23
     9
typedef enum _PEP_transports {
vb@23
    10
    PEP_trans_auto = 0,
vb@28
    11
//    PEP_trans_email,
vb@28
    12
//    PEP_trans_whatsapp,
vb@23
    13
vb@23
    14
    PEP_trans__count
vb@23
    15
} PEP_transports;
vb@23
    16
vb@23
    17
typedef struct _PEP_transport_t PEP_transport_t;
vb@23
    18
vb@29
    19
pEp_identity *identity_dup(const pEp_identity *src);
vb@29
    20
vb@29
    21
typedef struct _identity_list {
vb@29
    22
    pEp_identity *ident;
vb@29
    23
    struct _identity_list *next;
vb@29
    24
} identity_list;
vb@29
    25
vb@29
    26
identity_list *new_identity_list(const pEp_identity *ident);
vb@29
    27
void free_identity_list(identity_list *id_list);
vb@29
    28
identity_list *identity_list_add(identity_list *id_list, const pEp_identity *ident);
vb@29
    29
vb@29
    30
typedef enum _msg_format {
vb@29
    31
    format_plain = 0,
vb@29
    32
    format_html
vb@29
    33
} msg_format;
vb@29
    34
vb@29
    35
typedef enum _msg_direction {
vb@29
    36
    dir_incoming = 0,
vb@29
    37
    dir_outgoing
vb@29
    38
} msg_direction;
vb@29
    39
vb@29
    40
struct _message_ref_list;
vb@29
    41
vb@29
    42
typedef struct _message {
vb@29
    43
    msg_direction dir;
vb@29
    44
    char * id;
vb@29
    45
    size_t id_size;
vb@29
    46
    char * shortmsg;
vb@29
    47
    size_t shortmsg_size;
vb@29
    48
    char * longmsg;
vb@29
    49
    size_t longmsg_size;
vb@29
    50
    char * longmsg_formatted;
vb@29
    51
    size_t longmsg_formatted_size;
vb@29
    52
    msg_format format;
vb@29
    53
    char * rawmsg;
vb@29
    54
    size_t rawmsg_size;
vb@29
    55
    timestamp sent;
vb@29
    56
    timestamp recv;
vb@29
    57
    pEp_identity *from;
vb@29
    58
    identity_list *to;
vb@29
    59
    pEp_identity *recv_by;
vb@29
    60
    identity_list *cc;
vb@29
    61
    identity_list *bcc;
vb@29
    62
    char * refering_id;
vb@29
    63
    size_t refering_id_size;
vb@29
    64
    struct _message *refering_msg;
vb@29
    65
    struct _message_ref_list *refered_by;
vb@29
    66
} message;
vb@29
    67
vb@29
    68
typedef struct _message_ref_list {
vb@29
    69
    message *msg_ref;
vb@29
    70
    struct _message_ref_list *next;
vb@29
    71
} message_ref_list;
vb@29
    72
vb@29
    73
message *new_message(
vb@29
    74
        msg_direction dir,
vb@29
    75
        const pEp_identity *from,
vb@29
    76
        const pEp_identity *to,
vb@29
    77
        const char *shortmsg
vb@29
    78
    );
vb@29
    79
vb@29
    80
void free_message(message *msg);
vb@29
    81
vb@29
    82
message_ref_list *new_message_ref_list(message *msg);
vb@29
    83
void free_message_ref_list(message_ref_list *msg_list);
vb@29
    84
message_ref_list *message_ref_list_add(message_ref_list *msg_list, message *msg);
vb@29
    85
vb@29
    86
typedef PEP_STATUS (*sendto_t)(PEP_SESSION session, const message *msg);
vb@29
    87
typedef PEP_STATUS (*readnext_t)(PEP_SESSION session, message **msg, PEP_transport_t **via);
vb@23
    88
vb@23
    89
struct _PEP_transport_t {
vb@23
    90
    uint8_t id;
vb@23
    91
    sendto_t sendto;
vb@23
    92
    readnext_t readnext;
vb@23
    93
};
vb@23
    94
vb@23
    95
typedef uint64_t transports_mask;
vb@28
    96
vb@28
    97
PEP_STATUS init_transport_system(PEP_SESSION session);
vb@28
    98
void release_transport_system(PEP_SESSION session);