Mercurial > pidgin
changeset 19400:97fcd4429c2f
propagate from branch 'im.pidgin.pidgin' (head 54129de486cffc56bea31f4ea38c3972e450958b)
to branch 'im.pidgin.soc.2007.msimprpl' (head fea00266488c85ba94e735d5885d991298e8f9d7)
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Fri, 24 Aug 2007 06:21:20 +0000 |
parents | 649ac48fce1d (current diff) 5ed02bbcf1ff (diff) |
children | ff23b2470850 |
files | COPYRIGHT pidgin/pixmaps/emotes/default/24/madtongue.png |
diffstat | 6 files changed, 95 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/blist.c Fri Aug 24 03:08:54 2007 +0000 +++ b/libpurple/blist.c Fri Aug 24 06:21:20 2007 +0000 @@ -1190,6 +1190,9 @@ group = purple_group_new(_("Chats")); purple_blist_add_group(group, purple_blist_get_last_sibling(purplebuddylist->root)); + } else { + /* Fail if tried to add buddy to a group that isn't on the blist. #2752. */ + g_return_if_fail(purple_find_group(group->name)); } } else { group = (PurpleGroup*)node->parent; @@ -1284,6 +1287,10 @@ g = (PurpleGroup *)((PurpleBlistNode *)c)->parent; } else { if (group) { + /* Fail if trying to add buddy to a group that is not on the buddy list. + * Fix for #2752. */ + g_return_if_fail(purple_find_group(group->name)); + g = group; } else { g = purple_group_new(_("Buddies"));
--- a/libpurple/protocols/myspace/CHANGES Fri Aug 24 03:08:54 2007 +0000 +++ b/libpurple/protocols/myspace/CHANGES Fri Aug 24 06:21:20 2007 +0000 @@ -1,3 +1,19 @@ +2007-08-22 Jeff Connelly <pidgin@xyzzy.cjb.net> - 0.15 +* Incomplete implementation of adding friends from myspace.com. +* Change msim_msg_get() to start at the given node instead of the beginning. +* Add msim_msg_get_*_from_element() to access data in MsimMessagElement *'s. +* Use MsimMessage dictionaries everywhere in incoming messages, instead of + the old GHashTable method. Dictionary type is now fully implemented. +* Add functions to loop over MsimMessages. +* Link to myspace.com profile in Get Info. +* Conditionally use my proposed attention API if defined. +* Propagate to im.pidgin.pidgin branch for 2.1.2. +* GSoC ended on 2007-08-20. The code in this release hasn't changed since + then. I did, however, bump the version number to 0.15 to distinguish this + release from the previous one. But there were no code changes. I updated + the text files, too. +* Note: msimprpl will continue to be developed as time permits. + 2007-08-12 Jeff Connelly <jeff2@soc.pidgin.im> - 0.14 * Full emoticon support (except no difference between nerd and geek emoticons), thanks to a number of new icons from Hylke Bons.
--- a/libpurple/protocols/myspace/README Fri Aug 24 03:08:54 2007 +0000 +++ b/libpurple/protocols/myspace/README Fri Aug 24 06:21:20 2007 +0000 @@ -1,4 +1,4 @@ -MySpaceIM Protocol Plugin by Jeff Connelly 20070807 +MySpaceIM Protocol Plugin for Libpurple by Jeff Connelly 20070807 Greetings. This package contains a plugin for libpurple (as used in @@ -6,7 +6,7 @@ network and send/receive messages. Functionality is only basic as of yet, and this code should be considered alpha quality. -This code is being developed under Google Summer of Code 2007. +This code was initially developed under Google Summer of Code 2007. For features and TODO, see http://developer.pidgin.im/wiki/MySpaceIM @@ -28,7 +28,5 @@ Enjoy, -Jeff Connelly -California Polytechnic State University at San Luis Obispo -myspaceim@xyzzy.cjb.net -jeff2@soc.pidgin.im +msimprpl@xyzzy.cjb.net
--- a/libpurple/protocols/myspace/myspace.c Fri Aug 24 03:08:54 2007 +0000 +++ b/libpurple/protocols/myspace/myspace.c Fri Aug 24 06:21:20 2007 +0000 @@ -1669,8 +1669,8 @@ * by Alexandr Shutko, who maintains OSCAR protocol documentation). */ purple_debug_info("msim", "Unrecognized data on account for %s\n", - session->account->username ? session->account->username - : "(NULL)"); + (session && session->account && session->account->username) ? + session->account->username : "(NULL)"); if (note) { purple_debug_info("msim", "(Note: %s)\n", note); } @@ -1784,7 +1784,7 @@ return rc; } -/* Process an incoming media (buddy icon) message. */ +/* Process an incoming media (message background?) message. */ static gboolean msim_incoming_media(MsimSession *session, MsimMessage *msg) { @@ -2656,11 +2656,18 @@ purple_debug_info("msim_downloaded_buddy_icon", "Downloaded %d bytes\n", len); + if (!url_text) { + purple_debug_info("msim_downloaded_buddy_icon", + "failed to download icon for %s", + user->buddy->name); + return; + } + purple_buddy_icons_set_for_user(user->buddy->account, user->buddy->name, - (gchar *)url_text, len, - /* Use URL itself as buddy icon "checksum" */ - user->image_url); + g_memdup((gchar *)url_text, len), len, + /* Use URL itself as buddy icon "checksum" (TODO: ETag) */ + user->image_url); /* checksum */ } /** Store a field of information about a buddy. */ @@ -2696,6 +2703,15 @@ const gchar *previous_url; user->image_url = g_strdup(value_str); + + /* Instead of showing 'no photo' picture, show nothing. */ + if (!strcmp(user->image_url, "http://x.myspace.com/images/no_pic.gif")) + { + purple_buddy_icons_set_for_user(user->buddy->account, + user->buddy->name, + NULL, 0, NULL); + return; + } previous_url = purple_buddy_icons_get_checksum_for_user(user->buddy); @@ -2703,6 +2719,9 @@ if (!previous_url || strcmp(previous_url, user->image_url)) { purple_util_fetch_url(user->image_url, TRUE, NULL, TRUE, msim_downloaded_buddy_icon, (gpointer)user); } + } else if (!strcmp(key_str, "LastImageUpdated")) { + /* TODO: use somewhere */ + user->last_image_updated = atol(value_str); } else if (!strcmp(key_str, "Headline")) { user->headline = g_strdup(value_str); } else { @@ -3207,7 +3226,7 @@ msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) { - gchar *uid_field_name, *uid_before; + gchar *uid_field_name, *uid_before, *username; guint uid; MsimMessage *msg, *body; @@ -3222,6 +3241,19 @@ uid = msim_msg_get_integer(body, "UserID"); msim_msg_free(body); + username = msim_msg_get_string(msg, "_username"); + + if (!uid) { + gchar *msg; + + msg = g_strdup_printf(_("No such user: %s"), username); + purple_notify_error(NULL, NULL, _("User lookup"), msg); + g_free(msg); + g_free(username); + //msim_msg_free(msg); + return; + } + uid_field_name = msim_msg_get_string(msg, "_uid_field_name"); uid_before = msim_msg_get_string(msg, "_uid_before"); @@ -3238,6 +3270,7 @@ */ g_free(uid_field_name); g_free(uid_before); + g_free(username); //msim_msg_free(msg); } @@ -3908,6 +3941,8 @@ group_name = msim_msg_get_string(contact_info, "GroupName"); if (group_name) { group = purple_group_new(group_name); + purple_debug_info("msim_add_contact_from_server_cb", + "adding to GroupName: %s\n", group_name); g_free(group_name); } else { group = purple_group_new(_("IM Friends")); @@ -3916,13 +3951,17 @@ /* 2. Get or create buddy */ buddy = purple_find_buddy(session->account, username); if (!buddy) { + purple_debug_info("msim_add_contact_from_server_cb", + "creating new buddy: %s\n", username); buddy = purple_buddy_new(session->account, username, NULL); } + /* Add group to beginning. See #2752. */ + purple_blist_add_group(group, NULL); + /* TODO: use 'Position' in contact_info to take into account where buddy is */ purple_blist_add_buddy(buddy, NULL, group, NULL /* insertion point */); - /* 3. Update buddy information */ user = msim_get_user_from_buddy(buddy); @@ -3943,14 +3982,14 @@ * * @return TRUE if added. * */ -static void +static gboolean msim_add_contact_from_server(MsimSession *session, MsimMessage *contact_info) { guint uid; const gchar *username; uid = msim_msg_get_integer(contact_info, "ContactID"); - g_return_if_fail(uid != 0); + g_return_val_if_fail(uid != 0, FALSE); /* Lookup the username, since NickName and IMName is unreliable */ username = msim_uid2username_from_blist(session, uid); @@ -3965,6 +4004,10 @@ } else { msim_add_contact_from_server_cb(session, NULL, (gpointer)msim_msg_clone(contact_info)); } + + /* Say that the contact was added, even if we're still looking up + * their username. */ + return TRUE; } /** Called when contact list is received from server. */ @@ -3972,12 +4015,16 @@ msim_got_contact_list(MsimSession *session, MsimMessage *reply, gpointer user_data) { MsimMessage *body, *body_node; + gchar *msg; + guint buddy_count; msim_msg_dump("msim_got_contact_list: reply=%s", reply); body = msim_msg_get_dictionary(reply, "body"); g_return_if_fail(body != NULL); + buddy_count = 0; + for (body_node = body; body_node != NULL; body_node = msim_msg_get_next_element_node(body_node)) @@ -3989,10 +4036,18 @@ if (!strcmp(elem->name, "ContactID")) { /* Will look for first contact in body_node */ - msim_add_contact_from_server(session, body_node); + if (msim_add_contact_from_server(session, body_node)) { + ++buddy_count; + } } } + msg = g_strdup_printf(_("%d buddies were added or updated"), buddy_count); + + purple_notify_info(session->account, _("Add contacts from server"), msg, NULL); + + g_free(msg); + msim_msg_free(body); }
--- a/libpurple/protocols/myspace/myspace.h Fri Aug 24 03:08:54 2007 +0000 +++ b/libpurple/protocols/myspace/myspace.h Fri Aug 24 06:21:20 2007 +0000 @@ -90,7 +90,7 @@ #define MSIM_LANGUAGE_NAME_ENGLISH "ENGLISH" /* msimprpl version string of this plugin */ -#define MSIM_PRPL_VERSION_STRING "0.14" +#define MSIM_PRPL_VERSION_STRING "0.15" /* Default server */ #define MSIM_SERVER "im.myspace.akadns.net" @@ -226,6 +226,7 @@ gchar *username; gchar *band_name, *song_name; gchar *image_url; + guint last_image_updated; } MsimUser;
--- a/libpurple/protocols/myspace/release.sh Fri Aug 24 03:08:54 2007 +0000 +++ b/libpurple/protocols/myspace/release.sh Fri Aug 24 06:21:20 2007 +0000 @@ -4,7 +4,7 @@ # Package a new msimprpl for release. Must be run with bash. -VERSION=0.14 +VERSION=0.15 make # Include 'myspace' directory in archive, so it can easily be unextracted # into ~/pidgin/libpurple/protocols at the correct location.