Fix compilation warnings
[silc.git] / apps / irssi / src / silc / core / client_ops.c
index 75f3b147728d15937001fcac93bf36d6e0b595bd..25db9eae17f7fcce96171ca588cd9594e9a15ac7 100644 (file)
@@ -212,14 +212,26 @@ void silc_say(SilcClient client, SilcClientConnection conn,
              SilcClientMessageType type, char *msg, ...)
 {
   SILC_SERVER_REC *server;
+  char *target = NULL;
   va_list va;
   char *str;
 
   server = conn == NULL ? NULL : conn->context;
 
+  switch (conn->context_type) {
+    case SILC_ID_CLIENT:
+      target = (conn->client_entry->nickname[0] ?
+               conn->client_entry->nickname : NULL);
+    break;
+
+    case SILC_ID_CHANNEL:
+      target = conn->channel_entry->channel_name;
+    break;
+  }
+
   va_start(va, msg);
   str = g_strdup_vprintf(msg, va);
-  printtext(server, NULL, MSGLEVEL_CRAP, "%s", str);
+  printtext(server, target, MSGLEVEL_CRAP, "%s", str);
   g_free(str);
   va_end(va);
 }
@@ -1407,7 +1419,7 @@ typedef struct {
   SilcIdType id_type;
 } *GetkeyContext;
 
-void silc_getkey_cb(bool success, void *context)
+void silc_getkey_cb(SilcBool success, void *context)
 {
   GetkeyContext getkey = (GetkeyContext)context;
   char *entity = (getkey->id_type == SILC_ID_CLIENT ? "user" : "server");
@@ -2464,7 +2476,7 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn,
   SilcPublicKey local_pubkey;
   SilcSILCPublicKey silc_pubkey;
   SilcUInt16 port;
-  SILC_SERVER_REC *server;
+  SILC_SERVER_REC *server = NULL;
   const char *hostname, *ip;
   unsigned char *pk;
   SilcUInt32 pk_len;
@@ -2587,6 +2599,14 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn,
                         silc_pubkey->identifier.realname,
                         silc_pubkey->identifier.email ?
                         silc_pubkey->identifier.email : "");
+    else if (conn_type == SILC_CONN_CLIENT &&
+            (silc_pubkey->identifier.realname ||
+             silc_pubkey->identifier.email))
+      printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
+                        SILCTXT_PUBKEY_RECEIVED_CLIENT, "",
+                        silc_pubkey->identifier.realname,
+                        silc_pubkey->identifier.email ?
+                        silc_pubkey->identifier.email : "");
     printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
                       SILCTXT_PUBKEY_FINGERPRINT, entity, fingerprint);
     printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
@@ -2594,7 +2614,8 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn,
     format = format_get_text("fe-common/silc", NULL, NULL, NULL,
                             SILCTXT_PUBKEY_ACCEPT);
     silc_keyboard_entry_redirect(verify_public_key_completion,
-                           format, 0, verify, &server->prompt_op);
+                                format, 0, verify,
+                                server ? &server->prompt_op : NULL);
     g_free(format);
     silc_free(fingerprint);
     silc_free(babbleprint);
@@ -2618,6 +2639,14 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn,
                           silc_pubkey->identifier.realname,
                           silc_pubkey->identifier.email ?
                           silc_pubkey->identifier.email : "");
+      else if (conn_type == SILC_CONN_CLIENT &&
+              (silc_pubkey->identifier.realname ||
+               silc_pubkey->identifier.email))
+       printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
+                          SILCTXT_PUBKEY_RECEIVED_CLIENT, "",
+                          silc_pubkey->identifier.realname,
+                          silc_pubkey->identifier.email ?
+                          silc_pubkey->identifier.email : "");
       printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
                         SILCTXT_PUBKEY_FINGERPRINT, entity, fingerprint);
       printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
@@ -2627,7 +2656,9 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn,
       format = format_get_text("fe-common/silc", NULL, NULL, NULL,
                               SILCTXT_PUBKEY_ACCEPT_ANYWAY);
       silc_keyboard_entry_redirect(verify_public_key_completion,
-                             format, 0, verify, &server->prompt_op);
+                                  format, 0, verify,
+                                  server ? &server->prompt_op : NULL);
+
       g_free(format);
       silc_free(fingerprint);
       silc_free(babbleprint);
@@ -2648,6 +2679,14 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn,
                           silc_pubkey->identifier.realname,
                           silc_pubkey->identifier.email ?
                           silc_pubkey->identifier.email : "");
+      else if (conn_type == SILC_CONN_CLIENT &&
+              (silc_pubkey->identifier.realname ||
+               silc_pubkey->identifier.email))
+       printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
+                          SILCTXT_PUBKEY_RECEIVED_CLIENT, "",
+                          silc_pubkey->identifier.realname,
+                          silc_pubkey->identifier.email ?
+                          silc_pubkey->identifier.email : "");
       printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
                         SILCTXT_PUBKEY_FINGERPRINT, entity, fingerprint);
       printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
@@ -2657,7 +2696,8 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn,
       format = format_get_text("fe-common/silc", NULL, NULL, NULL,
                               SILCTXT_PUBKEY_ACCEPT_ANYWAY);
       silc_keyboard_entry_redirect(verify_public_key_completion,
-                             format, 0, verify, &server->prompt_op);
+                                  format, 0, verify,
+                                  server ? &server->prompt_op : NULL);
       g_free(format);
       silc_free(fingerprint);
       silc_free(babbleprint);
@@ -2678,6 +2718,14 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn,
                           silc_pubkey->identifier.realname,
                           silc_pubkey->identifier.email ?
                           silc_pubkey->identifier.email : "");
+      else if (conn_type == SILC_CONN_CLIENT &&
+              (silc_pubkey->identifier.realname ||
+               silc_pubkey->identifier.email))
+       printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
+                          SILCTXT_PUBKEY_RECEIVED_CLIENT, "",
+                          silc_pubkey->identifier.realname,
+                          silc_pubkey->identifier.email ?
+                          silc_pubkey->identifier.email : "");
       printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
                         SILCTXT_PUBKEY_FINGERPRINT, entity, fingerprint);
       printformat_module("fe-common/silc", NULL, NULL, MSGLEVEL_CRAP,
@@ -2693,7 +2741,8 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn,
       format = format_get_text("fe-common/silc", NULL, NULL, NULL,
                               SILCTXT_PUBKEY_ACCEPT_ANYWAY);
       silc_keyboard_entry_redirect(verify_public_key_completion,
-                             format, 0, verify, &server->prompt_op);
+                                  format, 0, verify,
+                                  server ? &server->prompt_op : NULL);
       g_free(format);
       silc_free(fingerprint);
       silc_free(babbleprint);