]> granicus.if.org Git - icinga2/commitdiff
Remove EventArgs struct.
authorGunnar Beutner <gunnar@beutner.name>
Sat, 16 Jun 2012 01:42:54 +0000 (03:42 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Sat, 16 Jun 2012 01:42:54 +0000 (03:42 +0200)
42 files changed:
base/application.cpp
base/base.vcxproj
base/eventargs.h [deleted file]
base/i2-base.h
base/objectmap.h
base/objectset.h
base/socket.cpp
base/socket.h
base/tcpclient.cpp
base/tcpclient.h
base/tcpserver.cpp
base/tcpserver.h
base/timer.cpp
base/timer.h
base/tlsclient.cpp
base/tlsclient.h
components/checker/checker.vcxproj.filters [new file with mode: 0644]
components/checker/checkercomponent.cpp
components/checker/checkercomponent.h
components/configrpc/configrpccomponent.cpp
components/configrpc/configrpccomponent.h
components/delegation/delegation.vcxproj.filters [new file with mode: 0644]
components/delegation/delegationcomponent.cpp
components/delegation/delegationcomponent.h
components/demo/democomponent.cpp
components/demo/democomponent.h
components/discovery/discoverycomponent.cpp
components/discovery/discoverycomponent.h
dyntest/dyntest.vcxproj.filters [new file with mode: 0644]
icinga/endpoint.cpp
icinga/endpoint.h
icinga/endpointmanager.cpp
icinga/endpointmanager.h
icinga/icingaapplication.cpp
icinga/icingaapplication.h
icinga/jsonrpcendpoint.cpp
icinga/jsonrpcendpoint.h
icinga/virtualendpoint.cpp
icinga/virtualendpoint.h
jsonrpc/jsonrpcclient.cpp
jsonrpc/jsonrpcclient.h
jsonrpc/netstring.cpp

index 0e724197af7b4e2d1c6c9828c0c3ae084c8152e5..88c12a372891f1825b4a6d78913e7d70a56dcfb6 100644 (file)
@@ -159,9 +159,6 @@ void Application::RunEventLoop(void)
                else if (ready == 0)
                        continue;
 
-               EventArgs ea;
-               ea.Source = shared_from_this();
-
                for (i = Socket::Sockets.begin();
                    i != Socket::Sockets.end(); ) {
                        Socket::Ptr socket = i->lock();
@@ -178,15 +175,15 @@ void Application::RunEventLoop(void)
 
                        fd = socket->GetFD();
                        if (fd != INVALID_SOCKET && FD_ISSET(fd, &writefds))
-                               socket->OnWritable(ea);
+                               socket->OnWritable(socket);
 
                        fd = socket->GetFD();
                        if (fd != INVALID_SOCKET && FD_ISSET(fd, &readfds))
-                               socket->OnReadable(ea);
+                               socket->OnReadable(socket);
 
                        fd = socket->GetFD();
                        if (fd != INVALID_SOCKET && FD_ISSET(fd, &exceptfds))
-                               socket->OnException(ea);
+                               socket->OnException(socket);
                }
        }
 }
index fd5a13cf42737f05702b3f31a7cc7bb918a4b119..651193e837c57c1df3f9e9e7710f8ee531903557 100644 (file)
@@ -36,7 +36,6 @@
     <ClInclude Include="component.h" />
     <ClInclude Include="configobject.h" />
     <ClInclude Include="dictionary.h" />
-    <ClInclude Include="eventargs.h" />
     <ClInclude Include="objectmap.h" />
     <ClInclude Include="objectset.h" />
     <ClInclude Include="exception.h" />
diff --git a/base/eventargs.h b/base/eventargs.h
deleted file mode 100644 (file)
index f913b7e..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/******************************************************************************
- * Icinga 2                                                                   *
- * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
- *                                                                            *
- * This program is free software; you can redistribute it and/or              *
- * modify it under the terms of the GNU General Public License                *
- * as published by the Free Software Foundation; either version 2             *
- * of the License, or (at your option) any later version.                     *
- *                                                                            *
- * This program is distributed in the hope that it will be useful,            *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
- * GNU General Public License for more details.                               *
- *                                                                            *
- * You should have received a copy of the GNU General Public License          *
- * along with this program; if not, write to the Free Software Foundation     *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
- ******************************************************************************/
-
-#ifndef EVENTARGS_H
-#define EVENTARGS_H
-
-namespace icinga
-{
-
-/**
- * Base class for event arguments.
- *
- * @ingroup base
- */
-struct I2_BASE_API EventArgs
-{
-       Object::Ptr Source; /**< The source of the event. */
-};
-
-}
-
-#endif /* EVENTARGS_H */
index af524ef7c8bfe64a4f8ba6b8f59987647233ee20..63141d1668618e215ecee1c71ea2e1260b4cbe54 100644 (file)
@@ -145,7 +145,6 @@ using boost::function;
 #include "exception.h"
 #include "memory.h"
 #include "variant.h"
-#include "eventargs.h"
 #include "dictionary.h"
 #include "timer.h"
 #include "fifo.h"
index 0fb42f55dcaab2e4ef926199d289510adb2fe7c6..9a6cc04b0bd78b0e89ff6a60383b23ec9ac4f27c 100644 (file)
@@ -43,9 +43,9 @@ public:
 
        void Start(void)
        {
-               m_Parent->OnObjectAdded.connect(boost::bind(&ObjectMap::ObjectAddedHandler, this, _1));
-               m_Parent->OnObjectCommitted.connect(boost::bind(&ObjectMap::ObjectCommittedHandler, this, _1));
-               m_Parent->OnObjectRemoved.connect(boost::bind(&ObjectMap::ObjectRemovedHandler, this, _1));
+               m_Parent->OnObjectAdded.connect(boost::bind(&ObjectMap::ObjectAddedHandler, this, _2));
+               m_Parent->OnObjectCommitted.connect(boost::bind(&ObjectMap::ObjectCommittedHandler, this, _2));
+               m_Parent->OnObjectRemoved.connect(boost::bind(&ObjectMap::ObjectRemovedHandler, this, _2));
 
                for (typename ObjectSet<TValue>::Iterator it = m_Parent->Begin(); it != m_Parent->End(); it++)
                        AddObject(*it);
@@ -56,16 +56,12 @@ public:
                return m_Objects.equal_range(key);
        }
 
-       void ForeachObject(TKey key, function<void (const ObjectSetEventArgs<TValue>&)> callback)
+       void ForeachObject(TKey key, function<void (const typename ObjectMap<TValue>::Ptr, const TValue&)> callback)
        {
-               ObjectSetEventArgs<TValue> ea;
-               ea.Source = shared_from_this();
-
                Range range = GetRange(key);
 
                for (Iterator it = range.first; it != range.second; it++) {
-                       ea.Target(*it);
-                       callback(ea);
+                       callback(shared_from_this(), *it);
                }
        }
 
@@ -105,19 +101,19 @@ private:
                AddObject(object);
        }
 
-       void ObjectAddedHandler(const ObjectSetEventArgs<TValue>& ea)
+       void ObjectAddedHandler(const TValue& object)
        {
-               AddObject(ea.Target);
+               AddObject(object);
        }
 
-       void ObjectCommittedHandler(const ObjectSetEventArgs<TValue>& ea)
+       void ObjectCommittedHandler(const TValue& object)
        {
-               CheckObject(ea.Target);
+               CheckObject(object);
        }
 
-       void ObjectRemovedHandler(const ObjectSetEventArgs<TValue>& ea)
+       void ObjectRemovedHandler(const TValue& object)
        {
-               RemoveObject(ea.Target);
+               RemoveObject(object);
        }
 };
 
index 692723e8c690c6582238fa75f9b4ffe2abad80a7..394045610b1eb265888700366834c75ec48c2809 100644 (file)
 namespace icinga
 {
 
-template<typename TValue>
-struct ObjectSetEventArgs : public EventArgs
-{
-       TValue Target;
-};
-
 template<typename TValue>
 class ObjectSet : public Object
 {
@@ -49,25 +43,19 @@ public:
        void Start(void)
        {
                if (m_Parent) {
-                       m_Parent->OnObjectAdded.connect(boost::bind(&ObjectSet::ObjectAddedOrCommittedHandler, this, _1));
-                       m_Parent->OnObjectCommitted.connect(boost::bind(&ObjectSet::ObjectAddedOrCommittedHandler, this, _1));
-                       m_Parent->OnObjectRemoved.connect(boost::bind(&ObjectSet::ObjectRemovedHandler, this, _1));
+                       m_Parent->OnObjectAdded.connect(boost::bind(&ObjectSet::ObjectAddedOrCommittedHandler, this, _2));
+                       m_Parent->OnObjectCommitted.connect(boost::bind(&ObjectSet::ObjectAddedOrCommittedHandler, this, _2));
+                       m_Parent->OnObjectRemoved.connect(boost::bind(&ObjectSet::ObjectRemovedHandler, this, _2));
 
                        for (ObjectSet::Iterator it = m_Parent->Begin(); it != m_Parent->End(); it++)
                                CheckObject(*it);
-               }
-
-
+        }
        }
 
        void AddObject(const TValue& object)
        {
                m_Objects.insert(object);
-
-               ObjectSetEventArgs<TValue> ea;
-               ea.Source = shared_from_this();
-               ea.Target = object;
-               OnObjectAdded(ea);
+               OnObjectAdded(shared_from_this(), object);
        }
 
        void RemoveObject(const TValue& object)
@@ -76,11 +64,7 @@ public:
 
                if (it != m_Objects.end()) {
                        m_Objects.erase(it);
-
-                       ObjectSetEventArgs<TValue> ea;
-                       ea.Source = shared_from_this();
-                       ea.Target = object;
-                       OnObjectRemoved(ea);
+                       OnObjectRemoved(shared_from_this(), object);
                }
        }
 
@@ -97,17 +81,14 @@ public:
                        if (!Contains(object)) {
                                AddObject(object);
                        } else {
-                               ObjectSetEventArgs<TValue> ea;
-                               ea.Source = shared_from_this();
-                               ea.Target = object;
-                               OnObjectCommitted(ea);
+                               OnObjectCommitted(shared_from_this(), object);
                        }
                }
        }
 
-       boost::signal<void (const ObjectSetEventArgs<TValue>&)> OnObjectAdded;
-       boost::signal<void (const ObjectSetEventArgs<TValue>&)> OnObjectCommitted;
-       boost::signal<void (const ObjectSetEventArgs<TValue>&)> OnObjectRemoved;
+       boost::signal<void (const Object::Ptr&, const TValue&)> OnObjectAdded;
+       boost::signal<void (const Object::Ptr&, const TValue&)> OnObjectCommitted;
+       boost::signal<void (const Object::Ptr&, const TValue&)> OnObjectRemoved;
 
        Iterator Begin(void)
        {
@@ -119,14 +100,10 @@ public:
                return m_Objects.end();
        }
 
-       void ForeachObject(function<void (const ObjectSetEventArgs<TValue>&)> callback)
+       void ForeachObject(function<void (const typename Object::Ptr&, const TValue&)> callback)
        {
-               ObjectSetEventArgs<TValue> ea;
-               ea.Source = shared_from_this();
-
                for (Iterator it = Begin(); it != End(); it++) {
-                       ea.Target(*it);
-                       callback(ea);
+                       callback(shared_from_this(), *it);
                }
        }
 
@@ -136,14 +113,14 @@ private:
        typename ObjectSet<TValue>::Ptr m_Parent;
        function<bool (const TValue&)> m_Predicate;
 
-       void ObjectAddedOrCommittedHandler(const ObjectSetEventArgs<TValue>& ea)
+       void ObjectAddedOrCommittedHandler(const TValue& object)
        {
-               CheckObject(ea.Target);
+               CheckObject(object);
        }
 
-       void ObjectRemovedHandler(const ObjectSetEventArgs<TValue>& ea)
+       void ObjectRemovedHandler(const TValue& object)
        {
-               RemoveObject(ea.Target);
+               RemoveObject(object);
        }
 };
 
index 570c0363e4f9b6aa2eb9811ca196c9b35e9e8f19..6701342dd85a939dad0cc09b8c15e4f8f2a2d1dc 100644 (file)
@@ -50,7 +50,7 @@ void Socket::Start(void)
 {
        assert(m_FD != INVALID_SOCKET);
 
-       OnException.connect(boost::bind(&Socket::ExceptionEventHandler, this, _1));
+       OnException.connect(boost::bind(&Socket::ExceptionEventHandler, this));
 
        Sockets.push_back(static_pointer_cast<Socket>(shared_from_this()));
 }
@@ -125,9 +125,7 @@ void Socket::CloseInternal(bool from_dtor)
        if (!from_dtor) {
                Stop();
 
-               EventArgs ea;
-               ea.Source = shared_from_this();
-               OnClosed(ea);
+               OnClosed(shared_from_this());
        }
 }
 
@@ -172,8 +170,7 @@ int Socket::GetLastSocketError(void)
 void Socket::HandleSocketError(const std::exception& ex)
 {
        if (!OnError.empty()) {
-               SocketErrorEventArgs sea(ex);
-               OnError(sea);
+               OnError(shared_from_this(), ex);
 
                Close();
        } else {
@@ -186,7 +183,7 @@ void Socket::HandleSocketError(const std::exception& ex)
  *
  * @param - Event arguments for the socket error.
  */
-void Socket::ExceptionEventHandler(const EventArgs&)
+void Socket::ExceptionEventHandler(void)
 {
        HandleSocketError(SocketException(
            "select() returned fd in except fdset", GetError()));
index feb8a2c58064fa73a6fbab204d0866bb758da55a..0fe6316f25ade02e583d895a9c92fdc2140ee8d3 100644 (file)
 
 namespace icinga {
 
-/**
- * Event arguments for socket errors.
- *
- * @ingroup base
- */
-struct I2_BASE_API SocketErrorEventArgs : public EventArgs
-{
-       const std::exception& Exception;
-
-       SocketErrorEventArgs(const std::exception& ex)
-           : Exception(ex) { }
-};
-
 /**
  * Base class for sockets.
  *
@@ -55,12 +42,12 @@ public:
        void SetFD(SOCKET fd);
        SOCKET GetFD(void) const;
 
-       boost::signal<void (const EventArgs&)> OnReadable;
-       boost::signal<void (const EventArgs&)> OnWritable;
-       boost::signal<void (const EventArgs&)> OnException;
+       boost::signal<void (const Object::Ptr&)> OnReadable;
+       boost::signal<void (const Object::Ptr&)> OnWritable;
+       boost::signal<void (const Object::Ptr&)> OnException;
 
-       boost::signal<void (const SocketErrorEventArgs&)> OnError;
-       boost::signal<void (const EventArgs&)> OnClosed;
+       boost::signal<void (const Object::Ptr&, const std::exception&)> OnError;
+       boost::signal<void (const Object::Ptr&)> OnClosed;
 
        virtual bool WantsToRead(void) const;
        virtual bool WantsToWrite(void) const;
@@ -85,7 +72,7 @@ protected:
 private:
        SOCKET m_FD; /**< The socket descriptor. */
 
-       void ExceptionEventHandler(const EventArgs& ea);
+       void ExceptionEventHandler(void);
 
        static string GetAddressFromSockaddr(sockaddr *address, socklen_t len);
 };
index 4b5e07113ad004bca65955d2aee695bc5d157399..1363ef308f4c93cb37e750297484e6642f2016bc 100644 (file)
@@ -51,8 +51,8 @@ void TcpClient::Start(void)
 {
        TcpSocket::Start();
 
-       OnReadable.connect(boost::bind(&TcpClient::ReadableEventHandler, this, _1));
-       OnWritable.connect(boost::bind(&TcpClient::WritableEventHandler, this, _1));
+       OnReadable.connect(boost::bind(&TcpClient::ReadableEventHandler, this));
+       OnWritable.connect(boost::bind(&TcpClient::WritableEventHandler, this));
 }
 
 /**
@@ -136,10 +136,8 @@ FIFO::Ptr TcpClient::GetRecvQueue(void)
 
 /**
  * Processes data that is available for this socket.
- *
- * @param - Event arguments.
  */
-void TcpClient::ReadableEventHandler(const EventArgs&)
+void TcpClient::ReadableEventHandler(void)
 {
        int rc;
 
@@ -161,17 +159,13 @@ void TcpClient::ReadableEventHandler(const EventArgs&)
 
        m_RecvQueue->Write(NULL, rc);
 
-       EventArgs dea;
-       dea.Source = shared_from_this();
-       OnDataAvailable(dea);
+       OnDataAvailable(shared_from_this());
 }
 
 /**
  * Processes data that can be written for this socket.
- *
- * @param - Event arguments.
  */
-void TcpClient::WritableEventHandler(const EventArgs&)
+void TcpClient::WritableEventHandler(void)
 {
        int rc;
 
index 5f2d553cbd01ba727a78f128961fbbde7080ee14..2afd01942cccea3f9f251212b36191e8cf7a0d89 100644 (file)
@@ -61,7 +61,7 @@ public:
        virtual bool WantsToRead(void) const;
        virtual bool WantsToWrite(void) const;
 
-       boost::signal<void (const EventArgs&)> OnDataAvailable;
+       boost::signal<void (const Object::Ptr&)> OnDataAvailable;
 
 private:
        TcpClientRole m_Role;
@@ -69,8 +69,8 @@ private:
        FIFO::Ptr m_SendQueue;
        FIFO::Ptr m_RecvQueue;
 
-       virtual void ReadableEventHandler(const EventArgs& ea);
-       virtual void WritableEventHandler(const EventArgs& ea);
+       virtual void ReadableEventHandler(void);
+       virtual void WritableEventHandler(void);
 };
 
 /**
index e50343ff45a265c3ed3eb64ba6ec81d6d3d49517..876bb91688321114f7046343cd83c7908cef45a7 100644 (file)
@@ -56,7 +56,7 @@ void TcpServer::Start(void)
 {
        TcpSocket::Start();
 
-       OnReadable.connect(boost::bind(&TcpServer::ReadableEventHandler, this, _1));
+       OnReadable.connect(boost::bind(&TcpServer::ReadableEventHandler, this));
 }
 
 /**
@@ -64,9 +64,7 @@ void TcpServer::Start(void)
  */
 void TcpServer::Listen(void)
 {
-       int rc = listen(GetFD(), SOMAXCONN);
-
-       if (rc < 0) {
+       if (listen(GetFD(), SOMAXCONN) < 0) {
                HandleSocketError(SocketException(
                    "listen() failed", GetError()));
                return;
@@ -76,11 +74,8 @@ void TcpServer::Listen(void)
 /**
  * Accepts a new client and creates a new client object for it
  * using the client factory function.
- *
- * @param - Event arguments.
- * @returns 0
  */
-int TcpServer::ReadableEventHandler(const EventArgs&)
+void TcpServer::ReadableEventHandler(void)
 {
        int fd;
        sockaddr_storage addr;
@@ -91,17 +86,14 @@ int TcpServer::ReadableEventHandler(const EventArgs&)
        if (fd < 0) {
                HandleSocketError(SocketException(
                    "accept() failed", GetError()));
-               return 0;
+               return;
        }
 
-       NewClientEventArgs nea;
-       nea.Source = shared_from_this();
-       nea.Client = static_pointer_cast<TcpSocket>(m_ClientFactory());
-       nea.Client->SetFD(fd);
-       nea.Client->Start();
-       OnNewClient(nea);
+       TcpClient::Ptr client = m_ClientFactory();
+       client->SetFD(fd);
+       client->Start();
 
-       return 0;
+       OnNewClient(shared_from_this(), client);
 }
 
 /**
index 260effcd4a2e8e4d0cf89cdc9f94f6c7aee146ce..62b59d65f9c308c0f409b5d7f35a09ad835f8aff 100644 (file)
 namespace icinga
 {
 
-/**
- * Event arguments for the "new client" event.
- *
- * @ingroup base
- */
-struct I2_BASE_API NewClientEventArgs : public EventArgs
-{
-       TcpSocket::Ptr Client; /**< The new client object. */
-};
-
 /**
  * A TCP server that listens on a TCP port and accepts incoming
  * client connections.
@@ -54,12 +44,12 @@ public:
 
        void Listen(void);
 
-       boost::signal<void (const NewClientEventArgs&)> OnNewClient;
+       boost::signal<void (const Object::Ptr&, const TcpClient::Ptr&)> OnNewClient;
 
        virtual bool WantsToRead(void) const;
 
 private:
-       int ReadableEventHandler(const EventArgs& ea);
+       void ReadableEventHandler(void);
 
        function<TcpClient::Ptr()> m_ClientFactory;
 };
index bf212786e79b4b20606758291e0c6f2bedea326b..9d404af34610a5a71ef2915f8180c00552f9e028 100644 (file)
@@ -100,9 +100,7 @@ void Timer::CallExpiredTimers(void)
  */
 void Timer::Call(void)
 {
-       EventArgs tea;
-       tea.Source = shared_from_this();
-       OnTimerExpired(tea);
+       OnTimerExpired(shared_from_this());
 }
 
 /**
index 5f119e11a4f7471ddca4c3e35067d9e90bf72153..c9ea4db0b8170ee0b6dbe86635669c3dd3ce2e76 100644 (file)
@@ -52,7 +52,7 @@ public:
 
        void Reschedule(time_t next);
 
-       boost::signal<void(const EventArgs&)> OnTimerExpired;
+       boost::signal<void(const Object::Ptr&)> OnTimerExpired;
 
 private:
        time_t m_Interval; /**< The interval of the timer. */
index 886b5ea6cd771b49729ab8c78381cd3923654e4a..065730745dae69eaa46548ec51aadda2e80a0e30 100644 (file)
@@ -105,10 +105,8 @@ void TlsClient::Start(void)
 
 /**
  * Processes data that is available for this socket.
- *
- * @param - Event arguments.
  */
-void TlsClient::ReadableEventHandler(const EventArgs&)
+void TlsClient::ReadableEventHandler(void)
 {
        int rc;
 
@@ -138,17 +136,13 @@ void TlsClient::ReadableEventHandler(const EventArgs&)
 
        GetRecvQueue()->Write(NULL, rc);
 
-       EventArgs dea;
-       dea.Source = shared_from_this();
-       OnDataAvailable(dea);
+       OnDataAvailable(shared_from_this());
 }
 
 /**
  * Processes data that can be written for this socket.
- *
- * @param - Event arguments.
  */
-void TlsClient::WritableEventHandler(const EventArgs&)
+void TlsClient::WritableEventHandler(void)
 {
        int rc;
 
@@ -248,12 +242,9 @@ int TlsClient::SSLVerifyCertificate(int ok, X509_STORE_CTX *x509Context)
        if (client == NULL)
                return 0;
 
-       VerifyCertificateEventArgs vcea;
-       vcea.Source = client->shared_from_this();
-       vcea.ValidCertificate = (ok != 0);
-       vcea.Context = x509Context;
-       vcea.Certificate = shared_ptr<X509>(x509Context->cert, &TlsClient::NullCertificateDeleter);
-       client->OnVerifyCertificate(vcea);
+       bool valid = false;
+       shared_ptr<X509> x509Certificate = shared_ptr<X509>(x509Context->cert, &TlsClient::NullCertificateDeleter);
+       client->OnVerifyCertificate(client->shared_from_this(), valid, x509Context, x509Certificate);
 
-       return (int)vcea.ValidCertificate;
+       return valid ? 1 : 0;
 }
index 2773c0c96961d16476b39852cd0000e891c7d80a..0968fbff0bad70720b4143e95e2113b84457702a 100644 (file)
 namespace icinga
 {
 
-/**
- * Event arguments for the "SSL certificate verification" event.
- *
- * @ingroup base
- */
-struct I2_BASE_API VerifyCertificateEventArgs : public EventArgs
-{
-       bool ValidCertificate; /**< Whether the certificate is valid, can be
-                                   changed by the event handler. */
-       X509_STORE_CTX *Context; /**< The X509 store context. */
-       shared_ptr<X509> Certificate; /**< The X509 certificate that should
-                                          ve verified. */
-};
-
 /**
  * A TLS client connection.
  *
@@ -55,7 +41,7 @@ public:
        virtual bool WantsToRead(void) const;
        virtual bool WantsToWrite(void) const;
 
-       boost::signal<void (const VerifyCertificateEventArgs&)> OnVerifyCertificate;
+       boost::signal<void (const Object::Ptr&, bool&, X509_STORE_CTX *, const shared_ptr<X509>&)> OnVerifyCertificate;
 
 protected:
        void HandleSSLError(void);
@@ -70,8 +56,8 @@ private:
        static int m_SSLIndex;
        static bool m_SSLIndexInitialized;
 
-       virtual void ReadableEventHandler(const EventArgs& ea);
-       virtual void WritableEventHandler(const EventArgs& ea);
+       virtual void ReadableEventHandler(void);
+       virtual void WritableEventHandler(void);
 
        virtual void CloseInternal(bool from_dtor);
 
diff --git a/components/checker/checker.vcxproj.filters b/components/checker/checker.vcxproj.filters
new file mode 100644 (file)
index 0000000..7e4bd06
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Quelldateien">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Headerdateien">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="i2-checker.h">
+      <Filter>Headerdateien</Filter>
+    </ClInclude>
+    <ClInclude Include="checkercomponent.h">
+      <Filter>Headerdateien</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="checkercomponent.cpp">
+      <Filter>Quelldateien</Filter>
+    </ClCompile>
+  </ItemGroup>
+</Project>
\ No newline at end of file
index 79ef54ae89c5ef7f189974bde7276a673fbf85b7..97b8f4883283f11b7a805248ef1dedb8c2656f3e 100644 (file)
@@ -30,11 +30,11 @@ void CheckerComponent::Start(void)
 {
        m_CheckerEndpoint = boost::make_shared<VirtualEndpoint>();
        m_CheckerEndpoint->RegisterTopicHandler("checker::AssignService",
-               boost::bind(&CheckerComponent::AssignServiceRequestHandler, this, _1));
+               boost::bind(&CheckerComponent::AssignServiceRequestHandler, this, _2, _3));
        m_CheckerEndpoint->RegisterTopicHandler("checker::RevokeService",
-               boost::bind(&CheckerComponent::RevokeServiceRequestHandler, this, _1));
+               boost::bind(&CheckerComponent::RevokeServiceRequestHandler, this, _2, _3));
        m_CheckerEndpoint->RegisterTopicHandler("checker::ClearServices",
-               boost::bind(&CheckerComponent::ClearServicesRequestHandler, this, _1));
+               boost::bind(&CheckerComponent::ClearServicesRequestHandler, this, _2, _3));
        m_CheckerEndpoint->RegisterPublication("checker::CheckResult");
        GetEndpointManager()->RegisterEndpoint(m_CheckerEndpoint);
 
@@ -90,10 +90,10 @@ void CheckerComponent::CheckTimerHandler(void)
        m_CheckTimer->SetInterval(service.GetNextCheck() - now);
 }
 
-void CheckerComponent::AssignServiceRequestHandler(const NewRequestEventArgs& nrea)
+void CheckerComponent::AssignServiceRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
 {
        MessagePart params;
-       if (!nrea.Request.GetParams(&params))
+       if (!request.GetParams(&params))
                return;
 
        MessagePart serviceMsg;
@@ -110,20 +110,20 @@ void CheckerComponent::AssignServiceRequestHandler(const NewRequestEventArgs& nr
        m_CheckTimer->Reschedule(0);
 
        string id;
-       if (nrea.Request.GetID(&id)) {
+       if (request.GetID(&id)) {
                ResponseMessage rm;
                rm.SetID(id);
 
                MessagePart result;
                rm.SetResult(result);
-               GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, nrea.Sender, rm);
+               GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, sender, rm);
        }
 }
 
-void CheckerComponent::RevokeServiceRequestHandler(const NewRequestEventArgs& nrea)
+void CheckerComponent::RevokeServiceRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
 {
        MessagePart params;
-       if (!nrea.Request.GetParams(&params))
+       if (!request.GetParams(&params))
                return;
 
        string name;
@@ -148,29 +148,29 @@ void CheckerComponent::RevokeServiceRequestHandler(const NewRequestEventArgs& nr
        Application::Log(LogInformation, "checker", "Revoked delegation for service '" + name + "'");
 
        string id;
-       if (nrea.Request.GetID(&id)) {
+       if (request.GetID(&id)) {
                ResponseMessage rm;
                rm.SetID(id);
 
                MessagePart result;
                rm.SetResult(result);
-               GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, nrea.Sender, rm);
+               GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, sender, rm);
        }
 }
 
-void CheckerComponent::ClearServicesRequestHandler(const NewRequestEventArgs& nrea)
+void CheckerComponent::ClearServicesRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
 {
        Application::Log(LogInformation, "checker", "Clearing service delegations.");
        m_Services = ServiceQueue();
 
        string id;
-       if (nrea.Request.GetID(&id)) {
+       if (request.GetID(&id)) {
                ResponseMessage rm;
                rm.SetID(id);
 
                MessagePart result;
                rm.SetResult(result);
-               GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, nrea.Sender, rm);
+               GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, sender, rm);
        }
 }
 
index 7dca5ccce53c06c6ab873e13d7e424278f0190b1..080a50eb88b275fc7441e16f9d3ac24735f4f475 100644 (file)
@@ -54,9 +54,9 @@ private:
 
        void CheckTimerHandler(void);
 
-       void AssignServiceRequestHandler(const NewRequestEventArgs& nrea);
-       void RevokeServiceRequestHandler(const NewRequestEventArgs& nrea);
-       void ClearServicesRequestHandler(const NewRequestEventArgs& nrea);
+       void AssignServiceRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
+       void RevokeServiceRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
+       void ClearServicesRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
 };
 
 }
index 38ae78d31ea68628901b545d3d8e28e47e4695f7..a3ba0e0e33bacd08286a299fd1fa9d82befe236e 100644 (file)
@@ -35,23 +35,23 @@ void ConfigRpcComponent::Start(void)
        long configSource;
        if (GetConfig()->GetProperty("configSource", &configSource) && configSource != 0) {
                m_ConfigRpcEndpoint->RegisterTopicHandler("config::FetchObjects",
-                   boost::bind(&ConfigRpcComponent::FetchObjectsHandler, this, _1));
+                   boost::bind(&ConfigRpcComponent::FetchObjectsHandler, this, _2));
 
-               ConfigObject::GetAllObjects()->OnObjectAdded.connect(boost::bind(&ConfigRpcComponent::LocalObjectCommittedHandler, this, _1));
-               ConfigObject::GetAllObjects()->OnObjectCommitted.connect(boost::bind(&ConfigRpcComponent::LocalObjectCommittedHandler, this, _1));
-               ConfigObject::GetAllObjects()->OnObjectRemoved.connect(boost::bind(&ConfigRpcComponent::LocalObjectRemovedHandler, this, _1));
+               ConfigObject::GetAllObjects()->OnObjectAdded.connect(boost::bind(&ConfigRpcComponent::LocalObjectCommittedHandler, this, _2));
+               ConfigObject::GetAllObjects()->OnObjectCommitted.connect(boost::bind(&ConfigRpcComponent::LocalObjectCommittedHandler, this, _2));
+               ConfigObject::GetAllObjects()->OnObjectRemoved.connect(boost::bind(&ConfigRpcComponent::LocalObjectRemovedHandler, this, _2));
 
                m_ConfigRpcEndpoint->RegisterPublication("config::ObjectCommitted");
                m_ConfigRpcEndpoint->RegisterPublication("config::ObjectRemoved");
        }
 
-       endpointManager->OnNewEndpoint.connect(boost::bind(&ConfigRpcComponent::NewEndpointHandler, this, _1));
+       endpointManager->OnNewEndpoint.connect(boost::bind(&ConfigRpcComponent::NewEndpointHandler, this, _2));
 
        m_ConfigRpcEndpoint->RegisterPublication("config::FetchObjects");
        m_ConfigRpcEndpoint->RegisterTopicHandler("config::ObjectCommitted",
-           boost::bind(&ConfigRpcComponent::RemoteObjectCommittedHandler, this, _1));
+           boost::bind(&ConfigRpcComponent::RemoteObjectCommittedHandler, this, _3));
        m_ConfigRpcEndpoint->RegisterTopicHandler("config::ObjectRemoved",
-           boost::bind(&ConfigRpcComponent::RemoteObjectRemovedHandler, this, _1));
+           boost::bind(&ConfigRpcComponent::RemoteObjectRemovedHandler, this, _3));
 
        endpointManager->RegisterEndpoint(m_ConfigRpcEndpoint);
 }
@@ -64,17 +64,17 @@ void ConfigRpcComponent::Stop(void)
                mgr->UnregisterEndpoint(m_ConfigRpcEndpoint);
 }
 
-void ConfigRpcComponent::NewEndpointHandler(const NewEndpointEventArgs& ea)
+void ConfigRpcComponent::NewEndpointHandler(const Endpoint::Ptr& endpoint)
 {
-       ea.Endpoint->OnSessionEstablished.connect(boost::bind(&ConfigRpcComponent::SessionEstablishedHandler, this, _1));
+       endpoint->OnSessionEstablished.connect(boost::bind(&ConfigRpcComponent::SessionEstablishedHandler, this, _1));
 }
 
-void ConfigRpcComponent::SessionEstablishedHandler(const EventArgs& ea)
+void ConfigRpcComponent::SessionEstablishedHandler(const Object::Ptr& source)
 {
        RequestMessage request;
        request.SetMethod("config::FetchObjects");
 
-       Endpoint::Ptr endpoint = static_pointer_cast<Endpoint>(ea.Source);
+       Endpoint::Ptr endpoint = static_pointer_cast<Endpoint>(source);
        GetEndpointManager()->SendUnicastMessage(m_ConfigRpcEndpoint, endpoint, request);
 }
 
@@ -100,9 +100,8 @@ bool ConfigRpcComponent::ShouldReplicateObject(const ConfigObject::Ptr& object)
        return (!object->IsLocal());
 }
 
-void ConfigRpcComponent::FetchObjectsHandler(const NewRequestEventArgs& ea)
+void ConfigRpcComponent::FetchObjectsHandler(const Endpoint::Ptr& sender)
 {
-       Endpoint::Ptr client = ea.Sender;
        ConfigObject::Set::Ptr allObjects = ConfigObject::GetAllObjects();
 
        for (ConfigObject::Set::Iterator ci = allObjects->Begin(); ci != allObjects->End(); ci++) {
@@ -113,14 +112,12 @@ void ConfigRpcComponent::FetchObjectsHandler(const NewRequestEventArgs& ea)
 
                RequestMessage request = MakeObjectMessage(object, "config::ObjectCreated", true);
 
-               GetEndpointManager()->SendUnicastMessage(m_ConfigRpcEndpoint, client, request);
+               GetEndpointManager()->SendUnicastMessage(m_ConfigRpcEndpoint, sender, request);
        }
 }
 
-void ConfigRpcComponent::LocalObjectCommittedHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
+void ConfigRpcComponent::LocalObjectCommittedHandler(const ConfigObject::Ptr& object)
 {
-       ConfigObject::Ptr object = ea.Target;
-       
        if (!ShouldReplicateObject(object))
                return;
 
@@ -128,10 +125,8 @@ void ConfigRpcComponent::LocalObjectCommittedHandler(const ObjectSetEventArgs<Co
            MakeObjectMessage(object, "config::ObjectCreated", true));
 }
 
-void ConfigRpcComponent::LocalObjectRemovedHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
+void ConfigRpcComponent::LocalObjectRemovedHandler(const ConfigObject::Ptr& object)
 {
-       ConfigObject::Ptr object = ea.Target;
-       
        if (!ShouldReplicateObject(object))
                return;
 
@@ -139,12 +134,10 @@ void ConfigRpcComponent::LocalObjectRemovedHandler(const ObjectSetEventArgs<Conf
            MakeObjectMessage(object, "config::ObjectRemoved", false));
 }
 
-void ConfigRpcComponent::RemoteObjectCommittedHandler(const NewRequestEventArgs& ea)
+void ConfigRpcComponent::RemoteObjectCommittedHandler(const RequestMessage& request)
 {
-       RequestMessage message = ea.Request;
-
        MessagePart params;
-       if (!message.GetParams(&params))
+       if (!request.GetParams(&params))
                return;
 
        string name;
@@ -169,12 +162,10 @@ void ConfigRpcComponent::RemoteObjectCommittedHandler(const NewRequestEventArgs&
        object->Commit();
 }
 
-void ConfigRpcComponent::RemoteObjectRemovedHandler(const NewRequestEventArgs& ea)
+void ConfigRpcComponent::RemoteObjectRemovedHandler(const RequestMessage& request)
 {
-       RequestMessage message = ea.Request;
-       
        MessagePart params;
-       if (!message.GetParams(&params))
+       if (!request.GetParams(&params))
                return;
 
        string name;
index 35d9fd875fd479ef66e27d023c61a07fbdd315cb..696f6e01c085777a6166da96891ce0c25a60a083 100644 (file)
@@ -36,15 +36,15 @@ public:
 private:
        VirtualEndpoint::Ptr m_ConfigRpcEndpoint;
 
-       void NewEndpointHandler(const NewEndpointEventArgs& ea);
-       void SessionEstablishedHandler(const EventArgs& ea);
+       void NewEndpointHandler(const Endpoint::Ptr& endpoint);
+       void SessionEstablishedHandler(const Object::Ptr& source);
 
-       void LocalObjectCommittedHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
-       void LocalObjectRemovedHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
+       void LocalObjectCommittedHandler(const ConfigObject::Ptr& object);
+       void LocalObjectRemovedHandler(const ConfigObject::Ptr& object);
 
-       void FetchObjectsHandler(const NewRequestEventArgs& ea);
-       void RemoteObjectCommittedHandler(const NewRequestEventArgs& ea);
-       void RemoteObjectRemovedHandler(const NewRequestEventArgs& ea);
+       void FetchObjectsHandler(const Endpoint::Ptr& sender);
+       void RemoteObjectCommittedHandler(const RequestMessage& request);
+       void RemoteObjectRemovedHandler(const RequestMessage& request);
 
        static RequestMessage MakeObjectMessage(const ConfigObject::Ptr& object,
            string method, bool includeProperties);
diff --git a/components/delegation/delegation.vcxproj.filters b/components/delegation/delegation.vcxproj.filters
new file mode 100644 (file)
index 0000000..3988c4e
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Quelldateien">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Headerdateien">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="delegationcomponent.cpp">
+      <Filter>Quelldateien</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="delegationcomponent.h">
+      <Filter>Headerdateien</Filter>
+    </ClInclude>
+    <ClInclude Include="i2-delegation.h">
+      <Filter>Headerdateien</Filter>
+    </ClInclude>
+  </ItemGroup>
+</Project>
\ No newline at end of file
index 91cf711568a31b808ff4bb911fe17658b69a7e7a..0a27018c3d1bb26bb8de9d7660a616bf62b9993d 100644 (file)
@@ -29,9 +29,9 @@ string DelegationComponent::GetName(void) const
 void DelegationComponent::Start(void)
 {
        m_AllServices = boost::make_shared<ConfigObject::Set>(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("service"));
-       m_AllServices->OnObjectAdded.connect(boost::bind(&DelegationComponent::NewServiceHandler, this, _1));
-       m_AllServices->OnObjectCommitted.connect(boost::bind(&DelegationComponent::NewServiceHandler, this, _1));
-       m_AllServices->OnObjectRemoved.connect(boost::bind(&DelegationComponent::RemovedServiceHandler, this, _1));
+       m_AllServices->OnObjectAdded.connect(boost::bind(&DelegationComponent::NewServiceHandler, this, _2));
+       m_AllServices->OnObjectCommitted.connect(boost::bind(&DelegationComponent::NewServiceHandler, this, _2));
+       m_AllServices->OnObjectRemoved.connect(boost::bind(&DelegationComponent::RemovedServiceHandler, this, _2));
        m_AllServices->Start();
 
        m_DelegationTimer = boost::make_shared<Timer>();
@@ -53,14 +53,14 @@ void DelegationComponent::Stop(void)
                mgr->UnregisterEndpoint(m_DelegationEndpoint);
 }
 
-void DelegationComponent::NewServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
+void DelegationComponent::NewServiceHandler(const ConfigObject::Ptr& object)
 {
-       AssignService(ea.Target);
+       AssignService(object);
 }
 
-void DelegationComponent::RemovedServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
+void DelegationComponent::RemovedServiceHandler(const ConfigObject::Ptr& object)
 {
-       RevokeService(ea.Target);
+       RevokeService(object);
 }
 
 void DelegationComponent::AssignService(const ConfigObject::Ptr& service)
@@ -75,15 +75,15 @@ void DelegationComponent::AssignService(const ConfigObject::Ptr& service)
        Application::Log(LogInformation, "delegation", "Trying to delegate service '" + service->GetName() + "'");
 
        GetEndpointManager()->SendAPIMessage(m_DelegationEndpoint, request,
-           boost::bind(&DelegationComponent::AssignServiceResponseHandler, this, service, _1));
+           boost::bind(&DelegationComponent::AssignServiceResponseHandler, this, service, _2, _5));
 }
 
-void DelegationComponent::AssignServiceResponseHandler(const ConfigObject::Ptr& service, const NewResponseEventArgs& nrea)
+void DelegationComponent::AssignServiceResponseHandler(const ConfigObject::Ptr& service, const Endpoint::Ptr& sender, bool timedOut)
 {
-       if (nrea.TimedOut) {
+       if (timedOut) {
                Application::Log(LogInformation, "delegation", "Service delegation for service '" + service->GetName() + "' timed out.");
        } else {
-               service->SetTag("checker", nrea.Sender->GetIdentity());
+               service->SetTag("checker", sender->GetIdentity());
                Application::Log(LogInformation, "delegation", "Service delegation for service '" + service->GetName() + "' was successful.");
        }
 }
@@ -93,7 +93,7 @@ void DelegationComponent::RevokeService(const ConfigObject::Ptr& service)
 
 }
 
-void DelegationComponent::RevokeServiceResponseHandler(const NewResponseEventArgs& nrea)
+void DelegationComponent::RevokeServiceResponseHandler(const ConfigObject::Ptr& service, const Endpoint::Ptr& sender, bool timedOut)
 {
 }
 
index db80707016d94d17c3bfe4168bc494894b46d560..d665fac73827fe4263d34befb3776878ac5b476e 100644 (file)
@@ -38,11 +38,11 @@ private:
        ConfigObject::Set::Ptr m_AllServices;
        Timer::Ptr m_DelegationTimer;
 
-       void NewServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
-       void RemovedServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
+       void NewServiceHandler(const ConfigObject::Ptr& object);
+       void RemovedServiceHandler(const ConfigObject::Ptr& object);
 
-       void AssignServiceResponseHandler(const ConfigObject::Ptr& service, const NewResponseEventArgs& nrea);
-       void RevokeServiceResponseHandler(const NewResponseEventArgs& nrea);
+       void AssignServiceResponseHandler(const ConfigObject::Ptr& service, const Endpoint::Ptr& sender, bool timedOut);
+       void RevokeServiceResponseHandler(const ConfigObject::Ptr& service, const Endpoint::Ptr& sender, bool timedOut);
 
        void DelegationTimerHandler(void);
 
index f08272ec21740eb23dc0c925fc8ef8d31bd3c495..0fc00669246655db93040ce17a7b1877d7adc34c 100644 (file)
@@ -38,7 +38,7 @@ void DemoComponent::Start(void)
 {
        m_DemoEndpoint = boost::make_shared<VirtualEndpoint>();
        m_DemoEndpoint->RegisterTopicHandler("demo::HelloWorld",
-           boost::bind(&DemoComponent::HelloWorldRequestHandler, this, _1));
+           boost::bind(&DemoComponent::HelloWorldRequestHandler, this, _2, _3));
        m_DemoEndpoint->RegisterPublication("demo::HelloWorld");
        GetEndpointManager()->RegisterEndpoint(m_DemoEndpoint);
 
@@ -80,9 +80,9 @@ void DemoComponent::DemoTimerHandler(void)
 /**
  * Processes demo::HelloWorld messages.
  */
-void DemoComponent::HelloWorldRequestHandler(const NewRequestEventArgs& nrea)
+void DemoComponent::HelloWorldRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
 {
-       Application::Log(LogInformation, "demo", "Got 'hello world' from address=" + nrea.Sender->GetAddress() + ", identity=" + nrea.Sender->GetIdentity());
+       Application::Log(LogInformation, "demo", "Got 'hello world' from address=" + sender->GetAddress() + ", identity=" + sender->GetIdentity());
 }
 
 EXPORT_COMPONENT(demo, DemoComponent);
index e6341558f9c4232d4e101728b61daf2297da7259..92176fdc97b76ef2b778b06daa21432792b4e11b 100644 (file)
@@ -38,7 +38,7 @@ private:
        VirtualEndpoint::Ptr m_DemoEndpoint;
 
        void DemoTimerHandler(void);
-       void HelloWorldRequestHandler(const NewRequestEventArgs& nrea);
+       void HelloWorldRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
 };
 
 }
index 1bf293c6b28e81d33fbef566f0221a83822dfea3..78df88da7469287c59ad0cd18304ccb64c8a5f55 100644 (file)
@@ -40,17 +40,17 @@ void DiscoveryComponent::Start(void)
 
        m_DiscoveryEndpoint->RegisterPublication("discovery::RegisterComponent");
        m_DiscoveryEndpoint->RegisterTopicHandler("discovery::RegisterComponent",
-               boost::bind(&DiscoveryComponent::RegisterComponentMessageHandler, this, _1));
+               boost::bind(&DiscoveryComponent::RegisterComponentMessageHandler, this, _2, _3));
 
        m_DiscoveryEndpoint->RegisterPublication("discovery::NewComponent");
        m_DiscoveryEndpoint->RegisterTopicHandler("discovery::NewComponent",
-               boost::bind(&DiscoveryComponent::NewComponentMessageHandler, this, _1));
+               boost::bind(&DiscoveryComponent::NewComponentMessageHandler, this, _3));
 
        m_DiscoveryEndpoint->RegisterTopicHandler("discovery::Welcome",
-               boost::bind(&DiscoveryComponent::WelcomeMessageHandler, this, _1));
+               boost::bind(&DiscoveryComponent::WelcomeMessageHandler, this, _2, _3));
 
-       GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::NewEndpointHandler, this, _1));
-       GetEndpointManager()->OnNewEndpoint.connect(boost::bind(&DiscoveryComponent::NewEndpointHandler, this, _1));
+       GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::NewEndpointHandler, this, _2));
+       GetEndpointManager()->OnNewEndpoint.connect(boost::bind(&DiscoveryComponent::NewEndpointHandler, this, _2));
 
        GetEndpointManager()->RegisterEndpoint(m_DiscoveryEndpoint);
 
@@ -79,40 +79,39 @@ void DiscoveryComponent::Stop(void)
  * Checks whether the specified endpoint is already connected
  * and disconnects older endpoints.
  *
- * @param endpoint The endpoint that is to be checked.
- * @param neea Event arguments for another endpoint.
+ * @param self The endpoint that is to be checked.
+ * @param other The other endpoint.
  */
-void DiscoveryComponent::CheckExistingEndpoint(Endpoint::Ptr endpoint, const NewEndpointEventArgs& neea)
+void DiscoveryComponent::CheckExistingEndpoint(const Endpoint::Ptr& self, const Endpoint::Ptr& other)
 {
-       if (endpoint == neea.Endpoint)
+       if (self == other)
                return;
 
-       if (!neea.Endpoint->IsConnected())
+       if (!other->IsConnected())
                return;
 
-       if (endpoint->GetIdentity() == neea.Endpoint->GetIdentity()) {
-               Application::Log(LogWarning, "discovery", "Detected duplicate identity:" + endpoint->GetIdentity() + " - Disconnecting old endpoint.");
+       if (self->GetIdentity() == other->GetIdentity()) {
+               Application::Log(LogWarning, "discovery", "Detected duplicate identity:" + other->GetIdentity() + " - Disconnecting old endpoint.");
 
-               neea.Endpoint->Stop();
-               GetEndpointManager()->UnregisterEndpoint(neea.Endpoint);
+               other->Stop();
+               GetEndpointManager()->UnregisterEndpoint(other);
        }
 }
 
 /**
  * Registers handlers for new endpoints.
  *
- * @param neea Event arguments for the new endpoint.
- * @returns 0
+ * @param endpoint The endpoint.
  */
-void DiscoveryComponent::NewEndpointHandler(const NewEndpointEventArgs& neea)
+void DiscoveryComponent::NewEndpointHandler(const Endpoint::Ptr& endpoint)
 {
-       neea.Endpoint->OnIdentityChanged.connect(boost::bind(&DiscoveryComponent::NewIdentityHandler, this, _1));
+       endpoint->OnIdentityChanged.connect(boost::bind(&DiscoveryComponent::NewIdentityHandler, this, _1));
 
        /* accept discovery::RegisterComponent messages from any endpoint */
-       neea.Endpoint->RegisterPublication("discovery::RegisterComponent");
+       endpoint->RegisterPublication("discovery::RegisterComponent");
 
        /* accept discovery::Welcome messages from any endpoint */
-       neea.Endpoint->RegisterPublication("discovery::Welcome");
+       endpoint->RegisterPublication("discovery::Welcome");
 }
 
 /**
@@ -122,17 +121,15 @@ void DiscoveryComponent::NewEndpointHandler(const NewEndpointEventArgs& neea)
  * @param info Component information object.
  * @return 0
  */
-void DiscoveryComponent::DiscoveryEndpointHandler(const NewEndpointEventArgs& neea, ComponentDiscoveryInfo::Ptr info) const
+void DiscoveryComponent::DiscoveryEndpointHandler(const Endpoint::Ptr& endpoint, const ComponentDiscoveryInfo::Ptr& info) const
 {
        Endpoint::ConstTopicIterator i;
 
-       for (i = neea.Endpoint->BeginSubscriptions(); i != neea.Endpoint->EndSubscriptions(); i++) {
+       for (i = endpoint->BeginSubscriptions(); i != endpoint->EndSubscriptions(); i++)
                info->Subscriptions.insert(*i);
-       }
 
-       for (i = neea.Endpoint->BeginPublications(); i != neea.Endpoint->EndPublications(); i++) {
+       for (i = endpoint->BeginPublications(); i != endpoint->EndPublications(); i++)
                info->Publications.insert(*i);
-       }
 }
 
 /**
@@ -147,7 +144,7 @@ bool DiscoveryComponent::GetComponentDiscoveryInfo(string component, ComponentDi
        if (component == GetEndpointManager()->GetIdentity()) {
                /* Build fake discovery info for ourselves */
                *info = boost::make_shared<ComponentDiscoveryInfo>();
-               GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::DiscoveryEndpointHandler, this, _1, *info));
+               GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::DiscoveryEndpointHandler, this, _2, *info));
                
                (*info)->LastSeen = 0;
                (*info)->Node = GetIcingaApplication()->GetNode();
@@ -173,9 +170,9 @@ bool DiscoveryComponent::GetComponentDiscoveryInfo(string component, ComponentDi
  * @param ea Event arguments for the component.
  * @returns 0
  */
-void DiscoveryComponent::NewIdentityHandler(const EventArgs& ea)
+void DiscoveryComponent::NewIdentityHandler(const Object::Ptr& source)
 {
-       Endpoint::Ptr endpoint = static_pointer_cast<Endpoint>(ea.Source);
+       Endpoint::Ptr endpoint = static_pointer_cast<Endpoint>(source);
        string identity = endpoint->GetIdentity();
 
        if (identity == GetEndpointManager()->GetIdentity()) {
@@ -187,7 +184,7 @@ void DiscoveryComponent::NewIdentityHandler(const EventArgs& ea)
                return;
        }
 
-       GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::CheckExistingEndpoint, this, endpoint, _1));
+       GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::CheckExistingEndpoint, this, endpoint, _2));
 
        // we assume the other component _always_ wants
        // discovery::RegisterComponent messages from us
@@ -241,20 +238,15 @@ void DiscoveryComponent::NewIdentityHandler(const EventArgs& ea)
  * @param nrea Event arguments for the request.
  * @returns 0
  */
-void DiscoveryComponent::WelcomeMessageHandler(const NewRequestEventArgs& nrea)
+void DiscoveryComponent::WelcomeMessageHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
 {
-       Endpoint::Ptr endpoint = nrea.Sender;
-
-       if (endpoint->HasReceivedWelcome())
+       if (sender->HasReceivedWelcome())
                return;
 
-       endpoint->SetReceivedWelcome(true);
+       sender->SetReceivedWelcome(true);
 
-       if (endpoint->HasSentWelcome()) {
-               EventArgs ea;
-               ea.Source = endpoint;
-               endpoint->OnSessionEstablished(ea);
-       }
+       if (sender->HasSentWelcome())
+               sender->OnSessionEstablished(sender);
 }
 
 /**
@@ -264,7 +256,7 @@ void DiscoveryComponent::WelcomeMessageHandler(const NewRequestEventArgs& nrea)
  *
  * @param endpoint The endpoint to set up.
  */
-void DiscoveryComponent::FinishDiscoverySetup(Endpoint::Ptr endpoint)
+void DiscoveryComponent::FinishDiscoverySetup(const Endpoint::Ptr& endpoint)
 {
        if (endpoint->HasSentWelcome())
                return;
@@ -278,11 +270,8 @@ void DiscoveryComponent::FinishDiscoverySetup(Endpoint::Ptr endpoint)
 
        endpoint->SetSentWelcome(true);
 
-       if (endpoint->HasReceivedWelcome()) {
-               EventArgs ea;
-               ea.Source = endpoint;
-               endpoint->OnSessionEstablished(ea);
-       }
+       if (endpoint->HasReceivedWelcome())
+               endpoint->OnSessionEstablished(endpoint);
 }
 
 /**
@@ -293,7 +282,7 @@ void DiscoveryComponent::FinishDiscoverySetup(Endpoint::Ptr endpoint)
  * @param identity The identity of the component for which a message should be sent.
  * @param recipient The recipient of the message. A multicast message is sent if this parameter is empty.
  */
-void DiscoveryComponent::SendDiscoveryMessage(string method, string identity, Endpoint::Ptr recipient)
+void DiscoveryComponent::SendDiscoveryMessage(const string& method, const string& identity, const Endpoint::Ptr& recipient)
 {
        RequestMessage request;
        request.SetMethod(method);
@@ -332,7 +321,7 @@ void DiscoveryComponent::SendDiscoveryMessage(string method, string identity, En
                GetEndpointManager()->SendMulticastMessage(m_DiscoveryEndpoint, request);
 }
 
-bool DiscoveryComponent::HasMessagePermission(Dictionary::Ptr roles, string messageType, string message)
+bool DiscoveryComponent::HasMessagePermission(const Dictionary::Ptr& roles, const string& messageType, const string& message)
 {
        if (!roles)
                return false;
@@ -367,7 +356,7 @@ bool DiscoveryComponent::HasMessagePermission(Dictionary::Ptr roles, string mess
  * @param message The discovery message.
  * @param trusted Whether the message comes from a trusted source (i.e. a broker).
  */
-void DiscoveryComponent::ProcessDiscoveryMessage(string identity, DiscoveryMessage message, bool trusted)
+void DiscoveryComponent::ProcessDiscoveryMessage(const string& identity, const DiscoveryMessage& message, bool trusted)
 {
        /* ignore discovery messages that are about ourselves */
        if (identity == GetEndpointManager()->GetIdentity())
@@ -438,10 +427,10 @@ void DiscoveryComponent::ProcessDiscoveryMessage(string identity, DiscoveryMessa
  *
  * @param nrea Event arguments for the request.
  */
-void DiscoveryComponent::NewComponentMessageHandler(const NewRequestEventArgs& nrea)
+void DiscoveryComponent::NewComponentMessageHandler(const RequestMessage& request)
 {
        DiscoveryMessage message;
-       nrea.Request.GetParams(&message);
+       request.GetParams(&message);
 
        string identity;
        if (!message.GetIdentity(&identity))
@@ -455,11 +444,11 @@ void DiscoveryComponent::NewComponentMessageHandler(const NewRequestEventArgs& n
  *
  * @param nrea Event arguments for the request.
  */
-void DiscoveryComponent::RegisterComponentMessageHandler(const NewRequestEventArgs& nrea)
+void DiscoveryComponent::RegisterComponentMessageHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
 {
        DiscoveryMessage message;
-       nrea.Request.GetParams(&message);
-       ProcessDiscoveryMessage(nrea.Sender->GetIdentity(), message, false);
+       request.GetParams(&message);
+       ProcessDiscoveryMessage(sender->GetIdentity(), message, false);
 }
 
 /**
index 3e3ec83a9034f4ba0633824d94a97b4768259e0c..39172f96ff869d31b60d32917a3281e487db5fac 100644 (file)
@@ -56,27 +56,27 @@ private:
        map<string, ComponentDiscoveryInfo::Ptr> m_Components;
        Timer::Ptr m_DiscoveryTimer;
 
-       void NewEndpointHandler(const NewEndpointEventArgs& neea);
-       void NewIdentityHandler(const EventArgs& ea);
+       void NewEndpointHandler(const Endpoint::Ptr& endpoint);
+       void NewIdentityHandler(const Object::Ptr& source);
 
-       void NewComponentMessageHandler(const NewRequestEventArgs& nrea);
-       void RegisterComponentMessageHandler(const NewRequestEventArgs& nrea);
+       void NewComponentMessageHandler(const RequestMessage& request);
+       void RegisterComponentMessageHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
 
-       void WelcomeMessageHandler(const NewRequestEventArgs& nrea);
+       void WelcomeMessageHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
 
-       void SendDiscoveryMessage(string method, string identity, Endpoint::Ptr recipient);
-       void ProcessDiscoveryMessage(string identity, DiscoveryMessage message, bool trusted);
+       void SendDiscoveryMessage(const string& method, const string& identity, const Endpoint::Ptr& recipient);
+       void ProcessDiscoveryMessage(const string& identity, const DiscoveryMessage& message, bool trusted);
 
        bool GetComponentDiscoveryInfo(string component, ComponentDiscoveryInfo::Ptr *info) const;
 
-       void CheckExistingEndpoint(Endpoint::Ptr endpoint, const NewEndpointEventArgs& neea);
-       void DiscoveryEndpointHandler(const NewEndpointEventArgs& neea, ComponentDiscoveryInfo::Ptr info) const;
+       void CheckExistingEndpoint(const Endpoint::Ptr& self, const Endpoint::Ptr& other);
+       void DiscoveryEndpointHandler(const Endpoint::Ptr& endpoint, const ComponentDiscoveryInfo::Ptr& info) const;
 
        void DiscoveryTimerHandler(void);
 
-       void FinishDiscoverySetup(Endpoint::Ptr endpoint);
+       void FinishDiscoverySetup(const Endpoint::Ptr& endpoint);
 
-       bool HasMessagePermission(Dictionary::Ptr roles, string messageType, string message);
+       bool HasMessagePermission(const Dictionary::Ptr& roles, const string& messageType, const string& message);
 
        static const int RegistrationTTL = 300;
 };
diff --git a/dyntest/dyntest.vcxproj.filters b/dyntest/dyntest.vcxproj.filters
new file mode 100644 (file)
index 0000000..5fa60e0
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Quelldateien">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Headerdateien">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Ressourcendateien">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="dyntest.cpp">
+      <Filter>Quelldateien</Filter>
+    </ClCompile>
+  </ItemGroup>
+</Project>
\ No newline at end of file
index 94c015e7aeecffa6b1a3c3b45e4adba974240c1c..980693137d5c31d00be4e65324a7db1ae59d8acf 100644 (file)
@@ -48,10 +48,7 @@ string Endpoint::GetIdentity(void) const
 void Endpoint::SetIdentity(string identity)
 {
        m_Identity = identity;
-
-       EventArgs ea;
-       ea.Source = shared_from_this();
-       OnIdentityChanged(ea);
+       OnIdentityChanged(shared_from_this());
 }
 
 /**
index a9bb89168007c3bc66cd456fa76f8d0d53c9aede..46848cd28f249ce352ce560728deb8c131c7f7bf 100644 (file)
@@ -79,8 +79,8 @@ public:
        ConstTopicIterator BeginPublications(void) const;
        ConstTopicIterator EndPublications(void) const;
 
-       boost::signal<void (const EventArgs&)> OnIdentityChanged;
-       boost::signal<void (const EventArgs&)> OnSessionEstablished;
+       boost::signal<void (const Object::Ptr&)> OnIdentityChanged;
+       boost::signal<void (const Object::Ptr&)> OnSessionEstablished;
 
 private:
        string m_Identity; /**< The identity of this endpoint. */
index fa310c5422790e1f0e2ee9b44dd8cc094c993070..c3b11d59a4d5c32617e311b72246785cde439f7d 100644 (file)
@@ -110,7 +110,7 @@ void EndpointManager::RegisterServer(JsonRpcServer::Ptr server)
 {
        m_Servers.push_back(server);
        server->OnNewClient.connect(boost::bind(&EndpointManager::NewClientHandler,
-           this, _1));
+           this, _2));
 }
 
 /**
@@ -118,13 +118,12 @@ void EndpointManager::RegisterServer(JsonRpcServer::Ptr server)
  *
  * @param ncea Event arguments.
  */
-void EndpointManager::NewClientHandler(const NewClientEventArgs& ncea)
+void EndpointManager::NewClientHandler(const TcpClient::Ptr& client)
 {
-       string address = ncea.Client->GetPeerAddress();
-       Application::Log(LogInformation, "icinga", "Accepted new client from " + address);
+       Application::Log(LogInformation, "icinga", "Accepted new client from " + client->GetPeerAddress());
 
        JsonRpcEndpoint::Ptr endpoint = boost::make_shared<JsonRpcEndpoint>();
-       endpoint->SetClient(static_pointer_cast<JsonRpcClient>(ncea.Client));
+       endpoint->SetClient(static_pointer_cast<JsonRpcClient>(client));
        RegisterEndpoint(endpoint);
 }
 
@@ -154,10 +153,7 @@ void EndpointManager::RegisterEndpoint(Endpoint::Ptr endpoint)
        endpoint->SetEndpointManager(static_pointer_cast<EndpointManager>(shared_from_this()));
        m_Endpoints.push_back(endpoint);
 
-       NewEndpointEventArgs neea;
-       neea.Source = shared_from_this();
-       neea.Endpoint = endpoint;
-       OnNewEndpoint(neea);
+       OnNewEndpoint(shared_from_this(), endpoint);
 }
 
 /**
@@ -257,18 +253,14 @@ void EndpointManager::SendMulticastMessage(Endpoint::Ptr sender,
  *
  * @param callback The callback function.
  */
-void EndpointManager::ForEachEndpoint(function<void (const NewEndpointEventArgs&)> callback)
+void EndpointManager::ForEachEndpoint(function<void (const Object::Ptr&, const Endpoint::Ptr&)> callback)
 {
-       NewEndpointEventArgs neea;
-       neea.Source = shared_from_this();
-
        vector<Endpoint::Ptr>::iterator prev, i;
        for (i = m_Endpoints.begin(); i != m_Endpoints.end(); ) {
                prev = i;
                i++;
 
-               neea.Endpoint = *prev;
-               callback(neea);
+               callback(shared_from_this(), *prev);
        }
 }
 
@@ -290,7 +282,7 @@ Endpoint::Ptr EndpointManager::GetEndpointByIdentity(string identity) const
 
 void EndpointManager::SendAPIMessage(Endpoint::Ptr sender,
     RequestMessage& message,
-    function<void(const NewResponseEventArgs&)> callback, time_t timeout)
+    function<void(const Object::Ptr&, const Endpoint::Ptr, const RequestMessage&, const ResponseMessage&, bool TimedOut)> callback, time_t timeout)
 {
        m_NextMessageID++;
 
@@ -345,12 +337,7 @@ void EndpointManager::RequestTimerHandler(void)
        map<string, PendingRequest>::iterator it;
        for (it = m_Requests.begin(); it != m_Requests.end(); it++) {
                if (it->second.HasTimedOut()) {
-                       NewResponseEventArgs nrea;
-                       nrea.Request = it->second.Request;
-                       nrea.Source = shared_from_this();
-                       nrea.TimedOut = true;
-
-                       it->second.Callback(nrea);
+                       it->second.Callback(shared_from_this(), Endpoint::Ptr(), it->second.Request, ResponseMessage(), true);
 
                        m_Requests.erase(it);
 
@@ -373,14 +360,7 @@ void EndpointManager::ProcessResponseMessage(const Endpoint::Ptr& sender, const
        if (it == m_Requests.end())
                return;
 
-       NewResponseEventArgs nrea;
-       nrea.Sender = sender;
-       nrea.Request = it->second.Request;
-       nrea.Response = message;
-       nrea.Source = shared_from_this();
-       nrea.TimedOut = false;
-
-       it->second.Callback(nrea);
+       it->second.Callback(shared_from_this(), sender, it->second.Request, message, false);
 
        m_Requests.erase(it);
        RescheduleRequestTimer();
index 8636f1e8b14b1797688abf6089252bf699b8ae96..7c31740b44415c7c4408c5b06df8f8ae26b44de7 100644 (file)
 namespace icinga
 {
 
-/**
- * Event arguments for the "new endpoint registered" event.
- *
- * @ingroup icinga
- */
-struct I2_ICINGA_API NewEndpointEventArgs : public EventArgs
-{
-       icinga::Endpoint::Ptr Endpoint; /**< The new endpoint. */
-};
-
-struct NewResponseEventArgs;
-
 /**
  * Information about a pending API request.
  *
@@ -44,7 +32,7 @@ struct I2_ICINGA_API PendingRequest
 {
        time_t Timeout;
        RequestMessage Request;
-       function<void(const NewResponseEventArgs&)> Callback;
+       function<void(const Object::Ptr&, const Endpoint::Ptr, const RequestMessage&, const ResponseMessage&, bool TimedOut)> Callback;
 
        bool HasTimedOut(void) const
        {
@@ -52,19 +40,6 @@ struct I2_ICINGA_API PendingRequest
        }
 };
 
-/**
- * Event arguments for the "new response" event.
- *
- * @ingroup icinga
- */
-struct I2_ICINGA_API NewResponseEventArgs : public EventArgs
-{
-       Endpoint::Ptr Sender;
-       RequestMessage Request;
-       ResponseMessage Response;
-       bool TimedOut;
-};
-
 /**
  * Forwards messages between endpoints.
  *
@@ -97,15 +72,15 @@ public:
        void SendMulticastMessage(Endpoint::Ptr sender, const RequestMessage& message);
 
        void SendAPIMessage(Endpoint::Ptr sender, RequestMessage& message,
-           function<void(const NewResponseEventArgs&)> callback, time_t timeout = 10);
+           function<void(const Object::Ptr&, const Endpoint::Ptr, const RequestMessage&, const ResponseMessage&, bool TimedOut)> callback, time_t timeout = 10);
 
        void ProcessResponseMessage(const Endpoint::Ptr& sender, const ResponseMessage& message);
 
-       void ForEachEndpoint(function<void (const NewEndpointEventArgs&)> callback);
+       void ForEachEndpoint(function<void (const Object::Ptr&, const Endpoint::Ptr&)> callback);
 
        Endpoint::Ptr GetEndpointByIdentity(string identity) const;
 
-       boost::signal<void (const NewEndpointEventArgs&)> OnNewEndpoint;
+       boost::signal<void (const Object::Ptr&, const Endpoint::Ptr&)> OnNewEndpoint;
 
 private:
        string m_Identity;
@@ -125,7 +100,7 @@ private:
        void RescheduleRequestTimer(void);
        void RequestTimerHandler(void);
 
-       void NewClientHandler(const NewClientEventArgs& ncea);
+       void NewClientHandler(const TcpClient::Ptr& client);
 };
 
 }
index 4780298e720c90090bf92d40ffd0da613b24dc36..7955eb1617ddfa19ff77a559ed257e7d960feaa6 100644 (file)
@@ -56,10 +56,9 @@ int IcingaApplication::Main(const vector<string>& args)
 
        /* register handler for 'component' config objects */
        static ConfigObject::Set::Ptr componentObjects = boost::make_shared<ConfigObject::Set>(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("component"));
-       function<void (const ObjectSetEventArgs<ConfigObject::Ptr>&)> NewComponentHandler = boost::bind(&IcingaApplication::NewComponentHandler, this, _1);
-       componentObjects->OnObjectAdded.connect(NewComponentHandler);
-       componentObjects->OnObjectCommitted.connect(NewComponentHandler);
-       componentObjects->OnObjectRemoved.connect(boost::bind(&IcingaApplication::DeletedComponentHandler, this, _1));
+       componentObjects->OnObjectAdded.connect(boost::bind(&IcingaApplication::NewComponentHandler, this, _2));
+       componentObjects->OnObjectCommitted.connect(boost::bind(&IcingaApplication::NewComponentHandler, this, _2));
+       componentObjects->OnObjectRemoved.connect(boost::bind(&IcingaApplication::DeletedComponentHandler, this, _2));
        componentObjects->Start();
 
        /* load config file */
@@ -113,10 +112,8 @@ EndpointManager::Ptr IcingaApplication::GetEndpointManager(void)
        return m_EndpointManager;
 }
 
-void IcingaApplication::NewComponentHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
+void IcingaApplication::NewComponentHandler(const ConfigObject::Ptr& object)
 {
-       ConfigObject::Ptr object = ea.Target;
-       
        /* don't allow replicated config objects */
        if (!object->IsLocal())
                throw runtime_error("'component' objects must be 'local'");
@@ -133,10 +130,8 @@ void IcingaApplication::NewComponentHandler(const ObjectSetEventArgs<ConfigObjec
        LoadComponent(path, object);
 }
 
-void IcingaApplication::DeletedComponentHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
+void IcingaApplication::DeletedComponentHandler(const ConfigObject::Ptr& object)
 {
-       ConfigObject::Ptr object = ea.Target;
-
        Component::Ptr component = GetComponent(object->GetName());
        UnregisterComponent(component);
 }
index 6b928d129b26c26f47c0af4eab44a713883d6847..4dbfb00d24504b496c64fae93e0baf53666463fb 100644 (file)
@@ -53,8 +53,8 @@ private:
        string m_Node;
        string m_Service;
 
-       void NewComponentHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
-       void DeletedComponentHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
+       void NewComponentHandler(const ConfigObject::Ptr& object);
+       void DeletedComponentHandler(const ConfigObject::Ptr& object);
 };
 
 }
index 594141c6a402ddfa1a7277a41ae9c44db3535b40..a9dfc1f7304206996a7bb1071dcbfa20d034d203 100644 (file)
@@ -45,10 +45,10 @@ void JsonRpcEndpoint::Connect(string node, string service, shared_ptr<SSL_CTX> s
 void JsonRpcEndpoint::SetClient(JsonRpcClient::Ptr client)
 {
        m_Client = client;
-       client->OnNewMessage.connect(boost::bind(&JsonRpcEndpoint::NewMessageHandler, this, _1));
-       client->OnClosed.connect(boost::bind(&JsonRpcEndpoint::ClientClosedHandler, this, _1));
-       client->OnError.connect(boost::bind(&JsonRpcEndpoint::ClientErrorHandler, this, _1));
-       client->OnVerifyCertificate.connect(boost::bind(&JsonRpcEndpoint::VerifyCertificateHandler, this, _1));
+       client->OnNewMessage.connect(boost::bind(&JsonRpcEndpoint::NewMessageHandler, this, _2));
+       client->OnClosed.connect(boost::bind(&JsonRpcEndpoint::ClientClosedHandler, this));
+       client->OnError.connect(boost::bind(&JsonRpcEndpoint::ClientErrorHandler, this, _2));
+       client->OnVerifyCertificate.connect(boost::bind(&JsonRpcEndpoint::VerifyCertificateHandler, this, _2, _4));
 }
 
 bool JsonRpcEndpoint::IsLocal(void) const
@@ -80,9 +80,8 @@ void JsonRpcEndpoint::ProcessResponse(Endpoint::Ptr sender, const ResponseMessag
        m_Client->SendMessage(message);
 }
 
-void JsonRpcEndpoint::NewMessageHandler(const NewMessageEventArgs& nmea)
+void JsonRpcEndpoint::NewMessageHandler(const MessagePart& message)
 {
-       const MessagePart& message = nmea.Message;
        Endpoint::Ptr sender = static_pointer_cast<Endpoint>(shared_from_this());
 
        if (ResponseMessage::IsResponseMessage(message)) {
@@ -108,7 +107,7 @@ void JsonRpcEndpoint::NewMessageHandler(const NewMessageEventArgs& nmea)
                GetEndpointManager()->SendMulticastMessage(sender, request);
 }
 
-void JsonRpcEndpoint::ClientClosedHandler(const EventArgs&)
+void JsonRpcEndpoint::ClientClosedHandler(void)
 {
        Application::Log(LogWarning, "jsonrpc", "Lost connection to endpoint: identity=" + GetIdentity());
 
@@ -130,18 +129,18 @@ void JsonRpcEndpoint::ClientClosedHandler(const EventArgs&)
        // TODO: persist events, etc., for now we just disable the endpoint
 }
 
-void JsonRpcEndpoint::ClientErrorHandler(const SocketErrorEventArgs& ea)
+void JsonRpcEndpoint::ClientErrorHandler(const std::exception& ex)
 {
        stringstream message;
-       message << "Error occured for JSON-RPC socket: Message=" << ea.Exception.what();
+       message << "Error occured for JSON-RPC socket: Message=" << ex.what();
 
        Application::Log(LogWarning, "jsonrpc", message.str());
 }
 
-void JsonRpcEndpoint::VerifyCertificateHandler(const VerifyCertificateEventArgs& ea)
+void JsonRpcEndpoint::VerifyCertificateHandler(bool& valid, const shared_ptr<X509>& certificate)
 {
-       if (ea.Certificate && ea.ValidCertificate) {
-               string identity = Utility::GetCertificateCN(ea.Certificate);
+       if (certificate && valid) {
+               string identity = Utility::GetCertificateCN(certificate);
 
                if (GetIdentity().empty() && !identity.empty())
                        SetIdentity(identity);
index 2c07eb54e37eb6e93570f30ae23075a84c29b68a..d566b9f3fe09822f924ea5e7c2dfa92e6f1de292 100644 (file)
@@ -58,10 +58,10 @@ private:
        JsonRpcClient::Ptr m_Client;
        map<string, Endpoint::Ptr> m_PendingCalls;
 
-       void NewMessageHandler(const NewMessageEventArgs& nmea);
-       void ClientClosedHandler(const EventArgs& ea);
-       void ClientErrorHandler(const SocketErrorEventArgs& ea);
-       void VerifyCertificateHandler(const VerifyCertificateEventArgs& ea);
+       void NewMessageHandler(const MessagePart& message);
+       void ClientClosedHandler(void);
+       void ClientErrorHandler(const std::exception& ex);
+       void VerifyCertificateHandler(bool& valid, const shared_ptr<X509>& certificate);
 };
 
 }
index 8737d9ff3862c10cb7d83fe2406f8e4f5af58c67..02ff52efeedb5a98ceabdbbe6e31fd4a71ac87a1 100644 (file)
@@ -38,15 +38,15 @@ bool VirtualEndpoint::IsConnected(void) const
        return true;
 }
 
-void VirtualEndpoint::RegisterTopicHandler(string topic, function<void (const NewRequestEventArgs&)> callback)
+void VirtualEndpoint::RegisterTopicHandler(string topic, function<void (const Object::Ptr&, const Endpoint::Ptr, const RequestMessage&)> callback)
 {
-       map<string, shared_ptr<boost::signal<void (const NewRequestEventArgs&)> > >::iterator it;
+       map<string, shared_ptr<boost::signal<void (const Object::Ptr&, const Endpoint::Ptr, const RequestMessage&)> > >::iterator it;
        it = m_TopicHandlers.find(topic);
 
-       shared_ptr<boost::signal<void (const NewRequestEventArgs&)> > sig;
+       shared_ptr<boost::signal<void (const Object::Ptr&, const Endpoint::Ptr, const RequestMessage&)> > sig;
 
        if (it == m_TopicHandlers.end()) {
-               sig = boost::make_shared<boost::signal<void (const NewRequestEventArgs&)> >();
+               sig = boost::make_shared<boost::signal<void (const Object::Ptr&, const Endpoint::Ptr, const RequestMessage&)> >();
                m_TopicHandlers.insert(make_pair(topic, sig));
        } else {
                sig = it->second;
@@ -57,7 +57,7 @@ void VirtualEndpoint::RegisterTopicHandler(string topic, function<void (const Ne
        RegisterSubscription(topic);
 }
 
-void VirtualEndpoint::UnregisterTopicHandler(string topic, function<void (const NewRequestEventArgs&)> callback)
+void VirtualEndpoint::UnregisterTopicHandler(string topic, function<void (const Object::Ptr&, const Endpoint::Ptr, const RequestMessage&)> callback)
 {
        // TODO: implement
        //m_TopicHandlers[method] -= callback;
@@ -72,17 +72,13 @@ void VirtualEndpoint::ProcessRequest(Endpoint::Ptr sender, const RequestMessage&
        if (!request.GetMethod(&method))
                return;
 
-       map<string, shared_ptr<boost::signal<void (const NewRequestEventArgs&)> > >::iterator it;
+       map<string, shared_ptr<boost::signal<void (const Object::Ptr&, const Endpoint::Ptr, const RequestMessage&)> > >::iterator it;
        it = m_TopicHandlers.find(method);
 
        if (it == m_TopicHandlers.end())
                return;
 
-       NewRequestEventArgs nrea;
-       nrea.Source = shared_from_this();
-       nrea.Sender = sender;
-       nrea.Request = request;
-       (*it->second)(nrea);
+       (*it->second)(shared_from_this(), sender, request);
 }
 
 void VirtualEndpoint::ProcessResponse(Endpoint::Ptr sender, const ResponseMessage& response)
index 9e42f34a92c38766762d844ea2c2d573a647d42e..4da70c053769a9f6fd34f39ae0263d94653a8713 100644 (file)
 namespace icinga
 {
 
-/**
- * Event arguments for the "new request" event.
- *
- * @ingroup icinga
- */
-struct I2_ICINGA_API NewRequestEventArgs : public EventArgs
-{
-       Endpoint::Ptr Sender;
-       RequestMessage Request;
-};
-
 /**
  * A local endpoint.
  *
@@ -45,8 +34,8 @@ public:
        typedef shared_ptr<VirtualEndpoint> Ptr;
        typedef weak_ptr<VirtualEndpoint> WeakPtr;
 
-       void RegisterTopicHandler(string topic, function<void (const NewRequestEventArgs&)> callback);
-       void UnregisterTopicHandler(string topic, function<void (const NewRequestEventArgs&)> callback);
+       void RegisterTopicHandler(string topic, function<void (const Object::Ptr&, const Endpoint::Ptr, const RequestMessage&)> callback);
+       void UnregisterTopicHandler(string topic, function<void (const Object::Ptr&, const Endpoint::Ptr, const RequestMessage&)> callback);
 
        virtual string GetAddress(void) const;
 
@@ -59,7 +48,7 @@ public:
        virtual void Stop(void);
 
 private:
-       map< string, shared_ptr<boost::signal<void (const NewRequestEventArgs&)> > > m_TopicHandlers;
+       map< string, shared_ptr<boost::signal<void (const Object::Ptr&, const Endpoint::Ptr, const RequestMessage&)> > > m_TopicHandlers;
 };
 
 }
index e7ce12ce2afff69fef5c4aa95d5502be0964f2ba..e35e76f08f3143944a59eaa433a3a7dff2b45206 100644 (file)
@@ -28,13 +28,9 @@ using namespace icinga;
  * @param sslContext SSL context for the TLS connection.
  */
 JsonRpcClient::JsonRpcClient(TcpClientRole role, shared_ptr<SSL_CTX> sslContext)
-    : TlsClient(role, sslContext) { }
-
-void JsonRpcClient::Start(void)
+       : TlsClient(role, sslContext)
 {
-       TlsClient::Start();
-
-       OnDataAvailable.connect(boost::bind(&JsonRpcClient::DataAvailableHandler, this, _1));
+       OnDataAvailable.connect(boost::bind(&JsonRpcClient::DataAvailableHandler, this));
 }
 
 /**
@@ -49,11 +45,8 @@ void JsonRpcClient::SendMessage(const MessagePart& message)
 
 /**
  * Processes inbound data.
- *
- * @param - Event arguments for the event.
- * @returns 0
  */
-void JsonRpcClient::DataAvailableHandler(const EventArgs&)
+void JsonRpcClient::DataAvailableHandler(void)
 {
        for (;;) {
                try {
@@ -64,11 +57,7 @@ void JsonRpcClient::DataAvailableHandler(const EventArgs&)
                                return;
 
                        message = MessagePart(jsonString);
-
-                       NewMessageEventArgs nea;
-                       nea.Source = shared_from_this();
-                       nea.Message = message;
-                       OnNewMessage(nea);
+                       OnNewMessage(shared_from_this(), message);
                } catch (const Exception& ex) {
                        Application::Log(LogCritical, "jsonrpc", "Exception while processing message from JSON-RPC client: " + string(ex.GetMessage()));
                        Close();
index 384dff3c426a3eb6b1925614b4d1d229cf01a3e6..a8f96288445b93a282f588927bfff8026288d6f8 100644 (file)
 namespace icinga
 {
 
-/**
- * Event arguments for the "new message" event.
- *
- * @ingroup jsonrpc
- */
-struct I2_JSONRPC_API NewMessageEventArgs : public EventArgs
-{
-       icinga::MessagePart Message;
-};
-
 /**
  * A JSON-RPC client.
  *
@@ -48,12 +38,10 @@ public:
 
        void SendMessage(const MessagePart& message);
 
-       virtual void Start(void);
-
-       boost::signal<void (const NewMessageEventArgs&)> OnNewMessage;
+       boost::signal<void (const Object::Ptr&, const MessagePart&)> OnNewMessage;
 
 private:
-       void DataAvailableHandler(const EventArgs&);
+       void DataAvailableHandler(void);
 };
 
 JsonRpcClient::Ptr JsonRpcClientFactory(TcpClientRole role, shared_ptr<SSL_CTX> sslContext);
index 57b7056401a161ae5b38ce63340b8c2e898f7125..de11045448d456c8b7a370c7c130c170071a43a8 100644 (file)
@@ -82,12 +82,12 @@ bool Netstring::ReadStringFromFIFO(FIFO::Ptr fifo, string *str)
  */
 void Netstring::WriteStringToFIFO(FIFO::Ptr fifo, const string& str)
 {
-       unsigned long len = str.size();
-       char strLength[50];
-       sprintf(strLength, "%lu:", (unsigned long)len);
+       stringstream prefixbuf;
+       prefixbuf << str.size() << ":";
 
-       fifo->Write(strLength, strlen(strLength));
-       fifo->Write(str.c_str(), len);
+       string prefix = prefixbuf.str();
+       fifo->Write(prefix.c_str(), prefix.size());
+       fifo->Write(str.c_str(), str.size());
 
        fifo->Write(",", 1);
 }