Quick Fix for correspondence with legacy services, updated test cases.
authorPhilip Rauwolf <rauwolf@itestra.de>
Tue, 5 Feb 2013 15:54:37 +0000 (16:54 +0100)
committerPhilip Rauwolf <rauwolf@itestra.de>
Tue, 5 Feb 2013 15:54:37 +0000 (16:54 +0100)
20 files changed:
Makefile.am
TODO
src/CommonAPI/DBus/DBusServiceRegistry.cpp
src/CommonAPI/DBus/DBusServiceRegistry.h
src/CommonAPI/DBus/DBusUtils.h
src/test/DBusAddressTranslatorTest.cpp
src/test/DBusProxyTest.cpp
src/test/DBusStubAdapterTest.cpp
src/test/fakeLegacyService/fake.legacy.service.xml [new file with mode: 0644]
src/test/fakeLegacyService/fake/legacy/service/LegacyInterface.h [new file with mode: 0644]
src/test/fakeLegacyService/fake/legacy/service/LegacyInterfaceDBusProxy.cpp [new file with mode: 0644]
src/test/fakeLegacyService/fake/legacy/service/LegacyInterfaceDBusProxy.h [new file with mode: 0644]
src/test/fakeLegacyService/fake/legacy/service/LegacyInterfaceProxy.h [new file with mode: 0644]
src/test/fakeLegacyService/fake/legacy/service/LegacyInterfaceProxyBase.h [new file with mode: 0644]
src/test/fakeLegacyService/fakeLegacyService.fidl [new file with mode: 0644]
src/test/fakeLegacyService/fakeLegacyService.py [new file with mode: 0644]
src/test/fakeLegacyService/sendToFakeLegacyService.py [new file with mode: 0644]
src/test/test-derived-types.fidl [new file with mode: 0644]
src/test/test-interface-proxy.fidl [new file with mode: 0644]
src/test/test-predefined-types.fidl [new file with mode: 0644]

index 615be33..16f680b 100644 (file)
@@ -84,7 +84,8 @@ TestInterfaceSources = \
                src/test/commonapi/tests/DerivedTypeCollection.cpp \
                src/test/commonapi/tests/TestInterfaceDBusProxy.cpp \
                src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp \
-               src/test/commonapi/tests/TestInterfaceStubDefault.cpp
+               src/test/commonapi/tests/TestInterfaceStubDefault.cpp \
+               src/test/fakeLegacyService/fake/legacy/service/LegacyInterfaceDBusProxy.cpp
 
 check_PROGRAMS = \
                DBusAddressTranslatorTest \
diff --git a/TODO b/TODO
index 57a34d6..01bf31e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -8,9 +8,6 @@ Remaining issues:
   * When one of the defined error codes is thrown
 - Search for an appropriate file in global configuration directory ("/etc/commonapi-dbus/<BinaryName>_dbus.conf").
 - To check: Giving a serviceName now could influence the interfaceName on registering a proxy or service.
-  * Current situation:
-    # Given service name only alters the name under which the proxy/service is registered.
-    # The given service name does NOT influence communication, here always the predefined interface name is used.
   * Reasons to support alternative interface names for a given proxy:
     # Some legacy service might exist that has a deviating interface name.
   * Alternative:
@@ -18,6 +15,13 @@ Remaining issues:
     # Ignore the given service name on DBus level.
 - Incorporate checks on binary-file-name-retrieval in unit test.
 - Incorporate test on cooperation of "getAvailableServices" and the DBusAddressTranslator
+- Aufräumen in DBusServiceRegistry! Hier ist scheinbar einiges doppelt und/oder undurchsichtig.
+  * "IsServiceInstanceAlive": Sollte bereits true returnen, wenn nur die Connection dazu lebt.
+    --> Use Cases:
+        # Legacy services implementieren eher nicht "getManagedObjects"
+        # Dienste sollen nicht aufgeweckt werden, wenn z.B. nur ein Proxy für sie angelegt wird
+    --> Macht das den ObjectManager obsolet?
+    --> Können beide Mechanismen sinnvoll nebeneinander existieren?
 
 
 -----
@@ -83,6 +87,13 @@ Bestehende Tests durchgehen und in aktuelle Version überführen! Nicht aktuell:
 - DBusNameCacheTest
 - ?
 
+Discussion: Does the ServiceRegistry really NEED to ask ALL targets EVERY startup for their managed objects?
+Alternatives:
+- On demand, as this is only necessary for the factory method "getAllAvailableServices"
+- Specific proxy asks only for its own defined service, does not implicitly start the registration
+  of all services with the local ObjectManager
+
+
 * Move Version checking to the ServiceRegistry:
        Currently, ensuring the interface-version based compatibility of the local proxy and
        a given remote service would be done asynchronously within the proxy right after its creation.
index b34cb52..85a18a8 100644 (file)
@@ -42,7 +42,6 @@ DBusServiceRegistry::DBusServiceRegistry(std::shared_ptr<DBusConnection> dbusCon
 \r
 void DBusServiceRegistry::registerAvailabilityListener(const std::string& service, const std::function<void(bool)>& listener) {\r
     availabilityCallbackList.insert({service, listener});\r
-\r
 }\r
 \r
 DBusServiceStatusEvent& DBusServiceRegistry::getServiceStatusEvent() {\r
@@ -154,6 +153,11 @@ bool DBusServiceRegistry::isServiceInstanceAlive(const std::string& dbusInterfac
         }\r
         ++knownInstancesForInterfaceIteratorPair.first;\r
     }\r
+\r
+    if(dbusLivingServiceBusNames_.find(dbusConnectionName) != dbusLivingServiceBusNames_.end()) {\r
+        return true;\r
+    }\r
+\r
     return false;\r
 }\r
 \r
@@ -217,7 +221,7 @@ void DBusServiceRegistry::addProvidedServiceInstancesToCache(const std::string&
        getManagedObjects(dbusNames);\r
 }\r
 \r
-void DBusServiceRegistry::addProvidedServiceInstancesToCache(std::vector<std::string>& dbusNames) {\r
+void DBusServiceRegistry::addProvidedServiceInstancesToCache(const std::set<std::string>& dbusNames) {\r
 \r
     std::shared_ptr<std::list<std::string>> dbusList = std::make_shared<std::list<std::string>>(dbusNames.begin(), dbusNames.end());\r
 \r
@@ -285,15 +289,14 @@ void DBusServiceRegistry::removeProvidedServiceInstancesFromCache(const std::str
 void DBusServiceRegistry::onListNames(const CommonAPI::CallStatus& callStatus, std::vector<std::string> existingBusConnections) {\r
 \r
        if (callStatus == CallStatus::SUCCESS) {\r
-               std::vector<std::string> dbusLivingServiceBusNames;\r
                for (const std::string& connectionName : existingBusConnections) {\r
                        const bool isWellKnownName = (connectionName[0] != ':');\r
 \r
                        if (isWellKnownName) {\r
-                               dbusLivingServiceBusNames.push_back(connectionName);\r
+                               dbusLivingServiceBusNames_.insert(connectionName);\r
                        }\r
                }\r
-               addProvidedServiceInstancesToCache(dbusLivingServiceBusNames);\r
+               addProvidedServiceInstancesToCache(dbusLivingServiceBusNames_);\r
        }\r
 }\r
 \r
index 6360936..35d96a9 100644 (file)
@@ -23,6 +23,7 @@
 #include <list>\r
 #include <mutex>\r
 #include <algorithm>\r
+#include <set>\r
 \r
 namespace CommonAPI {\r
 namespace DBus {\r
@@ -58,6 +59,7 @@ class DBusServiceRegistry {
     bool isServiceInstanceAlive(const std::string& dbusInterfaceName,\r
                                 const std::string& dbusConnectionName,\r
                                 const std::string& dbusObjectPath) const;\r
+    bool isConnectionAlive(const std::string& dbusConnectionName) const;\r
 \r
     bool isReady() const;\r
 \r
@@ -73,7 +75,7 @@ class DBusServiceRegistry {
     void cacheAllServices();\r
 \r
     void removeProvidedServiceInstancesFromCache(const std::string& serviceBusName);\r
-    void addProvidedServiceInstancesToCache(std::vector<std::string>& dbusNames);\r
+    void addProvidedServiceInstancesToCache(const std::set<std::string>& dbusNames);\r
     void addProvidedServiceInstancesToCache(const std::string& dbusNames);\r
     void addAllProvidedServiceInstancesToCache(const std::vector<std::string>& serviceBusNames);\r
 \r
@@ -91,6 +93,7 @@ class DBusServiceRegistry {
     void updateListeners(const std::string& conName, const std::string& objName, const std::string& intName , bool available);\r
 \r
     std::multimap<std::string, DBusInstanceId> dbusCachedProvidersForInterfaces_;\r
+    std::set<std::string> dbusLivingServiceBusNames_;\r
 \r
     std::shared_ptr<DBusConnection> dbusConnection_;\r
 \r
index ef20606..a85bc10 100644 (file)
@@ -38,7 +38,7 @@ inline std::string getCurrentBinaryFileName() {
     char fqnOfBinary[FILENAME_MAX];
     char pathToProcessImage[FILENAME_MAX];
 
-    sprintf(pathToProcessImage, "/proc/%ld/exe", getpid());
+    sprintf(pathToProcessImage, "/proc/%d/exe", getpid());
     const unsigned int lengthOfFqn = readlink(pathToProcessImage, fqnOfBinary, sizeof(fqnOfBinary) - 1);
 
     if (lengthOfFqn != -1) {
index b0ceff7..1706ad4 100644 (file)
@@ -7,8 +7,9 @@
 
 
 #include <gtest/gtest.h>
-
 #include <fstream>
+#include <thread>
+#include <unistd.h>
 
 #include <CommonAPI/DBus/DBusAddressTranslator.h>
 #include <CommonAPI/DBus/DBusUtils.h>
 #include "commonapi/tests/TestInterfaceStubDefault.h"
 #include "commonapi/tests/TestInterfaceDBusStubAdapter.h"
 
+#include "fakeLegacyService/fake/legacy/service/LegacyInterfaceProxy.h"
+
+
+static const std::vector<std::string> commonApiAddresses = {
+    "local:no.nothing.service:no.nothing.instance",
+    "local:service:instance",
+    "local:no.interface.service:no.interface.instance",
+    "local:no.connection.service:no.connection.instance",
+    "local:no.object.service:no.object.instance",
+    "local:only.interface.service:only.interface.instance",
+    "local:only.connection.service:only.connection.instance",
+    "local:only.object.service:only.object.instance",
+    "local:fake.legacy.service.LegacyInterface:fake.legacy.service"
+};
 
 static const std::string fileString =
 "[local:no.nothing.service:no.nothing.instance]\n"
@@ -55,18 +70,12 @@ static const std::string fileString =
 "dbus_connection=only.connection.connection\n"
 "\n"
 "[local:only.object.service:only.object.instance]\n"
-"dbus_object=/only/object/path";
-
-static const std::vector<std::string> commonApiAddresses = {
-    "local:no.nothing.service:no.nothing.instance",
-    "local:service:instance",
-    "local:no.interface.service:no.interface.instance",
-    "local:no.connection.service:no.connection.instance",
-    "local:no.object.service:no.object.instance",
-    "local:only.interface.service:only.interface.instance",
-    "local:only.connection.service:only.connection.instance",
-    "local:only.object.service:only.object.instance"
-};
+"dbus_object=/only/object/path\n"
+"\n"
+"[local:fake.legacy.service.LegacyInterface:fake.legacy.service]\n"
+"dbus_connection=fake.legacy.service.connection\n"
+"dbus_object=/some/legacy/path/6259504\n"
+"dbus_interface=fake.legacy.service.LegacyInterface\n";
 
 typedef std::vector<CommonAPI::DBus::DBusServiceAddress>::value_type vt;
 static const std::vector<CommonAPI::DBus::DBusServiceAddress> dbusAddresses = {
@@ -77,9 +86,11 @@ static const std::vector<CommonAPI::DBus::DBusServiceAddress> dbusAddresses = {
                 vt("no.object.connection", "/no/object/instance", "no.object.interface"),
                 vt("only.interface.instance", "/only/interface/instance", "only.interface.interface"),
                 vt("only.connection.connection", "/only/connection/instance", "only.connection.service"),
-                vt("only.object.instance", "/only/object/path", "only.object.service")
+                vt("only.object.instance", "/only/object/path", "only.object.service"),
+                vt("fake.legacy.service.connection", "/some/legacy/path/6259504", "fake.legacy.service.LegacyInterface")
 };
 
+
 class Environment: public ::testing::Environment {
 public:
     virtual ~Environment() {
@@ -176,6 +187,79 @@ TEST_F(AddressTranslatorTest, ServicesUsingPredefinedAddressesCanCommunicate) {
 }
 
 
+const std::string addressOfFakeLegacyService = commonApiAddresses[8];
+
+const std::string domainOfFakeLegacyService = "local";
+const std::string serviceIdOfFakeLegacyService = "fake.legacy.service.LegacyInterface";
+const std::string participantIdOfFakeLegacyService = "fake.legacy.service";
+
+TEST_F(AddressTranslatorTest, CreatedProxyHasCorrectCommonApiAddress) {
+    std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
+    ASSERT_TRUE((bool)runtime);
+    CommonAPI::DBus::DBusRuntime* dbusRuntime = dynamic_cast<CommonAPI::DBus::DBusRuntime*>(&(*runtime));
+    ASSERT_TRUE(dbusRuntime != NULL);
+
+    std::shared_ptr<CommonAPI::Factory> proxyFactory = runtime->createFactory();
+    ASSERT_TRUE((bool)proxyFactory);
+    auto proxyForFakeLegacyService = proxyFactory->buildProxy<fake::legacy::service::LegacyInterfaceProxy>(addressOfFakeLegacyService);
+    ASSERT_TRUE((bool)proxyForFakeLegacyService);
+
+    ASSERT_EQ(addressOfFakeLegacyService, proxyForFakeLegacyService->getAddress());
+    ASSERT_EQ(domainOfFakeLegacyService, proxyForFakeLegacyService->getDomain());
+    ASSERT_EQ(serviceIdOfFakeLegacyService, proxyForFakeLegacyService->getServiceId());
+    ASSERT_EQ(participantIdOfFakeLegacyService, proxyForFakeLegacyService->getInstanceId());
+}
+
+
+void fakeLegacyServiceThread() {
+    int resultCode = system("python ./src/test/fakeLegacyService/fakeLegacyService.py");
+    EXPECT_EQ(0, resultCode);
+}
+
+TEST_F(AddressTranslatorTest, FakeLegacyServiceCanBeAddressed) {
+    std::thread fakeServiceThread = std::thread(fakeLegacyServiceThread);
+    sleep(1);
+
+    std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
+    ASSERT_TRUE((bool)runtime);
+    CommonAPI::DBus::DBusRuntime* dbusRuntime = dynamic_cast<CommonAPI::DBus::DBusRuntime*>(&(*runtime));
+    ASSERT_TRUE(dbusRuntime != NULL);
+
+    std::shared_ptr<CommonAPI::Factory> proxyFactory = runtime->createFactory();
+    ASSERT_TRUE((bool)proxyFactory);
+    auto proxyForFakeLegacyService = proxyFactory->buildProxy<fake::legacy::service::LegacyInterfaceProxy>(addressOfFakeLegacyService);
+    ASSERT_TRUE((bool)proxyForFakeLegacyService);
+
+    ASSERT_EQ(addressOfFakeLegacyService, proxyForFakeLegacyService->getAddress());
+
+    CommonAPI::CallStatus status;
+
+    const int32_t input = 42;
+    int32_t output1, output2;
+    proxyForFakeLegacyService->TestMethod(input, status, output1, output2);
+    EXPECT_EQ(CommonAPI::CallStatus::SUCCESS, status);
+    if(CommonAPI::CallStatus::SUCCESS == status) {
+        EXPECT_EQ(input -5, output1);
+        EXPECT_EQ(input +5, output2);
+    }
+
+    std::string greeting;
+    int32_t identifier;
+    proxyForFakeLegacyService->OtherTestMethod(status, greeting, identifier);
+    EXPECT_EQ(CommonAPI::CallStatus::SUCCESS, status);
+    if(CommonAPI::CallStatus::SUCCESS == status) {
+        EXPECT_EQ(std::string("Hello"), greeting);
+        EXPECT_EQ(42, identifier);
+    }
+
+    //end the fake legacy service via dbus
+    int resultCode = system("python ./src/test/fakeLegacyService/sendToFakeLegacyService.py finish");
+    EXPECT_EQ(0, resultCode);
+
+    fakeServiceThread.join();
+}
+
+
 int main(int argc, char** argv) {
     ::testing::InitGoogleTest(&argc, argv);
     ::testing::AddGlobalTestEnvironment(new Environment());
index 1adc4c6..04776c4 100644 (file)
@@ -133,10 +133,8 @@ TEST_F(ProxyTest, IsAvailableBlocking) {
     std::shared_ptr<TestStubAdapter> stub = std::make_shared<TestStubAdapter>(dbusConnection_);
     stub->init();
     bool registered = dbusConnection_->requestServiceNameAndBlock(ID);
-    ASSERT_TRUE(registered);
-
     bool isAvailable = proxy_->isAvailableBlocking();
-    EXPECT_TRUE(isAvailable);
+    EXPECT_EQ(registered, isAvailable);
 }
 
 TEST_F(ProxyTest, HasNecessaryAttributesAndEvents) {
index 4106bd1..984132b 100644 (file)
@@ -98,11 +98,13 @@ typedef CommonAPI::DBus::DBusStubAdapterHelper<TestStub> TestStubAdapterHelper;
 
 class TestDBusStubAdapter: public TestStubAdapter,  public TestStubAdapterHelper {
  public:
-    TestDBusStubAdapter(const std::string& dbusBusName,
-                    const std::string& dbusObjectPath,
-                    const std::shared_ptr<CommonAPI::DBus::DBusConnection>& dbusConnection,
-                    const std::shared_ptr<TestStub>& testStub) :
+    TestDBusStubAdapter(const std::string& commonApiAddress,
+                        const std::string& dbusBusName,
+                        const std::string& dbusObjectPath,
+                        const std::shared_ptr<CommonAPI::DBus::DBusConnection>& dbusConnection,
+                        const std::shared_ptr<TestStub>& testStub) :
                     TestStubAdapterHelper(
+                                    commonApiAddress,
                                     dbusBusName,
                                     dbusObjectPath,
                                     "org.genivi.CommonAPI.DBus.TestInterface",
@@ -197,6 +199,7 @@ int main(void) {
 
     auto testStub = std::make_shared<TestStub>();
     auto testStubAdapter = std::make_shared<TestDBusStubAdapter>(
+                    "my:common.api:address.for.dbus",
                     "org.genivi.CommonAPI.DBus.TestDBusInterfaceAdapter",
                     "/common/api/dbus/TestDBusInterfaceAdapter",
                     dbusConnection,
@@ -212,11 +215,9 @@ int main(void) {
     const bool messageSent = dbusConnection->sendDBusMessage(dbusMessageCall);
     assert(messageSent);
 
-    for (int i = 0; i < 10; i++)
+    for (int i = 0; i < 10; i++) {
         dbusConnection->readWriteDispatch(100);
-
-//    while (dbusConnection->readWriteDispatch(100))
-//        ;
+    }
 
     assert(dispatchedMessageCount > 0);
 
diff --git a/src/test/fakeLegacyService/fake.legacy.service.xml b/src/test/fakeLegacyService/fake.legacy.service.xml
new file mode 100644 (file)
index 0000000..bb40a96
--- /dev/null
@@ -0,0 +1,259 @@
+<!--  Auto-Generated interface from Rhapsody: 'Repository::ssw_LifecycleSupport::NodeStateManagement::Concept::Interface::INSM_Consumer' -->\r
+<!--  Created at 2012-06-01 09:36:05 by uid65904 -->\r
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"\r
+       "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">\r
+<node>\r
+<interface name="org.freedesktop.DBus.Introspectable">\r
+       <method name="Introspect">\r
+               <arg name="data" direction="out" type="s"/>\r
+       </method>\r
+</interface>\r
+<interface name="org.freedesktop.DBus.Properties">\r
+       <method name="Get">\r
+               <arg name="interface" direction="in" type="s"/>\r
+               <arg name="propname" direction="in" type="s"/>\r
+               <arg name="value" direction="out" type="v"/>\r
+       </method>\r
+       \r
+       <method name="Set">\r
+               <arg name="interface" direction="in" type="s"/>\r
+               <arg name="propname" direction="in" type="s"/>\r
+               <arg name="value" direction="in" type="v"/>\r
+       </method>\r
+       \r
+       <method name="GetAll">\r
+               <arg name="interface" direction="in" type="s"/>\r
+               <arg name="props" direction="out" type="a{sv}"/>\r
+       </method>\r
+</interface>\r
+ <!--\r
+       org.genivi.NodeStateManager.Consumer:\r
+       @short_description: "Consumer" interface of the NodeStateManager.\r
+       \r
+       This interface contains functions which are not safety critical and can be accessed by "every" client without further restrictions.\r
+  -->\r
+  <interface name="org.genivi.NodeStateManager.Consumer">\r
+    <!--\r
+        RestartReason: This property informs clients about the reason for the last restart. The values are based upon the enummeration NsmRestartReason_e. Note: The value is only set once at start-up.\r
+    -->\r
+    <property name="RestartReason" type="i" access="read"/>\r
+\r
+    <!--\r
+        ShutdownReason: This property informs clients about the reason for the last shutdown. The values are based upon the enummeration NsmShutdownReason_e. Note: The value is only set once at start-up.\r
+    -->\r
+    <property name="ShutdownReason" type="i" access="read"/>\r
+\r
+    <!--\r
+        WakeUpReason: This property informs clients about the recent reason for waking up the target. The values are based upon the enummeration NsmWakeUpReason_e. Note: The value is only set once at start-up.\r
+    -->\r
+    <property name="WakeUpReason" type="i" access="read"/>\r
+\r
+    <!--\r
+        BootMode: This property informs clients about the recent BootMode of the target. The values will be defined by a third party header, which has not been delivered yet. The description needs to be updated as soon as the header is available.\r
+    -->\r
+    <property name="BootMode" type="i" access="read"/>\r
+\r
+    <!--\r
+          NodeState:\r
+          @NodeState: Numeric value for the current NodeState, defined in NsmNodeState_e.\r
+\r
+          Clients can register for notifications when the NodeState is updated inside the NodeStateManager. This signal is sent to registered clients and will include the current NodeState as a parameter.\r
+    -->\r
+    <signal name="NodeState">\r
+      <arg name="NodeState" type="i"/>\r
+    </signal>\r
+\r
+    <!--\r
+          NodeApplicationMode:\r
+          @ApplicationModeId: Numeric value for the current ApplicationMode, defined in NsmAplicationMode_e.\r
+\r
+          Clients can register for notifications when the NodeApplicationMode is updated inside the NodeStateManager. This signal is sent to registered clients and will include the current NodeApplicationMode as a parameter.\r
+    -->\r
+    <signal name="NodeApplicationMode">\r
+      <arg name="ApplicationModeId" type="i"/>\r
+    </signal>\r
+\r
+    <!--\r
+       SessionStateChanged:\r
+       @SessionStateName: The SessionName will be based upon either the pre-defined platform SessionNames or using a newly added product defined session name.\r
+       @SeatID:           This parameter will be based upon the enum NsmSeat_e.\r
+       @SessionState:     This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional session states.\r
+    \r
+       This signal is sent to registered clients when a particular session is state is changed. The client can register for notification about a specific session through the use of the SessionName, as a "match rule".\r
+    -->\r
+    <signal name="SessionStateChanged">\r
+      <arg name="SessionStateName" type="s"/>\r
+      <arg name="SeatID" type="i"/>\r
+      <arg name="SessionState" type="i"/>\r
+    </signal>\r
+\r
+    <!-- \r
+       GetNodeState:\r
+       @NodeStateId: Will be based on the NsmNodeState_e.\r
+       @ErrorCode:   Return value passed to the caller, based upon NsmErrorStatus_e.\r
+    \r
+       The method is used by other applications to get the NodeState without the need of registration to the signal.\r
+    -->\r
+    <method name="GetNodeState">\r
+      <arg name="NodeStateId" direction="out" type="i"/>\r
+      <arg name="ErrorCode" direction="out" type="i"/>\r
+    </method>\r
+\r
+    <!--\r
+       SetSessionState:\r
+       @SessionName:  The SessionName will be based upon either the pre-defined platform SessionNames (see NSM content page) or using a newly added product defined session name.\r
+       @SessionOwner: This parameter defines the name of the application that is setting the state of the session. This must be the applications systemd unit filename.\r
+       @SeatID:       This parameter will be based upon the enum NsmSeat_e\r
+       @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional SessionStates.\r
+       @ErrorCode:    Return value passed to the caller, based upon NsmErrorStatus_e.\r
+    \r
+       The method is used by applications to set the state of a session.\r
+    -->\r
+    <method name="SetSessionState">\r
+      <arg name="SessionName" direction="in" type="s"/>\r
+      <arg name="SessionOwner" direction="in" type="s"/>\r
+      <arg name="SeatID" direction="in" type="i"/>\r
+      <arg name="SessionState" direction="in" type="i"/>\r
+      <arg name="ErrorCode" direction="out" type="i"/>\r
+    </method>\r
+\r
+    <!--\r
+       GetSessionState:\r
+       @SessionName:  The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.\r
+       @SeatID:       This parameter will be based upon the enum NsmSeat_e.\r
+       @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional SessionStates.\r
+       @ErrorCode:    Return value passed to the caller, based upon NsmErrorStatus_e.\r
+    \r
+       The method is used by applications to get the state of a session.\r
+    -->\r
+    <method name="GetSessionState">\r
+      <arg name="SessionName" direction="in" type="s"/>\r
+      <arg name="SeatID" direction="in" type="i"/>\r
+      <arg name="SessionState" direction="out" type="i"/>\r
+      <arg name="ErrorCode" direction="out" type="i"/>\r
+    </method>\r
+\r
+    <!--\r
+       GetApplicationMode:\r
+       @ApplicationModeId: This parameter will be based upon the NsmNodeApplicationMode_e.\r
+       @ErrorCode:         Return value passed to the caller, based upon NsmErrorStatus_e.\r
+\r
+       The method is used by other applications to get the application mode.\r
+    -->\r
+    <method name="GetApplicationMode">\r
+      <arg name="ApplicationModeId" direction="out" type="i"/>\r
+      <arg name="ErrorCode" direction="out" type="i"/>\r
+    </method>\r
+\r
+    <!--\r
+        RegisterShutdownClient:\r
+       @BusName:      Bus name of remote application.\r
+       @ObjName:      Object name of remote object that provides the shutdown interface.\r
+       @ShutdownMode: Shutdown mode for which client wants to be informed (i.e normal, fast etc).\r
+       @TimeoutMs:    Max. Timeout to wait for response from shutdown client in ms.\r
+       @ErrorCode:    Return value passed to the caller, based upon NsmErrorStatus_e.\r
+    \r
+       The method is used by other applications to register themselves as shutdown client. Any client that registers must provide a method in their D-Bus object called "LifecycleRequest". This method will take one parameter which is the RequestType (NSM_SHUTDOWNTYPE_NORMAL, NSM_SHUTDOWNTYPE_FAST). For an example of the required client interface please see the BootManager component who will be a client of the NSM.\r
+       -->\r
+    <method name="RegisterShutdownClient">\r
+      <arg name="BusName" direction="in" type="s"/>\r
+      <arg name="ObjName" direction="in" type="s"/>\r
+      <arg name="ShutdownMode" direction="in" type="u"/>\r
+      <arg name="TimeoutMs" direction="in" type="u"/>\r
+      <arg name="ErrorCode" direction="out" type="i"/>\r
+    </method>\r
+\r
+    <!--\r
+       UnRegisterShutdownClient:\r
+       @BusName:      Bus name of remote application.\r
+       @ObjName:      Object name of remote object that provides the shutdown interface.\r
+       @ShutdownMode: Shutdown mode for which client wants to unregister (NSM_SHUTDOWNTYPE_NORMAL, NSM_SHUTDOWNTYPE_FAST).\r
+       @ErrorCode:    Return value passed to the caller, based upon NsmErrorStatus_e.\r
+    \r
+       The method is used by other applications to unregister themselves as shutdown client.\r
+    -->\r
+    <method name="UnRegisterShutdownClient">\r
+      <arg name="BusName" direction="in" type="s"/>\r
+      <arg name="ObjName" direction="in" type="s"/>\r
+      <arg name="ShutdownMode" direction="in" type="u"/>\r
+      <arg name="ErrorCode" direction="out" type="i"/>\r
+    </method>\r
+\r
+    <!--\r
+           RegisterSession:\r
+       @SessionName:  The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.\r
+       @SessionOwner: This is the name of the application that is registering the new session (this must be the applications systemd unit filename).\r
+       @SeatID:       This parameter will be based upon the enum NsmSeatId_e\r
+       @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional session states.\r
+       @ErrorCode:    Return value passed to the caller, based upon NsmErrorStatus_e.\r
+    \r
+       The method is used by other applications to register a new session whose state should be observed and distributed by the NSM.\r
+       -->\r
+    <method name="RegisterSession">\r
+      <arg name="SessionName" direction="in" type="s"/>\r
+      <arg name="SessionOwner" direction="in" type="s"/>\r
+      <arg name="SeatID" direction="in" type="i"/>\r
+      <arg name="SessionState" direction="in" type="i"/>\r
+      <arg name="ErrorCode" direction="out" type="i"/>\r
+    </method>\r
+\r
+    <!--\r
+       UnRegisterSession:\r
+       @SessionName:  The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.\r
+       @SessionOwner: This is the name of the application that originally registered the session. It will be validated that this value matches the stored value from the registration.\r
+       @SeatID:       This parameter will be based upon the enum NsmSeat_e.\r
+       @ErrorCode:    Return value passed to the caller, based upon NsmErrorStatus_e.\r
+    \r
+       The method is used by other applications to remove a new session from the session list hosted by NSM.\r
+    -->\r
+    <method name="UnRegisterSession">\r
+      <arg name="SessionName" direction="in" type="s"/>\r
+      <arg name="SessionOwner" direction="in" type="s"/>\r
+      <arg name="SeatID" direction="in" type="i"/>\r
+      <arg name="ErrorCode" direction="out" type="i"/>\r
+    </method>\r
+\r
+    <!--\r
+       GetAppHealthCount:\r
+       @Count: Return value passed to the caller. Number of applications that crashed or terminated accidentally.\r
+       \r
+       The method returns the number of applications that crashed or terminated accidentally, within the current life cycle. It can be used to observe the system state.\r
+    -->\r
+    <method name="GetAppHealthCount">\r
+      <arg name="Count" direction="out" type="u"/>\r
+    </method>\r
+\r
+    <!--\r
+       GetInterfaceVersion:\r
+       @Version: Unsigned integer that represents the version number of the Node State Manager.\r
+       \r
+       The method returns the version number of the Node State Manager. The number is organized in four bytes:\r
+    \r
+       Version: VVV.RRR.PPP.BBB\r
+    \r
+       <literallayout>\r
+               VVV => Version  [1..255]\r
+               RRR => Release  [0..255]\r
+               PPP => Patch    [0..255]\r
+               BBB => Build    [0..255]\r
+       </literallayout>\r
+    -->\r
+    <method name="GetInterfaceVersion">\r
+      <arg name="Version" direction="out" type="u"/>\r
+    </method>\r
+\r
+    <!--    \r
+        LifecycleRequestComplete:\r
+        @RequestId: The request Id of the called life cycle client. The value has been passed when "LifecycleRequest" was called.\r
+        @Status:    The result of the call to "LifecycleRequest". NsmErrorStatus_Ok: Request successfully processed. NsmErrorStatus_Error: An error occured while processing the "LifecycleRequest".\r
+        @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.\r
+        \r
+        The function has to be called by a "asynchrounous" lifecycle client, when he processed the "LifecycleRequest".\r
+    --> \r
+    <method name="LifecycleRequestComplete">\r
+      <arg name="RequestId" direction="in" type="u"/>\r
+      <arg name="Status"    direction="in" type="i"/>\r
+      <arg name="ErrorCode" direction="out" type="i"/>\r
+    </method>\r
+  </interface>\r
+</node>\r
diff --git a/src/test/fakeLegacyService/fake/legacy/service/LegacyInterface.h b/src/test/fakeLegacyService/fake/legacy/service/LegacyInterface.h
new file mode 100644 (file)
index 0000000..4b1720d
--- /dev/null
@@ -0,0 +1,38 @@
+/* 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/. */
+#ifndef FAKE_LEGACY_SERVICE_LEGACY_INTERFACE_H_
+#define FAKE_LEGACY_SERVICE_LEGACY_INTERFACE_H_
+
+#include <CommonAPI/types.h>
+
+namespace fake {
+namespace legacy {
+namespace service {
+
+class LegacyInterface {
+ public:
+    virtual ~LegacyInterface() { }
+
+    static inline const char* getInterfaceId();
+    static inline CommonAPI::Version getInterfaceVersion();
+};
+
+const char* LegacyInterface::getInterfaceId() {
+    return "fake.legacy.service.LegacyInterface";
+}
+
+CommonAPI::Version LegacyInterface::getInterfaceVersion() {
+    return CommonAPI::Version(1, 0);
+}
+
+
+} // namespace service
+} // namespace legacy
+} // namespace fake
+
+namespace CommonAPI {
+
+}
+
+#endif // FAKE_LEGACY_SERVICE_LEGACY_INTERFACE_H_
diff --git a/src/test/fakeLegacyService/fake/legacy/service/LegacyInterfaceDBusProxy.cpp b/src/test/fakeLegacyService/fake/legacy/service/LegacyInterfaceDBusProxy.cpp
new file mode 100644 (file)
index 0000000..292e0c6
--- /dev/null
@@ -0,0 +1,97 @@
+/* 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/. */
+#include "LegacyInterfaceDBusProxy.h"
+
+namespace fake {
+namespace legacy {
+namespace service {
+
+std::shared_ptr<CommonAPI::DBus::DBusProxy> createLegacyInterfaceDBusProxy(
+                    const std::string& commonApiAddress,
+                    const std::string& interfaceName,
+                    const std::string& busName,
+                    const std::string& objectPath,
+                    const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusProxyConnection) {
+    return std::make_shared<LegacyInterfaceDBusProxy>(commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection);
+}
+
+__attribute__((constructor)) void registerLegacyInterfaceDBusProxy(void) {
+    CommonAPI::DBus::DBusFactory::registerProxyFactoryMethod(LegacyInterface::getInterfaceId(),
+       &createLegacyInterfaceDBusProxy);
+}
+
+LegacyInterfaceDBusProxy::LegacyInterfaceDBusProxy(
+                    const std::string& commonApiAddress,
+                    const std::string& interfaceName,
+                    const std::string& busName,
+                    const std::string& objectPath,
+                    const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusProxyconnection):
+        CommonAPI::DBus::DBusProxy(commonApiAddress, interfaceName, busName, objectPath, dbusProxyconnection)
+ {
+}
+
+
+
+void LegacyInterfaceDBusProxy::TestMethod(const int32_t& input, CommonAPI::CallStatus& callStatus, int32_t& val1, int32_t& val2) {
+    CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<int32_t>,
+                                     CommonAPI::DBus::DBusSerializableArguments<int32_t, int32_t> >::callMethodWithReply(
+        *this,
+        "TestMethod",
+        "i",
+        input, 
+        callStatus
+        , val1, val2);
+}
+std::future<CommonAPI::CallStatus> LegacyInterfaceDBusProxy::TestMethodAsync(const int32_t& input, TestMethodAsyncCallback callback) {
+    return CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<int32_t>,
+                                     CommonAPI::DBus::DBusSerializableArguments<int32_t, int32_t> >::callMethodAsync(
+        *this,
+        "TestMethod",
+        "i",
+        input, 
+        std::move(callback));
+}
+void LegacyInterfaceDBusProxy::OtherTestMethod(CommonAPI::CallStatus& callStatus, std::string& greeting, int32_t& identifier) {
+    CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<>,
+                                     CommonAPI::DBus::DBusSerializableArguments<std::string, int32_t> >::callMethodWithReply(
+        *this,
+        "OtherTestMethod",
+        "",
+        callStatus
+        , greeting, identifier);
+}
+std::future<CommonAPI::CallStatus> LegacyInterfaceDBusProxy::OtherTestMethodAsync(OtherTestMethodAsyncCallback callback) {
+    return CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<>,
+                                     CommonAPI::DBus::DBusSerializableArguments<std::string, int32_t> >::callMethodAsync(
+        *this,
+        "OtherTestMethod",
+        "",
+        std::move(callback));
+}
+void LegacyInterfaceDBusProxy::finish(CommonAPI::CallStatus& callStatus) {
+    CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<>,
+                                     CommonAPI::DBus::DBusSerializableArguments<> >::callMethodWithReply(
+        *this,
+        "finish",
+        "",
+        callStatus
+        );
+}
+std::future<CommonAPI::CallStatus> LegacyInterfaceDBusProxy::finishAsync(FinishAsyncCallback callback) {
+    return CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<>,
+                                     CommonAPI::DBus::DBusSerializableArguments<> >::callMethodAsync(
+        *this,
+        "finish",
+        "",
+        std::move(callback));
+}
+
+void LegacyInterfaceDBusProxy::getOwnVersion(uint16_t& ownVersionMajor, uint16_t& ownVersionMinor) const {
+    ownVersionMajor = 1;
+    ownVersionMinor = 0;
+}
+
+} // namespace service
+} // namespace legacy
+} // namespace fake
diff --git a/src/test/fakeLegacyService/fake/legacy/service/LegacyInterfaceDBusProxy.h b/src/test/fakeLegacyService/fake/legacy/service/LegacyInterfaceDBusProxy.h
new file mode 100644 (file)
index 0000000..db13b78
--- /dev/null
@@ -0,0 +1,48 @@
+/* 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/. */
+#ifndef FAKE_LEGACY_SERVICE_LEGACY_INTERFACE_DBUS_PROXY_H_
+#define FAKE_LEGACY_SERVICE_LEGACY_INTERFACE_DBUS_PROXY_H_
+
+#include "LegacyInterfaceProxyBase.h"
+#include <CommonAPI/DBus/DBusFactory.h>
+#include <CommonAPI/DBus/DBusProxy.h>
+
+#include <string>
+
+namespace fake {
+namespace legacy {
+namespace service {
+
+class LegacyInterfaceDBusProxy: virtual public LegacyInterfaceProxyBase, virtual public CommonAPI::DBus::DBusProxy {
+ public:
+    LegacyInterfaceDBusProxy(
+                    const std::string& commonApiAddress,
+                    const std::string& interfaceName,
+                    const std::string& busName,
+                    const std::string& objectPath,
+                    const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusProxyconnection);
+
+
+
+
+    virtual void TestMethod(const int32_t& input, CommonAPI::CallStatus& callStatus, int32_t& val1, int32_t& val2);
+    virtual std::future<CommonAPI::CallStatus> TestMethodAsync(const int32_t& input, TestMethodAsyncCallback callback);
+
+    virtual void OtherTestMethod(CommonAPI::CallStatus& callStatus, std::string& greeting, int32_t& identifier);
+    virtual std::future<CommonAPI::CallStatus> OtherTestMethodAsync(OtherTestMethodAsyncCallback callback);
+
+    virtual void finish(CommonAPI::CallStatus& callStatus);
+    virtual std::future<CommonAPI::CallStatus> finishAsync(FinishAsyncCallback callback);
+    
+    virtual void getOwnVersion(uint16_t& ownVersionMajor, uint16_t& ownVersionMinor) const;
+
+ private:
+
+};
+
+} // namespace service
+} // namespace legacy
+} // namespace fake
+
+#endif // FAKE_LEGACY_SERVICE_LEGACY_INTERFACE_DBUS_PROXY_H_
diff --git a/src/test/fakeLegacyService/fake/legacy/service/LegacyInterfaceProxy.h b/src/test/fakeLegacyService/fake/legacy/service/LegacyInterfaceProxy.h
new file mode 100644 (file)
index 0000000..bb231cb
--- /dev/null
@@ -0,0 +1,131 @@
+/* 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/. */
+#ifndef FAKE_LEGACY_SERVICE_LEGACY_INTERFACE_PROXY_H_
+#define FAKE_LEGACY_SERVICE_LEGACY_INTERFACE_PROXY_H_
+
+#include "LegacyInterfaceProxyBase.h"
+
+namespace fake {
+namespace legacy {
+namespace service {
+
+template <typename ... _AttributeExtensions>
+class LegacyInterfaceProxy: virtual public LegacyInterface, virtual public LegacyInterfaceProxyBase, public _AttributeExtensions... {
+ public:
+    LegacyInterfaceProxy(std::shared_ptr<CommonAPI::Proxy> delegate);
+    ~LegacyInterfaceProxy();
+
+
+
+
+    virtual void TestMethod(const int32_t& input, CommonAPI::CallStatus& callStatus, int32_t& val1, int32_t& val2);
+    virtual std::future<CommonAPI::CallStatus> TestMethodAsync(const int32_t& input, TestMethodAsyncCallback callback);
+
+    virtual void OtherTestMethod(CommonAPI::CallStatus& callStatus, std::string& greeting, int32_t& identifier);
+    virtual std::future<CommonAPI::CallStatus> OtherTestMethodAsync(OtherTestMethodAsyncCallback callback);
+
+    virtual void finish(CommonAPI::CallStatus& callStatus);
+    virtual std::future<CommonAPI::CallStatus> finishAsync(FinishAsyncCallback callback);
+
+    virtual std::string getAddress() const;
+    virtual const std::string& getDomain() const;
+    virtual const std::string& getServiceId() const;
+    virtual const std::string& getInstanceId() const;
+    virtual bool isAvailable() const;
+    virtual CommonAPI::ProxyStatusEvent& getProxyStatusEvent();
+    virtual CommonAPI::InterfaceVersionAttribute& getInterfaceVersionAttribute();
+
+ private:
+    std::shared_ptr<LegacyInterfaceProxyBase> delegate_;
+};
+
+
+//
+// LegacyInterfaceProxy Implementation
+//
+template <typename ... _AttributeExtensions>
+LegacyInterfaceProxy<_AttributeExtensions...>::LegacyInterfaceProxy(std::shared_ptr<CommonAPI::Proxy> delegate):
+        delegate_(std::dynamic_pointer_cast<LegacyInterfaceProxyBase>(delegate)),
+        _AttributeExtensions(*(std::dynamic_pointer_cast<LegacyInterfaceProxyBase>(delegate)))... {
+}
+
+template <typename ... _AttributeExtensions>
+LegacyInterfaceProxy<_AttributeExtensions...>::~LegacyInterfaceProxy() {
+}
+
+
+
+template <typename ... _AttributeExtensions>
+void LegacyInterfaceProxy<_AttributeExtensions...>::TestMethod(const int32_t& input, CommonAPI::CallStatus& callStatus, int32_t& val1, int32_t& val2) {
+    delegate_->TestMethod(input, callStatus, val1, val2);
+}
+
+template <typename ... _AttributeExtensions>
+std::future<CommonAPI::CallStatus> LegacyInterfaceProxy<_AttributeExtensions...>::TestMethodAsync(const int32_t& input, TestMethodAsyncCallback callback) {
+    return delegate_->TestMethodAsync(input, callback);
+}
+
+template <typename ... _AttributeExtensions>
+void LegacyInterfaceProxy<_AttributeExtensions...>::OtherTestMethod(CommonAPI::CallStatus& callStatus, std::string& greeting, int32_t& identifier) {
+    delegate_->OtherTestMethod(callStatus, greeting, identifier);
+}
+
+template <typename ... _AttributeExtensions>
+std::future<CommonAPI::CallStatus> LegacyInterfaceProxy<_AttributeExtensions...>::OtherTestMethodAsync(OtherTestMethodAsyncCallback callback) {
+    return delegate_->OtherTestMethodAsync(callback);
+}
+
+template <typename ... _AttributeExtensions>
+void LegacyInterfaceProxy<_AttributeExtensions...>::finish(CommonAPI::CallStatus& callStatus) {
+    delegate_->finish(callStatus);
+}
+
+template <typename ... _AttributeExtensions>
+std::future<CommonAPI::CallStatus> LegacyInterfaceProxy<_AttributeExtensions...>::finishAsync(FinishAsyncCallback callback) {
+    return delegate_->finishAsync(callback);
+}
+
+
+template <typename ... _AttributeExtensions>
+std::string LegacyInterfaceProxy<_AttributeExtensions...>::getAddress() const {
+    return delegate_->getAddress();
+}
+
+template <typename ... _AttributeExtensions>
+const std::string& LegacyInterfaceProxy<_AttributeExtensions...>::getDomain() const {
+    return delegate_->getDomain();
+}
+
+template <typename ... _AttributeExtensions>
+const std::string& LegacyInterfaceProxy<_AttributeExtensions...>::getServiceId() const {
+    return delegate_->getServiceId();
+}
+
+template <typename ... _AttributeExtensions>
+const std::string& LegacyInterfaceProxy<_AttributeExtensions...>::getInstanceId() const {
+    return delegate_->getInstanceId();
+}
+
+template <typename ... _AttributeExtensions>
+bool LegacyInterfaceProxy<_AttributeExtensions...>::isAvailable() const {
+    return delegate_->isAvailable();
+}
+
+template <typename ... _AttributeExtensions>
+CommonAPI::ProxyStatusEvent& LegacyInterfaceProxy<_AttributeExtensions...>::getProxyStatusEvent() {
+    return delegate_->getProxyStatusEvent();
+}
+
+template <typename ... _AttributeExtensions>
+CommonAPI::InterfaceVersionAttribute& LegacyInterfaceProxy<_AttributeExtensions...>::getInterfaceVersionAttribute() {
+    return delegate_->getInterfaceVersionAttribute();
+}
+
+} // namespace service
+} // namespace legacy
+} // namespace fake
+
+
+
+#endif // FAKE_LEGACY_SERVICE_LEGACY_INTERFACE_PROXY_H_
diff --git a/src/test/fakeLegacyService/fake/legacy/service/LegacyInterfaceProxyBase.h b/src/test/fakeLegacyService/fake/legacy/service/LegacyInterfaceProxyBase.h
new file mode 100644 (file)
index 0000000..fb430e0
--- /dev/null
@@ -0,0 +1,40 @@
+/* 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/. */
+#ifndef FAKE_LEGACY_SERVICE_LEGACY_INTERFACE_PROXY_BASE_H_
+#define FAKE_LEGACY_SERVICE_LEGACY_INTERFACE_PROXY_BASE_H_
+
+#include "LegacyInterface.h"
+#include <CommonAPI/Proxy.h>
+#include <functional>
+#include <future>
+
+namespace fake {
+namespace legacy {
+namespace service {
+
+class LegacyInterfaceProxyBase: virtual public CommonAPI::Proxy {
+ public:
+    typedef std::function<void(const CommonAPI::CallStatus&, const int32_t&, const int32_t&)> TestMethodAsyncCallback;
+    typedef std::function<void(const CommonAPI::CallStatus&, const std::string&, const int32_t&)> OtherTestMethodAsyncCallback;
+    typedef std::function<void(const CommonAPI::CallStatus&)> FinishAsyncCallback;
+
+
+
+
+    virtual void TestMethod(const int32_t& input, CommonAPI::CallStatus& callStatus, int32_t& val1, int32_t& val2) = 0;
+    virtual std::future<CommonAPI::CallStatus> TestMethodAsync(const int32_t& input, TestMethodAsyncCallback callback) = 0;
+
+    virtual void OtherTestMethod(CommonAPI::CallStatus& callStatus, std::string& greeting, int32_t& identifier) = 0;
+    virtual std::future<CommonAPI::CallStatus> OtherTestMethodAsync(OtherTestMethodAsyncCallback callback) = 0;
+
+    virtual void finish(CommonAPI::CallStatus& callStatus) = 0;
+    virtual std::future<CommonAPI::CallStatus> finishAsync(FinishAsyncCallback callback) = 0;
+};
+
+
+} // namespace service
+} // namespace legacy
+} // namespace fake
+
+#endif // FAKE_LEGACY_SERVICE_LEGACY_INTERFACE_PROXY_BASE_H_
diff --git a/src/test/fakeLegacyService/fakeLegacyService.fidl b/src/test/fakeLegacyService/fakeLegacyService.fidl
new file mode 100644 (file)
index 0000000..6aaa8a8
--- /dev/null
@@ -0,0 +1,24 @@
+package fake.legacy.service
+
+interface LegacyInterface {
+    version { major 1 minor 0 }
+
+    method TestMethod {
+        in {
+            Int32 input
+        }
+        out {
+            Int32 val1
+            Int32 val2
+        }
+    }
+
+    method OtherTestMethod {
+        out {
+            String greeting
+            Int32 identifier
+        }
+    }
+    
+    method finish {}
+}
diff --git a/src/test/fakeLegacyService/fakeLegacyService.py b/src/test/fakeLegacyService/fakeLegacyService.py
new file mode 100644 (file)
index 0000000..b082efd
--- /dev/null
@@ -0,0 +1,52 @@
+# Copyright (C) 2013 BMW Group
+# Author: Manfred Bathelt (manfred.bathelt@bmw.de)
+# Author: Juergen Gehring (juergen.gehring@bmw.de)
+# 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/. */
+
+import sys
+import traceback
+import gobject
+import math
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+
+loop = gobject.MainLoop()
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+class FakeLegacyService(dbus.service.Object):
+  def __init__(self, loop):
+    busName = dbus.service.BusName('fake.legacy.service.connection', bus = dbus.SessionBus())
+    dbus.service.Object.__init__(self, busName, '/some/legacy/path/6259504')
+    #self.properties = {'RestartReason': 1, 'ShutdownReason': 2, 'WakeUpReason' :3, 'BootMode' :4}
+    self.ABus=""
+    self.APath=""
+    self.loop=loop
+
+  @dbus.service.method(dbus_interface='fake.legacy.service.Introspectable', out_signature = 's')
+  def Introspect(self):
+       f = open('fake.legacy.service.xml', "r")
+       text = f.read()
+       return text
+  @dbus.service.method(dbus_interface='fake.legacy.service.LegacyInterface', in_signature = 'i', out_signature = 'ii')
+  def TestMethod(self, input):
+    val1=input - 5
+    val2=input + 5
+    return val1, val2
+
+  @dbus.service.method(dbus_interface='fake.legacy.service.LegacyInterface', out_signature = 'si')
+  def OtherTestMethod(self):
+    greeting='Hello'
+    identifier=42
+    return greeting, identifier
+
+  @dbus.service.method(dbus_interface='fake.legacy.service.LegacyInterface')
+  def finish(self): 
+       self.loop.quit()
+       return 0
+
+nsm = FakeLegacyService(loop)
+loop.run()
diff --git a/src/test/fakeLegacyService/sendToFakeLegacyService.py b/src/test/fakeLegacyService/sendToFakeLegacyService.py
new file mode 100644 (file)
index 0000000..ea23a74
--- /dev/null
@@ -0,0 +1,23 @@
+# Copyright (C) 2013 BMW Group
+# Author: Manfred Bathelt (manfred.bathelt@bmw.de)
+# Author: Juergen Gehring (juergen.gehring@bmw.de)
+# 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/. */
+
+import sys
+import traceback
+import gobject
+import math
+import dbus
+import dbus.service
+       
+def finish():
+       bus = dbus.SessionBus()
+       remote_object = bus.get_object('fake.legacy.service.connection','/some/legacy/path/6259504')
+       iface = dbus.Interface(remote_object, 'fake.legacy.service.LegacyInterface')
+       iface.finish()
+
+command=sys.argv[1]
+if command=="finish":
+       finish()
diff --git a/src/test/test-derived-types.fidl b/src/test/test-derived-types.fidl
new file mode 100644 (file)
index 0000000..051b438
--- /dev/null
@@ -0,0 +1,56 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public\r
+ * License, v. 2.0. If a copy of the MPL was not distributed with this\r
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\r
+package commonapi.tests\r
+\r
+import commonapi.tests.* from "test-predefined-types.fidl"\r
+\r
+typeCollection DerivedTypeCollection {\r
+       <** @description : Common errors. **>\r
+       enumeration TestEnum {\r
+                <** @description : default **>\r
+               E_UNKNOWN = "0x00"\r
+               <** @description : no error - positive reply **>\r
+               E_OK = "0x01"\r
+               <** @description : value out of range **>\r
+               E_OUT_OF_RANGE = "0x02"\r
+           <** @description : not used **>\r
+               E_NOT_USED = "0x03"\r
+       }\r
+       \r
+       enumeration TestEnumMissingValue {\r
+                <** @description : default **>\r
+               E1 = "A"\r
+               E2\r
+               E3 = "2"\r
+       }\r
+       \r
+       enumeration TestEnumExtended extends TestEnum {\r
+               <** @description : new error **>\r
+               E_NEW = "0x04"\r
+       }\r
+       \r
+       enumeration TestEnumExtended2 extends TestEnumExtended {\r
+               <** @description : new error **>\r
+               E_NEW2 = "0x05"\r
+       }\r
+       \r
+       struct TestStruct {\r
+               <** @description : the name of the property **>\r
+               PredefinedTypeCollection.TestString testString\r
+\r
+               <** @description : the actual value **>\r
+               UInt16 uintValue\r
+       }\r
+       \r
+       struct TestStructExtended extends TestStruct {\r
+               TestEnumExtended2 testEnumExtended2\r
+       }\r
+       \r
+       array TestArrayUInt64 of UInt64\r
+       array TestArrayTestStruct of TestStruct\r
+\r
+       map TestMap { UInt32 to TestArrayTestStruct }\r
+}\r
+\r
+\r
diff --git a/src/test/test-interface-proxy.fidl b/src/test/test-interface-proxy.fidl
new file mode 100644 (file)
index 0000000..f23fb7a
--- /dev/null
@@ -0,0 +1,58 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public\r
+ * License, v. 2.0. If a copy of the MPL was not distributed with this\r
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\r
+package commonapi.tests\r
+\r
+import commonapi.tests.* from "test-derived-types.fidl"\r
+\r
+interface TestInterface {\r
+       version { major 1 minor 0 }\r
+\r
+       attribute UInt32 TestPredefinedTypeAttribute\r
+       attribute DerivedTypeCollection.TestStructExtended TestDerivedStructAttribute\r
+       attribute DerivedTypeCollection.TestArrayUInt64 TestDerivedArrayAttribute\r
+\r
+       method testVoidPredefinedTypeMethod {\r
+               in {\r
+                       UInt32 uint32Value\r
+                       String stringValue\r
+               }\r
+       }\r
+\r
+       method testPredefinedTypeMethod {\r
+               in {\r
+                       UInt32 uint32InValue\r
+                       String stringInValue\r
+               }\r
+               out {\r
+                       UInt32 uint32OutValue\r
+                       String stringOutValue\r
+               }\r
+       }\r
+\r
+       method testVoidDerivedTypeMethod {\r
+               in {\r
+                       DerivedTypeCollection.TestEnumExtended2 testEnumExtended2Value\r
+                       DerivedTypeCollection.TestMap testMapValue\r
+               }\r
+       }\r
+\r
+       method testDerivedTypeMethod {\r
+               in {\r
+                       DerivedTypeCollection.TestEnumExtended2 testEnumExtended2InValue\r
+                       DerivedTypeCollection.TestMap testMapInValue\r
+               }\r
+               out {\r
+                       DerivedTypeCollection.TestEnumExtended2 testEnumExtended2OutValue\r
+                       DerivedTypeCollection.TestMap testMapOutValue\r
+               }\r
+       }\r
+\r
+       broadcast TestPredefinedTypeBroadcast {\r
+               out {\r
+                       UInt32 uint32Value\r
+                       String stringValue\r
+               }\r
+       }\r
+}\r
+\r
diff --git a/src/test/test-predefined-types.fidl b/src/test/test-predefined-types.fidl
new file mode 100644 (file)
index 0000000..8a69103
--- /dev/null
@@ -0,0 +1,22 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public\r
+ * License, v. 2.0. If a copy of the MPL was not distributed with this\r
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\r
+package commonapi.tests\r
+\r
+typeCollection PredefinedTypeCollection {\r
+       typedef TestUInt8 is UInt8\r
+       typedef TestUInt16 is UInt16\r
+       typedef TestUInt32 is UInt32\r
+       typedef TestUInt64 is UInt64\r
+       typedef TestInt8 is Int8\r
+       typedef TestInt16 is Int16\r
+       typedef TestInt32 is Int32\r
+       typedef TestInt64 is Int64\r
+       typedef TestBoolean is Boolean\r
+       typedef TestByteBuffer is ByteBuffer\r
+       typedef TestDouble is Double\r
+       typedef TestFloat is Float\r
+       typedef TestString is String\r
+}\r
+\r
+\r