summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin')
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h10
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h9
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h57
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h6
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h161
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h5
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h2
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h3
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h4
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h16
10 files changed, 245 insertions, 28 deletions
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h
index fb77bc6169..7ee56c4437 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h
@@ -1,7 +1,7 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H
-#include "application_manager/commands/request_from_hmi.h"
+#include "application_manager/commands/request_to_hmi.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -9,14 +9,16 @@ namespace app_mngr = application_manager;
namespace commands {
class RCButtonPressRequest
- : public application_manager::commands::RequestFromHMI {
+ : public application_manager::commands::RequestToHMI {
public:
RCButtonPressRequest(
const app_mngr::commands::MessageSharedPtr& message,
app_mngr::ApplicationManager& application_manager);
- bool Init() OVERRIDE;
+ /**
+ * @brief Execute command
+ */
void Run() OVERRIDE;
- void on_event(const application_manager::event_engine::Event& event) OVERRIDE;
+ virtual ~RCButtonPressRequest();
};
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h
index 01093d3548..6972762515 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h
@@ -1,7 +1,7 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H
-#include "application_manager/commands/response_to_hmi.h"
+#include "application_manager/commands/response_from_hmi.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -9,14 +9,15 @@ namespace app_mngr = application_manager;
namespace commands {
class RCButtonPressResponse
- : public application_manager::commands::ResponseToHMI {
+ : public application_manager::commands::ResponseFromHMI {
public:
RCButtonPressResponse(
const app_mngr::commands::MessageSharedPtr& message,
app_mngr::ApplicationManager& application_manager);
- bool Init() OVERRIDE;
+
void Run() OVERRIDE;
- void on_event(const application_manager::event_engine::Event& event);
+
+ virtual ~RCButtonPressResponse();
};
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h
index 7c88cea5a7..746eb152b7 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h
@@ -1,21 +1,62 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_REQUEST_H
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_REQUEST_H
-#include "application_manager/commands/command_request_impl.h"
-#include "utils/macro.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
namespace rc_rpc_plugin {
namespace app_mngr = application_manager;
namespace commands {
-class ButtonPressRequest : public app_mngr::commands::CommandRequestImpl {
+class ButtonPressRequest : public RCCommandRequest {
public:
- ButtonPressRequest(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager);
- bool Init() OVERRIDE;
- void Run() OVERRIDE;
- void on_event(const application_manager::event_engine::Event& event) OVERRIDE;
+ ButtonPressRequest(
+ const app_mngr::commands::MessageSharedPtr& message,
+ app_mngr::ApplicationManager& application_manager,
+ rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager);
+
+ /**
+ * @brief Execute command
+ * send HMI request if message contains appropriate
+ * button name and module type
+ * otherwise sends negative sesponse to mobile
+ */
+ void Execute() FINAL;
+
+ /**
+ * @brief AcquireResource Tries to acquire specific resource
+ * @param message Incoming message containg the resource name
+ * @return Acquire result
+ */
+ AcquireResult::eType AcquireResource(
+ const app_mngr::commands::MessageSharedPtr& message) FINAL;
+
+ /**
+ * @brief IsResourceFree check resource state
+ * @param module_type Resource name
+ * @return True if free, otherwise - false
+ */
+ bool IsResourceFree(const std::string& module_type) const FINAL;
+
+ /**
+ * @brief SetResourceState changes state of resource
+ * @param state State to set for resource
+ */
+ void SetResourceState(const std::string& module_type,
+ const ResourceState::eType state) FINAL;
+
+ /**
+ * @brief Interface method that is called whenever new event received
+ *
+ * @param event The received event
+ */
+ void on_event(const app_mngr::event_engine::Event& event) FINAL;
+
+ /**
+ * @brief ButtonPressRequest class destructor
+ */
+ virtual ~ButtonPressRequest();
};
+
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h
index 165124cdfe..fa113df91e 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h
@@ -13,9 +13,11 @@ class ButtonPressResponse
public:
ButtonPressResponse(const app_mngr::commands::MessageSharedPtr& message,
app_mngr::ApplicationManager& application_manager);
- bool Init() OVERRIDE;
void Run() OVERRIDE;
- void on_event(const application_manager::event_engine::Event& event);
+ /**
+ * @brief ButtonPressResponse class destructor
+ */
+ virtual ~ButtonPressResponse();
};
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h
new file mode 100644
index 0000000000..f1d1f57704
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h
@@ -0,0 +1,161 @@
+/*
+ Copyright (c) 2018, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H
+
+#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/rc_app_extension.h"
+#include "application_manager/commands/command_request_impl.h"
+
+namespace rc_rpc_plugin {
+namespace app_mngr = application_manager;
+
+enum TypeAccess { kDisallowed, kAllowed };
+
+namespace commands {
+
+class RCCommandRequest : public app_mngr::commands::CommandRequestImpl {
+ public:
+ /**
+ * @brief RCCommandRequest class constructor
+ *
+ **/
+ RCCommandRequest(
+ rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager,
+ const app_mngr::commands::MessageSharedPtr& message,
+ app_mngr::ApplicationManager& application_manager);
+
+ virtual ~RCCommandRequest();
+
+ void onTimeOut() OVERRIDE;
+
+ void Run() OVERRIDE;
+
+ virtual void on_event(const app_mngr::event_engine::Event& event) OVERRIDE;
+
+ protected:
+ ResourceAllocationManager& resource_allocation_manager_;
+ bool auto_allowed_;
+
+ /**
+ * @brief AcquireResource try to allocate resource for application
+ * In case if allocation of resource is not required, return ALLOWED by
+ * default.
+ * This method should be overrided in RPCs that requires resource allocation
+ * @return result of resource allocation, in case if allocation os not
+ * required, return ALLOWED
+ */
+ virtual AcquireResult::eType AcquireResource(
+ const app_mngr::commands::MessageSharedPtr& message) {
+ return AcquireResult::ALLOWED;
+ }
+
+ /**
+ * @brief IsResourceFree check resource state
+ * This is default implementation which has to be redefined for RPCs which
+ * need to manage the resources
+ * @param module_type Resource name
+ * @return True if free, otherwise - false
+ */
+ virtual bool IsResourceFree(const std::string& module_type) const {
+ UNUSED(module_type);
+ return true;
+ }
+ /**
+ * @brief SetResourceState changes state of resource
+ * This is default implementation which has to be redefined for RPCs which
+ * need to manage the resources
+ * @param module_type Resource name
+ * @param State to set for resource
+ */
+ virtual void SetResourceState(const std::string& module_type,
+ const ResourceState::eType) {}
+
+ /**
+ * Checks if module for application is present in policy table
+ * @param app_id id of application
+ * @param module type Resource name
+ * @return kAllowed if module is present, otherwise - kDisallowed
+ */
+ TypeAccess CheckModule(const std::string& module_type,
+ application_manager::ApplicationSharedPtr app);
+
+ bool auto_allowed() const {
+ return auto_allowed_;
+ }
+
+ void set_auto_allowed(const bool value) {
+ auto_allowed_ = value;
+ }
+
+ /**
+ * @brief executes specific logic of children classes
+ */
+ void virtual Execute() = 0;
+
+ void set_disallowed_info(const std::string& info) {
+ disallowed_info_ = info;
+ }
+
+ private:
+ /**
+ * @brief CheckDriverConsent checks driver consent defined in policy table
+ * @return True if no consent is required, otherwise - false
+ */
+ bool CheckDriverConsent();
+
+ /**
+ * @brief AcquireResources checks whether resource status is busy or not and
+ * then tries to acquire this resource. In case driver consent is required -
+ * sends consent request to HMI.
+ * @return True in case of resource is free and successfully acquired,
+ * otherwise false
+ */
+ bool AcquireResources();
+ void SendDisallowed(TypeAccess access);
+
+ /**
+ * @brief SendGetUserConsent sends consent request to HMI
+ * @param module_type Resource name
+ */
+ void SendGetUserConsent(const std::string& module_type);
+ void ProcessAccessResponse(const app_mngr::event_engine::Event& event);
+ bool IsInterfaceAvailable(
+ const app_mngr::HmiInterfaces::InterfaceID interface) const;
+
+ std::string disallowed_info_;
+};
+}
+}
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h
index fc4ba13b85..af32cfc82b 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h
@@ -8,6 +8,7 @@
#include "application_manager/rpc_service.h"
#include "application_manager/hmi_capabilities.h"
#include "application_manager/policies/policy_handler_interface.h"
+#include "rc_rpc_plugin/resource_allocation_manager.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -17,7 +18,8 @@ class RCCommandFactory : public application_manager::CommandFactory {
RCCommandFactory(app_mngr::ApplicationManager& app_manager,
app_mngr::rpc_service::RPCService& rpc_service,
app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler);
+ policy::PolicyHandlerInterface& policy_handler,
+ ResourceAllocationManager& allocation_manager);
application_manager::CommandSharedPtr CreateCommand(
const app_mngr::commands::MessageSharedPtr& message,
app_mngr::commands::Command::CommandSource source) OVERRIDE;
@@ -35,6 +37,7 @@ class RCCommandFactory : public application_manager::CommandFactory {
app_mngr::rpc_service::RPCService& rpc_service_;
app_mngr::HMICapabilities& hmi_capabilities_;
policy::PolicyHandlerInterface& policy_handler_;
+ ResourceAllocationManager& allocation_manager_;
};
} // namespace rc_rpc_plugin
#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h
index 021e3cd6f0..d0f01d78ce 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h
@@ -33,7 +33,7 @@
#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_CONSTANTS_H_
#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_CONSTANTS_H_
-namespace remote_control {
+namespace rc_rpc_plugin {
namespace strings {
// RemoteControlCapabilities constants
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h
index ffc6cab609..e102dc597d 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h
@@ -61,4 +61,7 @@ class RCRPCPlugin : public plugins::RPCPlugin {
std::unique_ptr<ResourceAllocationManager> resource_allocation_manager_;
};
} // namespace rc_rpc_plugin
+
+extern "C" application_manager::plugin_manager::RPCPlugin* Create();
+
#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_PLUGIN_H
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h
index 8a829aa1dc..26472aa517 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h
@@ -5,6 +5,7 @@
#include "utils/shared_ptr.h"
#include "interfaces/HMI_API.h"
#include "application_manager/plugin_manager/rpc_plugin.h"
+#include "rc_rpc_plugin/rc_app_extension.h"
//#include "remote_control/event_engine/event.h"
//#include "functional_module/generic_module.h"
@@ -110,6 +111,9 @@ class ResourceAllocationManager {
*/
virtual void ResetAllAllocations() = 0;
+ virtual RCAppExtensionPtr GetApplicationExtention(
+ application_manager::ApplicationSharedPtr application) = 0;
+
virtual ~ResourceAllocationManager() {}
};
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h
index 433cfef33c..c99b47c5f8 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h
@@ -56,6 +56,14 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager {
void ResetAllAllocations() FINAL;
+ /**
+ * @brief GetApplicationExtention Provides access to application RC extention
+ * @param application Application
+ * @return Pointer to RC extention of application or NULL if not available
+ */
+ RCAppExtensionPtr GetApplicationExtention(
+ application_manager::ApplicationSharedPtr application) FINAL;
+
private:
typedef std::vector<application_manager::ApplicationSharedPtr> Apps;
@@ -96,14 +104,6 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager {
void ProcessApplicationPolicyUpdate();
/**
- * @brief GetApplicationExtention Provides access to application RC extention
- * @param application Application
- * @return Pointer to RC extention of application or NULL if not available
- */
- RCAppExtensionPtr GetApplicationExtention(
- application_manager::ApplicationSharedPtr application);
-
- /**
* @brief RemoveAppsSubscriptions Removes subscriptions for interior data for
* applications in the list
* @param apps Application list