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_SQL_PT_REPRESENTATION_H_
34 #define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_PT_REPRESENTATION_H_
38 #include "policy/pt_representation.h"
39 #include "rpc_base/rpc_base.h"
40 #include "policy_table_interface_base/types.h"
42 namespace policy_table = rpc::policy_table_interface_base;
50 class SQLPTRepresentation : public virtual PTRepresentation {
52 SQLPTRepresentation();
53 ~SQLPTRepresentation();
54 virtual CheckPermissionResult CheckPermissions(const PTString& app_id,
55 const PTString& hmi_level,
58 virtual bool IsPTPreloaded();
59 virtual int IgnitionCyclesBeforeExchange();
60 virtual int KilometersBeforeExchange(int current);
61 virtual bool SetCountersPassedForSuccessfulUpdate(int kilometers,
62 int days_after_epoch);
63 virtual int DaysBeforeExchange(int current);
64 virtual void IncrementIgnitionCycles();
65 virtual void ResetIgnitionCycles();
66 virtual int TimeoutResponse();
67 virtual bool SecondsBetweenRetries(std::vector<int>* seconds);
69 virtual VehicleData GetVehicleData();
71 virtual std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
72 const std::vector<std::string>& msg_codes, const std::string& language);
74 virtual EndpointUrls GetUpdateUrls(int service_type);
76 virtual int GetNotificationsNumber(policy_table::Priority priority);
80 virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot() const;
81 bool Save(const policy_table::Table& table);
82 bool GetInitialAppData(const std::string& app_id, StringArray* nicknames =
84 StringArray* app_hmi_types = NULL);
85 bool GetFunctionalGroupings(policy_table::FunctionalGroupings& groups);
88 virtual void GatherModuleMeta(policy_table::ModuleMeta* meta) const;
89 virtual void GatherModuleConfig(policy_table::ModuleConfig* config) const;
90 virtual bool GatherUsageAndErrorCounts(
91 policy_table::UsageAndErrorCounts* counts) const;
92 virtual void GatherDeviceData(policy_table::DeviceData* data) const;
93 virtual bool GatherFunctionalGroupings(
94 policy_table::FunctionalGroupings* groups) const;
95 virtual bool GatherConsumerFriendlyMessages(
96 policy_table::ConsumerFriendlyMessages* messages) const;
97 virtual bool GatherApplicationPolicies(
98 policy_table::ApplicationPolicies* apps) const;
100 bool GatherAppGroup(const std::string& app_id,
101 policy_table::Strings* app_groups) const;
102 bool GatherAppType(const std::string& app_id,
103 policy_table::AppHMITypes* app_types) const;
104 bool GatherNickName(const std::string& app_id,
105 policy_table::Strings* nicknames) const;
107 virtual bool SaveModuleMeta(const policy_table::ModuleMeta& meta);
108 virtual bool SaveModuleConfig(const policy_table::ModuleConfig& config);
109 virtual bool SaveUsageAndErrorCounts(
110 const policy_table::UsageAndErrorCounts& counts);
111 virtual bool SaveDeviceData(const policy_table::DeviceData& devices);
112 virtual bool SaveFunctionalGroupings(
113 const policy_table::FunctionalGroupings& groups);
114 virtual bool SaveConsumerFriendlyMessages(
115 const policy_table::ConsumerFriendlyMessages& messages);
116 virtual bool SaveApplicationPolicies(
117 const policy_table::ApplicationPolicies& apps);
119 virtual bool SaveMessageString(const std::string& type,
120 const std::string& lang,
121 const policy_table::MessageString& strings);
123 bool SaveAppGroup(const std::string& app_id,
124 const policy_table::Strings& app_groups);
125 bool SaveNickname(const std::string& app_id,
126 const policy_table::Strings& nicknames);
127 bool SaveAppType(const std::string& app_id,
128 const policy_table::AppHMITypes& types);
130 bool UpdateRequired() const;
131 void SaveUpdateRequired(bool value);
133 bool IsApplicationRevoked(const std::string& app_id) const;
134 bool IsApplicationRepresented(const std::string& app_id) const;
135 virtual bool IsDefaultPolicy(const std::string& app_id) const;
136 virtual bool IsPredataPolicy(const std::string& app_id) const;
137 virtual bool SetDefaultPolicy(const std::string& app_id);
138 bool CleanupUnpairedDevices(const DeviceIds& device_ids);
140 dbms::SQLDatabase* db() const;
141 virtual bool SetIsDefault(const std::string& app_id, bool is_default);
144 static const std::string kDatabaseName;
145 dbms::SQLDatabase* db_;
147 bool SaveRpcs(int64_t group_id, const policy_table::Rpc& rpcs);
148 bool SaveServiceEndpoints(const policy_table::ServiceEndpoints& endpoints);
149 bool SaveSecondsBetweenRetries(
150 const policy_table::SecondsBetweenRetries& seconds);
151 bool SaveNumberOfNotificationsPerMinute(
152 const policy_table::NumberOfNotificationsPerMinute& notifications);
153 bool SaveMessageType(const std::string& type);
154 bool SaveLanguage(const std::string& code);
156 } // namespace policy
158 #endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_PT_REPRESENTATION_H_