diff options
author | Michael Stahl <mstahl@redhat.com> | 2016-01-22 13:39:32 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-29 13:29:54 +0000 |
commit | 2241a7fd97b8b70d2d3106ac531cc72192ad708f (patch) | |
tree | 4cb96b50ab72165882952b6fa59710a630620a73 /include | |
parent | 2cbd9dffe76068c71c9de3f6525ce68d949085c3 (diff) |
libreofficekit: password interaction optional and off by default
Add setOptionalFeatures() function that clients must call during
initialization, and enum LibreOfficeKitOptionalFeatures.
Reviewed-on: https://gerrit.libreoffice.org/21809
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
(cherry picked from commit 23a0ee3c01c3588472e1c19605909d6b9401253c)
libreofficekit: ask for password when loading encrypted documents
(cherry picked from commit 2b63e576a5cf06f4af877d63403ad7955ac71b72)
desktop: use x prefix for uno::Reference
(cherry picked from commit 0101cd3da6262169fa273309a86ba5e7cfe573bf)
loplugin:defaultparams
(cherry picked from commit 95c8b8e85d3328bfbe906ef3f69145842aae01db)
Change-Id: I73035193c87033052921c3aad94fdc057fe81111
Reviewed-on: https://gerrit.libreoffice.org/21838
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.h | 9 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.hxx | 34 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKitEnums.h | 45 |
3 files changed, 87 insertions, 1 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 5189cca5eb5e..b31e5eef1c01 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -15,6 +15,7 @@ #ifdef LOK_USE_UNSTABLE_API // the unstable API needs C99's bool #include <stdbool.h> +#include <stdint.h> #endif #include <LibreOfficeKit/LibreOfficeKitTypes.h> @@ -62,6 +63,14 @@ struct _LibreOfficeKitClass /// @see lok::Office::getFilterTypes(). char* (*getFilterTypes) (LibreOfficeKit* pThis); + + /// @see lok::Office::setOptionalFeatures(). + void (*setOptionalFeatures)(LibreOfficeKit* pThis, uint64_t features); + + /// @see lok::Office::setDocumentPassword(). + void (*setDocumentPassword) (LibreOfficeKit* pThis, + char const* pURL, + char const* pPassword); #endif }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 5e86101f62af..bc52c5c026d1 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -442,6 +442,40 @@ public: { return mpThis->pClass->getFilterTypes(mpThis); } + + /** + * Set bitmask of optional features supported by the client. + * + * @see LibreOfficeKitOptionalFeatures + */ + void setOptionalFeatures(uint64_t features) + { + return mpThis->pClass->setOptionalFeatures(mpThis, features); + } + + /** + * Set password required for loading or editing a document. + * + * Loading the document is blocked until the password is provided. + * + * @param pURL the URL of the document, as sent to the callback + * @param pPassword the password, nullptr indicates no password + * + * In response to LOK_CALLBACK_DOCUMENT_PASSWORD, a vaild password + * will continue loading the document, an invalid password will + * result in another LOK_CALLBACK_DOCUMENT_PASSWORD request, + * and a NULL password will abort loading the document. + * + * In response to LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY, a vaild + * password will continue loading the document, an invalid password will + * result in another LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY request, + * and a NULL password will continue loading the document in read-only + * mode. + */ + inline void setDocumentPassword(char const* pURL, char const* pPassword) + { + mpThis->pClass->setDocumentPassword(mpThis, pURL, pPassword); + } #endif // LOK_USE_UNSTABLE_API }; diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index a0f5e886dcac..5931f7871e50 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -40,6 +40,32 @@ typedef enum } LibreOfficeKitTileMode; +/** Optional features of LibreOfficeKit, in particular callbacks that block + * LibreOfficeKit until the corresponding reply is received, which would + * deadlock if the client does not support the feature. + * + * @see lok::Office::setOptionalFeatures(). + */ +typedef enum +{ + /** + * Handle LOK_CALLBACK_DOCUMENT_PASSWORD by prompting the user + * for a password. + * + * @see lok::Office::setDocumentPassword(). + */ + LOK_FEATURE_DOCUMENT_PASSWORD = (1ULL << 0), + + /** + * Handle LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY by prompting the user + * for a password. + * + * @see lok::Office::setDocumentPassword(). + */ + LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY = (1ULL << 1), +} +LibreOfficeKitOptionalFeatures; + typedef enum { /** @@ -221,7 +247,24 @@ typedef enum /** * The text content of the formula bar in Calc. */ - LOK_CALLBACK_CELL_FORMULA + LOK_CALLBACK_CELL_FORMULA, + + /** + * Loading a document requires a password. + * + * Loading the document is blocked until the password is provided via + * lok::Office::setDocumentPassword(). The document cannot be loaded + * without the password. + */ + LOK_CALLBACK_DOCUMENT_PASSWORD, + + /** + * Editing a document requires a password. + * + * Loading the document is blocked until the password is provided via + * lok::Office::setDocumentPassword(). + */ + LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY, } LibreOfficeKitCallbackType; |