Mercurial > pidgin
annotate src/idle.c @ 4109:4efc492cf16f
[gaim-migrate @ 4324]
(21:14:00) Robot101: although I just had a thought.... before you commit it, change this:
(21:14:11) LSchiere: ugh
(21:14:24) Robot101: trust me, it's far harder for me to re-diff it :P
(21:14:30) LSchiere: not now it isn't
(21:14:34) LSchiere: what line?
(21:14:53) LSchiere: of the file not the patch
(21:15:05) Robot101: buddy.c 2479
(21:15:22) LSchiere: kay
(21:15:36) LSchiere: gint x, y, width, height;
(21:15:47) Robot101: remove width and height, then remove the call to gtk_window_get_size, and change the
4 occurences of width and height to event.width and event.height
(21:16:13) Robot101: size is not dependent on gravity, so we don't need to get it via gtk.
(21:17:03) LSchiere: any other thoughts?
(21:17:33) Robot101: yes. I'm an idiot.
(21:17:42) LSchiere: you said it, not me.
(21:17:53) deryni: I smell commit message
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 21 Dec 2002 02:19:42 +0000 |
parents | 3e508dd31b76 |
children | 511c2b63caa4 |
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 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1952
diff
changeset
|
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 |
3905
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3517
diff
changeset
|
30 #ifndef _WIN32 |
1026 | 31 #include <X11/Xlib.h> |
32 #include <X11/Xutil.h> | |
33 #include <X11/extensions/scrnsaver.h> | |
2115
3ce77b547cf2
[gaim-migrate @ 2125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2114
diff
changeset
|
34 #include <gdk/gdkx.h> |
3905
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3517
diff
changeset
|
35 #else |
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3517
diff
changeset
|
36 #include "IdleTracker.h" |
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3517
diff
changeset
|
37 #endif |
1026 | 38 #endif /* USE_SCREENSAVER */ |
1 | 39 |
1026 | 40 #include "multi.h" |
41 #include "gaim.h" | |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1367
diff
changeset
|
42 #include "prpl.h" |
1 | 43 |
44 | |
2381
427ccd7dfdd2
[gaim-migrate @ 2394]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
45 gint check_idle(gpointer data) |
1 | 46 { |
2381
427ccd7dfdd2
[gaim-migrate @ 2394]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
47 struct gaim_connection *gc = data; |
1026 | 48 time_t t; |
49 #ifdef USE_SCREENSAVER | |
3905
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3517
diff
changeset
|
50 #ifndef _WIN32 |
1026 | 51 static XScreenSaverInfo *mit_info = NULL; |
1062
9446ac58745e
[gaim-migrate @ 1072]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1058
diff
changeset
|
52 #endif |
3905
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3517
diff
changeset
|
53 #endif |
1026 | 54 time_t idle_time; |
1 | 55 |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1141
diff
changeset
|
56 /* Not idle, really... :) */ |
1058
4927ce25d8cc
[gaim-migrate @ 1068]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
57 update_idle_times(); |
4927ce25d8cc
[gaim-migrate @ 1068]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
58 |
3517 | 59 plugin_event(event_blist_update); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1141
diff
changeset
|
60 |
1026 | 61 time(&t); |
1 | 62 |
63 | |
1026 | 64 #ifdef USE_SCREENSAVER |
65 if (report_idle == IDLE_SCREENSAVER) { | |
3905
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3517
diff
changeset
|
66 #ifndef _WIN32 |
2115
3ce77b547cf2
[gaim-migrate @ 2125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2114
diff
changeset
|
67 int event_base, error_base; |
3ce77b547cf2
[gaim-migrate @ 2125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2114
diff
changeset
|
68 if (XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base)) { |
2114
c582116e8463
[gaim-migrate @ 2124]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
69 if (mit_info == NULL) { |
c582116e8463
[gaim-migrate @ 2124]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
70 mit_info = XScreenSaverAllocInfo(); |
c582116e8463
[gaim-migrate @ 2124]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
71 } |
2115
3ce77b547cf2
[gaim-migrate @ 2125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2114
diff
changeset
|
72 XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(), mit_info); |
2114
c582116e8463
[gaim-migrate @ 2124]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
73 idle_time = (mit_info->idle) / 1000; |
c582116e8463
[gaim-migrate @ 2124]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
74 } else |
c582116e8463
[gaim-migrate @ 2124]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
75 idle_time = 0; |
3905
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3517
diff
changeset
|
76 #else |
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3517
diff
changeset
|
77 /* IdleTracker monitors usage of all other apps by setting a hook function */ |
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3517
diff
changeset
|
78 idle_time = (GetTickCount() - IdleTrackerGetLastTickCount()) / 1000; |
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3517
diff
changeset
|
79 #endif |
1026 | 80 } else |
81 #endif /* USE_SCREENSAVER */ | |
82 idle_time = t - gc->lastsent; | |
1 | 83 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
84 if ((away_options & OPT_AWAY_AUTO) && (idle_time > (60 * auto_away)) && (!gc->is_auto_away)) { |
1446
38f712e75836
[gaim-migrate @ 1456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1407
diff
changeset
|
85 if (!gc->away) { |
1952
39df68320a82
[gaim-migrate @ 1962]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1895
diff
changeset
|
86 debug_printf("making %s away automatically\n", gc->username); |
1446
38f712e75836
[gaim-migrate @ 1456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1407
diff
changeset
|
87 if (g_slist_length(connections) == 1) |
38f712e75836
[gaim-migrate @ 1456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1407
diff
changeset
|
88 do_away_message(NULL, default_away); |
1895
e65b9942f649
[gaim-migrate @ 1905]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1885
diff
changeset
|
89 else if (default_away) |
1446
38f712e75836
[gaim-migrate @ 1456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1407
diff
changeset
|
90 serv_set_away(gc, GAIM_AWAY_CUSTOM, default_away->message); |
1468
9db35684c68c
[gaim-migrate @ 1478]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1450
diff
changeset
|
91 gc->is_auto_away = 1; |
1952
39df68320a82
[gaim-migrate @ 1962]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1895
diff
changeset
|
92 set_default_away(NULL, (gpointer)g_slist_index(away_messages, default_away)); |
1468
9db35684c68c
[gaim-migrate @ 1478]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1450
diff
changeset
|
93 } else |
9db35684c68c
[gaim-migrate @ 1478]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1450
diff
changeset
|
94 gc->is_auto_away = 2; |
9db35684c68c
[gaim-migrate @ 1478]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1450
diff
changeset
|
95 } else if (gc->is_auto_away && idle_time < 60 * auto_away) { |
9db35684c68c
[gaim-migrate @ 1478]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1450
diff
changeset
|
96 if (gc->is_auto_away == 2) { |
9db35684c68c
[gaim-migrate @ 1478]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1450
diff
changeset
|
97 gc->is_auto_away = 0; |
1815
f15d449b3167
[gaim-migrate @ 1825]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1575
diff
changeset
|
98 return TRUE; |
1446
38f712e75836
[gaim-migrate @ 1456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1407
diff
changeset
|
99 } |
1468
9db35684c68c
[gaim-migrate @ 1478]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1450
diff
changeset
|
100 gc->is_auto_away = 0; |
1407
9f356885a77a
[gaim-migrate @ 1417]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
101 if (awaymessage == NULL) { |
9f356885a77a
[gaim-migrate @ 1417]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
102 debug_printf("removing auto-away message for %s\n", gc->username); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1367
diff
changeset
|
103 serv_set_away(gc, GAIM_AWAY_CUSTOM, NULL); |
1407
9f356885a77a
[gaim-migrate @ 1417]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
104 } else { |
1450
024f9250ba63
[gaim-migrate @ 1460]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1446
diff
changeset
|
105 if (g_slist_length(connections) == 1) |
024f9250ba63
[gaim-migrate @ 1460]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1446
diff
changeset
|
106 do_im_back(0, 0); |
024f9250ba63
[gaim-migrate @ 1460]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1446
diff
changeset
|
107 else { |
024f9250ba63
[gaim-migrate @ 1460]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1446
diff
changeset
|
108 debug_printf("replacing auto-away with global for %s\n", gc->username); |
024f9250ba63
[gaim-migrate @ 1460]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1446
diff
changeset
|
109 serv_set_away(gc, GAIM_AWAY_CUSTOM, awaymessage->message); |
024f9250ba63
[gaim-migrate @ 1460]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1446
diff
changeset
|
110 } |
1407
9f356885a77a
[gaim-migrate @ 1417]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
111 } |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1062
diff
changeset
|
112 } |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1062
diff
changeset
|
113 |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1062
diff
changeset
|
114 |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1062
diff
changeset
|
115 /* If we're not reporting idle times to the server, still use Gaim |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1062
diff
changeset
|
116 usage for auto-away, but quit here so we don't report to the |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1062
diff
changeset
|
117 server */ |
1367
ad346597b7b2
[gaim-migrate @ 1377]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1254
diff
changeset
|
118 if (report_idle == IDLE_NONE) { |
1109
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1062
diff
changeset
|
119 return TRUE; |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1062
diff
changeset
|
120 } |
c73736fa0b7c
[gaim-migrate @ 1119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1062
diff
changeset
|
121 |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1141
diff
changeset
|
122 if (idle_time > 600 && !gc->is_idle) { /* 10 minutes! */ |
1029
740c6f933fe0
[gaim-migrate @ 1039]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1028
diff
changeset
|
123 debug_printf("setting %s idle %d seconds\n", gc->username, idle_time); |
1026 | 124 serv_set_idle(gc, idle_time); |
125 gc->is_idle = 1; | |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1468
diff
changeset
|
126 system_log(log_idle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1141
diff
changeset
|
127 } else if (idle_time < 600 && gc->is_idle) { |
1029
740c6f933fe0
[gaim-migrate @ 1039]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1028
diff
changeset
|
128 debug_printf("setting %s unidle\n", gc->username); |
1026 | 129 serv_touch_idle(gc); |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1468
diff
changeset
|
130 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
|
131 } |
1 | 132 |
1026 | 133 return TRUE; |
1 | 134 |
135 } |