removed the "libxml.h" dependency which is unnecessary (and requires source)
[OpenSRF.git] / include / opensrf / transport_message.h
1 #include "opensrf/generic_utils.h"
2
3 #include <string.h>
4 #include <libxml/globals.h>
5 #include <libxml/xmlerror.h>
6 #include <libxml/parser.h>
7 #include <libxml/tree.h>
8 #include <libxml/debugXML.h>
9 #include <libxml/xmlmemory.h>
10
11 #ifndef TRANSPORT_MESSAGE_H
12 #define TRANSPORT_MESSAGE_H
13
14
15
16 // ---------------------------------------------------------------------------------
17 // Jabber message object.
18 // ---------------------------------------------------------------------------------
19 struct transport_message_struct {
20         char* body;
21         char* subject;
22         char* thread;
23         char* recipient;
24         char* sender;
25         char* router_from;
26         char* router_to;
27         char* router_class;
28         char* router_command;
29         int is_error;
30         char* error_type;
31         int error_code;
32         int broadcast;
33         char* msg_xml; /* the entire message as XML complete with entity encoding */
34 };
35 typedef struct transport_message_struct transport_message;
36
37 // ---------------------------------------------------------------------------------
38 // Allocates and returns a transport_message.  All chars are safely re-allocated
39 // within this method.
40 // Returns NULL on error
41 // ---------------------------------------------------------------------------------
42 transport_message* message_init( char* body, char* subject, 
43                 char* thread, char* recipient, char* sender );
44
45 transport_message* new_message_from_xml( const char* msg_xml );
46
47
48 void message_set_router_info( transport_message* msg, char* router_from,
49                 char* router_to, char* router_class, char* router_command, int broadcast_enabled );
50
51 // ---------------------------------------------------------------------------------
52 // Formats the Jabber message as XML for encoding. 
53 // Returns NULL on error
54 // ---------------------------------------------------------------------------------
55 char* message_to_xml( const transport_message* msg );
56
57
58 // ---------------------------------------------------------------------------------
59 // Call this to create the encoded XML for sending on the wire.
60 // This is a seperate function so that encoding will not necessarily have
61 // to happen on all messages (i.e. typically only occurs outbound messages).
62 // ---------------------------------------------------------------------------------
63 int message_prepare_xml( transport_message* msg );
64
65 // ---------------------------------------------------------------------------------
66 // Deallocates the memory used by the transport_message
67 // Returns 0 on error
68 // ---------------------------------------------------------------------------------
69 int message_free( transport_message* msg );
70
71 // ---------------------------------------------------------------------------------
72 // Prepares the shared XML document
73 // ---------------------------------------------------------------------------------
74 //int message_init_xml();
75
76 // ---------------------------------------------------------------------------------
77 // Determines the username of a Jabber ID.  This expects a pre-allocated char 
78 // array for the return value.
79 // ---------------------------------------------------------------------------------
80 void jid_get_username( const char* jid, char buf[] );
81
82 // ---------------------------------------------------------------------------------
83 // Determines the resource of a Jabber ID.  This expects a pre-allocated char 
84 // array for the return value.
85 // ---------------------------------------------------------------------------------
86 void jid_get_resource( const char* jid, char buf[] );
87
88 void set_msg_error( transport_message*, char* error_type, int error_code);
89
90 #endif