#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 */
#define LAYOUT_ROW_KEY_HINT_STRING_TAG "hint_string"
+#ifndef LOG_TAG
+#define LOG_TAG "LIBSCL_UI"
+#endif
+
class LayoutParserImpl {
public:
typedef struct {
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];
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;
};
release_layout_strings();
release_key_strings();
+ release_upper_strings();
}
void
}
release_key_strings();
+ release_upper_strings();
}
bool
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) {
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);
}
}
}
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;
}
}
}
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) {
}
} 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);
}
}
}