summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorailin-nemui <ailin-nemui@users.noreply.github.com>2016-03-22 23:00:01 +0100
committerailin-nemui <ailin-nemui@users.noreply.github.com>2016-03-22 23:00:01 +0100
commit9cb0419435d1ad331c1f55361a003d9682fae9a8 (patch)
treedb48c93e1a60c820e95a43e36d1018b56d37a7df /src
parent29e160f0bf9e2c42c88c756b4fc61af29a7bfd59 (diff)
parente5ee243ab6ff7f640bdd45a232ad81ed97520a46 (diff)
downloadirssi-9cb0419435d1ad331c1f55361a003d9682fae9a8.zip
Merge pull request #443 from LemonBoy/chatnet
Throw an error when a chatnet has no available url
Diffstat (limited to 'src')
-rw-r--r--src/core/chat-commands.c7
-rw-r--r--src/core/commands.h3
-rw-r--r--src/core/servers-setup.c4
-rw-r--r--src/fe-common/core/fe-core-commands.c3
-rw-r--r--src/fe-common/core/module-formats.c1
-rw-r--r--src/fe-common/core/module-formats.h1
6 files changed, 15 insertions, 4 deletions
diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c
index 7f000cf5..a9404fa3 100644
--- a/src/core/chat-commands.c
+++ b/src/core/chat-commands.c
@@ -73,6 +73,13 @@ static SERVER_CONNECT_REC *get_server_connect(const char *data, int *plus_addr,
conn = server_create_conn(proto != NULL ? proto->id : -1, addr,
atoi(portstr), chatnet, password, nick);
+ if (conn == NULL) {
+ signal_emit("error command", 1,
+ GINT_TO_POINTER(CMDERR_NO_SERVER_DEFINED));
+ cmd_params_free(free_arg);
+ return NULL;
+ }
+
if (proto == NULL)
proto = chat_protocol_find_id(conn->chat_type);
diff --git a/src/core/commands.h b/src/core/commands.h
index 72105ad3..93d6276b 100644
--- a/src/core/commands.h
+++ b/src/core/commands.h
@@ -41,7 +41,8 @@ enum {
CMDERR_INVALID_TIME, /* invalid time specification */
CMDERR_INVALID_CHARSET, /* invalid charset specification */
CMDERR_EVAL_MAX_RECURSE, /* eval hit recursion limit */
- CMDERR_PROGRAM_NOT_FOUND /* program not found */
+ CMDERR_PROGRAM_NOT_FOUND, /* program not found */
+ CMDERR_NO_SERVER_DEFINED, /* no server has been defined for a given chatnet */
};
/* Return the full command for `alias' */
diff --git a/src/core/servers-setup.c b/src/core/servers-setup.c
index 4a048282..0cecfece 100644
--- a/src/core/servers-setup.c
+++ b/src/core/servers-setup.c
@@ -321,8 +321,8 @@ server_create_conn(int chat_type, const char *dest, int port,
chatrec = chatnet_find(dest);
if (chatrec != NULL) {
rec = create_chatnet_conn(chatrec->name, port, password, nick);
- if (rec != NULL)
- return rec;
+ /* If rec is NULL the chatnet has no url to connect to */
+ return rec;
}
chatrec = chatnet == NULL ? NULL : chatnet_find(chatnet);
diff --git a/src/fe-common/core/fe-core-commands.c b/src/fe-common/core/fe-core-commands.c
index 7b1d7b94..97a246ec 100644
--- a/src/fe-common/core/fe-core-commands.c
+++ b/src/fe-common/core/fe-core-commands.c
@@ -51,7 +51,8 @@ static int ret_texts[] = {
TXT_INVALID_TIME,
TXT_INVALID_CHARSET,
TXT_EVAL_MAX_RECURSE,
- TXT_PROGRAM_NOT_FOUND
+ TXT_PROGRAM_NOT_FOUND,
+ TXT_NO_SERVER_DEFINED,
};
int command_hide_output;
diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c
index e6d32b6d..b897b0c6 100644
--- a/src/fe-common/core/module-formats.c
+++ b/src/fe-common/core/module-formats.c
@@ -223,6 +223,7 @@ FORMAT_REC fecommon_core_formats[] = {
{ "invalid_charset", "Invalid charset: $0", 1, { 0 } },
{ "eval_max_recurse", "/eval hit maximum recursion limit", 0 },
{ "program_not_found", "Could not find file or file is not executable", 0 },
+ { "no_server_defined", "No servers defined for this network, see /help server for how to add one", 0 },
/* ---- */
{ NULL, "Themes", 0 },
diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h
index 3f06bb97..de1e13f2 100644
--- a/src/fe-common/core/module-formats.h
+++ b/src/fe-common/core/module-formats.h
@@ -192,6 +192,7 @@ enum {
TXT_INVALID_CHARSET,
TXT_EVAL_MAX_RECURSE,
TXT_PROGRAM_NOT_FOUND,
+ TXT_NO_SERVER_DEFINED,
TXT_FILL_11,