gaim/gaim

Parents 7913c2ace90c
Children bc00d75f7801
Some minor MSN reorganization from Felipe and a bunch of MSN chat related fixes
and improvements from me.
--- a/src/protocols/msn/httpconn.c Wed Jan 19 22:22:53 2005 -0500
+++ b/src/protocols/msn/httpconn.c Thu Jan 20 11:36:49 2005 -0500
@@ -283,7 +283,6 @@
{
gaim_debug_error("msn", "HTTP: Read error\n");
msn_servconn_got_error(httpconn->servconn, MSN_SERVCONN_ERROR_READ);
- msn_httpconn_disconnect(httpconn);
return;
}
@@ -310,11 +309,15 @@
{
gaim_debug_error("msn", "HTTP: Special error\n");
msn_servconn_got_error(httpconn->servconn, MSN_SERVCONN_ERROR_READ);
- msn_httpconn_disconnect(httpconn);
return;
}
+ if (httpconn->rx_buf != NULL)
+ g_free(httpconn->rx_buf);
+ httpconn->rx_buf = NULL;
+ httpconn->rx_len = 0;
+
if (result_len == 0)
{
/* Nothing to do here */
@@ -322,17 +325,11 @@
gaim_debug_info("msn", "HTTP: nothing to do here\n");
#endif
g_free(result_msg);
- g_free(httpconn->rx_buf);
- httpconn->rx_buf = NULL;
- httpconn->rx_len = 0;
return;
}
- g_free(httpconn->rx_buf);
- httpconn->rx_buf = NULL;
- httpconn->rx_len = 0;
-
- g_free(servconn->rx_buf);
+ if (servconn->rx_buf != NULL)
+ g_free(servconn->rx_buf);
servconn->rx_buf = result_msg;
servconn->rx_len = result_len;
@@ -702,8 +699,10 @@
servconn = httpconn->servconn;
- if (servconn != NULL)
- servconn->wasted = TRUE;
+ /* I'll be honest, I don't fully understand all this, but this
+ * causes crashes, Stu. */
+ /* if (servconn != NULL)
+ servconn->wasted = TRUE; */
g_free(full_session_id);
g_free(session_id);
--- a/src/protocols/msn/msn.c Wed Jan 19 22:22:53 2005 -0500
+++ b/src/protocols/msn/msn.c Thu Jan 20 11:36:49 2005 -0500
@@ -1050,16 +1050,21 @@
{
MsnSession *session;
MsnSwitchBoard *swboard;
- MsnCmdProc *cmdproc;
session = gc->proto_data;
swboard = msn_session_find_switch_with_id(session, id);
- g_return_if_fail(swboard != NULL);
- cmdproc = swboard->servconn->cmdproc;
+ if (swboard == NULL)
+ {
+ /* if we have no switchboard, everyone else left the chat already */
+ swboard = msn_switchboard_new(session);
+ msn_switchboard_request(swboard);
+ swboard->chat_id = id;
+ swboard->conv = gaim_find_chat(gc, id);
+ }
- msn_cmdproc_send(cmdproc, "CAL", "%s", who);
+ msn_switchboard_request_add_user(swboard, who);
}
static void
@@ -1071,11 +1076,12 @@
session = gc->proto_data;
swboard = msn_session_find_switch_with_id(session, id);
- g_return_if_fail(swboard != NULL);
+
+ /* if swboard is NULL we were the only person left anyway */
+ if (swboard == NULL)
+ return;
msn_switchboard_close(swboard);
-
- /* serv_got_chat_left(gc, id); */
}
static int
--- a/src/protocols/msn/session.c Wed Jan 19 22:22:53 2005 -0500
+++ b/src/protocols/msn/session.c Thu Jan 20 11:36:49 2005 -0500
@@ -322,6 +322,7 @@
}
msn_session_disconnect(session);
+
gaim_connection_error(gc, msg);
g_free(msg);
@@ -375,12 +376,12 @@
GaimAccount *account;
GaimConnection *gc;
+ if (session->logged_in)
+ return;
+
account = session->account;
gc = gaim_account_get_connection(account);
- if (session->logged_in)
- return;
-
msn_user_set_buddy_icon(session->user,
gaim_account_get_buddy_icon(session->account));
--- a/src/protocols/msn/switchboard.c Wed Jan 19 22:22:53 2005 -0500
+++ b/src/protocols/msn/switchboard.c Thu Jan 20 11:36:49 2005 -0500
@@ -227,9 +227,12 @@
GList *l;
/* gaim_debug_info("msn", "[chat] Switching to chat.\n"); */
-
+#if 0
+ /* this is bad - it causes msn_switchboard_close to be called on the
+ * switchboard we're in the middle of using :( */
if (swboard->conv != NULL)
gaim_conversation_destroy(swboard->conv);
+#endif
cmdproc->session->conv_seq++;
swboard->chat_id = cmdproc->session->conv_seq;
@@ -310,7 +313,9 @@
gaim_debug_info("msg", "Error: Unable to call the user %s\n", passport);
- if (swboard->total_users == 0)
+ /* TODO: if current_users > 0, this is probably a chat and an invite failed,
+ * we should report that in the chat or something */
+ if (swboard->current_users == 0)
{
swboard->error = reason;
msn_switchboard_close(swboard);
@@ -608,10 +613,14 @@
/* This is a helper switchboard */
msn_switchboard_destroy(swboard);
}
- else if (swboard->current_users > 1)
+ else if ((swboard->current_users > 1) ||
+ (gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT))
{
/* This is a switchboard used for a chat */
gaim_conv_chat_remove_user(GAIM_CONV_CHAT(swboard->conv), user, NULL);
+ swboard->current_users--;
+ if (swboard->current_users == 0)
+ msn_switchboard_destroy(swboard);
}
else
{
@@ -849,13 +858,22 @@
body_final = body_enc;
}
- if (swboard->current_users > 1)
+ if (swboard->current_users > 1 ||
+ ((swboard->conv != NULL) &&
+ gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT))
{
serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final,
time(NULL));
+ if (swboard->conv == NULL)
+ swboard->conv = gaim_find_chat(gc, swboard->chat_id);
}
else
+ {
serv_got_im(gc, passport, body_final, 0, time(NULL));
+ if (swboard->conv == NULL)
+ swboard->conv = gaim_find_conversation_with_account(passport,
+ gaim_connection_get_account(gc));
+ }
g_free(body_final);
}
@@ -1093,6 +1111,9 @@
{
g_return_if_fail(swboard != NULL);
+ /* forget any conversation that used to be associated with this swboard */
+ swboard->conv = NULL;
+
if (swboard->error != MSN_SB_ERROR_NONE)
{
msn_switchboard_destroy(swboard);
--- a/src/protocols/msn/userlist.c Wed Jan 19 22:22:53 2005 -0500
+++ b/src/protocols/msn/userlist.c Thu Jan 20 11:36:49 2005 -0500
@@ -154,10 +154,25 @@
g_return_val_if_fail(user != NULL, NULL);
- if ((store_name = msn_user_get_store_name(user)) != NULL)
- return gaim_url_encode(store_name);
+ store_name = msn_user_get_store_name(user);
+
+ if (store_name != NULL)
+ store_name = gaim_url_encode(store_name);
+ else
+ store_name = msn_user_get_passport(user);
- return msn_user_get_passport(user);
+ /* this might be a bit of a hack, but it should prevent notification server
+ * disconnections for people who have buddies with insane friendly names
+ * who added you to their buddy list from being disconnected. Stu. */
+ /* Shx: What? Isn't the store_name obtained from the server, and hence it's
+ * below the BUDDY_ALIAS_MAXLEN ? */
+ /* Stu: yeah, that's why it's a bit of a hack, as you pointed out, we're
+ * probably decoding the incoming store_name wrong, or something. bleh. */
+
+ if (strlen(store_name) > BUDDY_ALIAS_MAXLEN)
+ store_name = msn_user_get_passport(user);
+
+ return store_name;
}
static void
@@ -467,7 +482,6 @@
msn_userlist_remove_group(MsnUserList *userlist, MsnGroup *group)
{
userlist->groups = g_list_remove(userlist->groups, group);
- msn_group_destroy(group);
}
MsnGroup *
@@ -554,7 +568,10 @@
group = msn_userlist_find_group_with_id(userlist, group_id);
if (group != NULL)
+ {
msn_userlist_remove_group(userlist, group);
+ msn_group_destroy(group);
+ }
}
void
@@ -631,13 +648,6 @@
store_name = (user != NULL) ? get_store_name(user) : who;
- /* this might be a bit of a hack, but it should prevent notification server
- * disconnections for people who have buddies with insane friendly names
- * who added you to their buddy list from being disconnected. Stu. */
- /* ... No, that sentence didn't parse for me either. Stu. */
- if (strlen(store_name) > BUDDY_ALIAS_MAXLEN)
- store_name = who;
-
/* Then request the add to the server. */
list = lists[list_id];