Implement a per-connection-class default usermode option.
[ircu2.10.12-pk.git] / ircd / s_user.c
index ce5ea555e1a5c71b1f8887e9e601db3427d7d0f8..7134b256d7155847309fbc098a852300020e62d7 100644 (file)
@@ -348,7 +348,7 @@ int register_user(struct Client *cptr, struct Client *sptr,
                   const char *nick, char *username)
 {
   struct ConfItem* aconf;
-  char*            parv[3];
+  char*            parv[4];
   char*            tmpstr;
   char*            tmpstr2;
   char             c = 0;    /* not alphanum */
@@ -362,7 +362,6 @@ int register_user(struct Client *cptr, struct Client *sptr,
   short            badid = 0;
   short            digitgroups = 0;
   struct User*     user = cli_user(sptr);
-  struct Flags flag;
   char             ip_base64[8];
 
   user->last = CurrentTime;
@@ -551,7 +550,8 @@ int register_user(struct Client *cptr, struct Client *sptr,
      */
     send_reply(sptr, RPL_YOURHOST, cli_name(&me), version);
     send_reply(sptr, RPL_CREATED, creation);
-    send_reply(sptr, RPL_MYINFO, cli_name(&me), version);
+    send_reply(sptr, RPL_MYINFO, cli_name(&me), infousermodes, infochanmodes,
+               infochanmodeswithparams, version);
     send_supported(sptr);
     m_lusers(sptr, sptr, 1, parv);
     update_load();
@@ -566,6 +566,15 @@ int register_user(struct Client *cptr, struct Client *sptr,
                            cli_sock_ip(sptr), get_client_class(sptr));
 
     IPcheck_connect_succeeded(sptr);
+    /*
+     * Set user's initial modes
+     */
+    parv[0] = (char*)nick;
+    parv[1] = (char*)nick;
+    parv[2] = (char*)client_get_default_umode(sptr);
+    parv[3] = NULL; /* needed in case of +s */
+    set_user_mode(sptr, sptr, 3, parv);
+    ClearHiddenHost(sptr); /* just in case somebody stuck +x in there */
   }
   else
     /* if (IsServer(cptr)) */
@@ -614,13 +623,9 @@ int register_user(struct Client *cptr, struct Client *sptr,
                        inttobase64(ip_base64, ntohl(cli_ip(sptr).s_addr), 6),
                        NumNick(sptr), cli_info(sptr));
   
-  /* Send umode to client */
-  if (MyUser(sptr))
-  {
-    send_umode(cptr, sptr, &flag, ALL_UMODES);
-    if (cli_snomask(sptr) != SNO_DEFAULT && HasFlag(sptr, FLAG_SERVNOTICE))
-      send_reply(sptr, RPL_SNOMASK, cli_snomask(sptr), cli_snomask(sptr));
-  }
+  /* Send server notice mask to client */
+  if (MyUser(sptr) && (cli_snomask(sptr) != SNO_DEFAULT) && HasFlag(sptr, FLAG_SERVNOTICE))
+    send_reply(sptr, RPL_SNOMASK, cli_snomask(sptr), cli_snomask(sptr));
 
   return 0;
 }
@@ -1057,6 +1062,11 @@ hide_hostmask(struct Client *cptr, unsigned int flag)
       flag == FLAG_HIDDENHOST)
     return 0;
 
+/* Invalidate all bans against the user so we check them again */
+      for (chan = (cli_user(cptr))->channel; chan;
+           chan = chan->next_channel)
+        ClearBanValid(chan);
+
   SetFlag(cptr, flag);
   if (!HasFlag(cptr, FLAG_HIDDENHOST) || !HasFlag(cptr, FLAG_ACCOUNT))
     return 0;
@@ -1075,8 +1085,14 @@ hide_hostmask(struct Client *cptr, unsigned int flag)
    */
   for (chan = cli_user(cptr)->channel; chan; chan = chan->next_channel)
   {
-    sendcmdto_channel_butserv_butone(cptr, CMD_JOIN, chan->channel, cptr,
-                                     "%H", chan->channel);
+    /* For a user with no modes in a join-delayed channel, do not show
+     * the rejoin. */
+    if (!IsChanOp(chan) && !HasVoice(chan)
+        && (chan->channel->mode.mode & MODE_DELJOINS))
+      SetDelayedJoin(chan);
+    else
+      sendcmdto_channel_butserv_butone(cptr, CMD_JOIN, chan->channel, cptr,
+                                         "%H", chan->channel);
     if (IsChanOp(chan) && HasVoice(chan))
       sendcmdto_channel_butserv_butone(&me, CMD_MODE, chan->channel, cptr,
                                        "%H +ov %C %C", chan->channel, cptr,
@@ -1339,7 +1355,7 @@ char *umode_str(struct Client *cptr)
   /* Maximum string size: "owidgrx\0" */
   char *m = umodeBuf;
   int i;
-  struct Flags c_flags;
+  struct Flags c_flags = cli_flags(cptr);
 
   if (HasPriv(cptr, PRIV_PROPAGATE))
     FlagSet(&c_flags, FLAG_OPER);