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 the following conditions:
37 * - the Widget Id matches the Widget Id of an installed widget
38 * - the Widget version number is greater (as a compared string) than that of the installed widget, or no version
39 * information was provided for the installed widget
41 * To ensure that a string comparison of widget versions can reliably determine which version is an updated widget,
42 * WAC will mandate a specific version string format for WAC widgets. All widgets coming through the WAC channel
43 * will be required to have version strings in this format. Side-loaded widgets may have any format and, in this
44 * case, there is no requirement that the WRT support version detection for update of these widgets.
46 * The widget version format is the rec-version-tag grammar as described in [Widget Packaging]:
48 * rec-version-tag = 1*DIGIT "." 1*DIGIT [ "." 1*DIGIT] *[ 1*ALPHA / SP / 1*DIGIT ]
50 * Examples of rec-version-tag:
56 * WL-3371 The WRT MUST use the following widget version comparison algorithm to compare WAC widget version strings:
58 * - prepare the version strings for comparison:
59 * - all leading zeros are discarded
60 * - the optional *[ 1*ALPHA / SP / 1*DIGIT ] part, if present, is discarded
61 * - the resulting numbers are then in the format major.minor[.micro]
62 * - Version A = Amajor.Aminor[.Amicro] is equal to Version B = Bmajor.Bminor[.Bmicro] if and only if:
65 * - both Amicro and Bmicro are present and Amicro == Bmicro; or both Amicro and Bmicro are absent.
66 * - Version A = Amajor.Aminor[.Amicro] is greater than Version B = Bmajor.Bminor[.Bmicro] if and only if:
67 * - Amajor > Bmajor; or
68 * - Amajor Bmajor && Aminor > Bminor; or
69 * - Amajor Bmajor && Aminor == Bminor && both Amicro and Bmicro are present and Amicro > Bmicro; or Bmicro is absent.
79 DPL::Optional<DPL::String> m_micro;
80 DPL::Optional<DPL::String> m_optional;
82 void WacCertify(const DPL::String &major,
83 const DPL::String &minor,
84 const DPL::Optional<DPL::String> µ,
85 const DPL::Optional<DPL::String> &optional);
88 explicit WidgetVersion(const DPL::String &str = DPL::String());
89 WidgetVersion(const DPL::String &major,
90 const DPL::String &minor,
91 const DPL::Optional<DPL::String> µ,
92 const DPL::Optional<DPL::String> &optional);
95 const DPL::String &Raw() const;
97 const DPL::String &Major() const;
98 const DPL::String &Minor() const;
99 const DPL::Optional<DPL::String> &Micro() const;
100 const DPL::Optional<DPL::String> &Optional() const;
103 bool operator<(const WidgetVersion &left,
104 const WidgetVersion &right);
105 bool operator<=(const WidgetVersion &left,
106 const WidgetVersion &right);
107 bool operator>(const WidgetVersion &left,
108 const WidgetVersion &right);
109 bool operator>=(const WidgetVersion &left,
110 const WidgetVersion &right);
111 bool operator==(const WidgetVersion &left,
112 const WidgetVersion &right);
113 bool operator!=(const WidgetVersion &left,
114 const WidgetVersion &right);
115 std::ostream & operator<<(std::ostream& stream,
116 const WidgetVersion& version);
118 #endif // WIDGET_VERSION_H