diff 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
line wrap: on
line diff
--- a/src/server.c	Sat Dec 21 05:37:45 2002 +0000
+++ b/src/server.c	Sat Dec 21 19:33:54 2002 +0000
@@ -232,6 +232,12 @@
 {
 	if (gc && gc->prpl && gc->prpl->set_away) {
 		char *buf = NULL;
+
+		if (gc->away_state) {
+			g_free(gc->away_state);
+			gc->away_state = NULL;
+		}
+
 		if (message) {
 			buf = g_malloc(strlen(message) + 1);
 			if (gc->flags & OPT_CONN_HTML)
@@ -242,6 +248,10 @@
 
 		gc->prpl->set_away(gc, state, buf);
 
+		if (gc->away && state) {
+			gc->away_state = g_strdup(state);
+		}
+
 		plugin_event(event_away, gc, state, buf);
 
 		if (buf)
@@ -671,10 +681,15 @@
 			write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime, len);
 		}
 
-		/* regardless of whether we queue it or not, we should send an auto-response. That is,
-		 * of course, unless the horse.... no wait. */
-		if ((away_options & OPT_AWAY_NO_AUTO_RESP) || !strlen(gc->away) ||
-				((away_options & OPT_AWAY_IDLE_RESP) && !gc->is_idle)) {
+		/* regardless of whether we queue it or not, we should send an auto-response.
+		 * that is, of course, unless the horse.... no wait. don't autorespond if:
+		 *  - it's not supported on this connection
+		 *  - or it's disabled
+		 *  - or the away message is empty
+		 *  - or we're not idle and the 'only auto respond if idle' pref is set
+		 */
+		if (!(gc->flags & OPT_CONN_AUTO_RESP) || (away_options & OPT_AWAY_NO_AUTO_RESP) ||
+		      !strlen(gc->away) || ((away_options & OPT_AWAY_IDLE_RESP) && !gc->is_idle)) {
 			g_free(name);
 			g_free(message);
 			return;