Modified to use g_utf8_strup for enhanced 'toupper' functionality 85/92785/3
authorJi-hoon Lee <dalton.lee@samsung.com>
Tue, 18 Oct 2016 13:06:18 +0000 (22:06 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Tue, 18 Oct 2016 13:23:45 +0000 (22:23 +0900)
Change-Id: I2dfed813ab0415bdcc0f2d6bcbc5808a4df9117e

CMakeLists.txt
packaging/libscl-ui.spec
scl/gwes/efl/sclwindows-efl.cpp
xmlresource/layout_parser.cpp

index 1228acf..5ab8a79 100644 (file)
@@ -90,6 +90,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src
 INCLUDE(FindPkgConfig)
 SET(PKGS_CHECK_MODULES
         elementary
+        glib-2.0
         feedback
         dlog
         libxml-2.0
index 8bc0e9e..3be5267 100644 (file)
@@ -16,6 +16,7 @@ BuildRequires:  pkgconfig(ecore-x)
 BuildRequires:  pkgconfig(x11)
 %endif
 BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(feedback)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(libxml-2.0)
index 7783c76..9fd8b93 100644 (file)
@@ -239,6 +239,7 @@ CSCLWindowsImplEfl::create_magnifier_window(const sclwindow parent, SclWindowCon
     CSCLUtils *utils = CSCLUtils::get_instance();
 
     win = elm_win_add(static_cast<Evas_Object*>(parent), "Magnifier", ELM_WIN_UTILITY);
+    LOGD("Created magnifier window %p, using parent %p", win, parent);
 
     elm_win_borderless_set(win, EINA_TRUE);
     elm_win_alpha_set(win, EINA_TRUE);
index a7903a0..19142e9 100644 (file)
@@ -20,6 +20,7 @@
 #include <malloc.h>
 #include <string.h>
 #include <libxml/parser.h>
+#include <glib.h>
 
 #include "layout_parser.h"
 #include "default_configure_parser.h" /* use data in default_configure.xml */
@@ -145,6 +146,10 @@ using namespace std;
 
 #define LAYOUT_ROW_KEY_HINT_STRING_TAG "hint_string"
 
+#ifndef LOG_TAG
+#define LOG_TAG "LIBSCL_UI"
+#endif
+
 class LayoutParserImpl {
     public:
         typedef struct {
@@ -217,6 +222,9 @@ class LayoutParserImpl {
         void add_key_string(xmlChar*);
         void release_key_strings();
 
+        void add_upper_string(gchar*);
+        void release_upper_strings();
+
     private:
         int m_layout_size;
         SclLayout m_layout_table[MAX_SCL_LAYOUT];
@@ -225,6 +233,7 @@ class LayoutParserImpl {
 
         std::vector<xmlChar*> m_vec_layout_strings;
         std::vector<xmlChar*> m_vec_key_strings;
+        std::vector<gchar*> m_vec_upper_strings;
         std::string m_dir;
 };
 
@@ -245,6 +254,7 @@ LayoutParserImpl::~LayoutParserImpl() {
 
     release_layout_strings();
     release_key_strings();
+    release_upper_strings();
 }
 
 void
@@ -292,6 +302,7 @@ void LayoutParserImpl::unload() {
     }
 
     release_key_strings();
+    release_upper_strings();
 }
 
 bool
@@ -346,6 +357,24 @@ LayoutParserImpl::release_key_strings() {
     m_vec_key_strings.clear();
 }
 
+void
+LayoutParserImpl::add_upper_string(gchar* newstr) {
+    if (newstr) {
+        m_vec_upper_strings.push_back(newstr);
+        LOGD("Adding upper string : %s", newstr);
+    }
+}
+
+void
+LayoutParserImpl::release_upper_strings() {
+    for (size_t loop = 0; loop < m_vec_upper_strings.size(); loop++) {
+        if (m_vec_upper_strings[loop]) {
+            g_free(m_vec_upper_strings[loop]);
+        }
+    }
+    m_vec_upper_strings.clear();
+}
+
 int
 LayoutParserImpl::get_layout_index(const char *name) {
     if (name) {
@@ -966,22 +995,26 @@ LayoutParserImpl::parsing_label_record_node(
                     if ((shift_state == shift_loop || shift_state == -1)) {
                         xmlChar* key = xmlNodeGetContent(child_node);
                         if (key) {
-                            cur_rec->label[shift_loop][label_for_one_state] = (sclchar*)key;
+                            sclboolean upper_created = FALSE;
                             if (auto_upper) {
                                 if (shift_loop != SCL_SHIFT_STATE_OFF) {
-                                    for (int key_loop = 0; key_loop < xmlStrlen(key); key_loop++) {
-                                        /* Let's manipulate the string for auto_upper */
-                                        *(key + key_loop) = toupper(*(key + key_loop));
-                                    }
+                                    gchar *upper = g_utf8_strup(reinterpret_cast<gchar*>(key), -1);
+                                    xmlFree(key);
+                                    add_upper_string(upper);
+                                    upper_created = TRUE;
+                                    key = reinterpret_cast<xmlChar*>(upper);
                                 }
                             }
+                            if (!upper_created) {
+                                add_key_string(key);
+                            }
+                            cur_rec->label[shift_loop][label_for_one_state] = (sclchar*)key;
                             /* If current key_value is NULL, let's just consider this label is the default key_value */
                             if (label_for_one_state == 0) {
                                 if (cur_rec->key_value[shift_loop][label_for_one_state] == NULL) {
                                     cur_rec->key_value[shift_loop][label_for_one_state] = (sclchar*)key;
                                 }
                             }
-                            add_key_string(key);
                         }
                     }
                 }
@@ -1137,16 +1170,20 @@ LayoutParserImpl::parsing_key_value_record_node(
                     if ((shift_state == shift_loop || shift_state == -1)) {
                         xmlChar* key = xmlNodeGetContent(child_node);
                         if (key) {
-                            cur_rec->key_value[shift_loop][multichar_state] = (sclchar*)key;
+                            sclboolean upper_created = FALSE;
                             if (auto_upper) {
                                 if (shift_loop != SCL_SHIFT_STATE_OFF) {
-                                    for (int key_loop = 0; key_loop < xmlStrlen(key); key_loop++) {
-                                        /* Let's manipulate the string for auto_upper */
-                                        *(key + key_loop) = toupper(*(key + key_loop));
-                                    }
+                                    gchar *upper = g_utf8_strup(reinterpret_cast<gchar*>(key), -1);
+                                    xmlFree(key);
+                                    add_upper_string(upper);
+                                    upper_created = TRUE;
+                                    key = reinterpret_cast<xmlChar*>(upper);
                                 }
                             }
-                            add_key_string(key);
+                            if (!upper_created) {
+                                add_key_string(key);
+                            }
+                            cur_rec->key_value[shift_loop][multichar_state] = (sclchar*)key;
                         }
                     }
                 }
@@ -1206,14 +1243,19 @@ LayoutParserImpl::parsing_auto_popup_keys_record_node(
                     xmlChar* key = xmlNodeGetContent(child_node);
                     if (key) {
                         if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"label")) {
+                            sclboolean upper_created = FALSE;
                             if (auto_upper) {
                                 if (shift_loop != SCL_SHIFT_STATE_OFF) {
-                                    for (int key_loop = 0; key_loop < xmlStrlen(key); key_loop++) {
-                                        /* Let's manipulate the string for auto_upper */
-                                        *(key + key_loop) = toupper(*(key + key_loop));
-                                    }
+                                    gchar *upper = g_utf8_strup(reinterpret_cast<gchar*>(key), -1);
+                                    xmlFree(key);
+                                    add_upper_string(upper);
+                                    upper_created = TRUE;
+                                    key = reinterpret_cast<xmlChar*>(upper);
                                 }
                             }
+                            if (!upper_created) {
+                                add_key_string(key);
+                            }
                             cur_rec->autopopup_key_labels[shift_loop][autopopup_state] = (sclchar*)key;
                             /* If current key_value is NULL, let's just consider this label is the default key_value */
                             if (cur_rec->autopopup_key_values[shift_loop][autopopup_state] == NULL) {
@@ -1221,10 +1263,11 @@ LayoutParserImpl::parsing_auto_popup_keys_record_node(
                             }
                         } else if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"value")) {
                             cur_rec->autopopup_key_values[shift_loop][autopopup_state] = (sclchar*)key;
+                            add_key_string(key);
                         } else if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"event")) {
                             cur_rec->autopopup_key_events[shift_loop][autopopup_state] = atoi((sclchar*)key);
+                            add_key_string(key);
                         }
-                        add_key_string(key);
                     }
                 }
             }