Wed, 01 Nov 2000 11:22:04 +0000
[gaim-migrate @ 1054]
Thanks to Ryan C. Gordon for the Away message patch!
committer: Rob Flynn <gaim@robflynn.com>
| 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> | |
| 28 | #include <aim.h> | |
| 1 | 29 | |
| 1026 | 30 | #ifdef USE_SCREENSAVER |
| 31 | #include <X11/Xlib.h> | |
| 32 | #include <X11/Xutil.h> | |
| 33 | #include <X11/extensions/scrnsaver.h> | |
| 34 | #endif /* USE_SCREENSAVER */ | |
| 1 | 35 | |
| 1026 | 36 | #include "multi.h" |
| 37 | #include "gaim.h" | |
| 1 | 38 | |
| 39 | ||
| 1026 | 40 | gint check_idle(struct gaim_connection *gc) |
| 1 | 41 | { |
| 1026 | 42 | time_t t; |
| 43 | #ifdef USE_SCREENSAVER | |
| 44 | static XScreenSaverInfo *mit_info = NULL; | |
| 1028 | 45 | static Display *d = NULL; |
| 1026 | 46 | time_t idle_time; |
| 47 | #endif | |
| 1 | 48 | |
| 1026 | 49 | /* Not idle, really... :) */ |
| 50 | ||
| 51 | time(&t); | |
| 1 | 52 | |
| 1026 | 53 | if (report_idle == 0) |
| 54 | return TRUE; | |
| 1 | 55 | |
| 1026 | 56 | #ifdef USE_SCREENSAVER |
| 57 | if (report_idle == IDLE_SCREENSAVER) { | |
| 1028 | 58 | if (!d) |
| 59 | d = XOpenDisplay((char *)NULL); | |
| 1026 | 60 | if (mit_info == NULL) { |
| 61 | mit_info = XScreenSaverAllocInfo (); | |
| 62 | } | |
| 63 | XScreenSaverQueryInfo (d, DefaultRootWindow(d), mit_info); | |
| 64 | idle_time = (mit_info->idle)/1000; | |
| 65 | } else | |
| 66 | #endif /* USE_SCREENSAVER */ | |
| 67 | idle_time = t - gc->lastsent; | |
| 1 | 68 | |
|
1029
c5ea048dc7ac
[gaim-migrate @ 1039]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1028
diff
changeset
|
69 | if (idle_time > 600 && !gc->is_idle) { /* 10 minutes! */ |
|
c5ea048dc7ac
[gaim-migrate @ 1039]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1028
diff
changeset
|
70 | debug_printf("setting %s idle %d seconds\n", gc->username, idle_time); |
| 1026 | 71 | serv_set_idle(gc, idle_time); |
| 72 | gc->is_idle = 1; | |
|
1029
c5ea048dc7ac
[gaim-migrate @ 1039]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1028
diff
changeset
|
73 | } else if (idle_time < 600 && gc->is_idle) { |
|
c5ea048dc7ac
[gaim-migrate @ 1039]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1028
diff
changeset
|
74 | debug_printf("setting %s unidle\n", gc->username); |
| 1026 | 75 | serv_touch_idle(gc); |
|
1029
c5ea048dc7ac
[gaim-migrate @ 1039]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1028
diff
changeset
|
76 | } |
| 1 | 77 | |
| 1026 | 78 | return TRUE; |
| 1 | 79 | |
| 80 | } |