Source code formating unification
[platform/framework/web/wrt.git] / src / view / common / view_logic_custom_header_support.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    view_logic_custom_header_support.cpp
18  * @author  Jihoon Chung (jihoon.chung@samsung.com)
19  * @brief   Implementation file of CustomHeaderSupport API used by ViewLogic
20  */
21
22 #include "view_logic_custom_header_support.h"
23
24 #include <vconf.h>
25 #include <vconf-keys.h>
26
27 #include <string>
28 #include <dpl/log/log.h>
29
30 namespace {
31 const std::string LANGUAGE_EN = "en";
32 };
33
34 namespace ViewModule {
35 namespace CustomHeaderSupport {
36 std::string getValueByField(const std::string field)
37 {
38     LogDebug("Field : " << field);
39     std::string ret;
40
41     if (field == ACCEPT_LANGUAGE) {
42         char *systemLanguageSet = NULL;
43         systemLanguageSet = vconf_get_str(VCONFKEY_LANGSET);
44         LogDebug("system language = [" << systemLanguageSet << "]");
45
46         if (!systemLanguageSet) {
47             LogError("Failed to get VCONFKEY_LANGSET. set as English");
48             ret.append(LANGUAGE_EN);
49         } else {
50             // copy first 2bytes of language set (en, ko, po)
51             ret.append(systemLanguageSet, 2);
52         }
53
54         if (systemLanguageSet) {
55             free(systemLanguageSet);
56         }
57     } else {
58         LogError("Wrong field is passed");
59         Assert(false);
60     }
61
62     return ret;
63 }
64 } // namespace CustomHeaderSupport
65 } // namespace ViewModule