diff options
author | Ma Yuan <mayuan2006@gmail.com> | 2006-08-23 15:07:17 +0000 |
---|---|---|
committer | Ma Yuan <mayuan2006@gmail.com> | 2006-08-23 15:07:17 +0000 |
commit | b104d73c04426a04b07e201299297180b691a68d (patch) | |
tree | 2e90c7b9fa78afa2f48934942ddc6ccd4a4e33d2 | |
parent | 00fc30d729704b837e5320fcdaf598f6d365bbcd (diff) | |
download | pidgin-b104d73c04426a04b07e201299297180b691a68d.tar.gz |
[gaim-migrate @ 17003]
add the PSM processing
need to store the PSM info to XML.
Thanks for Chris <ukdrizzle@yahoo.co.uk> 's code!
committed by MaYuan<mayuan2006@gmail.com>
committer: Ethan Blanton <elb@pidgin.im>
-rw-r--r-- | src/protocols/msn/msn.c | 72 | ||||
-rw-r--r-- | src/protocols/msn/notification.c | 30 | ||||
-rw-r--r-- | src/protocols/msn/servconn.c | 7 | ||||
-rw-r--r-- | src/protocols/msn/state.c | 28 | ||||
-rw-r--r-- | src/protocols/msn/state.h | 3 | ||||
-rw-r--r-- | src/protocols/msn/user.c | 21 | ||||
-rw-r--r-- | src/protocols/msn/user.h | 10 |
7 files changed, 147 insertions, 24 deletions
diff --git a/src/protocols/msn/msn.c b/src/protocols/msn/msn.c index 61f4690aad..9dce5ca5dc 100644 --- a/src/protocols/msn/msn.c +++ b/src/protocols/msn/msn.c @@ -517,18 +517,45 @@ msn_list_emblems(GaimBuddy *b, const char **se, const char **sw, *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 @@ msn_status_types(GaimAccount *account) { 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 --git a/src/protocols/msn/notification.c b/src/protocols/msn/notification.c index 209ba15ec0..cca84a3ff9 100644 --- a/src/protocols/msn/notification.c +++ b/src/protocols/msn/notification.c @@ -1393,12 +1393,40 @@ sbs_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) /*get the payload content*/ } +/* + * Get the UBX's PSM info + * Post it to the User status + * Thanks for Chris <ukdrizzle@yahoo.co.uk>'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 --git a/src/protocols/msn/servconn.c b/src/protocols/msn/servconn.c index f3bf5fb928..7760abf55a 100644 --- a/src/protocols/msn/servconn.c +++ b/src/protocols/msn/servconn.c @@ -235,13 +235,12 @@ msn_servconn_connect(MsnServConn *servconn, const char *host, int port) 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 diff --git a/src/protocols/msn/state.c b/src/protocols/msn/state.c index 634b7fdfe3..61f57b7abf 100644 --- a/src/protocols/msn/state.c +++ b/src/protocols/msn/state.c @@ -80,6 +80,34 @@ msn_build_psm(char * psmstr,char *mediastr,char * guidstr) 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 --git a/src/protocols/msn/state.h b/src/protocols/msn/state.h index 2ff4092e3b..c43a7b7431 100644 --- a/src/protocols/msn/state.h +++ b/src/protocols/msn/state.h @@ -61,6 +61,9 @@ const char *msn_state_get_text(MsnAwayType state); 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 --git a/src/protocols/msn/user.c b/src/protocols/msn/user.c index e02a945d5b..4502e57a3e 100644 --- a/src/protocols/msn/user.c +++ b/src/protocols/msn/user.c @@ -84,13 +84,19 @@ msn_user_update(MsnUser *user) 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 @@ msn_user_set_friendly_name(MsnUser *user, const char *name) } 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 --git a/src/protocols/msn/user.h b/src/protocols/msn/user.h index dd556639f3..dc3aec3d5e 100644 --- a/src/protocols/msn/user.h +++ b/src/protocols/msn/user.h @@ -48,6 +48,8 @@ struct _MsnUser 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_destroy(MsnUser *user); */ 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. * |