1 #ifndef TRANSPORT_MESSAGE_H
2 #define TRANSPORT_MESSAGE_H
5 @file transport_message.h
6 @brief Header for routines to manage transport_messages.
8 A transport_message is a representation of a Jabber message. i.e. a message stanza in a
13 #include <libxml/globals.h>
14 #include <libxml/xmlerror.h>
15 #include <libxml/parser.h>
16 #include <libxml/tree.h>
17 #include <libxml/debugXML.h>
18 #include <libxml/xmlmemory.h>
20 #include <opensrf/utils.h>
21 #include <opensrf/xml_utils.h>
22 #include <opensrf/log.h>
29 @brief A representation of a Jabber message.
31 A transport_message represents a message stanza of a Jabber XML stream. The various
32 members store the contents of various attributes or text in the XML. The following
33 members represent OSRF extensions:
41 struct transport_message_struct {
42 char* body; /**< Text enclosed by the body element. */
43 char* subject; /**< Text enclosed by the subject element. */
44 char* thread; /**< Text enclosed by the thread element. */
45 char* recipient; /**< Value of the "to" attribute in the message element. */
46 char* sender; /**< Value of the "from" attribute in the message element. */
47 char* router_from; /**< Value of the "router_from" attribute in the message element. */
48 char* router_to; /**< Value of the "router_to" attribute in the message element. */
49 char* router_class; /**< Value of the "router_class" attribute in the message element. */
50 char* router_command; /**< Value of the "router_command" attribute in the message element. */
51 char* osrf_xid; /**< Value of the "osrf_xid" attribute in the message element. */
52 int is_error; /**< Boolean; true if <error> is present. */
53 char* error_type; /**< Value of the "type" attribute of <error>. */
54 int error_code; /**< Value of the "code" attribute of <error>. */
55 int broadcast; /**< Value of the "broadcast" attribute in the message element. */
56 char* msg_xml; /**< The entire message as XML, complete with entity encoding. */
57 struct transport_message_struct* next;
59 typedef struct transport_message_struct transport_message;
61 transport_message* message_init( const char* body, const char* subject,
62 const char* thread, const char* recipient, const char* sender );
64 transport_message* new_message_from_xml( const char* msg_xml );
66 void message_set_router_info( transport_message* msg, const char* router_from,
67 const char* router_to, const char* router_class, const char* router_command,
68 int broadcast_enabled );
70 void message_set_osrf_xid( transport_message* msg, const char* osrf_xid );
72 int message_prepare_xml( transport_message* msg );
74 int message_free( transport_message* msg );
76 void jid_get_username( const char* jid, char buf[], int size );
78 void jid_get_resource( const char* jid, char buf[], int size );
80 void jid_get_domain( const char* jid, char buf[], int size );
82 void set_msg_error( transport_message*, const char* error_type, int error_code);