summary refs log tree commit diff stats
path: root/src/common
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2015-02-01 01:45:34 -0500
committerTingPing <tingping@tingping.se>2015-02-01 01:47:50 -0500
commit60fa7efbc861cc6b6d6ff0f619a16ed79025cb12 (patch)
treeb2c7a195edae991b12681a38f1fe13f75af305e3 /src/common
parentdc9a7d3a59ffaa47523dbbc4daadfda9c891ecb0 (diff)
Fix logging hostname of queries
- Move query topic setting from frontend (where its too late)
- Respect chanopts for logging hostname
- Open query logfile *after* chanopts loaded
Diffstat (limited to 'src/common')
-rw-r--r--src/common/hexchat.c12
-rw-r--r--src/common/inbound.c18
2 files changed, 20 insertions, 10 deletions
diff --git a/src/common/hexchat.c b/src/common/hexchat.c
index 1428039a..e304d5ff 100644
--- a/src/common/hexchat.c
+++ b/src/common/hexchat.c
@@ -41,6 +41,7 @@
 #include "chanopt.h"
 #include "ignore.h"
 #include "hexchat-plugin.h"
+#include "inbound.h"
 #include "plugin.h"
 #include "plugin-identd.h"
 #include "plugin-timer.h"
@@ -491,7 +492,6 @@ new_ircwindow (server *serv, char *name, int type, int focus)
 		break;
 	case SESS_DIALOG:
 		sess = session_new (serv, name, type, focus);
-		log_open_or_close (sess);
 		break;
 	default:
 /*	case SESS_CHANNEL:
@@ -506,6 +506,16 @@ new_ircwindow (server *serv, char *name, int type, int focus)
 	scrollback_load (sess);
 	if (sess->scrollwritten && sess->scrollback_replay_marklast)
 		sess->scrollback_replay_marklast (sess);
+	if (type == SESS_DIALOG)
+	{
+		struct User *user;
+
+		log_open_or_close (sess);
+
+		user = userlist_find_global (serv, name);
+		if (user && user->hostname)
+			set_topic (sess, user->hostname, user->hostname);
+	}
 	plugin_emit_dummy_print (sess, "Open Context");
 
 	return sess;
diff --git a/src/common/inbound.c b/src/common/inbound.c
index db68c64c..ef26890b 100644
--- a/src/common/inbound.c
+++ b/src/common/inbound.c
@@ -81,6 +81,15 @@ clear_channel (session *sess)
 void
 set_topic (session *sess, char *topic, char *stripped_topic)
 {
+	/* The topic of dialogs are the users hostname which is logged is new */
+	if (sess->type == SESS_DIALOG && (!sess->topic || strcmp(sess->topic, stripped_topic))
+		&& sess->logfd != -1)
+	{
+		char tbuf[1024];
+		g_snprintf (tbuf, sizeof (tbuf), "[%s has address %s]\n", sess->channel, stripped_topic);
+		write (sess->logfd, tbuf, strlen (tbuf));
+	}
+
 	g_free (sess->topic);
 	sess->topic = g_strdup (stripped_topic);
 	fe_set_topic (sess, topic, stripped_topic);
@@ -179,16 +188,7 @@ inbound_privmsg (server *serv, char *from, char *ip, char *text, int id,
 		}
 
 		if (ip && ip[0])
-		{
-			if (prefs.hex_irc_logging && sess->logfd != -1 &&
-				(!sess->topic || strcmp(sess->topic, ip)))
-			{
-				char tbuf[1024];
-				g_snprintf (tbuf, sizeof (tbuf), "[%s has address %s]\n", from, ip);
-				write (sess->logfd, tbuf, strlen (tbuf));
-			}
 			set_topic (sess, ip, ip);
-		}
 		inbound_chanmsg (serv, NULL, NULL, from, text, FALSE, id, tags_data);
 		return;
 	}