7#include <QtCore/private/qohoscommon_p.h>
8#include <QtCore/private/qohoslogger_p.h>
9#include <QtCore/qglobal.h>
10#include <QtCore/qpoint.h>
11#include <arkui/native_type.h>
15#include <qohosutils.h>
32 const char *
value()
const;
40template<
typename Func, Func f,
typename... FuncArgs>
53template<
typename Func, Func f,
typename... FuncArgs>
64 return std::to_string(funcArg);
71 return std::to_string(funcArg) +
":enum(" +
typeid(T).name() +
"):";
78 char buffer[] =
"0xFFFFFFFFFFFFFFFF";
79 std::snprintf(buffer,
sizeof(buffer),
"%p", funcArg);
80 return std::string(buffer);
92 return '"' +
std::string(funcArg) +
'"';
95template<
typename... FuncArgs>
98 std::string allArgsString;
99 std::string argsStrings[] = {buildFuncArgString(funcArgs)...};
100 for (
const auto &argString : argsStrings) {
101 if (!allArgsString.empty())
102 allArgsString +=
", ";
103 allArgsString += argString;
106 return std::string(funcName) +
"(" + allArgsString +
")";
119 "callArkUiFunc: %s => %s",
127template<
typename Func,
typename... FuncArgs>
136 qOhosPrintfDebug(
"callArkUiFunc: %s", buildFuncCallString(funcName, funcArgs...).c_str());
143 return {
static_cast<
float>(point.x()),
static_cast<
float>(point.y())};
166template<
typename Func, Func f,
typename... FuncArgs>
176 if (funcResult != ::ARKUI_ERROR_CODE_NO_ERROR) {
177 qOhosReportFatalErrorAndAbort(
178 "ArkUi function call %s failed with error: %d",
179 buildFuncCallString(func.name(), funcArgs...).c_str(), funcResult);
194 "ArkUi function call %s failed (returned null)",
200template<
typename Func, Func f,
typename... FuncArgs>
operator std::string() const
operator const char *() const
const char * value() const
CZString(const char *value)
JsWindowRef(JsWindowRef &&)=delete
JsWindowRef(const JsWindowRef &)=delete
JsWindowRef & operator=(JsWindowRef &&)=delete
JsWindowRef(JsWindowId windowId, QNapi::Object jsWindow)
Result call(const std::string &methodName, const std::vector< QNapi::ValueWrapper > &args={}) const
bool isWindowShown() const
JsWindowRef & operator=(const JsWindowRef &)=delete
QOhosOptional(const std::optional< U > &other)
T valueOr(const T &fallback) const
QOhosOptional< T > & operator=(const std::optional< U > &other)
QOhosOptional(const QOhosOptional< void > &empty)
QOhosOptional< T > & operator=(const T &value)
std::enable_if_t< qohosplugincore_h_detail::isQOhosOptional< QOhosInvokeResult< Func, T > >, QOhosInvokeResult< Func, T > > andThen(Func &&func) const
QOhosOptional< T > & operator=(const QOhosOptional< void > &empty)
QOhosOptional(const T &value)
T & emplace(Args &&...args)
QOhosOptional< T > & operator=(const QOhosOptional< T > &other)
QOhosOptional< QOhosInvokeResult< Func, T > > transform(Func &&func) const
QOhosOptional(const QOhosOptional< T > &other)
virtual void startQAbilityInstance(QNapi::Object baseQAbility, QObjectThreadSafeRef qwindow, QNapi::Object optStartOptions, std::function< void(JsState &, std::shared_ptr< QAbilityPeer >)> startupNotifyFunc)=0
virtual void tagWidgetOrWindowAsFloatWindow(QObject *widgetOrWindow, bool floatWindowEnabled)=0
virtual void startAppProcess(QNapi::Object baseQAbility, const std::string &processId, QNapi::Object want, QNapi::Object optStartOptions)=0
virtual void startAppProcess(QNapi::Object baseQAbility, const std::string &processId, QNapi::Object want, QNapi::Object optStartOptions, std::function< void(JsState &)> continueFunc)=0
virtual void startNoUiChildProcess(JsState &jsState, const std::string &libraryName, const std::vector< std::string > &args)=0
JsState & jsState() const
JsState & operator=(const JsState &)=delete
virtual void addNewWantConsumer(QOhosConsumer< JsState &, QNapi::Object, QNapi::Object > wantConsumer)=0
virtual QtRunMode qtRunMode()=0
JsState(const JsState &)=delete
virtual std::shared_ptr< QAbilityPeer > tryGetQAbilityPeerByInstanceId(const std::string &instanceId)=0
virtual void * getAttachedObjectWithLazyCreate(const std::type_info &objectTypeInfo, QOhosSupplier< std::shared_ptr< void > > objectFactory)=0
virtual void startAppProcess(const std::string &processId, QNapi::Object requestWant, QNapi::Object optStartOptions, std::function< void(JsState &)> continueFunc)=0
virtual void startNoUiChildProcess(const std::string &libraryName, const std::vector< std::string > &args)=0
virtual std::shared_ptr< QAbilityPeer > tryGetQAbilityPeerByQWindow(QObjectThreadSafeRef qwindow)=0
virtual void visitEachQAbilityPeer(const std::function< void(std::shared_ptr< QAbilityPeer >)> &visitor)=0
QNapi::Symbol getJsSymbolForType()
virtual std::shared_ptr< QAbilityPeer > defaultQAbilityPeer()=0
virtual std::shared_ptr< QAbilityPeer > tryGetQAbilityPeerByInstance(QNapi::Object qAbility)=0
virtual QOhosOptional< QNapi::Object > optAppLaunchParam()=0
virtual QNapi::Object appLaunchWant()=0
std::enable_if_t< std::is_default_constructible< T >::value, T > & getAttachedObjectWithLazyCreate()
virtual QNapi::Symbol getJsSymbolForType(const std::type_info &typeInfo)=0
virtual void startNewQAbilityInstance(std::shared_ptr< QAbilityPeer > baseQAbilityPeer, QObjectThreadSafeRef qwindow, QNapi::Object optStartOptions, std::function< void(JsState &, std::shared_ptr< QAbilityPeer >)> startupNotifyFunc)=0
virtual void startAppProcess(const std::string &processId, QNapi::Object requestWant, QNapi::Object optStartOptions={})=0
JsWindowsTracker()=delete
static void tagWindowAsClosing(QNapi::Object jsWindow, const char *logContext)
static bool isWindowClosing(QNapi::Object jsWindow)
virtual QAbilityInfo readAbilityInfo(const QNapi::Object &ability) const =0
virtual ~QAbilityEngine()
virtual QOhosOptional< QNapi::Promise > qWindowDestroyPromise()=0
virtual std::string instanceId()=0
virtual QObjectThreadSafeRef qWindowRef()=0
virtual QNapi::Object launchWant()=0
virtual bool isTerminating()=0
virtual void setQWindow(Napi::Env env, QObjectThreadSafeRef qwindow)=0
virtual void * tryCastWithTypeIdObject(const void *matchTypeIdObject)=0
virtual std::shared_ptr< std::atomic_bool > destroyAllowedFlag()=0
virtual QNapi::Object qAbility()=0
virtual QNapi::Object uiContext()=0
virtual void setOnContinueRequestsHandler(std::function< void(JsState &, QNapi::Object, QOhosConsumer< JsState &, QOhosAbilityOnContinueResult >)> requestsHandler)=0
virtual QNapi::Object launchParam()=0
virtual QNapi::Object windowStage()=0
void * tryCastWithTypeIdObject(const void *matchTypeIdObject) final
static std::shared_ptr< QUiAbilityPeer > tryCastFromQAbilityPeerOrNull(std::shared_ptr< QAbilityPeer > qAbilityPeer)
~QUiAbilityPeer() override
virtual QNapi::Object window()=0
bool operator!=(const TypedId &other) const
IdValueType value() const
bool operator==(const TypedId &other) const
TypedId(IdValueType value)
TypedId(const TypedId &other)
TypedId & operator=(const TypedId &other)
TypedId & operator=(TypedId &&other)
bool operator<(const TypedId &other) const
std::string buildFuncCallString(const char *funcName, FuncArgs &&...funcArgs)
std::enable_if_t< std::is_arithmetic< T >::value, std::string > buildFuncArgString(const T &funcArg)
constexpr bool arkUiCallsLogging
std::string buildFuncArgString(CZString funcArg)
std::enable_if_t< std::is_void< QOhosInvokeResult< Func, FuncArgs... > >::value, void > callArkUiFunc(const char *funcName, Func &&func, FuncArgs &&...funcArgs)
std::array< float, 2 > toFloatArray(const QPointF &point)
QOhosInvokeResult< Func, FuncArgs... > callArkUi(QOhosNamedFunc< Func, f > func, FuncArgs &&...funcArgs)
QOhosOptional< WindowProperties > tryGetWindowProperties(JsWindowId jsWindowId)
std::enable_if_t< std::is_same< QOhosInvokeResult< Func, FuncArgs... >, std::int32_t >::value||std::is_enum< QOhosInvokeResult< Func, FuncArgs... > >::value, void > callArkUiOrFailOnErrorResult(QOhosNamedFunc< Func, f > func, FuncArgs &&...funcArgs)
Combined button and popup list for selecting options.
QOhosOptional< std::uintmax_t > tryParseStringAsUIntMax(const std::string &inputString)
std::string const char * mapBoolToTrueFalseStr(bool value)
void invokeInJsThread(std::function< void(JsState &)> task)
void dispatchNewWant(QNapi::Object want, QNapi::Object launchParam)
QOhosConsumer< T > makeCompressingAsyncConsumer(QOhosConsumer< T > baseConsumer, QOhosConsumer< std::function< void()> > asyncExecutor)
void removeMatchingJsQAbilityPeer(QNapi::Object qAbility)
std::enable_if_t< std::is_integral< T >::value &&std::is_unsigned< T >::value, QOhosOptional< T > > tryParseStringAsUnsignedInteger(const std::string &inputString)
T evalInJsThreadWithConsumer(std::function< void(QtOhos::JsState &, std::function< void(T)>)> evalFunc)
ForwardIt removeMatchingWithLookahead(ForwardIt firstIt, ForwardIt lastIt, Predicate &&predicate)
void initJsThreadState(napi_env env, std::map< std::string, QNapi::Reference< QNapi::Function > > &&jsModulesFactories, std::shared_ptr< AppFunctions > appFunctions, QtRunMode qtRunMode)
Q_REQUIRED_RESULT bool tryInvokeInQtThreadAndTryWaitForContinue(std::function< void(std::function< void()>)> &&task, std::chrono::nanoseconds timeout)
auto evalInJsThread(Func &&func) -> decltype(func(std::declval< JsState & >()))
QOhosAbilityOnContinueResult
void tupleForEach(const std::tuple< TupleElements... > &tuple, UnaryFunc func, std::index_sequence< TupleIndices... >)
void runInJsThreadAndWait(const std::function< void(JsState &)> &task)
std::shared_ptr< QtOhos::QAbilityPeer > tryMapOptMainWindowToAbilityPeer(QtOhos::JsState &jsState, QOhosOptional< QtOhos::QObjectThreadSafeRef > optInstanceMainWindowRef)
void tupleForEach(const std::tuple< TupleElements... > &tuple, UnaryFunc func)
void invokeInJsThreadAndWaitForContinue(std::function< void(JsState &, std::function< void()>)> &&task)
QOhosOptional< double > tryParseStringAsFiniteDouble(const std::string &inputString)
void addJsQAbilityPeer(std::shared_ptr< QAbilityPeer > qAbilityPeer)
constexpr T makeCopyByValue(T value)
constexpr bool isQOhosOptional
constexpr bool hasEqualityComparator
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QOhosDisplayInfo::DisplaySourceMode))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QOhosDisplayInfo::JsDisplayOrientation))
std::enable_if_t< qohosplugincore_h_detail::hasEqualityComparator< T, U >, bool > operator!=(const QOhosOptional< T > &lhs, const U &rhs)
std::enable_if_t< qohosplugincore_h_detail::hasEqualityComparator< T, U >, bool > operator==(const QOhosOptional< T > &lhs, const QOhosOptional< U > &rhs)
std::enable_if_t< qohosplugincore_h_detail::hasEqualityComparator< T, U >, bool > operator!=(const T &lhs, const QOhosOptional< U > &rhs)
std::enable_if_t< qohosplugincore_h_detail::hasEqualityComparator< T, U >, bool > operator==(const T &lhs, const QOhosOptional< U > &rhs)
QOhosOptional< void > makeEmptyQOhosOptional()
QOhosOptional< T > makeQOhosOptional(const T &value)
std::enable_if_t< qohosplugincore_h_detail::hasEqualityComparator< T, U >, bool > operator!=(const QOhosOptional< T > &lhs, const QOhosOptional< U > &rhs)
std::enable_if_t< qohosplugincore_h_detail::hasEqualityComparator< T, U >, bool > operator==(const QOhosOptional< T > &lhs, const U &rhs)
QOhosOptional< QOhosDisplayInfo::JsDisplayId > displayId
QSizeF physicalSize() const
QOhosOptional< QPoint > topLeftOffsetPixels
QRect displayGeometryPixels() const
static QOhosDisplayInfo makeFromOhosDisplayObject(QtOhos::JsState &jsState, QNapi::Object displayObject)
QOhosOptional< JsDisplayOrientation > orientation
QOhosOptional< DisplaySourceMode > sourceMode
EvaluateSequentially(Args &&...)