Mercurial > pidgin
annotate src/protocols/msn/slpcall.c @ 13395:ff4e85e04adf
[gaim-migrate @ 15768]
Remove some dead code.
Resolves Coverity CID 1 of 113 ;)
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 06 Mar 2006 07:53:52 +0000 |
parents | 442b23efba54 |
children | 1b6c631012d9 |
rev | line source |
---|---|
9193 | 1 /** |
2 * @file slpcall.c SLP Call Functions | |
3 * | |
4 * gaim | |
5 * | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
6 * Gaim is the legal property of its developers, whose names are too numerous |
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
8 * source distribution. |
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
9 * |
9193 | 10 * This program is free software; you can redistribute it and/or modify |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 */ | |
24 #include "msn.h" | |
25 #include "slpcall.h" | |
26 #include "slpsession.h" | |
27 | |
28 #include "slp.h" | |
29 | |
10773 | 30 /* #define MSN_DEBUG_SLPCALL */ |
31 | |
9193 | 32 /************************************************************************** |
33 * Util | |
34 **************************************************************************/ | |
35 | |
11897 | 36 static char * |
9193 | 37 rand_guid() |
38 { | |
39 return g_strdup_printf("%4X%4X-%4X-%4X-%4X-%4X%4X%4X", | |
40 rand() % 0xAAFF + 0x1111, | |
41 rand() % 0xAAFF + 0x1111, | |
42 rand() % 0xAAFF + 0x1111, | |
43 rand() % 0xAAFF + 0x1111, | |
44 rand() % 0xAAFF + 0x1111, | |
45 rand() % 0xAAFF + 0x1111, | |
46 rand() % 0xAAFF + 0x1111, | |
47 rand() % 0xAAFF + 0x1111); | |
48 } | |
49 | |
50 /************************************************************************** | |
10602 | 51 * Main |
9193 | 52 **************************************************************************/ |
53 | |
54 MsnSlpCall * | |
55 msn_slp_call_new(MsnSlpLink *slplink) | |
56 { | |
57 MsnSlpCall *slpcall; | |
58 | |
59 g_return_val_if_fail(slplink != NULL, NULL); | |
60 | |
61 slpcall = g_new0(MsnSlpCall, 1); | |
62 | |
10773 | 63 #ifdef MSN_DEBUG_SLPCALL |
64 gaim_debug_info("msn", "slpcall_new: slpcall(%p)\n", slpcall); | |
65 #endif | |
66 | |
9193 | 67 slpcall->slplink = slplink; |
10602 | 68 |
69 msn_slplink_add_slpcall(slplink, slpcall); | |
9193 | 70 |
10225 | 71 slpcall->timer = gaim_timeout_add(MSN_SLPCALL_TIMEOUT, msn_slp_call_timeout, slpcall); |
72 | |
9193 | 73 return slpcall; |
74 } | |
75 | |
76 void | |
77 msn_slp_call_destroy(MsnSlpCall *slpcall) | |
78 { | |
79 GList *e; | |
13125 | 80 MsnSession *session; |
9193 | 81 |
10773 | 82 #ifdef MSN_DEBUG_SLPCALL |
83 gaim_debug_info("msn", "slpcall_destroy: slpcall(%p)\n", slpcall); | |
84 #endif | |
85 | |
9193 | 86 g_return_if_fail(slpcall != NULL); |
87 | |
10225 | 88 if (slpcall->timer) |
89 gaim_timeout_remove(slpcall->timer); | |
90 | |
9193 | 91 if (slpcall->id != NULL) |
92 g_free(slpcall->id); | |
93 | |
94 if (slpcall->branch != NULL) | |
95 g_free(slpcall->branch); | |
96 | |
97 if (slpcall->data_info != NULL) | |
98 g_free(slpcall->data_info); | |
99 | |
100 for (e = slpcall->slplink->slp_msgs; e != NULL; ) | |
101 { | |
102 MsnSlpMessage *slpmsg = e->data; | |
103 e = e->next; | |
104 | |
10773 | 105 #ifdef MSN_DEBUG_SLPCALL_VERBOSE |
106 gaim_debug_info("msn", "slpcall_destroy: trying slpmsg(%p)\n", | |
10345 | 107 slpmsg); |
10481 | 108 #endif |
10345 | 109 |
9193 | 110 if (slpmsg->slpcall == slpcall) |
10481 | 111 { |
9193 | 112 msn_slpmsg_destroy(slpmsg); |
10481 | 113 } |
9193 | 114 } |
115 | |
13125 | 116 session = slpcall->slplink->session; |
9193 | 117 |
13027 | 118 msn_slplink_remove_slpcall(slpcall->slplink, slpcall); |
119 | |
13125 | 120 if (slpcall->end_cb != NULL) |
121 slpcall->end_cb(slpcall, session); | |
122 | |
9193 | 123 g_free(slpcall); |
124 } | |
125 | |
126 void | |
10345 | 127 msn_slp_call_init(MsnSlpCall *slpcall, MsnSlpCallType type) |
128 { | |
129 slpcall->session_id = rand() % 0xFFFFFF00 + 4; | |
130 slpcall->id = rand_guid(); | |
131 slpcall->type = type; | |
132 } | |
133 | |
134 void | |
135 msn_slp_call_session_init(MsnSlpCall *slpcall) | |
136 { | |
137 MsnSlpSession *slpsession; | |
138 | |
139 slpsession = msn_slp_session_new(slpcall); | |
140 | |
141 if (slpcall->session_init_cb) | |
142 slpcall->session_init_cb(slpsession); | |
143 | |
144 slpcall->started = TRUE; | |
145 } | |
146 | |
147 void | |
9193 | 148 msn_slp_call_invite(MsnSlpCall *slpcall, const char *euf_guid, |
149 int app_id, const char *context) | |
150 { | |
151 MsnSlpLink *slplink; | |
152 MsnSlpMessage *slpmsg; | |
153 char *header; | |
154 char *content; | |
155 | |
156 g_return_if_fail(slpcall != NULL); | |
157 g_return_if_fail(context != NULL); | |
158 | |
159 slplink = slpcall->slplink; | |
160 | |
10000 | 161 slpcall->branch = rand_guid(); |
9193 | 162 |
163 content = g_strdup_printf( | |
164 "EUF-GUID: {%s}\r\n" | |
165 "SessionID: %lu\r\n" | |
166 "AppID: %d\r\n" | |
167 "Context: %s\r\n\r\n", | |
168 euf_guid, | |
169 slpcall->session_id, | |
170 app_id, | |
171 context); | |
172 | |
173 header = g_strdup_printf("INVITE MSNMSGR:%s MSNSLP/1.0", | |
174 slplink->remote_user); | |
175 | |
10000 | 176 slpmsg = msn_slpmsg_sip_new(slpcall, 0, header, slpcall->branch, |
9193 | 177 "application/x-msnmsgr-sessionreqbody", content); |
10773 | 178 |
10345 | 179 #ifdef MSN_DEBUG_SLP |
9193 | 180 slpmsg->info = "SLP INVITE"; |
181 slpmsg->text_body = TRUE; | |
182 #endif | |
183 | |
184 msn_slplink_send_slpmsg(slplink, slpmsg); | |
185 | |
186 g_free(header); | |
187 g_free(content); | |
188 } | |
189 | |
190 void | |
191 msn_slp_call_close(MsnSlpCall *slpcall) | |
192 { | |
193 g_return_if_fail(slpcall != NULL); | |
194 g_return_if_fail(slpcall->slplink != NULL); | |
195 | |
196 send_bye(slpcall, "application/x-msnmsgr-sessionclosebody"); | |
197 msn_slplink_unleash(slpcall->slplink); | |
198 msn_slp_call_destroy(slpcall); | |
199 } | |
200 | |
10225 | 201 gboolean |
202 msn_slp_call_timeout(gpointer data) | |
203 { | |
10296 | 204 MsnSlpCall *slpcall; |
205 | |
10504 | 206 slpcall = data; |
10225 | 207 |
10773 | 208 #ifdef MSN_DEBUG_SLPCALL |
209 gaim_debug_info("msn", "slpcall_timeout: slpcall(%p)\n", slpcall); | |
210 #endif | |
10225 | 211 |
10296 | 212 if (!slpcall->pending && !slpcall->progress) |
213 { | |
214 msn_slp_call_destroy(slpcall); | |
215 return FALSE; | |
216 } | |
217 | |
218 slpcall->progress = FALSE; | |
219 | |
220 return TRUE; | |
10225 | 221 } |
222 | |
9193 | 223 MsnSlpCall * |
224 msn_slp_process_msg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg) | |
225 { | |
226 MsnSlpCall *slpcall; | |
11164 | 227 const guchar *body; |
9193 | 228 gsize body_len; |
229 | |
230 slpcall = NULL; | |
231 body = slpmsg->buffer; | |
232 body_len = slpmsg->size; | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
233 |
9193 | 234 if (slpmsg->flags == 0x0) |
235 { | |
11236 | 236 char *body_str; |
237 | |
238 body_str = g_strndup((const char *)body, body_len); | |
239 slpcall = msn_slp_sip_recv(slplink, body_str); | |
240 g_free(body_str); | |
9193 | 241 } |
242 else if (slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030) | |
243 { | |
244 slpcall = msn_slplink_find_slp_call_with_session_id(slplink, slpmsg->session_id); | |
245 | |
246 if (slpcall != NULL) | |
10225 | 247 { |
248 if (slpcall->timer) | |
249 gaim_timeout_remove(slpcall->timer); | |
250 | |
9193 | 251 slpcall->cb(slpcall, body, body_len); |
10225 | 252 |
253 slpcall->wasted = TRUE; | |
254 } | |
9193 | 255 } |
256 #if 0 | |
257 else if (slpmsg->flags == 0x100) | |
258 { | |
259 slpcall = slplink->directconn->initial_call; | |
260 | |
261 if (slpcall != NULL) | |
262 msn_slp_call_session_init(slpcall); | |
263 } | |
264 #endif | |
265 | |
266 return slpcall; | |
267 } |