]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc-channel.c
Mac OS X: fix test for packagemaker(1) tool in Makefile
[ngircd-alex.git] / src / ngircd / irc-channel.c
index 586d46cabd8c7f3ebd341442ab41f1208de45314..af0f06681568289512438c91d868507fda2840d5 100644 (file)
@@ -89,10 +89,9 @@ join_allowed(CLIENT *Client, CLIENT *target, CHANNEL *chan,
        }
 
        /* Is the channel protected by a key? */
-       if (strchr(channel_modes, 'k') &&
-               strcmp(Channel_Key(chan), key ? key : ""))
-       {
-               IRC_WriteStrClient(Client, ERR_BADCHANNELKEY_MSG, Client_ID(Client), channame);
+       if (!Channel_CheckKey(chan, target, key ? key : "")) {
+               IRC_WriteStrClient(Client, ERR_BADCHANNELKEY_MSG,
+                                  Client_ID(Client), channame);
                return false;
        }
        /* Are there already too many members? */
@@ -156,16 +155,24 @@ join_forward(CLIENT *Client, CLIENT *target, CHANNEL *chan,
        else
                modes[0] = '\0';
 
-       /* forward to other servers */
-       snprintf(str, sizeof(str), "%s%s", channame, modes);
-       IRC_WriteStrServersPrefixFlag_CB(Client, target, '\0', cb_join_forward, str);
+       /* forward to other servers (if it is not a local channel) */
+       if (!Channel_IsLocal(chan)) {
+               snprintf(str, sizeof(str), "%s%s", channame, modes);
+               IRC_WriteStrServersPrefixFlag_CB(Client, target, '\0',
+                                                cb_join_forward, str);
+       }
 
        /* tell users in this channel about the new client */
-       IRC_WriteStrChannelPrefix(Client, chan, target, false, "JOIN :%s", channame);
-       if (modes[1])
-               IRC_WriteStrChannelPrefix(Client, chan, target, false, "MODE %s +%s %s",
-                                               channame, &modes[1], Client_ID(target));
-}
+       IRC_WriteStrChannelPrefix(Client, chan, target, false,
+                                 "JOIN :%s",  channame);
+
+       /* syncronize channel modes */
+       if (modes[1]) {
+               IRC_WriteStrChannelPrefix(Client, chan, target, false,
+                                         "MODE %s +%s %s", channame,
+                                         &modes[1], Client_ID(target));
+       }
+} /* join_forward */
 
 
 static bool
@@ -296,7 +303,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
                if (!chan) { /* channel is new; it has been created above */
                        chan = Channel_Search(channame);
                        assert(chan != NULL);
-                       if (*channame == '+') { /* modeless channel... */
+                       if (Channel_IsModeless(chan)) {
                                Channel_ModeAdd(chan, 't'); /* /TOPIC not allowed */
                                Channel_ModeAdd(chan, 'n'); /* no external msgs */
                        }
@@ -423,12 +430,18 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
                 Client_TypeText(from), Client_Mask(from), Channel_Name(chan),
                 Req->argv[1][0] ? Req->argv[1] : "<none>");
 
-       /* im Channel bekannt machen und an Server weiterleiten */
-       IRC_WriteStrServersPrefix( Client, from, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
-       IRC_WriteStrChannelPrefix( Client, chan, from, false, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
+       /* Update channel and forward new topic to other servers */
+       if (!Channel_IsLocal(chan))
+               IRC_WriteStrServersPrefix(Client, from, "TOPIC %s :%s",
+                                         Req->argv[0], Req->argv[1]);
+       IRC_WriteStrChannelPrefix(Client, chan, from, false, "TOPIC %s :%s",
+                                 Req->argv[0], Req->argv[1]);
 
-       if( Client_Type( Client ) == CLIENT_USER ) return IRC_WriteStrClientPrefix( Client, Client, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
-       else return CONNECTED;
+       if (Client_Type(Client) == CLIENT_USER)
+               return IRC_WriteStrClientPrefix(Client, Client, "TOPIC %s :%s",
+                                               Req->argv[0], Req->argv[1]);
+       else
+               return CONNECTED;
 } /* IRC_TOPIC */