src/transport.h
changeset 29 31881fe94d3c
parent 28 7fc9fc3e680c
child 30 49f7cbcb91df
     1.1 --- a/src/transport.h	Mon Sep 01 20:56:05 2014 +0200
     1.2 +++ b/src/transport.h	Tue Sep 09 13:00:10 2014 +0200
     1.3 @@ -1,6 +1,10 @@
     1.4  #pragma once
     1.5  
     1.6  #include "pEpEngine.h"
     1.7 +#include <time.h>
     1.8 +#include <stdlib.h>
     1.9 +
    1.10 +typedef struct tm timestamp;
    1.11  
    1.12  typedef enum _PEP_transports {
    1.13      PEP_trans_auto = 0,
    1.14 @@ -12,8 +16,75 @@
    1.15  
    1.16  typedef struct _PEP_transport_t PEP_transport_t;
    1.17  
    1.18 -typedef PEP_STATUS (*sendto_t)(PEP_SESSION session, const pEp_identity *address, const char *shortmsg, const char *longmsg, const char *longmsg_formatted);
    1.19 -typedef PEP_STATUS (*readnext_t)(PEP_SESSION session, pEp_identity *from, pEp_identity *reached, char **shortmsg, size_t shortmsg_size, char ** longmsg, size_t longmsg_size, char ** longmsg_formatted, size_t longmsg_formatted_size, PEP_transport_t **via);
    1.20 +pEp_identity *identity_dup(const pEp_identity *src);
    1.21 +
    1.22 +typedef struct _identity_list {
    1.23 +    pEp_identity *ident;
    1.24 +    struct _identity_list *next;
    1.25 +} identity_list;
    1.26 +
    1.27 +identity_list *new_identity_list(const pEp_identity *ident);
    1.28 +void free_identity_list(identity_list *id_list);
    1.29 +identity_list *identity_list_add(identity_list *id_list, const pEp_identity *ident);
    1.30 +
    1.31 +typedef enum _msg_format {
    1.32 +    format_plain = 0,
    1.33 +    format_html
    1.34 +} msg_format;
    1.35 +
    1.36 +typedef enum _msg_direction {
    1.37 +    dir_incoming = 0,
    1.38 +    dir_outgoing
    1.39 +} msg_direction;
    1.40 +
    1.41 +struct _message_ref_list;
    1.42 +
    1.43 +typedef struct _message {
    1.44 +    msg_direction dir;
    1.45 +    char * id;
    1.46 +    size_t id_size;
    1.47 +    char * shortmsg;
    1.48 +    size_t shortmsg_size;
    1.49 +    char * longmsg;
    1.50 +    size_t longmsg_size;
    1.51 +    char * longmsg_formatted;
    1.52 +    size_t longmsg_formatted_size;
    1.53 +    msg_format format;
    1.54 +    char * rawmsg;
    1.55 +    size_t rawmsg_size;
    1.56 +    timestamp sent;
    1.57 +    timestamp recv;
    1.58 +    pEp_identity *from;
    1.59 +    identity_list *to;
    1.60 +    pEp_identity *recv_by;
    1.61 +    identity_list *cc;
    1.62 +    identity_list *bcc;
    1.63 +    char * refering_id;
    1.64 +    size_t refering_id_size;
    1.65 +    struct _message *refering_msg;
    1.66 +    struct _message_ref_list *refered_by;
    1.67 +} message;
    1.68 +
    1.69 +typedef struct _message_ref_list {
    1.70 +    message *msg_ref;
    1.71 +    struct _message_ref_list *next;
    1.72 +} message_ref_list;
    1.73 +
    1.74 +message *new_message(
    1.75 +        msg_direction dir,
    1.76 +        const pEp_identity *from,
    1.77 +        const pEp_identity *to,
    1.78 +        const char *shortmsg
    1.79 +    );
    1.80 +
    1.81 +void free_message(message *msg);
    1.82 +
    1.83 +message_ref_list *new_message_ref_list(message *msg);
    1.84 +void free_message_ref_list(message_ref_list *msg_list);
    1.85 +message_ref_list *message_ref_list_add(message_ref_list *msg_list, message *msg);
    1.86 +
    1.87 +typedef PEP_STATUS (*sendto_t)(PEP_SESSION session, const message *msg);
    1.88 +typedef PEP_STATUS (*readnext_t)(PEP_SESSION session, message **msg, PEP_transport_t **via);
    1.89  
    1.90  struct _PEP_transport_t {
    1.91      uint8_t id;