Thu, 14 Dec 2000 00:11:59 +0000
[gaim-migrate @ 1264]
bmiller's away-on-signon patch. does --away=mesg use "mesg" or the away message titled "mesg"? i didn't look hehe. but if it uses "mesg" instead of the away message titled "mesg" then i'm not sure it works.... i figured someone would report a bug if it didn't work
committer: Eric Warmenhoven <warmenhoven@yahoo.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> | |
| 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 | ||
| 1109 | 39 | int auto_is_away = 0; |
| 40 | ||
| 41 | ||
| 1026 | 42 | gint check_idle(struct gaim_connection *gc) |
| 1 | 43 | { |
| 1026 | 44 | time_t t; |
| 45 | #ifdef USE_SCREENSAVER | |
| 46 | static XScreenSaverInfo *mit_info = NULL; | |
| 1028 | 47 | static Display *d = NULL; |
|
1062
5936424ca7b1
[gaim-migrate @ 1072]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1058
diff
changeset
|
48 | #endif |
| 1026 | 49 | time_t idle_time; |
| 1 | 50 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1141
diff
changeset
|
51 | /* Not idle, really... :) */ |
|
1058
e878d758cff6
[gaim-migrate @ 1068]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1056
diff
changeset
|
52 | update_idle_times(); |
|
e878d758cff6
[gaim-migrate @ 1068]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1056
diff
changeset
|
53 | |
|
e878d758cff6
[gaim-migrate @ 1068]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1056
diff
changeset
|
54 | plugin_event(event_blist_update, 0, 0, 0, 0); |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1141
diff
changeset
|
55 | |
| 1026 | 56 | time(&t); |
| 1 | 57 | |
| 58 | ||
| 1026 | 59 | #ifdef USE_SCREENSAVER |
| 60 | if (report_idle == IDLE_SCREENSAVER) { | |
| 1028 | 61 | if (!d) |
| 62 | d = XOpenDisplay((char *)NULL); | |
| 1026 | 63 | if (mit_info == NULL) { |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1141
diff
changeset
|
64 | mit_info = XScreenSaverAllocInfo(); |
| 1026 | 65 | } |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1141
diff
changeset
|
66 | XScreenSaverQueryInfo(d, DefaultRootWindow(d), mit_info); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1141
diff
changeset
|
67 | idle_time = (mit_info->idle) / 1000; |
| 1026 | 68 | } else |
| 69 | #endif /* USE_SCREENSAVER */ | |
| 70 | idle_time = t - gc->lastsent; | |
| 1 | 71 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1141
diff
changeset
|
72 | if ((general_options & OPT_GEN_AUTO_AWAY) && |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1141
diff
changeset
|
73 | (idle_time > (60 * auto_away)) && (awaymessage == NULL) && (auto_is_away == 0)) { |
| 1254 | 74 | set_default_away((GtkWidget*)NULL, |
| 75 | (gpointer)g_slist_index(away_messages, | |
| 76 | default_away)); | |
| 77 | do_away_message((GtkWidget*)NULL, default_away); | |
| 1109 | 78 | auto_is_away = 1; |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1141
diff
changeset
|
79 | } else if (auto_is_away == 1 && idle_time < 60 * auto_away) { |
| 1109 | 80 | auto_is_away = 0; |
|
1141
ed6937ee20eb
[gaim-migrate @ 1151]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1109
diff
changeset
|
81 | if (awaymessage != NULL) |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1141
diff
changeset
|
82 | do_im_back((GtkWidget *)NULL, (GtkWidget *)NULL); |
| 1109 | 83 | } |
| 84 | ||
| 85 | ||
| 86 | /* If we're not reporting idle times to the server, still use Gaim | |
| 87 | usage for auto-away, but quit here so we don't report to the | |
| 88 | server */ | |
| 89 | if (report_idle == 0) { | |
| 90 | return TRUE; | |
| 91 | } | |
| 92 | ||
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1141
diff
changeset
|
93 | if (idle_time > 600 && !gc->is_idle) { /* 10 minutes! */ |
|
1029
c5ea048dc7ac
[gaim-migrate @ 1039]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1028
diff
changeset
|
94 | debug_printf("setting %s idle %d seconds\n", gc->username, idle_time); |
| 1026 | 95 | serv_set_idle(gc, idle_time); |
| 96 | gc->is_idle = 1; | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1141
diff
changeset
|
97 | } else if (idle_time < 600 && gc->is_idle) { |
|
1029
c5ea048dc7ac
[gaim-migrate @ 1039]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1028
diff
changeset
|
98 | debug_printf("setting %s unidle\n", gc->username); |
| 1026 | 99 | serv_touch_idle(gc); |
|
1029
c5ea048dc7ac
[gaim-migrate @ 1039]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1028
diff
changeset
|
100 | } |
| 1 | 101 | |
| 1026 | 102 | return TRUE; |
| 1 | 103 | |
| 104 | } |