updates.
[silc.git] / apps / silc / client_ops.c
index a127140ce0b0fc7112542f2683b24431fcdb9edd..830c6e9004d1be1f233998c12761ddc6f9d5261d 100644 (file)
@@ -46,22 +46,26 @@ void silc_say(SilcClient client, SilcClientConnection conn,
    received in the packet. The `channel_name' is the name of the channel. */
 
 void silc_channel_message(SilcClient client, SilcClientConnection conn,
-                         char *sender, char *channel_name, char *msg)
+                         SilcClientEntry sender, SilcChannelEntry channel
+                         , char *msg)
 {
   /* Message from client */
-  if (!strcmp(conn->current_channel->channel_name, channel_name))
-    silc_print(client, "<%s> %s", sender, msg);
+  if (conn && !strcmp(conn->current_channel->channel_name, 
+                     channel->channel_name))
+    silc_print(client, "<%s> %s", sender ? sender->nickname : "[<unknown>]", 
+              msg);
   else
-    silc_print(client, "<%s:%s> %s", sender, channel_name, msg);
+    silc_print(client, "<%s:%s> %s", sender ? sender->nickname : "[<unknown>]",
+              channel->channel_name, msg);
 }
 
 /* Private message to the client. The `sender' is the nickname of the
    sender received in the packet. */
 
 void silc_private_message(SilcClient client, SilcClientConnection conn,
-                         char *sender, char *msg)
+                         SilcClientEntry sender, char *msg)
 {
-  silc_print(client, "*%s* %s", sender, msg);
+  silc_print(client, "*%s* %s", sender->nickname, msg);
 }
 
 
@@ -81,7 +85,7 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
   char message[4096];
   SilcClientEntry client_entry, client_entry2;
   SilcChannelEntry channel_entry;
-  char *tmp;
+  char *tmp = NULL;
   unsigned int tmp_int;
 
   va_start(vp, type);
@@ -126,12 +130,15 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
 
   case SILC_NOTIFY_TYPE_SIGNOFF:
     client_entry = va_arg(vp, SilcClientEntry);
+    tmp = va_arg(vp, char *);
     if (client_entry->server)
-      snprintf(message, sizeof(message), "Signoff: %s@%s", 
-              client_entry->nickname, client_entry->server);
+      snprintf(message, sizeof(message), "Signoff: %s@%s %s%s%s", 
+              client_entry->nickname, client_entry->server,
+              tmp ? "(" : "", tmp ? tmp : "", tmp ? ")" : "");
     else
-      snprintf(message, sizeof(message), "Signoff: %s", 
-              client_entry->nickname);
+      snprintf(message, sizeof(message), "Signoff: %s %s%s%s", 
+              client_entry->nickname,
+              tmp ? "(" : "", tmp ? tmp : "", tmp ? ")" : "");
     break;
 
   case SILC_NOTIFY_TYPE_TOPIC_SET:
@@ -182,10 +189,10 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
     client_entry2 = va_arg(vp, SilcClientEntry);
     channel_entry = va_arg(vp, SilcChannelEntry);
     if (tmp)
-      snprintf(message, sizeof(message), "%s changed %s mode to +%s", 
+      snprintf(message, sizeof(message), "%s changed %s's mode to +%s", 
               client_entry->nickname, client_entry2->nickname, tmp);
     else
-      snprintf(message, sizeof(message), "%s removed %s modes", 
+      snprintf(message, sizeof(message), "%s removed %s's modes", 
               client_entry->nickname, client_entry2->nickname);
     if (client_entry2 == conn->local_entry) {
       if (app->screen->bottom_line->mode)
@@ -219,6 +226,9 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
     }
     return;
 
+  case SILC_NOTIFY_TYPE_CHANNEL_CHANGE:
+    break;
+
   default:
     break;
   }
@@ -284,8 +294,8 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
                        SilcCommand command, SilcCommandStatus status, ...)
 {
   SilcClientInternal app = (SilcClientInternal)client->application;
+  SilcChannelUser chu;
   va_list vp;
-  int i;
 
   if (!success)
     return;
@@ -318,17 +328,20 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
       }
       break;
 
-    case SILC_COMMAND_NAMES:
-      for (i = 0; i < conn->current_channel->clients_count; i++)
-       if (conn->current_channel->clients[i].client == conn->local_entry) {
+    case SILC_COMMAND_USERS:
+      silc_list_start(conn->current_channel->clients);
+      while ((chu = silc_list_get(conn->current_channel->clients)) 
+            != SILC_LIST_END) {
+       if (chu->client == conn->local_entry) {
          if (app->screen->bottom_line->mode)
            silc_free(app->screen->bottom_line->mode);
          app->screen->bottom_line->mode = 
-           silc_client_chumode_char(conn->current_channel->clients[i].mode);
+           silc_client_chumode_char(chu->mode);
          silc_screen_print_bottom_line(app->screen, 0);
          break;
        }
       break;
+      }
     }
 }
 
@@ -355,6 +368,7 @@ void silc_disconnect(SilcClient client, SilcClientConnection conn)
 
   app->screen->bottom_line->connection = NULL;
   silc_screen_print_bottom_line(app->screen, 0);
+  app->conn = NULL;
 }
 
 /* Asks passphrase from user on the input line. */