2 Copyright (c) 2013, Ford Motor Company
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
8 Redistributions of source code must retain the above copyright notice, this
9 list of conditions and the following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice,
12 this list of conditions and the following
13 disclaimer in the documentation and/or other materials provided with the
16 Neither the name of the Ford Motor Company nor the names of its contributors
17 may be used to endorse or promote products derived from this software
18 without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
33 #ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_TYPES_H_
34 #define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_TYPES_H_
40 #include "utils/shared_ptr.h"
44 // TODO(PV): specify errors
45 enum PolicyErrorEnum {
48 const std::string kDefaultDeviceMacAddress = "00:00:00:00:00:00";
49 const std::string kDefaultDeviceName = "MyDevice";
52 * @brief Constants for special ids in application policies section of
55 const std::string kPreDataConsentId = "pre_DataConsent";
56 const std::string kDefaultId = "default";
57 const std::string kDeviceId = "device";
60 *@brief Policy Services specifies Users of Updates
61 * received from cloud through mobile device
63 enum PolicyServiceTypes {
70 * @brief Status of policy table update
72 enum PolicyTableStatus {
79 // Code generator uses String class name, so this typedef was renamed to PTSring
80 typedef std::string PTString;
81 typedef std::vector<uint8_t> BinaryMessage;
82 typedef utils::SharedPtr<BinaryMessage> BinaryMessageSptr;
84 typedef std::string HMILevel;
85 typedef std::string Parameter;
86 typedef std::string RpcName;
88 typedef std::map<std::string, std::set<policy::HMILevel> > HMIPermissions;
89 typedef std::map<std::string, std::set<policy::Parameter> > ParameterPermissions;
91 struct RpcPermissions {
92 HMIPermissions hmi_permissions;
93 ParameterPermissions parameter_permissions;
96 typedef std::map<RpcName, RpcPermissions> Permissions;
99 * @brief Typedef for use with AllowApp request/notification
101 typedef std::vector<std::string> PermissionsList;
104 * @brief Typedef for getting initial application data, e.g. nickname list
106 typedef std::vector<std::string> StringArray;
115 * @struct Stores result of check:
116 * if HMI Level was allowed for RPC to work in
117 * and list of parameters allowed for RPC if specified in PT.
119 struct CheckPermissionResult {
120 CheckPermissionResult()
121 : hmi_level_permitted(kRpcDisallowed) {
124 PermitResult hmi_level_permitted;
125 utils::SharedPtr<std::vector<PTString> > list_of_allowed_params;
129 @struct Holds Url string and optional policy app id.
131 struct EndpointData {
132 explicit EndpointData(const std::string& url_string = "")
134 , app_id("default") {}
139 typedef std::vector<EndpointData> EndpointUrls;
142 * @brief Struct contains device data to be used for dialogs, generation of IDs
144 struct DeviceParams {
146 : device_name(kDefaultDeviceName),
147 device_mac_address(kDefaultDeviceMacAddress),
151 std::string device_name;
152 std::string device_mac_address;
153 uint32_t device_handle;
157 * @brief Stores data to be sent to HMI on application permissions change
159 struct AppPermissions {
161 AppPermissions(const std::string& app_id)
162 : application_id(app_id),
163 isAppPermissionsRevoked(false),
165 appPermissionsConsentNeeded(false),
166 appUnauthorized(false) {
169 std::string application_id;
170 bool isAppPermissionsRevoked;
171 // TODO(AOleynik): Change type according to HMI_API spec
172 std::vector<std::string> appRevokedPermissions;
174 bool appPermissionsConsentNeeded;
175 bool appUnauthorized;
177 std::string priority;
178 DeviceParams deviceInfo;
182 * @brief User consent for device data usage
191 * @brief Struct contains parameters, which can be received during application
192 * registration and should be stored in policy table
196 : max_number_rfcom_ports(0) {
199 std::string hardware;
200 std::string firmware_rev;
204 uint32_t max_number_rfcom_ports;
208 * @brief User consent for functional group
217 * @brief Contains user permission for RPC functional group with specific name
220 struct FunctionalGroupPermission {
221 FunctionalGroupPermission()
223 state(kGroupUndefined) {
226 std::string group_alias;
227 std::string group_name;
233 * @brief Contains parameters for user-defined consent for appication
234 * functional groups on given device
236 struct PermissionConsent {
237 std::string device_id;
238 std::string policy_app_id;
239 std::vector<FunctionalGroupPermission> group_permissions;
240 std::string consent_source;
244 * @brief Contain data for GetUserFriendyMessage response
246 struct UserFriendlyMessage {
247 std::string message_code;
252 std::string text_body;
256 * @brief Types of functional groups in policy table
263 kTypeGeneral, // means, all types above
264 kTypePreDataConsented,
269 * @brief Array of functional group id from DB
271 typedef std::vector<uint32_t> FunctionalGroupIDs;
274 * @brief Array of functional group ids sorted by types
276 typedef std::map<GroupType, FunctionalGroupIDs> FunctionalIdType;
279 * @brief Array of functional group ids binded to group name (e.g.
280 * VehicleData-4) and user_consent_prompt (e.g. VehicleData)
282 typedef std::map<uint32_t, std::pair<std::string, std::string> > FunctionalGroupNames;
285 * @brief Array of device ids, which are an identifiers in policy table
287 typedef std::vector<std::string> DeviceIds;
289 } // namespace policy
291 #endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_TYPES_H_