]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/commandbuilder.h
Fix sending DEL for caps which have not been advertised yet.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / commandbuilder.h
index 26eb4587f4e27accefd910d5a017b3e732af5921..f6cca9917739e7f28345d03bf4c2c043c53daed6 100644 (file)
@@ -26,28 +26,53 @@ class TreeServer;
 class CmdBuilder
 {
  protected:
+       /** The raw message contents. */
        std::string content;
 
+       /** Tags which have been added to this message. */
+       ClientProtocol::TagMap tags;
+
+       /** The size of tags within the contents. */
+       size_t tagsize;
+
+       /** Fires the ServerProtocol::MessageEventListener::OnBuildMessage event for a server target. */
+       void FireEvent(Server* target, const char* cmd, ClientProtocol::TagMap& taglist);
+
+       /** Fires the ServerProtocol::MessageEventListener::OnBuildMessage event for a user target. */
+       void FireEvent(User* target, const char* cmd, ClientProtocol::TagMap& taglist);
+
+       /** Updates the tag string within the buffer. */
+       void UpdateTags();
+
  public:
        CmdBuilder(const char* cmd)
                : content(1, ':')
+               , tagsize(0)
        {
                content.append(ServerInstance->Config->GetSID());
                push(cmd);
+               FireEvent(ServerInstance->FakeClient->server, cmd, tags);
        }
 
-       CmdBuilder(const std::string& src, const char* cmd)
+       CmdBuilder(TreeServer* src, const char* cmd)
                : content(1, ':')
+               , tagsize(0)
        {
-               content.append(src);
+               content.append(src->GetID());
                push(cmd);
+               FireEvent(src, cmd, tags);
        }
 
        CmdBuilder(User* src, const char* cmd)
                : content(1, ':')
+               , tagsize(0)
        {
                content.append(src->uuid);
                push(cmd);
+               if (InspIRCd::IsSID(src->uuid))
+                       FireEvent(src->server, cmd, tags);
+               else
+                       FireEvent(src, cmd, tags);
        }
 
        CmdBuilder& push_raw(const std::string& s)
@@ -119,6 +144,15 @@ class CmdBuilder
                return *this;
        }
 
+       CmdBuilder& push_tags(ClientProtocol::TagMap newtags)
+       {
+               // It has to be this way around so new tags get priority.
+               newtags.insert(tags.begin(), tags.end());
+               std::swap(tags, newtags);
+               UpdateTags();
+               return *this;
+       }
+
        template<typename T>
        CmdBuilder& insert(const T& cont)
        {
@@ -127,8 +161,6 @@ class CmdBuilder
                return *this;
        }
 
-       void push_back(const std::string& s) { push(s); }
-
        const std::string& str() const { return content; }
        operator const std::string&() const { return str(); }
 
@@ -142,11 +174,6 @@ class CmdBuilder
                Utils->DoOneToAllButSender(*this, omit);
        }
 
-       bool Unicast(const std::string& target) const
-       {
-               return Utils->DoOneToOne(*this, target);
-       }
-
        void Unicast(User* target) const
        {
                Utils->DoOneToOne(*this, target->server);