Refactor AppControlLauncher class. 91/137091/3
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Tue, 4 Jul 2017 10:01:46 +0000 (13:01 +0300)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Tue, 4 Jul 2017 13:37:58 +0000 (13:37 +0000)
Change-Id: Ia9ca75b7625852cb3b81154af8aebb6c886b8711
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Common/AppControl/inc/AppControlHandle.h [new file with mode: 0644]
src/Common/AppControl/inc/AppControlLauncher.h
src/Common/AppControl/inc/InputSelector.h
src/Common/AppControl/src/AppControlHandle.cpp [new file with mode: 0644]
src/Common/AppControl/src/AppControlLauncher.cpp
src/Common/AppControl/src/InputSelector.cpp

diff --git a/src/Common/AppControl/inc/AppControlHandle.h b/src/Common/AppControl/inc/AppControlHandle.h
new file mode 100644 (file)
index 0000000..a8fb00a
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 AppControlHandle_h_
+#define AppControlHandle_h_
+
+#include "AppControlUtils.h"
+
+namespace Msg {
+
+    class AppControlLauncher;
+
+    class AppControlHandle {
+
+        friend class AppControlLauncher;
+
+        public:
+            AppControlHandle(app_control_launch_mode_e launchMode = APP_CONTROL_LAUNCH_MODE_GROUP);
+            virtual ~AppControlHandle();
+
+            /**
+             *@brief Terminate launch request related with this handle.
+             */
+            void terminate();
+
+            /**
+             *@brief Sends the launch request.
+             *@return bool is launch success, false otherwise
+             */
+            bool launch();
+
+            /**
+             *@brief Returns internal handle to app_control_h
+             */
+            operator app_control_h();
+
+            void setOperation(const char *operation);
+            void setUri(const char *uri);
+            void setLaunchMode(app_control_launch_mode_e mode);
+
+        protected:
+            virtual void onReply(app_control_h request, app_control_h reply, app_control_result_e result) {};
+
+            AppControlHandle(const AppControlHandle&) = delete;
+            AppControlHandle& operator=(AppControlHandle) = delete;
+
+        protected:
+            app_control_h m_Handle;
+    };
+}
+
+#endif /* AppControlHandle_h_ */
index a1ae4443c0e91e0f60d3257e2fabb919a5e42613..8fa3075f98b7d1f926352344a5dc9db3e10029c3 100644 (file)
 #ifndef AppControlLauncher_h_
 #define AppControlLauncher_h_
 
-#include "AppControlUtils.h"
+#include "AppControlHandle.h"
 
 #include <Ecore.h>
 
 namespace Msg {
-    class AppControlLauncher;
-    class AppControlHandle {
-        friend class AppControlLauncher;
-
-        public:
-            AppControlHandle(app_control_launch_mode_e launchMode = APP_CONTROL_LAUNCH_MODE_GROUP);
-            virtual ~AppControlHandle();
-
-            /**
-             *@brief Terminate launch request related with this handle.
-             */
-            void terminate();
-
-            /**
-             *@brief Returns internal handle to app_control_h
-             */
-            operator app_control_h();
-
-        protected:
-            virtual void onReply(app_control_h request, app_control_h reply, app_control_result_e result) {};
-
-            AppControlHandle(const AppControlHandle&) = delete;
-            AppControlHandle& operator=(AppControlHandle) = delete;
-
-        protected:
-            app_control_h m_Handle;
-    };
-
     class AppControlLauncher {
+
         friend class AppControlHandle;
 
         public:
index 831afc4c6184ca794b55033f0ac0cc32f49128b8..653dec3252b80c2121d8c3d3545d5d913673c1b1 100644 (file)
@@ -27,8 +27,6 @@ namespace Msg {
             InputSelector();
             virtual ~InputSelector();
 
-            bool launch();
-
         protected:
             virtual void onKeyboardReply(const std::string &text) {};
             virtual void onVoiceReply(const std::string &text, const std::string &filePath) {};
diff --git a/src/Common/AppControl/src/AppControlHandle.cpp b/src/Common/AppControl/src/AppControlHandle.cpp
new file mode 100644 (file)
index 0000000..9a6167a
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2016  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "AppControlHandle.h"
+#include "AppControlLauncher.h"
+
+using namespace Msg;
+
+AppControlHandle::AppControlHandle(app_control_launch_mode_e launchMode)
+    : m_Handle()
+{
+    app_control_create(&m_Handle);
+    if (m_Handle)
+        setLaunchMode(launchMode);
+}
+
+AppControlHandle::~AppControlHandle()
+{
+    if (m_Handle) {
+        terminate();
+        app_control_destroy(m_Handle);
+    }
+}
+
+AppControlHandle::operator app_control_h()
+{
+    return m_Handle;
+}
+
+bool AppControlHandle::launch()
+{
+    return AppControlLauncher::getInst().launch(*this);
+}
+
+void AppControlHandle::terminate()
+{
+    if (m_Handle && AppControlLauncher::getInst().m_pHandle == this)
+        AppControlLauncher::getInst().terminate();
+}
+
+void AppControlHandle::setOperation(const char *operation)
+{
+    app_control_set_operation(m_Handle, operation);
+}
+
+void AppControlHandle::setUri(const char *uri)
+{
+    app_control_set_uri(m_Handle, uri);
+}
+
+void AppControlHandle::setLaunchMode(app_control_launch_mode_e mode)
+{
+    app_control_set_launch_mode(m_Handle, mode);
+}
index 187bcfcdcaa4f9b3ddacef98ff8408b7e25027f2..740eb433ec462658d5c7911b6114575962d69a1b 100644 (file)
 
 using namespace Msg;
 
-AppControlHandle::AppControlHandle(app_control_launch_mode_e launchMode)
-    : m_Handle()
-{
-    app_control_create(&m_Handle);
-    if (m_Handle)
-        app_control_set_launch_mode(m_Handle, launchMode);
-}
-
-AppControlHandle::~AppControlHandle()
-{
-    if (m_Handle) {
-        terminate();
-        app_control_destroy(m_Handle);
-    }
-}
-
-AppControlHandle::operator app_control_h()
-{
-    return m_Handle;
-}
-
-void AppControlHandle::terminate()
-{
-    if (m_Handle && AppControlLauncher::getInst().m_pHandle == this)
-        AppControlLauncher::getInst().terminate();
-}
-
 AppControlLauncher::AppControlLauncher()
     : m_LaunchInProgress(false)
     , m_pTimer(nullptr)
index e083ea1f062ce0156b9dd3595758c4b177b3caee..eb8bd8467ba0cac14b81cef362e873dc0aff3683 100644 (file)
@@ -21,18 +21,13 @@ using namespace Msg;
 
 InputSelector::InputSelector()
 {
-    app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_GET_INPUT);
+    setOperation(APP_CONTROL_OPERATION_GET_INPUT);
 }
 
 InputSelector::~InputSelector()
 {
 }
 
-bool InputSelector::launch()
-{
-    return  AppControlLauncher::getInst().launch(*this);
-}
-
 void InputSelector::onReply(app_control_h request, app_control_h reply, app_control_result_e result)
 {
     MSG_LOG("result = ", result);
@@ -53,5 +48,3 @@ void InputSelector::onReply(app_control_h request, app_control_h reply, app_cont
     }
 }
 
-
-