annotate src/protocols/msn/oim.c @ 19789:7e36832172a9

[gaim-migrate @ 16601] change Windows Live ID authentication code style to simplify the code. add some comments committed by Ma Yuan<mayuan2006@gmail.com> committer: Ethan Blanton <elb@pidgin.im>
author Ma Yuan <mayuan2006@gmail.com>
date Sun, 30 Jul 2006 15:55:30 +0000
parents 8b4653986e8e
children 4f21c73a0c48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19785
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
1 /**
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
2 * @file oim.c
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
3 * get and send MSN offline Instant Message via SOAP request
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
4 * Author
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
5 * MaYuan<mayuan2006@gmail.com>
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
6 * gaim
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
7 *
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
8 * Gaim is the legal property of its developers, whose names are too numerous
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
10 * source distribution.
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
11 *
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
15 * (at your option) any later version.
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
16 *
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
20 * GNU General Public License for more details.
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
21 *
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
25 */
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
26 #include "msn.h"
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
27 #include "soap.h"
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
28 #include "oim.h"
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
29
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
30 /*new a OIM object*/
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
31 MsnOim *
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
32 msn_oim_new(MsnSession *session)
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
33 {
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
34 MsnOim *oim;
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
35
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
36 oim = g_new0(MsnOim, 1);
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
37 oim->session = session;
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
38 oim->retrieveconn = msn_soap_new(session,oim,1);
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
39 oim->sendconn = msn_soap_new(session,oim,1);
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
40
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
41 return oim;
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
42 }
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
43
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
44 /*destroy the oim object*/
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
45 void
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
46 msn_oim_destroy(MsnOim *oim)
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
47 {
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
48 msn_soap_destroy(oim->retrieveconn);
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
49 msn_soap_destroy(oim->sendconn);
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
50 g_free(oim);
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
51 }
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
52
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
53 /****************************************
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
54 * OIM send SOAP request
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
55 * **************************************/
19785
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
56 /*oim SOAP server login error*/
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
57 static void
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
58 msn_oim_send_error_cb(GaimSslConnection *gsc, GaimSslErrorType error, void *data)
19785
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
59 {
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
60 MsnSoapConn *soapconn = data;
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
61 MsnSession *session;
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
62
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
63 session = soapconn->session;
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
64 g_return_if_fail(session != NULL);
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
65
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
66 msn_session_set_error(session, MSN_ERROR_SERV_DOWN, _("Unable to connect to OIM server"));
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
67 }
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
68
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
69 /*msn oim SOAP server connect process*/
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
70 static void
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
71 msn_oim_send_connect_cb(gpointer data, GaimSslConnection *gsc,
19785
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
72 GaimInputCondition cond)
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
73 {
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
74 MsnSoapConn *soapconn = data;
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
75 MsnSession * session;
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
76 MsnOim *oim;
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
77
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
78 oim = soapconn->parent;
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
79 g_return_if_fail(oim != NULL);
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
80
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
81 session = oim->session;
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
82 g_return_if_fail(session != NULL);
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
83 }
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
84
19788
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
85 void msn_oim_send_msg(MsnOim *oim,char *msg)
19785
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
86 {
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
87 if(msn_soap_connected(oim->sendconn) == -1){
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
88 msn_soap_init(oim->sendconn,MSN_OIM_SEND_HOST,1,
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
89 msn_oim_send_connect_cb,
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
90 msn_oim_send_error_cb);
19785
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
91 }
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
92
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
93 }
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
94
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
95 /****************************************
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
96 * OIM get SOAP request
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
97 * **************************************/
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
98 /*oim SOAP server login error*/
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
99 static void
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
100 msn_oim_get_error_cb(GaimSslConnection *gsc, GaimSslErrorType error, void *data)
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
101 {
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
102 MsnSoapConn *soapconn = data;
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
103 MsnSession *session;
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
104
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
105 session = soapconn->session;
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
106 g_return_if_fail(session != NULL);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
107
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
108 msn_session_set_error(session, MSN_ERROR_SERV_DOWN, _("Unable to connect to OIM server"));
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
109 }
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
110
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
111 /*msn oim SOAP server connect process*/
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
112 static void
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
113 msn_oim_get_connect_cb(gpointer data, GaimSslConnection *gsc,
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
114 GaimInputCondition cond)
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
115 {
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
116 MsnSoapConn *soapconn = data;
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
117 MsnSession * session;
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
118 MsnOim *oim;
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
119
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
120 oim = soapconn->parent;
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
121 g_return_if_fail(oim != NULL);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
122
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
123 session = oim->session;
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
124 g_return_if_fail(session != NULL);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
125 }
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
126
19788
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
127 static void
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
128 msn_oim_get_read_cb(gpointer data, GaimSslConnection *gsc,
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
129 GaimInputCondition cond)
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
130 {
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
131 MsnSoapConn * soapconn = data;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
132 MsnOim * msnoim;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
133
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
134 gaim_debug_info("MaYuan","read buffer:{%s}\n",soapconn->body);
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
135 }
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
136
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
137 static void
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
138 msn_oim_get_written_cb(gpointer data, gint source, GaimInputCondition cond)
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
139 {
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
140 MsnSoapConn * soapconn = data;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
141
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
142 soapconn->read_cb = msn_oim_get_read_cb;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
143 msn_soap_read_cb(data,source,cond);
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
144 }
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
145
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
146 /*get the conversation*/
19788
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
147 static GaimConversation *
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
148 msn_oim_get_conv(MsnOim *oim,char *passport)
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
149 {
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
150 GaimAccount *account;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
151 GaimConversation * conv;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
152
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
153 g_return_val_if_fail(oim != NULL, NULL);
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
154 account = oim->session->account;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
155
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
156 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM,
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
157 passport, account);
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
158 if(conv == NULL){
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
159 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, passport);
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
160 }
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
161 return conv;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
162 }
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
163
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
164 /*put the OIM Message to User Conversation*/
19788
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
165 void
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
166 msn_oim_report_user(MsnOim *oim,const char *passport,char *msg)
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
167 {
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
168 GaimConversation * conv;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
169
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
170 if ((conv = msn_oim_get_conv(oim,passport)) != NULL){
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
171 gaim_conversation_write(conv, NULL, msg, GAIM_MESSAGE_SYSTEM, time(NULL));
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
172 }
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
173
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
174 }
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
175
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
176 /*parse the oim XML data*/
19788
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
177 void
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
178 msn_parse_oim_msg(MsnOim *oim,char *xmlmsg)
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
179 {
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
180 xmlnode *mdNode,*mNode,*INode,*nNode,*ENode,*rtNode;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
181 char *passport,*rTime,*msgid,*nickname;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
182
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
183 mdNode = xmlnode_from_str(xmlmsg, strlen(xmlmsg));
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
184 for(mNode = xmlnode_get_child(mdNode, "M"); mNode;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
185 mNode = xmlnode_get_next_twin(mNode)){
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
186 INode = xmlnode_get_child(mNode,"E");
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
187 passport = xmlnode_get_data(INode);
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
188 INode = xmlnode_get_child(mNode,"I");
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
189 msgid = xmlnode_get_data(INode);
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
190 rtNode = xmlnode_get_child(mNode,"RT");
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
191 rTime = xmlnode_get_data(rtNode);
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
192 nNode = xmlnode_get_child(mNode,"N");
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
193 nickname = xmlnode_get_data(nNode);
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
194 gaim_debug_info("MaYuan","E:{%s},I:{%s},rTime:{%s}\n",passport,msgid,rTime);
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
195 // msn_oim_report_user(oim,passport,"hello");
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
196 msn_oim_get_msg(oim,msgid);
19788
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
197 }
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
198 }
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
199
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
200 /*MSN OIM get SOAP request*/
19788
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
201 void msn_oim_get_msg(MsnOim *oim,char *msgid)
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
202 {
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
203 const char *oimid ,*oimsoapbody,*t,*p;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
204
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
205 if(msn_soap_connected(oim->retrieveconn) == -1){
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
206 gaim_debug_info("MaYuan","retreive OIM server not connected!\n");
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
207 return;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
208 }
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
209
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
210 gaim_debug_info("MaYuan","Get OIM with SOAP \n");
19788
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
211 oim->retrieveconn->login_path = g_strdup(MSN_OIM_RETRIEVE__URL);
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
212 oim->retrieveconn->soap_action = g_strdup(MSN_OIM_GET_SOAP_ACTION);
19788
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
213 t = oim->session->passport_info.t;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
214 p = oim->session->passport_info.p;
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
215
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
216 oimsoapbody = g_strdup_printf(MSN_OIM_GET_TEMPLATE,
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
217 t,
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
218 p,
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
219 msgid
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
220 );
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
221 msn_soap_post(oim->retrieveconn, oimsoapbody, msn_oim_get_written_cb);
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
222 }
8b4653986e8e [gaim-migrate @ 16600]
Ma Yuan <mayuan2006@gmail.com>
parents: 19785
diff changeset
223
19785
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
224 /*msn oim server connect*/
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
225 void
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
226 msn_oim_connect(MsnOim *oim)
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
227 {
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
228 gaim_debug_info("MaYuan","msn_oim_connect...\n");
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
229
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
230 msn_soap_init(oim->retrieveconn,MSN_OIM_RETRIEVE_HOST,1,
19789
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
231 msn_oim_get_connect_cb,
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
232 msn_oim_get_error_cb);
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
233 msn_soap_init(oim->sendconn,MSN_OIM_SEND_HOST,1,
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
234 msn_oim_send_connect_cb,
7e36832172a9 [gaim-migrate @ 16601]
Ma Yuan <mayuan2006@gmail.com>
parents: 19788
diff changeset
235 msn_oim_send_error_cb);
19785
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
236 }
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
237
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents:
diff changeset
238 /*endof oim.c*/