From 83a48cf8a8ff7660a30210ec04add136f19aeb5d Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Thu, 23 Nov 2023 01:01:06 -0500 Subject: [PATCH] Manage Test update based on provider integration --- src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp | 11 ++- .../src/cpp/sdk/cpptest/ManageSDKTest.cpp | 70 ++++++++++++++++++- .../src/cpp/sdk/cpptest/ManageSDKTest.h | 22 +++++- 3 files changed, 99 insertions(+), 4 deletions(-) diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp index df37559ae..7d5c79a13 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp @@ -3,7 +3,7 @@ void ShowMenu() { - printf("Enter\n" + printf("Options ---- >\n" "\tN : Get Device Name\n" "\tS : Set Device Name\n" "\tC : Subscribe/Unsubscribe for Device Name Change\n" @@ -19,6 +19,8 @@ void ShowMenu() #ifdef RPC_ONLY "\tP : Subscribe/Unsubscribe for PinChallenge RequestChallenge\n" #endif + "\tD : Register for Keyboard Provider\n" + "\tE : Send Keyboard Result to Provider\n" "\tQ : Quit\n\n" ); } @@ -131,6 +133,13 @@ int main (int argc, char* argv[]) break; } #endif + case 'D': { + ManageSDKTest::RegisterKeyboardProvider(); + break; + } + case 'E': { + ManageSDKTest::SendMessageToKeyboardProvider(); + } default: break; } diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp index f5d498518..c4c7ebd5f 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp @@ -28,6 +28,7 @@ ManageSDKTest::OnPreferredAudioLanguagesChangedNotification ManageSDKTest::_pref #ifdef RPC_ONLY ManageSDKTest::OnRequestChallengeNotification ManageSDKTest::_requestChallengeNotification; #endif +ManageSDKTest::KeyboardProvider ManageSDKTest::_keyboardProvider; void ManageSDKTest::ConnectionChanged(const bool connected, const Firebolt::Error error) { @@ -99,7 +100,7 @@ void ManageSDKTest::SetDeviceName() } } -void ManageSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged( const std::string& name ) +void ManageSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged( const std::string& name) { cout << "Name changed, new name --> " << name << endl; } @@ -270,7 +271,7 @@ void ManageSDKTest::SetLocalizationPreferredAudioLanguages() } } -void ManageSDKTest::OnPreferredAudioLanguagesChangedNotification::onPreferredAudioLanguagesChanged( const std::vector& languages ) +void ManageSDKTest::OnPreferredAudioLanguagesChangedNotification::onPreferredAudioLanguagesChanged( const std::vector& languages) { cout << "PreferredAudioLanguages Changed, new languages --> " << endl; for (auto language : languages) { @@ -342,3 +343,68 @@ void ManageSDKTest::UnsubscribePinChallengeRequestChallenge() } } #endif + +ManageSDKTest::KeyboardProvider::KeyboardProvider() + : _session(nullptr) + , _parameters() + , _keyInput(false) +{ +} + +void ManageSDKTest::KeyboardProvider::keyboardLoop() +{ + if (_keyInput) { + cout << " Invoking _session.get()->focus " << endl; + _session.get()->focus(); + string key; + cout << _parameters.message << " : "; + getchar(); + getline(cin, key); + cout<< " key --> " << key; + cin.putback('\n'); + Firebolt::Keyboard::KeyboardResult keyboardResult; + keyboardResult.text = key; + keyboardResult.canceled = false; + cout << " Invoking _session.get()->result " << endl; + cout << " keyboardResult.text " << keyboardResult.text << endl; + _session.get()->result(keyboardResult); + _keyInput = false; + } else { + cout << " there is no active keyboard input session " << endl; + } +} + +void ManageSDKTest::KeyboardProvider::standard(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session) +{ + cout << "KeyboardProvider Standard is invoked" << endl; + startKeyboardSession(parameters, std::move(session)); +} + +void ManageSDKTest::KeyboardProvider::password(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session) +{ + cout << "KeyboardProvider Password is invoked" << endl; + startKeyboardSession(parameters, std::move(session)); +} + +void ManageSDKTest::KeyboardProvider::email(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session) +{ + cout << "KeyboardProvider Email is invoked" << endl; + startKeyboardSession(parameters, std::move(session)); +} + +void ManageSDKTest::KeyboardProvider::startKeyboardSession( const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session ) +{ + _session = std::move(session); + _parameters = parameters; + _keyInput = true; +} + +void ManageSDKTest::RegisterKeyboardProvider() +{ + Firebolt::IFireboltAccessor::Instance().KeyboardInterface().provide(_keyboardProvider); +} + +void ManageSDKTest::SendMessageToKeyboardProvider() +{ + _keyboardProvider.keyboardLoop(); +} diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.h b/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.h index 894aa3324..72812dce7 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.h +++ b/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.h @@ -42,11 +42,28 @@ class ManageSDKTest { }; #ifdef RPC_ONLY - struct OnRequestChallengeNotification : public Firebolt::PinChallenge::IPinChallenge::IOnRequestChallengeNotification { + class OnRequestChallengeNotification : public Firebolt::PinChallenge::IPinChallenge::IOnRequestChallengeNotification { public: void onRequestChallenge( const Firebolt::PinChallenge::PinChallengeProviderRequest& ) override; }; #endif + class KeyboardProvider : public Firebolt::Keyboard::IKeyboardProvider { + public: + KeyboardProvider(); + ~KeyboardProvider() override = default; + void standard( const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session ) override; + void password( const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session ) override; + void email( const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session ) override; + void keyboardLoop(); + + private: + void startKeyboardSession(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session); + + private: + std::unique_ptr _session; + Firebolt::Keyboard::KeyboardParameters _parameters; + bool _keyInput; + }; public: ManageSDKTest() = default; virtual ~ManageSDKTest() = default; @@ -74,6 +91,8 @@ class ManageSDKTest { static void SubscribePinChallengeRequestChallenge(); static void UnsubscribePinChallengeRequestChallenge(); #endif + static void RegisterKeyboardProvider(); + static void SendMessageToKeyboardProvider(); static bool WaitOnConnectionReady(); private: @@ -86,5 +105,6 @@ class ManageSDKTest { #ifdef RPC_ONLY static OnRequestChallengeNotification _requestChallengeNotification; #endif + static KeyboardProvider _keyboardProvider; };