Skip to content

Commit

Permalink
Merge branch 'next' into feature/cpp-app-passthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
ksentak authored Jul 29, 2024
2 parents b6357ca + a1f75cb commit 03eb84a
Show file tree
Hide file tree
Showing 15 changed files with 461 additions and 29 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [1.2.1-next.3](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.1-next.2...v1.2.1-next.3) (2024-07-29)


### Bug Fixes

* Added Lifecycle template in cpp ([#292](https://github.com/rdkcentral/firebolt-apis/issues/292)) ([046adc1](https://github.com/rdkcentral/firebolt-apis/commit/046adc18ca7f2d35d02b9ce597be6f330c3b1972))

## [1.2.1-next.2](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.1-next.1...v1.2.1-next.2) (2024-07-01)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firebolt-js/sdks",
"version": "1.2.1-next.2",
"version": "1.2.1-next.3",
"description": "The Firebolt JS SDK",
"type": "module",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion src/sdks/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firebolt-js/sdk",
"version": "1.2.1-next.2",
"version": "1.2.1-next.3",
"description": "The Firebolt JS SDK",
"main": "./dist/lib/firebolt.mjs",
"types": "./dist/lib/firebolt.d.ts",
Expand Down
76 changes: 75 additions & 1 deletion src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <string>
#include "CoreSDKTest.h"


using namespace std;
bool CoreSDKTest::_connected;
CoreSDKTest::OnPolicyChangedNotification CoreSDKTest::_policyChangedNotification;
Expand Down Expand Up @@ -727,7 +728,41 @@ EnumMap<Firebolt::Lifecycle::LifecycleEventSource> lifecycleEventSourceMap = {
{ Firebolt::Lifecycle::LifecycleEventSource::REMOTE, "remote" }
};

void CoreSDKTest::OnBackgroundNotification::onBackground(const Firebolt::Lifecycle::LifecycleEvent& lifecycleEvent)
void CoreSDKTest::LifecycleReady()
{
Firebolt::Error error = Firebolt::Error::None;
Firebolt::IFireboltAccessor::Instance().LifecycleInterface().ready(&error);
if (error == Firebolt::Error::None) {
cout << "Lifecycle ready is success" << endl;
} else {
cout << "Lifecycle ready status = " << static_cast<int>(error) << endl;
}
}

void CoreSDKTest::LifecycleFinished()
{
Firebolt::Error error = Firebolt::Error::None;
Firebolt::IFireboltAccessor::Instance().LifecycleInterface().finished(&error);
if (error == Firebolt::Error::None) {
cout << "Lifecycle finished is success" << endl;
} else {
cout << "Lifecycle finished status = " << static_cast<int>(error) << endl;
}
}

void CoreSDKTest::LifecycleState()
{
Firebolt::Error error = Firebolt::Error::None;
const std::string state = Firebolt::IFireboltAccessor::Instance().LifecycleInterface().state(&error);

if (error == Firebolt::Error::None) {
cout << "State of the App = " << state.c_str() << endl;
} else {
cout << "State of the App throws an error = " << static_cast<int>(error) << endl;
}
}

void CoreSDKTest::OnBackgroundNotification::onBackground( const Firebolt::Lifecycle::LifecycleEvent& lifecycleEvent)
{
cout <<"onBackground event is triggered" << endl;
cout <<"\tstate: " << ConvertFromEnum<Firebolt::Lifecycle::LifecycleState>(lifecycleStateMap, lifecycleEvent.state) << endl;
Expand Down Expand Up @@ -1038,6 +1073,45 @@ void CoreSDKTest::MetricsStopContent()
}
}

void CoreSDKTest::MetricsReady()
{
Firebolt::Error error = Firebolt::Error::None;
std::optional<std::string> 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<int>(error) << endl;
}
}

void CoreSDKTest::MetricsSignIn()
{
Firebolt::Error error = Firebolt::Error::None;
std::optional<std::string> 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<int>(error) << endl;
}
}

void CoreSDKTest::MetricsSignOut()
{
Firebolt::Error error = Firebolt::Error::None;
std::optional<std::string> 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<int>(error) << endl;
}
}

void CoreSDKTest::GetSecondScreenDevice()
{
Firebolt::Error error = Firebolt::Error::None;
Expand Down
7 changes: 6 additions & 1 deletion src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ class CoreSDKTest {
static void GetProfileFlags();

static void LifecycleClose();
static void LifecycleFinished();
static void LifecycleReady();
static void LifecycleState();
static void SubscribeLifecycleBackgroundNotification();
static void UnsubscribeLifecycleBackgroundNotification();
static void SubscribeLifecycleForegroundNotification();
Expand All @@ -152,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();
Expand Down Expand Up @@ -201,4 +207,3 @@ class CoreSDKTest {
static KeyboardPasswordAsyncResponse _keyboardPasswordAsyncResponse;
static KeyboardStandardAsyncResponse _keyboardStandardAsyncResponse;
};

8 changes: 8 additions & 0 deletions src/sdks/core/src/cpp/sdk/cpptest/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,22 @@ void RunAllTests() {

// Lifecycle methods
// runTest(CoreSDKTest::LifecycleClose, "LifecycleClose");
runTest(CoreSDKTest::LifecycleReady, "LifecycleReady");
runTest(CoreSDKTest::LifecycleFinished, "LifecycleFinished");
runTest(CoreSDKTest::LifecycleState, "LifecycleState");
runTest(CoreSDKTest::SubscribeLifecycleBackgroundNotification, "SubscribeLifecycleBackgroundNotification");
runTest(CoreSDKTest::UnsubscribeLifecycleBackgroundNotification, "UnsubscribeLifecycleBackgroundNotification");
runTest(CoreSDKTest::SubscribeLifecycleForegroundNotification, "SubscribeLifecycleForegroundNotification");
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");
Expand Down
60 changes: 60 additions & 0 deletions src/sdks/core/src/cpp/templates/Lifecycle/include/module.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* 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
*/

#pragma once

#include "error.h"
#include <string>
/* ${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 void ready(Firebolt::Error *err = nullptr) = 0;
virtual void finished(Firebolt::Error *err = nullptr) = 0;
virtual std::string state(Firebolt::Error *err = nullptr) = 0;

// Methods & Events
/* ${METHODS:declarations} */
};${end.if.methods}

// Template for mapping enums to strings
template<typename T>
using EnumMap = std::unordered_map<T, std::string>;

// Function to convert enum values to string representations
template <typename T>
inline const std::string& ConvertEnum(EnumMap<T> enumMap, T type)
{
return enumMap[type];
}

} //namespace ${info.Title}
}${end.if.declarations}
Loading

0 comments on commit 03eb84a

Please sign in to comment.