annotate src/protocols/msn/session.c @ 9098:9ebde9d3a622

[gaim-migrate @ 9875] (19:41:44) stu|laptop: oh... LSchiere: would it be good to include ChangeLog.API in EXTRA_DIST? committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 27 May 2004 23:55:27 +0000
parents ffecda0c1f45
children c30d81b4dd22
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
8831
ffecda0c1f45 [gaim-migrate @ 9595]
Christian Hammond <chipx86@chipx86.com>
parents: 8808
diff changeset
114 session->notification_conn = msn_notification_new(session);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115
8831
ffecda0c1f45 [gaim-migrate @ 9595]
Christian Hammond <chipx86@chipx86.com>
parents: 8808
diff changeset
116 if (msn_notification_connect(session->notification_conn,
8583
fc27237783ee [gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents: 8499
diff changeset
117 session->dispatch_server,
fc27237783ee [gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents: 8499
diff changeset
118 session->dispatch_port))
8831
ffecda0c1f45 [gaim-migrate @ 9595]
Christian Hammond <chipx86@chipx86.com>
parents: 8808
diff changeset
119 {
ffecda0c1f45 [gaim-migrate @ 9595]
Christian Hammond <chipx86@chipx86.com>
parents: 8808
diff changeset
120 return TRUE;
7288
ff9127038a5a [gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents: 6827
diff changeset
121 }
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 return FALSE;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 msn_session_disconnect(MsnSession *session)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 g_return_if_fail(session != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 g_return_if_fail(session->connected);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 while (session->switches != NULL) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 MsnSwitchBoard *board = (MsnSwitchBoard *)session->switches->data;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 msn_switchboard_destroy(board);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 }
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 if (session->notification_conn != NULL) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 msn_servconn_destroy(session->notification_conn);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 session->notification_conn = NULL;
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 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 MsnSwitchBoard *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 msn_session_open_switchboard(MsnSession *session)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 MsnSwitchBoard *swboard;
8808
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
148 MsnCmdProc *cmdproc;
5309
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 g_return_val_if_fail(session != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151
8808
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
152 cmdproc = session->notification_conn->cmdproc;
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
153
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
154 msn_cmdproc_send(cmdproc, "XFR", "%s", "SB");
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
155
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
156 if (cmdproc->error)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 swboard = msn_switchboard_new(session);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 return swboard;
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
7590
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
164 gboolean
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
165 msn_session_change_status(MsnSession *session, const char *state)
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
166 {
8808
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
167 MsnCmdProc *cmdproc;
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
168 MsnUser *user;
7590
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
169 MsnObject *msnobj;
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
170
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
171 g_return_val_if_fail(session != NULL, FALSE);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
172 g_return_val_if_fail(state != NULL, FALSE);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
173
8808
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
174 user = session->user;
7590
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
175 msnobj = msn_user_get_object(user);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
176
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
177 if (state != session->away_state)
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
178 {
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
179 if (session->away_state != NULL)
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
180 g_free(session->away_state);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
181
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
182 session->away_state = g_strdup(state);
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
8808
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
185 cmdproc = session->notification_conn->cmdproc;
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
186
7590
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
187 if (msnobj == NULL)
8808
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
188 {
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
189 msn_cmdproc_send(cmdproc, "CHG", "%s %d", state, MSN_CLIENT_ID);
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
190 }
7590
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
191 else
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
192 {
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
193 char *msnobj_str = msn_object_to_string(msnobj);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
194
8808
bbd8cdaf0ad5 [gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents: 8661
diff changeset
195 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
196 gaim_url_encode(msnobj_str));
7590
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
197
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
198 g_free(msnobj_str);
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
199 }
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
200
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
201 return TRUE;
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
202 }
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
203
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 MsnSwitchBoard *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 msn_session_find_switch_with_passport(const MsnSession *session,
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 const char *passport)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 GList *l;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 MsnSwitchBoard *swboard;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 g_return_val_if_fail(session != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 g_return_val_if_fail(passport != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213
8499
467b01d02f9c [gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
214 for (l = session->switches; l != NULL; l = l->next)
467b01d02f9c [gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
215 {
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 swboard = (MsnSwitchBoard *)l->data;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217
8499
467b01d02f9c [gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
218 if (!swboard->hidden && !swboard->chat_id &&
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents: 5318
diff changeset
219 !g_ascii_strcasecmp(passport,
8499
467b01d02f9c [gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
220 msn_user_get_passport(swboard->user)))
467b01d02f9c [gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
221 {
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 return 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 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 MsnSwitchBoard *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 msn_session_find_switch_with_id(const MsnSession *session, int chat_id)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 GList *l;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 MsnSwitchBoard *swboard;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 g_return_val_if_fail(session != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 g_return_val_if_fail(chat_id > 0, NULL);
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 for (l = session->switches; l != NULL; l = l->next) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239 swboard = (MsnSwitchBoard *)l->data;
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 if (swboard->chat_id == chat_id)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242 return swboard;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 }
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 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 }
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 MsnSwitchBoard *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 msn_session_find_unused_switch(const MsnSession *session)
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 GList *l;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 MsnSwitchBoard *swboard;
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 g_return_val_if_fail(session != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 for (l = session->switches; l != NULL; l = l->next) {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257 swboard = (MsnSwitchBoard *)l->data;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258
5354
8a74fbcb7bcb [gaim-migrate @ 5730]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
259 if (!swboard->in_use)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 return swboard;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 }