Mercurial > pidgin
annotate src/protocols/msn/session.c @ 12645:fc28451f5d96
[gaim-migrate @ 14983]
SF Patch #1314512 from Sadrul (who has a patch for everything)
"This patch introduces a flag for protocol plugins that
support offline messages (like Y!M and ICQ). This was
encouraged by the following conversation:
<sadrul> should offline buddies be listed/enabled in
the send-to menu?
<rekkanoryo> i would think only for protocols that
support offline messaging, if it's indicated that the
buddy is offline
-- <snip> --
<Bleeter> sadrul: personally, I'd like to see a
'supports offline' flag of some description
<Bleeter> one could then redirect (via plugins) through
email or alternative methods
<Bleeter> just a thought
<Paco-Paco> yeah, that sounds like a reasonble thing to have
This patch uses this flag to disable the buddies in the
send-to menu who are offline and the protocol doesn't
support offline messages."
I made this make the label insensitive instead of the whole menuitem. This
should address SimGuy's concerns about inconsistency (i.e. you could create a
conversation with someone via the buddy list that you couldn't create via the
Send To menu). I also hacked up some voodoo to show the label as sensitive when
moused-over, as that looks better (given the label-insensitive thing is itself a
hack). I think this works quite well.
BUG NOTE:
This makes more obvious an existing bug. The Send To menu isn't updated when
buddies sign on or off or change status (at least under some circumstances).
We need to fix that anyway, so I'm not going to let it hold up this commit.
Switching tabs will clear it up. I'm thinking we just might want to build the
contents of that menu when it is selected. That would save us a mess of
inefficient signal callbacks that update the Send To menus in open windows all
the time.
AIM NOTE:
This assumes that AIM can't offline message. That's not strictly true. You can
message invisible users on AIM. However, by design, we can't tell when a user
is invisible without resorting to dirty hackery. In practice, this isn't a
problem, as you can still select the AIM user from the menu. And really, how
often will you be choosing the Invisible contact, rather than the user going
Invisible in the middle of a conversation or IMing you while they're Invisible?
JABBER NOTE:
This assumes that Jabber can always offline message. This isn't strictly true.
Sadrul said:
I have updated Jabber according to this link which seems to
talk about how to determine the existence offline-message
support in a server:
http://www.jabber.org/jeps/jep-0013.html#discover
However, jabber.org doesn't seem to send the required
info. So I am not sure about it.
He later said:
I talked to Nathan and he said offline message support is
mostly assumed for most jabber servers. GTalk doesn't yet
support it, but they are working on it. So I have made
jabber to always return TRUE.
If there is truly no way to detect offline messaging capability, then this is
an acceptable solution. We could special case Google Talk because of its
popularity, and remove that later. It's probably not worth it though.
MSN NOTE:
This assumes that MSN can never offline message. That's effectively true, but
to be technically correct, MSN can offline message if there's already a
switchboard conversation open with a user. We could write an offline_message
function in the MSN prpl to detect that, but it'd be of limited usefulness,
especially given that under most circumstances (where this might matter), the
switchboard connection will be closed almost immediately.
CVS NOTE:
I'm writing to share a tragic little story.
I have a PC that I use for Gaim development. One day, I was writing a commit
message on it, when all of a suddent it went berserk. The screen started
flashing, and the whole commit message just disappeared. All of it. And it was
a good commit message! I had to cram and rewrite it really quickly. Needless to
say, my rushed commit message wasn't nearly as good, and I blame the PC for that.
Seriously, though, what kind of version control system loses your commit
message on a broken connection to the server? Stupid!
committer: Tailor Script <tailor@pidgin.im>
| author | Richard Laager <rlaager@wiktel.com> |
|---|---|
| date | Fri, 23 Dec 2005 19:26:04 +0000 |
| parents | c824e39db0e7 |
| children | 8872789902a1 |
| rev | line source |
|---|---|
| 5309 | 1 /** |
| 2 * @file session.c MSN session functions | |
| 3 * | |
| 4 * gaim | |
| 5 * | |
|
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
6 * Gaim is the legal property of its developers, whose names are too numerous |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
8 * source distribution. |
|
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
9 * |
| 5309 | 10 * This program is free software; you can redistribute it and/or modify |
| 11 * it under the terms of the GNU General Public License as published by | |
| 12 * the Free Software Foundation; either version 2 of the License, or | |
| 13 * (at your option) any later version. | |
| 14 * | |
| 15 * This program is distributed in the hope that it will be useful, | |
| 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 * GNU General Public License for more details. | |
| 19 * | |
| 20 * You should have received a copy of the GNU General Public License | |
| 21 * along with this program; if not, write to the Free Software | |
| 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 23 */ | |
| 24 #include "msn.h" | |
| 25 #include "session.h" | |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
26 #include "notification.h" |
| 5309 | 27 |
| 10044 | 28 #include "dialog.h" |
| 29 | |
| 5309 | 30 MsnSession * |
| 10481 | 31 msn_session_new(GaimAccount *account) |
| 5309 | 32 { |
| 33 MsnSession *session; | |
| 34 | |
| 35 g_return_val_if_fail(account != NULL, NULL); | |
| 36 | |
| 37 session = g_new0(MsnSession, 1); | |
| 38 | |
| 10481 | 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); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
42 |
| 10481 | 43 session->user = msn_user_new(session->userlist, |
| 44 gaim_account_get_username(account), NULL); | |
| 45 | |
|
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
46 session->protocol_ver = 9; |
| 10621 | 47 session->conv_seq = 1; |
|
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
48 |
| 5309 | 49 return session; |
| 50 } | |
| 51 | |
| 52 void | |
| 53 msn_session_destroy(MsnSession *session) | |
| 54 { | |
| 55 g_return_if_fail(session != NULL); | |
| 56 | |
| 10296 | 57 session->destroying = TRUE; |
| 58 | |
| 5309 | 59 if (session->connected) |
| 60 msn_session_disconnect(session); | |
| 61 | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
62 if (session->notification != NULL) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
63 msn_notification_destroy(session->notification); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
64 |
| 5309 | 65 while (session->switches != NULL) |
| 66 msn_switchboard_destroy(session->switches->data); | |
| 67 | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
68 while (session->slplinks != NULL) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
69 msn_slplink_destroy(session->slplinks->data); |
| 5309 | 70 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
71 msn_userlist_destroy(session->userlist); |
| 5309 | 72 |
|
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
73 if (session->passport_info.kv != NULL) |
|
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
74 g_free(session->passport_info.kv); |
|
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
75 |
|
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
76 if (session->passport_info.sid != NULL) |
|
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
77 g_free(session->passport_info.sid); |
|
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->passport_info.mspauth != NULL) |
|
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
80 g_free(session->passport_info.mspauth); |
|
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
81 |
| 10284 | 82 if (session->passport_info.client_ip != NULL) |
| 83 g_free(session->passport_info.client_ip); | |
| 84 | |
|
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
85 if (session->passport_info.file != NULL) |
| 10275 | 86 { |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10582
diff
changeset
|
87 g_unlink(session->passport_info.file); |
|
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6779
diff
changeset
|
88 g_free(session->passport_info.file); |
| 10275 | 89 } |
| 5427 | 90 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
91 if (session->sync != NULL) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
92 msn_sync_destroy(session->sync); |
|
7590
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
93 |
|
8171
d0ba2f7b40e7
[gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
94 if (session->nexus != NULL) |
|
d0ba2f7b40e7
[gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
95 msn_nexus_destroy(session->nexus); |
|
d0ba2f7b40e7
[gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
7590
diff
changeset
|
96 |
| 10481 | 97 if (session->user != NULL) |
| 98 msn_user_destroy(session->user); | |
| 99 | |
| 5309 | 100 g_free(session); |
| 101 } | |
| 102 | |
| 103 gboolean | |
| 10481 | 104 msn_session_connect(MsnSession *session, const char *host, int port, |
| 105 gboolean http_method) | |
| 5309 | 106 { |
| 107 g_return_val_if_fail(session != NULL, FALSE); | |
| 108 g_return_val_if_fail(!session->connected, TRUE); | |
| 109 | |
| 110 session->connected = TRUE; | |
| 10481 | 111 session->http_method = http_method; |
| 5309 | 112 |
| 10463 | 113 if (session->notification == NULL) |
| 114 { | |
| 115 gaim_debug_error("msn", "This shouldn't happen\n"); | |
| 116 g_return_val_if_reached(FALSE); | |
| 117 } | |
| 118 | |
| 10481 | 119 if (msn_notification_connect(session->notification, host, port)) |
|
8831
ffecda0c1f45
[gaim-migrate @ 9595]
Christian Hammond <chipx86@chipx86.com>
parents:
8808
diff
changeset
|
120 { |
|
ffecda0c1f45
[gaim-migrate @ 9595]
Christian Hammond <chipx86@chipx86.com>
parents:
8808
diff
changeset
|
121 return TRUE; |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
122 } |
| 5309 | 123 |
| 124 return FALSE; | |
| 125 } | |
| 126 | |
| 127 void | |
| 128 msn_session_disconnect(MsnSession *session) | |
| 129 { | |
| 130 g_return_if_fail(session != NULL); | |
| 131 g_return_if_fail(session->connected); | |
| 132 | |
| 10481 | 133 session->connected = FALSE; |
| 134 | |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
8831
diff
changeset
|
135 while (session->switches != NULL) |
| 10463 | 136 msn_switchboard_close(session->switches->data); |
| 5309 | 137 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
138 if (session->notification != NULL) |
| 10463 | 139 msn_notification_close(session->notification); |
| 5309 | 140 } |
| 141 | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
142 /* TODO: This must go away when conversation is redesigned */ |
| 5309 | 143 MsnSwitchBoard * |
| 10621 | 144 msn_session_find_swboard(MsnSession *session, const char *username) |
| 5309 | 145 { |
| 146 GList *l; | |
| 147 | |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
8831
diff
changeset
|
148 g_return_val_if_fail(session != NULL, NULL); |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
149 g_return_val_if_fail(username != NULL, NULL); |
| 5309 | 150 |
|
8499
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
151 for (l = session->switches; l != NULL; l = l->next) |
|
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
152 { |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
153 MsnSwitchBoard *swboard; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
154 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
155 swboard = l->data; |
| 5309 | 156 |
| 10621 | 157 if ((swboard->im_user != NULL) && !strcmp(username, swboard->im_user)) |
| 10602 | 158 return swboard; |
| 5309 | 159 } |
| 160 | |
| 161 return NULL; | |
| 162 } | |
| 163 | |
| 164 MsnSwitchBoard * | |
| 10621 | 165 msn_session_find_swboard_with_conv(MsnSession *session, GaimConversation *conv) |
| 166 { | |
| 167 GList *l; | |
| 168 | |
| 169 g_return_val_if_fail(session != NULL, NULL); | |
| 170 g_return_val_if_fail(conv != NULL, NULL); | |
| 171 | |
| 172 for (l = session->switches; l != NULL; l = l->next) | |
| 173 { | |
| 174 MsnSwitchBoard *swboard; | |
| 175 | |
| 176 swboard = l->data; | |
| 177 | |
| 178 if (swboard->conv == conv) | |
| 179 return swboard; | |
| 180 } | |
| 181 | |
| 182 return NULL; | |
| 183 } | |
| 184 | |
| 185 MsnSwitchBoard * | |
| 186 msn_session_find_swboard_with_id(const MsnSession *session, int chat_id) | |
| 5309 | 187 { |
| 188 GList *l; | |
| 189 | |
| 190 g_return_val_if_fail(session != NULL, NULL); | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
191 g_return_val_if_fail(chat_id >= 0, NULL); |
| 5309 | 192 |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
8831
diff
changeset
|
193 for (l = session->switches; l != NULL; l = l->next) |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
8831
diff
changeset
|
194 { |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
195 MsnSwitchBoard *swboard; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
196 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
197 swboard = l->data; |
| 5309 | 198 |
| 10621 | 199 if (swboard->chat_id == chat_id) |
| 5309 | 200 return swboard; |
| 201 } | |
| 202 | |
| 203 return NULL; | |
| 204 } | |
| 205 | |
| 206 MsnSwitchBoard * | |
| 10773 | 207 msn_session_get_swboard(MsnSession *session, const char *username, |
| 208 MsnSBFlag flag) | |
| 5309 | 209 { |
| 210 MsnSwitchBoard *swboard; | |
| 211 | |
| 10621 | 212 swboard = msn_session_find_swboard(session, username); |
| 5309 | 213 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
214 if (swboard == NULL) |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
8831
diff
changeset
|
215 { |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
216 swboard = msn_switchboard_new(session); |
| 10225 | 217 swboard->im_user = g_strdup(username); |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
218 msn_switchboard_request(swboard); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
219 msn_switchboard_request_add_user(swboard, username); |
| 5309 | 220 } |
| 221 | |
| 10773 | 222 swboard->flag |= flag; |
| 223 | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
224 return swboard; |
| 5309 | 225 } |
| 10044 | 226 |
| 227 static void | |
| 228 msn_session_sync_users(MsnSession *session) | |
| 229 { | |
| 11992 | 230 GaimBlistNode *gnode, *cnode, *bnode; |
| 231 GaimConnection *gc = gaim_account_get_connection(session->account); | |
| 10044 | 232 |
| 11992 | 233 g_return_if_fail(gc != NULL); |
| 10044 | 234 |
| 11992 | 235 /* The core used to use msn_add_buddy to add all buddies before |
| 236 * being logged in. This no longer happens, so we manually iterate | |
| 237 * over the whole buddy list to identify sync issues. */ | |
| 10044 | 238 |
| 11992 | 239 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
| 240 GaimGroup *group = (GaimGroup *)gnode; | |
| 241 const char *group_name = group->name; | |
| 242 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 243 continue; | |
| 244 for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
| 245 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
| 246 continue; | |
| 247 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
| 248 GaimBuddy *b; | |
| 249 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 250 continue; | |
| 251 b = (GaimBuddy *)bnode; | |
| 252 if(b->account == gc->account) { | |
| 253 MsnUser *remote_user; | |
| 10044 | 254 gboolean found = FALSE; |
| 11992 | 255 |
| 256 remote_user = msn_userlist_find_user(session->userlist, b->name); | |
| 10044 | 257 |
| 11992 | 258 if ((remote_user != NULL) && (remote_user->list_op & MSN_LIST_FL_OP)) |
| 259 { | |
| 260 int group_id; | |
| 261 GList *l; | |
| 10044 | 262 |
| 11992 | 263 group_id = msn_userlist_find_group_id(remote_user->userlist, |
| 264 group_name); | |
| 10044 | 265 |
| 11992 | 266 for (l = remote_user->group_ids; l != NULL; l = l->next) |
| 10044 | 267 { |
| 11992 | 268 if (group_id == GPOINTER_TO_INT(l->data)) |
| 269 { | |
| 270 found = TRUE; | |
| 271 break; | |
| 272 } | |
| 10044 | 273 } |
| 11992 | 274 |
| 10044 | 275 } |
| 276 | |
| 277 if (!found) | |
| 278 { | |
| 11992 | 279 /* The user was not on the server list or not in that group |
| 280 * on the server list */ | |
| 281 msn_show_sync_issue(session, b->name, group_name); | |
| 10044 | 282 } |
| 283 } | |
| 284 } | |
| 285 } | |
| 286 } | |
| 287 } | |
| 288 | |
| 289 void | |
| 10481 | 290 msn_session_set_error(MsnSession *session, MsnErrorType error, |
| 291 const char *info) | |
| 292 { | |
| 293 GaimConnection *gc; | |
| 294 char *msg; | |
| 295 | |
| 10568 | 296 gc = gaim_account_get_connection(session->account); |
| 10481 | 297 |
| 298 switch (error) | |
| 299 { | |
| 300 case MSN_ERROR_SERVCONN: | |
| 301 msg = g_strdup(info); | |
| 302 break; | |
| 10519 | 303 case MSN_ERROR_UNSUPPORTED_PROTOCOL: |
| 10481 | 304 msg = g_strdup(_("Our protocol is not supported by the " |
| 305 "server.")); | |
| 306 break; | |
| 307 case MSN_ERROR_HTTP_MALFORMED: | |
| 308 msg = g_strdup(_("Error parsing HTTP.")); | |
| 309 break; | |
| 310 case MSN_ERROR_SIGN_OTHER: | |
| 311 gc->wants_to_die = TRUE; | |
| 312 msg = g_strdup(_("You have signed on from another location.")); | |
| 313 break; | |
| 10568 | 314 case MSN_ERROR_SERV_UNAVAILABLE: |
| 315 msg = g_strdup(_("The MSN servers are temporarily " | |
| 316 "unavailable. Please wait and try " | |
| 317 "again.")); | |
| 318 break; | |
| 10481 | 319 case MSN_ERROR_SERV_DOWN: |
| 320 msg = g_strdup(_("The MSN servers are going down " | |
| 321 "temporarily.")); | |
| 322 break; | |
| 323 case MSN_ERROR_AUTH: | |
| 324 msg = g_strdup_printf(_("Unable to authenticate: %s"), | |
| 325 (info == NULL ) ? | |
| 326 _("Unknown error") : info); | |
| 327 break; | |
| 328 case MSN_ERROR_BAD_BLIST: | |
| 329 msg = g_strdup(_("Your MSN buddy list is temporarily " | |
| 330 "unavailable. Please wait and try " | |
| 331 "again.")); | |
| 332 break; | |
| 333 default: | |
| 334 msg = g_strdup(_("Unknown error.")); | |
| 335 break; | |
| 336 } | |
| 337 | |
| 338 msn_session_disconnect(session); | |
| 10533 | 339 |
| 10481 | 340 gaim_connection_error(gc, msg); |
| 341 | |
| 342 g_free(msg); | |
| 343 } | |
| 344 | |
| 345 static const char * | |
| 346 get_login_step_text(MsnSession *session) | |
| 347 { | |
| 348 const char *steps_text[] = { | |
| 349 _("Connecting"), | |
| 350 _("Handshaking"), | |
| 10514 | 351 _("Transferring"), |
| 352 _("Handshaking"), | |
| 10481 | 353 _("Starting authentication"), |
| 354 _("Getting cookie"), | |
| 355 _("Authenticating"), | |
| 356 _("Sending cookie"), | |
| 357 _("Retrieving buddy list") | |
| 358 }; | |
| 359 | |
| 360 return steps_text[session->login_step]; | |
| 361 } | |
| 362 | |
| 363 void | |
| 364 msn_session_set_login_step(MsnSession *session, MsnLoginStep step) | |
| 365 { | |
| 366 GaimConnection *gc; | |
| 367 | |
| 10519 | 368 /* Prevent the connection progress going backwards, eg. if we get |
| 369 * transferred several times during login */ | |
| 10582 | 370 if (session->login_step > step) |
| 10519 | 371 return; |
| 372 | |
| 373 /* If we're already logged in, we're probably here because of a | |
| 374 * mid-session XFR from the notification server, so we don't want to | |
| 375 * popup the connection progress dialog */ | |
| 376 if (session->logged_in) | |
| 377 return; | |
| 378 | |
| 10481 | 379 gc = session->account->gc; |
| 380 | |
| 381 session->login_step = step; | |
| 382 | |
| 383 gaim_connection_update_progress(gc, get_login_step_text(session), step, | |
| 384 MSN_LOGIN_STEPS); | |
| 385 } | |
| 386 | |
| 387 void | |
| 10044 | 388 msn_session_finish_login(MsnSession *session) |
| 389 { | |
| 390 GaimAccount *account; | |
| 391 GaimConnection *gc; | |
|
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
10908
diff
changeset
|
392 char *icon; |
| 10044 | 393 |
| 10533 | 394 if (session->logged_in) |
| 395 return; | |
| 396 | |
| 10044 | 397 account = session->account; |
| 398 gc = gaim_account_get_connection(account); | |
| 399 | |
|
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
10908
diff
changeset
|
400 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
|
401 msn_user_set_buddy_icon(session->user, icon); |
|
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
10908
diff
changeset
|
402 g_free(icon); |
| 10044 | 403 |
| 10908 | 404 session->logged_in = TRUE; |
| 405 | |
| 11992 | 406 msn_change_status(session); |
| 10044 | 407 |
| 408 gaim_connection_set_state(gc, GAIM_CONNECTED); | |
| 409 | |
| 410 /* Sync users */ | |
| 411 msn_session_sync_users(session); | |
| 412 } |
