tizen beta release
[framework/web/wrt-installer.git] / src / 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
25 using namespace WrtDB;
26
27 namespace {
28 const std::string XML_NAMESPACE = "";
29
30 const std::string TOKEN_LIBRARY_NAME = "library-name";
31 const std::string TOKEN_FEATURE_INSTALL_URI = "feature-install-uri";
32 const std::string TOKEN_FEATURE_KEY_CN = "feature-key-cn";
33 const std::string TOKEN_FEATURE_ROOT_CN = "feature-root-cn";
34 const std::string TOKEN_FEATURE_ROOT_FINGERPRINT = "feature-root-fingerprint";
35 const std::string TOKEN_API_FEATURE = "api-feature";
36 const std::string TOKEN_NAME = "name";
37 const std::string TOKEN_DEVICECAPABILITY = "device-capability";
38 }
39
40 PluginMetafileReader::PluginMetafileReader() : m_parserSchema(this)
41 {
42     m_parserSchema.addEndTagCallback(
43         TOKEN_LIBRARY_NAME,
44         XML_NAMESPACE,
45         &PluginMetafileReader::tokenEndLibraryName);
46
47     m_parserSchema.addEndTagCallback(
48         TOKEN_FEATURE_INSTALL_URI,
49         XML_NAMESPACE,
50         &PluginMetafileReader::tokenEndFeatureInstallURI);
51
52     m_parserSchema.addEndTagCallback(
53         TOKEN_FEATURE_KEY_CN,
54         XML_NAMESPACE,
55         &PluginMetafileReader::tokenEndFeatureKeyCN);
56
57     m_parserSchema.addEndTagCallback(
58         TOKEN_FEATURE_ROOT_CN,
59         XML_NAMESPACE,
60         &PluginMetafileReader::tokenEndFeatureRootCN);
61
62     m_parserSchema.addEndTagCallback(
63         TOKEN_FEATURE_ROOT_FINGERPRINT,
64         XML_NAMESPACE,
65         &PluginMetafileReader::tokenEndFeatureRootFingerprint);
66
67     m_parserSchema.addEndTagCallback(
68         TOKEN_API_FEATURE,
69         XML_NAMESPACE,
70         &PluginMetafileReader::tokenEndApiFeature);
71
72     m_parserSchema.addEndTagCallback(
73         TOKEN_NAME,
74         XML_NAMESPACE,
75         &PluginMetafileReader::tokenEndName);
76
77     m_parserSchema.addEndTagCallback(
78         TOKEN_DEVICECAPABILITY,
79         XML_NAMESPACE,
80         &PluginMetafileReader::tokenEndDeviceCapability);
81 }
82
83 void PluginMetafileReader::blankFunction(PluginMetafileData & /* data */)
84 {
85 }
86
87 void PluginMetafileReader::tokenEndLibraryName(PluginMetafileData &data)
88 {
89     data.m_libraryName = m_parserSchema.getText();
90 }
91
92 void PluginMetafileReader::tokenEndFeatureInstallURI(PluginMetafileData &data)
93 {
94     data.m_featuresInstallURI = m_parserSchema.getText();
95 }
96
97 void PluginMetafileReader::tokenEndFeatureKeyCN(PluginMetafileData &data)
98 {
99     data.m_featuresKeyCN = m_parserSchema.getText();
100 }
101
102 void PluginMetafileReader::tokenEndFeatureRootCN(PluginMetafileData &data)
103 {
104     data.m_featuresRootCN = m_parserSchema.getText();
105 }
106
107 void PluginMetafileReader::tokenEndFeatureRootFingerprint(
108         PluginMetafileData &data)
109 {
110     data.m_featuresRootFingerprint = m_parserSchema.getText();
111 }
112
113 void PluginMetafileReader::tokenEndApiFeature(PluginMetafileData &data)
114 {
115     data.m_featureContainer.insert(m_feature);
116 }
117
118 void PluginMetafileReader::tokenEndName(PluginMetafileData & /* data */)
119 {
120     m_feature.m_name = m_parserSchema.getText();
121 }
122
123 void PluginMetafileReader::tokenEndDeviceCapability(PluginMetafileData& /*data*/)
124 {
125     m_feature.m_deviceCapabilities.insert(m_parserSchema.getText());
126 }
127