annotate src/idle.c @ 1106:5bc8fdacd2cb

[gaim-migrate @ 1116] lots of changes. buddy.c: just in general tried to get things to work better. moving things in the edit list window and signing off should be handled better in the main buddy list window (watch out for flashes). gaim.h: removed toc-specific things and moved them to toc.c and rvous.c as needed. gtkhtml.c: possible fix for AOL 6.0 problems (I wasn't able to reproduce the problem before or after the fix, but i fixed what i think might have been causing the problem). multi.c: moved LOGIN_STEPS from gaim.h here and actually use it now oscar.c: moved an oscar-specific struct definition from gaim.h here and also handle problems better perl.c: fix for stupid problem rvous.c: first pass at attempt to be able to remove toc.c and rvous.c (though this will never happen; gaim will support toc as long as aol does) without cruft. gaim is now only dependent on toc.c and rvous.c for toc_build_config and parse_toc_buddy_list, which gaim needs to save and read its buddy list. toc.c: rewrote the signin process so that the read()'s won't block. it's not actually a non-blocking read; it's just that it won't ever get to the read until there's data to be read (thanks to the gdk_input watcher). this means the cancel button should work after it's connected, but it's still not a non-blocking connect. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 20 Nov 2000 07:24:18 +0000
parents 9446ac58745e
children c73736fa0b7c
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 *
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 *
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
6 * 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
7 * 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
8 * the Free Software Foundation; either version 2 of the License, or
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
9 * (at your option) any later version.
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 *
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
11 * 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
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
14 * GNU General Public License for more details.
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 *
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
16 * 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
17 * along with this program; if not, write to the Free Software
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
18 * 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
19 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 */
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 #ifdef HAVE_CONFIG_H
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
23 #include "../config.h"
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
24 #endif
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
25 #include <time.h>
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
26 #include <stdio.h>
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
27 #include <unistd.h>
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
29 #ifdef USE_SCREENSAVER
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
30 #include <X11/Xlib.h>
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
31 #include <X11/Xutil.h>
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
32 #include <X11/extensions/scrnsaver.h>
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
33 #endif /* USE_SCREENSAVER */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
34
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
35 #include "multi.h"
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
36 #include "gaim.h"
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
37
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
38
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
39 gint check_idle(struct gaim_connection *gc)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40 {
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
41 time_t t;
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
42 #ifdef USE_SCREENSAVER
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
43 static XScreenSaverInfo *mit_info = NULL;
1028
e4147c8604cc [gaim-migrate @ 1038]
Rob Flynn <gaim@robflynn.com>
parents: 1027
diff changeset
44 static Display *d = NULL;
1062
9446ac58745e [gaim-migrate @ 1072]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1058
diff changeset
45 #endif
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
46 time_t idle_time;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
48 /* Not idle, really... :) */
1058
4927ce25d8cc [gaim-migrate @ 1068]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
49 update_idle_times();
4927ce25d8cc [gaim-migrate @ 1068]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
50
4927ce25d8cc [gaim-migrate @ 1068]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1056
diff changeset
51 plugin_event(event_blist_update, 0, 0, 0, 0);
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
52
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
53 time(&t);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
54
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
55 if (report_idle == 0)
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
56 return TRUE;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
57
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
58 #ifdef USE_SCREENSAVER
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
59 if (report_idle == IDLE_SCREENSAVER) {
1028
e4147c8604cc [gaim-migrate @ 1038]
Rob Flynn <gaim@robflynn.com>
parents: 1027
diff changeset
60 if (!d)
e4147c8604cc [gaim-migrate @ 1038]
Rob Flynn <gaim@robflynn.com>
parents: 1027
diff changeset
61 d = XOpenDisplay((char *)NULL);
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
62 if (mit_info == NULL) {
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
63 mit_info = XScreenSaverAllocInfo ();
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
64 }
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
65 XScreenSaverQueryInfo (d, DefaultRootWindow(d), mit_info);
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
66 idle_time = (mit_info->idle)/1000;
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
67 } else
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
68 #endif /* USE_SCREENSAVER */
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
69 idle_time = t - gc->lastsent;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
70
1029
740c6f933fe0 [gaim-migrate @ 1039]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1028
diff changeset
71 if (idle_time > 600 && !gc->is_idle) { /* 10 minutes! */
740c6f933fe0 [gaim-migrate @ 1039]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1028
diff changeset
72 debug_printf("setting %s idle %d seconds\n", gc->username, idle_time);
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
73 serv_set_idle(gc, idle_time);
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
74 gc->is_idle = 1;
1029
740c6f933fe0 [gaim-migrate @ 1039]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1028
diff changeset
75 } else if (idle_time < 600 && gc->is_idle) {
740c6f933fe0 [gaim-migrate @ 1039]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1028
diff changeset
76 debug_printf("setting %s unidle\n", gc->username);
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
77 serv_touch_idle(gc);
1029
740c6f933fe0 [gaim-migrate @ 1039]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1028
diff changeset
78 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
79
1026
5bad25457843 [gaim-migrate @ 1036]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
80 return TRUE;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
81
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
82 }