diff --git a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp index a333c3bef..f09f554ef 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp +++ b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp @@ -1073,6 +1073,45 @@ void CoreSDKTest::MetricsStopContent() } } +void CoreSDKTest::MetricsReady() +{ + Firebolt::Error error = Firebolt::Error::None; + std::optional entityId; + bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().ready(&error); + + if (error == Firebolt::Error::None) { + cout << "Metrics Ready status = " << (status ? "true" : "false") << endl; + } else { + cout << "Metrics Ready status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::MetricsSignIn() +{ + Firebolt::Error error = Firebolt::Error::None; + std::optional entityId; + bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().signIn(&error); + + if (error == Firebolt::Error::None) { + cout << "Metrics signIn status = " << (status ? "true" : "false") << endl; + } else { + cout << "Metrics signIn status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::MetricsSignOut() +{ + Firebolt::Error error = Firebolt::Error::None; + std::optional entityId; + bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().signOut(&error); + + if (error == Firebolt::Error::None) { + cout << "Metrics signOut status = " << (status ? "true" : "false") << endl; + } else { + cout << "Metrics signOut status = " << static_cast(error) << endl; + } +} + void CoreSDKTest::GetSecondScreenDevice() { Firebolt::Error error = Firebolt::Error::None; @@ -1614,4 +1653,4 @@ void CoreSDKTest::OnNavigateToEntityIntentNotification::onNavigateTo(const Fireb void CoreSDKTest::OnNavigateToTuneIntentNotification::onNavigateTo(const Firebolt::Intents::TuneIntent& intent) { cout << "onNavigateTo for action : " << intent.action << endl; -} +} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h index aa15b374c..d0fd48c67 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h +++ b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h @@ -155,6 +155,9 @@ class CoreSDKTest { static void MetricsStartContent(); static void MetricsStopContent(); + static void MetricsReady(); + static void MetricsSignIn(); + static void MetricsSignOut(); static void GetSecondScreenDevice(); static void GetSecondScreenProtocols(); @@ -203,4 +206,3 @@ class CoreSDKTest { static KeyboardPasswordAsyncResponse _keyboardPasswordAsyncResponse; static KeyboardStandardAsyncResponse _keyboardStandardAsyncResponse; }; - diff --git a/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp b/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp index 6652de37b..5b235dadb 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp +++ b/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp @@ -1,3 +1,21 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + #include #include #include @@ -99,8 +117,13 @@ void RunAllTests() { runTest(CoreSDKTest::UnsubscribeLifecycleForegroundNotification, "UnsubscribeLifecycleForegroundNotification"); // Metrics methods + runTest(CoreSDKTest::MetricsReady, "MetricsReady"); + runTest(CoreSDKTest::MetricsSignIn, "MetricsSignIn"); + runTest(CoreSDKTest::MetricsSignOut, "MetricsSignOut"); runTest(CoreSDKTest::MetricsStartContent, "MetricsStartContent"); runTest(CoreSDKTest::MetricsStopContent, "MetricsStopContent"); + + // SecondScreen methods runTest(CoreSDKTest::GetSecondScreenDevice, "GetSecondScreenDevice"); @@ -119,7 +142,7 @@ void RunAllTests() { runTest(CoreSDKTest::DiscoveryPolicy, "DiscoveryPolicy"); runTest(CoreSDKTest::DiscoveryPurchasedContent, "DiscoveryPurchasedContent"); runTest(CoreSDKTest::DiscoveryWatchNext, "DiscoveryWatchNext"); - // runTest(CoreSDKTest::DiscoveryLaunch, "DiscoveryLaunch"); + runTest(CoreSDKTest::DiscoveryLaunch, "DiscoveryLaunch"); #ifdef POLYMORPHICS_REDUCER_METHODS runTest(CoreSDKTest::DiscoveryWatched, "DiscoveryWatched"); runTest(CoreSDKTest::DiscoveryWatchedReduced, "DiscoveryWatchedReduced"); diff --git a/src/sdks/core/src/cpp/templates/Metrics/include/module.h b/src/sdks/core/src/cpp/templates/Metrics/include/module.h new file mode 100644 index 000000000..ccca61a6a --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Metrics/include/module.h @@ -0,0 +1,36 @@ +#pragma once + +#include "error.h" +/* ${IMPORTS} */ + +${if.declarations}namespace Firebolt { +namespace ${info.Title} { +${if.enums} + +// Enums +/* ${ENUMS} */${end.if.enums} +${if.types} +// Types +/* ${TYPES} */${end.if.types} +${if.providers}/* ${PROVIDERS} */${end.if.providers}${if.xuses}/* ${XUSES} */${end.if.xuses} +${if.methods}struct I${info.Title} { + + virtual ~I${info.Title}() = default; + virtual bool ready( Firebolt::Error *err = nullptr ) = 0 ; + virtual bool signIn( Firebolt::Error *err = nullptr ) = 0 ; + virtual bool signOut( Firebolt::Error *err = nullptr ) = 0 ; + + // Methods & Events + /* ${METHODS:declarations} */ +};${end.if.methods} + +} //namespace ${info.Title} +}${end.if.declarations} + + + + + + + + diff --git a/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.cpp b/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.cpp index 59a50162d..085c4173a 100644 --- a/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.cpp +++ b/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.cpp @@ -18,68 +18,95 @@ #include "${info.title.lowercase}_impl.h" + ${if.implementations} namespace Firebolt { namespace ${info.Title} { ${if.providers} /* ${PROVIDERS} */${end.if.providers} - void ${info.Title}Impl::signIn() + +/* ready - Inform the platform that your app is minimally usable. This method is called automatically by `Lifecycle.ready()` */ + bool ${info.Title}Impl::ready( Firebolt::Error *err ) { Firebolt::Error status = Firebolt::Error::NotConnected; + bool success = false; FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); if (transport != nullptr) { - + JsonObject jsonParameters; - + WPEFramework::Core::JSON::Boolean jsonResult; - status = transport->Invoke("${info.title.lowercase}.signIn", jsonParameters, jsonResult); + status = transport->Invoke("${info.title.lowercase}.ready", jsonParameters, jsonResult); if (status == Firebolt::Error::None) { - FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "${info.Title.signIn is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false")); + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Metrics.ready is successfully invoked"); + success = jsonResult.Value(); } } else { FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); } + if (err != nullptr) { + *err = status; + } + + return success; } - void ${info.Title}Impl::signOut() + + /* signIn - Log a sign In event, called by Discovery.signIn(). */ + bool ${info.Title}Impl::signIn( Firebolt::Error *err ) { Firebolt::Error status = Firebolt::Error::NotConnected; + bool success = false; FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); if (transport != nullptr) { - + JsonObject jsonParameters; - + WPEFramework::Core::JSON::Boolean jsonResult; - status = transport->Invoke("${info.title.lowercase}.signOut", jsonParameters, jsonResult); + status = transport->Invoke("${info.title.lowercase}.signIn", jsonParameters, jsonResult); if (status == Firebolt::Error::None) { - FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "${info.Title}.signOut is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false")); + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Metrics.signOut is successfully invoked"); + success = jsonResult.Value(); } } else { FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); } - } + if (err != nullptr) { + *err = status; + } + return success; - void ${info.Title}Impl::ready() + } + /* signOut - Log a sign out event, called by Discovery.signOut(). */ + bool ${info.Title}Impl::signOut( Firebolt::Error *err ) { Firebolt::Error status = Firebolt::Error::NotConnected; + bool success = false; FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); if (transport != nullptr) { - + JsonObject jsonParameters; - + WPEFramework::Core::JSON::Boolean jsonResult; - status = transport->Invoke("${info.title.lowercase}.ready", jsonParameters, jsonResult); + status = transport->Invoke("${info.title.lowercase}.signOut", jsonParameters, jsonResult); if (status == Firebolt::Error::None) { - FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "${info.Title}.ready is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false")); + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Metrics.signOut is successfully invoked"); + success = jsonResult.Value(); } } else { FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); } + if (err != nullptr) { + *err = status; + } + + return success; } + // Methods /* ${METHODS} */ @@ -93,4 +120,4 @@ namespace ${info.Title} { namespace WPEFramework { /* ${ENUMS} */ -}${end.if.enums} +}${end.if.enums} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.h b/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.h index d64b59695..219803938 100644 --- a/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.h +++ b/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.h @@ -20,6 +20,7 @@ #include "FireboltSDK.h" #include "IModule.h" + /* ${IMPORTS} */ #include "${info.title.lowercase}.h" @@ -41,12 +42,16 @@ namespace ${info.Title} { ~${info.Title}Impl() override = default; - static void signIn(); - static void signOut(); - static void ready(); + + bool ready( Firebolt::Error *err = nullptr ) ; + bool signIn( Firebolt::Error *err = nullptr ) ; + bool signOut( Firebolt::Error *err = nullptr ) ; + + + // Methods & Events /* ${METHODS:declarations-override} */ };${end.if.methods} }//namespace ${info.Title} -}${end.if.implementations} +}${end.if.implementations} \ No newline at end of file