pull in new policy updates
[profile/ivi/smartdevicelink.git] / src / components / policy / src / policy / include / policy / pt_ext_representation.h
1 /*
2  Copyright (c) 2013, Ford Motor Company
3  All rights reserved.
4
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7
8  Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10
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
14  distribution.
15
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.
19
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.
31  */
32
33 #ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_
34 #define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_
35
36 #include "policy/pt_representation.h"
37
38 namespace policy {
39
40 enum StatisticsType {
41   S_NONE = 0,
42   S_IAP_BUFFER_FULL,
43   S_SYNC_OUT_OF_MEMORY,
44   S_SYNC_REBOOTS,
45   S_MINS_HMI_FULL,
46   S_MINS_HMI_LIMITED,
47   S_MINS_HMI_BACKGROUND,
48   S_MINS_HMI_NONE,
49   S_RFCOM_LIMIT_REACHED,
50   S_USER_SELECTIONS,
51   S_REJECTIONS_SYNC_OUT_OF_MEMORY,
52   S_REJECTIONS_NICKNAME_MISMATCH,
53   S_REJECTIONS_DUPLICATE_NAME,
54   S_REJECTED_RPC_CALLS,
55   S_RPCS_IN_HMI_NONE,
56   S_REMOVALS_MISBEHAVED,
57   S_RUN_ATTEMPTS_WHILE_REVOKED
58 };
59
60 enum LanguageType {
61   L_NONE = 0,
62   L_GUI,
63   L_VUI
64 };
65
66 class PTExtRepresentation : public virtual PTRepresentation {
67   public:
68     virtual ~PTExtRepresentation() {
69     }
70
71     /**
72      * @brief Is application allowed to send notifications while in
73      * Backgound or limited mode.
74      * @param app_id Application id
75      * @return bool Allowed/disallowed.
76      */
77     virtual bool CanAppKeepContext(const std::string& app_id) = 0;
78
79     /**
80      * @brief Is application allowed to move foreground at will?
81      * @param app_id Application id
82      * @return bool Allowed/disallowed.
83      */
84     virtual bool CanAppStealFocus(const std::string& app_id) = 0;
85
86     /**
87      * @brief Get default_hmi for given application
88      * @param policy_app_id Unique application id
89      * @param default_hmi Default HMI level for application or empty, if value was
90      * not set
91      * @return true, if succedeed, otherwise - false
92      */
93     virtual bool GetDefaultHMI(const std::string& policy_app_id,
94                                std::string* default_hmi) = 0;
95
96     /**
97      * @brief Get priority for given application
98      * @param policy_app_id Unique application id
99      * @param priority Priority for application or empty, if value was not set
100      * @return true, if succedeed, otherwise - false
101      */
102     virtual bool GetPriority(const std::string& policy_app_id,
103                              std::string* priority) = 0;
104
105     /**
106      * @brief Reset user consent for device data and applications permissions
107      * @return
108      */
109     virtual bool ResetUserConsent() = 0;
110
111     /**
112      * @brief Reset user consent for device data
113      * @return
114      */
115     virtual bool ResetDeviceConsents() = 0;
116
117     /**
118      * @brief Reset user consent for applications permissions
119      * @return
120      */
121     virtual bool ResetAppConsents() = 0;
122
123     /**
124      * @brief Get user permissions for device data usage
125      * @param device_id Generated or obtained id of device
126      * @param consented_groups Groups consented by user
127      * @param disallowed_groups Groups not consented by user
128      * @return true, if query was successfull, otherwise - false
129      */
130     virtual bool GetUserPermissionsForDevice(
131       const std::string& device_id, StringArray* consented_groups = NULL,
132       StringArray* disallowed_groups = NULL) = 0;
133
134     /**
135      * @brief GetUserPermissionsForApp
136      * @param device_id
137      * @param policy_app_id
138      * @param group_types
139      * @return
140      */
141     virtual bool GetUserPermissionsForApp(
142       const std::string& device_id,
143       const std::string& policy_app_id,
144       FunctionalIdType* group_types) = 0;
145
146     /**
147      * @brief Get device groups and preconsented groups from policies section
148      * @param groups List of groups to be consented for device usage
149      * @param preconsented_groups List of preconsented groups for device usage
150      * @return true, if query was successful, otherwise - false
151      */
152     virtual bool GetDeviceGroupsFromPolicies(
153       policy_table::Strings* groups = NULL,
154       policy_table::Strings* preconsented_groups = NULL) = 0;
155
156     /**
157      * @brief Record information about mobile device in Policy Table.
158      * @param device_id Generated or obtained id of device
159      * @return bool Success of operation
160      */
161     virtual bool SetDeviceData(const std::string& device_id,
162                                const std::string& hardware = "",
163                                const std::string& firmware = "",
164                                const std::string& os = "",
165                                const std::string& os_version = "",
166                                const std::string& carrier = "",
167                                const uint32_t number_of_ports = 0) = 0;
168
169     /**
170      * @brief Sets user consent for particular mobile device,
171      * i.e. to use device for exchanging of Policy Table.
172      * @return bool Success of operation
173      */
174     virtual bool SetUserPermissionsForDevice(
175       const std::string& device_id, const StringArray& consented_groups =
176         StringArray(),
177       const StringArray& disallowed_gropus = StringArray()) = 0;
178
179     /**
180      * @brief Update Application Policies as reaction
181      * on User allowing/disallowing device this app is running on.
182      */
183     virtual bool ReactOnUserDevConsentForApp(
184       const std::string& app_id,
185       bool is_device_allowed) = 0;
186
187     /**
188      * @brief Set user consent on functional groups
189      * @param permissions User consent on functional group
190      * @return true, if operation succedeed, otherwise - false
191      */
192     virtual bool SetUserPermissionsForApp(
193       const PermissionConsent& permissions) = 0;
194
195     /**
196      * @brief Counter for statistics information: adds 1 to existing number.
197      * @param type Type of statistics (errors, mins in mode etc)
198      * @return bool Success of operation
199      */
200     virtual bool IncreaseStatisticsData(StatisticsType type) = 0;
201
202     /**
203      * @brief Records information about what language
204      * application tried to register with.
205      * @param app_id Id of application
206      * @param type - language for UI/VR
207      * @param language Language
208      * @return bool Success of operation
209      */
210     virtual bool SetAppRegistrationLanguage(const std::string& app_id,
211                                             LanguageType type,
212                                             const std::string& language) = 0;
213
214     /**
215      * @brief Records information about head unit system to PT
216      * @return bool Success of operation
217      */
218     virtual bool SetMetaInfo(const std::string& ccpu_version,
219                              const std::string& wers_country_code,
220                              const std::string& language) = 0;
221
222     /**
223      * @brief Kms pass since last successfull PT update
224      */
225     virtual int GetKmFromSuccessfulExchange() = 0;
226
227     /**
228      * @brief Days pass since last successfull PT update
229      */
230     virtual int GetDayFromScsExchange() = 0;
231
232     /**
233      * @brief Ignition cycles pass since last successfull PT update
234      */
235     virtual int GetIgnitionsFromScsExchange() = 0;
236
237     /**
238      * @brief Set current system language
239      * @param language System language
240      * @return true, if succedeed, otherwise - false
241      */
242     virtual bool SetSystemLanguage(const std::string& language) = 0;
243
244     /**
245      * Increments global counter
246      * @param type type of counter
247      */
248     virtual void Increment(const std::string& type) const = 0;
249
250     /**
251      * Increments counter of application
252      * @param app_id id application
253      * @param type type of counter
254      */
255     virtual void Increment(const std::string& app_id,
256                            const std::string& type) const = 0;
257
258     /**
259      * Sets value of application information
260      * @param app_id id application
261      * @param type type of information
262      * @param value value of information
263      */
264     virtual void Set(const std::string& app_id, const std::string& type,
265                      const std::string& value) const = 0;
266
267     /**
268      * Adds value to stopwatch of application
269      * @param app_id id application
270      * @param type type of stopwatch
271      * @param seconds value for adding in seconds
272      */
273     virtual void Add(const std::string& app_id, const std::string& type,
274                      int seconds) const = 0;
275
276     virtual bool CountUnconsentedGroups(const std::string& policy_app_id,
277                                         const std::string& device_id,
278                                         int* result) const = 0;
279
280     /**
281      * @brief Gets functional group names and user_consent_prompts, if any
282      * @param Array to be filled with group ids, names and functional prompts
283      * @return true, if succeeded, otherwise - false
284      */
285     // TODO(AOleynik): Possibly, we can get rid of this method. Check this.
286     virtual bool GetFunctionalGroupNames(policy::FunctionalGroupNames& names) = 0;
287
288     /**
289          * @brief Set app policy to pre_DataConsented policy
290          * @param app_id Policy ID of application to be changed
291          * @return true, if succeeded, otherwise - false
292          */
293     virtual bool SetPredataPolicy(const std::string& app_id) = 0;
294
295     /**
296      * @brief Updates application policy to either pre_DataConsented or not
297      * @param app_id Policy Id of application to be checked
298      * @param is_pre_data True of False to setting app policy to be pre_DataConsented
299      * @return true, if succeeded, otherwise - false
300      */
301     virtual bool SetIsPredata(const std::string& app_id, bool is_pre_data) = 0;
302
303     /**
304      * @brief Removes unpaired devices
305      * @return true if success
306      */
307     virtual bool CleanupUnpairedDevices(const DeviceIds& device_ids) const = 0;
308
309     /**
310      * Sets flag of unpaired device
311      * @param device_id
312      * @return true if success
313      */
314     virtual bool SetUnpairedDevice(const std::string& device_id) const = 0;
315
316     /**
317      * Gets list of unpaired devices
318      * @param device_ids output list
319      * @return true if success
320      */
321     virtual bool UnpairedDevicesList(DeviceIds* device_ids) const = 0;
322 };
323 }  //  namespace policy
324
325 #endif  //  SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_