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 widget_version.h
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20 * @brief Header file for widget version
22 #ifndef WIDGET_VERSION_H
23 #define WIDGET_VERSION_H
25 #include <dpl/string.h>
26 #include <dpl/optional.h>
30 * Note: This class also support non-WAC compliant version numbers
32 * WAC Waikiki Beta Release Core Specification: Widget Runtime
35 * WL-3370 The WRT MUST process widget packages as an update when received under
36 * the following conditions:
38 * - the Widget Id matches the Widget Id of an installed widget
39 * - the Widget version number is greater (as a compared string) than that of
40 * the installed widget, or no version
41 * information was provided for the installed widget
43 * To ensure that a string comparison of widget versions can reliably determine
44 * which version is an updated widget,
45 * WAC will mandate a specific version string format for WAC widgets. All
46 * widgets coming through the WAC channel
47 * will be required to have version strings in this format. Side-loaded widgets
48 * may have any format and, in this
49 * case, there is no requirement that the WRT support version detection for
50 * update of these widgets.
52 * The widget version format is the rec-version-tag grammar as described in
55 * rec-version-tag = 1*DIGIT "." 1*DIGIT [ "." 1*DIGIT] *[ 1*ALPHA / SP /
58 * Examples of rec-version-tag:
64 * WL-3371 The WRT MUST use the following widget version comparison algorithm to
65 * compare WAC widget version strings:
67 * - prepare the version strings for comparison:
68 * - all leading zeros are discarded
69 * - the optional *[ 1*ALPHA / SP / 1*DIGIT ] part, if present, is discarded
70 * - the resulting numbers are then in the format major.minor[.micro]
71 * - Version A = Amajor.Aminor[.Amicro] is equal to Version B =
72 * Bmajor.Bminor[.Bmicro] if and only if:
75 * - both Amicro and Bmicro are present and Amicro == Bmicro; or both Amicro
76 * and Bmicro are absent.
77 * - Version A = Amajor.Aminor[.Amicro] is greater than Version B =
78 * Bmajor.Bminor[.Bmicro] if and only if:
79 * - Amajor > Bmajor; or
80 * - Amajor Bmajor && Aminor > Bminor; or
81 * - Amajor Bmajor && Aminor == Bminor && both Amicro and Bmicro are present
82 * and Amicro > Bmicro; or Bmicro is absent.
92 DPL::Optional<DPL::String> m_micro;
93 DPL::Optional<DPL::String> m_optional;
95 void WacCertify(const DPL::String &major,
96 const DPL::String &minor,
97 const DPL::Optional<DPL::String> µ,
98 const DPL::Optional<DPL::String> &optional);
101 explicit WidgetVersion(const DPL::String &str = DPL::String());
102 WidgetVersion(const DPL::String &major,
103 const DPL::String &minor,
104 const DPL::Optional<DPL::String> µ,
105 const DPL::Optional<DPL::String> &optional);
108 const DPL::String &Raw() const;
110 const DPL::String &Major() const;
111 const DPL::String &Minor() const;
112 const DPL::Optional<DPL::String> &Micro() const;
113 const DPL::Optional<DPL::String> &Optional() const;
116 bool operator<(const WidgetVersion &left,
117 const WidgetVersion &right);
118 bool operator<=(const WidgetVersion &left,
119 const WidgetVersion &right);
120 bool operator>(const WidgetVersion &left,
121 const WidgetVersion &right);
122 bool operator>=(const WidgetVersion &left,
123 const WidgetVersion &right);
124 bool operator==(const WidgetVersion &left,
125 const WidgetVersion &right);
126 bool operator!=(const WidgetVersion &left,
127 const WidgetVersion &right);
128 std::ostream & operator<<(std::ostream& stream,
129 const WidgetVersion& version);
131 #endif // WIDGET_VERSION_H