pidgin/purple-plugin-pack

95c444eb0de8
Parents 66030123bbae
Children c84228b025f7
Bring in Eion's recent okcupid changes from SVN.
--- a/ChangeLog Sat Jul 09 02:06:51 2011 -0400
+++ b/ChangeLog Sat Jul 09 11:41:40 2011 -0400
@@ -3,6 +3,9 @@
* Added capsnot plugin (Eion Robb)
* Added icon-override plugin (Eion Robb)
* Added translate plugin (Eion Robb)
+ * Added Ning protocol plugin (Eion Robb)
+ * Added OkCupid protocol plugin (Eion Robb)
+ * Added Omegle protocol plugin (Eion Robb)
* Fix a use-after-free in IRC Helper.
* IRC Helper delays autojoins until after identifying with Purple 2.7.0 or
newer.
--- a/okcupid/okc_blist.c Sat Jul 09 02:06:51 2011 -0400
+++ b/okcupid/okc_blist.c Sat Jul 09 11:41:40 2011 -0400
@@ -83,11 +83,20 @@
purple_notify_userinfo(oca->pc, username, user_info, NULL, NULL);
purple_notify_user_info_destroy(user_info);
g_free(username);
- return;
+ return;
}
root = json_parser_get_root(parser);
info = json_node_get_object(root);
+ if (json_object_get_member(info, "error"))
+ {
+ purple_debug_error("okcupid", "got_info error\n");
+ purple_notify_userinfo(oca->pc, username, user_info, NULL, NULL);
+ purple_notify_user_info_destroy(user_info);
+ g_free(username);
+ return;
+ }
+
value_tmp = g_strdup_printf("%" G_GINT64_FORMAT " years", json_node_get_int(json_object_get_member(info, "age")));
purple_notify_user_info_add_pair(user_info, _("Age"), value_tmp);
g_free(value_tmp);
@@ -107,37 +116,43 @@
const gchar *buddy_icon = json_node_get_string(json_object_get_member(info, "thumbnail"));
PurpleBuddy *buddy = purple_find_buddy(oca->account, username);
- OkCupidBuddy *obuddy = buddy->proto_data;
- if (obuddy == NULL)
- {
- obuddy = g_new0(OkCupidBuddy, 1);
- obuddy->buddy = buddy;
- obuddy->oca = oca;
-
- // load the old buddy icon url from the icon 'checksum'
- const gchar *buddy_icon_url = purple_buddy_icons_get_checksum_for_user(buddy);
- if (buddy_icon_url != NULL)
- obuddy->thumb_url = g_strdup(buddy_icon_url);
-
- buddy->proto_data = obuddy;
- }
- if (!obuddy->thumb_url || !g_str_equal(obuddy->thumb_url, buddy_icon))
+ if (buddy != NULL)
{
- gchar *host, *path, *path2;
-
- g_free(obuddy->thumb_url);
- obuddy->thumb_url = purple_strreplace(buddy_icon, "/60x60/", "/256x256/");
-
- purple_url_parse(obuddy->thumb_url, &host, NULL, &path, NULL, NULL);
- if (path[0] != '/')
- path2 = g_strdup_printf("/%s", path);
- else
- path2 = g_strdup(path);
- okc_post_or_get(oca, OKC_METHOD_GET, host, path2, NULL, okc_buddy_icon_cb, g_strdup(username), FALSE);
-
- g_free(host);
- g_free(path);
- g_free(path2);
+ OkCupidBuddy *obuddy = buddy->proto_data;
+ if (obuddy == NULL)
+ {
+ obuddy = g_new0(OkCupidBuddy, 1);
+ obuddy->buddy = buddy;
+ obuddy->oca = oca;
+
+ // load the old buddy icon url from the icon 'checksum'
+ const gchar *buddy_icon_url = purple_buddy_icons_get_checksum_for_user(buddy);
+ if (buddy_icon_url != NULL)
+ obuddy->thumb_url = g_strdup(buddy_icon_url);
+
+ buddy->proto_data = obuddy;
+ }
+ if (!obuddy->thumb_url || !g_str_equal(obuddy->thumb_url, buddy_icon))
+ {
+ gchar *host, *path, *path2;
+ gchar *large_image_url;
+
+ g_free(obuddy->thumb_url);
+ obuddy->thumb_url = g_strdup(buddy_icon);
+ large_image_url = purple_strreplace(buddy_icon, "/60x60/", "/256x256/");
+
+ purple_url_parse(large_image_url, &host, NULL, &path, NULL, NULL);
+ g_free(large_image_url);
+ if (path[0] != '/')
+ path2 = g_strdup_printf("/%s", path);
+ else
+ path2 = g_strdup(path);
+ okc_post_or_get(oca, OKC_METHOD_GET, host, path2, NULL, okc_buddy_icon_cb, g_strdup(username), FALSE);
+
+ g_free(host);
+ g_free(path);
+ g_free(path2);
+ }
}
purple_notify_user_info_add_section_break(user_info);
--- a/okcupid/okc_connection.c Sat Jul 09 02:06:51 2011 -0400
+++ b/okcupid/okc_connection.c Sat Jul 09 11:41:40 2011 -0400
@@ -470,6 +470,12 @@
/* TODO: Fix keepalive and use it as much as possible */
keepalive = FALSE;
+
+ if (purple_account_get_bool(oca->account, "force_https", TRUE) && !(method & OKC_METHOD_SSL) &&
+ (!host || g_str_equal(host, "www.okcupid.com") || g_str_equal(host, "api.okcupid.com")))
+ {
+ method |= OKC_METHOD_SSL;
+ }
if (method & OKC_METHOD_SSL)
host = "www.okcupid.com";
@@ -569,7 +575,7 @@
* the TTL returned by the DNS server. We should expire things
* from the cache after some amount of time.
*/
- if (!is_proxy && !g_hostname_is_ip_address(host))
+ if (!is_proxy && !g_hostname_is_ip_address(host) && !(method & OKC_METHOD_SSL))
{
/* Don't do this for proxy connections, since proxies do the DNS lookup */
gchar *host_ip;
--- a/okcupid/okc_messages.c Sat Jul 09 02:06:51 2011 -0400
+++ b/okcupid/okc_messages.c Sat Jul 09 11:41:40 2011 -0400
@@ -172,15 +172,18 @@
obuddy->thumb_url = g_strdup(buddy_icon_url);
pbuddy->proto_data = obuddy;
- }
+ }
if (!obuddy->thumb_url || !g_str_equal(obuddy->thumb_url, buddy_icon))
{
gchar *host, *path, *path2;
+ gchar *large_image_url;
g_free(obuddy->thumb_url);
- obuddy->thumb_url = purple_strreplace(buddy_icon, "/60x60/", "/256x256/");
+ obuddy->thumb_url = g_strdup(buddy_icon);
+ large_image_url = purple_strreplace(buddy_icon, "/60x60/", "/256x256/");
- purple_url_parse(obuddy->thumb_url, &host, NULL, &path, NULL, NULL);
+ purple_url_parse(large_image_url, &host, NULL, &path, NULL, NULL);
+ g_free(large_image_url);
if (path[0] != '/')
path2 = g_strdup_printf("/%s", path);
else
@@ -191,6 +194,13 @@
g_free(path);
g_free(path2);
}
+ if (obuddy->status_cache == NULL && json_object_has_member(person, "age"))
+ {
+ gint age = json_node_get_int(json_object_get_member(person, "age"));
+ const gchar *gender = json_node_get_string(json_object_get_member(person, "gender"));
+ const gchar *location = json_node_get_string(json_object_get_member(person, "location"));
+ obuddy->status_cache = g_strdup_printf("%d / %s / %s", age, gender, location );
+ }
}
}
g_list_free(people_list);
@@ -253,7 +263,7 @@
g_list_free(event_list);
}
- if (unread_message_count != oca->last_message_count)
+ if (unread_message_count != oca->last_message_count && purple_account_get_check_mail(pc->account))
{
oca->last_message_count = unread_message_count;
if (unread_message_count > 0)
--- a/okcupid/okcupid.c Sat Jul 09 02:06:51 2011 -0400
+++ b/okcupid/okcupid.c Sat Jul 09 11:41:40 2011 -0400
@@ -291,11 +291,36 @@
{
buddy->proto_data = NULL;
+ g_free(obuddy->status_cache);
g_free(obuddy->thumb_url);
g_free(obuddy);
}
}
+void okc_fake_group_buddy(PurpleConnection *pc, const char *who, const char *old_group, const char *new_group)
+{
+ /* Do nuffink, so that buddies aren't deleted! */
+}
+
+gchar *okc_status_text(PurpleBuddy *buddy)
+{
+ OkCupidBuddy *obuddy = buddy->proto_data;
+ if (obuddy != NULL && obuddy->status_cache != NULL)
+ {
+ return g_strdup(obuddy->status_cache);
+ }
+ return NULL;
+}
+
+void okc_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full)
+{
+ OkCupidBuddy *obuddy = buddy->proto_data;
+ if (obuddy != NULL && obuddy->status_cache != NULL)
+ {
+ purple_notify_user_info_add_pair(user_info, NULL, obuddy->status_cache);
+ }
+}
+
/******************************************************************************/
/* Plugin functions */
/******************************************************************************/
@@ -324,11 +349,14 @@
option = purple_account_option_bool_new("Show people who visit your profile", "show_stalkers", TRUE);
prpl_info->protocol_options = g_list_append(prpl_info->protocol_options, option);
+
+ option = purple_account_option_bool_new("Always use HTTPS", "force_https", TRUE);
+ prpl_info->protocol_options = g_list_append(prpl_info->protocol_options, option);
}
static PurplePluginProtocolInfo prpl_info = {
/* options */
- OPT_PROTO_UNIQUE_CHATNAME,
+ OPT_PROTO_MAIL_CHECK,
NULL, /* user_splits */
NULL, /* protocol_options */
@@ -336,8 +364,8 @@
/*{"jpg", 0, 0, 50, 50, -1, PURPLE_ICON_SCALE_SEND}*/, /* icon_spec */
okc_list_icon, /* list_icon */
NULL, /* list_emblems */
- NULL, /* status_text */
- NULL, /* tooltip_text */
+ okc_status_text, /* status_text */
+ okc_tooltip_text, /* tooltip_text */
okc_statuses, /* status_types */
okc_blist_node_menu, /* blist_node_menu */
NULL, /* chat_info */
@@ -372,7 +400,7 @@
NULL, /* get_cb_info */
NULL, /* get_cb_away */
NULL, /* alias_buddy */
- NULL, /* group_buddy */
+ okc_fake_group_buddy, /* group_buddy */
NULL, /* rename_group */
okc_buddy_free, /* buddy_free */
NULL, /* convo_closed */
--- a/okcupid/okcupid.h Sat Jul 09 02:06:51 2011 -0400
+++ b/okcupid/okcupid.h Sat Jul 09 11:41:40 2011 -0400
@@ -95,6 +95,7 @@
OkCupidAccount *oca;
PurpleBuddy *buddy;
gchar *thumb_url;
+ gchar *status_cache;
};
gchar *okc_strdup_withhtml(const gchar *src);