Jump to content

Qt for HarmonyOS/qtohosextras doc/QOhosOnContinueContext Class: Difference between revisions

From Qt Wiki
No edit summary
Drop manual breadcrumb, MediaWiki renders it automatically (QTFOROH-2307)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= QOhosOnContinueContext Class =


(QtOhosExtras::QOhosOnContinueContext)
class [[Qt_for_HarmonyOS/qtohosextras_doc/Qt_Ohos_Extras_C++_Classes|QtOhosExtras]]::QOhosOnContinueContext
 
The QOhosOnContinueContext class manages onContinue context. It provides system data, like source application version code and set the onContinue result that is requested by the system. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V13/js-apis-app-ability-uiability-V13#uiabilityoncontinue UIAbility onContinue]. [[#details|More...]]


The QOhosOnContinueContext class manages onContinue context. It provides system data, like source application version code and set the onContinue result that is requested by the system. See UIAbility onContinue. More...
{| class="wikitable"
{| class="wikitable"
|Header:
|#include <QOhosOnContinueContext>
|-
|-
|qmake:
| Header:
|QT += ohosextras
| #include <QOhosOnContinueContext>
|-
|-
|Since:
| qmake:
|Qt 5.12.12
| QT += ohosextras
|-
| Since:
| Qt 5.12.12
|}
|}


* List of all members, including inherited members
This class was introduced in Qt 5.12.12.
 
* [[Qt_for_HarmonyOS/qtohosextras_doc/List_of_All_Members_for_QOhosOnContinueContext|List of all members, including inherited members]]


== Public Functions ==
== Public Functions ==
{| class="wikitable"
{| class="wikitable"
|virtual
|'''~QOhosOnContinueContext'''()
|-
|-
|virtual void
| virtual void
|'''setAgreeResponse'''(const QByteArray &''responseData'') = 0
| '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosOnContinueContext_Class#setAgreeResponse|setAgreeResponse]]'''(const QByteArray &''responseData'') = 0
|-
| virtual void
| '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosOnContinueContext_Class#setExitAppOnSourceDeviceAfterMigration|setExitAppOnSourceDeviceAfterMigration]]'''(bool ''exitAfterMigration'') = 0
|-
| virtual void
| '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosOnContinueContext_Class#setMismatchResponse|setMismatchResponse]]'''() = 0
|-
|-
|virtual void
| virtual void
|'''setExitAppOnSourceDeviceAfterMigration'''(bool ''exitAfterMigration'') = 0
| '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosOnContinueContext_Class#setRejectResponse|setRejectResponse]]'''() = 0
|-
|-
|virtual void
| virtual void
|'''setMismatchResponse'''() = 0
| '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosOnContinueContext_Class#setResponseOnDistributedDataObjectsSaveResults|setResponseOnDistributedDataObjectsSaveResults]]'''(const QList<QSharedPointer<QOhosDistributedDataObject>> &''dataObjects'', QObject *''saveResultsHandlerContext'', std::function<void (QList<bool>)> ''saveResultsHandler'') = 0
|-
|-
|virtual void
| virtual int
|'''setRejectResponse'''() = 0
| '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosOnContinueContext_Class#sourceApplicationVersionCode|sourceApplicationVersionCode]]'''() const = 0
|-
|-
|virtual int
| virtual QString
|'''sourceApplicationVersionCode'''() const = 0
| '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosOnContinueContext_Class#targetDeviceId|targetDeviceId]]'''() const = 0
|}
|}


== Protected Functions ==
== Detailed Description ==
{| class="wikitable"
 
|
== Member Function Documentation ==
|'''QOhosOnContinueContext'''()
 
|}
=== <span id="setAgreeResponse"></span><code>[pure virtual] </code>void QOhosOnContinueContext::setAgreeResponse(const [https://doc.qt.io/qt-5/qbytearray.html QByteArray] &''responseData'') ===
 
Sets On Continue action as agreed with a given ''responseData''. Agreed response means that on continuation process is accepted. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V13/js-apis-app-ability-abilityconstant-V13#oncontinueresult OnContinueResult]
 
=== <span id="setExitAppOnSourceDeviceAfterMigration"></span><code>[pure virtual] </code>void QOhosOnContinueContext::setExitAppOnSourceDeviceAfterMigration(bool ''exitAfterMigration'') ===
 
Decides whether the application should automatically exit on the source device after successful migration to the target device, as per the ''exitAfterMigration'' parameter.
 
The default setting is determined by the platform. As of API17 it's set to "true" by default.
 
=== <span id="setMismatchResponse"></span><code>[pure virtual] </code>void QOhosOnContinueContext::setMismatchResponse() ===
 
Sets On Continue action as mismatched. Mismatched responses means that on continuation process should not be continued - most probably due to source and target application version code difference. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V13/js-apis-app-ability-abilityconstant-V13#oncontinueresult OnContinueResult]
 
'''See also '''[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosOnContinueContext_Class#sourceApplicationVersionCode|sourceApplicationVersionCode]]().
 
=== <span id="setRejectResponse"></span><code>[pure virtual] </code>void QOhosOnContinueContext::setRejectResponse() ===
 
Sets On Continue action as rejected. Rejected responses means that on continuation process should not be continued. This is typically used when the target application cannot handle the continuation request for any reason. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V13/js-apis-app-ability-abilityconstant-V13#oncontinueresult OnContinueResult]
 
=== <span id="setResponseOnDistributedDataObjectsSaveResults"></span><code>[pure virtual] </code>void QOhosOnContinueContext::setResponseOnDistributedDataObjectsSaveResults(const [https://doc.qt.io/qt-5/qlist.html QList]<[https://doc.qt.io/qt-5/qsharedpointer.html QSharedPointer]<[[Qt_for_HarmonyOS/qtohosextras_doc/QOhosDistributedDataObject_Class|QOhosDistributedDataObject]]>> &''dataObjects'', [https://doc.qt.io/qt-5/qobject.html QObject] *''saveResultsHandlerContext'', std::function<void ([https://doc.qt.io/qt-5/qlist.html QList]<bool>)> ''saveResultsHandler'') ===


== Detailed Description ==
Saves ''dataObjects'' to the target device as part of the onContinue response and defers delivery of the response until every save has settled. Any file assets attached to the objects are copied into the distributed files directory first, so they are migrated together with the objects. Each object is given a fresh session id, and the session id and field names of every object that was saved successfully are encoded into the response, so the target device can recreate those objects with [[Qt_for_HarmonyOS/qtohosextras_doc/QtOhosExtras_Namespace#tryRestoreOnContinueDistributedDataObjects|tryRestoreOnContinueDistributedDataObjects]]().
The QOhosOnContinueContext class manages onContinue context. It provides system data, like source application version code and set the onContinue result that is requested by the system. See UIAbility onContinue.


When all saves have finished, ''saveResultsHandler'', if set, is invoked with one boolean per object, in the same order as ''dataObjects'', telling whether that object was saved successfully. The handler is bound to ''saveResultsHandlerContext'': if that object is destroyed while the saves are still in flight, the handler is not invoked and the response is delivered without it.


== Member Function Documentation ==
A request that cannot be started rejects the continuation and leaves ''saveResultsHandler'' uninvoked. This happens when more than 16 objects are requested, or when the continuation has no target device id.


=== [protected] QOhosOnContinueContext::QOhosOnContinueContext() ===
Only one such request can be made per continuation. A further call is ignored together with its ''saveResultsHandler'', which is then never invoked.
Default constructs an instance of QOhosOnContinueContext.


=== [virtual] QOhosOnContinueContext::~QOhosOnContinueContext() ===
'''See also '''[[Qt_for_HarmonyOS/qtohosextras_doc/QtOhosExtras_Namespace#tryRestoreOnContinueDistributedDataObjects|tryRestoreOnContinueDistributedDataObjects]](), [[Qt_for_HarmonyOS/qtohosextras_doc/QOhosOnContinueContext_Class#setAgreeResponse|setAgreeResponse]](), and [[Qt_for_HarmonyOS/qtohosextras_doc/QOhosOnContinueContext_Class#setRejectResponse|setRejectResponse]]().
Destroys the instance of QOhosOnContinueContext. The destructor is virtual.


=== [pure virtual] void QOhosOnContinueContext::setAgreeResponse(const QByteArray &''responseData'') ===
=== <span id="sourceApplicationVersionCode"></span><code>[pure virtual] </code>int QOhosOnContinueContext::sourceApplicationVersionCode() const ===


=== [pure virtual] void QOhosOnContinueContext::setExitAppOnSourceDeviceAfterMigration(bool ''exitAfterMigration'') ===
Returns source application version code. Source application is the one which has started the continuation process. This version code is devlivered as "version" property in onContinue wantParam.


=== [pure virtual] void QOhosOnContinueContext::setMismatchResponse() ===
=== <span id="targetDeviceId"></span><code>[pure virtual] </code>[https://doc.qt.io/qt-5/qstring.html QString] QOhosOnContinueContext::targetDeviceId() const ===


=== [pure virtual]  void QOhosOnContinueContext::setRejectResponse() ===
Returns target device id. Target device is the one the continuation is migrating to. This device id is delivered as "targetDevice" property in onContinue wantParam.


=== [pure virtual] int QOhosOnContinueContext::sourceApplicationVersionCode() const ===
[[Category:Qt for HarmonyOS]]

Latest revision as of 06:17, 17 September 2026

QOhosOnContinueContext Class

class QtOhosExtras::QOhosOnContinueContext

The QOhosOnContinueContext class manages onContinue context. It provides system data, like source application version code and set the onContinue result that is requested by the system. See UIAbility onContinue. More...

Header: #include <QOhosOnContinueContext>
qmake: QT += ohosextras
Since: Qt 5.12.12

This class was introduced in Qt 5.12.12.

Public Functions

virtual void setAgreeResponse(const QByteArray &responseData) = 0
virtual void setExitAppOnSourceDeviceAfterMigration(bool exitAfterMigration) = 0
virtual void setMismatchResponse() = 0
virtual void setRejectResponse() = 0
virtual void setResponseOnDistributedDataObjectsSaveResults(const QList<QSharedPointer<QOhosDistributedDataObject>> &dataObjects, QObject *saveResultsHandlerContext, std::function<void (QList<bool>)> saveResultsHandler) = 0
virtual int sourceApplicationVersionCode() const = 0
virtual QString targetDeviceId() const = 0

Detailed Description

Member Function Documentation

[pure virtual] void QOhosOnContinueContext::setAgreeResponse(const QByteArray &responseData)

Sets On Continue action as agreed with a given responseData. Agreed response means that on continuation process is accepted. See OnContinueResult

[pure virtual] void QOhosOnContinueContext::setExitAppOnSourceDeviceAfterMigration(bool exitAfterMigration)

Decides whether the application should automatically exit on the source device after successful migration to the target device, as per the exitAfterMigration parameter.

The default setting is determined by the platform. As of API17 it's set to "true" by default.

[pure virtual] void QOhosOnContinueContext::setMismatchResponse()

Sets On Continue action as mismatched. Mismatched responses means that on continuation process should not be continued - most probably due to source and target application version code difference. See OnContinueResult

See also sourceApplicationVersionCode().

[pure virtual] void QOhosOnContinueContext::setRejectResponse()

Sets On Continue action as rejected. Rejected responses means that on continuation process should not be continued. This is typically used when the target application cannot handle the continuation request for any reason. See OnContinueResult

[pure virtual] void QOhosOnContinueContext::setResponseOnDistributedDataObjectsSaveResults(const QList<QSharedPointer<QOhosDistributedDataObject>> &dataObjects, QObject *saveResultsHandlerContext, std::function<void (QList<bool>)> saveResultsHandler)

Saves dataObjects to the target device as part of the onContinue response and defers delivery of the response until every save has settled. Any file assets attached to the objects are copied into the distributed files directory first, so they are migrated together with the objects. Each object is given a fresh session id, and the session id and field names of every object that was saved successfully are encoded into the response, so the target device can recreate those objects with tryRestoreOnContinueDistributedDataObjects().

When all saves have finished, saveResultsHandler, if set, is invoked with one boolean per object, in the same order as dataObjects, telling whether that object was saved successfully. The handler is bound to saveResultsHandlerContext: if that object is destroyed while the saves are still in flight, the handler is not invoked and the response is delivered without it.

A request that cannot be started rejects the continuation and leaves saveResultsHandler uninvoked. This happens when more than 16 objects are requested, or when the continuation has no target device id.

Only one such request can be made per continuation. A further call is ignored together with its saveResultsHandler, which is then never invoked.

See also tryRestoreOnContinueDistributedDataObjects(), setAgreeResponse(), and setRejectResponse().

[pure virtual] int QOhosOnContinueContext::sourceApplicationVersionCode() const

Returns source application version code. Source application is the one which has started the continuation process. This version code is devlivered as "version" property in onContinue wantParam.

[pure virtual] QString QOhosOnContinueContext::targetDeviceId() const

Returns target device id. Target device is the one the continuation is migrating to. This device id is delivered as "targetDevice" property in onContinue wantParam.