libpurple/protocols/msn/oim.c

Wed, 30 Jul 2008 03:58:21 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Wed, 30 Jul 2008 03:58:21 +0000
changeset 23931
8975bb78b51a
parent 23925
aa38fbc30cfb
child 23998
bb70dc6dd4ce
permissions
-rw-r--r--

Cleanup unnecessary casts and etc.

20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
1 /**
23441
fd45c23a3eb2 Delete trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 23095
diff changeset
2 * @file oim.c
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
3 * get and send MSN offline Instant Message via SOAP request
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
4 * Author
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
5 * MaYuan<mayuan2006@gmail.com>
20484
4a410a579a80 Fix up some gaim -> purple issues.
Richard Laager <rlaager@pidgin.im>
parents: 20481
diff changeset
6 * purple
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
7 *
20484
4a410a579a80 Fix up some gaim -> purple issues.
Richard Laager <rlaager@pidgin.im>
parents: 20481
diff changeset
8 * Purple is the legal property of its developers, whose names are too numerous
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
10 * source distribution.
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
11 *
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
15 * (at your option) any later version.
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
16 *
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
20 * GNU General Public License for more details.
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
21 *
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
25 */
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
26 #include "msn.h"
23819
c3bbef4646b1 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23804
diff changeset
27 #include "soap.h"
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
28 #include "oim.h"
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
29 #include "msnutils.h"
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
30
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
31 typedef struct _MsnOimSendReq {
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
32 char *from_member;
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
33 char *friendname;
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
34 char *to_member;
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
35 char *oim_msg;
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
36 } MsnOimSendReq;
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
37
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
38 typedef struct {
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
39 MsnOim *oim;
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
40 char *msg_id;
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
41 } MsnOimRecvData;
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
42
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
43 /*Local Function Prototype*/
23766
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
44 static void msn_parse_oim_xml(MsnOim *oim, xmlnode *node);
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
45 static void msn_oim_post_single_get_msg(MsnOim *oim, char *msgid);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
46 static MsnOimSendReq *msn_oim_new_send_req(const char *from_member,
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
47 const char *friendname,
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
48 const char* to_member,
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
49 const char *msg);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
50 static void msn_oim_free_send_req(MsnOimSendReq *req);
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
51 static void msn_oim_report_to_user(MsnOimRecvData *rdata, const char *msg_str);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
52 static char *msn_oim_msg_to_str(MsnOim *oim, const char *body);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
53
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
54 /*new a OIM object*/
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
55 MsnOim *
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
56 msn_oim_new(MsnSession *session)
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
57 {
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
58 MsnOim *oim;
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
59
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
60 oim = g_new0(MsnOim, 1);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
61 oim->session = session;
22981
b83a23981419 Fix a number of leaks. As far as I can tell, MSNP14 now logs in without
Daniel Atallah <datallah@pidgin.im>
parents: 22977
diff changeset
62 oim->oim_list = NULL;
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
63 oim->run_id = rand_guid();
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
64 oim->challenge = NULL;
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
65 oim->send_queue = g_queue_new();
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
66 oim->send_seq = 1;
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
67 return oim;
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
68 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
69
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
70 /*destroy the oim object*/
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
71 void
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
72 msn_oim_destroy(MsnOim *oim)
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
73 {
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
74 MsnOimSendReq *request;
22981
b83a23981419 Fix a number of leaks. As far as I can tell, MSNP14 now logs in without
Daniel Atallah <datallah@pidgin.im>
parents: 22977
diff changeset
75
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
76 purple_debug_info("msn", "destroy the OIM %p\n", oim);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
77 g_free(oim->run_id);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
78 g_free(oim->challenge);
22981
b83a23981419 Fix a number of leaks. As far as I can tell, MSNP14 now logs in without
Daniel Atallah <datallah@pidgin.im>
parents: 22977
diff changeset
79
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
80 while((request = g_queue_pop_head(oim->send_queue)) != NULL){
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
81 msn_oim_free_send_req(request);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
82 }
22981
b83a23981419 Fix a number of leaks. As far as I can tell, MSNP14 now logs in without
Daniel Atallah <datallah@pidgin.im>
parents: 22977
diff changeset
83
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
84 g_queue_free(oim->send_queue);
22981
b83a23981419 Fix a number of leaks. As far as I can tell, MSNP14 now logs in without
Daniel Atallah <datallah@pidgin.im>
parents: 22977
diff changeset
85 g_list_free(oim->oim_list);
b83a23981419 Fix a number of leaks. As far as I can tell, MSNP14 now logs in without
Daniel Atallah <datallah@pidgin.im>
parents: 22977
diff changeset
86
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
87 g_free(oim);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
88 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
89
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
90 static MsnOimSendReq *
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
91 msn_oim_new_send_req(const char *from_member, const char*friendname,
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
92 const char* to_member, const char *msg)
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
93 {
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
94 MsnOimSendReq *request;
23441
fd45c23a3eb2 Delete trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 23095
diff changeset
95
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
96 request = g_new0(MsnOimSendReq, 1);
22981
b83a23981419 Fix a number of leaks. As far as I can tell, MSNP14 now logs in without
Daniel Atallah <datallah@pidgin.im>
parents: 22977
diff changeset
97 request->from_member = g_strdup(from_member);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
98 request->friendname = g_strdup(friendname);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
99 request->to_member = g_strdup(to_member);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
100 request->oim_msg = g_strdup(msg);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
101 return request;
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
102 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
103
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
104 static void
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
105 msn_oim_free_send_req(MsnOimSendReq *req)
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
106 {
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
107 g_return_if_fail(req != NULL);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
108
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
109 g_free(req->from_member);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
110 g_free(req->friendname);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
111 g_free(req->to_member);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
112 g_free(req->oim_msg);
23441
fd45c23a3eb2 Delete trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 23095
diff changeset
113
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
114 g_free(req);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
115 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
116
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
117 /****************************************
23781
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
118 * Manage OIM Tokens
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
119 ****************************************/
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
120 typedef struct _MsnOimRequestData {
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
121 MsnOim *oim;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
122 gboolean send;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
123 const char *action;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
124 const char *host;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
125 const char *url;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
126 xmlnode *body;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
127 MsnSoapCallback cb;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
128 gpointer cb_data;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
129 } MsnOimRequestData;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
130
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
131 static void msn_oim_request_helper(MsnOimRequestData *data);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
132
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
133 static void
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
134 msn_oim_request_cb(MsnSoapMessage *request, MsnSoapMessage *response,
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
135 gpointer req_data)
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
136 {
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
137 MsnOimRequestData *data = (MsnOimRequestData *)req_data;
23804
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
138 xmlnode *fault = NULL;
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
139 xmlnode *faultcode = NULL;
23781
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
140
23865
588b5cc83024 Avoid a crash in OIM processing if the request was cancelled outside of
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23863
diff changeset
141 if (response == NULL)
588b5cc83024 Avoid a crash in OIM processing if the request was cancelled outside of
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23863
diff changeset
142 return;
588b5cc83024 Avoid a crash in OIM processing if the request was cancelled outside of
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23863
diff changeset
143
23804
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
144 fault = xmlnode_get_child(response->xml, "Body/Fault");
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
145 if (fault)
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
146 faultcode = xmlnode_get_child(fault, "faultcode");
23781
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
147
23804
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
148 if (faultcode) {
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
149 gchar *faultcode_str = xmlnode_get_data(faultcode);
23781
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
150
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
151 if (faultcode_str && g_str_equal(faultcode_str, "q0:BadContextToken")) {
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
152 purple_debug_warning("msn", "OIM Request Error, Updating token now.");
23781
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
153 msn_nexus_update_token(data->oim->session->nexus,
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
154 data->send ? MSN_AUTH_LIVE_SECURE : MSN_AUTH_MESSENGER_WEB,
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
155 (GSourceFunc)msn_oim_request_helper, data);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
156 g_free(faultcode_str);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
157 return;
23804
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
158
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
159 } else if (faultcode_str && g_str_equal(faultcode_str, "q0:AuthenticationFailed")) {
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
160 if (xmlnode_get_child(fault, "detail/RequiredAuthPolicy") != NULL) {
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
161 purple_debug_warning("msn", "OIM Request Error, Updating token now.");
23804
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
162 msn_nexus_update_token(data->oim->session->nexus,
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
163 data->send ? MSN_AUTH_LIVE_SECURE : MSN_AUTH_MESSENGER_WEB,
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
164 (GSourceFunc)msn_oim_request_helper, data);
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
165 g_free(faultcode_str);
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
166 return;
17761ebfbe47 Apparently, when the token expires, OIM requests get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23802
diff changeset
167 }
23781
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
168 }
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
169 g_free(faultcode_str);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
170 }
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
171
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
172 if (data->cb)
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
173 data->cb(request, response, data->cb_data);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
174 xmlnode_free(data->body);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
175 g_free(data);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
176 }
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
177
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
178 static void
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
179 msn_oim_request_helper(MsnOimRequestData *data)
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
180 {
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
181 MsnSession *session = data->oim->session;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
182
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
183 if (data->send) {
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
184 /* The Sending of OIM's uses a different token for some reason. */
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
185 xmlnode *ticket;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
186 ticket = xmlnode_get_child(data->body, "Header/Ticket");
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
187 xmlnode_set_attrib(ticket, "passport",
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
188 msn_nexus_get_token_str(session->nexus, MSN_AUTH_LIVE_SECURE));
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
189 }
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
190 else
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
191 {
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
192 xmlnode *passport;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
193 xmlnode *xml_t;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
194 xmlnode *xml_p;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
195 GHashTable *token;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
196 const char *msn_t;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
197 const char *msn_p;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
198
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
199 token = msn_nexus_get_token(session->nexus, MSN_AUTH_MESSENGER_WEB);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
200 g_return_if_fail(token != NULL);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
201
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
202 msn_t = g_hash_table_lookup(token, "t");
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
203 msn_p = g_hash_table_lookup(token, "p");
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
204
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
205 g_return_if_fail(msn_t != NULL);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
206 g_return_if_fail(msn_p != NULL);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
207
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
208 passport = xmlnode_get_child(data->body, "Header/PassportCookie");
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
209 xml_t = xmlnode_get_child(passport, "t");
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
210 xml_p = xmlnode_get_child(passport, "p");
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
211
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
212 /* frees old token text, or the 'EMPTY' text if first time */
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
213 xmlnode_free(xml_t->child);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
214 xmlnode_free(xml_p->child);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
215
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
216 xmlnode_insert_data(xml_t, msn_t, -1);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
217 xmlnode_insert_data(xml_p, msn_p, -1);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
218 }
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
219
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
220 msn_soap_message_send(session,
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
221 msn_soap_message_new(data->action, xmlnode_copy(data->body)),
23925
aa38fbc30cfb Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23924
diff changeset
222 data->host, data->url, FALSE,
aa38fbc30cfb Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23924
diff changeset
223 msn_oim_request_cb, data);
23781
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
224 }
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
225
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
226
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
227 static void
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
228 msn_oim_make_request(MsnOim *oim, gboolean send, const char *action,
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
229 const char *host, const char *url, xmlnode *body, MsnSoapCallback cb,
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
230 gpointer cb_data)
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
231 {
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
232 MsnOimRequestData *data = g_new0(MsnOimRequestData, 1);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
233 data->oim = oim;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
234 data->send = send;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
235 data->action = action;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
236 data->host = host;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
237 data->url = url;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
238 data->body = body;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
239 data->cb = cb;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
240 data->cb_data = cb_data;
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
241
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
242 msn_oim_request_helper(data);
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
243 }
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
244
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
245 /****************************************
23766
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
246 * OIM GetMetadata request
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
247 * **************************************/
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
248 static void
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
249 msn_oim_get_metadata_cb(MsnSoapMessage *request, MsnSoapMessage *response,
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
250 gpointer data)
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
251 {
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
252 MsnOim *oim = data;
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
253
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
254 if (response) {
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
255 msn_parse_oim_xml(oim,
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
256 xmlnode_get_child(response->xml, "Body/GetMetadataResponse/MD"));
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
257 }
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
258 }
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
259
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
260 /* Post to get the OIM Metadata */
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
261 static void
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
262 msn_oim_get_metadata(MsnOim *oim)
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
263 {
23781
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
264 msn_oim_make_request(oim, FALSE, MSN_OIM_GET_METADATA_ACTION,
23766
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
265 MSN_OIM_RETRIEVE_HOST, MSN_OIM_RETRIEVE_URL,
23781
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
266 xmlnode_from_str(MSN_OIM_GET_METADATA_TEMPLATE, -1),
23766
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
267 msn_oim_get_metadata_cb, oim);
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
268 }
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
269
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
270 /****************************************
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
271 * OIM send SOAP request
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
272 * **************************************/
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
273 /*encode the message to OIM Message Format*/
21065
8bbf0f6700ed Fix some leaks and prevent some unnecessary allocations and frees.
Daniel Atallah <datallah@pidgin.im>
parents: 20936
diff changeset
274 static gchar *
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
275 msn_oim_msg_to_str(MsnOim *oim, const char *body)
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
276 {
23858
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
277 GString *oim_body;
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
278 char *oim_base64;
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
279 char *c;
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
280 int len;
23862
5695d613ccdc fixes a crash and probably more correct and definitely easier to understand
Ka-Hing Cheung <khc@pidgin.im>
parents: 23858
diff changeset
281 size_t base64_len;
23858
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
282
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
283 purple_debug_info("msn", "Encoding OIM Message...\n");
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
284 len = strlen(body);
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
285 c = oim_base64 = purple_base64_encode((const guchar *)body, len);
23862
5695d613ccdc fixes a crash and probably more correct and definitely easier to understand
Ka-Hing Cheung <khc@pidgin.im>
parents: 23858
diff changeset
286 base64_len = strlen(oim_base64);
23858
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
287 purple_debug_info("msn", "Encoded base64 body:{%s}\n", oim_base64);
23441
fd45c23a3eb2 Delete trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 23095
diff changeset
288
23858
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
289 oim_body = g_string_new(NULL);
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
290 g_string_printf(oim_body, MSN_OIM_MSG_TEMPLATE,
23863
e0b1cd6a1509 Commit the changes to oim.h that I forgot last time. Fixes #6343,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23862
diff changeset
291 oim->run_id, oim->send_seq);
23858
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
292
23862
5695d613ccdc fixes a crash and probably more correct and definitely easier to understand
Ka-Hing Cheung <khc@pidgin.im>
parents: 23858
diff changeset
293 #define OIM_LINE_LEN 76
5695d613ccdc fixes a crash and probably more correct and definitely easier to understand
Ka-Hing Cheung <khc@pidgin.im>
parents: 23858
diff changeset
294 while (base64_len > OIM_LINE_LEN) {
5695d613ccdc fixes a crash and probably more correct and definitely easier to understand
Ka-Hing Cheung <khc@pidgin.im>
parents: 23858
diff changeset
295 g_string_append_len(oim_body, c, OIM_LINE_LEN);
23858
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
296 g_string_append_c(oim_body, '\n');
23862
5695d613ccdc fixes a crash and probably more correct and definitely easier to understand
Ka-Hing Cheung <khc@pidgin.im>
parents: 23858
diff changeset
297 c += OIM_LINE_LEN;
5695d613ccdc fixes a crash and probably more correct and definitely easier to understand
Ka-Hing Cheung <khc@pidgin.im>
parents: 23858
diff changeset
298 base64_len -= OIM_LINE_LEN;
23858
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
299 }
23862
5695d613ccdc fixes a crash and probably more correct and definitely easier to understand
Ka-Hing Cheung <khc@pidgin.im>
parents: 23858
diff changeset
300 #undef OIM_LINE_LEN
5695d613ccdc fixes a crash and probably more correct and definitely easier to understand
Ka-Hing Cheung <khc@pidgin.im>
parents: 23858
diff changeset
301
23858
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
302 g_string_append(oim_body, c);
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
303
21065
8bbf0f6700ed Fix some leaks and prevent some unnecessary allocations and frees.
Daniel Atallah <datallah@pidgin.im>
parents: 20936
diff changeset
304 g_free(oim_base64);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
305
23858
4b40daef9f4a When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23830
diff changeset
306 return g_string_free(oim_body, FALSE);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
307 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
308
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
309 /*
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
310 * Process the send return SOAP string
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
311 * If got SOAP Fault,get the lock key,and resend it.
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
312 */
20513
351eb76ee992 Compile warning fixes
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20485
diff changeset
313 static void
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
314 msn_oim_send_read_cb(MsnSoapMessage *request, MsnSoapMessage *response,
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
315 gpointer data)
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
316 {
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
317 MsnOim *oim = data;
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
318 MsnOimSendReq *msg = g_queue_pop_head(oim->send_queue);
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
319
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
320 g_return_if_fail(msg != NULL);
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
321
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
322 if (response == NULL) {
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
323 purple_debug_info("msn", "cannot send OIM: %s\n", msg->oim_msg);
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
324 } else {
23765
8a43c0d4a095 References #4382, replaces usage of msn_soap_xml_get with xmlnode_get_child
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23764
diff changeset
325 xmlnode *faultNode = xmlnode_get_child(response->xml, "Body/Fault");
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
326
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
327 if (faultNode == NULL) {
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
328 /*Send OK! return*/
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
329 purple_debug_info("msn", "sent OIM: %s\n", msg->oim_msg);
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
330 } else {
21368
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
331 xmlnode *faultcode = xmlnode_get_child(faultNode, "faultcode");
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
332
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
333 if (faultcode) {
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
334 char *faultcode_str = xmlnode_get_data(faultcode);
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
335
21368
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
336 if (g_str_equal(faultcode_str, "q0:AuthenticationFailed")) {
23765
8a43c0d4a095 References #4382, replaces usage of msn_soap_xml_get with xmlnode_get_child
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23764
diff changeset
337 xmlnode *challengeNode = xmlnode_get_child(faultNode,
21368
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
338 "detail/LockKeyChallenge");
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
339
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
340 if (challengeNode == NULL) {
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
341 if (oim->challenge) {
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
342 g_free(oim->challenge);
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
343 oim->challenge = NULL;
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
344
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
345 purple_debug_info("msn", "Resending OIM: %s\n",
21368
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
346 msg->oim_msg);
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
347 g_queue_push_head(oim->send_queue, msg);
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
348 msn_oim_send_msg(oim);
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
349 } else {
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
350 purple_debug_info("msn",
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
351 "Can't find lock key for OIM: %s\n",
21368
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
352 msg->oim_msg);
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
353 }
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
354 } else {
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
355 char buf[33];
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
356
21368
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
357 char *challenge = xmlnode_get_data(challengeNode);
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
358 msn_handle_chl(challenge, buf);
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
359
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
360 g_free(oim->challenge);
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
361 oim->challenge = g_strndup(buf, sizeof(buf));
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
362 g_free(challenge);
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
363 purple_debug_info("msn", "Found lockkey:{%s}\n", oim->challenge);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
364
21368
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
365 /*repost the send*/
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
366 purple_debug_info("msn", "Resending OIM: %s\n", msg->oim_msg);
21368
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
367 g_queue_push_head(oim->send_queue, msg);
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
368 msn_oim_send_msg(oim);
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
369 }
23802
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
370 } else {
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
371 /* Report the error */
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
372 const char *str_reason;
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
373
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
374 if (g_str_equal(faultcode_str, "q0:SystemUnavailable")) {
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
375 str_reason = _("Message was not sent because the system is "
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
376 "unavailable. This normally happens when the "
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
377 "user is blocked or does not exist.");
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
378
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
379 } else if (g_str_equal(faultcode_str, "q0:SenderThrottleLimitExceeded")) {
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
380 str_reason = _("Message was not sent because messages "
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
381 "are being sent too quickly.");
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
382
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
383 } else if (g_str_equal(faultcode_str, "q0:InvalidContent")) {
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
384 str_reason = _("Message was not sent because an unknown "
23873
aee16b24d8ed Fix up some spelling mistakes in MSN oim.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23865
diff changeset
385 "encoding error occurred.");
23802
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
386
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
387 } else {
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
388 str_reason = _("Message was not sent because an unknown "
23873
aee16b24d8ed Fix up some spelling mistakes in MSN oim.c.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23865
diff changeset
389 "error occurred.");
23802
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
390 }
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
391
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
392 msn_session_report_user(oim->session, msg->to_member,
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
393 str_reason, PURPLE_MESSAGE_ERROR);
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
394 msn_session_report_user(oim->session, msg->to_member,
61305f9c37e1 Make errors when sending OIM's more visible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23801
diff changeset
395 msg->oim_msg, PURPLE_MESSAGE_RAW);
21368
d270fe91b138 finish converting the rest of stuff to the new soap api, signing on, getting
Ka-Hing Cheung <khc@pidgin.im>
parents: 21363
diff changeset
396 }
22977
619a2612bb92 This is the way we plug the leaks, plug the leaks, plug the leaks...
Daniel Atallah <datallah@pidgin.im>
parents: 21886
diff changeset
397
619a2612bb92 This is the way we plug the leaks, plug the leaks, plug the leaks...
Daniel Atallah <datallah@pidgin.im>
parents: 21886
diff changeset
398 g_free(faultcode_str);
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
399 }
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
400 }
20522
177cad886d4c A bunch of MSNP14 stuff:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20518
diff changeset
401 }
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
402 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
403
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
404 void
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
405 msn_oim_prep_send_msg_info(MsnOim *oim, const char *membername,
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
406 const char* friendname, const char *tomember,
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
407 const char * msg)
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
408 {
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
409 g_return_if_fail(oim != NULL);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
410
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
411 g_queue_push_tail(oim->send_queue,
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
412 msn_oim_new_send_req(membername, friendname, tomember, msg));
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
413 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
414
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
415 /*post send single message request to oim server*/
23441
fd45c23a3eb2 Delete trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 23095
diff changeset
416 void
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
417 msn_oim_send_msg(MsnOim *oim)
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
418 {
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
419 MsnOimSendReq *oim_request;
23759
1abf46eeccec fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@pidgin.im>
parents: 23755
diff changeset
420 char *soap_body;
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
421 char *msg_body;
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
422
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
423 g_return_if_fail(oim != NULL);
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
424 oim_request = g_queue_peek_head(oim->send_queue);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
425 g_return_if_fail(oim_request != NULL);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
426
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
427 purple_debug_info("msn", "Sending OIM: %s\n", oim_request->oim_msg);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
428
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
429 /* if we got the challenge lock key, we compute it
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
430 * else we go for the SOAP fault and resend it.
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
431 */
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
432 if (oim->challenge == NULL){
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
433 purple_debug_info("msn", "No lock key challenge, waiting for SOAP Fault and Resend\n");
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
434 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
435
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
436 msg_body = msn_oim_msg_to_str(oim, oim_request->oim_msg);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
437 soap_body = g_strdup_printf(MSN_OIM_SEND_TEMPLATE,
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
438 oim_request->from_member,
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
439 oim_request->friendname,
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
440 oim_request->to_member,
23755
6b2413139fae Patch 1 from Qulogic, this one mostly updates the version sent by pidgin
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21886
diff changeset
441 MSNP15_WLM_PRODUCT_ID,
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
442 oim->challenge ? oim->challenge : "",
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
443 oim->send_seq,
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
444 msg_body);
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
445
23781
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
446 msn_oim_make_request(oim, TRUE, MSN_OIM_SEND_SOAP_ACTION, MSN_OIM_SEND_HOST,
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
447 MSN_OIM_SEND_URL, xmlnode_from_str(soap_body, -1), msn_oim_send_read_cb,
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
448 oim);
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
449
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
450 /*increase the offline Sequence control*/
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
451 if (oim->challenge != NULL) {
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
452 oim->send_seq++;
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
453 }
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
454
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
455 g_free(msg_body);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
456 g_free(soap_body);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
457 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
458
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
459 /****************************************
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
460 * OIM delete SOAP request
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
461 * **************************************/
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
462 static void
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
463 msn_oim_delete_read_cb(MsnSoapMessage *request, MsnSoapMessage *response,
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
464 gpointer data)
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
465 {
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
466 MsnOimRecvData *rdata = data;
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
467
23765
8a43c0d4a095 References #4382, replaces usage of msn_soap_xml_get with xmlnode_get_child
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23764
diff changeset
468 if (response && xmlnode_get_child(response->xml, "Body/Fault") == NULL) {
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
469 purple_debug_info("msn", "Delete OIM success\n");
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
470 rdata->oim->oim_list = g_list_remove(rdata->oim->oim_list,
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
471 rdata->msg_id);
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
472 g_free(rdata->msg_id);
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
473 } else {
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
474 purple_debug_info("msn", "Delete OIM failed\n");
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
475 }
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
476
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
477 g_free(rdata);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
478 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
479
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
480 /*Post to get the Offline Instant Message*/
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
481 static void
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
482 msn_oim_post_delete_msg(MsnOimRecvData *rdata)
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
483 {
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
484 MsnOim *oim = rdata->oim;
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
485 char *msgid = rdata->msg_id;
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
486 char *soap_body;
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
487
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
488 purple_debug_info("msn", "Delete single OIM Message {%s}\n",msgid);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
489
23781
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
490 soap_body = g_strdup_printf(MSN_OIM_DEL_TEMPLATE, msgid);
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
491
23781
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
492 msn_oim_make_request(oim, FALSE, MSN_OIM_DEL_SOAP_ACTION, MSN_OIM_RETRIEVE_HOST,
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
493 MSN_OIM_RETRIEVE_URL, xmlnode_from_str(soap_body, -1), msn_oim_delete_read_cb, rdata);
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
494
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
495 g_free(soap_body);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
496 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
497
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
498 /****************************************
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
499 * OIM get SOAP request
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
500 * **************************************/
20573
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
501 /* like purple_str_to_time, but different. The format of the timestamp
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
502 * is like this: 5 Sep 2007 21:42:12 -0700 */
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
503 static time_t
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
504 msn_oim_parse_timestamp(const char *timestamp)
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
505 {
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
506 char month_str[4], tz_str[6];
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
507 char *tz_ptr = tz_str;
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
508 static const char *months[] = {
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
509 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
510 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
511 };
21362
8fd2932c4d25 fixes oim timestamp for me, non HAVE_TM_GMTOFF people probably want to test
Ka-Hing Cheung <khc@pidgin.im>
parents: 21361
diff changeset
512 time_t tval = 0;
20573
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
513 struct tm t;
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
514 memset(&t, 0, sizeof(t));
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
515
21362
8fd2932c4d25 fixes oim timestamp for me, non HAVE_TM_GMTOFF people probably want to test
Ka-Hing Cheung <khc@pidgin.im>
parents: 21361
diff changeset
516 time(&tval);
8fd2932c4d25 fixes oim timestamp for me, non HAVE_TM_GMTOFF people probably want to test
Ka-Hing Cheung <khc@pidgin.im>
parents: 21361
diff changeset
517 localtime_r(&tval, &t);
8fd2932c4d25 fixes oim timestamp for me, non HAVE_TM_GMTOFF people probably want to test
Ka-Hing Cheung <khc@pidgin.im>
parents: 21361
diff changeset
518
20573
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
519 if (sscanf(timestamp, "%02d %03s %04d %02d:%02d:%02d %05s",
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
520 &t.tm_mday, month_str, &t.tm_year,
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
521 &t.tm_hour, &t.tm_min, &t.tm_sec, tz_str) == 7) {
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
522 gboolean offset_positive = TRUE;
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
523 int tzhrs;
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
524 int tzmins;
23441
fd45c23a3eb2 Delete trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 23095
diff changeset
525
20573
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
526 for (t.tm_mon = 0;
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
527 months[t.tm_mon] != NULL &&
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
528 strcmp(months[t.tm_mon], month_str) != 0; t.tm_mon++);
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
529 if (months[t.tm_mon] != NULL) {
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
530 if (*tz_str == '-') {
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
531 offset_positive = FALSE;
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
532 tz_ptr++;
20579
00d8534821bf Fixes #2990, apparently I used the wrong #define. Also fix + timezone
Ka-Hing Cheung <khc@pidgin.im>
parents: 20573
diff changeset
533 } else if (*tz_str == '+') {
00d8534821bf Fixes #2990, apparently I used the wrong #define. Also fix + timezone
Ka-Hing Cheung <khc@pidgin.im>
parents: 20573
diff changeset
534 tz_ptr++;
20573
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
535 }
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
536
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
537 if (sscanf(tz_ptr, "%02d%02d", &tzhrs, &tzmins) == 2) {
20583
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
538 time_t tzoff = tzhrs * 60 * 60 + tzmins * 60;
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
539 #ifdef _WIN32
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
540 long sys_tzoff;
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
541 #endif
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
542
23801
f137f8b472a0 Change msn_oim_parse_timestamp to match purple_str_to_time more
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23781
diff changeset
543 if (offset_positive)
20583
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
544 tzoff *= -1;
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
545
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
546 t.tm_year -= 1900;
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
547
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
548 #ifdef _WIN32
20587
55af483c9e86 3rd time the charm? Fixes #2990, maybe
Ka-Hing Cheung <khc@pidgin.im>
parents: 20585
diff changeset
549 if ((sys_tzoff = wpurple_get_tz_offset()) != -1)
20583
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
550 tzoff += sys_tzoff;
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
551 #else
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
552 #ifdef HAVE_TM_GMTOFF
23801
f137f8b472a0 Change msn_oim_parse_timestamp to match purple_str_to_time more
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23781
diff changeset
553 tzoff += t.tm_gmtoff;
20583
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
554 #else
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
555 # ifdef HAVE_TIMEZONE
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
556 tzset(); /* making sure */
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
557 tzoff -= timezone;
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
558 # endif
20573
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
559 #endif
20583
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
560 #endif /* _WIN32 */
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
561
4be8dc494644 I think this is the right way to fix timezone. People on Win32 _and_
Ka-Hing Cheung <khc@pidgin.im>
parents: 20579
diff changeset
562 return mktime(&t) + tzoff;
20573
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
563 }
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
564 }
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
565 }
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
566
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
567 purple_debug_info("msn", "Can't parse timestamp %s\n", timestamp);
21362
8fd2932c4d25 fixes oim timestamp for me, non HAVE_TM_GMTOFF people probably want to test
Ka-Hing Cheung <khc@pidgin.im>
parents: 21361
diff changeset
568 return tval;
20573
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
569 }
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
570
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
571 /*Post the Offline Instant Message to User Conversation*/
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
572 static void
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
573 msn_oim_report_to_user(MsnOimRecvData *rdata, const char *msg_str)
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
574 {
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
575 MsnMessage *message;
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
576 char *date,*from,*decode_msg;
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
577 gsize body_len;
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
578 char **tokens;
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
579 char *start,*end;
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
580 int has_nick = 0;
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
581 char *passport_str, *passport;
20518
8aa1360ee12a Parse the message timestamp using purple_str_to_time. I haven't been able
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20516
diff changeset
582 time_t stamp;
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
583
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
584 message = msn_message_new(MSN_MSG_UNKNOWN);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
585
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
586 msn_message_parse_payload(message, msg_str, strlen(msg_str),
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
587 MSG_OIM_LINE_DEM, MSG_OIM_BODY_DEM);
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
588 purple_debug_info("msn", "oim body:{%s}\n", message->body);
20513
351eb76ee992 Compile warning fixes
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20485
diff changeset
589 decode_msg = (char *)purple_base64_decode(message->body,&body_len);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
590 date = (char *)g_hash_table_lookup(message->attr_table, "Date");
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
591 from = (char *)g_hash_table_lookup(message->attr_table, "From");
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
592 if (strstr(from," ")) {
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
593 has_nick = 1;
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
594 }
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
595 if (has_nick) {
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
596 tokens = g_strsplit(from , " " , 2);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
597 passport_str = g_strdup(tokens[1]);
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
598 purple_debug_info("msn", "oim Date:{%s},nickname:{%s},tokens[1]:{%s} passport{%s}\n",
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
599 date, tokens[0], tokens[1], passport_str);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
600 g_strfreev(tokens);
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
601 } else {
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
602 passport_str = g_strdup(from);
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
603 purple_debug_info("msn", "oim Date:{%s},passport{%s}\n",
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
604 date, passport_str);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
605 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
606 start = strstr(passport_str,"<");
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
607 start += 1;
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
608 end = strstr(passport_str,">");
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
609 passport = g_strndup(start,end - start);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
610 g_free(passport_str);
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
611 purple_debug_info("msn", "oim Date:{%s},passport{%s}\n", date, passport);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
612
20573
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
613 stamp = msn_oim_parse_timestamp(date);
20518
8aa1360ee12a Parse the message timestamp using purple_str_to_time. I haven't been able
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20516
diff changeset
614
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
615 serv_got_im(rdata->oim->session->account->gc, passport, decode_msg, 0,
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
616 stamp);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
617
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
618 /*Now get the oim message ID from the oim_list.
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
619 * and append to read list to prepare for deleting the Offline Message when sign out
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
620 */
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
621 msn_oim_post_delete_msg(rdata);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
622
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
623 g_free(passport);
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
624 g_free(decode_msg);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
625 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
626
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
627 /* Parse the XML data,
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
628 * prepare to report the OIM to user
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
629 */
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
630 static void
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
631 msn_oim_get_read_cb(MsnSoapMessage *request, MsnSoapMessage *response,
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
632 gpointer data)
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
633 {
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
634 MsnOimRecvData *rdata = data;
20585
a82494142fe3 cleans up ownership of soap callback data, this soap stuff is perfect
Ka-Hing Cheung <khc@pidgin.im>
parents: 20584
diff changeset
635
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
636 if (response != NULL) {
23765
8a43c0d4a095 References #4382, replaces usage of msn_soap_xml_get with xmlnode_get_child
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23764
diff changeset
637 xmlnode *msg_node = xmlnode_get_child(response->xml,
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
638 "Body/GetMessageResponse/GetMessageResult");
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
639
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
640 if (msg_node) {
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
641 char *msg_str = xmlnode_get_data(msg_node);
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
642 msn_oim_report_to_user(rdata, msg_str);
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
643 g_free(msg_str);
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
644 } else {
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
645 char *str = xmlnode_to_str(response->xml, NULL);
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
646 purple_debug_info("msn", "Unknown OIM response: %s\n", str);
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
647 g_free(str);
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
648 }
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
649 } else {
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
650 purple_debug_info("msn", "Failed to get OIM\n");
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
651 }
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
652 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
653
23441
fd45c23a3eb2 Delete trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 23095
diff changeset
654 /* parse the oim XML data
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
655 * and post it to the soap server to get the Offline Message
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
656 * */
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
657 void
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
658 msn_parse_oim_msg(MsnOim *oim,const char *xmlmsg)
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
659 {
23766
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
660 xmlnode *node;
20522
177cad886d4c A bunch of MSNP14 stuff:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20518
diff changeset
661
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
662 purple_debug_info("msn", "%s\n", xmlmsg);
20573
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
663
23766
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
664 if (!strcmp(xmlmsg, "too-large")) {
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
665 /* Too many OIM's to send via NS, so we need to request them via SOAP. */
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
666 msn_oim_get_metadata(oim);
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
667 } else {
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
668 node = xmlnode_from_str(xmlmsg, -1);
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
669 msn_parse_oim_xml(oim, node);
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
670 xmlnode_free(node);
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
671 }
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
672 }
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
673
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
674 static void
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
675 msn_parse_oim_xml(MsnOim *oim, xmlnode *node)
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
676 {
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
677 xmlnode *mNode;
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
678 xmlnode *iu_node;
20527
1ee8b2a70ed7 Compile fix, whoops! Thanks Masca/salinasv.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20526
diff changeset
679 MsnSession *session = oim->session;
20522
177cad886d4c A bunch of MSNP14 stuff:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20518
diff changeset
680
23766
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
681 g_return_if_fail(node != NULL);
20573
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
682
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
683 if (strcmp(node->name, "MD") != 0) {
23766
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
684 char *xmlmsg = xmlnode_to_str(node, NULL);
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
685 purple_debug_info("msn", "WTF is this? %s\n", xmlmsg);
23766
a9233ec4fdb2 References #4382, fixes receiving too many offline messages
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
686 g_free(xmlmsg);
20573
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
687 return;
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
688 }
20522
177cad886d4c A bunch of MSNP14 stuff:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20518
diff changeset
689
23765
8a43c0d4a095 References #4382, replaces usage of msn_soap_xml_get with xmlnode_get_child
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23764
diff changeset
690 iu_node = xmlnode_get_child(node, "E/IU");
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
691
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
692 if (iu_node != NULL && purple_account_get_check_mail(session->account))
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
693 {
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
694 char *unread = xmlnode_get_data(iu_node);
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
695 const char *passport = msn_user_get_passport(session->user);
23924
1f8e75759bf3 Use a URL to open MSN Hotmail inbox instead of a temporary file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23873
diff changeset
696 const char *url = session->passport_info.mail_url;
21886
be9880b42bd2 Don't show a 'you ain't got no new mail' notification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21369
diff changeset
697 int count = atoi(unread);
20522
177cad886d4c A bunch of MSNP14 stuff:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20518
diff changeset
698
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
699 /* XXX/khc: pretty sure this is wrong */
21886
be9880b42bd2 Don't show a 'you ain't got no new mail' notification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21369
diff changeset
700 if (count > 0)
be9880b42bd2 Don't show a 'you ain't got no new mail' notification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21369
diff changeset
701 purple_notify_emails(session->account->gc, count, FALSE, NULL,
be9880b42bd2 Don't show a 'you ain't got no new mail' notification.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21369
diff changeset
702 NULL, &passport, &url, NULL, NULL);
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
703 g_free(unread);
20522
177cad886d4c A bunch of MSNP14 stuff:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20518
diff changeset
704 }
177cad886d4c A bunch of MSNP14 stuff:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20518
diff changeset
705
20573
d4d5f8079126 mostly fixed offline messaging, still 2 bugs:
Ka-Hing Cheung <khc@pidgin.im>
parents: 20564
diff changeset
706 for(mNode = xmlnode_get_child(node, "M"); mNode;
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
707 mNode = xmlnode_get_next_twin(mNode)){
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
708 char *passport, *msgid, *nickname, *rtime = NULL;
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
709 xmlnode *e_node, *i_node, *n_node, *rt_node;
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
710
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
711 e_node = xmlnode_get_child(mNode, "E");
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
712 passport = xmlnode_get_data(e_node);
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
713
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
714 i_node = xmlnode_get_child(mNode, "I");
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
715 msgid = xmlnode_get_data(i_node);
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
716
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
717 n_node = xmlnode_get_child(mNode, "N");
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
718 nickname = xmlnode_get_data(n_node);
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
719
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
720 rt_node = xmlnode_get_child(mNode, "RT");
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
721 if (rt_node != NULL) {
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
722 rtime = xmlnode_get_data(rt_node);
20522
177cad886d4c A bunch of MSNP14 stuff:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20518
diff changeset
723 }
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
724 /* purple_debug_info("msn", "E:{%s},I:{%s},rTime:{%s}\n",passport,msgid,rTime); */
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
725
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
726 if (!g_list_find_custom(oim->oim_list, msgid, (GCompareFunc)strcmp)) {
21362
8fd2932c4d25 fixes oim timestamp for me, non HAVE_TM_GMTOFF people probably want to test
Ka-Hing Cheung <khc@pidgin.im>
parents: 21361
diff changeset
727 oim->oim_list = g_list_append(oim->oim_list, msgid);
8fd2932c4d25 fixes oim timestamp for me, non HAVE_TM_GMTOFF people probably want to test
Ka-Hing Cheung <khc@pidgin.im>
parents: 21361
diff changeset
728 msn_oim_post_single_get_msg(oim, msgid);
8fd2932c4d25 fixes oim timestamp for me, non HAVE_TM_GMTOFF people probably want to test
Ka-Hing Cheung <khc@pidgin.im>
parents: 21361
diff changeset
729 msgid = NULL;
8fd2932c4d25 fixes oim timestamp for me, non HAVE_TM_GMTOFF people probably want to test
Ka-Hing Cheung <khc@pidgin.im>
parents: 21361
diff changeset
730 }
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
731
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
732 g_free(passport);
20522
177cad886d4c A bunch of MSNP14 stuff:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20518
diff changeset
733 g_free(msgid);
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
734 g_free(rtime);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
735 g_free(nickname);
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
736 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
737 }
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
738
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
739 /*Post to get the Offline Instant Message*/
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
740 static void
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
741 msn_oim_post_single_get_msg(MsnOim *oim, char *msgid)
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
742 {
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
743 char *soap_body;
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
744 MsnOimRecvData *data = g_new0(MsnOimRecvData, 1);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
745
23830
1436e3de5d6c The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23822
diff changeset
746 purple_debug_info("msn", "Get single OIM Message\n");
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
747
21363
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
748 data->oim = oim;
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
749 data->msg_id = msgid;
343c9a27098a seems to fix duplicate oim messages for real. The problem was that MSN tells
Ka-Hing Cheung <khc@pidgin.im>
parents: 21362
diff changeset
750
23781
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
751 soap_body = g_strdup_printf(MSN_OIM_GET_TEMPLATE, msgid);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
752
23781
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
753 msn_oim_make_request(oim, FALSE, MSN_OIM_GET_SOAP_ACTION, MSN_OIM_RETRIEVE_HOST,
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
754 MSN_OIM_RETRIEVE_URL, xmlnode_from_str(soap_body, -1), msn_oim_get_read_cb,
1bc9a749b753 Correctly update MSN OIM tokens when an invalid token error is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23776
diff changeset
755 data);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
756
21361
f890366c8ec6 oim migrated to new soap code, quadruply duplicated message!
Ka-Hing Cheung <khc@pidgin.im>
parents: 20587
diff changeset
757 g_free(soap_body);
20478
46933dc62880 propagate from branch 'im.pidgin.pidgin' (head 88b7040408c88e4516c008f4eac579f98ef53e85)
Richard Laager <rlaager@pidgin.im>
parents:
diff changeset
758 }

mercurial