Mercurial > pidgin.yaz
annotate src/protocols/msn/slpcall.c @ 9686:882e7e423457
[gaim-migrate @ 10538]
[ 837502 ] 0.72 tooltip shadows render incorrectly
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Thu, 05 Aug 2004 23:04:16 +0000 |
parents | f5f7482678d2 |
children | 3a701f15e45d |
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 char *branch; | |
140 | |
141 g_return_if_fail(slpcall != NULL); | |
142 g_return_if_fail(context != NULL); | |
143 | |
144 slplink = slpcall->slplink; | |
145 | |
146 branch = rand_guid(); | |
147 | |
148 content = g_strdup_printf( | |
149 "EUF-GUID: {%s}\r\n" | |
150 "SessionID: %lu\r\n" | |
151 "AppID: %d\r\n" | |
152 "Context: %s\r\n\r\n", | |
153 euf_guid, | |
154 slpcall->session_id, | |
155 app_id, | |
156 context); | |
157 | |
158 header = g_strdup_printf("INVITE MSNMSGR:%s MSNSLP/1.0", | |
159 slplink->remote_user); | |
160 | |
161 slpmsg = msn_slpmsg_sip_new(slpcall, 0, header, branch, | |
162 "application/x-msnmsgr-sessionreqbody", content); | |
163 #ifdef DEBUG_SLP | |
164 slpmsg->info = "SLP INVITE"; | |
165 slpmsg->text_body = TRUE; | |
166 #endif | |
167 | |
168 msn_slplink_send_slpmsg(slplink, slpmsg); | |
169 | |
170 g_free(header); | |
171 g_free(content); | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
172 |
9193 | 173 g_free(branch); |
174 } | |
175 | |
176 void | |
177 msn_slp_call_close(MsnSlpCall *slpcall) | |
178 { | |
179 g_return_if_fail(slpcall != NULL); | |
180 g_return_if_fail(slpcall->slplink != NULL); | |
181 | |
182 send_bye(slpcall, "application/x-msnmsgr-sessionclosebody"); | |
183 msn_slplink_unleash(slpcall->slplink); | |
184 msn_slp_call_destroy(slpcall); | |
185 } | |
186 | |
187 MsnSlpCall * | |
188 msn_slp_process_msg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg) | |
189 { | |
190 MsnSlpCall *slpcall; | |
191 const char *body; | |
192 gsize body_len; | |
193 | |
194 slpcall = NULL; | |
195 body = slpmsg->buffer; | |
196 body_len = slpmsg->size; | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
197 |
9193 | 198 if (slpmsg->flags == 0x0) |
199 { | |
200 slpcall = msn_slp_sip_recv(slplink, body, body_len); | |
201 } | |
202 else if (slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030) | |
203 { | |
204 slpcall = msn_slplink_find_slp_call_with_session_id(slplink, slpmsg->session_id); | |
205 | |
206 if (slpcall != NULL) | |
207 slpcall->cb(slpcall, body, body_len); | |
208 } | |
209 #if 0 | |
210 else if (slpmsg->flags == 0x100) | |
211 { | |
212 slpcall = slplink->directconn->initial_call; | |
213 | |
214 if (slpcall != NULL) | |
215 msn_slp_call_session_init(slpcall); | |
216 } | |
217 #endif | |
218 | |
219 return slpcall; | |
220 } |