]> git.evergreen-ils.org Git - OpenSRF.git/blob - include/opensrf/transport_message.h
added a force set option on log XID to override it even we can act as an origin client
[OpenSRF.git] / include / opensrf / transport_message.h
1 #include <string.h>
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>
8
9 #include <opensrf/utils.h>
10 #include <opensrf/xml_utils.h>
11 #include <opensrf/log.h>
12
13 #ifndef TRANSPORT_MESSAGE_H
14 #define TRANSPORT_MESSAGE_H
15
16
17
18 // ---------------------------------------------------------------------------------
19 // Jabber message object.
20 // ---------------------------------------------------------------------------------
21 struct transport_message_struct {
22         char* body;
23         char* subject;
24         char* thread;
25         char* recipient;
26         char* sender;
27         char* router_from;
28         char* router_to;
29         char* router_class;
30         char* router_command;
31         char* osrf_xid;
32         int is_error;
33         char* error_type;
34         int error_code;
35         int broadcast;
36         char* msg_xml; /* the entire message as XML complete with entity encoding */
37 };
38 typedef struct transport_message_struct transport_message;
39
40 // ---------------------------------------------------------------------------------
41 // Allocates and returns a transport_message.  All chars are safely re-allocated
42 // within this method.
43 // Returns NULL on error
44 // ---------------------------------------------------------------------------------
45 transport_message* message_init( const char* body, const char* subject, 
46                 const char* thread, const char* recipient, const char* sender );
47
48 transport_message* new_message_from_xml( const char* msg_xml );
49
50
51 void message_set_router_info( transport_message* msg, const char* router_from,
52                 const char* router_to, const char* router_class, const char* router_command,
53                 int broadcast_enabled );
54
55 void message_set_osrf_xid( transport_message* msg, const char* osrf_xid );
56
57 // ---------------------------------------------------------------------------------
58 // Formats the Jabber message as XML for encoding. 
59 // Returns NULL on error
60 // ---------------------------------------------------------------------------------
61 char* message_to_xml( const transport_message* msg );
62
63
64 // ---------------------------------------------------------------------------------
65 // Call this to create the encoded XML for sending on the wire.
66 // This is a seperate function so that encoding will not necessarily have
67 // to happen on all messages (i.e. typically only occurs outbound messages).
68 // ---------------------------------------------------------------------------------
69 int message_prepare_xml( transport_message* msg );
70
71 // ---------------------------------------------------------------------------------
72 // Deallocates the memory used by the transport_message
73 // Returns 0 on error
74 // ---------------------------------------------------------------------------------
75 int message_free( transport_message* msg );
76
77 // ---------------------------------------------------------------------------------
78 // Prepares the shared XML document
79 // ---------------------------------------------------------------------------------
80 //int message_init_xml();
81
82 // ---------------------------------------------------------------------------------
83 // Determines the username of a Jabber ID.  This expects a pre-allocated char 
84 // array for the return value.
85 // ---------------------------------------------------------------------------------
86 void jid_get_username( const char* jid, char buf[], int size );
87
88 // ---------------------------------------------------------------------------------
89 // Determines the resource of a Jabber ID.  This expects a pre-allocated char 
90 // array for the return value.
91 // ---------------------------------------------------------------------------------
92 void jid_get_resource( const char* jid, char buf[], int size );
93
94 /** Puts the domain portion of the given jid into the pre-allocated buffer */
95 void jid_get_domain( const char* jid, char buf[], int size );
96
97 void set_msg_error( transport_message*, const char* error_type, int error_code);
98
99
100 #endif