3 #include "opensrf/generic_utils.h"
6 #include <libxml/globals.h>
7 #include <libxml/xmlerror.h>
8 #include <libxml/parser.h>
9 #include <libxml/tree.h>
10 #include <libxml/debugXML.h>
11 #include <libxml/xmlmemory.h>
13 #ifndef TRANSPORT_MESSAGE_H
14 #define TRANSPORT_MESSAGE_H
18 // ---------------------------------------------------------------------------------
19 // Jabber message object.
20 // ---------------------------------------------------------------------------------
21 struct transport_message_struct {
35 char* msg_xml; /* the entire message as XML complete with entity encoding */
37 typedef struct transport_message_struct transport_message;
39 // ---------------------------------------------------------------------------------
40 // Allocates and returns a transport_message. All chars are safely re-allocated
41 // within this method.
42 // Returns NULL on error
43 // ---------------------------------------------------------------------------------
44 transport_message* message_init( char* body, char* subject,
45 char* thread, char* recipient, char* sender );
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 );
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 );
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 );
65 // ---------------------------------------------------------------------------------
66 // Deallocates the memory used by the transport_message
68 // ---------------------------------------------------------------------------------
69 int message_free( transport_message* msg );
71 // ---------------------------------------------------------------------------------
72 // Prepares the shared XML document
73 // ---------------------------------------------------------------------------------
74 //int message_init_xml();
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[] );
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[] );
88 void set_msg_error( transport_message*, char* error_type, int error_code);