Mercurial > pidgin
changeset 20391:0b0ecee55091
The second msn.tgz from SF Patch #1621854 from Ka-Hing Cheung.
"new version, fixes some crashes because group_id is char * but in some
places it's set to an int (!). skadotnet, I don't understand why you need
`if (!strcmp(type, "MFN")) {` in so many places, so I didn't include most
of them. I also have different versions of some of your fixes because I
already fixed them.
Group manipulations may still not work, at least it's not crashing :-)"
committer: Richard Laager <rlaager@wiktel.com>
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Sun, 15 Apr 2007 02:43:47 +0000 |
parents | d634f88e25d8 |
children | 9ba7dee775e1 |
files | libgaim/protocols/msn/contact.c libgaim/protocols/msn/contact.h libgaim/protocols/msn/directconn.c libgaim/protocols/msn/msn-utils.c libgaim/protocols/msn/msn-utils.h libgaim/protocols/msn/msn.c libgaim/protocols/msn/notification.c libgaim/protocols/msn/oim.c libgaim/protocols/msn/oim.h libgaim/protocols/msn/servconn.c libgaim/protocols/msn/state.c libgaim/protocols/msn/state.h libgaim/protocols/msn/sync.c libgaim/protocols/msn/user.c libgaim/protocols/msn/user.h |
diffstat | 15 files changed, 122 insertions(+), 93 deletions(-) [+] |
line wrap: on
line diff
--- a/libgaim/protocols/msn/contact.c Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/contact.c Sun Apr 15 02:43:47 2007 +0000 @@ -250,7 +250,7 @@ /*SOAP get contact list*/ void -msn_get_contact_list(MsnContact * contact,char * update_time) +msn_get_contact_list(MsnContact * contact, const char *update_time) { MsnSoapReq *soap_request; char *body = NULL; @@ -378,7 +378,7 @@ /*setup the Display Name*/ if (!strcmp(type, "Me")){ char *friendly; - friendly = xmlnode_get_data(xmlnode_get_child(contactInfo,"displayName")); + friendly = xmlnode_get_data(xmlnode_get_child(contactInfo, "displayName")); gaim_connection_set_display_name(session->account->gc, gaim_url_decode(friendly)); g_free(friendly); }
--- a/libgaim/protocols/msn/contact.h Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/contact.h Sun Apr 15 02:43:47 2007 +0000 @@ -213,7 +213,7 @@ void msn_contact_destroy(MsnContact *contact); void msn_contact_connect(MsnContact *contact); -void msn_get_contact_list(MsnContact * contact,char * update); +void msn_get_contact_list(MsnContact * contact, const char *update); void msn_get_address_book(MsnContact *contact, const char * update, const char * gupdate); /*contact SOAP Operation*/
--- a/libgaim/protocols/msn/directconn.c Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/directconn.c Sun Apr 15 02:43:47 2007 +0000 @@ -422,7 +422,6 @@ msn_directconn_connect(MsnDirectConn *directconn, const char *host, int port) { MsnSession *session; - int r; g_return_val_if_fail(directconn != NULL, FALSE); g_return_val_if_fail(host != NULL, TRUE);
--- a/libgaim/protocols/msn/msn-utils.c Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/msn-utils.c Sun Apr 15 02:43:47 2007 +0000 @@ -26,6 +26,8 @@ #include "time.h" //#include <openssl/md5.h> +char *rand_guid(void); + /************************************************************************** * Util **************************************************************************/ @@ -150,12 +152,12 @@ * Currently only support the UTF-8 and base64 encode */ char * -msn_encode_mime(char *str) +msn_encode_mime(const char *str) { char *base64; - base64 = gaim_base64_encode(str,strlen(str)); - return g_strdup_printf("=?utf-8?B?%s?=",base64); + base64 = gaim_base64_encode((guchar *)str, strlen(str)); + return g_strdup_printf("=?utf-8?B?%s?=", base64); } /* @@ -549,7 +551,7 @@ # endif /* GCC. */ #endif /* Not __P. */ -#if ! HAVE_LOCALTIME_R && ! defined localtime_r +#if defined(HAVE_LOCALTIME_R) && ! HAVE_LOCALTIME_R && ! defined localtime_r # ifdef _LIBC # define localtime_r __localtime_r # else
--- a/libgaim/protocols/msn/msn-utils.h Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/msn-utils.h Sun Apr 15 02:43:47 2007 +0000 @@ -25,12 +25,12 @@ #define _MSN_UTILS_H_ /*encode the str to RFC2047 style*/ -char * msn_encode_mime(char *str); +char * msn_encode_mime(const char *str); /** * Generate the Random GUID */ -char * rand_guid(); +char * rand_guid(void); /** * Parses the MSN message formatting into a format compatible with Gaim.
--- a/libgaim/protocols/msn/msn.c Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/msn.c Sun Apr 15 02:43:47 2007 +0000 @@ -137,9 +137,12 @@ return; } - msn_cmdproc_send(cmdproc, "REA", "%s %s", - gaim_account_get_username(account), - alias); + if (*alias != '\0') { + msn_cmdproc_send(cmdproc, "PRP", "MFN %s", alias); + } else { + msn_cmdproc_send(cmdproc, "PRP", "MFN %s", + gaim_url_encode(gaim_account_get_username(account))); + } } static void @@ -524,7 +527,8 @@ { GaimPresence *presence; GaimStatus *status; - char *msg, *psm_str, *tmp2, *text, *name; + const char *msg, *name; + char *psm_str, *tmp2, *text; presence = gaim_buddy_get_presence(buddy); status = gaim_presence_get_active_status(presence); @@ -903,9 +907,8 @@ oim = session->oim; friendname = msn_encode_mime(account->username); - msn_oim_prep_send_msg_info(oim, - gaim_account_get_username(account),friendname,who, - message); + msn_oim_prep_send_msg_info(oim, gaim_account_get_username(account), + friendname, who, message); msn_oim_send_msg(oim); } return 1;
--- a/libgaim/protocols/msn/notification.c Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/notification.c Sun Apr 15 02:43:47 2007 +0000 @@ -37,9 +37,10 @@ /**************************************************************************** * Local Function Prototype ****************************************************************************/ -void msn_notification_post_adl(MsnCmdProc *cmdproc,char *payload ,int payload_len); -void msn_add_contact_xml(xmlnode *mlNode,const char *passport,int list_op,int type); +static void msn_notification_fqy_yahoo(MsnSession *session, const char *passport); +static void msn_notification_post_adl(MsnCmdProc *cmdproc, char *payload, int payload_len); +static void msn_add_contact_xml(xmlnode *mlNode, const char *passport, int list_op, int type); /************************************************************************** * Main @@ -233,15 +234,17 @@ if (!g_ascii_strcasecmp(cmd->params[1], "OK")){ /* authenticate OK */ + /* friendly name part no longer true in msnp11 */ +#if 0 const char *friendly = gaim_url_decode(cmd->params[3]); gaim_connection_set_display_name(gc, friendly); - +#endif msn_session_set_login_step(session, MSN_LOGIN_STEP_SYN); // msn_cmdproc_send(cmdproc, "SYN", "%s", "0"); //TODO we should use SOAP contact to fetch contact list - }else if (!g_ascii_strcasecmp(cmd->params[1], "TWN")){ + } else if (!g_ascii_strcasecmp(cmd->params[1], "TWN")){ /* Passport authentication */ char **elems, **cur, **tokens; @@ -561,7 +564,7 @@ * Buddy Lists **************************************************************************/ /* add contact to xmlnode */ -void +static void msn_add_contact_xml(xmlnode *mlNode,const char *passport,int list_op,int type) { xmlnode *d_node,*c_node; @@ -622,10 +625,19 @@ g_free(tokens); } -void +static void msn_notification_post_adl(MsnCmdProc *cmdproc,char *payload, int payload_len) { MsnTransaction *trans; + const char *display_name; + const char *friendly; + + display_name = gaim_connection_get_display_name(cmdproc->session->account->gc); + if (display_name) { + friendly = gaim_url_encode(display_name); + msn_cmdproc_send(cmdproc, "PRP", "MFN %s", friendly); + } + gaim_debug_info("MaYuan","Send ADL{%s}\n",payload); trans = msn_transaction_new(cmdproc, "ADL","%d",strlen(payload)); @@ -662,8 +674,8 @@ } /*Post FQY to NS,Inform add a Yahoo User*/ -void -msn_notification_fqy_yahoo(MsnSession *session,char *passport) +static void +msn_notification_fqy_yahoo(MsnSession *session, const char *passport) { MsnTransaction *trans; MsnCmdProc *cmdproc; @@ -715,8 +727,10 @@ static void rml_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { +#if 0 MsnTransaction *trans; char * payload; +#endif gaim_debug_info("MaYuan","Process ADL\n"); #if 0 @@ -820,7 +834,7 @@ group_name = gaim_url_decode(cmd->params[2]); - msn_group_new(session->userlist, group_id, group_name); + msn_group_new(session->userlist, cmd->params[3], group_name); /* There is a user that must me moved to this group */ if (cmd->trans->data) @@ -1045,6 +1059,12 @@ msn_user_set_work_phone(session->user, NULL); else if (!strcmp(type, "PHM")) msn_user_set_mobile_phone(session->user, NULL); + else if (!strcmp(type, "MFM")) { + type = cmd->params[1]; + gaim_connection_set_display_name( + gaim_account_get_connection(session->account), + gaim_url_decode(cmd->params[2])); + } } } @@ -1052,11 +1072,10 @@ reg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { MsnSession *session; - int group_id; - const char *group_name; + const char *group_id, *group_name; session = cmdproc->session; - group_id = atoi(cmd->params[2]); + group_id = cmd->params[2]; group_name = gaim_url_decode(cmd->params[3]); msn_userlist_rename_group_id(session->userlist, group_id, group_name); @@ -1082,10 +1101,8 @@ { MsnSession *session; MsnUser *user; - const char *list; - const char *passport; + const char *group_id, *list, *passport; MsnListId list_id; - int group_id; session = cmdproc->session; list = cmd->params[1]; @@ -1097,9 +1114,9 @@ list_id = msn_get_list_id(list); if (cmd->param_count == 5) - group_id = atoi(cmd->params[4]); + group_id = cmd->params[4]; else - group_id = -1; + group_id = NULL; msn_got_rem_user(session, user, list_id, group_id); msn_user_update(user); @@ -1109,10 +1126,10 @@ rmg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { MsnSession *session; - int group_id; + const char *group_id; session = cmdproc->session; - group_id = atoi(cmd->params[2]); + group_id = cmd->params[2]; msn_userlist_remove_group_id(session->userlist, group_id); } @@ -1120,7 +1137,7 @@ static void rmg_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) { - int group_id; + const char *group_id; char **params; params = g_strsplit(trans->params, " ", 0); @@ -1412,7 +1429,8 @@ GaimAccount *account; GaimConnection *gc; MsnUser *user; - const char *passport, *psm_str; + const char *passport; + char *psm_str; /*get the payload content*/ // gaim_debug_info("MaYuan","UBX {%s} payload{%s}\n",cmd->params[0], cmd->payload); @@ -1507,7 +1525,7 @@ msn_session_set_bnode(session); session->contact = msn_contact_new(session); clLastChange = gaim_blist_node_get_string(msn_session_get_bnode(session),"CLLastChange"); - msn_get_contact_list(session->contact,clLastChange); + msn_get_contact_list(session->contact, clLastChange); // msn_contact_connect(session->contact); } @@ -1738,7 +1756,6 @@ const char *group_id) { MsnCmdProc *cmdproc; - MsnTransaction *trans; xmlnode *adl_node; char *payload; int payload_len;
--- a/libgaim/protocols/msn/oim.c Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/oim.c Sun Apr 15 02:43:47 2007 +0000 @@ -30,9 +30,18 @@ /*Local Function Prototype*/ static void msn_oim_post_single_get_msg(MsnOim *oim,const char *msgid); -void msn_oim_retrieve_connect_init(MsnSoapConn *soapconn); -void msn_oim_send_connect_init(MsnSoapConn *soapconn); -void msn_oim_free_send_req(MsnOimSendReq *req); +static MsnOimSendReq *msn_oim_new_send_req(const char *from_member, + const char *friendname, + const char* to_member, + gint send_seq, + const char *msg); +static void msn_oim_retrieve_connect_init(MsnSoapConn *soapconn); +static void msn_oim_send_connect_init(MsnSoapConn *soapconn); +static void msn_oim_free_send_req(MsnOimSendReq *req); +static void msn_oim_report_to_user(MsnOim *oim, char *msg_str); +static void msn_oim_get_process(MsnOim *oim, char *oim_msg); +static char *msn_oim_msg_to_str(MsnOim *oim, const char *body); +const void msn_oim_send_process(MsnOim *oim, const char *body, int len); /*new a OIM object*/ MsnOim * @@ -73,11 +82,10 @@ g_free(oim); } -MsnOimSendReq * -msn_oim_new_send_req(char *from_member, - char*friendname,char* to_member, - gint send_seq, - char *msg) +static MsnOimSendReq * +msn_oim_new_send_req(const char *from_member, const char*friendname, + const char* to_member, gint send_seq, + const char *msg) { MsnOimSendReq *request; @@ -90,7 +98,7 @@ return request; } -void +static void msn_oim_free_send_req(MsnOimSendReq *req) { g_return_if_fail(req != NULL); @@ -107,8 +115,8 @@ * OIM send SOAP request * **************************************/ /*encode the message to OIM Message Format*/ -char * -msn_oim_msg_to_str(MsnOim *oim,char *body) +static char * +msn_oim_msg_to_str(MsnOim *oim, const char *body) { char *oim_body,*oim_base64; @@ -154,14 +162,13 @@ * Process the send return SOAP string * If got SOAP Fault,get the lock key,and resend it. */ -void -msn_oim_send_process(MsnOim *oim,char *body,int len) +const void +msn_oim_send_process(MsnOim *oim, const char *body, int len) { - xmlnode *responseNode,*bodyNode; - xmlnode *faultNode,*faultCodeNode,*faultstringNode; - xmlnode *detailNode,*challengeNode; - char *faultCodeStr,*faultstring; - char *challenge; + xmlnode *responseNode, *bodyNode; + xmlnode *faultNode, *faultCodeNode, *faultstringNode; + xmlnode *detailNode, *challengeNode; + char *faultCodeStr, *faultstring; responseNode = xmlnode_from_str(body,len); g_return_if_fail(responseNode != NULL); @@ -245,9 +252,9 @@ } void -msn_oim_prep_send_msg_info(MsnOim *oim, - char *membername,char*friendname,char *tomember, - char * msg) +msn_oim_prep_send_msg_info(MsnOim *oim, const char *membername, + const char* friendname, const char *tomember, + const char * msg) { MsnOimSendReq *request; @@ -324,7 +331,6 @@ GaimInputCondition cond) { MsnSoapConn * soapconn = data; - MsnOim * oim = soapconn->session->oim; gaim_debug_info("MaYuan","OIM delete read buffer:{%s}\n",soapconn->body); @@ -404,8 +410,8 @@ } /*Post the Offline Instant Message to User Conversation*/ -void -msn_oim_report_to_user(MsnOim *oim,char *msg_str) +static void +msn_oim_report_to_user(MsnOim *oim, char *msg_str) { MsnMessage *message; char *date,*from,*decode_msg; @@ -413,13 +419,13 @@ char **tokens; char *start,*end; int has_nick = 0; - char *passport_str,*passport; + char *passport_str, *passport; char *msg_id; message = msn_message_new(MSN_MSG_UNKNOWN); - msn_message_parse_payload(message,msg_str,strlen(msg_str), - MSG_OIM_LINE_DEM, MSG_OIM_BODY_DEM); + msn_message_parse_payload(message, msg_str, strlen(msg_str), + MSG_OIM_LINE_DEM, MSG_OIM_BODY_DEM); gaim_debug_info("MaYuan","oim body:{%s}\n",message->body); decode_msg = gaim_base64_decode(message->body,&body_len); date = (char *)g_hash_table_lookup(message->attr_table, "Date"); @@ -463,8 +469,8 @@ /* Parse the XML data, * prepare to report the OIM to user */ -void -msn_oim_get_process(MsnOim *oim,char *oim_msg) +static void +msn_oim_get_process(MsnOim *oim, char *oim_msg) { xmlnode *oimNode,*bodyNode,*responseNode,*msgNode; char *msg_data,*msg_str; @@ -569,7 +575,7 @@ } /*msn oim retrieve server connect init */ -void +static void msn_oim_retrieve_connect_init(MsnSoapConn *soapconn) { gaim_debug_info("MaYuan","msn_oim_connect...\n"); @@ -579,7 +585,8 @@ } /*Msn OIM Send Server Connect Init Function*/ -void msn_oim_send_connect_init(MsnSoapConn *sendconn) +static void +msn_oim_send_connect_init(MsnSoapConn *sendconn) { gaim_debug_info("MaYuan","msn oim send connect init...\n"); msn_soap_init(sendconn,MSN_OIM_SEND_HOST,1,
--- a/libgaim/protocols/msn/oim.h Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/oim.h Sun Apr 15 02:43:47 2007 +0000 @@ -132,9 +132,9 @@ void msn_parse_oim_msg(MsnOim *oim,const char *xmlmsg); /*Send OIM Message*/ -void msn_oim_prep_send_msg_info(MsnOim *oim, - char *membername,char*friendname,char *tomember, - char * msg); +void msn_oim_prep_send_msg_info(MsnOim *oim, const char *membername, + const char *friendname, const char *tomember, + const char * msg); void msn_oim_send_msg(MsnOim *oim);
--- a/libgaim/protocols/msn/servconn.c Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/servconn.c Sun Apr 15 02:43:47 2007 +0000 @@ -203,7 +203,6 @@ msn_servconn_connect(MsnServConn *servconn, const char *host, int port) { MsnSession *session; - int r; g_return_val_if_fail(servconn != NULL, FALSE); g_return_val_if_fail(host != NULL, FALSE);
--- a/libgaim/protocols/msn/state.c Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/state.c Sun Apr 15 02:43:47 2007 +0000 @@ -39,7 +39,8 @@ }; /* Local Function Prototype*/ -char * msn_build_psm(char * psmstr,char *mediastr,char * guidstr); +static char *msn_build_psm(const char *psmstr,const char *mediastr, + const char *guidstr); /* * WLM media PSM info build prcedure @@ -49,8 +50,8 @@ * <CurrentMedia>\0Games\01\0Playing {0}\0Game Name\0</CurrentMedia>\ * <CurrentMedia>\0Office\01\0Office Message\0Office App Name\0</CurrentMedia>" */ -char * -msn_build_psm(char * psmstr,char *mediastr,char * guidstr) +static char * +msn_build_psm(const char *psmstr,const char *mediastr, const char *guidstr) { xmlnode *dataNode,*psmNode,*mediaNode,*guidNode; char *result; @@ -81,11 +82,11 @@ } /*get the PSM info from the XML string*/ -const char * -msn_get_psm(char *xml_str,gsize len) +char * +msn_get_psm(char *xml_str, gsize len) { xmlnode *payloadNode, *psmNode; - char *psm_str,*psm; + char *psm_str, *psm; gaim_debug_info("Ma Yuan","msn get PSM\n"); payloadNode = xmlnode_from_str(xml_str, len); @@ -119,7 +120,8 @@ GaimStatus *status; MsnCmdProc *cmdproc; MsnTransaction *trans; - char *payload,*statusline; + char *payload; + const char *statusline; g_return_if_fail(session != NULL); g_return_if_fail(session->notification != NULL); @@ -133,7 +135,7 @@ presence = gaim_account_get_presence(account); status = gaim_presence_get_active_status(presence); statusline = gaim_status_get_attr_string(status, "message"); - session ->psm = g_strdup(msn_build_psm(statusline,NULL,NULL)); + session ->psm = msn_build_psm(statusline, NULL, NULL); payload = session->psm; gaim_debug_info("MaYuan","UUX{%s}\n",payload);
--- a/libgaim/protocols/msn/state.h Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/state.h Sun Apr 15 02:43:47 2007 +0000 @@ -62,7 +62,7 @@ void msn_set_psm(MsnSession *session); /*get the PSM info from the XML string*/ -const char * msn_get_psm(char *xml_str,gsize len); +char * msn_get_psm(char *xml_str,gsize len); MsnAwayType msn_state_from_account(GaimAccount *account);
--- a/libgaim/protocols/msn/sync.c Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/sync.c Sun Apr 15 02:43:47 2007 +0000 @@ -86,10 +86,9 @@ lsg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { MsnSession *session = cmdproc->session; - const char *name; - int group_id; + const char *name, *group_id; - group_id = atoi(cmd->params[0]); + group_id = cmd->params[0]; name = gaim_url_decode(cmd->params[1]); msn_group_new(session->userlist, group_id, name);
--- a/libgaim/protocols/msn/user.c Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/user.c Sun Apr 15 02:43:47 2007 +0000 @@ -90,7 +90,7 @@ account = user->userlist->session->account; if (user->statusline != NULL) { - char *status = g_strdup_printf("%s - %s", user->status, user->statusline); + //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) { @@ -188,7 +188,7 @@ void msn_user_set_op(MsnUser *user,int list_op) { - g_return_if_fail(list_op != NULL); + g_return_if_fail(list_op != 0); user->list_op |= list_op; } @@ -277,14 +277,14 @@ GaimBuddy *b; GaimGroup *g; const char *passport; - const char *group_id; + char *group_id; const char *group_name; g_return_if_fail(user != NULL); g_return_if_fail(id != NULL); group_id = g_strdup(id); - user->group_ids = g_list_append(user->group_ids,group_id); + user->group_ids = g_list_append(user->group_ids, group_id); userlist = user->userlist; account = userlist->session->account; @@ -337,7 +337,8 @@ g_return_if_fail(id != NULL); user->group_ids = g_list_remove(user->group_ids, id); - g_free(id); + /* khc need to use g_list_find_custom here to find the right link */ + //g_free(id); } void
--- a/libgaim/protocols/msn/user.h Sun Apr 15 02:18:17 2007 +0000 +++ b/libgaim/protocols/msn/user.h Sun Apr 15 02:43:47 2007 +0000 @@ -48,7 +48,7 @@ char * uid; /*< User Id */ const char *status; /**< The state of the user. */ - const char *statusline; /**< The state of the user. */ + char *statusline; /**< The state of the user. */ gboolean idle; /**< The idle state of the user. */