merge with master
authorJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:20:07 +0000 (01:20 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:20:07 +0000 (01:20 +0900)
52 files changed:
CMakeLists.txt
binary_xmlresource/binary_xmlresource.cpp
binary_xmlresource/default_configure_bin_parser.cpp
binary_xmlresource/include/_auto_metadata.h
binary_xmlresource/key_coordinate_frame_bin_parser.cpp
binary_xmlresource/label_properties_bin_parser.cpp
packaging/libscl-ui.spec
res/put_record.h
res/simple_debug.cpp [new file with mode: 0644]
res/simple_debug.h
res/simple_debug_test.cpp [moved from res/timer.cpp with 64% similarity]
res/timer.h [deleted file]
scl/gwes/efl/sclevents-efl.cpp
scl/gwes/efl/sclwindows-efl.cpp
scl/include/sclstructs.h
scl/include/sclui.h
scl/include/scluiimpl.h
scl/include/sclversion.h
scl/sclcontroller.cpp
scl/sclresourcecache.cpp
scl/sclui.cpp
scl/scluibuilder.cpp
scl/scluiimpl.cpp
sclres/sclres_manager.cpp
xml2binary/CMakeLists.txt
xml2binary/data/metadata.xml
xml2binary/encode_default_configure.cpp
xml2binary/encode_input_mode_configure.cpp
xml2binary/encode_key_coordinate_frame.cpp
xml2binary/encode_layout.cpp
xml2binary/include/_auto_metadata.h
xml2binary/xml2dat.cpp
xmlresource/autopopup_configure_parser.cpp
xmlresource/default_configure_parser.cpp
xmlresource/include/autopopup_configure_parser.h
xmlresource/include/default_configure_parser.h
xmlresource/include/input_mode_configure_parser.h
xmlresource/include/label_properties_parser.h
xmlresource/include/layout_parser.h
xmlresource/include/magnifier_configure_parser.h
xmlresource/include/main_entry_parser.h
xmlresource/include/modifier_decoration_parser.h
xmlresource/include/nine_patch_file_list_parser.h
xmlresource/include/xmlresource.h
xmlresource/input_mode_configure_parser.cpp
xmlresource/label_properties_parser.cpp
xmlresource/layout_parser.cpp
xmlresource/magnifier_configure_parser.cpp
xmlresource/main_entry_parser.cpp
xmlresource/modifier_decoration_parser.cpp
xmlresource/nine_patch_file_list_parser.cpp
xmlresource/xmlresource.cpp

index d3c0d00..13435e9 100644 (file)
@@ -56,7 +56,7 @@ SET(SRCS
     scl/sclactionstate.cpp
     scl/sclresourcecache.cpp
     res/sclresource.cpp
-    res/timer.cpp
+    res/simple_debug.cpp
 )
 
 SET(PACKAGE ${PROJECT_NAME})
@@ -123,6 +123,7 @@ INSTALL(FILES "${CMAKE_SOURCE_DIR}/scl/include/scltypes.h" DESTINATION include/l
 INSTALL(FILES "${CMAKE_SOURCE_DIR}/scl/include/sclconfig.h" DESTINATION include/libscl-ui)
 INSTALL(FILES "${CMAKE_SOURCE_DIR}/scl/include/sclstructs.h" DESTINATION include/libscl-ui)
 INSTALL(FILES "${CMAKE_SOURCE_DIR}/scl/include/scleventcallback.h" DESTINATION include/libscl-ui)
+INSTALL(FILES "${CMAKE_SOURCE_DIR}/res/simple_debug.h" DESTINATION include/libscl-ui)
 
 CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
 INSTALL(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
index 965d199..cb8e4ef 100644 (file)
 #include "string_provider.h"
 #include "metadata_provider.h"
 #include <assert.h>
-
-//for debug begin
 #include "simple_debug.h"
-#include "timer.h"
-//for debug end
 
 using namespace binary_xmlresource;
 
@@ -86,10 +82,7 @@ BinXmlResource* BinXmlResource::get_instance() {
 }
 
 void BinXmlResource::init(const char *entry_filepath) {
-    //for cal time begin
-    struct timeval tBegin;
-    gettimeofday(&tBegin, 0);
-    //for cal time end
+    SCLLOG_TIME_BEGIN();
 
     char path[_POSIX_PATH_MAX] = {0};
 
@@ -165,10 +158,8 @@ void BinXmlResource::init(const char *entry_filepath) {
         m_nine_patch_file_list_parser = Nine_patch_file_list_bin_Parser::get_instance();
         m_nine_patch_file_list_parser->init(storageAllData, info[NINE_PATCH].offset, info[NINE_PATCH].size, &parser_info_provider);
     }
-    //for cal time begin
-    printTime(&tBegin, "parsing binary xmlfiles");
-    //for cal time end
 
+    SCLLOG_TIME_END("Parsing binary XML files");
 }
 
 void BinXmlResource::load(int layout_id) {
index 4050f46..851f9b1 100644 (file)
@@ -118,9 +118,6 @@ void Default_Configure_Bin_Parser::parsing_default_configure() {
     //dim_color
     decode_color(cur->dim_color, record_width.dim_color);
 
-    //use_lazy_loading
-    cur->use_lazy_loading = m_storage.get<sint_t>(record_width.use_lazy_loading);
-
 #ifdef __SCL_TXT_DEBUG
     put_default_configure(DECODE, m_default_configure);
 #endif
index 12913a7..31cae4f 100644 (file)
@@ -141,7 +141,6 @@ typedef struct _Default_configure_width {
        int default_sub_layout;
        int use_actual_dim_window;
        int dim_color;
-       int use_lazy_loading;
 }Default_configure_width;
 
 typedef struct _Magnifier_configure_width {
@@ -340,7 +339,6 @@ void set_default_configure_width(T& md_helper,
        record_width.default_sub_layout = md_helper.get_width("default_sub_layout");
        record_width.use_actual_dim_window = md_helper.get_width("use_actual_dim_window");
        record_width.dim_color = md_helper.get_width("dim_color");
-       record_width.use_lazy_loading = md_helper.get_width("use_lazy_loading");
 }
 
 template <class T>
index 618f3d1..da32e0d 100644 (file)
@@ -27,6 +27,7 @@
 #include "put_record.h"
 #include <malloc.h>
 #include "binary_xmlresource.h"
+#include "simple_debug.h"
 using namespace binary_xmlresource;
 
 using namespace std;
@@ -108,7 +109,7 @@ load(int layout_id)
             for (int j = 0; j < pKey_num_array[i]; ++j) {
                 SclLayoutKeyCoordinatePointer curPointer = (SclLayoutKeyCoordinatePointer)malloc(sizeof(SclLayoutKeyCoordinate));
                 if (curPointer == NULL) {
-                    printf("Memory malloc error.\n");
+                    SCLLOG(SclLog::ERROR, "Memory malloc error.\n");
                     assert(0);
                 }
                 memset(curPointer, 0x00, sizeof(SclLayoutKeyCoordinate));
@@ -148,71 +149,18 @@ unload()
         }
     }
 }
-void Key_coordinate_frame_bin_Parser::init(const FileStorage& storage, int offset, int size, IParserInfo_Provider* parser_info_provider) {
+void
+Key_coordinate_frame_bin_Parser::init(const FileStorage& storage, int offset, int size, IParserInfo_Provider* parser_info_provider) {
     m_storage.set_str_provider(parser_info_provider);
     m_storage.get_storage(storage, offset, size);
     this->parser_info_provider = parser_info_provider;
-    parsing_key_coordinate_frame();
 }
 
-PSclLayoutKeyCoordinatePointerTable Key_coordinate_frame_bin_Parser::get_key_coordinate_pointer_frame() {
+PSclLayoutKeyCoordinatePointerTable
+Key_coordinate_frame_bin_Parser::get_key_coordinate_pointer_frame() {
     return m_key_coordinate_pointer_frame;
 }
-void Key_coordinate_frame_bin_Parser::parsing_key_coordinate_frame() {
-    sclboolean use_lazy_loading = FALSE;
-    Default_Configure_Bin_Parser *defalut_configure_parser = Default_Configure_Bin_Parser::get_instance();
-    if (defalut_configure_parser) {
-        PSclDefaultConfigure default_configure = defalut_configure_parser->get_default_configure();
-        if (default_configure) {
-            use_lazy_loading = default_configure->use_lazy_loading;
-        }
-    }
-    if (use_lazy_loading) {
-        return;
-    }
-    // 4 byte (range[0-4,294,967,295))
-    const int DATA_SIZE_BYTES = 4;
-    // 1 byte (range[0-128))
-    const int REC_NUM_BYTES = 1;
-    const int KEY_NUM_BYTES = 1;
-    // 2 byte (range[0-65536))
-    const int KEY_COORDIANTE_REC_DATA_SIZE_BYTES = 2;
-
-    // skip data_size
-    m_storage.advance(DATA_SIZE_BYTES);
-
-    // rec_num
-    int layout_num = m_storage.get<uint_t>(REC_NUM_BYTES);
-    int *pKey_num_array = new int[layout_num];
-    memset(pKey_num_array, 0x00, layout_num * sizeof(int));
-    for (int i = 0; i < layout_num; ++i) {
-        pKey_num_array[i] = m_storage.get<uint_t>(KEY_NUM_BYTES);
-    }
 
-    // key_coordinate_rec_data_size
-    int key_coordinate_rec_data_size = m_storage.get<uint_t>(KEY_COORDIANTE_REC_DATA_SIZE_BYTES);
-    Key_coordinate_record_width record_width;
-    set_key_coordinate_record_width(*parser_info_provider, record_width);
-
-    for (int i = 0; i < layout_num; ++i) {
-        for (int j = 0; j < pKey_num_array[i]; ++j) {
-            SclLayoutKeyCoordinatePointer curPointer = (SclLayoutKeyCoordinatePointer)malloc(sizeof(SclLayoutKeyCoordinate));
-            if (curPointer == NULL) {
-                printf("Memory malloc error.\n");
-                assert(0);
-            }
-
-            memset(curPointer, 0x00, sizeof(SclLayoutKeyCoordinate));
-            decode_key_coordinate_record(m_storage, curPointer, record_width);
-            m_key_coordinate_pointer_frame[i][j] = curPointer;
-        }
-    }
-
-    delete []pKey_num_array;
-#ifdef __SCL_TXT_DEBUG
-    put_key_coordinate_frame(DECODE, m_key_coordinate_pointer_frame);
-#endif
-}
 void
 Key_coordinate_frame_bin_Parser::decode_key_coordinate_record(FileStorage& storage, const PSclLayoutKeyCoordinate cur, const Key_coordinate_record_width& record_width) {
     int width = 0;
index f37b853..11ac35a 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #include "label_properties_bin_parser.h"
-
+#include "simple_debug.h"
 #include "put_record.h"
 Label_properties_bin_Parser* Label_properties_bin_Parser::m_instance = NULL;
 
@@ -59,7 +59,7 @@ void Label_properties_bin_Parser::parsing_label_properties_frame() {
     int maxj = m_storage.get<sint_t>(4);
 
     if (parser_info_provider == NULL) {
-        printf("Error parser_info_provider is NULL\n");
+        SCLLOG(SclLog::ERROR, "Error parser_info_provider is NULL\n");
         return;
     }
 
index 04992ea..b53c87d 100644 (file)
@@ -3,7 +3,7 @@
 
 Name:       libscl-ui
 Summary:    A library for developing XML-based software keyboards
-Version:    0.2.0
+Version:    0.2.3
 Release:    1
 Group:      TO BE / FILLED IN
 License:    TO BE / FILLED IN
index 34d8b1d..2a18a10 100644 (file)
@@ -224,7 +224,6 @@ put_default_configure_record(FILE* fp, const SclDefaultConfigure& record) {
     put_str(fp, record.default_sub_layout);
     put_int(fp, record.use_actual_dim_window);
     put_color(fp, record.dim_color);
-    put_int(fp, record.use_lazy_loading);
 }
 
 static void put_label_properties_record(FILE* fp, const SclLabelProperties& record) {
diff --git a/res/simple_debug.cpp b/res/simple_debug.cpp
new file mode 100644 (file)
index 0000000..de48aa6
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2012-2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.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://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 "simple_debug.h"
+#include <stdlib.h>
+#include <time.h>
+#include <sys/time.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+SclLog* SclLog::m_instance = NULL;
+
+SclLog::SclLog() : m_flog(NULL) {
+    char *env = NULL;
+    char *scllog = NULL;
+    char log_path[128];
+
+    /*
+     * Use export scllog="true" to enable scllog
+     */
+    scllog = getenv("scllog");
+    if (scllog == NULL || 0 != strcmp(scllog, "true")) {
+        return;
+    }
+
+    env = getenv("HOME");
+    if (env == NULL) {
+        return;
+    }
+
+    snprintf(log_path, 128, "%s/scl.log", env);
+    m_flog = fopen(log_path, "w+");
+    if (m_flog == NULL) {
+        fprintf(stderr, "Could not open file: %s", log_path);
+    }
+}
+
+SclLog::~SclLog() {
+    if (m_flog != NULL) {
+        fclose(m_flog);
+    }
+}
+
+SclLog*
+SclLog::get_instance() {
+    if(m_instance == NULL) {
+        m_instance = new SclLog();
+    }
+
+    return m_instance;
+}
+
+void
+SclLog::log(enum LOG_LEVEL level, char* fmt, ...) {
+    static const char *log_message[MAX_LOG_LEVEL] = {
+        "message", "warning", "debug", "error"
+    };
+
+    if (m_flog == NULL) {
+        return;
+    }
+
+    char str_log[128];
+    va_list ap;
+    va_start(ap, fmt);
+    vsprintf(str_log, fmt, ap);
+    va_end(ap);
+
+    /*
+     * log current time
+     */
+    time_t now;
+    struct tm *timenow;
+
+    time(&now);
+    timenow = localtime(&now);
+
+    fprintf(m_flog, "[ %s ] %s\n", log_message[level], asctime(timenow));
+    fprintf(m_flog, "\t%s\n", str_log);
+
+    fflush(m_flog);
+}
+
+void
+SCLLOG(enum SclLog::LOG_LEVEL level, char* fmt, ...) {
+    SclLog *log = SclLog::get_instance();
+    if (log) {
+        char str_log[128];
+        va_list ap;
+        va_start(ap, fmt);
+        vsprintf(str_log, fmt, ap);
+        va_end(ap);
+        log->log(level, str_log);
+    }
+}
+
+static struct timeval g_time_begin;
+static struct timeval g_time_end;
+void
+SCLLOG_TIME_BEGIN() {
+    gettimeofday(&g_time_begin, NULL);
+}
+
+void
+SCLLOG_TIME_END(char *msg) {
+    gettimeofday(&g_time_end, NULL);
+
+    long diff = (g_time_end.tv_sec - g_time_begin.tv_sec) * 1000000 + g_time_end.tv_usec - g_time_begin.tv_usec;
+    fprintf(stdout, "%s use %ld usec\n", msg, diff);
+}
index ce0b04a..1a6ccc3 100644 (file)
 
 #ifndef __SIMPLE_DEBUG_H__
 #define __SIMPLE_DEBUG_H__
-#define _PRINT(label, ...)\
-    do{\
-        fprintf(stderr, "[%s] %s at %s:", label, __FILE__, __FUNCTION__); \
-        fprintf(stderr, __VA_ARGS__);\
-        fprintf(stderr, "\n");\
-    }while (0);
+#include <stdio.h>
 
-#define LOG(...) _PRINT("log", __VA_ARGS__)
-#define DEBUG(...) _PRINT("debug", __VA_ARGS__)
+class SclLog {
+    public:
+        enum LOG_LEVEL {
+            MESSAGE = 0,
+            WARNING,
+            DEBUG,
+            ERROR,
+            MAX_LOG_LEVEL
+        };
+
+        static SclLog* get_instance();
+        void log(enum LOG_LEVEL, char* fmt, ...);
+        ~SclLog();
+    private:
+        SclLog();
+        static SclLog* m_instance;
+
+        FILE *m_flog;
+};
+
+
+void SCLLOG(enum SclLog::LOG_LEVEL level, char* fmt, ...);
+
+void SCLLOG_TIME_BEGIN();
+void SCLLOG_TIME_END(char *msg);
 #endif
similarity index 64%
rename from res/timer.cpp
rename to res/simple_debug_test.cpp
index 9d6ba1a..e50736e 100644 (file)
  *
  */
 
-#include "timer.h"
+/*
+ * Use `g++ -I. simple_debug.cpp simple_debug_test.cpp` to compiler it
+ */
+#include <simple_debug.h>
 #include <stdio.h>
-void
-printTime(struct timeval* tBegin, const char* note) {
-    struct timeval tEnd;
-    gettimeofday(&tEnd, 0);
-    long diff = (tEnd.tv_sec - tBegin->tv_sec) * 1000000 + tEnd.tv_usec - tBegin->tv_usec;
-    printf("%s use %ld usec\n", note, diff);
+
+int main() {
+    /* Test SclLog */
+    SclLog *log = SclLog::get_instance();
+    if (log) {
+        log->log(SclLog::WARNING, "Test %d\n", 100);
+    }
+
+    /* Test SCLLOG */
+    SCLLOG(SclLog::ERROR, "%s/%d", "SCLLOG", 100);
+    return 0;
 }
diff --git a/res/timer.h b/res/timer.h
deleted file mode 100644 (file)
index e9105e7..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2012-2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.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://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 __TIMER_H__
-#define __TIMER_H__
-#include <time.h>
-#include <sys/time.h>
-/**
- *Usage:
-       struct timeval tBegin;
-
-        gettimeofdaty(&tBegin, 0);
-        //Some CODES Here
-        printTime(&tBegin, "info");
- *
- */
-void
-printTime(struct timeval* tBegin, const char* note);
-
-#endif
index 2b21ce1..60b7c32 100644 (file)
@@ -220,7 +220,8 @@ Eina_Bool mouse_press(void *data, int type, void *event_info)
             if (window) {
                 // Update the position of the target window
                 //windows->get_window_context(window, TRUE);
-                windows->get_window_context(window);
+                SclWindowContext *winctx = windows->get_window_context(window);
+                windows->get_window_rect(window, &(winctx->geometry));
                 if (get_window_rect(window, &rect)) {
                     int adjustx = ev->root.x;
                     int adjusty = ev->root.y;
@@ -327,6 +328,8 @@ Eina_Bool mouse_release (void *data, int type, void *event_info)
             do {
                 window = windows->get_nth_window_in_Z_order_list(index);
                 if (window) {
+                    SclWindowContext *winctx = windows->get_window_context(window);
+                    windows->get_window_rect(window, &(winctx->geometry));
                     if (get_window_rect(window, &rect)) {
                         int adjustx = ev->root.x;
                         int adjusty = ev->root.y;
@@ -434,6 +437,8 @@ Eina_Bool mouse_move (void *data, int type, void *event_info)
             do {
                 window = windows->get_nth_window_in_Z_order_list(index);
                 if (window) {
+                    SclWindowContext *winctx = windows->get_window_context(window);
+                    windows->get_window_rect(window, &(winctx->geometry));
                     if (get_window_rect(window, &rect)) {
                         int adjustx = ev->root.x;
                         int adjusty = ev->root.y;
index 8cb5a60..c584d5f 100644 (file)
@@ -32,6 +32,13 @@ using namespace scl;
 
 Ecore_X_Atom ATOM_WM_CLASS = 0;
 
+const sclint rotation_values_EFL[ROTATION_MAX] = {
+    0, // ROTATION_0
+    90, // ROTATION_90_CW
+    180, // ROTATION_180
+    270, // ROTATION_90_CCW
+};
+
 void release_all(Evas_Object *win);
 
 #include "sclgraphics-efl.h"
@@ -115,8 +122,29 @@ CSCLWindowsImplEfl::create_window(const sclwindow parent, SclWindowContext *winc
 
     elm_win_borderless_set(win, EINA_TRUE);
     elm_win_alpha_set(win, EINA_TRUE);
+
+    scl16 new_width;
+    scl16 new_height;
+    CSCLContext *context = CSCLContext::get_instance();
+    if(context->get_rotation() == ROTATION_90_CW || context->get_rotation() == ROTATION_90_CCW) {
+        new_width = height;
+        new_height = width;
+    } else {
+        new_width = width;
+        new_height = height;
+    }
+
+    ecore_x_e_window_rotation_geometry_set(elm_win_xwindow_get(win),
+        rotation_values_EFL[ROTATION_0], 0, 0, new_width, new_height);
+    ecore_x_e_window_rotation_geometry_set(elm_win_xwindow_get(win),
+        rotation_values_EFL[ROTATION_90_CW], 0, 0, new_width, new_height);
+    ecore_x_e_window_rotation_geometry_set(elm_win_xwindow_get(win),
+        rotation_values_EFL[ROTATION_180], 0, 0, new_width, new_height);
+    ecore_x_e_window_rotation_geometry_set(elm_win_xwindow_get(win),
+        rotation_values_EFL[ROTATION_90_CCW], 0, 0, new_width, new_height);
+
 #ifndef FULL_SCREEN_TEST
-    evas_object_resize(win, width, height);
+    //evas_object_resize(win, width, height);
 #endif
 
     const char *szProfile[] = {"mobile", ""};
@@ -134,10 +162,9 @@ CSCLWindowsImplEfl::create_window(const sclwindow parent, SclWindowContext *winc
     //utilx_set_window_effect_style((Display*)dpy, elm_win_xwindow_get(static_cast<Evas_Object*>(win)), UTILX_EFFECT_TYPE_MAP, UTILX_EFFECT_STYLE_NONE);
 #endif
 
-    CSCLContext *context = CSCLContext::get_instance();
     set_window_rotation(win, context->get_rotation());
 
-    elm_win_override_set(win, EINA_TRUE);
+    //elm_win_override_set(win, EINA_TRUE);
     CSCLUtils *utils = CSCLUtils::get_instance();
     if (utils) {
         utils->log("%p, %d %d\n", win, width, height);
@@ -166,7 +193,7 @@ CSCLWindowsImplEfl::create_magnifier_window(const sclwindow parent, SclWindowCon
     /*
      * FIXME set override to let window manager responds elm_win_raise request
      */
-    elm_win_override_set(win, EINA_TRUE);
+    //elm_win_override_set(win, EINA_TRUE);
 
 #ifdef DO_NOT_MOVE_MAGNIFIER_WINDOW
     CSCLUtils *utils = CSCLUtils::get_instance();
@@ -176,12 +203,21 @@ CSCLWindowsImplEfl::create_magnifier_window(const sclwindow parent, SclWindowCon
     SclWindowContext *winctx = windows->get_window_context(windows->get_base_window());
     evas_object_resize(win, scrx, height + winctx->height);
 #else
-    evas_object_resize(win, width, height);
+    //evas_object_resize(win, width, height);
 #endif
 
     const char *szProfile[] = {"mobile", ""};
     elm_win_profiles_set(win, szProfile, 1);
 
+    ecore_x_e_window_rotation_geometry_set(elm_win_xwindow_get(win),
+        rotation_values_EFL[ROTATION_0], 0, 0, width, height);
+    ecore_x_e_window_rotation_geometry_set(elm_win_xwindow_get(win),
+        rotation_values_EFL[ROTATION_90_CW], 0, 0, height, width);
+    ecore_x_e_window_rotation_geometry_set(elm_win_xwindow_get(win),
+        rotation_values_EFL[ROTATION_180], 0, 0, width, height);
+    ecore_x_e_window_rotation_geometry_set(elm_win_xwindow_get(win),
+        rotation_values_EFL[ROTATION_90_CCW], 0, 0, height, width);
+
 #ifndef APPLY_WINDOW_MANAGER_CHANGE
     ecore_x_icccm_name_class_set(elm_win_xwindow_get(static_cast<Evas_Object*>(win)), "Key Magnifier", "ISF");
 
@@ -255,7 +291,7 @@ CSCLWindowsImplEfl::create_dim_window(const sclwindow parent, SclWindowContext *
     evas_object_color_set(bg, color.r, color.g, color.b, color.a);
     evas_object_show(bg);*/
 
-    elm_win_override_set(win, EINA_TRUE);
+    //elm_win_override_set(win, EINA_TRUE);
     hide_window(win);
 
     CSCLUtils *utils = CSCLUtils::get_instance();
@@ -390,7 +426,7 @@ CSCLWindowsImplEfl::show_window(const sclwindow window, sclboolean queue)
          * N_SE-17689: magnifier window showing behind of candidate window
          */
         if (window != windows->get_base_window()) {
-            elm_win_raise((Evas_Object *)window);
+            //elm_win_raise((Evas_Object *)window);
         }
         utils->log("%p (basewin %p mag %p)\n", window,
             windows->get_base_window(), windows->get_magnifier_window());
@@ -590,7 +626,9 @@ CSCLWindowsImplEfl::move_window(const sclwindow window, const scl16 x, const scl
 
         Evas_Object *win = (Evas_Object*)window;
 #ifndef FULL_SCREEN_TEST
-        evas_object_move(win, rotatex, rotatey);
+        if (window != windows->get_base_window()) {
+            evas_object_move(win, rotatex, rotatey);
+        }
 #endif
         //Evas_Object *window_object = (Evas_Object*)window;
         //Evas *evas = evas_object_evas_get(window_object);
@@ -631,7 +669,6 @@ CSCLWindowsImplEfl::resize_window(const sclwindow window, const scl16 width, con
 
     Evas_Object *win = (Evas_Object*)window;
 #ifndef FULL_SCREEN_TEST
-    evas_object_resize(win, width, height);
     if (windows && utils) {
         utils->log("%p %d %d (basewin %p mag %p)\n", window, width, height,
             windows->get_base_window(), windows->get_magnifier_window());
@@ -645,6 +682,10 @@ CSCLWindowsImplEfl::resize_window(const sclwindow window, const scl16 width, con
     }*/
     //evas_render_idle_flush(evas);
     if (windows) {
+        if (window != windows->get_base_window()) {
+            evas_object_resize(win, width, height);
+        }
+
         if (window == windows->get_dim_window()) {
             hide_window(window);
         }
@@ -660,11 +701,13 @@ CSCLWindowsImplEfl::move_resize_window(const sclwindow window, const scl16 x, co
     SCL_DEBUG();
     Evas_Object *win = (Evas_Object*)window;
 #ifndef FULL_SCREEN_TEST
-    evas_object_move(win, x, y);
-    evas_object_resize(win, width, height);
     CSCLWindows *windows = CSCLWindows::get_instance();
     CSCLUtils *utils = CSCLUtils::get_instance();
     if (windows && utils) {
+        if (window != windows->get_base_window()) {
+            evas_object_move(win, x, y);
+            evas_object_resize(win, width, height);
+        }
         utils->log("%p %d %d %d %d (basewin %p mag %p)\n",
             window, x, y, width, height, windows->get_base_window());
     }
@@ -897,13 +940,6 @@ CSCLWindowsImplEfl::set_window_rotation(const sclwindow window, const SCLRotatio
 {
     SCL_DEBUG();
 
-    const sclint rotation_values_EFL[ROTATION_MAX] = {
-        0, // ROTATION_0
-        90, // ROTATION_90_CW
-        180, // ROTATION_180
-        270, // ROTATION_90_CCW
-    };
-
     CSCLWindows *windows = CSCLWindows::get_instance();
     SclWindowContext *winctx = NULL;
 
@@ -919,8 +955,7 @@ CSCLWindowsImplEfl::set_window_rotation(const sclwindow window, const SCLRotatio
     }
 
     if (scl_check_arrindex(rotation, ROTATION_MAX)) {
-        elm_win_rotation_set(static_cast<Evas_Object*>(window), rotation_values_EFL[rotation]);
-        //elm_win_rotation_with_resize_set(static_cast<Evas_Object*>(window),degree);
+        elm_win_rotation_with_resize_set(static_cast<Evas_Object*>(window), rotation_values_EFL[rotation]);
     }
 
     XSizeHints hint;
index fd81201..ed4d0ac 100644 (file)
@@ -208,8 +208,8 @@ typedef struct _SclLabelProperties {
     /* Font color depending on the button and shift state */
     SclColor font_color[SCL_SHIFT_STATE_MAX][SCL_BUTTON_STATE_MAX];
     SCLLabelAlignment alignment;                       /* Alignment option for this label property */
-    sclbyte padding_x;                                         /* X padding value for alignment option above */
-    sclbyte padding_y;                                         /* Y padding value for alignment option above */
+    sclshort padding_x;                                                /* X padding value for alignment option above */
+    sclshort padding_y;                                                /* Y padding value for alignment option above */
     sclbyte inner_width;                                       /* Inner width value for making a inner rect padded in above values */
     sclbyte inner_height;                                      /* Inner height value for making a inner rect padded in above values */
     sclbyte shadow_distance;                           /* A distance value for drawing shadow */
@@ -345,7 +345,6 @@ typedef struct _SclDefaultConfigure {
     sclchar *default_sub_layout;                       /* Initial sub_layout_name */
     sclboolean use_actual_dim_window;          /* Whether to use a new window or make a dim window as a layer of existing base window */
     SclColor dim_color;                                                /* Color setting for dim window */
-    sclboolean use_lazy_loading;                       /* Whether to load layout files when needed */
 }SclDefaultConfigure;
 
 /**
index 0d06282..0e10dd0 100644 (file)
@@ -49,7 +49,7 @@ public:
      * @param[in] entry_filepath a file path to SCL's UI resource entry file
      * @return non-zero value is returned when successful
      */
-    sclboolean init(sclwindow main_window, SCLParserType parser_type, const char *entry_filepath);
+    sclboolean init(sclwindow main_window, SCLParserType parser_type, const sclchar *entry_filepath);
 
     /**
      * @brief This API requests SCL library to show the S/W keyboard on the screen
@@ -88,13 +88,13 @@ public:
 
     /**
      * @brief This API checks if the current display mode is portrait or landscape
-     * @return non-zero value is returned when successful
+     * @return current display mode
      */
     SCLDisplayMode get_display_mode();
 
     /**
      * @brief This API request SCL library to change to given input mode
-     * @param[in] name the name of the desired input mode
+     * @param[in] input_mode the name of the desired input mode
      * @return non-zero value is returned when successful
      */
     sclboolean set_input_mode(const sclchar *input_mode);
@@ -184,11 +184,19 @@ public:
      */
     void close_all_popups();
 
+    /*
+     * @brief This API acquires the size of main window
+     * @param[out] rect the geometry information of main window
+     */
+    SclRectangle get_main_window_rect();
+
     /**
-     * @brief This API acquires the size of base window
-     * @param[out] rect the geometry information of base window
+     * @brief This API retrieves the current input mode
+     * @param[in] input_mode the name of the desired input mode
+     * @param[in] display_mode desired display mode value
+     * @return a size struct contains the input_mode's size in given display_mode
      */
-    void get_window_rect(SclRectangle *rect);
+    SclSize get_input_mode_size(const sclchar *input_mode, SCLDisplayMode display_mode);
 
     /**
      * @brief This API acquires the screen size of current device
index 3d17769..9a70d63 100644 (file)
@@ -76,7 +76,8 @@ public:
     void reset_popup_timeout();
     void close_all_popups();
 
-    void get_window_rect(SclRectangle *rect);
+    SclRectangle get_main_window_rect();
+    SclSize get_input_mode_size(const sclchar *input_mode, SCLDisplayMode display_mode);
     void get_screen_resolution(sclint *width, sclint *height);
 
     scl16 get_scale_x(scl16 x);
index 333ee57..5729cfc 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef __SCL_VERSION_H__
 #define __SCL_VERSION_H__
 
-#define SCL_VERSION "0.2.0-1"
+#define SCL_VERSION "0.2.3-1"
 
 #endif //__SCL_VERSION_H
 
@@ -40,4 +40,6 @@ Version History
         - Minor changes for tizen 2.0 open
     0.1.8-1
         - Modified the EFL backend to call elm_win_raise() for popup windows as well
+    0.2.2-1
+        - Implemented synchronization feature with window manager
 */
index 1f9743f..a86299e 100644 (file)
@@ -135,8 +135,8 @@ typedef enum {
         sclint width;
         sclint height;
         SCLLabelAlignment align;
-        sclbyte padding_x;
-        sclbyte padding_y;
+        sclshort padding_x;
+        sclshort padding_y;
         sclbyte inner_width;
         sclbyte inner_height;
     } TextCache;
@@ -258,12 +258,14 @@ CSCLController::process_rotation_change(const SCLRotation rotation)
         /* FIXME : NEWXML temporary commenting out */
         //context->set_base_layout(sclres_input_mode_configure[context->get_input_mode()].layouts[context->get_display()]);
 
-        /* Make sure to set window's rotation degree before sending engine signal, which adjusts the size of main window */
-        windows->set_window_rotation(NULL, rotation);
-
         sclwindow window = windows->get_base_window();
         handle_engine_signal(SCL_SIG_DISP_CHANGE, window);
         windows->update_window(window);
+
+        /* Moved to here since the new WMSync requires the rotation call be invoked as the
+           last step of display change process */
+        /* Make sure to set window's rotation degree before sending engine signal, which adjusts the size of main window */
+        windows->set_window_rotation(NULL, rotation);
     }
     return TRUE;
 }
@@ -3149,7 +3151,7 @@ void CSCLController::handle_engine_signal( SclInternalSignal signal, sclwindow t
         // SIGACTION_CLOSE_MAGNIFIER
         {      TRUE,   TRUE,   TRUE,   TRUE,           TRUE,           0,                      0,                      0,                      0,                      0,                      0,              TRUE    },
         // SIGACTION_UNSET_SHIFT
-        {      TRUE,   0       ,       0       ,       TRUE,           TRUE,           0,                      0,                      0,                      0,                      0,                      0,              TRUE    },
+        {      TRUE,   0       ,       0       ,       TRUE,           0,                      0,                      0,                      0,                      0,                      0,                      0,              TRUE    },
         // SIGACTION_UNPRESS_KEYS
         {      TRUE,   TRUE,   TRUE,   TRUE,           TRUE,           0,                      0,                      0,                      0,                      0,                      0,              TRUE    },
         // SIGACTION_INIT_DISPLAY
index 45f507e..dbaaa27 100644 (file)
@@ -138,19 +138,19 @@ CSCLResourceCache::resize_layout_by_resolution(sclbyte layout_index, sclboolean
             }
         }
 
-        /* FIXME : We should apply this contraint to other scaling routines also! */
-        /* If the current screen resolution Y is bigger than our target height */
-        if (scale_value_y > 1.0f) {
-            /* And if we have to scale Y-axis more than the X-axis, limit the scale value to X-axis rate */
-            if (scale_value_y > scale_value_x) {
-                scale_value_y = scale_value_x;
-            }
-        } else if (scale_value_y < 1.0f) { /* Or current screen is smaller than our target resolution */
-            /* And if we have to scale Y-axis more than the X-axis, limit the scale value to X-axis rate */
-            if (scale_value_y < scale_value_x) {
-                scale_value_y = scale_value_x;
-            }
-        }
+        ///* FIXME : We should apply this contraint to other scaling routines also! */
+        ///* If the current screen resolution Y is bigger than our target height */
+        //if (scale_value_y > 1.0f) {
+        //    /* And if we have to scale Y-axis more than the X-axis, limit the scale value to X-axis rate */
+        //    if (scale_value_y > scale_value_x) {
+        //        scale_value_y = scale_value_x;
+        //    }
+        //} else if (scale_value_y < 1.0f) { /* Or current screen is smaller than our target resolution */
+        //    /* And if we have to scale Y-axis more than the X-axis, limit the scale value to X-axis rate */
+        //    if (scale_value_y < scale_value_x) {
+        //        scale_value_y = scale_value_x;
+        //    }
+        //}
 
         if (!resize_key_only) {
             sclres_layout[layout_index].width *= scale_value_x;
@@ -842,15 +842,15 @@ CSCLResourceCache::recompute_layout(sclwindow window)
         sclbyte inputmode = context->get_input_mode();
 
         if (windows->is_base_window(window)) {
-            layout = sclres_manager->get_layout_id(sclres_input_mode_configure[inputmode].layouts[context->get_display_mode()]);
-            if (default_configure->use_lazy_loading) {
-                if (layout != context->get_base_layout()) {
-                    sclres_manager->unload();
-                }
-                if (!(sclres_manager->loaded(layout))) {
-                    sclres_manager->load(layout);
-                    resize_layout_by_resolution(layout, TRUE);
-                }
+            SCLDisplayMode display_mode = context->get_display_mode();
+            layout = sclres_manager->get_layout_id(
+                    sclres_input_mode_configure[inputmode].layouts[display_mode]);
+            if (layout != context->get_base_layout()) {
+                sclres_manager->unload();
+            }
+            if (!(sclres_manager->loaded(layout))) {
+                sclres_manager->load(layout);
+                resize_layout_by_resolution(layout, TRUE);
             }
             context->set_base_layout(layout);
 
@@ -864,11 +864,9 @@ CSCLResourceCache::recompute_layout(sclwindow window)
 
             layout = context->get_popup_layout(window);
 
-            if (default_configure->use_lazy_loading) {
-                if (!(sclres_manager->loaded(layout))) {
-                    sclres_manager->load(layout);
-                    resize_layout_by_resolution(layout, TRUE);
-                }
+            if (!(sclres_manager->loaded(layout))) {
+                sclres_manager->load(layout);
+                resize_layout_by_resolution(layout, TRUE);
             }
             context->set_base_layout(layout);
 
@@ -946,10 +944,10 @@ CSCLResourceCache::recompute_layout(sclwindow window)
             }
 
             /* Resize window */
-            if (windows->is_base_window(window)) {
+            /*if (windows->is_base_window(window)) {
                 windows->resize_window(window, mCurBaseLayout.width, mCurBaseLayout.height);
                 windows->resize_window(windows->get_dim_window(), mCurBaseLayout.width, mCurBaseLayout.height);
-            }
+            }*/
 
             /* EFL testing */
             windows->update_window(window);
index ccd951a..c6e2c28 100644 (file)
@@ -294,14 +294,33 @@ CSCLUI::get_scale_y(scl16 y)
 }
 
 /**
- * Returns the scl base window size
+ * Returns the scl main window size
  */
-void
-CSCLUI::get_window_rect(SclRectangle *rect)
+SclRectangle
+CSCLUI::get_main_window_rect()
+{
+    SclRectangle ret = {0};
+
+    if (m_impl) {
+        ret = m_impl->get_main_window_rect();
+    }
+
+    return ret;
+}
+
+/**
+ * Returns the size of given input mode
+ */
+SclSize
+CSCLUI::get_input_mode_size(const sclchar *input_mode, SCLDisplayMode display_mode)
 {
+    SclSize ret = {0};
+
     if (m_impl) {
-        m_impl->get_window_rect(rect);
+        ret = m_impl->get_input_mode_size(input_mode, display_mode);
     }
+
+    return ret;
 }
 
 /**
index 5f38316..0902f1c 100644 (file)
@@ -441,8 +441,8 @@ CSCLUIBuilder::draw_button_label(const sclwindow window, const scldrawctx draw_c
                 const SclLabelProperties *labelproperties = cache->get_label_properties(coordination->image_label_type, 0);
                 if (labelproperties) {
                     SCLLabelAlignment align = labelproperties->alignment;
-                    sclbyte padding_x = labelproperties->padding_x;
-                    sclbyte padding_y = labelproperties->padding_y;
+                    sclshort padding_x = labelproperties->padding_x;
+                    sclshort padding_y = labelproperties->padding_y;
                     if (align == LABEL_ALIGN_LEFT_MIDDLE ||
                         align == LABEL_ALIGN_CENTER_MIDDLE ||
                         align == LABEL_ALIGN_RIGHT_MIDDLE) {
index a243b4c..441f81a 100644 (file)
@@ -112,8 +112,7 @@ CSCLUIImpl::show()
                 /* Let's relocate our base window - bottomed center aligned */
                 sclint width, height;
                 //get_layout_size(&width, &height);
-                SclRectangle rect;
-                get_window_rect(&rect);
+                SclRectangle rect = get_main_window_rect();
 
                 sclint scrx, scry;
                 utils->get_screen_resolution(&scrx, &scry);
@@ -231,8 +230,7 @@ CSCLUIImpl::set_rotation(SCLRotation rotation)
                 /* Let's relocate our base window - bottomed center aligned */
                 sclint width, height;
                 //get_layout_size(&width, &height);
-                SclRectangle rect;
-                get_window_rect(&rect);
+                SclRectangle rect = get_main_window_rect();
 
                 sclint scrx, scry;
                 utils->get_screen_resolution(&scrx, &scry);
@@ -530,10 +528,10 @@ CSCLUIImpl::get_scale_y(scl16 y)
 /**
  * Returns the scl base window size
  */
-void
-CSCLUIImpl::get_window_rect(SclRectangle *rect)
+SclRectangle
+CSCLUIImpl::get_main_window_rect()
 {
-    sclboolean ret = FALSE;
+    SclRectangle ret = {0};
 
     if (m_initialized) {
         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
@@ -542,15 +540,41 @@ CSCLUIImpl::get_window_rect(SclRectangle *rect)
             //const SclLayout *layout  = cache->get_cur_layout(windows->get_base_window());
             SclWindowContext *winctx = windows->get_window_context(windows->get_base_window());
             if (winctx) {
-                if (rect) {
-                    rect->x = winctx->geometry.x;
-                    rect->y = winctx->geometry.y;
-                    rect->width = winctx->geometry.width;
-                    rect->height = winctx->geometry.height;
-                }
+                ret.x = winctx->geometry.x;
+                ret.y = winctx->geometry.y;
+                ret.width = winctx->geometry.width;
+                ret.height = winctx->geometry.height;
             }
         }
     }
+
+    return ret;
+}
+
+/**
+ * Returns the scl base window size
+ */
+SclSize
+CSCLUIImpl::get_input_mode_size(const sclchar *input_mode, SCLDisplayMode display_mode)
+{
+    SclSize ret = {0};
+
+    if (m_initialized) {
+        CSCLUtils *utils = CSCLUtils::get_instance();
+        SclResParserManager *sclres_manager = SclResParserManager::get_instance();
+        if (utils && sclres_manager) {
+            const PSclInputModeConfigure sclres_input_mode_configure = sclres_manager->get_input_mode_configure_table();
+            const PSclLayout sclres_layout = sclres_manager->get_layout_table();
+            sclint inputmode = sclres_manager->get_inputmode_id(input_mode);
+            sclint layout = sclres_manager->get_layout_id(
+                sclres_input_mode_configure[inputmode].layouts[display_mode]);
+
+            ret.width = sclres_layout[layout].width;
+            ret.height = sclres_layout[layout].height;
+        }
+    }
+
+    return ret;
 }
 
 /**
index f1b6431..7e563cb 100644 (file)
@@ -19,6 +19,7 @@
 #include "xmlresource.h"
 #include "binary_xmlresource.h"
 #include <assert.h>
+#include "simple_debug.h"
 using namespace xmlresource;
 using namespace binary_xmlresource;
 using namespace sclres;
@@ -46,11 +47,11 @@ SclResParserManager::SclResParserManager() {
 void
 SclResParserManager::init(const SCLParserType parser_type, const char *entry_filepath) {
     if (parser_type == SCL_PARSER_TYPE_XML) {
-        printf("Use text xml\n");
+        SCLLOG(SclLog::MESSAGE, "Use text xml\n");
         m_cur = XMLResource::get_instance();
     }
     else if (parser_type == SCL_PARSER_TYPE_BINARY_XML) {
-        printf("Use binary xml\n");
+        SCLLOG(SclLog::MESSAGE, "Use binary xml\n");
         m_cur = BinXmlResource::get_instance();
     }
 
index d13c8d1..64c4925 100644 (file)
@@ -27,7 +27,7 @@ SET(SRCS
     metadata_handler.cpp
     xml2dat.cpp
     ../sclres/sclres.cpp
-    ../res/timer.cpp
+    ../res/simple_debug.cpp
 )
 
 SET(PACKAGE ${PROJECT_NAME})
index f574e58..ad81a7c 100644 (file)
     <field name = "default_sub_layout" type = "string_id"/>
     <field name = "use_actual_dim_window" type = "int8"/>
     <field name = "dim_color" type = "int8"/>
-    <field name = "use_lazy_loading" type = "int8"/>
 </record>
 <record name = "magnifier_configure">
     <field name = "style" type = "int8"/>
index 5971104..4f2bf34 100644 (file)
@@ -87,9 +87,6 @@ encode_default_configure_record(ResourceStorage& storage, const PSclDefaultConfi
 
     //dim_color
     _encode_color(storage, cur->dim_color, record_width.dim_color);
-
-    //use_lazy_loading
-    storage.put<sint_t>(cur->use_lazy_loading, record_width.use_lazy_loading);
 }
 
 int
index dc0a698..c26212d 100644 (file)
@@ -19,7 +19,6 @@
 #include "encode_input_mode_configure.h"
 #include <string>
 #include <libxml/parser.h>
-#include "timer.h"
 #include "xmlresource.h"
 #include "imetadata_helper.h"
 #include "put_record.h"
index 002bf65..59b53e3 100644 (file)
@@ -216,18 +216,10 @@ encode_key_coordinate_frame_file(ResourceStorage& storage, IMetaData_Helper& md_
     SclLayoutKeyCoordinatePointer _key_coordinate_pointer_frame[MAX_SCL_LAYOUT][MAX_KEY];
     memset(_key_coordinate_pointer_frame, 0x00, MAX_KEY * MAX_SCL_LAYOUT * sizeof(SclLayoutKeyCoordinatePointer));
 
-    if (xmlresource->get_default_configure()->use_lazy_loading == FALSE) {
-        for (int i = 0; i < layout_num; ++i) {
-            for (int j = 0; j < MAX_KEY; ++j) {
-                _key_coordinate_pointer_frame[i][j] = xmlresource->get_key_coordinate_pointer_frame()[i][j];
-            }
-        }
-    }else {
-        for (int i = 0; i < layout_num; ++i) {
-            xmlresource->load(i);
-            for (int j = 0; j < MAX_KEY; ++j) {
-                _key_coordinate_pointer_frame[i][j] = xmlresource->get_key_coordinate_pointer_frame()[i][j];
-            }
+    for (int i = 0; i < layout_num; ++i) {
+        xmlresource->load(i);
+        for (int j = 0; j < MAX_KEY; ++j) {
+            _key_coordinate_pointer_frame[i][j] = xmlresource->get_key_coordinate_pointer_frame()[i][j];
         }
     }
     // 4 byte (range[0-4,294,967,295))
index a5a9701..64a1dc3 100644 (file)
@@ -19,7 +19,6 @@
 #include "encode_layout.h"
 #include <string>
 #include <libxml/parser.h>
-#include "timer.h"
 #include "xmlresource.h"
 #include "put_record.h"
 #include "_auto_metadata.h"
index 12913a7..31cae4f 100644 (file)
@@ -141,7 +141,6 @@ typedef struct _Default_configure_width {
        int default_sub_layout;
        int use_actual_dim_window;
        int dim_color;
-       int use_lazy_loading;
 }Default_configure_width;
 
 typedef struct _Magnifier_configure_width {
@@ -340,7 +339,6 @@ void set_default_configure_width(T& md_helper,
        record_width.default_sub_layout = md_helper.get_width("default_sub_layout");
        record_width.use_actual_dim_window = md_helper.get_width("use_actual_dim_window");
        record_width.dim_color = md_helper.get_width("dim_color");
-       record_width.use_lazy_loading = md_helper.get_width("use_lazy_loading");
 }
 
 template <class T>
index 5e33cc7..165ed60 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <limits.h>
+#include <unistd.h>
 #include "xml2dat.h"
 #include "string_encoder.h"
 #include "metadata_handler.h"
 #include "encode_autopopup_configure.h"
 #include "encode_nine_patch.h"
 #include "xmlresource.h"
-
 using namespace xmlresource;
 using namespace std;
 
 String_Encoder actual_string_encoder;
 IString_Encoder& string_encoder = actual_string_encoder;
 
-static inline const char* Usage(){
+static inline void show_usage(){
     static const char* message = {  "xml2binary: missing folder operand\n"
                                     "-------------------------------------------------------\n"
                                     "|  Usage: xml2binary operand1 operand2                |\n"
                                     "|  operand1: the folder where xml text files located  |\n"
                                     "|  operand2: the folder you want to place the bin file|\n"
                                     "------------------------------------------------------- \n"};
-    return message;
+    printf("%s", message);
 }
 
 int main(const int argc, char* argv[]) {
     if (argc < 2) {
-        printf(Usage());
+        show_usage();
         return -1;
     }
 
index 52404bb..1c7e611 100644 (file)
  *
  */
 
-#include "autopopup_configure_parser.h"
-#include "main_entry_parser.h"
 #include <assert.h>
+#include <string.h>
+#include <libxml/parser.h>
+
+#include "autopopup_configure_parser.h"
 #include "xml_parser_utils.h"
+#include "simple_debug.h"
 using namespace std;
 
-AutoPopup_Configure_Parser* AutoPopup_Configure_Parser::m_instance = NULL;
+class AutoPopupConfigureParserImpl {
+    public:
+        AutoPopupConfigureParserImpl() {
+            memset((void*)&m_autopopup_configure, 0x00, sizeof(SclAutoPopupConfigure));
 
-AutoPopup_Configure_Parser::AutoPopup_Configure_Parser() {
-    memset((void*)&m_autopopup_configure, 0x00, sizeof(SclAutoPopupConfigure));
+            m_autopopup_configure.add_grab_left = NOT_USED;
+            m_autopopup_configure.add_grab_right = NOT_USED;
+            m_autopopup_configure.add_grab_top = NOT_USED;
+            m_autopopup_configure.add_grab_bottom= NOT_USED;
+        }
 
-    m_autopopup_configure.add_grab_left = NOT_USED;
-    m_autopopup_configure.add_grab_right = NOT_USED;
-    m_autopopup_configure.add_grab_top = NOT_USED;
-    m_autopopup_configure.add_grab_bottom= NOT_USED;
-}
+        ~AutoPopupConfigureParserImpl() {
+            /* Let's create de-initializing function for this resource releasement */
+            sclint loop;
+            for(loop = 0;loop < SCL_BUTTON_STATE_MAX;loop++) {
+                if (m_autopopup_configure.button_image_path[loop]) {
+                    xmlFree(m_autopopup_configure.button_image_path[loop]);
+                    m_autopopup_configure.button_image_path[loop] = NULL;
+                }
+            }
+            for(loop = 0;loop < MAX_WND_DECORATOR;loop++) {
+                if (m_autopopup_configure.decoration_image_path[loop]) {
+                    xmlFree(m_autopopup_configure.decoration_image_path[loop]);
+                    m_autopopup_configure.decoration_image_path[loop] = NULL;
+                }
+            }
+            if (m_autopopup_configure.label_type) {
+                xmlFree(m_autopopup_configure.label_type);
+                m_autopopup_configure.label_type = NULL;
+            }
 
-AutoPopup_Configure_Parser::~AutoPopup_Configure_Parser() {
-    /* Let's create de-initializing function for this resource releasement */
-    sclint loop;
-    for(loop = 0;loop < SCL_BUTTON_STATE_MAX;loop++) {
-        if (m_autopopup_configure.button_image_path[loop]) {
-            xmlFree(m_autopopup_configure.button_image_path[loop]);
-            m_autopopup_configure.button_image_path[loop] = NULL;
-        }
-    }
-    for(loop = 0;loop < MAX_WND_DECORATOR;loop++) {
-        if (m_autopopup_configure.decoration_image_path[loop]) {
-            xmlFree(m_autopopup_configure.decoration_image_path[loop]);
-            m_autopopup_configure.decoration_image_path[loop] = NULL;
         }
-    }
-    if (m_autopopup_configure.label_type) {
-        xmlFree(m_autopopup_configure.label_type);
-        m_autopopup_configure.label_type = NULL;
-    }
-}
 
-AutoPopup_Configure_Parser* AutoPopup_Configure_Parser::get_instance() {
-    if (m_instance == NULL) {
-        m_instance = new AutoPopup_Configure_Parser();
-    }
-    return m_instance;
-}
+        int parsing_autopopup_configure(const char* input_file) {
+            xmlDocPtr doc;
+            xmlNodePtr cur_node;
 
-int
-AutoPopup_Configure_Parser::get_button_state_prop(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
-    int button_state = -1;
-
-    if (equal_prop(cur_node, "button_state", "pressed")) {
-        button_state = BUTTON_STATE_PRESSED;
-    } else if (equal_prop(cur_node, "button_state", "normal")) {
-        button_state = BUTTON_STATE_NORMAL;
-    }
-    else if (equal_prop(cur_node, "button_state", "disabled")) {
-        button_state = BUTTON_STATE_DISABLED;
-    }
-    return button_state;
-}
+            doc = xmlReadFile(input_file, NULL, 0);
+            if (doc == NULL) {
+                SCLLOG(SclLog::WARNING, "Could not load file: %s.", input_file);
+                return -1;
+            }
 
-SCLDisplayMode
-AutoPopup_Configure_Parser::get_content_displaymode(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
+            cur_node = xmlDocGetRootElement(doc);
+            if (cur_node == NULL) {
+                SCLLOG(SclLog::WARNING, "AutoPopup_Configure_Parser: empty document.\n");
+                xmlFreeDoc(doc);
+                return -1;
+            }
+            if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"autopopup_configure"))
+            {
+                SCLLOG(SclLog::WARNING, "AutoPopup_Configure: root name error: %s\n!", (char *)cur_node->name);
+                xmlFreeDoc(doc);
+                return -1;
+            }
 
-    SCLDisplayMode display_mode = DISPLAYMODE_PORTRAIT;
+            cur_node = cur_node->xmlChildrenNode;
+
+            while (cur_node != NULL) {
+                if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"background_image_path")) {
+                    xmlChar* temp = xmlNodeGetContent(cur_node);
+                    m_autopopup_configure.bg_image_path = (sclchar *)temp;
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"background_color")) {
+                    parsing_background_color(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"background_line_width")) {
+                    m_autopopup_configure.bg_line_width = get_content_int(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"background_line_color")) {
+                    parsing_background_line_color(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"background_padding")) {
+                    m_autopopup_configure.bg_padding = get_content_int(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"button_image_path")) {
+                    parsing_button_image_path(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"sw_button_style")) {
+                    m_autopopup_configure.sw_button_style = get_content_int(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"button_size")) {
+                    parsing_button_size(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"button_spacing")) {
+                    m_autopopup_configure.button_spacing = get_content_int(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"label_type")) {
+                    xmlChar* temp = xmlNodeGetContent(cur_node);
+                    m_autopopup_configure.label_type = (sclchar *)temp;
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"window_decorator")) {
+                    get_prop_number(cur_node, "size", &(m_autopopup_configure.decoration_size));
+                    parsing_window_decorator_image_path(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"max_column")) {
+                    m_autopopup_configure.max_column = get_content_int(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"grab_area")) {
+                    parsing_grab_area(cur_node);
+                }
+
+                cur_node = cur_node->next;
+            }
+            xmlFreeDoc(doc);
+            return 0;
 
-    xmlChar* key = xmlNodeGetContent(cur_node);
-    if (key!= NULL) {
-        if (0 == strcmp("landscape", (const char*)key)) {
-            display_mode = DISPLAYMODE_LANDSCAPE;
         }
-        xmlFree(key);
-    }
-
-    return display_mode;
-}
-
-void AutoPopup_Configure_Parser::init() {
-    parsing_autopopup_configure();
-}
-
-void AutoPopup_Configure_Parser::parsing_background_color(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
+        void parsing_background_color(const xmlNodePtr cur_node) {
+            assert(cur_node != NULL);
+
+            xmlNodePtr child_node = cur_node->xmlChildrenNode;
+            while (child_node!=NULL) {
+                if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"r") ) {
+                    m_autopopup_configure.bg_color.r = get_content_int(child_node);
+                }
+                else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"g") ) {
+                    m_autopopup_configure.bg_color.g = get_content_int(child_node);
+                }
+                else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"b") ) {
+                    m_autopopup_configure.bg_color.b = get_content_int(child_node);
+                }
+                else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"a") ) {
+                    m_autopopup_configure.bg_color.a = get_content_int(child_node);
+                }
+
+                child_node = child_node->next;
+            }
 
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-    while (child_node!=NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"r") ) {
-            m_autopopup_configure.bg_color.r = get_content_int(child_node);
-        }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"g") ) {
-            m_autopopup_configure.bg_color.g = get_content_int(child_node);
-        }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"b") ) {
-            m_autopopup_configure.bg_color.b = get_content_int(child_node);
-        }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"a") ) {
-            m_autopopup_configure.bg_color.a = get_content_int(child_node);
         }
 
-        child_node = child_node->next;
-    }
-}
+        void parsing_background_line_color(const xmlNodePtr cur_node) {
+            assert(cur_node != NULL);
+
+            xmlNodePtr child_node = cur_node->xmlChildrenNode;
+            while (child_node!=NULL) {
+                if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"r") ) {
+                    m_autopopup_configure.bg_line_color.r = get_content_int(child_node);
+                }
+                else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"g") ) {
+                    m_autopopup_configure.bg_line_color.g = get_content_int(child_node);
+                }
+                else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"b") ) {
+                    m_autopopup_configure.bg_line_color.b = get_content_int(child_node);
+                }
+                else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"a") ) {
+                    m_autopopup_configure.bg_line_color.a = get_content_int(child_node);
+                }
+
+                child_node = child_node->next;
+            }
+        }
 
-void AutoPopup_Configure_Parser::parsing_background_line_color(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
+        void parsing_button_image_path(const xmlNodePtr cur_node) {
+            assert(cur_node != NULL);
+            assert(0 == xmlStrcmp(cur_node->name, (const xmlChar*)"button_image_path"));
+            xmlNodePtr child_node = cur_node->xmlChildrenNode;
+
+            while (child_node != NULL) {
+                if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"image") ) {
+                    int button_state = get_button_state_prop(child_node);
+                    if (button_state >= 0 && button_state < SCL_BUTTON_STATE_MAX) {
+                        m_autopopup_configure.button_image_path[button_state] = (sclchar*)xmlNodeGetContent(child_node);
+                    }
+                }
+                child_node = child_node->next;
+            }
 
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-    while (child_node!=NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"r") ) {
-            m_autopopup_configure.bg_line_color.r = get_content_int(child_node);
-        }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"g") ) {
-            m_autopopup_configure.bg_line_color.g = get_content_int(child_node);
-        }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"b") ) {
-            m_autopopup_configure.bg_line_color.b = get_content_int(child_node);
-        }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"a") ) {
-            m_autopopup_configure.bg_line_color.a = get_content_int(child_node);
         }
+        void parsing_button_size(const xmlNodePtr cur_node) {
+            assert(cur_node != NULL);
+
+            xmlNodePtr child_node = cur_node->xmlChildrenNode;
+            while (child_node!=NULL) {
+                if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"width") ) {
+                    m_autopopup_configure.button_width = get_content_int(child_node);
+                } else if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"height") ) {
+                    m_autopopup_configure.button_height = get_content_int(child_node);
+                }
+                child_node = child_node->next;
+            }
 
-        child_node = child_node->next;
-    }
-}
+        }
 
-void
-AutoPopup_Configure_Parser::parsing_button_image_path(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
-    assert(0 == xmlStrcmp(cur_node->name, (const xmlChar*)"button_image_path"));
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-
-    while (child_node != NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"image") ) {
-            int button_state = get_button_state_prop(child_node);
-            if (button_state >= 0 && button_state < SCL_BUTTON_STATE_MAX) {
-                m_autopopup_configure.button_image_path[button_state] = (sclchar*)xmlNodeGetContent(child_node);
+        void parsing_window_decorator_image_path(const xmlNodePtr cur_node) {
+            assert(cur_node != NULL);
+            assert(0 == xmlStrcmp(cur_node->name, (const xmlChar*)"window_decorator"));
+            xmlNodePtr child_node = cur_node->xmlChildrenNode;
+
+            while (child_node != NULL) {
+                if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"image") ) {
+                    if (equal_prop(cur_node, "direction", "top_left")) {
+                        m_autopopup_configure.decoration_image_path[WND_DECORATOR_TOP_LEFT] = (sclchar *)xmlNodeGetContent(cur_node);;
+                    }
+                    else if (equal_prop(cur_node, "direction", "top_center")) {
+                        m_autopopup_configure.decoration_image_path[WND_DECORATOR_TOP_CENTER] = (sclchar *)xmlNodeGetContent(cur_node);;
+                    }
+                    else if (equal_prop(cur_node, "direction", "top_right")) {
+                        m_autopopup_configure.decoration_image_path[WND_DECORATOR_TOP_RIGHT] = (sclchar *)xmlNodeGetContent(cur_node);;
+                    }
+                    else if (equal_prop(cur_node, "direction", "middle_left")) {
+                        m_autopopup_configure.decoration_image_path[WND_DECORATOR_MIDDLE_LEFT] = (sclchar *)xmlNodeGetContent(cur_node);;
+                    }
+                    else if (equal_prop(cur_node, "direction", "middle_right")) {
+                        m_autopopup_configure.decoration_image_path[WND_DECORATOR_MIDDLE_RIGHT] = (sclchar *)xmlNodeGetContent(cur_node);;
+                    }
+                    else if (equal_prop(cur_node, "direction", "bottom_left")) {
+                        m_autopopup_configure.decoration_image_path[WND_DECORATOR_BOTTOM_LEFT] = (sclchar *)xmlNodeGetContent(cur_node);;
+                    }
+                    else if (equal_prop(cur_node, "direction", "bottom_center")) {
+                        m_autopopup_configure.decoration_image_path[WND_DECORATOR_BOTTOM_CENTER] = (sclchar *)xmlNodeGetContent(cur_node);;
+                    }
+                    else if (equal_prop(cur_node, "direction", "bottom_right")) {
+                        m_autopopup_configure.decoration_image_path[WND_DECORATOR_BOTTOM_RIGHT] = (sclchar *)xmlNodeGetContent(cur_node);;
+                    }
+                }
+                child_node = child_node->next;
             }
+
         }
-        child_node = child_node->next;
-    }
-}
 
-void AutoPopup_Configure_Parser::parsing_button_size(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
+        void parsing_grab_area(const xmlNodePtr cur_node) {
+            assert(cur_node != NULL);
+
+            xmlNodePtr child_node = cur_node->xmlChildrenNode;
+            while (child_node!=NULL) {
+                if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"left") ) {
+                    m_autopopup_configure.add_grab_left = get_content_int(child_node);
+                }
+                else if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"right") ) {
+                    m_autopopup_configure.add_grab_right = get_content_int(child_node);
+                }
+                else if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"top") ) {
+                    m_autopopup_configure.add_grab_top = get_content_int(child_node);
+                }
+                else if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"bottom") ) {
+                    m_autopopup_configure.add_grab_bottom = get_content_int(child_node);
+                }
+                child_node = child_node->next;
+            }
 
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-    while (child_node!=NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"width") ) {
-            m_autopopup_configure.button_width = get_content_int(child_node);
-        } else if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"height") ) {
-            m_autopopup_configure.button_height = get_content_int(child_node);
         }
-        child_node = child_node->next;
-    }
-}
 
-void
-AutoPopup_Configure_Parser::parsing_window_decorator_iamge_path(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
-    assert(0 == xmlStrcmp(cur_node->name, (const xmlChar*)"window_decorator"));
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
+        int get_button_state_prop(const xmlNodePtr cur_node) {
+            assert(cur_node != NULL);
+            int button_state = -1;
 
-    while (child_node != NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"image") ) {
-            if (equal_prop(cur_node, "direction", "top_left")) {
-                m_autopopup_configure.decoration_image_path[WND_DECORATOR_TOP_LEFT] = (sclchar *)xmlNodeGetContent(cur_node);;
-            }
-            else if (equal_prop(cur_node, "direction", "top_center")) {
-                m_autopopup_configure.decoration_image_path[WND_DECORATOR_TOP_CENTER] = (sclchar *)xmlNodeGetContent(cur_node);;
+            if (equal_prop(cur_node, "button_state", "pressed")) {
+                button_state = BUTTON_STATE_PRESSED;
+            } else if (equal_prop(cur_node, "button_state", "normal")) {
+                button_state = BUTTON_STATE_NORMAL;
             }
-            else if (equal_prop(cur_node, "direction", "top_right")) {
-                m_autopopup_configure.decoration_image_path[WND_DECORATOR_TOP_RIGHT] = (sclchar *)xmlNodeGetContent(cur_node);;
+            else if (equal_prop(cur_node, "button_state", "disabled")) {
+                button_state = BUTTON_STATE_DISABLED;
             }
-            else if (equal_prop(cur_node, "direction", "middle_left")) {
-                m_autopopup_configure.decoration_image_path[WND_DECORATOR_MIDDLE_LEFT] = (sclchar *)xmlNodeGetContent(cur_node);;
-            }
-            else if (equal_prop(cur_node, "direction", "middle_right")) {
-                m_autopopup_configure.decoration_image_path[WND_DECORATOR_MIDDLE_RIGHT] = (sclchar *)xmlNodeGetContent(cur_node);;
-            }
-            else if (equal_prop(cur_node, "direction", "bottom_left")) {
-                m_autopopup_configure.decoration_image_path[WND_DECORATOR_BOTTOM_LEFT] = (sclchar *)xmlNodeGetContent(cur_node);;
-            }
-            else if (equal_prop(cur_node, "direction", "bottom_center")) {
-                m_autopopup_configure.decoration_image_path[WND_DECORATOR_BOTTOM_CENTER] = (sclchar *)xmlNodeGetContent(cur_node);;
-            }
-            else if (equal_prop(cur_node, "direction", "bottom_right")) {
-                m_autopopup_configure.decoration_image_path[WND_DECORATOR_BOTTOM_RIGHT] = (sclchar *)xmlNodeGetContent(cur_node);;
-            }
-        }
-        child_node = child_node->next;
-    }
-}
-
-void AutoPopup_Configure_Parser::parsing_grab_area(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
+            return button_state;
 
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-    while (child_node!=NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"left") ) {
-            m_autopopup_configure.add_grab_left = get_content_int(child_node);
-        }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"right") ) {
-            m_autopopup_configure.add_grab_right = get_content_int(child_node);
-        }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"top") ) {
-            m_autopopup_configure.add_grab_top = get_content_int(child_node);
-        }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"bottom") ) {
-            m_autopopup_configure.add_grab_bottom = get_content_int(child_node);
         }
-        child_node = child_node->next;
-    }
-}
+        SCLDisplayMode get_content_displaymode(const xmlNodePtr cur_node) {
+            assert(cur_node != NULL);
 
-void AutoPopup_Configure_Parser::parsing_autopopup_configure() {
-    xmlDocPtr doc;
-    xmlNodePtr cur_node;
+            SCLDisplayMode display_mode = DISPLAYMODE_PORTRAIT;
 
-    char input_file[_POSIX_PATH_MAX] = {0};
-    Main_Entry_Parser::get_file_full_path(input_file, "autopopup_configure");
+            xmlChar* key = xmlNodeGetContent(cur_node);
+            if (key!= NULL) {
+                if (0 == strcmp("landscape", (const char*)key)) {
+                    display_mode = DISPLAYMODE_LANDSCAPE;
+                }
+                xmlFree(key);
+            }
 
-    doc = xmlReadFile(input_file, NULL, 0);
-    if (doc == NULL) {
-        printf("Could not load file.\n");
-        exit(1);
-    }
+            return display_mode;
 
-    cur_node = xmlDocGetRootElement(doc);
-    if (cur_node == NULL) {
-        printf("empty document.\n");
-        xmlFreeDoc(doc);
-        exit(1);
-    }
-    if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"autopopup_configure"))
-    {
-        printf("root name %s error!\n", cur_node->name);
-        xmlFreeDoc(doc);
-        exit(1);
-    }
+        }
+        SclAutoPopupConfigure m_autopopup_configure;
+};
 
-    cur_node = cur_node->xmlChildrenNode;
+AutoPopup_Configure_Parser* AutoPopup_Configure_Parser::m_instance = NULL;
 
-    while (cur_node != NULL) {
-        if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"background_image_path")) {
-            xmlChar* temp = xmlNodeGetContent(cur_node);
-            m_autopopup_configure.bg_image_path = (sclchar *)temp;
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"background_color")) {
-            parsing_background_color(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"background_line_width")) {
-            m_autopopup_configure.bg_line_width = get_content_int(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"background_line_color")) {
-            parsing_background_line_color(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"background_padding")) {
-            m_autopopup_configure.bg_padding = get_content_int(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"button_image_path")) {
-            parsing_button_image_path(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"sw_button_style")) {
-            m_autopopup_configure.sw_button_style = get_content_int(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"button_size")) {
-            parsing_button_size(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"button_spacing")) {
-            m_autopopup_configure.button_spacing = get_content_int(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"label_type")) {
-            xmlChar* temp = xmlNodeGetContent(cur_node);
-            m_autopopup_configure.label_type = (sclchar *)temp;
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"window_decorator")) {
-            get_prop_number(cur_node, "size", &(m_autopopup_configure.decoration_size));
-            parsing_window_decorator_iamge_path(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"max_column")) {
-            m_autopopup_configure.max_column = get_content_int(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"grab_area")) {
-            parsing_grab_area(cur_node);
-        }
+AutoPopup_Configure_Parser::AutoPopup_Configure_Parser() {
+    m_impl = new AutoPopupConfigureParserImpl;
+    if (m_impl == NULL) {
+        SCLLOG(SclLog::ERROR, "Create AutoPopup_Configure_Parser failed");
+    }
+}
 
-        cur_node = cur_node->next;
+AutoPopup_Configure_Parser::~AutoPopup_Configure_Parser() {
+    if (m_impl) {
+        SCLLOG(SclLog::MESSAGE, "~AutoPopup_Configure_Parser() has called");
+        delete m_impl;
+        m_impl = NULL;
     }
-    //print_default_configure_table();
-    xmlFreeDoc(doc);
 }
 
-PSclAutoPopupConfigure AutoPopup_Configure_Parser::get_autopopup_configure() {
-    return &m_autopopup_configure;
+AutoPopup_Configure_Parser*
+AutoPopup_Configure_Parser::get_instance() {
+    if (m_instance == NULL) {
+        m_instance = new AutoPopup_Configure_Parser();
+    }
+    return m_instance;
 }
 
-void AutoPopup_Configure_Parser::print_default_configure_table() {
+int
+AutoPopup_Configure_Parser::init(const char* file) {
+    return m_impl->parsing_autopopup_configure(file);
+}
 
+PSclAutoPopupConfigure
+AutoPopup_Configure_Parser::get_autopopup_configure() {
+    return &m_impl->m_autopopup_configure;
 }
index 0318146..73f1746 100644 (file)
  *
  */
 
-#include "default_configure_parser.h"
-#include "main_entry_parser.h"
 #include <assert.h>
+#include <string.h>
+#include <libxml/parser.h>
+#include "default_configure_parser.h"
 #include "xml_parser_utils.h"
+#include "simple_debug.h"
 using namespace std;
 
-Default_Configure_Parser* Default_Configure_Parser::m_instance = NULL;
-
-Default_Configure_Parser::Default_Configure_Parser() {
-    memset((void*)&m_default_configure, 0x00, sizeof(SclDefaultConfigure));
-}
+class DefaultConfigureParserImpl {
+    public:
+        DefaultConfigureParserImpl() {
+            memset((void*)&m_default_configure, 0x00, sizeof(SclDefaultConfigure));
+        }
 
-Default_Configure_Parser::~Default_Configure_Parser() {
-    /* Let's create de-initializing function for this resource releasement */
-    if (m_default_configure.input_mode) {
-        xmlFree(m_default_configure.input_mode);
-        m_default_configure.input_mode = NULL;
-    }
-    if (m_default_configure.input_mode) {
-        xmlFree(m_default_configure.input_mode);
-        m_default_configure.input_mode = NULL;
-    }
-    if (m_default_configure.image_file_base_path) {
-        xmlFree(m_default_configure.image_file_base_path);
-        m_default_configure.image_file_base_path = NULL;
-    }
-}
+        ~DefaultConfigureParserImpl() {
+            /* Let's create de-initializing function for this resource releasement */
+            if (m_default_configure.input_mode) {
+                xmlFree(m_default_configure.input_mode);
+                m_default_configure.input_mode = NULL;
+            }
+            if (m_default_configure.input_mode) {
+                xmlFree(m_default_configure.input_mode);
+                m_default_configure.input_mode = NULL;
+            }
+            if (m_default_configure.image_file_base_path) {
+                xmlFree(m_default_configure.image_file_base_path);
+                m_default_configure.image_file_base_path = NULL;
+            }
 
-Default_Configure_Parser* Default_Configure_Parser::get_instance() {
-    if (m_instance == NULL) {
-        m_instance = new Default_Configure_Parser();
-    }
-    return m_instance;
-}
+        }
 
-void Default_Configure_Parser::init() {
-    parsing_default_configure();
-}
+        int parsing_default_configure(const char* input_file) {
+            xmlDocPtr doc;
+            xmlNodePtr cur_node;
 
-void Default_Configure_Parser::parsing_touch_offset(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
+            doc = xmlReadFile(input_file, NULL, 0);
+            if (doc == NULL) {
+                SCLLOG(SclLog::DEBUG, "Could not load file: %s.", input_file);
+                return -1;
+            }
 
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-    while (child_node!=NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"portrait") ) {
-            xmlNodePtr grandChildNode = child_node->xmlChildrenNode;
-            while (grandChildNode!=NULL) {
-                if (0 == xmlStrcmp(grandChildNode->name, (const xmlChar*)"x") ) {
-                    m_default_configure.touch_offset[DISPLAYMODE_PORTRAIT].x = get_content_int(grandChildNode);
-                } else if (0 == xmlStrcmp(grandChildNode->name, (const xmlChar*)"y") ) {
-                    m_default_configure.touch_offset[DISPLAYMODE_PORTRAIT].y = get_content_int(grandChildNode);
-                }
-                grandChildNode = grandChildNode->next;
+            cur_node = xmlDocGetRootElement(doc);
+            if (cur_node == NULL) {
+                SCLLOG(SclLog::DEBUG, "Default_Configure_Parser: empty document.\n");
+                xmlFreeDoc(doc);
+                return -1;
             }
-        } else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"landscape") ) {
-            xmlNodePtr grandChildNode = child_node->xmlChildrenNode;
-            while (grandChildNode!=NULL) {
-                if (0 == xmlStrcmp(grandChildNode->name, (const xmlChar*)"x") ) {
-                    m_default_configure.touch_offset[DISPLAYMODE_LANDSCAPE].x = get_content_int(grandChildNode);
-                } else if (0 == xmlStrcmp(grandChildNode->name, (const xmlChar*)"y") ) {
-                    m_default_configure.touch_offset[DISPLAYMODE_LANDSCAPE].y = get_content_int(grandChildNode);
-                }
-                grandChildNode = grandChildNode->next;
+            if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"default_configure"))
+            {
+                SCLLOG(SclLog::DEBUG, "Default_Configure_Parser: root name error: %s\n!", (char *)cur_node->name);
+                xmlFreeDoc(doc);
+                return -1;
             }
-        }
 
-        child_node = child_node->next;
-    }
-}
+            cur_node = cur_node->xmlChildrenNode;
 
-void Default_Configure_Parser::parsing_dim_color(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
+            while (cur_node != NULL) {
+                if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"display")) {
+                    m_default_configure.display_mode = get_content_display_mode(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"input_mode")) {
+                    xmlChar* temp = xmlNodeGetContent(cur_node);
+                    m_default_configure.input_mode = (sclchar *)temp;
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"base_screen_width")) {
+                    m_default_configure.target_screen_width = get_content_int(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"base_screen_height")) {
+                    m_default_configure.target_screen_height = get_content_int(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"image_file_base_path")) {
+                    xmlChar* temp = xmlNodeGetContent(cur_node);
+                    m_default_configure.image_file_base_path = (sclchar *)temp;
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"use_magnifier")) {
+                    m_default_configure.use_magnifier_window = get_content_bool(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"use_autopopup")) {
+                    m_default_configure.use_auto_popup = get_content_bool(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"use_zoomwindow")) {
+                    m_default_configure.use_zoom_window = get_content_bool(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"use_error_sound")) {
+                    m_default_configure.on_error_noti_send = get_content_bool(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"use_word_deletion")) {
+                    m_default_configure.use_word_deletion = get_content_bool(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"touch_offset_level")) {
+                    // Let's skip this item since it does not seem to be useful anymore
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"touch_offset")) {
+                    // Let's skip this item since it does not seem to be useful anymore
+                    parsing_touch_offset(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"default_sub_layout")) {
+                    xmlChar* temp = xmlNodeGetContent(cur_node);
+                    m_default_configure.default_sub_layout = (sclchar *)temp;
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"dim_use_window_flag")) {
+                    m_default_configure.use_actual_dim_window = get_content_bool(cur_node);
+                }
+                else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"dim_color")) {
+                    parsing_dim_color(cur_node);
+                }
+                cur_node = cur_node->next;
+            }
+            xmlFreeDoc(doc);
+
+            return 0;
+
+        }
+
+        void parsing_touch_offset(const xmlNodePtr cur_node) {
+            assert(cur_node != NULL);
+
+            xmlNodePtr child_node = cur_node->xmlChildrenNode;
+            while (child_node!=NULL) {
+                if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"portrait") ) {
+                    xmlNodePtr grandChildNode = child_node->xmlChildrenNode;
+                    while (grandChildNode!=NULL) {
+                        if (0 == xmlStrcmp(grandChildNode->name, (const xmlChar*)"x") ) {
+                            m_default_configure.touch_offset[DISPLAYMODE_PORTRAIT].x = get_content_int(grandChildNode);
+                        } else if (0 == xmlStrcmp(grandChildNode->name, (const xmlChar*)"y") ) {
+                            m_default_configure.touch_offset[DISPLAYMODE_PORTRAIT].y = get_content_int(grandChildNode);
+                        }
+                        grandChildNode = grandChildNode->next;
+                    }
+                } else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"landscape") ) {
+                    xmlNodePtr grandChildNode = child_node->xmlChildrenNode;
+                    while (grandChildNode!=NULL) {
+                        if (0 == xmlStrcmp(grandChildNode->name, (const xmlChar*)"x") ) {
+                            m_default_configure.touch_offset[DISPLAYMODE_LANDSCAPE].x = get_content_int(grandChildNode);
+                        } else if (0 == xmlStrcmp(grandChildNode->name, (const xmlChar*)"y") ) {
+                            m_default_configure.touch_offset[DISPLAYMODE_LANDSCAPE].y = get_content_int(grandChildNode);
+                        }
+                        grandChildNode = grandChildNode->next;
+                    }
+                }
 
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-    while (child_node!=NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"r") ) {
-            m_default_configure.dim_color.r = get_content_int(child_node);
-        }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"g") ) {
-            m_default_configure.dim_color.g = get_content_int(child_node);
-        }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"b") ) {
-            m_default_configure.dim_color.b = get_content_int(child_node);
-        }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"a") ) {
-            m_default_configure.dim_color.a = get_content_int(child_node);
-        }
+                child_node = child_node->next;
+            }
 
-        child_node = child_node->next;
-    }
-}
+        }
 
+        void parsing_dim_color(const xmlNodePtr cur_node) {
+            assert(cur_node != NULL);
 
-SCLDisplayMode
-Default_Configure_Parser::get_content_display_mode(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
+            xmlNodePtr child_node = cur_node->xmlChildrenNode;
+            while (child_node!=NULL) {
+                if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"r") ) {
+                    m_default_configure.dim_color.r = get_content_int(child_node);
+                }
+                else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"g") ) {
+                    m_default_configure.dim_color.g = get_content_int(child_node);
+                }
+                else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"b") ) {
+                    m_default_configure.dim_color.b = get_content_int(child_node);
+                }
+                else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"a") ) {
+                    m_default_configure.dim_color.a = get_content_int(child_node);
+                }
 
-    SCLDisplayMode display_mode = DISPLAYMODE_PORTRAIT;
+                child_node = child_node->next;
+            }
 
-    xmlChar* key = xmlNodeGetContent(cur_node);
-    if (key!= NULL) {
-        if (0 == strcmp("landscape", (const char*)key)) {
-            display_mode = DISPLAYMODE_LANDSCAPE;
         }
-        xmlFree(key);
-    }
 
-    return display_mode;
-}
+        SCLDisplayMode get_content_display_mode(const xmlNodePtr cur_node) {
+            assert(cur_node != NULL);
 
-void Default_Configure_Parser::parsing_default_configure() {
-    xmlDocPtr doc;
-    xmlNodePtr cur_node;
+            SCLDisplayMode display_mode = DISPLAYMODE_PORTRAIT;
 
-    char input_file[_POSIX_PATH_MAX] = {0};
-    Main_Entry_Parser::get_file_full_path(input_file, "default_configure");
+            xmlChar* key = xmlNodeGetContent(cur_node);
+            if (key!= NULL) {
+                if (0 == strcmp("landscape", (const char*)key)) {
+                    display_mode = DISPLAYMODE_LANDSCAPE;
+                }
+                xmlFree(key);
+            }
 
-    doc = xmlReadFile(input_file, NULL, 0);
-    if (doc == NULL) {
-        printf("Could not load file.\n");
-        exit(1);
-    }
+            return display_mode;
+        }
+        SclDefaultConfigure m_default_configure;
+};
+
+Default_Configure_Parser* Default_Configure_Parser::m_instance = NULL;
 
-    cur_node = xmlDocGetRootElement(doc);
-    if (cur_node == NULL) {
-        printf("empty document.\n");
-        xmlFreeDoc(doc);
-        exit(1);
+Default_Configure_Parser*
+Default_Configure_Parser::get_instance() {
+    if (m_instance == NULL) {
+        m_instance = new Default_Configure_Parser();
     }
-    if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"default_configure"))
-    {
-        printf("root name %s error!\n", cur_node->name);
-        xmlFreeDoc(doc);
-        exit(1);
+    return m_instance;
+}
+Default_Configure_Parser::Default_Configure_Parser() {
+    m_impl = new DefaultConfigureParserImpl;
+    if (m_impl == NULL) {
+        SCLLOG(SclLog::ERROR, "Create DefaultConfigureParserImpl failed");
     }
+}
 
-    cur_node = cur_node->xmlChildrenNode;
-
-    while (cur_node != NULL) {
-        if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"display")) {
-            m_default_configure.display_mode = get_content_display_mode(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"input_mode")) {
-            xmlChar* temp = xmlNodeGetContent(cur_node);
-            m_default_configure.input_mode = (sclchar *)temp;
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"base_screen_width")) {
-            m_default_configure.target_screen_width = get_content_int(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"base_screen_height")) {
-            m_default_configure.target_screen_height = get_content_int(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"image_file_base_path")) {
-            xmlChar* temp = xmlNodeGetContent(cur_node);
-            m_default_configure.image_file_base_path = (sclchar *)temp;
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"use_magnifier")) {
-            m_default_configure.use_magnifier_window = get_content_bool(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"use_autopopup")) {
-            m_default_configure.use_auto_popup = get_content_bool(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"use_zoomwindow")) {
-            m_default_configure.use_zoom_window = get_content_bool(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"use_error_sound")) {
-            m_default_configure.on_error_noti_send = get_content_bool(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"use_word_deletion")) {
-            m_default_configure.use_word_deletion = get_content_bool(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"touch_offset_level")) {
-            // Let's skip this item since it does not seem to be useful anymore
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"touch_offset")) {
-            // Let's skip this item since it does not seem to be useful anymore
-            parsing_touch_offset(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"default_sub_layout")) {
-            xmlChar* temp = xmlNodeGetContent(cur_node);
-            m_default_configure.default_sub_layout = (sclchar *)temp;
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"dim_use_window_flag")) {
-            m_default_configure.use_actual_dim_window = get_content_bool(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"dim_color")) {
-            parsing_dim_color(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"use_lazy_loading")) {
-            m_default_configure.use_lazy_loading = get_content_bool(cur_node);
-        }
-        cur_node = cur_node->next;
+Default_Configure_Parser::~Default_Configure_Parser() {
+    if (m_impl) {
+        SCLLOG(SclLog::MESSAGE, "~Default_Configure_Parser() has called");
+        delete m_impl;
+        m_impl = NULL;
     }
-    //print_default_configure_table();
-    xmlFreeDoc(doc);
 }
 
-PSclDefaultConfigure Default_Configure_Parser::get_default_configure() {
-    return &m_default_configure;
+int
+Default_Configure_Parser::init(const char* file) {
+        return m_impl->parsing_default_configure(file);
 }
 
-void Default_Configure_Parser::print_default_configure_table() {
-    printf("------------------\n");
-    printf("\tdisplay:\t%d\n", m_default_configure.display_mode);
-    printf("\tinputMode:\t%s\n", m_default_configure.input_mode);
-    printf("\tuse_magnifier:\t%d\n", m_default_configure.use_magnifier_window);
-    printf("\tuse_autopopup:\t%d\n", m_default_configure.use_auto_popup);
-    printf("\tuse_zoomwindow:\t%d\n", m_default_configure.use_zoom_window);
-    printf("\tuse_error_sound:\t%d\n", m_default_configure.use_zoom_window);
-    printf("\tuse_word_deletion:\t%d\n", m_default_configure.use_zoom_window);
-    printf("\ttouch_offset:\n");
-    printf("\\t\t\t%d %d %d %d\n",
-        m_default_configure.touch_offset[0].x, m_default_configure.touch_offset[0].y,
-        m_default_configure.touch_offset[1].x, m_default_configure.touch_offset[1].y);
-    printf("------------------\n");
+PSclDefaultConfigure
+Default_Configure_Parser::get_default_configure() {
+    return &m_impl->m_default_configure;
 }
index 4630a9d..b188d57 100644 (file)
 
 #ifndef __AutoPopup_Configure_Parser__H__
 #define __AutoPopup_Configure_Parser__H__
-#include <libxml/parser.h>
 #include "sclres_type.h"
 
 typedef SclAutoPopupConfigure *PSclAutoPopupConfigure;
 
-class AutoPopup_Configure_Parser {
-public:
-    ~AutoPopup_Configure_Parser();
-    static AutoPopup_Configure_Parser *get_instance();
-    void init();
-
-    PSclAutoPopupConfigure get_autopopup_configure();
-
-    //just for debug
-    void print_default_configure_table();
-
-    //These private methods for parsing
-private:
-    AutoPopup_Configure_Parser();
-    void parsing_autopopup_configure();
-    void parsing_background_color(const xmlNodePtr);
-    void parsing_background_line_color(const xmlNodePtr);
-    void parsing_button_image_path(const xmlNodePtr);
-    void parsing_button_size(const xmlNodePtr);
-    void parsing_window_decorator_iamge_path(const xmlNodePtr);
-    void parsing_grab_area(const xmlNodePtr);
+class AutoPopupConfigureParserImpl;
 
-    int get_button_state_prop(const xmlNodePtr cur_node);
-    SCLDisplayMode get_content_displaymode(const xmlNodePtr cur_node);
-
-private:
-    static AutoPopup_Configure_Parser *m_instance;
-    SclAutoPopupConfigure m_autopopup_configure;
-
-private:
-    class DestructHelper {
+class AutoPopup_Configure_Parser {
+    AutoPopupConfigureParserImpl *m_impl;
+    public:
+        int init(const char* file);
+        PSclAutoPopupConfigure get_autopopup_configure();
     public:
-        ~DestructHelper() {
-            if (AutoPopup_Configure_Parser::m_instance != NULL)
-                delete m_instance;
-        }
-    };
-    static DestructHelper des;
+        ~AutoPopup_Configure_Parser();
+        static AutoPopup_Configure_Parser *get_instance();
+    private:
+        AutoPopup_Configure_Parser();
+        static AutoPopup_Configure_Parser *m_instance;
 };
 
 
index e03789a..1061f2c 100644 (file)
 
 #ifndef __DEFAULT_CONFIGURE_PARSER__H__
 #define __DEFAULT_CONFIGURE_PARSER__H__
-#include <libxml/parser.h>
 #include "sclres_type.h"
 
 typedef SclDefaultConfigure *PSclDefaultConfigure;
 
+class DefaultConfigureParserImpl;
+
 class Default_Configure_Parser {
+    DefaultConfigureParserImpl *m_impl;
+public:
+    int init(const char* file);
+    PSclDefaultConfigure get_default_configure();
 public:
     ~Default_Configure_Parser();
     static Default_Configure_Parser *get_instance();
-    void init();
-
-    PSclDefaultConfigure get_default_configure();
-
-    //just for debug
-    void print_default_configure_table();
-
-    //These private methods for parsing
 private:
     Default_Configure_Parser();
-    void parsing_default_configure();
-    void parsing_touch_offset(const xmlNodePtr);
-    void parsing_dim_color(const xmlNodePtr);
-
-    SCLDisplayMode get_content_display_mode(const xmlNodePtr cur_node);
-
-private:
     static Default_Configure_Parser *m_instance;
-    SclDefaultConfigure m_default_configure;
-
-private:
-    class DestructHelper {
-    public:
-        ~DestructHelper() {
-            if (Default_Configure_Parser::m_instance != NULL)
-                delete m_instance;
-        }
-    };
-    static DestructHelper des;
 };
 
 
index e74e807..4f72df7 100644 (file)
 
 #ifndef __INPUT_MODE_PARSER__H__
 #define __INPUT_MODE_PARSER__H__
-#include <libxml/parser.h>
 #include "sclres_type.h"
 
-/** Example of input mode XML file :
- * <?xml version="1.0"?>
- * <input_mode_table>
- *   <mode name="ENGLISH_QTY">
- *       <keyset>PORTRAIT_QTY_DEFAULT</keyset>
- *       <keyset>LANDSCAPE_QTY_DEFAULT</keyset>
- *   </mode>
- *   <mode name="PUNCTUATION_POPUP" dim_window="true">
- *       <keyset>PORTRAIT_PUNCTUATION_POPUP</keyset>
- *       <keyset>LANDSCAPE_PUNCTUATION_POPUP</keyset>
- *   </mode>
- * </input_mode_table>
- */
-
-#define INPUT_MODE_CONFIGURE_TABLE_TAG "input_mode_table"
-
-#define INPUT_MODE_CONFIGURE_MODE_TAG "mode"
-#define INPUT_MODE_CONFIGURE_MODE_NAME_ATTRIBUTE "name"
-#define INPUT_MODE_CONFIGURE_MODE_DIM_WINDOW_ATTRIBUTE "dim_window"
-#define INPUT_MODE_CONFIGURE_MODE_VIRTUAL_WINDOW_ATTRIBUTE "virtual_window"
-
-#define INPUT_MODE_CONFIGURE_LAYOUT_TAG "layouts"
-#define INPUT_MODE_CONFIGURE_LAYOUT_PORTRAIT_TAG "portrait"
-#define INPUT_MODE_CONFIGURE_LAYOUT_LANDSCAPE_TAG "landscape"
+class InputModeConfigureParserImpl;
 
 class Input_Mode_Configure_Parser {
+    InputModeConfigureParserImpl *m_impl;
     public:
-        ~Input_Mode_Configure_Parser();
-        static Input_Mode_Configure_Parser *get_instance();
-        void init();
+        int init(const char* file);
         PSclInputModeConfigure get_input_mode_configure_table();
         int get_inputmode_id(const char *name);
         const char* get_inputmode_name(int id);
         int get_inputmode_size();
-
+    public:
+        ~Input_Mode_Configure_Parser();
+        static Input_Mode_Configure_Parser *get_instance();
     private:
         Input_Mode_Configure_Parser();
-        void parsing_input_mode_configure_table();
-        void set_input_mode_configure_default_record(const PSclInputModeConfigure);
-        void parsing_mode_node(const xmlNodePtr, const PSclInputModeConfigure);
-        void parsing_layouts(const xmlNodePtr, const PSclInputModeConfigure);
-
-    private:
         static Input_Mode_Configure_Parser *m_instance;
-        int m_inputmode_size;
-        SclInputModeConfigure m_input_mode_configure_table[MAX_SCL_INPUT_MODE];
-
-    private:
-        class DestructHelper {
-            public:
-                ~DestructHelper() {
-                    if (Input_Mode_Configure_Parser::m_instance != NULL)
-                        delete m_instance;
-                }
-        };
-        static DestructHelper des;
 };
 #endif
index 5b4a8de..85c2aa0 100644 (file)
 
 #ifndef __Label_properties_Parser__H__
 #define __Label_properties_Parser__H__
-#include <libxml/parser.h>
 #include "sclres_type.h"
+class LabelPropertiesParserImpl;
 
 class Label_properties_Parser {
+    LabelPropertiesParserImpl *m_impl;
     public:
-        ~Label_properties_Parser();
-        static Label_properties_Parser *get_instance();
-    void init();
+    int init(const char* file);
     PSclLabelPropertiesTable get_label_properties_frame();
-    const int get_size();
-
+    int get_size();
+    public:
+    ~Label_properties_Parser();
+    static Label_properties_Parser *get_instance();
     private:
     Label_properties_Parser();
-    void parsing_label_properties_frame();
-    void parsing_label_properties_table(const xmlNodePtr, const PSclLabelPropertiesTable);
-    void parsing_label_properties_record(const xmlNodePtr, const PSclLabelProperties);
-    void set_label_properties_default_record(const PSclLabelProperties);
-    void parsing_font_color_record(const xmlNodePtr cur_node, const PSclLabelProperties cur_rec);
-    void parsing_shadow_color_record(const xmlNodePtr cur_node, const PSclLabelProperties cur_rec);
-    void parsing_rgb(const xmlNodePtr, SclColor&);
-    int get_shift_state_prop(const xmlNodePtr cur_node);
-    int get_button_state_prop(const xmlNodePtr cur_node);
-
-    private:
-        static Label_properties_Parser *m_instance;
-        SclLabelProperties m_label_properties_frame[MAX_SCL_LABEL_PROPERTIES][MAX_SIZE_OF_LABEL_FOR_ONE];
-        int m_size;
-    private:
-    class DestructHelper {
-        public:
-        ~DestructHelper() {
-            if (Label_properties_Parser::m_instance != NULL)
-                delete m_instance;
-        }
-    };
-    static DestructHelper des;
+    static Label_properties_Parser *m_instance;
 };
 
 
index 854cd89..ea0bf1a 100644 (file)
@@ -137,7 +137,7 @@ class Layout_Parser {
     public:
         ~Layout_Parser();
         static Layout_Parser *get_instance();
-    void init();
+    int init(const char *dir, char **layout_files, int size);
 
     void load(int layout_id);
     void unload();
@@ -177,9 +177,9 @@ class Layout_Parser {
     int get_multitouch_type_prop(const xmlNodePtr cur_node);
     int get_extra_option_prop(const xmlNodePtr cur_node);
 
-    void parsing_layout_table();
+    int parsing_layout_table(const char* dir, char **layout_files, int size);
     void parsing_layout_node(const xmlNodePtr cur_node, const PSclLayout cur_rec_layout, int layout_no);
-    void parsing_layout_node_lazy(const xmlNodePtr cur_node, const PSclLayout cur_rec_layout, int layout_no);
+    void loading_coordinate_resources(const xmlNodePtr cur_node, const PSclLayout cur_rec_layout, int layout_no);
     void parsing_background(const xmlNodePtr cur_node, const PSclLayout);
     void parsing_key_background(const xmlNodePtr cur_node, const PSclLayout);
     void parsing_grab_area(const xmlNodePtr cur_node, const PSclLayout cur_rec_layout);
@@ -213,12 +213,12 @@ class Layout_Parser {
         static Layout_Parser *m_instance;
         int m_layout_size;
         SclLayout m_layout_table[MAX_SCL_LAYOUT];
-        const sclchar *m_layout_files[MAX_SCL_LAYOUT];
+        sclchar *m_layout_files[MAX_SCL_LAYOUT];
         SclLayoutKeyCoordinate* m_key_coordinate_pointer_frame[MAX_SCL_LAYOUT][MAX_KEY];
 
         std::vector<xmlChar*> m_vec_layout_strings;
         std::vector<xmlChar*> m_vec_key_strings;
-
+        std::string m_dir;
     private:
     class DestructHelper {
         public:
index c036627..b40ad83 100644 (file)
 
 #ifndef __Magnifier_Configure_Parser__H__
 #define __Magnifier_Configure_Parser__H__
-#include <libxml/parser.h>
 #include "sclres_type.h"
 
 typedef SclMagnifierWndConfigure *PSclMagnifierWndConfigure;
 
+class MagnifierConfigureParserImpl;
+
 class Magnifier_Configure_Parser {
+    MagnifierConfigureParserImpl *m_impl;
+public:
+    int init(const char* file);
+    PSclMagnifierWndConfigure get_magnifier_configure();
 public:
     ~Magnifier_Configure_Parser();
     static Magnifier_Configure_Parser *get_instance();
-    void init();
-
-    PSclMagnifierWndConfigure get_magnifier_configure();
-
-    //just for debug
-    void print_magnifier_configure_table();
-
-    //These private methods for parsing
 private:
     Magnifier_Configure_Parser();
-    void parsing_magnifier_configure();
-    void parsing_label_area(const xmlNodePtr);
-    void parsing_background_images(const xmlNodePtr);
-    void parsing_padding_values(const xmlNodePtr);
-
-private:
     static Magnifier_Configure_Parser *m_instance;
-    SclMagnifierWndConfigure m_magnifier_configure;
-
-private:
-    class DestructHelper {
-    public:
-        ~DestructHelper() {
-            if (Magnifier_Configure_Parser::m_instance != NULL)
-                delete m_instance;
-        }
-    };
-    static DestructHelper des;
 };
 
 
index 4a4697a..dcf9240 100644 (file)
 
 #ifndef __Main_Entry_Parser__H__
 #define __Main_Entry_Parser__H__
-#include <libxml/parser.h>
-#include <string.h>
-#include <map>
-struct ltstr{
-    bool operator()(const char* st1, const char* st2)const {
-        return strcmp(st1, st2)<0;
-    }
-};
-
-typedef std::map<const char*, char*, ltstr> MapFile;
-typedef MapFile::iterator Iter_data;
-
 class XMLFiles{
     public:
-    char* inputmode_name_list;
-    char* inputmode_popup_name_list;
-    char* layout_name_list;
-    char* keyset_name_list;
     char* input_mode_configure;
-    char* input_mode_popup_configure;
     char* layout;
-    char* layout_keyset;
     char* default_configure;
     char* autopopup_configure;
     char* magnifier_configure;
-    MapFile layout_key_configure;
-    MapFile layout_key_property;
-    MapFile layout_key_coordinate;
     char* key_label_property;
     char* modifier_decoration;
     char* nine_patch_file_list;
 
     public:
     XMLFiles() {
-        inputmode_name_list = NULL;
-        inputmode_popup_name_list = NULL;
-        layout_name_list = NULL;
-        keyset_name_list = NULL;
         input_mode_configure = NULL;
-        input_mode_popup_configure = NULL;
         layout = NULL;
-        layout_keyset = NULL;
         key_label_property = NULL;
         modifier_decoration = NULL;
         default_configure = NULL;
@@ -67,22 +40,10 @@ class XMLFiles{
         nine_patch_file_list = NULL;
     }
     ~XMLFiles() {
-        if (inputmode_name_list)
-            delete inputmode_name_list;
-        if (inputmode_popup_name_list)
-            delete inputmode_popup_name_list;
-        if (layout_name_list)
-            delete layout_name_list;
-        if (keyset_name_list)
-            delete keyset_name_list;
         if (input_mode_configure)
             delete input_mode_configure;
-        if (input_mode_popup_configure)
-            delete input_mode_popup_configure;
         if (layout)
             delete layout;
-        if (layout_keyset)
-            delete layout_keyset;
         if (key_label_property)
             delete key_label_property;
         if (modifier_decoration)
@@ -95,62 +56,23 @@ class XMLFiles{
             delete magnifier_configure;
         if (nine_patch_file_list)
             delete nine_patch_file_list;
-
-        MapFile::iterator it;
-        it = layout_key_configure.begin();
-        for(; it != layout_key_configure.end(); ++it) {
-            if (it->first)
-                delete it->first;
-            if (it->second)
-                delete it->second;
-        }
-        it = layout_key_property.begin();
-        for(; it != layout_key_property.end(); ++it) {
-            if (it->first)
-                delete it->first;
-            if (it->second)
-                delete it->second;
-        }
-        it = layout_key_coordinate.begin();
-        for(; it != layout_key_coordinate.end(); ++it) {
-            if (it->first)
-                delete it->first;
-            if (it->second)
-                delete it->second;
-        }
     }
 };
 
+class MainEntryParserImpl;
 class Main_Entry_Parser {
+    MainEntryParserImpl *m_impl;
     public:
-        ~Main_Entry_Parser();
-        static Main_Entry_Parser *get_instance();
-    void init(const char *entry_filepath);
+    /* parsing xml file, path is assigned */
+    int init(const char* path);
+
     XMLFiles& get_xml_files();
-    static void get_file_full_path(char* full_path, const char* file_type);
+    public:
+    ~Main_Entry_Parser();
+    static Main_Entry_Parser *get_instance();
     private:
     Main_Entry_Parser();
-    void parsing_main_entry(const char *entry_filepath);
-    void make_xml_files(const xmlNodePtr);
-    void parsing_files_node(const xmlNodePtr);
-    void parsing_configure_files(const xmlNodePtr);
-    void parsing_property_files(const xmlNodePtr);
-    void parsing_coordinate_files(const xmlNodePtr);
-    private:
-        static Main_Entry_Parser *m_instance;
-
-        XMLFiles m_xml_files;
-
-    private:
-    class DestructHelper {
-        public:
-        ~DestructHelper() {
-            if (Main_Entry_Parser::m_instance != NULL)
-            delete m_instance;
-        }
-    };
-    static DestructHelper des;
+    static Main_Entry_Parser *m_instance;
 };
 
-
 #endif
index 1925925..b357834 100644 (file)
 
 #ifndef __Modifier_decoration_Parser__H__
 #define __Modifier_decoration_Parser__H__
-#include <libxml/parser.h>
 #include "sclres_type.h"
 
+class ModifierDecorationParserImpl;
+
 class Modifier_decoration_Parser {
+    ModifierDecorationParserImpl *m_impl;
     public:
-        ~Modifier_decoration_Parser();
-        static Modifier_decoration_Parser *get_instance();
-        void init();
+        int init(const char* file);
         PSclModifierDecoration get_modifier_decoration_table();
         int get_modifier_decoration_id(const char *name);
+    public:
+        ~Modifier_decoration_Parser();
+        static Modifier_decoration_Parser *get_instance();
     private:
         Modifier_decoration_Parser();
-        void parsing_modifier_decoration_table();
-        void parsing_modifier_decoration_record(const xmlNodePtr, const PSclModifierDecoration);
-        void set_modifier_decoration_default_record(const PSclModifierDecoration);
-        void parsing_background_image_record_node(const xmlNodePtr cur_node, const PSclModifierDecoration cur_rec);
-
-    private:
         static Modifier_decoration_Parser *m_instance;
-        SclModifierDecoration m_modifier_decoration_table[MAX_SCL_MODIFIER_DECORATION_NUM];
-    private:
-        class DestructHelper {
-            public:
-                ~DestructHelper() {
-                    if (Modifier_decoration_Parser::m_instance != NULL)
-                        delete m_instance;
-                }
-        };
-        static DestructHelper des;
 };
 
 
index 398ba43..eec02bc 100644 (file)
 
 #ifndef __Nine_patch_file_list_Parser__H__
 #define __Nine_patch_file_list_Parser__H__
-#include <libxml/parser.h>
 #include "sclres_type.h"
 
 const int MAX_NINE_PATCH_FILE_LIST = 128;
+class NinePatchFileListParserImpl;
 
 class Nine_patch_file_list_Parser {
+    NinePatchFileListParserImpl *m_impl;
     public:
-        ~Nine_patch_file_list_Parser();
-        static Nine_patch_file_list_Parser *get_instance();
-    void init();
+    int init(const char* file);
     SclNinePatchInfo* get_nine_patch_list();
     bool get_nine_patch_info(const char *filename, SclNinePatchInfo *info);
+    public:
+    ~Nine_patch_file_list_Parser();
+    static Nine_patch_file_list_Parser *get_instance();
     private:
     Nine_patch_file_list_Parser();
-    void parsing_nine_patch_file_list();
-    private:
-        static Nine_patch_file_list_Parser *m_instance;
-        SclNinePatchInfo m_nine_patch_file_list[MAX_NINE_PATCH_FILE_LIST];
-        int m_size;
-    private:
-    class DestructHelper {
-        public:
-        ~DestructHelper() {
-            if (Nine_patch_file_list_Parser::m_instance != NULL)
-                delete m_instance;
-        }
-    };
-    static DestructHelper des;
+    static Nine_patch_file_list_Parser *m_instance;
 };
 
 
index 27846e2..f761465 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef __XMLRESOURCE__
 #define __XMLRESOURCE__
 
-#include <libxml/parser.h>
 #include "main_entry_parser.h"
 #include "input_mode_configure_parser.h"
 #include "layout_parser.h"
index 3b3cf47..d609ac4 100644 (file)
  *
  */
 
+#include <string.h>
+#include <libxml/parser.h>
+
 #include "input_mode_configure_parser.h"
-#include "main_entry_parser.h"
 #include "xml_parser_utils.h"
 #include "simple_debug.h"
 
+/** Example of input mode XML file :
+ * <?xml version="1.0"?>
+ * <input_mode_table>
+ *   <mode name="ENGLISH_QTY">
+ *       <keyset>PORTRAIT_QTY_DEFAULT</keyset>
+ *       <keyset>LANDSCAPE_QTY_DEFAULT</keyset>
+ *   </mode>
+ *   <mode name="PUNCTUATION_POPUP" dim_window="true">
+ *       <keyset>PORTRAIT_PUNCTUATION_POPUP</keyset>
+ *       <keyset>LANDSCAPE_PUNCTUATION_POPUP</keyset>
+ *   </mode>
+ * </input_mode_table>
+ */
+
+#define INPUT_MODE_CONFIGURE_TABLE_TAG "input_mode_table"
+
+#define INPUT_MODE_CONFIGURE_MODE_TAG "mode"
+#define INPUT_MODE_CONFIGURE_MODE_NAME_ATTRIBUTE "name"
+#define INPUT_MODE_CONFIGURE_MODE_DIM_WINDOW_ATTRIBUTE "dim_window"
+#define INPUT_MODE_CONFIGURE_MODE_VIRTUAL_WINDOW_ATTRIBUTE "virtual_window"
+
+#define INPUT_MODE_CONFIGURE_LAYOUT_TAG "layouts"
+#define INPUT_MODE_CONFIGURE_LAYOUT_PORTRAIT_TAG "portrait"
+#define INPUT_MODE_CONFIGURE_LAYOUT_LANDSCAPE_TAG "landscape"
+
+class InputModeConfigureParserImpl {
+    public:
+        InputModeConfigureParserImpl() {
+            m_inputmode_size = 0;
+            memset(m_input_mode_configure_table, 0x00, sizeof(SclInputModeConfigure) * MAX_SCL_INPUT_MODE);
+        }
+
+        ~InputModeConfigureParserImpl() {
+            for(int input_mode = 0; input_mode < MAX_SCL_INPUT_MODE; ++input_mode) {
+                SclInputModeConfigure& cur_rec = m_input_mode_configure_table[input_mode];
+                if (cur_rec.name) {
+                    xmlFree(cur_rec.name);
+                    cur_rec.name = NULL;
+                }
+                if (cur_rec.layouts[DISPLAYMODE_PORTRAIT]) {
+                    xmlFree(cur_rec.layouts[DISPLAYMODE_PORTRAIT]);
+                    cur_rec.layouts[DISPLAYMODE_PORTRAIT] = NULL;
+                }
+                if (cur_rec.layouts[DISPLAYMODE_LANDSCAPE]) {
+                    xmlFree(cur_rec.layouts[DISPLAYMODE_LANDSCAPE]);
+                    cur_rec.layouts[DISPLAYMODE_LANDSCAPE] = NULL;
+                }
+            }
+        }
+
+        int parsing_input_mode_configure_table(const char* input_file) {
+            xmlDocPtr doc;
+            xmlNodePtr cur_node;
+
+            xmlChar* key;
+
+            doc = xmlReadFile(input_file, NULL, 0);
+            if (doc == NULL) {
+                SCLLOG(SclLog::DEBUG, "Could not load file: %s.", input_file);
+                return -1;
+            }
+
+            cur_node = xmlDocGetRootElement(doc);
+            if (cur_node == NULL) {
+                SCLLOG(SclLog::DEBUG, "Input_Mode_Configure_Parser: empty document.\n");
+                xmlFreeDoc(doc);
+                return -1;
+            }
+            if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)INPUT_MODE_CONFIGURE_TABLE_TAG))
+            {
+                SCLLOG(SclLog::DEBUG, "Input_Mode_Configure_Parser: root name error: %s\n!", (char *)cur_node->name);
+                xmlFreeDoc(doc);
+                return -1;
+            }
+
+            m_inputmode_size = 0;
+            cur_node = cur_node->xmlChildrenNode;
+
+            SclInputModeConfigure* cur_rec = m_input_mode_configure_table;
+            while (cur_node != NULL) {
+                if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)INPUT_MODE_CONFIGURE_MODE_TAG)) {
+                    set_input_mode_configure_default_record(cur_rec);
+
+                    key = xmlGetProp(cur_node, (const xmlChar*)INPUT_MODE_CONFIGURE_MODE_NAME_ATTRIBUTE);
+                    if (key) {
+                        cur_rec->name = (sclchar*)key;
+                    }
+
+                    get_prop_bool(cur_node, INPUT_MODE_CONFIGURE_MODE_DIM_WINDOW_ATTRIBUTE, &(cur_rec->use_dim_window));
+                    get_prop_bool(cur_node, INPUT_MODE_CONFIGURE_MODE_VIRTUAL_WINDOW_ATTRIBUTE, &(cur_rec->use_virtual_window));
+
+                    parsing_mode_node(cur_node, cur_rec);
+                    m_inputmode_size++;
+                    cur_rec++;
+                    if (m_inputmode_size >= MAX_SCL_INPUT_MODE) {
+                        SCLLOG(SclLog::ERROR, "No Space for input mode record.");
+                        break;
+                    }
+                }
+                cur_node = cur_node->next;
+            }
+            xmlFreeDoc(doc);
+
+            return 0;
+
+        }
+
+        void set_input_mode_configure_default_record(const PSclInputModeConfigure cur_rec) {
+            cur_rec->name=NULL;
+            cur_rec->layouts[DISPLAYMODE_PORTRAIT] = NULL;
+            cur_rec->layouts[DISPLAYMODE_LANDSCAPE] = NULL;
+            cur_rec->use_virtual_window = FALSE;
+            cur_rec->use_dim_window = FALSE;
+        }
+
+        void parsing_mode_node(const xmlNodePtr cur_node, const PSclInputModeConfigure cur_rec) {
+            assert(cur_node != NULL);
+            assert(cur_rec != NULL);
+
+            sclboolean val;
+            get_prop_bool(cur_node, INPUT_MODE_CONFIGURE_MODE_VIRTUAL_WINDOW_ATTRIBUTE, &val);
+            get_prop_bool(cur_node, INPUT_MODE_CONFIGURE_MODE_DIM_WINDOW_ATTRIBUTE, &(cur_rec->use_dim_window));
+
+            xmlChar* temp = xmlGetProp(cur_node, (const xmlChar*)INPUT_MODE_CONFIGURE_MODE_NAME_ATTRIBUTE);
+            cur_rec->name = (sclchar *)temp;
+
+            xmlNodePtr child_node = cur_node->xmlChildrenNode;
+            while (child_node!=NULL) {
+                if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"text") ) {
+                    child_node = child_node->next;
+                    continue;
+                }
+                if (0 == xmlStrcmp(child_node->name, (const xmlChar *)INPUT_MODE_CONFIGURE_LAYOUT_TAG) ) {
+                    parsing_layouts(child_node, cur_rec);
+                } else {
+                    SCLLOG(SclLog::WARNING, "input_mode_configure has no such node name: %s\n", (char *)child_node->name);
+                }
+
+                child_node = child_node->next;
+            }
+        }
+
+        void parsing_layouts(const xmlNodePtr cur_node, const PSclInputModeConfigure cur_rec) {
+            assert(cur_node != NULL);
+            assert(cur_rec != NULL);
+            assert(0 == xmlStrcmp(cur_node->name, (const xmlChar*)INPUT_MODE_CONFIGURE_LAYOUT_TAG) );
+
+            xmlNodePtr child_node = cur_node->xmlChildrenNode;
+            while (child_node != NULL) {
+                if ( 0 == xmlStrcmp(child_node->name, (const xmlChar *)INPUT_MODE_CONFIGURE_LAYOUT_PORTRAIT_TAG) ) {
+                    xmlChar* temp = xmlNodeGetContent(child_node);
+                    cur_rec->layouts[DISPLAYMODE_PORTRAIT] = (sclchar*)temp;
+                }
+                else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar *)INPUT_MODE_CONFIGURE_LAYOUT_LANDSCAPE_TAG) ) {
+                    xmlChar* temp = xmlNodeGetContent(child_node);
+                    cur_rec->layouts[DISPLAYMODE_LANDSCAPE] = (sclchar*)temp;
+                }
+                child_node = child_node->next;
+            }
+        }
+
+        int m_inputmode_size;
+        SclInputModeConfigure m_input_mode_configure_table[MAX_SCL_INPUT_MODE];
+};
+
 Input_Mode_Configure_Parser* Input_Mode_Configure_Parser::m_instance = NULL;
 
 Input_Mode_Configure_Parser::Input_Mode_Configure_Parser() {
-    m_inputmode_size = 0;
-    memset(m_input_mode_configure_table, 0x00, sizeof(SclInputModeConfigure) * MAX_SCL_INPUT_MODE);
+    m_impl = new InputModeConfigureParserImpl;
+    if (m_impl == NULL) {
+        SCLLOG(SclLog::ERROR, "Create Input_Mode_Configure_Parser failed");
+    }
 }
 
 Input_Mode_Configure_Parser::~Input_Mode_Configure_Parser() {
-    for(int input_mode = 0; input_mode < MAX_SCL_INPUT_MODE; ++input_mode) {
-        SclInputModeConfigure& cur_rec = m_input_mode_configure_table[input_mode];
-        if (cur_rec.name) {
-            xmlFree(cur_rec.name);
-            cur_rec.name = NULL;
-        }
-        if (cur_rec.layouts[DISPLAYMODE_PORTRAIT]) {
-            xmlFree(cur_rec.layouts[DISPLAYMODE_PORTRAIT]);
-            cur_rec.layouts[DISPLAYMODE_PORTRAIT] = NULL;
-        }
-        if (cur_rec.layouts[DISPLAYMODE_LANDSCAPE]) {
-            xmlFree(cur_rec.layouts[DISPLAYMODE_LANDSCAPE]);
-            cur_rec.layouts[DISPLAYMODE_LANDSCAPE] = NULL;
-        }
+    if (m_impl) {
+        SCLLOG(SclLog::MESSAGE, "~Input_Mode_Configure_Parser() has called");
+        delete m_impl;
+        m_impl = NULL;
     }
 }
 
@@ -53,51 +212,44 @@ Input_Mode_Configure_Parser::get_instance() {
     return m_instance;
 }
 
-void
-Input_Mode_Configure_Parser::init() {
-    parsing_input_mode_configure_table();
+int
+Input_Mode_Configure_Parser::init(const char* file) {
+    return m_impl->parsing_input_mode_configure_table(file);
 }
 
+int
+Input_Mode_Configure_Parser::get_inputmode_id(const char *name) {
+    if (name == NULL) {
+        SCLLOG(SclLog::DEBUG, "get_inputmode_id failed");
+        return -1;
+    }
 
-void
-Input_Mode_Configure_Parser::parsing_layouts( const xmlNodePtr cur_node, const PSclInputModeConfigure cur_rec) {
-    assert(cur_node != NULL);
-    assert(cur_rec != NULL);
-    assert(0 == xmlStrcmp(cur_node->name, (const xmlChar*)INPUT_MODE_CONFIGURE_LAYOUT_TAG) );
+    PSclInputModeConfigure config_table = get_input_mode_configure_table();
 
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-    while (child_node != NULL) {
-        if ( 0 == xmlStrcmp(child_node->name, (const xmlChar *)INPUT_MODE_CONFIGURE_LAYOUT_PORTRAIT_TAG) ) {
-            xmlChar* temp = xmlNodeGetContent(child_node);
-            cur_rec->layouts[DISPLAYMODE_PORTRAIT] = (sclchar*)temp;
-        }
-        else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar *)INPUT_MODE_CONFIGURE_LAYOUT_LANDSCAPE_TAG) ) {
-            xmlChar* temp = xmlNodeGetContent(child_node);
-            cur_rec->layouts[DISPLAYMODE_LANDSCAPE] = (sclchar*)temp;
-        }
-        child_node = child_node->next;
+    if (config_table == NULL) {
+        SCLLOG(SclLog::DEBUG, "get_inputmode_id failed");
+        return -1;
     }
-}
 
-int
-Input_Mode_Configure_Parser::get_inputmode_id(const char *name) {
-    if (name == NULL) return -1;
-
-    for(int i = 0; i < MAX_SCL_INPUT_MODE; ++i) {
-        if ( m_input_mode_configure_table[i].name) {
-            if ( 0 == strcmp(m_input_mode_configure_table[i].name, name) ) {
+    for(int i = 0; i < get_inputmode_size(); ++i) {
+        if ( config_table[i].name) {
+            if ( 0 == strcmp(config_table[i].name, name) ) {
                 return i;
             }
         }
     }
 
+    SCLLOG(SclLog::DEBUG, "get_inputmode_id failed");
     return -1;
 }
 
 const char*
 Input_Mode_Configure_Parser::get_inputmode_name(int id) {
     if (id >= 0 && id < MAX_SCL_INPUT_MODE) {
-        return m_input_mode_configure_table[id].name;
+        PSclInputModeConfigure config_table = get_input_mode_configure_table();
+        if (config_table) {
+            return config_table[id].name;
+        }
     }
 
     return NULL;
@@ -105,101 +257,11 @@ Input_Mode_Configure_Parser::get_inputmode_name(int id) {
 
 int
 Input_Mode_Configure_Parser::get_inputmode_size() {
-    return m_inputmode_size;
-}
-
-void
-Input_Mode_Configure_Parser::set_input_mode_configure_default_record(const PSclInputModeConfigure cur_rec) {
-    cur_rec->name=NULL;
-    cur_rec->layouts[DISPLAYMODE_PORTRAIT] = NULL;
-    cur_rec->layouts[DISPLAYMODE_LANDSCAPE] = NULL;
-    cur_rec->use_virtual_window = FALSE;
-    cur_rec->use_dim_window = FALSE;
-}
-
-void
-Input_Mode_Configure_Parser::parsing_mode_node(const xmlNodePtr cur_node, const PSclInputModeConfigure cur_rec) {
-    assert(cur_node != NULL);
-    assert(cur_rec != NULL);
-
-    sclboolean val;
-    get_prop_bool(cur_node, INPUT_MODE_CONFIGURE_MODE_VIRTUAL_WINDOW_ATTRIBUTE, &val);
-    get_prop_bool(cur_node, INPUT_MODE_CONFIGURE_MODE_DIM_WINDOW_ATTRIBUTE, &(cur_rec->use_dim_window));
-
-    xmlChar* temp = xmlGetProp(cur_node, (const xmlChar*)INPUT_MODE_CONFIGURE_MODE_NAME_ATTRIBUTE);
-    cur_rec->name = (sclchar *)temp;
-
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-    while (child_node!=NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"text") ) {
-            child_node = child_node->next;
-            continue;
-        }
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar *)INPUT_MODE_CONFIGURE_LAYOUT_TAG) ) {
-            parsing_layouts(child_node, cur_rec);
-        } else {
-            LOG("Warning: input_mode_configure.xml has no such attribute.\n");
-        }
-
-        child_node = child_node->next;
-    }
-}
-
-void
-Input_Mode_Configure_Parser::parsing_input_mode_configure_table() {
-    xmlDocPtr doc;
-    xmlNodePtr cur_node;
-
-    xmlChar* key;
-
-    char input_file[_POSIX_PATH_MAX] = {0};
-    Main_Entry_Parser::get_file_full_path(input_file, "input_mode_configure");
-
-    doc = xmlReadFile(input_file, NULL, 0);
-    if (doc == NULL) {
-        printf("Could not load file.\n");
-        exit(1);
-    }
-
-    cur_node = xmlDocGetRootElement(doc);
-    if (cur_node == NULL) {
-        printf("empty document.\n");
-        xmlFreeDoc(doc);
-        exit(1);
-    }
-    if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)INPUT_MODE_CONFIGURE_TABLE_TAG))
-    {
-       printf("root name %s error!\n", cur_node->name);
-       xmlFreeDoc(doc);
-       exit(1);
-    }
-
-    m_inputmode_size = 0;
-    cur_node = cur_node->xmlChildrenNode;
-
-    SclInputModeConfigure* cur_rec = m_input_mode_configure_table;
-    while (cur_node != NULL) {
-        if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)INPUT_MODE_CONFIGURE_MODE_TAG)) {
-            set_input_mode_configure_default_record(cur_rec);
-
-            key = xmlGetProp(cur_node, (const xmlChar*)INPUT_MODE_CONFIGURE_MODE_NAME_ATTRIBUTE);
-            if (key) {
-                cur_rec->name = (sclchar*)key;
-            }
-
-            get_prop_bool(cur_node, INPUT_MODE_CONFIGURE_MODE_DIM_WINDOW_ATTRIBUTE, &(cur_rec->use_dim_window));
-            get_prop_bool(cur_node, INPUT_MODE_CONFIGURE_MODE_VIRTUAL_WINDOW_ATTRIBUTE, &(cur_rec->use_virtual_window));
-
-            parsing_mode_node(cur_node, cur_rec);
-            m_inputmode_size++;
-            cur_rec++;
-        }
-        cur_node = cur_node->next;
-    }
-    xmlFreeDoc(doc);
+    return m_impl->m_inputmode_size;
 }
 
-PSclInputModeConfigure Input_Mode_Configure_Parser::get_input_mode_configure_table() {
-    return m_input_mode_configure_table;
+PSclInputModeConfigure
+Input_Mode_Configure_Parser::get_input_mode_configure_table() {
+    return m_impl->m_input_mode_configure_table;
 }
 
index fd40e4a..d5bd308 100644 (file)
  *
  */
 
-#include "label_properties_parser.h"
-#include "main_entry_parser.h"
 #include <memory.h>
+#include <libxml/parser.h>
+#include "label_properties_parser.h"
 #include "xml_parser_utils.h"
-
-Label_properties_Parser* Label_properties_Parser::m_instance = NULL;
-
-Label_properties_Parser::Label_properties_Parser() {
-    m_size = 0;
-    memset(m_label_properties_frame, 0, sizeof(SclLabelProperties) * MAX_SCL_LABEL_PROPERTIES * MAX_SIZE_OF_LABEL_FOR_ONE);
-}
-
-Label_properties_Parser::~Label_properties_Parser() {
-    for(int i = 0; i < MAX_SCL_LABEL_PROPERTIES && i < m_size; ++i) {
-        for(int j = 0; j < MAX_SIZE_OF_LABEL_FOR_ONE; ++j) {
-            if (m_label_properties_frame[i][j].font_name)
-                delete m_label_properties_frame[i][j].font_name;
-            m_label_properties_frame[i][j].font_name = NULL;
-            if (m_label_properties_frame[i][j].label_type)
-                delete m_label_properties_frame[i][j].label_type;
-            m_label_properties_frame[i][j].label_type = NULL;
-        }
-    }
-    m_size = 0;
-}
-
-Label_properties_Parser* Label_properties_Parser::get_instance() {
-    if (m_instance == NULL) {
-        m_instance = new Label_properties_Parser();
-    }
-    return m_instance;
-}
-void Label_properties_Parser::init() {
-    parsing_label_properties_frame();
-}
-const int
-Label_properties_Parser::get_size() {
-    return m_size;
-}
-
-//recompute_layout will change the table
-PSclLabelPropertiesTable Label_properties_Parser::get_label_properties_frame() {
-    return m_label_properties_frame;
-}
-
-void Label_properties_Parser::parsing_label_properties_frame() {
-    xmlDocPtr doc;
-    xmlNodePtr cur_node;
-
-    char input_file[_POSIX_PATH_MAX] = {0};
-    Main_Entry_Parser::get_file_full_path(input_file, "label_property");
-
-    doc = xmlReadFile(input_file, NULL, 0);
-    if (doc == NULL) {
-        printf("Could not load file.");
-        exit(1);
-    }
-
-    cur_node = xmlDocGetRootElement(doc);
-    if (cur_node == NULL) {
-        printf("empty document.\n");
-        xmlFreeDoc(doc);
-        exit(1);
-    }
-    if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"label_properties_frame"))
-    {
-       printf("root name error!");
-       xmlFreeDoc(doc);
-       exit(1);
-    }
-
-    cur_node = cur_node->xmlChildrenNode;
-
-    assert(m_size == 0);
-    PSclLabelPropertiesTable curTable = m_label_properties_frame;
-    while (cur_node != NULL && m_size < MAX_SCL_LABEL_PROPERTIES) {
-        if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"label_properties_table")) {
-            parsing_label_properties_table( cur_node, curTable);
-            xmlChar* key = xmlGetProp(cur_node, (const xmlChar*)"label_type");
-            PSclLabelProperties cur_rec = (PSclLabelProperties)curTable;
-            cur_rec->label_type = (sclchar *)key;
-            curTable++;
-            m_size++;
-        }
-
-        cur_node = cur_node->next;
-    }
-    xmlFreeDoc(doc);
-}
-
-void
-Label_properties_Parser::parsing_label_properties_table(const xmlNodePtr cur_node, const PSclLabelPropertiesTable curTable) {
-    assert(cur_node != NULL);
-    assert(curTable != NULL);
-
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-
-    PSclLabelProperties cur_rec = (PSclLabelProperties)curTable;
-    while (NULL != child_node) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"label_properties")) {
-            parsing_label_properties_record(child_node, cur_rec);
-            cur_rec++;
-        }
-
-        child_node = child_node->next;
-    }
-}
-
-void
-Label_properties_Parser::set_label_properties_default_record(const PSclLabelProperties cur_rec) {
-    cur_rec->valid = true;
-    cur_rec->font_name = NULL;
-    cur_rec->font_size = 0;
-    for(int shift_state = 0; shift_state < SCL_SHIFT_STATE_MAX; ++shift_state) {
-        for(int button_state = 0; button_state < SCL_BUTTON_STATE_MAX; ++button_state) {
-            cur_rec->font_color[shift_state][button_state].r = 0;
-            cur_rec->font_color[shift_state][button_state].g = 0;
-            cur_rec->font_color[shift_state][button_state].b = 0;
-        }
-    }
-
-    cur_rec->alignment = LABEL_ALIGN_LEFT_TOP;
-    cur_rec->padding_x = 0;
-    cur_rec->padding_y = 0;
-    cur_rec->inner_width = 0;
-    cur_rec->inner_height = 0;
-    cur_rec->shadow_distance = 0;
-
-    cur_rec->shadow_direction = SHADOW_DIRECTION_NONE;
-
-    for(int shift_state = 0; shift_state < SCL_SHIFT_STATE_MAX; ++shift_state) {
-        for(int button_state = 0; button_state < SCL_BUTTON_STATE_MAX; ++button_state) {
-            cur_rec->shadow_color[shift_state][button_state].r = 0;
-            cur_rec->shadow_color[shift_state][button_state].g = 0;
-            cur_rec->shadow_color[shift_state][button_state].b = 0;
-        }
-    }
-}
-
-static int match_alignment(const char* key) {
+#include "simple_debug.h"
+#include "put_record.h"
+static int
+match_alignment(const char* key) {
   assert(key != NULL);
 
     typedef struct _match_table_t{
@@ -186,7 +54,8 @@ static int match_alignment(const char* key) {
     }
     return value;
 }
-static int match_shadow_direction(const char* key) {
+static int
+match_shadow_direction(const char* key) {
   assert(key != NULL);
 
     typedef struct _match_table_t{
@@ -220,160 +89,334 @@ static int match_shadow_direction(const char* key) {
     }
     return value;
 }
+class LabelPropertiesParserImpl {
+    public:
+        LabelPropertiesParserImpl() {
+            m_size = 0;
+            memset(m_label_properties_frame, 0, sizeof(SclLabelProperties) * MAX_SCL_LABEL_PROPERTIES * MAX_SIZE_OF_LABEL_FOR_ONE);
+        }
 
-void
-Label_properties_Parser::parsing_label_properties_record(const xmlNodePtr cur_node, const PSclLabelProperties cur_rec) {
-    assert(cur_node != NULL);
-    assert(cur_rec != NULL);
+        ~LabelPropertiesParserImpl() {
+            for(int i = 0; i < MAX_SCL_LABEL_PROPERTIES && i < m_size; ++i) {
+                for(int j = 0; j < MAX_SIZE_OF_LABEL_FOR_ONE; ++j) {
+                    if (m_label_properties_frame[i][j].font_name)
+                        delete m_label_properties_frame[i][j].font_name;
+                    m_label_properties_frame[i][j].font_name = NULL;
+                    if (m_label_properties_frame[i][j].label_type)
+                        delete m_label_properties_frame[i][j].label_type;
+                    m_label_properties_frame[i][j].label_type = NULL;
+                }
+            }
+            m_size = 0;
 
-   set_label_properties_default_record(cur_rec);
+        }
 
-    xmlChar* key = xmlGetProp(cur_node, (const xmlChar*)"font_name");
-    if (NULL != key) {
-        cur_rec->font_name = (sclchar*)key;
-    }
+        int parsing_label_properties_frame(const char* input_file) {
+            xmlDocPtr doc;
+            xmlNodePtr cur_node;
 
-    get_prop_number(cur_node, "font_size", &(cur_rec->font_size));
+            doc = xmlReadFile(input_file, NULL, 0);
+            if (doc == NULL) {
+                SCLLOG(SclLog::DEBUG, "Could not load file: %s.", input_file);
+                return -1;
+            }
 
-    key = xmlGetProp(cur_node, (const xmlChar*)"label_alignment");
-    if (NULL != key) {
-        cur_rec->alignment = (SCLLabelAlignment)match_alignment((const char*)key);
-        xmlFree(key);
-    }
+            cur_node = xmlDocGetRootElement(doc);
+            if (cur_node == NULL) {
+                SCLLOG(SclLog::DEBUG, "Label_Properties_Parser: empty document.\n");
+                xmlFreeDoc(doc);
+                return -1;
+            }
+            if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"label_properties_frame"))
+            {
+                SCLLOG(SclLog::DEBUG, "Label_Properties_Parser: root name error: %s\n!", (char *)cur_node->name);
+                xmlFreeDoc(doc);
+                return -1;
+            }
+
+            cur_node = cur_node->xmlChildrenNode;
+
+            assert(m_size == 0);
+            PSclLabelPropertiesTable curTable = m_label_properties_frame;
+            while (cur_node != NULL) {
+                if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"label_properties_table")) {
+                    parsing_label_properties_table( cur_node, curTable);
+                    xmlChar* key = xmlGetProp(cur_node, (const xmlChar*)"label_type");
+                    PSclLabelProperties cur_rec = (PSclLabelProperties)curTable;
+                    cur_rec->label_type = (sclchar *)key;
+                    m_size++;
+                    curTable++;
+                    if (m_size >= MAX_SCL_LABEL_PROPERTIES) {
+                        SCLLOG(SclLog::ERROR, "No Space for label properties record.");
+                        break;
+                    }
+                }
 
-    get_prop_number(cur_node, "padding_X", &(cur_rec->padding_x));
-    get_prop_number(cur_node, "padding_Y", &(cur_rec->padding_y));
-    get_prop_number(cur_node, "inner_width", &(cur_rec->inner_width));
-    get_prop_number(cur_node, "inner_height", &(cur_rec->inner_height));
+                cur_node = cur_node->next;
+            }
+            xmlFreeDoc(doc);
 
-    get_prop_number(cur_node, "shadow_distance", &(cur_rec->shadow_distance));
-    key = xmlGetProp(cur_node, (const xmlChar*)"shadow_direction");
-    if (NULL != key) {
-        cur_rec->shadow_direction = (SCLShadowDirection)match_shadow_direction((const char*)key);
-        xmlFree(key);
-    }
+            return 0;
+
+        }
+        void parsing_label_properties_table(const xmlNodePtr cur_node, const PSclLabelPropertiesTable curTable) {
+            assert(cur_node != NULL);
+            assert(curTable != NULL);
+
+            xmlNodePtr child_node = cur_node->xmlChildrenNode;
+
+            PSclLabelProperties cur_rec = (PSclLabelProperties)curTable;
+            while (NULL != child_node) {
+                if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"label_properties")) {
+                    parsing_label_properties_record(child_node, cur_rec);
+                    cur_rec++;
+                }
 
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
+                child_node = child_node->next;
+            }
 
-    while (child_node != NULL) {
-        if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)"font_color_record")) {
-            parsing_font_color_record(child_node, cur_rec);
-        } else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)"shadow_color_record")) {
-            parsing_shadow_color_record(child_node, cur_rec);
+        }
+        void parsing_label_properties_record(const xmlNodePtr cur_node, const PSclLabelProperties cur_rec) {
+            assert(cur_node != NULL);
+            assert(cur_rec != NULL);
+
+            set_label_properties_default_record(cur_rec);
+
+            xmlChar* key = xmlGetProp(cur_node, (const xmlChar*)"font_name");
+            if (NULL != key) {
+                cur_rec->font_name = (sclchar*)key;
+            }
+
+            get_prop_number(cur_node, "font_size", &(cur_rec->font_size));
+
+            key = xmlGetProp(cur_node, (const xmlChar*)"label_alignment");
+            if (NULL != key) {
+                cur_rec->alignment = (SCLLabelAlignment)match_alignment((const char*)key);
+                xmlFree(key);
+            }
+
+            get_prop_number(cur_node, "padding_X", &(cur_rec->padding_x));
+            get_prop_number(cur_node, "padding_Y", &(cur_rec->padding_y));
+            get_prop_number(cur_node, "inner_width", &(cur_rec->inner_width));
+            get_prop_number(cur_node, "inner_height", &(cur_rec->inner_height));
+
+            get_prop_number(cur_node, "shadow_distance", &(cur_rec->shadow_distance));
+            key = xmlGetProp(cur_node, (const xmlChar*)"shadow_direction");
+            if (NULL != key) {
+                cur_rec->shadow_direction = (SCLShadowDirection)match_shadow_direction((const char*)key);
+                xmlFree(key);
+            }
+
+            xmlNodePtr child_node = cur_node->xmlChildrenNode;
+
+            while (child_node != NULL) {
+                if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)"font_color_record")) {
+                    parsing_font_color_record(child_node, cur_rec);
+                } else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)"shadow_color_record")) {
+                    parsing_shadow_color_record(child_node, cur_rec);
+                }
+
+                child_node = child_node->next;
+            }
+        }
+
+        void set_label_properties_default_record(const PSclLabelProperties cur_rec) {
+        cur_rec->valid = true;
+        cur_rec->font_name = NULL;
+        cur_rec->font_size = 0;
+        for(int shift_state = 0; shift_state < SCL_SHIFT_STATE_MAX; ++shift_state) {
+            for(int button_state = 0; button_state < SCL_BUTTON_STATE_MAX; ++button_state) {
+                cur_rec->font_color[shift_state][button_state].r = 0;
+                cur_rec->font_color[shift_state][button_state].g = 0;
+                cur_rec->font_color[shift_state][button_state].b = 0;
+            }
+        }
+
+        cur_rec->alignment = LABEL_ALIGN_LEFT_TOP;
+        cur_rec->padding_x = 0;
+        cur_rec->padding_y = 0;
+        cur_rec->inner_width = 0;
+        cur_rec->inner_height = 0;
+        cur_rec->shadow_distance = 0;
+
+        cur_rec->shadow_direction = SHADOW_DIRECTION_NONE;
+
+        for(int shift_state = 0; shift_state < SCL_SHIFT_STATE_MAX; ++shift_state) {
+            for(int button_state = 0; button_state < SCL_BUTTON_STATE_MAX; ++button_state) {
+                cur_rec->shadow_color[shift_state][button_state].r = 0;
+                cur_rec->shadow_color[shift_state][button_state].g = 0;
+                cur_rec->shadow_color[shift_state][button_state].b = 0;
+            }
         }
 
-        child_node = child_node->next;
     }
-}
 
-void
-Label_properties_Parser::parsing_font_color_record(const xmlNodePtr cur_node, const PSclLabelProperties cur_rec) {
-    assert(cur_node != NULL);
-    assert(cur_rec != NULL);
-    assert(0 == xmlStrcmp(cur_node->name, (const xmlChar*)"font_color_record"));
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-
-    while (child_node != NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"color") ) {
-            SclColor font_color = {0x00, 0x00, 0x00, 0xFF};
-            parsing_rgb(child_node, font_color);
-
-            int shift_state = get_shift_state_prop(child_node);
-            int button_state = get_button_state_prop(child_node);
-
-            for(int shift_loop = 0;shift_loop < SCL_SHIFT_STATE_MAX;shift_loop++) {
-                for(int button_loop = 0;button_loop < SCL_BUTTON_STATE_MAX;button_loop++) {
-                    if ((shift_state == shift_loop || shift_state == -1) &&
-                        (button_state == button_loop || button_state == -1)) {
+    void parsing_font_color_record(const xmlNodePtr cur_node, const PSclLabelProperties cur_rec) {
+        assert(cur_node != NULL);
+        assert(cur_rec != NULL);
+        assert(0 == xmlStrcmp(cur_node->name, (const xmlChar*)"font_color_record"));
+        xmlNodePtr child_node = cur_node->xmlChildrenNode;
+
+        while (child_node != NULL) {
+            if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"color") ) {
+                SclColor font_color = {0x00, 0x00, 0x00, 0xFF};
+                parsing_rgb(child_node, font_color);
+
+                int shift_state = get_shift_state_prop(child_node);
+                int button_state = get_button_state_prop(child_node);
+
+                for(int shift_loop = 0;shift_loop < SCL_SHIFT_STATE_MAX;shift_loop++) {
+                    for(int button_loop = 0;button_loop < SCL_BUTTON_STATE_MAX;button_loop++) {
+                        if ((shift_state == shift_loop || shift_state == -1) &&
+                                (button_state == button_loop || button_state == -1)) {
                             cur_rec->font_color[shift_loop][button_loop] = font_color;
+                        }
                     }
                 }
             }
+            child_node = child_node->next;
         }
-        child_node = child_node->next;
     }
-}
 
-void
-Label_properties_Parser::parsing_rgb(const xmlNodePtr cur_node, SclColor& cur_color) {
-   assert(cur_node != NULL);
-
-    assert(0 == xmlStrcmp(cur_node->name, (const xmlChar*)"color"));
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-
-    if (child_node) {
-        /* FIXME : A hardcoded routine for parsing 0xRRGGBBAA style string */
-        xmlChar* key = xmlNodeGetContent(child_node);
-        if (key) {
-            if (xmlStrlen(key) == 10) {
-                char temp_string[5] = {"0xFF"};
-                temp_string[2] = key[2];
-                temp_string[3] = key[3];
-                sscanf(temp_string, "%x",&(cur_color.r));
-                temp_string[2] = key[4];
-                temp_string[3] = key[5];
-                sscanf(temp_string, "%x",&(cur_color.g));
-                temp_string[2] = key[6];
-                temp_string[3] = key[7];
-                sscanf(temp_string, "%x",&(cur_color.b));
-                temp_string[2] = key[8];
-                temp_string[3] = key[9];
-                sscanf(temp_string, "%x",&(cur_color.a));
+    void parsing_shadow_color_record(const xmlNodePtr cur_node, const PSclLabelProperties cur_rec) {
+        assert(cur_node != NULL);
+        assert(cur_rec != NULL);
+        assert(0 == xmlStrcmp(cur_node->name, (const xmlChar*)"shadow_color_record"));
+        xmlNodePtr child_node = cur_node->xmlChildrenNode;
+
+        while (child_node != NULL) {
+            if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"color") ) {
+                int shift_state = get_shift_state_prop(child_node);
+                int button_state = get_button_state_prop(child_node);
+                if (shift_state != -1 && button_state != -1 ) {
+                    parsing_rgb(child_node, cur_rec->shadow_color[shift_state][button_state]);
+                }
             }
+            child_node = child_node->next;
         }
-        xmlFree(key);
     }
-}
 
-void
-Label_properties_Parser::parsing_shadow_color_record(const xmlNodePtr cur_node, const PSclLabelProperties cur_rec) {
-    assert(cur_node != NULL);
-    assert(cur_rec != NULL);
-    assert(0 == xmlStrcmp(cur_node->name, (const xmlChar*)"shadow_color_record"));
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-
-    while (child_node != NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"color") ) {
-            int shift_state = get_shift_state_prop(child_node);
-            int button_state = get_button_state_prop(child_node);
-            if (shift_state != -1 && button_state != -1 ) {
-                parsing_rgb(child_node, cur_rec->shadow_color[shift_state][button_state]);
+    void parsing_rgb(const xmlNodePtr cur_node, SclColor& cur_color) {
+        assert(cur_node != NULL);
+
+        assert(0 == xmlStrcmp(cur_node->name, (const xmlChar*)"color"));
+        xmlNodePtr child_node = cur_node->xmlChildrenNode;
+
+        if (child_node) {
+            /* FIXME : A hardcoded routine for parsing 0xRRGGBBAA style string */
+            xmlChar* key = xmlNodeGetContent(child_node);
+            if (key) {
+                if (xmlStrlen(key) == 10) {
+                    int r, g, b, a;
+                    r = g = b = 0;
+                    a = 0xff;
+
+                    char temp_string[5] = {"0xFF"};
+                    temp_string[2] = key[2];
+                    temp_string[3] = key[3];
+                    if (sscanf(temp_string, "%x", &r) <= 0) {
+                        SCLLOG(SclLog::ERROR, "parsing_rgb() has failed.");
+                    }
+
+                    temp_string[2] = key[4];
+                    temp_string[3] = key[5];
+                    if (sscanf(temp_string, "%x", &g) <= 0) {
+                        SCLLOG(SclLog::ERROR, "parsing_rgb() has failed.");
+                    }
+                    temp_string[2] = key[6];
+                    temp_string[3] = key[7];
+                    if (sscanf(temp_string, "%x", &b) <= 0) {
+                        SCLLOG(SclLog::ERROR, "parsing_rgb() has failed.");
+                    }
+
+                    temp_string[2] = key[8];
+                    temp_string[3] = key[9];
+                    if (sscanf(temp_string, "%x", &a) <= 0) {
+                        SCLLOG(SclLog::ERROR, "parsing_rgb() has failed.");
+                    }
+
+                    cur_color.r = r;
+                    cur_color.g = g;
+                    cur_color.b = b;
+                    cur_color.a = a;
+                }
             }
+            xmlFree(key);
         }
-        child_node = child_node->next;
     }
-}
-//UTILS
-int
-Label_properties_Parser::get_shift_state_prop(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
-   
-    int shift_state = -1;
-    if (equal_prop(cur_node, "shift", "on")) {
-        shift_state = SCL_SHIFT_STATE_ON;
-    } else if (equal_prop(cur_node, "shift", "off")) {
-        shift_state = SCL_SHIFT_STATE_OFF;
-
-    } else if (equal_prop(cur_node, "shift", "loc")) {
-        shift_state = SCL_SHIFT_STATE_LOCK;
+
+    int get_shift_state_prop(const xmlNodePtr cur_node) {
+        assert(cur_node != NULL);
+
+        int shift_state = -1;
+
+        if (equal_prop(cur_node, "shift", "on")) {
+            shift_state = SCL_SHIFT_STATE_ON;
+        } else if (equal_prop(cur_node, "shift", "off")) {
+            shift_state = SCL_SHIFT_STATE_OFF;
+
+        } else if (equal_prop(cur_node, "shift", "loc")) {
+            shift_state = SCL_SHIFT_STATE_LOCK;
+        }
+        return shift_state;
+    }
+
+    int get_button_state_prop(const xmlNodePtr cur_node) {
+        assert(cur_node != NULL);
+        int button_state = -1;
+
+        if (equal_prop(cur_node, "button", "pressed")) {
+            button_state = BUTTON_STATE_PRESSED;
+        } else if (equal_prop(cur_node, "button", "normal")) {
+            button_state = BUTTON_STATE_NORMAL;
+        }
+        else if (equal_prop(cur_node, "button", "disabled")) {
+            button_state = BUTTON_STATE_DISABLED;
+        }
+        return button_state;
+    }
+
+    SclLabelProperties m_label_properties_frame[MAX_SCL_LABEL_PROPERTIES][MAX_SIZE_OF_LABEL_FOR_ONE];
+    int m_size;
+};
+
+Label_properties_Parser* Label_properties_Parser::m_instance = NULL;
+
+Label_properties_Parser::Label_properties_Parser() {
+    m_impl = new LabelPropertiesParserImpl;
+    if (m_impl == NULL) {
+        SCLLOG(SclLog::ERROR, "Create Label_properties_Parser failed");
     }
-    return shift_state;
 }
-int
-Label_properties_Parser::get_button_state_prop(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
-    int button_state = -1;
-
-    if (equal_prop(cur_node, "button", "pressed")) {
-        button_state = BUTTON_STATE_PRESSED;
-    } else if (equal_prop(cur_node, "button", "normal")) {
-        button_state = BUTTON_STATE_NORMAL;
+
+Label_properties_Parser::~Label_properties_Parser() {
+    if (m_impl) {
+        SCLLOG(SclLog::MESSAGE, "~Label_properties_Parser() has called");
+        delete m_impl;
+        m_impl = NULL;
     }
-    else if (equal_prop(cur_node, "button", "disabled")) {
-        button_state = BUTTON_STATE_DISABLED;
+}
+
+Label_properties_Parser*
+Label_properties_Parser::get_instance() {
+    if (m_instance == NULL) {
+        m_instance = new Label_properties_Parser();
     }
-    return button_state;
+    return m_instance;
 }
 
+int
+Label_properties_Parser::init(const char* file) {
+    return m_impl->parsing_label_properties_frame(file);
+}
 
+int
+Label_properties_Parser::get_size() {
+    return m_impl->m_size;
+}
+
+//recompute_layout will change the table
+PSclLabelPropertiesTable
+Label_properties_Parser::get_label_properties_frame() {
+    return m_impl->m_label_properties_frame;
+}
index b8027a0..289a8f1 100644 (file)
  *
  */
 
-#include "xmlresource.h"
+#include <algorithm>
+#include <malloc.h>
+#include <string.h>
+
 #include "layout_parser.h"
-#include "main_entry_parser.h"
+#include "default_configure_parser.h" /* use data in default_configure.xml */
 #include "xml_parser_utils.h"
-#include "input_mode_configure_parser.h"
 #include "layout_parser_helper.h"
 #include "put_record.h"
-#include <algorithm>
-#include <malloc.h>
+#include "simple_debug.h"
+
 using namespace std;
-using namespace xmlresource;
 
 Layout_Parser* Layout_Parser::m_instance = NULL;
 
@@ -42,67 +43,71 @@ Layout_Parser::~Layout_Parser() {
             free(m_key_coordinate_pointer_frame[i][j]);
             m_key_coordinate_pointer_frame[i][j] = NULL;
         }
+
+        if (m_layout_files[i]) {
+            free(m_layout_files[i]);
+            m_layout_files[i] = NULL;
+        }
     }
 
     release_layout_strings();
     release_key_strings();
 }
-Layout_Parser* Layout_Parser::get_instance() {
+
+Layout_Parser*
+Layout_Parser::get_instance() {
     if (m_instance == NULL) {
         m_instance = new Layout_Parser();
     }
     return m_instance;
 }
-void Layout_Parser::init() {
-    parsing_layout_table();
-}
 
-void Layout_Parser::load(int layout_id) {
-    /* Check if the lazy_loading feature is enabled, and if so, load key resources now */
-    sclboolean use_lazy_loading = FALSE;
-    Default_Configure_Parser *defalut_configure_parser = Default_Configure_Parser::get_instance();
-    if (defalut_configure_parser) {
-        PSclDefaultConfigure default_configure = defalut_configure_parser->get_default_configure();
-        if (default_configure) {
-            use_lazy_loading = default_configure->use_lazy_loading;
-        }
+int
+Layout_Parser::init(const char* dir, char **layout_files, int size) {
+    int ret = -1;
+    if (dir && layout_files) {
+        m_dir = string(dir);
+        ret = parsing_layout_table(dir, layout_files, size);
     }
-    if (use_lazy_loading) {
-        if (layout_id >= 0 && layout_id < MAX_SCL_LAYOUT) {
-            xmlDocPtr doc;
-            xmlNodePtr cur_node;
-
-            char input_file[_POSIX_PATH_MAX] = {0};
-            XMLResource *xml_resource = XMLResource::get_instance();
-            snprintf(input_file, _POSIX_PATH_MAX, "%s/%s",
-                xml_resource->get_resource_directory(), m_layout_files[layout_id]);
-
-            doc = xmlReadFile(input_file, NULL, 0);
-            if (doc == NULL) {
-                printf("Could not load file.\n");
-                exit(1);
-            }
 
-            cur_node = xmlDocGetRootElement(doc);
-            if (cur_node == NULL) {
-                printf("empty document.\n");
-                xmlFreeDoc(doc);
-                exit(1);
-            }
-            if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)LAYOUT_TAG))
-            {
-                printf("root name %s error!\n", cur_node->name);
-                xmlFreeDoc(doc);
-                exit(1);
-            }
+    return ret;
+}
 
-            PSclLayout cur_rec_layout = m_layout_table + layout_id;
-            parsing_layout_node_lazy(cur_node, cur_rec_layout, layout_id);
+void
+Layout_Parser::load(int layout_id) {
+    if (layout_id >= 0 && layout_id < MAX_SCL_LAYOUT) {
+        xmlDocPtr doc;
+        xmlNodePtr cur_node;
+
+        char input_file[_POSIX_PATH_MAX] = {0};
+        snprintf(input_file, _POSIX_PATH_MAX, "%s/%s", m_dir.c_str(), m_layout_files[layout_id]);
+
+        doc = xmlReadFile(input_file, NULL, 0);
+        if (doc == NULL) {
+            SCLLOG(SclLog::ERROR, "Could not load file: %s.", input_file);
+            exit(1);
+        }
 
+        cur_node = xmlDocGetRootElement(doc);
+        if (cur_node == NULL) {
+            SCLLOG(SclLog::ERROR, "Layout_Parser: empty document.\n");
+            xmlFreeDoc(doc);
+            exit(1);
+        }
+        if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)LAYOUT_TAG))
+        {
+            SCLLOG(SclLog::ERROR, "Layout_Parser: root name error: %s\n!", (char *)cur_node->name);
             xmlFreeDoc(doc);
+            exit(1);
         }
+
+        PSclLayout cur_rec_layout = m_layout_table + layout_id;
+        loading_coordinate_resources(cur_node, cur_rec_layout, layout_id);
+
+        xmlFreeDoc(doc);
     }
 }
+
 void Layout_Parser::unload() {
     for (int i = 0; i < MAX_SCL_LAYOUT; ++i) {
         for (int j = 0; j < MAX_KEY; ++j) {
@@ -113,38 +118,29 @@ void Layout_Parser::unload() {
 
     release_key_strings();
 }
-bool Layout_Parser::loaded(int layout_id) {
-    bool ret = TRUE;
 
-    sclboolean use_lazy_loading = FALSE;
-    Default_Configure_Parser *defalut_configure_parser = Default_Configure_Parser::get_instance();
-    if (defalut_configure_parser) {
-        PSclDefaultConfigure default_configure = defalut_configure_parser->get_default_configure();
-        if (default_configure) {
-            use_lazy_loading = default_configure->use_lazy_loading;
-        }
-    }
+bool
+Layout_Parser::loaded(int layout_id) {
+    bool ret = TRUE;
 
-    if (use_lazy_loading) {
-        if (layout_id >= 0 && layout_id < MAX_SCL_LAYOUT) {
-            if (m_key_coordinate_pointer_frame[layout_id][0] == NULL) {
-                ret = FALSE;
-            }
+    if (layout_id >= 0 && layout_id < MAX_SCL_LAYOUT) {
+        if (m_key_coordinate_pointer_frame[layout_id][0] == NULL) {
+            ret = FALSE;
         }
     }
 
     return ret;
 }
 
-bool xmlStringCompare (xmlChar* i, xmlChar* j) { return (xmlStrcmp(i, j) < 0); }
-
-void Layout_Parser::add_layout_string(xmlChar* newstr) {
+void
+Layout_Parser::add_layout_string(xmlChar* newstr) {
     if (newstr) {
         m_vec_layout_strings.push_back(newstr);
     }
 }
 
-void Layout_Parser::release_layout_strings() {
+void
+Layout_Parser::release_layout_strings() {
     for(int loop = 0;loop < m_vec_layout_strings.size();loop++) {
         if (m_vec_layout_strings[loop]) {
             xmlFree(m_vec_layout_strings[loop]);
@@ -153,13 +149,15 @@ void Layout_Parser::release_layout_strings() {
     m_vec_layout_strings.clear();
 }
 
-void Layout_Parser::add_key_string(xmlChar* newstr) {
+void
+Layout_Parser::add_key_string(xmlChar* newstr) {
     if (newstr) {
         m_vec_key_strings.push_back(newstr);
     }
 }
 
-void Layout_Parser::release_key_strings() {
+void
+Layout_Parser::release_key_strings() {
     for(int loop = 0;loop < m_vec_key_strings.size();loop++) {
         if (m_vec_key_strings[loop]) {
             xmlFree(m_vec_key_strings[loop]);
@@ -168,7 +166,8 @@ void Layout_Parser::release_key_strings() {
     m_vec_key_strings.clear();
 }
 
-int Layout_Parser::get_layout_index(const char *name) {
+int
+Layout_Parser::get_layout_index(const char *name) {
     int ret = NOT_USED;
     if (name) {
         for(int loop = 0;loop < MAX_SCL_LAYOUT && ret == NOT_USED;loop++) {
@@ -183,76 +182,58 @@ int Layout_Parser::get_layout_index(const char *name) {
     return ret;
 }
 
-PSclLayout Layout_Parser::get_layout_table() {
+PSclLayout
+Layout_Parser::get_layout_table() {
     return m_layout_table;
 }
-int Layout_Parser::get_layout_size() {
+
+int
+Layout_Parser::get_layout_size() {
     return m_layout_size;
 }
-PSclLayoutKeyCoordinatePointerTable Layout_Parser::get_key_coordinate_pointer_frame() {
+
+PSclLayoutKeyCoordinatePointerTable
+Layout_Parser::get_key_coordinate_pointer_frame() {
     return m_key_coordinate_pointer_frame;
 }
 
-void Layout_Parser::parsing_layout_table() {
-    int index = 0;
-
-    m_layout_size = 0;
-
-    Input_Mode_Configure_Parser *input_mode_configure_parser = Input_Mode_Configure_Parser::get_instance();
-    for(int inputmode = 0;inputmode < MAX_SCL_INPUT_MODE;inputmode++) {
-        int empty_index;
-        const sclchar* layout_filepath;
-        PSclInputModeConfigure configure_table = input_mode_configure_parser->get_input_mode_configure_table();
-        SclInputModeConfigure& cur_rec = configure_table[inputmode];
-
-        for(int display = 0;display < DISPLAYMODE_MAX;display++) {
-            empty_index = NOT_USED;
-            layout_filepath = cur_rec.layouts[display];
-            if (layout_filepath) {
-                for(int checkidx = 0;checkidx < MAX_SCL_LAYOUT && empty_index == NOT_USED;checkidx++) {
-                    if (m_layout_files[checkidx] == NULL) empty_index = checkidx;
-                    else if (strncmp(m_layout_files[checkidx], layout_filepath, _POSIX_PATH_MAX) == 0) break;
-                }
-                if (empty_index != NOT_USED) {
-                    m_layout_size++;
-                    m_layout_files[empty_index] = layout_filepath;
-
-                    xmlDocPtr doc;
-                    xmlNodePtr cur_node;
-
-                    char input_file[_POSIX_PATH_MAX] = {0};
-                    XMLResource *xml_resource = XMLResource::get_instance();
-                    snprintf(input_file, _POSIX_PATH_MAX, "%s/%s",
-                        xml_resource->get_resource_directory(), layout_filepath);
-
-                    doc = xmlReadFile(input_file, NULL, 0);
-                    if (doc == NULL) {
-                        printf("Could not load file.\n");
-                        exit(1);
-                    }
+int
+Layout_Parser::parsing_layout_table(const char* dir, char** file, int file_num) {
+    m_layout_size = file_num;
+    for (int index = 0; index < file_num; ++index) {
+        m_layout_files[index] = strdup(file[index]);
+        xmlDocPtr doc;
+        xmlNodePtr cur_node;
+
+        char input_file[_POSIX_PATH_MAX] = {0};
+        snprintf(input_file, _POSIX_PATH_MAX, "%s/%s", dir, m_layout_files[index]);
+
+        doc = xmlReadFile(input_file, NULL, 0);
+        if (doc == NULL) {
+            SCLLOG(SclLog::DEBUG, "Could not load file: %s.", input_file);
+            return -1;
+        }
 
-                    cur_node = xmlDocGetRootElement(doc);
-                    if (cur_node == NULL) {
-                        printf("empty document.\n");
-                        xmlFreeDoc(doc);
-                        exit(1);
-                    }
-                    if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)LAYOUT_TAG))
-                    {
-                       printf("root name %s error!\n", cur_node->name);
-                       xmlFreeDoc(doc);
-                       exit(1);
-                    }
+        cur_node = xmlDocGetRootElement(doc);
+        if (cur_node == NULL) {
+            SCLLOG(SclLog::DEBUG, "Layout_Parser: empty document.\n");
+            xmlFreeDoc(doc);
+            return -1;
+        }
+        if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)LAYOUT_TAG))
+        {
+            SCLLOG(SclLog::DEBUG, "Layout_Parser: root name error: %s\n!", (char *)cur_node->name);
+            xmlFreeDoc(doc);
+            return -1;
+        }
 
-                    PSclLayout cur_rec_layout = m_layout_table + empty_index;
-                    parsing_layout_node(cur_node, cur_rec_layout, empty_index);
-                    cur_rec_layout->name = (sclchar*)layout_filepath;
+        PSclLayout cur_rec_layout = m_layout_table + index;
+        parsing_layout_node(cur_node, cur_rec_layout, index);
+        cur_rec_layout->name = (sclchar*)strdup(m_layout_files[index]);
 
-                    xmlFreeDoc(doc);
-                }
-            }
-        }
+        xmlFreeDoc(doc);
     }
+    return 0;
 }
 
 void
@@ -284,7 +265,8 @@ Layout_Parser::parsing_background(
     }
 }
 
-void Layout_Parser::parsing_key_background(
+void
+Layout_Parser::parsing_key_background(
         const xmlNodePtr cur_node,
         PSclLayout cur_layout) {
     assert(cur_node != NULL);
@@ -312,18 +294,21 @@ void Layout_Parser::parsing_key_background(
 }
 
 
-void Layout_Parser::set_default_layout_value(const PSclLayout cur_layout) {
-    XMLResource *xml_resource = XMLResource::get_instance();
-    const PSclDefaultConfigure sclres_default_configure = xml_resource->get_default_configure();
+void
+Layout_Parser::set_default_layout_value(const PSclLayout cur_layout) {
+    Default_Configure_Parser *default_configure_parser = Default_Configure_Parser::get_instance();
+    assert(default_configure_parser);
+    const PSclDefaultConfigure sclres_default_configure = default_configure_parser->get_default_configure();
 
-    assert(cur_layout != NULL && sclres_default_configure != NULL);
-    //default value
+    assert(cur_layout != NULL);
     cur_layout->valid = 1;
     cur_layout->style = LAYOUT_STYLE_BASE;
     cur_layout->name = NULL;
 
-    cur_layout->width = sclres_default_configure->target_screen_width;
-    cur_layout->height = sclres_default_configure->target_screen_height;
+    if (sclres_default_configure) {
+        cur_layout->width = sclres_default_configure->target_screen_width;
+        cur_layout->height = sclres_default_configure->target_screen_height;
+    }
 
     cur_layout->key_width = 0;
     cur_layout->key_height = 0;
@@ -355,7 +340,8 @@ void Layout_Parser::set_default_layout_value(const PSclLayout cur_layout) {
     cur_layout->add_grab_bottom = NOT_USED;
 }
 
-void Layout_Parser::set_default_row_value(
+void
+Layout_Parser::set_default_row_value(
         Row* row,
         const PSclLayout cur_rec_layout,
         int row_y) {
@@ -382,7 +368,8 @@ void Layout_Parser::set_default_row_value(
     }
 }
 
-void Layout_Parser::set_default_key_coordinate_value(
+void
+Layout_Parser::set_default_key_coordinate_value(
         const PSclLayoutKeyCoordinate cur_rec_coordinate,
         const Row* row) {
     assert(row != NULL);
@@ -468,7 +455,8 @@ void Layout_Parser::set_default_key_coordinate_value(
     }
 }
 
-void Layout_Parser::parsing_grab_area(
+void
+Layout_Parser::parsing_grab_area(
         const xmlNodePtr cur_node,
         const PSclLayout cur_rec_layout) {
     assert(cur_node != NULL);
@@ -491,7 +479,8 @@ void Layout_Parser::parsing_grab_area(
     }
 }
 
-void Layout_Parser::parsing_layout_node(
+void
+Layout_Parser::parsing_layout_node(
         const xmlNodePtr cur_node,
         const PSclLayout cur_rec_layout,
         int layout_no) {
@@ -505,11 +494,6 @@ void Layout_Parser::parsing_layout_node(
 
     SclLayoutKeyCoordinatePointer *cur_key = &m_key_coordinate_pointer_frame[layout_no][0];
 
-    /*key = xmlGetProp(cur_node, (const xmlChar*)LAYOUT_NAME_ATTRIBUTE);
-    if (key) {
-        cur_rec_layout->name = (sclchar*)key;
-    }*/
-
     if (equal_prop(cur_node, LAYOUT_DIRECTION_ATTRIBUTE,
         LAYOUT_DIRECTION_ATTRIBUTE_LANDSCAPE_VALUE)) {
         cur_rec_layout->display_mode = DISPLAYMODE_LANDSCAPE;
@@ -564,21 +548,10 @@ void Layout_Parser::parsing_layout_node(
 
     xmlNodePtr child_node = cur_node->xmlChildrenNode;
     while (child_node != NULL) {
-        if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)LAYOUT_ROW_TAG)) {
-            /* Check if the lazy_loading feature is enabled, and if so, do not load any layout resources now */
-            sclboolean use_lazy_loading = FALSE;
-            Default_Configure_Parser *defalut_configure_parser = Default_Configure_Parser::get_instance();
-            if (defalut_configure_parser) {
-                PSclDefaultConfigure default_configure = defalut_configure_parser->get_default_configure();
-                if (default_configure) {
-                    use_lazy_loading = default_configure->use_lazy_loading;
-                }
-            }
-            if (!use_lazy_loading) {
-                parsing_layout_row_node(child_node, cur_rec_layout, &row_y, &cur_key);
-            }
-        }
-        else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)LAYOUT_BACKGROUND_TAG)) {
+
+        /* row node: layout coordinate resources is no need to parsing at this time */
+
+        if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)LAYOUT_BACKGROUND_TAG)) {
             parsing_background(child_node, cur_rec_layout);
         }
         else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)LAYOUT_KEY_BACKGROUND_TAG)) {
@@ -592,7 +565,8 @@ void Layout_Parser::parsing_layout_node(
     }
 }
 
-void Layout_Parser::parsing_layout_node_lazy(
+void
+Layout_Parser::loading_coordinate_resources(
         const xmlNodePtr cur_node,
         const PSclLayout cur_rec_layout,
         int layout_no) {
@@ -603,23 +577,11 @@ void Layout_Parser::parsing_layout_node_lazy(
 
     SclLayoutKeyCoordinatePointer *cur_key = &m_key_coordinate_pointer_frame[layout_no][0];
 
-    /* Do a lazy loading, only when the key_coordinate_pointer_frame does not have any keys */
     if (*cur_key == NULL) {
         xmlNodePtr child_node = cur_node->xmlChildrenNode;
         while (child_node != NULL) {
             if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)LAYOUT_ROW_TAG)) {
-                /* Check if the lazy_loading feature is enabled, and if so, do not load any layout resources now */
-                sclboolean use_lazy_loading = FALSE;
-                Default_Configure_Parser *defalut_configure_parser = Default_Configure_Parser::get_instance();
-                if (defalut_configure_parser) {
-                    PSclDefaultConfigure default_configure = defalut_configure_parser->get_default_configure();
-                    if (default_configure) {
-                        use_lazy_loading = default_configure->use_lazy_loading;
-                    }
-                }
-                if (use_lazy_loading) {
-                    parsing_layout_row_node(child_node, cur_rec_layout, &row_y, &cur_key);
-                }
+                parsing_layout_row_node(child_node, cur_rec_layout, &row_y, &cur_key);
             }
 
             child_node = child_node->next;
@@ -1046,7 +1008,8 @@ Layout_Parser::parsing_auto_popup_keys_record_node(
     }
 }
 
-void Layout_Parser::parsing_key_coordinate_record_node(
+void
+Layout_Parser::parsing_key_coordinate_record_node(
         const xmlNodePtr cur_node, Row *row,
         SclLayoutKeyCoordinatePointer *cur_rec_coordinate) {
     assert(cur_node != NULL);
@@ -1054,7 +1017,7 @@ void Layout_Parser::parsing_key_coordinate_record_node(
 
     *cur_rec_coordinate = (SclLayoutKeyCoordinatePointer)malloc(sizeof(SclLayoutKeyCoordinate));
     if (*cur_rec_coordinate == NULL) {
-        printf("memory malloc eror.\n");
+        SCLLOG(SclLog::ERROR, "Layout_Parser: memory malloc eror.\n");
         return;
     }
     memset(*cur_rec_coordinate, 0x00, sizeof(SclLayoutKeyCoordinate));
index c4eac45..6b27a98 100644 (file)
  * limitations under the License.
  *
  */
+#include <string.h>
+#include <libxml/parser.h>
 
 #include "magnifier_configure_parser.h"
-#include "main_entry_parser.h"
 #include <assert.h>
 #include "xml_parser_utils.h"
+#include "simple_debug.h"
 using namespace std;
 
-Magnifier_Configure_Parser* Magnifier_Configure_Parser::m_instance = NULL;
-
-Magnifier_Configure_Parser::Magnifier_Configure_Parser() {
-    memset((void*)&m_magnifier_configure, 0x00, sizeof(SclMagnifierWndConfigure));
-}
+static SCLMagnifierStyle
+get_content_magnifier_style(const xmlNodePtr cur_node) {
+    assert(cur_node != NULL);
 
-Magnifier_Configure_Parser::~Magnifier_Configure_Parser() {
-    /* Let's create de-initializing function for this resource releasement */
-    if (m_magnifier_configure.bg_image_path) {
-        xmlFree(m_magnifier_configure.bg_image_path);
-        m_magnifier_configure.bg_image_path = NULL;
-    }
-    if (m_magnifier_configure.bg_shift_image_path) {
-        xmlFree(m_magnifier_configure.bg_shift_image_path);
-        m_magnifier_configure.bg_shift_image_path = NULL;
-    }
-    if (m_magnifier_configure.bg_shift_lock_image_path) {
-        xmlFree(m_magnifier_configure.bg_shift_lock_image_path);
-        m_magnifier_configure.bg_shift_lock_image_path = NULL;
-    }
-    if (m_magnifier_configure.bg_long_key_image_path) {
-        xmlFree(m_magnifier_configure.bg_long_key_image_path);
-        m_magnifier_configure.bg_long_key_image_path = NULL;
-    }
-    if (m_magnifier_configure.label_type) {
-        xmlFree(m_magnifier_configure.label_type);
-        m_magnifier_configure.label_type = NULL;
-    }
-}
+    SCLMagnifierStyle style = MAGNIFIER_STYLE_LABEL_ONLY;
 
-Magnifier_Configure_Parser* Magnifier_Configure_Parser::get_instance() {
-    if (m_instance == NULL) {
-        m_instance = new Magnifier_Configure_Parser();
+    xmlChar* key = xmlNodeGetContent(cur_node);
+    if (key!= NULL) {
+        if (0 == strcmp("area_capture", (const char*)key)) {
+            style = MAGNIFIER_STYLE_SEL_AREA_CAPTURE;
+        }
+        xmlFree(key);
     }
-    return m_instance;
-}
 
-void Magnifier_Configure_Parser::init() {
-    parsing_magnifier_configure();
+    return style;
 }
 
-void Magnifier_Configure_Parser::parsing_label_area(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
+class MagnifierConfigureParserImpl {
+    public:
+    MagnifierConfigureParserImpl() {
+        memset((void*)&m_magnifier_configure, 0x00, sizeof(SclMagnifierWndConfigure));
+    }
 
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-    while (child_node!=NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"left") ) {
-            m_magnifier_configure.label_area_rect.left = get_content_int(child_node);
+    ~MagnifierConfigureParserImpl() {
+        /* Let's create de-initializing function for this resource releasement */
+        if (m_magnifier_configure.bg_image_path) {
+            xmlFree(m_magnifier_configure.bg_image_path);
+            m_magnifier_configure.bg_image_path = NULL;
+        }
+        if (m_magnifier_configure.bg_shift_image_path) {
+            xmlFree(m_magnifier_configure.bg_shift_image_path);
+            m_magnifier_configure.bg_shift_image_path = NULL;
         }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"top") ) {
-            m_magnifier_configure.label_area_rect.top = get_content_int(child_node);
+        if (m_magnifier_configure.bg_shift_lock_image_path) {
+            xmlFree(m_magnifier_configure.bg_shift_lock_image_path);
+            m_magnifier_configure.bg_shift_lock_image_path = NULL;
         }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"right") ) {
-            m_magnifier_configure.label_area_rect.right = get_content_int(child_node);
+        if (m_magnifier_configure.bg_long_key_image_path) {
+            xmlFree(m_magnifier_configure.bg_long_key_image_path);
+            m_magnifier_configure.bg_long_key_image_path = NULL;
         }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"bottom") ) {
-            m_magnifier_configure.label_area_rect.bottom = get_content_int(child_node);
+        if (m_magnifier_configure.label_type) {
+            xmlFree(m_magnifier_configure.label_type);
+            m_magnifier_configure.label_type = NULL;
         }
 
-        child_node = child_node->next;
     }
-}
 
-void Magnifier_Configure_Parser::parsing_background_images(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
+    int parsing_magnifier_configure(const char* input_file) {
+        xmlDocPtr doc;
+        xmlNodePtr cur_node;
+
+        doc = xmlReadFile(input_file, NULL, 0);
+        if (doc == NULL) {
+            SCLLOG(SclLog::DEBUG, "Could not load file: %s.", input_file);
+            return -1;
+        }
+
+        cur_node = xmlDocGetRootElement(doc);
+        if (cur_node == NULL) {
+            SCLLOG(SclLog::DEBUG, "Magnifier_Configure_Parser: empty document.\n");
+            xmlFreeDoc(doc);
+            return -1;
+        }
+        if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"magnifier_configure"))
+        {
+            SCLLOG(SclLog::DEBUG, "Magnifier_Configure_Parser: root name error: %s\n!", (char *)cur_node->name);
+            xmlFreeDoc(doc);
+            return -1;
+        }
 
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-    while (child_node!=NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"image") ) {
-            if (equal_prop(child_node, "state", "normal")) {
-                xmlChar* temp = xmlNodeGetContent(child_node);
-                m_magnifier_configure.bg_image_path = (sclchar *)temp;
+        cur_node = cur_node->xmlChildrenNode;
+
+        while (cur_node != NULL) {
+            if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"magnifier_style")) {
+                m_magnifier_configure.style = get_content_magnifier_style(cur_node);
+            }
+            else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"width")) {
+                m_magnifier_configure.width = get_content_int(cur_node);
+            }
+            else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"height")) {
+                m_magnifier_configure.height = get_content_int(cur_node);
+            }
+            else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"label_area")) {
+                parsing_label_area(cur_node);
+            }
+            else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"background_image_path")) {
+                parsing_background_images(cur_node);
+            }
+            else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"use_window")) {
+                m_magnifier_configure.use_actual_window = get_content_bool(cur_node);
             }
-            else if (equal_prop(child_node, "state", "shift")) {
-                xmlChar* temp = xmlNodeGetContent(child_node);
-                m_magnifier_configure.bg_shift_image_path = (sclchar *)temp;
+            else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"label_type")) {
+                xmlChar* temp = xmlNodeGetContent(cur_node);
+                m_magnifier_configure.label_type = (sclchar*)temp;
             }
-            else if (equal_prop(child_node, "state", "lock")) {
-                xmlChar* temp = xmlNodeGetContent(child_node);
-                m_magnifier_configure.bg_shift_lock_image_path = (sclchar *)temp;
+            else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"padding")) {
+                parsing_padding_values(cur_node);
             }
-            else if (equal_prop(child_node, "state", "longkey")) {
-                xmlChar* temp = xmlNodeGetContent(child_node);
-                m_magnifier_configure.bg_long_key_image_path = (sclchar *)temp;
+            else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"show_shift_label")) {
+                m_magnifier_configure.show_shift_label = get_content_bool(cur_node);
             }
+            cur_node = cur_node->next;
         }
+        xmlFreeDoc(doc);
 
-        child_node = child_node->next;
+        return 0;
     }
-}
 
-void Magnifier_Configure_Parser::parsing_padding_values(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
+    void parsing_label_area(const xmlNodePtr cur_node) {
+        assert(cur_node != NULL);
 
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-    while (child_node!=NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"x") ) {
-            m_magnifier_configure.padding_x = get_content_int(child_node);
-        }
-        else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"y") ) {
-            m_magnifier_configure.padding_y = get_content_int(child_node);
-        }
+        xmlNodePtr child_node = cur_node->xmlChildrenNode;
+        while (child_node!=NULL) {
+            if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"left") ) {
+                m_magnifier_configure.label_area_rect.left = get_content_int(child_node);
+            }
+            else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"top") ) {
+                m_magnifier_configure.label_area_rect.top = get_content_int(child_node);
+            }
+            else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"right") ) {
+                m_magnifier_configure.label_area_rect.right = get_content_int(child_node);
+            }
+            else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"bottom") ) {
+                m_magnifier_configure.label_area_rect.bottom = get_content_int(child_node);
+            }
 
-        child_node = child_node->next;
+            child_node = child_node->next;
+        }
     }
-}
-
-SCLMagnifierStyle 
-get_content_magnifier_style(const xmlNodePtr cur_node) {
-    assert(cur_node != NULL);
-
-    SCLMagnifierStyle style = MAGNIFIER_STYLE_LABEL_ONLY;
+    void parsing_background_images(const xmlNodePtr cur_node) {
+        assert(cur_node != NULL);
+
+        xmlNodePtr child_node = cur_node->xmlChildrenNode;
+        while (child_node!=NULL) {
+            if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"image") ) {
+                if (equal_prop(child_node, "state", "normal")) {
+                    xmlChar* temp = xmlNodeGetContent(child_node);
+                    m_magnifier_configure.bg_image_path = (sclchar *)temp;
+                }
+                else if (equal_prop(child_node, "state", "shift")) {
+                    xmlChar* temp = xmlNodeGetContent(child_node);
+                    m_magnifier_configure.bg_shift_image_path = (sclchar *)temp;
+                }
+                else if (equal_prop(child_node, "state", "lock")) {
+                    xmlChar* temp = xmlNodeGetContent(child_node);
+                    m_magnifier_configure.bg_shift_lock_image_path = (sclchar *)temp;
+                }
+                else if (equal_prop(child_node, "state", "longkey")) {
+                    xmlChar* temp = xmlNodeGetContent(child_node);
+                    m_magnifier_configure.bg_long_key_image_path = (sclchar *)temp;
+                }
+            }
 
-    xmlChar* key = xmlNodeGetContent(cur_node);
-    if (key!= NULL) {
-        if (0 == strcmp("area_capture", (const char*)key)) {
-            style = MAGNIFIER_STYLE_SEL_AREA_CAPTURE;
+            child_node = child_node->next;
         }
-        xmlFree(key);
     }
+    void parsing_padding_values(const xmlNodePtr cur_node) {
+        assert(cur_node != NULL);
 
-    return style;
-}
-
-void Magnifier_Configure_Parser::parsing_magnifier_configure() {
-    xmlDocPtr doc;
-    xmlNodePtr cur_node;
+        xmlNodePtr child_node = cur_node->xmlChildrenNode;
+        while (child_node!=NULL) {
+            if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"x") ) {
+                m_magnifier_configure.padding_x = get_content_int(child_node);
+            }
+            else if (0 == xmlStrcmp(child_node->name, (const xmlChar *)"y") ) {
+                m_magnifier_configure.padding_y = get_content_int(child_node);
+            }
 
-    char input_file[_POSIX_PATH_MAX] = {0};
-    Main_Entry_Parser::get_file_full_path(input_file, "magnifier_configure");
+            child_node = child_node->next;
+        }
 
-    doc = xmlReadFile(input_file, NULL, 0);
-    if (doc == NULL) {
-        printf("Could not load file.\n");
-        exit(1);
     }
+    SclMagnifierWndConfigure m_magnifier_configure;
+};
 
-    cur_node = xmlDocGetRootElement(doc);
-    if (cur_node == NULL) {
-        printf("empty document.\n");
-        xmlFreeDoc(doc);
-        exit(1);
-    }
-    if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"magnifier_configure"))
-    {
-        printf("root name %s error!\n", cur_node->name);
-        xmlFreeDoc(doc);
-        exit(1);
+Magnifier_Configure_Parser* Magnifier_Configure_Parser::m_instance = NULL;
+
+Magnifier_Configure_Parser::Magnifier_Configure_Parser() {
+    m_impl = new MagnifierConfigureParserImpl;
+    if (m_impl == NULL) {
+        SCLLOG(SclLog::ERROR, "Create Magnifier_Configure_Parser failed");
     }
+}
 
-    cur_node = cur_node->xmlChildrenNode;
+Magnifier_Configure_Parser::~Magnifier_Configure_Parser() {
+    if (m_impl) {
+        SCLLOG(SclLog::MESSAGE, "~Magnifier_Configure_Parser() has called");
+        delete m_impl;
+        m_impl = NULL;
+    }
+}
 
-    while (cur_node != NULL) {
-        if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"magnifier_style")) {
-            m_magnifier_configure.style = get_content_magnifier_style(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"width")) {
-            m_magnifier_configure.width = get_content_int(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"height")) {
-            m_magnifier_configure.height = get_content_int(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"label_area")) {
-            parsing_label_area(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"background_image_path")) {
-            parsing_background_images(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"use_window")) {
-            m_magnifier_configure.use_actual_window = get_content_bool(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"label_type")) {
-            xmlChar* temp = xmlNodeGetContent(cur_node);
-            m_magnifier_configure.label_type = (sclchar*)temp;
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"padding")) {
-            parsing_padding_values(cur_node);
-        }
-        else if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"show_shift_label")) {
-            m_magnifier_configure.show_shift_label = get_content_bool(cur_node);
-        }
-        cur_node = cur_node->next;
+Magnifier_Configure_Parser*
+Magnifier_Configure_Parser::get_instance() {
+    if (m_instance == NULL) {
+        m_instance = new Magnifier_Configure_Parser();
     }
-    //print_default_configure_table();
-    xmlFreeDoc(doc);
+    return m_instance;
 }
 
-PSclMagnifierWndConfigure Magnifier_Configure_Parser::get_magnifier_configure() {
-    return &m_magnifier_configure;
+int
+Magnifier_Configure_Parser::init(const char* file) {
+    return m_impl->parsing_magnifier_configure(file);
 }
 
-void Magnifier_Configure_Parser::print_magnifier_configure_table() {
-    //printf("------------------\n");
-    //printf("\tdisplay:\t%d\n", m_magnifier_configure.display);
-    //printf("\tinputMode:\t%s\n", m_magnifier_configure.input_mode);
-    //printf("\tuse_magnifier:\t%d\n", m_magnifier_configure.use_magnifier_window);
-    //printf("\tuse_autopopup:\t%d\n", m_magnifier_configure.use_auto_popup);
-    //printf("\tuse_zoomwindow:\t%d\n", m_magnifier_configure.use_zoom_window);
-    //printf("\tuse_error_sound:\t%d\n", m_magnifier_configure.use_zoom_window);
-    //printf("\tuse_word_deletion:\t%d\n", m_magnifier_configure.use_zoom_window);
-    //printf("\ttouch_offset:\n");
-    //printf("\\t\t\t%d %d %d %d\n",
-    //    m_magnifier_configure.touch_offset[0].x, m_magnifier_configure.touch_offset[0].y,
-    //    m_magnifier_configure.touch_offset[1].x, m_magnifier_configure.touch_offset[1].y);
-    //printf("------------------\n");
+PSclMagnifierWndConfigure
+Magnifier_Configure_Parser::get_magnifier_configure() {
+    return &m_impl->m_magnifier_configure;
 }
index 215a78b..5c1d00c 100644 (file)
  *
  */
 
-#include "main_entry_parser.h"
 #include <assert.h>
-#include "xmlresource.h"
+#include <string.h>
+#include <libxml/parser.h>
+
+#include "main_entry_parser.h"
 #include "xml_parser_utils.h"
+#include "simple_debug.h"
 
 using namespace std;
-using namespace xmlresource;
 
-static int get_keyset_id(const xmlNodePtr cur_node);
-static int get_layout_id(const xmlNodePtr cur_node);
+class MainEntryParserImpl {
+    public:
+        int parsing_main_entry(const char *input_file) {
+            xmlDocPtr doc;
+            xmlNodePtr cur_node;
+
+            doc = xmlReadFile(input_file, NULL, 0);
+            if (doc == NULL) {
+                SCLLOG(SclLog::DEBUG, "Could not load file: %s.", input_file);
+                return -1;
+            }
+
+            cur_node = xmlDocGetRootElement(doc);
+            if (cur_node == NULL) {
+                SCLLOG(SclLog::DEBUG, "Main_Entry_Parser: empty document.\n");
+                xmlFreeDoc(doc);
+                return -1;
+            }
+            if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"main-entry"))
+            {
+                SCLLOG(SclLog::DEBUG, "Main_Entry_Parser: root name error: %s\n!", (char *)cur_node->name);
+                xmlFreeDoc(doc);
+                return -1;
+            }
+
+            make_xml_files(cur_node);
+
+            xmlFreeDoc(doc);
+
+            return 0;
+
+        }
+        void make_xml_files(const xmlNodePtr p_node) {
+            assert(p_node != NULL);
+            xmlNodePtr node = p_node->xmlChildrenNode;
+            while (node != NULL) {
+                if (0 == xmlStrcmp(node->name, (const xmlChar *)"files")) {
+                    parsing_files_node(node);
+                }
+                node = node->next;
+            }
+
+        }
+
+        void parsing_files_node(const xmlNodePtr p_node) {
+            assert(p_node != NULL);
+            xmlNodePtr node = p_node->xmlChildrenNode;
+
+            while (node != NULL) {
+                if (0 == xmlStrcmp(node->name, (const xmlChar *)"input-mode-configure")) {
+                    m_xml_files.input_mode_configure = (char*)xmlNodeGetContent(node);
+                }
+                else if (0 == xmlStrcmp(node->name, (const xmlChar *)"layout")) {
+                    m_xml_files.layout = (char*)xmlNodeGetContent(node);
+                }
+                else if (0 == xmlStrcmp(node->name, (const xmlChar *)"key-label-property")) {
+                    m_xml_files.key_label_property = (char*)xmlNodeGetContent(node);
+                }
+                else if (0 == xmlStrcmp(node->name, (const xmlChar *)"modifier-decoration")) {
+                    m_xml_files.modifier_decoration = (char*)xmlNodeGetContent(node);
+                }
+                else if (0 == xmlStrcmp(node->name, (const xmlChar *)"default-configure")) {
+                    m_xml_files.default_configure = (char*)xmlNodeGetContent(node);
+                }
+                else if (0 == xmlStrcmp(node->name, (const xmlChar *)"autopopup-configure")) {
+                    m_xml_files.autopopup_configure = (char*)xmlNodeGetContent(node);
+                }
+                else if (0 == xmlStrcmp(node->name, (const xmlChar *)"magnifier-configure")) {
+                    m_xml_files.magnifier_configure = (char*)xmlNodeGetContent(node);
+                }
+                else if (0 == xmlStrcmp(node->name, (const xmlChar *)"nine-patch-file-list")) {
+                    m_xml_files.nine_patch_file_list = (char*)xmlNodeGetContent(node);
+                }
+                node = node->next;
+            }
+
+        }
+        XMLFiles m_xml_files;
+};
 
 Main_Entry_Parser* Main_Entry_Parser::m_instance = NULL;
 
 Main_Entry_Parser::Main_Entry_Parser() {
+    m_impl = new MainEntryParserImpl;
+    if (m_impl == NULL) {
+        SCLLOG(SclLog::ERROR, "Create MainEntryParserImpl failed");
+        return;
+    }
 }
 
 Main_Entry_Parser::~Main_Entry_Parser() {
+    if (m_impl) {
+        SCLLOG(SclLog::MESSAGE, "~Main_Entry_Parser() has called");
+        delete m_impl;
+        m_impl = NULL;
+    }
 }
-Main_Entry_Parser* Main_Entry_Parser::get_instance() {
+
+Main_Entry_Parser*
+Main_Entry_Parser::get_instance() {
     if (m_instance == NULL) {
         m_instance = new Main_Entry_Parser();
     }
     return m_instance;
 }
-void
-Main_Entry_Parser::Main_Entry_Parser::init(const char *entry_filepath) {
-    char input_file[_POSIX_PATH_MAX] = {0};
-    XMLResource *xml_resource = XMLResource::get_instance();
-    snprintf(input_file, _POSIX_PATH_MAX, "%s/%s",
-        xml_resource->get_resource_directory(), entry_filepath);
-    parsing_main_entry(input_file);
-}
 
-XMLFiles& Main_Entry_Parser::get_xml_files() {
-    return m_xml_files;
+int
+Main_Entry_Parser::init(const char* path) {
+    return m_impl->parsing_main_entry(path);
 }
 
-void Main_Entry_Parser::parsing_main_entry(const char *entry_filepath) {
-    xmlDocPtr doc;
-    xmlNodePtr cur_node;
-
-    doc = xmlReadFile(entry_filepath, NULL, 0);
-    if (doc == NULL) {
-        printf("Could not load file.\n");
-        exit(1);
-    }
 
-    cur_node = xmlDocGetRootElement(doc);
-    if (cur_node == NULL) {
-        printf("empty document.\n");
-        xmlFreeDoc(doc);
-        exit(1);
-    }
-    if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"main-entry"))
-    {
-       printf("root name %s error!\n", cur_node->name);
-       xmlFreeDoc(doc);
-       exit(1);
-    }
-
-    make_xml_files(cur_node);
-
-    xmlFreeDoc(doc);
-}
-
-void
-Main_Entry_Parser::make_xml_files(const xmlNodePtr p_node) {
-    assert(p_node != NULL);
-    xmlNodePtr node = p_node->xmlChildrenNode;
-    while (node != NULL) {
-        if (0 == xmlStrcmp(node->name, (const xmlChar *)"files")) {
-            parsing_files_node(node);
-        }
-        node = node->next;
-    }
-}
-
-void
-Main_Entry_Parser::parsing_files_node(const xmlNodePtr p_node) {
-    assert(p_node != NULL);
-    xmlNodePtr node = p_node->xmlChildrenNode;
-
-    while (node != NULL) {
-        if (0 == xmlStrcmp(node->name, (const xmlChar *)"inputmode-name-list")) {
-            m_xml_files.inputmode_name_list = (char*)xmlNodeGetContent(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"inputmode-popup-name-list")) {
-            m_xml_files.inputmode_popup_name_list = (char*)xmlNodeGetContent(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"layout-name-list")) {
-            m_xml_files.layout_name_list = (char*)xmlNodeGetContent(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"keyset-name-list")) {
-            m_xml_files.keyset_name_list = (char*)xmlNodeGetContent(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"input-mode-configure")) {
-            m_xml_files.input_mode_configure = (char*)xmlNodeGetContent(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"input-mode-popup-configure")) {
-            m_xml_files.input_mode_popup_configure = (char*)xmlNodeGetContent(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"layout")) {
-            m_xml_files.layout = (char*)xmlNodeGetContent(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"layout-keyset")) {
-            m_xml_files.layout_keyset = (char*)xmlNodeGetContent(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"configure-files")) {
-            parsing_configure_files(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"coordinate-files")) {
-            parsing_coordinate_files(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"property-files")) {
-            parsing_property_files(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"key-label-property")) {
-            m_xml_files.key_label_property = (char*)xmlNodeGetContent(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"modifier-decoration")) {
-            m_xml_files.modifier_decoration = (char*)xmlNodeGetContent(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"default-configure")) {
-            m_xml_files.default_configure = (char*)xmlNodeGetContent(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"autopopup-configure")) {
-            m_xml_files.autopopup_configure = (char*)xmlNodeGetContent(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"magnifier-configure")) {
-            m_xml_files.magnifier_configure = (char*)xmlNodeGetContent(node);
-        }
-        else if (0 == xmlStrcmp(node->name, (const xmlChar *)"nine-patch-file-list")) {
-            m_xml_files.nine_patch_file_list = (char*)xmlNodeGetContent(node);
-        }
-        node = node->next;
-    }
-}
-
-void
-Main_Entry_Parser::parsing_configure_files(const xmlNodePtr p_node) {
-    assert(p_node != NULL);
-    xmlNodePtr node = p_node->xmlChildrenNode;
-
-    while (node != NULL) {
-        if (0 == xmlStrcmp(node->name, (const xmlChar *)"file")) {
-            xmlChar* keyset = xmlGetProp(node, (const xmlChar*)"keyset");
-            assert(keyset != NULL);
-            xmlChar* file_name = xmlNodeGetContent(node);
-            assert(file_name != NULL);
-            m_xml_files.layout_key_configure.insert(Iter_data::value_type((const char*)keyset, (char*)file_name));
-        }
-        node = node->next;
-    }
-}
-void
-Main_Entry_Parser::parsing_property_files(const xmlNodePtr p_node) {
-    assert(p_node != NULL);
-    xmlNodePtr node = p_node->xmlChildrenNode;
-
-    while (node != NULL) {
-        if (0 == xmlStrcmp(node->name, (const xmlChar *)"file")) {
-            xmlChar* keyset = xmlGetProp(node, (const xmlChar*)"keyset");
-            xmlChar* file_name = xmlNodeGetContent(node);
-            assert(keyset != NULL);
-            assert(file_name != NULL);
-
-            m_xml_files.layout_key_property.insert(Iter_data::value_type((const char*)keyset, (char*)file_name));
-        }
-        node = node->next;
-    }
-}
-
-void
-Main_Entry_Parser::parsing_coordinate_files(const xmlNodePtr p_node) {
-    assert(p_node != NULL);
-    xmlNodePtr node = p_node->xmlChildrenNode;
-
-    while (node != NULL) {
-        if (0 == xmlStrcmp(node->name, (const xmlChar *)"file")) {
-            xmlChar* layout = xmlGetProp(node, (const xmlChar*)"layout");
-            xmlChar* file_name = xmlNodeGetContent(node);
-            assert(layout != NULL);
-            assert(file_name != NULL);
-
-            m_xml_files.layout_key_coordinate.insert(Iter_data::value_type((const char*)layout, (char*)file_name));
-        }
-        node = node->next;
-    }
-}
-
-void
-Main_Entry_Parser::get_file_full_path(char* dest_path, const char* file_type) {
-    assert(file_type != NULL);
-    assert(dest_path != NULL);
-
-    Main_Entry_Parser* main_entry_parser = Main_Entry_Parser::get_instance();
-    XMLFiles& xml_files = main_entry_parser->get_xml_files();
-
-    const char* input_file = NULL;
-    if (0 == strcmp(file_type, "input_mode_configure")) {
-        input_file = xml_files.input_mode_configure;
-    }
-    else if (0 == strcmp(file_type, "layout")) {
-        input_file = xml_files.layout;
-    }
-    else if (0 == strcmp(file_type, "label_property")) {
-        input_file = xml_files.key_label_property;
-    }
-    else if (0 == strcmp(file_type, "modifier_decoration")) {
-        input_file = xml_files.modifier_decoration;
-    }
-    else if (0 == strcmp(file_type, "default_configure")) {
-        input_file = xml_files.default_configure;
-    }
-    else if (0 == strcmp(file_type, "autopopup_configure")) {
-        input_file = xml_files.autopopup_configure;
-    }
-    else if (0 == strcmp(file_type, "magnifier_configure")) {
-        input_file = xml_files.magnifier_configure;
-    }
-    else if (0 == strcmp(file_type, "nine_patch_file_list")) {
-        input_file = xml_files.nine_patch_file_list;
-    } else {
-        printf("file_type : %s is not exist.\n", file_type);
-        assert(0);
-    }
-
-    if (input_file && dest_path) {
-        XMLResource *xml_resource = XMLResource::get_instance();
-        snprintf(dest_path, _POSIX_PATH_MAX, "%s/%s",
-            xml_resource->get_resource_directory(), input_file);
-    }
+XMLFiles&
+Main_Entry_Parser::get_xml_files() {
+    return m_impl->m_xml_files;
 }
index d128d35..e775997 100644 (file)
  *
  */
 
-#include "modifier_decoration_parser.h"
-#include "main_entry_parser.h"
 #include <memory.h>
-#include "xml_parser_utils.h"
-static int get_display_state_prop(const char*);
-static int get_key_modifier_state_prop(const char*);
-
-Modifier_decoration_Parser* Modifier_decoration_Parser::m_instance = NULL;
-
-Modifier_decoration_Parser::Modifier_decoration_Parser() {
-    memset(m_modifier_decoration_table, 0x00, sizeof(SclModifierDecoration) * MAX_SCL_MODIFIER_DECORATION_NUM);
-}
-
-Modifier_decoration_Parser::~Modifier_decoration_Parser() {
-    for(int i = 0; i < MAX_SCL_MODIFIER_DECORATION_NUM; ++i) {
-        SclModifierDecoration& cur_rec = m_modifier_decoration_table[i];
-        for (int display_state = 0; display_state < DISPLAYMODE_MAX; ++display_state ) {
-            for( int key_modifier_state = 0; key_modifier_state < KEY_MODIFIER_MAX; ++key_modifier_state) {
-                if (cur_rec.bg_image_path[display_state][key_modifier_state])
-                    delete cur_rec.bg_image_path[display_state][key_modifier_state];
-                cur_rec.bg_image_path[display_state][key_modifier_state] = NULL;
-            }
-        }
-
-    }
-}
-
-Modifier_decoration_Parser* Modifier_decoration_Parser::get_instance() {
-    if (m_instance == NULL) {
-        m_instance = new Modifier_decoration_Parser();
-    }
-    return m_instance;
-}
-void Modifier_decoration_Parser::init() {
-    parsing_modifier_decoration_table();
-}
-
-/* recompute_layout will change the table */
-PSclModifierDecoration Modifier_decoration_Parser::get_modifier_decoration_table() {
-    return m_modifier_decoration_table;
-}
-
-void Modifier_decoration_Parser::parsing_modifier_decoration_table() {
-    xmlDocPtr doc;
-    xmlNodePtr cur_node;
-
-    char input_file[_POSIX_PATH_MAX] = {0};
-    Main_Entry_Parser::get_file_full_path(input_file, "modifier_decoration");
-
-    doc = xmlReadFile(input_file, NULL, 0);
-    if (doc == NULL) {
-        printf("Could not load file.");
-        exit(1);
-    }
-    cur_node = xmlDocGetRootElement(doc);
-    if (cur_node == NULL) {
-        printf("empty document.\n");
-        xmlFreeDoc(doc);
-        exit(1);
-    }
-    if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"modifier_decoration_table"))
-    {
-       printf("root name error!");
-       xmlFreeDoc(doc);
-       exit(1);
-    }
-
-    cur_node = cur_node->xmlChildrenNode;
-
-
-    SclModifierDecoration* cur_rec = m_modifier_decoration_table;
-    while (cur_node != NULL) {
-        if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"modifier_decoration_record")) {
-            parsing_modifier_decoration_record( cur_node, cur_rec);
-            cur_rec++;
-        }
-
-        cur_node = cur_node->next;
-    }
-    xmlFreeDoc(doc);
-}
+#include <libxml/parser.h>
 
-void
-Modifier_decoration_Parser::set_modifier_decoration_default_record(const PSclModifierDecoration cur_rec) {
-    cur_rec->valid = FALSE;
-    cur_rec->extract_background = false;
-    cur_rec->name = NULL;
-    for (int display_state = 0; display_state < DISPLAYMODE_MAX; ++display_state ) {
-        for( int key_modifier_state = 0; key_modifier_state < KEY_MODIFIER_MAX; ++key_modifier_state) {
-            cur_rec->bg_image_path[display_state][key_modifier_state] = NULL;
-        }
-    }
-}
-
-void
-Modifier_decoration_Parser::parsing_modifier_decoration_record(const xmlNodePtr cur_node, const PSclModifierDecoration cur_rec) {
-    assert(cur_node != NULL);
-    assert(cur_rec != NULL);
-
-   set_modifier_decoration_default_record(cur_rec);
-
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-
-    while (child_node != NULL) {
-        if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)"name")) {
-            xmlChar* temp = xmlNodeGetContent(child_node);
-            cur_rec->name = (sclchar *)temp;
-            cur_rec->valid = TRUE;
-        }
-        else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)"display_part_background")) {
-            cur_rec->extract_background = get_content_bool(child_node);
-            cur_rec->valid = TRUE;
-        }
-        else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)"background_image_path")) {
-            parsing_background_image_record_node(child_node, cur_rec);
-            cur_rec->valid = TRUE;
-        }
-        child_node = child_node->next;
-    }
-}
-
-void
-Modifier_decoration_Parser::parsing_background_image_record_node(const xmlNodePtr cur_node, const PSclModifierDecoration cur_rec) {
-    assert(cur_node != NULL);
-    assert(cur_rec != NULL);
-    assert(0 == xmlStrcmp(cur_node->name, (const xmlChar*)"background_image_path"));
-    xmlNodePtr child_node = cur_node->xmlChildrenNode;
-
-    while (child_node != NULL) {
-        if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"image") ) {
-            /* FIXME */
-            int display_state = DISPLAYMODE_PORTRAIT;
-            xmlChar* display_state_xml = xmlGetProp(child_node, (const xmlChar*)"display_state");
-            if (display_state_xml != NULL) {
-                if (0 == xmlStrcmp(display_state_xml, (const xmlChar*)"landscape")) {
-                    display_state = DISPLAYMODE_LANDSCAPE;
-                }
-                xmlFree(display_state_xml);
-            }
-
-            int key_modifier_state = KEY_MODIFIER_NONE;
-            xmlChar* key_modifier_state_xml = xmlGetProp(child_node, (const xmlChar*)"key_modifier_state");
-            if (key_modifier_state_xml != NULL) {
-                key_modifier_state = get_key_modifier_state_prop((const char*)key_modifier_state_xml);
-                xmlFree(key_modifier_state_xml);
-            }
-
-           if (display_state != -1 && key_modifier_state != -1 ) {
-                sclchar* key = (sclchar*)xmlNodeGetContent(child_node);
-                cur_rec->bg_image_path[display_state][key_modifier_state] = key;
-                //Warning:: Donot xmlFree key
-            }
-        }
-        child_node = child_node->next;
-    }
-}
-
-int
-Modifier_decoration_Parser::get_modifier_decoration_id( const char *name )
-{
-    if (name == NULL) return -1;
-
-    for(int i = 0; i < MAX_SCL_MODIFIER_DECORATION_NUM; ++i) {
-        if ( m_modifier_decoration_table[i].name) {
-            if ( 0 == strcmp(m_modifier_decoration_table[i].name, name) ) {
-                return i;
-            }
-        }
-    }
-
-    return -1;
-}
+#include "modifier_decoration_parser.h"
+#include "xml_parser_utils.h"
+#include "simple_debug.h"
 
+static int get_key_modifier_state_prop(const char*);
 //UTILS
 typedef struct _Modifier_decoration_state_match_table{
     int modifier_decoration_state;
@@ -254,3 +89,208 @@ get_key_modifier_state_prop(const char* key ) {
     }
     return key_modifier_state;
 }
+
+class ModifierDecorationParserImpl {
+    public:
+        ModifierDecorationParserImpl() {
+            memset(m_modifier_decoration_table, 0x00, sizeof(SclModifierDecoration) * MAX_SCL_MODIFIER_DECORATION_NUM);
+        }
+
+        ~ModifierDecorationParserImpl() {
+            for(int i = 0; i < MAX_SCL_MODIFIER_DECORATION_NUM; ++i) {
+                SclModifierDecoration& cur_rec = m_modifier_decoration_table[i];
+                for (int display_state = 0; display_state < DISPLAYMODE_MAX; ++display_state ) {
+                    for( int key_modifier_state = 0; key_modifier_state < KEY_MODIFIER_MAX; ++key_modifier_state) {
+                        if (cur_rec.bg_image_path[display_state][key_modifier_state])
+                            delete cur_rec.bg_image_path[display_state][key_modifier_state];
+                        cur_rec.bg_image_path[display_state][key_modifier_state] = NULL;
+                    }
+                }
+
+            }
+        }
+
+        int parsing_modifier_decoration_table(const char* input_file) {
+            xmlDocPtr doc;
+            xmlNodePtr cur_node;
+
+            doc = xmlReadFile(input_file, NULL, 0);
+            if (doc == NULL) {
+                SCLLOG(SclLog::DEBUG, "Could not load file: %s.", input_file);
+                return -1;
+            }
+            cur_node = xmlDocGetRootElement(doc);
+            if (cur_node == NULL) {
+                SCLLOG(SclLog::DEBUG, "Modifier_decoration_Parser: empty document.\n");
+                xmlFreeDoc(doc);
+                return -1;
+            }
+            if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"modifier_decoration_table"))
+            {
+                SCLLOG(SclLog::DEBUG, "Modifier_decoration_Parser: root name error: %s\n!", (char *)cur_node->name);
+                xmlFreeDoc(doc);
+                return -1;
+            }
+
+            cur_node = cur_node->xmlChildrenNode;
+
+
+            SclModifierDecoration* cur_rec = m_modifier_decoration_table;
+
+            int size = 0;
+            while (cur_node != NULL) {
+                if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"modifier_decoration_record")) {
+                    parsing_modifier_decoration_record( cur_node, cur_rec);
+                    size++;
+                    cur_rec++;
+                    if (size >= MAX_SCL_MODIFIER_DECORATION_NUM) {
+                        SCLLOG(SclLog::ERROR, "No Space for modifier decoration record.");
+                        break;
+                    }
+                }
+
+                cur_node = cur_node->next;
+            }
+            xmlFreeDoc(doc);
+
+            return 0;
+
+        }
+
+        void parsing_modifier_decoration_record(const xmlNodePtr cur_node, const PSclModifierDecoration cur_rec) {
+            assert(cur_node != NULL);
+            assert(cur_rec != NULL);
+
+            set_modifier_decoration_default_record(cur_rec);
+
+            xmlNodePtr child_node = cur_node->xmlChildrenNode;
+
+            while (child_node != NULL) {
+                if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)"name")) {
+                    xmlChar* temp = xmlNodeGetContent(child_node);
+                    cur_rec->name = (sclchar *)temp;
+                    cur_rec->valid = TRUE;
+                }
+                else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)"display_part_background")) {
+                    cur_rec->extract_background = get_content_bool(child_node);
+                    cur_rec->valid = TRUE;
+                }
+                else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar*)"background_image_path")) {
+                    parsing_background_image_record_node(child_node, cur_rec);
+                    cur_rec->valid = TRUE;
+                }
+                child_node = child_node->next;
+            }
+
+        }
+
+        void set_modifier_decoration_default_record(const PSclModifierDecoration cur_rec) {
+            cur_rec->valid = FALSE;
+            cur_rec->extract_background = false;
+            cur_rec->name = NULL;
+            for (int display_state = 0; display_state < DISPLAYMODE_MAX; ++display_state ) {
+                for( int key_modifier_state = 0; key_modifier_state < KEY_MODIFIER_MAX; ++key_modifier_state) {
+                    cur_rec->bg_image_path[display_state][key_modifier_state] = NULL;
+                }
+            }
+        }
+
+        void parsing_background_image_record_node(const xmlNodePtr cur_node, const PSclModifierDecoration cur_rec) {
+            assert(cur_node != NULL);
+            assert(cur_rec != NULL);
+            assert(0 == xmlStrcmp(cur_node->name, (const xmlChar*)"background_image_path"));
+            xmlNodePtr child_node = cur_node->xmlChildrenNode;
+
+            while (child_node != NULL) {
+                if (0 == xmlStrcmp(child_node->name, (const xmlChar*)"image") ) {
+                    /* FIXME */
+                    int display_state = DISPLAYMODE_PORTRAIT;
+                    xmlChar* display_state_xml = xmlGetProp(child_node, (const xmlChar*)"display_state");
+                    if (display_state_xml != NULL) {
+                        if (0 == xmlStrcmp(display_state_xml, (const xmlChar*)"landscape")) {
+                            display_state = DISPLAYMODE_LANDSCAPE;
+                        }
+                        xmlFree(display_state_xml);
+                    }
+
+                    int key_modifier_state = KEY_MODIFIER_NONE;
+                    xmlChar* key_modifier_state_xml = xmlGetProp(child_node, (const xmlChar*)"key_modifier_state");
+                    if (key_modifier_state_xml != NULL) {
+                        key_modifier_state = get_key_modifier_state_prop((const char*)key_modifier_state_xml);
+                        xmlFree(key_modifier_state_xml);
+                    }
+
+                    if (display_state != -1 && key_modifier_state != -1 ) {
+                        sclchar* key = (sclchar*)xmlNodeGetContent(child_node);
+                        cur_rec->bg_image_path[display_state][key_modifier_state] = key;
+                        //Warning:: Donot xmlFree key
+                    }
+                }
+                child_node = child_node->next;
+            }
+        }
+
+        SclModifierDecoration m_modifier_decoration_table[MAX_SCL_MODIFIER_DECORATION_NUM];
+};
+
+Modifier_decoration_Parser* Modifier_decoration_Parser::m_instance = NULL;
+
+Modifier_decoration_Parser*
+Modifier_decoration_Parser::get_instance() {
+    if (m_instance == NULL) {
+        m_instance = new Modifier_decoration_Parser();
+    }
+    return m_instance;
+}
+
+Modifier_decoration_Parser::Modifier_decoration_Parser() {
+    m_impl = new ModifierDecorationParserImpl;
+    if (m_impl == NULL) {
+        SCLLOG(SclLog::ERROR, "Create Modifier_decoration_Parser failed");
+    }
+}
+
+Modifier_decoration_Parser::~Modifier_decoration_Parser() {
+    if (m_impl) {
+        SCLLOG(SclLog::MESSAGE, "~Modifier_decoration_Parser() has called");
+        delete m_impl;
+        m_impl = NULL;
+    }
+}
+
+int
+Modifier_decoration_Parser::init(const char* file) {
+    return m_impl->parsing_modifier_decoration_table(file);
+}
+
+/* recompute_layout will change the table */
+PSclModifierDecoration
+Modifier_decoration_Parser::get_modifier_decoration_table() {
+    return m_impl->m_modifier_decoration_table;
+}
+
+int
+Modifier_decoration_Parser::get_modifier_decoration_id( const char *name )
+{
+    if (name == NULL) {
+        SCLLOG(SclLog::DEBUG, "get_modifier_decoration_id() has failed");
+        return -1;
+    }
+
+    PSclModifierDecoration modifier_decoration_table = get_modifier_decoration_table();
+    if (modifier_decoration_table == NULL) {
+        SCLLOG(SclLog::DEBUG, "get_modifier_decoration_id() has failed");
+        return -1;
+    }
+    for(int i = 0; i < MAX_SCL_MODIFIER_DECORATION_NUM; ++i) {
+        if ( modifier_decoration_table[i].name) {
+            if ( 0 == strcmp(modifier_decoration_table[i].name, name) ) {
+                return i;
+            }
+        }
+    }
+
+    SCLLOG(SclLog::DEBUG, "get_modifier_decoration_id() has failed");
+    return -1;
+}
+
index 10b67d7..63d4cf9 100644 (file)
  *
  */
 
-#include "nine_patch_file_list_parser.h"
-#include "main_entry_parser.h"
-#include "xml_parser_utils.h"
 #include <memory.h>
 #include <assert.h>
+#include <libxml/parser.h>
+
+#include "nine_patch_file_list_parser.h"
+#include "xml_parser_utils.h"
+#include "simple_debug.h"
+
+class NinePatchFileListParserImpl {
+    public:
+        NinePatchFileListParserImpl() {
+            m_size = 0;
+            memset(m_nine_patch_file_list, 0x00, sizeof(SclNinePatchInfo) * MAX_NINE_PATCH_FILE_LIST);
+        }
+        ~NinePatchFileListParserImpl() {
+            for(int i = 0; i < m_size; ++i) {
+                if (m_nine_patch_file_list[i].image_path)
+                    delete m_nine_patch_file_list[i].image_path;
+                m_nine_patch_file_list[i].image_path = NULL;
+            }
+            m_size = 0;
+        }
+
+        int parsing_nine_patch_file_list(const char* input_file) {
+            xmlDocPtr doc;
+            xmlNodePtr cur_node;
+
+            doc = xmlReadFile(input_file, NULL, 0);
+            if (doc == NULL) {
+                SCLLOG(SclLog::DEBUG, "Could not load file: %s.", input_file);
+                return -1;
+            }
+
+            cur_node = xmlDocGetRootElement(doc);
+            if (cur_node == NULL) {
+                SCLLOG(SclLog::DEBUG, "Nine_Patch_File_Parser: empty document.\n");
+                xmlFreeDoc(doc);
+                return -1;
+            }
+            if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"nine_patch_file_list"))
+            {
+                SCLLOG(SclLog::DEBUG, "Nine_Patch_File_Parser: root name error: %s\n!", (char *)cur_node->name);
+                xmlFreeDoc(doc);
+                return -1;
+            }
+
+            cur_node = cur_node->xmlChildrenNode;
+
+            assert(m_size == 0);
+            while (cur_node != NULL) {
+                if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"file")) {
+                    m_nine_patch_file_list[m_size].image_path = (const char*)xmlNodeGetContent(cur_node);
+                    get_prop_number(cur_node, "left", &(m_nine_patch_file_list[m_size].left));
+                    get_prop_number(cur_node, "right", &(m_nine_patch_file_list[m_size].right));
+                    get_prop_number(cur_node, "top", &(m_nine_patch_file_list[m_size].top));
+                    get_prop_number(cur_node, "bottom", &(m_nine_patch_file_list[m_size].bottom));
+                    if (m_nine_patch_file_list[m_size].image_path == NULL) {
+                        SCLLOG(SclLog::ERROR, "Nine_patch_file_list_Parser: image_path should be not NULL");
+                    }
+                    m_size++;
+                    if (m_size >= MAX_NINE_PATCH_FILE_LIST) {
+                        SCLLOG(SclLog::ERROR, "No Space for nine patch file list record.");
+                    }
+                }
+
+                cur_node = cur_node->next;
+            }
+            xmlFreeDoc(doc);
+
+            return 0;
+
+        }
+        SclNinePatchInfo m_nine_patch_file_list[MAX_NINE_PATCH_FILE_LIST];
+        int m_size;
+
+};
 
 Nine_patch_file_list_Parser* Nine_patch_file_list_Parser::m_instance = NULL;
 
 Nine_patch_file_list_Parser::Nine_patch_file_list_Parser() {
-    m_size = 0;
-    memset(m_nine_patch_file_list, 0x00, sizeof(SclNinePatchInfo) * MAX_NINE_PATCH_FILE_LIST);
+    m_impl = new NinePatchFileListParserImpl;
+    if (m_impl == NULL) {
+        SCLLOG(SclLog::ERROR, "Create Nine_patch_file_list_Parser failed");
+    }
 }
 
 Nine_patch_file_list_Parser::~Nine_patch_file_list_Parser() {
-    for(int i = 0; i < m_size; ++i) {
-        if (m_nine_patch_file_list[i].image_path)
-            delete m_nine_patch_file_list[i].image_path;
-        m_nine_patch_file_list[i].image_path = NULL;
+    if (m_impl) {
+        SCLLOG(SclLog::MESSAGE, "~Nine_patch_file_list_Parser() has called.");
+        delete m_impl;
+        m_impl = NULL;
     }
-    m_size = 0;
 }
-Nine_patch_file_list_Parser* Nine_patch_file_list_Parser::get_instance() {
+Nine_patch_file_list_Parser*
+Nine_patch_file_list_Parser::get_instance() {
     if (m_instance == NULL) {
         m_instance = new Nine_patch_file_list_Parser();
     }
     return m_instance;
 }
-void Nine_patch_file_list_Parser::init() {
-    parsing_nine_patch_file_list();
-}
-
-void Nine_patch_file_list_Parser::parsing_nine_patch_file_list() {
-    xmlDocPtr doc;
-    xmlNodePtr cur_node;
-
-    char input_file[_POSIX_PATH_MAX] = {0};
-    Main_Entry_Parser::get_file_full_path(input_file, "nine_patch_file_list");
 
-    doc = xmlReadFile(input_file, NULL, 0);
-    if (doc == NULL) {
-        printf("Could not load file.\n");
-        exit(1);
-    }
-
-    cur_node = xmlDocGetRootElement(doc);
-    if (cur_node == NULL) {
-        printf("empty document.\n");
-        xmlFreeDoc(doc);
-        exit(1);
-    }
-    if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"nine_patch_file_list"))
-    {
-       printf("root name %s error!\n", cur_node->name);
-       xmlFreeDoc(doc);
-       exit(1);
-    }
-
-    cur_node = cur_node->xmlChildrenNode;
-
-    assert(m_size == 0);
-    while (cur_node != NULL) {
-        if (0 == xmlStrcmp(cur_node->name, (const xmlChar *)"file")) {
-            m_nine_patch_file_list[m_size].image_path = (const char*)xmlNodeGetContent(cur_node);
-            get_prop_number(cur_node, "left", &(m_nine_patch_file_list[m_size].left));
-            get_prop_number(cur_node, "right", &(m_nine_patch_file_list[m_size].right));
-            get_prop_number(cur_node, "top", &(m_nine_patch_file_list[m_size].top));
-            get_prop_number(cur_node, "bottom", &(m_nine_patch_file_list[m_size].bottom));
-            assert(m_nine_patch_file_list[m_size].image_path != NULL);
-            m_size++;
-        }
-
-        cur_node = cur_node->next;
-    }
-    xmlFreeDoc(doc);
+int
+Nine_patch_file_list_Parser::init(const char* file) {
+    return m_impl->parsing_nine_patch_file_list(file);
 }
 
 bool
 Nine_patch_file_list_Parser::get_nine_patch_info(const char* filename, SclNinePatchInfo *info) {
-    if (filename == NULL) return false;
+    if (filename == NULL) {
+        SCLLOG(SclLog::DEBUG, "get_nine_patch_info() has failed.");
+        return false;
+    }
+
+    SclNinePatchInfo *nine_patch_list = get_nine_patch_list();
+    if (nine_patch_list == NULL) {
+        SCLLOG(SclLog::DEBUG, "get_nine_patch_info() has failed.");
+        return false;
+    }
 
-    for(int i = 0; i < MAX_NINE_PATCH_FILE_LIST && i < m_size; ++i) {
-        if ( m_nine_patch_file_list[i].image_path != NULL &&
-            0 == strcmp(m_nine_patch_file_list[i].image_path, filename) ) {
+    for(int i = 0; i < MAX_NINE_PATCH_FILE_LIST && i < m_impl->m_size; ++i) {
+        if ( nine_patch_list[i].image_path != NULL &&
+            0 == strcmp(nine_patch_list[i].image_path, filename) ) {
                 if (info) {
-                    *info = m_nine_patch_file_list[i];
+                    *info = nine_patch_list[i];
                 }
             return true;
         }
     }
 
+    SCLLOG(SclLog::DEBUG, "get_nine_patch_info() has failed.");
     return false;
 
 }
 
-SclNinePatchInfo* Nine_patch_file_list_Parser::get_nine_patch_list() {
-    return m_nine_patch_file_list;
+SclNinePatchInfo*
+Nine_patch_file_list_Parser::get_nine_patch_list() {
+    return m_impl->m_nine_patch_file_list;
 }
index aba1991..7809afc 100644 (file)
  *
  */
 
-#include "xmlresource.h"
+#include <libxml/parser.h>
 #include <assert.h>
+#include <limits.h>
+#include <string.h>
+#include "xmlresource.h"
+#include "simple_debug.h"
+
 using namespace xmlresource;
 
 XMLResource* XMLResource::m_instance = NULL;
@@ -67,133 +72,285 @@ XMLResource::~XMLResource() {
     m_nine_patch_file_list_parser = NULL;
 }
 
-XMLResource* XMLResource::get_instance() {
+XMLResource*
+XMLResource::get_instance() {
     if (m_instance == NULL) {
         m_instance = new XMLResource();
     }
     return m_instance;
 }
 
-void XMLResource::init(const char *entry_filepath) {
+static void
+get_layout_files(char **layout_files, int* size) {
+    if (layout_files == NULL) return;
+    int layout_file_size = 0;
+
+    Input_Mode_Configure_Parser *input_mode_configure_parser = Input_Mode_Configure_Parser::get_instance();
+    for(int inputmode = 0; inputmode < MAX_SCL_INPUT_MODE; inputmode++) {
+        int empty_index;
+        const sclchar* cur_layout_file;
+        PSclInputModeConfigure configure_table = input_mode_configure_parser->get_input_mode_configure_table();
+        SclInputModeConfigure& cur_input_mode_configure = configure_table[inputmode];
+
+        for(int display = 0; display < DISPLAYMODE_MAX; display++) {
+            char *cur_layout_file = cur_input_mode_configure.layouts[display];
+            if (cur_layout_file == NULL) {
+                continue;
+            }
+            bool found = false;
+            int empty_index = NOT_USED;
+
+            for(int checkidx = 0; checkidx < MAX_SCL_LAYOUT; checkidx++) {
+                // not found (assert array end with null)
+                if (layout_files[checkidx] == NULL) {
+                    empty_index = checkidx;
+                    break;
+                }
+                // found layout
+                else if (strncmp(layout_files[checkidx], cur_layout_file, _POSIX_PATH_MAX) == 0) {
+                    found = true;
+                    break;
+                }
+            }
+
+            if (found) {
+                continue;
+            }
+
+            if (empty_index == NOT_USED) {
+                SCLLOG(SclLog::ERROR, "No space for new layout %s\n", cur_layout_file);
+            }
+
+            if (empty_index != NOT_USED) {
+                layout_file_size++;
+                layout_files[empty_index] = strdup(cur_layout_file);
+            }
+        }
+    }
+    if (size) {
+        *size = layout_file_size;
+    }
+}
+void
+XMLResource::init(const char *entry_filepath) {
     if (m_main_entry_parser == NULL) {
         m_main_entry_parser = Main_Entry_Parser::get_instance();
-        m_main_entry_parser->init(entry_filepath);
+        char input_file[_POSIX_PATH_MAX] = {0};
+        snprintf(input_file, _POSIX_PATH_MAX, "%s/%s", get_resource_directory(), entry_filepath);
+        if ( 0 != m_main_entry_parser->init(input_file)) {
+            /* main entry is necessary */
+            SCLLOG(SclLog::ERROR, "main entry init");
+        }
     }
-    printf("init inputmode configure\n\n");
+
+    /* get each type of xml file name */
+    XMLFiles& xml_files = m_main_entry_parser->get_xml_files();
+
+    SCLLOG(SclLog::MESSAGE, "init inputmode configure\n\n");
     if (m_input_mode_configure_parser == NULL) {
         m_input_mode_configure_parser = Input_Mode_Configure_Parser::get_instance();
-        m_input_mode_configure_parser->init();
+        char input_file[_POSIX_PATH_MAX] = {0};
+        snprintf(input_file, _POSIX_PATH_MAX, "%s/%s", get_resource_directory(), xml_files.input_mode_configure);
+        if (0 != m_input_mode_configure_parser->init(input_file)) {
+            /* input mode configure is necessary */
+            SCLLOG(SclLog::ERROR, "input mode configure init");
+        }
     }
 
-    printf("init default_configure\n\n");
+    SCLLOG(SclLog::MESSAGE, "init default_configure\n\n");
     if (m_default_configure_parser == NULL) {
         m_default_configure_parser = Default_Configure_Parser::get_instance();
-        m_default_configure_parser->init();
+        char input_file[_POSIX_PATH_MAX] = {0};
+        snprintf(input_file, _POSIX_PATH_MAX, "%s/%s", get_resource_directory(), xml_files.default_configure);
+
+        if (0 != m_default_configure_parser->init(input_file)) {
+            /* default configure is not necessary */
+            SCLLOG(SclLog::WARNING, "default configure init");
+        }
     }
 
-    printf("init modifier_decoration\n\n");
+    SCLLOG(SclLog::MESSAGE, "init modifier_decoration\n\n");
     if (m_modifier_decoration_parser == NULL) {
         m_modifier_decoration_parser = Modifier_decoration_Parser::get_instance();
-        m_modifier_decoration_parser->init();
+        char input_file[_POSIX_PATH_MAX] = {0};
+        snprintf(input_file, _POSIX_PATH_MAX, "%s/%s", get_resource_directory(), xml_files.modifier_decoration);
+
+        if (0 != m_modifier_decoration_parser->init(input_file)) {
+            /* modifier decoration is not necessary */
+            SCLLOG(SclLog::WARNING, "modifier decoration init");
+        }
     }
-    printf("init label_properties\n\n");
+    SCLLOG(SclLog::MESSAGE, "init label_properties\n\n");
     if (m_label_properties_parser == NULL) {
         m_label_properties_parser = Label_properties_Parser::get_instance();
-        m_label_properties_parser->init();
+        char input_file[_POSIX_PATH_MAX] = {0};
+        snprintf(input_file, _POSIX_PATH_MAX, "%s/%s", get_resource_directory(), xml_files.key_label_property);
+
+        if (0 != m_label_properties_parser->init(input_file)) {
+            /* label properties is not necessary */
+            SCLLOG(SclLog::WARNING, "label properties init");
+        }
     }
 
-    printf("init autopopup_configure\n\n");
+    SCLLOG(SclLog::MESSAGE, "init autopopup_configure\n\n");
     if (m_autopopup_configure_parser == NULL) {
         m_autopopup_configure_parser = AutoPopup_Configure_Parser::get_instance();
-        m_autopopup_configure_parser->init();
+        char input_file[_POSIX_PATH_MAX] = {0};
+        snprintf(input_file, _POSIX_PATH_MAX, "%s/%s", get_resource_directory(), xml_files.autopopup_configure);
+        if (0 != m_autopopup_configure_parser->init(input_file)) {
+            /* autopopup configure is not necessary */
+            SCLLOG(SclLog::WARNING, "autopopup configure init");
+        }
     }
-    printf("init magnifier_configure\n\n");
+    SCLLOG(SclLog::MESSAGE, "init magnifier_configure\n\n");
     if (m_magnifier_configure_parser == NULL) {
         m_magnifier_configure_parser = Magnifier_Configure_Parser::get_instance();
-        m_magnifier_configure_parser->init();
+        char input_file[_POSIX_PATH_MAX] = {0};
+        snprintf(input_file, _POSIX_PATH_MAX, "%s/%s", get_resource_directory(), xml_files.magnifier_configure);
+
+        if (0 != m_magnifier_configure_parser->init(input_file)) {
+            /* magnifier configure is not necessary */
+            SCLLOG(SclLog::WARNING, "magnifier configure init");
+        }
     }
 
-    printf("init nine_patch_file_list\n\n");
+    SCLLOG(SclLog::MESSAGE, "init nine_patch_file_list\n\n");
     if (m_nine_patch_file_list_parser == NULL) {
         m_nine_patch_file_list_parser = Nine_patch_file_list_Parser::get_instance();
-        m_nine_patch_file_list_parser->init();
+        char input_file[_POSIX_PATH_MAX] = {0};
+        snprintf(input_file, _POSIX_PATH_MAX, "%s/%s", get_resource_directory(), xml_files.nine_patch_file_list);
+
+        if (0 != m_nine_patch_file_list_parser->init(input_file)) {
+            /* nine patch file list is not necessary */
+            SCLLOG(SclLog::WARNING, "nine patch file list init");
+        }
     }
 
-    printf("init layout\n\n");
+    SCLLOG(SclLog::MESSAGE, "init layout\n\n");
     if (m_layout_parser == NULL) {
         m_layout_parser = Layout_Parser::get_instance();
-        m_layout_parser->init();
+        char **layout_files = NULL;
+        int layout_file_size = 0;
+
+        layout_files = (char**)malloc(sizeof(char*) * MAX_SCL_LAYOUT);
+        if (layout_files == NULL) {
+            SCLLOG(SclLog::ERROR, "layout init");
+            exit(1);
+        }
+        memset(layout_files, 0, sizeof(char*) * MAX_SCL_LAYOUT);
+
+        get_layout_files(layout_files, &layout_file_size);
+        if ( 0 != m_layout_parser->init(get_resource_directory(), layout_files, layout_file_size)) {
+            /* layout is necessary */
+            SCLLOG(SclLog::ERROR, "layout init");
+        }
+        for (int i = 0; i < layout_file_size; ++i) {
+            free(layout_files[i]);
+        }
+
+        free(layout_files);
     }
 
-    printf("leaving init\n\n");
+    SCLLOG(SclLog::MESSAGE, "init Text XML resources OK.\n\n");
 }
 
 
-void XMLResource::load(int layout_id) {
+void
+XMLResource::load(int layout_id) {
     m_layout_parser->load(layout_id);
 }
-void XMLResource::unload() {
+
+void
+XMLResource::unload() {
     m_layout_parser->unload();
 }
-bool XMLResource::loaded(int layout_id) {
+
+bool
+XMLResource::loaded(int layout_id) {
     return m_layout_parser->loaded(layout_id);
 }
 
-SclNinePatchInfo* XMLResource::get_nine_patch_list() {
+SclNinePatchInfo*
+XMLResource::get_nine_patch_list() {
     return m_nine_patch_file_list_parser->get_nine_patch_list();
 }
-XMLFiles& XMLResource::get_xml_files() {
-    return m_main_entry_parser->get_xml_files();
-}
-int XMLResource::get_labelproperty_size() {
+
+int
+XMLResource::get_labelproperty_size() {
     return m_label_properties_parser->get_size();
 }
-bool XMLResource::get_nine_patch_info(const char *filename, SclNinePatchInfo *info) {
+
+bool
+XMLResource::get_nine_patch_info(const char *filename, SclNinePatchInfo *info) {
     return m_nine_patch_file_list_parser->get_nine_patch_info(filename, info);
 }
-int XMLResource::get_inputmode_id(const char *name) {
+
+int
+XMLResource::get_inputmode_id(const char *name) {
     return m_input_mode_configure_parser->get_inputmode_id(name);
 }
-const char* XMLResource::get_inputmode_name(int id) {
+
+const char*
+XMLResource::get_inputmode_name(int id) {
     return m_input_mode_configure_parser->get_inputmode_name(id);
 }
-int XMLResource::get_inputmode_size() {
+
+int
+XMLResource::get_inputmode_size() {
     return m_input_mode_configure_parser->get_inputmode_size();
 }
-PSclInputModeConfigure XMLResource::get_input_mode_configure_table() {
+
+PSclInputModeConfigure
+XMLResource::get_input_mode_configure_table() {
     return m_input_mode_configure_parser->get_input_mode_configure_table();
 }
-int XMLResource::get_layout_id(const char *name) {
+
+int
+XMLResource::get_layout_id(const char *name) {
     return m_layout_parser->get_layout_index(name);
 }
-int XMLResource::get_layout_size() {
+
+int
+XMLResource::get_layout_size() {
     return m_layout_parser->get_layout_size();
 }
-int XMLResource::get_modifier_decoration_id(const char *name) {
+
+int
+XMLResource::get_modifier_decoration_id(const char *name) {
     return m_modifier_decoration_parser->get_modifier_decoration_id(name);
 }
-PSclLayout XMLResource::get_layout_table() {
+
+PSclLayout
+XMLResource::get_layout_table() {
     return m_layout_parser->get_layout_table();
 }
-PSclLayoutKeyCoordinatePointerTable XMLResource::get_key_coordinate_pointer_frame() {
+
+PSclLayoutKeyCoordinatePointerTable
+XMLResource::get_key_coordinate_pointer_frame() {
     return m_layout_parser->get_key_coordinate_pointer_frame();
 }
-PSclModifierDecoration XMLResource::get_modifier_decoration_table() {
+
+PSclModifierDecoration
+XMLResource::get_modifier_decoration_table() {
     return m_modifier_decoration_parser->get_modifier_decoration_table();
 }
 
-PSclLabelPropertiesTable XMLResource::get_label_properties_frame() {
+PSclLabelPropertiesTable
+XMLResource::get_label_properties_frame() {
     return m_label_properties_parser->get_label_properties_frame();
 }
 
-PSclDefaultConfigure XMLResource::get_default_configure() {
+PSclDefaultConfigure
+XMLResource::get_default_configure() {
     return m_default_configure_parser->get_default_configure();
 }
 
-PSclAutoPopupConfigure XMLResource::get_autopopup_configure() {
+PSclAutoPopupConfigure
+XMLResource::get_autopopup_configure() {
     return m_autopopup_configure_parser->get_autopopup_configure();
 }
 
-PSclMagnifierWndConfigure XMLResource::get_magnifier_configure() {
+PSclMagnifierWndConfigure
+XMLResource::get_magnifier_configure() {
     return m_magnifier_configure_parser->get_magnifier_configure();
 }