-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make focuable interface separate
- Loading branch information
Showing
7 changed files
with
82 additions
and
41 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
languages/cpp/templates/codeblocks/interface-focusable.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
static void ProviderInvokeSession(std::string& methodName, JsonObject& jsonParameters, Firebolt::Error *err = nullptr) | ||
{ | ||
Firebolt::Error status = Firebolt::Error::NotConnected; | ||
FireboltSDK::Transport<WPEFramework::Core::JSON::IElement>* transport = FireboltSDK::Accessor::Instance().GetTransport(); | ||
if (transport != nullptr) { | ||
|
||
JsonObject jsonResult; | ||
status = transport->Invoke(methodName, jsonParameters, jsonResult); | ||
if (status == Firebolt::Error::None) { | ||
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "%s is successfully invoked", methodName.c_str()); | ||
} | ||
|
||
} else { | ||
FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "Error in getting Transport err = %d", status); | ||
} | ||
if (err != nullptr) { | ||
*err = status; | ||
} | ||
} | ||
static void ProviderFocusSession(std::string methodName, std::string& correlationId, Firebolt::Error *err = nullptr) | ||
{ | ||
JsonObject jsonParameters; | ||
WPEFramework::Core::JSON::Variant CorrelationId(correlationId); | ||
jsonParameters.Set(_T("correlationId"), CorrelationId); | ||
|
||
ProviderInvokeSession(methodName, jsonParameters, err); | ||
} | ||
static void ProviderResultSession(std::string methodName, std::string& correlationId, ${provider.xresponse.name} result, Firebolt::Error *err = nullptr) | ||
{ | ||
JsonObject jsonParameters; | ||
WPEFramework::Core::JSON::Variant CorrelationId(correlationId); | ||
jsonParameters.Set(_T("correlationId"), CorrelationId); | ||
|
||
${provider.xresponse.serialization} | ||
ProviderInvokeSession(methodName, jsonParameters, err); | ||
} | ||
static void ProviderErrorSession(std::string methodName, std::string& correlationId, ${provider.xerror.name} result, Firebolt::Error *err = nullptr) | ||
{ | ||
JsonObject jsonParameters; | ||
WPEFramework::Core::JSON::Variant CorrelationId(correlationId); | ||
jsonParameters.Set(_T("correlationId"), CorrelationId); | ||
|
||
${provider.xerror.serialization} | ||
ProviderInvokeSession(methodName, jsonParameters, err); | ||
} | ||
|
||
${methods} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
struct I${info.Title}Session : virtual public IFocussableProviderSession { | ||
virtual ~I${info.Title}Session() override = default; | ||
|
||
virtual void error( ${provider.xerror.name} error, Firebolt::Error *err = nullptr ) = 0; | ||
virtual void result( ${provider.xresponse.name} result, Firebolt::Error *err = nullptr ) = 0; | ||
}; | ||
|
||
struct I${info.Title}Provider { | ||
virtual ~I${info.Title}Provider() = default; | ||
|
||
${methods} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters