DelChannelUser call and semantic fixups
authorMichael Poole <mdpoole@troilus.org>
Sun, 3 Sep 2006 15:21:10 +0000 (15:21 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sun, 3 Sep 2006 15:21:10 +0000 (15:21 +0000)
src/hash.c (DelChannel): Fix type of 'reason' arg to DelChannelUser().
  (DelChannelUser): Only send part message if user is local.

src/proto-bahamut.c (DelUser): Unswap arguments to DelChannelUser().
  (cmd_part): Move to proto-common.c.

src/proto-common.c (part_desc): New structure type.
  (part_helper): Use it to capture user and reason.
  (cmd_part): New common function.

src/proto-p10.c (cmd_part): Move to proto-common.c.
  (DelUser): Unswap arguments to DelChannelUser().
git-archimport-id: srvx@srvx.net--2006/srvx--devo--1.3--patch-29

ChangeLog
src/hash.c
src/proto-bahamut.c
src/proto-common.c
src/proto-p10.c

index 4c2dd85ea5e9edf1e8b2a98e9a5d7e2393c654e4..d513265dda0a551df25eadd48804e1fc4d9b7c26 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,31 @@
 # arch-tag: automatic-ChangeLog--srvx@srvx.net--2006/srvx--devo--1.3
 #
 
+2006-09-03 15:21:10 GMT        Michael Poole <mdpoole@troilus.org>     patch-29
+
+    Summary:
+      DelChannelUser call and semantic fixups
+    Revision:
+      srvx--devo--1.3--patch-29
+
+    src/hash.c (DelChannel): Fix type of 'reason' arg to DelChannelUser().
+      (DelChannelUser): Only send part message if user is local.
+    
+    src/proto-bahamut.c (DelUser): Unswap arguments to DelChannelUser().
+      (cmd_part): Move to proto-common.c.
+    
+    src/proto-common.c (part_desc): New structure type.
+      (part_helper): Use it to capture user and reason.
+      (cmd_part): New common function.
+    
+    src/proto-p10.c (cmd_part): Move to proto-common.c.
+      (DelUser): Unswap arguments to DelChannelUser().
+
+    modified files:
+     ChangeLog src/hash.c src/proto-bahamut.c src/proto-common.c
+     src/proto-p10.c
+
+
 2006-09-03 15:17:05 GMT        Michael Poole <mdpoole@troilus.org>     patch-28
 
     Summary:
index 468086588b60978e87af67908e296f5c85615a8b..f08a3c593b35cbdca1a9bab92f14d08f7ec011ee 100644 (file)
@@ -440,7 +440,7 @@ DelChannel(struct chanNode *channel)
 
     /* go through all channel members and delete them from the channel */
     for (n=channel->members.used; n>0; )
-       DelChannelUser(channel->members.list[--n]->user, channel, false, 1);
+       DelChannelUser(channel->members.list[--n]->user, channel, NULL, 1);
 
     /* delete all channel bans */
     for (n=channel->banlist.used; n>0; )
@@ -550,7 +550,7 @@ DelChannelUser(struct userNode* user, struct chanNode* channel, const char *reas
     struct modeNode* mNode;
     unsigned int n;
 
-    if (reason)
+    if (IsLocal(user) && reason)
         irc_part(user, channel, reason);
 
     mNode = GetUserMode(channel, user);
index d63aef01a2cc7fae8710b62aa0b12336c519dd0f..d493744ce00892fee8138d05e5544926469e1750 100644 (file)
@@ -210,7 +210,7 @@ DelUser(struct userNode* user, struct userNode *killer, int announce, const char
     unsigned int nn;
 
     for (nn=user->channels.used; nn>0;) {
-        DelChannelUser(user, user->channels.list[--nn]->channel, false, 0);
+        DelChannelUser(user, user->channels.list[--nn]->channel, NULL, false);
     }
     for (nn=duf_used; nn>0; ) duf_list[--nn](user, killer, why);
     user->uplink->clients--;
@@ -892,12 +892,6 @@ static CMD_FUNC(cmd_topic) {
     return 1;
 }
 
-static CMD_FUNC(cmd_part) {
-    if (argc < 2) return 0;
-    parse_foreach(argv[1], part_helper, NULL, NULL, NULL, GetUserH(origin));
-    return 1;
-}
-
 static CMD_FUNC(cmd_away) {
     struct userNode *un;
 
index bd392e0f3eaa845039e05ef6db0027d99571ff4e..a8b2888a14bfd4d1dc096ce1b5bb593bed20d3f8 100644 (file)
@@ -464,10 +464,30 @@ privmsg_invalid(char *name, void *data)
     irc_numeric(pd->user, ERR_NOSUCHNICK, "%s@%s :No such nick", name, self->name);
 }
 
+struct part_desc {
+    struct userNode *user;
+    const char *text;
+};
+
 static void
 part_helper(struct chanNode *cn, void *data)
 {
-    DelChannelUser(data, cn, false, 0);
+    struct part_desc *desc = data;
+    DelChannelUser(desc->user, cn, desc->text, false);
+}
+
+static CMD_FUNC(cmd_part)
+{
+    struct part_desc desc;
+
+    if (argc < 2)
+        return 0;
+    desc.user = GetUserH(origin);
+    if (!desc.user)
+        return 0;
+    desc.text = (argc > 2) ? argv[argc - 1] : NULL;
+    parse_foreach(argv[1], part_helper, NULL, NULL, NULL, &desc);
+    return 1;
 }
 
 void
index 595bd142f7a61fab6020e299d41b22025df096d9..35e5a0928c3753b2859410a2ff51ec1ed6ed7240 100644 (file)
@@ -1388,19 +1388,6 @@ static CMD_FUNC(cmd_kill)
     return 1;
 }
 
-static CMD_FUNC(cmd_part)
-{
-    struct userNode *user;
-
-    if (argc < 2)
-        return 0;
-    user = GetUserH(origin);
-    if (!user)
-        return 0;
-    parse_foreach(argv[1], part_helper, NULL, NULL, NULL, user);
-    return 1;
-}
-
 static CMD_FUNC(cmd_kick)
 {
     if (argc < 3)
@@ -2056,7 +2043,7 @@ DelUser(struct userNode* user, struct userNode *killer, int announce, const char
 
     /* remove user from all channels */
     while (user->channels.used > 0)
-        DelChannelUser(user, user->channels.list[user->channels.used-1]->channel, false, 0);
+        DelChannelUser(user, user->channels.list[user->channels.used-1]->channel, NULL, false);
 
     /* Call these in reverse order so ChanServ can update presence
        information before NickServ nukes the handle_info. */