diff options
author | Timo Sirainen <cras@irssi.org> | 2001-02-17 19:44:22 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-02-17 19:44:22 +0000 |
commit | be6ba53fa47bc546279a2575523281845fe80da9 (patch) | |
tree | 2f08f6281cfbd38a1df2abe4fe69ccfd6f208f51 /src/fe-common/core/fe-channels.c | |
parent | 513e140bcebce617d6078a9532ab9976437c3ef6 (diff) | |
download | irssi-be6ba53fa47bc546279a2575523281845fe80da9.zip |
Config file: ircnets -> chatnets, added type = "chat protocol" to
chatnet config. Moved reading chatnets to core. Lots of other
multiprotocol updates.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1237 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/core/fe-channels.c')
-rw-r--r-- | src/fe-common/core/fe-channels.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/fe-common/core/fe-channels.c b/src/fe-common/core/fe-channels.c index e15742d6..e3941b2c 100644 --- a/src/fe-common/core/fe-channels.c +++ b/src/fe-common/core/fe-channels.c @@ -27,6 +27,8 @@ #include "misc.h" #include "settings.h" +#include "chat-protocols.h" +#include "chatnets.h" #include "channels.h" #include "channels-setup.h" #include "nicklist.h" @@ -232,6 +234,7 @@ static void cmd_channel(const char *data, SERVER_REC *server, WI_ITEM_REC *item) static void cmd_channel_add(const char *data) { GHashTable *optlist; + CHATNET_REC *chatnetrec; CHANNEL_SETUP_REC *rec; char *botarg, *botcmdarg, *chatnet, *channel, *password; void *free_arg; @@ -240,14 +243,23 @@ static void cmd_channel_add(const char *data) "channel add", &optlist, &channel, &chatnet, &password)) return; + if (*chatnet == '\0' || *channel == '\0') + cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + + chatnetrec = chatnet_find(chatnet); + if (chatnetrec == NULL) { + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + TXT_UNKNOWN_CHATNET, chatnet); + cmd_params_free(free_arg); + return; + } + botarg = g_hash_table_lookup(optlist, "bots"); botcmdarg = g_hash_table_lookup(optlist, "botcmd"); - if (*chatnet == '\0' || *channel == '\0') - cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - rec = channels_setup_find(channel, chatnet); + rec = channel_setup_find(channel, chatnet); if (rec == NULL) { - rec = g_new0(CHANNEL_SETUP_REC, 1); + rec = CHAT_PROTOCOL(chatnetrec)->create_channel_setup(); rec->name = g_strdup(channel); rec->chatnet = g_strdup(chatnet); } else { @@ -260,8 +272,12 @@ static void cmd_channel_add(const char *data) if (botarg != NULL && *botarg != '\0') rec->botmasks = g_strdup(botarg); if (botcmdarg != NULL && *botcmdarg != '\0') rec->autosendcmd = g_strdup(botcmdarg); if (*password != '\0' && strcmp(password, "-") != 0) rec->password = g_strdup(password); - channels_setup_create(rec); - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_CHANSETUP_ADDED, channel, chatnet); + + signal_emit("channel add fill", 2, rec, optlist); + + channel_setup_create(rec); + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + TXT_CHANSETUP_ADDED, channel, chatnet); cmd_params_free(free_arg); } @@ -278,12 +294,12 @@ static void cmd_channel_remove(const char *data) if (*chatnet == '\0' || *channel == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - rec = channels_setup_find(channel, chatnet); + rec = channel_setup_find(channel, chatnet); if (rec == NULL) printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_CHANSETUP_NOT_FOUND, channel, chatnet); else { printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_CHANSETUP_REMOVED, channel, chatnet); - channels_setup_destroy(rec); + channel_setup_remove(rec); } cmd_params_free(free_arg); } @@ -317,6 +333,10 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist) g_free(stripped); g_free(format); + if (settings_get_int("names_max_width") > 0 && + max_width > settings_get_int("names_max_width")) + max_width = settings_get_int("names_max_width"); + /* remove width of timestamp from max_width */ format_create_dest(&dest, channel->server, channel->name, MSGLEVEL_CLIENTCRAP, NULL); @@ -329,10 +349,6 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist) } /* calculate columns */ - if (settings_get_int("names_max_width") > 0 && - max_width > settings_get_int("names_max_width")) - max_width = settings_get_int("names_max_width"); - cols = get_max_column_count(nicklist, get_nick_length, max_width, settings_get_int("names_max_columns"), item_extra, 3, &columns, &rows); |