annotate plugins/idle.c @ 9807:0c170246a9ec

[gaim-migrate @ 10675] Get rid of AIM_IMFLAGS_UNICODE and AIM_IMFLAGS_ISO_8859_1. Use AIM_IMCHARSET_ASCII, AIM_IMCHARSET_UNICODE, and AIM_IMCHARSET_CUSTOM instead. And compare these values directly to aim_incomingim_ch1_args->charset or aim_mpmsg_section_t->charset committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 21 Aug 2004 22:24:50 +0000
parents 67421e0dc497
children f8e395a054e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /* a nifty little plugin to set your idle time to whatever you want it to be.
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * useful for almost nothing. mostly just a demo plugin. but it's fun to have
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * 40-day idle times.
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 */
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5614
diff changeset
6 #include "internal.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5614
diff changeset
7
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5614
diff changeset
8 #include "connection.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5614
diff changeset
9 #include "debug.h"
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
10 #include "plugin.h"
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
11 #include "request.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5614
diff changeset
12 #include "server.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5614
diff changeset
13
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
14 #define IDLE_PLUGIN_ID "gtk-idle"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
15
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
17 static void
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
18 idle_action_ok(void *ignored, GaimRequestFields *fields)
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
19 {
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 time_t t;
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
21 int tm;
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
22 GaimAccount *acct;
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
23 GaimConnection *gc;
5587
1c55b1540e18 [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5530
diff changeset
24
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
25 tm = gaim_request_fields_get_integer(fields, "mins");
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
26 acct = gaim_request_fields_get_account(fields, "acct");
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
27 gc = gaim_account_get_connection(acct);
5587
1c55b1540e18 [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5530
diff changeset
28
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
29 gaim_debug(GAIM_DEBUG_INFO, "idle",
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
30 "setting idle time for %s to %d\n",
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
31 gaim_account_get_username(acct), tm);
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 time(&t);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 t -= 60 * tm;
5587
1c55b1540e18 [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5530
diff changeset
34 gc->last_sent_time = t;
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 serv_set_idle(gc, 60 * tm);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 gc->is_idle = 0;
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 }
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
39
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
40 static void
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8994
diff changeset
41 idle_action(GaimPluginAction *action)
6008
35679a3f2bcc [gaim-migrate @ 6456]
Christian Hammond <chipx86@chipx86.com>
parents: 5920
diff changeset
42 {
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
43 /* Use the super fancy request API */
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
45 GaimRequestFields *request;
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
46 GaimRequestFieldGroup *group;
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
47 GaimRequestField *field;
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
48
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
49 group = gaim_request_field_group_new(NULL);
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50
8994
c5825a04fb97 [gaim-migrate @ 9769]
Luke Schierer <lschiere@pidgin.im>
parents: 8986
diff changeset
51 field = gaim_request_field_account_new("acct", _("Account"), NULL);
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
52 gaim_request_field_account_set_show_all(field, FALSE);
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
53 gaim_request_field_group_add_field(group, field);
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
54
8994
c5825a04fb97 [gaim-migrate @ 9769]
Luke Schierer <lschiere@pidgin.im>
parents: 8986
diff changeset
55 field = gaim_request_field_int_new("mins", _("Minutes"), 10);
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
56 gaim_request_field_group_add_field(group, field);
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
58 request = gaim_request_fields_new();
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
59 gaim_request_fields_add_group(request, group);
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
60
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8994
diff changeset
61 gaim_request_fields(action->plugin,
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
62 N_("I'dle Mak'er"),
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
63 _("Set Account Idle Time"),
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
64 NULL,
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
65 request,
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
66 _("_Set"), G_CALLBACK(idle_action_ok),
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
67 _("_Cancel"), NULL,
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
68 NULL);
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 }
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
71
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
72 static GList *
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8994
diff changeset
73 actions(GaimPlugin *plugin, gpointer context)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
74 {
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
75 GList *l = NULL;
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8994
diff changeset
76 GaimPluginAction *act = NULL;
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8994
diff changeset
78 act = gaim_plugin_action_new(_("Set Account Idle Time"),
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8994
diff changeset
79 idle_action);
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8994
diff changeset
80 l = g_list_append(l, act);
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
82 return l;
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 }
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
84
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
85
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
86 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
87 {
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 7989
diff changeset
88 GAIM_PLUGIN_API_VERSION,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
89 GAIM_PLUGIN_STANDARD,
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
90 NULL,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
91 0,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
92 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
93 GAIM_PRIORITY_DEFAULT,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
94 IDLE_PLUGIN_ID,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
95 N_("I'dle Mak'er"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
96 VERSION,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
97 N_("Allows you to hand-configure how long you've been idle for"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
98 N_("Allows you to hand-configure how long you've been idle for"),
6481
4dfae12a97bc [gaim-migrate @ 6995]
Mark Doliner <mark@kingant.net>
parents: 6371
diff changeset
99 "Eric Warmenhoven <eric@warmenhoven.org>",
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6064
diff changeset
100 GAIM_WEBSITE,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
101 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
102 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
103 NULL,
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
104 NULL,
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
105 NULL,
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
106 NULL,
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
107 actions
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
108 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
109
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
110
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
111 static void
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5873
diff changeset
112 init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
113 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
114 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
115
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
116
6063
5239a3b4ab33 [gaim-migrate @ 6513]
Nathan Walp <nwalp@pidgin.im>
parents: 6008
diff changeset
117 GAIM_INIT_PLUGIN(idle, init_plugin, info)
8986
8cf32769ba1b [gaim-migrate @ 9761]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
118