pidgin/purple-plugin-pack
The okcupid plugin now compiles on !Windows. No idea if it works.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/okcupid/Makefile.am Wed Jul 06 10:16:05 2011 -0400
@@ -0,0 +1,59 @@
+# $(PIXMAPS) #add \ to the line above and uncomment this line if we get pixmaps +okcupiddir = $(PURPLE_LIBDIR) +okcupid_la_LDFLAGS = -module -avoid-version +okcupid_LTLIBRARIES = okcupid.la +# uncomment the lines below if we get pixmaps +#okcupidpix16dir=$(PIDGIN_PIXMAPSDIR)/protocols/16 +#okcupidpix16_DATA=16/okcupid.png +#okcupidpix22dir=$(PIDGIN_PIXMAPSDIR)/protocols/22 +#okcupidpix22_DATA=22/okcupid.png +#okcupidpix48dir=$(PIDGIN_PIXMAPSDIR)/protocols/48 +#okcupidpix48_DATA=48/okcupid.png + -DLIBDIR=\"$(PURPLE_LIBDIR)\" \ + -DDATADIR=\"$(PURPLE_DATADIR)\" \ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/okcupid/Makefile.mingw Wed Jul 06 10:16:05 2011 -0400
@@ -0,0 +1,17 @@
+# Description: Makefile for okcupid plugin. +include $(PP_TOP)/win_pp.mak --- a/okcupid/libokcupid.c Tue Jul 05 09:27:44 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,433 +0,0 @@
- * libokcupid is the property of its developers. See the COPYRIGHT file
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "okc_connection.h"
-#include "okc_messages.h"
-/******************************************************************************/
-/******************************************************************************/
-gchar *okc_convert_unicode(const gchar *input)
- gchar unicode_char_str[6];
- next_pos = input_string = g_strdup(input);
- while ((next_pos = strstr(next_pos, "\\u")))
- sscanf(next_pos, "\\u%4x", &unicode_char);
- /* turn it to a char* */
- unicode_char_len = g_unichar_to_utf8(unicode_char, unicode_char_str);
- /* shove it back into the string */
- g_memmove(next_pos, unicode_char_str, unicode_char_len);
- /* move all the data after the \u0000 along */
- g_stpcpy(next_pos + unicode_char_len, next_pos + 6);
- output_string = g_strcompress(input_string);
-/* Like purple_strdup_withhtml, but escapes htmlentities too */
-gchar *okc_strdup_withhtml(const gchar *src)
- g_return_val_if_fail(src != NULL, NULL);
- /* New length is (length of src) + (number of \n's * 3) + (number of &'s * 5) +
- (number of <'s * 4) + (number of >'s *4) + (number of "'s * 6) -
- (number of \r's) + 1 */
- for (i = 0; src[i] != '\0'; i++)
- if (src[i] == '\n' || src[i] == '<' || src[i] == '>')
- else if (src[i] == '&')
- else if (src[i] == '"')
- else if (src[i] != '\r')
- dest = g_malloc(destsize);
- /* Copy stuff, ignoring \r's, because they are dumb */
- for (i = 0, j = 0; src[i] != '\0'; i++) {
- strcpy(&dest[j], "<BR>");
- } else if (src[i] == '<') {
- strcpy(&dest[j], "<");
- } else if (src[i] == '>') {
- strcpy(&dest[j], ">");
- } else if (src[i] == '&') {
- strcpy(&dest[j], "&");
- } else if (src[i] == '"') {
- strcpy(&dest[j], """);
- } else if (src[i] != '\r')
- dest[destsize-1] = '\0';
-/******************************************************************************/
-/******************************************************************************/
-static const char *okc_list_icon(PurpleAccount *account, PurpleBuddy *buddy)
-static GList *okc_statuses(PurpleAccount *account)
- PurpleStatusType *status;
- purple_debug_info("okcupid", "statuses\n");
- /* OkCupid people are either online, online with no IM, offline */
- status = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE);
- types = g_list_append(types, status);
- status = purple_status_type_new_full(PURPLE_STATUS_OFFLINE, NULL, NULL, TRUE, TRUE, FALSE);
- types = g_list_append(types, status);
- purple_debug_info("okcupid", "statuses return\n");
-static gboolean okc_get_messages_failsafe(OkCupidAccount *oca)
- if (oca->last_messages_download_time < (time(NULL) - (60*5))) {
- /* Messages haven't been downloaded in a while-
- * something is probably wrong */
- purple_debug_warning("okcupid",
- "executing message check failsafe\n");
- okc_get_new_messages(oca);
-static void okc_login_cb(OkCupidAccount *oca, gchar *response, gsize len,
- purple_connection_update_progress(oca->pc, _("Authenticating"), 2, 3);
- purple_connection_error(oca->pc, "No login response");
- parser = json_parser_new();
- if (!json_parser_load_from_data(parser, response, len, NULL))
- purple_connection_error(oca->pc, "Error parsing login response");
- root = json_parser_get_root(parser);
- message = json_node_get_object(root);
- status = json_node_get_int(json_object_get_member(message, "status"));
- purple_connection_error(oca->pc, "Bad username or password");
- /* ok, we're logged in now! */
- purple_connection_set_state(oca->pc, PURPLE_CONNECTED);
- /* This will kick off our long-poll message retrieval loop */
- okc_get_new_messages_now(oca);
- oca->perpetual_messages_timer = purple_timeout_add_seconds(15,
- (GSourceFunc)okc_get_messages_failsafe, oca);
-static void okc_login(PurpleAccount *account)
- gchar *postdata, *encoded_username, *encoded_password;
- purple_debug_info("okcupid", "login\n");
- /* Create account and initialize state */
- oca = g_new0(OkCupidAccount, 1);
- oca->account = account;
- oca->pc = purple_account_get_connection(account);
- oca->last_messages_download_time = time(NULL) - 60; /* 60 secs is a safe buffer */
- oca->server_seqid = purple_account_get_int(oca->account, "server_seqid", 0);
- oca->server_gmt = purple_account_get_int(oca->account, "server_gmt", 0);
- oca->cookie_table = g_hash_table_new_full(g_str_hash, g_str_equal,
- oca->hostname_ip_cache = g_hash_table_new_full(g_str_hash, g_str_equal,
- oca->waiting_conns = g_queue_new();
- account->gc->proto_data = oca;
- purple_connection_set_state(oca->pc, PURPLE_CONNECTING);
- purple_connection_update_progress(oca->pc, _("Connecting"), 1, 3);
- encoded_username = g_strdup(purple_url_encode(
- purple_account_get_username(account)));
- encoded_password = g_strdup(purple_url_encode(
- purple_account_get_password(account)));
- postdata = g_strdup_printf("username=%s&password=%s",
- encoded_username, encoded_password);
- g_free(encoded_username);
- g_free(encoded_password);
- okc_post_or_get(oca, OKC_METHOD_POST | OKC_METHOD_SSL, "www.okcupid.com",
- "/login", postdata, okc_login_cb, NULL, FALSE);
-static void okc_close(PurpleConnection *pc)
- purple_debug_info("okcupid", "disconnecting account\n");
- okc_post_or_get(oca, OKC_METHOD_POST, NULL, "/logout",
- "ajax=1", NULL, NULL, FALSE);
- if (oca->new_messages_check_timer)
- purple_timeout_remove(oca->new_messages_check_timer);
- if (oca->buddy_presence_timer)
- purple_timeout_remove(oca->buddy_presence_timer);
- if (oca->perpetual_messages_timer)
- purple_timeout_remove(oca->perpetual_messages_timer);
- purple_debug_info("okcupid", "destroying %d waiting connections\n",
- g_queue_get_length(oca->waiting_conns));
- while (!g_queue_is_empty(oca->waiting_conns))
- okc_connection_destroy(g_queue_pop_tail(oca->waiting_conns));
- g_queue_free(oca->waiting_conns);
- purple_debug_info("okcupid", "destroying %d incomplete connections\n",
- g_slist_length(oca->conns));
- while (oca->conns != NULL)
- okc_connection_destroy(oca->conns->data);
- while (oca->dns_queries != NULL) {
- PurpleDnsQueryData *dns_query = oca->dns_queries->data;
- purple_debug_info("okcupid", "canceling dns query for %s\n",
- purple_dnsquery_get_host(dns_query));
- oca->dns_queries = g_slist_remove(oca->dns_queries, dns_query);
- purple_dnsquery_destroy(dns_query);
- g_hash_table_destroy(oca->cookie_table);
- g_hash_table_destroy(oca->hostname_ip_cache);
- //Store server_seqid and server_gmt so that we dont download all the messages on startup
- purple_account_set_int(oca->account, "server_seqid", oca->server_seqid);
- purple_account_set_int(oca->account, "server_gmt", oca->server_gmt);
-static void okc_buddy_free(PurpleBuddy *buddy)
- OkCupidBuddy *obuddy = buddy->proto_data;
- buddy->proto_data = NULL;
- g_free(obuddy->thumb_url);
-/******************************************************************************/
-/******************************************************************************/
-static gboolean plugin_load(PurplePlugin *plugin)
-static gboolean plugin_unload(PurplePlugin *plugin)
-static void plugin_init(PurplePlugin *plugin)
- PurpleAccountOption *option;
- PurplePluginInfo *info = plugin->info;
- PurplePluginProtocolInfo *prpl_info = info->extra_info;
- option = purple_account_option_string_new("Host", "host", "api.okcupid.com");
- prpl_info->protocol_options = g_list_append(prpl_info->protocol_options, option);
- option = purple_account_option_bool_new("Show messages sent from website", "show_sent_messages", FALSE);
- prpl_info->protocol_options = g_list_append(prpl_info->protocol_options, option);
- 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);
-static PurplePluginProtocolInfo prpl_info = {
- OPT_PROTO_UNIQUE_CHATNAME,
- NULL, /* user_splits */
- NULL, /* protocol_options */
- NO_BUDDY_ICONS /* icon_spec */
- /*{"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_statuses, /* status_types */
- okc_blist_node_menu, /* blist_node_menu */
- NULL, /* chat_info_defaults */
- okc_send_im, /* send_im */
- NULL, /* send_typing */
- okc_get_info, /* get_info */
- NULL, /* change_passwd */
- okc_add_buddy, /* add_buddy */
- NULL, /* add_buddies */
- okc_remove_buddy, /* remove_buddy */
- NULL, /* remove_buddies */
- okc_block_buddy, /* add_deny */
- NULL, /* set_permit_deny */
- NULL, /* reject chat invite */
- NULL, /* get_chat_name */
- NULL, /* chat_invite */
- NULL, /* chat_whisper */
- NULL, /* register_user */
- NULL, /* get_cb_info */
- NULL, /* get_cb_away */
- NULL, /* alias_buddy */
- NULL, /* group_buddy */
- NULL, /* rename_group */
- okc_buddy_free, /* buddy_free */
- NULL, /* convo_closed */
- purple_normalize_nocase,/* normalize */
- NULL, /* set_buddy_icon */
- NULL, /* remove_group */
- NULL, /* get_cb_real_name */
- NULL, /* set_chat_topic */
- NULL, /* find_blist_chat */
- NULL, /* roomlist_get_list */
- NULL, /* roomlist_cancel */
- NULL, /* roomlist_expand_category */
- NULL, /* can_receive_file */
- NULL, /* offline_message */
- NULL, /* whiteboard_prpl_ops */
- NULL, /* roomlist_room_serialize */
- NULL, /* unregister_user */
- NULL, /* send_attention */
- NULL, /* attention_types */
- sizeof(PurplePluginProtocolInfo), /* struct_size */
- NULL, /* get_account_text_table */
-static PurplePluginInfo info = {
- PURPLE_PLUGIN_PROTOCOL, /* type */
- NULL, /* ui_requirement */
- NULL, /* dependencies */
- PURPLE_PRIORITY_DEFAULT, /* priority */
- "prpl-bigbrownchunx-okcupid", /* id */
- OKCUPID_PLUGIN_VERSION, /* version */
- N_("OkCupid Protocol Plugin"), /* summary */
- N_("OkCupid Protocol Plugin"), /* description */
- "Eion Robb <eionrobb@gmail.com>", /* author */
- plugin_load, /* load */
- plugin_unload, /* unload */
- &prpl_info, /* extra_info */
-PURPLE_INIT_PLUGIN(okcupid, plugin_init, info);
--- a/okcupid/libokcupid.h Tue Jul 05 09:27:44 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
- * libokcupid is the property of its developers. See the COPYRIGHT file
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
-#define OKCUPID_PLUGIN_VERSION "2.03"
-#define OKC_MAX_CONNECTIONS 16
-#include <json-glib/json-glib.h>
-#ifndef G_GNUC_NULL_TERMINATED
-# define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
-# define G_GNUC_NULL_TERMINATED
-# endif /* __GNUC__ >= 4 */
-#endif /* G_GNUC_NULL_TERMINATED */
-# define dlopen(a,b) LoadLibrary(a)
-# define dlsym(a,b) GetProcAddress(a,b)
-# define dlclose(a) FreeLibrary(a)
-# include <netinet/in.h>
-# include <sys/socket.h>
-typedef struct _OkCupidAccount OkCupidAccount;
-typedef struct _OkCupidBuddy OkCupidBuddy;
-typedef void (*OkCupidProxyCallbackFunc)(OkCupidAccount *oca, gchar *data, gsize data_len, gpointer user_data);
-struct _OkCupidAccount {
- PurpleAccount *account;
- GHashTable *hostname_ip_cache;
- GSList *conns; /**< A list of all active OkCupidConnections */
- GQueue *waiting_conns; /**< A list of all OkCupidConnections waiting to process */
- GHashTable *cookie_table;
- time_t last_messages_download_time;
- guint new_messages_check_timer;
- guint perpetual_messages_timer;
- guint buddy_presence_timer;
- guint last_message_count;
-gchar *okc_strdup_withhtml(const gchar *src);
-gchar *okc_convert_unicode(const gchar *input);
-#endif /* LIBOKCUPID_H */
--- a/okcupid/okc_blist.c Tue Jul 05 09:27:44 2011 -0400
+++ b/okcupid/okc_blist.c Wed Jul 06 10:16:05 2011 -0400
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "okc_connection.h"
#include "okc_messages.h"
--- a/okcupid/okc_blist.h Tue Jul 05 09:27:44 2011 -0400
+++ b/okcupid/okc_blist.h Wed Jul 06 10:16:05 2011 -0400
@@ -21,7 +21,7 @@
void okc_blist_wink_buddy(PurpleBlistNode *node, gpointer data);
void okc_get_info(PurpleConnection *pc, const gchar *uid);
--- a/okcupid/okc_connection.h Tue Jul 05 09:27:44 2011 -0400
+++ b/okcupid/okc_connection.h Wed Jul 06 10:16:05 2011 -0400
@@ -21,7 +21,7 @@
#ifndef OKCUPID_CONNECTION_H
#define OKCUPID_CONNECTION_H
--- a/okcupid/okc_messages.c Tue Jul 05 09:27:44 2011 -0400
+++ b/okcupid/okc_messages.c Wed Jul 06 10:16:05 2011 -0400
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "okc_messages.h"
#include "okc_connection.h"
--- a/okcupid/okc_messages.h Tue Jul 05 09:27:44 2011 -0400
+++ b/okcupid/okc_messages.h Wed Jul 06 10:16:05 2011 -0400
@@ -21,7 +21,7 @@
#ifndef OKCUPID_MESSAGES_H
#define OKCUPID_MESSAGES_H
int okc_send_im(PurpleConnection *pc, const gchar *who, const gchar *message,
PurpleMessageFlags flags);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/okcupid/okcupid.c Wed Jul 06 10:16:05 2011 -0400
@@ -0,0 +1,433 @@
+ * libokcupid is the property of its developers. See the COPYRIGHT file + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +#include "okc_connection.h" +#include "okc_messages.h" +/******************************************************************************/ +/******************************************************************************/ +gchar *okc_convert_unicode(const gchar *input) + gchar unicode_char_str[6]; + next_pos = input_string = g_strdup(input); + while ((next_pos = strstr(next_pos, "\\u"))) + sscanf(next_pos, "\\u%4x", &unicode_char); + /* turn it to a char* */ + unicode_char_len = g_unichar_to_utf8(unicode_char, unicode_char_str); + /* shove it back into the string */ + g_memmove(next_pos, unicode_char_str, unicode_char_len); + /* move all the data after the \u0000 along */ + g_stpcpy(next_pos + unicode_char_len, next_pos + 6); + output_string = g_strcompress(input_string); +/* Like purple_strdup_withhtml, but escapes htmlentities too */ +gchar *okc_strdup_withhtml(const gchar *src) + g_return_val_if_fail(src != NULL, NULL); + /* New length is (length of src) + (number of \n's * 3) + (number of &'s * 5) + + (number of <'s * 4) + (number of >'s *4) + (number of "'s * 6) - + (number of \r's) + 1 */ + for (i = 0; src[i] != '\0'; i++) + if (src[i] == '\n' || src[i] == '<' || src[i] == '>') + else if (src[i] == '&') + else if (src[i] == '"') + else if (src[i] != '\r') + dest = g_malloc(destsize); + /* Copy stuff, ignoring \r's, because they are dumb */ + for (i = 0, j = 0; src[i] != '\0'; i++) { + strcpy(&dest[j], "<BR>"); + } else if (src[i] == '<') { + strcpy(&dest[j], "<"); + } else if (src[i] == '>') { + strcpy(&dest[j], ">"); + } else if (src[i] == '&') { + strcpy(&dest[j], "&"); + } else if (src[i] == '"') { + strcpy(&dest[j], """); + } else if (src[i] != '\r') + dest[destsize-1] = '\0'; +/******************************************************************************/ +/******************************************************************************/ +static const char *okc_list_icon(PurpleAccount *account, PurpleBuddy *buddy) +static GList *okc_statuses(PurpleAccount *account) + PurpleStatusType *status; + purple_debug_info("okcupid", "statuses\n"); + /* OkCupid people are either online, online with no IM, offline */ + status = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE); + types = g_list_append(types, status); + status = purple_status_type_new_full(PURPLE_STATUS_OFFLINE, NULL, NULL, TRUE, TRUE, FALSE); + types = g_list_append(types, status); + purple_debug_info("okcupid", "statuses return\n"); +static gboolean okc_get_messages_failsafe(OkCupidAccount *oca) + if (oca->last_messages_download_time < (time(NULL) - (60*5))) { + /* Messages haven't been downloaded in a while- + * something is probably wrong */ + purple_debug_warning("okcupid", + "executing message check failsafe\n"); + okc_get_new_messages(oca); +static void okc_login_cb(OkCupidAccount *oca, gchar *response, gsize len, + purple_connection_update_progress(oca->pc, _("Authenticating"), 2, 3); + purple_connection_error(oca->pc, "No login response"); + parser = json_parser_new(); + if (!json_parser_load_from_data(parser, response, len, NULL)) + purple_connection_error(oca->pc, "Error parsing login response"); + root = json_parser_get_root(parser); + message = json_node_get_object(root); + status = json_node_get_int(json_object_get_member(message, "status")); + purple_connection_error(oca->pc, "Bad username or password"); + /* ok, we're logged in now! */ + purple_connection_set_state(oca->pc, PURPLE_CONNECTED); + /* This will kick off our long-poll message retrieval loop */ + okc_get_new_messages_now(oca); + oca->perpetual_messages_timer = purple_timeout_add_seconds(15, + (GSourceFunc)okc_get_messages_failsafe, oca); +static void okc_login(PurpleAccount *account) + gchar *postdata, *encoded_username, *encoded_password; + purple_debug_info("okcupid", "login\n"); + /* Create account and initialize state */ + oca = g_new0(OkCupidAccount, 1); + oca->account = account; + oca->pc = purple_account_get_connection(account); + oca->last_messages_download_time = time(NULL) - 60; /* 60 secs is a safe buffer */ + oca->server_seqid = purple_account_get_int(oca->account, "server_seqid", 0); + oca->server_gmt = purple_account_get_int(oca->account, "server_gmt", 0); + oca->cookie_table = g_hash_table_new_full(g_str_hash, g_str_equal, + oca->hostname_ip_cache = g_hash_table_new_full(g_str_hash, g_str_equal, + oca->waiting_conns = g_queue_new(); + account->gc->proto_data = oca; + purple_connection_set_state(oca->pc, PURPLE_CONNECTING); + purple_connection_update_progress(oca->pc, _("Connecting"), 1, 3); + encoded_username = g_strdup(purple_url_encode( + purple_account_get_username(account))); + encoded_password = g_strdup(purple_url_encode( + purple_account_get_password(account))); + postdata = g_strdup_printf("username=%s&password=%s", + encoded_username, encoded_password); + g_free(encoded_username); + g_free(encoded_password); + okc_post_or_get(oca, OKC_METHOD_POST | OKC_METHOD_SSL, "www.okcupid.com", + "/login", postdata, okc_login_cb, NULL, FALSE); +static void okc_close(PurpleConnection *pc) + purple_debug_info("okcupid", "disconnecting account\n"); + okc_post_or_get(oca, OKC_METHOD_POST, NULL, "/logout", + "ajax=1", NULL, NULL, FALSE); + if (oca->new_messages_check_timer) + purple_timeout_remove(oca->new_messages_check_timer); + if (oca->buddy_presence_timer) + purple_timeout_remove(oca->buddy_presence_timer); + if (oca->perpetual_messages_timer) + purple_timeout_remove(oca->perpetual_messages_timer); + purple_debug_info("okcupid", "destroying %d waiting connections\n", + g_queue_get_length(oca->waiting_conns)); + while (!g_queue_is_empty(oca->waiting_conns)) + okc_connection_destroy(g_queue_pop_tail(oca->waiting_conns)); + g_queue_free(oca->waiting_conns); + purple_debug_info("okcupid", "destroying %d incomplete connections\n", + g_slist_length(oca->conns)); + while (oca->conns != NULL) + okc_connection_destroy(oca->conns->data); + while (oca->dns_queries != NULL) { + PurpleDnsQueryData *dns_query = oca->dns_queries->data; + purple_debug_info("okcupid", "canceling dns query for %s\n", + purple_dnsquery_get_host(dns_query)); + oca->dns_queries = g_slist_remove(oca->dns_queries, dns_query); + purple_dnsquery_destroy(dns_query); + g_hash_table_destroy(oca->cookie_table); + g_hash_table_destroy(oca->hostname_ip_cache); + //Store server_seqid and server_gmt so that we dont download all the messages on startup + purple_account_set_int(oca->account, "server_seqid", oca->server_seqid); + purple_account_set_int(oca->account, "server_gmt", oca->server_gmt); +static void okc_buddy_free(PurpleBuddy *buddy) + OkCupidBuddy *obuddy = buddy->proto_data; + buddy->proto_data = NULL; + g_free(obuddy->thumb_url); +/******************************************************************************/ +/******************************************************************************/ +static gboolean plugin_load(PurplePlugin *plugin) +static gboolean plugin_unload(PurplePlugin *plugin) +static void plugin_init(PurplePlugin *plugin) + PurpleAccountOption *option; + PurplePluginInfo *info = plugin->info; + PurplePluginProtocolInfo *prpl_info = info->extra_info; + option = purple_account_option_string_new("Host", "host", "api.okcupid.com"); + prpl_info->protocol_options = g_list_append(prpl_info->protocol_options, option); + option = purple_account_option_bool_new("Show messages sent from website", "show_sent_messages", FALSE); + prpl_info->protocol_options = g_list_append(prpl_info->protocol_options, option); + 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); +static PurplePluginProtocolInfo prpl_info = { + OPT_PROTO_UNIQUE_CHATNAME, + NULL, /* user_splits */ + NULL, /* protocol_options */ + NO_BUDDY_ICONS /* icon_spec */ + /*{"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_statuses, /* status_types */ + okc_blist_node_menu, /* blist_node_menu */ + NULL, /* chat_info_defaults */ + okc_send_im, /* send_im */ + NULL, /* send_typing */ + okc_get_info, /* get_info */ + NULL, /* change_passwd */ + okc_add_buddy, /* add_buddy */ + NULL, /* add_buddies */ + okc_remove_buddy, /* remove_buddy */ + NULL, /* remove_buddies */ + okc_block_buddy, /* add_deny */ + NULL, /* set_permit_deny */ + NULL, /* reject chat invite */ + NULL, /* get_chat_name */ + NULL, /* chat_invite */ + NULL, /* chat_whisper */ + NULL, /* register_user */ + NULL, /* get_cb_info */ + NULL, /* get_cb_away */ + NULL, /* alias_buddy */ + NULL, /* group_buddy */ + NULL, /* rename_group */ + okc_buddy_free, /* buddy_free */ + NULL, /* convo_closed */ + purple_normalize_nocase,/* normalize */ + NULL, /* set_buddy_icon */ + NULL, /* remove_group */ + NULL, /* get_cb_real_name */ + NULL, /* set_chat_topic */ + NULL, /* find_blist_chat */ + NULL, /* roomlist_get_list */ + NULL, /* roomlist_cancel */ + NULL, /* roomlist_expand_category */ + NULL, /* can_receive_file */ + NULL, /* offline_message */ + NULL, /* whiteboard_prpl_ops */ + NULL, /* roomlist_room_serialize */ + NULL, /* unregister_user */ + NULL, /* send_attention */ + NULL, /* attention_types */ + sizeof(PurplePluginProtocolInfo), /* struct_size */ + NULL, /* get_account_text_table */ +static PurplePluginInfo info = { + PURPLE_PLUGIN_PROTOCOL, /* type */ + NULL, /* ui_requirement */ + NULL, /* dependencies */ + PURPLE_PRIORITY_DEFAULT, /* priority */ + "prpl-bigbrownchunx-okcupid", /* id */ + OKCUPID_PLUGIN_VERSION, /* version */ + N_("OkCupid Protocol Plugin"), /* summary */ + N_("OkCupid Protocol Plugin"), /* description */ + "Eion Robb <eionrobb@gmail.com>", /* author */ + plugin_load, /* load */ + plugin_unload, /* unload */ + &prpl_info, /* extra_info */ +PURPLE_INIT_PLUGIN(okcupid, plugin_init, info); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/okcupid/okcupid.h Wed Jul 06 10:16:05 2011 -0400
@@ -0,0 +1,103 @@
+ * libokcupid is the property of its developers. See the COPYRIGHT file + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +#define OKCUPID_PLUGIN_VERSION "2.03" +#define OKC_MAX_CONNECTIONS 16 +#include <json-glib/json-glib.h> +#ifndef G_GNUC_NULL_TERMINATED +# define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) +# define G_GNUC_NULL_TERMINATED +# endif /* __GNUC__ >= 4 */ +#endif /* G_GNUC_NULL_TERMINATED */ +# define dlopen(a,b) LoadLibrary(a) +# define dlsym(a,b) GetProcAddress(a,b) +# define dlclose(a) FreeLibrary(a) +# include <netinet/in.h> +# include <sys/socket.h> +typedef struct _OkCupidAccount OkCupidAccount; +typedef struct _OkCupidBuddy OkCupidBuddy; +typedef void (*OkCupidProxyCallbackFunc)(OkCupidAccount *oca, gchar *data, gsize data_len, gpointer user_data); +struct _OkCupidAccount { + PurpleAccount *account; + GHashTable *hostname_ip_cache; + GSList *conns; /**< A list of all active OkCupidConnections */ + GQueue *waiting_conns; /**< A list of all OkCupidConnections waiting to process */ + GHashTable *cookie_table; + time_t last_messages_download_time; + guint new_messages_check_timer; + guint perpetual_messages_timer; + guint buddy_presence_timer; + guint last_message_count; +gchar *okc_strdup_withhtml(const gchar *src); +gchar *okc_convert_unicode(const gchar *input); +#endif /* LIBOKCUPID_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/okcupid/plugins.cfg Wed Jul 06 10:16:05 2011 -0400
@@ -0,0 +1,9 @@
+[OkCupid Protocol Plugin] +depends=purple json-glib +summary=Protocol plugin for the OkCupid social networking site framework +description=Protocol plugin for the OkCupid social networking site framework