From: Martin Johansson Date: Wed, 13 Nov 2013 21:47:37 +0000 (+0100) Subject: Add channel position. X-Git-Url: http://git.code-monkey.de/?p=umurmur.git;a=commitdiff_plain;h=36601a5de5f90e16188deadd271b70595b4cc237 Add channel position. --- diff --git a/src/channel.c b/src/channel.c index 7e939a5..021f9bd 100644 --- a/src/channel.c +++ b/src/channel.c @@ -161,6 +161,7 @@ void Chan_init() channel_t *ch, *ch_itr = NULL; ch = Chan_createChannel(chdesc.name, chdesc.description); ch->noenter = chdesc.noenter; + ch->position = chdesc.position; if (chdesc.password) { Log_info("Setting password on channel '%s'", ch->name); ch->password = strdup(chdesc.password); diff --git a/src/channel.h b/src/channel.h index c32ae5b..35caceb 100644 --- a/src/channel.h +++ b/src/channel.h @@ -42,6 +42,7 @@ typedef struct channel { char *password; struct channel *parent; bool_t temporary, noenter, silent; + int position; struct dlist node; struct dlist subs; struct dlist clients; diff --git a/src/conf.c b/src/conf.c index 447061f..2ec69a5 100644 --- a/src/conf.c +++ b/src/conf.c @@ -340,6 +340,13 @@ int Conf_getNextChannel(conf_channel_t *chdesc, int index) chdesc->silent = false; else chdesc->silent = config_setting_get_bool(setting); + + ret = snprintf(configstr, maxconfig, "channels.[%d].position", index); + setting = config_lookup(&configuration, configstr); + if (ret >= maxconfig || ret < 0 || setting == NULL) /* Optional */ + chdesc->position = 0; + else + chdesc->position = config_setting_get_int(setting); return 0; } diff --git a/src/conf.h b/src/conf.h index d30ed41..9cab3d1 100644 --- a/src/conf.h +++ b/src/conf.h @@ -55,7 +55,6 @@ typedef enum param { BANFILE, SYNC_BANFILE, OPUS_THRESHOLD, - SILENT_CHANNEL, } param_t; typedef struct { @@ -64,6 +63,7 @@ typedef struct { const char *description; const char *password; bool_t noenter, silent; + int position; } conf_channel_t; typedef struct { diff --git a/src/messagehandler.c b/src/messagehandler.c index f075c46..1e49241 100644 --- a/src/messagehandler.c +++ b/src/messagehandler.c @@ -263,6 +263,10 @@ void Mh_handle_message(client_t *client, message_t *msg) sendmsg->payload.channelState->name = strdup(ch_itr->name); if (ch_itr->desc) sendmsg->payload.channelState->description = strdup(ch_itr->desc); + if (ch_itr->position != 0) { + sendmsg->payload.channelState->has_position = true; + sendmsg->payload.channelState->position = ch_itr->position; + } Log_debug("Send channel info: %s", sendmsg->payload.channelState->name); Client_send_message(client, sendmsg); } @@ -728,6 +732,8 @@ void Mh_handle_message(client_t *client, message_t *msg) newchan = Chan_createChannel(msg->payload.channelState->name, msg->payload.channelState->description); newchan->temporary = true; + if (msg->payload.channelState->has_position) + newchan->position = msg->payload.channelState->position; Chan_addChannel(parent, newchan); msg->payload.channelState->has_channel_id = true; msg->payload.channelState->channel_id = newchan->id;