Update User Agent String
[framework/web/wrt-commons.git] / modules / localization / include / dpl / localization / localization_utils.h
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    localization_utils.h
18  * @author  Bartosz Janiak (b.janiak@samsung.com)
19  * @version 1.0
20  */
21
22 #ifndef LOCALIZATION_UTILS_H
23 #define LOCALIZATION_UTILS_H
24
25 #include <list>
26
27 #include <dpl/log/log.h>
28 #include <dpl/optional.h>
29 #include <dpl/read_write_mutex.h>
30 #include <dpl/string.h>
31
32 /**
33  * WidgetIcon
34  * Structure to hold information about widget icon.
35  */
36
37 struct WidgetIcon
38 {
39     WidgetIcon() :
40         width(DPL::Optional<int>::Null),
41         height(DPL::Optional<int>::Null)
42     {
43     }
44
45     /*
46      * a valid URI to an image file inside the widget package that represents an
47      * iconic representation of the widget
48      */
49     DPL::String src;
50     DPL::Optional<int> width;       /// the width of the icon in pixels
51     DPL::Optional<int> height;      /// the height of the icon in pixels
52
53     bool operator==(const WidgetIcon &other) const
54     {
55         return src == other.src;
56     }
57 };
58
59 struct WidgetStartFileInfo
60 {
61     DPL::String file;
62     DPL::String localizedPath;
63     DPL::String encoding;
64     DPL::String type;
65
66     bool operator==(const WidgetStartFileInfo& other) const
67     {
68         return file == other.file &&
69                localizedPath == other.localizedPath &&
70                encoding == other.encoding &&
71                type == other.type;
72     }
73 };
74
75 typedef DPL::Optional<WidgetIcon> OptionalWidgetIcon;
76 typedef std::list<DPL::String> LanguageTagsList;
77 typedef DPL::Optional<WidgetStartFileInfo> OptionalWidgetStartFileInfo;
78
79 namespace LocalizationUtils {
80 DPL::String BCP47LanguageTagToLocale(const DPL::String&);
81 DPL::String LocaleToBCP47LanguageTag(const DPL::String&);
82
83 void SetSystemLanguageTags(const LanguageTagsList& tags);
84 LanguageTagsList GetUserAgentLanguageTags();
85 }
86 #endif //LOCALIZATION_UTILS_H