1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-22 04:35:58 -04:00

revert core changes

This commit is contained in:
ailin-nemui 2018-10-06 19:26:36 +02:00
parent 7b09cac9ec
commit 8b1afbd355
4 changed files with 17 additions and 55 deletions

View File

@ -73,22 +73,12 @@ const char *get_irssi_dir(void)
return irssi_dir; return irssi_dir;
} }
void set_irssi_dir(char *const s)
{
irssi_dir = s;
}
/* return full path for ~/.irssi/config */ /* return full path for ~/.irssi/config */
const char *get_irssi_config(void) const char *get_irssi_config(void)
{ {
return irssi_config_file; return irssi_config_file;
} }
void set_irssi_config(char *const s)
{
irssi_config_file = s;
}
static void sig_reload_config(int signo) static void sig_reload_config(int signo)
{ {
reload_config = TRUE; reload_config = TRUE;

View File

@ -16,9 +16,6 @@ extern int irssi_init_finished; /* TRUE after "irssi init finished" signal is se
extern int reload_config; /* TRUE after received SIGHUP. */ extern int reload_config; /* TRUE after received SIGHUP. */
extern time_t client_start_time; extern time_t client_start_time;
void set_irssi_dir(char *const);
void set_irssi_config(char *const);
void core_preinit(const char *path); void core_preinit(const char *path);
void core_register_options(void); void core_register_options(void);

View File

@ -29,9 +29,6 @@
#include "irc-servers.h" #include "irc-servers.h"
#include "irc-channels.h" #include "irc-channels.h"
static void set_topic_info(CHANNEL_REC *const, char const *const,
time_t const);
static void check_join_failure(IRC_SERVER_REC *server, const char *channel) static void check_join_failure(IRC_SERVER_REC *server, const char *channel)
{ {
CHANNEL_REC *chanrec; CHANNEL_REC *chanrec;
@ -130,51 +127,27 @@ static void channel_change_topic(IRC_SERVER_REC *server, const char *channel,
chanrec = channel_find(SERVER(server), channel); chanrec = channel_find(SERVER(server), channel);
if (chanrec == NULL) return; if (chanrec == NULL) return;
/* the topic may be send out encoded, so we need to
g_free_and_null(chanrec->topic);
g_free_and_null(chanrec->topic_by);
chanrec->topic_time = 0;
/* the topic may be sent out encoded, so we need to
recode it back or /topic <tab> will not work properly */ recode it back or /topic <tab> will not work properly */
recoded = recode_in(SERVER(server), topic, channel); recoded = recode_in(SERVER(server), topic, channel);
if (recoded == NULL || *recoded == '\0') { if (topic != NULL) {
signal_emit("channel topic changed", 1, chanrec); g_free_not_null(chanrec->topic);
g_free(recoded); chanrec->topic = recoded == NULL ? NULL : g_strdup(recoded);
return;
} }
g_free(recoded);
chanrec->topic = recoded; g_free_not_null(chanrec->topic_by);
set_topic_info(chanrec, setby, settime);
signal_emit("channel topic changed", 1, chanrec);
}
static void channel_change_topic_info(IRC_SERVER_REC *server,
const char *channel, const char *setby, time_t settime)
{
CHANNEL_REC *chanrec;
chanrec = channel_find(SERVER(server), channel);
if (chanrec == NULL) return;
g_free_and_null(chanrec->topic_by);
chanrec->topic_time = 0;
set_topic_info(chanrec, setby, settime);
signal_emit("channel topic changed", 1, chanrec);
}
static void set_topic_info(CHANNEL_REC *const chanrec, char const *const setby,
time_t const settime)
{
chanrec->topic_by = g_strdup(setby); chanrec->topic_by = g_strdup(setby);
if (chanrec->topic_by != NULL) {
if (chanrec->topic_by == NULL) {
/* ensure invariant topic_time > 0 <=> topic_by != NULL. /* ensure invariant topic_time > 0 <=> topic_by != NULL.
this could be triggered by a topic command without sender */ this could be triggered by a topic command without sender */
chanrec->topic_time = 0;
} else {
chanrec->topic_time = settime; chanrec->topic_time = settime;
} }
signal_emit("channel topic changed", 1, chanrec);
} }
static void event_topic_get(IRC_SERVER_REC *server, const char *data) static void event_topic_get(IRC_SERVER_REC *server, const char *data)
@ -214,7 +187,7 @@ static void event_topic_info(IRC_SERVER_REC *server, const char *data)
&topicby, &topictime); &topicby, &topictime);
t = (time_t) atol(topictime); t = (time_t) atol(topictime);
channel_change_topic_info(server, channel, topicby, t); channel_change_topic(server, channel, NULL, topicby, t);
g_free(params); g_free(params);
} }

View File

@ -31,6 +31,7 @@
#include <settings.h> #include <settings.h>
#include <signals.h> #include <signals.h>
#include <time.h> #include <time.h>
#include <args.h>
#define MODULE_NAME "test-channel-events" #define MODULE_NAME "test-channel-events"
@ -87,10 +88,11 @@ int main(int argc, char **argv)
g_test_init(&argc, &argv, NULL); g_test_init(&argc, &argv, NULL);
core_preinit(*argv);
irssi_gui = IRSSI_GUI_NONE;
modules_init(); modules_init();
signals_init(); signals_init();
set_irssi_dir("/tmp/irssi");
set_irssi_config("/tmp/irssi/config");
settings_init(); settings_init();
recode_init(); recode_init();
channel_events_init(); channel_events_init();