updates.
[silc.git] / apps / irssi / src / silc / core / silc-core.c
index 9ea0cfdc844812501c59131118e5f5589195dba7..1bc44d9855279d2b303567493e384d15b32cb09b 100644 (file)
 
 /* Command line option variables */
 static bool opt_create_keypair = FALSE;
-static bool opt_debug = FALSE;
 static bool opt_list_ciphers = FALSE;
 static bool opt_list_hash = FALSE;
 static bool opt_list_hmac = FALSE;
 static bool opt_list_pkcs = FALSE;
 static bool opt_version = FALSE;
+static char *opt_debug = FALSE;
 static char *opt_pkcs = NULL;
 static char *opt_keyfile = NULL;
 static int opt_bits = 0;
@@ -57,7 +57,8 @@ static int idletag;
 SilcClient silc_client = NULL;
 SilcClientConfig silc_config = NULL;
 extern SilcClientOperations ops;
-extern int silc_debug;
+extern bool silc_debug;
+extern bool silc_debug_hexdump;
 #ifdef SILC_SIM
 /* SIM (SILC Module) table */
 SilcSimContext **sims = NULL;
@@ -66,7 +67,7 @@ uint32 sims_count = 0;
 
 static int my_silc_scheduler(void)
 {
-  silc_schedule_one(silc_client->schedule, 0);
+  silc_client_run_one(silc_client);
   return 1;
 }
 
@@ -119,7 +120,7 @@ static void silc_init_userinfo(void)
     
     user_name = settings_get_str("user_name");
   }
-         
+
   /* nick */
   nick = settings_get_str("nick");
   if (nick == NULL || *nick == '\0') {
@@ -193,8 +194,8 @@ void silc_core_init(void)
       "List supported HMACs", NULL },
     { "list-pkcs", 'P', POPT_ARG_NONE, &opt_list_pkcs, 0,
       "List supported PKCSs", NULL },
-    { "debug", 'd', POPT_ARG_NONE, &opt_debug, 0,
-      "Enable debugging", NULL },
+    { "debug", 'd', POPT_ARG_STRING, &opt_debug, 0,
+      "Enable debugging", "STRING" },
     { "version", 'V', POPT_ARG_NONE, &opt_version, 0,
       "Show version", NULL },
     { NULL, '\0', 0, NULL }
@@ -203,11 +204,18 @@ void silc_core_init(void)
   args_register(options);
 }
 
+static void silc_nickname_format_parse(const char *nickname,
+                                      char **ret_nickname)
+{
+  silc_parse_userfqdn(nickname, ret_nickname, NULL);
+}
+
 /* Finalize init. Called from src/fe-text/silc.c */
 
 void silc_core_init_finish(void)
 {
   CHAT_PROTOCOL_REC *rec;
+  SilcClientParams params;
 
   if (opt_create_keypair == TRUE) {
     /* Create new key pair and exit */
@@ -255,29 +263,54 @@ void silc_core_init_finish(void)
   }
 
   if (opt_version) {
-    printf("SILC Secure Internet Live Conferencing, version %s\n", 
-          silc_version);
+    printf("SILC Secure Internet Live Conferencing, version %s "
+          "(base: SILC Toolkit %s)\n", silc_dist_version, silc_version);
     printf("(c) 1997 - 2001 Pekka Riikonen <priikone@silcnet.org>\n");
     exit(0); 
   }
 
-  silc_debug = opt_debug;
-  silc_log_set_callbacks(silc_log_info, silc_log_warning,
-                        silc_log_error, NULL);
+  if (opt_debug) {
+    silc_debug = TRUE;
+    silc_debug_hexdump = TRUE;
+    silc_log_set_debug_string(opt_debug);
+    silc_log_set_callbacks(silc_log_info, silc_log_warning,
+                          silc_log_error, NULL);
+#ifndef SILC_DEBUG
+    fprintf(stdout, 
+           "Run-time debugging is not enabled. To enable it recompile\n"
+           "the client with --enable-debug configuration option.\n");
+#endif
+  }
 
   /* Do some irssi initializing */
   settings_add_bool("server", "skip_motd", FALSE);
   settings_add_str("server", "alternate_nick", NULL);
+  
+  /* Initialize the auto_addr variables Is "server" the best choice for
+   * this?  No existing category seems to apply.
+   */
+  
+  settings_add_bool("server", "use_auto_addr", FALSE);
+  settings_add_str("server", "auto_bind_ip", "");
+  settings_add_str("server", "auto_public_ip", "");
+  settings_add_int("server", "auto_bind_port", 0);
+                               
   silc_init_userinfo();
 
+  /* Initialize client parameters */
+  memset(&params, 0, sizeof(params));
+  strcat(params.nickname_format, "%n@%h%a");
+  params.nickname_parse = silc_nickname_format_parse;
+
   /* Allocate SILC client */
-  silc_client = silc_client_alloc(&ops, NULL, NULL, silc_version_string);
+  silc_client = silc_client_alloc(&ops, &params, NULL, silc_version_string);
 
   /* Load local config file */
   silc_config = silc_client_config_alloc(SILC_CLIENT_HOME_CONFIG_FILE);
 
   /* Get user information */
   silc_client->username = g_strdup(settings_get_str("user_name"));
+  silc_client->nickname = g_strdup(settings_get_str("nick"));
   silc_client->hostname = silc_net_localhost();
   silc_client->realname = g_strdup(settings_get_str("real_name"));
 
@@ -341,7 +374,7 @@ void silc_core_init_finish(void)
   silc_channels_init();
   silc_queries_init();
 
-  idletag = g_timeout_add(50, (GSourceFunc) my_silc_scheduler, NULL);
+  idletag = g_timeout_add(5, (GSourceFunc) my_silc_scheduler, NULL);
 }
 
 /* Deinit SILC. Called from src/fe-text/silc.c */