updates.
authorPekka Riikonen <priikone@silcnet.org>
Sat, 26 May 2001 08:05:09 +0000 (08:05 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 26 May 2001 08:05:09 +0000 (08:05 +0000)
apps/irssi/src/silc/core/clientutil.c
apps/irssi/src/silc/core/clientutil.h
apps/irssi/src/silc/core/silc-channels.c
apps/irssi/src/silc/core/silc-core.c

index 02b5d301441495d3e7c6bdd0b2998710f2863805..77607adc6f644c5964424c06b357fb61ec852713 100644 (file)
 #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. */
index aaded30637ca37b80a4648547a086cc4a304b66a..7a3b946dccfd0ed053bf45638b9edcd121f865a1 100644 (file)
 #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();
index dfa58a3188abc2a41bb400de25ad50ade00a9371..c00ec25891b2541e604b4b4632c5134d2ed6bb55 100644 (file)
@@ -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);
index c13b0403d208a622c0061fae5302b50c9b306369..fed647f51260c622bd6c854266d47c96754a5df7 100644 (file)
@@ -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 */