comparison libpurple/protocols/myspace/user.c @ 24764:c044eb54b7ac

Fix a leak in myspace prpl. In myspace.c:msim_process_reply, the clone of 'msg' sent to the callbacks were never freed. Also, do not unnecessarily dup a static string (which needs to be marked for translation after the string freeze).
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 17 Dec 2008 20:50:49 +0000
parents 8e75a1525156
children 22fd7467f0cc 47540809ae91
comparison
equal deleted inserted replaced
24763:a8643ca8d2e0 24764:c044eb54b7ac
386 * 386 *
387 * If the function has no buddy information, this function 387 * If the function has no buddy information, this function
388 * is a no-op (and returns FALSE). 388 * is a no-op (and returns FALSE).
389 */ 389 */
390 gboolean 390 gboolean
391 msim_store_user_info(MsimSession *session, MsimMessage *msg, MsimUser *user) 391 msim_store_user_info(MsimSession *session, const MsimMessage *msg, MsimUser *user)
392 { 392 {
393 gchar *username; 393 gchar *username;
394 MsimMessage *body, *body_node; 394 MsimMessage *body, *body_node;
395 395
396 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); 396 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
590 } 590 }
591 591
592 /** 592 /**
593 * Called after username is set. 593 * Called after username is set.
594 */ 594 */
595 static void msim_username_is_set_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) 595 static void msim_username_is_set_cb(MsimSession *session, const MsimMessage *userinfo, gpointer data)
596 { 596 {
597 gchar *username, *errmsg; 597 gchar *username;
598 const gchar *errmsg;
598 MsimMessage *body; 599 MsimMessage *body;
599 600
600 guint rid; 601 guint rid;
601 gint cmd,dsn,uid,lid,code; 602 gint cmd,dsn,uid,lid,code;
602 /* \persistr\\cmd\258\dsn\9\uid\204084363\lid\14\rid\369\body\UserName=TheAlbinoRhino1.Code=0\final\ */ 603 /* \persistr\\cmd\258\dsn\9\uid\204084363\lid\14\rid\369\body\UserName=TheAlbinoRhino1.Code=0\final\ */
608 cmd = msim_msg_get_integer(userinfo, "cmd"); 609 cmd = msim_msg_get_integer(userinfo, "cmd");
609 dsn = msim_msg_get_integer(userinfo, "dsn"); 610 dsn = msim_msg_get_integer(userinfo, "dsn");
610 uid = msim_msg_get_integer(userinfo, "uid"); 611 uid = msim_msg_get_integer(userinfo, "uid");
611 lid = msim_msg_get_integer(userinfo, "lid"); 612 lid = msim_msg_get_integer(userinfo, "lid");
612 body = msim_msg_get_dictionary(userinfo, "body"); 613 body = msim_msg_get_dictionary(userinfo, "body");
613 errmsg = g_strdup("An error occurred while trying to set the username.\n" 614 /* XXX: Mark for translation */
615 errmsg = ("An error occurred while trying to set the username.\n"
614 "Please try again, or visit http://editprofile.myspace.com/index.cfm?" 616 "Please try again, or visit http://editprofile.myspace.com/index.cfm?"
615 "fuseaction=profile.username to set your username."); 617 "fuseaction=profile.username to set your username.");
616 618
617 if (!body) { 619 if (!body) {
618 purple_debug_info("msim_username_is_set_cb", "No body"); 620 purple_debug_info("msim_username_is_set_cb", "No body");
665 } else { 667 } else {
666 /* Error! */ 668 /* Error! */
667 purple_debug_info("msim","username_is_set Error: Invalid cmd/dsn/lid combination"); 669 purple_debug_info("msim","username_is_set Error: Invalid cmd/dsn/lid combination");
668 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg); 670 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg);
669 } 671 }
670 g_free(errmsg);
671 } 672 }
672 673
673 /** 674 /**
674 * Asynchronously set new username, calling callback when receive result. 675 * Asynchronously set new username, calling callback when receive result.
675 * 676 *
749 /** 750 /**
750 * This is where we do a bit more than merely prompt the user. 751 * This is where we do a bit more than merely prompt the user.
751 * Now we have some real data to tell us the state of their requested username 752 * Now we have some real data to tell us the state of their requested username
752 * \persistr\\cmd\257\dsn\5\uid\204084363\lid\7\rid\367\body\UserName=TheAlbinoRhino1\final\ 753 * \persistr\\cmd\257\dsn\5\uid\204084363\lid\7\rid\367\body\UserName=TheAlbinoRhino1\final\
753 */ 754 */
754 static void msim_username_is_available_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) 755 static void msim_username_is_available_cb(MsimSession *session, const MsimMessage *userinfo, gpointer data)
755 { 756 {
756 MsimMessage *msg; 757 MsimMessage *msg;
757 gchar *username; 758 gchar *username;
758 MsimMessage *body; 759 MsimMessage *body;
759 gint userid; 760 gint userid;