From c2fc1997d458ad96db44453ae3771640e6fc5e2b Mon Sep 17 00:00:00 2001 From: Markus Freutsmiedl Date: Fri, 11 Apr 2014 18:11:50 +0200 Subject: [PATCH 01/16] Project settings in project files reworked. Additional information added for windows part in readme. --- CommonAPI-DBus.vcxproj | 8 ++++---- README | 48 +++++++++++++++++++++++++++++++++++++++++++----- UnitTests.vcxproj | 15 +++++++-------- 3 files changed, 54 insertions(+), 17 deletions(-) diff --git a/CommonAPI-DBus.vcxproj b/CommonAPI-DBus.vcxproj index 94b0e1a..3176711 100644 --- a/CommonAPI-DBus.vcxproj +++ b/CommonAPI-DBus.vcxproj @@ -39,8 +39,7 @@ - $(ProjectDir)\src;..\ascgit017.CommonAPI\src;$(DBUS_DIR);$(DBUS_BUILD_DIR);$(IncludePath) - ..\ascgit017.CommonAPI\Debug;$(LibraryPath) + $(ProjectName)d @@ -51,15 +50,15 @@ MultiThreadedDebugDLL OldStyle 4996;%(DisableSpecificWarnings) + $(COMMONAPI_DIR)\src;$(DBUS_BUILD_DIR);$(DBUS_DIR);$(SolutionDir)\src;%(AdditionalIncludeDirectories) true - CommonAPI.dll;dbus-1d.dll;%(AdditionalDependencies) $(ProgramFiles)\dbus\bin\;%(AdditionalLibraryDirectories) /VERBOSE %(AdditionalOptions) - CommonAPI.lib;%(AdditionalDependencies) + %(AdditionalDependencies) @@ -69,6 +68,7 @@ true true true + $(COMMONAPI_DIR)\src;$(DBUS_BUILD_DIR);$(DBUS_DIR);$(SolutionDir)\src;%(AdditionalIncludeDirectories) true diff --git a/README b/README index 284f852..bc5fb08 100644 --- a/README +++ b/README @@ -72,6 +72,31 @@ For example, if CommonAPI and patched dbus are available in /usr/local, set the ---- # export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" ---- +To build the Windows version of the dbus following steps have to be done: +# Download dbus from http://www.freedesktop.org/wiki/Software/dbus/ e.g. dbus-1.8.0.tar.gz + Unpack the archive into a directory +# For building the dbus cmake is needed. Download cmake from http://cmake.org/cmake/resources/software.html + Downloading the zip archive is ok e.g. cmake-2.8.12.2-win32-x86.zip + Unpack the archive into a directory +# For building the dbus expat is needed. Expat can be downloaded from http://expat.sourceforge.net/ + e.g. Download expat-win32bin-2.1.0.exe from http://sourceforge.net/projects/expat/files/expat_win32/2.1.0/ + Install expat +# For patching the dbus patch is needed. Download patch from http://gnuwin32.sourceforge.net/packages/patch.htm e.g. patch-2.5.9-7-setup.exe + Install patch +# Install dbus patch + e.g. \patch.exe -p1 < \dbus-DBusMessage-add-support-for-custom-marshaling.patch +# Build dbus via the cmake command line tool + Open the developer command line for VS2013 + Change into root directory of the unpacked dbus archive e.g. dbus-1.8.0 + Create a new directory dbus-build-dir e.g. mkdir dbus-build-dir + Change into this new created directory e.g. cd dbus-build-dir + Create the Visual Studio files for building the dbus: + cmake -DEXPAT_INCLUDE_DIR="\Source\lib" -DEXPAT_LIBRARY="\Bin\libexpat.lib" -G "Visual Studio 12" \cmake + e.g. C:\Work\cmake-2.8.12.2-win32-x86\bin\cmake.exe -DEXPAT_INCLUDE_DIR="C:\Program Files (x86)\Expat 2.1.0\Source\lib" + -DEXPAT_LIBRARY="C:\Program Files (x86)\Expat 2.1.0\Bin\libexpat.lib" -G "Visual Studio 12" C:\Work\dbus-1.8.0\cmake + The Visual Studio files are created in the directory dbus-build-dir + Open the solution dbus.sln and build all projects + Info for dbus-1.8.0: In file printf.c the #include "test-utils.h" must be changed to #include "test/test-utils.h" === Instructions Use autotools to build this package withthe above requirements available through Pkgconfig : @@ -81,12 +106,16 @@ Use autotools to build this package withthe above requirements available through # make # sudo make install (or alternative install process, eg. checkinstall on debian-based distributions, such as Ubuntu) ---- -To build the Windows version with Visual Studio, you can use the solution file CommonAPI-DBus.sln. It is configured to build CommonAPI-DBus as a static library. -Set the environment variable DBUS_DIR to the directory containing your patched DBus sources. -Set the environment variable DBUS_BUILD_DIR to the directory containing your built DBus. -Add the path of CommonAPI.lib to "Additional Library Directories" +To build the Windows version with Visual Studio 2013, you can use the solution file CommonAPI-DBus.sln. It is configured to build CommonAPI-DBus as a static library. +Before opening the solution file CommonAPI-DBus.sln the following environment variables must be set: +DBUS_DIR: directory containing the patched DBus sources e.g. \dbus-1.8.0 +DBUS_BUILD_DIR: directory containing the build DBus e.g. \dbus-1.8.0\dbus-build-dir +COMMONAPI_DIR: directory containing the CommonAPI e.g. \ascgit017.CommonAPI -To run the tests, you need to add the location of your built dbus-1d.dll to the PATH environment variable +To run the tests, you need to add the location of your built dbus-1d.dll to the PATH environment variable. +Please note: +For building the tests the environment variable GTEST must be set (see README of CommonAPI). +Furthermore the files DemoPoll.h and DemoPoll.cpp are needed (part of gnulib). == Linking against CommonAPI-D-Bus @@ -108,6 +137,15 @@ Generated proxies and stubs also require successful activation of all static ini If they are provided in either a static or dynamic library to the application they must also be linked wrapped in the flags described above. +For linking the proxies and stubs on Windows notice the following information: +# In case an error C4996 occurs disable this warning via the project settings +# Following code must be added to the file containing the call CommonAPI::Runtime::load(): + #define COMMONAPI_INTERNAL_COMPILATION + #include + After loading of the runtime (std::shared_ptr runtime = CommonAPI::Runtime::load();) following code must be added: + // access the middlewareInfo in order to get a call to DBusRuntime. This forces the windows linker not to remove DBusRuntime from resulting binary + std::cout << "Middleware Name: " << CommonAPI::DBus::DBusRuntime::middlewareInfo_.middlewareName_ << std::endl; + === Building and executing the Unit Tests ---- # export GTEST_CONFIG=/path/to/gtest-1.6.0/scripts/gtest-config diff --git a/UnitTests.vcxproj b/UnitTests.vcxproj index ff2528c..5c5ad0e 100644 --- a/UnitTests.vcxproj +++ b/UnitTests.vcxproj @@ -156,9 +156,7 @@ true - $(DBUS_BUILD_DIR)\bin\Debug;$(GTEST)\msvc\gtest\Debug;..\ascgit017.CommonAPI\Debug;$(SolutionDir)\Debug;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86) - $(DBUS_DIR);$(DBUS_BUILD_DIR);$(ProjectDir);$(SolutionDir)\src\test;$(SolutionDir)\src;..\ascgit017.CommonAPI\src;$(GTEST)\include;$(VC_IncludePath);$(WindowsSDK_IncludePath) - $(SourcePath) + $(ProjectName)d true @@ -168,7 +166,7 @@ NotUsing Level3 Disabled - $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + $(DBUS_DIR);$(DBUS_BUILD_DIR);$(SolutionDir)\src;$(SolutionDir)\src\test;$(COMMONAPI_DIR)\src;$(GTEST)\include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) ENABLE_ATTRIBUTE_EXTENSIONS;WIN32;COMMONAPI_INTERNAL_COMPILATION;_DEBUG;%(PreprocessorDefinitions) true true @@ -177,8 +175,8 @@ Console true - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) - CommonAPI-DBus.lib;gtestd.lib;gtest_maind.lib;dbus-1d.lib;Ws2_32.lib;%(AdditionalDependencies) + $(DBUS_BUILD_DIR)\bin\Debug;$(GTEST)\msvc\gtest-md\Debug;$(COMMONAPI_DIR)\Debug;$(SolutionDir)\Debug;$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + CommonAPId.lib;CommonAPI-DBusd.lib;gtestd.lib;gtest_main-mdd.lib;dbus-1d.lib;Ws2_32.lib;%(AdditionalDependencies) @@ -188,7 +186,7 @@ MaxSpeed true true - $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + $(DBUS_DIR);$(DBUS_BUILD_DIR);$(SolutionDir)\src;$(SolutionDir)\src\test;$(COMMONAPI_DIR)\src;$(GTEST)\include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;%(PreprocessorDefinitions) true @@ -197,7 +195,8 @@ true true true - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + $(DBUS_BUILD_DIR)\bin\Release;$(GTEST)\msvc\gtest-md\Release;$(COMMONAPI_DIR)\Release;$(SolutionDir)\Release;$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + CommonAPI.lib;CommonAPI-DBus.lib;gtest.lib;gtest_main-md.lib;dbus-1.lib;Ws2_32.lib;%(AdditionalDependencies) -- 2.7.4 From 31531e88ab2358934e7f5dcdd14e1d5dd662627c Mon Sep 17 00:00:00 2001 From: Markus Freutsmiedl Date: Mon, 14 Apr 2014 10:22:53 +0200 Subject: [PATCH 02/16] Project settings in project files reworked. Release build is possible now. Information about dbus-1.dll added in README. --- CommonAPI-DBus.vcxproj | 10 ++++++---- README | 2 +- UnitTests.vcxproj | 14 ++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CommonAPI-DBus.vcxproj b/CommonAPI-DBus.vcxproj index 3176711..8fb18c3 100644 --- a/CommonAPI-DBus.vcxproj +++ b/CommonAPI-DBus.vcxproj @@ -22,7 +22,7 @@ MultiByte - Application + StaticLibrary false v120 true @@ -51,15 +51,14 @@ OldStyle 4996;%(DisableSpecificWarnings) $(COMMONAPI_DIR)\src;$(DBUS_BUILD_DIR);$(DBUS_DIR);$(SolutionDir)\src;%(AdditionalIncludeDirectories) + false true $(ProgramFiles)\dbus\bin\;%(AdditionalLibraryDirectories) /VERBOSE %(AdditionalOptions) - - %(AdditionalDependencies) - + @@ -69,6 +68,9 @@ true true $(COMMONAPI_DIR)\src;$(DBUS_BUILD_DIR);$(DBUS_DIR);$(SolutionDir)\src;%(AdditionalIncludeDirectories) + WIN32;COMMONAPI_INTERNAL_COMPILATION;COMMONAPI_DBUS_VERSION_MAJOR=2;COMMONAPI_DBUS_VERSION_MINOR=1;%(PreprocessorDefinitions) + OldStyle + 4996;%(DisableSpecificWarnings) true diff --git a/README b/README index bc5fb08..e263841 100644 --- a/README +++ b/README @@ -112,7 +112,7 @@ DBUS_DIR: directory containing the patched DBus sources e.g. \db DBUS_BUILD_DIR: directory containing the build DBus e.g. \dbus-1.8.0\dbus-build-dir COMMONAPI_DIR: directory containing the CommonAPI e.g. \ascgit017.CommonAPI -To run the tests, you need to add the location of your built dbus-1d.dll to the PATH environment variable. +To run the tests, you need to add the location of your built dbus-1d.dll or dbus-1.dll (depending on Debug or Release built) to the PATH environment variable. Please note: For building the tests the environment variable GTEST must be set (see README of CommonAPI). Furthermore the files DemoPoll.h and DemoPoll.cpp are needed (part of gnulib). diff --git a/UnitTests.vcxproj b/UnitTests.vcxproj index 5c5ad0e..f788db5 100644 --- a/UnitTests.vcxproj +++ b/UnitTests.vcxproj @@ -137,7 +137,7 @@ false - DynamicLibrary + Application false v120 true @@ -158,9 +158,7 @@ true $(ProjectName)d - - true - + NotUsing @@ -171,6 +169,7 @@ true true OldStyle + false Console @@ -182,17 +181,16 @@ Level3 - Use + NotUsing MaxSpeed true true $(DBUS_DIR);$(DBUS_BUILD_DIR);$(SolutionDir)\src;$(SolutionDir)\src\test;$(COMMONAPI_DIR)\src;$(GTEST)\include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;%(PreprocessorDefinitions) + ENABLE_ATTRIBUTE_EXTENSIONS;COMMONAPI_INTERNAL_COMPILATION;WIN32;NDEBUG;%(PreprocessorDefinitions) true - Windows - true + Console true true $(DBUS_BUILD_DIR)\bin\Release;$(GTEST)\msvc\gtest-md\Release;$(COMMONAPI_DIR)\Release;$(SolutionDir)\Release;$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) -- 2.7.4 From 163161b6e965f8fdd41352aeccdb8d2c64aaadb8 Mon Sep 17 00:00:00 2001 From: Juergen Gehring Date: Mon, 14 Apr 2014 11:44:17 +0200 Subject: [PATCH 03/16] License for pugixml added. --- .gitignore | 4 +++- LICENSE_pugixml | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 LICENSE_pugixml diff --git a/.gitignore b/.gitignore index 23ee12a..5c8eb8a 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,9 @@ /m4/libtool.m4 /m4/lt*.m4 +/DBusBroadcastTest +/DBusFreedesktopPropertiesTest +/DBusLoadTest /DBusBenchmarkingTest /DBusCommunicationTest /DBusDaemonProxyTest @@ -39,7 +42,6 @@ /DBusVariantOutputStreamTest /DBusVariantTest /DBusAddressTranslatorTest -/.pydevproject /DBusServiceRegistryTest /DBusClientIdTest /DBusConnectionTest diff --git a/LICENSE_pugixml b/LICENSE_pugixml new file mode 100644 index 0000000..796004f --- /dev/null +++ b/LICENSE_pugixml @@ -0,0 +1,23 @@ +This license applies to src/pugiconfig.hpp, src/pugixml.cpp and src/pugixml.hpp: + +The MIT License (MIT) + +Copyright (c) 2006-2012 Arseny Kapoulkine + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file -- 2.7.4 From 6e52023d8bc4b813092b856f7269586eabacdc29 Mon Sep 17 00:00:00 2001 From: Michael Bauer Date: Mon, 14 Apr 2014 14:12:48 +0200 Subject: [PATCH 04/16] fixed compilation problem in DBusBroadcastTest.cpp on Windows --- src/test/DBusBroadcastTest.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/DBusBroadcastTest.cpp b/src/test/DBusBroadcastTest.cpp index 646e663..491baab 100644 --- a/src/test/DBusBroadcastTest.cpp +++ b/src/test/DBusBroadcastTest.cpp @@ -255,10 +255,9 @@ TEST_F(DBusBroadcastTest, ProxysCanUnsubscribeFromBroadcastAndSubscribeAgainInAL for(unsigned int i=0; i<10; i++) { bool callbackArrived = false; - auto broadcastSubscription = broadcastEvent.subscribe([&,i](uint32_t intParam, std::string stringParam) -> CommonAPI::SubscriptionStatus { + auto broadcastSubscription = broadcastEvent.subscribe([&,i](uint32_t intParam, std::string stringParam) { EXPECT_EQ(intParam, i); callbackArrived = true; - return CommonAPI::SubscriptionStatus::RETAIN; }); stub->fireTestPredefinedTypeBroadcastEvent(i, "xyz"); -- 2.7.4 From 32cf8e909ea56dbcfb7f61b43bd600b8a8e5ae93 Mon Sep 17 00:00:00 2001 From: Michael Bauer Date: Tue, 15 Apr 2014 16:52:35 +0200 Subject: [PATCH 05/16] Temporarily removing DBusBroadcastTest.cpp from .sln as the test fails with an assertion Debug error --- UnitTests.vcxproj | 1 - 1 file changed, 1 deletion(-) diff --git a/UnitTests.vcxproj b/UnitTests.vcxproj index f788db5..9ba7a45 100644 --- a/UnitTests.vcxproj +++ b/UnitTests.vcxproj @@ -37,7 +37,6 @@ - -- 2.7.4 From 29bdc128d232478f039ac0100424c8d1d2b5a355 Mon Sep 17 00:00:00 2001 From: Juergen Gehring Date: Tue, 15 Apr 2014 16:54:12 +0200 Subject: [PATCH 06/16] Documentation cleanup. --- README | 317 +++++++++++++++++++++++++++++++++--------------------------- doxygen.cfg | 8 +- 2 files changed, 179 insertions(+), 146 deletions(-) diff --git a/README b/README index e263841..293c1cb 100644 --- a/README +++ b/README @@ -1,55 +1,54 @@ -GENIVI_CommonAPI-D-Bus -====================== +IPC CommonAPI C++ D-Bus +----------------------- :Author: Juergen Gehring - juergen.gehring@bmw.de, Manfred Bathelt - manfred.bathelt@bmw.de -:doctitle: GENIVI_CommonAPI-D-Bus +:doctitle: IPC CommonAPI C++ D-Bus +:version: Copyright ---------- -Copyright (C) 2013, GENIVI Alliance, Inc. -Copyright (C) 2013, BMW AG ++++++++++ +Copyright (C) 2014, BMW AG. +Copyright (C) 2014, GENIVI Alliance, Inc. -This file is part of GENIVI Project IPC Common API. +This file is part of GENIVI Project IPC Common API C++ D-Bus. -Contributions are licensed to the GENIVI Alliance under one or more -Contribution License Agreements or MPL 2.0 . - -(C) Copyright -This Source Code Form is subject to the terms of the -Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with -this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -For further information see https://collab.genivi.org/wiki/display/genivi/SysInfraEGCommonIDLCommonAPIGuide +Contributions are licensed to the GENIVI Alliance under one or more Contribution License Agreements or MPL 2.0. -== License -This project is licensed under MPL 2.0 +License ++++++++ +This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, you can obtain one at http://mozilla.org/MPL/2.0/. -Contribution is done under GENIVI CLA or MPL2.0. +The files MurmurHash3.h, MurmurHash3.cpp, pugiconfig.hpp, pugixml.cpp and pugixml.hpp are subject to the terms of the MIT License (MIT). If a copy of the MIT was not distributed with this file, you can obtain one at http://opensource.org/licenses/MIT. -== Version -The current version can be taken from the git. +Version ++++++++ +{version} -== Common API Overview +Further information ++++++++++++++++++++ +Source code and latest news can be found at http://projects.genivi.org/commonapi/. -Common API and its mechanism specific bindings (e.g. Common API D-Bus) provide a set of libraries and tools to work with -RPC communication in a way independent of wich mechanism is used. It consist currently consists of four subprojects: ----- -CommonAPI - This is the base C++ library, which provides the application interface for users and can - load runtime bindings such as dbus. -CommonAPI-Tools - The eclipse based tools for CommonAPI. This is essentially the code generator for - Franca -> Common API C++ code. -CommonAPI-D-Bus - This is the D-Bus binding C++ library, which provides the necesary code to communicate - over D-Bus. This is invisible to the application code, and simply needs to be linked against. - (This is the current package.) -CommonAPI-D-Bus-Tools - The eclipse based tools for CommonAPI D-Bus. This is the code generator for - Franca -> Common API D-Bus C++ code. ----- -== Build Instructions +Common API Overview +~~~~~~~~~~~~~~~~~~~ + +Common API C++ and its mechanism specific bindings (e.g. Common API D-Bus) provide a set of libraries and tools to work with +RPC communication in a way independent of which mechanism is used. It currently consists of four sub-projects: + +*CommonAPI* - This is the base C++ library, which provides the application interface for users and can load runtime bindings such as DBus. + +*CommonAPI-Tools* - The Eclipse based tools for CommonAPI. This is essentially the code generator for the generation of C++ code from Franca IDL. + +*CommonAPI-D-Bus* - This is the D-Bus binding C++ library, which provides the necessary code to communicate over D-Bus. This is invisible to the application code, and simply needs to be linked against. + +*CommonAPI-D-Bus-Tools* - The eclipse based tools for CommonAPI D-Bus. This is the code generator for Franca IDL to Common API D-Bus C++ code. -=== Requirements +Build Instructions +~~~~~~~~~~~~~~~~~~~ -To build this package the CommonAPI library and a version of libdbus patched with the marshaling patch must be available through PkgConfig. +Linux ++++++ + +To build this package the CommonAPI library and a version of libdbus patched with the marshaling patch must be available through PkgConfig. Instructions for making a patched version of libdbus available in /usr/local: -Instructions for making a patched version of libdbus available in /usr/local: ---- # wget http://dbus.freedesktop.org/releases/dbus/dbus-1.4.16.tar.gz @@ -66,62 +65,87 @@ Instructions for making a patched version of libdbus available in /usr/local: # sudo make -C dbus install # sudo make install-pkgconfigDATA ---- -The path to CommonAPI and patched libdbus pkgconfig files must be added to the PKG_CONFIG_PATH for the entire build process. -For example, if CommonAPI and patched dbus are available in /usr/local, set the PKG_CONFIG_PATH variable as follows: +The path to CommonAPI and patched libdbus pkgconfig files must be added to the +PKG_CONFIG_PATH+ for the entire build process. + +For example, if CommonAPI and patched dbus are available in /usr/local, set the +PKG_CONFIG_PATH+ variable as follows: + ---- # export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" ---- -To build the Windows version of the dbus following steps have to be done: -# Download dbus from http://www.freedesktop.org/wiki/Software/dbus/ e.g. dbus-1.8.0.tar.gz - Unpack the archive into a directory -# For building the dbus cmake is needed. Download cmake from http://cmake.org/cmake/resources/software.html - Downloading the zip archive is ok e.g. cmake-2.8.12.2-win32-x86.zip - Unpack the archive into a directory -# For building the dbus expat is needed. Expat can be downloaded from http://expat.sourceforge.net/ - e.g. Download expat-win32bin-2.1.0.exe from http://sourceforge.net/projects/expat/files/expat_win32/2.1.0/ - Install expat -# For patching the dbus patch is needed. Download patch from http://gnuwin32.sourceforge.net/packages/patch.htm e.g. patch-2.5.9-7-setup.exe - Install patch -# Install dbus patch - e.g. \patch.exe -p1 < \dbus-DBusMessage-add-support-for-custom-marshaling.patch -# Build dbus via the cmake command line tool - Open the developer command line for VS2013 - Change into root directory of the unpacked dbus archive e.g. dbus-1.8.0 - Create a new directory dbus-build-dir e.g. mkdir dbus-build-dir - Change into this new created directory e.g. cd dbus-build-dir - Create the Visual Studio files for building the dbus: - cmake -DEXPAT_INCLUDE_DIR="\Source\lib" -DEXPAT_LIBRARY="\Bin\libexpat.lib" -G "Visual Studio 12" \cmake - e.g. C:\Work\cmake-2.8.12.2-win32-x86\bin\cmake.exe -DEXPAT_INCLUDE_DIR="C:\Program Files (x86)\Expat 2.1.0\Source\lib" - -DEXPAT_LIBRARY="C:\Program Files (x86)\Expat 2.1.0\Bin\libexpat.lib" -G "Visual Studio 12" C:\Work\dbus-1.8.0\cmake - The Visual Studio files are created in the directory dbus-build-dir - Open the solution dbus.sln and build all projects - Info for dbus-1.8.0: In file printf.c the #include "test-utils.h" must be changed to #include "test/test-utils.h" - -=== Instructions -Use autotools to build this package withthe above requirements available through Pkgconfig : + +Now use Autotools to build this package with the above requirements available through Pkgconfig: + ---- # autoreconf -i # ./configure # make # sudo make install (or alternative install process, eg. checkinstall on debian-based distributions, such as Ubuntu) ---- -To build the Windows version with Visual Studio 2013, you can use the solution file CommonAPI-DBus.sln. It is configured to build CommonAPI-DBus as a static library. + +Building and executing the Unit Tests: + +---- +# export GTEST_CONFIG=/path/to/gtest-1.6.0/scripts/gtest-config +# autoreconf -i +# ./configure +# make check +---- + +In order to execute the unit tests, the test framework "Google Test" (available at https://code.google.com/p/googletest/) needs to be available on your system. Google Test comes with a subfolder called "scripts", there you will find a file called "gtest-config". The path to this script has to be set via the environment variable GTEST_CONFIG. After having done so, CommonAPI and CommonAPI-D-Bus can be built and the make command "check" can be executed. + +"make check" builds and executes all tests. As the tests are developed as regression tests, the test output is limited to "OK" and "ERROR" for each test performed. + +Windows ++++++++ + +To build the Windows version of the dbus following steps have to be done: + +- Download dbus from http://www.freedesktop.org/wiki/Software/dbus/ e.g. dbus-1.8.0.tar.gz and unpack the archive into a directory +- For building the dbus CMake is needed. Download CMake from http://cmake.org/cmake/resources/software.html. The result of the download is e.g. cmake-2.8.12.2-win32-x86.zip. Unpack the archive into a directory. +- For building the dbus +expat+ is needed. +Expat+ can be downloaded from http://expat.sourceforge.net/ e.g. Download expat-win32bin-2.1.0.exe from http://sourceforge.net/projects/expat/files/expat_win32/2.1.0/. Install expat. +- Now the dbus patch is needed. Download the patch from http://gnuwin32.sourceforge.net/packages/patch.htm e.g. patch-2.5.9-7-setup.exe and install the patch. +- Install the CommonAPI dbus patch e.g. \patch.exe -p1 < \dbus-DBusMessage-add-support-for-custom-marshaling.patch. +* Build dbus via the CMake command line tool: +** Open the developer command line for VS2013 +** Change into root directory of the unpacked dbus archive e.g. dbus-1.8.0 +** Create a new directory dbus-build-dir e.g. mkdir dbus-build-dir +** Change into this new created directory e.g. cd dbus-build-dir +** Create the Visual Studio files for building the dbus: + +---- +cmake -DEXPAT_INCLUDE_DIR="\Source\lib" + -DEXPAT_LIBRARY="\Bin\libexpat.lib" -G "Visual Studio 12" \cmake +---- + +e.g. C:\Work\cmake-2.8.12.2-win32-x86\bin\cmake.exe + -DEXPAT_INCLUDE_DIR="C:\Program Files (x86)\Expat 2.1.0\Source\lib" + -DEXPAT_LIBRARY="C:\Program Files (x86)\Expat 2.1.0\Bin\libexpat.lib" + -G "Visual Studio 12" C:\Work\dbus-1.8.0\cmake + +The Visual Studio files are created in the directory dbus-build-dir. Open the solution dbus.sln and build all projects. Info for dbus-1.8.0: In file printf.c the #include "test-utils.h" must be changed to #include "test/test-utils.h". + +To build now the Windows version with Visual Studio 2013, you can use the solution file CommonAPI-DBus.sln. It is configured to build CommonAPI-DBus as a static library. + Before opening the solution file CommonAPI-DBus.sln the following environment variables must be set: -DBUS_DIR: directory containing the patched DBus sources e.g. \dbus-1.8.0 -DBUS_BUILD_DIR: directory containing the build DBus e.g. \dbus-1.8.0\dbus-build-dir -COMMONAPI_DIR: directory containing the CommonAPI e.g. \ascgit017.CommonAPI + +* DBUS_DIR: directory containing the patched DBus sources e.g. \dbus-1.8.0 +* DBUS_BUILD_DIR: directory containing the build DBus e.g. \dbus-1.8.0\dbus-build-dir +* COMMONAPI_DIR: directory containing the CommonAPI e.g. \ascgit017.CommonAPI To run the tests, you need to add the location of your built dbus-1d.dll or dbus-1.dll (depending on Debug or Release built) to the PATH environment variable. -Please note: + +[NOTE] For building the tests the environment variable GTEST must be set (see README of CommonAPI). Furthermore the files DemoPoll.h and DemoPoll.cpp are needed (part of gnulib). -== Linking against CommonAPI-D-Bus +Linking +~~~~~~~ -CommonAPI-D-Bus requires successful activation of all static initialization code on library load. Therefore it is necessary to -activate certain linker flags to ensure this is always the case. These are specified in the pkg-config files, but are also -listed here. In case of dynamic linking (.so) --no-as-needed must be specified for the CommonAPI-D-Bus library: +Against CommonAPI ++++++++++++++++++ + +CommonAPI-D-Bus requires successful activation of all static initialization code on library load. Therefore it is necessary to activate certain linker flags to ensure this is always the case. These are specified in the pkg-config files, but are also listed here. In case of dynamic linking (.so) --no-as-needed must be specified for the CommonAPI-D-Bus library: ---- -Wl,--no-as-needed -lCommonAPI-DBus -Wl,--as-needed ---- @@ -131,50 +155,45 @@ In case of static linking --whole-archive must be specified: -Wl,--whole-archive libCommonAPI-DBus.a -Wl,--no-whole-archive ---- -=== Linking generated proxies & stubs +Generated Proxies and Stubs ++++++++++++++++++++++++++++ -Generated proxies and stubs also require successful activation of all static initialization code on load. -If they are provided in either a static or dynamic library to the application they must also be linked wrapped in the -flags described above. +Generated proxies and stubs also require successful activation of all static initialization code on load. If they are provided in either a static or dynamic library to the application they must also be linked wrapped in the flags described above. For linking the proxies and stubs on Windows notice the following information: -# In case an error C4996 occurs disable this warning via the project settings -# Following code must be added to the file containing the call CommonAPI::Runtime::load(): - #define COMMONAPI_INTERNAL_COMPILATION - #include - After loading of the runtime (std::shared_ptr runtime = CommonAPI::Runtime::load();) following code must be added: - // access the middlewareInfo in order to get a call to DBusRuntime. This forces the windows linker not to remove DBusRuntime from resulting binary - std::cout << "Middleware Name: " << CommonAPI::DBus::DBusRuntime::middlewareInfo_.middlewareName_ << std::endl; -=== Building and executing the Unit Tests +* In case an error C4996 occurs disable this warning via the project settings. +* Following code must be added to the file containing the call _CommonAPI::Runtime::load()_: +** #define COMMONAPI_INTERNAL_COMPILATION +** #include + +After loading of the runtime (std::shared_ptr runtime = CommonAPI::Runtime::load();) the following code must be added: + ---- -# export GTEST_CONFIG=/path/to/gtest-1.6.0/scripts/gtest-config -# autoreconf -i -# ./configure -# make check +// access the middlewareInfo in order to get a call to DBusRuntime. This forces the windows linker not to remove DBusRuntime from resulting binary +std::cout << "Middleware Name: " << CommonAPI::DBus::DBusRuntime::middlewareInfo_.middlewareName_ << std::endl; ---- -In order to execute the unit tests, the test framework "Google Test" (available at https://code.google.com/p/googletest/) -needs to be available on your system. Google Test comes with a subfolder called "scripts", there you will find a file called -"gtest-config". The path to this script has to be set via the environment variable GTEST_CONFIG. After having done so, -CommonAPI and CommonAPI-D-Bus can be built and the make command "check" can be executed. -"make check" builds and executes all tests. As the tests are developed as regression tests, the test output is limited to -"OK" and "ERROR" for each test performed. +Configuring CommonAPI +~~~~~~~~~~~~~~~~~~~~~ +Well known name ++++++++++++++++ -== Configuring the D-Bus middleware binding - -=== Well known name The well known name that may be used to identify and dynamically load the D-Bus middleware binding is "DBus". -=== Defining D-Bus Service Parameters +Defining D-Bus Service Parameters ++++++++++++++++++++++++++++++++++ + Normally, a CommonAPI address, format + ---- :: ---- is mapped to a D-Bus address the following way: + ---- # D-Bus Interface Name = ServiceID # D-Bus Connection Name = InstanceID @@ -182,15 +201,15 @@ is mapped to a D-Bus address the following way: ---- For Domain, only the value "local" is allowed in this context, and it has no influence on the associated D-Bus service address values. -In case a proxy or a service should not use the default mapping, it is possible to define config files that use the CommonAPI Address -as a key in order to map any combination of D-Bus address values to it. The config files can be defined locally per binary, globally -per binary or globally for all binaries. If more than one config file is defined and a CommonAPI address is defined more than once -across several config files, the locally defined values override the global ones. If a CommonAPI address is defined more than once -within a single file, the first definition found will be the only definition used. +In case a proxy or a service should not use the default mapping, it is possible to define config files that use the CommonAPI Address as a key in order to map any combination of D-Bus address values to it. The config files can be defined locally per binary, globally per binary or globally for all binaries. -Note: Only one managing interface can be defined per D-Bus object path! +If more than one config file is defined and a CommonAPI address is defined more than once across several config files, the locally defined values override the global ones. If a CommonAPI address is defined more than once within a single file, the first definition found will be the only definition used. + +[NOTE] +Only one managing interface can be defined per D-Bus object path! CommonAPI D-Bus Config files have to be named this way: + ---- # Binary local: "_dbus.conf", e.g. "/usr/bin/myBinary_dbus.conf" if the binary is "/usr/bin/myBinary" # Binary global: "/etc/CommonApiDBus/_dbus.conf", e.g. "/etc/CommonApiDBus/myBinary_dbus.conf" @@ -198,6 +217,7 @@ CommonAPI D-Bus Config files have to be named this way: ---- Each config file may have an arbitrary number of entries of the following format, with each entry being separated from the others by a newline: + ---- [] dbus_connection= @@ -205,57 +225,70 @@ dbus_object= dbus_interface= dbus_predefined= ---- -All "dbus_*"-values are optional. For each such omitted value the default value as described above will be used. For "dbus_predefined", -the default value is "false". -"dbus_predefined" should be used if the associated service of a proxy is a legacy service that does not provide the -"org.freedesktop.DBus.ObjectManager" interface. ----- -# If "dbus_predefined" is set to "false" (which is default), a proxy will try to verify the existence of the specific interface - at the specific connection name and object path, using the "org.freedesktop.DBus.ObjectManager" interface, before it is marked as available. -# If "dbus_predefined" is set to "true", a proxy is marked as available as soon as the connection name of the associated +All "dbus_*"-values are optional. For each such omitted value the default value as described above will be used. For "dbus_predefined", the default value is "false". + +"dbus_predefined" should be used if the associated service of a proxy is a legacy service that does not provide the "org.freedesktop.DBus.ObjectManager" interface. + +* If "dbus_predefined" is set to "false" (which is default), a proxy will try to verify the existence of the specific interface at the specific connection name and object path, using the "org.freedesktop.DBus.ObjectManager" interface, before it is marked as available. +* If "dbus_predefined" is set to "true", a proxy is marked as available as soon as the connection name of the associated service is visible. No further checks will be performed. ----- -=== Defining D-Bus Factory Parameters -If a section in a config file starts with "factory$", it defines a factory configuration, which can be referred to at factory creation. -The name of the factory configuration follows the $ sign. +Defining D-Bus Factory Parameters ++++++++++++++++++++++++++++++++++ + +If a section in a config file starts with "factory$", it defines a factory configuration, which can be referred to at factory creation. The name of the factory configuration follows the $ sign. + ---- [factory$] dbus_bustype= ---- + All "dbus_*"-values are optional. For each such omitted value the default value as described below will be used. # dbus_bustype may be set to "session" or "system" for communication on the user's session bus or on the system wide bus. The default value is "session" -== Remarks on Windows version +Remarks on Windows Version +~~~~~~~~~~~~~~~~~~~~~~~~~~ -On Windows systems there are some drawbacks: -# Calling disconnect and later connect on the same DBusConnection somehow damages the libdbus connection. On Linux -implementation this all works fine. -# The DBusLoadTest revealed that a number of more than about 50 proxies slows down the dbus communication -significantly. That's why we run the DBusLoadTest on windows with just 50 instead of 100 proxies. +Restrictions +++++++++++++ -== Working on the code & contribution +* Calling disconnect and later connect on the same DBusConnection somehow damages the libdbus connection. On Linux implementation this all works fine. +* The DBusLoadTest revealed that a number of more than about 50 proxies slows down the dbus communication significantly. That's why we run the DBusLoadTest on windows with just 50 instead of 100 proxies. -.First get the code from the git: - git clone +Working on the code & contribution +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.Get an overview of all branches: - git branch +- First get the code from the git: +---- +git clone +---- -.Switch to the branch you want to work on (master is the feature branch) and verify that it has switched (* changed) - git checkout - git branch +- Get an overview of all branches: +---- +git branch +---- -.Best practice is to create a local branch based on the current branch: - git branch working_branch +- Switch to the branch you want to work on (master is the feature branch) and verify that it has switched (* changed) +---- +git checkout +git branch +---- + +- Best practice is to create a local branch based on the current branch: +---- +git branch working_branch +---- Start working, best practice is to commit smaller, compilable pieces during the development process that makes it easier to handle later on. -.If you want to commit you changes, send them to the author, you can create a patch like this: - git format-patch working_branch +- If you want to commit you changes, send them to the author, you can create a patch like this: +---- +git format-patch working_branch +---- + +This creates a set of patches that are published via the mailing list. The patches will be discussed and then merged & uploaded on the git by the maintainer. -This creates a set of patches that are published via the mailing list.The patches will be discussed and then merged & uploaded on the git by the maintainer. +Patches can be accepted under MPL 2.0 (see section License). Please be sure that the signed-off-by is set correctly. For more, check out http://gerrit.googlecode.com/svn/documentation/2.0/user-signedoffby.html -Patches can be accepted either under GENIVI Cla or MPL 2.0 (see section License). Please be sure that the signed-off-by is set correctly. For more, check out http://gerrit.googlecode.com/svn/documentation/2.0/user-signedoffby.html diff --git a/doxygen.cfg b/doxygen.cfg index bbae96b..357f4a1 100644 --- a/doxygen.cfg +++ b/doxygen.cfg @@ -398,28 +398,28 @@ EXTRACT_ANON_NSPACES = NO # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. -HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_MEMBERS = YES # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. -HIDE_UNDOC_CLASSES = NO +HIDE_UNDOC_CLASSES = YES # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. -HIDE_FRIEND_COMPOUNDS = NO +HIDE_FRIEND_COMPOUNDS = YES # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. -HIDE_IN_BODY_DOCS = NO +HIDE_IN_BODY_DOCS = YES # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set -- 2.7.4 From cddc9d49f09dc8e455800d8e5982144d9bd7c44a Mon Sep 17 00:00:00 2001 From: Stefan Laner Date: Wed, 9 Apr 2014 10:13:41 +0200 Subject: [PATCH 07/16] Bugfix: DBusEvent does only remove its own subscriptions on unsubscribe / destroy and not all subscriptions for that signal anymore --- src/CommonAPI/DBus/DBusEvent.h | 4 +- src/CommonAPI/DBus/DBusProxyBase.cpp | 4 +- src/CommonAPI/DBus/DBusProxyBase.h | 2 +- src/test/DBusBroadcastTest.cpp | 84 ++++++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 5 deletions(-) diff --git a/src/CommonAPI/DBus/DBusEvent.h b/src/CommonAPI/DBus/DBusEvent.h index 7b43ba2..df21e24 100644 --- a/src/CommonAPI/DBus/DBusEvent.h +++ b/src/CommonAPI/DBus/DBusEvent.h @@ -58,7 +58,7 @@ class DBusEvent: public _EventType, public DBusProxyConnection::DBusSignalHandle virtual ~DBusEvent() { if (this->hasListeners()) - dbusProxy_.removeSignalMemberHandler(subscription_); + dbusProxy_.removeSignalMemberHandler(subscription_, this); } virtual SubscriptionStatus onSignalDBusMessage(const DBusMessage& dbusMessage) { @@ -74,7 +74,7 @@ class DBusEvent: public _EventType, public DBusProxyConnection::DBusSignalHandle } virtual void onLastListenerRemoved(const CancellableListener&) { - dbusProxy_.removeSignalMemberHandler(subscription_); + dbusProxy_.removeSignalMemberHandler(subscription_, this); } template diff --git a/src/CommonAPI/DBus/DBusProxyBase.cpp b/src/CommonAPI/DBus/DBusProxyBase.cpp index f796cfb..a493606 100644 --- a/src/CommonAPI/DBus/DBusProxyBase.cpp +++ b/src/CommonAPI/DBus/DBusProxyBase.cpp @@ -59,8 +59,8 @@ DBusProxyConnection::DBusSignalHandlerToken DBusProxyBase::addSignalMemberHandle justAddFilter); } -bool DBusProxyBase::removeSignalMemberHandler(const DBusProxyConnection::DBusSignalHandlerToken& dbusSignalHandlerToken) { - return dbusConnection_->removeSignalMemberHandler(dbusSignalHandlerToken); +bool DBusProxyBase::removeSignalMemberHandler(const DBusProxyConnection::DBusSignalHandlerToken& dbusSignalHandlerToken, const DBusProxyConnection::DBusSignalHandler* dbusSignalHandler) { + return dbusConnection_->removeSignalMemberHandler(dbusSignalHandlerToken, dbusSignalHandler); } } // namespace DBus diff --git a/src/CommonAPI/DBus/DBusProxyBase.h b/src/CommonAPI/DBus/DBusProxyBase.h index 2896d83..d1a3a51 100644 --- a/src/CommonAPI/DBus/DBusProxyBase.h +++ b/src/CommonAPI/DBus/DBusProxyBase.h @@ -55,7 +55,7 @@ class DBusProxyBase: public virtual CommonAPI::Proxy { DBusProxyConnection::DBusSignalHandler* dbusSignalHandler, const bool justAddFilter = false); - bool removeSignalMemberHandler(const DBusProxyConnection::DBusSignalHandlerToken& dbusSignalHandlerToken); + bool removeSignalMemberHandler(const DBusProxyConnection::DBusSignalHandlerToken& dbusSignalHandlerToken, const DBusProxyConnection::DBusSignalHandler* dbusSignalHandler = NULL); virtual void init() = 0; diff --git a/src/test/DBusBroadcastTest.cpp b/src/test/DBusBroadcastTest.cpp index 491baab..b4eb77e 100644 --- a/src/test/DBusBroadcastTest.cpp +++ b/src/test/DBusBroadcastTest.cpp @@ -387,6 +387,90 @@ TEST_F(DBusBroadcastTest, ProxysCanCancelSubscriptionAndSubscribeAgainWithOtherP broadcastEvent2.unsubscribe(broadcastSubscription2); } +TEST_F(DBusBroadcastTest, ProxysCanUnsubscribeFromBroadcastAndSubscribeAgainWhileOtherProxyIsStillSubscribed) { + // register service + auto stub = std::make_shared(); + + bool serviceRegistered = servicePublisher_->registerService(stub, serviceAddress_, stubFactory_); + for (unsigned int i = 0; !serviceRegistered && i < 100; ++i) { + serviceRegistered = servicePublisher_->registerService(stub, serviceAddress_, stubFactory_); + usleep(10000); + } + ASSERT_TRUE(serviceRegistered); + + // build 2 proxies from same factory + auto proxy = proxyFactory_->buildProxy(serviceAddress_); + auto proxy2 = proxyFactory_->buildProxy(serviceAddress_); + + commonapi::tests::TestInterfaceProxyDefault::TestPredefinedTypeBroadcastEvent& broadcastEvent = + proxy->getTestPredefinedTypeBroadcastEvent(); + + commonapi::tests::TestInterfaceProxyDefault::TestPredefinedTypeBroadcastEvent& broadcastEvent2 = + proxy2->getTestPredefinedTypeBroadcastEvent(); + + bool callback1Arrived = false; + bool callback2Arrived = false; + + // subscribe for each proxy's broadcast event + auto broadcastSubscription = broadcastEvent.subscribeCancellableListener([&](uint32_t intParam, std::string stringParam) -> CommonAPI::SubscriptionStatus { + callback1Arrived = true; + return CommonAPI::SubscriptionStatus::RETAIN; + }); + + auto broadcastSubscription2 = broadcastEvent2.subscribeCancellableListener([&](uint32_t intParam, std::string stringParam) -> CommonAPI::SubscriptionStatus { + callback2Arrived = true; + return CommonAPI::SubscriptionStatus::RETAIN; + }); + + // fire broadcast and wait for results + stub->fireTestPredefinedTypeBroadcastEvent(1, "xyz"); + + for(unsigned int i=0; i<100 && !(callback1Arrived && callback2Arrived); i++) { + usleep(10000); + } + + const bool callbackOnBothSubscriptionsArrived = callback1Arrived && callback2Arrived; + + EXPECT_TRUE(callbackOnBothSubscriptionsArrived); + + // unsubscribe from one proxy's broadcast + broadcastEvent.unsubscribe(broadcastSubscription); + + // fire broadcast again + callback1Arrived = false; + callback2Arrived = false; + + stub->fireTestPredefinedTypeBroadcastEvent(2, "xyz"); + + for(unsigned int i=0; i<100; i++) { + usleep(10000); + } + + const bool onlyCallback2Arrived = !callback1Arrived && callback2Arrived; + + EXPECT_TRUE(onlyCallback2Arrived); + + // subscribe first proxy again + broadcastSubscription = broadcastEvent.subscribeCancellableListener([&](uint32_t intParam, std::string stringParam) -> CommonAPI::SubscriptionStatus { + callback1Arrived = true; + return CommonAPI::SubscriptionStatus::RETAIN; + }); + + // fire broadcast another time + callback1Arrived = false; + callback2Arrived = false; + + stub->fireTestPredefinedTypeBroadcastEvent(1, "xyz"); + + for(unsigned int i=0; i<100 && !(callback1Arrived && callback2Arrived); i++) { + usleep(10000); + } + + const bool callbackOnBothSubscriptionsArrivedAgain = callback1Arrived && callback2Arrived; + + EXPECT_TRUE(callbackOnBothSubscriptionsArrivedAgain); +} + TEST_F(DBusBroadcastTest, ProxysCanSubscribeForSelectiveBroadcast) -- 2.7.4 From c35cdcc6e360e2f11c5ca6137099c4318fd04f1f Mon Sep 17 00:00:00 2001 From: Stefan Laner Date: Wed, 9 Apr 2014 10:36:46 +0200 Subject: [PATCH 08/16] removed compile warnings in DBusBraodcastTest --- src/test/DBusBroadcastTest.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/DBusBroadcastTest.cpp b/src/test/DBusBroadcastTest.cpp index b4eb77e..ea184ef 100644 --- a/src/test/DBusBroadcastTest.cpp +++ b/src/test/DBusBroadcastTest.cpp @@ -469,6 +469,9 @@ TEST_F(DBusBroadcastTest, ProxysCanUnsubscribeFromBroadcastAndSubscribeAgainWhil const bool callbackOnBothSubscriptionsArrivedAgain = callback1Arrived && callback2Arrived; EXPECT_TRUE(callbackOnBothSubscriptionsArrivedAgain); + + broadcastEvent.unsubscribe(broadcastSubscription); + broadcastEvent2.unsubscribe(broadcastSubscription2); } -- 2.7.4 From 3a18da1a04e6b7860fde158966138c9e0bd5c7a6 Mon Sep 17 00:00:00 2001 From: Stefan Laner Date: Tue, 22 Apr 2014 15:15:05 +0200 Subject: [PATCH 09/16] fixed unsubscribe mechanism in DBusEvent and added additional tests for Broadcasts --- src/test/DBusBroadcastTest.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/DBusBroadcastTest.cpp b/src/test/DBusBroadcastTest.cpp index ea184ef..b07571a 100644 --- a/src/test/DBusBroadcastTest.cpp +++ b/src/test/DBusBroadcastTest.cpp @@ -348,7 +348,7 @@ TEST_F(DBusBroadcastTest, ProxysCanCancelSubscriptionAndSubscribeAgainWithOtherP bool callbackArrived = false; - auto broadcastSubscription = broadcastEvent.subscribeCancellableListener([&](uint32_t intParam, std::string stringParam) -> CommonAPI::SubscriptionStatus { + broadcastEvent.subscribeCancellableListener([&](uint32_t intParam, std::string stringParam) -> CommonAPI::SubscriptionStatus { EXPECT_EQ(intParam, 1); callbackArrived = true; return CommonAPI::SubscriptionStatus::CANCEL; @@ -383,7 +383,6 @@ TEST_F(DBusBroadcastTest, ProxysCanCancelSubscriptionAndSubscribeAgainWithOtherP ASSERT_TRUE(callbackArrived); - broadcastEvent.unsubscribe(broadcastSubscription); broadcastEvent2.unsubscribe(broadcastSubscription2); } -- 2.7.4 From a62a84b5db8f2b9a79a79f8102a2b3ead6eddb7f Mon Sep 17 00:00:00 2001 From: Juergen Gehring Date: Thu, 8 May 2014 16:11:41 +0200 Subject: [PATCH 10/16] Commented out disabled connection test. --- src/test/DBusConnectionTest.cpp | 104 ++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/src/test/DBusConnectionTest.cpp b/src/test/DBusConnectionTest.cpp index 8477e38..00d41fa 100644 --- a/src/test/DBusConnectionTest.cpp +++ b/src/test/DBusConnectionTest.cpp @@ -304,60 +304,60 @@ TEST_F(DBusConnectionTest, LibdbusConnectionsMayCommitSuicide) { dispatchThread.join(); } -std::promise promise2; -std::future future2 = promise2.get_future(); -std::promise promise3; -std::future future3 = promise3.get_future(); - -void noPartnerCallback(DBusPendingCall*, void* data) { - ::DBusConnection* libdbusConnection = reinterpret_cast(data); - dbus_connection_close(libdbusConnection); - dbus_connection_unref(libdbusConnection); - promise2.set_value(true); -} - -void noPartnerCleanup(void* data) { - promise3.set_value(true); -} +//std::promise promise2; +//std::future future2 = promise2.get_future(); +//std::promise promise3; +//std::future future3 = promise3.get_future(); +// +//void noPartnerCallback(DBusPendingCall*, void* data) { +// ::DBusConnection* libdbusConnection = reinterpret_cast(data); +// dbus_connection_close(libdbusConnection); +// dbus_connection_unref(libdbusConnection); +// promise2.set_value(true); +//} +// +//void noPartnerCleanup(void* data) { +// promise3.set_value(true); +//} // libdbus bug -TEST_F(DBusConnectionTest, DISABLED_TimeoutForNonexistingServices) { - const ::DBusBusType libdbusType = ::DBusBusType::DBUS_BUS_SESSION; - ::DBusError libdbusError; - dbus_error_init(&libdbusError); - ::DBusConnection* libdbusConnection = dbus_bus_get_private(libdbusType, &libdbusError); - - assert(libdbusConnection); - dbus_connection_set_exit_on_disconnect(libdbusConnection, false); - - auto dispatchThread = std::thread(&dispatch, libdbusConnection); - - ::DBusMessage* libdbusMessageCall = dbus_message_new_method_call( - "some.connection.somewhere", - "/some/non/existing/object", - "some.interface.somewhere.but.same.place", - "NoReasonableMethod"); - - dbus_message_set_signature(libdbusMessageCall, ""); - - - DBusPendingCall* libdbusPendingCall; - - dbus_connection_send_with_reply( - libdbusConnection, - libdbusMessageCall, - &libdbusPendingCall, - 5000); - - dbus_pending_call_set_notify( - libdbusPendingCall, - noPartnerCallback, - libdbusConnection, - noPartnerCleanup); - - ASSERT_EQ(true, future2.get()); - dispatchThread.join(); -} +//TEST_F(DBusConnectionTest, DISABLED_TimeoutForNonexistingServices) { +// const ::DBusBusType libdbusType = ::DBusBusType::DBUS_BUS_SESSION; +// ::DBusError libdbusError; +// dbus_error_init(&libdbusError); +// ::DBusConnection* libdbusConnection = dbus_bus_get_private(libdbusType, &libdbusError); +// +// assert(libdbusConnection); +// dbus_connection_set_exit_on_disconnect(libdbusConnection, false); +// +// auto dispatchThread = std::thread(&dispatch, libdbusConnection); +// +// ::DBusMessage* libdbusMessageCall = dbus_message_new_method_call( +// "some.connection.somewhere", +// "/some/non/existing/object", +// "some.interface.somewhere.but.same.place", +// "NoReasonableMethod"); +// +// dbus_message_set_signature(libdbusMessageCall, ""); +// +// +// DBusPendingCall* libdbusPendingCall; +// +// dbus_connection_send_with_reply( +// libdbusConnection, +// libdbusMessageCall, +// &libdbusPendingCall, +// 5000); +// +// dbus_pending_call_set_notify( +// libdbusPendingCall, +// noPartnerCallback, +// libdbusConnection, +// noPartnerCleanup); +// +// ASSERT_EQ(true, future2.get()); +// dispatchThread.join(); +//} #ifndef WIN32 int main(int argc, char** argv) { -- 2.7.4 From fffba1b6b48befe8e2ea4483c8d94930296245a3 Mon Sep 17 00:00:00 2001 From: Juergen Gehring Date: Thu, 12 Jun 2014 11:05:04 +0200 Subject: [PATCH 11/16] Added NEWS file for release 2.1.6 --- NEWS | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 NEWS diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..3e45246 --- /dev/null +++ b/NEWS @@ -0,0 +1,25 @@ + +This is CommonAPI-D-Bus 2.1.6 + +Changes since 2.1.5 + +- enhanced Windows Support +- fixed compile warnings +- fixed asciidoc errors +- fixed unsubscribe mechanism in DBusEvent and added additional tests for Broadcasts +- removed compile warnings in DBusBraodcastTest +- Bugfix: DBusEvent does only remove its own subscriptions on unsubscribe / destroy and not all subscriptions for that signal anymore +- fixed compilation problem in DBusBroadcastTest.cpp on Windows +- improved DBusBroadcastTest and DBusLoadTest +- pushed wait time in DBusServiceRegistryTest.SubscribeBeforeConnectWorks to 5 seconds, to avoid timing issues on windows +- removing VERBOSE command line flags +- making Unittests.vcxproj compile and adapting README to tell developer how he is able to run UnitTests.exe +- modified vcxproj file of UnitTests to now use environment variables and relative paths, adapted build execution order in .sln +- modified vcxproj file of CommonAPI-DBus to now use environment variables and relative paths, adapted README accordingly +- added unit tests for broadcast subscriptions. renamed unit test DBusSelectiveBroadcastTest to DBusBroadcastTest +- Implemented stub support for org.freedesktop.DBus.Properties +- Removed fulfilling of purely internal promises in ServiceRegistry. +- fix for GENIVI bug 164 "Interface names starting with org.freedesktop.* are ignored" +- All public inline functions arn't anymore inline - methods with templates excluded +- Timeout for introspection call in DBusServiceRegistry set to default value +- Windows support, fixed attribute handling with inherited interfaces -- 2.7.4 From 7a68f4e1376b36243fcda736f6a0b3fbce0a5cd6 Mon Sep 17 00:00:00 2001 From: Mikko Ylinen Date: Wed, 13 Aug 2014 13:14:33 +0300 Subject: [PATCH 12/16] Add .gbs.conf Change-Id: I158d799a02d1f00d4ce03093526b5b60085d83a9 Signed-off-by: Mikko Ylinen --- .gbs.conf | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gbs.conf diff --git a/.gbs.conf b/.gbs.conf new file mode 100644 index 0000000..fa9fdc5 --- /dev/null +++ b/.gbs.conf @@ -0,0 +1,3 @@ +[general] +upstream_branch = upstream +upstream_tag = ${upstreamversion} -- 2.7.4 From 89ef290ddea1621c32ff96cbd4d1cbef2ac9b7dd Mon Sep 17 00:00:00 2001 From: Mikko Ylinen Date: Wed, 13 Aug 2014 13:18:46 +0300 Subject: [PATCH 13/16] Add tizen packaging files Change-Id: I0652f90b0c83e222aab0f6a8525e07643520f560 Signed-off-by: Mikko Ylinen --- packaging/CommonAPI-DBus.spec | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 packaging/CommonAPI-DBus.spec diff --git a/packaging/CommonAPI-DBus.spec b/packaging/CommonAPI-DBus.spec new file mode 100755 index 0000000..213500c --- /dev/null +++ b/packaging/CommonAPI-DBus.spec @@ -0,0 +1,65 @@ +%bcond_with dbus_patch_enabled + +Name: CommonAPI-DBus +Summary: GENIVI IPC Common API C++ DBus +Version: 2.1.6 +Release: 0 +Group: Automotive/GENIVI +License: MPL-2.0 +Source0: %{name}-%{version}.tar.gz +BuildRequires: pkgconfig(CommonAPI) +BuildRequires: pkgconfig(dbus-1) +BuildRequires: pkgconfig(glib-2.0) +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description +GENIVI IPC Common API C++ DBus components + +%package -n libCommonAPI-DBus +Summary: CommonAPI C++ DBus libraries + +%description -n libCommonAPI-DBus +GENIVI IPC CommonAPI C++ DBus libraries + +%package devel +Summary: CommonAPI C++ DBus devel package +Requires: libCommonAPI-DBus = %{version}-%{release} + +%description devel +Files needed to build against CommonAPI. + +%prep +%setup -q + +%build +autoreconf -i +%configure \ +%if %{with dbus_patch_enabled} + CXXFLAGS=-DDBUS_PATCH_ENABLED +%endif + +make %{?jobs:-j%jobs} + +%install +%make_install + +%post -n libCommonAPI-DBus -p /sbin/ldconfig + +%postun -n libCommonAPI-DBus -p /sbin/ldconfig + +%files -n libCommonAPI-DBus +%defattr(-,root,root,-) +%{_libdir}/*so.* +%license LICENSE +%license LICENSE_MurmurHash +%license LICENSE_pugixml + +%files devel +%defattr(-,root,root,-) +%license LICENSE +%license LICENSE_pugixml +%{_includedir}/CommonAPI-2.1/CommonAPI/* +%{_includedir}/CommonAPI-2.1/pugixml/* +%{_libdir}/*.so +%{_libdir}/pkgconfig/*.pc -- 2.7.4 From 26428bc4aef787a51c1bbaaa1f0104a1161f557e Mon Sep 17 00:00:00 2001 From: Mikko Ylinen Date: Wed, 13 Aug 2014 13:26:58 +0300 Subject: [PATCH 14/16] Add a workaround to DBusMessage.cpp build failure CommonAPI-DBus depends on a DBus patch that is not (yet) applied in Tizen. Stub out the problematic DBus functions but make it via a build config option. Add README.Tizen to explain the steps to build a modified dbus and CommonAPI-DBus using that with GBS. Change-Id: I161f2a2a617c18ec343508b86af57f898186d75c Signed-off-by: Mikko Ylinen --- README.Tizen | 21 +++++++++++++++++++++ src/CommonAPI/DBus/DBusMessage.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 README.Tizen diff --git a/README.Tizen b/README.Tizen new file mode 100644 index 0000000..6b4cfe2 --- /dev/null +++ b/README.Tizen @@ -0,0 +1,21 @@ +README.Tizen + +The DBus patch needed by CommonAPI-DBus is not applied in Tizen DBus. +Therefore, a local build is needed to enable full CommonAPI-DBus +functionality. + +# STEPS + +1. git clone dbus, common-api-runtime, and common-api-dbus-runtime in the same + directory (e.g., 'franca/') +2. Apply dbus-DBusMessage-add-support-for-custom-marshaling.patch to dbus +3. run gbs build with + '--include-all --define "_with_dbus_patch_enabled 1" franca/', e.g., + + gbs build -A i586 -R \ + http://download.tizen.org/releases/daily/tizen/ivi/latest/repos/atom/packages/ \ + --skip-conf-repos --include-all --define "_with_dbus_patch_enabled 1" franca/ + + (it builds dbus, common-api-runtime, and common-api-dbus-runtime in one go) + +4. Install the libraries in the image. diff --git a/src/CommonAPI/DBus/DBusMessage.cpp b/src/CommonAPI/DBus/DBusMessage.cpp index 512ed57..ac9148f 100644 --- a/src/CommonAPI/DBus/DBusMessage.cpp +++ b/src/CommonAPI/DBus/DBusMessage.cpp @@ -100,8 +100,12 @@ DBusMessage DBusMessage::createMethodCall(const char* busName, methodName); assert(libdbusMessageCall); +#ifdef DBUS_PATCH_ENABLED if (signature) dbus_message_set_signature(libdbusMessageCall, signature); +#else + (void)signature; +#endif const bool increaseLibdbusMessageReferenceCount = false; return DBusMessage(libdbusMessageCall, increaseLibdbusMessageReferenceCount); @@ -128,8 +132,12 @@ DBusMessage DBusMessage::createMethodReturn(const char* signature) const { ::DBusMessage* libdbusMessageReturn = dbus_message_new_method_return(libdbusMessage_); assert(libdbusMessageReturn); +#ifdef DBUS_PATCH_ENABLED if (signature) dbus_message_set_signature(libdbusMessageReturn, signature); +#else + (void)signature; +#endif const bool increaseLibdbusMessageReferenceCount = false; return DBusMessage(libdbusMessageReturn, increaseLibdbusMessageReferenceCount); @@ -160,8 +168,12 @@ DBusMessage DBusMessage::createSignal(const char* objectPath, signalName); assert(libdbusMessageSignal); +#ifdef DBUS_PATCH_ENABLED if (signature) dbus_message_set_signature(libdbusMessageSignal, signature); +#else + (void)signature; +#endif const bool increaseLibdbusMessageReferenceCount = false; return DBusMessage(libdbusMessageSignal, increaseLibdbusMessageReferenceCount); @@ -253,19 +265,35 @@ const DBusMessage::Type DBusMessage::getType() const { } char* DBusMessage::getBodyData() const { +#ifdef DBUS_PATCH_ENABLED return dbus_message_get_body(libdbusMessage_); +#else + return NULL; +#endif } int DBusMessage::getBodyLength() const { +#ifdef DBUS_PATCH_ENABLED return dbus_message_get_body_length(libdbusMessage_); +#else + return 0; +#endif } int DBusMessage::getBodySize() const { +#ifdef DBUS_PATCH_ENABLED return dbus_message_get_body_allocated(libdbusMessage_); +#else + return 0; +#endif } bool DBusMessage::setBodyLength(const int bodyLength) { +#ifdef DBUS_PATCH_ENABLED return dbus_message_set_body_length(libdbusMessage_, bodyLength); +#else + return 0; +#endif } bool DBusMessage::setDestination(const char* destination) -- 2.7.4 From f5383391b93eaa4640494f87bbadeb7ad97504a9 Mon Sep 17 00:00:00 2001 From: Mikko Ylinen Date: Wed, 13 Aug 2014 13:31:53 +0300 Subject: [PATCH 15/16] Add .changes file with initial release notes Change-Id: I7d392ba349887726429f76438369b05cf4a5515e Signed-off-by: Mikko Ylinen --- packaging/CommonAPI-DBus.changes | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 packaging/CommonAPI-DBus.changes diff --git a/packaging/CommonAPI-DBus.changes b/packaging/CommonAPI-DBus.changes new file mode 100644 index 0000000..6b5e70a --- /dev/null +++ b/packaging/CommonAPI-DBus.changes @@ -0,0 +1,3 @@ +* Wed Aug 13 2014 Mikko Ylinen 2.1.6-3-g26428bc +- Initial Tizen release (v2.1.6) +- Add a workaround to DBusMessage.cpp build failure -- 2.7.4 From a1dd3cf92c548e65b3a8bd2b83f35902a5450a6d Mon Sep 17 00:00:00 2001 From: =?utf8?q?K=C3=A9vin=20THIERRY?= Date: Fri, 26 Sep 2014 13:36:54 +0200 Subject: [PATCH 16/16] Packaging: add missing de pendency to pkgconfig MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Ibf9eb2f48a1989ddec9b6b37c94ecec6124ef844 Signed-off-by: Kévin THIERRY --- packaging/CommonAPI-DBus.spec | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packaging/CommonAPI-DBus.spec b/packaging/CommonAPI-DBus.spec index 213500c..142dc70 100755 --- a/packaging/CommonAPI-DBus.spec +++ b/packaging/CommonAPI-DBus.spec @@ -7,6 +7,7 @@ Release: 0 Group: Automotive/GENIVI License: MPL-2.0 Source0: %{name}-%{version}.tar.gz +BuildRequires: pkgconfig BuildRequires: pkgconfig(CommonAPI) BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(glib-2.0) @@ -36,10 +37,10 @@ Files needed to build against CommonAPI. autoreconf -i %configure \ %if %{with dbus_patch_enabled} - CXXFLAGS=-DDBUS_PATCH_ENABLED + CXXFLAGS=-DDBUS_PATCH_ENABLED %endif -make %{?jobs:-j%jobs} +%__make %{?_smp_mflags} %install %make_install -- 2.7.4