2 * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <libxml/parser.h>
22 #include "main_entry_parser.h"
23 #include "xml_parser_utils.h"
24 #include "simple_debug.h"
28 class MainEntryParserImpl {
30 int parsing_main_entry(const char *input_file) {
34 doc = xmlReadFile(input_file, NULL, 0);
39 cur_node = xmlDocGetRootElement(doc);
40 if (cur_node == NULL) {
44 if (0 != xmlStrcmp(cur_node->name, (const xmlChar*)"main-entry"))
50 make_xml_files(cur_node);
56 int reload_main_entry(const char *input_file) {
58 return parsing_main_entry(input_file);
60 void make_xml_files(const xmlNodePtr p_node) {
61 assert(p_node != NULL);
62 xmlNodePtr node = p_node->xmlChildrenNode;
63 while (node != NULL) {
64 if (0 == xmlStrcmp(node->name, (const xmlChar *)"files")) {
65 parsing_files_node(node);
71 void parsing_files_node(const xmlNodePtr p_node) {
72 assert(p_node != NULL);
73 xmlNodePtr node = p_node->xmlChildrenNode;
75 while (node != NULL) {
76 if (0 == xmlStrcmp(node->name, (const xmlChar *)"input-mode-configure")) {
77 m_xml_files.input_mode_configure = (char*)xmlNodeGetContent(node);
78 } else if (0 == xmlStrcmp(node->name, (const xmlChar *)"layout")) {
79 m_xml_files.layout = (char*)xmlNodeGetContent(node);
80 } else if (0 == xmlStrcmp(node->name, (const xmlChar *)"key-label-property")) {
81 m_xml_files.key_label_property = (char*)xmlNodeGetContent(node);
82 } else if (0 == xmlStrcmp(node->name, (const xmlChar *)"modifier-decoration")) {
83 m_xml_files.modifier_decoration = (char*)xmlNodeGetContent(node);
84 } else if (0 == xmlStrcmp(node->name, (const xmlChar *)"default-configure")) {
85 m_xml_files.default_configure = (char*)xmlNodeGetContent(node);
86 } else if (0 == xmlStrcmp(node->name, (const xmlChar *)"autopopup-configure")) {
87 m_xml_files.autopopup_configure = (char*)xmlNodeGetContent(node);
88 } else if (0 == xmlStrcmp(node->name, (const xmlChar *)"magnifier-configure")) {
89 m_xml_files.magnifier_configure = (char*)xmlNodeGetContent(node);
90 } else if (0 == xmlStrcmp(node->name, (const xmlChar *)"nine-patch-file-list")) {
91 m_xml_files.nine_patch_file_list = (char*)xmlNodeGetContent(node);
99 MainEntryParser::MainEntryParser() {
100 m_impl = new MainEntryParserImpl;
103 MainEntryParser::~MainEntryParser() {
110 MainEntryParser::get_instance() {
111 static MainEntryParser instance;
116 MainEntryParser::init(const char* path) {
117 return m_impl->parsing_main_entry(path);
121 MainEntryParser::reload(const char* path) {
122 return m_impl->reload_main_entry(path);
126 MainEntryParser::get_xml_files() {
127 return m_impl->m_xml_files;