1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-15 04:28:09 -04:00

Throw an error when a chatnet has no available url

If you type /connect <CN> and the chatnet <CN> has no url available
let's just throw an error instead of trying to process <CN> as a url.
This commit is contained in:
LemonBoy 2016-03-18 20:18:58 +01:00
parent 795b7de808
commit 6745dd6159
6 changed files with 15 additions and 2 deletions

View File

@ -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, conn = server_create_conn(proto != NULL ? proto->id : -1, addr,
atoi(portstr), chatnet, password, nick); 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) if (proto == NULL)
proto = chat_protocol_find_id(conn->chat_type); proto = chat_protocol_find_id(conn->chat_type);

View File

@ -41,7 +41,8 @@ enum {
CMDERR_INVALID_TIME, /* invalid time specification */ CMDERR_INVALID_TIME, /* invalid time specification */
CMDERR_INVALID_CHARSET, /* invalid charset specification */ CMDERR_INVALID_CHARSET, /* invalid charset specification */
CMDERR_EVAL_MAX_RECURSE, /* eval hit recursion limit */ 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' */ /* Return the full command for `alias' */

View File

@ -323,6 +323,8 @@ server_create_conn(int chat_type, const char *dest, int port,
rec = create_chatnet_conn(chatrec->name, port, password, nick); rec = create_chatnet_conn(chatrec->name, port, password, nick);
if (rec != NULL) if (rec != NULL)
return rec; return rec;
/* The chatnet has no url to connect to */
return NULL;
} }
chatrec = chatnet == NULL ? NULL : chatnet_find(chatnet); chatrec = chatnet == NULL ? NULL : chatnet_find(chatnet);

View File

@ -51,7 +51,8 @@ static int ret_texts[] = {
TXT_INVALID_TIME, TXT_INVALID_TIME,
TXT_INVALID_CHARSET, TXT_INVALID_CHARSET,
TXT_EVAL_MAX_RECURSE, TXT_EVAL_MAX_RECURSE,
TXT_PROGRAM_NOT_FOUND TXT_PROGRAM_NOT_FOUND,
TXT_NO_SERVER_DEFINED,
}; };
int command_hide_output; int command_hide_output;

View File

@ -223,6 +223,7 @@ FORMAT_REC fecommon_core_formats[] = {
{ "invalid_charset", "Invalid charset: $0", 1, { 0 } }, { "invalid_charset", "Invalid charset: $0", 1, { 0 } },
{ "eval_max_recurse", "/eval hit maximum recursion limit", 0 }, { "eval_max_recurse", "/eval hit maximum recursion limit", 0 },
{ "program_not_found", "Could not find file or file is not executable", 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 }, { NULL, "Themes", 0 },

View File

@ -192,6 +192,7 @@ enum {
TXT_INVALID_CHARSET, TXT_INVALID_CHARSET,
TXT_EVAL_MAX_RECURSE, TXT_EVAL_MAX_RECURSE,
TXT_PROGRAM_NOT_FOUND, TXT_PROGRAM_NOT_FOUND,
TXT_NO_SERVER_DEFINED,
TXT_FILL_11, TXT_FILL_11,