Mercurial > pidgin
annotate src/protocols/msn/session.c @ 8830:f8038b1f7449
[gaim-migrate @ 9594]
Patch by Daniel Atallah to prevent passing NULL to a vsprintf, which was
causing gaim to exit (but not crash, for some reason).
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 27 Apr 2004 02:33:29 +0000 |
parents | bbd8cdaf0ad5 |
children | ffecda0c1f45 |
rev | line source |
---|---|
5309 | 1 /** |
2 * @file session.c MSN session functions | |
3 * | |
4 * gaim | |
5 * | |
8475
06f57183e29f
[gaim-migrate @ 9208]
Christian Hammond <chipx86@chipx86.com>
parents:
8171
diff
changeset
|
6 * Copyright (C) 2003-2004 Christian Hammond <chipx86@gnupdate.org> |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
7 * |
5309 | 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 */ | |
22 #include "msn.h" | |
23 #include "session.h" | |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
24 #include "notification.h" |
5309 | 25 |
26 MsnSession * | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
27 msn_session_new(GaimAccount *account, const char *server, int port) |
5309 | 28 { |
29 MsnSession *session; | |
30 | |
31 g_return_val_if_fail(account != NULL, NULL); | |
32 | |
33 session = g_new0(MsnSession, 1); | |
34 | |
35 session->account = account; | |
36 session->dispatch_server = g_strdup(server); | |
37 session->dispatch_port = port; | |
38 | |
7590
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
39 session->away_state = NULL; |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
40 |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5427
diff
changeset
|
41 session->users = msn_users_new(); |
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5427
diff
changeset
|
42 session->groups = msn_groups_new(); |
5309 | 43 |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6726
diff
changeset
|
44 #ifdef HAVE_SSL |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
45 session->protocol_ver = 9; |
6726
3c234b619685
[gaim-migrate @ 7253]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
46 #else |
3c234b619685
[gaim-migrate @ 7253]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
47 session->protocol_ver = 7; |
3c234b619685
[gaim-migrate @ 7253]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
48 #endif |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
49 |
5309 | 50 return session; |
51 } | |
52 | |
53 void | |
54 msn_session_destroy(MsnSession *session) | |
55 { | |
56 g_return_if_fail(session != NULL); | |
57 | |
58 if (session->connected) | |
59 msn_session_disconnect(session); | |
60 | |
61 if (session->dispatch_server != NULL) | |
62 g_free(session->dispatch_server); | |
63 | |
64 while (session->switches != NULL) | |
65 msn_switchboard_destroy(session->switches->data); | |
66 | |
67 while (session->lists.forward) | |
8661
060171053a32
[gaim-migrate @ 9413]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
68 { |
060171053a32
[gaim-migrate @ 9413]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
69 MsnUser *user = (MsnUser *)session->lists.forward->data; |
060171053a32
[gaim-migrate @ 9413]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
70 |
060171053a32
[gaim-migrate @ 9413]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
71 msn_user_destroy(user); |
060171053a32
[gaim-migrate @ 9413]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
72 |
060171053a32
[gaim-migrate @ 9413]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
73 session->lists.forward = g_slist_remove(session->lists.forward, user); |
060171053a32
[gaim-migrate @ 9413]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
74 } |
5309 | 75 |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
76 if (session->lists.allow != NULL) |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
77 g_slist_free(session->lists.allow); |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
78 |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
79 if (session->lists.block != NULL) |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
80 g_slist_free(session->lists.block); |
5309 | 81 |
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5427
diff
changeset
|
82 msn_groups_destroy(session->groups); |
5309 | 83 msn_users_destroy(session->users); |
84 | |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
85 if (session->passport_info.kv != NULL) |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
86 g_free(session->passport_info.kv); |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
87 |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
88 if (session->passport_info.sid != NULL) |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
89 g_free(session->passport_info.sid); |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
90 |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
91 if (session->passport_info.mspauth != NULL) |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
92 g_free(session->passport_info.mspauth); |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
93 |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
94 if (session->passport_info.file != NULL) |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
95 g_free(session->passport_info.file); |
5427 | 96 |
7590
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
97 if (session->away_state != NULL) |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
98 g_free(session->away_state); |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
99 |
8171
d0ba2f7b40e7
[gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
100 if (session->nexus != NULL) |
d0ba2f7b40e7
[gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
101 msn_nexus_destroy(session->nexus); |
d0ba2f7b40e7
[gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
102 |
5309 | 103 g_free(session); |
104 } | |
105 | |
106 gboolean | |
107 msn_session_connect(MsnSession *session) | |
108 { | |
109 g_return_val_if_fail(session != NULL, FALSE); | |
110 g_return_val_if_fail(!session->connected, TRUE); | |
111 | |
112 session->connected = TRUE; | |
113 | |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
114 if (session->http_method) |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
115 { |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
116 session->notification_conn = msn_notification_new(session); |
5309 | 117 |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
118 if (msn_notification_connect(session->notification_conn, |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
119 "gateway.messenger.hotmail.com", 80)) |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
120 { |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
121 return TRUE; |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
122 } |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
123 } |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
124 else |
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
125 { |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
126 session->notification_conn = msn_notification_new(session); |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
127 |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
128 if (msn_notification_connect(session->notification_conn, |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
129 session->dispatch_server, |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
130 session->dispatch_port)) |
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
131 { |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
132 return TRUE; |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
133 } |
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
134 } |
5309 | 135 |
136 return FALSE; | |
137 } | |
138 | |
139 void | |
140 msn_session_disconnect(MsnSession *session) | |
141 { | |
142 g_return_if_fail(session != NULL); | |
143 g_return_if_fail(session->connected); | |
144 | |
145 while (session->switches != NULL) { | |
146 MsnSwitchBoard *board = (MsnSwitchBoard *)session->switches->data; | |
147 | |
148 msn_switchboard_destroy(board); | |
149 } | |
150 | |
151 if (session->notification_conn != NULL) { | |
152 msn_servconn_destroy(session->notification_conn); | |
153 session->notification_conn = NULL; | |
154 } | |
155 } | |
156 | |
157 MsnSwitchBoard * | |
158 msn_session_open_switchboard(MsnSession *session) | |
159 { | |
160 MsnSwitchBoard *swboard; | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
161 MsnCmdProc *cmdproc; |
5309 | 162 |
163 g_return_val_if_fail(session != NULL, NULL); | |
164 | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
165 cmdproc = session->notification_conn->cmdproc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
166 |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
167 msn_cmdproc_send(cmdproc, "XFR", "%s", "SB"); |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
168 |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
169 if (cmdproc->error) |
5309 | 170 return NULL; |
171 | |
172 swboard = msn_switchboard_new(session); | |
173 | |
174 return swboard; | |
175 } | |
176 | |
7590
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
177 gboolean |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
178 msn_session_change_status(MsnSession *session, const char *state) |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
179 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
180 MsnCmdProc *cmdproc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
181 MsnUser *user; |
7590
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
182 MsnObject *msnobj; |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
183 |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
184 g_return_val_if_fail(session != NULL, FALSE); |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
185 g_return_val_if_fail(state != NULL, FALSE); |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
186 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
187 user = session->user; |
7590
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
188 msnobj = msn_user_get_object(user); |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
189 |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
190 if (state != session->away_state) |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
191 { |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
192 if (session->away_state != NULL) |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
193 g_free(session->away_state); |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
194 |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
195 session->away_state = g_strdup(state); |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
196 } |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
197 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
198 cmdproc = session->notification_conn->cmdproc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
199 |
7590
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
200 if (msnobj == NULL) |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
201 { |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
202 msn_cmdproc_send(cmdproc, "CHG", "%s %d", state, MSN_CLIENT_ID); |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
203 } |
7590
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
204 else |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
205 { |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
206 char *msnobj_str = msn_object_to_string(msnobj); |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
207 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
208 msn_cmdproc_send(cmdproc, "CHG", "%s %d %s", state, MSN_CLIENT_ID, |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8661
diff
changeset
|
209 gaim_url_encode(msnobj_str)); |
7590
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
210 |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
211 g_free(msnobj_str); |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
212 } |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
213 |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
214 return TRUE; |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
215 } |
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
216 |
5309 | 217 MsnSwitchBoard * |
218 msn_session_find_switch_with_passport(const MsnSession *session, | |
219 const char *passport) | |
220 { | |
221 GList *l; | |
222 MsnSwitchBoard *swboard; | |
223 | |
224 g_return_val_if_fail(session != NULL, NULL); | |
225 g_return_val_if_fail(passport != NULL, NULL); | |
226 | |
8499
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
227 for (l = session->switches; l != NULL; l = l->next) |
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
228 { |
5309 | 229 swboard = (MsnSwitchBoard *)l->data; |
230 | |
8499
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
231 if (!swboard->hidden && !swboard->chat_id && |
5351
2aa7e4237142
[gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
232 !g_ascii_strcasecmp(passport, |
8499
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
233 msn_user_get_passport(swboard->user))) |
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
234 { |
5309 | 235 return swboard; |
236 } | |
237 } | |
238 | |
239 return NULL; | |
240 } | |
241 | |
242 MsnSwitchBoard * | |
243 msn_session_find_switch_with_id(const MsnSession *session, int chat_id) | |
244 { | |
245 GList *l; | |
246 MsnSwitchBoard *swboard; | |
247 | |
248 g_return_val_if_fail(session != NULL, NULL); | |
249 g_return_val_if_fail(chat_id > 0, NULL); | |
250 | |
251 for (l = session->switches; l != NULL; l = l->next) { | |
252 swboard = (MsnSwitchBoard *)l->data; | |
253 | |
254 if (swboard->chat_id == chat_id) | |
255 return swboard; | |
256 } | |
257 | |
258 return NULL; | |
259 } | |
260 | |
261 MsnSwitchBoard * | |
262 msn_session_find_unused_switch(const MsnSession *session) | |
263 { | |
264 GList *l; | |
265 MsnSwitchBoard *swboard; | |
266 | |
267 g_return_val_if_fail(session != NULL, NULL); | |
268 | |
269 for (l = session->switches; l != NULL; l = l->next) { | |
270 swboard = (MsnSwitchBoard *)l->data; | |
271 | |
5354
8a74fbcb7bcb
[gaim-migrate @ 5730]
Christian Hammond <chipx86@chipx86.com>
parents:
5351
diff
changeset
|
272 if (!swboard->in_use) |
5309 | 273 return swboard; |
274 } | |
275 | |
276 return NULL; | |
277 } |