7#include <QtCore/private/qohoscommon_p.h>
8#include <QtCore/qglobal.h>
9#include <QtCore/qlogging.h>
16#include <qohosplugincore.h>
33template<
typename IdValueType,
typename TypeTag>
60template<
typename ...
Ts>
64template<
typename ForwardIt,
typename Predicate>
69 template<
typename... Args>
73template<
typename UnaryFunc,
typename... TupleElements,
std::size_t... TupleIndices>
76template<
typename UnaryFunc,
typename... TupleElements>
77void tupleForEach(
const std::tuple<TupleElements...> &tuple, UnaryFunc func);
81 QOhosConsumer<T> baseConsumer, QOhosConsumer<std::function<
void()>> asyncExecutor);
98 QtOhos::
JsState &jsState, QOhosOptional<QtOhos::QObjectThreadSafeRef> optInstanceMainWindowRef);
100template<
typename ForwardIt,
typename Predicate>
103 if (firstIt == lastIt)
106 auto outputIt = firstIt;
107 auto currentIt = firstIt;
108 auto nextIt = currentIt;
111 while (nextIt != lastIt) {
112 if (!predicate(*currentIt, *nextIt)) {
113 if (outputIt != currentIt) {
114 *outputIt =
std::move(*currentIt);
122 if (outputIt != currentIt) {
123 *outputIt =
std::move(*currentIt);
130template<
typename UnaryFunc,
typename... TupleElements,
std::size_t... TupleIndices>
136template<
typename UnaryFunc,
typename... TupleElements>
139 tupleForEach(tuple, func, std::make_index_sequence<
sizeof...(TupleElements)>());
148template<
typename IdValueType,
typename Tag>
154template<
typename IdValueType,
typename Tag>
157 return m_value == other.m_value;
160template<
typename IdValueType,
typename Tag>
163 return m_value != other.m_value;
166template<
typename IdValueType,
typename Tag>
169 return m_value < other.m_value;
172template<
typename IdValueType,
typename Tag>
178template<
typename IdValueType,
typename Tag>
181template<
typename IdValueType,
typename Tag>
184template<
typename IdValueType,
typename Tag>
187template<
typename IdValueType,
typename Tag>
192 QOhosConsumer<T> baseConsumer, QOhosConsumer<std::function<
void()>> asyncExecutor)
196 QOhosConsumer<T> baseConsumer;
197 QOhosConsumer<std::function<
void()>> asyncExecutor;
198 std::mutex pendingValueMutex;
199 QOhosOptional<T> pendingValue;
202 auto context =
std::make_shared<Context>();
203 context->baseConsumer =
std::move(baseConsumer);
204 context->asyncExecutor =
std::move(asyncExecutor);
206 return [context](T value) {
207 std::lock_guard<
std::mutex> pendingValueLock(context->pendingValueMutex);
208 if (!context->pendingValue.has_value()) {
209 context->asyncExecutor(
211 QOhosOptional<T> pendingValue;
213 std::lock_guard<
std::mutex> pendingValueLock(context->pendingValueMutex);
214 std::swap(pendingValue, context->pendingValue);
216 context->baseConsumer(pendingValue.value());
219 context->pendingValue.emplace(
std::move(value));
241 auto parsedValue = qohosutils_details::tryParseStringAsUIntMax(inputString);
242 bool valueValidForType = parsedValue.has_value()
243 && parsedValue.value() <=
std::numeric_limits<T>::max();
244 return valueValidForType
245 ? makeQOhosOptional(
static_cast<T>(parsedValue.value()))
JsWindowRef(JsWindowRef &&)=delete
JsWindowRef(const JsWindowRef &)=delete
JsWindowRef & operator=(JsWindowRef &&)=delete
JsWindowRef(JsWindowId windowId, QNapi::Object jsWindow)
Result eval(const std::string &expr, const std::vector< QNapi::ValueWrapper > &exprArgs={}) const
bool isWindowShown() const
JsWindowRef & operator=(const JsWindowRef &)=delete
QNapi::Promise evalToPromiseOrRejectOnThrow(const std::string &expr, const std::vector< QNapi::ValueWrapper > &exprArgs={}) const
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 forceResolveQWindowDestroyPromiseIfPresent(Napi::Env env)=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
QOhosOptional< WindowProperties > tryGetWindowProperties(JsWindowId jsWindowId)
Combined button and popup list for selecting options.
@ WINDOW_MODE_SPLIT_PRIMARY
@ WINDOW_MODE_SPLIT_SECONDARY
@ NEW_PROCESS_ATTACH_TO_PARENT
@ NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM
@ ATTACH_TO_STATUS_BAR_ITEM
@ FLAG_AUTH_PERSISTABLE_URI_PERMISSION
@ FLAG_AUTH_READ_URI_PERMISSION
@ FLAG_ABILITY_ON_COLLABORATE
@ FLAG_START_WITHOUT_TIPS
@ FLAG_AUTH_WRITE_URI_PERMISSION
@ NET_CAPABILITY_VALIDATED
@ NET_CAPABILITY_INTERNET
@ NET_CAPABILITY_NOT_METERED
@ NET_CAPABILITY_CHECKING_CONNECTIVITY
@ NOTIFICATION_CONTENT_MULTILINE
@ NOTIFICATION_CONTENT_LONG_TEXT
@ NOTIFICATION_CONTENT_CONVERSATION
@ NOTIFICATION_CONTENT_SYSTEM_LIVE_VIEW
@ NOTIFICATION_CONTENT_PICTURE
@ NOTIFICATION_CONTENT_LIVE_VIEW
@ NOTIFICATION_CONTENT_BASIC_TEXT
@ TYPE_NAVIGATION_INDICATOR
@ ENTER_IMMERSIVE_DISABLE_TITLE_AND_DOCK_HOVER
@ FOLLOW_APP_IMMERSIVE_SETTING
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)
T evalInJsThreadWithPromise(std::function< void(QtOhos::JsState &, QOhosTaskPromise< T >)> evalFunc, std::string callerContextName={})
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 runInJsThreadAndWait(const std::function< void(JsState &)> &task, std::string callerContextName={})
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)
void tupleForEach(const std::tuple< TupleElements... > &tuple, UnaryFunc func, std::index_sequence< TupleIndices... >)
std::shared_ptr< QtOhos::QAbilityPeer > tryMapOptMainWindowToAbilityPeer(QtOhos::JsState &jsState, QOhosOptional< QtOhos::QObjectThreadSafeRef > optInstanceMainWindowRef)
void invokeInJsThreadAndWaitForContinue(std::function< void(JsState &, QOhosTaskPromise<>)> &&task, std::string callerContextName={})
auto evalInJsThread(Func &&func, std::string callerContextName={}) -> decltype(func(std::declval< JsState & >()))
void tupleForEach(const std::tuple< TupleElements... > &tuple, UnaryFunc func)
enums::ohos::app::ability::AbilityConstant::OnContinueResult QOhosAbilityOnContinueResult
QOhosOptional< double > tryParseStringAsFiniteDouble(const std::string &inputString)
void addJsQAbilityPeer(std::shared_ptr< QAbilityPeer > qAbilityPeer)
constexpr T makeCopyByValue(T value)
constexpr bool isStdOptional
constexpr bool hasEqualityComparator
QT_END_NAMESPACE Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::kit::ShareKit::systemShare::SelectionMode))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::inputMethod::TextInputType))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::kit::ShareKit::systemShare::ShareAbilityType))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::inputMethod::RequestKeyboardReason))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::window::AvoidAreaType))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::bundle::bundleManager::SupportWindowMode))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::multimodalInput::pointer::PointerStyle))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::app::ability::AbilityConstant::WindowMode))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::app::ability::contextConstant::ProcessMode))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::display::DisplaySourceMode))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::window::AnimationType))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::kit::ShareKit::systemShare::SharePreviewMode))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::file::picker::DocumentSelectMode))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::app::ability::contextConstant::StartupVisibility))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::app::ability::wantConstant::Flags))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::display::Orientation))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::window::RectChangeReason))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::window::ModalityType))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::inputMethod::Direction))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::window::WindowStatusType))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::app::ability::AbilityConstant::OnContinueResult))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::app::ability::ConfigurationConstant::ColorMode))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::window::WindowEventType))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::window::MaximizePresentation))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::inputMethod::EnterKeyType))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::app::ability::AbilityConstant::LaunchReason))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::app::ability::AbilityConstant::ContinueState))
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::ohos::notificationManager::ContentType))
std::optional< std::remove_cv_t< QOhosInvokeResult< Func, T > > > qTransform(const std::optional< T > &opt, Func &&func)
std::nullopt_t makeEmptyQOhosOptional()
std::optional< T > QOhosOptional
std::optional< T > makeQOhosOptional(const T &value)
QOhosOptional< QOhosDisplayInfo::JsDisplayId > displayId
bool isDisplayMainOrExtended() const
QSizeF physicalSize() const
QtOhos::enums::ohos::display::Orientation JsDisplayOrientation
QOhosOptional< QPoint > topLeftOffsetPixels
QRect displayGeometryPixels() const
static QOhosOptional< QNapi::Object > tryGetDisplayById(QtOhos::JsState &jsState, QOhosDisplayInfo::JsDisplayId displayId)
static QOhosDisplayInfo makeFromOhosDisplayObject(QtOhos::JsState &jsState, QNapi::Object displayObject)
QOhosOptional< JsDisplayOrientation > orientation
QtOhos::enums::ohos::display::DisplaySourceMode DisplaySourceMode
QOhosOptional< DisplaySourceMode > sourceMode
bool shouldIgnoreDisplay() const
EvaluateSequentially(Args &&...)
static constexpr const char * fullTypeName
static constexpr std::array< std::pair< Enum, const char * >, 3 > enumeratorsNames
enums::ohos::app::ability::contextConstant::ProcessMode Enum
enums::ohos::app::ability::contextConstant::StartupVisibility Enum
static constexpr const char * fullTypeName
static constexpr std::array< std::pair< Enum, const char * >, 2 > enumeratorsNames
static constexpr std::array< std::pair< Enum, const char * >, 15 > enumeratorsNames
static constexpr const char * fullTypeName
enums::ohos::inputMethod::TextInputType Enum
enums::ohos::notificationManager::ContentType Enum
static constexpr std::array< std::pair< Enum, const char * >, 7 > enumeratorsNames
static constexpr const char * fullTypeName