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/storageaddsel.cpp b/storageaddsel.cpp
index 3343772..9d15a49 100644
--- a/storageaddsel.cpp
+++ b/storageaddsel.cpp
@@ -7,7 +7,7 @@
 #include <vector>
 #include <memory>
 #include <systemd/sd-bus.h>
-
+#include <mapper.h>
 #include "ipmid.H"
 #include "storagehandler.h"
 #include "sensorhandler.h"
@@ -179,12 +179,18 @@
     sd_bus_message *reply = NULL, *m=NULL;
     uint16_t x;
     int r;
+    const char *object_name  =  "/org/openbmc/records/events";
+    char *bus_name = NULL;
 
     mbus = ipmid_get_sd_bus_connection();
-
+    r = mapper_get_service(mbus, object_name, &bus_name);
+    if (r < 0) {
+        fprintf(stderr, "Failed to get connection, return value: %s.\n", strerror(-r));
+        goto finish;
+    }
     r = sd_bus_message_new_method_call(mbus,&m,
-    									"org.openbmc.records.events",
-    									"/org/openbmc/records/events",
+    									bus_name,
+    									object_name,
     									"org.openbmc.recordlog",
     									"acceptHostMessage");
     if (r < 0) {
@@ -218,6 +224,7 @@
     sd_bus_error_free(&error);
     m = sd_bus_message_unref(m);
     reply = sd_bus_message_unref(reply);
+    free (bus_name);
     return r;
 }