diff --git a/CHANGELOG.md b/CHANGELOG.md index 479e710c1..9281b5666 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,38 @@ +# [1.3.0-next.3](https://github.com/rdkcentral/firebolt-apis/compare/v1.3.0-next.2...v1.3.0-next.3) (2024-08-08) + + +### Bug Fixes + +* Small update to Manage SDK test ([#297](https://github.com/rdkcentral/firebolt-apis/issues/297)) ([95e3b0f](https://github.com/rdkcentral/firebolt-apis/commit/95e3b0f211f4a80d4573adc9c1b35d2e74a78777)) + +# [1.3.0-next.2](https://github.com/rdkcentral/firebolt-apis/compare/v1.3.0-next.1...v1.3.0-next.2) (2024-08-02) + + +### Features + +* Add Metrics.appInfo API ([#294](https://github.com/rdkcentral/firebolt-apis/issues/294)) ([47264b5](https://github.com/rdkcentral/firebolt-apis/commit/47264b5c5c71fd117a52ca50f2e57315932905ad)) + +# [1.3.0-next.1](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.1-next.4...v1.3.0-next.1) (2024-07-29) + + +### Features + +* CPP App-Passthrough Logic ([#286](https://github.com/rdkcentral/firebolt-apis/issues/286)) ([4eb84ee](https://github.com/rdkcentral/firebolt-apis/commit/4eb84ee08c463915e3b13afec6603541ea0b1ae4)) + +## [1.2.1-next.4](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.1-next.3...v1.2.1-next.4) (2024-07-29) + + +### Bug Fixes + +* Added Static Metrics template in CPP ([#293](https://github.com/rdkcentral/firebolt-apis/issues/293)) ([a1f75cb](https://github.com/rdkcentral/firebolt-apis/commit/a1f75cb22577c3eded0968ca51ca656336a88506)) + +## [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) diff --git a/package-lock.json b/package-lock.json index e94a89102..eef15d77e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@firebolt-js/sdks", - "version": "1.2.1-next.2", + "version": "1.3.0-next.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@firebolt-js/sdks", - "version": "1.2.1-next.2", + "version": "1.3.0-next.3", "license": "Apache-2.0", "workspaces": [ "src/sdks/core", diff --git a/package.json b/package.json index f8d99849b..bb010b1d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/sdks", - "version": "1.2.1-next.2", + "version": "1.3.0-next.3", "description": "The Firebolt JS SDK", "type": "module", "bin": { diff --git a/src/openrpc/discovery.json b/src/openrpc/discovery.json index c3706de03..01ab2205e 100644 --- a/src/openrpc/discovery.json +++ b/src/openrpc/discovery.json @@ -642,7 +642,7 @@ "name": "identifiers", "summary": "A set of content identifiers for this call to action", "schema": { - "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/Entity" + "$ref": "https://meta.comcast.com/firebolt/entertainment#/definitions/ContentIdentifiers" }, "required": true }, diff --git a/src/openrpc/metrics.json b/src/openrpc/metrics.json index d3a9516c5..692245cbd 100644 --- a/src/openrpc/metrics.json +++ b/src/openrpc/metrics.json @@ -1064,7 +1064,50 @@ } } ] - } + }, + { + "name": "appInfo", + "tags": [ + { + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capability:metrics:general" + ] + } + ], + "summary": "Inform the platform about an app's build info.", + "params": [ + { + "name": "build", + "summary": "The build / version of this app.", + "schema": { + "type": "string" + }, + "required": true + } + ], + "result": { + "name": "result", + "schema": { + "type": "null" + } + }, + "examples": [ + { + "name": "Send appInfo metric", + "params": [ + { + "name": "build", + "value": "1.2.2" + } + ], + "result": { + "name": "result", + "value": null + } + } + ] + } ], "components": { "schemas": { diff --git a/src/sdks/core/package.json b/src/sdks/core/package.json index a42466cad..de4c0b5b4 100644 --- a/src/sdks/core/package.json +++ b/src/sdks/core/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/sdk", - "version": "1.2.1-next.2", + "version": "1.3.0-next.3", "description": "The Firebolt JS SDK", "main": "./dist/lib/firebolt.mjs", "types": "./dist/lib/firebolt.d.ts", diff --git a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp index b5d35f16e..e50d394de 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp +++ b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp @@ -22,6 +22,7 @@ #include #include "CoreSDKTest.h" + using namespace std; bool CoreSDKTest::_connected; CoreSDKTest::OnPolicyChangedNotification CoreSDKTest::_policyChangedNotification; @@ -234,6 +235,18 @@ void CoreSDKTest::GetDeviceName() } } +void CoreSDKTest::GetDeviceVersion() +{ + Firebolt::Error error = Firebolt::Error::None; + const std::string version = Firebolt::IFireboltAccessor::Instance().DeviceInterface().version(&error); + + if (error == Firebolt::Error::None) { + cout << "Get Device Version = " << version.c_str() << endl; + } else { + cout << "Get Device Version status = " << static_cast(error) << endl; + } +} + void CoreSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged(const std::string& name) { cout << "Name changed, new name --> " << name << endl; @@ -715,7 +728,41 @@ EnumMap 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(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(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(error) << endl; + } +} + +void CoreSDKTest::OnBackgroundNotification::onBackground( const Firebolt::Lifecycle::LifecycleEvent& lifecycleEvent) { cout <<"onBackground event is triggered" << endl; cout <<"\tstate: " << ConvertFromEnum(lifecycleStateMap, lifecycleEvent.state) << endl; @@ -1026,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; @@ -1242,6 +1328,32 @@ void CoreSDKTest::DiscoveryWatchNext() } } +void CoreSDKTest::DiscoveryUserInterest() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Discovery::InterestType type = Firebolt::Discovery::InterestType::INTEREST; + Firebolt::Discovery::InterestReason reason = Firebolt::Discovery::InterestReason::PLAYLIST; + + // Set up the entity details + Firebolt::Entity::EntityDetails entity; + + // Identifiers + entity.identifiers = "{\"entityId\": \"123\"}"; + + // Optional Info Metadata + entity.info = Firebolt::Entity::Metadata(); + entity.info->title = "A Cool Show"; + entity.info->synopsis = "A cool show synopsis"; + + Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().userInterest(type, reason, entity, &error); + + if (error == Firebolt::Error::None) { + cout << "Discovery User Interest is success" << endl; + } else { + cout << "Discovery User Interest status = " << static_cast(error) << endl; + } +} + void CoreSDKTest::DiscoveryPolicy() { Firebolt::Error error = Firebolt::Error::None; @@ -1399,15 +1511,12 @@ void CoreSDKTest::DiscoveryPurchasedContent() void CoreSDKTest::DiscoveryLaunch() { Firebolt::Error error = Firebolt::Error::None; - cout << "Enter appId :"; - getchar(); - std::string appId; - getline(cin, appId); + std::string appId = "123"; { std::optional intent = std::make_optional(); intent.value().action = "tune"; intent.value().data.entity.entityType = "channel"; - intent.value().data.entity.channelType = Firebolt::Intents::ChannelEntityChannelType::STREAMING; + intent.value().data.entity.channelType = Firebolt::Entity::ChannelEntityChannelType::STREAMING; intent.value().data.entity.entityId = "an-ott-channel"; std::string entityId; std::optional appContentData; @@ -1416,6 +1525,7 @@ void CoreSDKTest::DiscoveryLaunch() intent.value().context.source = "voice"; cout << "Calling Discovery Launch TuneIntent method " << endl; bool status = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().launch(appId, intent, &error); + if (error == Firebolt::Error::None) { cout << "Discovery Launch TuneIntent is " << (status ? "true" : "false") << endl; } else { @@ -1453,7 +1563,6 @@ void CoreSDKTest::DiscoveryLaunch() throw std::runtime_error("DiscoveryLaunch failed. " + errorMessage); } } - cin.putback('\n'); } #ifdef POLYMORPHICS_REDUCER_METHODS void CoreSDKTest::DiscoveryWatched() @@ -1567,4 +1676,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 9b8d056ea..d25521043 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h +++ b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h @@ -92,6 +92,7 @@ class CoreSDKTest { static void GetAccountUid(); static void GetDeviceName(); + static void GetDeviceVersion(); static void SubscribeDeviceNameChanged(); static void UnsubscribeDeviceNameChanged(); static void GetDeviceModel(); @@ -131,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(); @@ -151,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(); @@ -174,6 +181,7 @@ class CoreSDKTest { static void SubscribeDiscoveryOnNavigateToLaunchNotification(); static void UnsubscribeDiscoveryOnNavigateToLaunchNotification(); static void DiscoveryWatchNext(); + static void DiscoveryUserInterest(); static void ParametersInitialization(); @@ -199,4 +207,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 df361a238..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 @@ -40,6 +58,7 @@ void RunAllTests() { runTest(CoreSDKTest::GetDeviceModel, "GetDeviceModel"); runTest(CoreSDKTest::GetDeviceSku, "GetDeviceSku"); runTest(CoreSDKTest::GetDeviceName, "GetDeviceName"); + runTest(CoreSDKTest::GetDeviceName, "GetDeviceVersion"); runTest(CoreSDKTest::SubscribeDeviceNameChanged, "SubscribeDeviceNameChanged"); runTest(CoreSDKTest::UnsubscribeDeviceNameChanged, "UnsubscribeDeviceNameChanged"); runTest(CoreSDKTest::GetDeviceAudio, "GetDeviceAudio"); @@ -89,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"); @@ -115,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"); @@ -166,4 +193,4 @@ int main(int argc, char* argv[]) { CoreSDKTest::DestroyFireboltInstance(); return 0; -} +} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Device/include/module.h b/src/sdks/core/src/cpp/templates/Device/include/module.h new file mode 100644 index 000000000..a4d42be2c --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Device/include/module.h @@ -0,0 +1,37 @@ +/* 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" +/* ${IMPORTS} */ + +${if.declarations} +namespace Firebolt { + namespace ${info.Title} { + ${if.enums}/* ${ENUMS} */${end.if.enums} + ${if.types}/* ${TYPES} */${end.if.types} + ${if.providers}/* ${PROVIDERS} */${end.if.providers}${if.xuses}/* ${XUSES} */${end.if.xuses} + ${if.methods}struct I${info.Title} { + // Methods & Events + /* ${METHODS:declarations} */ + virtual ~I${info.Title}() = default; + virtual std::string version( Firebolt::Error *err = nullptr ) const = 0; + }; + ${end.if.methods} + } //namespace ${info.Title} +} +${end.if.declarations} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Device/src/module_impl.cpp b/src/sdks/core/src/cpp/templates/Device/src/module_impl.cpp new file mode 100644 index 000000000..242897d9d --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Device/src/module_impl.cpp @@ -0,0 +1,65 @@ +/* + * 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 "${info.title.lowercase}_impl.h" + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { +${if.providers} +/* ${PROVIDERS} */${end.if.providers} + std::string ${info.Title}Impl::version(Firebolt::Error *err) const + { + JsonObject jsonParameters; + JsonData_Versions jsonResult; + std::string version; + + Firebolt::Error status = Firebolt::Error::NotConnected; + FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); + if (transport != nullptr) { + + status = transport->Invoke("${info.title.lowercase}.version", jsonParameters, jsonResult); + if (status == Firebolt::Error::None) { + !jsonResult.IsSet() ? jsonResult.Clear() : (void)0; + !jsonResult.Sdk.IsSet() ? jsonResult.Sdk.Clear() : (void)0; + jsonResult.Sdk.Major = static_cast(${major}); + jsonResult.Sdk.Minor = static_cast(${minor}); + jsonResult.Sdk.Patch = static_cast(${patch}); + jsonResult.Sdk.Readable = "${readable}"; + jsonResult.ToString(version); + } + + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); + } + return version; + } + // Methods + /* ${METHODS} */ + + // Events + /* ${EVENTS} */ + +}//namespace ${info.Title} +}${end.if.implementations} +${if.enums} + +namespace WPEFramework { + +/* ${ENUMS} */ +}${end.if.enums} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Device/src/module_impl.h b/src/sdks/core/src/cpp/templates/Device/src/module_impl.h new file mode 100644 index 000000000..b96de7778 --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Device/src/module_impl.h @@ -0,0 +1,54 @@ +/* + * 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 "FireboltSDK.h" +#include "IModule.h" +#include + + +/* ${IMPORTS} */ +#include "${info.title.lowercase}.h" + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { +${if.enums} + +/* ${ENUMS:json-types} */${end.if.enums} +${if.types} + // Types +/* ${TYPES:json-types} */${end.if.types} + ${if.methods}class ${info.Title}Impl : public I${info.Title}, public IModule { + + public: + ${info.Title}Impl() = default; + ${info.Title}Impl(const ${info.Title}Impl&) = delete; + ${info.Title}Impl& operator=(const ${info.Title}Impl&) = delete; + + ~${info.Title}Impl() override = default; + + std::string version(Firebolt::Error *err = nullptr) const override; + + // Methods & Events + /* ${METHODS:declarations-override} */ + };${end.if.methods} + +}//namespace ${info.Title} +}${end.if.implementations} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Lifecycle/include/module.h b/src/sdks/core/src/cpp/templates/Lifecycle/include/module.h new file mode 100644 index 000000000..1f954f6de --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Lifecycle/include/module.h @@ -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 +/* ${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 +using EnumMap = std::unordered_map; + +// Function to convert enum values to string representations +template +inline const std::string& ConvertEnum(EnumMap enumMap, T type) +{ + return enumMap[type]; +} + +} //namespace ${info.Title} +}${end.if.declarations} diff --git a/src/sdks/core/src/cpp/templates/Lifecycle/src/module_impl.cpp b/src/sdks/core/src/cpp/templates/Lifecycle/src/module_impl.cpp new file mode 100644 index 000000000..233d3f973 --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Lifecycle/src/module_impl.cpp @@ -0,0 +1,152 @@ +/* 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 "${info.title.lowercase}_impl.h" + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { +${if.providers} +/* ${PROVIDERS} */${end.if.providers} + +EnumMap lifecycleStateMap = { + { Firebolt::Lifecycle::LifecycleState::INITIALIZING, "initializing" }, + { Firebolt::Lifecycle::LifecycleState::INACTIVE, "inactive" }, + { Firebolt::Lifecycle::LifecycleState::FOREGROUND, "foreground" }, + { Firebolt::Lifecycle::LifecycleState::BACKGROUND, "background" }, + { Firebolt::Lifecycle::LifecycleState::UNLOADING, "unloading" }, + { Firebolt::Lifecycle::LifecycleState::SUSPENDED, "suspended" } +}; + + +/* ready - Notify the platform that the app is ready */ +static void readyDispatcher(const void* result) { + Firebolt::IFireboltAccessor::Instance().MetricsInterface().ready(); +} + +// localCallback to update the state +static void onReadyInnerCallback(void* notification, const void* userData, void* jsonResponse ) +{ + const LifecycleImpl* selfConst = static_cast(userData); + LifecycleImpl* self = const_cast(selfConst); + + WPEFramework::Core::ProxyType& proxyResponse = *(reinterpret_cast*>(jsonResponse)); + ASSERT(proxyResponse.IsValid() == true); + + if (proxyResponse.IsValid() == true) { + LifecycleEvent value; + + value.state = proxyResponse->State; + std::string stateStr = ConvertEnum(lifecycleStateMap, value.state); + // Assign stateStr to currentState in ${info.Title}Impl instance + self->currentState = stateStr; + std::cout << "Updated the Current State to: " << self->currentState << std::endl; + + proxyResponse.Release(); + + } +} + + + +/* ready - Notify the platform that the app is ready */ +void ${info.Title}Impl::ready(Firebolt::Error *err) { + Firebolt::Error status = Firebolt::Error::NotConnected; + + JsonObject jsonParameters; + + // Call Prioritize to subscribe to corresponding event, add to internalMap, and prioritize its callback + status = FireboltSDK::Event::Instance().Prioritize("lifecycle.onForeground", jsonParameters, onReadyInnerCallback, (void*)nullptr, this); + status = FireboltSDK::Event::Instance().Prioritize("lifecycle.onBackground", jsonParameters, onReadyInnerCallback, (void*)nullptr, this); + status = FireboltSDK::Event::Instance().Prioritize("lifecycle.onInactive", jsonParameters, onReadyInnerCallback, (void*)nullptr, this); + status = FireboltSDK::Event::Instance().Prioritize("lifecycle.onSuspended", jsonParameters, onReadyInnerCallback, (void*)nullptr, this); + status = FireboltSDK::Event::Instance().Prioritize("lifecycle.onUnloading", jsonParameters, onReadyInnerCallback, (void*)nullptr, this); + + FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); + if (transport != nullptr) { + WPEFramework::Core::JSON::VariantContainer jsonResult; + status = transport->Invoke("lifecycle.ready", jsonParameters, jsonResult); + if (status == Firebolt::Error::None) { + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Lifecycle.ready is successfully invoked"); + + WPEFramework::Core::ProxyType job = WPEFramework::Core::ProxyType(WPEFramework::Core::ProxyType::Create(readyDispatcher, nullptr)); + WPEFramework::Core::IWorkerPool::Instance().Submit(job); + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in invoking lifecycle.ready: %d", status); + if (err != nullptr) { + *err = status; + } + } + + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); + if (err != nullptr) { + *err = status; + } + } +} + + +/* state - return the state of the app */ +std::string ${info.Title}Impl::state(Firebolt::Error *err) { + std::cout << "**CURRENT STATE OF THE APP::::**" << currentState << std::endl; + return currentState; +} + + + +/* finished - Notify the platform that the app is done unloading */ +void ${info.Title}Impl::finished(Firebolt::Error *err) +{ + Firebolt::Error status = Firebolt::Error::NotConnected; + if(currentState == "unloading") + { + FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); + if (transport != nullptr) { + + JsonObject jsonParameters; + + WPEFramework::Core::JSON::VariantContainer jsonResult; + status = transport->Invoke("lifecycle.finished", jsonParameters, jsonResult); + if (status == Firebolt::Error::None) { + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Lifecycle.finished is successfully invoked"); + + } + + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); + } + } + + return; +} + +// Methods +/* ${METHODS} */ + +// Events +/* ${EVENTS} */ + +}//namespace Lifecycle +}${end.if.implementations} +${if.enums} + +namespace WPEFramework { + +/* ${ENUMS} */ +}${end.if.enums} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Lifecycle/src/module_impl.h b/src/sdks/core/src/cpp/templates/Lifecycle/src/module_impl.h new file mode 100644 index 000000000..79a582da5 --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Lifecycle/src/module_impl.h @@ -0,0 +1,58 @@ +/* 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 "FireboltSDK.h" +#include "IModule.h" +#include "firebolt.h" +#include "jsondata_lifecycle.h" +#include "${info.title.lowercase}.h" + +/* ${IMPORTS} */ + + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { +${if.enums} + +/* ${ENUMS:json-types} */${end.if.enums} +${if.types} +// Types +/* ${TYPES:json-types} */${end.if.types} +${if.methods}class ${info.Title}Impl : public I${info.Title}, public IModule { + +public: + ${info.Title}Impl() = default; + ${info.Title}Impl(const ${info.Title}Impl&) = delete; + ${info.Title}Impl& operator=(const ${info.Title}Impl&) = delete; + ~${info.Title}Impl() override = default; + + std::string currentState = "INITIALIZING"; + + // Methods & Events + /* ${METHODS:declarations-override} */ + + void finished(Firebolt::Error *err = nullptr) override ; + void ready(Firebolt::Error *err = nullptr) override; + std::string state(Firebolt::Error *err = nullptr) override; + +};${end.if.methods} + +} // namespace ${info.Title} +} // namespace Firebolt +${end.if.implementations} \ No newline at end of file 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 diff --git a/src/sdks/discovery/package.json b/src/sdks/discovery/package.json index 0e4ec34e9..022f0a0ff 100644 --- a/src/sdks/discovery/package.json +++ b/src/sdks/discovery/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/discovery-sdk", - "version": "1.2.1-next.2", + "version": "1.3.0-next.3", "description": "The Firebolt Discovery JS SDK", "main": "./dist/lib/firebolt-discovery.mjs", "types": "./dist/lib/firebolt-discovery.d.ts", @@ -12,6 +12,9 @@ "validate": "npx firebolt-openrpc validate --input ./dist/firebolt-discovery-open-rpc.json", "sdk": "npx firebolt-openrpc sdk --input ./dist/firebolt-discovery-open-rpc.json --template ./src/js --output ./build/javascript/src", "native": "npx firebolt-openrpc sdk --input ./dist/firebolt-discovery-open-rpc.json --template ./src/js --output ./build/c/src --language ../../../node_modules/@firebolt-js/openrpc/languages/c", + "cpp": "npm run cpp:compile && npm run cpp:install", + "cpp:compile": "npx firebolt-openrpc sdk --input ./dist/firebolt-discovery-open-rpc.json --template ./src/cpp --output ./build/cpp/src --static-module Platform --language ../../../node_modules/@firebolt-js/openrpc/languages/cpp", + "cpp:install": "./build/cpp/src/scripts/install.sh -i ./build/cpp/src -s ./build/cpp/src/ -m discovery", "compile": "cd ../../.. && npm run compile", "slice": "npx firebolt-openrpc slice -i ../../../dist/firebolt-open-rpc.json --sdk ./sdk.config.json -o ./dist/firebolt-discovery-open-rpc.json", "docs": "npx firebolt-openrpc docs --input ./dist/firebolt-discovery-open-rpc.json --output build/docs/markdown --as-path", diff --git a/src/sdks/discovery/src/cpp/sdk/cpptest/CMakeLists.txt b/src/sdks/discovery/src/cpp/sdk/cpptest/CMakeLists.txt new file mode 100644 index 000000000..e2fc88793 --- /dev/null +++ b/src/sdks/discovery/src/cpp/sdk/cpptest/CMakeLists.txt @@ -0,0 +1,75 @@ +# 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 + +cmake_minimum_required(VERSION 3.3) + +project(FireboltDiscoverySDKTests) + +if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${SYSROOT_PATH}/usr" CACHE INTERNAL "" FORCE) + set(CMAKE_PREFIX_PATH ${SYSROOT_PATH}/usr/lib/cmake CACHE INTERNAL "" FORCE) +endif() + +list(APPEND CMAKE_MODULE_PATH + "${SYSROOT_PATH}/usr/lib/cmake" + "${SYSROOT_PATH}/tools/cmake") +message("FIREBOLT_PATH inside cmake " ${FIREBOLT_PATH}) +if (FIREBOLT_PATH) + set(CMAKE_FIREBOLT_PATH + "${FIREBOLT_PATH}/usr/lib/cmake/Firebolt" + "${FIREBOLT_PATH}/usr/lib/cmake/FireboltSDK") + list(APPEND CMAKE_PREFIX_PATH ${CMAKE_FIREBOLT_PATH}) + list(APPEND CMAKE_MODULE_PATH ${CMAKE_FIREBOLT_PATH}) +else () + set(FIREBOLT_PATH "${SYSROOT_PATH}" CACHE INTERNAL "" FORCE) +endif () + +find_package(WPEFramework CONFIG REQUIRED) +find_package(${NAMESPACE}Core CONFIG REQUIRED) +find_package(Firebolt CONFIG REQUIRED) +find_package(${FIREBOLT_NAMESPACE}SDK CONFIG REQUIRED) + +set(TESTAPP TestFireboltDiscovery) + +message("Setup ${TESTAPP}") + +add_executable(${TESTAPP} DiscoverySDKTest.cpp Main.cpp) + +target_link_libraries(${TESTAPP} + PRIVATE + ${NAMESPACE}Core::${NAMESPACE}Core + ${FIREBOLT_NAMESPACE}SDK::${FIREBOLT_NAMESPACE}SDK +) + +target_include_directories(${TESTAPP} + PRIVATE + $ + $ + $ +) + +set_target_properties(${TESTAPP} PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED YES +) + +add_custom_command( + TARGET ${TESTAPP} + POST_BUILD + COMMENT "=================== Installing TestApp ======================" + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}/usr/bin + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${TESTAPP} ${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}/usr/bin +) diff --git a/src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.cpp b/src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.cpp new file mode 100644 index 000000000..27fe67244 --- /dev/null +++ b/src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.cpp @@ -0,0 +1,102 @@ +/* + * 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 +#include "DiscoverySDKTest.h" + +using namespace std; +bool DiscoverySDKTest::_connected; + +void DiscoverySDKTest::ConnectionChanged(const bool connected, const Firebolt::Error error) +{ + cout << "Change in connection: connected: " << connected << " error: " << static_cast(error) << endl; + _connected = connected; +} + +void DiscoverySDKTest::CreateFireboltInstance(const std::string& url) +{ + const std::string config = "{\ + \"waitTime\": 100000,\ + \"logLevel\": \"Info\",\ + \"workerPool\":{\ + \"queueSize\": 8,\ + \"threadCount\": 3\ + },\ + \"wsUrl\": " + url + "}"; + + _connected = false; + Firebolt::IFireboltAccessor::Instance().Initialize(config); + Firebolt::IFireboltAccessor::Instance().Connect(ConnectionChanged); +} + +void DiscoverySDKTest::DestroyFireboltInstance() +{ + Firebolt::IFireboltAccessor::Instance().Disconnect(); + Firebolt::IFireboltAccessor::Instance().Deinitialize(); + Firebolt::IFireboltAccessor::Instance().Dispose(); +} + +bool DiscoverySDKTest::WaitOnConnectionReady() +{ + uint32_t waiting = 10000; + static constexpr uint32_t SLEEPSLOT_TIME = 100; + + // Right, a wait till connection is closed is requested.. + while ((waiting > 0) && (_connected == false)) { + + uint32_t sleepSlot = (waiting > SLEEPSLOT_TIME ? SLEEPSLOT_TIME : waiting); + // Right, lets sleep in slices of 100 ms + usleep(sleepSlot); + waiting -= sleepSlot; + } + return _connected; +} + +template +using EnumMap = std::unordered_map; +template +inline const string& ConvertFromEnum(EnumMap enumMap, T type) +{ + return enumMap[type]; +} +template +inline const T ConvertToEnum(EnumMap enumMap, const string& str) +{ + T value; + for (auto element: enumMap) { + if (element.second == str) { + value = element.first; + break; + } + } + return value; +} + +void DiscoverySDKTest::SampleTest() +{ + Firebolt::Error error = Firebolt::Error::None; + + if (error == Firebolt::Error::None) { + cout << "Sample Test Passed!" << endl; + } else { + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SampleTest failed. " + errorMessage); + } +} diff --git a/src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.h b/src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.h new file mode 100644 index 000000000..2fcd2bcc0 --- /dev/null +++ b/src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.h @@ -0,0 +1,41 @@ +/* + * 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 +#include "firebolt.h" + +class DiscoverySDKTest { + +public: + DiscoverySDKTest() = default; + virtual ~DiscoverySDKTest() = default; + + static void CreateFireboltInstance(const std::string& url); + static void DestroyFireboltInstance(); + static void TestDiscoveryStaticSDK(); + + static void SampleTest(); + + static bool WaitOnConnectionReady(); + +private: + static void ConnectionChanged(const bool, const Firebolt::Error); + static bool _connected; +}; \ No newline at end of file diff --git a/src/sdks/discovery/src/cpp/sdk/cpptest/Main.cpp b/src/sdks/discovery/src/cpp/sdk/cpptest/Main.cpp new file mode 100644 index 000000000..26e2b5dc6 --- /dev/null +++ b/src/sdks/discovery/src/cpp/sdk/cpptest/Main.cpp @@ -0,0 +1,89 @@ +/* + * 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 +#include +#include +#include "DiscoverySDKTest.h" + +using namespace std; + +const char* options = ":hu:"; + +void RunAllTests() { + bool allTestsPassed = true; + vector errorMessages; + + auto runTest = [&allTestsPassed, &errorMessages](auto testFunction, const string& testName) { + try { + testFunction(); + } catch (const exception& e) { + errorMessages.push_back("Test " + testName + " failed: " + e.what()); + allTestsPassed = false; + } + }; + + // Ensure the connection is ready before running tests + if (DiscoverySDKTest::WaitOnConnectionReady()) { + // Add tests here + + runTest(DiscoverySDKTest::SampleTest, "SampleTest"); + + if (allTestsPassed) { + cout << "============================" << endl; + cout << "ALL DISCOVERY SDK TESTS SUCCEEDED!" << endl; + cout << "============================" << endl; + } else { + cout << "============================" << endl; + cout << "SOME TESTS FAILED:" << endl; + for (const auto& errorMessage : errorMessages) { + cout << errorMessage << endl; + } + cout << "============================" << endl; + exit(1); + } + } else { + cout << "Discovery Test not able to connect with server..." << endl; + exit(1); + } +} + +int main(int argc, char* argv[]) { + int c; + string url = "ws://127.0.0.1:9998"; + while ((c = getopt(argc, argv, options)) != -1) { + switch (c) { + case 'u': + url = optarg; + break; + case 'h': + printf("./TestFireboltDiscovery -u ws://ip:port\n"); + exit(1); + } + } + + printf("Firebolt Discovery SDK Test\n"); + + DiscoverySDKTest::CreateFireboltInstance(url); + RunAllTests(); + DiscoverySDKTest::DestroyFireboltInstance(); + + return 0; +} \ No newline at end of file diff --git a/src/sdks/discovery/src/cpp/sdk/cpptest/build.sh b/src/sdks/discovery/src/cpp/sdk/cpptest/build.sh new file mode 100644 index 000000000..4db39cbe8 --- /dev/null +++ b/src/sdks/discovery/src/cpp/sdk/cpptest/build.sh @@ -0,0 +1,40 @@ +#!/bin/bash +usage() +{ + echo "options:" + echo " -t test path" + echo " -s sysroot path" + echo " -f firebolt path" + echo " -c clear build" + echo " -h : help" + echo + echo "usage: " + echo " ./build.sh -t testpath -c -f fireboltpath -s sysrootpath" +} + +TestPath="." +FireboltPath=${FIREBOLT_PATH} +SysrootPath=${SYSROOT_PATH} +ClearBuild="N" +while getopts t:s:f:ch flag +do + case "${flag}" in + t) TestPath="${OPTARG}";; + s) SysrootPath="${OPTARG}";; + f) FireboltPath="${OPTARG}";; + c) ClearBuild="Y";; + h) usage && exit 1;; + esac +done + +if [ "${ClearBuild}" == "Y" ]; +then + rm -rf ${TestPath}/build +fi + +echo "TestPath" +echo "${TestPath}" +echo "FireboltPath" +echo ${FireboltPath} +cmake -B${TestPath}/build -S${TestPath} -DSYSROOT_PATH=${SysrootPath} -DFIREBOLT_PATH=${FireboltPath} +cmake --build ${TestPath}/build diff --git a/src/sdks/discovery/src/cpp/templates/Content/src/module_impl.cpp b/src/sdks/discovery/src/cpp/templates/Content/src/module_impl.cpp new file mode 100644 index 000000000..1b174038b --- /dev/null +++ b/src/sdks/discovery/src/cpp/templates/Content/src/module_impl.cpp @@ -0,0 +1,380 @@ +/* + * 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 "${info.title.lowercase}_impl.h" + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { +${if.providers} +/* ${PROVIDERS} */${end.if.providers} + + // Methods + /* requestUserInterest - Provide information about the entity currently displayed or selected on the screen. */ + InterestResult ContentImpl::requestUserInterest( const Discovery::InterestType& type, const Discovery::InterestReason& reason, Firebolt::Error *err ) + { + Firebolt::Error status = Firebolt::Error::NotConnected; + InterestResult interest; + FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); + if (transport != nullptr) { + + JsonObject jsonParameters; + Firebolt::Discovery::JsonData_InterestType jsonType = type; + WPEFramework::Core::JSON::Variant typeVariant(jsonType.Data()); + jsonParameters.Set(_T("type"), typeVariant); + Firebolt::Discovery::JsonData_InterestReason jsonReason = reason; + WPEFramework::Core::JSON::Variant reasonVariant(jsonReason.Data()); + jsonParameters.Set(_T("reason"), reasonVariant); + JsonData_InterestResult jsonResult; + status = transport->Invoke("content.requestUserInterest", jsonParameters, jsonResult); + if (status == Firebolt::Error::None) { + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Content.requestUserInterest is successfully invoked"); + InterestResult interestResult; + interestResult.appId = jsonResult.AppId.Value(); + { + string identifiersStr; + jsonResult.Entity.Identifiers.ToString(identifiersStr); + interestResult.entity.identifiers = identifiersStr; + if (jsonResult.Entity.Info.IsSet()) { + interestResult.entity.info = std::make_optional(); + if (jsonResult.Entity.Info.Title.IsSet()) { + interestResult.entity.info.value().title = jsonResult.Entity.Info.Title; + } + if (jsonResult.Entity.Info.Synopsis.IsSet()) { + interestResult.entity.info.value().synopsis = jsonResult.Entity.Info.Synopsis; + } + if (jsonResult.Entity.Info.SeasonNumber.IsSet()) { + interestResult.entity.info.value().seasonNumber = jsonResult.Entity.Info.SeasonNumber; + } + if (jsonResult.Entity.Info.SeasonCount.IsSet()) { + interestResult.entity.info.value().seasonCount = jsonResult.Entity.Info.SeasonCount; + } + if (jsonResult.Entity.Info.EpisodeNumber.IsSet()) { + interestResult.entity.info.value().episodeNumber = jsonResult.Entity.Info.EpisodeNumber; + } + if (jsonResult.Entity.Info.EpisodeCount.IsSet()) { + interestResult.entity.info.value().episodeCount = jsonResult.Entity.Info.EpisodeCount; + } + if (jsonResult.Entity.Info.ReleaseDate.IsSet()) { + interestResult.entity.info.value().releaseDate = jsonResult.Entity.Info.ReleaseDate; + } + if (jsonResult.Entity.Info.ContentRatings.IsSet()) { + interestResult.entity.info.value().contentRatings = std::make_optional>(); + auto index(jsonResult.Entity.Info.ContentRatings.Elements()); + while (index.Next() == true) { + Entertainment::ContentRating contentRatingsResult1; + Firebolt::Entertainment::JsonData_ContentRating jsonResult = index.Current(); + { + contentRatingsResult1.scheme = jsonResult.Scheme; + contentRatingsResult1.rating = jsonResult.Rating; + if (jsonResult.Advisories.IsSet()) { + contentRatingsResult1.advisories = std::make_optional>(); + auto index(jsonResult.Advisories.Elements()); + while (index.Next() == true) { + contentRatingsResult1.advisories.value().push_back(index.Current().Value()); + } + } + } + interestResult.entity.info.value().contentRatings->push_back(contentRatingsResult1); + } + } + } + if (jsonResult.Entity.WaysToWatch.IsSet()) { + interestResult.entity.waysToWatch = std::make_optional>(); + auto index(jsonResult.Entity.WaysToWatch.Elements()); + while (index.Next() == true) { + Entertainment::WayToWatch waysToWatchResult1; + Firebolt::Entertainment::JsonData_WayToWatch jsonResult = index.Current(); + { + { + if (jsonResult.Identifiers.AssetId.IsSet()) { + waysToWatchResult1.identifiers.assetId = jsonResult.Identifiers.AssetId; + } + if (jsonResult.Identifiers.EntityId.IsSet()) { + waysToWatchResult1.identifiers.entityId = jsonResult.Identifiers.EntityId; + } + if (jsonResult.Identifiers.SeasonId.IsSet()) { + waysToWatchResult1.identifiers.seasonId = jsonResult.Identifiers.SeasonId; + } + if (jsonResult.Identifiers.SeriesId.IsSet()) { + waysToWatchResult1.identifiers.seriesId = jsonResult.Identifiers.SeriesId; + } + if (jsonResult.Identifiers.AppContentData.IsSet()) { + waysToWatchResult1.identifiers.appContentData = jsonResult.Identifiers.AppContentData; + } + } + if (jsonResult.Expires.IsSet()) { + waysToWatchResult1.expires = jsonResult.Expires; + } + if (jsonResult.Entitled.IsSet()) { + waysToWatchResult1.entitled = jsonResult.Entitled; + } + if (jsonResult.EntitledExpires.IsSet()) { + waysToWatchResult1.entitledExpires = jsonResult.EntitledExpires; + } + if (jsonResult.OfferingType.IsSet()) { + waysToWatchResult1.offeringType = jsonResult.OfferingType; + } + if (jsonResult.HasAds.IsSet()) { + waysToWatchResult1.hasAds = jsonResult.HasAds; + } + if (jsonResult.Price.IsSet()) { + waysToWatchResult1.price = jsonResult.Price; + } + if (jsonResult.VideoQuality.IsSet()) { + waysToWatchResult1.videoQuality = std::make_optional>(); + auto index(jsonResult.VideoQuality.Elements()); + while (index.Next() == true) { + waysToWatchResult1.videoQuality.value().push_back(index.Current().Value()); + } + } + auto index(jsonResult.AudioProfile.Elements()); + while (index.Next() == true) { + waysToWatchResult1.audioProfile.push_back(index.Current().Value()); + } + if (jsonResult.AudioLanguages.IsSet()) { + waysToWatchResult1.audioLanguages = std::make_optional>(); + auto index(jsonResult.AudioLanguages.Elements()); + while (index.Next() == true) { + waysToWatchResult1.audioLanguages.value().push_back(index.Current().Value()); + } + } + if (jsonResult.ClosedCaptions.IsSet()) { + waysToWatchResult1.closedCaptions = std::make_optional>(); + auto index(jsonResult.ClosedCaptions.Elements()); + while (index.Next() == true) { + waysToWatchResult1.closedCaptions.value().push_back(index.Current().Value()); + } + } + if (jsonResult.Subtitles.IsSet()) { + waysToWatchResult1.subtitles = std::make_optional>(); + auto index(jsonResult.Subtitles.Elements()); + while (index.Next() == true) { + waysToWatchResult1.subtitles.value().push_back(index.Current().Value()); + } + } + if (jsonResult.AudioDescriptions.IsSet()) { + waysToWatchResult1.audioDescriptions = std::make_optional>(); + auto index(jsonResult.AudioDescriptions.Elements()); + while (index.Next() == true) { + waysToWatchResult1.audioDescriptions.value().push_back(index.Current().Value()); + } + } + } + interestResult.entity.waysToWatch->push_back(waysToWatchResult1); + } + } + } + interest = interestResult; + } + + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); + } + if (err != nullptr) { + *err = status; + } + + return interest; + } + + + // Events + /* onUserInterest - Provide information about the entity currently displayed or selected on the screen. */ + static void onUserInterestInnerCallback( void* notification, const void* userData, void* jsonResponse ) + { + WPEFramework::Core::ProxyType& proxyResponse = *(reinterpret_cast*>(jsonResponse)); + + ASSERT(proxyResponse.IsValid() == true); + + if (proxyResponse.IsValid() == true) { + InterestEvent interest; + + interest.appId = proxyResponse->AppId; + interest.type = proxyResponse->Type; + interest.reason = proxyResponse->Reason; + { + string identifiersStr; + (*proxyResponse).Entity.Identifiers.ToString(identifiersStr); + interest.entity.identifiers = identifiersStr; + if ((*proxyResponse).Entity.Info.IsSet()) { + interest.entity.info = std::make_optional(); + if ((*proxyResponse).Entity.Info.Title.IsSet()) { + interest.entity.info.value().title = (*proxyResponse).Entity.Info.Title; + } + if ((*proxyResponse).Entity.Info.Synopsis.IsSet()) { + interest.entity.info.value().synopsis = (*proxyResponse).Entity.Info.Synopsis; + } + if ((*proxyResponse).Entity.Info.SeasonNumber.IsSet()) { + interest.entity.info.value().seasonNumber = (*proxyResponse).Entity.Info.SeasonNumber; + } + if ((*proxyResponse).Entity.Info.SeasonCount.IsSet()) { + interest.entity.info.value().seasonCount = (*proxyResponse).Entity.Info.SeasonCount; + } + if ((*proxyResponse).Entity.Info.EpisodeNumber.IsSet()) { + interest.entity.info.value().episodeNumber = (*proxyResponse).Entity.Info.EpisodeNumber; + } + if ((*proxyResponse).Entity.Info.EpisodeCount.IsSet()) { + interest.entity.info.value().episodeCount = (*proxyResponse).Entity.Info.EpisodeCount; + } + if ((*proxyResponse).Entity.Info.ReleaseDate.IsSet()) { + interest.entity.info.value().releaseDate = (*proxyResponse).Entity.Info.ReleaseDate; + } + if ((*proxyResponse).Entity.Info.ContentRatings.IsSet()) { + interest.entity.info.value().contentRatings = std::make_optional>(); + auto index((*proxyResponse).Entity.Info.ContentRatings.Elements()); + while (index.Next() == true) { + Entertainment::ContentRating contentRatingsResult1; + Firebolt::Entertainment::JsonData_ContentRating jsonResult = index.Current(); + contentRatingsResult1.scheme = jsonResult.Scheme; + contentRatingsResult1.rating = jsonResult.Rating; + if (jsonResult.Advisories.IsSet()) { + contentRatingsResult1.advisories = std::make_optional>(); + auto index(jsonResult.Advisories.Elements()); + while (index.Next() == true) { + contentRatingsResult1.advisories.value().push_back(index.Current().Value()); + } + } + interest.entity.info.value().contentRatings.value().push_back(contentRatingsResult1); + } + } + } + if ((*proxyResponse).Entity.WaysToWatch.IsSet()) { + interest.entity.waysToWatch = std::make_optional>(); + auto index((*proxyResponse).Entity.WaysToWatch.Elements()); + while (index.Next() == true) { + Entertainment::WayToWatch waysToWatchResult1; + Firebolt::Entertainment::JsonData_WayToWatch jsonResult = index.Current(); + { + if (jsonResult.Identifiers.AssetId.IsSet()) { + waysToWatchResult1.identifiers.assetId = jsonResult.Identifiers.AssetId; + } + if (jsonResult.Identifiers.EntityId.IsSet()) { + waysToWatchResult1.identifiers.entityId = jsonResult.Identifiers.EntityId; + } + if (jsonResult.Identifiers.SeasonId.IsSet()) { + waysToWatchResult1.identifiers.seasonId = jsonResult.Identifiers.SeasonId; + } + if (jsonResult.Identifiers.SeriesId.IsSet()) { + waysToWatchResult1.identifiers.seriesId = jsonResult.Identifiers.SeriesId; + } + if (jsonResult.Identifiers.AppContentData.IsSet()) { + waysToWatchResult1.identifiers.appContentData = jsonResult.Identifiers.AppContentData; + } + } + if (jsonResult.Expires.IsSet()) { + waysToWatchResult1.expires = jsonResult.Expires; + } + if (jsonResult.Entitled.IsSet()) { + waysToWatchResult1.entitled = jsonResult.Entitled; + } + if (jsonResult.EntitledExpires.IsSet()) { + waysToWatchResult1.entitledExpires = jsonResult.EntitledExpires; + } + if (jsonResult.OfferingType.IsSet()) { + waysToWatchResult1.offeringType = jsonResult.OfferingType; + } + if (jsonResult.HasAds.IsSet()) { + waysToWatchResult1.hasAds = jsonResult.HasAds; + } + if (jsonResult.Price.IsSet()) { + waysToWatchResult1.price = jsonResult.Price; + } + if (jsonResult.VideoQuality.IsSet()) { + waysToWatchResult1.videoQuality = std::make_optional>(); + auto index(jsonResult.VideoQuality.Elements()); + while (index.Next() == true) { + waysToWatchResult1.videoQuality.value().push_back(index.Current().Value()); + } + } + auto index(jsonResult.AudioProfile.Elements()); + while (index.Next() == true) { + waysToWatchResult1.audioProfile.push_back(index.Current().Value()); + } + if (jsonResult.AudioLanguages.IsSet()) { + waysToWatchResult1.audioLanguages = std::make_optional>(); + auto index(jsonResult.AudioLanguages.Elements()); + while (index.Next() == true) { + waysToWatchResult1.audioLanguages.value().push_back(index.Current().Value()); + } + } + if (jsonResult.ClosedCaptions.IsSet()) { + waysToWatchResult1.closedCaptions = std::make_optional>(); + auto index(jsonResult.ClosedCaptions.Elements()); + while (index.Next() == true) { + waysToWatchResult1.closedCaptions.value().push_back(index.Current().Value()); + } + } + if (jsonResult.Subtitles.IsSet()) { + waysToWatchResult1.subtitles = std::make_optional>(); + auto index(jsonResult.Subtitles.Elements()); + while (index.Next() == true) { + waysToWatchResult1.subtitles.value().push_back(index.Current().Value()); + } + } + if (jsonResult.AudioDescriptions.IsSet()) { + waysToWatchResult1.audioDescriptions = std::make_optional>(); + auto index(jsonResult.AudioDescriptions.Elements()); + while (index.Next() == true) { + waysToWatchResult1.audioDescriptions.value().push_back(index.Current().Value()); + } + } + interest.entity.waysToWatch.value().push_back(waysToWatchResult1); + } + } + } + + proxyResponse.Release(); + + IContent::IOnUserInterestNotification& notifier = *(reinterpret_cast(notification)); + notifier.onUserInterest(interest); + } + } + void ContentImpl::subscribe( IContent::IOnUserInterestNotification& notification, Firebolt::Error *err ) + { + const string eventName = _T("content.onUserInterest"); + Firebolt::Error status = Firebolt::Error::None; + + JsonObject jsonParameters; + + status = FireboltSDK::Event::Instance().Subscribe(eventName, jsonParameters, onUserInterestInnerCallback, reinterpret_cast(¬ification), nullptr); + + if (err != nullptr) { + *err = status; + } + } + void ContentImpl::unsubscribe( IContent::IOnUserInterestNotification& notification, Firebolt::Error *err ) + { + Firebolt::Error status = FireboltSDK::Event::Instance().Unsubscribe(_T("content.onUserInterest"), reinterpret_cast(¬ification)); + + if (err != nullptr) { + *err = status; + } + } + + +}//namespace ${info.Title} +}${end.if.implementations} + +${if.enums} + +namespace WPEFramework { + +/* ${ENUMS} */ +}${end.if.enums} + diff --git a/src/sdks/discovery/src/cpp/templates/Content/src/module_impl.h b/src/sdks/discovery/src/cpp/templates/Content/src/module_impl.h new file mode 100644 index 000000000..a01a3eb3e --- /dev/null +++ b/src/sdks/discovery/src/cpp/templates/Content/src/module_impl.h @@ -0,0 +1,136 @@ +/* + * 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 "FireboltSDK.h" +#include "IModule.h" +/* ${IMPORTS} */ +#include "${info.title.lowercase}.h" + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { + + + // Types + class JsonData_InterestResult: public WPEFramework::Core::JSON::Container { + public: + ~JsonData_InterestResult() override = default; + + public: + JsonData_InterestResult() + : WPEFramework::Core::JSON::Container() + { + Add(_T("appId"), &AppId); + Add(_T("entity"), &Entity); + } + + JsonData_InterestResult(const JsonData_InterestResult& other) + { + Add(_T("appId"), &AppId); + AppId = other.AppId; + Add(_T("entity"), &Entity); + Entity = other.Entity; + } + + JsonData_InterestResult& operator=(const JsonData_InterestResult& other) + { + Add(_T("appId"), &AppId); + AppId = other.AppId; + Add(_T("entity"), &Entity); + Entity = other.Entity; + return (*this); + } + + public: + FireboltSDK::JSON::String AppId; + Firebolt::Entity::JsonData_EntityDetails Entity; + }; + + class JsonData_InterestEvent: public WPEFramework::Core::JSON::Container { + public: + ~JsonData_InterestEvent() override = default; + + public: + JsonData_InterestEvent() + : WPEFramework::Core::JSON::Container() + { + Add(_T("appId"), &AppId); + Add(_T("type"), &Type); + Add(_T("reason"), &Reason); + Add(_T("entity"), &Entity); + } + + JsonData_InterestEvent(const JsonData_InterestEvent& other) + { + Add(_T("appId"), &AppId); + AppId = other.AppId; + Add(_T("type"), &Type); + Type = other.Type; + Add(_T("reason"), &Reason); + Reason = other.Reason; + Add(_T("entity"), &Entity); + Entity = other.Entity; + } + + JsonData_InterestEvent& operator=(const JsonData_InterestEvent& other) + { + Add(_T("appId"), &AppId); + AppId = other.AppId; + Add(_T("type"), &Type); + Type = other.Type; + Add(_T("reason"), &Reason); + Reason = other.Reason; + Add(_T("entity"), &Entity); + Entity = other.Entity; + return (*this); + } + + public: + FireboltSDK::JSON::String AppId; + Firebolt::Discovery::JsonData_InterestType Type; + Firebolt::Discovery::JsonData_InterestReason Reason; + Firebolt::Entity::JsonData_EntityDetails Entity; + }; + + class ContentImpl : public IContent, public IModule { + + public: + ContentImpl() = default; + ContentImpl(const ContentImpl&) = delete; + ContentImpl& operator=(const ContentImpl&) = delete; + + ~ContentImpl() override = default; + + // Methods & Events + // signature callback params: + // method result properties : + void subscribe( IContent::IOnUserInterestNotification& notification, Firebolt::Error *err = nullptr ) override; + void unsubscribe( IContent::IOnUserInterestNotification& notification, Firebolt::Error *err = nullptr ) override; + + /* + requestUserInterest + Provide information about the entity currently displayed or selected on the screen. + */ + InterestResult requestUserInterest( const Discovery::InterestType& type, const Discovery::InterestReason& reason, Firebolt::Error *err = nullptr ) override; + + }; + +}//namespace ${info.Title} +}${end.if.implementations} diff --git a/src/sdks/manage/package.json b/src/sdks/manage/package.json index 98e856a1c..b7d1e981f 100644 --- a/src/sdks/manage/package.json +++ b/src/sdks/manage/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/manage-sdk", - "version": "1.2.1-next.2", + "version": "1.3.0-next.3", "description": "The Firebolt Manage JS SDK", "main": "./dist/lib/firebolt-manage.mjs", "types": "./dist/lib/firebolt-manage.d.ts", diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp index c28aa7e0c..4d2698dbe 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp +++ b/src/sdks/manage/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 diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp index f8a388724..6dde2c9c2 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp @@ -617,9 +617,7 @@ void ManageSDKTest::KeyboardProvider::SendMessage(bool response) cout << _parameters.message << " : "; getline(cin, key); if (response) { - Firebolt::Keyboard::KeyboardResult keyboardResult; - keyboardResult.text = key; - keyboardResult.canceled = false; + std::string keyboardResult = key; cout << " Invoking _session->result " << endl; _session->result(keyboardResult); } else {