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-core.c

index 8b835b19fe90ef662f0bdb2c3087da04553db576..02b5d301441495d3e7c6bdd0b2998710f2863805 100644 (file)
 /* Asks yes/no from user on the input line. Returns TRUE on "yes" and
    FALSE on "no". */
 
-int silc_client_ask_yes_no(SilcClient client, char *prompt)
+void silc_client_ask_yes_no(char *prompt, SIGNAL_FUNC func)
 {
-  char answer[4];
-  int ret;
-
- again:
-  /* Print prompt */
-  attroff(A_INVIS);
-  //  silc_screen_input_print_prompt(app->screen, prompt);
-
-  /* Get string */
-  memset(answer, 0, sizeof(answer));
-  echo();
-  getnstr(answer, sizeof(answer));
-  if (!strncasecmp(answer, "yes", strlen(answer)) ||
-      !strncasecmp(answer, "y", strlen(answer))) {
-    ret = TRUE;
-  } else if (!strncasecmp(answer, "no", strlen(answer)) ||
-            !strncasecmp(answer, "n", strlen(answer))) {
-    ret = FALSE;
-  } else {
-    printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, "Type yes or no");
-    goto again;
-  }
-  noecho();
-
-  //  silc_screen_input_reset(app->screen);
-
-  return ret;
+  keyboard_entry_redirect(func, prompt, 0, NULL);
 }
 
 /* Lists supported (builtin) ciphers */
@@ -105,36 +79,9 @@ void silc_client_list_pkcs()
 
 /* Displays input prompt on command line and takes input data from user */
 
-char *silc_client_get_input(const char *prompt)
+void silc_client_get_input(char *prompt, SIGNAL_FUNC func)
 {
-#if 0
-  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);
-#endif
-  return NULL;
+  keyboard_entry_redirect(func, prompt, 0, NULL);
 }
 
 /* Returns identifier string for public key generation. */
index f69a36886166efe9a63840ddfa20798b5ca31300..aaded30637ca37b80a4648547a086cc4a304b66a 100644 (file)
@@ -22,8 +22,8 @@
 #define CLIENTUTIL_H
 
 /* Prototypes */
-int silc_client_ask_yes_no(SilcClient client, char *prompt);
-char *silc_client_get_input(const char *prompt);
+void silc_client_ask_yes_no(char *prompt, SIGNAL_FUNC func);
+void silc_client_get_input(char *prompt, SIGNAL_FUNC func);
 void silc_client_list_ciphers();
 void silc_client_list_hash_funcs();
 void silc_client_list_pkcs();
index 10866c51c3c382f158fb14fc7a2a26cdfec2ff6f..c13b0403d208a622c0061fae5302b50c9b306369 100644 (file)
 #include "fe-common/core/fe-channels.h"
 
 /* Command line option variables */
-static char *opt_server = NULL;
-static int opt_port = 0;
-static char *opt_nickname = NULL;
-static char *opt_channel = NULL;
-static char *opt_cipher = NULL;
-static char *opt_public_key = NULL;
-static char *opt_private_key = NULL;
-static char *opt_config_file = NULL;
-static bool opt_no_silcrc = FALSE;
-
 static bool opt_create_keypair = FALSE;
 static char *opt_pkcs = NULL;
 static char *opt_keyfile = NULL;
@@ -547,8 +537,6 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
       list_count = va_arg(vp, uint32);
       client_id_list = va_arg(vp, SilcBuffer);
 
-      /* XXX what an earth do I do with the topic??? */
-
       if (!success)
        return;
 
@@ -558,6 +546,13 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
       else if (chanrec == NULL && success)
        chanrec = silc_channel_create(server, channel, TRUE);
       
+      if (topic) {
+       g_free_not_null(chanrec->topic);
+       chanrec->topic = *topic == '\0' ? NULL : g_strdup(topic);
+       signal_emit("channel topic changed", 1, chanrec);
+       silc_say(client, conn, "Topic for %s: %s", channel, topic);
+      }
+
       mode = silc_client_chmode(modei, channel_entry);
       g_free_not_null(chanrec->mode);
       chanrec->mode = g_strdup(mode == NULL ? "" : mode);