diff options
author | Alexander Kutsan <akutsan@luxoft.com> | 2017-01-16 15:42:42 +0200 |
---|---|---|
committer | Alex Kutsan <akutsan@luxoft.com> | 2017-01-17 12:38:47 +0200 |
commit | e164cc18f5044ebc3f294b2452ec69e9ec1097e7 (patch) | |
tree | f4c64f5887d5910ec73de3dd3c7ef8e077f3ccbf /src/components/include | |
parent | 787736fe317125e77d9a422c86169c17e1d3a678 (diff) | |
download | sdl_core-e164cc18f5044ebc3f294b2452ec69e9ec1097e7.tar.gz |
Remove nitification update_manager on AddApplication
AddApplication will return function that will sen d appropriate notifications on call
Relates issue : APPLINK-31436
Diffstat (limited to 'src/components/include')
6 files changed, 42 insertions, 5 deletions
diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 8f34fa9ae5..e1623a92c3 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -45,8 +45,11 @@ #include "utils/custom_string.h" #include "policy/policy_settings.h" #include "smart_objects/smart_object.h" +#include "utils/callable.h" namespace policy { +typedef utils::SharedPtr<utils::Callable> StatusNotifier; + class PolicyHandlerInterface { public: virtual ~PolicyHandlerInterface() {} @@ -306,8 +309,9 @@ class PolicyHandlerInterface { * @brief Allows to add new or update existed application during * registration process * @param application_id The policy aplication id. + * @return function that will notify update manager about new application */ - virtual void AddApplication(const std::string& application_id) = 0; + virtual StatusNotifier AddApplication(const std::string& application_id) = 0; /** * Checks whether application is revoked diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index c587a00111..7d5bbb5e52 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -35,12 +35,15 @@ #include <vector> +#include "utils/callable.h" + #include "policy/policy_types.h" #include "policy/policy_listener.h" #include "usage_statistics/statistics_manager.h" namespace policy { class PolicySettings; +typedef utils::SharedPtr<utils::Callable> StatusNotifier; class PolicyManager : public usage_statistics::StatisticsManager { public: @@ -354,8 +357,9 @@ class PolicyManager : public usage_statistics::StatisticsManager { * @brief Adds, application to the db or update existed one * run PTU if policy update is necessary for application. * @param Application id assigned by Ford to the application + * @return function that will notify update manager about new application */ - virtual void AddApplication(const std::string& application_id) = 0; + virtual StatusNotifier AddApplication(const std::string& application_id) = 0; /** * @brief Removes unpaired device records and related records from DB diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index 509ca05056..33a86c6f98 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -173,7 +173,8 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { const std::string& policy_app_id)); MOCK_METHOD0(OnPTExchangeNeeded, void()); MOCK_METHOD1(GetAvailableApps, void(std::queue<std::string>& apps)); - MOCK_METHOD1(AddApplication, void(const std::string& application_id)); + MOCK_METHOD1(AddApplication, + policy::StatusNotifier(const std::string& application_id)); MOCK_METHOD1(IsApplicationRevoked, bool(const std::string& app_id)); MOCK_METHOD0(OnUpdateRequestSentToMobile, void()); MOCK_CONST_METHOD1(HeartBeatTimeout, uint32_t(const std::string& app_id)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 31f80859c1..0140efddf5 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -140,7 +140,8 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD1(SendNotificationOnPermissionsUpdated, void(const std::string& application_id)); MOCK_METHOD1(MarkUnpairedDevice, void(const std::string& device_id)); - MOCK_METHOD1(AddApplication, void(const std::string& application_id)); + MOCK_METHOD1(AddApplication, + StatusNotifier(const std::string& application_id)); MOCK_METHOD0(CleanupUnpairedDevices, bool()); MOCK_CONST_METHOD1(CanAppKeepContext, bool(const std::string& app_id)); MOCK_CONST_METHOD1(CanAppStealFocus, bool(const std::string& app_id)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index 5405792d6b..b3f48686e4 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -139,7 +139,8 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD1(SendNotificationOnPermissionsUpdated, void(const std::string& application_id)); MOCK_METHOD1(MarkUnpairedDevice, void(const std::string& device_id)); - MOCK_METHOD1(AddApplication, void(const std::string& application_id)); + MOCK_METHOD1(AddApplication, + StatusNotifier(const std::string& application_id)); MOCK_METHOD0(CleanupUnpairedDevices, bool()); MOCK_CONST_METHOD1(CanAppKeepContext, bool(const std::string& app_id)); MOCK_CONST_METHOD1(CanAppStealFocus, bool(const std::string& app_id)); diff --git a/src/components/include/utils/callable.h b/src/components/include/utils/callable.h new file mode 100644 index 0000000000..aff91814bf --- /dev/null +++ b/src/components/include/utils/callable.h @@ -0,0 +1,26 @@ +#ifndef SRC_COMPONENTS_INCLUDE_UTILS_CALLABLE_H +#define SRC_COMPONENTS_INCLUDE_UTILS_CALLABLE_H + +#include "utils/macro.h" + +namespace utils { +/** + * @brief The Callable class allows + * to create functor to call in other context + */ +class Callable { + public: + virtual void operator()() const = 0; + virtual ~Callable() {} +}; + +/** + * @brief The CallNothing class functior that to nothing + */ +class CallNothing : public Callable { + // Callable interface + public: + void operator()() const OVERRIDE {} +}; +} // namespace utils +#endif // SRC_COMPONENTS_INCLUDE_UTILS_CALLABLE_H |