1
0
forked from bip/bip

Untested no_client_away_msg support.

This commit is contained in:
nohar 2006-09-18 16:06:23 +00:00
parent a4fe5d0861
commit 925bee51c8
9 changed files with 49 additions and 10 deletions

View File

@ -1,3 +1,8 @@
2006-09-18 Arnaud Cornet <arnaud.cornet@gmail.com>
* src/irc.c: added no_client_away_msg configuration directive and
code.
2006-07-02 Arnaud Cornet <arnaud.cornet@gmail.com>
* src/irc.c: added /bip subcommands:

9
TODO
View File

@ -8,9 +8,6 @@
- use gnutls
- MODE #channel and WHO #channel on join
11:23 < KiBi> Un /away truc chose automatique quand plus aucun client n'est
attaché.
- in english: automatic command when no more client is connected
- this:
Hi Arnaud,
@ -27,3 +24,9 @@ Best regards,
Whoopie
--
Donner des droits plus méchants au log global
DONE:
11:23 < KiBi> Un /away truc chose automatique quand plus aucun client n'est
attaché.
- in english: automatic command when no more client is connected

View File

@ -407,6 +407,7 @@ static int add_connection(list_t *connectionl, list_t *data,
c = calloc(sizeof(struct c_connection), 1);
list_init(&c->channell, NULL);
list_init(&c->on_connect_send, NULL);
while ((t = list_remove_first(data))) {
switch (t->type) {
@ -455,7 +456,7 @@ static int add_connection(list_t *connectionl, list_t *data,
c->away_nick = t->pdata;
break;
case LEX_ON_CONNECT_SEND:
c->on_connect_send = t->pdata;
list_add(&c->on_connect_send, t->pdata);
break;
default:
conf_die("unknown keyword in connection statement");
@ -790,6 +791,7 @@ void ircize(list_t *ll)
} \
} while(0);
MAYFREE(link->away_nick);
MAYFREE(link->no_client_away_msg);
MAYFREE(link->password);
MAYFREE(link->user);
MAYFREE(link->real_name);
@ -811,8 +813,20 @@ void ircize(list_t *ll)
link->follow_nick = c->follow_nick;
link->ignore_first_nick = c->ignore_first_nick;
link->on_connect_send = strmaydup(c->on_connect_send);
/* XXX vider laliste on_connect_send */
list_iterator_t ocsit;
for (list_it_init(&c->channell, &ocsit);
list_it_item(&ocsit);
list_it_next(&ocsit)) {
free(list_it_item(&ocsit));
}
list_init(&link->on_connect_send);
list_append(&link->on_connect_send,
&c->on_connect_send);
link->away_nick = strmaydup(c->away_nick);
link->no_client_away_msg =
strmaydup(c->no_client_away_msg);
link->username = strmaydup(u->name);
link->password = malloc(20);

View File

@ -51,7 +51,8 @@ struct c_connection
int follow_nick;
int ignore_first_nick;
char *away_nick;
char *on_connect_send;
list_t on_connect_send;
char *no_client_away_msg;
struct client *client;
};

View File

@ -80,7 +80,7 @@ struct tuple *tuple_l_new(int type, void *p)
%}
%token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_USERNAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_SSL_CHECK_MODE LEX_SSL_CHECK_STORE LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_BACKLOG LEX_LOG LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_LOGIN LEX_BLRESET_ON_TALK LEX_DEFAULT_USER LEX_DEFAULT_NICK LEX_DEFAULT_REALNAME
%token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_USERNAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_SSL_CHECK_MODE LEX_SSL_CHECK_STORE LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_BACKLOG LEX_LOG LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_LOGIN LEX_BLRESET_ON_TALK LEX_DEFAULT_USER LEX_DEFAULT_NICK LEX_DEFAULT_REALNAME LEX_NO_CLIENT_AWAY_MSG
%union {
int number;

View File

@ -814,7 +814,7 @@ static int irc_cli_startup(struct link_client *ic, struct line *line,
list_it_item(&it); list_it_next(&it))
write_init_string(CONN(ic), list_it_item(&it), init_nick);
/* we change nick on client */
/* we change nick on server */
if (LINK(ic)->l_server) {
struct link_server *server = LINK(ic)->l_server;
WRITE_LINE1(CONN(ic), initmask, "NICK", server->nick);
@ -825,6 +825,12 @@ static int irc_cli_startup(struct link_client *ic, struct line *line,
strcmp(LINK(ic)->away_nick, server->nick) == 0)
WRITE_LINE1(CONN(server), NULL, "NICK",
LINK(server)->connect_nick);
/* change away status */
if (LINK(ic)->l_clientc == 0) {
if (server && LINK(ic)->no_client_away_msg)
WRITE_LINE0(CONN(server), NULL, "AWAY");
}
}
free(initmask);
@ -1921,6 +1927,9 @@ void irc_client_close(struct link_client *ic)
if (is && LINK(ic)->away_nick)
WRITE_LINE1(CONN(is), NULL, "NICK",
LINK(ic)->away_nick);
if (is && LINK(ic)->no_client_away_msg)
WRITE_LINE1(CONN(is), NULL, "AWAY",
LINK(ic)->no_client_away_msg);
log_client_none_connected(LINK(ic)->log);
}
irc_client_free(ic);
@ -2391,6 +2400,7 @@ struct link *irc_link_new()
hash_init(&link->chan_infos, HASH_NOCASE);
list_init(&link->chan_infos_order, list_ptr_cmp);
list_init(&link->on_connect_send, list_ptr_cmp);
return link;
}

View File

@ -90,7 +90,7 @@ struct link {
int follow_nick;
int ignore_first_nick;
char *on_connect_send;
list_t on_connect_send;
char *away_nick;
hash_t chan_infos; /* channels we want */
list_t chan_infos_order; /* for order only */

View File

@ -91,6 +91,7 @@ list_t *parse_conf(FILE *file)
"ignore_first_nick" { return LEX_IGN_FIRST_NICK; }
"away_nick" { return LEX_AWAY_NICK; }
"on_connect_send" { return LEX_ON_CONNECT_SEND; }
"no_client_away_msg" { return LEX_NO_CLIENT_AWAY_MSG; }
"pid_file" { return LEX_PID_FILE; }
"blreset_on_talk" { return LEX_BLRESET_ON_TALK; }
\"[^"]*\" {

View File

@ -262,6 +262,11 @@ void *list_remove_last(list_t *list)
return ptr;
}
static void *__list_ptr_cpy(void *a)
{
return a;
}
/*
static void *list_remove_item(list_t *l, struct list_item *li)
{
@ -384,7 +389,7 @@ void list_free(list_t *t)
void list_append(list_t *src, list_t *dest)
{
list_iterator_t it;
for (list_it_init(src, &it); list_it_item(&it); list_it_next(&it))
list_add_last(dest, list_it_item(&it));
}