Mercurial > pidgin
comparison src/protocols/msn/oim.c @ 19790:4f21c73a0c48
[gaim-migrate @ 16613]
add oim retrieve,can get oim message
write the framework of oim send
Committed by MaYuan <mayuan2006@gmail.com>
committer: Ethan Blanton <elb@pidgin.im>
author | Ma Yuan <mayuan2006@gmail.com> |
---|---|
date | Wed, 02 Aug 2006 05:44:42 +0000 |
parents | 7e36832172a9 |
children | bddd32f36bde |
comparison
equal
deleted
inserted
replaced
19789:7e36832172a9 | 19790:4f21c73a0c48 |
---|---|
25 */ | 25 */ |
26 #include "msn.h" | 26 #include "msn.h" |
27 #include "soap.h" | 27 #include "soap.h" |
28 #include "oim.h" | 28 #include "oim.h" |
29 | 29 |
30 /*Local Function Prototype*/ | |
31 static void msn_oim_post_single_get_msg(MsnOim *oim,const char *msgid); | |
32 | |
30 /*new a OIM object*/ | 33 /*new a OIM object*/ |
31 MsnOim * | 34 MsnOim * |
32 msn_oim_new(MsnSession *session) | 35 msn_oim_new(MsnSession *session) |
33 { | 36 { |
34 MsnOim *oim; | 37 MsnOim *oim; |
35 | 38 |
36 oim = g_new0(MsnOim, 1); | 39 oim = g_new0(MsnOim, 1); |
37 oim->session = session; | 40 oim->session = session; |
38 oim->retrieveconn = msn_soap_new(session,oim,1); | 41 oim->retrieveconn = msn_soap_new(session,oim,1); |
42 oim->oim_list = NULL; | |
39 oim->sendconn = msn_soap_new(session,oim,1); | 43 oim->sendconn = msn_soap_new(session,oim,1); |
40 | 44 |
41 return oim; | 45 return oim; |
42 } | 46 } |
43 | 47 |
80 | 84 |
81 session = oim->session; | 85 session = oim->session; |
82 g_return_if_fail(session != NULL); | 86 g_return_if_fail(session != NULL); |
83 } | 87 } |
84 | 88 |
89 static void | |
90 msn_oim_send_read_cb(gpointer data, GaimSslConnection *gsc, | |
91 GaimInputCondition cond) | |
92 { | |
93 MsnSoapConn * soapconn = data; | |
94 MsnOim * msnoim; | |
95 | |
96 gaim_debug_info("MaYuan","read buffer:{%s}\n",soapconn->body); | |
97 } | |
98 | |
99 static void | |
100 msn_oim_send_written_cb(gpointer data, gint source, GaimInputCondition cond) | |
101 { | |
102 MsnSoapConn * soapconn = data; | |
103 | |
104 soapconn->read_cb = msn_oim_send_read_cb; | |
105 msn_soap_read_cb(data,source,cond); | |
106 } | |
107 | |
108 /*pose single message to oim server*/ | |
109 void msn_oim_send_single_msg(MsnOim *oim,char * msg) | |
110 { | |
111 const char *oimsoapbody,*t,*p; | |
112 | |
113 gaim_debug_info("MaYuan","send single OIM Message\n"); | |
114 oim->sendconn->login_path = g_strdup(MSN_OIM_SEND_URL); | |
115 oim->sendconn->soap_action = g_strdup(MSN_OIM_SEND_SOAP_ACTION); | |
116 t = oim->session->passport_info.t; | |
117 p = oim->session->passport_info.p; | |
118 #if 0 | |
119 oimsoapbody = g_strdup_printf(MSN_OIM_SEND_TEMPLATE, | |
120 membername, | |
121 friendname, | |
122 tomember, | |
123 mspauth, | |
124 prod_id, | |
125 lock_key, | |
126 msg_num, | |
127 msg | |
128 ); | |
129 #endif | |
130 msn_soap_post(oim->retrieveconn, oimsoapbody, msn_oim_send_written_cb); | |
131 | |
132 } | |
133 | |
85 void msn_oim_send_msg(MsnOim *oim,char *msg) | 134 void msn_oim_send_msg(MsnOim *oim,char *msg) |
86 { | 135 { |
87 if(msn_soap_connected(oim->sendconn) == -1){ | 136 if(msn_soap_connected(oim->sendconn) == -1){ |
88 msn_soap_init(oim->sendconn,MSN_OIM_SEND_HOST,1, | |
89 msn_oim_send_connect_cb, | |
90 msn_oim_send_error_cb); | |
91 } | 137 } |
92 | 138 |
93 } | 139 } |
94 | 140 |
95 /**************************************** | 141 /**************************************** |
120 oim = soapconn->parent; | 166 oim = soapconn->parent; |
121 g_return_if_fail(oim != NULL); | 167 g_return_if_fail(oim != NULL); |
122 | 168 |
123 session = oim->session; | 169 session = oim->session; |
124 g_return_if_fail(session != NULL); | 170 g_return_if_fail(session != NULL); |
171 | |
172 gaim_debug_info("MaYuan","oim get SOAP Server connected!\n"); | |
173 /*call to get the message*/ | |
174 msn_oim_get_msg(oim); | |
125 } | 175 } |
126 | 176 |
127 static void | 177 static void |
128 msn_oim_get_read_cb(gpointer data, GaimSslConnection *gsc, | 178 msn_oim_get_read_cb(gpointer data, GaimSslConnection *gsc, |
129 GaimInputCondition cond) | 179 GaimInputCondition cond) |
143 msn_soap_read_cb(data,source,cond); | 193 msn_soap_read_cb(data,source,cond); |
144 } | 194 } |
145 | 195 |
146 /*get the conversation*/ | 196 /*get the conversation*/ |
147 static GaimConversation * | 197 static GaimConversation * |
148 msn_oim_get_conv(MsnOim *oim,char *passport) | 198 msn_oim_get_conv(MsnOim *oim,const char *passport) |
149 { | 199 { |
150 GaimAccount *account; | 200 GaimAccount *account; |
151 GaimConversation * conv; | 201 GaimConversation * conv; |
152 | 202 |
153 g_return_val_if_fail(oim != NULL, NULL); | 203 g_return_val_if_fail(oim != NULL, NULL); |
191 rTime = xmlnode_get_data(rtNode); | 241 rTime = xmlnode_get_data(rtNode); |
192 nNode = xmlnode_get_child(mNode,"N"); | 242 nNode = xmlnode_get_child(mNode,"N"); |
193 nickname = xmlnode_get_data(nNode); | 243 nickname = xmlnode_get_data(nNode); |
194 gaim_debug_info("MaYuan","E:{%s},I:{%s},rTime:{%s}\n",passport,msgid,rTime); | 244 gaim_debug_info("MaYuan","E:{%s},I:{%s},rTime:{%s}\n",passport,msgid,rTime); |
195 // msn_oim_report_user(oim,passport,"hello"); | 245 // msn_oim_report_user(oim,passport,"hello"); |
196 msn_oim_get_msg(oim,msgid); | 246 oim->oim_list = g_list_append(oim->oim_list,msgid); |
197 } | 247 } |
198 } | |
199 | |
200 /*MSN OIM get SOAP request*/ | |
201 void msn_oim_get_msg(MsnOim *oim,char *msgid) | |
202 { | |
203 const char *oimid ,*oimsoapbody,*t,*p; | |
204 | |
205 if(msn_soap_connected(oim->retrieveconn) == -1){ | 248 if(msn_soap_connected(oim->retrieveconn) == -1){ |
206 gaim_debug_info("MaYuan","retreive OIM server not connected!\n"); | 249 gaim_debug_info("MaYuan","retreive OIM server not connected! We need to connect it first\n"); |
250 msn_oim_connect(oim); | |
207 return; | 251 return; |
208 } | 252 } |
209 | 253 msn_oim_get_msg(oim); |
210 gaim_debug_info("MaYuan","Get OIM with SOAP \n"); | 254 } |
255 | |
256 static void msn_oim_post_single_get_msg(MsnOim *oim,const char *msgid) | |
257 { | |
258 const char *oimsoapbody,*t,*p; | |
259 | |
260 gaim_debug_info("MaYuan","Get single OIM Message\n"); | |
211 oim->retrieveconn->login_path = g_strdup(MSN_OIM_RETRIEVE__URL); | 261 oim->retrieveconn->login_path = g_strdup(MSN_OIM_RETRIEVE__URL); |
212 oim->retrieveconn->soap_action = g_strdup(MSN_OIM_GET_SOAP_ACTION); | 262 oim->retrieveconn->soap_action = g_strdup(MSN_OIM_GET_SOAP_ACTION); |
213 t = oim->session->passport_info.t; | 263 t = oim->session->passport_info.t; |
214 p = oim->session->passport_info.p; | 264 p = oim->session->passport_info.p; |
215 | 265 |
217 t, | 267 t, |
218 p, | 268 p, |
219 msgid | 269 msgid |
220 ); | 270 ); |
221 msn_soap_post(oim->retrieveconn, oimsoapbody, msn_oim_get_written_cb); | 271 msn_soap_post(oim->retrieveconn, oimsoapbody, msn_oim_get_written_cb); |
272 | |
273 } | |
274 | |
275 /*MSN OIM get SOAP request*/ | |
276 void msn_oim_get_msg(MsnOim *oim) | |
277 { | |
278 GList *list; | |
279 | |
280 gaim_debug_info("MaYuan","Get OIM with SOAP \n"); | |
281 // gaim_debug_info("MaYuan","oim->oim_list:%p,data:%s \n",oim->oim_list,oim->oim_list->data); | |
282 for(list = oim->oim_list; list!= NULL;list = g_list_next(list)){ | |
283 msn_oim_post_single_get_msg(oim,list->data); | |
284 oim->oim_list = g_list_remove(oim->oim_list, list->data); | |
285 } | |
222 } | 286 } |
223 | 287 |
224 /*msn oim server connect*/ | 288 /*msn oim server connect*/ |
225 void | 289 void |
226 msn_oim_connect(MsnOim *oim) | 290 msn_oim_connect(MsnOim *oim) |
227 { | 291 { |
228 gaim_debug_info("MaYuan","msn_oim_connect...\n"); | 292 gaim_debug_info("MaYuan","msn_oim_connect...\n"); |
229 | 293 |
230 msn_soap_init(oim->retrieveconn,MSN_OIM_RETRIEVE_HOST,1, | 294 if(msn_soap_connected(oim->retrieveconn) == -1){ |
295 msn_soap_init(oim->retrieveconn,MSN_OIM_RETRIEVE_HOST,1, | |
231 msn_oim_get_connect_cb, | 296 msn_oim_get_connect_cb, |
232 msn_oim_get_error_cb); | 297 msn_oim_get_error_cb); |
233 msn_soap_init(oim->sendconn,MSN_OIM_SEND_HOST,1, | 298 } |
299 | |
300 if(msn_soap_connected(oim->sendconn) == -1){ | |
301 msn_soap_init(oim->sendconn,MSN_OIM_SEND_HOST,1, | |
234 msn_oim_send_connect_cb, | 302 msn_oim_send_connect_cb, |
235 msn_oim_send_error_cb); | 303 msn_oim_send_error_cb); |
304 } | |
236 } | 305 } |
237 | 306 |
238 /*endof oim.c*/ | 307 /*endof oim.c*/ |