Mercurial > pidgin
annotate src/protocols/msn/msnslp.c @ 8718:6ab61697426e
[gaim-migrate @ 9473]
simguy wants this
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Tue, 20 Apr 2004 04:04:41 +0000 |
parents | 1e211dde3cae |
children | f32ee2e97b37 |
rev | line source |
---|---|
6701 | 1 /** |
2 * @file msnslp.c MSNSLP support | |
3 * | |
4 * gaim | |
5 * | |
8475
06f57183e29f
[gaim-migrate @ 9208]
Christian Hammond <chipx86@chipx86.com>
parents:
8372
diff
changeset
|
6 * Copyright (C) 2003-2004 Christian Hammond <chipx86@gnupdate.org> |
6701 | 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, |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
62 const char *local_user, const char *remote_user, |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
63 const char *header, const char *branch, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
64 int cseq, const char *call_id, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
65 const char *content) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
66 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
67 MsnMessage *invite_msg; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
68 char *body; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
69 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
70 g_return_if_fail(slpsession != NULL); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
71 g_return_if_fail(header != NULL); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
72 g_return_if_fail(branch != NULL); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
73 g_return_if_fail(call_id != NULL); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
74 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
75 if (branch == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
76 branch = "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 body = g_strdup_printf( |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
79 "%s\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
80 "To: <msnmsgr:%s>\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
81 "From: <msnmsgr:%s>\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
82 "Via: MSNSLP/1.0/TLP ;branch={%s}\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
83 "CSeq: %d\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
84 "Call-ID: {%s}\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
85 "Max-Forwards: 0\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
86 "Content-Type: application/x-msnmsgr-sessionreqbody\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
87 "Content-Length: %d\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
88 "\r\n" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
89 "%s" |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
90 "\r\n\r\n", |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
91 header, |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
92 remote_user, |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
93 local_user, |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
94 branch, cseq, call_id, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
95 (content == NULL ? 0 : (int)strlen(content) + 5), |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
96 (content == NULL ? "" : content)); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
97 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
98 gaim_debug_misc("msn", "Message = {%s}\n", body); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
99 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
100 invite_msg = msn_message_new_msnslp(); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
101 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
102 msn_message_set_body(invite_msg, body); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
103 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
104 g_free(body); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
105 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
106 msn_slp_session_send_msg(slpsession, invite_msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
107 } |
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 static gboolean |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
110 send_error_500(MsnSlpSession *slpsession, const char *call_id, MsnMessage *msg) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
111 { |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
112 MsnUser *local_user; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
113 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
114 g_return_val_if_fail(slpsession != NULL, TRUE); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
115 g_return_val_if_fail(msg != NULL, TRUE); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
116 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
117 local_user = slpsession->swboard->servconn->session->user; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
118 |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
119 msn_slp_session_send_message(slpsession, msg->passport, |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
120 msn_user_get_passport(local_user), |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
121 "MSNSLP/1.0 500 Internal Error", |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
122 slpsession->branch, 1, call_id, NULL); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
123 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
124 return TRUE; |
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 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
127 static gboolean |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
128 send_cb(gpointer user_data) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
129 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
130 MsnSlpSession *slpsession = (MsnSlpSession *)user_data; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
131 MsnMessage *msg; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
132 char data[1200]; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
133 size_t len; |
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 len = fread(data, 1, 1200, slpsession->send_fp); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
136 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
137 slpsession->remaining_size -= len; |
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 msg = msn_message_new_msnslp(); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
140 msn_message_set_bin_data(msg, data, len); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
141 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
142 msn_slp_session_send_msg(slpsession, msg); |
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 if (slpsession->remaining_size <= 0) |
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->send_timer = 0; |
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 return FALSE; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
149 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
150 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
151 return TRUE; |
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 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
154 gboolean |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
155 msn_slp_session_msg_received(MsnSlpSession *slpsession, MsnMessage *msg) |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
156 { |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
157 const char *body; |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
158 const char *c, *c2; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
159 GaimAccount *account; |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
160 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
161 g_return_val_if_fail(slpsession != NULL, TRUE); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
162 g_return_val_if_fail(msg != NULL, TRUE); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
163 g_return_val_if_fail(msg->msnslp_message, TRUE); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
164 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
|
165 "application/x-msnmsgrp2p"), TRUE); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
166 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
167 account = slpsession->swboard->servconn->session->account; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
168 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
169 body = msn_message_get_body(msg); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
170 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
171 gaim_debug_misc("msn", "MSNSLP Message: {%s}\n", body); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
172 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
173 if (*body == '\0') |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
174 { |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
175 /* ACK. Ignore it. */ |
6842
bd433a45a463
[gaim-migrate @ 7387]
Christian Hammond <chipx86@chipx86.com>
parents:
6831
diff
changeset
|
176 gaim_debug_info("msn", "Received MSNSLP ACK\n"); |
bd433a45a463
[gaim-migrate @ 7387]
Christian Hammond <chipx86@chipx86.com>
parents:
6831
diff
changeset
|
177 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
178 return FALSE; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
179 } |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
180 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
181 if (slpsession->send_fp != NULL && slpsession->remaining_size == 0) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
182 { |
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 * 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
|
185 * 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
|
186 * |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
187 * Say BYE-BYE. |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
188 */ |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
189 MsnUser *local_user; |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
190 char *header; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
191 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
192 fclose(slpsession->send_fp); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
193 slpsession->send_fp = NULL; |
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 header = g_strdup_printf("BYE MSNMSGR:%s MSNSLP/1.0", |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
196 msg->passport); |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
197 |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
198 local_user = slpsession->swboard->servconn->session->user; |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
199 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
200 msn_slp_session_send_message(slpsession, msg->passport, |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
201 msn_user_get_passport(local_user), |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
202 header, |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
203 "A0D624A6-6C0C-4283-A9E0-BC97B4B46D32", |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
204 0, slpsession->call_id, ""); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
205 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
206 g_free(header); |
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 return TRUE; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
209 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
210 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
211 if (!strncmp(body, "MSNSLP/1.0 ", strlen("MSNSLP/1.0 "))) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
212 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
213 /* Make sure this is "OK" */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
214 const char *status = body + strlen("MSNSLP/1.0 "); |
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 if (strncmp(status, "200 OK", 6)) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
217 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
218 /* It's not valid. Kill this off. */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
219 char temp[32]; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
220 const char *c; |
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 /* Eww */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
223 if ((c = strchr(status, '\r')) || (c = strchr(status, '\n')) || |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
224 (c = strchr(status, '\0'))) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
225 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
226 strncpy(temp, status, c - status); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
227 temp[c - status] = '\0'; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
228 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
229 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
230 gaim_debug_error("msn", "Received non-OK result: %s\n", temp); |
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 return TRUE; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
233 } |
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 else if (!strncmp(body, "INVITE", strlen("INVITE"))) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
236 { |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
237 /* Parse it. Oh this is fun. */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
238 char *branch, *call_id, *temp; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
239 unsigned int session_id, app_id; |
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 /* First, branch. */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
242 if ((c = strstr(body, ";branch={")) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
243 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
244 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
245 c += strlen(";branch={"); |
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 if ((c2 = strchr(c, '}')) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
248 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
249 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
250 branch = g_strndup(c, c2 - c); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
251 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
252 if (slpsession->branch != NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
253 slpsession->branch = branch; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
254 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
255 /* Second, Call-ID */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
256 if ((c = strstr(body, "Call-ID: {")) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
257 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
258 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
259 c += strlen("Call-ID: {"); |
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 if ((c2 = strchr(c, '}')) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
262 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
263 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
264 call_id = g_strndup(c, c2 - c); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
265 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
266 if (slpsession->call_id != NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
267 slpsession->call_id = call_id; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
268 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
269 /* Third, SessionID */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
270 if ((c = strstr(body, "SessionID: ")) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
271 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
272 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
273 c += strlen("SessionID: "); |
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 if ((c2 = strchr(c, '\r')) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
276 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
277 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
278 temp = g_strndup(c, c2 - c); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
279 session_id = atoi(temp); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
280 g_free(temp); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
281 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
282 /* Fourth, AppID */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
283 if ((c = strstr(body, "AppID: ")) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
284 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
285 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
286 c += strlen("AppID: "); |
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 if ((c2 = strchr(c, '\r')) == NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
289 return send_error_500(slpsession, NULL, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
290 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
291 temp = g_strndup(c, c2 - c); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
292 app_id = atoi(temp); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
293 g_free(temp); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
294 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
295 if (app_id == 1) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
296 { |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
297 MsnSession *session; |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
298 MsnMessage *new_msg; |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
299 MsnUser *local_user; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
300 MsnUser *remote_user; |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
301 char *content; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
302 char nil_body[4]; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
303 struct stat st; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
304 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
305 /* Send the 200 OK message. */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
306 content = g_strdup_printf("SessionID: %d", session_id); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
307 msn_slp_session_send_ack(slpsession, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
308 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
309 session = slpsession->swboard->servconn->session; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
310 |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
311 local_user = session->user; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
312 |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
313 msn_slp_session_send_message(slpsession, msg->passport, |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
314 msn_user_get_passport(local_user), |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
315 "MSNSLP/1.0 200 OK", |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
316 branch, 1, call_id, 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 g_free(content); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
319 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
320 /* Send the Data Preparation message. */ |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
321 memset(nil_body, 0, sizeof(nil_body)); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
322 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
323 slpsession->session_id = session_id; |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
324 |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
325 remote_user = msn_user_new(session, msg->passport, NULL); |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
326 |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
327 slpsession->receiver = remote_user; |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
328 slpsession->sender = session->user; |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
329 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
330 new_msg = msn_message_new_msnslp(); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
331 msn_message_set_bin_data(new_msg, nil_body, 4); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
332 new_msg->msnslp_footer.app_id = 1; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
333 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
334 msn_slp_session_send_msg(slpsession, new_msg); |
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 slpsession->send_fp = |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
337 fopen(gaim_account_get_buddy_icon(account), "rb"); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
338 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
339 if (stat(gaim_account_get_buddy_icon(account), &st) == 0) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
340 slpsession->remaining_size = st.st_size; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
341 |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
7604
diff
changeset
|
342 slpsession->send_timer = gaim_timeout_add(10, send_cb, slpsession); |
7604
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 else |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
345 return send_error_500(slpsession, call_id, msg); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
346 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
347 return FALSE; |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
348 } |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
349 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
350 /* Now send an ack, since we got this. */ |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
351 msn_slp_session_send_ack(slpsession, msg); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
352 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
353 return FALSE; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
354 } |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
355 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
356 static void |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
357 send_msg_part(MsnSlpSession *slpsession, MsnMessage *msg) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
358 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
359 msg->msnslp_header.length = |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
360 (slpsession->orig_len - slpsession->offset > 1202 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
361 ? 1202 : slpsession->orig_len - slpsession->offset); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
362 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
363 if (slpsession->offset > 0) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
364 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
365 if (msg->bin_content) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
366 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
367 msn_message_set_bin_data(msg, |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
368 slpsession->orig_body + slpsession->offset, |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
369 msg->msnslp_header.length); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
370 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
371 else |
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 msn_message_set_body(msg, |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
374 slpsession->orig_body + slpsession->offset); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
375 } |
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 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
378 msg->msnslp_header.offset_1 = slpsession->offset; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
379 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
380 msn_switchboard_send_msg(slpsession->swboard, msg); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
381 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
382 if (slpsession->offset + msg->msnslp_header.length == slpsession->orig_len) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
383 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
384 msn_message_destroy(msg); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
385 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
386 g_free(slpsession->orig_body); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
387 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
388 slpsession->offset = 0; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
389 slpsession->orig_len = 0; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
390 slpsession->orig_body = NULL; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
391 slpsession->outgoing_msg = NULL; |
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 else |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
394 slpsession->offset += msg->msnslp_header.length; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
395 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
396 |
6701 | 397 void |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
398 msn_slp_session_send_msg(MsnSlpSession *slpsession, MsnMessage *msg) |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
399 { |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
400 g_return_if_fail(slpsession != NULL); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
401 g_return_if_fail(msg != NULL); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
402 g_return_if_fail(msg->msnslp_message); |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
403 g_return_if_fail(slpsession->outgoing_msg == NULL); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
404 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
405 msg->msnslp_header.session_id = slpsession->session_id; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
406 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
407 slpsession->outgoing_msg = msn_message_ref(msg); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
408 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
409 if (slpsession->base_id == 0) |
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 slpsession->base_id = rand() % 0x0FFFFFF0 + 4; |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
412 slpsession->prev_msg_id = slpsession->base_id; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
413 } |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
414 else if (slpsession->offset == 0) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
415 slpsession->prev_msg_id = ++slpsession->base_id; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
416 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
417 msg->msnslp_header.id = slpsession->prev_msg_id; |
7475 | 418 /*msg->msnslp_header.ack_session_id = rand() % 0xFFFFFF00;*/ |
6883
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
419 msg->msnslp_header.ack_session_id = 0x1407C7DE; |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
420 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
421 msn_message_set_charset(msg, NULL); |
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->msnslp_header.session_id != 0) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
424 msg->msnslp_footer.app_id = 1; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
425 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
426 if (msg->bin_content) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
427 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
428 const void *temp; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
429 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
430 temp = msn_message_get_bin_data(msg, &slpsession->orig_len); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
431 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
432 slpsession->orig_body = g_memdup(temp, slpsession->orig_len); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
433 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
434 else |
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 slpsession->orig_body = g_strdup(msn_message_get_body(msg)); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
437 slpsession->orig_len = strlen(slpsession->orig_body); |
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 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
440 msg->msnslp_header.total_size_1 = slpsession->orig_len; |
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 send_msg_part(slpsession, msg); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
443 } |
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 void |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
446 msn_slp_session_send_ack(MsnSlpSession *slpsession, MsnMessage *acked_msg) |
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 MsnMessage *msg; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
449 gboolean new_base_id = FALSE; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
450 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
451 g_return_if_fail(slpsession != NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
452 g_return_if_fail(acked_msg != NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
453 g_return_if_fail(acked_msg->msnslp_message); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
454 g_return_if_fail(slpsession->outgoing_msg == NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
455 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
456 msg = msn_message_new_msnslp_ack(acked_msg); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
457 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
458 if (slpsession->base_id == 0) |
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 slpsession->base_id = rand() % 0x0FFFFE00 + 10; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
461 slpsession->prev_msg_id = slpsession->base_id; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
462 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
463 new_base_id = TRUE; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
464 } |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
465 else |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
466 slpsession->prev_msg_id = ++slpsession->base_id; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
467 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
468 msg->msnslp_header.id = slpsession->prev_msg_id; |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
469 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
470 if (new_base_id) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
471 slpsession->prev_msg_id -= 4; |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
472 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
473 msn_switchboard_send_msg(slpsession->swboard, msg); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
474 } |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
475 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
476 void |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
477 msn_slp_session_request_user_display(MsnSlpSession *slpsession, |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
478 MsnUser *local_user, |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
479 MsnUser *remote_user, |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
480 const MsnObject *obj) |
6701 | 481 { |
6842
bd433a45a463
[gaim-migrate @ 7387]
Christian Hammond <chipx86@chipx86.com>
parents:
6831
diff
changeset
|
482 long session_id; |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
483 char *msnobj_data; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
484 char *msnobj_base64; |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
485 char *header; |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
486 char *content; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
487 |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
488 g_return_if_fail(slpsession != NULL); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
489 g_return_if_fail(local_user != NULL); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
490 g_return_if_fail(remote_user != NULL); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
491 g_return_if_fail(obj != NULL); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
492 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
493 msnobj_data = msn_object_to_string(obj); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
6883
diff
changeset
|
494 msnobj_base64 = gaim_base64_encode(msnobj_data, strlen(msnobj_data)); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
495 g_free(msnobj_data); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
496 |
6842
bd433a45a463
[gaim-migrate @ 7387]
Christian Hammond <chipx86@chipx86.com>
parents:
6831
diff
changeset
|
497 session_id = rand() % 0xFFFFFF00 + 4; |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
498 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
499 if (slpsession->branch != NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
500 g_free(slpsession->branch); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
501 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
502 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
|
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 rand() % 0xAAFF + 0x1111, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
509 rand() % 0xAAFF + 0x1111, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
510 rand() % 0xAAFF + 0x1111); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
511 |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
512 if (slpsession->call_id != NULL) |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
513 g_free(slpsession->call_id); |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
514 |
6883
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
515 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
|
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, |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
521 rand() % 0xAAFF + 0x1111, |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
522 rand() % 0xAAFF + 0x1111, |
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
523 rand() % 0xAAFF + 0x1111); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
524 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
525 content = g_strdup_printf( |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
526 "EUF-GUID: {A4268EEC-FEC5-49E5-95C3-F126696BDBF6}\r\n" |
6883
ac638b90da44
[gaim-migrate @ 7429]
Christian Hammond <chipx86@chipx86.com>
parents:
6868
diff
changeset
|
527 "SessionID: %lu\r\n" |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
528 "AppID: 1\r\n" |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
529 "Context: %s", |
6842
bd433a45a463
[gaim-migrate @ 7387]
Christian Hammond <chipx86@chipx86.com>
parents:
6831
diff
changeset
|
530 session_id, |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
531 msnobj_base64); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
532 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
533 g_free(msnobj_base64); |
6701 | 534 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
535 header = g_strdup_printf("INVITE MSNMSGR:%s MSNSLP/1.0", |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
536 msn_user_get_passport(remote_user)); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
537 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
538 msn_slp_session_send_message(slpsession, |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
539 msn_user_get_passport(local_user), |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
540 msn_user_get_passport(remote_user), |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
541 header, slpsession->branch, 0, |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
542 slpsession->call_id, content); |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
543 |
7604
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
544 g_free(header); |
43803965ef45
[gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
545 g_free(content); |
6701 | 546 } |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
547 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
548 gboolean |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
549 msn_p2p_msg(MsnServConn *servconn, MsnMessage *msg) |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
550 { |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
551 MsnSwitchBoard *swboard = servconn->data; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
552 gboolean session_ended = FALSE; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
553 |
8372
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
554 #if 0 |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
555 FILE *fp; |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
556 size_t len; |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
557 char *buf; |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
558 |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
559 buf = msn_message_to_string(msg, &len); |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
560 /* Windows doesn't like Unix paths */ |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
561 fp = fopen("/tmp/msn-msg", "ab"); |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
562 fwrite(buf, 1, len, fp); |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
563 fclose(fp); |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
564 |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
565 g_free(buf); |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
566 #endif |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
567 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
568 if (swboard->slp_session == NULL) |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
569 swboard->slp_session = msn_slp_session_new(swboard, FALSE); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
570 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
571 session_ended = msn_slp_session_msg_received(swboard->slp_session, msg); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
572 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
573 if (session_ended) |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
574 msn_slp_session_destroy(swboard->slp_session); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
575 |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
576 return FALSE; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
577 } |