libpurple/plugins/idle/idle.c

Mon, 12 Dec 2022 23:38:47 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 12 Dec 2022 23:38:47 -0600
changeset 41966
c7bcaf2f41ef
parent 41663
301b7d002cf1
child 41974
9ad66abc9356
permissions
-rw-r--r--

Create PurpleAvatar to represent avatars

Testing Done:
Ran the unit tests and manually verified the docs.

Reviewed at https://reviews.imfreedom.org/r/2092/

11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
2 * idle.c - I'dle Mak'er plugin for Purple
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
3 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
4 * This file is part of Purple.
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
5 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
11551
ba20005d8f78 [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
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
8 * source distribution.
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
9 *
ba20005d8f78 [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
ba20005d8f78 [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
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
13 * (at your option) any later version.
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
14 *
ba20005d8f78 [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,
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
18 * GNU General Public License for more details.
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
19 *
ba20005d8f78 [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
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
21 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16745
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
4103
a74e571fb3a4 [gaim-migrate @ 4318]
Ashaman TU
parents:
diff changeset
23 */
a74e571fb3a4 [gaim-migrate @ 4318]
Ashaman TU
parents:
diff changeset
24
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40043
diff changeset
25 #include <glib/gi18n-lib.h>
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5614
diff changeset
26
40945
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40804
diff changeset
27 #include <gplugin.h>
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40804
diff changeset
28 #include <gplugin-native.h>
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40804
diff changeset
29
39959
e47fcffd061b migrate the libpurple plugins to using purple.h only
Gary Kramlich <grim@reaperworld.com>
parents: 39759
diff changeset
30 #include <purple.h>
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5614
diff changeset
31
11754
a1e9b517aa5e [gaim-migrate @ 14045]
Mark Doliner <markdoliner@pidgin.im>
parents: 11749
diff changeset
32 /* This plugin no longer depends on gtk */
a1e9b517aa5e [gaim-migrate @ 14045]
Mark Doliner <markdoliner@pidgin.im>
parents: 11749
diff changeset
33 #define IDLE_PLUGIN_ID "core-idle"
5205
242b8aa81328 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4635
diff changeset
34
11754
a1e9b517aa5e [gaim-migrate @ 14045]
Mark Doliner <markdoliner@pidgin.im>
parents: 11749
diff changeset
35 static GList *idled_accts = NULL;
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
36
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
37 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
38 unidle_filter(PurpleAccount *acct)
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
39 {
11754
a1e9b517aa5e [gaim-migrate @ 14045]
Mark Doliner <markdoliner@pidgin.im>
parents: 11749
diff changeset
40 if (g_list_find(idled_accts, acct))
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
41 return TRUE;
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
42
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
43 return FALSE;
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
44 }
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
45
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
46 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
47 idleable_filter(PurpleAccount *account)
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
48 {
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36626
diff changeset
49 PurpleProtocol *protocol;
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
50
40804
5496016b3c00 Port libpurple from purple_protocols_ to purple_protocol_manager_
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
51 protocol = purple_account_get_protocol(account);
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36626
diff changeset
52 g_return_val_if_fail(protocol != NULL, FALSE);
12776
574564498637 [gaim-migrate @ 15123]
Richard Laager <rlaager@pidgin.im>
parents: 12775
diff changeset
53
39759
ea1401483849 Rename *_GET_*_IFACE to more standard *_GET_IFACE.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 36934
diff changeset
54 return PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER, set_idle);
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
55 }
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
56
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
57 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
58 set_idle_time(PurpleAccount *acct, int mins_idle)
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
59 {
11972
23ac6d9de1fa [gaim-migrate @ 14265]
Mark Doliner <markdoliner@pidgin.im>
parents: 11754
diff changeset
60 time_t t;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
61 PurpleConnection *gc = purple_account_get_connection(acct);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
62 PurplePresence *presence = purple_account_get_presence(acct);
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
63
11749
3aa3ccce97bd [gaim-migrate @ 14040]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11551
diff changeset
64 if (!gc)
3aa3ccce97bd [gaim-migrate @ 14040]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11551
diff changeset
65 return;
3aa3ccce97bd [gaim-migrate @ 14040]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11551
diff changeset
66
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
67 purple_debug_info("idle",
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
68 "setting idle time for %s to %d\n",
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
69 purple_account_get_username(acct), mins_idle);
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
70
13659
13d0d6abc1d3 [gaim-migrate @ 16060]
Evan Schoenberg <evands@pidgin.im>
parents: 12844
diff changeset
71 if (mins_idle)
13d0d6abc1d3 [gaim-migrate @ 16060]
Evan Schoenberg <evands@pidgin.im>
parents: 12844
diff changeset
72 t = time(NULL) - (60 * mins_idle); /* subtract seconds idle from current time */
13d0d6abc1d3 [gaim-migrate @ 16060]
Evan Schoenberg <evands@pidgin.im>
parents: 12844
diff changeset
73 else
13d0d6abc1d3 [gaim-migrate @ 16060]
Evan Schoenberg <evands@pidgin.im>
parents: 12844
diff changeset
74 t = 0; /* time idle is irrelevant */
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
75
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
76 purple_presence_set_idle(presence, mins_idle ? TRUE : FALSE, t);
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
77 }
4103
a74e571fb3a4 [gaim-migrate @ 4318]
Ashaman TU
parents:
diff changeset
78
8986
30ba617356bb [gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents: 8749
diff changeset
79 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
80 idle_action_ok(void *ignored, PurpleRequestFields *fields)
8986
30ba617356bb [gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents: 8749
diff changeset
81 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
82 int tm = purple_request_fields_get_integer(fields, "mins");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
83 PurpleAccount *acct = purple_request_fields_get_account(fields, "acct");
5587
22cb9fe4798a [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5530
diff changeset
84
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
85 /* only add the account to the GList if it's not already been idled */
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
86 if (!unidle_filter(acct))
11754
a1e9b517aa5e [gaim-migrate @ 14045]
Mark Doliner <markdoliner@pidgin.im>
parents: 11749
diff changeset
87 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
88 purple_debug_misc("idle",
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
89 "%s hasn't been idled yet; adding to list.\n",
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
90 purple_account_get_username(acct));
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
91 idled_accts = g_list_append(idled_accts, acct);
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
92 }
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
93
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
94 set_idle_time(acct, tm);
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
95 }
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
96
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
97 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
98 idle_all_action_ok(void *ignored, PurpleRequestFields *fields)
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
99 {
41206
afcae29ce67e Port libpurple plugins and protocols to the AccountManager API
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
100 PurpleAccountManager *manager = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
101 PurpleAccount *acct = NULL;
13835
86dea5f9cffa [gaim-migrate @ 16282]
Yosef Radchenko
parents: 13702
diff changeset
102 GList *list, *iter;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
103 int tm = purple_request_fields_get_integer(fields, "mins");
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
104
41206
afcae29ce67e Port libpurple plugins and protocols to the AccountManager API
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
105 manager = purple_account_manager_get_default();
41453
380febc4aae7 Update libpurple for the purple_account_manager_get_(in)active deprecations
Gary Kramlich <grim@reaperworld.com>
parents: 41414
diff changeset
106 list = purple_account_manager_get_enabled(manager);
13835
86dea5f9cffa [gaim-migrate @ 16282]
Yosef Radchenko
parents: 13702
diff changeset
107 for(iter = list; iter; iter = iter->next) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
108 acct = (PurpleAccount *)(iter->data);
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
109
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
110 if(acct && idleable_filter(acct)) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
111 purple_debug_misc("idle", "Idling %s.\n",
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
112 purple_account_get_username(acct));
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
113
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
114 set_idle_time(acct, tm);
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
115
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
116 if(!g_list_find(idled_accts, acct))
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
117 idled_accts = g_list_append(idled_accts, acct);
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
118 }
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
119 }
13835
86dea5f9cffa [gaim-migrate @ 16282]
Yosef Radchenko
parents: 13702
diff changeset
120
86dea5f9cffa [gaim-migrate @ 16282]
Yosef Radchenko
parents: 13702
diff changeset
121 g_list_free(list);
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
122 }
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
123
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
124 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
125 unidle_action_ok(void *ignored, PurpleRequestFields *fields)
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
126 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
127 PurpleAccount *acct = purple_request_fields_get_account(fields, "acct");
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
128
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
129 set_idle_time(acct, 0); /* unidle the account */
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
130
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
131 /* once the account has been unidled it shouldn't be in the list */
11749
3aa3ccce97bd [gaim-migrate @ 14040]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11551
diff changeset
132 idled_accts = g_list_remove(idled_accts, acct);
4103
a74e571fb3a4 [gaim-migrate @ 4318]
Ashaman TU
parents:
diff changeset
133 }
a74e571fb3a4 [gaim-migrate @ 4318]
Ashaman TU
parents:
diff changeset
134
8986
30ba617356bb [gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents: 8749
diff changeset
135 static void
41414
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
136 signing_off_cb(PurpleConnection *gc, void *data)
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
137 {
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
138 PurpleAccount *account;
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
139
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
140 account = purple_connection_get_account(gc);
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
141 idled_accts = g_list_remove(idled_accts, account);
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
142 }
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
143
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
144 /******************************************************************************
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
145 * Actions
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
146 *****************************************************************************/
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
147 static void
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
148 purple_idle_set_account_idle_time(G_GNUC_UNUSED GSimpleAction *action,
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
149 G_GNUC_UNUSED GVariant *parameter,
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
150 gpointer data)
6008
052096edd56b [gaim-migrate @ 6456]
Christian Hammond <chipx86@chipx86.com>
parents: 5920
diff changeset
151 {
8986
30ba617356bb [gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents: 8749
diff changeset
152 /* Use the super fancy request API */
4103
a74e571fb3a4 [gaim-migrate @ 4318]
Ashaman TU
parents:
diff changeset
153
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
154 PurpleRequestFields *request;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
155 PurpleRequestFieldGroup *group;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
156 PurpleRequestField *field;
8986
30ba617356bb [gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents: 8749
diff changeset
157
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
158 group = purple_request_field_group_new(NULL);
4103
a74e571fb3a4 [gaim-migrate @ 4318]
Ashaman TU
parents:
diff changeset
159
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
160 field = purple_request_field_account_new("acct", _("Account"), NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
161 purple_request_field_account_set_filter(field, idleable_filter);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
162 purple_request_field_account_set_show_all(field, FALSE);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
163 purple_request_field_group_add_field(group, field);
11754
a1e9b517aa5e [gaim-migrate @ 14045]
Mark Doliner <markdoliner@pidgin.im>
parents: 11749
diff changeset
164
33935
e740bbb8350c Request API: fix integer fields, add bounds to them
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 30842
diff changeset
165 field = purple_request_field_int_new("mins", _("Minutes"), 10, 0, 9999);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
166 purple_request_field_group_add_field(group, field);
4103
a74e571fb3a4 [gaim-migrate @ 4318]
Ashaman TU
parents:
diff changeset
167
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
168 request = purple_request_fields_new();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
169 purple_request_fields_add_group(request, group);
8986
30ba617356bb [gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents: 8749
diff changeset
170
41414
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
171 purple_request_fields(data,
8986
30ba617356bb [gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents: 8749
diff changeset
172 N_("I'dle Mak'er"),
30ba617356bb [gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents: 8749
diff changeset
173 _("Set Account Idle Time"),
30ba617356bb [gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents: 8749
diff changeset
174 NULL,
30ba617356bb [gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents: 8749
diff changeset
175 request,
30ba617356bb [gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents: 8749
diff changeset
176 _("_Set"), G_CALLBACK(idle_action_ok),
30ba617356bb [gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents: 8749
diff changeset
177 _("_Cancel"), NULL,
34332
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 33935
diff changeset
178 NULL, NULL);
4103
a74e571fb3a4 [gaim-migrate @ 4318]
Ashaman TU
parents:
diff changeset
179 }
a74e571fb3a4 [gaim-migrate @ 4318]
Ashaman TU
parents:
diff changeset
180
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
181 static void
41414
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
182 purple_idle_unset_account_idle_time(G_GNUC_UNUSED GSimpleAction *action,
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
183 G_GNUC_UNUSED GVariant *parameter,
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
184 gpointer data)
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
185 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
186 PurpleRequestFields *request;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
187 PurpleRequestFieldGroup *group;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
188 PurpleRequestField *field;
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
189
11975
0abdd0c63f0f [gaim-migrate @ 14268]
Mark Doliner <markdoliner@pidgin.im>
parents: 11974
diff changeset
190 if (idled_accts == NULL)
0abdd0c63f0f [gaim-migrate @ 14268]
Mark Doliner <markdoliner@pidgin.im>
parents: 11974
diff changeset
191 {
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
192 purple_notify_info(NULL, NULL, _("None of your accounts are idle."), NULL, NULL);
11975
0abdd0c63f0f [gaim-migrate @ 14268]
Mark Doliner <markdoliner@pidgin.im>
parents: 11974
diff changeset
193 return;
0abdd0c63f0f [gaim-migrate @ 14268]
Mark Doliner <markdoliner@pidgin.im>
parents: 11974
diff changeset
194 }
0abdd0c63f0f [gaim-migrate @ 14268]
Mark Doliner <markdoliner@pidgin.im>
parents: 11974
diff changeset
195
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
196 group = purple_request_field_group_new(NULL);
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
197
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
198 field = purple_request_field_account_new("acct", _("Account"), NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
199 purple_request_field_account_set_filter(field, unidle_filter);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
200 purple_request_field_account_set_show_all(field, FALSE);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
201 purple_request_field_group_add_field(group, field);
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
202
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
203 request = purple_request_fields_new();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
204 purple_request_fields_add_group(request, group);
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
205
41414
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
206 purple_request_fields(data,
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
207 N_("I'dle Mak'er"),
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
208 _("Unset Account Idle Time"),
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
209 NULL,
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
210 request,
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
211 _("_Unset"), G_CALLBACK(unidle_action_ok),
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
212 _("_Cancel"), NULL,
34332
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 33935
diff changeset
213 NULL, NULL);
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
214 }
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
215
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
216 static void
41414
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
217 purple_idle_set_all_accounts_idle_time(G_GNUC_UNUSED GSimpleAction *action,
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
218 G_GNUC_UNUSED GVariant *parameter,
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
219 gpointer data)
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
220 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
221 PurpleRequestFields *request;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
222 PurpleRequestFieldGroup *group;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
223 PurpleRequestField *field;
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
224
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
225 group = purple_request_field_group_new(NULL);
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
226
33935
e740bbb8350c Request API: fix integer fields, add bounds to them
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 30842
diff changeset
227 field = purple_request_field_int_new("mins", _("Minutes"), 10, 0, 9999);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
228 purple_request_field_group_add_field(group, field);
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
229
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
230 request = purple_request_fields_new();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
231 purple_request_fields_add_group(request, group);
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
232
41414
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
233 purple_request_fields(data,
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
234 N_("I'dle Mak'er"),
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
235 _("Set Idle Time for All Accounts"),
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
236 NULL,
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
237 request,
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
238 _("_Set"), G_CALLBACK(idle_all_action_ok),
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
239 _("_Cancel"), NULL,
34332
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 33935
diff changeset
240 NULL, NULL);
12775
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
241 }
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
242
697b674e0db4 [gaim-migrate @ 15122]
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 12764
diff changeset
243 static void
41414
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
244 purple_idle_unset_all_accounts_idle_time(G_GNUC_UNUSED GSimpleAction *action,
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
245 G_GNUC_UNUSED GVariant *parameter,
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
246 G_GNUC_UNUSED gpointer data)
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
247 {
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
248 /* freeing the list here will cause segfaults if the user idles an account
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
249 * after the list is freed */
40043
90446617d967 Use GList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 39959
diff changeset
250 g_list_foreach(idled_accts, (GFunc)set_idle_time, GINT_TO_POINTER(0));
11754
a1e9b517aa5e [gaim-migrate @ 14045]
Mark Doliner <markdoliner@pidgin.im>
parents: 11749
diff changeset
251 g_list_free(idled_accts);
a1e9b517aa5e [gaim-migrate @ 14045]
Mark Doliner <markdoliner@pidgin.im>
parents: 11749
diff changeset
252 idled_accts = NULL;
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
253 }
8986
30ba617356bb [gaim-migrate @ 9761]
Christopher O'Brien <siege@pidgin.im>
parents: 8749
diff changeset
254
41414
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
255 /******************************************************************************
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
256 * GPlugin Exports
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
257 *****************************************************************************/
40945
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40804
diff changeset
258 static GPluginPluginInfo *
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40804
diff changeset
259 idle_query(GError **error)
36742
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
260 {
41414
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
261 GSimpleActionGroup *group = NULL;
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
262 GActionEntry entries[] = {
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
263 {
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
264 .name = "set-account-idle-time",
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
265 .activate = purple_idle_set_account_idle_time,
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
266 }, {
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
267 .name = "unset-account-idle-time",
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
268 .activate = purple_idle_unset_account_idle_time,
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
269 }, {
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
270 .name = "set-all-accounts-idle-time",
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
271 .activate = purple_idle_set_all_accounts_idle_time,
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
272 }, {
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
273 .name = "unset-all-accounts-idle-time",
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
274 .activate = purple_idle_unset_all_accounts_idle_time,
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
275 }
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
276 };
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
277 GMenu *menu = NULL;
36742
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
278 const gchar * const authors[] = {
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
279 "Eric Warmenhoven <eric@warmenhoven.org>",
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
280 NULL
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
281 };
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
282
41414
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
283 group = g_simple_action_group_new();
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
284 g_action_map_add_action_entries(G_ACTION_MAP(group), entries,
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
285 G_N_ELEMENTS(entries), NULL);
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
286
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
287 menu = g_menu_new();
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
288 g_menu_append(menu, _("Set Account Idle Time"), "set-account-idle-time");
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
289 g_menu_append(menu, _("Unset Account Idle Time"),
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
290 "unset-account-idle-time");
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
291 g_menu_append(menu, _("Set Idle Time for All Accounts"),
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
292 "set-all-accounts-idle-time");
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
293 g_menu_append(menu, _("Unset Idle Time for All Idled Accounts"),
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
294 "unset-all-accounts-idle-time");
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
295
36742
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
296 return purple_plugin_info_new(
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
297 "id", IDLE_PLUGIN_ID,
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
298 /* This is a cultural reference. Dy'er Mak'er is a song by Led Zeppelin.
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
299 If that doesn't translate well into your language, drop the 's before translating. */
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
300 "name", N_("I'dle Mak'er"),
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
301 "version", DISPLAY_VERSION,
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
302 "category", N_("Utility"),
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
303 "summary", N_("Allows you to hand-configure how long you've been idle"),
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
304 "description", N_("Allows you to hand-configure how long you've been idle"),
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
305 "authors", authors,
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
306 "website", PURPLE_WEBSITE,
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
307 "abi-version", PURPLE_ABI_VERSION,
41414
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
308 "action-group", group,
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
309 "action-menu", menu,
36742
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
310 NULL
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
311 );
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
312 }
5d43951cabc0 More refactoring
Ankit Vani <a@nevitus.org>
parents: 36727
diff changeset
313
12839
748f30ed8c9d [gaim-migrate @ 15187]
Richard Laager <rlaager@pidgin.im>
parents: 12826
diff changeset
314 static gboolean
40945
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40804
diff changeset
315 idle_load(GPluginPlugin *plugin, GError **error)
12839
748f30ed8c9d [gaim-migrate @ 15187]
Richard Laager <rlaager@pidgin.im>
parents: 12826
diff changeset
316 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
317 purple_signal_connect(purple_connections_get_handle(), "signing-off",
12839
748f30ed8c9d [gaim-migrate @ 15187]
Richard Laager <rlaager@pidgin.im>
parents: 12826
diff changeset
318 plugin,
41314
0dc72eacd8bf Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41206
diff changeset
319 G_CALLBACK(signing_off_cb), NULL);
12844
e989f8d36628 [gaim-migrate @ 15192]
Mark Doliner <markdoliner@pidgin.im>
parents: 12839
diff changeset
320
e989f8d36628 [gaim-migrate @ 15192]
Mark Doliner <markdoliner@pidgin.im>
parents: 12839
diff changeset
321 return TRUE;
12839
748f30ed8c9d [gaim-migrate @ 15187]
Richard Laager <rlaager@pidgin.im>
parents: 12826
diff changeset
322 }
748f30ed8c9d [gaim-migrate @ 15187]
Richard Laager <rlaager@pidgin.im>
parents: 12826
diff changeset
323
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
324 static gboolean
41078
84e48180ef67 Update to gplugin 0.35.0
Gary Kramlich <grim@reaperworld.com>
parents: 40945
diff changeset
325 idle_unload(GPluginPlugin *plugin, gboolean shutdown, GError **error)
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
326 {
41414
b76bc2b4d7cc Convert plugin actions to GMenu and GAction
Gary Kramlich <grim@reaperworld.com>
parents: 41314
diff changeset
327 purple_idle_unset_all_accounts_idle_time(NULL, NULL, NULL);
11551
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
328
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
329 return TRUE;
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
330 }
ba20005d8f78 [gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents: 11256
diff changeset
331
40945
bbeb2e98ea5b Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents: 40804
diff changeset
332 GPLUGIN_NATIVE_PLUGIN_DECLARE(idle);

mercurial