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