annotate src/idle.c @ 10584:7de819b5ed68

[gaim-migrate @ 11988] Here you go Sean. Here's your interface to the gtkrc settings plugin. It's probably far from what you'd intended in a bunch of ways but it should do about what you want. Everyone feel free to tell me what they don't like about it. committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Thu, 10 Feb 2005 06:35:32 +0000
parents 3232e1a33899
children fb6e85c55fb8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
1 /*
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
2 * gaim
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
3 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7475
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7475
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7475
diff changeset
6 * source distribution.
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 *
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
8 * This program is free software; you can redistribute it and/or modify
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
9 * it under the terms of the GNU General Public License as published by
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
11 * (at your option) any later version.
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 *
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
13 * This program is distributed in the hope that it will be useful,
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
16 * GNU General Public License for more details.
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 *
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
18 * You should have received a copy of the GNU General Public License
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
19 * along with this program; if not, write to the Free Software
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
22 */
9791
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9730
diff changeset
23 #include "internal.h"
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
24
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
25 #ifdef USE_SCREENSAVER
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5755
diff changeset
26 # ifndef _WIN32
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5755
diff changeset
27 # include <X11/Xlib.h>
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5755
diff changeset
28 # include <X11/Xutil.h>
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5755
diff changeset
29 # include <X11/extensions/scrnsaver.h>
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5755
diff changeset
30 # include <gdk/gdkx.h>
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5755
diff changeset
31 # else
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5755
diff changeset
32 # include "idletrack.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5755
diff changeset
33 # endif
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
34 #endif /* USE_SCREENSAVER */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
35
5615
6500a6c8d679 [gaim-migrate @ 6022]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
36 #include "connection.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5755
diff changeset
37 #include "debug.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5755
diff changeset
38 #include "log.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5755
diff changeset
39 #include "prefs.h"
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
40 #include "signals.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5755
diff changeset
41
4536
ba99d30afc14 [gaim-migrate @ 4815]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4201
diff changeset
42 #define IDLEMARK 600 /* 10 minutes! */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
43
10319
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
44 typedef enum
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
45 {
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
46 GAIM_IDLE_NOT_AWAY = 0,
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
47 GAIM_IDLE_AUTO_AWAY,
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
48 GAIM_IDLE_AWAY_BUT_NOT_AUTO_AWAY
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
49
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
50 } GaimAutoAwayState;
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
51
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
52 #ifdef USE_SCREENSAVER
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
53 /**
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
54 * Get the number of seconds the user has been idle. In Unix-world
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
55 * this is based on the X Windows usage. In MS Windows this is based
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
56 * on keyboard/mouse usage.
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
57 *
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
58 * In Debian bug #271639, jwz says:
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
59 *
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
60 * Gaim should simply ask xscreensaver how long the user has been idle:
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
61 * % xscreensaver-command -time
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
62 * XScreenSaver 4.18: screen blanked since Tue Sep 14 14:10:45 2004
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
63 *
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
64 * Or you can monitor the _SCREENSAVER_STATUS property on root window #0.
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
65 * Element 0 is the status (0, BLANK, LOCK), element 1 is the time_t since
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
66 * the last state change, and subsequent elements are which hack is running
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
67 * on the various screens:
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
68 * % xprop -f _SCREENSAVER_STATUS 32ac -root _SCREENSAVER_STATUS
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
69 * _SCREENSAVER_STATUS(INTEGER) = BLANK, 1095196626, 10, 237
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
70 *
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
71 * See watch() in xscreensaver/driver/xscreensaver-command.c.
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
72 *
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
73 * @return The number of seconds the user has been idle.
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
74 */
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
75 static int
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
76 get_idle_time_from_system()
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
77 {
10319
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
78 #ifndef _WIN32
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
79 static XScreenSaverInfo *mit_info = NULL;
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
80 int event_base, error_base;
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
81 if (XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base)) {
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
82 if (mit_info == NULL) {
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
83 mit_info = XScreenSaverAllocInfo();
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
84 }
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
85 XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(), mit_info);
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
86 return (mit_info->idle) / 1000;
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
87 } else
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
88 return 0;
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
89 #else
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
90 return (GetTickCount() - wgaim_get_lastactive()) / 1000;
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
91 #endif
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
92 }
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
93 #endif /* USE_SCREENSAVER */
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
94
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
95 /*
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
96 * This function should be called when you think your idle state
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
97 * may have changed. Maybe you're over the 10-minute mark and
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
98 * Gaim should start reporting idle time to the server. Maybe
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
99 * you've returned from being idle. Maybe your auto-away message
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
100 * should be set.
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
101 *
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
102 * There is no harm to calling this many many times, other than
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
103 * it will be kinda slow. This is called every 20 seconds by a
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
104 * timer set when an account logs in. It is also called when
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
105 * you send an IM, a chat, etc.
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
106 *
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
107 * This function has 3 sections.
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
108 * 1. Get your idle time. It will query XScreenSaver or Windows
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
109 * or get the Gaim idle time. Whatever.
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
110 * 2. Set or unset your auto-away message.
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
111 * 3. Report your current idle time to the IM server.
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
112 */
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
113 gint
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
114 check_idle(gpointer data)
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
115 {
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
116 GaimConnection *gc = data;
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
117 const char *report_idle;
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5560
diff changeset
118 GaimAccount *account;
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
119 time_t t;
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 3905
diff changeset
120 int idle_time;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
121
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5560
diff changeset
122 account = gaim_connection_get_account(gc);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5560
diff changeset
123
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
124 gaim_signal_emit(gaim_blist_get_handle(), "update-idle");
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1141
diff changeset
125
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
126 time(&t);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
127
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
128 report_idle = gaim_prefs_get_string("/gaim/gtk/idle/reporting_method");
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
129
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
130 #ifdef USE_SCREENSAVER
10319
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
131 if (report_idle != NULL && !strcmp(report_idle, "system"))
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
132 idle_time = get_idle_time_from_system();
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
133 else
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
134 #endif /* USE_SCREENSAVER */
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5560
diff changeset
135 idle_time = t - gc->last_sent_time;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
136
10319
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
137 /* Should be become auto-away? */
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
138 if (gaim_prefs_get_bool("/core/away/away_when_idle") &&
5748
c6a30e1868ae [gaim-migrate @ 6173]
Nathan Walp <nwalp@pidgin.im>
parents: 5615
diff changeset
139 (idle_time > (60 * gaim_prefs_get_int("/core/away/mins_before_away")))
9949
ced29c7b396c [gaim-migrate @ 10845]
Luke Schierer <lschiere@pidgin.im>
parents: 9944
diff changeset
140 && (!gc->is_auto_away))
ced29c7b396c [gaim-migrate @ 10845]
Luke Schierer <lschiere@pidgin.im>
parents: 9944
diff changeset
141 {
ced29c7b396c [gaim-migrate @ 10845]
Luke Schierer <lschiere@pidgin.im>
parents: 9944
diff changeset
142 GaimPresence *presence;
ced29c7b396c [gaim-migrate @ 10845]
Luke Schierer <lschiere@pidgin.im>
parents: 9944
diff changeset
143
ced29c7b396c [gaim-migrate @ 10845]
Luke Schierer <lschiere@pidgin.im>
parents: 9944
diff changeset
144 presence = gaim_account_get_presence(account);
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
145
9949
ced29c7b396c [gaim-migrate @ 10845]
Luke Schierer <lschiere@pidgin.im>
parents: 9944
diff changeset
146 if (gaim_presence_is_available(presence))
ced29c7b396c [gaim-migrate @ 10845]
Luke Schierer <lschiere@pidgin.im>
parents: 9944
diff changeset
147 {
6216
dc42b27101c0 [gaim-migrate @ 6702]
Nathan Walp <nwalp@pidgin.im>
parents: 5872
diff changeset
148 const char *default_name;
dc42b27101c0 [gaim-migrate @ 6702]
Nathan Walp <nwalp@pidgin.im>
parents: 5872
diff changeset
149
10319
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
150 gaim_debug_info("idle", "Making %s auto-away\n",
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
151 gaim_account_get_username(account));
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
152
6216
dc42b27101c0 [gaim-migrate @ 6702]
Nathan Walp <nwalp@pidgin.im>
parents: 5872
diff changeset
153 default_name = gaim_prefs_get_string("/core/away/default_message");
dc42b27101c0 [gaim-migrate @ 6702]
Nathan Walp <nwalp@pidgin.im>
parents: 5872
diff changeset
154
10319
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
155 /* XXX STATUS AWAY CORE/UI */
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
156 /* Need to set the default_name away message for this connection here */
6216
dc42b27101c0 [gaim-migrate @ 6702]
Nathan Walp <nwalp@pidgin.im>
parents: 5872
diff changeset
157
10319
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
158 gc->is_auto_away = GAIM_IDLE_AUTO_AWAY;
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
159 } else {
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
160 gc->is_auto_away = GAIM_IDLE_AWAY_BUT_NOT_AUTO_AWAY;
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
161 }
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9791
diff changeset
162
10319
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
163 /* Should we return from being auto-away? */
5748
c6a30e1868ae [gaim-migrate @ 6173]
Nathan Walp <nwalp@pidgin.im>
parents: 5615
diff changeset
164 } else if (gc->is_auto_away &&
c6a30e1868ae [gaim-migrate @ 6173]
Nathan Walp <nwalp@pidgin.im>
parents: 5615
diff changeset
165 idle_time < 60 * gaim_prefs_get_int("/core/away/mins_before_away")) {
10319
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
166 if (gc->is_auto_away == GAIM_IDLE_AWAY_BUT_NOT_AUTO_AWAY) {
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
167 gc->is_auto_away = GAIM_IDLE_NOT_AWAY;
1815
f15d449b3167 [gaim-migrate @ 1825]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1575
diff changeset
168 return TRUE;
1446
38f712e75836 [gaim-migrate @ 1456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1407
diff changeset
169 }
10319
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
170 gc->is_auto_away = GAIM_IDLE_NOT_AWAY;
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9791
diff changeset
171
10319
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
172 /* XXX STATUS AWAY CORE/UI */
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
173 /* Need to set this connection to available here */
1109
c73736fa0b7c [gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1062
diff changeset
174 }
c73736fa0b7c [gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1062
diff changeset
175
10319
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
176 /*
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
177 * If we're not reporting idle times to the server, still use Gaim
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
178 * usage for auto-away, but quit here so we don't report to the
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
179 * server.
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
180 *
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
181 * Hmm. What if _while_ we're idle we toggle the pref for reporting
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
182 * idle time to the server? We would never become unidle...
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
183 */
5755
9587ee01dc5d [gaim-migrate @ 6180]
Christian Hammond <chipx86@chipx86.com>
parents: 5748
diff changeset
184 if (report_idle != NULL && !strcmp(report_idle, "none"))
1109
c73736fa0b7c [gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1062
diff changeset
185 return TRUE;
c73736fa0b7c [gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1062
diff changeset
186
4547
1f19b66c5d84 [gaim-migrate @ 4826]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4536
diff changeset
187 if (idle_time >= IDLEMARK && !gc->is_idle) {
10319
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
188 gaim_debug_info("idle", "Setting %s idle %d seconds\n",
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5560
diff changeset
189 gaim_account_get_username(account), idle_time);
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
190 serv_set_idle(gc, idle_time);
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
191 gc->is_idle = 1;
7475
08ce2a94d9c7 [gaim-migrate @ 8088]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
192 /* LOG system_log(log_idle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); */
4536
ba99d30afc14 [gaim-migrate @ 4815]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4201
diff changeset
193 } else if (idle_time < IDLEMARK && gc->is_idle) {
10319
32e7baa81e03 [gaim-migrate @ 11526]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
194 gaim_debug_info("idle", "Setting %s unidle\n",
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5560
diff changeset
195 gaim_account_get_username(account));
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
196 serv_touch_idle(gc);
7475
08ce2a94d9c7 [gaim-migrate @ 8088]
Mark Doliner <mark@kingant.net>
parents: 7431
diff changeset
197 /* LOG system_log(log_unidle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); */
1029
740c6f933fe0 [gaim-migrate @ 1039]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1028
diff changeset
198 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
199
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
200 return TRUE;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
201 }