]> granicus.if.org Git - icinga2/commitdiff
Made build system more Windows-friendly
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 6 Apr 2012 06:56:52 +0000 (08:56 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 6 Apr 2012 06:56:52 +0000 (08:56 +0200)
Implemented endpoint system for the discovery service

55 files changed:
Makefile.am
base/application.cpp
base/application.h
base/base.vcxproj
base/component.h
base/condvar.h
base/configcollection.h
base/confighive.h
base/configobject.h
base/event.h
base/exception.h
base/fifo.h
base/i2-base.h
base/memory.h
base/mutex.h
base/object.h
base/socket.h
base/tcpclient.h
base/tcpserver.h
base/tcpsocket.h
base/thread.h
base/timer.h
cJSON/Makefile.am [new file with mode: 0644]
cJSON/cJSON.c [moved from jsonrpc/cJSON.c with 100% similarity]
cJSON/cJSON.h [moved from jsonrpc/cJSON.h with 100% similarity]
cJSON/cJSON.vcxproj [new file with mode: 0644]
configfilecomponent/Makefile.am
configfilecomponent/configfilecomponent.vcxproj
configrpccomponent/Makefile.am
configrpccomponent/configrpccomponent.cpp
configrpccomponent/configrpccomponent.h
configrpccomponent/configrpccomponent.vcxproj
configure.ac
icinga.sln
icinga/Makefile.am
icinga/connectionmanager.cpp [deleted file]
icinga/endpoint.cpp [new file with mode: 0644]
icinga/endpoint.h [new file with mode: 0644]
icinga/endpointmanager.cpp [new file with mode: 0644]
icinga/endpointmanager.h [moved from icinga/connectionmanager.h with 58% similarity]
icinga/i2-icinga.h
icinga/icinga.vcxproj
icinga/icingaapplication.cpp
icinga/icingaapplication.h
icinga/jsonrpcendpoint.cpp [new file with mode: 0644]
icinga/jsonrpcendpoint.h [new file with mode: 0644]
icinga/virtualendpoint.cpp [new file with mode: 0644]
icinga/virtualendpoint.h [new file with mode: 0644]
jsonrpc/Makefile.am
jsonrpc/i2-jsonrpc.h
jsonrpc/jsonrpc.vcxproj
jsonrpc/jsonrpcclient.h
jsonrpc/jsonrpcmessage.h
jsonrpc/jsonrpcserver.h
jsonrpc/netstring.h

index 1f2d5b6bda714e1580c80b75e87fb9778ef74de7..ea056e09b2b2e43b68a6bc1b54cb4579c22659b5 100644 (file)
@@ -3,6 +3,7 @@
 
 SUBDIRS = ltdl \
        base \
+       cJSON \
        jsonrpc \
        configfilecomponent \
        configrpccomponent \
index 98c85d8a94f80863425c27ed8580acf391bf2ab9..1f50c454f26e4994e9b0460138a757bb960595fa 100644 (file)
@@ -6,7 +6,7 @@
 
 using namespace icinga;
 
-Application::Ptr Application::Instance;
+Application::Ptr I2_EXPORT Application::Instance;
 
 Application::Application(void)
 {
@@ -371,3 +371,62 @@ void Application::SigIntHandler(int signum)
        sigaction(SIGINT, &sa, NULL);
 #endif /* _WIN32 */
 }
+
+static void application_sigint_handler(int signum)
+{
+       Application::Instance->SigIntHandler(signum);
+}
+
+int application_main(int argc, char **argv, Application::Ptr instance)
+{
+       int result;
+
+       Application::Instance = instance;
+
+#ifndef _WIN32
+       struct sigaction sa;
+       memset(&sa, 0, sizeof(sa));
+       sa.sa_handler = sigint_handler;
+       sigaction(SIGINT, &sa, NULL);
+#endif /* _WIN32 */
+
+       vector<string> args;
+
+       for (int i = 0; i < argc; i++)
+               args.push_back(string(argv[i]));
+
+       Application::Instance->SetArguments(args);
+
+       if (Application::Instance->IsDebugging()) {
+               result = Application::Instance->Main(args);
+       } else {
+               try {
+                       result = Application::Instance->Main(args);
+               } catch (const Exception& ex) {
+                       cout << "---" << endl;
+
+                       string klass = typeid(ex).name();
+
+#ifdef HAVE_GCC_ABI_DEMANGLE
+                       int status;
+                       char *realname = abi::__cxa_demangle(klass.c_str(), 0, 0, &status);
+
+                       if (realname != NULL) {
+                               klass = string(realname);
+                               free(realname);
+                       }
+#endif /* HAVE_GCC_ABI_DEMANGLE */
+
+                       cout << "Exception: " << klass << endl;
+                       cout << "Message: " << ex.GetMessage() << endl;
+
+                       return EXIT_FAILURE;
+               }
+       }
+
+       Application::Instance.reset();
+
+       assert(Object::ActiveObjects == 0);
+
+       return result;
+}
\ No newline at end of file
index e4211146b5c3d7fb5aebac0ec6bbf4e5cb45804d..2806a16e26e9608fbd964392f0a82e443c9d1daf 100644 (file)
@@ -7,7 +7,7 @@ class Component;
 
 DEFINE_EXCEPTION_CLASS(ComponentLoadException);
 
-class Application : public Object {
+class I2_BASE_API Application : public Object {
 private:
        bool m_ShuttingDown;
        ConfigHive::Ptr m_ConfigHive;
@@ -48,71 +48,14 @@ public:
        void SigIntHandler(int signum);
 };
 
-inline void sigint_handler(int signum)
-{
-       Application::Instance->SigIntHandler(signum);
 }
 
-template<class T>
-int application_main(int argc, char **argv)
-{
-       int result;
+int I2_EXPORT application_main(int argc, char **argv, icinga::Application::Ptr instance);
 
-       Application::Instance = make_shared<T>();
-
-#ifndef _WIN32
-       struct sigaction sa;
-       memset(&sa, 0, sizeof(sa));
-       sa.sa_handler = sigint_handler;
-       sigaction(SIGINT, &sa, NULL);
-#endif /* _WIN32 */
-
-       vector<string> args;
-
-       for (int i = 0; i < argc; i++)
-               args.push_back(string(argv[i]));
-
-       Application::Instance->SetArguments(args);
-
-       if (Application::Instance->IsDebugging()) {
-               result = Application::Instance->Main(args);
-       } else {
-               try {
-                       result = Application::Instance->Main(args);
-               } catch (const Exception& ex) {
-                       cout << "---" << endl;
-
-                       string klass = typeid(ex).name();
-
-#ifdef HAVE_GCC_ABI_DEMANGLE
-                       int status;
-                       char *realname = abi::__cxa_demangle(klass.c_str(), 0, 0, &status);
-
-                       if (realname != NULL) {
-                               klass = string(realname);
-                               free(realname);
-                       }
-#endif /* HAVE_GCC_ABI_DEMANGLE */
-
-                       cout << "Exception: " << klass << endl;
-                       cout << "Message: " << ex.GetMessage() << endl;
-
-                       return EXIT_FAILURE;
-               }
+#define SET_START_CLASS(klass)                                                                 \
+       int main(int argc, char **argv) {                                                       \
+               shared_ptr<klass> instance = make_shared<klass>();              \
+               return application_main(argc, argv, instance);                  \
        }
 
-       Application::Instance.reset();
-
-       assert(Object::ActiveObjects == 0);
-
-       return result;
-}
-
-#define SET_START_CLASS(klass)                         \
-       int main(int argc, char **argv) {               \
-               return application_main<klass>(argc, argv);     \
-       }
-
-}
-
 #endif /* APPLICATION_H */
index 5564b5393415cff04462c367ef131424ee869448..6ad5a6c67302de9324779cfe04f122bcba85289a 100644 (file)
@@ -65,7 +65,7 @@
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
     <UseDebugLibraries>true</UseDebugLibraries>
     <CharacterSet>MultiByte</CharacterSet>
   </PropertyGroup>
@@ -73,7 +73,7 @@
     <UseDebugLibraries>false</UseDebugLibraries>
     <WholeProgramOptimization>true</WholeProgramOptimization>
     <CharacterSet>MultiByte</CharacterSet>
-    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
   <ImportGroup Label="ExtensionSettings">
       </PrecompiledHeader>
       <WarningLevel>Level3</WarningLevel>
       <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>_WINDLL;I2_BASE_BUILD;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>ws2_32.lib;imagehlp.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>ws2_32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <Lib>
       <AdditionalDependencies>ws2_32.lib;shlwapi.lib</AdditionalDependencies>
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>_WINDLL;I2_BASE_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>ws2_32.lib;imagehlp.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>ws2_32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <Lib>
       <AdditionalDependencies>ws2_32.lib;shlwapi.lib</AdditionalDependencies>
index 4415a17e8bbdb15f462d66d6b64286a1737dffdf..68da36b5cf70df362660ae088ef37a98ee5cb055 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-class Component : public Object
+class I2_BASE_API Component : public Object
 {
 private:
        Application::WeakPtr m_Application;
index b34689be1f422c24bd948116d0b334a595437ddc..2c51a09ee1932c07fcc934ab00255c2f1d3898bf 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-class condvar
+class I2_BASE_API condvar
 {
 private:
 #ifdef _WIN32
index 6d30b3a5900d70757b3d5c06484e4bef86c73886..b8ea38512c0ddcb1181f8ee8217c1295eebe52ce 100644 (file)
@@ -6,7 +6,7 @@ namespace icinga
 
 class ConfigHive;
 
-class ConfigCollection : public Object
+class I2_BASE_API ConfigCollection : public Object
 {
 private:
        weak_ptr<ConfigHive> m_Hive;
index 8a6fb58df1267d77c730999464cf6a16713220a8..c7e54c33e04164ff3f1636d2f0e018a4529dcbff 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-class ConfigHive : public Object
+class I2_BASE_API ConfigHive : public Object
 {
 public:
        typedef shared_ptr<ConfigHive> Ptr;
index be48821850272e691341e958fba4d0891717e576..a084b5b47b080c42bcae8d9d01f37f20f9649bda 100644 (file)
@@ -8,7 +8,7 @@ namespace icinga
 
 class ConfigHive;
 
-struct ConfigObjectEventArgs : public EventArgs
+struct I2_BASE_API ConfigObjectEventArgs : public EventArgs
 {
        typedef shared_ptr<ConfigObjectEventArgs> Ptr;
        typedef weak_ptr<ConfigObjectEventArgs> WeakPtr;
@@ -17,7 +17,7 @@ struct ConfigObjectEventArgs : public EventArgs
        string OldValue;
 };
 
-class ConfigObject : public Object
+class I2_BASE_API ConfigObject : public Object
 {
 private:
        weak_ptr<ConfigHive> m_Hive;
index 60d9ecf1974d5758b4d88e2937b260a22908ee64..e306d73b02dbc22fd14fad2d400d452b5d24ca70 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-struct EventArgs : public Object
+struct I2_BASE_API EventArgs : public Object
 {
        typedef shared_ptr<EventArgs> Ptr;
        typedef weak_ptr<EventArgs> WeakPtr;
index 4853dde684f2222e167cd5fae658b9e5a15ec671..d454f79e339a63a6f312ab5098191873cdf480a0 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-class Exception
+class I2_BASE_API Exception
 {
 private:
        string m_Message;
index 2b2d82e5486f8fb911346cce8c2f9a0e484a0ac6..6cf57d40128a1cfd9e948f6ca3571cda291f8ac3 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-class FIFO : public Object
+class I2_BASE_API FIFO : public Object
 {
 private:
        char *m_Buffer;
index 2b9626175de7efd105c5ef9d032e38ebfe3e4616..a7afa25dbf993a98682b4b9a3f86673d8bf78dc0 100644 (file)
@@ -3,6 +3,7 @@
 
 #ifdef _MSC_VER
 #      define HAVE_CXX11
+#      pragma warning(disable:4251)
 #else /* _MSC_VER */
 #      include "config.h"
 #endif /* _MSC_VER */
@@ -55,6 +56,12 @@ using namespace std::tr1::placeholders;
 #      include "unix.h"
 #endif
 
+#ifdef I2_BASE_BUILD
+#      define I2_BASE_API I2_EXPORT
+#else /* I2_BASE_BUILD */
+#      define I2_BASE_API I2_IMPORT
+#endif /* I2_BASE_BUILD */
+
 #include "mutex.h"
 #include "condvar.h"
 #include "thread.h"
index 9abd0d28c3cef31dadf353635711e54b7db31ee6..70d5d4e25a1f247de024c470265f3d5fde159c9f 100644 (file)
@@ -6,7 +6,7 @@ namespace icinga
 
 DEFINE_EXCEPTION_CLASS(OutOfMemoryException);
 
-class Memory
+class I2_BASE_API Memory
 {
 private:
        Memory(void);
index 2d8d317b4a1db31ff5898241332414a4b6f477a4..9c632bc04459c14c0d16477236cead3353ada2cf 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-class mutex
+class I2_BASE_API mutex
 {
 private:
 #ifdef _WIN32
index 71c278ead3e6238938296b76953a228a4fa55c00..ffb609bb87ff071c584403675c3762663feabb65 100644 (file)
@@ -4,21 +4,20 @@
 namespace icinga
 {
 
-class Object : public enable_shared_from_this<Object>
+class I2_BASE_API Object : public enable_shared_from_this<Object>
 {
 private:
        Object(const Object &other);
 
 protected:
        Object(void);
+       virtual ~Object(void);
 
 public:
        typedef shared_ptr<Object> Ptr;
        typedef weak_ptr<Object> WeakPtr;
 
        static unsigned long ActiveObjects;
-
-       virtual ~Object(void);
 };
 
 template<class T>
index ca6179b431706d9eafda69a36d23361fa5683655..9b9e7da9f1cd2b45a00c46e94ecd9fd3777bc8f4 100644 (file)
@@ -3,7 +3,7 @@
 
 namespace icinga {
 
-struct SocketErrorEventArgs : public EventArgs
+struct I2_BASE_API SocketErrorEventArgs : public EventArgs
 {
        typedef shared_ptr<SocketErrorEventArgs> Ptr;
        typedef weak_ptr<SocketErrorEventArgs> WeakPtr;
@@ -12,7 +12,7 @@ struct SocketErrorEventArgs : public EventArgs
        string Message;
 };
 
-class Socket : public Object
+class I2_BASE_API Socket : public Object
 {
 private:
        SOCKET m_FD;
index 607ed299ad493a7b7977c0232287229c60b82aa2..91c027730f89d1cc042e0b0ebbebc6182c325dac 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-class TCPClient : public TCPSocket
+class I2_BASE_API TCPClient : public TCPSocket
 {
 private:
        string m_PeerHost;
index caef7bbf7ce501439d47a6a3bcbbec3a98466a07..44a438d6f9491bc3c5f947b902de0a049e35eca1 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-struct NewClientEventArgs : public EventArgs
+struct I2_BASE_API NewClientEventArgs : public EventArgs
 {
        typedef shared_ptr<NewClientEventArgs> Ptr;
        typedef weak_ptr<NewClientEventArgs> WeakPtr;
@@ -12,7 +12,7 @@ struct NewClientEventArgs : public EventArgs
        TCPSocket::Ptr Client;
 };
 
-class TCPServer : public TCPSocket
+class I2_BASE_API TCPServer : public TCPSocket
 {
 private:
        int ReadableEventHandler(EventArgs::Ptr ea);
index 394f890003ede01203b0bbf5c8c31ed558089654..8a3feb50dde436163c8b14fa199099c914c3ac0e 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-class TCPSocket : public Socket
+class I2_BASE_API TCPSocket : public Socket
 {
 public:
        typedef shared_ptr<TCPSocket> Ptr;
index a5b364fbd976843ae48984986efefb46f86e0eaa..17a0e993b3e2d0980097ebb8a89525fdd2087921 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-class thread
+class I2_BASE_API thread
 {
 private:
 #ifdef _WIN32
index 5732c271c10bcc552bd28ff816c3cd82a6c201b6..da27900afd9026cb3387457b94bac496a94b4fff 100644 (file)
@@ -5,7 +5,7 @@
 
 namespace icinga {
 
-struct TimerEventArgs : public EventArgs
+struct I2_BASE_API TimerEventArgs : public EventArgs
 {
        typedef shared_ptr<TimerEventArgs> Ptr;
        typedef weak_ptr<TimerEventArgs> WeakPtr;
@@ -13,7 +13,7 @@ struct TimerEventArgs : public EventArgs
        EventArgs::Ptr UserArgs;
 };
 
-class Timer : public Object
+class I2_BASE_API Timer : public Object
 {
 private:
        EventArgs::Ptr m_UserArgs;
diff --git a/cJSON/Makefile.am b/cJSON/Makefile.am
new file mode 100644 (file)
index 0000000..a4d45f7
--- /dev/null
@@ -0,0 +1,9 @@
+## Process this file with automake to produce Makefile.in
+
+
+noinst_LTLIBRARIES =  \
+       libcJSON.la
+
+libcJSON_la_SOURCES =  \
+       cJSON.c \
+       cJSON.h
similarity index 100%
rename from jsonrpc/cJSON.c
rename to cJSON/cJSON.c
similarity index 100%
rename from jsonrpc/cJSON.h
rename to cJSON/cJSON.h
diff --git a/cJSON/cJSON.vcxproj b/cJSON/cJSON.vcxproj
new file mode 100644 (file)
index 0000000..a148059
--- /dev/null
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="cJSON.c" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="cJSON.h" />
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{66BED474-C33F-48F9-90BA-BBCFEDC006B8}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>cJSON</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup />
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
index 23adca4ced8ec248e1be5adb74dc85f8a2029577..f148af252ccb030a0bcd98bd598e9745b38f0303 100644 (file)
@@ -11,4 +11,4 @@ libconfigfilecomponent_la_SOURCES =  \
 libconfigfilecomponent_la_CXXFLAGS = -I${top_srcdir}/base -I${top_srcdir}/jsonrpc
 
 libconfigfilecomponent_la_LDFLAGS = -module -version-info 0:0:0 -no-undefined
-libconfigfilecomponent_la_LIBADD = ${top_builddir}/base/libbase.la ${top_builddir}/jsonrpc/libjsonrpc.la
\ No newline at end of file
+libconfigfilecomponent_la_LIBADD = ${top_builddir}/base/libbase.la ${top_builddir}/cJSON/libcJSON.la
\ No newline at end of file
index fa0f9ff5fc1ab923b6ad695b0668f012a3b595b5..bf7d0199c4f649c2508b6730e6a67805c0b70f76 100644 (file)
   </ImportGroup>
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(IncludePath)</IncludePath>
+    <IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
     <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(IncludePath)</IncludePath>
+    <IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
     <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@@ -63,7 +63,7 @@
     <Link>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>base.lib;jsonrpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>base.lib;jsonrpc.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <Lib>
       <AdditionalDependencies>
@@ -85,7 +85,7 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>base.lib;jsonrpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>base.lib;jsonrpc.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <Lib>
       <AdditionalDependencies>$(OutDir)\base.lib;$(OutDir)\jsonrpc.lib</AdditionalDependencies>
index f76aec842dace3c3ce35c503defe35ec3f6a7a8d..8a57eb2cb1f3e42b097ba60b6fb9c29505bb0aa5 100644 (file)
@@ -11,4 +11,6 @@ libconfigrpccomponent_la_SOURCES =  \
 libconfigrpccomponent_la_CXXFLAGS = -I${top_srcdir}/base -I${top_srcdir}/jsonrpc -I${top_srcdir}/icinga
 
 libconfigrpccomponent_la_LDFLAGS = -module -version-info 0:0:0 -no-undefined -pthread
-libconfigrpccomponent_la_LIBADD = ${top_builddir}/base/libbase.la ${top_builddir}/jsonrpc/libjsonrpc.la
+libconfigrpccomponent_la_LIBADD = ${top_builddir}/base/libbase.la \
+       ${top_builddir}/jsonrpc/libjsonrpc.la \
+       ${top_builddir}/cJSON/libcJSON.la
index 7606c02f8762ce2ef349799ff46ec5e3023708c2..08317cdb02809687b2cde1aeb804e173e7e62de9 100644 (file)
@@ -16,21 +16,29 @@ void ConfigRpcComponent::Start(void)
 {
        IcingaApplication::Ptr icingaApp = GetIcingaApplication();
 
-       ConnectionManager::Ptr connectionManager = icingaApp->GetConnectionManager();
+       EndpointManager::Ptr endpointManager = icingaApp->GetEndpointManager();
        ConfigHive::Ptr configHive = icingaApp->GetConfigHive();
 
+       m_ConfigRpcEndpoint = make_shared<VirtualEndpoint>();
+
        int configSource;
        if (GetConfig()->GetPropertyInteger("configSource", &configSource) && configSource != 0) {
-               connectionManager->RegisterMethod("config::FetchObjects", bind_weak(&ConfigRpcComponent::FetchObjectsHandler, shared_from_this()));
+               m_ConfigRpcEndpoint->RegisterMethodHandler("config::FetchObjects", bind_weak(&ConfigRpcComponent::FetchObjectsHandler, shared_from_this()));
 
                configHive->OnObjectCreated += bind_weak(&ConfigRpcComponent::LocalObjectCreatedHandler, shared_from_this());
                configHive->OnObjectRemoved += bind_weak(&ConfigRpcComponent::LocalObjectRemovedHandler, shared_from_this());
                configHive->OnPropertyChanged += bind_weak(&ConfigRpcComponent::LocalPropertyChangedHandler, shared_from_this());
+
+               m_ConfigRpcEndpoint->RegisterMethodSource("config::ObjectCreated");
+               m_ConfigRpcEndpoint->RegisterMethodSource("config::ObjectRemoved");
+               m_ConfigRpcEndpoint->RegisterMethodSource("config::PropertyChanged");
        }
 
-       connectionManager->RegisterMethod("config::ObjectCreated", bind_weak(&ConfigRpcComponent::RemoteObjectUpdatedHandler, shared_from_this()));
-       connectionManager->RegisterMethod("config::ObjectRemoved", bind_weak(&ConfigRpcComponent::RemoteObjectRemovedHandler, shared_from_this()));
-       connectionManager->RegisterMethod("config::PropertyChanged", bind_weak(&ConfigRpcComponent::RemoteObjectUpdatedHandler, shared_from_this()));
+       m_ConfigRpcEndpoint->RegisterMethodHandler("config::ObjectCreated", bind_weak(&ConfigRpcComponent::RemoteObjectUpdatedHandler, shared_from_this()));
+       m_ConfigRpcEndpoint->RegisterMethodHandler("config::ObjectRemoved", bind_weak(&ConfigRpcComponent::RemoteObjectRemovedHandler, shared_from_this()));
+       m_ConfigRpcEndpoint->RegisterMethodHandler("config::PropertyChanged", bind_weak(&ConfigRpcComponent::RemoteObjectUpdatedHandler, shared_from_this()));
+
+       endpointManager->RegisterEndpoint(m_ConfigRpcEndpoint);
 }
 
 void ConfigRpcComponent::Stop(void)
@@ -88,8 +96,8 @@ int ConfigRpcComponent::LocalObjectCreatedHandler(ConfigObjectEventArgs::Ptr ea)
        object->GetPropertyInteger("replicate", &replicate);
 
        if (replicate) {
-               ConnectionManager::Ptr connectionManager = GetIcingaApplication()->GetConnectionManager();
-               connectionManager->SendMessage(MakeObjectMessage(object, "config::ObjectCreated", true));
+               EndpointManager::Ptr mgr = GetIcingaApplication()->GetEndpointManager();
+               mgr->SendMessage(m_ConfigRpcEndpoint, NULL, MakeObjectMessage(object, "config::ObjectCreated", true));
        }
 
        return 0;
@@ -103,8 +111,8 @@ int ConfigRpcComponent::LocalObjectRemovedHandler(ConfigObjectEventArgs::Ptr ea)
        object->GetPropertyInteger("replicate", &replicate);
 
        if (replicate) {
-               ConnectionManager::Ptr connectionManager = GetIcingaApplication()->GetConnectionManager();
-               connectionManager->SendMessage(MakeObjectMessage(object, "config::ObjectRemoved", false));
+               EndpointManager::Ptr mgr = GetIcingaApplication()->GetEndpointManager();
+               mgr->SendMessage(m_ConfigRpcEndpoint, NULL, MakeObjectMessage(object, "config::ObjectRemoved", false));
        }
 
        return 0;
@@ -129,8 +137,8 @@ int ConfigRpcComponent::LocalPropertyChangedHandler(ConfigObjectEventArgs::Ptr e
 
                cJSON_AddStringToObject(properties, ea->Property.c_str(), value.c_str());
 
-               ConnectionManager::Ptr connectionManager = GetIcingaApplication()->GetConnectionManager();
-               connectionManager->SendMessage(msg);
+               EndpointManager::Ptr mgr = GetIcingaApplication()->GetEndpointManager();
+               mgr->SendMessage(m_ConfigRpcEndpoint, NULL, msg);
        }
 
        return 0;
index 150a85dc384677ec51cc2d4a98f62c6a2d91e015..dcf2f740b7112ae9bc3bd310c27cb6a2ad7139e7 100644 (file)
@@ -7,6 +7,8 @@ namespace icinga
 class ConfigRpcComponent : public Component
 {
 private:
+       VirtualEndpoint::Ptr m_ConfigRpcEndpoint;
+
        IcingaApplication::Ptr GetIcingaApplication(void);
 
        int FetchObjectsHandler(NewMessageEventArgs::Ptr ea);
index 61feb47d92a3bb8046d8bf158cbd105ce95c41c4..66fc0443b3d60b76e3d8db908c7cc3838730d9da 100644 (file)
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>true</LinkIncremental>
-    <IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\icinga;$(IncludePath)</IncludePath>
+    <IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\icinga;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
     <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <LinkIncremental>false</LinkIncremental>
-    <IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\icinga;$(IncludePath)</IncludePath>
+    <IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\icinga;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
     <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@@ -65,7 +65,7 @@
     <Link>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>base.lib;jsonrpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>base.lib;jsonrpc.lib;icinga.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -83,7 +83,7 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>base.lib;jsonrpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>base.lib;jsonrpc.lib;icinga.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
index c2b8ae07d16d10d1577cceffc19ce52262e34ca0..8a2b0a35afb441f089fe0517dd862ea2f5916667 100644 (file)
@@ -43,6 +43,7 @@ fi
 AC_OUTPUT([
 Makefile
 base/Makefile
+cJSON/Makefile
 configfilecomponent/Makefile
 configrpccomponent/Makefile
 icinga/Makefile
index cfe447411786f83b324fafacaf7050c35ad19c71..5fd6e76cc27f91a6857c97c60ff1f3a2112e655b 100644 (file)
@@ -5,6 +5,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "base", "base\base.vcxproj",
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsonrpc", "jsonrpc\jsonrpc.vcxproj", "{8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}"
        ProjectSection(ProjectDependencies) = postProject
+               {66BED474-C33F-48F9-90BA-BBCFEDC006B8} = {66BED474-C33F-48F9-90BA-BBCFEDC006B8}
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
        EndProjectSection
 EndProject
@@ -15,24 +16,29 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icinga", "icinga\icinga.vcxproj", "{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}"
        ProjectSection(ProjectDependencies) = postProject
-               {697C6D7E-3109-484C-A7AF-384D28711610} = {697C6D7E-3109-484C-A7AF-384D28711610}
+               {66BED474-C33F-48F9-90BA-BBCFEDC006B8} = {66BED474-C33F-48F9-90BA-BBCFEDC006B8}
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
-               {E58F1DA7-B723-412B-B2B7-7FF58E2A944E} = {E58F1DA7-B723-412B-B2B7-7FF58E2A944E}
                {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8} = {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "configfilecomponent", "configfilecomponent\configfilecomponent.vcxproj", "{E58F1DA7-B723-412B-B2B7-7FF58E2A944E}"
        ProjectSection(ProjectDependencies) = postProject
+               {66BED474-C33F-48F9-90BA-BBCFEDC006B8} = {66BED474-C33F-48F9-90BA-BBCFEDC006B8}
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
                {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8} = {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}
+               {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "configrpccomponent", "configrpccomponent\configrpccomponent.vcxproj", "{697C6D7E-3109-484C-A7AF-384D28711610}"
        ProjectSection(ProjectDependencies) = postProject
+               {66BED474-C33F-48F9-90BA-BBCFEDC006B8} = {66BED474-C33F-48F9-90BA-BBCFEDC006B8}
                {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
                {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8} = {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}
+               {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
        EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cJSON", "cJSON\cJSON.vcxproj", "{66BED474-C33F-48F9-90BA-BBCFEDC006B8}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Win32 = Debug|Win32
@@ -59,6 +65,10 @@ Global
                {697C6D7E-3109-484C-A7AF-384D28711610}.Debug|Win32.Build.0 = Debug|Win32
                {697C6D7E-3109-484C-A7AF-384D28711610}.Release|Win32.ActiveCfg = Release|Win32
                {697C6D7E-3109-484C-A7AF-384D28711610}.Release|Win32.Build.0 = Release|Win32
+               {66BED474-C33F-48F9-90BA-BBCFEDC006B8}.Debug|Win32.ActiveCfg = Debug|Win32
+               {66BED474-C33F-48F9-90BA-BBCFEDC006B8}.Debug|Win32.Build.0 = Debug|Win32
+               {66BED474-C33F-48F9-90BA-BBCFEDC006B8}.Release|Win32.ActiveCfg = Release|Win32
+               {66BED474-C33F-48F9-90BA-BBCFEDC006B8}.Release|Win32.Build.0 = Release|Win32
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
index bd090f8cd61202cbbfd90455fc156c2d48f477c0..17173c70cc62de8aac2465c3d8d3dce249c70480 100644 (file)
@@ -5,14 +5,21 @@ bin_PROGRAMS =  \
        icinga
 
 icinga_SOURCES =  \
-       connectionmanager.cpp \
-       connectionmanager.h \
+       endpoint.cpp \
+       endpoint.h \
+       endpointmanager.cpp \
+       endpointmanager.h \
        icingaapplication.cpp \
        icingaapplication.h \
-       i2-icinga.h
+       i2-icinga.h \
+       jsonrpcendpoint.cpp \
+       jsonrpcendpoint.h \
+       virtualendpoint.cpp \
+       virtualendpoint.h
 
 icinga_CXXFLAGS = -I${top_srcdir}/base \
        -I${top_srcdir}/jsonrpc  -I${top_srcdir}
 
 icinga_LDFLAGS = $(top_builddir)/jsonrpc/libjsonrpc.la \
-       $(top_builddir)/base/libbase.la
\ No newline at end of file
+       $(top_builddir)/base/libbase.la \
+       ${top_builddir}/cJSON/libcJSON.la
\ No newline at end of file
diff --git a/icinga/connectionmanager.cpp b/icinga/connectionmanager.cpp
deleted file mode 100644 (file)
index 3688eff..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-#include "i2-icinga.h"
-
-using namespace icinga;
-
-void ConnectionManager::SetIdentity(string identity)
-{
-       m_Identity = identity;
-}
-
-string ConnectionManager::GetIdentity(void)
-{
-       return m_Identity;
-}
-
-void ConnectionManager::AddListener(unsigned short port)
-{
-       JsonRpcServer::Ptr server = make_shared<JsonRpcServer>();
-       RegisterServer(server);
-
-       server->MakeSocket();
-       server->Bind(port);
-       server->Listen();
-       server->Start();
-}
-
-void ConnectionManager::AddConnection(string host, short port)
-{
-       JsonRpcClient::Ptr client = make_shared<JsonRpcClient>();
-       RegisterClient(client);
-
-       client->MakeSocket();
-       client->Connect(host, port);
-       client->Start();
-}
-
-void ConnectionManager::RegisterServer(JsonRpcServer::Ptr server)
-{
-       m_Servers.push_front(server);
-       server->OnNewClient += bind_weak(&ConnectionManager::NewClientHandler, shared_from_this());
-}
-
-void ConnectionManager::UnregisterServer(JsonRpcServer::Ptr server)
-{
-       m_Servers.remove(server);
-       // TODO: unbind event
-}
-
-void ConnectionManager::RegisterClient(JsonRpcClient::Ptr client)
-{
-       m_Clients.push_front(client);
-       client->OnNewMessage += bind_weak(&ConnectionManager::NewMessageHandler, shared_from_this());
-       client->OnClosed += bind_weak(&ConnectionManager::CloseClientHandler, shared_from_this());
-       client->OnError += bind_weak(&ConnectionManager::ErrorClientHandler, shared_from_this());
-}
-
-void ConnectionManager::UnregisterClient(JsonRpcClient::Ptr client)
-{
-       m_Clients.remove(client);
-       // TODO: unbind event
-}
-
-int ConnectionManager::NewClientHandler(NewClientEventArgs::Ptr ncea)
-{
-       JsonRpcClient::Ptr client = static_pointer_cast<JsonRpcClient>(ncea->Client);
-       RegisterClient(client);
-
-       return 0;
-}
-
-int ConnectionManager::CloseClientHandler(EventArgs::Ptr ea)
-{
-       JsonRpcClient::Ptr client = static_pointer_cast<JsonRpcClient>(ea->Source);
-       UnregisterClient(client);
-
-       if (client->GetPeerHost() != string()) {
-               Timer::Ptr timer = make_shared<Timer>();
-               timer->SetInterval(30);
-               timer->SetUserArgs(ea);
-               timer->OnTimerExpired += bind_weak(&ConnectionManager::ReconnectClientHandler, shared_from_this());
-               timer->Start();
-               m_ReconnectTimers.push_front(timer);
-       }
-
-       return 0;
-}
-
-int ConnectionManager::ErrorClientHandler(SocketErrorEventArgs::Ptr ea)
-{
-       cout << "Error occured for JSON-RPC socket: Code=" << ea->Code << "; Message=" << ea->Message << endl;
-
-       return 0;
-}
-
-int ConnectionManager::ReconnectClientHandler(TimerEventArgs::Ptr ea)
-{
-       JsonRpcClient::Ptr client = static_pointer_cast<JsonRpcClient>(ea->UserArgs->Source);
-       Timer::Ptr timer = static_pointer_cast<Timer>(ea->Source);
-
-       AddConnection(client->GetPeerHost(), client->GetPeerPort());
-
-       timer->Stop();
-       m_ReconnectTimers.remove(timer);
-
-       return 0;
-}
-
-int ConnectionManager::NewMessageHandler(NewMessageEventArgs::Ptr nmea)
-{
-       JsonRpcMessage::Ptr request = nmea->Message;
-       JsonRpcClient::Ptr client = static_pointer_cast<JsonRpcClient>(nmea->Source);
-
-       map<string, event<NewMessageEventArgs::Ptr> >::iterator i;
-       i = m_Methods.find(request->GetMethod());
-
-       if (i == m_Methods.end()) {
-               JsonRpcMessage::Ptr response = make_shared<JsonRpcMessage>();
-               response->SetVersion("2.0");
-               response->SetError("Unknown method.");
-               response->SetID(request->GetID());
-               Netstring::WriteJSONToFIFO(client->GetSendQueue(), response->GetJSON());
-
-               return 0;
-       }
-
-       i->second(nmea);
-
-       return 0;
-}
-
-void ConnectionManager::RegisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> callback)
-{
-       m_Methods[method] += callback;
-}
-
-void ConnectionManager::UnregisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> callback)
-{
-       // TODO: implement
-       //m_Methods[method] -= callback;
-}
-
-void ConnectionManager::SendMessage(JsonRpcMessage::Ptr message)
-{
-       /* TODO: filter messages based on event subscriptions; also loopback message to our own handlers */
-       for (list<JsonRpcClient::Ptr>::iterator i = m_Clients.begin(); i != m_Clients.end(); i++)
-       {
-               JsonRpcClient::Ptr client = *i;
-               client->SendMessage(message);
-       }
-}
diff --git a/icinga/endpoint.cpp b/icinga/endpoint.cpp
new file mode 100644 (file)
index 0000000..b7c61b1
--- /dev/null
@@ -0,0 +1,18 @@
+#include "i2-icinga.h"
+
+using namespace icinga;
+
+Endpoint::Endpoint(void)
+{
+       m_Connected = false;
+}
+
+void Endpoint::SetConnected(bool connected)
+{
+       m_Connected = connected;
+}
+
+bool Endpoint::GetConnected(void)
+{
+       return m_Connected;
+}
diff --git a/icinga/endpoint.h b/icinga/endpoint.h
new file mode 100644 (file)
index 0000000..c02ad69
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef ENDPOINT_H
+#define ENDPOINT_H
+
+namespace icinga
+{
+
+class EndpointManager;
+
+class I2_ICINGA_API Endpoint : public Object
+{
+private:
+       bool m_Connected;
+
+public:
+       typedef shared_ptr<Endpoint> Ptr;
+       typedef weak_ptr<Endpoint> WeakPtr;
+
+       Endpoint(void);
+
+       virtual void SetConnected(bool connected);
+       virtual bool GetConnected(void);
+
+       virtual void SendMessage(Endpoint::Ptr source, JsonRpcMessage::Ptr message) = 0;
+};
+
+}
+
+#endif /* ENDPOINT_H */
diff --git a/icinga/endpointmanager.cpp b/icinga/endpointmanager.cpp
new file mode 100644 (file)
index 0000000..a4875a9
--- /dev/null
@@ -0,0 +1,139 @@
+#include "i2-icinga.h"
+
+using namespace icinga;
+
+void EndpointManager::SetIdentity(string identity)
+{
+       m_Identity = identity;
+}
+
+string EndpointManager::GetIdentity(void) const
+{
+       return m_Identity;
+}
+
+void EndpointManager::AddListener(unsigned short port)
+{
+       JsonRpcServer::Ptr server = make_shared<JsonRpcServer>();
+       RegisterServer(server);
+
+       server->MakeSocket();
+       server->Bind(port);
+       server->Listen();
+       server->Start();
+}
+
+void EndpointManager::AddConnection(string host, short port)
+{
+       JsonRpcClient::Ptr client = make_shared<JsonRpcClient>();
+       RegisterClient(client);
+
+       client->MakeSocket();
+       client->Connect(host, port);
+       client->Start();
+}
+
+void EndpointManager::RegisterServer(JsonRpcServer::Ptr server)
+{
+       m_Servers.push_front(server);
+       server->OnNewClient += bind_weak(&EndpointManager::NewClientHandler, shared_from_this());
+}
+
+void EndpointManager::UnregisterServer(JsonRpcServer::Ptr server)
+{
+       m_Servers.remove(server);
+       // TODO: unbind event
+}
+
+void EndpointManager::RegisterClient(JsonRpcClient::Ptr client)
+{
+       m_Clients.push_front(client);
+       client->OnNewMessage += bind_weak(&EndpointManager::NewMessageHandler, shared_from_this());
+       client->OnClosed += bind_weak(&EndpointManager::CloseClientHandler, shared_from_this());
+       client->OnError += bind_weak(&EndpointManager::ErrorClientHandler, shared_from_this());
+}
+
+void EndpointManager::UnregisterClient(JsonRpcClient::Ptr client)
+{
+       m_Clients.remove(client);
+       // TODO: unbind event
+}
+
+int EndpointManager::NewClientHandler(NewClientEventArgs::Ptr ncea)
+{
+       JsonRpcClient::Ptr client = static_pointer_cast<JsonRpcClient>(ncea->Client);
+       RegisterClient(client);
+
+       return 0;
+}
+
+int EndpointManager::CloseClientHandler(EventArgs::Ptr ea)
+{
+       JsonRpcClient::Ptr client = static_pointer_cast<JsonRpcClient>(ea->Source);
+       UnregisterClient(client);
+
+       if (client->GetPeerHost() != string()) {
+               Timer::Ptr timer = make_shared<Timer>();
+               timer->SetInterval(30);
+               timer->SetUserArgs(ea);
+               timer->OnTimerExpired += bind_weak(&EndpointManager::ReconnectClientHandler, shared_from_this());
+               timer->Start();
+               m_ReconnectTimers.push_front(timer);
+       }
+
+       return 0;
+}
+
+int EndpointManager::ErrorClientHandler(SocketErrorEventArgs::Ptr ea)
+{
+       cout << "Error occured for JSON-RPC socket: Code=" << ea->Code << "; Message=" << ea->Message << endl;
+
+       return 0;
+}
+
+int EndpointManager::ReconnectClientHandler(TimerEventArgs::Ptr ea)
+{
+       JsonRpcClient::Ptr client = static_pointer_cast<JsonRpcClient>(ea->UserArgs->Source);
+       Timer::Ptr timer = static_pointer_cast<Timer>(ea->Source);
+
+       AddConnection(client->GetPeerHost(), client->GetPeerPort());
+
+       timer->Stop();
+       m_ReconnectTimers.remove(timer);
+
+       return 0;
+}
+
+int EndpointManager::NewMessageHandler(NewMessageEventArgs::Ptr nmea)
+{
+// TODO: implement
+
+       return 0;
+}
+
+void EndpointManager::RegisterEndpoint(Endpoint::Ptr endpoint)
+{
+       m_Endpoints.push_front(endpoint);
+}
+
+void EndpointManager::UnregisterEndpoint(Endpoint::Ptr endpoint)
+{
+       m_Endpoints.remove(endpoint);
+}
+
+void EndpointManager::SendMessage(Endpoint::Ptr source, Endpoint::Ptr destination, JsonRpcMessage::Ptr message)
+{
+       if (destination) {
+               destination->SendMessageA(source, message);
+       } else {
+               for (list<Endpoint::Ptr>::iterator i = m_Endpoints.begin(); i != m_Endpoints.end(); i++)
+               {
+                       Endpoint::Ptr endpoint = *i;
+
+                       if (endpoint == source)
+                               continue;
+
+                       endpoint->SendMessage(source, message);
+               }
+       }
+}
similarity index 58%
rename from icinga/connectionmanager.h
rename to icinga/endpointmanager.h
index 2cd2f2fd8d3566423262aff56f91211d5c6713f5..6d0f1f0e6e079d6b0c3dfa30694e17caa453151a 100644 (file)
@@ -1,15 +1,15 @@
-#ifndef CONNECTIONMANAGER_H
-#define CONNECTIONMANAGER_H
+#ifndef ENDPOINTMANAGER_H
+#define ENDPOINTMANAGER_H
 
 namespace icinga
 {
 
-class ConnectionManager : public Object
+class I2_ICINGA_API EndpointManager : public Object
 {
        list<JsonRpcServer::Ptr> m_Servers;
        list<JsonRpcClient::Ptr> m_Clients;
-       map< string, event<NewMessageEventArgs::Ptr> > m_Methods;
        list<Timer::Ptr> m_ReconnectTimers;
+       list<Endpoint::Ptr> m_Endpoints;
        string m_Identity;
 
        int NewClientHandler(NewClientEventArgs::Ptr ncea);
@@ -23,22 +23,23 @@ class ConnectionManager : public Object
 
        void RegisterServer(JsonRpcServer::Ptr server);
        void UnregisterServer(JsonRpcServer::Ptr server);
+
 public:
-       typedef shared_ptr<ConnectionManager> Ptr;
-       typedef weak_ptr<ConnectionManager> WeakPtr;
+       typedef shared_ptr<EndpointManager> Ptr;
+       typedef weak_ptr<EndpointManager> WeakPtr;
 
        void SetIdentity(string identity);
-       string GetIdentity(void);
+       string GetIdentity(void) const;
 
        void AddListener(unsigned short port);
        void AddConnection(string host, short port);
 
-       void RegisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> callback);
-       void UnregisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> callback);
+       void RegisterEndpoint(Endpoint::Ptr endpoint);
+       void UnregisterEndpoint(Endpoint::Ptr endpoint);
 
-       void SendMessage(JsonRpcMessage::Ptr message);
+       void SendMessage(Endpoint::Ptr source, Endpoint::Ptr destination, JsonRpcMessage::Ptr message);
 };
 
 }
 
-#endif /* CONNECTIONMANAGER_H */
+#endif /* ENDPOINTMANAGER_H */
index 61d091e8a8d81e9bad1f30b3cd4f64ce2ca43fe8..cd37106b47fa0b4201930f2347556ecb100c26a6 100644 (file)
@@ -4,7 +4,16 @@
 #include <i2-base.h>
 #include <i2-jsonrpc.h>
 
-#include "connectionmanager.h"
+#ifdef I2_ICINGA_BUILD
+#      define I2_ICINGA_API I2_EXPORT
+#else /* I2_ICINGA_BUILD */
+#      define I2_ICINGA_API I2_IMPORT
+#endif /* I2_ICINGA_BUILD */
+
+#include "endpoint.h"
+#include "jsonrpcendpoint.h"
+#include "virtualendpoint.h"
+#include "endpointmanager.h"
 #include "icingaapplication.h"
 
 #endif /* I2ICINGA_H */
index 748c461201d231b138b60d040d236209a8c47d67..81cbcd9476b05f6e5242216ca2a1dd69d472d9e3 100644 (file)
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>true</LinkIncremental>
-    <IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\config;$(IncludePath)</IncludePath>
+    <IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
     <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <LinkIncremental>false</LinkIncremental>
-    <IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\config;$(IncludePath)</IncludePath>
+    <IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
     <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@@ -59,7 +59,7 @@
     <Link>
       <SubSystem>Console</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>base.lib;jsonrpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>base.lib;jsonrpc.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>base.lib;jsonrpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>base.lib;jsonrpc.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="connectionmanager.cpp" />
+    <ClCompile Include="endpoint.cpp" />
+    <ClCompile Include="endpointmanager.cpp" />
     <ClCompile Include="icingaapplication.cpp" />
+    <ClCompile Include="jsonrpcendpoint.cpp" />
+    <ClCompile Include="virtualendpoint.cpp" />
   </ItemGroup>
   <ItemGroup>
-    <ClInclude Include="connectionmanager.h" />
+    <ClInclude Include="endpoint.h" />
+    <ClInclude Include="endpointmanager.h" />
     <ClInclude Include="icingaapplication.h" />
     <ClInclude Include="i2-icinga.h" />
+    <ClInclude Include="jsonrpcendpoint.h" />
+    <ClInclude Include="virtualendpoint.h" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
index e39aaa52d2b3d959ca180792fef30cbe0c9bd21a..3ffdae9725746f12a2182111c59c338c50fecf4a 100644 (file)
@@ -11,7 +11,7 @@ using namespace icinga;
 
 IcingaApplication::IcingaApplication(void)
 {
-       m_ConnectionManager = make_shared<ConnectionManager>();
+       m_EndpointManager = make_shared<EndpointManager>();
 }
 
 int IcingaApplication::Main(const vector<string>& args)
@@ -71,9 +71,9 @@ void IcingaApplication::PrintUsage(const string& programPath)
        cout << "Syntax: " << programPath << " <config-file>" << endl;
 }
 
-ConnectionManager::Ptr IcingaApplication::GetConnectionManager(void)
+EndpointManager::Ptr IcingaApplication::GetEndpointManager(void)
 {
-       return m_ConnectionManager;
+       return m_EndpointManager;
 }
 
 int IcingaApplication::NewComponentHandler(ConfigObjectEventArgs::Ptr ea)
@@ -114,7 +114,7 @@ int IcingaApplication::NewRpcListenerHandler(ConfigObjectEventArgs::Ptr ea)
 
        Log("Creating JSON-RPC listener on port %d", port);
 
-       GetConnectionManager()->AddListener(port);
+       GetEndpointManager()->AddListener(port);
 
        return 0;
 }
@@ -140,7 +140,7 @@ int IcingaApplication::NewRpcConnectionHandler(ConfigObjectEventArgs::Ptr ea)
 
        Log("Creating JSON-RPC connection to %s:%d", hostname.c_str(), port);
 
-       GetConnectionManager()->AddConnection(hostname, port);
+       GetEndpointManager()->AddConnection(hostname, port);
 
        return 0;
 }
index 71b7bbfff440980a02643eefe9aa4f081d19b6de..30485b8dec1ff79009b46e475939a33c0951550b 100644 (file)
@@ -4,10 +4,10 @@
 namespace icinga
 {
 
-class IcingaApplication : public Application
+class I2_ICINGA_API IcingaApplication : public Application
 {
 private:
-       ConnectionManager::Ptr m_ConnectionManager;
+       EndpointManager::Ptr m_EndpointManager;
 
        int NewComponentHandler(ConfigObjectEventArgs::Ptr ea);
        int DeletedComponentHandler(ConfigObjectEventArgs::Ptr ea);
@@ -24,11 +24,11 @@ public:
 
        IcingaApplication(void);
 
-       virtual int Main(const vector<string>& args);
+       int Main(const vector<string>& args);
 
        void PrintUsage(const string& programPath);
 
-       virtual ConnectionManager::Ptr GetConnectionManager(void);
+       EndpointManager::Ptr GetEndpointManager(void);
 };
 
 }
diff --git a/icinga/jsonrpcendpoint.cpp b/icinga/jsonrpcendpoint.cpp
new file mode 100644 (file)
index 0000000..22bbf7d
--- /dev/null
@@ -0,0 +1,3 @@
+#include "i2-icinga.h"
+
+using namespace icinga;
diff --git a/icinga/jsonrpcendpoint.h b/icinga/jsonrpcendpoint.h
new file mode 100644 (file)
index 0000000..ffced0d
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef JSONRPCENDPOINT_H
+#define JSONRPCENDPOINT_H
+
+namespace icinga
+{
+
+class I2_ICINGA_API JsonRpcEndpoint : public Endpoint
+{
+public:
+};
+
+}
+
+#endif /* JSONRPCENDPOINT_H */
\ No newline at end of file
diff --git a/icinga/virtualendpoint.cpp b/icinga/virtualendpoint.cpp
new file mode 100644 (file)
index 0000000..c7146d0
--- /dev/null
@@ -0,0 +1,48 @@
+#include "i2-icinga.h"
+
+using namespace icinga;
+
+VirtualEndpoint::VirtualEndpoint()
+{
+       SetConnected(true);
+}
+
+void VirtualEndpoint::RegisterMethodHandler(string method, function<int (NewMessageEventArgs::Ptr)> callback)
+{
+       m_MethodHandlers[method] += callback;
+}
+
+void VirtualEndpoint::UnregisterMethodHandler(string method, function<int (NewMessageEventArgs::Ptr)> callback)
+{
+       // TODO: implement
+       //m_Methods[method] -= callback;
+}
+
+void VirtualEndpoint::RegisterMethodSource(string method)
+{
+       m_MethodSources.push_front(method);
+}
+
+void VirtualEndpoint::UnregisterMethodSource(string method)
+{
+       m_MethodSources.remove(method);
+}
+
+void VirtualEndpoint::SendMessage(Endpoint::Ptr source, JsonRpcMessage::Ptr message)
+{
+       map<string, event<NewMessageEventArgs::Ptr> >::iterator i;
+       i = m_MethodHandlers.find(message->GetMethod());
+
+       if (i == m_MethodHandlers.end()) {
+               JsonRpcMessage::Ptr response = make_shared<JsonRpcMessage>();
+               response->SetVersion("2.0");
+               response->SetError("Unknown method.");
+               response->SetID(message->GetID());
+               source->SendMessage(static_pointer_cast<Endpoint>(shared_from_this()), response);
+       }
+
+       NewMessageEventArgs::Ptr nmea = make_shared<NewMessageEventArgs>();
+       nmea->Source = shared_from_this();
+       nmea->Message = message;
+       i->second(nmea);
+}
diff --git a/icinga/virtualendpoint.h b/icinga/virtualendpoint.h
new file mode 100644 (file)
index 0000000..8c94dc9
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef VIRTUALENDPOINT_H
+#define VIRTUALENDPOINT_H
+
+namespace icinga
+{
+
+class I2_ICINGA_API VirtualEndpoint : public Endpoint
+{
+private:
+       map< string, event<NewMessageEventArgs::Ptr> > m_MethodHandlers;
+       list<string> m_MethodSources;
+
+public:
+       typedef shared_ptr<VirtualEndpoint> Ptr;
+       typedef weak_ptr<VirtualEndpoint> WeakPtr;
+
+       VirtualEndpoint();
+
+       virtual void RegisterMethodHandler(string method, function<int (NewMessageEventArgs::Ptr)> callback);
+       virtual void UnregisterMethodHandler(string method, function<int (NewMessageEventArgs::Ptr)> callback);
+
+       virtual void RegisterMethodSource(string method);
+       virtual void UnregisterMethodSource(string method);
+
+       virtual void SendMessage(Endpoint::Ptr source, JsonRpcMessage::Ptr message);
+};
+
+}
+
+#endif /* VIRTUALENDPOINT_H */
index 7ec7558c20791a905e1ddd37ca1ca9fe45bf36fe..bef23d8ddbeae0c5162f8de6797a2f32d4846712 100644 (file)
@@ -5,8 +5,6 @@ noinst_LTLIBRARIES =  \
        libjsonrpc.la
 
 libjsonrpc_la_SOURCES =  \
-       cJSON.c \
-       cJSON.h \
        i2-jsonrpc.h \
        jsonrpcclient.cpp \
        jsonrpcclient.h \
index 1a2b4311007e82d7a3bd0f69c42c7e0635a3fb9c..a9962f22facc5f0902cf95518bf04811cc8853a3 100644 (file)
@@ -3,8 +3,14 @@
 
 #include <map>
 #include <i2-base.h>
+#include <cJSON.h>
+
+#ifdef I2_JSONRPC_BUILD
+#      define I2_JSONRPC_API I2_EXPORT
+#else /* I2_JSONRPC_BUILD */
+#      define I2_JSONRPC_API I2_IMPORT
+#endif /* I2_JSONRPC_BUILD */
 
-#include "cJSON.h"
 #include "netstring.h"
 #include "jsonrpcmessage.h"
 #include "jsonrpcclient.h"
index 2a321fab90b5adfb6d56fbb2da90093ce6725133..87cbda58ba6365c83fd8702ac6f77d20fc12a9bf 100644 (file)
@@ -11,7 +11,6 @@
     </ProjectConfiguration>
   </ItemGroup>
   <ItemGroup>
-    <ClInclude Include="cJSON.h" />
     <ClInclude Include="i2-jsonrpc.h" />
     <ClInclude Include="jsonrpcclient.h" />
     <ClInclude Include="jsonrpcmessage.h" />
@@ -19,7 +18,6 @@
     <ClInclude Include="netstring.h" />
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="cJSON.c" />
     <ClCompile Include="jsonrpcclient.cpp" />
     <ClCompile Include="jsonrpcmessage.cpp" />
     <ClCompile Include="jsonrpcserver.cpp" />
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
     <UseDebugLibraries>true</UseDebugLibraries>
     <CharacterSet>MultiByte</CharacterSet>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
     <UseDebugLibraries>false</UseDebugLibraries>
     <WholeProgramOptimization>true</WholeProgramOptimization>
     <CharacterSet>MultiByte</CharacterSet>
   </ImportGroup>
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <IncludePath>$(ProjectDir)\..\base;$(IncludePath)</IncludePath>
+    <IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
     <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <IncludePath>$(ProjectDir)\..\base;$(IncludePath)</IncludePath>
+    <IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
     <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
       </PrecompiledHeader>
       <WarningLevel>Level3</WarningLevel>
       <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;I2_JSONRPC_BUILD;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>base.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <Lib>
       <AdditionalDependencies>
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;I2_JSONRPC_BUILD;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>base.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <Lib>
       <AdditionalDependencies>
index ceb13a490ed63a151779b71900f6bdfbc5180a58..408248fbf948b2b0c98332a525d9042028441451 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-struct NewMessageEventArgs : public EventArgs
+struct I2_JSONRPC_API NewMessageEventArgs : public EventArgs
 {
        typedef shared_ptr<NewMessageEventArgs> Ptr;
        typedef weak_ptr<NewMessageEventArgs> WeakPtr;
@@ -12,7 +12,7 @@ struct NewMessageEventArgs : public EventArgs
        JsonRpcMessage::Ptr Message;
 };
 
-class JsonRpcClient : public TCPClient
+class I2_JSONRPC_API JsonRpcClient : public TCPClient
 {
 private:
        int DataAvailableHandler(EventArgs::Ptr ea);
index 22056a94f9d305eb549d77fa4b21f8d3fbfa7672..f6b97f7004f0825259cc90c69cae124d0ef01301 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-class JsonRpcMessage : public Object
+class I2_JSONRPC_API JsonRpcMessage : public Object
 {
 private:
        cJSON *m_JSON;
index fd84d71aa3b6337a57f5f3d386c2f3419b480ad5..b7feb4ea8ba529519435a477e48ef91ee5089117 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-class JsonRpcServer : public TCPServer
+class I2_JSONRPC_API JsonRpcServer : public TCPServer
 {
 public:
        typedef shared_ptr<JsonRpcServer> Ptr;
index 6e6f4c3e2c041733e01d286a25519b890b5c5008..d5c382bd7c16cef1bfa7509c82f7f712e67ee03c 100644 (file)
@@ -4,7 +4,7 @@
 namespace icinga
 {
 
-class Netstring : public Object
+class I2_JSONRPC_API Netstring : public Object
 {
 private:
        size_t m_Length;