Mercurial > pidgin.yaz
annotate src/idle.c @ 1088:18a14e6dd0af
[gaim-migrate @ 1098]
more fixes for proxy stuff
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 13 Nov 2000 00:37:02 +0000 |
parents | 9446ac58745e |
children | c73736fa0b7c |
rev | line source |
---|---|
1026 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
1 | 5 * |
1026 | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
1 | 10 * |
1026 | 11 * This program is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
1 | 15 * |
1026 | 16 * You should have received a copy of the GNU General Public License |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
1 | 19 * |
20 */ | |
21 | |
22 #ifdef HAVE_CONFIG_H | |
1026 | 23 #include "../config.h" |
1 | 24 #endif |
1026 | 25 #include <time.h> |
26 #include <stdio.h> | |
27 #include <unistd.h> | |
1 | 28 |
1026 | 29 #ifdef USE_SCREENSAVER |
30 #include <X11/Xlib.h> | |
31 #include <X11/Xutil.h> | |
32 #include <X11/extensions/scrnsaver.h> | |
33 #endif /* USE_SCREENSAVER */ | |
1 | 34 |
1026 | 35 #include "multi.h" |
36 #include "gaim.h" | |
1 | 37 |
38 | |
1026 | 39 gint check_idle(struct gaim_connection *gc) |
1 | 40 { |
1026 | 41 time_t t; |
42 #ifdef USE_SCREENSAVER | |
43 static XScreenSaverInfo *mit_info = NULL; | |
1028 | 44 static Display *d = NULL; |
1062
9446ac58745e
[gaim-migrate @ 1072]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1058
diff
changeset
|
45 #endif |
1026 | 46 time_t idle_time; |
1 | 47 |
1026 | 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 | 52 |
53 time(&t); | |
1 | 54 |
1026 | 55 if (report_idle == 0) |
56 return TRUE; | |
1 | 57 |
1026 | 58 #ifdef USE_SCREENSAVER |
59 if (report_idle == IDLE_SCREENSAVER) { | |
1028 | 60 if (!d) |
61 d = XOpenDisplay((char *)NULL); | |
1026 | 62 if (mit_info == NULL) { |
63 mit_info = XScreenSaverAllocInfo (); | |
64 } | |
65 XScreenSaverQueryInfo (d, DefaultRootWindow(d), mit_info); | |
66 idle_time = (mit_info->idle)/1000; | |
67 } else | |
68 #endif /* USE_SCREENSAVER */ | |
69 idle_time = t - gc->lastsent; | |
1 | 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 | 73 serv_set_idle(gc, idle_time); |
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 | 77 serv_touch_idle(gc); |
1029
740c6f933fe0
[gaim-migrate @ 1039]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1028
diff
changeset
|
78 } |
1 | 79 |
1026 | 80 return TRUE; |
1 | 81 |
82 } |