Initialize Tizen 2.3
[framework/web/wrt-installer.git] / src_mobile / jobs / plugin_install / plugin_metafile_reader.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /**
17  * @file        plugin_metafile_reader.cpp
18  * @author      Grzegorz Krawczyk(g.krawczyk@samsung.com)
19  * @version     1.0
20  * @brief
21  */
22
23 #include "plugin_metafile_reader.h"
24 #include <plugin_path.h>
25
26 using namespace WrtDB;
27
28 namespace {
29 const std::string XML_NAMESPACE = "";
30
31 const std::string TOKEN_LIBRARY_NAME = "library-name";
32 const std::string TOKEN_API_FEATURE = "api-feature";
33 const std::string TOKEN_NAME = "name";
34 const std::string TOKEN_DEVICECAPABILITY = "device-capability";
35 }
36
37 PluginMetafileReader::PluginMetafileReader() : m_parserSchema(this)
38 {
39     m_parserSchema.addEndTagCallback(
40         TOKEN_LIBRARY_NAME,
41         XML_NAMESPACE,
42         &PluginMetafileReader::tokenEndLibraryName);
43
44     m_parserSchema.addEndTagCallback(
45         TOKEN_API_FEATURE,
46         XML_NAMESPACE,
47         &PluginMetafileReader::tokenEndApiFeature);
48
49     m_parserSchema.addEndTagCallback(
50         TOKEN_NAME,
51         XML_NAMESPACE,
52         &PluginMetafileReader::tokenEndName);
53
54     m_parserSchema.addEndTagCallback(
55         TOKEN_DEVICECAPABILITY,
56         XML_NAMESPACE,
57         &PluginMetafileReader::tokenEndDeviceCapability);
58 }
59
60 void PluginMetafileReader::initialize(const PluginPath &filename)
61 {
62     m_parserSchema.initialize(filename.Fullpath(),
63                               true,
64                               ValidationCore::SaxReader::VALIDATION_DTD,
65                               std::string());
66 }
67
68 void PluginMetafileReader::read(WrtDB::PluginMetafileData &data)
69 {
70     m_parserSchema.read(data);
71 }
72
73 void PluginMetafileReader::blankFunction(PluginMetafileData & /* data */)
74 {}
75
76 void PluginMetafileReader::tokenEndLibraryName(PluginMetafileData &data)
77 {
78     data.m_libraryName = m_parserSchema.getText();
79 }
80
81 void PluginMetafileReader::tokenEndApiFeature(PluginMetafileData &data)
82 {
83     data.m_featureContainer.insert(m_feature);
84     m_feature.m_deviceCapabilities.clear();
85 }
86
87 void PluginMetafileReader::tokenEndName(PluginMetafileData & /* data */)
88 {
89     m_feature.m_name = m_parserSchema.getText();
90 }
91
92 void PluginMetafileReader::tokenEndDeviceCapability(PluginMetafileData& /*data*/)
93 {
94     m_feature.m_deviceCapabilities.insert(m_parserSchema.getText());
95 }
96