Skip to content

Commit

Permalink
Add support for age/gender/location as a status message when two peop…
Browse files Browse the repository at this point in the history
…le are IM'ing
  • Loading branch information
eionrobb committed Mar 27, 2011
1 parent 0bad1f4 commit 79cc199
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
13 changes: 12 additions & 1 deletion libokcupid.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ static void okc_buddy_free(PurpleBuddy *buddy)
{
buddy->proto_data = NULL;

g_free(obuddy->status_cache);
g_free(obuddy->thumb_url);
g_free(obuddy);
}
Expand All @@ -301,6 +302,16 @@ void okc_fake_group_buddy(PurpleConnection *pc, const char *who, const char *old
/* 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;
}

/******************************************************************************/
/* Plugin functions */
/******************************************************************************/
Expand Down Expand Up @@ -344,7 +355,7 @@ static PurplePluginProtocolInfo prpl_info = {
/*{"jpg", 0, 0, 50, 50, -1, PURPLE_ICON_SCALE_SEND}*/, /* icon_spec */
okc_list_icon, /* list_icon */
NULL, /* list_emblems */
NULL, /* status_text */
okc_status_text, /* status_text */
NULL, /* tooltip_text */
okc_statuses, /* status_types */
okc_blist_node_menu, /* blist_node_menu */
Expand Down
1 change: 1 addition & 0 deletions libokcupid.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ struct _OkCupidBuddy {
OkCupidAccount *oca;
PurpleBuddy *buddy;
gchar *thumb_url;
gchar *status_cache;
};

gchar *okc_strdup_withhtml(const gchar *src);
Expand Down
7 changes: 7 additions & 0 deletions okc_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ void got_new_messages(OkCupidAccount *oca, gchar *data,
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);
Expand Down

0 comments on commit 79cc199

Please sign in to comment.