summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2020-08-05 20:05:36 +0200
committerSébastien Helleu <flashcode@flashtux.org>2020-08-05 20:05:36 +0200
commit0cc5df664955cafab8334d7abc3dfd6dc8bc77cd (patch)
treeae805a153fa5a19cfa911f1a599fcf54df12925c
parent36c55f6973b233c17c6e5baaf46be2e0fb334bb6 (diff)
downloadweechat-0cc5df664955cafab8334d7abc3dfd6dc8bc77cd.zip
irc: send all channels in a single JOIN command when reconnecting to the server (closes #1551)
-rw-r--r--ChangeLog.adoc1
-rw-r--r--doc/en/weechat_dev.en.adoc1
-rw-r--r--doc/fr/weechat_dev.fr.adoc1
-rw-r--r--doc/ja/weechat_dev.ja.adoc2
-rw-r--r--src/plugins/irc/irc-server.c117
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/unit/plugins/irc/test-irc-server.cpp1085
8 files changed, 1189 insertions, 22 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index 2d9cd5615..045d07fad 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -27,6 +27,7 @@ New features::
Bug fixes::
* core: do not add line with highlight and tag "notify_none" to hotlist (issue #1529)
+ * irc: send all channels in a single JOIN command when reconnecting to the server (issue #1551)
* trigger: fix recursive calls to triggers using regex (issue #1546)
* trigger: add `${tg_tags} !!- ,notify_none,` in conditions of default trigger "beep" (issue #1529)
diff --git a/doc/en/weechat_dev.en.adoc b/doc/en/weechat_dev.en.adoc
index 10ed469b9..94a0b38ef 100644
--- a/doc/en/weechat_dev.en.adoc
+++ b/doc/en/weechat_dev.en.adoc
@@ -419,6 +419,7 @@ WeeChat "core" is located in following directories:
|             test-irc-mode.cpp | Tests: IRC modes.
|             test-irc-nick.cpp | Tests: IRC nicks.
|             test-irc-protocol.cpp | Tests: IRC protocol.
+|             test-irc-server.cpp | Tests: IRC server.
|          relay/ | Root of unit tests for Relay plugin.
|             test-relay-auth.cpp | Tests: clients authentication.
diff --git a/doc/fr/weechat_dev.fr.adoc b/doc/fr/weechat_dev.fr.adoc
index 1b964ac83..f4e1e689e 100644
--- a/doc/fr/weechat_dev.fr.adoc
+++ b/doc/fr/weechat_dev.fr.adoc
@@ -421,6 +421,7 @@ Le cœur de WeeChat est situé dans les répertoires suivants :
|             test-irc-mode.cpp | Tests : modes IRC.
|             test-irc-nick.cpp | Tests : pseudos IRC.
|             test-irc-protocol.cpp | Tests : protocole IRC.
+|             test-irc-server.cpp | Tests : serveur IRC.
|          relay/ | Racine des tests unitaires pour l'extension Relay.
|             test-relay-auth.cpp | Tests : authentification des clients.
|===
diff --git a/doc/ja/weechat_dev.ja.adoc b/doc/ja/weechat_dev.ja.adoc
index 744283d06..bc8011365 100644
--- a/doc/ja/weechat_dev.ja.adoc
+++ b/doc/ja/weechat_dev.ja.adoc
@@ -439,6 +439,8 @@ WeeChat "core" は以下のディレクトリに配置されています:
|             test-irc-nick.cpp | Tests: IRC nicks.
|             test-irc-protocol.cpp | テスト: IRC プロトコル
// TRANSLATION MISSING
+|             test-irc-server.cpp | Tests: IRC server.
+// TRANSLATION MISSING
|          relay/ | Root of unit tests for Relay plugin.
// TRANSLATION MISSING
|             test-relay-auth.cpp | Tests: clients authentication.
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 5918ba027..e98749518 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -5311,39 +5311,114 @@ irc_server_autojoin_create_buffers (struct t_irc_server *server)
}
/*
+ * Build the arguments for JOIN command using channels in server, only if the
+ * channel is not in "part" state (/part command issued).
+ *
+ * The arguments have the following format, where keys are optional (this is
+ * the syntax of JOIN command in IRC protocol):
+ *
+ * #channel1,#channel2,#channel3 key1,key2
+ *
+ * Note: result must be freed after use.
+ */
+
+char *
+irc_server_build_autojoin (struct t_irc_server *server)
+{
+ struct t_irc_channel *ptr_channel;
+ char **channels_with_key, **channels_others, **keys;
+
+ channels_with_key = NULL;
+ channels_others = NULL;
+ keys = NULL;
+
+ channels_with_key = weechat_string_dyn_alloc (1024);
+ if (!channels_with_key)
+ goto error;
+ channels_others = weechat_string_dyn_alloc (1024);
+ if (!channels_others)
+ goto error;
+ keys = weechat_string_dyn_alloc (1024);
+ if (!keys)
+ goto error;
+
+ for (ptr_channel = server->channels; ptr_channel;
+ ptr_channel = ptr_channel->next_channel)
+ {
+ if ((ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
+ && !ptr_channel->part)
+ {
+ if (ptr_channel->key)
+ {
+ /* add channel with key and the key */
+ if (*channels_with_key[0])
+ weechat_string_dyn_concat (channels_with_key, ",");
+ weechat_string_dyn_concat (channels_with_key, ptr_channel->name);
+ if (*keys[0])
+ weechat_string_dyn_concat (keys, ",");
+ weechat_string_dyn_concat (keys, ptr_channel->key);
+ }
+ else
+ {
+ /* add channel without key */
+ if (*channels_others[0])
+ weechat_string_dyn_concat (channels_others, ",");
+ weechat_string_dyn_concat (channels_others, ptr_channel->name);
+ }
+ }
+ }
+
+ /*
+ * concatenate channels_with_key + channels_others + keys
+ * into channels_with_key
+ */
+ if (*channels_others[0])
+ {
+ if (*channels_with_key[0])
+ weechat_string_dyn_concat (channels_with_key, ",");
+ weechat_string_dyn_concat (channels_with_key, *channels_others);
+ }
+ if (*keys[0])
+ {
+ weechat_string_dyn_concat (channels_with_key, " ");
+ weechat_string_dyn_concat (channels_with_key, *keys);
+ }
+
+ weechat_string_dyn_free (channels_others, 1);
+ weechat_string_dyn_free (keys, 1);
+
+ return weechat_string_dyn_free (channels_with_key, 0);
+
+error:
+ if (channels_with_key)
+ weechat_string_dyn_free (channels_with_key, 1);
+ if (channels_others)
+ weechat_string_dyn_free (channels_others, 1);
+ if (keys)
+ weechat_string_dyn_free (keys, 1);
+ return NULL;
+}
+
+/*
* Autojoins (or auto-rejoins) channels.
*/
void
irc_server_autojoin_channels (struct t_irc_server *server)
{
- struct t_irc_channel *ptr_channel;
char *autojoin;
/* auto-join after disconnection (only rejoins opened channels) */
if (!server->disable_autojoin && server->reconnect_join && server->channels)
{
- for (ptr_channel = server->channels; ptr_channel;
- ptr_channel = ptr_channel->next_channel)
+ autojoin = irc_server_build_autojoin (server);
+ if (autojoin)
{
- if ((ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
- && !ptr_channel->part)
- {
- if (ptr_channel->key)
- {
- irc_server_sendf (server,
- IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
- "JOIN %s %s",
- ptr_channel->name, ptr_channel->key);
- }
- else
- {
- irc_server_sendf (server,
- IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
- "JOIN %s",
- ptr_channel->name);
- }
- }
+ irc_server_sendf (server,
+ IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
+ "JOIN %s",
+ autojoin);
+ free (autojoin);
}
server->reconnect_join = 0;
}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 5b24c7b2d..67c75b8d8 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -58,6 +58,7 @@ if(ENABLE_IRC)
unit/plugins/irc/test-irc-mode.cpp
unit/plugins/irc/test-irc-nick.cpp
unit/plugins/irc/test-irc-protocol.cpp
+ unit/plugins/irc/test-irc-server.cpp
)
endif()
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f97fe676f..d4b29ff7e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -72,7 +72,8 @@ tests_irc = unit/plugins/irc/test-irc-channel.cpp \
unit/plugins/irc/test-irc-message.cpp \
unit/plugins/irc/test-irc-mode.cpp \
unit/plugins/irc/test-irc-nick.cpp \
- unit/plugins/irc/test-irc-protocol.cpp
+ unit/plugins/irc/test-irc-protocol.cpp \
+ unit/plugins/irc/test-irc-server.cpp
endif
if PLUGIN_RELAY
diff --git a/tests/unit/plugins/irc/test-irc-server.cpp b/tests/unit/plugins/irc/test-irc-server.cpp
new file mode 100644
index 000000000..85460db1f
--- /dev/null
+++ b/tests/unit/plugins/irc/test-irc-server.cpp
@@ -0,0 +1,1085 @@
+/*
+ * test-irc-server.cpp - test IRC protocol functions
+ *
+ * Copyright (C) 2020 Sébastien Helleu <flashcode@flashtux.org>
+ *
+ * This file is part of WeeChat, the extensible chat client.
+ *
+ * WeeChat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * WeeChat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "CppUTest/TestHarness.h"
+
+extern "C"
+{
+#include <stdio.h>
+#include "src/plugins/plugin.h"
+#include "src/plugins/irc/irc-channel.h"
+#include "src/plugins/irc/irc-server.h"
+
+extern char *irc_server_build_autojoin (struct t_irc_server *server);
+}
+
+#include "tests/tests.h"
+
+#define IRC_FAKE_SERVER "fake"
+
+TEST_GROUP(IrcServer)
+{
+};
+
+/*
+ * Tests functions:
+ * irc_server_valid
+ */
+
+TEST(IrcServer, Valid)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_search
+ */
+
+TEST(IrcServer, Search)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_casesearch
+ */
+
+TEST(IrcServer, CaseSearch)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_search_option
+ */
+
+TEST(IrcServer, SearchOption)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_search_casemapping
+ */
+
+TEST(IrcServer, SearchCasemapping)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_search_utf8mapping
+ */
+
+TEST(IrcServer, SearchUtf8mapping)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_strcasecmp
+ */
+
+TEST(IrcServer, Strcasecmp)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_strncasecmp
+ */
+
+TEST(IrcServer, Strncasecmp)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_eval_expression
+ */
+
+TEST(IrcServer, EvalExpression)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_EvalFingerprint
+ */
+
+TEST(IrcServer, EvalFingerprint)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_sasl_enabled
+ */
+
+TEST(IrcServer, SaslEnabled)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_name_without_port
+ */
+
+TEST(IrcServer, GetNameWithoutPort)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_set_addresses
+ */
+
+TEST(IrcServer, SetAddresses)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_set_index_current_address
+ */
+
+TEST(IrcServer, SetIndexCurrentAddress)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_set_nicks
+ */
+
+TEST(IrcServer, SetNicks)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_set_nick
+ */
+
+TEST(IrcServer, SetNick)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_set_host
+ */
+
+TEST(IrcServer, SetHost)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_nick_index
+ */
+
+TEST(IrcServer, GetNickIndex)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_alternate_nick
+ */
+
+TEST(IrcServer, GetAlternateNick)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_isupport_value
+ */
+
+TEST(IrcServer, GetIsupportValue)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_set_prefix_modes_chars
+ */
+
+TEST(IrcServer, SetPrefixModesChars)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_set_lag
+ */
+
+TEST(IrcServer, SetLag)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_prefix_modes
+ */
+
+TEST(IrcServer, GetPrefixModes)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_prefix_chars
+ */
+
+TEST(IrcServer, GetPrefixChars)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_prefix_mode_index
+ */
+
+TEST(IrcServer, GetPrefixModeIndex)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_prefix_char_index
+ */
+
+TEST(IrcServer, GetPrefixCharIndex)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_prefix_mode_for_char
+ */
+
+TEST(IrcServer, GetPrefixModeForChar)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_prefix_char_for_mode
+ */
+
+TEST(IrcServer, GetPrefixCharForMode)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_chanmodes
+ */
+
+TEST(IrcServer, GetChanmodes)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_prefix_char_statusmsg
+ */
+
+TEST(IrcServer, PrefixCharStatusmsg)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_max_modes
+ */
+
+TEST(IrcServer, GetMaxModes)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_default_msg
+ */
+
+TEST(IrcServer, GetDefaultMsg)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_alloc
+ */
+
+TEST(IrcServer, Alloc)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_alloc_with_url
+ */
+
+TEST(IrcServer, AllocWithUrl)
+{
+ /* TODO: write tests */
+}
+
+
+/*
+ * Tests functions:
+ * irc_server_apply_command_line_options
+ */
+
+TEST(IrcServer, ApplyCommandLineOptions)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_outqueue_add
+ */
+
+TEST(IrcServer, OutqueueAdd)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_outqueue_free
+ */
+
+TEST(IrcServer, OutqueueFree)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_outqueue_free_all
+ */
+
+TEST(IrcServer, OutqueueFreeAll)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_free_data
+ */
+
+TEST(IrcServer, FreeData)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_free
+ */
+
+TEST(IrcServer, Free)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_free_all
+ */
+
+TEST(IrcServer, FreeAll)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_copy
+ */
+
+TEST(IrcServer, Copy)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_rename
+ */
+
+TEST(IrcServer, Rename)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_reorder
+ */
+
+TEST(IrcServer, Reorder)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_send_signal
+ */
+
+TEST(IrcServer, SendSignal)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_send
+ */
+
+TEST(IrcServer, Send)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_set_send_default_tags
+ */
+
+TEST(IrcServer, SetSendDefaultTags)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_tags_to_send
+ */
+
+TEST(IrcServer, GetTagsToSend)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_outqueue_send
+ */
+
+TEST(IrcServer, OutqueueSend)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_send_one_msg
+ */
+
+TEST(IrcServer, SendOneMsg)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_sendf
+ */
+
+TEST(IrcServer, Sendf)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_msgq_add_msg
+ */
+
+TEST(IrcServer, MsgqAddMsg)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_msgq_add_unterminated
+ */
+
+TEST(IrcServer, MsgqAddUnterminated)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_msgq_add_buffer
+ */
+
+TEST(IrcServer, MsgqAddBuffer)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_msgq_flush
+ */
+
+TEST(IrcServer, MsgqFlush)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_recv_cb
+ */
+
+TEST(IrcServer, RecvCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_timer_connection_cb
+ */
+
+TEST(IrcServer, TimerConnectionCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_timer_sasl_cb
+ */
+
+TEST(IrcServer, TimerSaslCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_check_join_manual_cb
+ */
+
+TEST(IrcServer, CheckJoinManualCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_check_join_noswitch_cb
+ */
+
+TEST(IrcServer, CheckJoinNoswitchCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_check_join_smart_filtered_cb
+ */
+
+TEST(IrcServer, CheckJoinSmartFilteredCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_timer_cb
+ */
+
+TEST(IrcServer, TimerCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_close_connection
+ */
+
+TEST(IrcServer, CloseConnection)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_reconnect_schedule
+ */
+
+TEST(IrcServer, ReconnectSchedule)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_login
+ */
+
+TEST(IrcServer, Login)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_switch_address
+ */
+
+TEST(IrcServer, SwitchAddress)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_connect_cb
+ */
+
+TEST(IrcServer, ConnectCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_set_buffer_title
+ */
+
+TEST(IrcServer, SetBufferTitle)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_create_buffer
+ */
+
+TEST(IrcServer, CreateBuffer)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_fingerprint_search_algo_with_size
+ */
+
+TEST(IrcServer, FingerprintSearchAlgoWithSize)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_fingerprint_str_sizes
+ */
+
+TEST(IrcServer, FingerprintStrSizes)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_compare_fingerprints
+ */
+
+TEST(IrcServer, CompareFingerprints)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_check_certificate_fingerprint
+ */
+
+TEST(IrcServer, CheckCertificateFingerprint)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_gnutls_callback
+ */
+
+TEST(IrcServer, GnutlsCallback)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_connect
+ */
+
+TEST(IrcServer, Connect)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_reconnect
+ */
+
+TEST(IrcServer, Reconnect)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_auto_connect_timer_cb
+ */
+
+TEST(IrcServer, AutoConnectTimerCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_auto_connect
+ */
+
+TEST(IrcServer, AutoConnect)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_disconnect
+ */
+
+TEST(IrcServer, Disconnect)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_disconnect_all
+ */
+
+TEST(IrcServer, DisconnectAll)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_autojoin_create_buffers
+ */
+
+TEST(IrcServer, AutojoinCreateBuffers)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_autojoin_channels
+ */
+
+TEST(IrcServer, AutojoinChannels)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_channel_count
+ */
+
+TEST(IrcServer, GetChannelCount)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_get_pv_count
+ */
+
+TEST(IrcServer, GetPvCount)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_remove_away
+ */
+
+TEST(IrcServer, RemoveAway)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_check_away
+ */
+
+TEST(IrcServer, CheckAway)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_set_away
+ */
+
+TEST(IrcServer, SetAway)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_xfer_send_ready_cb
+ */
+
+TEST(IrcServer, XferSendReadyCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_xfer_resume_ready_cb
+ */
+
+TEST(IrcServer, XferResumeReadyCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_xfer_send_accept_resume_cb
+ */
+
+TEST(IrcServer, XferSendAcceptResumeCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_hdata_server_cb
+ */
+
+TEST(IrcServer, HdataServerCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_add_to_infolist
+ */
+
+TEST(IrcServer, AddToInfolist)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * irc_server_print_log
+ */
+
+TEST(IrcServer, PrintLog)
+{
+ /* TODO: write tests */
+}
+
+TEST_GROUP(IrcServerConnected)
+{
+ struct t_irc_server *ptr_server;
+
+ void server_recv (const char *command)
+ {
+ char str_command[4096];
+
+ snprintf (str_command, sizeof (str_command),
+ "/command -buffer irc.server." IRC_FAKE_SERVER " irc "
+ "/server fakerecv %s",
+ command);
+ run_cmd (str_command);
+ }
+
+ void setup ()
+ {
+ printf ("\n");
+
+ /* create a fake server (no I/O) */
+ run_cmd ("/server add " IRC_FAKE_SERVER " fake:127.0.0.1 "
+ "-nicks=nick1,nick2,nick3");
+
+ /* connect to the fake server */
+ run_cmd ("/connect " IRC_FAKE_SERVER);
+
+ /* get the server pointer */
+ ptr_server = irc_server_search (IRC_FAKE_SERVER);
+ }
+
+ void teardown ()
+ {
+ /* disconnect and delete the fake server */
+ run_cmd ("/disconnect " IRC_FAKE_SERVER);
+ run_cmd ("/server del " IRC_FAKE_SERVER);
+ ptr_server = NULL;
+ }
+};
+
+/*
+ * Tests functions:
+ * irc_server_build_autojoin
+ */
+
+TEST(IrcServerConnected, BuildAutojoin)
+{
+ char *str;
+
+ server_recv (":server 001 alice");
+
+ WEE_TEST_STR("", irc_server_build_autojoin (ptr_server));
+
+ /* join one channel */
+ server_recv (":alice!user@host JOIN #test1");
+ WEE_TEST_STR("#test1", irc_server_build_autojoin (ptr_server));
+
+ /* simulate a "parted" channel */
+ ptr_server->channels->part = 1;
+ WEE_TEST_STR("", irc_server_build_autojoin (ptr_server));
+
+ /* restore "part" flag */
+ ptr_server->channels->part = 0;
+ WEE_TEST_STR("#test1", irc_server_build_autojoin (ptr_server));
+
+ /* add a key on channel */
+ server_recv (":alice!user@host MODE #test1 +k key1");
+ WEE_TEST_STR("#test1 key1",
+ irc_server_build_autojoin (ptr_server));
+
+ /* remove key */
+ server_recv (":alice!user@host MODE #test1 -k");
+ WEE_TEST_STR("#test1",
+ irc_server_build_autojoin (ptr_server));
+
+ /* join a second channel */
+ server_recv (":alice!user@host JOIN #test2");
+ WEE_TEST_STR("#test1,#test2", irc_server_build_autojoin (ptr_server));
+
+ /* join a third channel */
+ server_recv (":alice!user@host JOIN #test3");
+ WEE_TEST_STR("#test1,#test2,#test3",
+ irc_server_build_autojoin (ptr_server));
+
+ /* add key on first channel */
+ server_recv (":alice!user@host MODE #test1 +k key1");
+ WEE_TEST_STR("#test1,#test2,#test3 key1",
+ irc_server_build_autojoin (ptr_server));
+
+ /* add key on second channel */
+ server_recv (":alice!user@host MODE #test2 +k key2");
+ WEE_TEST_STR("#test1,#test2,#test3 key1,key2",
+ irc_server_build_autojoin (ptr_server));
+
+ /* add key on third channel */
+ server_recv (":alice!user@host MODE #test3 +k key3");
+ WEE_TEST_STR("#test1,#test2,#test3 key1,key2,key3",
+ irc_server_build_autojoin (ptr_server));
+
+ /* remove key from first channel */
+ server_recv (":alice!user@host MODE #test1 -k");
+ WEE_TEST_STR("#test2,#test3,#test1 key2,key3",
+ irc_server_build_autojoin (ptr_server));
+
+ /* remove key from second channel */
+ server_recv (":alice!user@host MODE #test2 -k");
+ WEE_TEST_STR("#test3,#test1,#test2 key3",
+ irc_server_build_autojoin (ptr_server));
+
+ /* remove key from third channel */
+ server_recv (":alice!user@host MODE #test3 -k");
+ WEE_TEST_STR("#test1,#test2,#test3",
+ irc_server_build_autojoin (ptr_server));
+}