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.
18 #include "resource_storage_impl.h"
19 #include "encode_input_mode_configure.h"
21 #include <libxml/parser.h>
22 #include "xmlresource.h"
23 #include "imetadata_helper.h"
24 #include "put_record.h"
25 #include "_auto_metadata.h"
27 using namespace xmlresource;
30 encode_input_mode_configure_record(ResourceStorage& storage, const PSclInputModeConfigure cur, const Input_mode_configure_width& record_width) {
32 storage.encode_string(cur->name, record_width.name);
34 storage.encode_string(cur->layouts[0], record_width.layout_portrait);
36 storage.encode_string(cur->layouts[1], record_width.layout_landscape);
38 storage.put<sint_t>(cur->use_virtual_window, record_width.use_virtual_window);
40 storage.put<sint_t>(cur->use_dim_window, record_width.use_dim_window);
42 storage.put<sint_t>(cur->timeout, record_width.timeout);
45 int encode_input_mode_configure_file(ResourceStorage& storage, IMetaData_Helper& md_helper) {
46 int init_size = storage.get_size();
48 const int INPUT_MODE_CONFIGURE_SIZE_WIDTH = 4;
51 XMLResource *xmlresource = XMLResource::get_instance();
52 PSclInputModeConfigure inputModeConfigureTable = xmlresource->get_input_mode_configure_table();
53 int size = xmlresource->get_inputmode_size();
54 #ifdef __SCL_TXT_DEBUG
55 put_input_mode_configure_table(ENCODE, inputModeConfigureTable);
58 PSclInputModeConfigure cur = inputModeConfigureTable;
60 //first 8 byte is the size of the block
62 storage.put<sint_t>(size, INPUT_MODE_CONFIGURE_SIZE_WIDTH);
64 Input_mode_configure_width record_width;
65 set_input_mode_configure_width(md_helper, record_width);
66 for ( int i = 0; i < size; ++i ) {
67 encode_input_mode_configure_record(storage, cur, record_width);
71 int advance_size = storage.get_size() - init_size;
72 storage.random_put<sint_t>(advance_size, 8, init_size);
73 return storage.get_size();
76 int encode_input_mode_configure_file(const char* file, int& offset, IMetaData_Helper& md_helper) {
79 ResourceStorage storage;
80 encode_input_mode_configure_file(storage, md_helper);
81 storage.toFile(file, offset);
83 return storage.get_size();
86 int encode_input_mode_configure_file(const char* file, IMetaData_Helper& md_helper) {
89 ResourceStorage storage;
90 encode_input_mode_configure_file(storage, md_helper);
93 return storage.get_size();