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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file session.c MSN session functions
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 * gaim
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * (at your option) any later version.
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * GNU General Public License for more details.
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 */
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 #include "msn.h"
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 #include "session.h"
7288
ff9127038a5a [gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents: 6827
diff changeset
24 #include "notification.h"
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 MsnSession *session;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 g_return_val_if_fail(account != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 session = g_new0(MsnSession, 1);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 session->account = account;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 session->dispatch_server = g_strdup(server);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 session->dispatch_port = port;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 return session;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 msn_session_destroy(MsnSession *session)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 g_return_if_fail(session != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 if (session->connected)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 msn_session_disconnect(session);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 if (session->dispatch_server != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 g_free(session->dispatch_server);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 while (session->switches != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 msn_switchboard_destroy(session->switches->data);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81
5518
bf2a7a7b739d [gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents: 5427
diff changeset
82 msn_groups_destroy(session->groups);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 msn_users_destroy(session->users);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
04e1e40b99b0 [gaim-migrate @ 5806]
Mark Doliner <mark@kingant.net>
parents: 5354
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 g_free(session);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 gboolean
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 msn_session_connect(MsnSession *session)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 g_return_val_if_fail(session != NULL, FALSE);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 g_return_val_if_fail(!session->connected, TRUE);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 session->connected = TRUE;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 return FALSE;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 msn_session_disconnect(MsnSession *session)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 g_return_if_fail(session != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 g_return_if_fail(session->connected);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 while (session->switches != NULL) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 MsnSwitchBoard *board = (MsnSwitchBoard *)session->switches->data;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 msn_switchboard_destroy(board);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 if (session->notification_conn != NULL) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 msn_servconn_destroy(session->notification_conn);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 session->notification_conn = NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 MsnSwitchBoard *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 msn_session_open_switchboard(MsnSession *session)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 MsnSwitchBoard *swboard;
8808
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
161 MsnCmdProc *cmdproc;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 g_return_val_if_fail(session != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 swboard = msn_switchboard_new(session);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 return swboard;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 MsnSwitchBoard *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 msn_session_find_switch_with_passport(const MsnSession *session,
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 const char *passport)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 GList *l;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 MsnSwitchBoard *swboard;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 g_return_val_if_fail(session != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 g_return_val_if_fail(passport != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 swboard = (MsnSwitchBoard *)l->data;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 return swboard;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242 MsnSwitchBoard *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 msn_session_find_switch_with_id(const MsnSession *session, int chat_id)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 GList *l;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 MsnSwitchBoard *swboard;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 g_return_val_if_fail(session != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 g_return_val_if_fail(chat_id > 0, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 for (l = session->switches; l != NULL; l = l->next) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 swboard = (MsnSwitchBoard *)l->data;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 if (swboard->chat_id == chat_id)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255 return swboard;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 MsnSwitchBoard *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262 msn_session_find_unused_switch(const MsnSession *session)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 GList *l;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 MsnSwitchBoard *swboard;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 g_return_val_if_fail(session != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
268
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269 for (l = session->switches; l != NULL; l = l->next) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 swboard = (MsnSwitchBoard *)l->data;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271
5354
8a74fbcb7bcb [gaim-migrate @ 5730]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
272 if (!swboard->in_use)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273 return swboard;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277 }