Update of /cvsroot/gaim/gaim/src/protocols/msn In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12520 Modified Files: msg.h msn.c notification.c slpcall.c switchboard.c switchboard.h sync.c user.c user.h Log Message: This is patch 1090620 from Felipe Contreras to improve the handling of the Individuals group on MSN and better buddy updates (modified by me to work in HEAD) Also included is my fix for bug 1090087 "MSN Groupchat Double Invite Crash", a few spelling corrections, and make some more strings translatable. Index: msg.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/msn/msg.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -p -r1.17 -r1.18 --- msg.h 12 Dec 2004 17:37:35 -0000 1.17 +++ msg.h 30 Dec 2004 15:55:19 -0000 1.18 @@ -60,7 +60,7 @@ typedef enum MSN_MSG_ERROR_TIMEOUT, /**< The message timedout. */ MSN_MSG_ERROR_NAK, /**< The message could not be sent. */ MSN_MSG_ERROR_SB, /**< The error comes from the switchboard. */ - MSN_MSG_ERROR_UNKNOWN /**< An unknown error occured. */ + MSN_MSG_ERROR_UNKNOWN /**< An unknown error occurred. */ } MsnMsgErrorType; Index: msn.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/msn/msn.c,v retrieving revision 1.342 retrieving revision 1.343 diff -u -d -p -r1.342 -r1.343 --- msn.c 23 Dec 2004 20:13:53 -0000 1.342 +++ msn.c 30 Dec 2004 15:55:19 -0000 1.343 @@ -448,8 +448,7 @@ msn_list_emblems(GaimBuddy *b, const cha else if (gaim_presence_is_status_active(presence, "busy") || gaim_presence_is_status_active(presence, "phone")) emblems[i++] = "occupied"; - else if (gaim_presence_is_status_active(presence, "away") || - gaim_presence_is_idle(presence)) + else if (!gaim_presence_is_available(presence)) emblems[i++] = "away"; if (user == NULL) @@ -1334,15 +1333,6 @@ msn_tooltip_info_text(MsnGetInfoData *in g_free(nicktext); } - if (gaim_presence_is_idle(presence)) - { - char *idletime = gaim_str_seconds_to_string(time(NULL) - - gaim_presence_get_idle_time(presence)); - g_string_append_printf(s, _("<b>%s:</b> %s<br>"), _("Idle"), - idletime); - g_free(idletime); - } - if (statustext) { char *tmp; Index: notification.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/msn/notification.c,v retrieving revision 1.130 retrieving revision 1.131 diff -u -d -p -r1.130 -r1.131 --- notification.c 23 Dec 2004 20:13:53 -0000 1.130 +++ notification.c 30 Dec 2004 15:55:19 -0000 1.131 @@ -37,6 +37,50 @@ static MsnTable *cbs_table; /************************************************************************** + * Util + **************************************************************************/ + +static void +group_error_helper(MsnSession *session, const char *msg, int group_id, int error) +{ + GaimAccount *account; + GaimConnection *gc; + char *reason = NULL; + char *title = NULL; + + account = session->account; + gc = gaim_account_get_connection(account); + + if (error == 224) + { + if (group_id == 0) + { + return; + } + else + { + const char *group_name; + group_name = + msn_userlist_find_group_name(session->userlist, + group_id); + reason = g_strdup_printf(_("%s is not a valid group."), + group_name); + } + } + else + { + reason = g_strdup(_("Unknown error.")); + } + + title = g_strdup_printf(_("%s on %s (%s)"), msg, + gaim_account_get_username(account), + gaim_account_get_protocol_name(account)); + gaim_notify_error(gc, NULL, title, reason); + g_free(title); + g_free(reason); +} + +/************************************************************************** * Login **************************************************************************/ @@ -331,6 +375,7 @@ add_cmd(MsnCmdProc *cmdproc, MsnCommand group_id = -1; msn_got_add_user(session, user, list_id, group_id); + msn_user_update(user); } static void @@ -353,15 +398,15 @@ add_error(MsnCmdProc *cmdproc, MsnTransa passport = params[1]; if (!strcmp(list, "FL")) - msg = g_strdup_printf("Unable to add user on %s (%s)", + msg = g_strdup_printf(_("Unable to add user on %s (%s)"), gaim_account_get_username(account), gaim_account_get_protocol_name(account)); else if (!strcmp(list, "BL")) - msg = g_strdup_printf("Unable to block user on %s (%s)", + msg = g_strdup_printf(_("Unable to block user on %s (%s)"), gaim_account_get_username(account), gaim_account_get_protocol_name(account)); else if (!strcmp(list, "AL")) - msg = g_strdup_printf("Unable to permit user on %s (%s)", + msg = g_strdup_printf(_("Unable to permit user on %s (%s)"), gaim_account_get_username(account), gaim_account_get_protocol_name(account)); @@ -369,8 +414,8 @@ add_error(MsnCmdProc *cmdproc, MsnTransa { if (error == 210) { - reason = g_strdup_printf("%s could not be added because " - "your buddy list is full.", passport); + reason = g_strdup_printf(_("%s could not be added because " + "your buddy list is full."), passport); } } @@ -378,12 +423,12 @@ add_error(MsnCmdProc *cmdproc, MsnTransa { if (error == 208) { - reason = g_strdup_printf("%s is not a valid passport account.", + reason = g_strdup_printf(_("%s is not a valid passport account."), passport); } else { - reason = g_strdup_printf("Unknown error."); + reason = g_strdup_printf(_("Unknown error.")); } } @@ -446,13 +491,13 @@ adg_cmd(MsnCmdProc *cmdproc, MsnCommand static void fln_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { - GaimAccount *account; - MsnSlpLink *slplink; + MsnUser *user; - account = cmdproc->session->account; + user = msn_userlist_find_user(cmdproc->session->userlist, cmd->params[0]); - gaim_prpl_got_user_status(account, cmd->params[0], "offline", NULL); + user->status = "offline"; + msn_user_update(user); slplink = msn_session_find_slplink(cmdproc->session, cmd->params[0]); @@ -461,10 +506,6 @@ fln_cmd(MsnCmdProc *cmdproc, MsnCommand } -/* - * XXX - There is a bit of code duplication between this function - * and nln_cmd. Someone should do something about that. - */ static void iln_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { @@ -473,7 +514,7 @@ iln_cmd(MsnCmdProc *cmdproc, MsnCommand GaimConnection *gc; MsnUser *user; MsnObject *msnobj; - const char *status, *state, *passport, *friendly; + const char *state, *passport, *friendly; session = cmdproc->session; account = session->account; @@ -485,7 +526,6 @@ iln_cmd(MsnCmdProc *cmdproc, MsnCommand user = msn_userlist_find_user(session->userlist, passport); - /* serv_got_nick(gc, passport, friendly); */ serv_got_alias(gc, passport, friendly); msn_user_set_friendly_name(user, friendly); @@ -496,30 +536,8 @@ iln_cmd(MsnCmdProc *cmdproc, MsnCommand msn_user_set_object(user, msnobj); } - /* XXX - What does this do????? - if ((b = gaim_find_buddy(account, passport)) != NULL) - status |= ((((b->uc) >> 1) & 0xF0) << 1); - */ - - if (!g_ascii_strcasecmp(state, "BSY")) - status = "busy"; - else if (!g_ascii_strcasecmp(state, "BRB")) - status = "brb"; - else if (!g_ascii_strcasecmp(state, "AWY")) - status = "away"; - else if (!g_ascii_strcasecmp(state, "PHN")) - status = "phone"; - else if (!g_ascii_strcasecmp(state, "LUN")) - status = "lunch"; - else - status = "available"; - - gaim_prpl_got_user_status(account, passport, status, NULL); - - if (!g_ascii_strcasecmp(state, "IDL")) - gaim_prpl_got_user_idle(account, passport, TRUE, -1); - else - gaim_prpl_got_user_idle(account, passport, FALSE, 0); + msn_user_set_state(user, state); + msn_user_update(user); } static void @@ -545,10 +563,7 @@ nln_cmd(MsnCmdProc *cmdproc, MsnCommand GaimConnection *gc; MsnUser *user; MsnObject *msnobj; - const char *state; - const char *passport; - const char *friendly; - const char *status; + const char *state, *passport, *friendly; session = cmdproc->session; account = session->account; @@ -560,7 +575,6 @@ nln_cmd(MsnCmdProc *cmdproc, MsnCommand user = msn_userlist_find_user(session->userlist, passport); - /* serv_got_nick(gc, passport, friendly); */ serv_got_alias(gc, passport, friendly); msn_user_set_friendly_name(user, friendly); @@ -579,25 +593,8 @@ nln_cmd(MsnCmdProc *cmdproc, MsnCommand } } - if (!g_ascii_strcasecmp(state, "BSY")) - status = "busy"; - else if (!g_ascii_strcasecmp(state, "BRB")) - status = "brb"; - else if (!g_ascii_strcasecmp(state, "AWY")) - status = "away"; - else if (!g_ascii_strcasecmp(state, "PHN")) - status = "phone"; - else if (!g_ascii_strcasecmp(state, "LUN")) - status = "lunch"; - else - status = "available"; - - gaim_prpl_got_user_status(account, passport, status, NULL); - - if (!g_ascii_strcasecmp(state, "IDL")) - gaim_prpl_got_user_idle(account, passport, TRUE, -1); - else - gaim_prpl_got_user_idle(account, passport, FALSE, 0); + msn_user_set_state(user, state); + msn_user_update(user); } static void @@ -646,7 +643,7 @@ not_cmd(MsnCmdProc *cmdproc, MsnCommand static void rea_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { - /* TODO: This might be with us too */ + /* TODO: This might be for us too */ MsnSession *session; GaimConnection *gc; @@ -674,6 +671,21 @@ reg_cmd(MsnCmdProc *cmdproc, MsnCommand } static void +reg_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) +{ + int group_id; + char **params; + + params = g_strsplit(trans->params, " ", 0); + + group_id = atoi(params[0]); + + group_error_helper(cmdproc->session, _("Unable to rename group"), group_id, error); + + g_strfreev(params); +} + +static void rem_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { MsnSession *session; @@ -698,6 +710,7 @@ rem_cmd(MsnCmdProc *cmdproc, MsnCommand group_id = -1; msn_got_rem_user(session, user, list_id, group_id); + msn_user_update(user); } static void @@ -713,6 +726,21 @@ rmg_cmd(MsnCmdProc *cmdproc, MsnCommand } static void +rmg_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) +{ + int group_id; + char **params; + + params = g_strsplit(trans->params, " ", 0); + + group_id = atoi(params[0]); + + group_error_helper(cmdproc->session, "Unable to delete group", group_id, error); + + g_strfreev(params); +} + +static void syn_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { MsnSession *session; @@ -1276,6 +1304,8 @@ msn_notification_init(void) msn_table_add_cmd(cbs_table, "fallback", "XFR", xfr_cmd); msn_table_add_error(cbs_table, "ADD", add_error); + msn_table_add_error(cbs_table, "REG", reg_error); + msn_table_add_error(cbs_table, "RMG", rmg_error); /* msn_table_add_error(cbs_table, "REA", rea_error); */ /* I received a '500' error from the notification server just now. Index: slpcall.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/msn/slpcall.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -p -r1.7 -r1.8 --- slpcall.c 11 Dec 2004 20:01:58 -0000 1.7 +++ slpcall.c 30 Dec 2004 15:55:19 -0000 1.8 @@ -96,7 +96,7 @@ msn_slp_call_destroy(MsnSlpCall *slpcall g_return_if_fail(slpmsg != NULL); - gaim_debug_info("msn", "slpcall destroy: tryping slp_msg (%p)\n", + gaim_debug_info("msn", "slpcall destroy: trying slp_msg (%p)\n", slpmsg); if (slpmsg->slpcall == slpcall) Index: switchboard.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/msn/switchboard.c,v retrieving revision 1.89 retrieving revision 1.90 diff -u -d -p -r1.89 -r1.90 --- switchboard.c 27 Dec 2004 18:53:59 -0000 1.89 +++ switchboard.c 30 Dec 2004 15:55:19 -0000 1.90 @@ -306,6 +306,8 @@ msn_switchboard_report_user(MsnSwitchBoa static void swboard_error_helper(MsnSwitchBoard *swboard, int reason, const char *passport) { + g_return_if_fail(swboard != NULL); + gaim_debug_info("msg", "Error: Unable to call the user %s\n", passport); if (swboard->total_users == 0) @@ -365,7 +367,7 @@ msg_error_helper(MsnCmdProc *cmdproc, Ms if (error == MSN_MSG_ERROR_TIMEOUT) { str_reason = _("Message may have not been sent " - "because a time out occurred:"); + "because a timeout occurred:"); } else if (error == MSN_MSG_ERROR_SB) { @@ -962,8 +964,15 @@ cal_error(MsnCmdProc *cmdproc, MsnTransa { int reason = MSN_SB_ERROR_UNKNOWN; - if (error == 217) + if (error == 215) + { + gaim_debug_info("msn", "Invited user already in switchboard\n"); + return; + } + else if (error == 217) + { reason = MSN_SB_ERROR_USER_OFFLINE; + } cal_error_helper(trans, reason); } Index: switchboard.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/msn/switchboard.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -p -r1.18 -r1.19 --- switchboard.h 23 Dec 2004 20:13:54 -0000 1.18 +++ switchboard.h 30 Dec 2004 15:55:19 -0000 1.19 @@ -45,7 +45,7 @@ typedef enum MSN_SB_ERROR_OFFLINE, /**< The account is offline. */ MSN_SB_ERROR_USER_OFFLINE, /**< The user to call is offline. */ MSN_SB_ERROR_CONNECTION, /**< There was a connection error. */ - MSN_SB_ERROR_UNKNOWN /**< An unknown error occured. */ + MSN_SB_ERROR_UNKNOWN /**< An unknown error occurred. */ } MsnSBErrorType; @@ -86,7 +86,7 @@ struct _MsnSwitchBoard GQueue *im_queue; /**< Queue of messages to send. */ GList *ack_list; /**< List of messages waiting for an ack. */ - MsnSBErrorType error; /**< The error that occured in this switchboard + MsnSBErrorType error; /**< The error that occurred in this switchboard (if applicable). */ MsnSlpLink *slplink; /**< The slplink that is using this switchboard. */ }; Index: sync.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/msn/sync.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -p -r1.5 -r1.6 --- sync.c 19 Sep 2004 03:02:28 -0000 1.5 +++ sync.c 30 Dec 2004 15:55:19 -0000 1.6 @@ -99,6 +99,11 @@ lsg_cmd(MsnCmdProc *cmdproc, MsnCommand group = msn_group_new(session->userlist, group_id, name); + /* HACK */ + if (group_id == 0) + /* Group of ungroupped buddies */ + return; + if ((g = gaim_find_group(name)) == NULL) { g = gaim_group_new(name); Index: user.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/msn/user.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -p -r1.21 -r1.22 --- user.c 16 Dec 2004 03:50:53 -0000 1.21 +++ user.c 30 Dec 2004 15:55:19 -0000 1.22 @@ -86,6 +86,49 @@ msn_user_destroy(MsnUser *user) } void +msn_user_update(MsnUser *user) +{ + GaimAccount *account; + GaimConnection *gc; + + account = user->userlist->session->account; + gc = gaim_account_get_connection(account); + + gaim_prpl_got_user_status(account, user->passport, user->status, NULL); + + if (user->idle) + gaim_prpl_got_user_idle(account, user->passport, TRUE, -1); + else + gaim_prpl_got_user_idle(account, user->passport, FALSE, 0); +} + +void +msn_user_set_state(MsnUser *user, const char *state) +{ + const char *status; + + if (!g_ascii_strcasecmp(state, "BSY")) + status = "busy"; + else if (!g_ascii_strcasecmp(state, "BRB")) + status = "brb"; + else if (!g_ascii_strcasecmp(state, "AWY")) + status = "away"; + else if (!g_ascii_strcasecmp(state, "PHN")) + status = "phone"; + else if (!g_ascii_strcasecmp(state, "LUN")) + status = "lunch"; + else + status = "available"; + + if (!g_ascii_strcasecmp(state, "IDL")) + user->idle = TRUE; + else + user->idle = FALSE; + + user->status = status; +} + +void msn_user_set_passport(MsnUser *user, const char *passport) { g_return_if_fail(user != NULL); @@ -222,6 +265,12 @@ msn_user_add_group_id(MsnUser *user, int g = gaim_find_group(group_name); + if ((id == 0) && (g == NULL)) + { + g = gaim_group_new(group_name); + gaim_blist_add_group(g, NULL); + } + b = gaim_find_buddy_in_group(account, passport, g); if (b == NULL) Index: user.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/msn/user.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -p -r1.15 -r1.16 --- user.h 6 Jun 2004 03:42:54 -0000 1.15 +++ user.h 30 Dec 2004 15:55:19 -0000 1.16 @@ -45,6 +45,9 @@ struct _MsnUser char *store_name; /**< The name stored in the server. */ char *friendly_name; /**< The friendly name. */ + const char *status; /**< The state of the user. */ + gboolean idle; /**< The idle state of the user. */ + struct { char *home; /**< Home phone number. */ @@ -89,6 +92,24 @@ MsnUser *msn_user_new(MsnUserList *userl */ void msn_user_destroy(MsnUser *user); + +/** + * Updates the user. + * + * Communicates with the core to update the ui, etc. + * + * @param user The user to update. + */ +void msn_user_update(MsnUser *user); + +/** + * Sets the new state of user. + * + * @param user The user. + * @param state The state string. + */ +void msn_user_set_state(MsnUser *user, const char *state); + /** * Sets the passport account for a user. * |