keep in sync with OGN upstream (SVN-320)
authorpk910 <philipp@zoelle1.de>
Thu, 10 May 2012 21:06:17 +0000 (23:06 +0200)
committerpk910 <philipp@zoelle1.de>
Thu, 10 May 2012 21:06:17 +0000 (23:06 +0200)
include/handlers.h
include/msg.h
ircd/Makefile.in
ircd/m_svspart.c [new file with mode: 0644]
ircd/parse.c

index 1fed4090b0c87142f727ccc80c781e29ef82a52e..34d9be02d8bf6f64a65b70eb2e71be4ec4f5d393 100644 (file)
@@ -232,6 +232,7 @@ extern int ms_svsmode(struct Client*, struct Client*, int, char*[]);
 extern int ms_svsnick(struct Client*, struct Client*, int, char*[]);
 extern int ms_svsnick_old(struct Client*, struct Client*, int, char*[]);
 extern int ms_svsjoin(struct Client*, struct Client*, int, char*[]);
+extern int ms_svspart(struct Client*, struct Client*, int, char*[]);
 extern int ms_topic(struct Client*, struct Client*, int, char*[]);
 extern int ms_trace(struct Client*, struct Client*, int, char*[]);
 extern int ms_uping(struct Client*, struct Client*, int, char*[]);
index e4798f3878355d27a5edf031db51f2e0522589a5..59f921cf769dbbac4fca0818000c87eecaa3a141 100644 (file)
@@ -392,6 +392,10 @@ struct Client;
 #define TOK_SVSJOIN        "SJ"
 #define CMD_SVSJOIN        MSG_SVSJOIN, TOK_SVSJOIN
 
+#define MSG_SVSPART        "SVSPART"
+#define TOK_SVSPART        "SP"
+#define CMD_SVSPART        MSG_SVSPART, TOK_SVSPART
+
 #define MSG_WEBIRC          "WEBIRC"
 #define TOK_WEBIRC          "WEBIRC"
 #define CMD_WEBIRC          MSG_WEBIRC, TOK_WEBIRC
index a4888a55b3ec8959c10fe852e019db2c16f457f0..2e3cf13002608e9efb866ecbc1898d776e4277ce 100644 (file)
@@ -175,6 +175,7 @@ IRCD_SRC = \
        m_svsmode.c \
        m_svsnick.c \
        m_svsjoin.c \
+       m_svspart.c \
        m_time.c \
        m_topic.c \
        m_trace.c \
diff --git a/ircd/m_svspart.c b/ircd/m_svspart.c
new file mode 100644 (file)
index 0000000..cb50456
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * IRC - Internet Relay Chat, ircd/m_svspart.c
+ * Written by Pierre Schweitzer.
+ */
+
+#include "config.h"
+
+#include "channel.h"
+#include "client.h"
+#include "handlers.h"
+#include "hash.h"
+#include "ircd.h"
+#include "ircd_chattr.h"
+#include "ircd_features.h"
+#include "ircd_reply.h"
+#include "ircd_string.h"
+#include "msg.h"
+#include "numeric.h"
+#include "numnicks.h"
+#include "s_debug.h"
+#include "s_user.h"
+#include "send.h"
+
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+/** SVSPART
+ * SVSPART is forwarded to the server where the user is connected to.
+ * This allows to send SVSPARTs from all servers in the network but additionally causes
+ * some overhead. Though, SVSPART is not often called and this overhead can be ignored.
+ */
+/* ms_svspart - server message handler
+ *
+ * parv[0] = sender prefix
+ * parv[1] = numeric of client
+ * parv[2] = channel, NO CHANLIST!
+ * parv[3] = comment (optional)
+ */
+signed int ms_svspart(struct Client* cptr, struct Client* sptr, signed int parc, char* parv[]) {
+    struct Client *acptr;
+    struct Channel *chptr;
+    struct JoinBuf part;
+    struct Membership *member;
+    unsigned int flags = 0;
+    int use_comment;
+
+    if(parc < 3) {
+        return protocol_violation(cptr, "Too few arguments for SVSPART");
+    }
+
+    /* Ignore if the user has already quitted. */
+    if(!(acptr = findNUser(parv[1]))) {
+        return 0;
+    }
+
+    /* Check channelname. */
+    if(!IsChannelName(parv[2]) || !strIsIrcCh(parv[2])) {
+        return 0;
+    }
+
+    /* Get the channel */
+    chptr = get_channel(acptr, parv[2], CGT_NO_CREATE);
+
+    /* Ensure the user is in channel */
+    if (!(member = find_member_link(chptr, acptr))) return 0;
+
+    /* Forward the message to the server where the user is connected to. */
+    if(!MyConnect(acptr)) {
+        if (parc > 3)
+            sendcmdto_one(sptr, CMD_SVSPART, acptr, "%s %s :%s", parv[1], chptr->chname, parv[3]);
+        else
+            sendcmdto_one(sptr, CMD_SVSPART, acptr, "%s %s", parv[1], chptr->chname);
+        return 0;
+    }
+
+    /* Check if we can put part message */
+    use_comment = (parc > 3 && !EmptyString(parv[3]) &&
+                   member_can_send_to_channel(member, 0));
+
+    /* Use join buf to make him leave - use comment if provided */
+    joinbuf_init(&part, acptr, acptr, JOINBUF_TYPE_PART,
+                     use_comment ? parv[3] : 0, 0);
+
+    if (!member_can_send_to_channel(member, 0))
+      flags |= CHFL_BANNED;
+
+    if (IsDelayedJoin(member))
+      flags |= CHFL_DELAYED;
+
+    /* Make the user leave */
+    joinbuf_join(&part, chptr, flags);
+
+    joinbuf_flush(&part);
+
+    return 0;
+}
+  
\ No newline at end of file
index 49e656421a1a2b4a16b035fb5bf744adf27af3af..3c3c3d5c7e5bcb8e0e34ef18855a3240461d77ee 100644 (file)
@@ -682,6 +682,13 @@ struct Message msgtab[] = {
     /* UNREG, CLIENT, SERVER, OPER, SERVICE */
     { m_ignore, m_ignore, ms_svsjoin, m_svsjoin, m_ignore }
   },
+  {
+    MSG_SVSPART,
+    TOK_SVSPART,
+    0, MAXPARA, MFLG_SLOW, 0, NULL,
+    /* UNREG, CLIENT, SERVER, OPER, SERVICE */
+    { m_ignore, m_ignore, ms_svspart, m_svspart, m_ignore }
+  },
   {
     MSG_WEBIRC,
     TOK_WEBIRC,