2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file view_logic_user_agent_support.cpp
18 * @author Jaroslaw Osmanski (j.osmanski@samsung.com)
19 * @brief Implementation file of UserAgent API used by ViewLogic
22 #include "view_logic_user_agent_support.h"
25 #include <vconf-keys.h>
28 #include <dpl/log/log.h>
29 #include <dpl/wrt-dao-ro/global_dao_read_only.h>
32 // TODO: remove this after ua is fixed...
33 const std::string USERAGENT_KEY = VCONFKEY_BROWSER_BROWSER_USER_AGENT;
34 const std::string SYSTEM_USER_AGENT = "System user agent";
37 namespace ViewModule {
38 namespace UserAgentSupport {
39 std::string getUserAgentFromVconf()
41 using namespace WrtDB;
42 char* vconfValue = vconf_get_str(USERAGENT_KEY.c_str());
43 std::string userAgentName;
46 userAgentName = "Tizen";
48 userAgentName = vconfValue;
51 LogDebug("userAgentName: " << userAgentName);
52 std::string userAgent;
54 if (userAgentName == SYSTEM_USER_AGENT) {
55 char* adminUAgent = NULL;
56 adminUAgent = vconf_get_str(VCONFKEY_BROWSER_USER_AGENT);
58 if (NULL == adminUAgent || 0 == strlen(adminUAgent)) {
59 LogError("Fail to get agent value. Default agent will be set");
60 userAgentName = "Tizen";
62 GlobalDAOReadOnly::GetUserAgentValue(
63 DPL::FromUTF8String(userAgentName));
64 userAgent = DPL::ToUTF8String(value);
66 userAgent = adminUAgent;
70 GlobalDAOReadOnly::GetUserAgentValue(DPL::FromUTF8String(
72 userAgent = DPL::ToUTF8String(value);
73 LogDebug("value : " << value);
75 LogDebug("UA:[" << userAgentName << "] UA string:[" << userAgent);
79 } // namespace ViewModule
80 } // namespace UserAgentSupport