Use cbhm API 39/97839/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 14 Nov 2016 08:40:24 +0000 (17:40 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 17 Nov 2016 07:28:27 +0000 (23:28 -0800)
Change-Id: I0bb1c03438eaa0bafc70b60d2788620b8168ed21
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
CMakeLists.txt
packaging/ise-default.spec
src/cbhm.cpp [deleted file]
src/include/cbhm.h [deleted file]
src/ise.cpp

index 25e3cf6..85d0b95 100644 (file)
@@ -24,7 +24,6 @@ SET(ISE_SRCS
 
     src/ise-emoticon-list.cpp
     src/ise-emoticon-mode.cpp
-    src/cbhm.cpp
     src/modeindicator.cpp
     src/eflutil.cpp
 )
@@ -48,7 +47,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/include
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(ISE_PKGS REQUIRED
+SET(PKGS_CHECK_MODULES
         elementary
         efl-extension
         dlog
@@ -63,6 +62,13 @@ pkg_check_modules(ISE_PKGS REQUIRED
         capi-media-audio-io
         )
 
+IF (with_cbhm)
+    ADD_DEFINITIONS("-DHAVE_CBHM")
+    SET(PKGS_CHECK_MODULES ${PKGS_CHECK_MODULES} cbhm)
+ENDIF(with_cbhm)
+
+pkg_check_modules(ISE_PKGS REQUIRED ${PKGS_CHECK_MODULES})
+
 FOREACH(flag ${ISE_PKGS_CFLAGS})
     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
index f2bd9a0..c77425b 100644 (file)
@@ -1,3 +1,9 @@
+%if "%{profile}" == "mobile"
+%define WITH_CBHM TRUE
+%else
+%define WITH_CBHM FALSE
+%endif
+
 Name:       ise-default
 Summary:    Tizen keyboard
 Version:    1.3.3
@@ -23,6 +29,9 @@ BuildRequires:  pkgconfig(libtzplatform-config)
 BuildRequires:  pkgconfig(stt)
 BuildRequires:  pkgconfig(capi-appfw-application)
 BuildRequires:  pkgconfig(capi-media-audio-io)
+%if "%{WITH_CBHM}" == "TRUE"
+BuildRequires:  pkgconfig(cbhm)
+%endif
 BuildRequires:  model-build-features
 
 
@@ -69,7 +78,8 @@ rm -rf CMakeCache.txt
 cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
         -DTARGET=%{?profile} \
         -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP \
-        -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES
+        -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES \
+        -Dwith_cbhm=%{WITH_CBHM}
 
 make %{?jobs:-j%jobs}
 
diff --git a/src/cbhm.cpp b/src/cbhm.cpp
deleted file mode 100644 (file)
index 8590d04..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2012 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 <Eldbus.h>
-
-#define CBHM_DBUS_OBJPATH "/org/tizen/cbhm/dbus"
-#ifndef CBHM_DBUS_INTERFACE
-#define CBHM_DBUS_INTERFACE "org.tizen.cbhm.dbus"
-#endif /* CBHM_DBUS_INTERFACE */
-
-static Eldbus_Proxy      *eldbus_proxy = NULL;
-static Eldbus_Connection *cbhm_conn    = NULL;
-
-Eldbus_Proxy* cbhm_proxy_get()
-{
-    return eldbus_proxy;
-}
-
-static void _cbhm_on_name_owner_changed(void *data EINA_UNUSED,
-      const char *bus EINA_UNUSED, const char *old_id EINA_UNUSED,
-      const char *new_id EINA_UNUSED)
-{
-    /* If client should know the time clipboard service is started or stoped,
-     * use this function. */
-}
-
-void cbhm_eldbus_init()
-{
-   Eldbus_Object *eldbus_obj;
-
-   cbhm_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
-   eldbus_obj = eldbus_object_get(cbhm_conn, CBHM_DBUS_INTERFACE, CBHM_DBUS_OBJPATH);
-   eldbus_proxy = eldbus_proxy_get(eldbus_obj, CBHM_DBUS_INTERFACE);
-   eldbus_name_owner_changed_callback_add(cbhm_conn, CBHM_DBUS_INTERFACE,
-         _cbhm_on_name_owner_changed, cbhm_conn, EINA_TRUE);
-}
-
-void cbhm_eldbus_deinit()
-{
-   if (cbhm_conn)
-      eldbus_connection_unref(cbhm_conn);
-}
-
diff --git a/src/include/cbhm.h b/src/include/cbhm.h
deleted file mode 100644 (file)
index f3651ad..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2012 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 __CBHM_H__
-#define __CBHM_H__
-
-Eldbus_Proxy* cbhm_proxy_get();
-
-void cbhm_eldbus_init();
-void cbhm_eldbus_deinit();
-
-#endif //__CBHM_H__
\ No newline at end of file
index cdf45fa..776653e 100644 (file)
@@ -26,6 +26,9 @@
 #include <Ecore_IMF.h>
 #include <Elementary.h>
 #include <scim.h>
+#ifdef HAVE_CBHM
+#include <cbhm.h>
+#endif
 
 #include "sclui.h"
 #include "sclcore.h"
@@ -36,7 +39,6 @@
 #include "languages.h"
 #include "candidate-factory.h"
 #include "ise-emoticon-mode.h"
-#include "cbhm.h"
 #include "ise-stt-mode.h"
 #include "ise-stt-option.h"
 #include "modeindicator.h"
@@ -53,6 +55,10 @@ CSCLUI *g_ui = NULL;
 
 #include "ise.h"
 
+#ifdef HAVE_CBHM
+static cbhm_h cbhm_handle;
+#endif
+
 static CCoreEventCallback g_core_event_callback;
 CSCLCore g_core(&g_core_event_callback);
 int g_imdata_state = 0;
@@ -332,7 +338,10 @@ void CCoreEventCallback::on_init()
 {
     LOGD("CCoreEventCallback::init()\n");
     ise_create();
-    cbhm_eldbus_init();
+
+#ifdef HAVE_CBHM
+    cbhm_open_service(&cbhm_handle);
+#endif
 }
 
 void CCoreEventCallback::on_run(int argc, char **argv)
@@ -345,7 +354,11 @@ void CCoreEventCallback::on_exit()
 {
     ::ise_hide();
     ise_destroy();
-    cbhm_eldbus_deinit();
+
+#ifdef HAVE_CBHM
+    cbhm_close_service(cbhm_handle);
+    cbhm_handle = NULL;
+#endif
 }
 
 void CCoreEventCallback::on_attach_input_context(sclint ic, const sclchar *ic_uuid)
@@ -1079,7 +1092,12 @@ SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_d
                     g_core.create_option_window();
                 ret = SCL_EVENT_DONE;
             } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
-                eldbus_proxy_call(cbhm_proxy_get(), "CbhmShow", NULL, NULL, -1, "s", "0");
+#ifdef HAVE_CBHM
+                int cbhm_ret = cbhm_show(cbhm_handle);
+                if (cbhm_ret != CBHM_ERROR_NONE)
+                    LOGW("cbhm show error : %d\n", cbhm_ret);
+#endif
+
                 ret = SCL_EVENT_DONE;
             } else if (on_input_mode_changed(event_desc.key_value, event_desc.key_event, event_desc.key_type)) {
                 ret = SCL_EVENT_DONE;
@@ -1103,7 +1121,12 @@ SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_d
                     g_core.create_option_window();
                 ret = SCL_EVENT_DONE;
             } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
-                eldbus_proxy_call(cbhm_proxy_get(), "CbhmShow", NULL, NULL, -1, "s", "0");
+#ifdef HAVE_CBHM
+                int cbhm_ret = cbhm_hide(cbhm_handle);
+                if (cbhm_ret != CBHM_ERROR_NONE)
+                    LOGW("cbhm hide error : %d\n", cbhm_ret);
+#endif
+
                 ret = SCL_EVENT_DONE;
             } else if (strcmp(event_desc.key_value, "Cancel") == 0) {
                 ret = SCL_EVENT_DONE;