Remove the IPC helper class 75/141275/3
authorMu-Woong Lee <muwoong.lee@samsung.com>
Sun, 30 Jul 2017 02:46:30 +0000 (11:46 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Mon, 31 Jul 2017 02:49:00 +0000 (02:49 +0000)
Change-Id: I17c64867b550c4a26c3bc847ca8a3321d2a608ff
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
src/server/IPC.cpp [deleted file]
src/server/IPC.h [deleted file]
src/server/JobSchedulerService.cpp
src/server/state/ActionState.cpp

diff --git a/src/server/IPC.cpp b/src/server/IPC.cpp
deleted file mode 100644 (file)
index d578212..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "IPC.h"
-
-using namespace ctx;
-
-GDBusConnection* IPC::__dbusConnection = NULL;
-
-static void __async_ready_cb(GObject* obj, GAsyncResult* res, gpointer data)
-{
-       GError *gerr = NULL;
-       GDBusConnection* conn = static_cast<GDBusConnection*>(data);
-       GVariant* param = g_dbus_connection_call_finish(conn, res, &gerr);
-
-       if (param)
-               g_variant_unref(param);
-
-       HANDLE_GERROR(gerr);
-}
-
-IPC::IPC()
-{
-}
-
-bool IPC::dbusCall(const std::string& busName, const std::string& objectPath,
-               const std::string& interface, const std::string& methodName, GVariant* param)
-{
-       IF_FAIL_RETURN(__dbusConnection, false);
-
-       g_dbus_connection_call(__dbusConnection, busName.c_str(),
-                       objectPath.c_str(), interface.c_str(), methodName.c_str(), param,
-                       NULL, G_DBUS_CALL_FLAGS_NONE, CTX_DBUS_TIMEOUT, NULL, __async_ready_cb, __dbusConnection);
-
-       return true;
-}
-
-void IPC::setDBus(GDBusConnection* conn)
-{
-       __dbusConnection = conn;
-}
diff --git a/src/server/IPC.h b/src/server/IPC.h
deleted file mode 100644 (file)
index f339b32..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __CONTEXT_JOB_SCHEDULER_IPC_H__
-#define __CONTEXT_JOB_SCHEDULER_IPC_H__
-
-#include <string>
-#include <ContextTypes.h>
-
-namespace ctx {
-
-       class IPC {
-       public:
-               static bool dbusCall(const std::string& busName, const std::string& objectPath,
-                               const std::string& interface, const std::string& methodName,
-                               GVariant* param);
-
-               static void setDBus(GDBusConnection* conn);
-
-               //TODO: Socket
-
-       private:
-               IPC();
-
-               static GDBusConnection* __dbusConnection;
-       };
-
-}
-
-#endif /* __CONTEXT_JOB_SCHEDULER_IPC_H__ */
index 9eda341f2ac756bfa82535d1627033a91f23046f..78eedcb80621a54c2e9c84063c6939fdc1bdde8f 100644 (file)
@@ -22,7 +22,6 @@
 #include "MethodCallHandler.h"
 #include "ContextManager.h"
 #include "SchedTimer.h"
-#include "IPC.h"
 
 #define SYSTEM_UID     0
 
@@ -63,7 +62,6 @@ bool JobSchedulerService::prepare()
 {
        ContextManager::init();
        SchedTimer::init();
-       IPC::setDBus(__serviceRunner->getConnection());
        __jobManagers.emplace(SYSTEM_UID, new JobManager(SYSTEM_UID));
        return true;
 }
index 91dd2408fbcd17ff2bcc2b6e0e51391aaf761b0c..a0e757ed91398db3e9aa9de9327e57588cafd113 100644 (file)
 #include <notification.h>
 #include <notification_internal.h>
 #include <vconf.h>
+#include <DBusCaller.h>
 #include <Conf.h>
 #include <JobSchedulerTypesPrivate.h>
 #include <JobAction.h>
-#include "../IPC.h"
 #include "ActionState.h"
 #include "ClosingState.h"
 
@@ -89,13 +89,19 @@ void ActionState::jobFinished()
 void ActionState::__callDBusMethod()
 {
        JobDBusCall* action = static_cast<JobDBusCall*>(getJobInfo()->getAction());
-       bool success = false;
+       DBusCaller caller;
 
        _D("Call %s.%s", action->getInterface().c_str(), action->getMethodName().c_str());
-       success = IPC::dbusCall(action->getBusName(), action->getObjectPath(),
+
+       GVariant* result = caller.call(action->getBusName(), action->getObjectPath(),
                        action->getInterface(), action->getMethodName(), action->getParameters());
 
-       IF_FAIL_VOID_TAG(success, _E, "DBus call failed");
+       if (!result) {
+               _E("DBus call failed");
+               return;
+       }
+
+       g_variant_unref(result);
 }
 
 static void __aul_svc_result_cb(bundle* b, int requestCode, aul_svc_result_val result, void* data)