From: <may...@us...> - 2006-08-23 15:07:34
|
Revision: 17003 Author: mayuan2006 Date: 2006-08-23 08:07:17 -0700 (Wed, 23 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=17003&view=rev Log Message: ----------- add the PSM processing need to store the PSM info to XML. Thanks for Chris <ukd...@ya...> 's code! committed by MaYuan<may...@gm...> Modified Paths: -------------- branches/soc-2006-msnp13/src/protocols/msn/msn.c branches/soc-2006-msnp13/src/protocols/msn/notification.c branches/soc-2006-msnp13/src/protocols/msn/servconn.c branches/soc-2006-msnp13/src/protocols/msn/state.c branches/soc-2006-msnp13/src/protocols/msn/state.h branches/soc-2006-msnp13/src/protocols/msn/user.c branches/soc-2006-msnp13/src/protocols/msn/user.h Modified: branches/soc-2006-msnp13/src/protocols/msn/msn.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/msn.c 2006-08-23 14:49:40 UTC (rev 17002) +++ branches/soc-2006-msnp13/src/protocols/msn/msn.c 2006-08-23 15:07:17 UTC (rev 17003) @@ -517,20 +517,47 @@ *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, Modified: branches/soc-2006-msnp13/src/protocols/msn/notification.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/notification.c 2006-08-23 14:49:40 UTC (rev 17002) +++ branches/soc-2006-msnp13/src/protocols/msn/notification.c 2006-08-23 15:07:17 UTC (rev 17003) @@ -1393,12 +1393,40 @@ /*get the payload content*/ } +/* + * Get the UBX's PSM info + * Post it to the User status + * Thanks for Chris <ukd...@ya...>'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 Modified: branches/soc-2006-msnp13/src/protocols/msn/servconn.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/servconn.c 2006-08-23 14:49:40 UTC (rev 17002) +++ branches/soc-2006-msnp13/src/protocols/msn/servconn.c 2006-08-23 15:07:17 UTC (rev 17003) @@ -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 + }else{ return FALSE; + } } void Modified: branches/soc-2006-msnp13/src/protocols/msn/state.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/state.c 2006-08-23 14:49:40 UTC (rev 17002) +++ branches/soc-2006-msnp13/src/protocols/msn/state.c 2006-08-23 15:07:17 UTC (rev 17003) @@ -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) { Modified: branches/soc-2006-msnp13/src/protocols/msn/state.h =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/state.h 2006-08-23 14:49:40 UTC (rev 17002) +++ branches/soc-2006-msnp13/src/protocols/msn/state.h 2006-08-23 15:07:17 UTC (rev 17003) @@ -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_ */ Modified: branches/soc-2006-msnp13/src/protocols/msn/user.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/user.c 2006-08-23 14:49:40 UTC (rev 17002) +++ branches/soc-2006-msnp13/src/protocols/msn/user.c 2006-08-23 15:07:17 UTC (rev 17003) @@ -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); Modified: branches/soc-2006-msnp13/src/protocols/msn/user.h =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/user.h 2006-08-23 14:49:40 UTC (rev 17002) +++ branches/soc-2006-msnp13/src/protocols/msn/user.h 2006-08-23 15:07:17 UTC (rev 17003) @@ -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. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |