Hard-coded service name replaced with call to ObjectMapper

In the openbmc code, the dbus service name is hardcoded.
The ObjectMapper provides a way to find out the service name by
issuing a GetObject method call to the ObjectMapper.
That functionality is implemented in mapper.c
The output of the call to the mapper is a service name.

Resolves openbmc/openbmc#319.

Change-Id: I724a31ede6bdf3ae4b361e730857b1f2696a8966
Signed-off-by: Sergey Solomin <sergey.solomin@us.ibm.com>
diff --git a/testaddsel.cpp b/testaddsel.cpp
index 202200a..9fd9d35 100644
--- a/testaddsel.cpp
+++ b/testaddsel.cpp
@@ -5,6 +5,7 @@
 #include <stdint.h>
 #include <systemd/sd-bus.h>
 #include "sensorhandler.h"
+#include <mapper.h>
 
 
 extern void send_esel(uint16_t recordid);
@@ -16,15 +17,19 @@
 // step for mapping IPMI
 int find_openbmc_path(const char *type, const uint8_t num, dbus_interface_t *interface) {
 
-    const char  *busname = "org.openbmc.managers.System";
     const char  *objname = "/org/openbmc/managers/System";
 
     char  *str1, *str2, *str3;
     sd_bus_error error = SD_BUS_ERROR_NULL;
     sd_bus_message *reply = NULL, *m=NULL;
-
-
     int r;
+    char  *busname = NULL;
+
+    r = mapper_get_service(bus, objname, &busname);
+    if (r < 0) {
+        fprintf(stderr, "Failed to get busname: %s\n", strerror(-r));
+        goto final;
+    }
 
     r = sd_bus_message_new_method_call(bus,&m,busname,objname,busname,"getObjectFromByteId");
     if (r < 0) {
@@ -60,6 +65,7 @@
 
     sd_bus_error_free(&error);
     sd_bus_message_unref(m);
+    free (busname);
 
     return r;
 }