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_PT_REPRESENTATION_H_
34 #define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_REPRESENTATION_H_
38 #include "policy/policy_types.h"
41 namespace policy_table = rpc::policy_table_interface_base;
46 * @struct Data about vehicle
49 const std::string vehicle_make;
50 const std::string vehicle_model;
61 class PTRepresentation {
63 virtual ~PTRepresentation() {
67 * @brief Check if specified RPC for specified application
68 * has permission to be executed in specified HMI Level
69 * and also its permitted params.
70 * @param app_id Id of application provided during registration
71 * @param hmi_level Current HMI Level of application
72 * @param rpc Name of RPC
73 * @return CheckPermissionResult containing flag if HMI Level is allowed
74 * and list of allowed params.
76 virtual CheckPermissionResult CheckPermissions(const PTString& app_id,
77 const PTString& hmi_level,
78 const PTString& rpc) = 0;
81 * @brief Returns true if Policy Table was not updated yet
82 * from preloaded pt file.
84 virtual bool IsPTPreloaded() = 0;
87 * Gets number of ignition cycles before next update policy table
88 * @return number of ignition cycles
90 virtual int IgnitionCyclesBeforeExchange() = 0;
93 * Gets value in kilometers before next update policy table
94 * @param current value in kilometers from the odometers
95 * @return value in kilometers
97 virtual int KilometersBeforeExchange(int current) = 0;
100 * @brief Sets kilometers and days after epoch, that passed for recieved
101 * successful PT UPdate
103 virtual bool SetCountersPassedForSuccessfulUpdate(int kilometers,
104 int days_after_epoch) = 0;
107 * Gets value in days before next update policy table
108 * @param current value in days after epoch
109 * @return value in days
111 virtual int DaysBeforeExchange(int current) = 0;
114 * @brief Increment number of ignition cycles since last exchange by 1
116 virtual void IncrementIgnitionCycles() = 0;
119 * @brief Reset number of ignition cycles since last exchange to 0
121 virtual void ResetIgnitionCycles() = 0;
124 * @brief Returns timeout to wait for a response of PT update
125 * @return value in seconds
127 virtual int TimeoutResponse() = 0;
130 * @brief Returns number of seconds between each try of sending PTS
131 * @param seconds Return value: array of 5 elements
132 * @return bool Success of operation
134 virtual bool SecondsBetweenRetries(std::vector<int>* seconds) = 0;
137 * @brief Get information about vehicle
139 virtual VehicleData GetVehicleData() = 0;
142 * @brief Get message text for displaying/pronouncing for user
143 * dependent on language and context.
144 * @param msg_codes Context of message (Driver distraction, Grant permission etc)
145 * @param language Language of the message
146 * @return Array of appropriate messages parameters
148 virtual std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
149 const std::vector<std::string>& msg_codes, const std::string& language) = 0;
152 * @brief Get list of URL to send PTS to
153 * @param service_type If URLs for specific service are preset,
154 * return them otherwise default URLs.
156 virtual EndpointUrls GetUpdateUrls(int service_type) = 0;
159 * @brief Get allowed number of notifications
160 * depending on application priority.
161 * @param priority Priority of application
163 virtual int GetNotificationsNumber(policy_table::Priority priority) = 0;
166 * @brief Initialized Policy Table (load)
167 * @return bool Success of operation
169 virtual InitResult Init() = 0;
172 * @brief Close policy table
173 * @return bool Success of operation
175 virtual bool Close() = 0;
178 * @brief Removes policy table content.
179 * @return bool Success of operation
181 virtual bool Clear() = 0;
184 * Drops policy table (schema and content)
185 * @return true if successfully
187 virtual bool Drop() = 0;
190 * @brief Get snapshot of Policy Table
191 * including app_policies, functional_groups,
192 * device_info, statistics, excluding user messages
193 * @return Generated structure for obtaining Json string.
195 virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot() const = 0;
198 * Saves policy table in storage
199 * @param table policy table
200 * @return true if successfully
202 virtual bool Save(const policy_table::Table& table) = 0;
205 * Gets flag updateRequired
206 * @return true if update is required
208 virtual bool UpdateRequired() const = 0;
211 * Saves flag updateRequired
213 virtual void SaveUpdateRequired(bool value) = 0;
216 Retrieves data from app_policies about app on its registration:
217 app_id - id of registered app; all outputs are filled in only if not null
218 output: nicknames Synonyms for application
219 output: app_types Section on HMI where app can appear (Navigation, Phone etc)
221 virtual bool GetInitialAppData(const std::string& app_id,
222 StringArray* nicknames = NULL,
223 StringArray* app_types = NULL) = 0;
226 * Checks if the application is revoked
227 * @param app_id application id
228 * @return true if application is revoked
230 virtual bool IsApplicationRevoked(const std::string& app_id) const = 0;
233 * @brief Get functional groupings from DB
234 * @param groups Known functional groupings
235 * @return true, if succeeded, otherwise - false
237 virtual bool GetFunctionalGroupings(policy_table::FunctionalGroupings& groups) = 0;
240 * Checks if the application is represented in policy table
241 * @param app_id application id
242 * @return true if application is represented in policy table
244 virtual bool IsApplicationRepresented(const std::string& app_id) const = 0;
247 * Checks if the application has default policy
248 * @param app_id application id
249 * @return true if application has default policy
251 virtual bool IsDefaultPolicy(const std::string& app_id) const = 0;
254 * Checks if the application has pre_data policy
255 * @param app_id application id
256 * @return true if application has pre_data policy
258 virtual bool IsPredataPolicy(const std::string& app_id) const = 0;
261 * Sets default policy for application
262 * @param app_id application id
263 * @return true if success
265 virtual bool SetDefaultPolicy(const std::string& app_id) = 0;
268 } // namespace policy
270 #endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_REPRESENTATION_H_