Mercurial > pidgin.yaz
comparison src/idle.c @ 1109:c73736fa0b7c
[gaim-migrate @ 1119]
Auto-Away, courtesy BMiller. damn cool. i'm impressed. also minor touch-ups, mostly to indicate what all the FIXME's mean.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 20 Nov 2000 10:37:40 +0000 |
parents | 9446ac58745e |
children | 8f4ce8b74901 |
comparison
equal
deleted
inserted
replaced
1108:cb338aa38e78 | 1109:c73736fa0b7c |
---|---|
34 | 34 |
35 #include "multi.h" | 35 #include "multi.h" |
36 #include "gaim.h" | 36 #include "gaim.h" |
37 | 37 |
38 | 38 |
39 int auto_is_away = 0; | |
40 | |
41 | |
39 gint check_idle(struct gaim_connection *gc) | 42 gint check_idle(struct gaim_connection *gc) |
40 { | 43 { |
41 time_t t; | 44 time_t t; |
42 #ifdef USE_SCREENSAVER | 45 #ifdef USE_SCREENSAVER |
43 static XScreenSaverInfo *mit_info = NULL; | 46 static XScreenSaverInfo *mit_info = NULL; |
50 | 53 |
51 plugin_event(event_blist_update, 0, 0, 0, 0); | 54 plugin_event(event_blist_update, 0, 0, 0, 0); |
52 | 55 |
53 time(&t); | 56 time(&t); |
54 | 57 |
55 if (report_idle == 0) | |
56 return TRUE; | |
57 | 58 |
58 #ifdef USE_SCREENSAVER | 59 #ifdef USE_SCREENSAVER |
59 if (report_idle == IDLE_SCREENSAVER) { | 60 if (report_idle == IDLE_SCREENSAVER) { |
60 if (!d) | 61 if (!d) |
61 d = XOpenDisplay((char *)NULL); | 62 d = XOpenDisplay((char *)NULL); |
66 idle_time = (mit_info->idle)/1000; | 67 idle_time = (mit_info->idle)/1000; |
67 } else | 68 } else |
68 #endif /* USE_SCREENSAVER */ | 69 #endif /* USE_SCREENSAVER */ |
69 idle_time = t - gc->lastsent; | 70 idle_time = t - gc->lastsent; |
70 | 71 |
72 if ((general_options & OPT_GEN_AUTO_AWAY) && | |
73 (idle_time > (60 * auto_away)) && | |
74 (awaymessage == NULL) && | |
75 (auto_is_away == 0)) { | |
76 struct away_message *a; | |
77 set_default_away((GtkWidget*)NULL, (gpointer)default_away); | |
78 a = g_slist_nth_data(away_messages, default_away); | |
79 do_away_message((GtkWidget*)NULL, a); | |
80 auto_is_away = 1; | |
81 } else if (auto_is_away == 1 && awaymessage != NULL && | |
82 idle_time < 60*auto_away) { | |
83 do_im_back((GtkWidget*)NULL, (GtkWidget*)NULL); | |
84 auto_is_away = 0; | |
85 } | |
86 if (auto_is_away == 1 && awaymessage == NULL) | |
87 auto_is_away = 0; | |
88 | |
89 | |
90 /* If we're not reporting idle times to the server, still use Gaim | |
91 usage for auto-away, but quit here so we don't report to the | |
92 server */ | |
93 if (report_idle == 0) { | |
94 return TRUE; | |
95 } | |
96 | |
71 if (idle_time > 600 && !gc->is_idle) { /* 10 minutes! */ | 97 if (idle_time > 600 && !gc->is_idle) { /* 10 minutes! */ |
72 debug_printf("setting %s idle %d seconds\n", gc->username, idle_time); | 98 debug_printf("setting %s idle %d seconds\n", gc->username, idle_time); |
73 serv_set_idle(gc, idle_time); | 99 serv_set_idle(gc, idle_time); |
74 gc->is_idle = 1; | 100 gc->is_idle = 1; |
75 } else if (idle_time < 600 && gc->is_idle) { | 101 } else if (idle_time < 600 && gc->is_idle) { |