2 #include <libxml/globals.h>
3 #include <libxml/xmlerror.h>
4 #include <libxml/parser.h>
5 #include <libxml/tree.h>
6 #include <libxml/debugXML.h>
7 #include <libxml/xmlmemory.h>
9 #include "opensrf/utils.h"
10 #include "opensrf/logging.h"
12 #ifndef TRANSPORT_MESSAGE_H
13 #define TRANSPORT_MESSAGE_H
17 // ---------------------------------------------------------------------------------
18 // Jabber message object.
19 // ---------------------------------------------------------------------------------
20 struct transport_message_struct {
34 char* msg_xml; /* the entire message as XML complete with entity encoding */
36 typedef struct transport_message_struct transport_message;
38 // ---------------------------------------------------------------------------------
39 // Allocates and returns a transport_message. All chars are safely re-allocated
40 // within this method.
41 // Returns NULL on error
42 // ---------------------------------------------------------------------------------
43 transport_message* message_init( char* body, char* subject,
44 char* thread, char* recipient, char* sender );
46 transport_message* new_message_from_xml( const char* msg_xml );
49 void message_set_router_info( transport_message* msg, char* router_from,
50 char* router_to, char* router_class, char* router_command, int broadcast_enabled );
52 // ---------------------------------------------------------------------------------
53 // Formats the Jabber message as XML for encoding.
54 // Returns NULL on error
55 // ---------------------------------------------------------------------------------
56 char* message_to_xml( const transport_message* msg );
59 // ---------------------------------------------------------------------------------
60 // Call this to create the encoded XML for sending on the wire.
61 // This is a seperate function so that encoding will not necessarily have
62 // to happen on all messages (i.e. typically only occurs outbound messages).
63 // ---------------------------------------------------------------------------------
64 int message_prepare_xml( transport_message* msg );
66 // ---------------------------------------------------------------------------------
67 // Deallocates the memory used by the transport_message
69 // ---------------------------------------------------------------------------------
70 int message_free( transport_message* msg );
72 // ---------------------------------------------------------------------------------
73 // Prepares the shared XML document
74 // ---------------------------------------------------------------------------------
75 //int message_init_xml();
77 // ---------------------------------------------------------------------------------
78 // Determines the username of a Jabber ID. This expects a pre-allocated char
79 // array for the return value.
80 // ---------------------------------------------------------------------------------
81 void jid_get_username( const char* jid, char buf[], int size );
83 // ---------------------------------------------------------------------------------
84 // Determines the resource of a Jabber ID. This expects a pre-allocated char
85 // array for the return value.
86 // ---------------------------------------------------------------------------------
87 void jid_get_resource( const char* jid, char buf[], int size );
89 /** Puts the domain portion of the given jid into the pre-allocated buffer */
90 void jid_get_domain( const char* jid, char buf[], int size );
92 void set_msg_error( transport_message*, char* error_type, int error_code);