Add clipboard feature 45/82445/2
authorHaifeng Deng <haifeng.deng@samsung.com>
Wed, 3 Aug 2016 10:24:29 +0000 (18:24 +0800)
committerHaifeng Deng <haifeng.deng@samsung.com>
Wed, 3 Aug 2016 11:01:39 +0000 (19:01 +0800)
Change-Id: I334b34bdbc57dec253fbc62906509f2ef1b93022
Signed-off-by: Haifeng Deng <haifeng.deng@samsung.com>
CMakeLists.txt
data/layout/sdk/LYT_CM_POPUP.xml
data/pixmaps/default/sdk/icon_clipboard.png [new file with mode: 0644]
src/cbhm.cpp [new file with mode: 0644]
src/include/cbhm.h [new file with mode: 0644]
src/ise.cpp

index f502f35..6db03ef 100644 (file)
@@ -17,6 +17,7 @@ SET(ISE_SRCS
 
     src/ise-emoticon-list.cpp
     src/ise-emoticon-mode.cpp
+    src/cbhm.cpp
 )
 
 SET(ISE_PACKAGE ${PROJECT_NAME})
index 6b01054..078e43f 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<layout width="160" height="124" style="popup" key_width="75" key_height="116" key_spacing="2" row_spacing="2" hit_left="1" hit_right="1" hit_top="4" hit_bottom="4" label_type="PUNC_POPUP" vibe_style="DEFAULT" sound_style="DEFAULT">
+<layout width="237" height="124" style="popup" key_width="75" key_height="116" key_spacing="2" row_spacing="2" hit_left="1" hit_right="1" hit_top="4" hit_bottom="4" label_type="PUNC_POPUP" vibe_style="DEFAULT" sound_style="DEFAULT">
   <image_path>
     <button_normal>B09_popup_bg.png</button_normal>
   </image_path>
@@ -20,7 +20,7 @@
         <rec button="normal">popup_line/popup_line_left.png</rec>
       </background_image>
     </key>
-    <key key_type="modechange" custom_id="EMOTICON_KEY" hit_right="4">
+    <key key_type="modechange" custom_id="EMOTICON_KEY">
       <key_value>
         <rec>EMOTICON_LAYOUT</rec>
       </key_value>
         <rec button="disabled"></rec>
       </image_label>
       <background_image>
+        <rec button="normal">popup_line/popup_line_center.png</rec>
+        <rec button="disabled">popup_line/popup_line_center.png</rec>
+      </background_image>
+    </key>
+    <key key_type="user" hit_right="4">
+      <key_value>
+        <rec>CLIPBOARD</rec>
+      </key_value>
+      <image_label>
+        <rec button="normal">icon_clipboard.png</rec>
+        <rec button="pressed">icon_clipboard.png</rec>
+        <rec button="disabled"></rec>
+      </image_label>
+      <background_image>
         <rec button="normal">popup_line/popup_line_right.png</rec>
         <rec button="disabled">popup_line/popup_line_right.png</rec>
       </background_image>
diff --git a/data/pixmaps/default/sdk/icon_clipboard.png b/data/pixmaps/default/sdk/icon_clipboard.png
new file mode 100644 (file)
index 0000000..f4ea9da
Binary files /dev/null and b/data/pixmaps/default/sdk/icon_clipboard.png differ
diff --git a/src/cbhm.cpp b/src/cbhm.cpp
new file mode 100644 (file)
index 0000000..8590d04
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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
new file mode 100644 (file)
index 0000000..f3651ad
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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 f520a7d..0fd1e08 100644 (file)
@@ -33,6 +33,8 @@
 #include "languages.h"
 #include "candidate-factory.h"
 #include "ise-emoticon-mode.h"
+#include "cbhm.h"
+
 #define CANDIDATE_WINDOW_HEIGHT 84
 using namespace scl;
 #include <vector>
@@ -131,12 +133,13 @@ static ISELanguageManager _language_manager;
 #define MVK_Shift_Enable 0x9fe7
 #define MVK_Shift_Disable 0x9fe8
 
-#define CM_KEY_LIST_SIZE        2
-#define USER_KEYSTRING_OPTION   "OPTION"
-#define USER_KEYSTRING_EMOTICON "EMOTICON_LAYOUT"
+#define CM_KEY_LIST_SIZE         3
+#define USER_KEYSTRING_OPTION    "OPTION"
+#define USER_KEYSTRING_EMOTICON  "EMOTICON_LAYOUT"
+#define USER_KEYSTRING_CLIPBOARD "CLIPBOARD"
 
 static sclboolean           _cm_popup_opened = FALSE;
-static const char          *_cm_key_list[CM_KEY_LIST_SIZE] = {USER_KEYSTRING_OPTION, USER_KEYSTRING_EMOTICON};
+static const char          *_cm_key_list[CM_KEY_LIST_SIZE] = {USER_KEYSTRING_OPTION, USER_KEYSTRING_EMOTICON, USER_KEYSTRING_CLIPBOARD};
 static scluint              _current_cm_key_id = 0;
 
 /*
@@ -207,6 +210,12 @@ static void ise_set_cm_private_key(scluint cm_key_id)
             const_cast<sclchar*>("setting icon/B09_icon_setting_press_54x54.png"),
             const_cast<sclchar*>("setting icon/B09_icon_setting_dim_54x54.png")};
         g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(""), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_OPTION), TRUE);
+    } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_CLIPBOARD) == 0) {
+        sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
+            const_cast<sclchar*>("icon_clipboard.png"),
+            const_cast<sclchar*>("icon_clipboard.png"),
+            const_cast<sclchar*>("icon_clipboard.png")};
+        g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(""), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_CLIPBOARD), TRUE);
     }
 }
 
@@ -273,6 +282,7 @@ void CCoreEventCallback::on_init()
 {
     LOGD("CCoreEventCallback::init()\n");
     ise_create();
+    cbhm_eldbus_init();
 }
 
 void CCoreEventCallback::on_run(int argc, char **argv)
@@ -285,6 +295,7 @@ void CCoreEventCallback::on_exit()
 {
     ::ise_hide();
     ise_destroy();
+    cbhm_eldbus_deinit();
 }
 
 void CCoreEventCallback::on_attach_input_context(sclint ic, const sclchar *ic_uuid)
@@ -952,6 +963,9 @@ SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_d
                 if (!option_window_is_available (OPTION_WINDOW_TYPE_NORMAL))
                     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");
+                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;
             }
@@ -972,6 +986,9 @@ SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_d
                 if (!option_window_is_available (OPTION_WINDOW_TYPE_NORMAL))
                     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");
+                ret = SCL_EVENT_DONE;
             } else {
                 const sclchar *input_mode = g_ui->get_input_mode();
                 if ((NULL != input_mode) && (!strcmp(input_mode, "EMOTICON_LAYOUT")))
@@ -1008,6 +1025,12 @@ SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_d
                         _current_cm_key_id = id;
                         ise_set_cm_private_key(_current_cm_key_id);
                     }
+                } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
+                    scluint id = ise_get_cm_key_id(USER_KEYSTRING_CLIPBOARD);
+                    if (id != _current_cm_key_id) {
+                        _current_cm_key_id = id;
+                        ise_set_cm_private_key(_current_cm_key_id);
+                    }
                 }
                 _cm_popup_opened = FALSE;
             }