comparison src/idle.c @ 5563:9eb5b13fd412

[gaim-migrate @ 5965] Just a taste of what's coming. Standard "This won't compile" thing. Plugin authors, you're going to hate me, but that's okay, because I have friends too! It's really late. My brain resembles that of fish swimming in jello pudding with neon lights flying around chanting musicals. I'm not on drugs. I'm just that tired. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Fri, 30 May 2003 09:38:29 +0000
parents b7319c094153
children 6500a6c8d679
comparison
equal deleted inserted replaced
5562:3c8d34574601 5563:9eb5b13fd412
46 #define IDLEMARK 600 /* 10 minutes! */ 46 #define IDLEMARK 600 /* 10 minutes! */
47 47
48 gint check_idle(gpointer data) 48 gint check_idle(gpointer data)
49 { 49 {
50 const char *report_idle; 50 const char *report_idle;
51 struct gaim_connection *gc = data; 51 GaimConnection *gc = data;
52 GaimAccount *account;
52 time_t t; 53 time_t t;
53 #ifdef USE_SCREENSAVER 54 #ifdef USE_SCREENSAVER
54 #ifndef _WIN32 55 #ifndef _WIN32
55 static XScreenSaverInfo *mit_info = NULL; 56 static XScreenSaverInfo *mit_info = NULL;
56 #endif 57 #endif
57 #endif 58 #endif
58 int idle_time; 59 int idle_time;
60
61 account = gaim_connection_get_account(gc);
59 62
60 gaim_event_broadcast(event_blist_update); 63 gaim_event_broadcast(event_blist_update);
61 64
62 time(&t); 65 time(&t);
63 66
78 #else 81 #else
79 idle_time = (GetTickCount() - wgaim_get_lastactive()) / 1000; 82 idle_time = (GetTickCount() - wgaim_get_lastactive()) / 1000;
80 #endif 83 #endif
81 } else 84 } else
82 #endif /* USE_SCREENSAVER */ 85 #endif /* USE_SCREENSAVER */
83 idle_time = t - gc->lastsent; 86 idle_time = t - gc->last_sent_time;
84 87
85 if (gaim_prefs_get_bool("/core/away/away_when_idle") && 88 if (gaim_prefs_get_bool("/core/away/away_when_idle") &&
86 (idle_time > (60 * auto_away)) && (!gc->is_auto_away)) { 89 (idle_time > (60 * auto_away)) && (!gc->is_auto_away)) {
87 90
88 if (!gc->away) { 91 if (!gc->away) {
89 gaim_debug(GAIM_DEBUG_INFO, "idle", 92 gaim_debug(GAIM_DEBUG_INFO, "idle",
90 "Making %s away automatically\n", gc->username); 93 "Making %s away automatically\n",
91 if (g_slist_length(connections) == 1) 94 gaim_account_get_username(account));
95 if (g_list_length(gaim_connections_get_all()) == 1)
92 do_away_message(NULL, default_away); 96 do_away_message(NULL, default_away);
93 else if (default_away) 97 else if (default_away)
94 serv_set_away(gc, GAIM_AWAY_CUSTOM, default_away->message); 98 serv_set_away(gc, GAIM_AWAY_CUSTOM, default_away->message);
95 gc->is_auto_away = 1; 99 gc->is_auto_away = 1;
96 set_default_away(NULL, (gpointer)g_slist_index(away_messages, default_away)); 100 set_default_away(NULL, (gpointer)g_slist_index(away_messages, default_away));
102 return TRUE; 106 return TRUE;
103 } 107 }
104 gc->is_auto_away = 0; 108 gc->is_auto_away = 0;
105 if (awaymessage == NULL) { 109 if (awaymessage == NULL) {
106 gaim_debug(GAIM_DEBUG_INFO, "idle", 110 gaim_debug(GAIM_DEBUG_INFO, "idle",
107 "Removing auto-away message for %s\n", gc->username); 111 "Removing auto-away message for %s\n", gaim_account_get_username(account));
108 serv_set_away(gc, GAIM_AWAY_CUSTOM, NULL); 112 serv_set_away(gc, GAIM_AWAY_CUSTOM, NULL);
109 } else { 113 } else {
110 if (g_slist_length(connections) == 1) 114 if (g_list_length(gaim_connections_get_all()) == 1)
111 do_im_back(0, 0); 115 do_im_back(0, 0);
112 else { 116 else {
113 gaim_debug(GAIM_DEBUG_INFO, "idle", 117 gaim_debug(GAIM_DEBUG_INFO, "idle",
114 "Replacing auto-away with global for %s\n", 118 "Replacing auto-away with global for %s\n",
115 gc->username); 119 gaim_account_get_username(account));
116 serv_set_away(gc, GAIM_AWAY_CUSTOM, awaymessage->message); 120 serv_set_away(gc, GAIM_AWAY_CUSTOM, awaymessage->message);
117 } 121 }
118 } 122 }
119 } 123 }
120 124
126 if (!strcmp(report_idle, "none")) 130 if (!strcmp(report_idle, "none"))
127 return TRUE; 131 return TRUE;
128 132
129 if (idle_time >= IDLEMARK && !gc->is_idle) { 133 if (idle_time >= IDLEMARK && !gc->is_idle) {
130 gaim_debug(GAIM_DEBUG_INFO, "idle", "Setting %s idle %d seconds\n", 134 gaim_debug(GAIM_DEBUG_INFO, "idle", "Setting %s idle %d seconds\n",
131 gc->username, idle_time); 135 gaim_account_get_username(account), idle_time);
132 serv_set_idle(gc, idle_time); 136 serv_set_idle(gc, idle_time);
133 gc->is_idle = 1; 137 gc->is_idle = 1;
134 system_log(log_idle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); 138 system_log(log_idle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON);
135 } else if (idle_time < IDLEMARK && gc->is_idle) { 139 } else if (idle_time < IDLEMARK && gc->is_idle) {
136 gaim_debug(GAIM_DEBUG_INFO, "idle", "Setting %s unidle\n", 140 gaim_debug(GAIM_DEBUG_INFO, "idle", "Setting %s unidle\n",
137 gc->username); 141 gaim_account_get_username(account));
138 serv_touch_idle(gc); 142 serv_touch_idle(gc);
139 system_log(log_unidle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON); 143 system_log(log_unidle, gc, NULL, OPT_LOG_BUDDY_IDLE | OPT_LOG_MY_SIGNON);
140 } 144 }
141 145
142 return TRUE; 146 return TRUE;