revert core changes

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

View file

@ -29,9 +29,6 @@
#include "irc-servers.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)
{
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);
if (chanrec == NULL) return;
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
/* the topic may be send out encoded, so we need to
recode it back or /topic <tab> will not work properly */
recoded = recode_in(SERVER(server), topic, channel);
if (recoded == NULL || *recoded == '\0') {
signal_emit("channel topic changed", 1, chanrec);
g_free(recoded);
return;
if (topic != NULL) {
g_free_not_null(chanrec->topic);
chanrec->topic = recoded == NULL ? NULL : g_strdup(recoded);
}
g_free(recoded);
chanrec->topic = recoded;
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)
{
g_free_not_null(chanrec->topic_by);
chanrec->topic_by = g_strdup(setby);
if (chanrec->topic_by != NULL) {
if (chanrec->topic_by == NULL) {
/* ensure invariant topic_time > 0 <=> topic_by != NULL.
this could be triggered by a topic command without sender */
chanrec->topic_time = 0;
} else {
chanrec->topic_time = settime;
}
signal_emit("channel topic changed", 1, chanrec);
}
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);
t = (time_t) atol(topictime);
channel_change_topic_info(server, channel, topicby, t);
channel_change_topic(server, channel, NULL, topicby, t);
g_free(params);
}