1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 12:56:37 +02:00

Improved /connect command to connect to a host by creating a temporary server, added option to /server to create temporary server (task #7095)

This commit is contained in:
Sebastien Helleu
2007-08-08 14:08:06 +00:00
parent 028d38b44e
commit 09ddfcd860
28 changed files with 5128 additions and 4314 deletions
+3 -1
View File
@@ -5,8 +5,10 @@ ChangeLog - 2007-08-08
Version 0.2.6 (under dev!):
* improved /connect command to connect to a host by creating a temporary
server, added option to /server to create temporary server (task #7095)
* added "copy", "rename" and "keep" options to /server command
* allow clear of multiple selected buffers with /clear (patch #6112)
* added "copy" and "rename" options to /server command
* added key for setting unread marker on all buffers (default:
ctrl-S + ctrl-U) (task 7180)
* fixed nick prefix display on servers that doesn't support all prefixes
+13 -4
View File
@@ -62,13 +62,17 @@ Fenster leeren
Nummer: lösche den Puffer mit der angegebenen Nummer
</programlisting>
<command>connect [-all [-nojoin] | servername [servername ...] [-nojoin]]</command>
<command>connect [-all [-nojoin] | servername [servername ...] [-nojoin] | hostname [-port port] [-ipv6] [-ssl]]</command>
<programlisting>
mit Server verbinden
-all: connect to all servers
servername: server name to connect
servername: internal server name to connect
-nojoin: do not join any channel (even if autojoin is enabled on server)
hostname: hostname to connect, creating temporary server
port: port for server (integer, default is 6667)
ipv6: use IPv6 protocol
ssl: use SSL protocol
</programlisting>
<command>disconnect [-all | Servername [Servername ...]]</command>
@@ -167,15 +171,19 @@ Konfiguration abspeichern
Datei: Name der zu speichernden Konfigurationsdatei
</programlisting>
<command>server [list [servername]] | [listfull [servername]] | [servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [copy server newservername] [rename servername newservername] [del servername]</command>
<command>server [list [servername]] | [listfull [servername]] | [servername] | [add servername hostname [-port port] [-temp] [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [copy server newservername] [rename servername newservername] | [keep servername] [del servername]</command>
<programlisting>
Auflisten, Hinzufügen oder Entfernen von Servern
list: list servers (no parameter implies this list)
listfull: list servers with detailed info for each server
add: create a new server
servername: server name, for internal and display use
hostname: name or IP address of server
port: port for server (integer)
port: port for server (integer, default is 6667)
temp: create temporary server (not saved in config file)
auto: automatically connect to server when WeeChat starts
noauto: do not connect to server when WeeChat starts (default)
ipv6: use IPv6 protocol
ssl: use SSL protocol
password: password for server
@@ -186,6 +194,7 @@ servername: server name, for internal and display use
realname: real name of user
copy: duplicate a server
rename: rename a server
keep: remove temporary flag on a server to keep it (in config file)
del: delete a server
</programlisting>
+13 -4
View File
@@ -62,13 +62,17 @@ clear window(s)
number: clear buffer by number
</programlisting>
<command>connect [-all [-nojoin] | servername [servername ...] [-nojoin]]</command>
<command>connect [-all [-nojoin] | servername [servername ...] [-nojoin] | hostname [-port port] [-ipv6] [-ssl]]</command>
<programlisting>
connect to server(s)
-all: connect to all servers
servername: server name to connect
servername: internal server name to connect
-nojoin: do not join any channel (even if autojoin is enabled on server)
hostname: hostname to connect, creating temporary server
port: port for server (integer, default is 6667)
ipv6: use IPv6 protocol
ssl: use SSL protocol
</programlisting>
<command>disconnect [-all | servername [servername ...]]</command>
@@ -166,15 +170,19 @@ save config to disk
file: filename for writing config
</programlisting>
<command>server [list [servername]] | [listfull [servername]] | [servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [copy server newservername] [rename servername newservername] [del servername]</command>
<command>server [list [servername]] | [listfull [servername]] | [servername] | [add servername hostname [-port port] [-temp] [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [copy server newservername] [rename servername newservername] | [keep servername] [del servername]</command>
<programlisting>
list, add or remove servers
list: list servers (no parameter implies this list)
listfull: list servers with detailed info for each server
add: create a new server
servername: server name, for internal and display use
hostname: name or IP address of server
port: port for server (integer)
port: port for server (integer, default is 6667)
temp: create temporary server (not saved in config file)
auto: automatically connect to server when WeeChat starts
noauto: do not connect to server when WeeChat starts (default)
ipv6: use IPv6 protocol
ssl: use SSL protocol
password: password for server
@@ -185,6 +193,7 @@ servername: server name, for internal and display use
realname: real name of user
copy: duplicate a server
rename: rename a server
keep: remove temporary flag on a server to keep it (in config file)
del: delete a server
</programlisting>
+13 -4
View File
@@ -62,13 +62,17 @@ effacer la/les fen
numéro: effacer un tampon par son numéro
</programlisting>
<command>connect [-all [-nojoin] | nom_serveur [nom_serveur...] [-nojoin]]</command>
<command>connect [-all [-nojoin] | nom_serveur [nom_serveur ...] [-nojoin] | nom/IP [-port port] [-ipv6] [-ssl]]</command>
<programlisting>
se connecter à un/plusieurs serveur(s)
-all: se connecter à tous les serveurs
-all: se reconnecter à tous les serveurs
nom_serveur: nom du serveur pour se connecter
-nojoin: ne rejoindre aucun canal (même si l'autojoin est activé pour le serveur)
nom/IP: nom/IP pour se connecter, en créant un serveur temporaire
port: port pour le serveur (nombre entier, 6667 par défaut)
ipv6: utiliser le protocole IPv6
ssl: utiliser le protocole SSL
</programlisting>
<command>disconnect [-all | nom_serveur [nom_serveur...]]</command>
@@ -166,15 +170,19 @@ sauvegarder la configuration sur disque
fichier: fichier pour sauvegarder la configuration
</programlisting>
<command>server [list [nom_serveur]] | [listfull [nom_serveur]] | [nom_serveur] | [nom_serveur nom/IP port [-auto | -noauto] [-ipv6] [-ssl] [-pwd mot_de_passe] [-nicks pseudo1 pseudo2 pseudo3] [-username nom_utilisateur] [-realname nom_réel] [-command commande] [-autojoin canal[,canal]] ] | [copy nom_serveur nouveau_nom_serveur] [rename nom_serveur nouveau_nom_serveur] [del nom_serveur]</command>
<command>server [list [nom_serveur]] | [listfull [nom_serveur]] | [nom_serveur] | [add nom_serveur nom/IP [-port port] [-temp] [-auto | -noauto] [-ipv6] [-ssl] [-pwd mot_de_passe] [-nicks pseudo1 pseudo2 pseudo3] [-username nom_utilisateur] [-realname nom_réel] [-command commande] [-autojoin canal[,canal]] ] | [copy nom_serveur nouveau_nom_serveur] | [rename nom_serveur nouveau_nom_serveur] | [keep nom_serveur] | [del nom_serveur]</command>
<programlisting>
liste, ajoute ou retire des serveurs
list: afficher les serveurs (pas de paramètre implique cette liste)
listfull: afficher les serveurs avec de l'info détaillée pour chaque
add: créer un nouveau serveur
nom_serveur: nom du serveur, pour usage interne et affichage
nom/IP: nom ou adresse IP du serveur
port: port pour le serveur (nombre entier)
port: port pour le serveur (nombre entier, 6667 par défaut)
temp: créer un serveur temporaire (non sauvé dans le fichier de configuration)
auto: se connecter automatiquement au serveur quand WeeChat démarre
noauto: ne pas se connecter au serveur quand WeeChat démarre (par défaut)
ipv6: utiliser le protocole IPv6
ssl: utiliser le protocole SSL
mot_de_passe: mot de passe pour le serveur
@@ -185,6 +193,7 @@ nom_utilisateur: nom d'utilisateur
nom_réel: nom réel de l'utilisateur
copy: dupliquer un serveur
rename: renommer un serveur
keep: supprimer le drapeau temporaire sur un serveur pour le garder (dans le fichier de configuration)
del: supprimer un serveur
</programlisting>
+311 -282
View File
File diff suppressed because it is too large Load Diff
+310 -281
View File
File diff suppressed because it is too large Load Diff
+308 -279
View File
File diff suppressed because it is too large Load Diff
+331 -288
View File
File diff suppressed because it is too large Load Diff
+308 -279
View File
File diff suppressed because it is too large Load Diff
+311 -282
View File
File diff suppressed because it is too large Load Diff
+305 -277
View File
File diff suppressed because it is too large Load Diff
+336 -174
View File
@@ -26,6 +26,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "weechat.h"
#include "command.h"
@@ -96,10 +97,15 @@ t_weechat_command weechat_commands[] =
"number: clear buffer by number"),
"-all", 0, MAX_ARGS, 0, weechat_cmd_clear, NULL },
{ "connect", N_("connect to server(s)"),
N_("[-all [-nojoin] | servername [servername ...] [-nojoin]]"),
N_("[-all [-nojoin] | servername [servername ...] [-nojoin] | hostname "
"[-port port] [-ipv6] [-ssl]]"),
N_(" -all: connect to all servers\n"
"servername: server name to connect\n"
" -nojoin: do not join any channel (even if autojoin is enabled on server)"),
"servername: internal server name to connect\n"
" -nojoin: do not join any channel (even if autojoin is enabled on server)\n"
" hostname: hostname to connect, creating temporary server\n"
" port: port for server (integer, default is 6667)\n"
" ipv6: use IPv6 protocol\n"
" ssl: use SSL protocol"),
"%S|-all|-nojoin|%*", 0, MAX_ARGS, 0, weechat_cmd_connect, NULL },
{ "disconnect", N_("disconnect from server(s)"),
N_("[-all | servername [servername ...]]"),
@@ -176,17 +182,22 @@ t_weechat_command weechat_commands[] =
N_("[file]"), N_("file: filename for writing config"),
NULL, 0, 1, 0, weechat_cmd_save, NULL },
{ "server", N_("list, add or remove servers"),
N_("[list [servername]] | [listfull [servername]] | "
"[servername hostname port [-auto | -noauto] [-ipv6] [-ssl] "
"[-pwd password] [-nicks nick1 nick2 nick3] [-username username] "
"[-realname realname] [-command command] [-autojoin channel[,channel]] ] | "
"[copy server newservername] [rename servername newservername] [del "
"servername]"),
N_("[list [servername]] | [listfull [servername]] | [servername] | "
"[add servername hostname [-port port] [-temp] [-auto | -noauto] "
"[-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] "
"[-username username] [-realname realname] [-command command] "
"[-autojoin channel[,channel]] ] | [copy server newservername] "
"[rename servername newservername] | [keep servername] "
"[del servername]"),
N_(" list: list servers (no parameter implies this list)\n"
" listfull: list servers with detailed info for each server\n"
" add: create a new server\n"
"servername: server name, for internal and display use\n"
" hostname: name or IP address of server\n"
" port: port for server (integer)\n"
" port: port for server (integer, default is 6667)\n"
" temp: create temporary server (not saved in config file)\n"
" auto: automatically connect to server when WeeChat starts\n"
" noauto: do not connect to server when WeeChat starts (default)\n"
" ipv6: use IPv6 protocol\n"
" ssl: use SSL protocol\n"
" password: password for server\n"
@@ -197,6 +208,7 @@ t_weechat_command weechat_commands[] =
" realname: real name of user\n"
" copy: duplicate a server\n"
" rename: rename a server\n"
" keep: remove temporary flag on a server to keep it (in config file)\n"
" del: delete a server"),
"copy|rename|del|list|listfull %S %S", 0, MAX_ARGS, 0, weechat_cmd_server, NULL },
{ "set", N_("set config options"),
@@ -1619,13 +1631,18 @@ weechat_cmd_connect (t_irc_server *server, t_irc_channel *channel,
{
t_gui_window *window;
t_gui_buffer *buffer;
t_irc_server *ptr_server;
int i, nb_connect, connect_ok, all_servers, no_join;
t_irc_server *ptr_server, server_tmp;
int i, nb_connect, connect_ok, all_servers, no_join, port, ipv6, ssl;
char *error;
long number;
gui_buffer_find_context (server, channel, &window, &buffer);
nb_connect = 0;
connect_ok = 1;
port = IRC_DEFAULT_PORT;
ipv6 = 0;
ssl = 0;
all_servers = 0;
no_join = 0;
@@ -1635,6 +1652,25 @@ weechat_cmd_connect (t_irc_server *server, t_irc_channel *channel,
all_servers = 1;
if (ascii_strcasecmp (argv[i], "-nojoin") == 0)
no_join = 1;
if (ascii_strcasecmp (argv[i], "-ipv6") == 0)
ipv6 = 1;
if (ascii_strcasecmp (argv[i], "-ssl") == 0)
ssl = 1;
if (ascii_strcasecmp (argv[i], "-port") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-port");
return -1;
}
error = NULL;
number = strtol (argv[++i], &error, 10);
if ((error) && (error[0] == '\0'))
port = number;
}
}
if (all_servers)
@@ -1667,12 +1703,57 @@ weechat_cmd_connect (t_irc_server *server, t_irc_channel *channel,
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s server \"%s\" not found\n"),
WEECHAT_ERROR, argv[i]);
connect_ok = 0;
irc_server_init (&server_tmp);
server_tmp.name = strdup (argv[i]);
server_tmp.address = strdup (argv[i]);
server_tmp.port = port;
server_tmp.ipv6 = ipv6;
server_tmp.ssl = ssl;
ptr_server = irc_server_new (server_tmp.name,
server_tmp.autoconnect,
server_tmp.autoreconnect,
server_tmp.autoreconnect_delay,
1, /* temp server */
server_tmp.address,
server_tmp.port,
server_tmp.ipv6,
server_tmp.ssl,
server_tmp.password,
server_tmp.nick1,
server_tmp.nick2,
server_tmp.nick3,
server_tmp.username,
server_tmp.realname,
server_tmp.hostname,
server_tmp.command,
1, /* command_delay */
server_tmp.autojoin,
1, /* autorejoin */
NULL);
if (ptr_server)
{
irc_display_prefix (NULL, NULL, PREFIX_INFO);
gui_printf (NULL, _("Server %s%s%s created (temporary server, NOT SAVED!)\n"),
GUI_COLOR(COLOR_WIN_CHAT_SERVER),
server_tmp.name,
GUI_COLOR(COLOR_WIN_CHAT));
if (!weechat_cmd_connect_one_server (window, ptr_server, 0))
connect_ok = 0;
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s unable to create server \"%s\"\n"),
WEECHAT_ERROR, argv[i]);
}
}
}
else
{
if (ascii_strcasecmp (argv[i], "-port") == 0)
i++;
}
}
}
@@ -2960,7 +3041,8 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
int i, detailed_list, one_server_found;
t_irc_server server_tmp, *ptr_server, *server_found, *new_server;
t_gui_buffer *ptr_buffer;
char *server_name;
char *server_name, *error;
long number;
gui_buffer_find_context (server, channel, &window, &buffer);
@@ -3029,7 +3111,197 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
}
else
{
if (ascii_strcasecmp (argv[0], "copy") == 0)
if (ascii_strcasecmp (argv[0], "add") == 0)
{
if (argc < 3)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing parameters for \"%s\" command\n"),
WEECHAT_ERROR, "server");
return -1;
}
if (irc_server_name_already_exists (argv[1]))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s server \"%s\" already exists, can't create it!\n"),
WEECHAT_ERROR, argv[1]);
return -1;
}
/* init server struct */
irc_server_init (&server_tmp);
server_tmp.name = strdup (argv[1]);
server_tmp.address = strdup (argv[2]);
server_tmp.port = IRC_DEFAULT_PORT;
/* parse arguments */
for (i = 3; i < argc; i++)
{
if (argv[i][0] == '-')
{
if (ascii_strcasecmp (argv[i], "-temp") == 0)
server_tmp.temp_server = 1;
if (ascii_strcasecmp (argv[i], "-auto") == 0)
server_tmp.autoconnect = 1;
if (ascii_strcasecmp (argv[i], "-noauto") == 0)
server_tmp.autoconnect = 0;
if (ascii_strcasecmp (argv[i], "-ipv6") == 0)
server_tmp.ipv6 = 1;
if (ascii_strcasecmp (argv[i], "-ssl") == 0)
server_tmp.ssl = 1;
if (ascii_strcasecmp (argv[i], "-port") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-port");
irc_server_destroy (&server_tmp);
return -1;
}
error = NULL;
number = strtol (argv[++i], &error, 10);
if ((error) && (error[0] == '\0'))
server_tmp.port = number;
}
if (ascii_strcasecmp (argv[i], "-pwd") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-pwd");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.password = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-nicks") == 0)
{
if (i >= (argc - 3))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-nicks");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.nick1 = strdup (argv[++i]);
server_tmp.nick2 = strdup (argv[++i]);
server_tmp.nick3 = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-username") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-username");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.username = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-realname") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-realname");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.realname = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-command") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-command");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.command = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-autojoin") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-autojoin");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.autojoin = strdup (argv[++i]);
}
}
}
/* create new server */
new_server = irc_server_new (server_tmp.name,
server_tmp.autoconnect,
server_tmp.autoreconnect,
server_tmp.autoreconnect_delay,
server_tmp.temp_server,
server_tmp.address,
server_tmp.port,
server_tmp.ipv6,
server_tmp.ssl,
server_tmp.password,
server_tmp.nick1,
server_tmp.nick2,
server_tmp.nick3,
server_tmp.username,
server_tmp.realname,
server_tmp.hostname,
server_tmp.command,
1, /* command_delay */
server_tmp.autojoin,
1, /* autorejoin */
NULL);
if (new_server)
{
irc_display_prefix (NULL, NULL, PREFIX_INFO);
gui_printf (NULL, _("Server %s%s%s created\n"),
GUI_COLOR(COLOR_WIN_CHAT_SERVER),
server_tmp.name,
GUI_COLOR(COLOR_WIN_CHAT));
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s unable to create server\n"),
WEECHAT_ERROR);
irc_server_destroy (&server_tmp);
return -1;
}
if (new_server->autoconnect)
{
(void) gui_buffer_new (window, new_server, NULL,
BUFFER_TYPE_STANDARD, 1);
irc_server_connect (new_server, 0);
}
irc_server_destroy (&server_tmp);
}
else if (ascii_strcasecmp (argv[0], "copy") == 0)
{
if (argc < 3)
{
@@ -3078,7 +3350,7 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
return -1;
}
if (ascii_strcasecmp (argv[0], "rename") == 0)
else if (ascii_strcasecmp (argv[0], "rename") == 0)
{
if (argc < 3)
{
@@ -3126,6 +3398,49 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
return -1;
}
else if (ascii_strcasecmp (argv[0], "keep") == 0)
{
if (argc < 2)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing server name for \"%s\" command\n"),
WEECHAT_ERROR, "server keep");
return -1;
}
/* look for server by name */
server_found = irc_server_search (argv[1]);
if (!server_found)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s server \"%s\" not found for \"%s\" command\n"),
WEECHAT_ERROR, argv[1], "server keep");
return -1;
}
/* check that it is temporary server */
if (!server_found->temp_server)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s server \"%s\" is not a temporary server\n"),
WEECHAT_ERROR, argv[1]);
return -1;
}
/* remove temporary flag on server */
server_found->temp_server = 0;
irc_display_prefix (NULL, NULL, PREFIX_INFO);
gui_printf (NULL, _("Server %s%s%s is not temporary any more\n"),
GUI_COLOR(COLOR_WIN_CHAT_SERVER),
argv[1],
GUI_COLOR(COLOR_WIN_CHAT));
return 0;
}
else if (ascii_strcasecmp (argv[0], "del") == 0)
{
if (argc < 2)
@@ -3182,167 +3497,14 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
return 0;
}
/* init server struct */
irc_server_init (&server_tmp);
if (argc < 3)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing parameters for \"%s\" command\n"),
WEECHAT_ERROR, "server");
irc_server_destroy (&server_tmp);
return -1;
}
if (irc_server_name_already_exists (argv[0]))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s server \"%s\" already exists, can't create it!\n"),
WEECHAT_ERROR, argv[0]);
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.name = strdup (argv[0]);
server_tmp.address = strdup (argv[1]);
server_tmp.port = atoi (argv[2]);
/* parse arguments */
for (i = 3; i < argc; i++)
{
if (argv[i][0] == '-')
{
if (ascii_strcasecmp (argv[i], "-auto") == 0)
server_tmp.autoconnect = 1;
if (ascii_strcasecmp (argv[i], "-noauto") == 0)
server_tmp.autoconnect = 0;
if (ascii_strcasecmp (argv[i], "-ipv6") == 0)
server_tmp.ipv6 = 1;
if (ascii_strcasecmp (argv[i], "-ssl") == 0)
server_tmp.ssl = 1;
if (ascii_strcasecmp (argv[i], "-pwd") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing password for \"%s\" parameter\n"),
WEECHAT_ERROR, "-pwd");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.password = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-nicks") == 0)
{
if (i >= (argc - 3))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing nick(s) for \"%s\" parameter\n"),
WEECHAT_ERROR, "-nicks");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.nick1 = strdup (argv[++i]);
server_tmp.nick2 = strdup (argv[++i]);
server_tmp.nick3 = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-username") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing password for \"%s\" parameter\n"),
WEECHAT_ERROR, "-username");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.username = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-realname") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing password for \"%s\" parameter\n"),
WEECHAT_ERROR, "-realname");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.realname = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-command") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing command for \"%s\" parameter\n"),
WEECHAT_ERROR, "-command");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.command = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-autojoin") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing password for \"%s\" parameter\n"),
WEECHAT_ERROR, "-autojoin");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.autojoin = strdup (argv[++i]);
}
}
}
/* create new server */
new_server = irc_server_new (server_tmp.name, server_tmp.autoconnect,
server_tmp.autoreconnect,
server_tmp.autoreconnect_delay,
0, server_tmp.address, server_tmp.port,
server_tmp.ipv6, server_tmp.ssl,
server_tmp.password, server_tmp.nick1,
server_tmp.nick2, server_tmp.nick3,
server_tmp.username, server_tmp.realname,
server_tmp.hostname,
server_tmp.command, 1, server_tmp.autojoin, 1, NULL);
if (new_server)
{
irc_display_prefix (NULL, NULL, PREFIX_INFO);
gui_printf (NULL, _("Server %s%s%s created\n"),
GUI_COLOR(COLOR_WIN_CHAT_SERVER),
server_tmp.name,
GUI_COLOR(COLOR_WIN_CHAT));
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s unable to create server\n"),
WEECHAT_ERROR);
irc_server_destroy (&server_tmp);
_("%s unknown option for \"%s\" command\n"),
WEECHAT_ERROR, "server");
return -1;
}
if (new_server->autoconnect)
{
(void) gui_buffer_new (window, new_server, NULL,
BUFFER_TYPE_STANDARD, 1);
irc_server_connect (new_server, 0);
}
irc_server_destroy (&server_tmp);
}
return 0;
}
+1 -1
View File
@@ -248,7 +248,7 @@ irc_server_init_with_url (char *irc_url, t_irc_server *server)
/* some default values */
if (server->port < 0)
server->port = DEFAULT_IRC_PORT;
server->port = IRC_DEFAULT_PORT;
server->nick2 = (char *) malloc (strlen (server->nick1) + 2);
strcpy (server->nick2, server->nick1);
server->nick2 = strcat (server->nick2, "1");
+1 -1
View File
@@ -52,7 +52,7 @@
#define PREFIX_RECV_MOD "==>"
#define PREFIX_SEND_MOD "<=="
#define DEFAULT_IRC_PORT 6667
#define IRC_DEFAULT_PORT 6667
/* nick types */
+3 -1
View File
@@ -5,8 +5,10 @@ ChangeLog - 2007-08-08
Version 0.2.6 (under dev!):
* improved /connect command to connect to a host by creating a temporary
server, added option to /server to create temporary server (task #7095)
* added "copy", "rename" and "keep" options to /server command
* allow clear of multiple selected buffers with /clear (patch #6112)
* added "copy" and "rename" options to /server command
* added key for setting unread marker on all buffers (default:
ctrl-S + ctrl-U) (task 7180)
* fixed nick prefix display on servers that doesn't support all prefixes
+13 -4
View File
@@ -62,13 +62,17 @@ Fenster leeren
Nummer: lösche den Puffer mit der angegebenen Nummer
</programlisting>
<command>connect [-all [-nojoin] | servername [servername ...] [-nojoin]]</command>
<command>connect [-all [-nojoin] | servername [servername ...] [-nojoin] | hostname [-port port] [-ipv6] [-ssl]]</command>
<programlisting>
mit Server verbinden
-all: connect to all servers
servername: server name to connect
servername: internal server name to connect
-nojoin: do not join any channel (even if autojoin is enabled on server)
hostname: hostname to connect, creating temporary server
port: port for server (integer, default is 6667)
ipv6: use IPv6 protocol
ssl: use SSL protocol
</programlisting>
<command>disconnect [-all | Servername [Servername ...]]</command>
@@ -167,15 +171,19 @@ Konfiguration abspeichern
Datei: Name der zu speichernden Konfigurationsdatei
</programlisting>
<command>server [list [servername]] | [listfull [servername]] | [servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [copy server newservername] [rename servername newservername] [del servername]</command>
<command>server [list [servername]] | [listfull [servername]] | [servername] | [add servername hostname [-port port] [-temp] [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [copy server newservername] [rename servername newservername] | [keep servername] [del servername]</command>
<programlisting>
Auflisten, Hinzufügen oder Entfernen von Servern
list: list servers (no parameter implies this list)
listfull: list servers with detailed info for each server
add: create a new server
servername: server name, for internal and display use
hostname: name or IP address of server
port: port for server (integer)
port: port for server (integer, default is 6667)
temp: create temporary server (not saved in config file)
auto: automatically connect to server when WeeChat starts
noauto: do not connect to server when WeeChat starts (default)
ipv6: use IPv6 protocol
ssl: use SSL protocol
password: password for server
@@ -186,6 +194,7 @@ servername: server name, for internal and display use
realname: real name of user
copy: duplicate a server
rename: rename a server
keep: remove temporary flag on a server to keep it (in config file)
del: delete a server
</programlisting>
+13 -4
View File
@@ -62,13 +62,17 @@ clear window(s)
number: clear buffer by number
</programlisting>
<command>connect [-all [-nojoin] | servername [servername ...] [-nojoin]]</command>
<command>connect [-all [-nojoin] | servername [servername ...] [-nojoin] | hostname [-port port] [-ipv6] [-ssl]]</command>
<programlisting>
connect to server(s)
-all: connect to all servers
servername: server name to connect
servername: internal server name to connect
-nojoin: do not join any channel (even if autojoin is enabled on server)
hostname: hostname to connect, creating temporary server
port: port for server (integer, default is 6667)
ipv6: use IPv6 protocol
ssl: use SSL protocol
</programlisting>
<command>disconnect [-all | servername [servername ...]]</command>
@@ -166,15 +170,19 @@ save config to disk
file: filename for writing config
</programlisting>
<command>server [list [servername]] | [listfull [servername]] | [servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [copy server newservername] [rename servername newservername] [del servername]</command>
<command>server [list [servername]] | [listfull [servername]] | [servername] | [add servername hostname [-port port] [-temp] [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [copy server newservername] [rename servername newservername] | [keep servername] [del servername]</command>
<programlisting>
list, add or remove servers
list: list servers (no parameter implies this list)
listfull: list servers with detailed info for each server
add: create a new server
servername: server name, for internal and display use
hostname: name or IP address of server
port: port for server (integer)
port: port for server (integer, default is 6667)
temp: create temporary server (not saved in config file)
auto: automatically connect to server when WeeChat starts
noauto: do not connect to server when WeeChat starts (default)
ipv6: use IPv6 protocol
ssl: use SSL protocol
password: password for server
@@ -185,6 +193,7 @@ servername: server name, for internal and display use
realname: real name of user
copy: duplicate a server
rename: rename a server
keep: remove temporary flag on a server to keep it (in config file)
del: delete a server
</programlisting>
+13 -4
View File
@@ -62,13 +62,17 @@ effacer la/les fen
numéro: effacer un tampon par son numéro
</programlisting>
<command>connect [-all [-nojoin] | nom_serveur [nom_serveur...] [-nojoin]]</command>
<command>connect [-all [-nojoin] | nom_serveur [nom_serveur ...] [-nojoin] | nom/IP [-port port] [-ipv6] [-ssl]]</command>
<programlisting>
se connecter à un/plusieurs serveur(s)
-all: se connecter à tous les serveurs
-all: se reconnecter à tous les serveurs
nom_serveur: nom du serveur pour se connecter
-nojoin: ne rejoindre aucun canal (même si l'autojoin est activé pour le serveur)
nom/IP: nom/IP pour se connecter, en créant un serveur temporaire
port: port pour le serveur (nombre entier, 6667 par défaut)
ipv6: utiliser le protocole IPv6
ssl: utiliser le protocole SSL
</programlisting>
<command>disconnect [-all | nom_serveur [nom_serveur...]]</command>
@@ -166,15 +170,19 @@ sauvegarder la configuration sur disque
fichier: fichier pour sauvegarder la configuration
</programlisting>
<command>server [list [nom_serveur]] | [listfull [nom_serveur]] | [nom_serveur] | [nom_serveur nom/IP port [-auto | -noauto] [-ipv6] [-ssl] [-pwd mot_de_passe] [-nicks pseudo1 pseudo2 pseudo3] [-username nom_utilisateur] [-realname nom_réel] [-command commande] [-autojoin canal[,canal]] ] | [copy nom_serveur nouveau_nom_serveur] [rename nom_serveur nouveau_nom_serveur] [del nom_serveur]</command>
<command>server [list [nom_serveur]] | [listfull [nom_serveur]] | [nom_serveur] | [add nom_serveur nom/IP [-port port] [-temp] [-auto | -noauto] [-ipv6] [-ssl] [-pwd mot_de_passe] [-nicks pseudo1 pseudo2 pseudo3] [-username nom_utilisateur] [-realname nom_réel] [-command commande] [-autojoin canal[,canal]] ] | [copy nom_serveur nouveau_nom_serveur] | [rename nom_serveur nouveau_nom_serveur] | [keep nom_serveur] | [del nom_serveur]</command>
<programlisting>
liste, ajoute ou retire des serveurs
list: afficher les serveurs (pas de paramètre implique cette liste)
listfull: afficher les serveurs avec de l'info détaillée pour chaque
add: créer un nouveau serveur
nom_serveur: nom du serveur, pour usage interne et affichage
nom/IP: nom ou adresse IP du serveur
port: port pour le serveur (nombre entier)
port: port pour le serveur (nombre entier, 6667 par défaut)
temp: créer un serveur temporaire (non sauvé dans le fichier de configuration)
auto: se connecter automatiquement au serveur quand WeeChat démarre
noauto: ne pas se connecter au serveur quand WeeChat démarre (par défaut)
ipv6: utiliser le protocole IPv6
ssl: utiliser le protocole SSL
mot_de_passe: mot de passe pour le serveur
@@ -185,6 +193,7 @@ nom_utilisateur: nom d'utilisateur
nom_réel: nom réel de l'utilisateur
copy: dupliquer un serveur
rename: renommer un serveur
keep: supprimer le drapeau temporaire sur un serveur pour le garder (dans le fichier de configuration)
del: supprimer un serveur
</programlisting>
+311 -282
View File
File diff suppressed because it is too large Load Diff
+310 -281
View File
File diff suppressed because it is too large Load Diff
+308 -279
View File
File diff suppressed because it is too large Load Diff
+331 -288
View File
File diff suppressed because it is too large Load Diff
+308 -279
View File
File diff suppressed because it is too large Load Diff
+311 -282
View File
File diff suppressed because it is too large Load Diff
+305 -277
View File
File diff suppressed because it is too large Load Diff
+336 -174
View File
@@ -26,6 +26,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "weechat.h"
#include "command.h"
@@ -96,10 +97,15 @@ t_weechat_command weechat_commands[] =
"number: clear buffer by number"),
"-all", 0, MAX_ARGS, 0, weechat_cmd_clear, NULL },
{ "connect", N_("connect to server(s)"),
N_("[-all [-nojoin] | servername [servername ...] [-nojoin]]"),
N_("[-all [-nojoin] | servername [servername ...] [-nojoin] | hostname "
"[-port port] [-ipv6] [-ssl]]"),
N_(" -all: connect to all servers\n"
"servername: server name to connect\n"
" -nojoin: do not join any channel (even if autojoin is enabled on server)"),
"servername: internal server name to connect\n"
" -nojoin: do not join any channel (even if autojoin is enabled on server)\n"
" hostname: hostname to connect, creating temporary server\n"
" port: port for server (integer, default is 6667)\n"
" ipv6: use IPv6 protocol\n"
" ssl: use SSL protocol"),
"%S|-all|-nojoin|%*", 0, MAX_ARGS, 0, weechat_cmd_connect, NULL },
{ "disconnect", N_("disconnect from server(s)"),
N_("[-all | servername [servername ...]]"),
@@ -176,17 +182,22 @@ t_weechat_command weechat_commands[] =
N_("[file]"), N_("file: filename for writing config"),
NULL, 0, 1, 0, weechat_cmd_save, NULL },
{ "server", N_("list, add or remove servers"),
N_("[list [servername]] | [listfull [servername]] | "
"[servername hostname port [-auto | -noauto] [-ipv6] [-ssl] "
"[-pwd password] [-nicks nick1 nick2 nick3] [-username username] "
"[-realname realname] [-command command] [-autojoin channel[,channel]] ] | "
"[copy server newservername] [rename servername newservername] [del "
"servername]"),
N_("[list [servername]] | [listfull [servername]] | [servername] | "
"[add servername hostname [-port port] [-temp] [-auto | -noauto] "
"[-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] "
"[-username username] [-realname realname] [-command command] "
"[-autojoin channel[,channel]] ] | [copy server newservername] "
"[rename servername newservername] | [keep servername] "
"[del servername]"),
N_(" list: list servers (no parameter implies this list)\n"
" listfull: list servers with detailed info for each server\n"
" add: create a new server\n"
"servername: server name, for internal and display use\n"
" hostname: name or IP address of server\n"
" port: port for server (integer)\n"
" port: port for server (integer, default is 6667)\n"
" temp: create temporary server (not saved in config file)\n"
" auto: automatically connect to server when WeeChat starts\n"
" noauto: do not connect to server when WeeChat starts (default)\n"
" ipv6: use IPv6 protocol\n"
" ssl: use SSL protocol\n"
" password: password for server\n"
@@ -197,6 +208,7 @@ t_weechat_command weechat_commands[] =
" realname: real name of user\n"
" copy: duplicate a server\n"
" rename: rename a server\n"
" keep: remove temporary flag on a server to keep it (in config file)\n"
" del: delete a server"),
"copy|rename|del|list|listfull %S %S", 0, MAX_ARGS, 0, weechat_cmd_server, NULL },
{ "set", N_("set config options"),
@@ -1619,13 +1631,18 @@ weechat_cmd_connect (t_irc_server *server, t_irc_channel *channel,
{
t_gui_window *window;
t_gui_buffer *buffer;
t_irc_server *ptr_server;
int i, nb_connect, connect_ok, all_servers, no_join;
t_irc_server *ptr_server, server_tmp;
int i, nb_connect, connect_ok, all_servers, no_join, port, ipv6, ssl;
char *error;
long number;
gui_buffer_find_context (server, channel, &window, &buffer);
nb_connect = 0;
connect_ok = 1;
port = IRC_DEFAULT_PORT;
ipv6 = 0;
ssl = 0;
all_servers = 0;
no_join = 0;
@@ -1635,6 +1652,25 @@ weechat_cmd_connect (t_irc_server *server, t_irc_channel *channel,
all_servers = 1;
if (ascii_strcasecmp (argv[i], "-nojoin") == 0)
no_join = 1;
if (ascii_strcasecmp (argv[i], "-ipv6") == 0)
ipv6 = 1;
if (ascii_strcasecmp (argv[i], "-ssl") == 0)
ssl = 1;
if (ascii_strcasecmp (argv[i], "-port") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-port");
return -1;
}
error = NULL;
number = strtol (argv[++i], &error, 10);
if ((error) && (error[0] == '\0'))
port = number;
}
}
if (all_servers)
@@ -1667,12 +1703,57 @@ weechat_cmd_connect (t_irc_server *server, t_irc_channel *channel,
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s server \"%s\" not found\n"),
WEECHAT_ERROR, argv[i]);
connect_ok = 0;
irc_server_init (&server_tmp);
server_tmp.name = strdup (argv[i]);
server_tmp.address = strdup (argv[i]);
server_tmp.port = port;
server_tmp.ipv6 = ipv6;
server_tmp.ssl = ssl;
ptr_server = irc_server_new (server_tmp.name,
server_tmp.autoconnect,
server_tmp.autoreconnect,
server_tmp.autoreconnect_delay,
1, /* temp server */
server_tmp.address,
server_tmp.port,
server_tmp.ipv6,
server_tmp.ssl,
server_tmp.password,
server_tmp.nick1,
server_tmp.nick2,
server_tmp.nick3,
server_tmp.username,
server_tmp.realname,
server_tmp.hostname,
server_tmp.command,
1, /* command_delay */
server_tmp.autojoin,
1, /* autorejoin */
NULL);
if (ptr_server)
{
irc_display_prefix (NULL, NULL, PREFIX_INFO);
gui_printf (NULL, _("Server %s%s%s created (temporary server, NOT SAVED!)\n"),
GUI_COLOR(COLOR_WIN_CHAT_SERVER),
server_tmp.name,
GUI_COLOR(COLOR_WIN_CHAT));
if (!weechat_cmd_connect_one_server (window, ptr_server, 0))
connect_ok = 0;
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s unable to create server \"%s\"\n"),
WEECHAT_ERROR, argv[i]);
}
}
}
else
{
if (ascii_strcasecmp (argv[i], "-port") == 0)
i++;
}
}
}
@@ -2960,7 +3041,8 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
int i, detailed_list, one_server_found;
t_irc_server server_tmp, *ptr_server, *server_found, *new_server;
t_gui_buffer *ptr_buffer;
char *server_name;
char *server_name, *error;
long number;
gui_buffer_find_context (server, channel, &window, &buffer);
@@ -3029,7 +3111,197 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
}
else
{
if (ascii_strcasecmp (argv[0], "copy") == 0)
if (ascii_strcasecmp (argv[0], "add") == 0)
{
if (argc < 3)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing parameters for \"%s\" command\n"),
WEECHAT_ERROR, "server");
return -1;
}
if (irc_server_name_already_exists (argv[1]))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s server \"%s\" already exists, can't create it!\n"),
WEECHAT_ERROR, argv[1]);
return -1;
}
/* init server struct */
irc_server_init (&server_tmp);
server_tmp.name = strdup (argv[1]);
server_tmp.address = strdup (argv[2]);
server_tmp.port = IRC_DEFAULT_PORT;
/* parse arguments */
for (i = 3; i < argc; i++)
{
if (argv[i][0] == '-')
{
if (ascii_strcasecmp (argv[i], "-temp") == 0)
server_tmp.temp_server = 1;
if (ascii_strcasecmp (argv[i], "-auto") == 0)
server_tmp.autoconnect = 1;
if (ascii_strcasecmp (argv[i], "-noauto") == 0)
server_tmp.autoconnect = 0;
if (ascii_strcasecmp (argv[i], "-ipv6") == 0)
server_tmp.ipv6 = 1;
if (ascii_strcasecmp (argv[i], "-ssl") == 0)
server_tmp.ssl = 1;
if (ascii_strcasecmp (argv[i], "-port") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-port");
irc_server_destroy (&server_tmp);
return -1;
}
error = NULL;
number = strtol (argv[++i], &error, 10);
if ((error) && (error[0] == '\0'))
server_tmp.port = number;
}
if (ascii_strcasecmp (argv[i], "-pwd") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-pwd");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.password = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-nicks") == 0)
{
if (i >= (argc - 3))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-nicks");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.nick1 = strdup (argv[++i]);
server_tmp.nick2 = strdup (argv[++i]);
server_tmp.nick3 = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-username") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-username");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.username = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-realname") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-realname");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.realname = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-command") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-command");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.command = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-autojoin") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing argument for \"%s\" option\n"),
WEECHAT_ERROR, "-autojoin");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.autojoin = strdup (argv[++i]);
}
}
}
/* create new server */
new_server = irc_server_new (server_tmp.name,
server_tmp.autoconnect,
server_tmp.autoreconnect,
server_tmp.autoreconnect_delay,
server_tmp.temp_server,
server_tmp.address,
server_tmp.port,
server_tmp.ipv6,
server_tmp.ssl,
server_tmp.password,
server_tmp.nick1,
server_tmp.nick2,
server_tmp.nick3,
server_tmp.username,
server_tmp.realname,
server_tmp.hostname,
server_tmp.command,
1, /* command_delay */
server_tmp.autojoin,
1, /* autorejoin */
NULL);
if (new_server)
{
irc_display_prefix (NULL, NULL, PREFIX_INFO);
gui_printf (NULL, _("Server %s%s%s created\n"),
GUI_COLOR(COLOR_WIN_CHAT_SERVER),
server_tmp.name,
GUI_COLOR(COLOR_WIN_CHAT));
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s unable to create server\n"),
WEECHAT_ERROR);
irc_server_destroy (&server_tmp);
return -1;
}
if (new_server->autoconnect)
{
(void) gui_buffer_new (window, new_server, NULL,
BUFFER_TYPE_STANDARD, 1);
irc_server_connect (new_server, 0);
}
irc_server_destroy (&server_tmp);
}
else if (ascii_strcasecmp (argv[0], "copy") == 0)
{
if (argc < 3)
{
@@ -3078,7 +3350,7 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
return -1;
}
if (ascii_strcasecmp (argv[0], "rename") == 0)
else if (ascii_strcasecmp (argv[0], "rename") == 0)
{
if (argc < 3)
{
@@ -3126,6 +3398,49 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
return -1;
}
else if (ascii_strcasecmp (argv[0], "keep") == 0)
{
if (argc < 2)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing server name for \"%s\" command\n"),
WEECHAT_ERROR, "server keep");
return -1;
}
/* look for server by name */
server_found = irc_server_search (argv[1]);
if (!server_found)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s server \"%s\" not found for \"%s\" command\n"),
WEECHAT_ERROR, argv[1], "server keep");
return -1;
}
/* check that it is temporary server */
if (!server_found->temp_server)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s server \"%s\" is not a temporary server\n"),
WEECHAT_ERROR, argv[1]);
return -1;
}
/* remove temporary flag on server */
server_found->temp_server = 0;
irc_display_prefix (NULL, NULL, PREFIX_INFO);
gui_printf (NULL, _("Server %s%s%s is not temporary any more\n"),
GUI_COLOR(COLOR_WIN_CHAT_SERVER),
argv[1],
GUI_COLOR(COLOR_WIN_CHAT));
return 0;
}
else if (ascii_strcasecmp (argv[0], "del") == 0)
{
if (argc < 2)
@@ -3182,167 +3497,14 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
return 0;
}
/* init server struct */
irc_server_init (&server_tmp);
if (argc < 3)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing parameters for \"%s\" command\n"),
WEECHAT_ERROR, "server");
irc_server_destroy (&server_tmp);
return -1;
}
if (irc_server_name_already_exists (argv[0]))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s server \"%s\" already exists, can't create it!\n"),
WEECHAT_ERROR, argv[0]);
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.name = strdup (argv[0]);
server_tmp.address = strdup (argv[1]);
server_tmp.port = atoi (argv[2]);
/* parse arguments */
for (i = 3; i < argc; i++)
{
if (argv[i][0] == '-')
{
if (ascii_strcasecmp (argv[i], "-auto") == 0)
server_tmp.autoconnect = 1;
if (ascii_strcasecmp (argv[i], "-noauto") == 0)
server_tmp.autoconnect = 0;
if (ascii_strcasecmp (argv[i], "-ipv6") == 0)
server_tmp.ipv6 = 1;
if (ascii_strcasecmp (argv[i], "-ssl") == 0)
server_tmp.ssl = 1;
if (ascii_strcasecmp (argv[i], "-pwd") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing password for \"%s\" parameter\n"),
WEECHAT_ERROR, "-pwd");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.password = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-nicks") == 0)
{
if (i >= (argc - 3))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing nick(s) for \"%s\" parameter\n"),
WEECHAT_ERROR, "-nicks");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.nick1 = strdup (argv[++i]);
server_tmp.nick2 = strdup (argv[++i]);
server_tmp.nick3 = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-username") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing password for \"%s\" parameter\n"),
WEECHAT_ERROR, "-username");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.username = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-realname") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing password for \"%s\" parameter\n"),
WEECHAT_ERROR, "-realname");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.realname = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-command") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing command for \"%s\" parameter\n"),
WEECHAT_ERROR, "-command");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.command = strdup (argv[++i]);
}
if (ascii_strcasecmp (argv[i], "-autojoin") == 0)
{
if (i == (argc - 1))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing password for \"%s\" parameter\n"),
WEECHAT_ERROR, "-autojoin");
irc_server_destroy (&server_tmp);
return -1;
}
server_tmp.autojoin = strdup (argv[++i]);
}
}
}
/* create new server */
new_server = irc_server_new (server_tmp.name, server_tmp.autoconnect,
server_tmp.autoreconnect,
server_tmp.autoreconnect_delay,
0, server_tmp.address, server_tmp.port,
server_tmp.ipv6, server_tmp.ssl,
server_tmp.password, server_tmp.nick1,
server_tmp.nick2, server_tmp.nick3,
server_tmp.username, server_tmp.realname,
server_tmp.hostname,
server_tmp.command, 1, server_tmp.autojoin, 1, NULL);
if (new_server)
{
irc_display_prefix (NULL, NULL, PREFIX_INFO);
gui_printf (NULL, _("Server %s%s%s created\n"),
GUI_COLOR(COLOR_WIN_CHAT_SERVER),
server_tmp.name,
GUI_COLOR(COLOR_WIN_CHAT));
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s unable to create server\n"),
WEECHAT_ERROR);
irc_server_destroy (&server_tmp);
_("%s unknown option for \"%s\" command\n"),
WEECHAT_ERROR, "server");
return -1;
}
if (new_server->autoconnect)
{
(void) gui_buffer_new (window, new_server, NULL,
BUFFER_TYPE_STANDARD, 1);
irc_server_connect (new_server, 0);
}
irc_server_destroy (&server_tmp);
}
return 0;
}
+1 -1
View File
@@ -248,7 +248,7 @@ irc_server_init_with_url (char *irc_url, t_irc_server *server)
/* some default values */
if (server->port < 0)
server->port = DEFAULT_IRC_PORT;
server->port = IRC_DEFAULT_PORT;
server->nick2 = (char *) malloc (strlen (server->nick1) + 2);
strcpy (server->nick2, server->nick1);
server->nick2 = strcat (server->nick2, "1");
+1 -1
View File
@@ -52,7 +52,7 @@
#define PREFIX_RECV_MOD "==>"
#define PREFIX_SEND_MOD "<=="
#define DEFAULT_IRC_PORT 6667
#define IRC_DEFAULT_PORT 6667
/* nick types */