view plugins/idle.c @ 8999:8f838ae3e710

[gaim-migrate @ 9774] " This patch renames the existing received-*-msg signals to receiving-*msg to fit the naming of other signals where a pointer to the message is passed (writing, sending, displaying) It adds new received-*-msg signals which are emitted after the receiving signals, in line with the other conversation signals (wrote, sent, displayed) This is necessary to allow plugins which depend on the final received message to work alongside plugins which may modify the message. One known example of this is festival-gaim alongside gaim-encryption - festival-gaim would try to "speak" the encrypted text: http://sf.net/tracker/?func=detail&aid=943216&group_id=89763&atid=591320 I've tested this with gaim-encryption and festival-gaim (locally modified so gaim-encryption uses the receiving signal and festival uses the received signal) All in-tree users of received-*-msg are updated to use receiving-*-msg if they do modify the message, the conversation-signals documentation is updated, the signals-test.c & signal-test.tcl plugins are also updated." --Stu Tomlinson committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Fri, 21 May 2004 14:33:32 +0000
parents c5825a04fb97
children 67421e0dc497
line wrap: on
line source

/* a nifty little plugin to set your idle time to whatever you want it to be.
 * useful for almost nothing. mostly just a demo plugin. but it's fun to have
 * 40-day idle times.
 */

#include "internal.h"

#include "connection.h"
#include "debug.h"
#include "multi.h"
#include "plugin.h"
#include "request.h"
#include "server.h"

#define IDLE_PLUGIN_ID "gtk-idle"


static void
idle_action_ok(void *ignored, GaimRequestFields *fields)
{
	time_t t;
	int tm;
	GaimAccount *acct;
	GaimConnection *gc;

	tm = gaim_request_fields_get_integer(fields, "mins");
	acct = gaim_request_fields_get_account(fields, "acct");
	gc = gaim_account_get_connection(acct);

	gaim_debug(GAIM_DEBUG_INFO, "idle",
			"setting idle time for %s to %d\n",
			gaim_account_get_username(acct), tm);
	time(&t);
	t -= 60 * tm;
	gc->last_sent_time = t;
	serv_set_idle(gc, 60 * tm);
	gc->is_idle = 0;
}


static void
idle_action(GaimPlugin *plugin)
{
	/* Use the super fancy request API */

	GaimRequestFields *request;
	GaimRequestFieldGroup *group;
	GaimRequestField *field;

	group = gaim_request_field_group_new(NULL);

	field = gaim_request_field_account_new("acct", _("Account"), NULL);
	gaim_request_field_account_set_show_all(field, FALSE);
	gaim_request_field_group_add_field(group, field);
	
	field = gaim_request_field_int_new("mins", _("Minutes"), 10);
	gaim_request_field_group_add_field(group, field);

	request = gaim_request_fields_new();
	gaim_request_fields_add_group(request, group);

	gaim_request_fields(plugin,
			N_("I'dle Mak'er"),
			_("Set Account Idle Time"),
			NULL,
			request,
			_("_Set"), G_CALLBACK(idle_action_ok),
			_("_Cancel"), NULL,
			NULL);
}


static GList *
actions(GaimPlugin *plugin)
{
	GList *l = NULL;
	struct plugin_actions_menu *pam;

	pam = g_new0(struct plugin_actions_menu, 1);
	pam->label = _("Set Account Idle Time");
	pam->callback = idle_action;
	pam->plugin = plugin;
	l = g_list_append(l, pam);

	return l;
}


static GaimPluginInfo info =
{
	GAIM_PLUGIN_API_VERSION,
	GAIM_PLUGIN_STANDARD,
	NULL,
	0,
	NULL,
	GAIM_PRIORITY_DEFAULT,
	IDLE_PLUGIN_ID,
	N_("I'dle Mak'er"),
	VERSION,
	N_("Allows you to hand-configure how long you've been idle for"),
	N_("Allows you to hand-configure how long you've been idle for"),
	"Eric Warmenhoven <eric@warmenhoven.org>",
	GAIM_WEBSITE,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	actions
};


static void
init_plugin(GaimPlugin *plugin)
{
}


GAIM_INIT_PLUGIN(idle, init_plugin, info)