comparison src/server.c @ 4111:ee884f1d7ae3

[gaim-migrate @ 4326] <Robot101> adds a gc->flag called OPT_CONN_AUTO_RESP so that gc->away can always store the away message even if the prpl doesn't support autoresponding <Robot101> makes all protos correctly free and set gc->away to avoid leaks <Robot101> stores the current away state in gc->away_state whenever gc->away is non-NULL (ie it's not just a plain on-line) <Robot101> also minor change to Jabber to make Chatty an away state, and to Gadu-Gadu to make some other thing an away state too committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 21 Dec 2002 19:33:54 +0000
parents 3ccbdf8e7f8d
children 19ee0409a3d7
comparison
equal deleted inserted replaced
4110:64d983d6b7bb 4111:ee884f1d7ae3
230 230
231 void serv_set_away(struct gaim_connection *gc, char *state, char *message) 231 void serv_set_away(struct gaim_connection *gc, char *state, char *message)
232 { 232 {
233 if (gc && gc->prpl && gc->prpl->set_away) { 233 if (gc && gc->prpl && gc->prpl->set_away) {
234 char *buf = NULL; 234 char *buf = NULL;
235
236 if (gc->away_state) {
237 g_free(gc->away_state);
238 gc->away_state = NULL;
239 }
240
235 if (message) { 241 if (message) {
236 buf = g_malloc(strlen(message) + 1); 242 buf = g_malloc(strlen(message) + 1);
237 if (gc->flags & OPT_CONN_HTML) 243 if (gc->flags & OPT_CONN_HTML)
238 strncpy(buf, message, strlen(message) + 1); 244 strncpy(buf, message, strlen(message) + 1);
239 else 245 else
240 strncpy_nohtml(buf, message, strlen(message) + 1); 246 strncpy_nohtml(buf, message, strlen(message) + 1);
241 } 247 }
242 248
243 gc->prpl->set_away(gc, state, buf); 249 gc->prpl->set_away(gc, state, buf);
250
251 if (gc->away && state) {
252 gc->away_state = g_strdup(state);
253 }
244 254
245 plugin_event(event_away, gc, state, buf); 255 plugin_event(event_away, gc, state, buf);
246 256
247 if (buf) 257 if (buf)
248 g_free(buf); 258 g_free(buf);
669 play_sound(SND_RECEIVE); 679 play_sound(SND_RECEIVE);
670 680
671 write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime, len); 681 write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime, len);
672 } 682 }
673 683
674 /* regardless of whether we queue it or not, we should send an auto-response. That is, 684 /* regardless of whether we queue it or not, we should send an auto-response.
675 * of course, unless the horse.... no wait. */ 685 * that is, of course, unless the horse.... no wait. don't autorespond if:
676 if ((away_options & OPT_AWAY_NO_AUTO_RESP) || !strlen(gc->away) || 686 * - it's not supported on this connection
677 ((away_options & OPT_AWAY_IDLE_RESP) && !gc->is_idle)) { 687 * - or it's disabled
688 * - or the away message is empty
689 * - or we're not idle and the 'only auto respond if idle' pref is set
690 */
691 if (!(gc->flags & OPT_CONN_AUTO_RESP) || (away_options & OPT_AWAY_NO_AUTO_RESP) ||
692 !strlen(gc->away) || ((away_options & OPT_AWAY_IDLE_RESP) && !gc->is_idle)) {
678 g_free(name); 693 g_free(name);
679 g_free(message); 694 g_free(message);
680 return; 695 return;
681 } 696 }
682 697