annotate src/protocols/msn/session.c @ 11464:610a243b4504

[gaim-migrate @ 13704] Fix Gaim's crash-on-exit bug in CVS HEAD committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 07 Sep 2005 04:37:02 +0000
parents 10066662176a
children c824e39db0e7
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 *
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.
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
9 *
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * 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
12 * the Free Software Foundation; either version 2 of the License, or
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * (at your option) any later version.
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * GNU General Public License for more details.
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 */
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #include "msn.h"
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include "session.h"
7288
ff9127038a5a [gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents: 6827
diff changeset
26 #include "notification.h"
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27
10044
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
28 #include "dialog.h"
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
29
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 MsnSession *
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
31 msn_session_new(GaimAccount *account)
5309
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 MsnSession *session;
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 g_return_val_if_fail(account != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 session = g_new0(MsnSession, 1);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
39 session->account = account;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
40 session->notification = msn_notification_new(session);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
41 session->userlist = msn_userlist_new(session);
10044
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
42 session->sync_userlist = msn_userlist_new(session);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
43
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
44 session->user = msn_user_new(session->userlist,
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
45 gaim_account_get_username(account), NULL);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
46
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
47 session->protocol_ver = 9;
10621
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
48 session->conv_seq = 1;
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
10296
a7b2fd5efcf2 [gaim-migrate @ 11476]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
58 session->destroying = TRUE;
a7b2fd5efcf2 [gaim-migrate @ 11476]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
59
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 if (session->connected)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 msn_session_disconnect(session);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
63 if (session->notification != NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
64 msn_notification_destroy(session->notification);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
65
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 while (session->switches != NULL)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 msn_switchboard_destroy(session->switches->data);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
69 while (session->slplinks != NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
70 msn_slplink_destroy(session->slplinks->data);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
72 msn_userlist_destroy(session->userlist);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73
10044
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
74 if (session->sync_userlist != NULL)
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
75 msn_userlist_destroy(session->sync_userlist);
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
76
6827
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6779
diff changeset
77 if (session->passport_info.kv != NULL)
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6779
diff changeset
78 g_free(session->passport_info.kv);
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6779
diff changeset
79
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6779
diff changeset
80 if (session->passport_info.sid != NULL)
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6779
diff changeset
81 g_free(session->passport_info.sid);
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6779
diff changeset
82
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6779
diff changeset
83 if (session->passport_info.mspauth != NULL)
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6779
diff changeset
84 g_free(session->passport_info.mspauth);
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6779
diff changeset
85
10284
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
86 if (session->passport_info.client_ip != NULL)
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
87 g_free(session->passport_info.client_ip);
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
88
6827
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6779
diff changeset
89 if (session->passport_info.file != NULL)
10275
d9468bd22b7c [gaim-migrate @ 11428]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10225
diff changeset
90 {
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10582
diff changeset
91 g_unlink(session->passport_info.file);
6827
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6779
diff changeset
92 g_free(session->passport_info.file);
10275
d9468bd22b7c [gaim-migrate @ 11428]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10225
diff changeset
93 }
5427
04e1e40b99b0 [gaim-migrate @ 5806]
Mark Doliner <mark@kingant.net>
parents: 5354
diff changeset
94
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
95 if (session->sync != NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
96 msn_sync_destroy(session->sync);
7590
3a48ade4f510 [gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents: 7288
diff changeset
97
8171
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents: 7590
diff changeset
98 if (session->nexus != NULL)
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents: 7590
diff changeset
99 msn_nexus_destroy(session->nexus);
d0ba2f7b40e7 [gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents: 7590
diff changeset
100
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
101 if (session->user != NULL)
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
102 msn_user_destroy(session->user);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
103
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 g_free(session);
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 gboolean
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
108 msn_session_connect(MsnSession *session, const char *host, int port,
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
109 gboolean http_method)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 g_return_val_if_fail(session != NULL, FALSE);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 g_return_val_if_fail(!session->connected, TRUE);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 session->connected = TRUE;
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
115 session->http_method = http_method;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116
10463
9bed28273ec7 [gaim-migrate @ 11737]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
117 if (session->notification == NULL)
9bed28273ec7 [gaim-migrate @ 11737]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
118 {
9bed28273ec7 [gaim-migrate @ 11737]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
119 gaim_debug_error("msn", "This shouldn't happen\n");
9bed28273ec7 [gaim-migrate @ 11737]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
120 g_return_val_if_reached(FALSE);
9bed28273ec7 [gaim-migrate @ 11737]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
121 }
9bed28273ec7 [gaim-migrate @ 11737]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
122
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
123 if (msn_notification_connect(session->notification, host, port))
8831
ffecda0c1f45 [gaim-migrate @ 9595]
Christian Hammond <chipx86@chipx86.com>
parents: 8808
diff changeset
124 {
ffecda0c1f45 [gaim-migrate @ 9595]
Christian Hammond <chipx86@chipx86.com>
parents: 8808
diff changeset
125 return TRUE;
7288
ff9127038a5a [gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents: 6827
diff changeset
126 }
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 return FALSE;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 msn_session_disconnect(MsnSession *session)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 g_return_if_fail(session != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 g_return_if_fail(session->connected);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
137 session->connected = FALSE;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
138
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 8831
diff changeset
139 while (session->switches != NULL)
10463
9bed28273ec7 [gaim-migrate @ 11737]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
140 msn_switchboard_close(session->switches->data);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
142 if (session->notification != NULL)
10463
9bed28273ec7 [gaim-migrate @ 11737]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
143 msn_notification_close(session->notification);
5309
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
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
146 /* TODO: This must go away when conversation is redesigned */
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 MsnSwitchBoard *
10621
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
148 msn_session_find_swboard(MsnSession *session, const char *username)
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 GList *l;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 8831
diff changeset
152 g_return_val_if_fail(session != NULL, NULL);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
153 g_return_val_if_fail(username != NULL, NULL);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154
8499
467b01d02f9c [gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
155 for (l = session->switches; l != NULL; l = l->next)
467b01d02f9c [gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
156 {
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
157 MsnSwitchBoard *swboard;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
158
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
159 swboard = l->data;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160
10621
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
161 if ((swboard->im_user != NULL) && !strcmp(username, swboard->im_user))
10602
f52ab405f1ab [gaim-migrate @ 12032]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10589
diff changeset
162 return swboard;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168 MsnSwitchBoard *
10621
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
169 msn_session_find_swboard_with_conv(MsnSession *session, GaimConversation *conv)
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
170 {
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
171 GList *l;
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
172
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
173 g_return_val_if_fail(session != NULL, NULL);
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
174 g_return_val_if_fail(conv != NULL, NULL);
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
175
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
176 for (l = session->switches; l != NULL; l = l->next)
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
177 {
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
178 MsnSwitchBoard *swboard;
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
179
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
180 swboard = l->data;
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
181
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
182 if (swboard->conv == conv)
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
183 return swboard;
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
184 }
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
185
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
186 return NULL;
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
187 }
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
188
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
189 MsnSwitchBoard *
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
190 msn_session_find_swboard_with_id(const MsnSession *session, int chat_id)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 GList *l;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 g_return_val_if_fail(session != NULL, NULL);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
195 g_return_val_if_fail(chat_id >= 0, NULL);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 8831
diff changeset
197 for (l = session->switches; l != NULL; l = l->next)
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 8831
diff changeset
198 {
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
199 MsnSwitchBoard *swboard;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
200
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
201 swboard = l->data;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202
10621
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
203 if (swboard->chat_id == chat_id)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 return swboard;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 return NULL;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 MsnSwitchBoard *
10773
888d4c328be5 [gaim-migrate @ 12382]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
211 msn_session_get_swboard(MsnSession *session, const char *username,
888d4c328be5 [gaim-migrate @ 12382]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
212 MsnSBFlag flag)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 MsnSwitchBoard *swboard;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215
10621
fe919915fceb [gaim-migrate @ 12090]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10602
diff changeset
216 swboard = msn_session_find_swboard(session, username);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
218 if (swboard == NULL)
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 8831
diff changeset
219 {
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
220 swboard = msn_switchboard_new(session);
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
221 swboard->im_user = g_strdup(username);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
222 msn_switchboard_request(swboard);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
223 msn_switchboard_request_add_user(swboard, username);
5309
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
10773
888d4c328be5 [gaim-migrate @ 12382]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
226 swboard->flag |= flag;
888d4c328be5 [gaim-migrate @ 12382]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
227
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
228 return swboard;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 }
10044
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
230
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
231 static void
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
232 msn_session_sync_users(MsnSession *session)
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
233 {
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
234 GList *l;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
235
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
236 l = session->sync_userlist->users;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
237
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
238 while (l != NULL)
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
239 {
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
240 MsnUser *local_user;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
241
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
242 local_user = (MsnUser *)l->data;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
243
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
244 if (local_user->passport != NULL)
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
245 {
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
246 MsnUser *remote_user;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
247
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
248 remote_user = msn_userlist_find_user(session->userlist,
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
249 local_user->passport);
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
250
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
251 if (remote_user == NULL ||
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
252 ((local_user->list_op & ( 1 << MSN_LIST_FL)) &&
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
253 !(remote_user->list_op & ( 1 << MSN_LIST_FL))))
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
254 {
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
255 /* The user was not on the server list */
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
256 msn_show_sync_issue(session, local_user->passport, NULL);
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
257 }
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
258 else
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
259 {
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
260 GList *l;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
261
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
262 for (l = local_user->group_ids; l != NULL; l = l->next)
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
263 {
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
264 const char *group_name;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
265 int gid;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
266 gboolean found = FALSE;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
267 GList *l2;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
268
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
269 group_name =
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
270 msn_userlist_find_group_name(local_user->userlist,
10112
1a91e814e9d8 [gaim-migrate @ 11145]
Nathan Walp <nwalp@pidgin.im>
parents: 10044
diff changeset
271 GPOINTER_TO_INT(l->data));
10044
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
272
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
273 gid = msn_userlist_find_group_id(remote_user->userlist,
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
274 group_name);
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
275
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
276 for (l2 = remote_user->group_ids; l2 != NULL; l2 = l2->next)
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
277 {
10112
1a91e814e9d8 [gaim-migrate @ 11145]
Nathan Walp <nwalp@pidgin.im>
parents: 10044
diff changeset
278 if (GPOINTER_TO_INT(l2->data) == gid)
10044
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
279 {
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
280 found = TRUE;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
281 break;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
282 }
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
283 }
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
284
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
285 if (!found)
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
286 {
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
287 /* The user was not on that group on the server list */
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
288 msn_show_sync_issue(session, local_user->passport,
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
289 group_name);
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
290 }
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
291 }
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
292 }
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
293 }
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
294
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
295 l = l->next;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
296 }
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
297
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
298 msn_userlist_destroy(session->sync_userlist);
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
299 session->sync_userlist = NULL;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
300 }
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
301
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
302 void
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
303 msn_session_set_error(MsnSession *session, MsnErrorType error,
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
304 const char *info)
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
305 {
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
306 GaimConnection *gc;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
307 char *msg;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
308
10568
fed2a7c2471d [gaim-migrate @ 11954]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10533
diff changeset
309 gc = gaim_account_get_connection(session->account);
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
310
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
311 switch (error)
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
312 {
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
313 case MSN_ERROR_SERVCONN:
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
314 msg = g_strdup(info);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
315 break;
10519
bec9130b24d2 [gaim-migrate @ 11833]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10514
diff changeset
316 case MSN_ERROR_UNSUPPORTED_PROTOCOL:
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
317 msg = g_strdup(_("Our protocol is not supported by the "
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
318 "server."));
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
319 break;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
320 case MSN_ERROR_HTTP_MALFORMED:
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
321 msg = g_strdup(_("Error parsing HTTP."));
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
322 break;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
323 case MSN_ERROR_SIGN_OTHER:
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
324 gc->wants_to_die = TRUE;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
325 msg = g_strdup(_("You have signed on from another location."));
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
326 break;
10568
fed2a7c2471d [gaim-migrate @ 11954]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10533
diff changeset
327 case MSN_ERROR_SERV_UNAVAILABLE:
fed2a7c2471d [gaim-migrate @ 11954]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10533
diff changeset
328 msg = g_strdup(_("The MSN servers are temporarily "
fed2a7c2471d [gaim-migrate @ 11954]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10533
diff changeset
329 "unavailable. Please wait and try "
fed2a7c2471d [gaim-migrate @ 11954]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10533
diff changeset
330 "again."));
fed2a7c2471d [gaim-migrate @ 11954]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10533
diff changeset
331 break;
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
332 case MSN_ERROR_SERV_DOWN:
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
333 msg = g_strdup(_("The MSN servers are going down "
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
334 "temporarily."));
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
335 break;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
336 case MSN_ERROR_AUTH:
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
337 msg = g_strdup_printf(_("Unable to authenticate: %s"),
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
338 (info == NULL ) ?
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
339 _("Unknown error") : info);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
340 break;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
341 case MSN_ERROR_BAD_BLIST:
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
342 msg = g_strdup(_("Your MSN buddy list is temporarily "
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
343 "unavailable. Please wait and try "
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
344 "again."));
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
345 break;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
346 default:
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
347 msg = g_strdup(_("Unknown error."));
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
348 break;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
349 }
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
350
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
351 msn_session_disconnect(session);
10533
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10519
diff changeset
352
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
353 gaim_connection_error(gc, msg);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
354
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
355 g_free(msg);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
356 }
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
357
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
358 static const char *
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
359 get_login_step_text(MsnSession *session)
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
360 {
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
361 const char *steps_text[] = {
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
362 _("Connecting"),
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
363 _("Handshaking"),
10514
8f1316d77315 [gaim-migrate @ 11814]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
364 _("Transferring"),
8f1316d77315 [gaim-migrate @ 11814]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
365 _("Handshaking"),
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
366 _("Starting authentication"),
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
367 _("Getting cookie"),
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
368 _("Authenticating"),
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
369 _("Sending cookie"),
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
370 _("Retrieving buddy list")
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
371 };
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
372
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
373 return steps_text[session->login_step];
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
374 }
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
375
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
376 void
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
377 msn_session_set_login_step(MsnSession *session, MsnLoginStep step)
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
378 {
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
379 GaimConnection *gc;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
380
10519
bec9130b24d2 [gaim-migrate @ 11833]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10514
diff changeset
381 /* Prevent the connection progress going backwards, eg. if we get
bec9130b24d2 [gaim-migrate @ 11833]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10514
diff changeset
382 * transferred several times during login */
10582
b953704d4d6c [gaim-migrate @ 11983]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10568
diff changeset
383 if (session->login_step > step)
10519
bec9130b24d2 [gaim-migrate @ 11833]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10514
diff changeset
384 return;
bec9130b24d2 [gaim-migrate @ 11833]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10514
diff changeset
385
bec9130b24d2 [gaim-migrate @ 11833]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10514
diff changeset
386 /* If we're already logged in, we're probably here because of a
bec9130b24d2 [gaim-migrate @ 11833]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10514
diff changeset
387 * mid-session XFR from the notification server, so we don't want to
bec9130b24d2 [gaim-migrate @ 11833]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10514
diff changeset
388 * popup the connection progress dialog */
bec9130b24d2 [gaim-migrate @ 11833]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10514
diff changeset
389 if (session->logged_in)
bec9130b24d2 [gaim-migrate @ 11833]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10514
diff changeset
390 return;
bec9130b24d2 [gaim-migrate @ 11833]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10514
diff changeset
391
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
392 gc = session->account->gc;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
393
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
394 session->login_step = step;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
395
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
396 gaim_connection_update_progress(gc, get_login_step_text(session), step,
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
397 MSN_LOGIN_STEPS);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
398 }
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
399
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10463
diff changeset
400 void
10044
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
401 msn_session_finish_login(MsnSession *session)
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
402 {
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
403 GaimAccount *account;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
404 GaimConnection *gc;
11303
10066662176a [gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents: 10908
diff changeset
405 char *icon;
10044
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
406
10533
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10519
diff changeset
407 if (session->logged_in)
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10519
diff changeset
408 return;
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10519
diff changeset
409
10044
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
410 account = session->account;
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
411 gc = gaim_account_get_connection(account);
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
412
11303
10066662176a [gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents: 10908
diff changeset
413 icon = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(session->account));
10066662176a [gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents: 10908
diff changeset
414 msn_user_set_buddy_icon(session->user, icon);
10066662176a [gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents: 10908
diff changeset
415 g_free(icon);
10044
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
416
10908
0317ad172e8d [gaim-migrate @ 12640]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10773
diff changeset
417 session->logged_in = TRUE;
0317ad172e8d [gaim-migrate @ 12640]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10773
diff changeset
418
0317ad172e8d [gaim-migrate @ 12640]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10773
diff changeset
419 msn_change_status(session, session->state == 0 ? MSN_ONLINE : session->state);
10044
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
420
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
421 gaim_connection_set_state(gc, GAIM_CONNECTED);
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
422
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
423 /* Sync users */
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
424 msn_session_sync_users(session);
86a6d78b070b [gaim-migrate @ 11003]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
425 }