diff options
author | Wouter Coekaerts <coekie@irssi.org> | 2005-01-03 19:22:53 +0000 |
---|---|---|
committer | coekie <coekie@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2005-01-03 19:22:53 +0000 |
commit | b52bbcfbbfa21d74815bc95c7b3934ef0e04d347 (patch) | |
tree | 52c71212e258c3c5c22355d796a9887213e926f1 /src | |
parent | a38c7d16315a0d5953b87cfc8ab25e3fbfe60d94 (diff) | |
download | irssi-b52bbcfbbfa21d74815bc95c7b3934ef0e04d347.zip |
improve queuing commands, patch by Timothy Hatcher (Bug 168)
(patch changed so it doesn't wait one second after the 001 event)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3698 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/irc/core/irc-nicklist.c | 6 | ||||
-rw-r--r-- | src/irc/core/irc-servers.c | 52 |
2 files changed, 39 insertions, 19 deletions
diff --git a/src/irc/core/irc-nicklist.c b/src/irc/core/irc-nicklist.c index c438ecbc..c09673a6 100644 --- a/src/irc/core/irc-nicklist.c +++ b/src/irc/core/irc-nicklist.c @@ -291,7 +291,7 @@ static void event_whois_ircop(SERVER_REC *server, const char *data) static void event_nick_in_use(IRC_SERVER_REC *server, const char *data) { - char *str; + char *str, *cmd; int n; g_return_if_fail(data != NULL); @@ -330,7 +330,9 @@ static void event_nick_in_use(IRC_SERVER_REC *server, const char *data) } } - irc_send_cmdv(server, "NICK %s", server->nick); + cmd = g_strdup_printf("NICK %s", server->nick); + irc_send_cmd_now(server, cmd); + g_free(cmd); } static void event_target_unavailable(IRC_SERVER_REC *server, const char *data) diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c index 5d7953cd..6a27437f 100644 --- a/src/irc/core/irc-servers.c +++ b/src/irc/core/irc-servers.c @@ -102,32 +102,38 @@ static void send_message(SERVER_REC *server, const char *target, static void server_init(IRC_SERVER_REC *server) { IRC_SERVER_CONNECT_REC *conn; - char hostname[100], *address, *ptr, *username; + char hostname[100], *address, *ptr, *username, *cmd; g_return_if_fail(server != NULL); conn = server->connrec; if (conn->proxy != NULL && conn->proxy_password != NULL && - *conn->proxy_password != '\0') - irc_send_cmdv(server, "PASS %s", conn->proxy_password); + *conn->proxy_password != '\0') { + cmd = g_strdup_printf("PASS %s", conn->proxy_password); + irc_send_cmd_now(server, cmd); + g_free(cmd); + } - if (conn->proxy != NULL && conn->proxy_string != NULL) - irc_send_cmdv(server, conn->proxy_string, conn->address, conn->port); + if (conn->proxy != NULL && conn->proxy_string != NULL) { + cmd = g_strdup_printf(conn->proxy_string, conn->address, conn->port); + irc_send_cmd_now(server, cmd); + g_free(cmd); + } if (conn->password != NULL && *conn->password != '\0') { /* send password */ - server->cmdcount = 0; - irc_send_cmdv(server, "PASS %s", conn->password); + cmd = g_strdup_printf("PASS %s", conn->password); + irc_send_cmd_now(server, cmd); + g_free(cmd); } /* send nick */ - server->cmdcount = 0; - irc_send_cmdv(server, "NICK %s", conn->nick); + cmd = g_strdup_printf("NICK %s", conn->nick); + irc_send_cmd_now(server, cmd); + g_free(cmd); /* send user/realname */ - server->cmdcount = 0; - if (gethostname(hostname, sizeof(hostname)) != 0 || *hostname == '\0') strcpy(hostname, "xx"); @@ -163,15 +169,15 @@ static void server_init(IRC_SERVER_REC *server) ptr = strchr(username, ' '); if (ptr != NULL) *ptr = '\0'; - irc_send_cmdv(server, "USER %s %s %s :%s", username, hostname, - address, conn->realname); + cmd = g_strdup_printf("USER %s %s %s :%s", username, hostname, address, conn->realname); + irc_send_cmd_now(server, cmd); + g_free(cmd); g_free(username); - server->cmdcount = 0; - if (conn->proxy != NULL && conn->proxy_string_after != NULL) { - irc_send_cmdv(server, conn->proxy_string_after, - conn->address, conn->port); + cmd = g_strdup_printf(conn->proxy_string_after, conn->address, conn->port); + irc_send_cmd_now(server, cmd); + g_free(cmd); } server->isupport = g_hash_table_new((GHashFunc) g_istr_hash, @@ -182,6 +188,13 @@ static void server_init(IRC_SERVER_REC *server) g_hash_table_insert(server->isupport, g_strdup("PREFIX"), g_strdup("(ohv)@%+")); server->cmdcount = 0; + + /* prevent the queue from sending too early, we have a max cut off of 120 secs */ + /* this will reset to 1 sec after we get the 001 event */ + GTimeVal now; + g_get_current_time(&now); + memcpy(&((IRC_SERVER_REC *)server)->wait_cmd, &now, sizeof(GTimeVal)); + ((IRC_SERVER_REC *)server)->wait_cmd.tv_sec += 120; } SERVER_REC *irc_server_init_connect(SERVER_CONNECT_REC *conn) @@ -535,6 +548,11 @@ static void event_connected(IRC_SERVER_REC *server, const char *data, const char server->connected = 1; server->real_connect_time = time(NULL); + /* let the queue send now that we are identified */ + GTimeVal now; + g_get_current_time(&now); + memcpy(&server->wait_cmd, &now, sizeof(GTimeVal)); + if (server->connrec->usermode != NULL) { /* wait a second and then send the user mode */ g_timeout_add(1000, (GSourceFunc) sig_set_user_mode, server); |