annotate plugins/idle.c @ 11597:036bd21c5560

[gaim-migrate @ 13867] Fix some declarations in cipher.c to be static and rename des_setkey to make FreeBSD happier. committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Mon, 03 Oct 2005 04:57:30 +0000
parents 78aad676fdb2
children 7da512f06185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11551
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
1 /*
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
2 * idle.c - I'dle Mak'er plugin for Gaim
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
3 *
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
4 * This file is part of Gaim.
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
5 *
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
6 * Gaim is the legal property of its developers, whose names are too numerous
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
8 * source distribution.
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
9 *
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
10 * This program is free software; you can redistribute it and/or modify
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
11 * it under the terms of the GNU General Public License as published by
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
13 * (at your option) any later version.
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
14 *
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
15 * This program is distributed in the hope that it will be useful,
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
18 * GNU General Public License for more details.
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
19 *
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
20 * You should have received a copy of the GNU General Public License
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
21 * along with this program; if not, write to the Free Software
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5614
diff changeset
25 #include "internal.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5614
diff changeset
26
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5614
diff changeset
27 #include "connection.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5614
diff changeset
28 #include "debug.h"
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
29 #include "plugin.h"
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
30 #include "request.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5614
diff changeset
31 #include "server.h"
11551
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
32 #include "status.h"
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9015
diff changeset
33 #include "version.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5614
diff changeset
34
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
35 #define IDLE_PLUGIN_ID "gtk-idle"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
36
11551
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
37 static GList *idled_accts;
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
38
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
39 static gboolean
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
40 idle_filter(GaimAccount *acct)
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
41 {
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
42 if(g_list_find(idled_accts, acct))
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
43 return TRUE;
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
44
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
45 return FALSE;
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
46 }
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
47
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
48 static void
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
49 set_idle_time(GaimAccount *acct, int mins_idle)
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
50 {
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
51 time_t t = time(NULL); /* grab the current time */
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
52 GaimConnection *gc = gaim_account_get_connection(acct);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
53 GaimPresence *presence = gaim_account_get_presence(acct);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
54
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
55 gaim_debug(GAIM_DEBUG_INFO, "idle",
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
56 "setting idle time for %s to %d\n",
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
57 gaim_account_get_username(acct), mins_idle);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
58
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
59 t -= 60 * mins_idle; /* subtract seconds idle from current time */
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
60 gc->last_sent_time = t;
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
61 gc->is_idle = 0;
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
62
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
63 gaim_presence_set_idle(presence, mins_idle ? TRUE : FALSE, t);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
64 }
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
66 static void
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
67 idle_action_ok(void *ignored, GaimRequestFields *fields)
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
68 {
11551
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
69 GList *l = idled_accts;
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
70 gboolean acct_found = FALSE;
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
71 int tm = gaim_request_fields_get_integer(fields, "mins");
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
72 GaimAccount *acct = gaim_request_fields_get_account(fields, "acct");
5587
1c55b1540e18 [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5530
diff changeset
73
11551
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
74 /* only add the account to the GList if it's not already been idled */
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
75 if((l = g_list_find(idled_accts, acct)) && (GaimAccount *)(l->data) == acct)
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
76 acct_found = TRUE;
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
77
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
78 if(!acct_found) {
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
79 gaim_debug_misc("idle",
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
80 "%s hasn't been idled yet; adding to list.\n",
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
81 gaim_account_get_username(acct));
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
82 idled_accts = g_list_append(idled_accts, acct);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
83 }
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
84
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
85 set_idle_time(acct, tm);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
86 }
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
87
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
88 static void
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
89 unidle_action_ok(void *ignored, GaimRequestFields *fields)
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
90 {
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
91 GaimAccount *acct = gaim_request_fields_get_account(fields, "acct");
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
92
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
93 set_idle_time(acct, 0); /* unidle the account */
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
94
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
95 /* once the account has been unidled it shouldn't be in the list */
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
96 g_list_remove(idled_accts, acct);
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 }
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
99
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
100 static void
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8994
diff changeset
101 idle_action(GaimPluginAction *action)
6008
35679a3f2bcc [gaim-migrate @ 6456]
Christian Hammond <chipx86@chipx86.com>
parents: 5920
diff changeset
102 {
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
103 /* Use the super fancy request API */
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
105 GaimRequestFields *request;
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
106 GaimRequestFieldGroup *group;
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
107 GaimRequestField *field;
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
108
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
109 group = gaim_request_field_group_new(NULL);
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110
8994
c5825a04fb97 [gaim-migrate @ 9769]
Luke Schierer <lschiere@pidgin.im>
parents: 8986
diff changeset
111 field = gaim_request_field_account_new("acct", _("Account"), NULL);
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
112 gaim_request_field_account_set_show_all(field, FALSE);
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
113 gaim_request_field_group_add_field(group, field);
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
114
8994
c5825a04fb97 [gaim-migrate @ 9769]
Luke Schierer <lschiere@pidgin.im>
parents: 8986
diff changeset
115 field = gaim_request_field_int_new("mins", _("Minutes"), 10);
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
116 gaim_request_field_group_add_field(group, field);
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
118 request = gaim_request_fields_new();
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
119 gaim_request_fields_add_group(request, group);
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
120
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8994
diff changeset
121 gaim_request_fields(action->plugin,
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
122 N_("I'dle Mak'er"),
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
123 _("Set Account Idle Time"),
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
124 NULL,
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
125 request,
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
126 _("_Set"), G_CALLBACK(idle_action_ok),
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
127 _("_Cancel"), NULL,
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
128 NULL);
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 }
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130
11551
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
131 static void
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
132 unidle_action(GaimPluginAction *action)
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
133 {
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
134 GaimRequestFields *request;
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
135 GaimRequestFieldGroup *group;
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
136 GaimRequestField *field;
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
137
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
138 group = gaim_request_field_group_new(NULL);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
139
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
140 field = gaim_request_field_account_new("acct", _("Account"), NULL);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
141 gaim_request_field_account_set_filter(field, idle_filter);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
142 gaim_request_field_account_set_show_all(field, FALSE);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
143 gaim_request_field_group_add_field(group, field);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
144
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
145 request = gaim_request_fields_new();
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
146 gaim_request_fields_add_group(request, group);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
147
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
148 gaim_request_fields(action->plugin,
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
149 N_("I'dle Mak'er"),
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
150 _("Unset Account Idle Time"),
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
151 NULL,
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
152 request,
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
153 _("_Unset"), G_CALLBACK(unidle_action_ok),
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
154 _("_Cancel"), NULL,
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
155 NULL);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
156 }
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
157
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
158 static void
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
159 unidle_all_action(GaimPluginAction *action)
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
160 {
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
161 GList *l;
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
162
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
163 /* freeing the list here will cause segfaults if the user idles an account
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
164 * after the list is freed */
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
165 for (l = idled_accts; l; l = l->next) {
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
166 set_idle_time((GaimAccount *)(l->data), 0);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
167 g_list_remove(idled_accts, l->data);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
168 }
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
169
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
170 }
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
171
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
172 static GList *
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8994
diff changeset
173 actions(GaimPlugin *plugin, gpointer context)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
174 {
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
175 GList *l = NULL;
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8994
diff changeset
176 GaimPluginAction *act = NULL;
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8994
diff changeset
178 act = gaim_plugin_action_new(_("Set Account Idle Time"),
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8994
diff changeset
179 idle_action);
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8994
diff changeset
180 l = g_list_append(l, act);
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181
11551
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
182 act = gaim_plugin_action_new(_("Unset Account Idle Time"),
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
183 unidle_action);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
184 l = g_list_append(l, act);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
185
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
186 act = gaim_plugin_action_new(
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
187 _("Unset Idle Time For All Idled Accounts"), unidle_all_action);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
188 l = g_list_append(l, act);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
189
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
190 return l;
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 }
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
192
11551
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
193 static gboolean
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
194 plugin_unload(GaimPlugin *plugin)
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
195 {
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
196 GList *l;
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
197
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
198 for (l = idled_accts; l; l = l->next)
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
199 set_idle_time((GaimAccount *)(l->data), 0);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
200
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
201 g_list_free(idled_accts);
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
202
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
203 return TRUE;
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
204 }
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
205
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
206 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
207 {
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9015
diff changeset
208 GAIM_PLUGIN_MAGIC,
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9015
diff changeset
209 GAIM_MAJOR_VERSION,
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9015
diff changeset
210 GAIM_MINOR_VERSION,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
211 GAIM_PLUGIN_STANDARD,
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
212 NULL,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
213 0,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
214 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
215 GAIM_PRIORITY_DEFAULT,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
216 IDLE_PLUGIN_ID,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
217 N_("I'dle Mak'er"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
218 VERSION,
11551
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
219 N_("Allows you to hand-configure how long you've been idle"),
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
220 N_("Allows you to hand-configure how long you've been idle"),
6481
4dfae12a97bc [gaim-migrate @ 6995]
Mark Doliner <mark@kingant.net>
parents: 6371
diff changeset
221 "Eric Warmenhoven <eric@warmenhoven.org>",
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6064
diff changeset
222 GAIM_WEBSITE,
11256
bb0d7b719af2 [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11033
diff changeset
223 NULL,
11551
78aad676fdb2 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
224 plugin_unload,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
225 NULL,
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
226 NULL,
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
227 NULL,
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
228 NULL,
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
229 actions
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
230 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
231
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
232
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
233 static void
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5873
diff changeset
234 init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
235 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
236 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
237
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
238
6063
5239a3b4ab33 [gaim-migrate @ 6513]
Nathan Walp <nwalp@pidgin.im>
parents: 6008
diff changeset
239 GAIM_INIT_PLUGIN(idle, init_plugin, info)
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
240