Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QtOhosAppKit::FileShare Namespace Reference

\inmodule QtOhosAppKit More...

Classes

class  PathPolicy
 \inmodule QtOhosAppKit More...
class  PathPolicyErrorInfo
 \variable QtOhosAppKit::FileShare::PathPolicy::path More...
class  PathPolicyCheckResult
 \variable QtOhosAppKit::FileShare::PathPolicyErrorInfo::path More...
class  ActionResult
 \inmodule QtOhosAppKit More...
class  CheckResult
 \inmodule QtOhosAppKit More...

Enumerations

enum class  OperationMode { Read = 1 << 0 , Write = 1 << 1 }
enum class  PathPolicyError {
  Unknown , PersistenceForbidden , InvalidMode , InvalidPath ,
  PermissionNotPersisted
}

Functions

std::shared_ptr< ActionResultpersistPermission (const QList< PathPolicy > &policies)
 Persists file or folder permissions from policies.
std::shared_ptr< ActionResultrevokePermission (const QList< PathPolicy > &policies)
 Revokes file or folder permissions from policies.
std::shared_ptr< ActionResultactivatePermission (const QList< PathPolicy > &policies)
 Activates file or folder permissions from policies.
std::shared_ptr< ActionResultdeactivatePermission (const QList< PathPolicy > &policies)
 Deactivates file or folder permissions from policies.
std::shared_ptr< CheckResultcheckPersistent (const QList< PathPolicy > &policies)
 Checks if file or folder permissions from policies have persistent permissions.

Detailed Description

\inmodule QtOhosAppKit

Since
5.12.12

The FileShare to expose file permission API.

This API uses file system paths, which differ from the URIs used internally by HarmonyOS. For example, the path /data/storage/el1/bundle/entry/resources/resfile/test.txt will be converted to the URI file://com.your.example/data/storage/el1/bundle/entry/resources/resfile/test.txt , where com.your.example is app bundle name.

To learn more about file paths and URIs in HarmonyOS, see \l{https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V5/app-sandbox-directory-V5} {sandbox documentation}.

Warning
This API relies on the underlying OHOS implementation. The following functions: persistPermission(), revokePermission(), activatePermission(), deactivatePermission(), and checkPersistent() may be unavailable on some devices. Additionally, there may be limitations on the maximum number of policies, and certain permissions may need to be explicitly granted to the application.

For more details and limitations, refer to the \l{https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V14/native-fileshare-guidelines-V14} {API documentation}.

Enumeration Type Documentation

◆ OperationMode

Enumerator
Read 
Write 

Definition at line 32 of file qohosfileshare_p.h.

◆ PathPolicyError

Enumerator
Unknown 
PersistenceForbidden 
InvalidMode 
InvalidPath 
PermissionNotPersisted 

Definition at line 41 of file qohosfileshare_p.h.

Function Documentation

◆ activatePermission()

std::shared_ptr< ActionResult > QtOhosAppKit::FileShare::activatePermission ( const QList< PathPolicy > & policies)

Activates file or folder permissions from policies.

The success of the action can be determined from ActionResult.

This function calls \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/file_share-V5#oh_fileshare_activatepermission} {OH_FileShare_ActivatePermission}. Each time an application is started, its persistent permissions have not been loaded to the memory. Use this function to make a persistent permission active after the application is started. If the activation fails because the permission has not been persisted, use persistPermission() first.

To deactivate an active permission, use deactivatePermission().

See also
ActionResult, PathPolicy, persistPermission(), deactivatePermission()

Definition at line 563 of file qohosfileshare.cpp.

◆ checkPersistent()

std::shared_ptr< CheckResult > QtOhosAppKit::FileShare::checkPersistent ( const QList< PathPolicy > & policies)

Checks if file or folder permissions from policies have persistent permissions.

The result check for each file or folder can be determined from CheckResult. CheckResult::PathPolicyCheckResult::result will be set to true for each file or folder only for succesufull check and persistent permission found, false otherwise.

This function calls \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/file_share-V5#oh_fileshare_checkpersistentpermission} {OH_FileShare_CheckPersistentPermission}.

To persist permission, use persistPermission().

See also
CheckResult, PathPolicy, persistPermission()

Definition at line 616 of file qohosfileshare.cpp.

◆ deactivatePermission()

std::shared_ptr< ActionResult > QtOhosAppKit::FileShare::deactivatePermission ( const QList< PathPolicy > & policies)

Deactivates file or folder permissions from policies.

The success of the action can be determined from ActionResult.

This function calls \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/file_share-V5#oh_fileshare_deactivatepermission} {OH_FileShare_DeactivatePermission}.

To activate permission, use activatePermission().

See also
ActionResult, PathPolicy, activatePermission()

Definition at line 589 of file qohosfileshare.cpp.

◆ persistPermission()

std::shared_ptr< ActionResult > QtOhosAppKit::FileShare::persistPermission ( const QList< PathPolicy > & policies)

Persists file or folder permissions from policies.

The success of the action can be determined from ActionResult.

This function calls \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/file_share-V5#oh_fileshare_persistpermission} {OH_FileShare_PersistPermission}. persistPermission() stores persistence data in the system database. After persistPermission() call, permissions are not yet active. Use activatePermission() to activate permissions. persistPermission() must be called at least once before activatePermission().

To revoke a persistent permission, use revokePermission().

See also
ActionResult, PathPolicy, revokePermission(), activatePermission()

Definition at line 509 of file qohosfileshare.cpp.

◆ revokePermission()

std::shared_ptr< ActionResult > QtOhosAppKit::FileShare::revokePermission ( const QList< PathPolicy > & policies)

Revokes file or folder permissions from policies.

The success of the action can be determined from ActionResult.

This function calls \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/file_share-V5#oh_fileshare_revokepermission} {OH_FileShare_RevokePermission}.

To persist permission, use persistPermission().

See also
ActionResult, PathPolicy, persistPermission()

Definition at line 535 of file qohosfileshare.cpp.