1 #ifndef TRANSPORT_MESSAGE_H
2 #define TRANSPORT_MESSAGE_H
5 #include <libxml/globals.h>
6 #include <libxml/xmlerror.h>
7 #include <libxml/parser.h>
8 #include <libxml/tree.h>
9 #include <libxml/debugXML.h>
10 #include <libxml/xmlmemory.h>
12 #include <opensrf/utils.h>
13 #include <opensrf/xml_utils.h>
14 #include <opensrf/log.h>
20 // ---------------------------------------------------------------------------------
21 // Jabber message object.
22 // ---------------------------------------------------------------------------------
23 struct transport_message_struct {
38 char* msg_xml; /* the entire message as XML complete with entity encoding */
39 struct transport_message_struct* next;
41 typedef struct transport_message_struct transport_message;
43 // ---------------------------------------------------------------------------------
44 // Allocates and returns a transport_message. All chars are safely re-allocated
45 // within this method.
46 // Returns NULL on error
47 // ---------------------------------------------------------------------------------
48 transport_message* message_init( const char* body, const char* subject,
49 const char* thread, const char* recipient, const char* sender );
51 transport_message* new_message_from_xml( const char* msg_xml );
54 void message_set_router_info( transport_message* msg, const char* router_from,
55 const char* router_to, const char* router_class, const char* router_command,
56 int broadcast_enabled );
58 void message_set_osrf_xid( transport_message* msg, const char* osrf_xid );
60 // ---------------------------------------------------------------------------------
61 // Call this to create the encoded XML for sending on the wire.
62 // This is a seperate function so that encoding will not necessarily have
63 // to happen on all messages (i.e. typically only occurs outbound messages).
64 // ---------------------------------------------------------------------------------
65 int message_prepare_xml( transport_message* msg );
67 // ---------------------------------------------------------------------------------
68 // Deallocates the memory used by the transport_message
70 // ---------------------------------------------------------------------------------
71 int message_free( transport_message* msg );
73 // ---------------------------------------------------------------------------------
74 // Determines the username of a Jabber ID. This expects a pre-allocated char
75 // array for the return value.
76 // ---------------------------------------------------------------------------------
77 void jid_get_username( const char* jid, char buf[], int size );
79 // ---------------------------------------------------------------------------------
80 // Determines the resource of a Jabber ID. This expects a pre-allocated char
81 // array for the return value.
82 // ---------------------------------------------------------------------------------
83 void jid_get_resource( const char* jid, char buf[], int size );
85 /** Puts the domain portion of the given jid into the pre-allocated buffer */
86 void jid_get_domain( const char* jid, char buf[], int size );
88 void set_msg_error( transport_message*, const char* error_type, int error_code);