# HG changeset patch # User Ma Yuan # Date 1156345637 0 # Node ID 2e078c892e0b8a9fc7d9a665201feb6f74b968e4 # Parent cf0611260c6b36f1f4f2f711f35afd5c652311b1 [gaim-migrate @ 17003] add the PSM processing need to store the PSM info to XML. Thanks for Chris 's code! committed by MaYuan committer: Ethan Blanton diff -r cf0611260c6b -r 2e078c892e0b src/protocols/msn/msn.c --- a/src/protocols/msn/msn.c Tue Aug 22 16:13:43 2006 +0000 +++ b/src/protocols/msn/msn.c Wed Aug 23 15:07:17 2006 +0000 @@ -517,18 +517,45 @@ *ne = emblems[3]; } +/* + * Set the User status text + * Add the PSM String Using "Name - PSM String" format + */ static char * msn_status_text(GaimBuddy *buddy) { GaimPresence *presence; GaimStatus *status; + char *msg, *psm_str, *tmp2, *text, *name; presence = gaim_buddy_get_presence(buddy); status = gaim_presence_get_active_status(presence); - if (!gaim_presence_is_available(presence) && !gaim_presence_is_idle(presence)) - { - return g_strdup(gaim_status_get_name(status)); + msg = gaim_status_get_attr_string(status, "message"); + if (!gaim_presence_is_available(presence) && !gaim_presence_is_idle(presence)){ + name = gaim_status_get_name(status); + }else{ + name = NULL; + } + + if (msg != NULL) { + tmp2 = gaim_markup_strip_html(msg); + if (name){ + psm_str = g_strdup_printf("%s - %s", name, tmp2); + g_free(tmp2); + }else{ + psm_str = tmp2; + } + text = g_markup_escape_text(psm_str, -1); + g_free(psm_str); + return text; + } else { + if (!gaim_presence_is_available(presence) && !gaim_presence_is_idle(presence)){ + psm_str = g_strdup(gaim_status_get_name(status)); + text = g_markup_escape_text(psm_str, -1); + g_free(psm_str); + return text; + } } return NULL; @@ -574,29 +601,42 @@ { GaimStatusType *status; GList *types = NULL; - +#if 0 status = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, NULL, NULL, FALSE, TRUE, FALSE); +#endif + status = gaim_status_type_new_with_attrs( + GAIM_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, + "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), + NULL); types = g_list_append(types, status); - status = gaim_status_type_new_full(GAIM_STATUS_AWAY, - NULL, NULL, FALSE, TRUE, FALSE); + status = gaim_status_type_new_with_attrs( + GAIM_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, + "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), + NULL); types = g_list_append(types, status); - status = gaim_status_type_new_full(GAIM_STATUS_AWAY, - "brb", _("Be Right Back"), FALSE, TRUE, FALSE); + status = gaim_status_type_new_with_attrs( + GAIM_STATUS_AWAY, "brb", _("Be Right Back"), TRUE, TRUE, FALSE, + "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), + NULL); types = g_list_append(types, status); - status = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, - "busy", _("Busy"), FALSE, TRUE, FALSE); + status = gaim_status_type_new_with_attrs( + GAIM_STATUS_AWAY, "busy", _("Busy"), TRUE, TRUE, FALSE, + "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), + NULL); types = g_list_append(types, status); - - status = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, - "phone", _("On the Phone"), FALSE, TRUE, FALSE); + status = gaim_status_type_new_with_attrs( + GAIM_STATUS_AWAY, "phone", _("On the Phone"), TRUE, TRUE, FALSE, + "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), + NULL); types = g_list_append(types, status); - - status = gaim_status_type_new_full(GAIM_STATUS_AWAY, - "lunch", _("Out to Lunch"), FALSE, TRUE, FALSE); + status = gaim_status_type_new_with_attrs( + GAIM_STATUS_AWAY, "lunch", _("Out to Lunch"), TRUE, TRUE, FALSE, + "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), + NULL); types = g_list_append(types, status); status = gaim_status_type_new_full(GAIM_STATUS_INVISIBLE, diff -r cf0611260c6b -r 2e078c892e0b src/protocols/msn/notification.c --- a/src/protocols/msn/notification.c Tue Aug 22 16:13:43 2006 +0000 +++ b/src/protocols/msn/notification.c Wed Aug 23 15:07:17 2006 +0000 @@ -1393,12 +1393,40 @@ /*get the payload content*/ } +/* + * Get the UBX's PSM info + * Post it to the User status + * Thanks for Chris 's code + */ static void ubx_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, size_t len) { + MsnSession *session; + GaimAccount *account; + GaimConnection *gc; + MsnUser *user; + MsnObject *msnobj; + int clientid; + int wlmclient; + const char *passport, *psm_str; + /*get the payload content*/ - gaim_debug_info("MaYuan","ubx{%s}\n",cmd->payload); + gaim_debug_info("MaYuan","UBX {%s} payload{%s}\n",cmd->params[0], cmd->payload); + + session = cmdproc->session; + account = session->account; + gc = gaim_account_get_connection(account); + + passport = cmd->params[0]; + user = msn_userlist_find_user(session->userlist, passport); + + psm_str = msn_get_psm(cmd->payload,len); + gaim_debug_info("Ma Yuan","got psm {%s}\n", psm_str); + msn_user_set_statusline(user, psm_str); + msn_user_update(user); + + g_free(psm_str); } static void diff -r cf0611260c6b -r 2e078c892e0b src/protocols/msn/servconn.c --- a/src/protocols/msn/servconn.c Tue Aug 22 16:13:43 2006 +0000 +++ b/src/protocols/msn/servconn.c Wed Aug 23 15:07:17 2006 +0000 @@ -235,13 +235,12 @@ r = gaim_proxy_connect(session->account, host, port, connect_cb, servconn); - if (r == 0) - { + if (r == 0){ servconn->processing = TRUE; return TRUE; + }else{ + return FALSE; } - else - return FALSE; } void diff -r cf0611260c6b -r 2e078c892e0b src/protocols/msn/state.c --- a/src/protocols/msn/state.c Tue Aug 22 16:13:43 2006 +0000 +++ b/src/protocols/msn/state.c Wed Aug 23 15:07:17 2006 +0000 @@ -80,6 +80,34 @@ return result; } +/*get the PSM info from the XML string*/ +const char * +msn_get_psm(char *xml_str,gsize len) +{ + xmlnode *payloadNode, *psmNode; + char *psm_str,*psm; + + payloadNode = xmlnode_from_str(xml_str, len); + if (!payloadNode){ + gaim_debug_error("MaYuan","PSM XML parse Error!\n"); + return NULL; + } + psmNode = xmlnode_get_child(payloadNode, "PSM"); + if (!psmNode){ + gaim_debug_info("Ma Yuan","No PSM status Node"); + g_free(payloadNode); + return NULL; + } + psm_str = xmlnode_get_data(psmNode); + gaim_debug_info("Ma Yuan","got PSM {%s}\n", psm_str); + psm = g_strdup(psm_str); + + g_free(psmNode); + g_free(payloadNode); + + return psm; +} + void msn_set_psm(MsnSession *session) { diff -r cf0611260c6b -r 2e078c892e0b src/protocols/msn/state.h --- a/src/protocols/msn/state.h Tue Aug 22 16:13:43 2006 +0000 +++ b/src/protocols/msn/state.h Wed Aug 23 15:07:17 2006 +0000 @@ -61,6 +61,9 @@ void msn_set_psm(MsnSession *session); +/*get the PSM info from the XML string*/ +const char * msn_get_psm(char *xml_str,gsize len); + MsnAwayType msn_state_from_account(GaimAccount *account); #endif /* _MSN_STATE_H_ */ diff -r cf0611260c6b -r 2e078c892e0b src/protocols/msn/user.c --- a/src/protocols/msn/user.c Tue Aug 22 16:13:43 2006 +0000 +++ b/src/protocols/msn/user.c Wed Aug 23 15:07:17 2006 +0000 @@ -84,13 +84,19 @@ account = user->userlist->session->account; - if (user->status != NULL) + if (user->statusline != NULL) { + char *status = g_strdup_printf("%s - %s", user->status, user->statusline); + gaim_prpl_got_user_status(account, user->passport, user->status, "message", user->statusline, NULL); + } + else if (user->status != NULL) { gaim_prpl_got_user_status(account, user->passport, user->status, NULL); + } - if (user->idle) + if (user->idle){ gaim_prpl_got_user_idle(account, user->passport, TRUE, -1); - else + }else{ gaim_prpl_got_user_idle(account, user->passport, FALSE, 0); + } } void @@ -138,6 +144,15 @@ } void +msn_user_set_statusline(MsnUser *user, const char *statusline) +{ + g_return_if_fail(user != NULL); + + g_free(user->statusline); + user->statusline = g_strdup(statusline); +} + +void msn_user_set_store_name(MsnUser *user, const char *name) { g_return_if_fail(user != NULL); diff -r cf0611260c6b -r 2e078c892e0b src/protocols/msn/user.h --- a/src/protocols/msn/user.h Tue Aug 22 16:13:43 2006 +0000 +++ b/src/protocols/msn/user.h Wed Aug 23 15:07:17 2006 +0000 @@ -48,6 +48,8 @@ char * uid; /*< User Id */ const char *status; /**< The state of the user. */ + const char *statusline; /**< The state of the user. */ + gboolean idle; /**< The idle state of the user. */ struct @@ -105,6 +107,14 @@ */ void msn_user_update(MsnUser *user); + /** + * Sets the new statusline of user. + * + * @param user The user. + * @param state The statusline string. + */ +void msn_user_set_statusline(MsnUser *user, const char *statusline); + /** * Sets the new state of user. *