]> git.evergreen-ils.org Git - OpenSRF.git/blob - include/opensrf/transport_message.h
LP#1286198: Teach osrf_router to (optionally) write its own PID files
[OpenSRF.git] / include / opensrf / transport_message.h
1 #ifndef TRANSPORT_MESSAGE_H
2 #define TRANSPORT_MESSAGE_H
3
4 /**
5         @file transport_message.h
6         @brief Header for routines to manage transport_messages.
7
8         A transport_message is a representation of a Jabber message. i.e. a message stanza in a
9         Jabber XML stream.
10 */
11
12 #include <string.h>
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>
19
20 #include <opensrf/utils.h>
21 #include <opensrf/xml_utils.h>
22 #include <opensrf/log.h>
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /**
29         @brief A representation of a Jabber message.
30
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:
34         - router_from
35         - router_to
36         - router_class
37         - router_command
38         - osrf_xid
39         - broadcast
40 */
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 &lt;error&gt; is present. */
53         char* error_type;      /**< Value of the "type" attribute of &lt;error&gt;. */
54         int error_code;        /**< Value of the "code" attribute of &lt;error&gt;. */
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;
58 };
59 typedef struct transport_message_struct transport_message;
60
61 transport_message* message_init( const char* body, const char* subject,
62                 const char* thread, const char* recipient, const char* sender );
63
64 transport_message* new_message_from_xml( const char* msg_xml );
65
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 );
69
70 void message_set_osrf_xid( transport_message* msg, const char* osrf_xid );
71
72 int message_prepare_xml( transport_message* msg );
73
74 int message_free( transport_message* msg );
75
76 void jid_get_username( const char* jid, char buf[], int size );
77
78 void jid_get_resource( const char* jid, char buf[], int size );
79
80 void jid_get_domain( const char* jid, char buf[], int size );
81
82 void set_msg_error( transport_message*, const char* error_type, int error_code);
83
84 #ifdef __cplusplus
85 }
86 #endif
87
88 #endif