From: Pekka Riikonen Date: Sat, 26 May 2001 08:05:09 +0000 (+0000) Subject: updates. X-Git-Tag: robodoc-323~287 X-Git-Url: http://git.silcnet.org/gitweb/?a=commitdiff_plain;h=c3605468d73126ecad0de98e994a68ad6d17adca;p=silc.git updates. --- diff --git a/apps/irssi/src/silc/core/clientutil.c b/apps/irssi/src/silc/core/clientutil.c index 02b5d301..77607adc 100644 --- a/apps/irssi/src/silc/core/clientutil.c +++ b/apps/irssi/src/silc/core/clientutil.c @@ -31,16 +31,17 @@ #include "rawlog.h" #include "misc.h" #include "settings.h" -#include "curses.h" -#include "servers-setup.h" +#include "channels-setup.h" #include "silc-servers.h" #include "silc-channels.h" #include "silc-queries.h" +#include "silc-nicklist.h" #include "window-item-def.h" #include "fe-common/core/printtext.h" +#include "fe-common/core/keyboard.h" /* Asks yes/no from user on the input line. Returns TRUE on "yes" and FALSE on "no". */ @@ -79,9 +80,34 @@ void silc_client_list_pkcs() /* Displays input prompt on command line and takes input data from user */ -void silc_client_get_input(char *prompt, SIGNAL_FUNC func) +char *silc_client_get_input(const char *prompt) { - keyboard_entry_redirect(func, prompt, 0, NULL); + char input[2048]; + int fd; + + fd = open("/dev/tty", O_RDONLY); + if (fd < 0) { + fprintf(stderr, "silc: %s\n", strerror(errno)); + return NULL; + } + + memset(input, 0, sizeof(input)); + + printf("%s", prompt); + fflush(stdout); + + if ((read(fd, input, sizeof(input))) < 0) { + fprintf(stderr, "silc: %s\n", strerror(errno)); + return NULL; + } + + if (strlen(input) <= 1) + return NULL; + + if (strchr(input, '\n')) + *strchr(input, '\n') = '\0'; + + return strdup(input); } /* Returns identifier string for public key generation. */ diff --git a/apps/irssi/src/silc/core/clientutil.h b/apps/irssi/src/silc/core/clientutil.h index aaded306..7a3b946d 100644 --- a/apps/irssi/src/silc/core/clientutil.h +++ b/apps/irssi/src/silc/core/clientutil.h @@ -21,9 +21,11 @@ #ifndef CLIENTUTIL_H #define CLIENTUTIL_H +#include "signals.h" + /* Prototypes */ void silc_client_ask_yes_no(char *prompt, SIGNAL_FUNC func); -void silc_client_get_input(char *prompt, SIGNAL_FUNC func); +char *silc_client_get_input(const char *prompt); void silc_client_list_ciphers(); void silc_client_list_hash_funcs(); void silc_client_list_pkcs(); diff --git a/apps/irssi/src/silc/core/silc-channels.c b/apps/irssi/src/silc/core/silc-channels.c index dfa58a31..c00ec258 100644 --- a/apps/irssi/src/silc/core/silc-channels.c +++ b/apps/irssi/src/silc/core/silc-channels.c @@ -93,6 +93,15 @@ static void sig_connected(SILC_SERVER_REC *server) server->channels_join = (void *) silc_channels_join; } +/* "server quit" signal from the core to indicate that QUIT command + was called. */ + +static void sig_server_quit(SILC_SERVER_REC *server, const char *msg) +{ + if (IS_SILC_SERVER(server)) + silc_command_exec(server, "QUIT", msg); +} + /* * "event join". Joined to a channel. */ @@ -285,10 +294,8 @@ static void event_cmode(SILC_SERVER_REC *server, va_list va) signal_emit("channel mode changed", 1, chanrec); } - /*signal_emit("message mode", 5, server, chanrec->name, - client->nickname, client->username, mode);*/ printtext(server, channel->channel_name, MSGLEVEL_MODES, - "mode/%s [%s] by %s", channel->channel_name, mode, + "cmode/%s [%s] by %s", channel->channel_name, mode, client->nickname); g_free(mode); @@ -328,11 +335,9 @@ static void event_cumode(SILC_SERVER_REC *server, va_list va) } } - /*signal_emit("message mode", 5, server, chanrec->name, - client->nickname, client->username, modestr);*/ printtext(server, channel->channel_name, MSGLEVEL_MODES, - "mode/%s [%s] by %s", channel->channel_name, modestr, - client->nickname); + "cumode/%s/%s [%s] by %s", destclient->nickname, + channel->channel_name, mode, client->nickname); g_free(modestr); } @@ -513,6 +518,7 @@ void silc_channels_init(void) { signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed); signal_add("server connected", (SIGNAL_FUNC) sig_connected); + signal_add("server quit", (SIGNAL_FUNC) sig_server_quit); signal_add("silc event join", (SIGNAL_FUNC) event_join); signal_add("silc event leave", (SIGNAL_FUNC) event_leave); @@ -540,6 +546,7 @@ void silc_channels_deinit(void) { signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed); signal_remove("server connected", (SIGNAL_FUNC) sig_connected); + signal_remove("server quit", (SIGNAL_FUNC) sig_server_quit); signal_remove("silc event join", (SIGNAL_FUNC) event_join); signal_remove("silc event leave", (SIGNAL_FUNC) event_leave); diff --git a/apps/irssi/src/silc/core/silc-core.c b/apps/irssi/src/silc/core/silc-core.c index c13b0403..fed647f5 100644 --- a/apps/irssi/src/silc/core/silc-core.c +++ b/apps/irssi/src/silc/core/silc-core.c @@ -40,6 +40,7 @@ /* Command line option variables */ static bool opt_create_keypair = FALSE; +static bool opt_debug = FALSE; static char *opt_pkcs = NULL; static char *opt_keyfile = NULL; static int opt_bits = 0; @@ -49,6 +50,7 @@ static int idletag; SilcClient silc_client = NULL; SilcClientConfig silc_config = NULL; extern SilcClientOperations ops; +extern int silc_debug; #ifdef SILC_SIM /* SIM (SILC Module) table */ SilcSimContext **sims = NULL; @@ -1045,6 +1047,23 @@ static void silc_init_userinfo(void) } } +/* Log callbacks */ + +static void silc_log_info(char *message) +{ + fprintf(stderr, "%s\n", message); +} + +static void silc_log_warning(char *message) +{ + fprintf(stderr, "%s\n", message); +} + +static void silc_log_error(char *message) +{ + fprintf(stderr, "%s\n", message); +} + /* Init SILC. Called from src/fe-text/silc.c */ void silc_core_init(void) @@ -1058,6 +1077,8 @@ void silc_core_init(void) "Set the length of the public key pair", "VALUE" }, { "show-key", 'S', POPT_ARG_STRING, &opt_keyfile, 0, "Show the contents of the public key", "FILE" }, + { "debug", 'd', POPT_ARG_NONE, &opt_debug, 0, + "Enable debugging", NULL }, { NULL, '\0', 0, NULL } }; @@ -1091,6 +1112,10 @@ void silc_core_init_finish(void) exit(0); } + silc_debug = opt_debug; + silc_log_set_callbacks(silc_log_info, silc_log_warning, + silc_log_error, NULL); + silc_init_userinfo(); /* Allocate SILC client */ @@ -1164,7 +1189,7 @@ void silc_core_init_finish(void) silc_channels_init(); silc_queries_init(); - idletag = g_timeout_add(100, (GSourceFunc) my_silc_scheduler, NULL); + idletag = g_timeout_add(50, (GSourceFunc) my_silc_scheduler, NULL); } /* Deinit SILC. Called from src/fe-text/silc.c */