Mercurial > pidgin.yaz
annotate src/protocols/msn/msnslp.c @ 8273:f24172f53650
[gaim-migrate @ 8997]
This is Scott Lamb's eventloop abstraction patch. If it breaks things,
Scott Lamb will be glad to take the punishment. If it doesn't, it should
make integration into other event loops easier. Well, no, not easier,
harder actually, but it'll be done more appropriately and less hackily..
er, hacky. Is hackily a word?
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 17 Feb 2004 02:17:48 +0000 |
parents | 43803965ef45 |
children | bd16ed85cfc2 |
rev | line source |
---|---|
6701 | 1 /** |
2 * @file msnslp.c MSNSLP support | |
3 * | |
4 * gaim | |
5 * | |
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 */ | |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
22 #include "msn.h" |
6701 | 23 #include "msnslp.h" |
24 | |
25 MsnSlpSession * | |
26 msn_slp_session_new(MsnSwitchBoard *swboard, gboolean local_initiated) | |
27 { | |
28 MsnSlpSession *slpsession; | |
29 | |
30 g_return_val_if_fail(swboard != NULL, NULL); | |
31 | |
32 slpsession = g_new0(MsnSlpSession, 1); | |
33 | |
34 slpsession->swboard = swboard; | |
35 slpsession->local_initiated = local_initiated; | |
36 | |
37 return slpsession; | |
38 } | |
39 | |
40 void | |
41 msn_slp_session_destroy(MsnSlpSession *session) | |
42 { | |
43 g_return_if_fail(session != NULL); | |
44 | |
6883
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
45 if (session->orig_body != NULL) |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
46 g_free(session->orig_body); |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
47 |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
48 if (session->outgoing_msg != NULL) |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
49 msn_message_unref(session->outgoing_msg); |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
50 |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
51 if (session->call_id != NULL) |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
52 g_free(session->call_id); |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
53 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
54 if (session->branch != NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
55 g_free(session->branch); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
56 |
6701 | 57 g_free(session); |
58 } | |
59 | |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
60 static void |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
61 msn_slp_session_send_message(MsnSlpSession *slpsession, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
62 MsnMessage *source_msg, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
63 MsnUser *local_user, MsnUser *remote_user, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
64 const char *header, const char *branch, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
65 int cseq, const char *call_id, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
66 const char *content) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
67 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
68 MsnMessage *invite_msg; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
69 char *body; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
70 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
71 g_return_if_fail(slpsession != NULL); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
72 g_return_if_fail(header != NULL); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
73 g_return_if_fail(branch != NULL); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
74 g_return_if_fail(call_id != NULL); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
75 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
76 if (source_msg != NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
77 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
78 if (msn_message_is_incoming(source_msg)) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
79 remote_user = msn_message_get_sender(source_msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
80 else |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
81 remote_user = msn_message_get_receiver(source_msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
82 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
83 local_user = slpsession->swboard->servconn->session->user; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
84 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
85 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
86 if (branch == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
87 branch = "null"; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
88 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
89 body = g_strdup_printf( |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
90 "%s\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
91 "To: <msnmsgr:%s>\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
92 "From: <msnmsgr:%s>\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
93 "Via: MSNSLP/1.0/TLP ;branch={%s}\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
94 "CSeq: %d\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
95 "Call-ID: {%s}\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
96 "Max-Forwards: 0\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
97 "Content-Type: application/x-msnmsgr-sessionreqbody\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
98 "Content-Length: %d\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
99 "\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
100 "%s" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
101 "\r\n\r\n", |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
102 header, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
103 msn_user_get_passport(remote_user), |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
104 msn_user_get_passport(local_user), |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
105 branch, cseq, call_id, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
106 (content == NULL ? 0 : (int)strlen(content) + 5), |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
107 (content == NULL ? "" : content)); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
108 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
109 gaim_debug_misc("msn", "Message = {%s}\n", body); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
110 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
111 invite_msg = msn_message_new_msnslp(); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
112 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
113 msn_message_set_sender(invite_msg, local_user); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
114 msn_message_set_receiver(invite_msg, remote_user); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
115 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
116 msn_message_set_body(invite_msg, body); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
117 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
118 g_free(body); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
119 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
120 msn_slp_session_send_msg(slpsession, invite_msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
121 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
122 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
123 static gboolean |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
124 send_error_500(MsnSlpSession *slpsession, const char *call_id, MsnMessage *msg) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
125 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
126 g_return_val_if_fail(slpsession != NULL, TRUE); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
127 g_return_val_if_fail(msg != NULL, TRUE); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
128 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
129 msn_slp_session_send_message(slpsession, msg, NULL, NULL, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
130 "MSNSLP/1.0 500 Internal Error", |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
131 slpsession->branch, 1, call_id, NULL); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
132 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
133 return TRUE; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
134 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
135 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
136 static gboolean |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
137 send_cb(gpointer user_data) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
138 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
139 MsnSlpSession *slpsession = (MsnSlpSession *)user_data; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
140 MsnMessage *msg; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
141 char data[1200]; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
142 size_t len; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
143 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
144 len = fread(data, 1, 1200, slpsession->send_fp); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
145 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
146 slpsession->remaining_size -= len; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
147 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
148 msg = msn_message_new_msnslp(); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
149 msn_message_set_sender(msg, slpsession->receiver); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
150 msn_message_set_receiver(msg, slpsession->sender); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
151 msn_message_set_bin_data(msg, data, len); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
152 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
153 msn_slp_session_send_msg(slpsession, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
154 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
155 if (slpsession->remaining_size <= 0) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
156 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
157 slpsession->send_timer = 0; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
158 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
159 return FALSE; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
160 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
161 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
162 return TRUE; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
163 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
164 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
165 gboolean |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
166 msn_slp_session_msg_received(MsnSlpSession *slpsession, MsnMessage *msg) |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
167 { |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
168 const char *body; |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
169 const char *c, *c2; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
170 GaimAccount *account; |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
171 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
172 g_return_val_if_fail(slpsession != NULL, TRUE); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
173 g_return_val_if_fail(msg != NULL, TRUE); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
174 g_return_val_if_fail(msg->msnslp_message, TRUE); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
175 g_return_val_if_fail(!strcmp(msn_message_get_content_type(msg), |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
176 "application/x-msnmsgrp2p"), TRUE); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
177 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
178 account = slpsession->swboard->servconn->session->account; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
179 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
180 body = msn_message_get_body(msg); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
181 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
182 gaim_debug_misc("msn", "MSNSLP Message: {%s}\n", body); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
183 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
184 if (*body == '\0') |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
185 { |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
186 /* ACK. Ignore it. */ |
6842
bd433a45a463
[gaim-migrate @ 7387]
Christian Hammond <chipx86@chipx86.com>
parents:
6831
diff
changeset
|
187 gaim_debug_info("msn", "Received MSNSLP ACK\n"); |
bd433a45a463
[gaim-migrate @ 7387]
Christian Hammond <chipx86@chipx86.com>
parents:
6831
diff
changeset
|
188 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
189 return FALSE; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
190 } |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
191 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
192 if (slpsession->send_fp != NULL && slpsession->remaining_size == 0) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
193 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
194 /* |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
195 * In theory, if we received something while send_fp is non-NULL, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
196 * but remaining_size is 0, then this is a data ack message. |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
197 * |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
198 * Say BYE-BYE. |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
199 */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
200 char *header; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
201 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
202 fclose(slpsession->send_fp); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
203 slpsession->send_fp = NULL; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
204 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
205 header = g_strdup_printf("BYE MSNMSGR:%s MSNSLP/1.0", |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
206 msn_user_get_passport(msn_message_get_sender(msg))); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
207 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
208 msn_slp_session_send_message(slpsession, msg, NULL, NULL, header, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
209 "A0D624A6-6C0C-4283-A9E0-BC97B4B46D32", |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
210 0, slpsession->call_id, ""); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
211 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
212 g_free(header); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
213 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
214 return TRUE; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
215 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
216 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
217 if (!strncmp(body, "MSNSLP/1.0 ", strlen("MSNSLP/1.0 "))) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
218 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
219 /* Make sure this is "OK" */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
220 const char *status = body + strlen("MSNSLP/1.0 "); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
221 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
222 if (strncmp(status, "200 OK", 6)) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
223 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
224 /* It's not valid. Kill this off. */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
225 char temp[32]; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
226 const char *c; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
227 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
228 /* Eww */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
229 if ((c = strchr(status, '\r')) || (c = strchr(status, '\n')) || |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
230 (c = strchr(status, '\0'))) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
231 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
232 strncpy(temp, status, c - status); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
233 temp[c - status] = '\0'; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
234 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
235 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
236 gaim_debug_error("msn", "Received non-OK result: %s\n", temp); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
237 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
238 return TRUE; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
239 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
240 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
241 else if (!strncmp(body, "INVITE", strlen("INVITE"))) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
242 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
243 /* Parse it. Oh this is fun. */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
244 char *branch, *call_id, *temp; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
245 unsigned int session_id, app_id; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
246 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
247 /* First, branch. */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
248 if ((c = strstr(body, ";branch={")) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
249 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
250 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
251 c += strlen(";branch={"); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
252 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
253 if ((c2 = strchr(c, '}')) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
254 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
255 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
256 branch = g_strndup(c, c2 - c); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
257 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
258 if (slpsession->branch != NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
259 slpsession->branch = branch; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
260 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
261 /* Second, Call-ID */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
262 if ((c = strstr(body, "Call-ID: {")) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
263 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
264 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
265 c += strlen("Call-ID: {"); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
266 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
267 if ((c2 = strchr(c, '}')) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
268 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
269 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
270 call_id = g_strndup(c, c2 - c); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
271 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
272 if (slpsession->call_id != NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
273 slpsession->call_id = call_id; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
274 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
275 /* Third, SessionID */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
276 if ((c = strstr(body, "SessionID: ")) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
277 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
278 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
279 c += strlen("SessionID: "); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
280 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
281 if ((c2 = strchr(c, '\r')) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
282 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
283 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
284 temp = g_strndup(c, c2 - c); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
285 session_id = atoi(temp); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
286 g_free(temp); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
287 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
288 /* Fourth, AppID */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
289 if ((c = strstr(body, "AppID: ")) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
290 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
291 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
292 c += strlen("AppID: "); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
293 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
294 if ((c2 = strchr(c, '\r')) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
295 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
296 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
297 temp = g_strndup(c, c2 - c); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
298 app_id = atoi(temp); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
299 g_free(temp); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
300 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
301 if (app_id == 1) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
302 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
303 MsnMessage *new_msg; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
304 char *content; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
305 char nil_body[4]; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
306 struct stat st; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
307 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
308 /* Send the 200 OK message. */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
309 content = g_strdup_printf("SessionID: %d", session_id); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
310 msn_slp_session_send_ack(slpsession, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
311 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
312 msn_slp_session_send_message(slpsession, msg, NULL, NULL, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
313 "MSNSLP/1.0 200 OK", |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
314 branch, 1, call_id, content); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
315 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
316 g_free(content); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
317 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
318 /* Send the Data Preparation message. */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
319 memset(nil_body, 0, sizeof(nil_body)); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
320 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
321 slpsession->session_id = session_id; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
322 slpsession->receiver = msn_message_get_sender(msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
323 slpsession->sender = slpsession->swboard->servconn->session->user; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
324 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
325 new_msg = msn_message_new_msnslp(); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
326 msn_message_set_sender(new_msg, slpsession->sender); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
327 msn_message_set_receiver(new_msg, slpsession->receiver); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
328 msn_message_set_bin_data(new_msg, nil_body, 4); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
329 new_msg->msnslp_footer.app_id = 1; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
330 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
331 msn_slp_session_send_msg(slpsession, new_msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
332 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
333 slpsession->send_fp = |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
334 fopen(gaim_account_get_buddy_icon(account), "rb"); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
335 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
336 if (stat(gaim_account_get_buddy_icon(account), &st) == 0) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
337 slpsession->remaining_size = st.st_size; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
338 |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
7604
diff
changeset
|
339 slpsession->send_timer = gaim_timeout_add(10, send_cb, slpsession); |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
340 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
341 else |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
342 return send_error_500(slpsession, call_id, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
343 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
344 return FALSE; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
345 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
346 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
347 /* Now send an ack, since we got this. */ |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
348 msn_slp_session_send_ack(slpsession, msg); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
349 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
350 return FALSE; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
351 } |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
352 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
353 static void |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
354 send_msg_part(MsnSlpSession *slpsession, MsnMessage *msg) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
355 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
356 msg->msnslp_header.length = |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
357 (slpsession->orig_len - slpsession->offset > 1202 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
358 ? 1202 : slpsession->orig_len - slpsession->offset); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
359 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
360 if (slpsession->offset > 0) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
361 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
362 if (msg->bin_content) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
363 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
364 msn_message_set_bin_data(msg, |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
365 slpsession->orig_body + slpsession->offset, |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
366 msg->msnslp_header.length); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
367 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
368 else |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
369 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
370 msn_message_set_body(msg, |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
371 slpsession->orig_body + slpsession->offset); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
372 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
373 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
374 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
375 msg->msnslp_header.offset_1 = slpsession->offset; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
376 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
377 msn_switchboard_send_msg(slpsession->swboard, msg); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
378 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
379 if (slpsession->offset + msg->msnslp_header.length == slpsession->orig_len) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
380 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
381 msn_message_destroy(msg); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
382 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
383 g_free(slpsession->orig_body); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
384 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
385 slpsession->offset = 0; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
386 slpsession->orig_len = 0; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
387 slpsession->orig_body = NULL; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
388 slpsession->outgoing_msg = NULL; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
389 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
390 else |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
391 slpsession->offset += msg->msnslp_header.length; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
392 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
393 |
6701 | 394 void |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
395 msn_slp_session_send_msg(MsnSlpSession *slpsession, MsnMessage *msg) |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
396 { |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
397 g_return_if_fail(slpsession != NULL); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
398 g_return_if_fail(msg != NULL); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
399 g_return_if_fail(msg->msnslp_message); |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
400 g_return_if_fail(slpsession->outgoing_msg == NULL); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
401 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
402 msg->msnslp_header.session_id = slpsession->session_id; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
403 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
404 slpsession->outgoing_msg = msn_message_ref(msg); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
405 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
406 if (slpsession->base_id == 0) |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
407 { |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
408 slpsession->base_id = rand() % 0x0FFFFFF0 + 4; |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
409 slpsession->prev_msg_id = slpsession->base_id; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
410 } |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
411 else if (slpsession->offset == 0) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
412 slpsession->prev_msg_id = ++slpsession->base_id; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
413 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
414 msg->msnslp_header.id = slpsession->prev_msg_id; |
7475 | 415 /*msg->msnslp_header.ack_session_id = rand() % 0xFFFFFF00;*/ |
6883
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
416 msg->msnslp_header.ack_session_id = 0x1407C7DE; |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
417 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
418 msn_message_set_charset(msg, NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
419 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
420 if (msg->msnslp_header.session_id != 0) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
421 msg->msnslp_footer.app_id = 1; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
422 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
423 if (msg->bin_content) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
424 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
425 const void *temp; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
426 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
427 temp = msn_message_get_bin_data(msg, &slpsession->orig_len); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
428 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
429 slpsession->orig_body = g_memdup(temp, slpsession->orig_len); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
430 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
431 else |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
432 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
433 slpsession->orig_body = g_strdup(msn_message_get_body(msg)); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
434 slpsession->orig_len = strlen(slpsession->orig_body); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
435 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
436 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
437 msg->msnslp_header.total_size_1 = slpsession->orig_len; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
438 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
439 send_msg_part(slpsession, msg); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
440 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
441 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
442 void |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
443 msn_slp_session_send_ack(MsnSlpSession *slpsession, MsnMessage *acked_msg) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
444 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
445 MsnMessage *msg; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
446 gboolean new_base_id = FALSE; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
447 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
448 g_return_if_fail(slpsession != NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
449 g_return_if_fail(acked_msg != NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
450 g_return_if_fail(acked_msg->msnslp_message); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
451 g_return_if_fail(slpsession->outgoing_msg == NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
452 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
453 msg = msn_message_new_msnslp_ack(acked_msg); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
454 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
455 if (slpsession->base_id == 0) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
456 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
457 slpsession->base_id = rand() % 0x0FFFFE00 + 10; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
458 slpsession->prev_msg_id = slpsession->base_id; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
459 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
460 new_base_id = TRUE; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
461 } |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
462 else |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
463 slpsession->prev_msg_id = ++slpsession->base_id; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
464 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
465 msg->msnslp_header.id = slpsession->prev_msg_id; |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
466 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
467 if (new_base_id) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
468 slpsession->prev_msg_id -= 4; |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
469 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
470 msn_switchboard_send_msg(slpsession->swboard, msg); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
471 } |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
472 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
473 void |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
474 msn_slp_session_request_user_display(MsnSlpSession *slpsession, |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
475 MsnUser *local_user, |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
476 MsnUser *remote_user, |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
477 const MsnObject *obj) |
6701 | 478 { |
6842
bd433a45a463
[gaim-migrate @ 7387]
Christian Hammond <chipx86@chipx86.com>
parents:
6831
diff
changeset
|
479 long session_id; |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
480 char *msnobj_data; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
481 char *msnobj_base64; |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
482 char *header; |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
483 char *content; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
484 |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
485 g_return_if_fail(slpsession != NULL); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
486 g_return_if_fail(local_user != NULL); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
487 g_return_if_fail(remote_user != NULL); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
488 g_return_if_fail(obj != NULL); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
489 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
490 msnobj_data = msn_object_to_string(obj); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
6883
diff
changeset
|
491 msnobj_base64 = gaim_base64_encode(msnobj_data, strlen(msnobj_data)); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
492 g_free(msnobj_data); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
493 |
6842
bd433a45a463
[gaim-migrate @ 7387]
Christian Hammond <chipx86@chipx86.com>
parents:
6831
diff
changeset
|
494 session_id = rand() % 0xFFFFFF00 + 4; |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
495 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
496 if (slpsession->branch != NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
497 g_free(slpsession->branch); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
498 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
499 slpsession->branch = g_strdup_printf("%4X%4X-%4X-%4X-%4X-%4X%4X%4X", |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
500 rand() % 0xAAFF + 0x1111, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
501 rand() % 0xAAFF + 0x1111, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
502 rand() % 0xAAFF + 0x1111, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
503 rand() % 0xAAFF + 0x1111, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
504 rand() % 0xAAFF + 0x1111, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
505 rand() % 0xAAFF + 0x1111, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
506 rand() % 0xAAFF + 0x1111, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
507 rand() % 0xAAFF + 0x1111); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
508 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
509 if (slpsession->call_id != NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
510 g_free(slpsession->call_id); |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
511 |
6883
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
512 slpsession->call_id = g_strdup_printf("%4X%4X-%4X-%4X-%4X-%4X%4X%4X", |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
513 rand() % 0xAAFF + 0x1111, |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
514 rand() % 0xAAFF + 0x1111, |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
515 rand() % 0xAAFF + 0x1111, |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
516 rand() % 0xAAFF + 0x1111, |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
517 rand() % 0xAAFF + 0x1111, |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
518 rand() % 0xAAFF + 0x1111, |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
519 rand() % 0xAAFF + 0x1111, |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
520 rand() % 0xAAFF + 0x1111); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
521 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
522 content = g_strdup_printf( |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
523 "EUF-GUID: {A4268EEC-FEC5-49E5-95C3-F126696BDBF6}\r\n" |
6883
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
524 "SessionID: %lu\r\n" |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
525 "AppID: 1\r\n" |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
526 "Context: %s", |
6842
bd433a45a463
[gaim-migrate @ 7387]
Christian Hammond <chipx86@chipx86.com>
parents:
6831
diff
changeset
|
527 session_id, |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
528 msnobj_base64); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
529 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
530 g_free(msnobj_base64); |
6701 | 531 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
532 header = g_strdup_printf("INVITE MSNMSGR:%s MSNSLP/1.0", |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
533 msn_user_get_passport(remote_user)); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
534 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
535 msn_slp_session_send_message(slpsession, NULL, local_user, remote_user, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
536 header, slpsession->branch, 0, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
537 slpsession->call_id, content); |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
538 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
539 g_free(header); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
540 g_free(content); |
6701 | 541 } |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
542 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
543 gboolean |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
544 msn_p2p_msg(MsnServConn *servconn, MsnMessage *msg) |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
545 { |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
546 MsnSwitchBoard *swboard = servconn->data; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
547 gboolean session_ended = FALSE; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
548 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
549 if (swboard->slp_session == NULL) |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
550 swboard->slp_session = msn_slp_session_new(swboard, FALSE); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
551 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
552 session_ended = msn_slp_session_msg_received(swboard->slp_session, msg); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
553 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
554 if (session_ended) |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
555 msn_slp_session_destroy(swboard->slp_session); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
556 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
557 return FALSE; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
558 } |