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
This commit is contained in:
TingPing 2015-02-01 01:45:34 -05:00
parent dc9a7d3a59
commit 60fa7efbc8
3 changed files with 20 additions and 19 deletions

View File

@ -41,6 +41,7 @@
#include "chanopt.h" #include "chanopt.h"
#include "ignore.h" #include "ignore.h"
#include "hexchat-plugin.h" #include "hexchat-plugin.h"
#include "inbound.h"
#include "plugin.h" #include "plugin.h"
#include "plugin-identd.h" #include "plugin-identd.h"
#include "plugin-timer.h" #include "plugin-timer.h"
@ -491,7 +492,6 @@ new_ircwindow (server *serv, char *name, int type, int focus)
break; break;
case SESS_DIALOG: case SESS_DIALOG:
sess = session_new (serv, name, type, focus); sess = session_new (serv, name, type, focus);
log_open_or_close (sess);
break; break;
default: default:
/* case SESS_CHANNEL: /* case SESS_CHANNEL:
@ -506,6 +506,16 @@ new_ircwindow (server *serv, char *name, int type, int focus)
scrollback_load (sess); scrollback_load (sess);
if (sess->scrollwritten && sess->scrollback_replay_marklast) if (sess->scrollwritten && sess->scrollback_replay_marklast)
sess->scrollback_replay_marklast (sess); 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"); plugin_emit_dummy_print (sess, "Open Context");
return sess; return sess;

View File

@ -81,6 +81,15 @@ clear_channel (session *sess)
void void
set_topic (session *sess, char *topic, char *stripped_topic) 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); g_free (sess->topic);
sess->topic = g_strdup (stripped_topic); sess->topic = g_strdup (stripped_topic);
fe_set_topic (sess, topic, 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 (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); set_topic (sess, ip, ip);
}
inbound_chanmsg (serv, NULL, NULL, from, text, FALSE, id, tags_data); inbound_chanmsg (serv, NULL, NULL, from, text, FALSE, id, tags_data);
return; return;
} }

View File

@ -3508,7 +3508,6 @@ mg_changui_new (session *sess, restore_gui *res, int tab, int focus)
{ {
int first_run = FALSE; int first_run = FALSE;
session_gui *gui; session_gui *gui;
struct User *user = NULL;
if (res == NULL) if (res == NULL)
{ {
@ -3522,9 +3521,6 @@ mg_changui_new (session *sess, restore_gui *res, int tab, int focus)
sess->server->front_session = sess; sess->server->front_session = sess;
} }
if (!is_channel (sess->server, sess->channel))
user = userlist_find_global (sess->server, sess->channel);
if (!tab) if (!tab)
{ {
gui = g_new0 (session_gui, 1); gui = g_new0 (session_gui, 1);
@ -3532,8 +3528,6 @@ mg_changui_new (session *sess, restore_gui *res, int tab, int focus)
sess->gui = gui; sess->gui = gui;
mg_create_topwindow (sess); mg_create_topwindow (sess);
fe_set_title (sess); fe_set_title (sess);
if (user && user->hostname)
set_topic (sess, user->hostname, user->hostname);
return; return;
} }
@ -3553,9 +3547,6 @@ mg_changui_new (session *sess, restore_gui *res, int tab, int focus)
gui->is_tab = TRUE; gui->is_tab = TRUE;
} }
if (user && user->hostname)
set_topic (sess, user->hostname, user->hostname);
mg_add_chan (sess); mg_add_chan (sess);
if (first_run || (prefs.hex_gui_tab_newtofront == FOCUS_NEW_ONLY_ASKED && focus) if (first_run || (prefs.hex_gui_tab_newtofront == FOCUS_NEW_ONLY_ASKED && focus)