From c04dcc2e7d834218ef2d4194331e383402495ae1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 20:07:22 +0200 Subject: Adding upstream version 2:20.4+dfsg. Signed-off-by: Daniel Baumann --- xbmc/interfaces/generic/ILanguageInvoker.cpp | 96 ++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 xbmc/interfaces/generic/ILanguageInvoker.cpp (limited to 'xbmc/interfaces/generic/ILanguageInvoker.cpp') diff --git a/xbmc/interfaces/generic/ILanguageInvoker.cpp b/xbmc/interfaces/generic/ILanguageInvoker.cpp new file mode 100644 index 0000000..df1193e --- /dev/null +++ b/xbmc/interfaces/generic/ILanguageInvoker.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2015-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "ILanguageInvoker.h" + +#include "interfaces/generic/ILanguageInvocationHandler.h" + +#include +#include + +ILanguageInvoker::ILanguageInvoker(ILanguageInvocationHandler *invocationHandler) + : m_id(-1), + m_state(InvokerStateUninitialized), + m_invocationHandler(invocationHandler) +{ } + +ILanguageInvoker::~ILanguageInvoker() = default; + +bool ILanguageInvoker::Execute(const std::string &script, const std::vector &arguments /* = std::vector() */) +{ + if (m_invocationHandler) + m_invocationHandler->OnScriptStarted(this); + + return execute(script, arguments); +} + +bool ILanguageInvoker::Stop(bool abort /* = false */) +{ + return stop(abort); +} + +bool ILanguageInvoker::IsActive() const +{ + return GetState() > InvokerStateUninitialized && GetState() < InvokerStateScriptDone; +} + +bool ILanguageInvoker::IsRunning() const +{ + return GetState() == InvokerStateRunning; +} + +bool ILanguageInvoker::IsStopping() const +{ + return GetState() == InvokerStateStopping; +} + +void ILanguageInvoker::pulseGlobalEvent() +{ + if (m_invocationHandler) + m_invocationHandler->PulseGlobalEvent(); +} + +bool ILanguageInvoker::onExecutionInitialized() +{ + if (m_invocationHandler == NULL) + return false; + + return m_invocationHandler->OnScriptInitialized(this); +} + +void ILanguageInvoker::AbortNotification() +{ + if (m_invocationHandler) + m_invocationHandler->NotifyScriptAborting(this); +} + +void ILanguageInvoker::onExecutionFailed() +{ + if (m_invocationHandler) + m_invocationHandler->OnExecutionEnded(this); +} + +void ILanguageInvoker::onExecutionDone() +{ + if (m_invocationHandler) + m_invocationHandler->OnExecutionEnded(this); +} + +void ILanguageInvoker::onExecutionFinalized() +{ + if (m_invocationHandler) + m_invocationHandler->OnScriptFinalized(this); +} + +void ILanguageInvoker::setState(InvokerState state) +{ + if (state <= m_state) + return; + + m_state = state; +} -- cgit v1.2.3