Mercurial > pidgin
annotate src/protocols/msn/slpcall.c @ 10170:3c88c2f1b732
[gaim-migrate @ 11262]
This patch changes proxy.c to set the FD_CLOEXEC flag on any sockets
it opens. This should (hopefully) fix problems with daemons propping
open oscar (and maybe other) accounts when the socket doesn't close
because a child owns it. Only time will tell...
(This just hit oldstatus as well)
committer: Tailor Script <tailor@pidgin.im>
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Thu, 11 Nov 2004 18:00:32 +0000 |
parents | 3a701f15e45d |
children | ecf3ce2e2ab1 |
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 | |
30 /************************************************************************** | |
31 * Util | |
32 **************************************************************************/ | |
33 | |
34 char * | |
35 rand_guid() | |
36 { | |
37 return g_strdup_printf("%4X%4X-%4X-%4X-%4X-%4X%4X%4X", | |
38 rand() % 0xAAFF + 0x1111, | |
39 rand() % 0xAAFF + 0x1111, | |
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 } | |
47 | |
48 /************************************************************************** | |
49 * SLP Call | |
50 **************************************************************************/ | |
51 | |
52 MsnSlpCall * | |
53 msn_slp_call_new(MsnSlpLink *slplink) | |
54 { | |
55 MsnSlpCall *slpcall; | |
56 | |
57 g_return_val_if_fail(slplink != NULL, NULL); | |
58 | |
59 slpcall = g_new0(MsnSlpCall, 1); | |
60 | |
61 slpcall->slplink = slplink; | |
62 slplink->slp_calls = | |
63 g_list_append(slplink->slp_calls, slpcall); | |
64 | |
65 return slpcall; | |
66 } | |
67 | |
68 void | |
69 msn_slp_call_init(MsnSlpCall *slpcall, MsnSlpCallType type) | |
70 { | |
71 slpcall->session_id = rand() % 0xFFFFFF00 + 4; | |
72 slpcall->id = rand_guid(); | |
73 slpcall->type = type; | |
74 } | |
75 | |
76 void | |
77 msn_slp_call_session_init(MsnSlpCall *slpcall) | |
78 { | |
79 MsnSlpSession *slpsession; | |
80 | |
81 slpsession = msn_slp_session_new(slpcall); | |
82 | |
83 if (slpcall->session_init_cb) | |
84 slpcall->session_init_cb(slpsession); | |
85 | |
86 slpcall->started = TRUE; | |
87 } | |
88 | |
89 void | |
90 msn_slp_call_destroy(MsnSlpCall *slpcall) | |
91 { | |
92 GList *e; | |
93 | |
94 g_return_if_fail(slpcall != NULL); | |
95 | |
96 if (slpcall->id != NULL) | |
97 g_free(slpcall->id); | |
98 | |
99 if (slpcall->branch != NULL) | |
100 g_free(slpcall->branch); | |
101 | |
102 if (slpcall->data_info != NULL) | |
103 g_free(slpcall->data_info); | |
104 | |
105 slpcall->slplink->slp_calls = | |
106 g_list_remove(slpcall->slplink->slp_calls, slpcall); | |
107 | |
108 for (e = slpcall->slplink->slp_msgs; e != NULL; ) | |
109 { | |
110 MsnSlpMessage *slpmsg = e->data; | |
111 e = e->next; | |
112 | |
113 g_return_if_fail(slpmsg != NULL); | |
114 | |
115 if (slpmsg->slpcall == slpcall) | |
116 { | |
117 #if 1 | |
118 msn_slpmsg_destroy(slpmsg); | |
119 #else | |
120 slpmsg->wasted = TRUE; | |
121 #endif | |
122 } | |
123 } | |
124 | |
9259
f5f7482678d2
[gaim-migrate @ 10058]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
125 if (slpcall->end_cb != NULL) |
f5f7482678d2
[gaim-migrate @ 10058]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
126 slpcall->end_cb(slpcall); |
9193 | 127 |
128 g_free(slpcall); | |
129 } | |
130 | |
131 void | |
132 msn_slp_call_invite(MsnSlpCall *slpcall, const char *euf_guid, | |
133 int app_id, const char *context) | |
134 { | |
135 MsnSlpLink *slplink; | |
136 MsnSlpMessage *slpmsg; | |
137 char *header; | |
138 char *content; | |
139 | |
140 g_return_if_fail(slpcall != NULL); | |
141 g_return_if_fail(context != NULL); | |
142 | |
143 slplink = slpcall->slplink; | |
144 | |
10000 | 145 slpcall->branch = rand_guid(); |
9193 | 146 |
147 content = g_strdup_printf( | |
148 "EUF-GUID: {%s}\r\n" | |
149 "SessionID: %lu\r\n" | |
150 "AppID: %d\r\n" | |
151 "Context: %s\r\n\r\n", | |
152 euf_guid, | |
153 slpcall->session_id, | |
154 app_id, | |
155 context); | |
156 | |
157 header = g_strdup_printf("INVITE MSNMSGR:%s MSNSLP/1.0", | |
158 slplink->remote_user); | |
159 | |
10000 | 160 slpmsg = msn_slpmsg_sip_new(slpcall, 0, header, slpcall->branch, |
9193 | 161 "application/x-msnmsgr-sessionreqbody", content); |
162 #ifdef DEBUG_SLP | |
163 slpmsg->info = "SLP INVITE"; | |
164 slpmsg->text_body = TRUE; | |
165 #endif | |
166 | |
167 msn_slplink_send_slpmsg(slplink, slpmsg); | |
168 | |
169 g_free(header); | |
170 g_free(content); | |
171 } | |
172 | |
173 void | |
174 msn_slp_call_close(MsnSlpCall *slpcall) | |
175 { | |
176 g_return_if_fail(slpcall != NULL); | |
177 g_return_if_fail(slpcall->slplink != NULL); | |
178 | |
179 send_bye(slpcall, "application/x-msnmsgr-sessionclosebody"); | |
180 msn_slplink_unleash(slpcall->slplink); | |
181 msn_slp_call_destroy(slpcall); | |
182 } | |
183 | |
184 MsnSlpCall * | |
185 msn_slp_process_msg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg) | |
186 { | |
187 MsnSlpCall *slpcall; | |
188 const char *body; | |
189 gsize body_len; | |
190 | |
191 slpcall = NULL; | |
192 body = slpmsg->buffer; | |
193 body_len = slpmsg->size; | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
194 |
9193 | 195 if (slpmsg->flags == 0x0) |
196 { | |
197 slpcall = msn_slp_sip_recv(slplink, body, body_len); | |
198 } | |
199 else if (slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030) | |
200 { | |
201 slpcall = msn_slplink_find_slp_call_with_session_id(slplink, slpmsg->session_id); | |
202 | |
203 if (slpcall != NULL) | |
204 slpcall->cb(slpcall, body, body_len); | |
205 } | |
206 #if 0 | |
207 else if (slpmsg->flags == 0x100) | |
208 { | |
209 slpcall = slplink->directconn->initial_call; | |
210 | |
211 if (slpcall != NULL) | |
212 msn_slp_call_session_init(slpcall); | |
213 } | |
214 #endif | |
215 | |
216 return slpcall; | |
217 } |