ddef78d26abe8ece9dd6a2ef8ed7d7be47d2b452
[apps/home/wrt-setting.git] / webapp-detail / tizen_feature.cpp
1 /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
4   * Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 #include <dpl/foreach.h>
18
19 #include "tizen_feature.h"
20 #include "util.h"
21
22 namespace WebAppDetailSetting {
23
24 const char *TizenFeature::m_feature[] = {
25     "http://tizen.org/api/application",
26     "http://tizen.org/api/time",
27     "http://tizen.org/api/contact",
28     "http://tizen.org/api/calendar",
29     "http://tizen.org/api/call",
30     "http://tizen.org/api/messaging",
31     "http://tizen.org/api/bluetooth",
32     "http://tizen.org/api/geocoder",
33     "http://tizen.org/api/nfc",
34     "http://tizen.org/api/sensors",
35     "http://tizen.org/api/systeminfo",
36 };
37
38 /* FIXME: i18n */
39 const char *TizenFeature::m_featureName[] = {
40     N_("Installed application"),
41     N_("Timezone"),
42     N_("Contacts"),
43     N_("Calendar"),
44     N_("Call Log"),
45     N_("Messaging"),
46     N_("Bluetooth"),
47     N_("Geocoder"),
48     N_("NFC"),
49     N_("Sensor"),
50     N_("System infomation"),
51 };
52
53 std::map<int, Feature> TizenFeature::getFeatureMap(
54         WrtDB::DbWidgetFeatureSet &features)
55 {
56     std::string uri;
57     std::map<int, Feature> featureMap;
58     unsigned int i;
59
60     FOREACH(feature, features) {
61         for (i = 0; i < sizeof(m_feature) / sizeof(*m_feature); i++) {
62             if (featureMap.find(i) != featureMap.end())
63                 continue;
64
65             uri = DPL::ToUTF8String(feature->name);
66             if (!uri.compare(0,
67                         strlen(m_feature[i]),
68                         m_feature[i])) {
69                 featureMap[i] = Feature(m_featureName[i],
70                                 uri.c_str());
71                 break;
72             }
73         }
74     }
75
76     return featureMap;
77 }
78
79 } /* WebAppDetailSetting */