tizen beta release
[framework/web/wrt-installer.git] / src / misc / wrt_powder_info_util.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    wrt_powder_info_util.h
18  * @author  Justyna Mejzner (j.kwiatkowsk@samsung.com)
19  * @version 1.0
20  */
21
22 #include "wrt_powder_info_util.h"
23 #include <dpl/singleton_impl.h>
24 IMPLEMENT_SINGLETON(PowderInfoUtil)
25
26 PowderInfoUtil::PowderInfoUtil()
27 {
28     m_categories[DPL::FromUTF8String("nu")] = "Nudity";
29     m_categories[DPL::FromUTF8String("se")] = "Sex";
30     m_categories[DPL::FromUTF8String("vi")] = "Violence";
31     m_categories[DPL::FromUTF8String("la")] = "Potentially offensive language";
32     m_categories[DPL::FromUTF8String("dr")] = "Drug use";
33     m_categories[DPL::FromUTF8String("ga")] = "Gambling";
34     m_categories[DPL::FromUTF8String("ha")] = "Hate or harmful activities";
35     m_categories[DPL::FromUTF8String("ug")] = "Use of user-generated content";
36
37     m_contexts[DPL::FromUTF8String("xa")] = "This material appears in"
38         " an artistic conteaxt";
39     m_contexts[DPL::FromUTF8String("xb")] = "This material appears in"
40         " an educational context";
41     m_contexts[DPL::FromUTF8String("xc")] = "This material appears in"
42         " a medical context";
43     m_contexts[DPL::FromUTF8String("xd")] = "This material appears in"
44         " a sports context";
45     m_contexts[DPL::FromUTF8String("xe")] = "This material appears in"
46         " a violent context";
47 }
48
49 std::string PowderInfoUtil::getCategoryLabel(const DPL::String &category) const
50 {
51     CategoryMap::const_iterator categoryIterator = m_categories.find(category);
52     if (categoryIterator == m_categories.end()) {
53         ThrowMsg(PowderException::IncorrectTypeError,
54                  "Wrong type of category.");
55     }
56     return categoryIterator->second;
57 }
58
59 std::string PowderInfoUtil::getContextLabel(const DPL::String &context) const
60 {
61     ContextMap::const_iterator contextIterator = m_contexts.find(context);
62     if (contextIterator == m_contexts.end()) {
63         ThrowMsg(PowderException::IncorrectTypeError, "Wrong type of context.");
64     }
65     return contextIterator->second;
66 }
67