Thursday, October 1, 2009

Nostalgic: Old Gaim Plugin

I feel a bit nostalgic right now. I was Googling myself (name, usernames, email addresses) and one of the things I found was a Gaim plugin I'd written years ago. Considering Gaim renamed itself to Pidgin in April 2007, that's an indication of how old this plugin is. It would probably require an entire rewrite to work with libpurple and Pidgin now. Anyway here's the old code:

This is Google's cache of http://tun0.net/misc/trash/gaim-random-away/gaim-random-away-0.1/random-away.c. It is a snapshot of the page as it appeared on Aug 22, 2009 18:31:57 GMT. The current page could have changed in the meantime. Learn more

Text-only version
These search terms are highlighted: thisemailaddress gmail com

/*
* Gaim Random Away Plugin
* V. Hari
* ========================================
*
* Read the COPYING file for license information.
* Read the README file for general information.
*
*/

#include "internal.h"
#include "debug.h"
#include "plugin.h"
#include "version.h"
#include "gtkgaim.h"
#include "signals.h"
#include "away.h"
#include "gtkblist.h"

#include
#include

#define RAWAY_PLUGIN "random-away"
#define RAWAY_VERSION "0.1"

static GaimPlugin *raway_plugin = NULL;

static int
raway_away_foo(void)
{
GSList *l;
const char *away_name = "You Are (Fight Club)";
guint i, n;

n = ((guint)rand() % g_slist_length(away_messages))+1;

for(l = away_messages, i = 1; l; l = l->next)
{
//if(strcmp(away_name, ((struct away_message *)l->data)->name))
if(i++ == n)
{
do_away_message(NULL, l->data);
break;
}
}

return TRUE;
}

static int
raway_make_menu(void)
{
GtkWidget *menuitem;

gaim_debug(GAIM_DEBUG_INFO, RAWAY_PLUGIN, "random-away creating menu\n");
gaim_separator(awaymenu);
menuitem = gtk_menu_item_new_with_label(_("Random Away"));
gtk_menu_shell_append(GTK_MENU_SHELL(awaymenu), menuitem);
g_signal_connect(G_OBJECT(menuitem), "activate",
G_CALLBACK(raway_away_foo), NULL);
gtk_widget_show(menuitem);

return TRUE;
}

static void
signed_on_cb(GaimConnection *gc, void *data)
{
raway_make_menu();
}


static gboolean
plugin_load(GaimPlugin *plugin)
{
void *conn_handle = gaim_connections_get_handle();

gaim_debug(GAIM_DEBUG_INFO, RAWAY_PLUGIN, "random-away plugin loaded.\n");

srand(time(NULL));

gaim_signal_connect(conn_handle, "signed-on", plugin,
GAIM_CALLBACK(signed_on_cb), NULL);

return TRUE;
}

static gboolean
plugin_unload(GaimPlugin *plugin)
{
gaim_debug(GAIM_DEBUG_INFO, RAWAY_PLUGIN, "random-away plugin unloaded.\n");

return TRUE;
}

static GaimPluginInfo info =
{
GAIM_PLUGIN_MAGIC,
GAIM_MAJOR_VERSION,
GAIM_MINOR_VERSION,
GAIM_PLUGIN_STANDARD,
NULL,
0,
NULL,
GAIM_PRIORITY_DEFAULT,
NULL,
N_("Random Away Plugin"),
RAWAY_VERSION,
N_("Set a random away message."),
N_("Set a random away message."),
"V. Hari ",
"http://packetjunkie.net/",
plugin_load,
plugin_unload,
NULL,
NULL,
NULL,
NULL,
NULL
};

static void
init_plugin(GaimPlugin *plugin)
{
}

GAIM_INIT_PLUGIN(random-away, init_plugin, info)