Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_mobile / plugins-installer / 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_API_FEATURE = "api-feature";
32 const std::string TOKEN_NAME = "name";
33 const std::string TOKEN_DEVICECAPABILITY = "device-capability";
34 }
35
36 PluginMetafileReader::PluginMetafileReader() : m_parserSchema(this)
37 {
38     m_parserSchema.addEndTagCallback(
39         TOKEN_LIBRARY_NAME,
40         XML_NAMESPACE,
41         &PluginMetafileReader::tokenEndLibraryName);
42
43     m_parserSchema.addEndTagCallback(
44         TOKEN_API_FEATURE,
45         XML_NAMESPACE,
46         &PluginMetafileReader::tokenEndApiFeature);
47
48     m_parserSchema.addEndTagCallback(
49         TOKEN_NAME,
50         XML_NAMESPACE,
51         &PluginMetafileReader::tokenEndName);
52
53     m_parserSchema.addEndTagCallback(
54         TOKEN_DEVICECAPABILITY,
55         XML_NAMESPACE,
56         &PluginMetafileReader::tokenEndDeviceCapability);
57 }
58
59 void PluginMetafileReader::blankFunction(PluginMetafileData & /* data */)
60 {}
61
62 void PluginMetafileReader::tokenEndLibraryName(PluginMetafileData &data)
63 {
64     data.m_libraryName = m_parserSchema.getText();
65 }
66
67 void PluginMetafileReader::tokenEndApiFeature(PluginMetafileData &data)
68 {
69     data.m_featureContainer.insert(m_feature);
70     m_feature.m_deviceCapabilities.clear();
71 }
72
73 void PluginMetafileReader::tokenEndName(PluginMetafileData & /* data */)
74 {
75     m_feature.m_name = m_parserSchema.getText();
76 }
77
78 void PluginMetafileReader::tokenEndDeviceCapability(PluginMetafileData& /*data*/)
79 {
80     m_feature.m_deviceCapabilities.insert(m_parserSchema.getText());
81 }
82