19785
|
1 /**
|
|
2 * @file oim.c
|
|
3 * get and send MSN offline Instant Message via SOAP request
|
|
4 * Author
|
|
5 * MaYuan<mayuan2006@gmail.com>
|
|
6 * gaim
|
|
7 *
|
|
8 * Gaim 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
|
|
10 * source distribution.
|
|
11 *
|
|
12 * This program is free software; you can redistribute it and/or modify
|
|
13 * it under the terms of the GNU General Public License as published by
|
|
14 * the Free Software Foundation; either version 2 of the License, or
|
|
15 * (at your option) any later version.
|
|
16 *
|
|
17 * This program is distributed in the hope that it will be useful,
|
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20 * GNU General Public License for more details.
|
|
21 *
|
|
22 * You should have received a copy of the GNU General Public License
|
|
23 * along with this program; if not, write to the Free Software
|
|
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
25 */
|
|
26 #include "msn.h"
|
|
27 #include "soap.h"
|
|
28 #include "oim.h"
|
|
29
|
|
30 /*new a OIM object*/
|
|
31 MsnOim *
|
|
32 msn_oim_new(MsnSession *session)
|
|
33 {
|
|
34 MsnOim *oim;
|
|
35
|
|
36 oim = g_new0(MsnOim, 1);
|
|
37 oim->session = session;
|
|
38 oim->retrieveconn = msn_soap_new(session,oim,1);
|
|
39 oim->sendconn = msn_soap_new(session,oim,1);
|
|
40
|
|
41 return oim;
|
|
42 }
|
|
43
|
|
44 /*destroy the oim object*/
|
|
45 void
|
|
46 msn_oim_destroy(MsnOim *oim)
|
|
47 {
|
|
48 msn_soap_destroy(oim->retrieveconn);
|
|
49 msn_soap_destroy(oim->sendconn);
|
|
50 g_free(oim);
|
|
51 }
|
|
52
|
|
53 /*oim SOAP server login error*/
|
|
54 static void
|
|
55 msn_oim_login_error_cb(GaimSslConnection *gsc, GaimSslErrorType error, void *data)
|
|
56 {
|
|
57 MsnSoapConn *soapconn = data;
|
|
58 MsnSession *session;
|
|
59
|
|
60 session = soapconn->session;
|
|
61 g_return_if_fail(session != NULL);
|
|
62
|
|
63 msn_session_set_error(session, MSN_ERROR_SERV_DOWN, _("Unable to connect to OIM server"));
|
|
64 }
|
|
65
|
|
66 /*msn oim SOAP server connect process*/
|
|
67 static void
|
|
68 msn_oim_login_connect_cb(gpointer data, GaimSslConnection *gsc,
|
|
69 GaimInputCondition cond)
|
|
70 {
|
|
71 MsnSoapConn *soapconn = data;
|
|
72 MsnSession * session;
|
|
73 MsnOim *oim;
|
|
74
|
|
75 oim = soapconn->parent;
|
|
76 g_return_if_fail(oim != NULL);
|
|
77
|
|
78 session = oim->session;
|
|
79 g_return_if_fail(session != NULL);
|
|
80 }
|
|
81
|
|
82 void msn_oim_send_msg(MsnOim *oim,char * msg)
|
|
83 {
|
|
84 if(msn_soap_connected(oim->sendconn) == -1){
|
|
85 msn_soap_init(oim->sendconn,MSN_OIM_SEND_HOST,1,
|
|
86 msn_oim_login_connect_cb,
|
|
87 msn_oim_login_error_cb);
|
|
88 }
|
|
89
|
|
90 }
|
|
91
|
|
92 /*msn oim server connect*/
|
|
93 void
|
|
94 msn_oim_connect(MsnOim *oim)
|
|
95 {
|
|
96 gaim_debug_info("MaYuan","msn_oim_connect...\n");
|
|
97
|
|
98 msn_soap_init(oim->retrieveconn,MSN_OIM_RETRIEVE_HOST,1,
|
|
99 msn_oim_login_connect_cb,
|
|
100 msn_oim_login_error_cb);
|
|
101 }
|
|
102
|
|
103 /*endof oim.c*/
|