comparison libpurple/protocols/msn/soap.h @ 23552:711773577380

Clean up some MSN SOAP stuff. I think soap2.[ch] have proven themselves since we've been using them all this time. Removed soap.[ch] and any references to them, since those were mostly in header files, without any actual use in code. Also, removed some SOAP templates from group.h which are now taken care of by contact.[ch].
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 28 Jun 2008 06:01:22 +0000
parents 5cdd93dac7a2
children 860e5e210fc9
comparison
equal deleted inserted replaced
23551:8263c86099df 23552:711773577380
1 /** 1 /**
2 * @file soap.h 2 * @file soap.h
3 * header file for SOAP connection related process 3 * header file for SOAP connection related process
4 * Author 4 *
5 * MaYuan<mayuan2006@gmail.com>
6 * purple 5 * purple
7 * 6 *
8 * Purple is the legal property of its developers, whose names are too numerous 7 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this 8 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution. 9 * source distribution.
21 * 20 *
22 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */ 24 */
26 #ifndef _MSN_SOAP_H_
27 #define _MSN_SOAP_H_
28 25
29 #define MSN_SOAP_READ_BUFF_SIZE 8192 26 #ifndef _MSN_SOAP_H
27 #define _MSN_SOAP_H
30 28
31 /* define this to debug the communications with the SOAP server */ 29 #include "session.h"
32 /* #define MSN_SOAP_DEBUG */ 30 #include "sslconn.h"
31 #include "xmlnode.h"
33 32
34 #define MSN_SOAP_READ 1 33 #include <glib.h>
35 #define MSN_SOAP_WRITE 2
36 34
37 typedef enum 35 typedef struct _MsnSoapMessage MsnSoapMessage;
38 { 36 typedef void (*MsnSoapCallback)(MsnSoapMessage *request,
39 MSN_SOAP_UNCONNECTED, 37 MsnSoapMessage *response, gpointer cb_data);
40 MSN_SOAP_CONNECTING,
41 MSN_SOAP_CONNECTED,
42 MSN_SOAP_PROCESSING,
43 MSN_SOAP_CONNECTED_IDLE
44 }MsnSoapStep;
45 38
46 /* MSN SoapRequest structure*/ 39 struct _MsnSoapMessage {
47 typedef struct _MsnSoapReq MsnSoapReq; 40 char *action;
48 41 xmlnode *xml;
49 /* MSN Https connection structure*/ 42 GSList *headers;
50 typedef struct _MsnSoapConn MsnSoapConn;
51
52 typedef void (*MsnSoapConnectInitFunction)(MsnSoapConn *);
53 typedef gboolean (*MsnSoapReadCbFunction)(MsnSoapConn *);
54 typedef void (*MsnSoapWrittenCbFunction)(MsnSoapConn *);
55
56 typedef gboolean (*MsnSoapSslConnectCbFunction)(MsnSoapConn *, PurpleSslConnection *);
57 typedef void (*MsnSoapSslErrorCbFunction)(MsnSoapConn *, PurpleSslConnection *, PurpleSslErrorType);
58
59
60 struct _MsnSoapReq{
61 /*request sequence*/
62 int id;
63
64 char *login_host;
65 char *login_path;
66 char *soap_action;
67
68 char *body;
69
70 gpointer data_cb;
71 MsnSoapReadCbFunction read_cb;
72 MsnSoapWrittenCbFunction written_cb;
73 MsnSoapConnectInitFunction connect_init;
74 }; 43 };
75 44
76 struct _MsnSoapConn{ 45 MsnSoapMessage *msn_soap_message_new(const char *action, xmlnode *xml);
77 MsnSession *session;
78 gpointer parent;
79 46
80 char *login_host; 47 void msn_soap_message_add_header(MsnSoapMessage *req,
81 char *login_path; 48 const char *name, const char *value);
82 char *soap_action;
83 49
84 MsnSoapStep step; 50 void msn_soap_message_send(MsnSession *session,
85 /*ssl connection?*/ 51 MsnSoapMessage *message, const char *host, const char *path,
86 gboolean ssl_conn; 52 MsnSoapCallback cb, gpointer cb_data);
87 /*normal connection*/
88 guint fd;
89 /*SSL connection*/
90 PurpleSslConnection *gsc;
91 /*ssl connection callback*/
92 MsnSoapSslConnectCbFunction connect_cb;
93 /*ssl error callback*/
94 MsnSoapSslErrorCbFunction error_cb;
95 53
96 /*read handler*/ 54 void msn_soap_message_destroy(MsnSoapMessage *message);
97 guint input_handler;
98 /*write handler*/
99 guint output_handler;
100 55
101 /*Queue of SOAP request to send*/ 56 #endif
102 int soap_id;
103 GQueue *soap_queue;
104
105 /*write buffer*/
106 char *write_buf;
107 gsize written_len;
108 MsnSoapWrittenCbFunction written_cb;
109
110 /*read buffer*/
111 char *read_buf;
112 gsize read_len;
113 gsize need_to_read;
114 MsnSoapReadCbFunction read_cb;
115
116 gpointer data_cb;
117
118 /*HTTP reply body part*/
119 char *body;
120 int body_len;
121 };
122
123
124 /*Function Prototype*/
125 /*Soap Request Function */
126 MsnSoapReq *msn_soap_request_new(const char *host, const char *post_url,
127 const char *soap_action, const char *body,
128 const gpointer data_cb,
129 MsnSoapReadCbFunction read_cb,
130 MsnSoapWrittenCbFunction written_cb,
131 MsnSoapConnectInitFunction connect_init);
132
133 void msn_soap_request_free(MsnSoapReq *request);
134 void msn_soap_post_request(MsnSoapConn *soapconn,MsnSoapReq *request);
135 void msn_soap_post_head_request(MsnSoapConn *soapconn);
136
137 /*new a soap conneciton */
138 MsnSoapConn *msn_soap_new(MsnSession *session, gpointer data, gboolean ssl);
139
140 /*destroy */
141 void msn_soap_destroy(MsnSoapConn *soapconn);
142
143 /*init a soap conneciton */
144 void msn_soap_init(MsnSoapConn *soapconn, char * host, gboolean ssl,
145 MsnSoapSslConnectCbFunction connect_cb,
146 MsnSoapSslErrorCbFunction error_cb);
147 void msn_soap_connect(MsnSoapConn *soapconn);
148 void msn_soap_close(MsnSoapConn *soapconn);
149
150 /*write to soap*/
151 void msn_soap_write(MsnSoapConn * soapconn, char *write_buf, MsnSoapWrittenCbFunction written_cb);
152 void msn_soap_post(MsnSoapConn *soapconn,MsnSoapReq *request);
153
154 void msn_soap_free_read_buf(MsnSoapConn *soapconn);
155 void msn_soap_free_write_buf(MsnSoapConn *soapconn);
156 void msn_soap_connect_cb(gpointer data, PurpleSslConnection *gsc, PurpleInputCondition cond);
157
158 /*clean the unhandled requests*/
159 void msn_soap_clean_unhandled_requests(MsnSoapConn *soapconn);
160
161 /*check if the soap connection is connected*/
162 int msn_soap_connected(MsnSoapConn *soapconn);
163 void msn_soap_set_process_step(MsnSoapConn *soapconn, MsnSoapStep step);
164
165 #endif/*_MSN_SOAP_H_*/
166