[Systemnifo] use throw-free methods from dbus
authorPiotr Kosko <p.kosko@samsung.com>
Fri, 20 Feb 2015 12:13:50 +0000 (13:13 +0100)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Mon, 23 Feb 2015 13:47:34 +0000 (22:47 +0900)
Change-Id: Id2fa781dc34cacac1bed90c368a22c43f4fed282
Signed-off-by: Piotr Kosko <p.kosko@samsung.com>
src/systeminfo/systeminfo-utils.cpp
src/systeminfo/systeminfo_instance.cc

index f0ce885412173fe22a772d11328e69294e1cbfee..ee70509454b5ad8aa8a32dc069ad6436aed1213d 100644 (file)
@@ -540,7 +540,6 @@ SystemInfoDeviceOrientation::SystemInfoDeviceOrientation() :
 }
 
 SystemInfoDeviceOrientation* SystemInfoDeviceOrientation::Create() {
-  //TODO DBUS based constructor can throw exception
   SystemInfoDeviceOrientation* deviceOrientation =
       new (std::nothrow) SystemInfoDeviceOrientation();
   if(!deviceOrientation) return nullptr;
@@ -604,8 +603,9 @@ PlatformResult SystemInfoDeviceOrientation::FetchStatus()
   args.AddArgumentInt32(0);
 
   std::string status = kOrientationPortraitPrimary;
-  //TODO DBUS still can throw exception
-  int ret = dbus_op_.InvokeSyncGetInt("DegreePhysicalRotation", &args);
+  int ret = 0;
+  PlatformResult platform_ret = dbus_op_.InvokeSyncGetInt("DegreePhysicalRotation", &args, &ret);
+  if (platform_ret.IsError()) return platform_ret;
 
   switch (ret) {
     case 0:
@@ -669,17 +669,17 @@ PlatformResult SystemInfoDeviceOrientation::RegisterDBus()
   DBusOperationArguments args;
   args.AddArgumentInt32(1);
 
-  ret = dbus_op_.InvokeSyncGetInt("StartRotation", &args);
+  PlatformResult platform_ret= dbus_op_.InvokeSyncGetInt("StartRotation", &args, &ret);
+  if (platform_ret.IsError()) return platform_ret;
 
   if (ret != 0) {
     LoggerE("Failed to start rotation broadcast");
     return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to start rotation broadcast");
   }
 
-  //TODO DBUS still throws
-  dbus_op_.RegisterSignalListener("ChangedPhysicalRotation", this);
+  platform_ret = dbus_op_.RegisterSignalListener("ChangedPhysicalRotation", this);
   LoggerD("registerSignalListener: ChangedPhysicalRotation");
-  return PlatformResult(ErrorCode::NO_ERROR);
+  return platform_ret;
 }
 
 PlatformResult SystemInfoDeviceOrientation::UnregisterDBus()
@@ -687,15 +687,16 @@ PlatformResult SystemInfoDeviceOrientation::UnregisterDBus()
   LoggerD("Enter");
 
   int ret = 0;
-  //TODO DBUS still throws
-  dbus_op_.UnregisterSignalListener("ChangedPhysicalRotation", this);
+  PlatformResult platform_ret = dbus_op_.UnregisterSignalListener(
+      "ChangedPhysicalRotation", this);
+  if (platform_ret.IsError()) return platform_ret;
   LoggerD("unregisterSignalListener: ChangedPhysicalRotation");
 
   DBusOperationArguments args;
   args.AddArgumentInt32(0);
 
-  //TODO DBUS still throws
-  ret = dbus_op_.InvokeSyncGetInt("StartRotation", &args);
+  platform_ret = dbus_op_.InvokeSyncGetInt("StartRotation", &args, &ret);
+  if (platform_ret.IsError()) return platform_ret;
 
   if (ret != 0) {
     LoggerE("Failed to stop rotation broadcast");
index c414d60b8db268d31a4b5cbf1effa0a913eeb134..003ecddf43b83abc54f5ab4743621b06e6514496 100644 (file)
@@ -218,10 +218,10 @@ void SysteminfoInstance::GetCapability(const picojson::value& args, picojson::ob
   PlatformResult ret = SystemInfoDeviceCapability::GetCapability(key, result);
   if (ret.IsSuccess()) {
     ReportSuccess(result, out);
+    LoggerD("Success");
   } else {
     ReportError(ret, &out);
   }
-  LoggerD("Success");
 }
 
 void SysteminfoInstance::GetPropertyValue(const picojson::value& args, picojson::object& out) {